(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.RTK = {})); }(this, (function (exports) { 'use strict'; var t,e,n,r=undefined&&undefined.__extends||(t=function(e,n){return (t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e;}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r);}),o=undefined&&undefined.__generator||function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:f(0),throw:f(1),return:f(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function f(i){return function(f){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]1?e-1:0),r=1;r3?e.i-4:e.i:Array.isArray(t)?1:E(t)?2:A(t)?3:0}function w(t,e){return 2===m(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function j(t,e,n){var r=m(t);2===r?t.set(e,n):3===r?(t.delete(e),t.add(n)):t[e]=n;}function P(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function E(t){return H&&t instanceof Map}function A(t){return Q&&t instanceof Set}function S(t){return t.o||t.t}function _(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var e=ot(t);delete e[et];for(var n=rt(e),r=0;r1&&(t.set=t.add=t.clear=t.delete=I),Object.freeze(t),e&&O(t,(function(t,e){return x(e,!0)}),!0)),t}function I(){y(2);}function D(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function k(t){var e=it[t];return e||y(18,t),e}function N(){return n}function R(t,e){e&&(k("Patches"),t.u=[],t.s=[],t.v=e);}function M(t){C(t),t.p.forEach(F),t.p=null;}function C(t){t===n&&(n=t.l);}function T(t){return n={p:[],l:n,h:t,m:!0,_:0}}function F(t){var e=t[et];0===e.i||1===e.i?e.j():e.g=!0;}function q(t,e){e._=e.p.length;var n=e.p[0],r=void 0!==t&&t!==n;return e.h.O||k("ES5").S(e,t,r),r?(n[et].P&&(M(e),y(4)),g(t)&&(t=W(e,t),e.l||K(e,t)),e.u&&k("Patches").M(n[et],t,e.u,e.s)):t=W(e,n,[]),M(e),e.u&&e.v(e.u,e.s),t!==Z?t:void 0}function W(t,e,n){if(D(e))return e;var r=e[et];if(!r)return O(e,(function(o,i){return z(t,r,e,o,i,n)}),!0),e;if(r.A!==t)return e;if(!r.P)return K(t,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var o=4===r.i||5===r.i?r.o=_(r.k):r.o;O(3===r.i?new Set(o):o,(function(e,i){return z(t,r,o,e,i,n)})),K(t,o,!1),n&&t.u&&k("Patches").R(r,n,t.u,t.s);}return r.o}function z(t,e,n,r,o,i){if(h(o)){var u=W(t,o,i&&e&&3!==e.i&&!w(e.D,r)?i.concat(r):void 0);if(j(n,r,u),!h(u))return;t.m=!1;}if(g(o)&&!D(o)){if(!t.h.F&&t._<1)return;W(t,o),e&&e.A.l||K(t,o);}}function K(t,e,n){void 0===n&&(n=!1),t.h.F&&t.m&&x(e,n);}function U(t,e){var n=t[et];return (n?S(n):t)[e]}function L(t,e){if(e in t)for(var n=Object.getPrototypeOf(t);n;){var r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Object.getPrototypeOf(n);}}function V(t){t.P||(t.P=!0,t.l&&V(t.l));}function X(t){t.o||(t.o=_(t.t));}function B(t,e,n){var r=E(e)?k("MapSet").N(e,n):A(e)?k("MapSet").T(e,n):t.O?function(t,e){var n=Array.isArray(t),r={i:n?1:0,A:e?e.A:N(),P:!1,I:!1,D:{},l:e,t:t,k:null,o:null,j:null,C:!1},o=r,i=ut;n&&(o=[r],i=ft);var u=Proxy.revocable(o,i),f=u.revoke,c=u.proxy;return r.k=c,r.j=f,c}(e,n):k("ES5").J(e,n);return (n?n.A:N()).p.push(r),r}function G(t){return h(t)||y(22,t),function t(e){if(!g(e))return e;var n,r=e[et],o=m(e);if(r){if(!r.P&&(r.i<4||!k("ES5").K(r)))return r.t;r.I=!0,n=J(e,o),r.I=!1;}else n=J(e,o);return O(n,(function(e,o){r&&function(t,e){return 2===m(t)?t.get(e):t[e]}(r.t,e)===o||j(n,e,t(o));})),3===o?new Set(n):n}(t)}function J(t,e){switch(e){case 2:return new Map(t);case 3:return Array.from(t)}return _(t)}var $="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),H="undefined"!=typeof Map,Q="undefined"!=typeof Set,Y="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,Z=$?Symbol.for("immer-nothing"):((e={})["immer-nothing"]=!0,e),tt=$?Symbol.for("immer-draftable"):"__$immer_draftable",et=$?Symbol.for("immer-state"):"__$immer_state",nt=(""+Object.prototype.constructor),rt="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,ot=Object.getOwnPropertyDescriptors||function(t){var e={};return rt(t).forEach((function(n){e[n]=Object.getOwnPropertyDescriptor(t,n);})),e},it={},ut={get:function(t,e){if(e===et)return t;var n,r,o,i=S(t);if(!w(i,e))return n=t,(o=L(i,e))?"value"in o?o.value:null===(r=o.get)||void 0===r?void 0:r.call(n.k):void 0;var u=i[e];return t.I||!g(u)?u:u===U(t.t,e)?(X(t),t.o[e]=B(t.A.h,u,t)):u},has:function(t,e){return e in S(t)},ownKeys:function(t){return Reflect.ownKeys(S(t))},set:function(t,e,n){var r=L(S(t),e);if(null==r?void 0:r.set)return r.set.call(t.k,n),!0;if(!t.P){var o=U(S(t),e),i=null==o?void 0:o[et];if(i&&i.t===n)return t.o[e]=n,t.D[e]=!1,!0;if(P(n,o)&&(void 0!==n||w(t.t,e)))return !0;X(t),V(t);}return t.o[e]===n&&"number"!=typeof n||(t.o[e]=n,t.D[e]=!0,!0)},deleteProperty:function(t,e){return void 0!==U(t.t,e)||e in t.t?(t.D[e]=!1,X(t),V(t)):delete t.D[e],t.o&&delete t.o[e],!0},getOwnPropertyDescriptor:function(t,e){var n=S(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r?{writable:!0,configurable:1!==t.i||"length"!==e,enumerable:r.enumerable,value:n[e]}:r},defineProperty:function(){y(11);},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){y(12);}},ft={};O(ut,(function(t,e){ft[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)};})),ft.deleteProperty=function(t,e){return ut.deleteProperty.call(this,t[0],e)},ft.set=function(t,e,n){return ut.set.call(this,t[0],e,n,t[0])};var ct=new(function(){function t(t){var e=this;this.O=Y,this.F=!0,this.produce=function(t,n,r){if("function"==typeof t&&"function"!=typeof n){var o=n;n=t;var i=e;return function(t){var e=this;void 0===t&&(t=o);for(var r=arguments.length,u=Array(r>1?r-1:0),f=1;f1?r-1:0),i=1;i=0;n--){var r=e[n];if(0===r.path.length&&"replace"===r.op){t=r.value;break}}var o=k("Patches").$;return h(t)?o(t,e):this.produce(t,(function(t){return o(t,e.slice(n+1))}))},t}()),at=ct.produce,lt=(ct.produceWithPatches.bind(ct),ct.setAutoFreeze.bind(ct),ct.setUseProxies.bind(ct),ct.applyPatches.bind(ct),ct.createDraft.bind(ct),ct.finishDraft.bind(ct),at);function st(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r);}return n}function dt(t){for(var e=1;e1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:At,n=null,r=null;return function(){return St(e,n,arguments)||(r=t.apply(null,arguments)),n=arguments,r}})),It=function(){for(var t=[],e=0;e",value:t};if("object"!=typeof t||null===t)return !1;for(var u=null!=r?r(t):Object.entries(t),f=o.length>0,c=0,a=u;c=0)){if(!n(p))return {keyPath:d,value:p};if("object"==typeof p&&(i=Ft(p,d,n,r,o)))return i}}return !1}function qt(t){return function(){return function(t){return function(e){return t(e)}}}}function Wt(t){void 0===t&&(t={});var e=t.thunk,n=void 0===e||e,r=new Ct;return n&&r.push("boolean"==typeof n?Mt:Mt.withExtraArgument(n.extraArgument)),r}function zt(t){var e,n=function(t){return Wt(t)},r=t||{},o=r.reducer,u=void 0===o?void 0:o,f=r.middleware,c=void 0===f?n():f,a=r.devTools,l=void 0===a||a,s=r.preloadedState,p=void 0===s?void 0:s,v=r.enhancers,y=void 0===v?void 0:v;if("function"==typeof u)e=u;else {if(!kt(u))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');e=mt(u);}var h=c;"function"==typeof h&&(h=h(n));var g=Et.apply(void 0,h),b=Pt;l&&(b=Dt(d({trace:!1},"object"==typeof l&&l)));var O=[g];return Array.isArray(y)?O=i([g],y):"function"==typeof y&&(O=y(O)),Ot(e,p,b.apply(void 0,O))}function Kt(t,e){function n(){for(var n=[],r=0;r-1}function Lt(t){return ""+t}function Vt(t){var e,n={},r=[],o={addCase:function(t,e){var r="string"==typeof t?t:t.type;if(r in n)throw new Error("addCase cannot be called with two reducers for the same action type");return n[r]=e,o},addMatcher:function(t,e){return r.push({matcher:t,reducer:e}),o},addDefaultCase:function(t){return e=t,o}};return t(o),[n,r,e]}function Xt(t,e,n,r){void 0===n&&(n=[]);var o="function"==typeof e?Vt(e):[e,n,r],u=o[0],f=o[1],c=o[2],a=lt(t,(function(){}));return function(t,e){void 0===t&&(t=a);var n=i([u[e.type]],f.filter((function(t){return (0, t.matcher)(e)})).map((function(t){return t.reducer})));return 0===n.filter((function(t){return !!t})).length&&(n=[c]),n.reduce((function(t,n){if(n){var r;if(h(t))return void 0===(r=n(t,e))?t:r;if(g(t))return lt(t,(function(t){return n(t,e)}));if(void 0===(r=n(t,e))){if(null===t)return t;throw Error("A case reducer on a non-draftable value must not return undefined")}return r}return t}),t)}}function Bt(t){var e=t.name,n=t.initialState;if(!e)throw new Error("`name` is a required option for createSlice");var r=t.reducers||{},o="function"==typeof t.extraReducers?Vt(t.extraReducers):[t.extraReducers],i=o[0],u=void 0===i?{}:i,f=o[1],c=void 0===f?[]:f,a=o[2],l=void 0===a?void 0:a,s=Object.keys(r),p={},v={},y={};s.forEach((function(t){var n,o,i=r[t],u=e+"/"+t;"reducer"in i?(n=i.reducer,o=i.prepare):n=i,p[t]=n,v[u]=n,y[t]=o?Kt(u,o):Kt(u);}));var h=Xt(n,d(d({},u),v),c,l);return {name:e,reducer:h,actions:y,caseReducers:p}}function Gt(t){return "object"!=typeof t||null==t||Object.isFrozen(t)}function Jt(t){return function(){return function(t){return function(e){return t(e)}}}}function $t(t){return function(e,n){var r=function(e){var r;kt(r=n)&&"string"==typeof r.type&&Object.keys(r).every(Ut)?t(n.payload,e):t(n,e);};return h(e)?(r(e),e):lt(e,r)}}function Ht(t,e){return e(t)}function Qt(t){return Array.isArray(t)||(t=Object.values(t)),t}function Yt(t,e,n){for(var r=[],o=[],i=0,u=t=Qt(t);i0&&e.filter((function(e){return function(e,n,r){var o=Object.assign({},r.entities[n.id],n.changes),i=Ht(o,t),u=i!==n.id;return u&&(e[n.id]=i,delete r.entities[n.id]),r.entities[i]=o,u}(r,e,n)})).length>0&&(n.ids=n.ids.map((function(t){return r[t]||t})));}function u(e,r){var o=Yt(e,t,r),u=o[0];i(o[1],r),n(u,r);}return {removeAll:(f=function(t){Object.assign(t,{ids:[],entities:{}});},c=$t((function(t,e){return f(e)})),function(t){return c(t,void 0)}),addOne:$t(e),addMany:$t(n),setOne:$t(r),setMany:$t((function(t,e){for(var n=0,o=t=Qt(t);n-1;return n&&r}function pe(t){return "function"==typeof t[0]&&"pending"in t[0]&&"fulfilled"in t[0]&&"rejected"in t[0]}function de(){for(var t=[],e=0;e=0;e--){var o=t[e][et];if(!o.P)switch(o.i){case 5:r(o)&&V(o);break;case 4:n(o)&&V(o);}}}function n(t){for(var e=t.t,n=t.k,r=rt(n),o=r.length-1;o>=0;o--){var i=r[o];if(i!==et){var u=e[i];if(void 0===u&&!w(e,i))return !0;var f=n[i],c=f&&f[et];if(c?c.t!==u:!P(f,u))return !0}}var a=!!e[et];return r.length!==rt(e).length+(a?0:1)}function r(t){var e=t.k;if(e.length!==t.t.length)return !0;var n=Object.getOwnPropertyDescriptor(e,e.length-1);return !(!n||n.get)}var o={};it.ES5||(it.ES5={J:function(e,n){var r=Array.isArray(e),o=function(e,n){if(e){for(var r=Array(n.length),o=0;o