UNPKG

57.8 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = function (d, b) {
3 extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6 return extendStatics(d, b);
7 };
8 return function (d, b) {
9 if (typeof b !== "function" && b !== null)
10 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11 extendStatics(d, b);
12 function __() { this.constructor = d; }
13 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14 };
15})();
16var __generator = (this && this.__generator) || function (thisArg, body) {
17 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
18 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
19 function verb(n) { return function (v) { return step([n, v]); }; }
20 function step(op) {
21 if (f) throw new TypeError("Generator is already executing.");
22 while (_) try {
23 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
24 if (y = 0, t) op = [op[0] & 2, t.value];
25 switch (op[0]) {
26 case 0: case 1: t = op; break;
27 case 4: _.label++; return { value: op[1], done: false };
28 case 5: _.label++; y = op[1]; op = [0]; continue;
29 case 7: op = _.ops.pop(); _.trys.pop(); continue;
30 default:
31 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
32 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
33 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
34 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
35 if (t[2]) _.ops.pop();
36 _.trys.pop(); continue;
37 }
38 op = body.call(thisArg, _);
39 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
40 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
41 }
42};
43var __spreadArray = (this && this.__spreadArray) || function (to, from) {
44 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
45 to[j] = from[i];
46 return to;
47};
48var __defProp = Object.defineProperty;
49var __hasOwnProp = Object.prototype.hasOwnProperty;
50var __getOwnPropSymbols = Object.getOwnPropertySymbols;
51var __propIsEnum = Object.prototype.propertyIsEnumerable;
52var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
53var __objSpread = function (a, b) {
54 for (var prop in b || (b = {}))
55 if (__hasOwnProp.call(b, prop))
56 __defNormalProp(a, prop, b[prop]);
57 if (__getOwnPropSymbols)
58 for (var _i = 0, _b = __getOwnPropSymbols(b); _i < _b.length; _i++) {
59 var prop = _b[_i];
60 if (__propIsEnum.call(b, prop))
61 __defNormalProp(a, prop, b[prop]);
62 }
63 return a;
64};
65var __async = function (__this, __arguments, generator) {
66 return new Promise(function (resolve, reject) {
67 var fulfilled = function (value) {
68 try {
69 step(generator.next(value));
70 }
71 catch (e) {
72 reject(e);
73 }
74 };
75 var rejected = function (value) {
76 try {
77 step(generator.throw(value));
78 }
79 catch (e) {
80 reject(e);
81 }
82 };
83 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
84 step((generator = generator.apply(__this, __arguments)).next());
85 });
86};
87// src/index.ts
88export * from "redux";
89import { default as default2, current as current2, freeze, original, isDraft as isDraft4 } from "immer";
90import { createSelector as createSelector2 } from "reselect";
91// src/createDraftSafeSelector.ts
92import { current, isDraft } from "immer";
93import { createSelector } from "reselect";
94var createDraftSafeSelector = function () {
95 var args = [];
96 for (var _i = 0; _i < arguments.length; _i++) {
97 args[_i] = arguments[_i];
98 }
99 var selector = createSelector.apply(void 0, args);
100 var wrappedSelector = function (value) {
101 var rest = [];
102 for (var _i = 1; _i < arguments.length; _i++) {
103 rest[_i - 1] = arguments[_i];
104 }
105 return selector.apply(void 0, __spreadArray([isDraft(value) ? current(value) : value], rest));
106 };
107 return wrappedSelector;
108};
109// src/configureStore.ts
110import { createStore, compose as compose2, applyMiddleware, combineReducers } from "redux";
111// src/devtoolsExtension.ts
112import { compose } from "redux";
113var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
114 if (arguments.length === 0)
115 return void 0;
116 if (typeof arguments[0] === "object")
117 return compose;
118 return compose.apply(null, arguments);
119};
120var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
121 return function (noop) {
122 return noop;
123 };
124};
125// src/isPlainObject.ts
126function isPlainObject(value) {
127 if (typeof value !== "object" || value === null)
128 return false;
129 var proto = value;
130 while (Object.getPrototypeOf(proto) !== null) {
131 proto = Object.getPrototypeOf(proto);
132 }
133 return Object.getPrototypeOf(value) === proto;
134}
135// src/getDefaultMiddleware.ts
136import thunkMiddleware from "redux-thunk";
137// src/utils.ts
138function getTimeMeasureUtils(maxDelay, fnName) {
139 var elapsed = 0;
140 return {
141 measureTime: function (fn) {
142 var started = Date.now();
143 try {
144 return fn();
145 }
146 finally {
147 var finished = Date.now();
148 elapsed += finished - started;
149 }
150 },
151 warnIfExceeded: function () {
152 if (elapsed > maxDelay) {
153 console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
154 }
155 }
156 };
157}
158var MiddlewareArray = /** @class */ (function (_super) {
159 __extends(MiddlewareArray, _super);
160 function MiddlewareArray() {
161 var args = [];
162 for (var _i = 0; _i < arguments.length; _i++) {
163 args[_i] = arguments[_i];
164 }
165 var _this = _super.apply(this, args) || this;
166 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
167 return _this;
168 }
169 Object.defineProperty(MiddlewareArray, Symbol.species, {
170 get: function () {
171 return MiddlewareArray;
172 },
173 enumerable: false,
174 configurable: true
175 });
176 MiddlewareArray.prototype.concat = function () {
177 var arr = [];
178 for (var _i = 0; _i < arguments.length; _i++) {
179 arr[_i] = arguments[_i];
180 }
181 return _super.prototype.concat.apply(this, arr);
182 };
183 MiddlewareArray.prototype.prepend = function () {
184 var arr = [];
185 for (var _i = 0; _i < arguments.length; _i++) {
186 arr[_i] = arguments[_i];
187 }
188 if (arr.length === 1 && Array.isArray(arr[0])) {
189 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
190 }
191 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
192 };
193 return MiddlewareArray;
194}(Array));
195// src/immutableStateInvariantMiddleware.ts
196var isProduction = process.env.NODE_ENV === "production";
197var prefix = "Invariant failed";
198function invariant(condition, message) {
199 if (condition) {
200 return;
201 }
202 if (isProduction) {
203 throw new Error(prefix);
204 }
205 throw new Error(prefix + ": " + (message || ""));
206}
207function stringify(obj, serializer, indent, decycler) {
208 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
209}
210function getSerialize(serializer, decycler) {
211 var stack = [], keys = [];
212 if (!decycler)
213 decycler = function (_, value) {
214 if (stack[0] === value)
215 return "[Circular ~]";
216 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
217 };
218 return function (key, value) {
219 if (stack.length > 0) {
220 var thisPos = stack.indexOf(this);
221 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
222 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
223 if (~stack.indexOf(value))
224 value = decycler.call(this, key, value);
225 }
226 else
227 stack.push(value);
228 return serializer == null ? value : serializer.call(this, key, value);
229 };
230}
231function isImmutableDefault(value) {
232 return typeof value !== "object" || value === null || typeof value === "undefined" || Object.isFrozen(value);
233}
234function trackForMutations(isImmutable, ignorePaths, obj) {
235 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
236 return {
237 detectMutations: function () {
238 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
239 }
240 };
241}
242function trackProperties(isImmutable, ignorePaths, obj, path) {
243 if (ignorePaths === void 0) { ignorePaths = []; }
244 if (path === void 0) { path = ""; }
245 var tracked = { value: obj };
246 if (!isImmutable(obj)) {
247 tracked.children = {};
248 for (var key in obj) {
249 var childPath = path ? path + "." + key : key;
250 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
251 continue;
252 }
253 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
254 }
255 }
256 return tracked;
257}
258function detectMutations(isImmutable, ignorePaths, trackedProperty, obj, sameParentRef, path) {
259 if (ignorePaths === void 0) { ignorePaths = []; }
260 if (sameParentRef === void 0) { sameParentRef = false; }
261 if (path === void 0) { path = ""; }
262 var prevObj = trackedProperty ? trackedProperty.value : void 0;
263 var sameRef = prevObj === obj;
264 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
265 return { wasMutated: true, path: path };
266 }
267 if (isImmutable(prevObj) || isImmutable(obj)) {
268 return { wasMutated: false };
269 }
270 var keysToDetect = {};
271 for (var key in trackedProperty.children) {
272 keysToDetect[key] = true;
273 }
274 for (var key in obj) {
275 keysToDetect[key] = true;
276 }
277 for (var key in keysToDetect) {
278 var childPath = path ? path + "." + key : key;
279 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
280 continue;
281 }
282 var result = detectMutations(isImmutable, ignorePaths, trackedProperty.children[key], obj[key], sameRef, childPath);
283 if (result.wasMutated) {
284 return result;
285 }
286 }
287 return { wasMutated: false };
288}
289function createImmutableStateInvariantMiddleware(options) {
290 if (options === void 0) { options = {}; }
291 if (process.env.NODE_ENV === "production") {
292 return function () { return function (next) { return function (action) { return next(action); }; }; };
293 }
294 var _b = options.isImmutable, isImmutable = _b === void 0 ? isImmutableDefault : _b, ignoredPaths = options.ignoredPaths, _c = options.warnAfter, warnAfter = _c === void 0 ? 32 : _c, ignore = options.ignore;
295 ignoredPaths = ignoredPaths || ignore;
296 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
297 return function (_b) {
298 var getState = _b.getState;
299 var state = getState();
300 var tracker = track(state);
301 var result;
302 return function (next) { return function (action) {
303 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
304 measureUtils.measureTime(function () {
305 state = getState();
306 result = tracker.detectMutations();
307 tracker = track(state);
308 invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
309 });
310 var dispatchedAction = next(action);
311 measureUtils.measureTime(function () {
312 state = getState();
313 result = tracker.detectMutations();
314 tracker = track(state);
315 result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
316 });
317 measureUtils.warnIfExceeded();
318 return dispatchedAction;
319 }; };
320 };
321}
322// src/serializableStateInvariantMiddleware.ts
323function isPlain(val) {
324 var type = typeof val;
325 return type === "undefined" || val === null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
326}
327function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths) {
328 if (path === void 0) { path = ""; }
329 if (isSerializable === void 0) { isSerializable = isPlain; }
330 if (ignoredPaths === void 0) { ignoredPaths = []; }
331 var foundNestedSerializable;
332 if (!isSerializable(value)) {
333 return {
334 keyPath: path || "<root>",
335 value: value
336 };
337 }
338 if (typeof value !== "object" || value === null) {
339 return false;
340 }
341 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
342 var hasIgnoredPaths = ignoredPaths.length > 0;
343 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
344 var _b = entries_1[_i], key = _b[0], nestedValue = _b[1];
345 var nestedPath = path ? path + "." + key : key;
346 if (hasIgnoredPaths && ignoredPaths.indexOf(nestedPath) >= 0) {
347 continue;
348 }
349 if (!isSerializable(nestedValue)) {
350 return {
351 keyPath: nestedPath,
352 value: nestedValue
353 };
354 }
355 if (typeof nestedValue === "object") {
356 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths);
357 if (foundNestedSerializable) {
358 return foundNestedSerializable;
359 }
360 }
361 }
362 return false;
363}
364function createSerializableStateInvariantMiddleware(options) {
365 if (options === void 0) { options = {}; }
366 if (process.env.NODE_ENV === "production") {
367 return function () { return function (next) { return function (action) { return next(action); }; }; };
368 }
369 var _b = options.isSerializable, isSerializable = _b === void 0 ? isPlain : _b, getEntries = options.getEntries, _c = options.ignoredActions, ignoredActions = _c === void 0 ? [] : _c, _d = options.ignoredActionPaths, ignoredActionPaths = _d === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _d, _e = options.ignoredPaths, ignoredPaths = _e === void 0 ? [] : _e, _f = options.warnAfter, warnAfter = _f === void 0 ? 32 : _f, _g = options.ignoreState, ignoreState = _g === void 0 ? false : _g;
370 return function (storeAPI) { return function (next) { return function (action) {
371 if (ignoredActions.length && ignoredActions.indexOf(action.type) !== -1) {
372 return next(action);
373 }
374 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
375 measureUtils.measureTime(function () {
376 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths);
377 if (foundActionNonSerializableValue) {
378 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
379 console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
380 }
381 });
382 var result = next(action);
383 if (!ignoreState) {
384 measureUtils.measureTime(function () {
385 var state = storeAPI.getState();
386 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths);
387 if (foundStateNonSerializableValue) {
388 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
389 console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
390 }
391 });
392 measureUtils.warnIfExceeded();
393 }
394 return result;
395 }; }; };
396}
397// src/getDefaultMiddleware.ts
398function isBoolean(x) {
399 return typeof x === "boolean";
400}
401function curryGetDefaultMiddleware() {
402 return function curriedGetDefaultMiddleware(options) {
403 return getDefaultMiddleware(options);
404 };
405}
406function getDefaultMiddleware(options) {
407 if (options === void 0) { options = {}; }
408 var _b = options.thunk, thunk = _b === void 0 ? true : _b, _c = options.immutableCheck, immutableCheck = _c === void 0 ? true : _c, _d = options.serializableCheck, serializableCheck = _d === void 0 ? true : _d;
409 var middlewareArray = new MiddlewareArray();
410 if (thunk) {
411 if (isBoolean(thunk)) {
412 middlewareArray.push(thunkMiddleware);
413 }
414 else {
415 middlewareArray.push(thunkMiddleware.withExtraArgument(thunk.extraArgument));
416 }
417 }
418 if (process.env.NODE_ENV !== "production") {
419 if (immutableCheck) {
420 var immutableOptions = {};
421 if (!isBoolean(immutableCheck)) {
422 immutableOptions = immutableCheck;
423 }
424 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
425 }
426 if (serializableCheck) {
427 var serializableOptions = {};
428 if (!isBoolean(serializableCheck)) {
429 serializableOptions = serializableCheck;
430 }
431 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
432 }
433 }
434 return middlewareArray;
435}
436// src/configureStore.ts
437var IS_PRODUCTION = process.env.NODE_ENV === "production";
438function configureStore(options) {
439 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
440 var _b = options || {}, _c = _b.reducer, reducer = _c === void 0 ? void 0 : _c, _d = _b.middleware, middleware = _d === void 0 ? curriedGetDefaultMiddleware() : _d, _e = _b.devTools, devTools = _e === void 0 ? true : _e, _f = _b.preloadedState, preloadedState = _f === void 0 ? void 0 : _f, _g = _b.enhancers, enhancers = _g === void 0 ? void 0 : _g;
441 var rootReducer;
442 if (typeof reducer === "function") {
443 rootReducer = reducer;
444 }
445 else if (isPlainObject(reducer)) {
446 rootReducer = combineReducers(reducer);
447 }
448 else {
449 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
450 }
451 var finalMiddleware = middleware;
452 if (typeof finalMiddleware === "function") {
453 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
454 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
455 throw new Error("when using a middleware builder function, an array of middleware must be returned");
456 }
457 }
458 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
459 throw new Error("each middleware provided to configureStore must be a function");
460 }
461 var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
462 var finalCompose = compose2;
463 if (devTools) {
464 finalCompose = composeWithDevTools(__objSpread({
465 trace: !IS_PRODUCTION
466 }, typeof devTools === "object" && devTools));
467 }
468 var storeEnhancers = [middlewareEnhancer];
469 if (Array.isArray(enhancers)) {
470 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
471 }
472 else if (typeof enhancers === "function") {
473 storeEnhancers = enhancers(storeEnhancers);
474 }
475 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
476 return createStore(rootReducer, preloadedState, composedEnhancer);
477}
478// src/createAction.ts
479function createAction(type, prepareAction) {
480 function actionCreator() {
481 var args = [];
482 for (var _i = 0; _i < arguments.length; _i++) {
483 args[_i] = arguments[_i];
484 }
485 if (prepareAction) {
486 var prepared = prepareAction.apply(void 0, args);
487 if (!prepared) {
488 throw new Error("prepareAction did not return an object");
489 }
490 return __objSpread(__objSpread({
491 type: type,
492 payload: prepared.payload
493 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
494 }
495 return { type: type, payload: args[0] };
496 }
497 actionCreator.toString = function () { return "" + type; };
498 actionCreator.type = type;
499 actionCreator.match = function (action) { return action.type === type; };
500 return actionCreator;
501}
502function isFSA(action) {
503 return isPlainObject(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
504}
505function isValidKey(key) {
506 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
507}
508function getType(actionCreator) {
509 return "" + actionCreator;
510}
511// src/createReducer.ts
512import createNextState, { isDraft as isDraft2, isDraftable, enableES5 } from "immer";
513// src/mapBuilders.ts
514function executeReducerBuilderCallback(builderCallback) {
515 var actionsMap = {};
516 var actionMatchers = [];
517 var defaultCaseReducer;
518 var builder = {
519 addCase: function (typeOrActionCreator, reducer) {
520 if (process.env.NODE_ENV !== "production") {
521 if (actionMatchers.length > 0) {
522 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
523 }
524 if (defaultCaseReducer) {
525 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
526 }
527 }
528 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
529 if (type in actionsMap) {
530 throw new Error("addCase cannot be called with two reducers for the same action type");
531 }
532 actionsMap[type] = reducer;
533 return builder;
534 },
535 addMatcher: function (matcher, reducer) {
536 if (process.env.NODE_ENV !== "production") {
537 if (defaultCaseReducer) {
538 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
539 }
540 }
541 actionMatchers.push({ matcher: matcher, reducer: reducer });
542 return builder;
543 },
544 addDefaultCase: function (reducer) {
545 if (process.env.NODE_ENV !== "production") {
546 if (defaultCaseReducer) {
547 throw new Error("`builder.addDefaultCase` can only be called once");
548 }
549 }
550 defaultCaseReducer = reducer;
551 return builder;
552 }
553 };
554 builderCallback(builder);
555 return [actionsMap, actionMatchers, defaultCaseReducer];
556}
557// src/createReducer.ts
558function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
559 if (actionMatchers === void 0) { actionMatchers = []; }
560 enableES5();
561 var _b = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _b[0], finalActionMatchers = _b[1], finalDefaultCaseReducer = _b[2];
562 var frozenInitialState = createNextState(initialState, function () {
563 });
564 return function (state, action) {
565 if (state === void 0) { state = frozenInitialState; }
566 var caseReducers = __spreadArray([
567 actionsMap[action.type]
568 ], finalActionMatchers.filter(function (_b) {
569 var matcher = _b.matcher;
570 return matcher(action);
571 }).map(function (_b) {
572 var reducer = _b.reducer;
573 return reducer;
574 }));
575 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
576 caseReducers = [finalDefaultCaseReducer];
577 }
578 return caseReducers.reduce(function (previousState, caseReducer) {
579 if (caseReducer) {
580 if (isDraft2(previousState)) {
581 var draft = previousState;
582 var result = caseReducer(draft, action);
583 if (typeof result === "undefined") {
584 return previousState;
585 }
586 return result;
587 }
588 else if (!isDraftable(previousState)) {
589 var result = caseReducer(previousState, action);
590 if (typeof result === "undefined") {
591 if (previousState === null) {
592 return previousState;
593 }
594 throw Error("A case reducer on a non-draftable value must not return undefined");
595 }
596 return result;
597 }
598 else {
599 return createNextState(previousState, function (draft) {
600 return caseReducer(draft, action);
601 });
602 }
603 }
604 return previousState;
605 }, state);
606 };
607}
608// src/createSlice.ts
609function getType2(slice, actionKey) {
610 return slice + "/" + actionKey;
611}
612function createSlice(options) {
613 var name = options.name, initialState = options.initialState;
614 if (!name) {
615 throw new Error("`name` is a required option for createSlice");
616 }
617 var reducers = options.reducers || {};
618 var _b = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers], _c = _b[0], extraReducers = _c === void 0 ? {} : _c, _d = _b[1], actionMatchers = _d === void 0 ? [] : _d, _e = _b[2], defaultCaseReducer = _e === void 0 ? void 0 : _e;
619 var reducerNames = Object.keys(reducers);
620 var sliceCaseReducersByName = {};
621 var sliceCaseReducersByType = {};
622 var actionCreators = {};
623 reducerNames.forEach(function (reducerName) {
624 var maybeReducerWithPrepare = reducers[reducerName];
625 var type = getType2(name, reducerName);
626 var caseReducer;
627 var prepareCallback;
628 if ("reducer" in maybeReducerWithPrepare) {
629 caseReducer = maybeReducerWithPrepare.reducer;
630 prepareCallback = maybeReducerWithPrepare.prepare;
631 }
632 else {
633 caseReducer = maybeReducerWithPrepare;
634 }
635 sliceCaseReducersByName[reducerName] = caseReducer;
636 sliceCaseReducersByType[type] = caseReducer;
637 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
638 });
639 var finalCaseReducers = __objSpread(__objSpread({}, extraReducers), sliceCaseReducersByType);
640 var reducer = createReducer(initialState, finalCaseReducers, actionMatchers, defaultCaseReducer);
641 return {
642 name: name,
643 reducer: reducer,
644 actions: actionCreators,
645 caseReducers: sliceCaseReducersByName
646 };
647}
648// src/entities/entity_state.ts
649function getInitialEntityState() {
650 return {
651 ids: [],
652 entities: {}
653 };
654}
655function createInitialStateFactory() {
656 function getInitialState(additionalState) {
657 if (additionalState === void 0) { additionalState = {}; }
658 return Object.assign(getInitialEntityState(), additionalState);
659 }
660 return { getInitialState: getInitialState };
661}
662// src/entities/state_selectors.ts
663function createSelectorsFactory() {
664 function getSelectors(selectState) {
665 var selectIds = function (state) { return state.ids; };
666 var selectEntities = function (state) { return state.entities; };
667 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
668 var selectId = function (_, id) { return id; };
669 var selectById = function (entities, id) { return entities[id]; };
670 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
671 if (!selectState) {
672 return {
673 selectIds: selectIds,
674 selectEntities: selectEntities,
675 selectAll: selectAll,
676 selectTotal: selectTotal,
677 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
678 };
679 }
680 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
681 return {
682 selectIds: createDraftSafeSelector(selectState, selectIds),
683 selectEntities: selectGlobalizedEntities,
684 selectAll: createDraftSafeSelector(selectState, selectAll),
685 selectTotal: createDraftSafeSelector(selectState, selectTotal),
686 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
687 };
688 }
689 return { getSelectors: getSelectors };
690}
691// src/entities/state_adapter.ts
692import createNextState2, { isDraft as isDraft3 } from "immer";
693function createSingleArgumentStateOperator(mutator) {
694 var operator = createStateOperator(function (_, state) { return mutator(state); });
695 return function operation(state) {
696 return operator(state, void 0);
697 };
698}
699function createStateOperator(mutator) {
700 return function operation(state, arg) {
701 function isPayloadActionArgument(arg2) {
702 return isFSA(arg2);
703 }
704 var runMutator = function (draft) {
705 if (isPayloadActionArgument(arg)) {
706 mutator(arg.payload, draft);
707 }
708 else {
709 mutator(arg, draft);
710 }
711 };
712 if (isDraft3(state)) {
713 runMutator(state);
714 return state;
715 }
716 else {
717 return createNextState2(state, runMutator);
718 }
719 };
720}
721// src/entities/utils.ts
722function selectIdValue(entity, selectId) {
723 var key = selectId(entity);
724 if (process.env.NODE_ENV !== "production" && key === void 0) {
725 console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
726 }
727 return key;
728}
729function ensureEntitiesArray(entities) {
730 if (!Array.isArray(entities)) {
731 entities = Object.values(entities);
732 }
733 return entities;
734}
735function splitAddedUpdatedEntities(newEntities, selectId, state) {
736 newEntities = ensureEntitiesArray(newEntities);
737 var added = [];
738 var updated = [];
739 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
740 var entity = newEntities_1[_i];
741 var id = selectIdValue(entity, selectId);
742 if (id in state.entities) {
743 updated.push({ id: id, changes: entity });
744 }
745 else {
746 added.push(entity);
747 }
748 }
749 return [added, updated];
750}
751// src/entities/unsorted_state_adapter.ts
752function createUnsortedStateAdapter(selectId) {
753 function addOneMutably(entity, state) {
754 var key = selectIdValue(entity, selectId);
755 if (key in state.entities) {
756 return;
757 }
758 state.ids.push(key);
759 state.entities[key] = entity;
760 }
761 function addManyMutably(newEntities, state) {
762 newEntities = ensureEntitiesArray(newEntities);
763 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
764 var entity = newEntities_2[_i];
765 addOneMutably(entity, state);
766 }
767 }
768 function setOneMutably(entity, state) {
769 var key = selectIdValue(entity, selectId);
770 if (!(key in state.entities)) {
771 state.ids.push(key);
772 }
773 state.entities[key] = entity;
774 }
775 function setManyMutably(newEntities, state) {
776 newEntities = ensureEntitiesArray(newEntities);
777 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
778 var entity = newEntities_3[_i];
779 setOneMutably(entity, state);
780 }
781 }
782 function setAllMutably(newEntities, state) {
783 newEntities = ensureEntitiesArray(newEntities);
784 state.ids = [];
785 state.entities = {};
786 addManyMutably(newEntities, state);
787 }
788 function removeOneMutably(key, state) {
789 return removeManyMutably([key], state);
790 }
791 function removeManyMutably(keys, state) {
792 var didMutate = false;
793 keys.forEach(function (key) {
794 if (key in state.entities) {
795 delete state.entities[key];
796 didMutate = true;
797 }
798 });
799 if (didMutate) {
800 state.ids = state.ids.filter(function (id) { return id in state.entities; });
801 }
802 }
803 function removeAllMutably(state) {
804 Object.assign(state, {
805 ids: [],
806 entities: {}
807 });
808 }
809 function takeNewKey(keys, update, state) {
810 var original2 = state.entities[update.id];
811 var updated = Object.assign({}, original2, update.changes);
812 var newKey = selectIdValue(updated, selectId);
813 var hasNewKey = newKey !== update.id;
814 if (hasNewKey) {
815 keys[update.id] = newKey;
816 delete state.entities[update.id];
817 }
818 state.entities[newKey] = updated;
819 return hasNewKey;
820 }
821 function updateOneMutably(update, state) {
822 return updateManyMutably([update], state);
823 }
824 function updateManyMutably(updates, state) {
825 var newKeys = {};
826 var updatesPerEntity = {};
827 updates.forEach(function (update) {
828 if (update.id in state.entities) {
829 updatesPerEntity[update.id] = {
830 id: update.id,
831 changes: __objSpread(__objSpread({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
832 };
833 }
834 });
835 updates = Object.values(updatesPerEntity);
836 var didMutateEntities = updates.length > 0;
837 if (didMutateEntities) {
838 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
839 if (didMutateIds) {
840 state.ids = state.ids.map(function (id) { return newKeys[id] || id; });
841 }
842 }
843 }
844 function upsertOneMutably(entity, state) {
845 return upsertManyMutably([entity], state);
846 }
847 function upsertManyMutably(newEntities, state) {
848 var _b = splitAddedUpdatedEntities(newEntities, selectId, state), added = _b[0], updated = _b[1];
849 updateManyMutably(updated, state);
850 addManyMutably(added, state);
851 }
852 return {
853 removeAll: createSingleArgumentStateOperator(removeAllMutably),
854 addOne: createStateOperator(addOneMutably),
855 addMany: createStateOperator(addManyMutably),
856 setOne: createStateOperator(setOneMutably),
857 setMany: createStateOperator(setManyMutably),
858 setAll: createStateOperator(setAllMutably),
859 updateOne: createStateOperator(updateOneMutably),
860 updateMany: createStateOperator(updateManyMutably),
861 upsertOne: createStateOperator(upsertOneMutably),
862 upsertMany: createStateOperator(upsertManyMutably),
863 removeOne: createStateOperator(removeOneMutably),
864 removeMany: createStateOperator(removeManyMutably)
865 };
866}
867// src/entities/sorted_state_adapter.ts
868function createSortedStateAdapter(selectId, sort) {
869 var _b = createUnsortedStateAdapter(selectId), removeOne = _b.removeOne, removeMany = _b.removeMany, removeAll = _b.removeAll;
870 function addOneMutably(entity, state) {
871 return addManyMutably([entity], state);
872 }
873 function addManyMutably(newEntities, state) {
874 newEntities = ensureEntitiesArray(newEntities);
875 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
876 if (models.length !== 0) {
877 merge(models, state);
878 }
879 }
880 function setOneMutably(entity, state) {
881 return setManyMutably([entity], state);
882 }
883 function setManyMutably(newEntities, state) {
884 newEntities = ensureEntitiesArray(newEntities);
885 if (newEntities.length !== 0) {
886 merge(newEntities, state);
887 }
888 }
889 function setAllMutably(newEntities, state) {
890 newEntities = ensureEntitiesArray(newEntities);
891 state.entities = {};
892 state.ids = [];
893 addManyMutably(newEntities, state);
894 }
895 function updateOneMutably(update, state) {
896 return updateManyMutably([update], state);
897 }
898 function takeUpdatedModel(models, update, state) {
899 if (!(update.id in state.entities)) {
900 return false;
901 }
902 var original2 = state.entities[update.id];
903 var updated = Object.assign({}, original2, update.changes);
904 var newKey = selectIdValue(updated, selectId);
905 delete state.entities[update.id];
906 models.push(updated);
907 return newKey !== update.id;
908 }
909 function updateManyMutably(updates, state) {
910 var models = [];
911 updates.forEach(function (update) { return takeUpdatedModel(models, update, state); });
912 if (models.length !== 0) {
913 merge(models, state);
914 }
915 }
916 function upsertOneMutably(entity, state) {
917 return upsertManyMutably([entity], state);
918 }
919 function upsertManyMutably(newEntities, state) {
920 var _b = splitAddedUpdatedEntities(newEntities, selectId, state), added = _b[0], updated = _b[1];
921 updateManyMutably(updated, state);
922 addManyMutably(added, state);
923 }
924 function areArraysEqual(a, b) {
925 if (a.length !== b.length) {
926 return false;
927 }
928 for (var i = 0; i < a.length && i < b.length; i++) {
929 if (a[i] === b[i]) {
930 continue;
931 }
932 return false;
933 }
934 return true;
935 }
936 function merge(models, state) {
937 models.forEach(function (model) {
938 state.entities[selectId(model)] = model;
939 });
940 var allEntities = Object.values(state.entities);
941 allEntities.sort(sort);
942 var newSortedIds = allEntities.map(selectId);
943 var ids = state.ids;
944 if (!areArraysEqual(ids, newSortedIds)) {
945 state.ids = newSortedIds;
946 }
947 }
948 return {
949 removeOne: removeOne,
950 removeMany: removeMany,
951 removeAll: removeAll,
952 addOne: createStateOperator(addOneMutably),
953 updateOne: createStateOperator(updateOneMutably),
954 upsertOne: createStateOperator(upsertOneMutably),
955 setOne: createStateOperator(setOneMutably),
956 setMany: createStateOperator(setManyMutably),
957 setAll: createStateOperator(setAllMutably),
958 addMany: createStateOperator(addManyMutably),
959 updateMany: createStateOperator(updateManyMutably),
960 upsertMany: createStateOperator(upsertManyMutably)
961 };
962}
963// src/entities/create_adapter.ts
964function createEntityAdapter(options) {
965 if (options === void 0) { options = {}; }
966 var _b = __objSpread({
967 sortComparer: false,
968 selectId: function (instance) { return instance.id; }
969 }, options), selectId = _b.selectId, sortComparer = _b.sortComparer;
970 var stateFactory = createInitialStateFactory();
971 var selectorsFactory = createSelectorsFactory();
972 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
973 return __objSpread(__objSpread(__objSpread({
974 selectId: selectId,
975 sortComparer: sortComparer
976 }, stateFactory), selectorsFactory), stateAdapter);
977}
978// src/nanoid.ts
979var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
980var nanoid = function (size) {
981 if (size === void 0) { size = 21; }
982 var id = "";
983 var i = size;
984 while (i--) {
985 id += urlAlphabet[Math.random() * 64 | 0];
986 }
987 return id;
988};
989// src/createAsyncThunk.ts
990var commonProperties = [
991 "name",
992 "message",
993 "stack",
994 "code"
995];
996var RejectWithValue = /** @class */ (function () {
997 function RejectWithValue(payload, meta) {
998 this.payload = payload;
999 this.meta = meta;
1000 }
1001 return RejectWithValue;
1002}());
1003var FulfillWithMeta = /** @class */ (function () {
1004 function FulfillWithMeta(payload, meta) {
1005 this.payload = payload;
1006 this.meta = meta;
1007 }
1008 return FulfillWithMeta;
1009}());
1010var miniSerializeError = function (value) {
1011 if (typeof value === "object" && value !== null) {
1012 var simpleError = {};
1013 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
1014 var property = commonProperties_1[_i];
1015 if (typeof value[property] === "string") {
1016 simpleError[property] = value[property];
1017 }
1018 }
1019 return simpleError;
1020 }
1021 return { message: String(value) };
1022};
1023function createAsyncThunk(typePrefix, payloadCreator, options) {
1024 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
1025 payload: payload,
1026 meta: __objSpread(__objSpread({}, meta || {}), {
1027 arg: arg,
1028 requestId: requestId,
1029 requestStatus: "fulfilled"
1030 })
1031 }); });
1032 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
1033 payload: void 0,
1034 meta: __objSpread(__objSpread({}, meta || {}), {
1035 arg: arg,
1036 requestId: requestId,
1037 requestStatus: "pending"
1038 })
1039 }); });
1040 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
1041 payload: payload,
1042 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1043 meta: __objSpread(__objSpread({}, meta || {}), {
1044 arg: arg,
1045 requestId: requestId,
1046 rejectedWithValue: !!payload,
1047 requestStatus: "rejected",
1048 aborted: (error == null ? void 0 : error.name) === "AbortError",
1049 condition: (error == null ? void 0 : error.name) === "ConditionError"
1050 })
1051 }); });
1052 var displayedWarning = false;
1053 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
1054 function class_1() {
1055 this.signal = {
1056 aborted: false,
1057 addEventListener: function () {
1058 },
1059 dispatchEvent: function () {
1060 return false;
1061 },
1062 onabort: function () {
1063 },
1064 removeEventListener: function () {
1065 }
1066 };
1067 }
1068 class_1.prototype.abort = function () {
1069 if (process.env.NODE_ENV !== "production") {
1070 if (!displayedWarning) {
1071 displayedWarning = true;
1072 console.info("This platform does not implement AbortController. \nIf you want to use the AbortController to react to `abort` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.");
1073 }
1074 }
1075 };
1076 return class_1;
1077 }());
1078 function actionCreator(arg) {
1079 return function (dispatch, getState, extra) {
1080 var _a;
1081 var requestId = ((_a = options == null ? void 0 : options.idGenerator) != null ? _a : nanoid)();
1082 var abortController = new AC();
1083 var abortReason;
1084 var abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({ name: "AbortError", message: abortReason || "Aborted" }); }); });
1085 var started = false;
1086 function abort(reason) {
1087 if (started) {
1088 abortReason = reason;
1089 abortController.abort();
1090 }
1091 }
1092 var promise = function () {
1093 return __async(this, null, function () {
1094 var _a2, finalAction, err_1, skipDispatch;
1095 return __generator(this, function (_b) {
1096 switch (_b.label) {
1097 case 0:
1098 _b.trys.push([0, 2, , 3]);
1099 if (options && options.condition && options.condition(arg, { getState: getState, extra: extra }) === false) {
1100 throw {
1101 name: "ConditionError",
1102 message: "Aborted due to condition callback returning false."
1103 };
1104 }
1105 started = true;
1106 dispatch(pending(requestId, arg, (_a2 = options == null ? void 0 : options.getPendingMeta) == null ? void 0 : _a2.call(options, { requestId: requestId, arg: arg }, { getState: getState, extra: extra })));
1107 return [4 /*yield*/, Promise.race([
1108 abortedPromise,
1109 Promise.resolve(payloadCreator(arg, {
1110 dispatch: dispatch,
1111 getState: getState,
1112 extra: extra,
1113 requestId: requestId,
1114 signal: abortController.signal,
1115 rejectWithValue: function (value, meta) {
1116 return new RejectWithValue(value, meta);
1117 },
1118 fulfillWithValue: function (value, meta) {
1119 return new FulfillWithMeta(value, meta);
1120 }
1121 })).then(function (result) {
1122 if (result instanceof RejectWithValue) {
1123 throw result;
1124 }
1125 if (result instanceof FulfillWithMeta) {
1126 return fulfilled(result.payload, requestId, arg, result.meta);
1127 }
1128 return fulfilled(result, requestId, arg);
1129 })
1130 ])];
1131 case 1:
1132 finalAction = _b.sent();
1133 return [3 /*break*/, 3];
1134 case 2:
1135 err_1 = _b.sent();
1136 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
1137 return [3 /*break*/, 3];
1138 case 3:
1139 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
1140 if (!skipDispatch) {
1141 dispatch(finalAction);
1142 }
1143 return [2 /*return*/, finalAction];
1144 }
1145 });
1146 });
1147 }();
1148 return Object.assign(promise, {
1149 abort: abort,
1150 requestId: requestId,
1151 arg: arg,
1152 unwrap: function () {
1153 return promise.then(unwrapResult);
1154 }
1155 });
1156 };
1157 }
1158 return Object.assign(actionCreator, {
1159 pending: pending,
1160 rejected: rejected,
1161 fulfilled: fulfilled,
1162 typePrefix: typePrefix
1163 });
1164}
1165function unwrapResult(action) {
1166 if (action.meta && action.meta.rejectedWithValue) {
1167 throw action.payload;
1168 }
1169 if (action.error) {
1170 throw action.error;
1171 }
1172 return action.payload;
1173}
1174// src/tsHelpers.ts
1175var hasMatchFunction = function (v) {
1176 return v && typeof v.match === "function";
1177};
1178// src/matchers.ts
1179var matches = function (matcher, action) {
1180 if (hasMatchFunction(matcher)) {
1181 return matcher.match(action);
1182 }
1183 else {
1184 return matcher(action);
1185 }
1186};
1187function isAnyOf() {
1188 var matchers = [];
1189 for (var _i = 0; _i < arguments.length; _i++) {
1190 matchers[_i] = arguments[_i];
1191 }
1192 return function (action) {
1193 return matchers.some(function (matcher) { return matches(matcher, action); });
1194 };
1195}
1196function isAllOf() {
1197 var matchers = [];
1198 for (var _i = 0; _i < arguments.length; _i++) {
1199 matchers[_i] = arguments[_i];
1200 }
1201 return function (action) {
1202 return matchers.every(function (matcher) { return matches(matcher, action); });
1203 };
1204}
1205function hasExpectedRequestMetadata(action, validStatus) {
1206 if (!action || !action.meta)
1207 return false;
1208 var hasValidRequestId = typeof action.meta.requestId === "string";
1209 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
1210 return hasValidRequestId && hasValidRequestStatus;
1211}
1212function isAsyncThunkArray(a) {
1213 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
1214}
1215function isPending() {
1216 var asyncThunks = [];
1217 for (var _i = 0; _i < arguments.length; _i++) {
1218 asyncThunks[_i] = arguments[_i];
1219 }
1220 if (asyncThunks.length === 0) {
1221 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
1222 }
1223 if (!isAsyncThunkArray(asyncThunks)) {
1224 return isPending()(asyncThunks[0]);
1225 }
1226 return function (action) {
1227 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
1228 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1229 return combinedMatcher(action);
1230 };
1231}
1232function isRejected() {
1233 var asyncThunks = [];
1234 for (var _i = 0; _i < arguments.length; _i++) {
1235 asyncThunks[_i] = arguments[_i];
1236 }
1237 if (asyncThunks.length === 0) {
1238 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
1239 }
1240 if (!isAsyncThunkArray(asyncThunks)) {
1241 return isRejected()(asyncThunks[0]);
1242 }
1243 return function (action) {
1244 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
1245 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1246 return combinedMatcher(action);
1247 };
1248}
1249function isRejectedWithValue() {
1250 var asyncThunks = [];
1251 for (var _i = 0; _i < arguments.length; _i++) {
1252 asyncThunks[_i] = arguments[_i];
1253 }
1254 var hasFlag = function (action) {
1255 return action && action.meta && action.meta.rejectedWithValue;
1256 };
1257 if (asyncThunks.length === 0) {
1258 return function (action) {
1259 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
1260 return combinedMatcher(action);
1261 };
1262 }
1263 if (!isAsyncThunkArray(asyncThunks)) {
1264 return isRejectedWithValue()(asyncThunks[0]);
1265 }
1266 return function (action) {
1267 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
1268 return combinedMatcher(action);
1269 };
1270}
1271function isFulfilled() {
1272 var asyncThunks = [];
1273 for (var _i = 0; _i < arguments.length; _i++) {
1274 asyncThunks[_i] = arguments[_i];
1275 }
1276 if (asyncThunks.length === 0) {
1277 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
1278 }
1279 if (!isAsyncThunkArray(asyncThunks)) {
1280 return isFulfilled()(asyncThunks[0]);
1281 }
1282 return function (action) {
1283 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
1284 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1285 return combinedMatcher(action);
1286 };
1287}
1288function isAsyncThunkAction() {
1289 var asyncThunks = [];
1290 for (var _i = 0; _i < arguments.length; _i++) {
1291 asyncThunks[_i] = arguments[_i];
1292 }
1293 if (asyncThunks.length === 0) {
1294 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
1295 }
1296 if (!isAsyncThunkArray(asyncThunks)) {
1297 return isAsyncThunkAction()(asyncThunks[0]);
1298 }
1299 return function (action) {
1300 var matchers = [];
1301 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
1302 var asyncThunk = asyncThunks_1[_i];
1303 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
1304 }
1305 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1306 return combinedMatcher(action);
1307 };
1308}
1309export { MiddlewareArray, configureStore, createAction, createAsyncThunk, createDraftSafeSelector, createEntityAdapter, createImmutableStateInvariantMiddleware, default2 as createNextState, createReducer, createSelector2 as createSelector, createSerializableStateInvariantMiddleware, createSlice, current2 as current, findNonSerializableValue, freeze, getDefaultMiddleware, getType, isAllOf, isAnyOf, isAsyncThunkAction, isDraft4 as isDraft, isFulfilled, isImmutableDefault, isPending, isPlain, isPlainObject, isRejected, isRejectedWithValue, miniSerializeError, nanoid, original, unwrapResult };
1310//# sourceMappingURL=module.js.map
\No newline at end of file