Socket
Socket
Sign inDemoInstall

@reduxjs/toolkit

Package Overview
Dependencies
Maintainers
5
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reduxjs/toolkit - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

src/createDraftSafeSelector.test.ts

307

dist/redux-toolkit.cjs.development.js

@@ -11,2 +11,24 @@ 'use strict';

/**
* "Draft-Safe" version of `reselect`'s `createSelector`:
* If an `immer`-drafted object is passed into the resulting selector's first argument,
* the selector will act on the current draft value, instead of returning a cached value
* that might be possibly outdated if the draft has been modified since.
* @public
*/
var createDraftSafeSelector = function createDraftSafeSelector() {
var selector = reselect.createSelector.apply(void 0, arguments);
var wrappedSelector = function wrappedSelector(value) {
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
return selector.apply(void 0, [createNextState.isDraft(value) ? createNextState.current(value) : value].concat(rest));
};
return wrappedSelector;
};
function _extends() {

@@ -137,2 +159,4 @@ _extends = Object.assign || function (target) {

* @returns {boolean} True if the argument appears to be a plain object.
*
* @public
*/

@@ -851,2 +875,6 @@ function isPlainObject(value) {

if (typeof _result === 'undefined') {
if (previousState === null) {
return previousState;
}
throw Error('A case reducer on a non-draftable value must not return undefined');

@@ -967,3 +995,3 @@ }

var selectAll = reselect.createSelector(selectIds, selectEntities, function (ids, entities) {
var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) {
return ids.map(function (id) {

@@ -982,3 +1010,3 @@ return entities[id];

var selectTotal = reselect.createSelector(selectIds, function (ids) {
var selectTotal = createDraftSafeSelector(selectIds, function (ids) {
return ids.length;

@@ -993,13 +1021,13 @@ });

selectTotal: selectTotal,
selectById: reselect.createSelector(selectEntities, selectId, selectById)
selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
};
}
var selectGlobalizedEntities = reselect.createSelector(selectState, selectEntities);
var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
return {
selectIds: reselect.createSelector(selectState, selectIds),
selectIds: createDraftSafeSelector(selectState, selectIds),
selectEntities: selectGlobalizedEntities,
selectAll: reselect.createSelector(selectState, selectAll),
selectTotal: reselect.createSelector(selectState, selectTotal),
selectById: reselect.createSelector(selectGlobalizedEntities, selectId, selectById)
selectAll: createDraftSafeSelector(selectState, selectAll),
selectTotal: createDraftSafeSelector(selectState, selectTotal),
selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
};

@@ -1463,4 +1491,6 @@ }

var RejectWithValue = function RejectWithValue(value) {
this.value = value;
var RejectWithValue = function RejectWithValue(payload) {
this.payload = payload;
this.name = 'RejectWithValue';
this.message = 'Rejected';
}; // Reworked from https://github.com/sindresorhus/serialize-error

@@ -1514,3 +1544,4 @@

arg: arg,
requestId: requestId
requestId: requestId,
requestStatus: 'fulfilled'
}

@@ -1524,15 +1555,19 @@ };

arg: arg,
requestId: requestId
requestId: requestId,
requestStatus: 'pending'
}
};
});
var rejected = createAction(typePrefix + '/rejected', function (error, requestId, arg, payload) {
var rejected = createAction(typePrefix + '/rejected', function (error, requestId, arg) {
var rejectedWithValue = error instanceof RejectWithValue;
var aborted = !!error && error.name === 'AbortError';
var condition = !!error && error.name === 'ConditionError';
return {
payload: payload,
error: miniSerializeError(error || 'Rejected'),
payload: error instanceof RejectWithValue ? error.payload : undefined,
error: (options && options.serializeError || miniSerializeError)(error || 'Rejected'),
meta: {
arg: arg,
requestId: requestId,
rejectedWithValue: rejectedWithValue,
requestStatus: 'rejected',
aborted: aborted,

@@ -1640,3 +1675,3 @@ condition: condition

if (result instanceof RejectWithValue) {
return rejected(null, requestId, arg, result.value);
return rejected(result, requestId, arg);
}

@@ -1659,3 +1694,5 @@

return Object.assign(promise, {
abort: abort
abort: abort,
requestId: requestId,
arg: arg
});

@@ -1676,10 +1713,223 @@ };

function unwrapResult(returned) {
if ('error' in returned) {
throw returned.error;
function unwrapResult(action) {
if (action.meta && action.meta.rejectedWithValue) {
throw action.payload;
}
return returned.payload;
if (action.error) {
throw action.error;
}
return action.payload;
}
var hasMatchFunction = function hasMatchFunction(v) {
return v && typeof v.match === 'function';
};
var matches = function matches(matcher, action) {
if (hasMatchFunction(matcher)) {
return matcher.match(action);
} else {
return matcher(action);
}
};
/**
* A higher-order function that returns a function that may be used to check
* whether an action matches any one of the supplied type guards or action
* creators.
*
* @param matchers The type guards or action creators to match against.
*
* @public
*/
function isAnyOf() {
for (var _len = arguments.length, matchers = new Array(_len), _key = 0; _key < _len; _key++) {
matchers[_key] = arguments[_key];
}
return function (action) {
return matchers.some(function (matcher) {
return matches(matcher, action);
});
};
}
/**
* A higher-order function that returns a function that may be used to check
* whether an action matches all of the supplied type guards or action
* creators.
*
* @param matchers The type guards or action creators to match against.
*
* @public
*/
function isAllOf() {
for (var _len2 = arguments.length, matchers = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
matchers[_key2] = arguments[_key2];
}
return function (action) {
return matchers.every(function (matcher) {
return matches(matcher, action);
});
};
}
/**
* @param action A redux action
* @param validStatus An array of valid meta.requestStatus values
*
* @internal
*/
function hasExpectedRequestMetadata(action, validStatus) {
if (!action || !action.meta) return false;
var hasValidRequestId = typeof action.meta.requestId === 'string';
var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
return hasValidRequestId && hasValidRequestStatus;
}
function isAsyncThunkArray(a) {
return typeof a[0] === 'function' && 'pending' in a[0] && 'fulfilled' in a[0] && 'rejected' in a[0];
}
function isPending() {
for (var _len3 = arguments.length, asyncThunks = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
asyncThunks[_key3] = arguments[_key3];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['pending']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isPending()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = asyncThunks.map(function (asyncThunk) {
return asyncThunk.pending;
});
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
function isRejected() {
for (var _len4 = arguments.length, asyncThunks = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
asyncThunks[_key4] = arguments[_key4];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['rejected']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isRejected()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = asyncThunks.map(function (asyncThunk) {
return asyncThunk.rejected;
});
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
function isRejectedWithValue() {
for (var _len5 = arguments.length, asyncThunks = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
asyncThunks[_key5] = arguments[_key5];
}
var hasFlag = function hasFlag(action) {
return action && action.meta && action.meta.rejectedWithValue;
};
if (asyncThunks.length === 0) {
return function (action) {
var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
return combinedMatcher(action);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isRejectedWithValue()(asyncThunks[0]);
}
return function (action) {
var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
return combinedMatcher(action);
};
}
function isFulfilled() {
for (var _len6 = arguments.length, asyncThunks = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
asyncThunks[_key6] = arguments[_key6];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['fulfilled']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isFulfilled()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = asyncThunks.map(function (asyncThunk) {
return asyncThunk.fulfilled;
});
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
function isAsyncThunkAction() {
for (var _len7 = arguments.length, asyncThunks = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
asyncThunks[_key7] = arguments[_key7];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['pending', 'fulfilled', 'rejected']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isAsyncThunkAction()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = [];
for (var _iterator = asyncThunks, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var asyncThunk = _ref;
matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
}
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
// we assume RTK will be used with React Native and other Proxy-less

@@ -1706,2 +1956,8 @@ // environments. In addition, that's how Immer 4 behaved, and since

});
Object.defineProperty(exports, 'freeze', {
enumerable: true,
get: function () {
return createNextState.freeze;
}
});
Object.defineProperty(exports, 'createSelector', {

@@ -1717,2 +1973,3 @@ enumerable: true,

exports.createAsyncThunk = createAsyncThunk;
exports.createDraftSafeSelector = createDraftSafeSelector;
exports.createEntityAdapter = createEntityAdapter;

@@ -1726,6 +1983,14 @@ exports.createImmutableStateInvariantMiddleware = createImmutableStateInvariantMiddleware;

exports.getType = getType;
exports.isAllOf = isAllOf;
exports.isAnyOf = isAnyOf;
exports.isAsyncThunkAction = isAsyncThunkAction;
exports.isFulfilled = isFulfilled;
exports.isImmutableDefault = isImmutableDefault;
exports.isPending = isPending;
exports.isPlain = isPlain;
exports.isPlainObject = isPlainObject;
exports.isRejected = isRejected;
exports.isRejectedWithValue = isRejectedWithValue;
exports.nanoid = nanoid;
exports.unwrapResult = unwrapResult;
//# sourceMappingURL=redux-toolkit.cjs.development.js.map

2

dist/redux-toolkit.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("immer"),r=e(t),n=require("redux"),o=require("reselect"),i=e(require("redux-thunk"));function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function s(e,t,r){return(s=f()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&c(o,r.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return s(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),c(r,e)})(e)}var d="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?n.compose:n.compose.apply(null,arguments)};function p(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var y=function(e){var t,r;function n(){return e.apply(this,arguments)||this}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var o=n.prototype;return o.concat=function(){for(var t,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return s(n,(t=e.prototype.concat).call.apply(t,[this].concat(o)))},o.prepend=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])?s(n,t[0].concat(this)):s(n,t.concat(this))},n}(l(Array));function v(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||p(e)}function b(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=new y;return r&&n.push("boolean"==typeof r?i:i.withExtraArgument(r.extraArgument)),n}function h(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw new Error("prepareAction did not return an object");return a({type:e,payload:r.payload},"meta"in r&&{meta:r.meta},{},"error"in r&&{error:r.error})}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return r.toString=function(){return""+e},r.type=e,r.match=function(t){return t.type===e},r}function m(e){return["type","payload","error","meta"].indexOf(e)>-1}function g(e){var t,r={},n=[],o={addCase:function(e,t){var n="string"==typeof e?e:e.type;if(n in r)throw new Error("addCase cannot be called with two reducers for the same action type");return r[n]=t,o},addMatcher:function(e,t){return n.push({matcher:e,reducer:t}),o},addDefaultCase:function(e){return t=e,o}};return e(o),[r,n,t]}function O(e,n,o,i){void 0===o&&(o=[]);var a="function"==typeof n?g(n):[n,o,i],u=a[0],c=a[1],f=a[2];return function(n,o){void 0===n&&(n=e);var i=[u[o.type]].concat(c.filter((function(e){return(0,e.matcher)(o)})).map((function(e){return e.reducer})));return 0===i.filter((function(e){return!!e})).length&&(i=[f]),i.reduce((function(e,n){if(n){if(t.isDraft(e)){var i=n(e,o);return void 0===i?e:i}if(t.isDraftable(e))return r(e,(function(e){return n(e,o)}));var a=n(e,o);if(void 0===a)throw Error("A case reducer on a non-draftable value must not return undefined");return a}return e}),n)}}function A(e){return function(n,o){var i=function(t){!function(e){return p(t=e)&&"string"==typeof t.type&&Object.keys(t).every(m);var t}(o)?e(o,t):e(o.payload,t)};return t.isDraft(n)?(i(n),n):r(n,i)}}function S(e,t){return t(e)}function j(e){function t(t,r){var n=S(t,e);n in r.entities||(r.ids.push(n),r.entities[n]=t)}function r(e,r){Array.isArray(e)||(e=Object.values(e));var n=e,o=Array.isArray(n),i=0;for(n=o?n:n[Symbol.iterator]();;){var a;if(o){if(i>=n.length)break;a=n[i++]}else{if((i=n.next()).done)break;a=i.value}t(a,r)}}function n(e,t){var r=!1;e.forEach((function(e){e in t.entities&&(delete t.entities[e],r=!0)})),r&&(t.ids=t.ids.filter((function(e){return e in t.entities})))}function o(t,r){var n={},o={};t.forEach((function(e){e.id in r.entities&&(o[e.id]={id:e.id,changes:a({},o[e.id]?o[e.id].changes:null,{},e.changes)})})),(t=Object.values(o)).length>0&&t.filter((function(t){return function(t,r,n){var o=Object.assign({},n.entities[r.id],r.changes),i=S(o,e),a=i!==r.id;return a&&(t[r.id]=i,delete n.entities[r.id]),n.entities[i]=o,a}(n,t,r)})).length>0&&(r.ids=r.ids.map((function(e){return n[e]||e})))}function i(t,n){Array.isArray(t)||(t=Object.values(t));var i=[],a=[],u=t,c=Array.isArray(u),f=0;for(u=c?u:u[Symbol.iterator]();;){var s;if(c){if(f>=u.length)break;s=u[f++]}else{if((f=u.next()).done)break;s=f.value}var l=s,d=S(l,e);d in n.entities?a.push({id:d,changes:l}):i.push(l)}o(a,n),r(i,n)}return{removeAll:(u=function(e){Object.assign(e,{ids:[],entities:{}})},c=A((function(e,t){return u(t)})),function(e){return c(e,void 0)}),addOne:A(t),addMany:A(r),setAll:A((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.ids=[],t.entities={},r(e,t)})),updateOne:A((function(e,t){return o([e],t)})),updateMany:A(o),upsertOne:A((function(e,t){return i([e],t)})),upsertMany:A(i),removeOne:A((function(e,t){return n([e],t)})),removeMany:A(n)};var u,c}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var x=function(e){void 0===e&&(e=21);for(var t="",r=e;r--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t},w=["name","message","stack","code"],E=function(e){this.value=e},_=function(e){if("object"==typeof e&&null!==e){var t={},r=w,n=Array.isArray(r),o=0;for(r=n?r:r[Symbol.iterator]();;){var i;if(n){if(o>=r.length)break;i=r[o++]}else{if((o=r.next()).done)break;i=o.value}"string"==typeof e[i]&&(t[i]=e[i])}return t}return{message:String(e)}};t.enableES5(),Object.keys(n).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),exports.createNextState=r,Object.defineProperty(exports,"current",{enumerable:!0,get:function(){return t.current}}),Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return o.createSelector}}),exports.MiddlewareArray=y,exports.configureStore=function(e){var t,r=function(e){return b(e)},o=e||{},i=o.reducer,u=void 0===i?void 0:i,c=o.middleware,f=void 0===c?r():c,s=o.devTools,l=void 0===s||s,y=o.preloadedState,v=void 0===y?void 0:y,h=o.enhancers,m=void 0===h?void 0:h;if("function"==typeof u)t=u;else{if(!p(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');t=n.combineReducers(u)}var g=n.applyMiddleware.apply(void 0,"function"==typeof f?f(r):f),O=n.compose;l&&(O=d(a({trace:!1},"object"==typeof l&&l)));var A=[g];Array.isArray(m)?A=[g].concat(m):"function"==typeof m&&(A=m(A));var S=O.apply(void 0,A);return n.createStore(t,v,S)},exports.createAction=h,exports.createAsyncThunk=function(e,t,r){var n=h(e+"/fulfilled",(function(e,t,r){return{payload:e,meta:{arg:r,requestId:t}}})),o=h(e+"/pending",(function(e,t){return{payload:void 0,meta:{arg:t,requestId:e}}})),i=h(e+"/rejected",(function(e,t,r,n){var o=!!e&&"AbortError"===e.name,i=!!e&&"ConditionError"===e.name;return{payload:n,error:_(e||"Rejected"),meta:{arg:r,requestId:t,aborted:o,condition:i}}})),a="undefined"!=typeof AbortController?AbortController:function(){function e(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){}}}return e.prototype.abort=function(){},e}();return Object.assign((function(e){return function(u,c,f){var s,l=x(),d=new a,p=new Promise((function(e,t){return d.signal.addEventListener("abort",(function(){return t({name:"AbortError",message:s||"Aborted"})}))})),y=!1,v=function(){try{var a,s=function(e){return v?e:(r&&!r.dispatchConditionRejection&&i.match(a)&&a.meta.condition||u(a),a)},v=!1,b=function(s,v){try{var b=function(){if(r&&r.condition&&!1===r.condition(e,{getState:c,extra:f}))throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return y=!0,u(o(l,e)),Promise.resolve(Promise.race([p,Promise.resolve(t(e,{dispatch:u,getState:c,extra:f,requestId:l,signal:d.signal,rejectWithValue:function(e){return new E(e)}})).then((function(t){return t instanceof E?i(null,l,e,t.value):n(t,l,e)}))])).then((function(e){a=e}))}()}catch(e){return v(e)}return b&&b.then?b.then(void 0,v):b}(0,(function(t){a=i(t,l,e)}));return Promise.resolve(b&&b.then?b.then(s):s(b))}catch(e){return Promise.reject(e)}}();return Object.assign(v,{abort:function(e){y&&(s=e,d.abort())}})}}),{pending:o,rejected:i,fulfilled:n,typePrefix:e})},exports.createEntityAdapter=function(e){void 0===e&&(e={});var t=a({sortComparer:!1,selectId:function(e){return e.id}},e),r=t.selectId,n=t.sortComparer;return a({selectId:r,sortComparer:n},{getInitialState:function(e){return void 0===e&&(e={}),Object.assign({ids:[],entities:{}},e)}},{},{getSelectors:function(e){var t=function(e){return e.ids},r=function(e){return e.entities},n=o.createSelector(t,r,(function(e,t){return e.map((function(e){return t[e]}))})),i=function(e,t){return t},a=function(e,t){return e[t]},u=o.createSelector(t,(function(e){return e.length}));if(!e)return{selectIds:t,selectEntities:r,selectAll:n,selectTotal:u,selectById:o.createSelector(r,i,a)};var c=o.createSelector(e,r);return{selectIds:o.createSelector(e,t),selectEntities:c,selectAll:o.createSelector(e,n),selectTotal:o.createSelector(e,u),selectById:o.createSelector(c,i,a)}}},{},n?function(e,t){var r=j(e);function n(t,r){Array.isArray(t)||(t=Object.values(t));var n=t.filter((function(t){return!(S(t,e)in r.entities)}));0!==n.length&&a(n,r)}function o(t,r){var n=[];t.forEach((function(t){return function(t,r,n){if(!(r.id in n.entities))return!1;var o=Object.assign({},n.entities[r.id],r.changes),i=S(o,e);return delete n.entities[r.id],t.push(o),i!==r.id}(n,t,r)})),0!==n.length&&a(n,r)}function i(t,r){Array.isArray(t)||(t=Object.values(t));var i=[],a=[],u=t,c=Array.isArray(u),f=0;for(u=c?u:u[Symbol.iterator]();;){var s;if(c){if(f>=u.length)break;s=u[f++]}else{if((f=u.next()).done)break;s=f.value}var l=s,d=S(l,e);d in r.entities?a.push({id:d,changes:l}):i.push(l)}o(a,r),n(i,r)}function a(r,n){r.sort(t),r.forEach((function(t){n.entities[e(t)]=t}));var o=Object.values(n.entities);o.sort(t);var i=o.map(e);(function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(e[r]!==t[r])return!1;return!0})(n.ids,i)||(n.ids=i)}return{removeOne:r.removeOne,removeMany:r.removeMany,removeAll:r.removeAll,addOne:A((function(e,t){return n([e],t)})),updateOne:A((function(e,t){return o([e],t)})),upsertOne:A((function(e,t){return i([e],t)})),setAll:A((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.entities={},t.ids=[],n(e,t)})),addMany:A(n),updateMany:A(o),upsertMany:A(i)}}(r,n):j(r))},exports.createImmutableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},exports.createReducer=O,exports.createSerializableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},exports.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var n=e.reducers||{},o=void 0===e.extraReducers?[]:"function"==typeof e.extraReducers?g(e.extraReducers):[e.extraReducers],i=o[0],u=void 0===i?{}:i,c=o[1],f=void 0===c?[]:c,s=o[2],l=void 0===s?void 0:s,d=Object.keys(n),p={},y={},v={};d.forEach((function(e){var r,o,i=n[e],a=t+"/"+e;"reducer"in i?(r=i.reducer,o=i.prepare):r=i,p[e]=r,y[a]=r,v[e]=o?h(a,o):h(a)}));var b=O(r,a({},u,{},y),f,l);return{name:t,reducer:b,actions:v,caseReducers:p}},exports.findNonSerializableValue=function e(t,r,n,o,i){var a;if(void 0===r&&(r=[]),void 0===n&&(n=v),void 0===i&&(i=[]),!n(t))return{keyPath:r.join(".")||"<root>",value:t};if("object"!=typeof t||null===t)return!1;var u=null!=o?o(t):Object.entries(t),c=i.length>0,f=u,s=Array.isArray(f),l=0;for(f=s?f:f[Symbol.iterator]();;){var d;if(s){if(l>=f.length)break;d=f[l++]}else{if((l=f.next()).done)break;d=l.value}var p=d[1],y=r.concat(d[0]);if(!(c&&i.indexOf(y.join("."))>=0)){if(!n(p))return{keyPath:y.join("."),value:p};if("object"==typeof p&&(a=e(p,y,n,o,i)))return a}}return!1},exports.getDefaultMiddleware=b,exports.getType=function(e){return""+e},exports.isImmutableDefault=function(e){return"object"!=typeof e||null==e},exports.isPlain=v,exports.nanoid=x,exports.unwrapResult=function(e){if("error"in e)throw e.error;return e.payload};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("immer"),r=e(t),n=require("redux"),o=require("reselect"),i=e(require("redux-thunk")),u=function(){var e=o.createSelector.apply(void 0,arguments),r=function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return e.apply(void 0,[t.isDraft(r)?t.current(r):r].concat(o))};return r};function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function l(e,t,r){return(l=s()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return l(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}var p="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?n.compose:n.compose.apply(null,arguments)};function y(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var v=function(e){var t,r;function n(){return e.apply(this,arguments)||this}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var o=n.prototype;return o.concat=function(){for(var t,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return l(n,(t=e.prototype.concat).call.apply(t,[this].concat(o)))},o.prepend=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])?l(n,t[0].concat(this)):l(n,t.concat(this))},n}(d(Array));function h(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||y(e)}function b(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=new v;return r&&n.push("boolean"==typeof r?i:i.withExtraArgument(r.extraArgument)),n}function m(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw new Error("prepareAction did not return an object");return a({type:e,payload:r.payload},"meta"in r&&{meta:r.meta},{},"error"in r&&{error:r.error})}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return r.toString=function(){return""+e},r.type=e,r.match=function(t){return t.type===e},r}function g(e){return["type","payload","error","meta"].indexOf(e)>-1}function O(e){var t,r={},n=[],o={addCase:function(e,t){var n="string"==typeof e?e:e.type;if(n in r)throw new Error("addCase cannot be called with two reducers for the same action type");return r[n]=t,o},addMatcher:function(e,t){return n.push({matcher:e,reducer:t}),o},addDefaultCase:function(e){return t=e,o}};return e(o),[r,n,t]}function j(e,n,o,i){void 0===o&&(o=[]);var u="function"==typeof n?O(n):[n,o,i],a=u[0],c=u[1],f=u[2];return function(n,o){void 0===n&&(n=e);var i=[a[o.type]].concat(c.filter((function(e){return(0,e.matcher)(o)})).map((function(e){return e.reducer})));return 0===i.filter((function(e){return!!e})).length&&(i=[f]),i.reduce((function(e,n){if(n){if(t.isDraft(e)){var i=n(e,o);return void 0===i?e:i}if(t.isDraftable(e))return r(e,(function(e){return n(e,o)}));var u=n(e,o);if(void 0===u){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return u}return e}),n)}}function A(e){return function(n,o){var i=function(t){!function(e){return y(t=e)&&"string"==typeof t.type&&Object.keys(t).every(g);var t}(o)?e(o,t):e(o.payload,t)};return t.isDraft(n)?(i(n),n):r(n,i)}}function x(e,t){return t(e)}function S(e){function t(t,r){var n=x(t,e);n in r.entities||(r.ids.push(n),r.entities[n]=t)}function r(e,r){Array.isArray(e)||(e=Object.values(e));var n=e,o=Array.isArray(n),i=0;for(n=o?n:n[Symbol.iterator]();;){var u;if(o){if(i>=n.length)break;u=n[i++]}else{if((i=n.next()).done)break;u=i.value}t(u,r)}}function n(e,t){var r=!1;e.forEach((function(e){e in t.entities&&(delete t.entities[e],r=!0)})),r&&(t.ids=t.ids.filter((function(e){return e in t.entities})))}function o(t,r){var n={},o={};t.forEach((function(e){e.id in r.entities&&(o[e.id]={id:e.id,changes:a({},o[e.id]?o[e.id].changes:null,{},e.changes)})})),(t=Object.values(o)).length>0&&t.filter((function(t){return function(t,r,n){var o=Object.assign({},n.entities[r.id],r.changes),i=x(o,e),u=i!==r.id;return u&&(t[r.id]=i,delete n.entities[r.id]),n.entities[i]=o,u}(n,t,r)})).length>0&&(r.ids=r.ids.map((function(e){return n[e]||e})))}function i(t,n){Array.isArray(t)||(t=Object.values(t));var i=[],u=[],a=t,c=Array.isArray(a),f=0;for(a=c?a:a[Symbol.iterator]();;){var s;if(c){if(f>=a.length)break;s=a[f++]}else{if((f=a.next()).done)break;s=f.value}var l=s,d=x(l,e);d in n.entities?u.push({id:d,changes:l}):i.push(l)}o(u,n),r(i,n)}return{removeAll:(u=function(e){Object.assign(e,{ids:[],entities:{}})},c=A((function(e,t){return u(t)})),function(e){return c(e,void 0)}),addOne:A(t),addMany:A(r),setAll:A((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.ids=[],t.entities={},r(e,t)})),updateOne:A((function(e,t){return o([e],t)})),updateMany:A(o),upsertOne:A((function(e,t){return i([e],t)})),upsertMany:A(i),removeOne:A((function(e,t){return n([e],t)})),removeMany:A(n)};var u,c}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var w=function(e){void 0===e&&(e=21);for(var t="",r=e;r--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t},E=["name","message","stack","code"],P=function(e){this.payload=e,this.name="RejectWithValue",this.message="Rejected"},_=function(e){if("object"==typeof e&&null!==e){var t={},r=E,n=Array.isArray(r),o=0;for(r=n?r:r[Symbol.iterator]();;){var i;if(n){if(o>=r.length)break;i=r[o++]}else{if((o=r.next()).done)break;i=o.value}"string"==typeof e[i]&&(t[i]=e[i])}return t}return{message:String(e)}},k=function(e,t){return(r=e)&&"function"==typeof r.match?e.match(t):e(t);var r};function I(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.some((function(t){return k(t,e)}))}}function R(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.every((function(t){return k(t,e)}))}}function M(e,t){if(!e||!e.meta)return!1;var r="string"==typeof e.meta.requestId,n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function q(e){return"function"==typeof e[0]&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function D(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return M(e,["rejected"])}:q(t)?function(e){var r=t.map((function(e){return e.rejected}));return I.apply(void 0,r)(e)}:D()(t[0])}t.enableES5(),Object.keys(n).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),exports.createNextState=r,Object.defineProperty(exports,"current",{enumerable:!0,get:function(){return t.current}}),Object.defineProperty(exports,"freeze",{enumerable:!0,get:function(){return t.freeze}}),Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return o.createSelector}}),exports.MiddlewareArray=v,exports.configureStore=function(e){var t,r=function(e){return b(e)},o=e||{},i=o.reducer,u=void 0===i?void 0:i,c=o.middleware,f=void 0===c?r():c,s=o.devTools,l=void 0===s||s,d=o.preloadedState,v=void 0===d?void 0:d,h=o.enhancers,m=void 0===h?void 0:h;if("function"==typeof u)t=u;else{if(!y(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');t=n.combineReducers(u)}var g=n.applyMiddleware.apply(void 0,"function"==typeof f?f(r):f),O=n.compose;l&&(O=p(a({trace:!1},"object"==typeof l&&l)));var j=[g];Array.isArray(m)?j=[g].concat(m):"function"==typeof m&&(j=m(j));var A=O.apply(void 0,j);return n.createStore(t,v,A)},exports.createAction=m,exports.createAsyncThunk=function(e,t,r){var n=m(e+"/fulfilled",(function(e,t,r){return{payload:e,meta:{arg:r,requestId:t,requestStatus:"fulfilled"}}})),o=m(e+"/pending",(function(e,t){return{payload:void 0,meta:{arg:t,requestId:e,requestStatus:"pending"}}})),i=m(e+"/rejected",(function(e,t,n){var o=e instanceof P,i=!!e&&"AbortError"===e.name,u=!!e&&"ConditionError"===e.name;return{payload:e instanceof P?e.payload:void 0,error:(r&&r.serializeError||_)(e||"Rejected"),meta:{arg:n,requestId:t,rejectedWithValue:o,requestStatus:"rejected",aborted:i,condition:u}}})),u="undefined"!=typeof AbortController?AbortController:function(){function e(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){}}}return e.prototype.abort=function(){},e}();return Object.assign((function(e){return function(a,c,f){var s,l=w(),d=new u,p=new Promise((function(e,t){return d.signal.addEventListener("abort",(function(){return t({name:"AbortError",message:s||"Aborted"})}))})),y=!1,v=function(){try{var u,s=function(e){return v?e:(r&&!r.dispatchConditionRejection&&i.match(u)&&u.meta.condition||a(u),u)},v=!1,h=function(s,v){try{var h=function(){if(r&&r.condition&&!1===r.condition(e,{getState:c,extra:f}))throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return y=!0,a(o(l,e)),Promise.resolve(Promise.race([p,Promise.resolve(t(e,{dispatch:a,getState:c,extra:f,requestId:l,signal:d.signal,rejectWithValue:function(e){return new P(e)}})).then((function(t){return t instanceof P?i(t,l,e):n(t,l,e)}))])).then((function(e){u=e}))}()}catch(e){return v(e)}return h&&h.then?h.then(void 0,v):h}(0,(function(t){u=i(t,l,e)}));return Promise.resolve(h&&h.then?h.then(s):s(h))}catch(e){return Promise.reject(e)}}();return Object.assign(v,{abort:function(e){y&&(s=e,d.abort())},requestId:l,arg:e})}}),{pending:o,rejected:i,fulfilled:n,typePrefix:e})},exports.createDraftSafeSelector=u,exports.createEntityAdapter=function(e){void 0===e&&(e={});var t=a({sortComparer:!1,selectId:function(e){return e.id}},e),r=t.selectId,n=t.sortComparer;return a({selectId:r,sortComparer:n},{getInitialState:function(e){return void 0===e&&(e={}),Object.assign({ids:[],entities:{}},e)}},{},{getSelectors:function(e){var t=function(e){return e.ids},r=function(e){return e.entities},n=u(t,r,(function(e,t){return e.map((function(e){return t[e]}))})),o=function(e,t){return t},i=function(e,t){return e[t]},a=u(t,(function(e){return e.length}));if(!e)return{selectIds:t,selectEntities:r,selectAll:n,selectTotal:a,selectById:u(r,o,i)};var c=u(e,r);return{selectIds:u(e,t),selectEntities:c,selectAll:u(e,n),selectTotal:u(e,a),selectById:u(c,o,i)}}},{},n?function(e,t){var r=S(e);function n(t,r){Array.isArray(t)||(t=Object.values(t));var n=t.filter((function(t){return!(x(t,e)in r.entities)}));0!==n.length&&u(n,r)}function o(t,r){var n=[];t.forEach((function(t){return function(t,r,n){if(!(r.id in n.entities))return!1;var o=Object.assign({},n.entities[r.id],r.changes),i=x(o,e);return delete n.entities[r.id],t.push(o),i!==r.id}(n,t,r)})),0!==n.length&&u(n,r)}function i(t,r){Array.isArray(t)||(t=Object.values(t));var i=[],u=[],a=t,c=Array.isArray(a),f=0;for(a=c?a:a[Symbol.iterator]();;){var s;if(c){if(f>=a.length)break;s=a[f++]}else{if((f=a.next()).done)break;s=f.value}var l=s,d=x(l,e);d in r.entities?u.push({id:d,changes:l}):i.push(l)}o(u,r),n(i,r)}function u(r,n){r.sort(t),r.forEach((function(t){n.entities[e(t)]=t}));var o=Object.values(n.entities);o.sort(t);var i=o.map(e);(function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(e[r]!==t[r])return!1;return!0})(n.ids,i)||(n.ids=i)}return{removeOne:r.removeOne,removeMany:r.removeMany,removeAll:r.removeAll,addOne:A((function(e,t){return n([e],t)})),updateOne:A((function(e,t){return o([e],t)})),upsertOne:A((function(e,t){return i([e],t)})),setAll:A((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.entities={},t.ids=[],n(e,t)})),addMany:A(n),updateMany:A(o),upsertMany:A(i)}}(r,n):S(r))},exports.createImmutableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},exports.createReducer=j,exports.createSerializableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},exports.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var n=e.reducers||{},o=void 0===e.extraReducers?[]:"function"==typeof e.extraReducers?O(e.extraReducers):[e.extraReducers],i=o[0],u=void 0===i?{}:i,c=o[1],f=void 0===c?[]:c,s=o[2],l=void 0===s?void 0:s,d=Object.keys(n),p={},y={},v={};d.forEach((function(e){var r,o,i=n[e],u=t+"/"+e;"reducer"in i?(r=i.reducer,o=i.prepare):r=i,p[e]=r,y[u]=r,v[e]=o?m(u,o):m(u)}));var h=j(r,a({},u,{},y),f,l);return{name:t,reducer:h,actions:v,caseReducers:p}},exports.findNonSerializableValue=function e(t,r,n,o,i){var u;if(void 0===r&&(r=[]),void 0===n&&(n=h),void 0===i&&(i=[]),!n(t))return{keyPath:r.join(".")||"<root>",value:t};if("object"!=typeof t||null===t)return!1;var a=null!=o?o(t):Object.entries(t),c=i.length>0,f=a,s=Array.isArray(f),l=0;for(f=s?f:f[Symbol.iterator]();;){var d;if(s){if(l>=f.length)break;d=f[l++]}else{if((l=f.next()).done)break;d=l.value}var p=d[1],y=r.concat(d[0]);if(!(c&&i.indexOf(y.join("."))>=0)){if(!n(p))return{keyPath:y.join("."),value:p};if("object"==typeof p&&(u=e(p,y,n,o,i)))return u}}return!1},exports.getDefaultMiddleware=b,exports.getType=function(e){return""+e},exports.isAllOf=R,exports.isAnyOf=I,exports.isAsyncThunkAction=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return 0===r.length?function(e){return M(e,["pending","fulfilled","rejected"])}:q(r)?function(e){var t=[],n=r,o=Array.isArray(n),i=0;for(n=o?n:n[Symbol.iterator]();;){var u;if(o){if(i>=n.length)break;u=n[i++]}else{if((i=n.next()).done)break;u=i.value}t.push(u.pending,u.rejected,u.fulfilled)}return I.apply(void 0,t)(e)}:e()(r[0])},exports.isFulfilled=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return 0===r.length?function(e){return M(e,["fulfilled"])}:q(r)?function(e){var t=r.map((function(e){return e.fulfilled}));return I.apply(void 0,t)(e)}:e()(r[0])},exports.isImmutableDefault=function(e){return"object"!=typeof e||null==e},exports.isPending=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return 0===r.length?function(e){return M(e,["pending"])}:q(r)?function(e){var t=r.map((function(e){return e.pending}));return I.apply(void 0,t)(e)}:e()(r[0])},exports.isPlain=h,exports.isPlainObject=y,exports.isRejected=D,exports.isRejectedWithValue=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var o=function(e){return e&&e.meta&&e.meta.rejectedWithValue};return 0===r.length?function(e){return R(D.apply(void 0,r),o)(e)}:q(r)?function(e){return R(D.apply(void 0,r),o)(e)}:e()(r[0])},exports.nanoid=w,exports.unwrapResult=function(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload};
//# sourceMappingURL=redux-toolkit.cjs.production.min.js.map

@@ -1,3 +0,3 @@

import createNextState, { isDraft, isDraftable, enableES5 } from 'immer';
export { default as createNextState, current } from 'immer';
import createNextState, { isDraft, current, isDraftable, enableES5 } from 'immer';
export { default as createNextState, current, freeze } from 'immer';
import { compose, combineReducers, applyMiddleware, createStore } from 'redux';

@@ -9,2 +9,24 @@ export * from 'redux';

/**
* "Draft-Safe" version of `reselect`'s `createSelector`:
* If an `immer`-drafted object is passed into the resulting selector's first argument,
* the selector will act on the current draft value, instead of returning a cached value
* that might be possibly outdated if the draft has been modified since.
* @public
*/
var createDraftSafeSelector = function createDraftSafeSelector() {
var selector = createSelector.apply(void 0, arguments);
var wrappedSelector = function wrappedSelector(value) {
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
return selector.apply(void 0, [isDraft(value) ? current(value) : value].concat(rest));
};
return wrappedSelector;
};
function _extends() {

@@ -135,2 +157,4 @@ _extends = Object.assign || function (target) {

* @returns {boolean} True if the argument appears to be a plain object.
*
* @public
*/

@@ -876,2 +900,6 @@ function isPlainObject(value) {

if (typeof _result === 'undefined') {
if (previousState === null) {
return previousState;
}
throw Error('A case reducer on a non-draftable value must not return undefined');

@@ -992,3 +1020,3 @@ }

var selectAll = createSelector(selectIds, selectEntities, function (ids, entities) {
var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) {
return ids.map(function (id) {

@@ -1007,3 +1035,3 @@ return entities[id];

var selectTotal = createSelector(selectIds, function (ids) {
var selectTotal = createDraftSafeSelector(selectIds, function (ids) {
return ids.length;

@@ -1018,13 +1046,13 @@ });

selectTotal: selectTotal,
selectById: createSelector(selectEntities, selectId, selectById)
selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
};
}
var selectGlobalizedEntities = createSelector(selectState, selectEntities);
var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
return {
selectIds: createSelector(selectState, selectIds),
selectIds: createDraftSafeSelector(selectState, selectIds),
selectEntities: selectGlobalizedEntities,
selectAll: createSelector(selectState, selectAll),
selectTotal: createSelector(selectState, selectTotal),
selectById: createSelector(selectGlobalizedEntities, selectId, selectById)
selectAll: createDraftSafeSelector(selectState, selectAll),
selectTotal: createDraftSafeSelector(selectState, selectTotal),
selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
};

@@ -1488,4 +1516,6 @@ }

var RejectWithValue = function RejectWithValue(value) {
this.value = value;
var RejectWithValue = function RejectWithValue(payload) {
this.payload = payload;
this.name = 'RejectWithValue';
this.message = 'Rejected';
}; // Reworked from https://github.com/sindresorhus/serialize-error

@@ -1539,3 +1569,4 @@

arg: arg,
requestId: requestId
requestId: requestId,
requestStatus: 'fulfilled'
}

@@ -1549,15 +1580,19 @@ };

arg: arg,
requestId: requestId
requestId: requestId,
requestStatus: 'pending'
}
};
});
var rejected = createAction(typePrefix + '/rejected', function (error, requestId, arg, payload) {
var rejected = createAction(typePrefix + '/rejected', function (error, requestId, arg) {
var rejectedWithValue = error instanceof RejectWithValue;
var aborted = !!error && error.name === 'AbortError';
var condition = !!error && error.name === 'ConditionError';
return {
payload: payload,
error: miniSerializeError(error || 'Rejected'),
payload: error instanceof RejectWithValue ? error.payload : undefined,
error: (options && options.serializeError || miniSerializeError)(error || 'Rejected'),
meta: {
arg: arg,
requestId: requestId,
rejectedWithValue: rejectedWithValue,
requestStatus: 'rejected',
aborted: aborted,

@@ -1665,3 +1700,3 @@ condition: condition

if (result instanceof RejectWithValue) {
return rejected(null, requestId, arg, result.value);
return rejected(result, requestId, arg);
}

@@ -1684,3 +1719,5 @@

return Object.assign(promise, {
abort: abort
abort: abort,
requestId: requestId,
arg: arg
});

@@ -1701,10 +1738,223 @@ };

function unwrapResult(returned) {
if ('error' in returned) {
throw returned.error;
function unwrapResult(action) {
if (action.meta && action.meta.rejectedWithValue) {
throw action.payload;
}
return returned.payload;
if (action.error) {
throw action.error;
}
return action.payload;
}
var hasMatchFunction = function hasMatchFunction(v) {
return v && typeof v.match === 'function';
};
var matches = function matches(matcher, action) {
if (hasMatchFunction(matcher)) {
return matcher.match(action);
} else {
return matcher(action);
}
};
/**
* A higher-order function that returns a function that may be used to check
* whether an action matches any one of the supplied type guards or action
* creators.
*
* @param matchers The type guards or action creators to match against.
*
* @public
*/
function isAnyOf() {
for (var _len = arguments.length, matchers = new Array(_len), _key = 0; _key < _len; _key++) {
matchers[_key] = arguments[_key];
}
return function (action) {
return matchers.some(function (matcher) {
return matches(matcher, action);
});
};
}
/**
* A higher-order function that returns a function that may be used to check
* whether an action matches all of the supplied type guards or action
* creators.
*
* @param matchers The type guards or action creators to match against.
*
* @public
*/
function isAllOf() {
for (var _len2 = arguments.length, matchers = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
matchers[_key2] = arguments[_key2];
}
return function (action) {
return matchers.every(function (matcher) {
return matches(matcher, action);
});
};
}
/**
* @param action A redux action
* @param validStatus An array of valid meta.requestStatus values
*
* @internal
*/
function hasExpectedRequestMetadata(action, validStatus) {
if (!action || !action.meta) return false;
var hasValidRequestId = typeof action.meta.requestId === 'string';
var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
return hasValidRequestId && hasValidRequestStatus;
}
function isAsyncThunkArray(a) {
return typeof a[0] === 'function' && 'pending' in a[0] && 'fulfilled' in a[0] && 'rejected' in a[0];
}
function isPending() {
for (var _len3 = arguments.length, asyncThunks = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
asyncThunks[_key3] = arguments[_key3];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['pending']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isPending()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = asyncThunks.map(function (asyncThunk) {
return asyncThunk.pending;
});
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
function isRejected() {
for (var _len4 = arguments.length, asyncThunks = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
asyncThunks[_key4] = arguments[_key4];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['rejected']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isRejected()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = asyncThunks.map(function (asyncThunk) {
return asyncThunk.rejected;
});
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
function isRejectedWithValue() {
for (var _len5 = arguments.length, asyncThunks = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
asyncThunks[_key5] = arguments[_key5];
}
var hasFlag = function hasFlag(action) {
return action && action.meta && action.meta.rejectedWithValue;
};
if (asyncThunks.length === 0) {
return function (action) {
var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
return combinedMatcher(action);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isRejectedWithValue()(asyncThunks[0]);
}
return function (action) {
var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
return combinedMatcher(action);
};
}
function isFulfilled() {
for (var _len6 = arguments.length, asyncThunks = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
asyncThunks[_key6] = arguments[_key6];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['fulfilled']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isFulfilled()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = asyncThunks.map(function (asyncThunk) {
return asyncThunk.fulfilled;
});
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
function isAsyncThunkAction() {
for (var _len7 = arguments.length, asyncThunks = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
asyncThunks[_key7] = arguments[_key7];
}
if (asyncThunks.length === 0) {
return function (action) {
return hasExpectedRequestMetadata(action, ['pending', 'fulfilled', 'rejected']);
};
}
if (!isAsyncThunkArray(asyncThunks)) {
return isAsyncThunkAction()(asyncThunks[0]);
}
return function (action) {
// note: this type will be correct because we have at least 1 asyncThunk
var matchers = [];
for (var _iterator = asyncThunks, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var asyncThunk = _ref;
matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
}
var combinedMatcher = isAnyOf.apply(void 0, matchers);
return combinedMatcher(action);
};
}
// we assume RTK will be used with React Native and other Proxy-less

@@ -1716,3 +1966,3 @@ // environments. In addition, that's how Immer 4 behaved, and since

export { MiddlewareArray, configureStore, createAction, createAsyncThunk, createEntityAdapter, createImmutableStateInvariantMiddleware, createReducer, createSerializableStateInvariantMiddleware, createSlice, findNonSerializableValue, getDefaultMiddleware, getType, isImmutableDefault, isPlain, nanoid, unwrapResult };
export { MiddlewareArray, configureStore, createAction, createAsyncThunk, createDraftSafeSelector, createEntityAdapter, createImmutableStateInvariantMiddleware, createReducer, createSerializableStateInvariantMiddleware, createSlice, findNonSerializableValue, getDefaultMiddleware, getType, isAllOf, isAnyOf, isAsyncThunkAction, isFulfilled, isImmutableDefault, isPending, isPlain, isPlainObject, isRejected, isRejectedWithValue, nanoid, unwrapResult };
//# sourceMappingURL=redux-toolkit.esm.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RTK={})}(this,(function(e){"use strict";function t(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(e){return!!e&&!!e[U]}function n(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);return!t||t===Object.prototype}(e)||Array.isArray(e)||!!e[K]||!!e.constructor[K]||f(e)||s(e))}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:W)(e).forEach((function(n){r&&"symbol"==typeof n||t(n,e[n],e)})):e.forEach((function(r,n){return t(n,r,e)}))}function i(e){var t=e[U];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:f(e)?2:s(e)?3:0}function u(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function a(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function c(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e){return M&&e instanceof Map}function s(e){return C&&e instanceof Set}function l(e){return e.o||e.t}function d(e){if(Array.isArray(e))return e.slice();var t=L(e);delete t[U];for(var r=W(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function p(e,t){Object.isFrozen(e)||r(e)||!n(e)||(i(e)>1&&(e.set=e.add=e.clear=e.delete=y),Object.freeze(e),t&&o(e,(function(e,t){return p(t,!0)}),!0))}function y(){t(2)}function v(e){var r=q[e];return r||t(19,e),r}function h(){return N}function b(e,t){t&&(v("Patches"),e.u=[],e.s=[],e.v=t)}function g(e){m(e),e.p.forEach(w),e.p=null}function m(e){e===N&&(N=e.l)}function O(e){return N={p:[],l:N,h:e,m:!0,_:0}}function w(e){var t=e[U];0===t.i||1===t.i?t.j():t.O=!0}function j(e,r){r._=r.p.length;var o=r.p[0],i=void 0!==e&&e!==o;return r.h.g||v("ES5").S(r,e,i),i?(o[U].P&&(g(r),t(4)),n(e)&&(e=A(r,e),r.l||E(r,e)),r.u&&v("Patches").M(o[U],e,r.u,r.s)):e=A(r,o,[]),g(r),r.u&&r.v(r.u,r.s),e!==z?e:void 0}function A(e,t,r){if(null==(n=t)||"object"!=typeof n||Object.isFrozen(n))return t;var n,i=t[U];if(!i)return o(t,(function(n,o){return P(e,i,t,n,o,r)}),!0),t;if(i.A!==e)return t;if(!i.P)return E(e,i.t,!0),i.t;if(!i.I){i.I=!0,i.A._--;var u=4===i.i||5===i.i?i.o=d(i.k):i.o;o(u,(function(t,n){return P(e,i,u,t,n,r)})),E(e,u,!1),r&&e.u&&v("Patches").R(i,r,e.u,e.s)}return i.o}function P(e,t,o,i,c,f){if(r(c)){var s=A(e,c,f&&t&&3!==t.i&&!u(t.D,i)?f.concat(i):void 0);if(a(o,i,s),!r(s))return;e.m=!1}if(n(c)&&!Object.isFrozen(c)){if(!e.h.N&&e._<1)return;A(e,c),t&&t.A.l||E(e,c)}}function E(e,t,r){void 0===r&&(r=!1),e.h.N&&e.m&&p(t,r)}function S(e,t){var r=e[U];return(r?l(r):e)[t]}function x(e){e.P||(e.P=!0,e.l&&x(e.l))}function I(e){e.o||(e.o=d(e.t))}function _(e,t,r){var n=f(t)?v("MapSet").T(t,r):s(t)?v("MapSet").F(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:h(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=B;r&&(o=[n],i=X);var u=Proxy.revocable(o,i),a=u.revoke,c=u.proxy;return n.k=c,n.j=a,c}(t,r):v("ES5").J(t,r);return(r?r.A:h()).p.push(n),n}function k(e){return r(e)||t(22,e),function e(t){if(!n(t))return t;var r,u=t[U],c=i(t);if(u){if(!u.P&&(u.i<4||!v("ES5").K(u)))return u.t;u.I=!0,r=R(t,c),u.I=!1}else r=R(t,c);return o(r,(function(t,n){u&&function(e,t){return 2===i(e)?e.get(t):e[t]}(u.t,t)===n||a(r,t,e(n))})),3===c?new Set(r):r}(e)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return d(e)}var D,N,T="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),M="undefined"!=typeof Map,C="undefined"!=typeof Set,F="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,z=T?Symbol("immer-nothing"):((D={})["immer-nothing"]=!0,D),K=T?Symbol("immer-draftable"):"__$immer_draftable",U=T?Symbol("immer-state"):"__$immer_state",W="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,L=Object.getOwnPropertyDescriptors||function(e){var t={};return W(e).forEach((function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)})),t},q={},B={get:function(e,t){if(t===U)return e;var r=l(e);if(!u(r,t))return function(e,t,r){if(r in t)for(var n=Object.getPrototypeOf(t);n;){var o,i=Object.getOwnPropertyDescriptor(n,r);if(i)return"value"in i?i.value:null===(o=i.get)||void 0===o?void 0:o.call(e.k);n=Object.getPrototypeOf(n)}}(e,r,t);var o=r[t];return e.I||!n(o)?o:o===S(e.t,t)?(I(e),e.o[t]=_(e.A.h,o,e)):o},has:function(e,t){return t in l(e)},ownKeys:function(e){return Reflect.ownKeys(l(e))},set:function(e,t,r){if(e.D[t]=!0,!e.P){if(c(r,S(l(e),t))&&void 0!==r)return!0;I(e),x(e)}return e.o[t]=r,!0},deleteProperty:function(e,t){return void 0!==S(e.t,t)||t in e.t?(e.D[t]=!1,I(e),x(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=l(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){t(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){t(12)}},X={};o(B,(function(e,t){X[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),X.deleteProperty=function(e,t){return B.deleteProperty.call(this,e[0],t)},X.set=function(e,t,r){return B.set.call(this,e[0],t,r,e[0])};var V=new(function(){function e(e){this.g=F,this.N=!1,"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),this.produce=this.produce.bind(this),this.produceWithPatches=this.produceWithPatches.bind(this)}var o=e.prototype;return o.produce=function(e,r,o){if("function"==typeof e&&"function"!=typeof r){var i=r;r=e;var u=this;return function(e){var t=this;void 0===e&&(e=i);for(var n=arguments.length,o=Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return u.produce(e,(function(e){var n;return(n=r).call.apply(n,[t,e].concat(o))}))}}var a;if("function"!=typeof r&&t(6),void 0!==o&&"function"!=typeof o&&t(7),n(e)){var c=O(this),f=_(this,e,void 0),s=!0;try{a=r(f),s=!1}finally{s?g(c):m(c)}return"undefined"!=typeof Promise&&a instanceof Promise?a.then((function(e){return b(c,o),j(e,c)}),(function(e){throw g(c),e})):(b(c,o),j(a,c))}if(!e||"object"!=typeof e){if((a=r(e))===z)return;return void 0===a&&(a=e),this.N&&p(a,!0),a}t(21,e)},o.produceWithPatches=function(e,t){var r,n,o=this;return"function"==typeof e?function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return o.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(n))}))}:[this.produce(e,t,(function(e,t){r=e,n=t})),r,n]},o.createDraft=function(e){n(e)||t(8),r(e)&&(e=k(e));var o=O(this),i=_(this,e,void 0);return i[U].C=!0,m(o),i},o.finishDraft=function(e,t){var r=(e&&e[U]).A;return b(r,t),j(void 0,r)},o.setAutoFreeze=function(e){this.N=e},o.setUseProxies=function(e){e&&!F&&t(20),this.g=e},o.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}var i=v("Patches").$;return r(e)?i(e,t):this.produce(e,(function(e){return i(e,t.slice(n+1))}))},e}()),Y=V.produce;V.produceWithPatches.bind(V),V.setAutoFreeze.bind(V),V.setUseProxies.bind(V),V.applyPatches.bind(V),V.createDraft.bind(V),V.finishDraft.bind(V);var J=function(e){var t,r=("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()).Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}(),$=function(){return Math.random().toString(36).substring(7).split("").join(".")},G={INIT:"@@redux/INIT"+$(),REPLACE:"@@redux/REPLACE"+$(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+$()}};function H(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Q(e,t,r){var n;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error("Expected the enhancer to be a function.");return r(Q)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var o=e,i=t,u=[],a=u,c=!1;function f(){a===u&&(a=u.slice())}function s(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function l(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return f(),a.push(e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,f();var r=a.indexOf(e);a.splice(r,1)}}}function d(e){if(!H(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!1}for(var t=u=a,r=0;r<t.length;r++)(0,t[r])();return e}function p(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");o=e,d({type:G.REPLACE})}function y(){var e,t=l;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function r(){e.next&&e.next(s())}return r(),{unsubscribe:t(r)}}})[J]=function(){return this},e}return d({type:G.INIT}),(n={dispatch:d,subscribe:l,getState:s,replaceReducer:p})[J]=y,n}function Z(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+String(r)+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function ee(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var o=t[n];"function"==typeof e[o]&&(r[o]=e[o])}var i,u=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(void 0===r(void 0,{type:G.INIT}))throw new Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===r(void 0,{type:G.PROBE_UNKNOWN_ACTION()}))throw new Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+G.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(r)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var n=!1,o={},a=0;a<u.length;a++){var c=u[a],f=e[c],s=(0,r[c])(f,t);if(void 0===s){var l=Z(c,t);throw new Error(l)}o[c]=s,n=n||s!==f}return n?o:e}}function te(e,t){return function(){return t(e.apply(this,arguments))}}function re(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){re(e,t,r[t])}))}return e}function oe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function ie(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return ne({},r,{dispatch:n=oe.apply(void 0,i)(r.dispatch)})}}}function ue(e,t){return e===t}function ae(e,t,r){if(null===t||null===r||t.length!==r.length)return!1;for(var n=t.length,o=0;o<n;o++)if(!e(t[o],r[o]))return!1;return!0}function ce(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var r=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}var fe=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=0,u=n.pop(),a=ce(n),c=e.apply(void 0,[function(){return i++,u.apply(null,arguments)}].concat(r)),f=e((function(){for(var e=[],t=a.length,r=0;r<t;r++)e.push(a[r].apply(null,arguments));return c.apply(null,e)}));return f.resultFunc=u,f.dependencies=a,f.recomputations=function(){return i},f.resetRecomputations=function(){return i=0},f}}((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ue,r=null,n=null;return function(){return ae(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}}));function se(){return(se=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function le(e){return(le=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function de(e,t){return(de=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function pe(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function ye(e,t,r){return(ye=pe()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&de(o,r.prototype),o}).apply(null,arguments)}function ve(e){var t="function"==typeof Map?new Map:void 0;return(ve=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return ye(e,arguments,le(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),de(r,e)})(e)}var he="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?oe:oe.apply(null,arguments)};function be(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ge(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(o){return"function"==typeof o?o(r,n,e):t(o)}}}}var me=ge();me.withExtraArgument=ge;var Oe=function(e){var t,r;function n(){return e.apply(this,arguments)||this}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var o=n.prototype;return o.concat=function(){for(var t,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return ye(n,(t=e.prototype.concat).call.apply(t,[this].concat(o)))},o.prepend=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])?ye(n,t[0].concat(this)):ye(n,t.concat(this))},n}(ve(Array));function we(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||be(e)}function je(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=new Oe;return r&&(function(e){return"boolean"==typeof e}(r)?n.push(me):n.push(me.withExtraArgument(r.extraArgument))),n}function Ae(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw new Error("prepareAction did not return an object");return se({type:e,payload:r.payload},"meta"in r&&{meta:r.meta},{},"error"in r&&{error:r.error})}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return r.toString=function(){return""+e},r.type=e,r.match=function(t){return t.type===e},r}function Pe(e){return["type","payload","error","meta"].indexOf(e)>-1}function Ee(e){var t,r={},n=[],o={addCase:function(e,t){var n="string"==typeof e?e:e.type;if(n in r)throw new Error("addCase cannot be called with two reducers for the same action type");return r[n]=t,o},addMatcher:function(e,t){return n.push({matcher:e,reducer:t}),o},addDefaultCase:function(e){return t=e,o}};return e(o),[r,n,t]}function Se(e,t,o,i){void 0===o&&(o=[]);var u="function"==typeof t?Ee(t):[t,o,i],a=u[0],c=u[1],f=u[2];return function(t,o){void 0===t&&(t=e);var i=[a[o.type]].concat(c.filter((function(e){return(0,e.matcher)(o)})).map((function(e){return e.reducer})));return 0===i.filter((function(e){return!!e})).length&&(i=[f]),i.reduce((function(e,t){if(t){if(r(e)){var i=t(e,o);return void 0===i?e:i}if(n(e))return Y(e,(function(e){return t(e,o)}));var u=t(e,o);if(void 0===u)throw Error("A case reducer on a non-draftable value must not return undefined");return u}return e}),t)}}function xe(e){return function(t,n){var o=function(t){!function(e){return be(t=e)&&"string"==typeof t.type&&Object.keys(t).every(Pe);var t}(n)?e(n,t):e(n.payload,t)};return r(t)?(o(t),t):Y(t,o)}}function Ie(e,t){return t(e)}function _e(e){function t(t,r){var n=Ie(t,e);n in r.entities||(r.ids.push(n),r.entities[n]=t)}function r(e,r){Array.isArray(e)||(e=Object.values(e));var n=e,o=Array.isArray(n),i=0;for(n=o?n:n[Symbol.iterator]();;){var u;if(o){if(i>=n.length)break;u=n[i++]}else{if((i=n.next()).done)break;u=i.value}t(u,r)}}function n(e,t){var r=!1;e.forEach((function(e){e in t.entities&&(delete t.entities[e],r=!0)})),r&&(t.ids=t.ids.filter((function(e){return e in t.entities})))}function o(t,r){var n={},o={};t.forEach((function(e){e.id in r.entities&&(o[e.id]={id:e.id,changes:se({},o[e.id]?o[e.id].changes:null,{},e.changes)})})),(t=Object.values(o)).length>0&&t.filter((function(t){return function(t,r,n){var o=Object.assign({},n.entities[r.id],r.changes),i=Ie(o,e),u=i!==r.id;return u&&(t[r.id]=i,delete n.entities[r.id]),n.entities[i]=o,u}(n,t,r)})).length>0&&(r.ids=r.ids.map((function(e){return n[e]||e})))}function i(t,n){Array.isArray(t)||(t=Object.values(t));var i=[],u=[],a=t,c=Array.isArray(a),f=0;for(a=c?a:a[Symbol.iterator]();;){var s;if(c){if(f>=a.length)break;s=a[f++]}else{if((f=a.next()).done)break;s=f.value}var l=s,d=Ie(l,e);d in n.entities?u.push({id:d,changes:l}):i.push(l)}o(u,n),r(i,n)}return{removeAll:(u=function(e){Object.assign(e,{ids:[],entities:{}})},a=xe((function(e,t){return u(t)})),function(e){return a(e,void 0)}),addOne:xe(t),addMany:xe(r),setAll:xe((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.ids=[],t.entities={},r(e,t)})),updateOne:xe((function(e,t){return o([e],t)})),updateMany:xe(o),upsertOne:xe((function(e,t){return i([e],t)})),upsertMany:xe(i),removeOne:xe((function(e,t){return n([e],t)})),removeMany:xe(n)};var u,a}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var ke=function(e){void 0===e&&(e=21);for(var t="",r=e;r--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t},Re=["name","message","stack","code"],De=function(e){this.value=e},Ne=function(e){if("object"==typeof e&&null!==e){var t={},r=Re,n=Array.isArray(r),o=0;for(r=n?r:r[Symbol.iterator]();;){var i;if(n){if(o>=r.length)break;i=r[o++]}else{if((o=r.next()).done)break;i=o.value}"string"==typeof e[i]&&(t[i]=e[i])}return t}return{message:String(e)}};!function(){function e(e,t){var r=a[e];return r?r.enumerable=t:a[e]=r={configurable:!0,enumerable:t,get:function(){return B.get(this[U],e)},set:function(t){B.set(this[U],e,t)}},r}function t(e){for(var t=e.length-1;t>=0;t--){var r=e[t][U];if(!r.P)switch(r.i){case 5:i(r)&&x(r);break;case 4:n(r)&&x(r)}}}function n(e){for(var t=e.t,r=e.k,n=W(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==U){var a=t[i];if(void 0===a&&!u(t,i))return!0;var f=r[i],s=f&&f[U];if(s?s.t!==a:!c(f,a))return!0}}var l=!!t[U];return n.length!==W(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var a={};!function(e,t){q.ES5=t}(0,{J:function(t,r){var n=Array.isArray(t),o=function(t,r){var n=L(r);t&&delete n.length,delete n[U];for(var o=W(n),i=0;i<o.length;i++){var u=o[i];n[u]=e(u,t||!!n[u].enumerable)}if(t){var a=Array(r.length);return Object.defineProperties(a,n),a}return Object.create(Object.getPrototypeOf(r),n)}(n,t),i={i:n?5:4,A:r?r.A:h(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,U,{value:i,writable:!0}),o},S:function(e,n,a){a?r(n)&&n[U].A===e&&t(e.p):(e.u&&function e(t){if(t&&"object"==typeof t){var r=t[U];if(r){var n=r.t,a=r.k,c=r.D,f=r.i;if(4===f)o(a,(function(t){t!==U&&(void 0!==n[t]||u(n,t)?c[t]||e(a[t]):(c[t]=!0,x(r)))})),o(n,(function(e){void 0!==a[e]||u(a,e)||(c[e]=!1,x(r))}));else if(5===f){if(i(r)&&(x(r),c.length=!0),a.length<n.length)for(var s=a.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<a.length;l++)c[l]=!0;for(var d=Math.min(a.length,n.length),p=0;p<d;p++)void 0===c[p]&&e(a[p])}}}}(e.p[0]),t(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}(),e.MiddlewareArray=Oe,e.__DO_NOT_USE__ActionTypes=G,e.applyMiddleware=ie,e.bindActionCreators=function(e,t){if("function"==typeof e)return te(e,t);if("object"!=typeof e||null===e)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o],u=e[i];"function"==typeof u&&(n[i]=te(u,t))}return n},e.combineReducers=ee,e.compose=oe,e.configureStore=function(e){var t,r=function(e){return je(e)},n=e||{},o=n.reducer,i=void 0===o?void 0:o,u=n.middleware,a=void 0===u?r():u,c=n.devTools,f=void 0===c||c,s=n.preloadedState,l=void 0===s?void 0:s,d=n.enhancers,p=void 0===d?void 0:d;if("function"==typeof i)t=i;else{if(!be(i))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=ee(i)}var y=ie.apply(void 0,"function"==typeof a?a(r):a),v=oe;f&&(v=he(se({trace:!1},"object"==typeof f&&f)));var h=[y];return Array.isArray(p)?h=[y].concat(p):"function"==typeof p&&(h=p(h)),Q(t,l,v.apply(void 0,h))},e.createAction=Ae,e.createAsyncThunk=function(e,t,r){var n=Ae(e+"/fulfilled",(function(e,t,r){return{payload:e,meta:{arg:r,requestId:t}}})),o=Ae(e+"/pending",(function(e,t){return{payload:void 0,meta:{arg:t,requestId:e}}})),i=Ae(e+"/rejected",(function(e,t,r,n){var o=!!e&&"AbortError"===e.name,i=!!e&&"ConditionError"===e.name;return{payload:n,error:Ne(e||"Rejected"),meta:{arg:r,requestId:t,aborted:o,condition:i}}})),u="undefined"!=typeof AbortController?AbortController:function(){function e(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){}}}return e.prototype.abort=function(){},e}();return Object.assign((function(e){return function(a,c,f){var s,l=ke(),d=new u,p=new Promise((function(e,t){return d.signal.addEventListener("abort",(function(){return t({name:"AbortError",message:s||"Aborted"})}))})),y=!1,v=function(){try{var u,s=function(e){return v?e:(r&&!r.dispatchConditionRejection&&i.match(u)&&u.meta.condition||a(u),u)},v=!1,h=function(s,v){try{var h=function(){if(r&&r.condition&&!1===r.condition(e,{getState:c,extra:f}))throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return y=!0,a(o(l,e)),Promise.resolve(Promise.race([p,Promise.resolve(t(e,{dispatch:a,getState:c,extra:f,requestId:l,signal:d.signal,rejectWithValue:function(e){return new De(e)}})).then((function(t){return t instanceof De?i(null,l,e,t.value):n(t,l,e)}))])).then((function(e){u=e}))}()}catch(e){return v(e)}return h&&h.then?h.then(void 0,v):h}(0,(function(t){u=i(t,l,e)}));return Promise.resolve(h&&h.then?h.then(s):s(h))}catch(e){return Promise.reject(e)}}();return Object.assign(v,{abort:function(e){y&&(s=e,d.abort())}})}}),{pending:o,rejected:i,fulfilled:n,typePrefix:e})},e.createEntityAdapter=function(e){void 0===e&&(e={});var t=se({sortComparer:!1,selectId:function(e){return e.id}},e),r=t.selectId,n=t.sortComparer;return se({selectId:r,sortComparer:n},{getInitialState:function(e){return void 0===e&&(e={}),Object.assign({ids:[],entities:{}},e)}},{},{getSelectors:function(e){var t=function(e){return e.ids},r=function(e){return e.entities},n=fe(t,r,(function(e,t){return e.map((function(e){return t[e]}))})),o=function(e,t){return t},i=function(e,t){return e[t]},u=fe(t,(function(e){return e.length}));if(!e)return{selectIds:t,selectEntities:r,selectAll:n,selectTotal:u,selectById:fe(r,o,i)};var a=fe(e,r);return{selectIds:fe(e,t),selectEntities:a,selectAll:fe(e,n),selectTotal:fe(e,u),selectById:fe(a,o,i)}}},{},n?function(e,t){var r=_e(e);function n(t,r){Array.isArray(t)||(t=Object.values(t));var n=t.filter((function(t){return!(Ie(t,e)in r.entities)}));0!==n.length&&u(n,r)}function o(t,r){var n=[];t.forEach((function(t){return function(t,r,n){if(!(r.id in n.entities))return!1;var o=Object.assign({},n.entities[r.id],r.changes),i=Ie(o,e);return delete n.entities[r.id],t.push(o),i!==r.id}(n,t,r)})),0!==n.length&&u(n,r)}function i(t,r){Array.isArray(t)||(t=Object.values(t));var i=[],u=[],a=t,c=Array.isArray(a),f=0;for(a=c?a:a[Symbol.iterator]();;){var s;if(c){if(f>=a.length)break;s=a[f++]}else{if((f=a.next()).done)break;s=f.value}var l=s,d=Ie(l,e);d in r.entities?u.push({id:d,changes:l}):i.push(l)}o(u,r),n(i,r)}function u(r,n){r.sort(t),r.forEach((function(t){n.entities[e(t)]=t}));var o=Object.values(n.entities);o.sort(t);var i=o.map(e);(function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(e[r]!==t[r])return!1;return!0})(n.ids,i)||(n.ids=i)}return{removeOne:r.removeOne,removeMany:r.removeMany,removeAll:r.removeAll,addOne:xe((function(e,t){return n([e],t)})),updateOne:xe((function(e,t){return o([e],t)})),upsertOne:xe((function(e,t){return i([e],t)})),setAll:xe((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.entities={},t.ids=[],n(e,t)})),addMany:xe(n),updateMany:xe(o),upsertMany:xe(i)}}(r,n):_e(r))},e.createImmutableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},e.createNextState=Y,e.createReducer=Se,e.createSelector=fe,e.createSerializableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},e.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var n=e.reducers||{},o=void 0===e.extraReducers?[]:"function"==typeof e.extraReducers?Ee(e.extraReducers):[e.extraReducers],i=o[0],u=void 0===i?{}:i,a=o[1],c=void 0===a?[]:a,f=o[2],s=void 0===f?void 0:f,l=Object.keys(n),d={},p={},y={};l.forEach((function(e){var r,o,i=n[e],u=t+"/"+e;"reducer"in i?(r=i.reducer,o=i.prepare):r=i,d[e]=r,p[u]=r,y[e]=o?Ae(u,o):Ae(u)}));var v=Se(r,se({},u,{},p),c,s);return{name:t,reducer:v,actions:y,caseReducers:d}},e.createStore=Q,e.current=k,e.findNonSerializableValue=function e(t,r,n,o,i){var u;if(void 0===r&&(r=[]),void 0===n&&(n=we),void 0===i&&(i=[]),!n(t))return{keyPath:r.join(".")||"<root>",value:t};if("object"!=typeof t||null===t)return!1;var a=null!=o?o(t):Object.entries(t),c=i.length>0,f=a,s=Array.isArray(f),l=0;for(f=s?f:f[Symbol.iterator]();;){var d;if(s){if(l>=f.length)break;d=f[l++]}else{if((l=f.next()).done)break;d=l.value}var p=d[1],y=r.concat(d[0]);if(!(c&&i.indexOf(y.join("."))>=0)){if(!n(p))return{keyPath:y.join("."),value:p};if("object"==typeof p&&(u=e(p,y,n,o,i)))return u}}return!1},e.getDefaultMiddleware=je,e.getType=function(e){return""+e},e.isImmutableDefault=function(e){return"object"!=typeof e||null==e},e.isPlain=we,e.nanoid=ke,e.unwrapResult=function(e){if("error"in e)throw e.error;return e.payload}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RTK={})}(this,(function(e){"use strict";function t(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map((function(e){return"'"+e+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(e){return!!e&&!!e[U]}function n(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);return!t||t===Object.prototype}(e)||Array.isArray(e)||!!e[K]||!!e.constructor[K]||f(e)||l(e))}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:V)(e).forEach((function(n){r&&"symbol"==typeof n||t(n,e[n],e)})):e.forEach((function(r,n){return t(n,r,e)}))}function i(e){var t=e[U];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:f(e)?2:l(e)?3:0}function u(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function a(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function c(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e){return W&&e instanceof Map}function l(e){return F&&e instanceof Set}function s(e){return e.o||e.t}function d(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=L(e);delete t[U];for(var r=V(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function p(e,t){return void 0===t&&(t=!1),v(e)||r(e)||!n(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=y),Object.freeze(e),t&&o(e,(function(e,t){return p(t,!0)}),!0),e)}function y(){t(2)}function v(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function h(e){var r=B[e];return r||t(18,e),r}function b(){return M}function g(e,t){t&&(h("Patches"),e.u=[],e.s=[],e.v=t)}function m(e){O(e),e.p.forEach(j),e.p=null}function O(e){e===M&&(M=e.l)}function w(e){return M={p:[],l:M,h:e,m:!0,_:0}}function j(e){var t=e[U];0===t.i||1===t.i?t.j():t.g=!0}function A(e,r){r._=r.p.length;var o=r.p[0],i=void 0!==e&&e!==o;return r.h.O||h("ES5").S(r,e,i),i?(o[U].P&&(m(r),t(4)),n(e)&&(e=P(r,e),r.l||E(r,e)),r.u&&h("Patches").M(o[U],e,r.u,r.s)):e=P(r,o,[]),m(r),r.u&&r.v(r.u,r.s),e!==z?e:void 0}function P(e,t,r){if(v(t))return t;var n=t[U];if(!n)return o(t,(function(o,i){return S(e,n,t,o,i,r)}),!0),t;if(n.A!==e)return t;if(!n.P)return E(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=d(n.k):n.o;o(3===n.i?new Set(i):i,(function(t,o){return S(e,n,i,t,o,r)})),E(e,i,!1),r&&e.u&&h("Patches").R(n,r,e.u,e.s)}return n.o}function S(e,t,o,i,c,f){if(r(c)){var l=P(e,c,f&&t&&3!==t.i&&!u(t.D,i)?f.concat(i):void 0);if(a(o,i,l),!r(l))return;e.m=!1}if(n(c)&&!v(c)){if(!e.h.N&&e._<1)return;P(e,c),t&&t.A.l||E(e,c)}}function E(e,t,r){void 0===r&&(r=!1),e.h.N&&e.m&&p(t,r)}function x(e,t){var r=e[U];return(r?s(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function _(e){e.P||(e.P=!0,e.l&&_(e.l))}function k(e){e.o||(e.o=d(e.t))}function R(e,t,r){var n=f(t)?h("MapSet").T(t,r):l(t)?h("MapSet").F(t,r):e.O?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:b(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=X;r&&(o=[n],i=Y);var u=Proxy.revocable(o,i),a=u.revoke,c=u.proxy;return n.k=c,n.j=a,c}(t,r):h("ES5").J(t,r);return(r?r.A:b()).p.push(n),n}function D(e){return r(e)||t(22,e),function e(t){if(!n(t))return t;var r,u=t[U],c=i(t);if(u){if(!u.P&&(u.i<4||!h("ES5").K(u)))return u.t;u.I=!0,r=N(t,c),u.I=!1}else r=N(t,c);return o(r,(function(t,n){u&&function(e,t){return 2===i(e)?e.get(t):e[t]}(u.t,t)===n||a(r,t,e(n))})),3===c?new Set(r):r}(e)}function N(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return d(e)}var T,M,C="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),W="undefined"!=typeof Map,F="undefined"!=typeof Set,q="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,z=C?Symbol.for("immer-nothing"):((T={})["immer-nothing"]=!0,T),K=C?Symbol.for("immer-draftable"):"__$immer_draftable",U=C?Symbol.for("immer-state"):"__$immer_state",V="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,L=Object.getOwnPropertyDescriptors||function(e){var t={};return V(e).forEach((function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)})),t},B={},X={get:function(e,t){if(t===U)return e;var r=s(e);if(!u(r,t))return function(e,t,r){var n,o=I(t,r);return o?"value"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,r,t);var o=r[t];return e.I||!n(o)?o:o===x(e.t,t)?(k(e),e.o[t]=R(e.A.h,o,e)):o},has:function(e,t){return t in s(e)},ownKeys:function(e){return Reflect.ownKeys(s(e))},set:function(e,t,r){var n=I(s(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=x(s(e),t),i=null==o?void 0:o[U];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(c(r,o)&&(void 0!==r||u(e.t,t)))return!0;k(e),_(e)}return e.o[t]=r,e.D[t]=!0,!0},deleteProperty:function(e,t){return void 0!==x(e.t,t)||t in e.t?(e.D[t]=!1,k(e),_(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=s(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){t(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){t(12)}},Y={};o(X,(function(e,t){Y[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Y.deleteProperty=function(e,t){return X.deleteProperty.call(this,e[0],t)},Y.set=function(e,t,r){return X.set.call(this,e[0],t,r,e[0])};var J=new(function(){function e(e){this.O=q,this.N=!0,"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),this.produce=this.produce.bind(this),this.produceWithPatches=this.produceWithPatches.bind(this)}var o=e.prototype;return o.produce=function(e,r,o){if("function"==typeof e&&"function"!=typeof r){var i=r;r=e;var u=this;return function(e){var t=this;void 0===e&&(e=i);for(var n=arguments.length,o=Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return u.produce(e,(function(e){var n;return(n=r).call.apply(n,[t,e].concat(o))}))}}var a;if("function"!=typeof r&&t(6),void 0!==o&&"function"!=typeof o&&t(7),n(e)){var c=w(this),f=R(this,e,void 0),l=!0;try{a=r(f),l=!1}finally{l?m(c):O(c)}return"undefined"!=typeof Promise&&a instanceof Promise?a.then((function(e){return g(c,o),A(e,c)}),(function(e){throw m(c),e})):(g(c,o),A(a,c))}if(!e||"object"!=typeof e){if((a=r(e))===z)return;return void 0===a&&(a=e),this.N&&p(a,!0),a}t(21,e)},o.produceWithPatches=function(e,t){var r,n,o=this;return"function"==typeof e?function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return o.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(n))}))}:[this.produce(e,t,(function(e,t){r=e,n=t})),r,n]},o.createDraft=function(e){n(e)||t(8),r(e)&&(e=D(e));var o=w(this),i=R(this,e,void 0);return i[U].C=!0,O(o),i},o.finishDraft=function(e,t){var r=(e&&e[U]).A;return g(r,t),A(void 0,r)},o.setAutoFreeze=function(e){this.N=e},o.setUseProxies=function(e){e&&!q&&t(20),this.O=e},o.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}var i=h("Patches").$;return r(e)?i(e,t):this.produce(e,(function(e){return i(e,t.slice(n+1))}))},e}()),$=J.produce;J.produceWithPatches.bind(J),J.setAutoFreeze.bind(J),J.setUseProxies.bind(J),J.applyPatches.bind(J),J.createDraft.bind(J),J.finishDraft.bind(J);var G=function(e){var t,r=("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()).Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}(),H=function(){return Math.random().toString(36).substring(7).split("").join(".")},Q={INIT:"@@redux/INIT"+H(),REPLACE:"@@redux/REPLACE"+H(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+H()}};function Z(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ee(e,t,r){var n;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error("Expected the enhancer to be a function.");return r(ee)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var o=e,i=t,u=[],a=u,c=!1;function f(){a===u&&(a=u.slice())}function l(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function s(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var t=!0;return f(),a.push(e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");t=!1,f();var r=a.indexOf(e);a.splice(r,1),u=null}}}function d(e){if(!Z(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!1}for(var t=u=a,r=0;r<t.length;r++)(0,t[r])();return e}function p(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");o=e,d({type:Q.REPLACE})}function y(){var e,t=s;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function r(){e.next&&e.next(l())}return r(),{unsubscribe:t(r)}}})[G]=function(){return this},e}return d({type:Q.INIT}),(n={dispatch:d,subscribe:s,getState:l,replaceReducer:p})[G]=y,n}function te(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+String(r)+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function re(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var o=t[n];"function"==typeof e[o]&&(r[o]=e[o])}var i,u=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(void 0===r(void 0,{type:Q.INIT}))throw new Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===r(void 0,{type:Q.PROBE_UNKNOWN_ACTION()}))throw new Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+Q.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(r)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var n=!1,o={},a=0;a<u.length;a++){var c=u[a],f=e[c],l=(0,r[c])(f,t);if(void 0===l){var s=te(c,t);throw new Error(s)}o[c]=l,n=n||l!==f}return(n=n||u.length!==Object.keys(e).length)?o:e}}function ne(e,t){return function(){return t(e.apply(this,arguments))}}function oe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ie(e,t){var r=Object.keys(e);return Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(e)),t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r}function ue(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ie(r,!0).forEach((function(t){oe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ie(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function ae(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function ce(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return ue({},r,{dispatch:n=ae.apply(void 0,i)(r.dispatch)})}}}function fe(e,t){return e===t}function le(e,t,r){if(null===t||null===r||t.length!==r.length)return!1;for(var n=t.length,o=0;o<n;o++)if(!e(t[o],r[o]))return!1;return!0}function se(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var r=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}var de=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=0,u=n.pop(),a=se(n),c=e.apply(void 0,[function(){return i++,u.apply(null,arguments)}].concat(r)),f=e((function(){for(var e=[],t=a.length,r=0;r<t;r++)e.push(a[r].apply(null,arguments));return c.apply(null,e)}));return f.resultFunc=u,f.dependencies=a,f.recomputations=function(){return i},f.resetRecomputations=function(){return i=0},f}}((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:fe,r=null,n=null;return function(){return le(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}})),pe=function(){var e=de.apply(void 0,arguments),t=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return e.apply(void 0,[r(t)?D(t):t].concat(o))};return t};function ye(){return(ye=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function ve(e){return(ve=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function be(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function ge(e,t,r){return(ge=be()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&he(o,r.prototype),o}).apply(null,arguments)}function me(e){var t="function"==typeof Map?new Map:void 0;return(me=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return ge(e,arguments,ve(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),he(r,e)})(e)}var Oe="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?ae:ae.apply(null,arguments)};function we(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function je(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(o){return"function"==typeof o?o(r,n,e):t(o)}}}}var Ae=je();Ae.withExtraArgument=je;var Pe=function(e){var t,r;function n(){return e.apply(this,arguments)||this}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var o=n.prototype;return o.concat=function(){for(var t,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return ge(n,(t=e.prototype.concat).call.apply(t,[this].concat(o)))},o.prepend=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])?ge(n,t[0].concat(this)):ge(n,t.concat(this))},n}(me(Array));function Se(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||we(e)}function Ee(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=new Pe;return r&&(function(e){return"boolean"==typeof e}(r)?n.push(Ae):n.push(Ae.withExtraArgument(r.extraArgument))),n}function xe(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw new Error("prepareAction did not return an object");return ye({type:e,payload:r.payload},"meta"in r&&{meta:r.meta},{},"error"in r&&{error:r.error})}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return r.toString=function(){return""+e},r.type=e,r.match=function(t){return t.type===e},r}function Ie(e){return["type","payload","error","meta"].indexOf(e)>-1}function _e(e){var t,r={},n=[],o={addCase:function(e,t){var n="string"==typeof e?e:e.type;if(n in r)throw new Error("addCase cannot be called with two reducers for the same action type");return r[n]=t,o},addMatcher:function(e,t){return n.push({matcher:e,reducer:t}),o},addDefaultCase:function(e){return t=e,o}};return e(o),[r,n,t]}function ke(e,t,o,i){void 0===o&&(o=[]);var u="function"==typeof t?_e(t):[t,o,i],a=u[0],c=u[1],f=u[2];return function(t,o){void 0===t&&(t=e);var i=[a[o.type]].concat(c.filter((function(e){return(0,e.matcher)(o)})).map((function(e){return e.reducer})));return 0===i.filter((function(e){return!!e})).length&&(i=[f]),i.reduce((function(e,t){if(t){if(r(e)){var i=t(e,o);return void 0===i?e:i}if(n(e))return $(e,(function(e){return t(e,o)}));var u=t(e,o);if(void 0===u){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return u}return e}),t)}}function Re(e){return function(t,n){var o=function(t){!function(e){return we(t=e)&&"string"==typeof t.type&&Object.keys(t).every(Ie);var t}(n)?e(n,t):e(n.payload,t)};return r(t)?(o(t),t):$(t,o)}}function De(e,t){return t(e)}function Ne(e){function t(t,r){var n=De(t,e);n in r.entities||(r.ids.push(n),r.entities[n]=t)}function r(e,r){Array.isArray(e)||(e=Object.values(e));var n=e,o=Array.isArray(n),i=0;for(n=o?n:n[Symbol.iterator]();;){var u;if(o){if(i>=n.length)break;u=n[i++]}else{if((i=n.next()).done)break;u=i.value}t(u,r)}}function n(e,t){var r=!1;e.forEach((function(e){e in t.entities&&(delete t.entities[e],r=!0)})),r&&(t.ids=t.ids.filter((function(e){return e in t.entities})))}function o(t,r){var n={},o={};t.forEach((function(e){e.id in r.entities&&(o[e.id]={id:e.id,changes:ye({},o[e.id]?o[e.id].changes:null,{},e.changes)})})),(t=Object.values(o)).length>0&&t.filter((function(t){return function(t,r,n){var o=Object.assign({},n.entities[r.id],r.changes),i=De(o,e),u=i!==r.id;return u&&(t[r.id]=i,delete n.entities[r.id]),n.entities[i]=o,u}(n,t,r)})).length>0&&(r.ids=r.ids.map((function(e){return n[e]||e})))}function i(t,n){Array.isArray(t)||(t=Object.values(t));var i=[],u=[],a=t,c=Array.isArray(a),f=0;for(a=c?a:a[Symbol.iterator]();;){var l;if(c){if(f>=a.length)break;l=a[f++]}else{if((f=a.next()).done)break;l=f.value}var s=l,d=De(s,e);d in n.entities?u.push({id:d,changes:s}):i.push(s)}o(u,n),r(i,n)}return{removeAll:(u=function(e){Object.assign(e,{ids:[],entities:{}})},a=Re((function(e,t){return u(t)})),function(e){return a(e,void 0)}),addOne:Re(t),addMany:Re(r),setAll:Re((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.ids=[],t.entities={},r(e,t)})),updateOne:Re((function(e,t){return o([e],t)})),updateMany:Re(o),upsertOne:Re((function(e,t){return i([e],t)})),upsertMany:Re(i),removeOne:Re((function(e,t){return n([e],t)})),removeMany:Re(n)};var u,a}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var Te=function(e){void 0===e&&(e=21);for(var t="",r=e;r--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t},Me=["name","message","stack","code"],Ce=function(e){this.payload=e,this.name="RejectWithValue",this.message="Rejected"},We=function(e){if("object"==typeof e&&null!==e){var t={},r=Me,n=Array.isArray(r),o=0;for(r=n?r:r[Symbol.iterator]();;){var i;if(n){if(o>=r.length)break;i=r[o++]}else{if((o=r.next()).done)break;i=o.value}"string"==typeof e[i]&&(t[i]=e[i])}return t}return{message:String(e)}},Fe=function(e,t){return function(e){return e&&"function"==typeof e.match}(e)?e.match(t):e(t)};function qe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.some((function(t){return Fe(t,e)}))}}function ze(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.every((function(t){return Fe(t,e)}))}}function Ke(e,t){if(!e||!e.meta)return!1;var r="string"==typeof e.meta.requestId,n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function Ue(e){return"function"==typeof e[0]&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function Ve(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return Ke(e,["rejected"])}:Ue(t)?function(e){var r=t.map((function(e){return e.rejected}));return qe.apply(void 0,r)(e)}:Ve()(t[0])}!function(){function e(e,t){var r=a[e];return r?r.enumerable=t:a[e]=r={configurable:!0,enumerable:t,get:function(){return X.get(this[U],e)},set:function(t){X.set(this[U],e,t)}},r}function t(e){for(var t=e.length-1;t>=0;t--){var r=e[t][U];if(!r.P)switch(r.i){case 5:i(r)&&_(r);break;case 4:n(r)&&_(r)}}}function n(e){for(var t=e.t,r=e.k,n=V(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==U){var a=t[i];if(void 0===a&&!u(t,i))return!0;var f=r[i],l=f&&f[U];if(l?l.t!==a:!c(f,a))return!0}}var s=!!t[U];return n.length!==V(t).length+(s?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var a={};!function(e,t){B.ES5||(B.ES5=t)}(0,{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,""+o,e(o,!0));return n}var i=L(r);delete i[U];for(var u=V(i),a=0;a<u.length;a++){var c=u[a];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:b(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,g:!1,C:!1};return Object.defineProperty(o,U,{value:i,writable:!0}),o},S:function(e,n,a){a?r(n)&&n[U].A===e&&t(e.p):(e.u&&function e(t){if(t&&"object"==typeof t){var r=t[U];if(r){var n=r.t,a=r.k,c=r.D,f=r.i;if(4===f)o(a,(function(t){t!==U&&(void 0!==n[t]||u(n,t)?c[t]||e(a[t]):(c[t]=!0,_(r)))})),o(n,(function(e){void 0!==a[e]||u(a,e)||(c[e]=!1,_(r))}));else if(5===f){if(i(r)&&(_(r),c.length=!0),a.length<n.length)for(var l=a.length;l<n.length;l++)c[l]=!1;else for(var s=n.length;s<a.length;s++)c[s]=!0;for(var d=Math.min(a.length,n.length),p=0;p<d;p++)void 0===c[p]&&e(a[p])}}}}(e.p[0]),t(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}(),e.MiddlewareArray=Pe,e.__DO_NOT_USE__ActionTypes=Q,e.applyMiddleware=ce,e.bindActionCreators=function(e,t){if("function"==typeof e)return ne(e,t);if("object"!=typeof e||null===e)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');var r={};for(var n in e){var o=e[n];"function"==typeof o&&(r[n]=ne(o,t))}return r},e.combineReducers=re,e.compose=ae,e.configureStore=function(e){var t,r=function(e){return Ee(e)},n=e||{},o=n.reducer,i=void 0===o?void 0:o,u=n.middleware,a=void 0===u?r():u,c=n.devTools,f=void 0===c||c,l=n.preloadedState,s=void 0===l?void 0:l,d=n.enhancers,p=void 0===d?void 0:d;if("function"==typeof i)t=i;else{if(!we(i))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=re(i)}var y=ce.apply(void 0,"function"==typeof a?a(r):a),v=ae;f&&(v=Oe(ye({trace:!1},"object"==typeof f&&f)));var h=[y];return Array.isArray(p)?h=[y].concat(p):"function"==typeof p&&(h=p(h)),ee(t,s,v.apply(void 0,h))},e.createAction=xe,e.createAsyncThunk=function(e,t,r){var n=xe(e+"/fulfilled",(function(e,t,r){return{payload:e,meta:{arg:r,requestId:t,requestStatus:"fulfilled"}}})),o=xe(e+"/pending",(function(e,t){return{payload:void 0,meta:{arg:t,requestId:e,requestStatus:"pending"}}})),i=xe(e+"/rejected",(function(e,t,n){var o=e instanceof Ce,i=!!e&&"AbortError"===e.name,u=!!e&&"ConditionError"===e.name;return{payload:e instanceof Ce?e.payload:void 0,error:(r&&r.serializeError||We)(e||"Rejected"),meta:{arg:n,requestId:t,rejectedWithValue:o,requestStatus:"rejected",aborted:i,condition:u}}})),u="undefined"!=typeof AbortController?AbortController:function(){function e(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){}}}return e.prototype.abort=function(){},e}();return Object.assign((function(e){return function(a,c,f){var l,s=Te(),d=new u,p=new Promise((function(e,t){return d.signal.addEventListener("abort",(function(){return t({name:"AbortError",message:l||"Aborted"})}))})),y=!1,v=function(){try{var u,l=function(e){return v?e:(r&&!r.dispatchConditionRejection&&i.match(u)&&u.meta.condition||a(u),u)},v=!1,h=function(l,v){try{var h=function(){if(r&&r.condition&&!1===r.condition(e,{getState:c,extra:f}))throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return y=!0,a(o(s,e)),Promise.resolve(Promise.race([p,Promise.resolve(t(e,{dispatch:a,getState:c,extra:f,requestId:s,signal:d.signal,rejectWithValue:function(e){return new Ce(e)}})).then((function(t){return t instanceof Ce?i(t,s,e):n(t,s,e)}))])).then((function(e){u=e}))}()}catch(e){return v(e)}return h&&h.then?h.then(void 0,v):h}(0,(function(t){u=i(t,s,e)}));return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}}();return Object.assign(v,{abort:function(e){y&&(l=e,d.abort())},requestId:s,arg:e})}}),{pending:o,rejected:i,fulfilled:n,typePrefix:e})},e.createDraftSafeSelector=pe,e.createEntityAdapter=function(e){void 0===e&&(e={});var t=ye({sortComparer:!1,selectId:function(e){return e.id}},e),r=t.selectId,n=t.sortComparer;return ye({selectId:r,sortComparer:n},{getInitialState:function(e){return void 0===e&&(e={}),Object.assign({ids:[],entities:{}},e)}},{},{getSelectors:function(e){var t=function(e){return e.ids},r=function(e){return e.entities},n=pe(t,r,(function(e,t){return e.map((function(e){return t[e]}))})),o=function(e,t){return t},i=function(e,t){return e[t]},u=pe(t,(function(e){return e.length}));if(!e)return{selectIds:t,selectEntities:r,selectAll:n,selectTotal:u,selectById:pe(r,o,i)};var a=pe(e,r);return{selectIds:pe(e,t),selectEntities:a,selectAll:pe(e,n),selectTotal:pe(e,u),selectById:pe(a,o,i)}}},{},n?function(e,t){var r=Ne(e);function n(t,r){Array.isArray(t)||(t=Object.values(t));var n=t.filter((function(t){return!(De(t,e)in r.entities)}));0!==n.length&&u(n,r)}function o(t,r){var n=[];t.forEach((function(t){return function(t,r,n){if(!(r.id in n.entities))return!1;var o=Object.assign({},n.entities[r.id],r.changes),i=De(o,e);return delete n.entities[r.id],t.push(o),i!==r.id}(n,t,r)})),0!==n.length&&u(n,r)}function i(t,r){Array.isArray(t)||(t=Object.values(t));var i=[],u=[],a=t,c=Array.isArray(a),f=0;for(a=c?a:a[Symbol.iterator]();;){var l;if(c){if(f>=a.length)break;l=a[f++]}else{if((f=a.next()).done)break;l=f.value}var s=l,d=De(s,e);d in r.entities?u.push({id:d,changes:s}):i.push(s)}o(u,r),n(i,r)}function u(r,n){r.sort(t),r.forEach((function(t){n.entities[e(t)]=t}));var o=Object.values(n.entities);o.sort(t);var i=o.map(e);(function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(e[r]!==t[r])return!1;return!0})(n.ids,i)||(n.ids=i)}return{removeOne:r.removeOne,removeMany:r.removeMany,removeAll:r.removeAll,addOne:Re((function(e,t){return n([e],t)})),updateOne:Re((function(e,t){return o([e],t)})),upsertOne:Re((function(e,t){return i([e],t)})),setAll:Re((function(e,t){Array.isArray(e)||(e=Object.values(e)),t.entities={},t.ids=[],n(e,t)})),addMany:Re(n),updateMany:Re(o),upsertMany:Re(i)}}(r,n):Ne(r))},e.createImmutableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},e.createNextState=$,e.createReducer=ke,e.createSelector=de,e.createSerializableStateInvariantMiddleware=function(e){return function(){return function(e){return function(t){return e(t)}}}},e.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var n=e.reducers||{},o=void 0===e.extraReducers?[]:"function"==typeof e.extraReducers?_e(e.extraReducers):[e.extraReducers],i=o[0],u=void 0===i?{}:i,a=o[1],c=void 0===a?[]:a,f=o[2],l=void 0===f?void 0:f,s=Object.keys(n),d={},p={},y={};s.forEach((function(e){var r,o,i=n[e],u=t+"/"+e;"reducer"in i?(r=i.reducer,o=i.prepare):r=i,d[e]=r,p[u]=r,y[e]=o?xe(u,o):xe(u)}));var v=ke(r,ye({},u,{},p),c,l);return{name:t,reducer:v,actions:y,caseReducers:d}},e.createStore=ee,e.current=D,e.findNonSerializableValue=function e(t,r,n,o,i){var u;if(void 0===r&&(r=[]),void 0===n&&(n=Se),void 0===i&&(i=[]),!n(t))return{keyPath:r.join(".")||"<root>",value:t};if("object"!=typeof t||null===t)return!1;var a=null!=o?o(t):Object.entries(t),c=i.length>0,f=a,l=Array.isArray(f),s=0;for(f=l?f:f[Symbol.iterator]();;){var d;if(l){if(s>=f.length)break;d=f[s++]}else{if((s=f.next()).done)break;d=s.value}var p=d[1],y=r.concat(d[0]);if(!(c&&i.indexOf(y.join("."))>=0)){if(!n(p))return{keyPath:y.join("."),value:p};if("object"==typeof p&&(u=e(p,y,n,o,i)))return u}}return!1},e.freeze=p,e.getDefaultMiddleware=Ee,e.getType=function(e){return""+e},e.isAllOf=ze,e.isAnyOf=qe,e.isAsyncThunkAction=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return 0===r.length?function(e){return Ke(e,["pending","fulfilled","rejected"])}:Ue(r)?function(e){var t=[],n=r,o=Array.isArray(n),i=0;for(n=o?n:n[Symbol.iterator]();;){var u;if(o){if(i>=n.length)break;u=n[i++]}else{if((i=n.next()).done)break;u=i.value}t.push(u.pending,u.rejected,u.fulfilled)}return qe.apply(void 0,t)(e)}:e()(r[0])},e.isFulfilled=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return 0===r.length?function(e){return Ke(e,["fulfilled"])}:Ue(r)?function(e){var t=r.map((function(e){return e.fulfilled}));return qe.apply(void 0,t)(e)}:e()(r[0])},e.isImmutableDefault=function(e){return"object"!=typeof e||null==e},e.isPending=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return 0===r.length?function(e){return Ke(e,["pending"])}:Ue(r)?function(e){var t=r.map((function(e){return e.pending}));return qe.apply(void 0,t)(e)}:e()(r[0])},e.isPlain=Se,e.isPlainObject=we,e.isRejected=Ve,e.isRejectedWithValue=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var o=function(e){return e&&e.meta&&e.meta.rejectedWithValue};return 0===r.length?function(e){return ze(Ve.apply(void 0,r),o)(e)}:Ue(r)?function(e){return ze(Ve.apply(void 0,r),o)(e)}:e()(r[0])},e.nanoid=Te,e.unwrapResult=function(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}}));
//# sourceMappingURL=redux-toolkit.umd.min.js.map
{
"name": "@reduxjs/toolkit",
"version": "1.4.0",
"version": "1.5.0",
"description": "The official, opinionated, batteries-included toolset for efficient Redux development",

@@ -31,2 +31,4 @@ "repository": "https://github.com/reduxjs/redux-toolkit",

"@types/node": "^10.14.4",
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"axios": "^0.19.2",

@@ -42,14 +44,15 @@ "console-testing-library": "^0.3.1",

"tslib": "^1.10.0",
"typescript": "^3.8.2",
"typescript": "^3.9.7",
"typings-tester": "^0.3.2"
},
"scripts": {
"build-ci": "tsdx build --format cjs,esm,umd --name redux-toolkit && api-extractor run",
"build": "tsdx build --format cjs,esm,umd --name redux-toolkit && api-extractor run --local",
"dev": "tsdx watch --format cjs,esm,umd",
"build-ci": "tsdx build --format cjs,esm,system,umd --name redux-toolkit && api-extractor run",
"build": "tsdx build --format cjs,esm,system,umd --name redux-toolkit && api-extractor run --local",
"dev": "tsdx watch --format cjs,esm,system,umd",
"format": "prettier --write \"src/**/*.ts\" \"**/*.md\"",
"format:check": "prettier --list-different \"src/**/*.ts\" \"docs/*/**.md\"",
"lint": "tsdx lint src",
"prepare": "npm run lint && npm run format:check && npm test && npm run build-ci",
"test": "tsdx test"
"prepare": "npm run lint && npm run format:check && npm test && npm run type-tests && npm run build-ci",
"test": "tsdx test",
"type-tests": "cd type-tests/files && tsc"
},

@@ -63,3 +66,3 @@ "files": [

"dependencies": {
"immer": "^7.0.3",
"immer": "^8.0.0",
"redux": "^4.0.0",

@@ -66,0 +69,0 @@ "redux-thunk": "^2.3.0",

@@ -108,3 +108,3 @@ import {

/**
* The `dispatch` method of your store, enhanced by all it's middlewares.
* The `dispatch` method of your store, enhanced by all its middlewares.
*

@@ -177,7 +177,3 @@ * @inheritdoc

return createStore(
rootReducer,
preloadedState as DeepPartial<S>,
composedEnhancer
)
return createStore(rootReducer, preloadedState as any, composedEnhancer)
}

@@ -232,3 +232,3 @@ import { Action } from 'redux'

* @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }.
* If this is given, the resulting action creator will pass it's arguments to this method to calculate payload & meta.
* If this is given, the resulting action creator will pass its arguments to this method to calculate payload & meta.
*

@@ -250,3 +250,3 @@ * @public

* @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }.
* If this is given, the resulting action creator will pass it's arguments to this method to calculate payload & meta.
* If this is given, the resulting action creator will pass its arguments to this method to calculate payload & meta.
*

@@ -253,0 +253,0 @@ * @public

@@ -77,4 +77,9 @@ import {

await thunkFunction(dispatch, () => {}, undefined)
const thunkPromise = thunkFunction(dispatch, () => {}, undefined)
expect(thunkPromise.requestId).toBe(generatedRequestId)
expect(thunkPromise.arg).toBe(args)
await thunkPromise
expect(passedArg).toBe(args)

@@ -359,4 +364,5 @@

},
meta: { aborted: true }
meta: { aborted: true, requestId: promise.requestId }
}
// abortedAction with reason is dispatched after test/pending is dispatched

@@ -440,3 +446,3 @@ expect(store.getState()).toMatchObject([

keepAbortController = window.AbortController
delete window.AbortController
delete (window as any).AbortController
jest.resetModules()

@@ -587,4 +593,6 @@ freshlyLoadedModule = require('./createAsyncThunk')

arg: arg,
rejectedWithValue: false,
condition: true,
requestId: expect.stringContaining('')
requestId: expect.stringContaining(''),
requestStatus: 'rejected'
},

@@ -596,2 +604,72 @@ payload: undefined,

})
test('serializeError implementation', async () => {
function serializeError() {
return 'serialized!'
}
const errorObject = 'something else!'
const store = configureStore({
reducer: (state = [], action) => [...state, action]
})
const asyncThunk = createAsyncThunk<
unknown,
void,
{ serializedErrorType: string }
>('test', () => Promise.reject(errorObject), { serializeError })
const rejected = await store.dispatch(asyncThunk())
if (!asyncThunk.rejected.match(rejected)) {
throw new Error()
}
const expectation = {
type: 'test/rejected',
payload: undefined,
error: 'serialized!',
meta: expect.any(Object)
}
expect(rejected).toEqual(expectation)
expect(store.getState()[2]).toEqual(expectation)
expect(rejected.error).not.toEqual(miniSerializeError(errorObject))
})
})
describe('unwrapResult', () => {
const getState = jest.fn(() => ({}))
const dispatch = jest.fn((x: any) => x)
const extra = {}
test('fulfilled case', async () => {
const asyncThunk = createAsyncThunk('test', () => {
return 'fulfilled!'
})
const unwrapPromise = asyncThunk()(dispatch, getState, extra).then(
unwrapResult
)
await expect(unwrapPromise).resolves.toBe('fulfilled!')
})
test('error case', async () => {
const error = new Error('Panic!')
const asyncThunk = createAsyncThunk('test', () => {
throw error
})
const unwrapPromise = asyncThunk()(dispatch, getState, extra).then(
unwrapResult
)
await expect(unwrapPromise).rejects.toEqual(miniSerializeError(error))
})
test('rejectWithValue case', async () => {
const asyncThunk = createAsyncThunk('test', (_, { rejectWithValue }) => {
return rejectWithValue('rejectWithValue!')
})
const unwrapPromise = asyncThunk()(dispatch, getState, extra).then(
unwrapResult
)
await expect(unwrapPromise).rejects.toBe('rejectWithValue!')
})
})

@@ -46,3 +46,5 @@ import { Dispatch, AnyAction } from 'redux'

class RejectWithValue<RejectValue> {
constructor(public readonly value: RejectValue) {}
public name = 'RejectWithValue'
public message = 'Rejected'
constructor(public readonly payload: RejectValue) {}
}

@@ -71,2 +73,3 @@

rejectValue?: unknown
serializedErrorType?: unknown
}

@@ -107,2 +110,9 @@

: unknown
type GetSerializedErrorType<ThunkApiConfig> = ThunkApiConfig extends {
serializedErrorType: infer GetSerializedErrorType
}
? GetSerializedErrorType
: SerializedError
/**

@@ -154,16 +164,8 @@ * A type describing the return value of the `payloadCreator` argument to `createAsyncThunk`.

) => Promise<
| PayloadAction<Returned, string, { arg: ThunkArg; requestId: string }>
| PayloadAction<
undefined | GetRejectValue<ThunkApiConfig>,
string,
{
arg: ThunkArg
requestId: string
aborted: boolean
condition: boolean
},
SerializedError
>
| ReturnType<AsyncThunkFulfilledActionCreator<Returned, ThunkArg>>
| ReturnType<AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>>
> & {
abort(reason?: string): void
requestId: string
arg: ThunkArg
}

@@ -220,5 +222,7 @@

dispatchConditionRejection?: boolean
serializeError?: (x: unknown) => GetSerializedErrorType<ThunkApiConfig>
}
type AsyncThunkPendingActionCreator<
export type AsyncThunkPendingActionCreator<
ThunkArg

@@ -233,21 +237,19 @@ > = ActionCreatorWithPreparedPayload<

requestId: string
requestStatus: 'pending'
}
>
type AsyncThunkRejectedActionCreator<
export type AsyncThunkRejectedActionCreator<
ThunkArg,
ThunkApiConfig
> = ActionCreatorWithPreparedPayload<
[
Error | null,
string,
ThunkArg,
(GetRejectValue<ThunkApiConfig> | undefined)?
],
[Error | null, string, ThunkArg],
GetRejectValue<ThunkApiConfig> | undefined,
string,
SerializedError,
GetSerializedErrorType<ThunkApiConfig>,
{
arg: ThunkArg
requestId: string
rejectedWithValue: boolean
requestStatus: 'rejected'
aborted: boolean

@@ -258,3 +260,3 @@ condition: boolean

type AsyncThunkFulfilledActionCreator<
export type AsyncThunkFulfilledActionCreator<
Returned,

@@ -270,2 +272,3 @@ ThunkArg

requestId: string
requestStatus: 'fulfilled'
}

@@ -315,3 +318,7 @@ >

payload: result,
meta: { arg, requestId }
meta: {
arg,
requestId,
requestStatus: 'fulfilled' as const
}
}

@@ -326,3 +333,7 @@ }

payload: undefined,
meta: { arg, requestId }
meta: {
arg,
requestId,
requestStatus: 'pending' as const
}
}

@@ -334,16 +345,17 @@ }

typePrefix + '/rejected',
(
error: Error | null,
requestId: string,
arg: ThunkArg,
payload?: RejectedValue
) => {
(error: Error | null, requestId: string, arg: ThunkArg) => {
const rejectedWithValue = error instanceof RejectWithValue
const aborted = !!error && error.name === 'AbortError'
const condition = !!error && error.name === 'ConditionError'
return {
payload,
error: miniSerializeError(error || 'Rejected'),
payload: error instanceof RejectWithValue ? error.payload : undefined,
error: ((options && options.serializeError) || miniSerializeError)(
error || 'Rejected'
) as GetSerializedErrorType<ThunkApiConfig>,
meta: {
arg,
requestId,
rejectedWithValue,
requestStatus: 'rejected' as const,
aborted,

@@ -438,3 +450,3 @@ condition

if (result instanceof RejectWithValue) {
return rejected(null, requestId, arg, result.value)
return rejected(result, requestId, arg)
}

@@ -463,3 +475,3 @@ return fulfilled(result, requestId, arg)

})()
return Object.assign(promise, { abort })
return Object.assign(promise, { abort, requestId, arg })
}

@@ -483,21 +495,26 @@ }

type ActionTypesWithOptionalErrorAction =
| { error: any }
| { error?: never; payload: any }
type PayloadForActionTypesExcludingErrorActions<T> = T extends { error: any }
? never
: T extends { payload: infer P }
? P
: never
interface UnwrappableAction {
payload: any
meta?: any
error?: any
}
type UnwrappedActionPayload<T extends UnwrappableAction> = Exclude<
T,
{ error: any }
>['payload']
/**
* @public
*/
export function unwrapResult<R extends ActionTypesWithOptionalErrorAction>(
returned: R
): PayloadForActionTypesExcludingErrorActions<R> {
if ('error' in returned) {
throw returned.error
export function unwrapResult<R extends UnwrappableAction>(
action: R
): UnwrappedActionPayload<R> {
if (action.meta && action.meta.rejectedWithValue) {
throw action.payload
}
return (returned as any).payload
if (action.error) {
throw action.error
}
return action.payload
}

@@ -504,0 +521,0 @@

@@ -53,2 +53,44 @@ import { createReducer, CaseReducer } from './createReducer'

describe('Immer in a production environment', () => {
let originalNodeEnv = process.env.NODE_ENV
beforeEach(() => {
jest.resetModules()
process.env.NODE_ENV = 'production'
})
afterEach(() => {
process.env.NODE_ENV = originalNodeEnv
})
test('Freezes data in production', () => {
const { createReducer } = require('./createReducer')
const addTodo: AddTodoReducer = (state, action) => {
const { newTodo } = action.payload
state.push({ ...newTodo, completed: false })
}
const toggleTodo: ToggleTodoReducer = (state, action) => {
const { index } = action.payload
const todo = state[index]
todo.completed = !todo.completed
}
const todosReducer = createReducer([] as TodoState, {
ADD_TODO: addTodo,
TOGGLE_TODO: toggleTodo
})
const result = todosReducer([], {
type: 'ADD_TODO',
payload: { text: 'Buy milk' }
})
const mutateStateOutsideReducer = () => (result[0].text = 'edited')
expect(mutateStateOutsideReducer).toThrowError(
'Cannot add property text, object is not extensible'
)
})
})
describe('given pure reducers with immutable updates', () => {

@@ -278,2 +320,16 @@ const addTodo: AddTodoReducer = (state, action) => {

})
test('allows you to return undefined if the state was null, thus skipping an update', () => {
const reducer = createReducer(null as number | null, builder =>
builder.addCase(
'decrement',
(state, action: { type: 'decrement'; payload: number }) => {
if (typeof state === 'number') {
return state - action.payload
}
}
)
)
expect(reducer(0, decrement(5))).toBe(-5)
expect(reducer(null, decrement(5))).toBe(null)
})
test('allows you to return null', () => {

@@ -280,0 +336,0 @@ const reducer = createReducer(0 as number | null, builder =>

@@ -51,3 +51,3 @@ import createNextState, { Draft, isDraft, isDraftable } from 'immer'

action: A
) => S | void
) => S | void | Draft<S>

@@ -72,2 +72,3 @@ /**

*
* @remarks
* The body of every case reducer is implicitly wrapped with a call to

@@ -80,21 +81,58 @@ * `produce()` from the [immer](https://github.com/mweststrate/immer) library.

*
* @param initialState The initial state to be returned by the reducer.
* @param actionsMap A mapping from action types to action-type-specific
* case reducers.
* @param actionMatchers An array of matcher definitions in the form `{matcher, reducer}`.
* All matching reducers will be executed in order, independently if a case reducer matched or not.
* @param defaultCaseReducer A "default case" reducer that is executed if no case reducer and no matcher
* reducer was executed for this action.
* @overloadSummary
* This overload accepts a callback function that receives a `builder` object as its argument.
* That builder provides `addCase`, `addMatcher` and `addDefaultCase` functions that may be
* called to define what actions this reducer will handle.
*
* @param initialState - The initial state that should be used when the reducer is called the first time.
* @param builderCallback - A callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
* @example
```ts
import {
createAction,
createReducer,
AnyAction,
PayloadAction,
} from "@reduxjs/toolkit";
const increment = createAction<number>("increment");
const decrement = createAction<number>("decrement");
function isActionWithNumberPayload(
action: AnyAction
): action is PayloadAction<number> {
return typeof action.payload === "number";
}
createReducer(
{
counter: 0,
sumOfNumberPayloads: 0,
unhandledActions: 0,
},
(builder) => {
builder
.addCase(increment, (state, action) => {
// action is inferred correctly here
state.counter += action.payload;
})
// You can chain calls, or have separate `builder.addCase()` lines each time
.addCase(decrement, (state, action) => {
state.counter -= action.payload;
})
// You can apply a "matcher function" to incoming actions
.addMatcher(isActionWithNumberPayload, (state, action) => {})
// and provide a default case if no other handlers matched
.addDefaultCase((state, action) => {});
}
);
```
* @public
*/
export function createReducer<
S,
CR extends CaseReducers<S, any> = CaseReducers<S, any>
>(
export function createReducer<S>(
initialState: S,
actionsMap: CR,
actionMatchers?: ActionMatcherDescriptionCollection<S>,
defaultCaseReducer?: CaseReducer<S>
builderCallback: (builder: ActionReducerMapBuilder<S>) => void
): Reducer<S>
/**

@@ -111,11 +149,43 @@ * A utility function that allows defining a reducer as a mapping from action

* convenience and immutability.
* @param initialState The initial state to be returned by the reducer.
* @param builderCallback A callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
*
* @overloadSummary
* This overload accepts an object where the keys are string action types, and the values
* are case reducer functions to handle those action types.
*
* @param initialState - The initial state that should be used when the reducer is called the first time.
* @param actionsMap - An object mapping from action types to _case reducers_, each of which handles one specific action type.
* @param actionMatchers - An array of matcher definitions in the form `{matcher, reducer}`.
* All matching reducers will be executed in order, independently if a case reducer matched or not.
* @param defaultCaseReducer - A "default case" reducer that is executed if no case reducer and no matcher
* reducer was executed for this action.
*
* @example
```js
const counterReducer = createReducer(0, {
increment: (state, action) => state + action.payload,
decrement: (state, action) => state - action.payload
})
```
* Action creators that were generated using [`createAction`](./createAction) may be used directly as the keys here, using computed property syntax:
```js
const increment = createAction('increment')
const decrement = createAction('decrement')
const counterReducer = createReducer(0, {
[increment]: (state, action) => state + action.payload,
[decrement.type]: (state, action) => state - action.payload
})
```
* @public
*/
export function createReducer<S>(
export function createReducer<
S,
CR extends CaseReducers<S, any> = CaseReducers<S, any>
>(
initialState: S,
builderCallback: (builder: ActionReducerMapBuilder<S>) => void
actionsMap: CR,
actionMatchers?: ActionMatcherDescriptionCollection<S>,
defaultCaseReducer?: CaseReducer<S>
): Reducer<S>

@@ -160,3 +230,3 @@

return result
return result as S
} else if (!isDraftable(previousState)) {

@@ -168,2 +238,5 @@ // If state is not draftable (ex: a primitive, such as 0), we want to directly

if (typeof result === 'undefined') {
if (previousState === null) {
return previousState
}
throw Error(

@@ -174,3 +247,3 @@ 'A case reducer on a non-draftable value must not return undefined'

return result
return result as S
} else {

@@ -177,0 +250,0 @@ // @ts-ignore createNextState() produces an Immutable<Draft<S>> rather

@@ -15,3 +15,3 @@ import { Reducer } from 'redux'

} from './mapBuilders'
import { Omit, NoInfer } from './tsHelpers'
import { NoInfer } from './tsHelpers'

@@ -88,7 +88,45 @@ /**

/**
* A mapping from action types to action-type-specific *case reducer*
* A callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
*
* Alternatively, a mapping from action types to action-type-specific *case reducer*
* functions. These reducers should have existing action types used
* as the keys, and action creators will _not_ be generated.
* Alternatively, a callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
*
* @example
```ts
import { createAction, createSlice, Action, AnyAction } from '@reduxjs/toolkit'
const incrementBy = createAction<number>('incrementBy')
const decrement = createAction('decrement')
interface RejectedAction extends Action {
error: Error
}
function isRejectedAction(action: AnyAction): action is RejectedAction {
return action.type.endsWith('rejected')
}
createSlice({
name: 'counter',
initialState: 0,
reducers: {},
extraReducers: builder => {
builder
.addCase(incrementBy, (state, action) => {
// action is inferred correctly here if using TS
})
// You can chain calls, or have separate `builder.addCase()` lines each time
.addCase(decrement, (state, action) => {})
// You can match a range of action types
.addMatcher(
isRejectedAction,
// `action` will be inferred as a RejectedAction due to isRejectedAction being defined as a type guard
(state, action) => {}
)
// and provide a default case if no other handlers matched
.addDefaultCase((state, action) => {})
}
})
```
*/

@@ -95,0 +133,0 @@ extraReducers?:

@@ -31,9 +31,3 @@ import { Action, ActionCreator, StoreEnhancer, compose } from 'redux'

/**
* - `undefined` - will use regular `JSON.stringify` to send data (it's the fast mode).
* - `false` - will handle also circular references.
* - `true` - will handle also date, regex, undefined, error objects, symbols, maps, sets and functions.
* - object, which contains `date`, `regex`, `undefined`, `error`, `symbol`, `map`, `set` and `function` keys.
* For each of them you can indicate if to include (by setting as `true`).
* For `function` key you can also specify a custom function which handles serialization.
* See [`jsan`](https://github.com/kolodny/jsan) for more details.
* See detailed documentation at http://extension.remotedev.io/docs/API/Arguments.html#serialize
*/

@@ -43,10 +37,18 @@ serialize?:

| {
date?: boolean
regex?: boolean
undefined?: boolean
error?: boolean
symbol?: boolean
map?: boolean
set?: boolean
function?: boolean | Function
options?:
| boolean
| {
date?: boolean
regex?: boolean
undefined?: boolean
error?: boolean
symbol?: boolean
map?: boolean
set?: boolean
function?: boolean | Function
}
replacer?: (key: string, value: unknown) => unknown
reviver?: (key: string, value: unknown) => unknown
immutable?: unknown
refs?: unknown[]
}

@@ -53,0 +55,0 @@ /**

@@ -420,2 +420,28 @@ import { EntityStateAdapter, EntityState } from './models'

it('should do nothing when upsertMany is given an empty array', () => {
const withMany = adapter.setAll(state, [TheGreatGatsby])
const withUpserts = adapter.upsertMany(withMany, [])
expect(withUpserts).toEqual({
ids: [TheGreatGatsby.id],
entities: {
[TheGreatGatsby.id]: TheGreatGatsby
}
})
})
it('should throw when upsertMany is passed undefined or null', async () => {
const withMany = adapter.setAll(state, [TheGreatGatsby])
const fakeRequest = (response: null | undefined) =>
new Promise(resolve => setTimeout(() => resolve(response), 50))
const undefinedBooks = (await fakeRequest(undefined)) as BookModel[]
expect(() => adapter.upsertMany(withMany, undefinedBooks)).toThrow()
const nullBooks = (await fakeRequest(null)) as BookModel[]
expect(() => adapter.upsertMany(withMany, nullBooks)).toThrow()
})
it('should let you upsert many entities in the state when passing in a dictionary', () => {

@@ -422,0 +448,0 @@ const firstChange = { title: 'Zack' }

@@ -103,6 +103,5 @@ import { createEntityAdapter, EntityAdapter, EntityState } from './index'

it('should type single entity from Dictionary as entity type or undefined', () => {
const singleEntity: Selector<
EntityState<BookModel>,
BookModel | undefined
> = createSelector(selectors.selectEntities, entities => entities[0])
expectType<Selector<EntityState<BookModel>, BookModel | undefined>>(
createSelector(selectors.selectEntities, entities => entities[0])
)
})

@@ -130,1 +129,5 @@

})
function expectType<T>(t: T) {
return t
}

@@ -1,2 +0,2 @@

import { createSelector } from 'reselect'
import { createDraftSafeSelector } from '../createDraftSafeSelector'
import { EntityState, EntitySelectors, Dictionary, EntityId } from './models'

@@ -16,3 +16,3 @@

const selectAll = createSelector(
const selectAll = createDraftSafeSelector(
selectIds,

@@ -28,3 +28,3 @@ selectEntities,

const selectTotal = createSelector(selectIds, ids => ids.length)
const selectTotal = createDraftSafeSelector(selectIds, ids => ids.length)

@@ -37,14 +37,25 @@ if (!selectState) {

selectTotal,
selectById: createSelector(selectEntities, selectId, selectById)
selectById: createDraftSafeSelector(
selectEntities,
selectId,
selectById
)
}
}
const selectGlobalizedEntities = createSelector(selectState, selectEntities)
const selectGlobalizedEntities = createDraftSafeSelector(
selectState,
selectEntities
)
return {
selectIds: createSelector(selectState, selectIds),
selectIds: createDraftSafeSelector(selectState, selectIds),
selectEntities: selectGlobalizedEntities,
selectAll: createSelector(selectState, selectAll),
selectTotal: createSelector(selectState, selectTotal),
selectById: createSelector(selectGlobalizedEntities, selectId, selectById)
selectAll: createDraftSafeSelector(selectState, selectAll),
selectTotal: createDraftSafeSelector(selectState, selectTotal),
selectById: createDraftSafeSelector(
selectGlobalizedEntities,
selectId,
selectById
)
}

@@ -51,0 +62,0 @@ }

@@ -129,3 +129,3 @@ import { EntityStateAdapter, EntityState } from './models'

const withoutOne = adapter.removeOne(state, TheGreatGatsby.id)
const withoutOne = adapter.removeOne(withOneEntity, TheGreatGatsby.id)

@@ -132,0 +132,0 @@ expect(withoutOne).toEqual({

@@ -20,3 +20,3 @@ import { selectIdValue } from './utils'

const key = selectIdValue(AClockworkOrange, book => book.id)
selectIdValue(AClockworkOrange, book => book.id)

@@ -29,3 +29,3 @@ expect(spy).not.toHaveBeenCalled()

const key = selectIdValue(AClockworkOrange, (book: any) => book.foo)
selectIdValue(AClockworkOrange, (book: any) => book.foo)

@@ -39,6 +39,3 @@ expect(spy).toHaveBeenCalled()

const undefinedAClockworkOrange = { ...AClockworkOrange, id: undefined }
const key = selectIdValue(
undefinedAClockworkOrange,
(book: any) => book.id
)
selectIdValue(undefinedAClockworkOrange, (book: any) => book.id)

@@ -52,3 +49,3 @@ expect(spy).toHaveBeenCalled()

const key = selectIdValue(AClockworkOrange, (book: any) => book.foo)
selectIdValue(AClockworkOrange, (book: any) => book.foo)

@@ -63,6 +60,3 @@ expect(spy).not.toHaveBeenCalled()

const undefinedAClockworkOrange = { ...AClockworkOrange, id: undefined }
const key = selectIdValue(
undefinedAClockworkOrange,
(book: any) => book.id
)
selectIdValue(undefinedAClockworkOrange, (book: any) => book.id)

@@ -69,0 +63,0 @@ expect(spy).not.toHaveBeenCalled()

import { enableES5 } from 'immer'
export * from 'redux'
export { default as createNextState, Draft, current } from 'immer'
// @ts-ignore
export { default as createNextState, Draft, current, freeze } from 'immer'
export {

@@ -11,2 +12,3 @@ createSelector,

} from 'reselect'
export { createDraftSafeSelector } from './createDraftSafeSelector'
export { ThunkAction, ThunkDispatch } from 'redux-thunk'

@@ -110,2 +112,18 @@

export {
// js
isAllOf,
isAnyOf,
isPending,
isRejected,
isFulfilled,
isAsyncThunkAction,
isRejectedWithValue,
// types
ActionMatchingAllOf,
ActionMatchingAnyOf
} from './matchers'
export { nanoid } from './nanoid'
export { default as isPlainObject } from './isPlainObject'

@@ -8,2 +8,4 @@ /**

* @returns {boolean} True if the argument appears to be a plain object.
*
* @public
*/

@@ -10,0 +12,0 @@ export default function isPlainObject(value: unknown): value is object {

@@ -21,5 +21,7 @@ import { Action, AnyAction } from 'redux'

/**
* Add a case reducer for actions created by this action creator.
* @param actionCreator
* @param reducer
* Adds a case reducer to handle a single exact action type.
* @remarks
* All calls to `builder.addCase` must come before any calls to `builder.addMatcher` or `builder.addDefaultCase`.
* @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type.
* @param reducer - The actual case reducer function.
*/

@@ -31,5 +33,7 @@ addCase<ActionCreator extends TypedActionCreator<string>>(

/**
* Add a case reducer for actions with the specified type.
* @param type
* @param reducer
* Adds a case reducer to handle a single exact action type.
* @remarks
* All calls to `builder.addCase` must come before any calls to `builder.addMatcher` or `builder.addDefaultCase`.
* @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type.
* @param reducer - The actual case reducer function.
*/

@@ -42,11 +46,59 @@ addCase<Type extends string, A extends Action<Type>>(

/**
* Adds a reducer for all actions, using `matcher` as a filter function.
* Allows you to match your incoming actions against your own filter function instead of only the `action.type` property.
* @remarks
* If multiple matcher reducers match, all of them will be executed in the order
* they were defined if - even if a case reducer already matched.
* @param matcher A matcher function. In TypeScript, this should be a [type predicate](https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates)
* they were defined in - even if a case reducer already matched.
* All calls to `builder.addMatcher` must come after any calls to `builder.addCase` and before any calls to `builder.addDefaultCase`.
* @param matcher - A matcher function. In TypeScript, this should be a [type predicate](https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates)
* function
* @param reducer
* @param reducer - The actual case reducer function.
*
* @example
```ts
import {
createAction,
createReducer,
AsyncThunk,
AnyAction,
} from "@reduxjs/toolkit";
type GenericAsyncThunk = AsyncThunk<unknown, unknown, any>;
type PendingAction = ReturnType<GenericAsyncThunk["pending"]>;
type RejectedAction = ReturnType<GenericAsyncThunk["rejected"]>;
type FulfilledAction = ReturnType<GenericAsyncThunk["fulfilled"]>;
const initialState: Record<string, string> = {};
const resetAction = createAction("reset-tracked-loading-state");
function isPendingAction(action: AnyAction): action is PendingAction {
return action.type.endsWith("/pending");
}
const reducer = createReducer(initialState, (builder) => {
builder
.addCase(resetAction, () => initialState)
// matcher can be defined outside as a type predicate function
.addMatcher(isPendingAction, (state, action) => {
state[action.meta.requestId] = "pending";
})
.addMatcher(
// matcher can be defined inline as a type predicate function
(action): action is RejectedAction => action.type.endsWith("/rejected"),
(state, action) => {
state[action.meta.requestId] = "rejected";
}
)
// matcher can just return boolean and the matcher can receive a generic argument
.addMatcher<FulfilledAction>(
(action) => action.type.endsWith("/fulfilled"),
(state, action) => {
state[action.meta.requestId] = "fulfilled";
}
);
});
```
*/
addMatcher<A extends AnyAction>(
matcher: ActionMatcher<A>,
matcher: ActionMatcher<A> | ((action: AnyAction) => boolean),
reducer: CaseReducer<State, A>

@@ -58,3 +110,17 @@ ): Omit<ActionReducerMapBuilder<State>, 'addCase'>

* reducer was executed for this action.
* @param reducer
* @param reducer - The fallback "default case" reducer function.
*
* @example
```ts
import { createReducer } from '@reduxjs/toolkit'
const initialState = { otherActions: 0 }
const reducer = createReducer(initialState, builder => {
builder
// .addCase(...)
// .addMatcher(...)
.addDefaultCase((state, action) => {
state.otherActions++
})
})
```
*/

@@ -61,0 +127,0 @@ addDefaultCase(reducer: CaseReducer<State, AnyAction>): {}

@@ -87,3 +87,3 @@ import { Middleware } from 'redux'

*/
type UnionToIntersection<U> = (U extends any
export type UnionToIntersection<U> = (U extends any
? (k: U) => void

@@ -104,1 +104,21 @@ : never) extends (k: infer I) => void

export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>
export interface HasMatchFunction<T> {
match(v: any): v is T
}
export const hasMatchFunction = <T>(
v: Matcher<T>
): v is HasMatchFunction<T> => {
return v && typeof (v as HasMatchFunction<T>).match === 'function'
}
/** @public */
export type Matcher<T> = HasMatchFunction<T> | ((v: any) => v is T)
/** @public */
export type ActionFromMatcher<M extends Matcher<any>> = M extends Matcher<
infer T
>
? T
: never

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc