{"version":3,"sources":["../src/index.ts","../src/createDraftSafeSelector.ts","../src/configureStore.ts","../src/devtoolsExtension.ts","../src/isPlainObject.ts","../src/getDefaultMiddleware.ts","../src/utils.ts","../src/immutableStateInvariantMiddleware.ts","../src/serializableStateInvariantMiddleware.ts","../src/createAction.ts","../src/createReducer.ts","../src/mapBuilders.ts","../src/createSlice.ts","../src/entities/entity_state.ts","../src/entities/state_selectors.ts","../src/entities/state_adapter.ts","../src/entities/utils.ts","../src/entities/unsorted_state_adapter.ts","../src/entities/sorted_state_adapter.ts","../src/entities/create_adapter.ts","../src/nanoid.ts","../src/createAsyncThunk.ts","../src/tsHelpers.ts","../src/matchers.ts","module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAA,EAAA,SAAA,EAAA,MAAA,OAAA,CAAA;AACA,cAAA,OAAA,CAAA;AACA,OAAA,EAAA,OAAA,IAAA,QAAA,EAAA,OAAA,IAAA,QAAA,EAAA,MAAA,EAAA,QAAA,EAAA,OAAA,IAAA,QAAA,EAAA,MAAA,OAAA,CAAA;AAQA,OAAA,EAAA,cAAA,IAAA,eAAA,EAAA,MAAA,UAAA,CAAA;;ACVA,OAAA,EAAA,OAAA,EAAA,OAAA,EAAA,MAAA,OAAA,CAAA;AACA,OAAA,EAAA,cAAA,EAAA,MAAA,UAAA,CAAA;AASO,IAAM,uBAAA,GAAiD;IAAA,cACzD;SADyD,UACzD,EADyD,qBACzD,EADyD,IACzD;QADyD,yBACzD;;IAEH,IAAM,QAAA,GAAY,cAAA,eAA0B,IAAA,CAAA,CAAA;IAC5C,IAAM,eAAA,GAAkB,UAAC,KAAA;QAAA,cAAmB;aAAnB,UAAmB,EAAnB,qBAAmB,EAAnB,IAAmB;YAAnB,6BAAmB;;QAC1C,OAAA,QAAA,8BAAS,OAAA,CAAQ,KAAA,CAAA,CAAA,C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AA,CAAA;IAAA,CAAA,CAAA;AAAA,CAAA;AAiDpB,SAAA,kBAAA;IAAA,qBAEF;SAFE,UAEF,EAFE,qBAEF,EAFE,IAEF;QAFE,gCAEF;;IACH,IAAI,WAAA,CAAY,MAAA,KAAW,CAAA,EAAG;QAC5B,OAAO,UAAC,MAAA,IACN,OAAA,0BAAA,CAA2B,MAAA,EAAQ,CAAC,SAAA,EAAW,WAAA,EAAa,UAAA,CAAA,CAAA,EAA5D,CAA4D,CAAA;KAAA;IAGhE,IAAI,CAAC,iBAAA,CAAkB,WAAA,CAAA,EAAc;QACnC,OAAO,kBAAA,EAAA,CAAqB,WAAA,CAAY,CAAA,CAAA,CAAA,CAAA;KAAA;IAG1C,OAAO,UACL,MAAA;QAGA,IAAM,QAAA,GAA8C,EAAA,CAAA;QAEpD,KAAyB,UAAA,EAAA,2BAAA,EAAA,yBAAA,EAAA,IAAA,EAAa;YAAtC,IAAW,UAAA,oBAAA;YACT,QAAA,CAAS,IAAA,CACP,UAAA,CAAW,OAAA,EACX,UAAA,CAAW,QAAA,EACX,UAAA,CAAW,SAAA,CAAA,CAAA;SAAA;QAIf,IAAM,eAAA,GAAkB,OAAA,eAAW,QAAA,CAAA,CAAA;QAEnC,OAAO,eAAA,CAAgB,MAAA,CAAA,CAAA;IAAA,CAAA,CAAA;AAAA,CAAA;;AvBhZ3B,SAAA,EAAA,CAAA","sourcesContent":["import { enableES5 } from 'immer'\r\nexport * from 'redux'\r\nexport {\r\n default as createNextState,\r\n current,\r\n freeze,\r\n original,\r\n isDraft,\r\n} from 'immer'\r\nexport type { Draft } from 'immer'\r\nexport { createSelector } from 'reselect'\r\nexport type {\r\n Selector,\r\n OutputParametricSelector,\r\n OutputSelector,\r\n ParametricSelector,\r\n} from 'reselect'\r\nexport { createDraftSafeSelector } from './createDraftSafeSelector'\r\nexport type { ThunkAction, ThunkDispatch } from 'redux-thunk'\r\n\r\n// We deliberately enable Immer's ES5 support, on the grounds that\r\n// we assume RTK will be used with React Native and other Proxy-less\r\n// environments. In addition, that's how Immer 4 behaved, and since\r\n// we want to ship this in an RTK minor, we should keep the same behavior.\r\nenableES5()\r\n\r\nexport {\r\n // js\r\n configureStore,\r\n} from './configureStore'\r\nexport type {\r\n // types\r\n ConfigureEnhancersCallback,\r\n ConfigureStoreOptions,\r\n EnhancedStore,\r\n} from './configureStore'\r\nexport {\r\n // js\r\n createAction,\r\n getType,\r\n} from './createAction'\r\nexport type {\r\n // types\r\n PayloadAction,\r\n PayloadActionCreator,\r\n ActionCreatorWithNonInferrablePayload,\r\n ActionCreatorWithOptionalPayload,\r\n ActionCreatorWithPayload,\r\n ActionCreatorWithoutPayload,\r\n ActionCreatorWithPreparedPayload,\r\n PrepareAction,\r\n} from './createAction'\r\nexport {\r\n // js\r\n createReducer,\r\n} from './createReducer'\r\nexport type {\r\n // types\r\n Actions,\r\n CaseReducer,\r\n CaseReducers,\r\n} from './createReducer'\r\nexport {\r\n // js\r\n createSlice,\r\n} from './createSlice'\r\n\r\nexport type {\r\n // types\r\n CreateSliceOptions,\r\n Slice,\r\n CaseReducerActions,\r\n SliceCaseReducers,\r\n ValidateSliceCaseReducers,\r\n CaseReducerWithPrepare,\r\n SliceActionCreator,\r\n} from './createSlice'\r\nexport {\r\n // js\r\n createImmutableStateInvariantMiddleware,\r\n isImmutableDefault,\r\n} from './immutableStateInvariantMiddleware'\r\nexport type {\r\n // types\r\n ImmutableStateInvariantMiddlewareOptions,\r\n} from './immutableStateInvariantMiddleware'\r\nexport {\r\n // js\r\n createSerializableStateInvariantMiddleware,\r\n findNonSerializableValue,\r\n isPlain,\r\n} from './serializableStateInvariantMiddleware'\r\nexport type {\r\n // types\r\n SerializableStateInvariantMiddlewareOptions,\r\n} from './serializableStateInvariantMiddleware'\r\nexport {\r\n // js\r\n getDefaultMiddleware,\r\n} from './getDefaultMiddleware'\r\nexport type {\r\n // types\r\n ActionReducerMapBuilder,\r\n} from './mapBuilders'\r\nexport { MiddlewareArray } from './utils'\r\n\r\nexport { createEntityAdapter } from './entities/create_adapter'\r\nexport type {\r\n Dictionary,\r\n EntityState,\r\n EntityAdapter,\r\n EntitySelectors,\r\n EntityStateAdapter,\r\n EntityId,\r\n Update,\r\n IdSelector,\r\n Comparer,\r\n} from './entities/models'\r\n\r\nexport {\r\n createAsyncThunk,\r\n unwrapResult,\r\n miniSerializeError,\r\n} from './createAsyncThunk'\r\nexport type {\r\n AsyncThunk,\r\n AsyncThunkOptions,\r\n AsyncThunkAction,\r\n AsyncThunkPayloadCreatorReturnValue,\r\n AsyncThunkPayloadCreator,\r\n SerializedError,\r\n} from './createAsyncThunk'\r\n\r\nexport {\r\n // js\r\n isAllOf,\r\n isAnyOf,\r\n isPending,\r\n isRejected,\r\n isFulfilled,\r\n isAsyncThunkAction,\r\n isRejectedWithValue,\r\n} from './matchers'\r\nexport type {\r\n // types\r\n ActionMatchingAllOf,\r\n ActionMatchingAnyOf,\r\n} from './matchers'\r\n\r\nexport { nanoid } from './nanoid'\r\n\r\nexport { default as isPlainObject } from './isPlainObject'\r\n","import { current, isDraft } from 'immer'\r\nimport { createSelector } from 'reselect'\r\n\r\n/**\r\n * \"Draft-Safe\" version of `reselect`'s `createSelector`:\r\n * If an `immer`-drafted object is passed into the resulting selector's first argument,\r\n * the selector will act on the current draft value, instead of returning a cached value\r\n * that might be possibly outdated if the draft has been modified since.\r\n * @public\r\n */\r\nexport const createDraftSafeSelector: typeof createSelector = (\r\n ...args: unknown[]\r\n) => {\r\n const selector = (createSelector as any)(...args)\r\n const wrappedSelector = (value: unknown, ...rest: unknown[]) =>\r\n selector(isDraft(value) ? current(value) : value, ...rest)\r\n return wrappedSelector as any\r\n}\r\n","import type {\r\n Reducer,\r\n ReducersMapObject,\r\n Middleware,\r\n Action,\r\n AnyAction,\r\n StoreEnhancer,\r\n Store,\r\n Dispatch,\r\n PreloadedState,\r\n CombinedState,\r\n} from 'redux'\r\nimport { createStore, compose, applyMiddleware, combineReducers } from 'redux'\r\nimport type { EnhancerOptions as DevToolsOptions } from './devtoolsExtension'\r\nimport { composeWithDevTools } from './devtoolsExtension'\r\n\r\nimport isPlainObject from './isPlainObject'\r\nimport type {\r\n ThunkMiddlewareFor,\r\n CurriedGetDefaultMiddleware,\r\n} from './getDefaultMiddleware'\r\nimport { curryGetDefaultMiddleware } from './getDefaultMiddleware'\r\nimport type { DispatchForMiddlewares, NoInfer } from './tsHelpers'\r\n\r\nconst IS_PRODUCTION = process.env.NODE_ENV === 'production'\r\n\r\n/**\r\n * Callback function type, to be used in `ConfigureStoreOptions.enhancers`\r\n *\r\n * @public\r\n */\r\nexport type ConfigureEnhancersCallback = (\r\n defaultEnhancers: readonly StoreEnhancer[]\r\n) => StoreEnhancer[]\r\n\r\n/**\r\n * Options for `configureStore()`.\r\n *\r\n * @public\r\n */\r\nexport interface ConfigureStoreOptions<\r\n S = any,\r\n A extends Action = AnyAction,\r\n M extends Middlewares = Middlewares\r\n> {\r\n /**\r\n * A single reducer function that will be used as the root reducer, or an\r\n * object of slice reducers that will be passed to `combineReducers()`.\r\n */\r\n reducer: Reducer | ReducersMapObject\r\n\r\n /**\r\n * An array of Redux middleware to install. If not supplied, defaults to\r\n * the set of middleware returned by `getDefaultMiddleware()`.\r\n */\r\n middleware?: ((getDefaultMiddleware: CurriedGetDefaultMiddleware) => M) | M\r\n\r\n /**\r\n * Whether to enable Redux DevTools integration. Defaults to `true`.\r\n *\r\n * Additional configuration can be done by passing Redux DevTools options\r\n */\r\n devTools?: boolean | DevToolsOptions\r\n\r\n /**\r\n * The initial state, same as Redux's createStore.\r\n * You may optionally specify it to hydrate the state\r\n * from the server in universal apps, or to restore a previously serialized\r\n * user session. If you use `combineReducers()` to produce the root reducer\r\n * function (either directly or indirectly by passing an object as `reducer`),\r\n * this must be an object with the same shape as the reducer map keys.\r\n */\r\n /* \r\n Not 100% correct but the best approximation we can get:\r\n - if S is a `CombinedState` applying a second `CombinedState` on it does not change anything.\r\n - if it is not, there could be two cases:\r\n - `ReducersMapObject` is being passed in. In this case, we will call `combineReducers` on it and `CombinedState` is correct\r\n - `Reducer` is being passed in. In this case, actually `CombinedState` is wrong and `S` would be correct.\r\n As we cannot distinguish between those two cases without adding another generic paramter, \r\n we just make the pragmatic assumption that the latter almost never happens.\r\n */\r\n preloadedState?: PreloadedState>>\r\n\r\n /**\r\n * The store enhancers to apply. See Redux's `createStore()`.\r\n * All enhancers will be included before the DevTools Extension enhancer.\r\n * If you need to customize the order of enhancers, supply a callback\r\n * function that will receive the original array (ie, `[applyMiddleware]`),\r\n * and should return a new array (such as `[applyMiddleware, offline]`).\r\n * If you only need to add middleware, you can use the `middleware` parameter instead.\r\n */\r\n enhancers?: StoreEnhancer[] | ConfigureEnhancersCallback\r\n}\r\n\r\ntype Middlewares = ReadonlyArray>\r\n\r\n/**\r\n * A Redux store returned by `configureStore()`. Supports dispatching\r\n * side-effectful _thunks_ in addition to plain actions.\r\n *\r\n * @public\r\n */\r\nexport interface EnhancedStore<\r\n S = any,\r\n A extends Action = AnyAction,\r\n M extends Middlewares = Middlewares\r\n> extends Store {\r\n /**\r\n * The `dispatch` method of your store, enhanced by all its middlewares.\r\n *\r\n * @inheritdoc\r\n */\r\n dispatch: DispatchForMiddlewares & Dispatch\r\n}\r\n\r\n/**\r\n * A friendly abstraction over the standard Redux `createStore()` function.\r\n *\r\n * @param config The store configuration.\r\n * @returns A configured Redux store.\r\n *\r\n * @public\r\n */\r\nexport function configureStore<\r\n S = any,\r\n A extends Action = AnyAction,\r\n M extends Middlewares = [ThunkMiddlewareFor]\r\n>(options: ConfigureStoreOptions): EnhancedStore {\r\n const curriedGetDefaultMiddleware = curryGetDefaultMiddleware()\r\n\r\n const {\r\n reducer = undefined,\r\n middleware = curriedGetDefaultMiddleware(),\r\n devTools = true,\r\n preloadedState = undefined,\r\n enhancers = undefined,\r\n } = options || {}\r\n\r\n let rootReducer: Reducer\r\n\r\n if (typeof reducer === 'function') {\r\n rootReducer = reducer\r\n } else if (isPlainObject(reducer)) {\r\n rootReducer = combineReducers(reducer)\r\n } else {\r\n throw new Error(\r\n '\"reducer\" is a required argument, and must be a function or an object of functions that can be passed to combineReducers'\r\n )\r\n }\r\n\r\n let finalMiddleware = middleware\r\n if (typeof finalMiddleware === 'function') {\r\n finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware)\r\n\r\n if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {\r\n throw new Error(\r\n 'when using a middleware builder function, an array of middleware must be returned'\r\n )\r\n }\r\n }\r\n if (\r\n !IS_PRODUCTION &&\r\n finalMiddleware.some((item) => typeof item !== 'function')\r\n ) {\r\n throw new Error(\r\n 'each middleware provided to configureStore must be a function'\r\n )\r\n }\r\n\r\n const middlewareEnhancer = applyMiddleware(...finalMiddleware)\r\n\r\n let finalCompose = compose\r\n\r\n if (devTools) {\r\n finalCompose = composeWithDevTools({\r\n // Enable capture of stack traces for dispatched Redux actions\r\n trace: !IS_PRODUCTION,\r\n ...(typeof devTools === 'object' && devTools),\r\n })\r\n }\r\n\r\n let storeEnhancers: StoreEnhancer[] = [middlewareEnhancer]\r\n\r\n if (Array.isArray(enhancers)) {\r\n storeEnhancers = [middlewareEnhancer, ...enhancers]\r\n } else if (typeof enhancers === 'function') {\r\n storeEnhancers = enhancers(storeEnhancers)\r\n }\r\n\r\n const composedEnhancer = finalCompose(...storeEnhancers) as any\r\n\r\n return createStore(rootReducer, preloadedState, composedEnhancer)\r\n}\r\n","import type { Action, ActionCreator, StoreEnhancer } from 'redux'\r\nimport { compose } from 'redux'\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface EnhancerOptions {\r\n /**\r\n * the instance name to be showed on the monitor page. Default value is `document.title`.\r\n * If not specified and there's no document title, it will consist of `tabId` and `instanceId`.\r\n */\r\n name?: string\r\n /**\r\n * action creators functions to be available in the Dispatcher.\r\n */\r\n actionCreators?: ActionCreator[] | { [key: string]: ActionCreator }\r\n /**\r\n * if more than one action is dispatched in the indicated interval, all new actions will be collected and sent at once.\r\n * It is the joint between performance and speed. When set to `0`, all actions will be sent instantly.\r\n * Set it to a higher value when experiencing perf issues (also `maxAge` to a lower value).\r\n *\r\n * @default 500 ms.\r\n */\r\n latency?: number\r\n /**\r\n * (> 1) - maximum allowed actions to be stored in the history tree. The oldest actions are removed once maxAge is reached. It's critical for performance.\r\n *\r\n * @default 50\r\n */\r\n maxAge?: number\r\n /**\r\n * See detailed documentation at http://extension.remotedev.io/docs/API/Arguments.html#serialize\r\n */\r\n serialize?:\r\n | boolean\r\n | {\r\n options?:\r\n | boolean\r\n | {\r\n date?: boolean\r\n regex?: boolean\r\n undefined?: boolean\r\n error?: boolean\r\n symbol?: boolean\r\n map?: boolean\r\n set?: boolean\r\n function?: boolean | Function\r\n }\r\n replacer?: (key: string, value: unknown) => unknown\r\n reviver?: (key: string, value: unknown) => unknown\r\n immutable?: unknown\r\n refs?: unknown[]\r\n }\r\n /**\r\n * function which takes `action` object and id number as arguments, and should return `action` object back.\r\n */\r\n actionSanitizer?: (action: A, id: number) => A\r\n /**\r\n * function which takes `state` object and index as arguments, and should return `state` object back.\r\n */\r\n stateSanitizer?: (state: S, index: number) => S\r\n /**\r\n * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).\r\n * If `actionsWhitelist` specified, `actionsBlacklist` is ignored.\r\n */\r\n actionsBlacklist?: string | string[]\r\n /**\r\n * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).\r\n * If `actionsWhitelist` specified, `actionsBlacklist` is ignored.\r\n */\r\n actionsWhitelist?: string | string[]\r\n /**\r\n * called for every action before sending, takes `state` and `action` object, and returns `true` in case it allows sending the current data to the monitor.\r\n * Use it as a more advanced version of `actionsBlacklist`/`actionsWhitelist` parameters.\r\n */\r\n predicate?: (state: S, action: A) => boolean\r\n /**\r\n * if specified as `false`, it will not record the changes till clicking on `Start recording` button.\r\n * Available only for Redux enhancer, for others use `autoPause`.\r\n *\r\n * @default true\r\n */\r\n shouldRecordChanges?: boolean\r\n /**\r\n * if specified, whenever clicking on `Pause recording` button and there are actions in the history log, will add this action type.\r\n * If not specified, will commit when paused. Available only for Redux enhancer.\r\n *\r\n * @default \"@@PAUSED\"\"\r\n */\r\n pauseActionType?: string\r\n /**\r\n * auto pauses when the extension’s window is not opened, and so has zero impact on your app when not in use.\r\n * Not available for Redux enhancer (as it already does it but storing the data to be sent).\r\n *\r\n * @default false\r\n */\r\n autoPause?: boolean\r\n /**\r\n * if specified as `true`, it will not allow any non-monitor actions to be dispatched till clicking on `Unlock changes` button.\r\n * Available only for Redux enhancer.\r\n *\r\n * @default false\r\n */\r\n shouldStartLocked?: boolean\r\n /**\r\n * if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Available only for Redux enhancer.\r\n *\r\n * @default true\r\n */\r\n shouldHotReload?: boolean\r\n /**\r\n * if specified as `true`, whenever there's an exception in reducers, the monitors will show the error message, and next actions will not be dispatched.\r\n *\r\n * @default false\r\n */\r\n shouldCatchErrors?: boolean\r\n /**\r\n * If you want to restrict the extension, specify the features you allow.\r\n * If not specified, all of the features are enabled. When set as an object, only those included as `true` will be allowed.\r\n * Note that except `true`/`false`, `import` and `export` can be set as `custom` (which is by default for Redux enhancer), meaning that the importing/exporting occurs on the client side.\r\n * Otherwise, you'll get/set the data right from the monitor part.\r\n */\r\n features?: {\r\n /**\r\n * start/pause recording of dispatched actions\r\n */\r\n pause?: boolean\r\n /**\r\n * lock/unlock dispatching actions and side effects\r\n */\r\n lock?: boolean\r\n /**\r\n * persist states on page reloading\r\n */\r\n persist?: boolean\r\n /**\r\n * export history of actions in a file\r\n */\r\n export?: boolean | 'custom'\r\n /**\r\n * import history of actions from a file\r\n */\r\n import?: boolean | 'custom'\r\n /**\r\n * jump back and forth (time travelling)\r\n */\r\n jump?: boolean\r\n /**\r\n * skip (cancel) actions\r\n */\r\n skip?: boolean\r\n /**\r\n * drag and drop actions in the history list\r\n */\r\n reorder?: boolean\r\n /**\r\n * dispatch custom actions or action creators\r\n */\r\n dispatch?: boolean\r\n /**\r\n * generate tests for the selected actions\r\n */\r\n test?: boolean\r\n }\r\n /**\r\n * Set to true or a stacktrace-returning function to record call stack traces for dispatched actions.\r\n * Defaults to false.\r\n */\r\n trace?: boolean | ((action: A) => string)\r\n /**\r\n * The maximum number of stack trace entries to record per action. Defaults to 10.\r\n */\r\n traceLimit?: number\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport const composeWithDevTools: {\r\n (options: EnhancerOptions): typeof compose\r\n (...funcs: Array>): StoreEnhancer\r\n} =\r\n typeof window !== 'undefined' &&\r\n (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__\r\n ? (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__\r\n : function () {\r\n if (arguments.length === 0) return undefined\r\n if (typeof arguments[0] === 'object') return compose\r\n return compose.apply(null, arguments as any as Function[])\r\n }\r\n\r\n/**\r\n * @public\r\n */\r\nexport const devToolsEnhancer: {\r\n (options: EnhancerOptions): StoreEnhancer\r\n} =\r\n typeof window !== 'undefined' && (window as any).__REDUX_DEVTOOLS_EXTENSION__\r\n ? (window as any).__REDUX_DEVTOOLS_EXTENSION__\r\n : function () {\r\n return function (noop) {\r\n return noop\r\n }\r\n }\r\n","/**\r\n * Returns true if the passed value is \"plain\" object, i.e. an object whose\r\n * prototype is the root `Object.prototype`. This includes objects created\r\n * using object literals, but not for instance for class instances.\r\n *\r\n * @param {any} value The value to inspect.\r\n * @returns {boolean} True if the argument appears to be a plain object.\r\n *\r\n * @public\r\n */\r\nexport default function isPlainObject(value: unknown): value is object {\r\n if (typeof value !== 'object' || value === null) return false\r\n\r\n let proto = value\r\n while (Object.getPrototypeOf(proto) !== null) {\r\n proto = Object.getPrototypeOf(proto)\r\n }\r\n\r\n return Object.getPrototypeOf(value) === proto\r\n}\r\n","import type { Middleware, AnyAction } from 'redux'\r\nimport type { ThunkMiddleware } from 'redux-thunk'\r\nimport thunkMiddleware from 'redux-thunk'\r\nimport type { ImmutableStateInvariantMiddlewareOptions } from './immutableStateInvariantMiddleware'\r\n/* PROD_START_REMOVE_UMD */\r\nimport { createImmutableStateInvariantMiddleware } from './immutableStateInvariantMiddleware'\r\n/* PROD_STOP_REMOVE_UMD */\r\n\r\nimport type { SerializableStateInvariantMiddlewareOptions } from './serializableStateInvariantMiddleware'\r\nimport { createSerializableStateInvariantMiddleware } from './serializableStateInvariantMiddleware'\r\nimport { MiddlewareArray } from './utils'\r\n\r\nfunction isBoolean(x: any): x is boolean {\r\n return typeof x === 'boolean'\r\n}\r\n\r\ninterface ThunkOptions {\r\n extraArgument: E\r\n}\r\n\r\ninterface GetDefaultMiddlewareOptions {\r\n thunk?: boolean | ThunkOptions\r\n immutableCheck?: boolean | ImmutableStateInvariantMiddlewareOptions\r\n serializableCheck?: boolean | SerializableStateInvariantMiddlewareOptions\r\n}\r\n\r\nexport type ThunkMiddlewareFor<\r\n S,\r\n O extends GetDefaultMiddlewareOptions = {}\r\n> = O extends {\r\n thunk: false\r\n}\r\n ? never\r\n : O extends { thunk: { extraArgument: infer E } }\r\n ? ThunkMiddleware\r\n :\r\n | ThunkMiddleware //The ThunkMiddleware with a `null` ExtraArgument is here to provide backwards-compatibility.\r\n | ThunkMiddleware\r\n\r\nexport type CurriedGetDefaultMiddleware = <\r\n O extends Partial = {\r\n thunk: true\r\n immutableCheck: true\r\n serializableCheck: true\r\n }\r\n>(\r\n options?: O\r\n) => MiddlewareArray | ThunkMiddlewareFor>\r\n\r\nexport function curryGetDefaultMiddleware<\r\n S = any\r\n>(): CurriedGetDefaultMiddleware {\r\n return function curriedGetDefaultMiddleware(options) {\r\n return getDefaultMiddleware(options)\r\n }\r\n}\r\n\r\n/**\r\n * Returns any array containing the default middleware installed by\r\n * `configureStore()`. Useful if you want to configure your store with a custom\r\n * `middleware` array but still keep the default set.\r\n *\r\n * @return The default middleware used by `configureStore()`.\r\n *\r\n * @public\r\n *\r\n * @deprecated Prefer to use the callback notation for the `middleware` option in `configureStore`\r\n * to access a pre-typed `getDefaultMiddleware` instead.\r\n */\r\nexport function getDefaultMiddleware<\r\n S = any,\r\n O extends Partial = {\r\n thunk: true\r\n immutableCheck: true\r\n serializableCheck: true\r\n }\r\n>(\r\n options: O = {} as O\r\n): MiddlewareArray | ThunkMiddlewareFor> {\r\n const {\r\n thunk = true,\r\n immutableCheck = true,\r\n serializableCheck = true,\r\n } = options\r\n\r\n let middlewareArray: Middleware<{}, S>[] = new MiddlewareArray()\r\n\r\n if (thunk) {\r\n if (isBoolean(thunk)) {\r\n middlewareArray.push(thunkMiddleware)\r\n } else {\r\n middlewareArray.push(\r\n thunkMiddleware.withExtraArgument(thunk.extraArgument)\r\n )\r\n }\r\n }\r\n\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (immutableCheck) {\r\n /* PROD_START_REMOVE_UMD */\r\n let immutableOptions: ImmutableStateInvariantMiddlewareOptions = {}\r\n\r\n if (!isBoolean(immutableCheck)) {\r\n immutableOptions = immutableCheck\r\n }\r\n\r\n middlewareArray.unshift(\r\n createImmutableStateInvariantMiddleware(immutableOptions)\r\n )\r\n /* PROD_STOP_REMOVE_UMD */\r\n }\r\n\r\n if (serializableCheck) {\r\n let serializableOptions: SerializableStateInvariantMiddlewareOptions = {}\r\n\r\n if (!isBoolean(serializableCheck)) {\r\n serializableOptions = serializableCheck\r\n }\r\n\r\n middlewareArray.push(\r\n createSerializableStateInvariantMiddleware(serializableOptions)\r\n )\r\n }\r\n }\r\n\r\n return middlewareArray as any\r\n}\r\n","import type { Middleware } from 'redux'\r\n\r\nexport function getTimeMeasureUtils(maxDelay: number, fnName: string) {\r\n let elapsed = 0\r\n return {\r\n measureTime(fn: () => T): T {\r\n const started = Date.now()\r\n try {\r\n return fn()\r\n } finally {\r\n const finished = Date.now()\r\n elapsed += finished - started\r\n }\r\n },\r\n warnIfExceeded() {\r\n if (elapsed > maxDelay) {\r\n console.warn(`${fnName} took ${elapsed}ms, which is more than the warning threshold of ${maxDelay}ms. \r\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.\r\nIt is disabled in production builds, so you don't need to worry about that.`)\r\n }\r\n },\r\n }\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport class MiddlewareArray<\r\n Middlewares extends Middleware\r\n> extends Array {\r\n constructor(arrayLength?: number)\r\n constructor(...items: Middlewares[])\r\n constructor(...args: any[]) {\r\n super(...args)\r\n Object.setPrototypeOf(this, MiddlewareArray.prototype)\r\n }\r\n\r\n static get [Symbol.species]() {\r\n return MiddlewareArray as any\r\n }\r\n\r\n concat>>(\r\n items: AdditionalMiddlewares\r\n ): MiddlewareArray\r\n\r\n concat>>(\r\n ...items: AdditionalMiddlewares\r\n ): MiddlewareArray\r\n concat(...arr: any[]) {\r\n return super.concat.apply(this, arr)\r\n }\r\n\r\n prepend>>(\r\n items: AdditionalMiddlewares\r\n ): MiddlewareArray\r\n\r\n prepend>>(\r\n ...items: AdditionalMiddlewares\r\n ): MiddlewareArray\r\n\r\n prepend(...arr: any[]) {\r\n if (arr.length === 1 && Array.isArray(arr[0])) {\r\n return new MiddlewareArray(...arr[0].concat(this))\r\n }\r\n return new MiddlewareArray(...arr.concat(this))\r\n }\r\n}\r\n","import type { Middleware } from 'redux'\r\nimport { getTimeMeasureUtils } from './utils'\r\n\r\ntype EntryProcessor = (key: string, value: any) => any\r\n\r\nconst isProduction: boolean = process.env.NODE_ENV === 'production'\r\nconst prefix: string = 'Invariant failed'\r\n\r\n// Throw an error if the condition fails\r\n// Strip out error messages for production\r\n// > Not providing an inline default argument for message as the result is smaller\r\nfunction invariant(condition: any, message?: string) {\r\n if (condition) {\r\n return\r\n }\r\n // Condition not passed\r\n\r\n // In production we strip the message but still throw\r\n if (isProduction) {\r\n throw new Error(prefix)\r\n }\r\n\r\n // When not in production we allow the message to pass through\r\n // *This block will be removed in production builds*\r\n throw new Error(`${prefix}: ${message || ''}`)\r\n}\r\n\r\nfunction stringify(\r\n obj: any,\r\n serializer?: EntryProcessor,\r\n indent?: string | number,\r\n decycler?: EntryProcessor\r\n): string {\r\n return JSON.stringify(obj, getSerialize(serializer, decycler), indent)\r\n}\r\n\r\nfunction getSerialize(\r\n serializer?: EntryProcessor,\r\n decycler?: EntryProcessor\r\n): EntryProcessor {\r\n let stack: any[] = [],\r\n keys: any[] = []\r\n\r\n if (!decycler)\r\n decycler = function (_: string, value: any) {\r\n if (stack[0] === value) return '[Circular ~]'\r\n return (\r\n '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']'\r\n )\r\n }\r\n\r\n return function (this: any, key: string, value: any) {\r\n if (stack.length > 0) {\r\n var thisPos = stack.indexOf(this)\r\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this)\r\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)\r\n if (~stack.indexOf(value)) value = decycler!.call(this, key, value)\r\n } else stack.push(value)\r\n\r\n return serializer == null ? value : serializer.call(this, key, value)\r\n }\r\n}\r\n\r\n/**\r\n * The default `isImmutable` function.\r\n *\r\n * @public\r\n */\r\nexport function isImmutableDefault(value: unknown): boolean {\r\n return (\r\n typeof value !== 'object' ||\r\n value === null ||\r\n typeof value === 'undefined' ||\r\n Object.isFrozen(value)\r\n )\r\n}\r\n\r\nexport function trackForMutations(\r\n isImmutable: IsImmutableFunc,\r\n ignorePaths: string[] | undefined,\r\n obj: any\r\n) {\r\n const trackedProperties = trackProperties(isImmutable, ignorePaths, obj)\r\n return {\r\n detectMutations() {\r\n return detectMutations(isImmutable, ignorePaths, trackedProperties, obj)\r\n },\r\n }\r\n}\r\n\r\ninterface TrackedProperty {\r\n value: any\r\n children: Record\r\n}\r\n\r\nfunction trackProperties(\r\n isImmutable: IsImmutableFunc,\r\n ignorePaths: IgnorePaths = [],\r\n obj: Record,\r\n path: string = ''\r\n) {\r\n const tracked: Partial = { value: obj }\r\n\r\n if (!isImmutable(obj)) {\r\n tracked.children = {}\r\n\r\n for (const key in obj) {\r\n const childPath = path ? path + '.' + key : key\r\n if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {\r\n continue\r\n }\r\n\r\n tracked.children[key] = trackProperties(\r\n isImmutable,\r\n ignorePaths,\r\n obj[key],\r\n childPath\r\n )\r\n }\r\n }\r\n return tracked as TrackedProperty\r\n}\r\n\r\ntype IgnorePaths = readonly string[]\r\n\r\nfunction detectMutations(\r\n isImmutable: IsImmutableFunc,\r\n ignorePaths: IgnorePaths = [],\r\n trackedProperty: TrackedProperty,\r\n obj: any,\r\n sameParentRef: boolean = false,\r\n path: string = ''\r\n): { wasMutated: boolean; path?: string } {\r\n const prevObj = trackedProperty ? trackedProperty.value : undefined\r\n\r\n const sameRef = prevObj === obj\r\n\r\n if (sameParentRef && !sameRef && !Number.isNaN(obj)) {\r\n return { wasMutated: true, path }\r\n }\r\n\r\n if (isImmutable(prevObj) || isImmutable(obj)) {\r\n return { wasMutated: false }\r\n }\r\n\r\n // Gather all keys from prev (tracked) and after objs\r\n const keysToDetect: Record = {}\r\n for (let key in trackedProperty.children) {\r\n keysToDetect[key] = true\r\n }\r\n for (let key in obj) {\r\n keysToDetect[key] = true\r\n }\r\n\r\n for (let key in keysToDetect) {\r\n const childPath = path ? path + '.' + key : key\r\n if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {\r\n continue\r\n }\r\n\r\n const result = detectMutations(\r\n isImmutable,\r\n ignorePaths,\r\n trackedProperty.children[key],\r\n obj[key],\r\n sameRef,\r\n childPath\r\n )\r\n\r\n if (result.wasMutated) {\r\n return result\r\n }\r\n }\r\n return { wasMutated: false }\r\n}\r\n\r\ntype IsImmutableFunc = (value: any) => boolean\r\n\r\n/**\r\n * Options for `createImmutableStateInvariantMiddleware()`.\r\n *\r\n * @public\r\n */\r\nexport interface ImmutableStateInvariantMiddlewareOptions {\r\n /**\r\n Callback function to check if a value is considered to be immutable.\r\n This function is applied recursively to every value contained in the state.\r\n The default implementation will return true for primitive types \r\n (like numbers, strings, booleans, null and undefined).\r\n */\r\n isImmutable?: IsImmutableFunc\r\n /** \r\n An array of dot-separated path strings that match named nodes from \r\n the root state to ignore when checking for immutability.\r\n Defaults to undefined\r\n */\r\n ignoredPaths?: string[]\r\n /** Print a warning if checks take longer than N ms. Default: 32ms */\r\n warnAfter?: number\r\n // @deprecated. Use ignoredPaths\r\n ignore?: string[]\r\n}\r\n\r\n/**\r\n * Creates a middleware that checks whether any state was mutated in between\r\n * dispatches or during a dispatch. If any mutations are detected, an error is\r\n * thrown.\r\n *\r\n * @param options Middleware options.\r\n *\r\n * @public\r\n */\r\nexport function createImmutableStateInvariantMiddleware(\r\n options: ImmutableStateInvariantMiddlewareOptions = {}\r\n): Middleware {\r\n if (process.env.NODE_ENV === 'production') {\r\n return () => (next) => (action) => next(action)\r\n }\r\n\r\n let {\r\n isImmutable = isImmutableDefault,\r\n ignoredPaths,\r\n warnAfter = 32,\r\n ignore,\r\n } = options\r\n\r\n // Alias ignore->ignoredPaths, but prefer ignoredPaths if present\r\n ignoredPaths = ignoredPaths || ignore\r\n\r\n const track = trackForMutations.bind(null, isImmutable, ignoredPaths)\r\n\r\n return ({ getState }) => {\r\n let state = getState()\r\n let tracker = track(state)\r\n\r\n let result\r\n return (next) => (action) => {\r\n const measureUtils = getTimeMeasureUtils(\r\n warnAfter,\r\n 'ImmutableStateInvariantMiddleware'\r\n )\r\n\r\n measureUtils.measureTime(() => {\r\n state = getState()\r\n\r\n result = tracker.detectMutations()\r\n // Track before potentially not meeting the invariant\r\n tracker = track(state)\r\n\r\n invariant(\r\n !result.wasMutated,\r\n `A state mutation was detected between dispatches, in the path '${\r\n result.path || ''\r\n }'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`\r\n )\r\n })\r\n\r\n const dispatchedAction = next(action)\r\n\r\n measureUtils.measureTime(() => {\r\n state = getState()\r\n\r\n result = tracker.detectMutations()\r\n // Track before potentially not meeting the invariant\r\n tracker = track(state)\r\n\r\n result.wasMutated &&\r\n invariant(\r\n !result.wasMutated,\r\n `A state mutation was detected inside a dispatch, in the path: ${\r\n result.path || ''\r\n }. Take a look at the reducer(s) handling the action ${stringify(\r\n action\r\n )}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`\r\n )\r\n })\r\n\r\n measureUtils.warnIfExceeded()\r\n\r\n return dispatchedAction\r\n }\r\n }\r\n}\r\n","import isPlainObject from './isPlainObject'\r\nimport type { Middleware } from 'redux'\r\nimport { getTimeMeasureUtils } from './utils'\r\n\r\n/**\r\n * Returns true if the passed value is \"plain\", i.e. a value that is either\r\n * directly JSON-serializable (boolean, number, string, array, plain object)\r\n * or `undefined`.\r\n *\r\n * @param val The value to check.\r\n *\r\n * @public\r\n */\r\nexport function isPlain(val: any) {\r\n const type = typeof val\r\n return (\r\n type === 'undefined' ||\r\n val === null ||\r\n type === 'string' ||\r\n type === 'boolean' ||\r\n type === 'number' ||\r\n Array.isArray(val) ||\r\n isPlainObject(val)\r\n )\r\n}\r\n\r\ninterface NonSerializableValue {\r\n keyPath: string\r\n value: unknown\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport function findNonSerializableValue(\r\n value: unknown,\r\n path: string = '',\r\n isSerializable: (value: unknown) => boolean = isPlain,\r\n getEntries?: (value: unknown) => [string, any][],\r\n ignoredPaths: readonly string[] = []\r\n): NonSerializableValue | false {\r\n let foundNestedSerializable: NonSerializableValue | false\r\n\r\n if (!isSerializable(value)) {\r\n return {\r\n keyPath: path || '',\r\n value: value,\r\n }\r\n }\r\n\r\n if (typeof value !== 'object' || value === null) {\r\n return false\r\n }\r\n\r\n const entries = getEntries != null ? getEntries(value) : Object.entries(value)\r\n\r\n const hasIgnoredPaths = ignoredPaths.length > 0\r\n\r\n for (const [key, nestedValue] of entries) {\r\n const nestedPath = path ? path + '.' + key : key\r\n\r\n if (hasIgnoredPaths && ignoredPaths.indexOf(nestedPath) >= 0) {\r\n continue\r\n }\r\n\r\n if (!isSerializable(nestedValue)) {\r\n return {\r\n keyPath: nestedPath,\r\n value: nestedValue,\r\n }\r\n }\r\n\r\n if (typeof nestedValue === 'object') {\r\n foundNestedSerializable = findNonSerializableValue(\r\n nestedValue,\r\n nestedPath,\r\n isSerializable,\r\n getEntries,\r\n ignoredPaths\r\n )\r\n\r\n if (foundNestedSerializable) {\r\n return foundNestedSerializable\r\n }\r\n }\r\n }\r\n\r\n return false\r\n}\r\n\r\n/**\r\n * Options for `createSerializableStateInvariantMiddleware()`.\r\n *\r\n * @public\r\n */\r\nexport interface SerializableStateInvariantMiddlewareOptions {\r\n /**\r\n * The function to check if a value is considered serializable. This\r\n * function is applied recursively to every value contained in the\r\n * state. Defaults to `isPlain()`.\r\n */\r\n isSerializable?: (value: any) => boolean\r\n /**\r\n * The function that will be used to retrieve entries from each\r\n * value. If unspecified, `Object.entries` will be used. Defaults\r\n * to `undefined`.\r\n */\r\n getEntries?: (value: any) => [string, any][]\r\n\r\n /**\r\n * An array of action types to ignore when checking for serializability.\r\n * Defaults to []\r\n */\r\n ignoredActions?: string[]\r\n\r\n /**\r\n * An array of dot-separated path strings to ignore when checking\r\n * for serializability, Defaults to ['meta.arg']\r\n */\r\n ignoredActionPaths?: string[]\r\n\r\n /**\r\n * An array of dot-separated path strings to ignore when checking\r\n * for serializability, Defaults to []\r\n */\r\n ignoredPaths?: string[]\r\n /**\r\n * Execution time warning threshold. If the middleware takes longer\r\n * than `warnAfter` ms, a warning will be displayed in the console.\r\n * Defaults to 32ms.\r\n */\r\n warnAfter?: number\r\n\r\n /**\r\n * Opt out of checking state, but continue checking actions\r\n */\r\n ignoreState?: boolean\r\n}\r\n\r\n/**\r\n * Creates a middleware that, after every state change, checks if the new\r\n * state is serializable. If a non-serializable value is found within the\r\n * state, an error is printed to the console.\r\n *\r\n * @param options Middleware options.\r\n *\r\n * @public\r\n */\r\nexport function createSerializableStateInvariantMiddleware(\r\n options: SerializableStateInvariantMiddlewareOptions = {}\r\n): Middleware {\r\n if (process.env.NODE_ENV === 'production') {\r\n return () => (next) => (action) => next(action)\r\n }\r\n const {\r\n isSerializable = isPlain,\r\n getEntries,\r\n ignoredActions = [],\r\n ignoredActionPaths = ['meta.arg', 'meta.baseQueryMeta'],\r\n ignoredPaths = [],\r\n warnAfter = 32,\r\n ignoreState = false,\r\n } = options\r\n\r\n return (storeAPI) => (next) => (action) => {\r\n if (ignoredActions.length && ignoredActions.indexOf(action.type) !== -1) {\r\n return next(action)\r\n }\r\n\r\n const measureUtils = getTimeMeasureUtils(\r\n warnAfter,\r\n 'SerializableStateInvariantMiddleware'\r\n )\r\n measureUtils.measureTime(() => {\r\n const foundActionNonSerializableValue = findNonSerializableValue(\r\n action,\r\n '',\r\n isSerializable,\r\n getEntries,\r\n ignoredActionPaths\r\n )\r\n\r\n if (foundActionNonSerializableValue) {\r\n const { keyPath, value } = foundActionNonSerializableValue\r\n\r\n console.error(\r\n `A non-serializable value was detected in an action, in the path: \\`${keyPath}\\`. Value:`,\r\n value,\r\n '\\nTake a look at the logic that dispatched this action: ',\r\n action,\r\n '\\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)',\r\n '\\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)'\r\n )\r\n }\r\n })\r\n\r\n const result = next(action)\r\n\r\n if (!ignoreState) {\r\n measureUtils.measureTime(() => {\r\n const state = storeAPI.getState()\r\n\r\n const foundStateNonSerializableValue = findNonSerializableValue(\r\n state,\r\n '',\r\n isSerializable,\r\n getEntries,\r\n ignoredPaths\r\n )\r\n\r\n if (foundStateNonSerializableValue) {\r\n const { keyPath, value } = foundStateNonSerializableValue\r\n\r\n console.error(\r\n `A non-serializable value was detected in the state, in the path: \\`${keyPath}\\`. Value:`,\r\n value,\r\n `\r\nTake a look at the reducer(s) handling this action type: ${action.type}.\r\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`\r\n )\r\n }\r\n })\r\n\r\n measureUtils.warnIfExceeded()\r\n }\r\n\r\n return result\r\n }\r\n}\r\n","import type { Action } from 'redux'\r\nimport type {\r\n IsUnknownOrNonInferrable,\r\n IfMaybeUndefined,\r\n IfVoid,\r\n IsAny,\r\n} from './tsHelpers'\r\nimport isPlainObject from './isPlainObject'\r\n\r\n/**\r\n * An action with a string type and an associated payload. This is the\r\n * type of action returned by `createAction()` action creators.\r\n *\r\n * @template P The type of the action's payload.\r\n * @template T the type used for the action type.\r\n * @template M The type of the action's meta (optional)\r\n * @template E The type of the action's error (optional)\r\n *\r\n * @public\r\n */\r\nexport type PayloadAction<\r\n P = void,\r\n T extends string = string,\r\n M = never,\r\n E = never\r\n> = {\r\n payload: P\r\n type: T\r\n} & ([M] extends [never]\r\n ? {}\r\n : {\r\n meta: M\r\n }) &\r\n ([E] extends [never]\r\n ? {}\r\n : {\r\n error: E\r\n })\r\n\r\n/**\r\n * A \"prepare\" method to be used as the second parameter of `createAction`.\r\n * Takes any number of arguments and returns a Flux Standard Action without\r\n * type (will be added later) that *must* contain a payload (might be undefined).\r\n *\r\n * @public\r\n */\r\nexport type PrepareAction

=\r\n | ((...args: any[]) => { payload: P })\r\n | ((...args: any[]) => { payload: P; meta: any })\r\n | ((...args: any[]) => { payload: P; error: any })\r\n | ((...args: any[]) => { payload: P; meta: any; error: any })\r\n\r\n/**\r\n * Internal version of `ActionCreatorWithPreparedPayload`. Not to be used externally.\r\n *\r\n * @internal\r\n */\r\nexport type _ActionCreatorWithPreparedPayload<\r\n PA extends PrepareAction | void,\r\n T extends string = string\r\n> = PA extends PrepareAction\r\n ? ActionCreatorWithPreparedPayload<\r\n Parameters,\r\n P,\r\n T,\r\n ReturnType extends {\r\n error: infer E\r\n }\r\n ? E\r\n : never,\r\n ReturnType extends {\r\n meta: infer M\r\n }\r\n ? M\r\n : never\r\n >\r\n : void\r\n\r\n/**\r\n * Basic type for all action creators.\r\n *\r\n * @inheritdoc {redux#ActionCreator}\r\n */\r\ninterface BaseActionCreator {\r\n type: T\r\n match: (action: Action) => action is PayloadAction\r\n}\r\n\r\n/**\r\n * An action creator that takes multiple arguments that are passed\r\n * to a `PrepareAction` method to create the final Action.\r\n * @typeParam Args arguments for the action creator function\r\n * @typeParam P `payload` type\r\n * @typeParam T `type` name\r\n * @typeParam E optional `error` type\r\n * @typeParam M optional `meta` type\r\n *\r\n * @inheritdoc {redux#ActionCreator}\r\n *\r\n * @public\r\n */\r\nexport interface ActionCreatorWithPreparedPayload<\r\n Args extends unknown[],\r\n P,\r\n T extends string = string,\r\n E = never,\r\n M = never\r\n> extends BaseActionCreator {\r\n /**\r\n * Calling this {@link redux#ActionCreator} with `Args` will return\r\n * an Action with a payload of type `P` and (depending on the `PrepareAction`\r\n * method used) a `meta`- and `error` property of types `M` and `E` respectively.\r\n */\r\n (...args: Args): PayloadAction\r\n}\r\n\r\n/**\r\n * An action creator of type `T` that takes an optional payload of type `P`.\r\n *\r\n * @inheritdoc {redux#ActionCreator}\r\n *\r\n * @public\r\n */\r\nexport interface ActionCreatorWithOptionalPayload\r\n extends BaseActionCreator {\r\n /**\r\n * Calling this {@link redux#ActionCreator} with an argument will\r\n * return a {@link PayloadAction} of type `T` with a payload of `P`.\r\n * Calling it without an argument will return a PayloadAction with a payload of `undefined`.\r\n */\r\n (payload?: P): PayloadAction\r\n}\r\n\r\n/**\r\n * An action creator of type `T` that takes no payload.\r\n *\r\n * @inheritdoc {redux#ActionCreator}\r\n *\r\n * @public\r\n */\r\nexport interface ActionCreatorWithoutPayload\r\n extends BaseActionCreator {\r\n /**\r\n * Calling this {@link redux#ActionCreator} will\r\n * return a {@link PayloadAction} of type `T` with a payload of `undefined`\r\n */\r\n (): PayloadAction\r\n}\r\n\r\n/**\r\n * An action creator of type `T` that requires a payload of type P.\r\n *\r\n * @inheritdoc {redux#ActionCreator}\r\n *\r\n * @public\r\n */\r\nexport interface ActionCreatorWithPayload\r\n extends BaseActionCreator {\r\n /**\r\n * Calling this {@link redux#ActionCreator} with an argument will\r\n * return a {@link PayloadAction} of type `T` with a payload of `P`\r\n */\r\n (payload: P): PayloadAction\r\n}\r\n\r\n/**\r\n * An action creator of type `T` whose `payload` type could not be inferred. Accepts everything as `payload`.\r\n *\r\n * @inheritdoc {redux#ActionCreator}\r\n *\r\n * @public\r\n */\r\nexport interface ActionCreatorWithNonInferrablePayload<\r\n T extends string = string\r\n> extends BaseActionCreator {\r\n /**\r\n * Calling this {@link redux#ActionCreator} with an argument will\r\n * return a {@link PayloadAction} of type `T` with a payload\r\n * of exactly the type of the argument.\r\n */\r\n (payload: PT): PayloadAction\r\n}\r\n\r\n/**\r\n * An action creator that produces actions with a `payload` attribute.\r\n *\r\n * @typeParam P the `payload` type\r\n * @typeParam T the `type` of the resulting action\r\n * @typeParam PA if the resulting action is preprocessed by a `prepare` method, the signature of said method.\r\n *\r\n * @public\r\n */\r\nexport type PayloadActionCreator<\r\n P = void,\r\n T extends string = string,\r\n PA extends PrepareAction

| void = void\r\n> = IfPrepareActionMethodProvided<\r\n PA,\r\n _ActionCreatorWithPreparedPayload,\r\n // else\r\n IsAny<\r\n P,\r\n ActionCreatorWithPayload,\r\n IsUnknownOrNonInferrable<\r\n P,\r\n ActionCreatorWithNonInferrablePayload,\r\n // else\r\n IfVoid<\r\n P,\r\n ActionCreatorWithoutPayload,\r\n // else\r\n IfMaybeUndefined<\r\n P,\r\n ActionCreatorWithOptionalPayload,\r\n // else\r\n ActionCreatorWithPayload\r\n >\r\n >\r\n >\r\n >\r\n>\r\n\r\n/**\r\n * A utility function to create an action creator for the given action type\r\n * string. The action creator accepts a single argument, which will be included\r\n * in the action object as a field called payload. The action creator function\r\n * will also have its toString() overriden so that it returns the action type,\r\n * allowing it to be used in reducer logic that is looking for that action type.\r\n *\r\n * @param type The action type to use for created actions.\r\n * @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }.\r\n * If this is given, the resulting action creator will pass its arguments to this method to calculate payload & meta.\r\n *\r\n * @public\r\n */\r\nexport function createAction

= PayloadActionCreator

\r\n\r\n/**\r\n * The return value of `createSlice`\r\n *\r\n * @public\r\n */\r\nexport interface Slice<\r\n State = any,\r\n CaseReducers extends SliceCaseReducers = SliceCaseReducers,\r\n Name extends string = string\r\n> {\r\n /**\r\n * The slice name.\r\n */\r\n name: Name\r\n\r\n /**\r\n * The slice's reducer.\r\n */\r\n reducer: Reducer\r\n\r\n /**\r\n * Action creators for the types of actions that are handled by the slice\r\n * reducer.\r\n */\r\n actions: CaseReducerActions\r\n\r\n /**\r\n * The individual case reducer functions that were passed in the `reducers` parameter.\r\n * This enables reuse and testing if they were defined inline when calling `createSlice`.\r\n */\r\n caseReducers: SliceDefinedCaseReducers\r\n}\r\n\r\n/**\r\n * Options for `createSlice()`.\r\n *\r\n * @public\r\n */\r\nexport interface CreateSliceOptions<\r\n State = any,\r\n CR extends SliceCaseReducers = SliceCaseReducers,\r\n Name extends string = string\r\n> {\r\n /**\r\n * The slice's name. Used to namespace the generated action types.\r\n */\r\n name: Name\r\n\r\n /**\r\n * The initial state to be returned by the slice reducer.\r\n */\r\n initialState: State\r\n\r\n /**\r\n * A mapping from action types to action-type-specific *case reducer*\r\n * functions. For every action type, a matching action creator will be\r\n * generated using `createAction()`.\r\n */\r\n reducers: ValidateSliceCaseReducers\r\n\r\n /**\r\n * A callback that receives a *builder* object to define\r\n * case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.\r\n * \r\n * Alternatively, a mapping from action types to action-type-specific *case reducer*\r\n * functions. These reducers should have existing action types used\r\n * as the keys, and action creators will _not_ be generated.\r\n * \r\n * @example\r\n```ts\r\nimport { createAction, createSlice, Action, AnyAction } from '@reduxjs/toolkit'\r\nconst incrementBy = createAction('incrementBy')\r\nconst decrement = createAction('decrement')\r\n\r\ninterface RejectedAction extends Action {\r\n error: Error\r\n}\r\n\r\nfunction isRejectedAction(action: AnyAction): action is RejectedAction {\r\n return action.type.endsWith('rejected')\r\n}\r\n\r\ncreateSlice({\r\n name: 'counter',\r\n initialState: 0,\r\n reducers: {},\r\n extraReducers: builder => {\r\n builder\r\n .addCase(incrementBy, (state, action) => {\r\n // action is inferred correctly here if using TS\r\n })\r\n // You can chain calls, or have separate `builder.addCase()` lines each time\r\n .addCase(decrement, (state, action) => {})\r\n // You can match a range of action types\r\n .addMatcher(\r\n isRejectedAction,\r\n // `action` will be inferred as a RejectedAction due to isRejectedAction being defined as a type guard\r\n (state, action) => {}\r\n )\r\n // and provide a default case if no other handlers matched\r\n .addDefaultCase((state, action) => {})\r\n }\r\n})\r\n```\r\n */\r\n extraReducers?:\r\n | CaseReducers, any>\r\n | ((builder: ActionReducerMapBuilder>) => void)\r\n}\r\n\r\n/**\r\n * A CaseReducer with a `prepare` method.\r\n *\r\n * @public\r\n */\r\nexport type CaseReducerWithPrepare = {\r\n reducer: CaseReducer\r\n prepare: PrepareAction\r\n}\r\n\r\n/**\r\n * The type describing a slice's `reducers` option.\r\n *\r\n * @public\r\n */\r\nexport type SliceCaseReducers = {\r\n [K: string]:\r\n | CaseReducer>\r\n | CaseReducerWithPrepare>\r\n}\r\n\r\n/**\r\n * Derives the slice's `actions` property from the `reducers` options\r\n *\r\n * @public\r\n */\r\nexport type CaseReducerActions> = {\r\n [Type in keyof CaseReducers]: CaseReducers[Type] extends { prepare: any }\r\n ? ActionCreatorForCaseReducerWithPrepare\r\n : ActionCreatorForCaseReducer\r\n}\r\n\r\n/**\r\n * Get a `PayloadActionCreator` type for a passed `CaseReducerWithPrepare`\r\n *\r\n * @internal\r\n */\r\ntype ActionCreatorForCaseReducerWithPrepare =\r\n _ActionCreatorWithPreparedPayload\r\n\r\n/**\r\n * Get a `PayloadActionCreator` type for a passed `CaseReducer`\r\n *\r\n * @internal\r\n */\r\ntype ActionCreatorForCaseReducer = CR extends (\r\n state: any,\r\n action: infer Action\r\n) => any\r\n ? Action extends { payload: infer P }\r\n ? PayloadActionCreator

\r\n : ActionCreatorWithoutPayload\r\n : ActionCreatorWithoutPayload\r\n\r\n/**\r\n * Extracts the CaseReducers out of a `reducers` object, even if they are\r\n * tested into a `CaseReducerWithPrepare`.\r\n *\r\n * @internal\r\n */\r\ntype SliceDefinedCaseReducers> = {\r\n [Type in keyof CaseReducers]: CaseReducers[Type] extends {\r\n reducer: infer Reducer\r\n }\r\n ? Reducer\r\n : CaseReducers[Type]\r\n}\r\n\r\n/**\r\n * Used on a SliceCaseReducers object.\r\n * Ensures that if a CaseReducer is a `CaseReducerWithPrepare`, that\r\n * the `reducer` and the `prepare` function use the same type of `payload`.\r\n *\r\n * Might do additional such checks in the future.\r\n *\r\n * This type is only ever useful if you want to write your own wrapper around\r\n * `createSlice`. Please don't use it otherwise!\r\n *\r\n * @public\r\n */\r\nexport type ValidateSliceCaseReducers<\r\n S,\r\n ACR extends SliceCaseReducers\r\n> = ACR &\r\n {\r\n [T in keyof ACR]: ACR[T] extends {\r\n reducer(s: S, action?: infer A): any\r\n }\r\n ? {\r\n prepare(...a: never[]): Omit\r\n }\r\n : {}\r\n }\r\n\r\nfunction getType(slice: string, actionKey: string): string {\r\n return `${slice}/${actionKey}`\r\n}\r\n\r\n/**\r\n * A function that accepts an initial state, an object full of reducer\r\n * functions, and a \"slice name\", and automatically generates\r\n * action creators and action types that correspond to the\r\n * reducers and state.\r\n *\r\n * The `reducer` argument is passed to `createReducer()`.\r\n *\r\n * @public\r\n */\r\nexport function createSlice<\r\n State,\r\n CaseReducers extends SliceCaseReducers,\r\n Name extends string = string\r\n>(\r\n options: CreateSliceOptions\r\n): Slice {\r\n const { name, initialState } = options\r\n if (!name) {\r\n throw new Error('`name` is a required option for createSlice')\r\n }\r\n const reducers = options.reducers || {}\r\n const [\r\n extraReducers = {},\r\n actionMatchers = [],\r\n defaultCaseReducer = undefined,\r\n ] =\r\n typeof options.extraReducers === 'function'\r\n ? executeReducerBuilderCallback(options.extraReducers)\r\n : [options.extraReducers]\r\n\r\n const reducerNames = Object.keys(reducers)\r\n\r\n const sliceCaseReducersByName: Record = {}\r\n const sliceCaseReducersByType: Record = {}\r\n const actionCreators: Record = {}\r\n\r\n reducerNames.forEach((reducerName) => {\r\n const maybeReducerWithPrepare = reducers[reducerName]\r\n const type = getType(name, reducerName)\r\n\r\n let caseReducer: CaseReducer\r\n let prepareCallback: PrepareAction | undefined\r\n\r\n if ('reducer' in maybeReducerWithPrepare) {\r\n caseReducer = maybeReducerWithPrepare.reducer\r\n prepareCallback = maybeReducerWithPrepare.prepare\r\n } else {\r\n caseReducer = maybeReducerWithPrepare\r\n }\r\n\r\n sliceCaseReducersByName[reducerName] = caseReducer\r\n sliceCaseReducersByType[type] = caseReducer\r\n actionCreators[reducerName] = prepareCallback\r\n ? createAction(type, prepareCallback)\r\n : createAction(type)\r\n })\r\n\r\n const finalCaseReducers = { ...extraReducers, ...sliceCaseReducersByType }\r\n const reducer = createReducer(\r\n initialState,\r\n finalCaseReducers as any,\r\n actionMatchers,\r\n defaultCaseReducer\r\n )\r\n\r\n return {\r\n name,\r\n reducer,\r\n actions: actionCreators as any,\r\n caseReducers: sliceCaseReducersByName as any,\r\n }\r\n}\r\n","import type { EntityState } from './models'\r\n\r\nexport function getInitialEntityState(): EntityState {\r\n return {\r\n ids: [],\r\n entities: {},\r\n }\r\n}\r\n\r\nexport function createInitialStateFactory() {\r\n function getInitialState(): EntityState\r\n function getInitialState(\r\n additionalState: S\r\n ): EntityState & S\r\n function getInitialState(additionalState: any = {}): any {\r\n return Object.assign(getInitialEntityState(), additionalState)\r\n }\r\n\r\n return { getInitialState }\r\n}\r\n","import { createDraftSafeSelector } from '../createDraftSafeSelector'\r\nimport type {\r\n EntityState,\r\n EntitySelectors,\r\n Dictionary,\r\n EntityId,\r\n} from './models'\r\n\r\nexport function createSelectorsFactory() {\r\n function getSelectors(): EntitySelectors>\r\n function getSelectors(\r\n selectState: (state: V) => EntityState\r\n ): EntitySelectors\r\n function getSelectors(\r\n selectState?: (state: any) => EntityState\r\n ): EntitySelectors {\r\n const selectIds = (state: any) => state.ids\r\n\r\n const selectEntities = (state: EntityState) => state.entities\r\n\r\n const selectAll = createDraftSafeSelector(\r\n selectIds,\r\n selectEntities,\r\n (ids: readonly T[], entities: Dictionary): any =>\r\n ids.map((id: any) => (entities as any)[id])\r\n )\r\n\r\n const selectId = (_: any, id: EntityId) => id\r\n\r\n const selectById = (entities: Dictionary, id: EntityId) => entities[id]\r\n\r\n const selectTotal = createDraftSafeSelector(selectIds, (ids) => ids.length)\r\n\r\n if (!selectState) {\r\n return {\r\n selectIds,\r\n selectEntities,\r\n selectAll,\r\n selectTotal,\r\n selectById: createDraftSafeSelector(\r\n selectEntities,\r\n selectId,\r\n selectById\r\n ),\r\n }\r\n }\r\n\r\n const selectGlobalizedEntities = createDraftSafeSelector(\r\n selectState,\r\n selectEntities\r\n )\r\n\r\n return {\r\n selectIds: createDraftSafeSelector(selectState, selectIds),\r\n selectEntities: selectGlobalizedEntities,\r\n selectAll: createDraftSafeSelector(selectState, selectAll),\r\n selectTotal: createDraftSafeSelector(selectState, selectTotal),\r\n selectById: createDraftSafeSelector(\r\n selectGlobalizedEntities,\r\n selectId,\r\n selectById\r\n ),\r\n }\r\n }\r\n\r\n return { getSelectors }\r\n}\r\n","import createNextState, { isDraft } from 'immer'\r\nimport type { EntityState, PreventAny } from './models'\r\nimport type { PayloadAction } from '../createAction'\r\nimport { isFSA } from '../createAction'\r\nimport { IsAny } from '../tsHelpers'\r\n\r\nexport function createSingleArgumentStateOperator(\r\n mutator: (state: EntityState) => void\r\n) {\r\n const operator = createStateOperator((_: undefined, state: EntityState) =>\r\n mutator(state)\r\n )\r\n\r\n return function operation>(\r\n state: PreventAny\r\n ): S {\r\n return operator(state as S, undefined)\r\n }\r\n}\r\n\r\nexport function createStateOperator(\r\n mutator: (arg: R, state: EntityState) => void\r\n) {\r\n return function operation>(\r\n state: S,\r\n arg: R | PayloadAction\r\n ): S {\r\n function isPayloadActionArgument(\r\n arg: R | PayloadAction\r\n ): arg is PayloadAction {\r\n return isFSA(arg)\r\n }\r\n\r\n const runMutator = (draft: EntityState) => {\r\n if (isPayloadActionArgument(arg)) {\r\n mutator(arg.payload, draft)\r\n } else {\r\n mutator(arg, draft)\r\n }\r\n }\r\n\r\n if (isDraft(state)) {\r\n // we must already be inside a `createNextState` call, likely because\r\n // this is being wrapped in `createReducer` or `createSlice`.\r\n // It's safe to just pass the draft to the mutator.\r\n runMutator(state)\r\n\r\n // since it's a draft, we'll just return it\r\n return state\r\n } else {\r\n // @ts-ignore createNextState() produces an Immutable> rather\r\n // than an Immutable, and TypeScript cannot find out how to reconcile\r\n // these two types.\r\n return createNextState(state, runMutator)\r\n }\r\n }\r\n}\r\n","import type { EntityState, IdSelector, Update, EntityId } from './models'\r\n\r\nexport function selectIdValue(entity: T, selectId: IdSelector) {\r\n const key = selectId(entity)\r\n\r\n if (process.env.NODE_ENV !== 'production' && key === undefined) {\r\n console.warn(\r\n 'The entity passed to the `selectId` implementation returned undefined.',\r\n 'You should probably provide your own `selectId` implementation.',\r\n 'The entity that was passed:',\r\n entity,\r\n 'The `selectId` implementation:',\r\n selectId.toString()\r\n )\r\n }\r\n\r\n return key\r\n}\r\n\r\nexport function ensureEntitiesArray(\r\n entities: readonly T[] | Record\r\n): readonly T[] {\r\n if (!Array.isArray(entities)) {\r\n entities = Object.values(entities)\r\n }\r\n\r\n return entities\r\n}\r\n\r\nexport function splitAddedUpdatedEntities(\r\n newEntities: readonly T[] | Record,\r\n selectId: IdSelector,\r\n state: EntityState\r\n): [T[], Update[]] {\r\n newEntities = ensureEntitiesArray(newEntities)\r\n\r\n const added: T[] = []\r\n const updated: Update[] = []\r\n\r\n for (const entity of newEntities) {\r\n const id = selectIdValue(entity, selectId)\r\n if (id in state.entities) {\r\n updated.push({ id, changes: entity })\r\n } else {\r\n added.push(entity)\r\n }\r\n }\r\n return [added, updated]\r\n}\r\n","import type {\r\n EntityState,\r\n EntityStateAdapter,\r\n IdSelector,\r\n Update,\r\n EntityId,\r\n} from './models'\r\nimport {\r\n createStateOperator,\r\n createSingleArgumentStateOperator,\r\n} from './state_adapter'\r\nimport {\r\n selectIdValue,\r\n ensureEntitiesArray,\r\n splitAddedUpdatedEntities,\r\n} from './utils'\r\n\r\nexport function createUnsortedStateAdapter(\r\n selectId: IdSelector\r\n): EntityStateAdapter {\r\n type R = EntityState\r\n\r\n function addOneMutably(entity: T, state: R): void {\r\n const key = selectIdValue(entity, selectId)\r\n\r\n if (key in state.entities) {\r\n return\r\n }\r\n\r\n state.ids.push(key)\r\n state.entities[key] = entity\r\n }\r\n\r\n function addManyMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n newEntities = ensureEntitiesArray(newEntities)\r\n\r\n for (const entity of newEntities) {\r\n addOneMutably(entity, state)\r\n }\r\n }\r\n\r\n function setOneMutably(entity: T, state: R): void {\r\n const key = selectIdValue(entity, selectId)\r\n if (!(key in state.entities)) {\r\n state.ids.push(key)\r\n }\r\n state.entities[key] = entity\r\n }\r\n\r\n function setManyMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n newEntities = ensureEntitiesArray(newEntities)\r\n for (const entity of newEntities) {\r\n setOneMutably(entity, state)\r\n }\r\n }\r\n\r\n function setAllMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n newEntities = ensureEntitiesArray(newEntities)\r\n\r\n state.ids = []\r\n state.entities = {}\r\n\r\n addManyMutably(newEntities, state)\r\n }\r\n\r\n function removeOneMutably(key: EntityId, state: R): void {\r\n return removeManyMutably([key], state)\r\n }\r\n\r\n function removeManyMutably(keys: readonly EntityId[], state: R): void {\r\n let didMutate = false\r\n\r\n keys.forEach((key) => {\r\n if (key in state.entities) {\r\n delete state.entities[key]\r\n didMutate = true\r\n }\r\n })\r\n\r\n if (didMutate) {\r\n state.ids = state.ids.filter((id) => id in state.entities)\r\n }\r\n }\r\n\r\n function removeAllMutably(state: R): void {\r\n Object.assign(state, {\r\n ids: [],\r\n entities: {},\r\n })\r\n }\r\n\r\n function takeNewKey(\r\n keys: { [id: string]: EntityId },\r\n update: Update,\r\n state: R\r\n ): boolean {\r\n const original = state.entities[update.id]\r\n const updated: T = Object.assign({}, original, update.changes)\r\n const newKey = selectIdValue(updated, selectId)\r\n const hasNewKey = newKey !== update.id\r\n\r\n if (hasNewKey) {\r\n keys[update.id] = newKey\r\n delete state.entities[update.id]\r\n }\r\n\r\n state.entities[newKey] = updated\r\n\r\n return hasNewKey\r\n }\r\n\r\n function updateOneMutably(update: Update, state: R): void {\r\n return updateManyMutably([update], state)\r\n }\r\n\r\n function updateManyMutably(\r\n updates: ReadonlyArray>,\r\n state: R\r\n ): void {\r\n const newKeys: { [id: string]: EntityId } = {}\r\n\r\n const updatesPerEntity: { [id: string]: Update } = {}\r\n\r\n updates.forEach((update) => {\r\n // Only apply updates to entities that currently exist\r\n if (update.id in state.entities) {\r\n // If there are multiple updates to one entity, merge them together\r\n updatesPerEntity[update.id] = {\r\n id: update.id,\r\n // Spreads ignore falsy values, so this works even if there isn't\r\n // an existing update already at this key\r\n changes: {\r\n ...(updatesPerEntity[update.id]\r\n ? updatesPerEntity[update.id].changes\r\n : null),\r\n ...update.changes,\r\n },\r\n }\r\n }\r\n })\r\n\r\n updates = Object.values(updatesPerEntity)\r\n\r\n const didMutateEntities = updates.length > 0\r\n\r\n if (didMutateEntities) {\r\n const didMutateIds =\r\n updates.filter((update) => takeNewKey(newKeys, update, state)).length >\r\n 0\r\n\r\n if (didMutateIds) {\r\n state.ids = state.ids.map((id) => newKeys[id] || id)\r\n }\r\n }\r\n }\r\n\r\n function upsertOneMutably(entity: T, state: R): void {\r\n return upsertManyMutably([entity], state)\r\n }\r\n\r\n function upsertManyMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n const [added, updated] = splitAddedUpdatedEntities(\r\n newEntities,\r\n selectId,\r\n state\r\n )\r\n\r\n updateManyMutably(updated, state)\r\n addManyMutably(added, state)\r\n }\r\n\r\n return {\r\n removeAll: createSingleArgumentStateOperator(removeAllMutably),\r\n addOne: createStateOperator(addOneMutably),\r\n addMany: createStateOperator(addManyMutably),\r\n setOne: createStateOperator(setOneMutably),\r\n setMany: createStateOperator(setManyMutably),\r\n setAll: createStateOperator(setAllMutably),\r\n updateOne: createStateOperator(updateOneMutably),\r\n updateMany: createStateOperator(updateManyMutably),\r\n upsertOne: createStateOperator(upsertOneMutably),\r\n upsertMany: createStateOperator(upsertManyMutably),\r\n removeOne: createStateOperator(removeOneMutably),\r\n removeMany: createStateOperator(removeManyMutably),\r\n }\r\n}\r\n","import type {\r\n EntityState,\r\n IdSelector,\r\n Comparer,\r\n EntityStateAdapter,\r\n Update,\r\n EntityId,\r\n} from './models'\r\nimport { createStateOperator } from './state_adapter'\r\nimport { createUnsortedStateAdapter } from './unsorted_state_adapter'\r\nimport {\r\n selectIdValue,\r\n ensureEntitiesArray,\r\n splitAddedUpdatedEntities,\r\n} from './utils'\r\n\r\nexport function createSortedStateAdapter(\r\n selectId: IdSelector,\r\n sort: Comparer\r\n): EntityStateAdapter {\r\n type R = EntityState\r\n\r\n const { removeOne, removeMany, removeAll } =\r\n createUnsortedStateAdapter(selectId)\r\n\r\n function addOneMutably(entity: T, state: R): void {\r\n return addManyMutably([entity], state)\r\n }\r\n\r\n function addManyMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n newEntities = ensureEntitiesArray(newEntities)\r\n\r\n const models = newEntities.filter(\r\n (model) => !(selectIdValue(model, selectId) in state.entities)\r\n )\r\n\r\n if (models.length !== 0) {\r\n merge(models, state)\r\n }\r\n }\r\n\r\n function setOneMutably(entity: T, state: R): void {\r\n return setManyMutably([entity], state)\r\n }\r\n\r\n function setManyMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n newEntities = ensureEntitiesArray(newEntities)\r\n if (newEntities.length !== 0) {\r\n merge(newEntities, state)\r\n }\r\n }\r\n\r\n function setAllMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n newEntities = ensureEntitiesArray(newEntities)\r\n state.entities = {}\r\n state.ids = []\r\n\r\n addManyMutably(newEntities, state)\r\n }\r\n\r\n function updateOneMutably(update: Update, state: R): void {\r\n return updateManyMutably([update], state)\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types\r\n function takeUpdatedModel(models: T[], update: Update, state: R): boolean {\r\n if (!(update.id in state.entities)) {\r\n return false\r\n }\r\n\r\n const original = state.entities[update.id]\r\n const updated = Object.assign({}, original, update.changes)\r\n const newKey = selectIdValue(updated, selectId)\r\n\r\n delete state.entities[update.id]\r\n\r\n models.push(updated)\r\n\r\n return newKey !== update.id\r\n }\r\n\r\n function updateManyMutably(\r\n updates: ReadonlyArray>,\r\n state: R\r\n ): void {\r\n const models: T[] = []\r\n\r\n updates.forEach((update) => takeUpdatedModel(models, update, state))\r\n\r\n if (models.length !== 0) {\r\n merge(models, state)\r\n }\r\n }\r\n\r\n function upsertOneMutably(entity: T, state: R): void {\r\n return upsertManyMutably([entity], state)\r\n }\r\n\r\n function upsertManyMutably(\r\n newEntities: readonly T[] | Record,\r\n state: R\r\n ): void {\r\n const [added, updated] = splitAddedUpdatedEntities(\r\n newEntities,\r\n selectId,\r\n state\r\n )\r\n\r\n updateManyMutably(updated, state)\r\n addManyMutably(added, state)\r\n }\r\n\r\n function areArraysEqual(a: readonly unknown[], b: readonly unknown[]) {\r\n if (a.length !== b.length) {\r\n return false\r\n }\r\n\r\n for (let i = 0; i < a.length && i < b.length; i++) {\r\n if (a[i] === b[i]) {\r\n continue\r\n }\r\n return false\r\n }\r\n return true\r\n }\r\n\r\n function merge(models: readonly T[], state: R): void {\r\n // Insert/overwrite all new/updated\r\n models.forEach((model) => {\r\n state.entities[selectId(model)] = model\r\n })\r\n\r\n const allEntities = Object.values(state.entities) as T[]\r\n allEntities.sort(sort)\r\n\r\n const newSortedIds = allEntities.map(selectId)\r\n const { ids } = state\r\n\r\n if (!areArraysEqual(ids, newSortedIds)) {\r\n state.ids = newSortedIds\r\n }\r\n }\r\n\r\n return {\r\n removeOne,\r\n removeMany,\r\n removeAll,\r\n addOne: createStateOperator(addOneMutably),\r\n updateOne: createStateOperator(updateOneMutably),\r\n upsertOne: createStateOperator(upsertOneMutably),\r\n setOne: createStateOperator(setOneMutably),\r\n setMany: createStateOperator(setManyMutably),\r\n setAll: createStateOperator(setAllMutably),\r\n addMany: createStateOperator(addManyMutably),\r\n updateMany: createStateOperator(updateManyMutably),\r\n upsertMany: createStateOperator(upsertManyMutably),\r\n }\r\n}\r\n","import type {\r\n EntityDefinition,\r\n Comparer,\r\n IdSelector,\r\n EntityAdapter,\r\n} from './models'\r\nimport { createInitialStateFactory } from './entity_state'\r\nimport { createSelectorsFactory } from './state_selectors'\r\nimport { createSortedStateAdapter } from './sorted_state_adapter'\r\nimport { createUnsortedStateAdapter } from './unsorted_state_adapter'\r\n\r\n/**\r\n *\r\n * @param options\r\n *\r\n * @public\r\n */\r\nexport function createEntityAdapter(\r\n options: {\r\n selectId?: IdSelector\r\n sortComparer?: false | Comparer\r\n } = {}\r\n): EntityAdapter {\r\n const { selectId, sortComparer }: EntityDefinition = {\r\n sortComparer: false,\r\n selectId: (instance: any) => instance.id,\r\n ...options,\r\n }\r\n\r\n const stateFactory = createInitialStateFactory()\r\n const selectorsFactory = createSelectorsFactory()\r\n const stateAdapter = sortComparer\r\n ? createSortedStateAdapter(selectId, sortComparer)\r\n : createUnsortedStateAdapter(selectId)\r\n\r\n return {\r\n selectId,\r\n sortComparer,\r\n ...stateFactory,\r\n ...selectorsFactory,\r\n ...stateAdapter,\r\n }\r\n}\r\n","// Borrowed from https://github.com/ai/nanoid/blob/3.0.2/non-secure/index.js\r\n// This alphabet uses `A-Za-z0-9_-` symbols. A genetic algorithm helped\r\n// optimize the gzip compression for this alphabet.\r\nlet urlAlphabet =\r\n 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'\r\n\r\n/**\r\n *\r\n * @public\r\n */\r\nexport let nanoid = (size = 21) => {\r\n let id = ''\r\n // A compact alternative for `for (var i = 0; i < step; i++)`.\r\n let i = size\r\n while (i--) {\r\n // `| 0` is more compact and faster than `Math.floor()`.\r\n id += urlAlphabet[(Math.random() * 64) | 0]\r\n }\r\n return id\r\n}\r\n","import type { Dispatch, AnyAction } from 'redux'\r\nimport type {\r\n PayloadAction,\r\n ActionCreatorWithPreparedPayload,\r\n} from './createAction'\r\nimport { createAction } from './createAction'\r\nimport type { ThunkDispatch } from 'redux-thunk'\r\nimport type { FallbackIfUnknown, IsAny, IsUnknown } from './tsHelpers'\r\nimport { nanoid } from './nanoid'\r\n\r\n// @ts-ignore we need the import of these types due to a bundling issue.\r\ntype _Keep = PayloadAction | ActionCreatorWithPreparedPayload\r\n\r\nexport type BaseThunkAPI<\r\n S,\r\n E,\r\n D extends Dispatch = Dispatch,\r\n RejectedValue = undefined,\r\n RejectedMeta = unknown,\r\n FulfilledMeta = unknown\r\n> = {\r\n dispatch: D\r\n getState: () => S\r\n extra: E\r\n requestId: string\r\n signal: AbortSignal\r\n rejectWithValue: IsUnknown<\r\n RejectedMeta,\r\n (value: RejectedValue) => RejectWithValue,\r\n (\r\n value: RejectedValue,\r\n meta: RejectedMeta\r\n ) => RejectWithValue\r\n >\r\n fulfillWithValue: IsUnknown<\r\n FulfilledMeta,\r\n (\r\n value: FulfilledValue\r\n ) => FulfillWithMeta,\r\n (\r\n value: FulfilledValue,\r\n meta: FulfilledMeta\r\n ) => FulfillWithMeta\r\n >\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface SerializedError {\r\n name?: string\r\n message?: string\r\n stack?: string\r\n code?: string\r\n}\r\n\r\nconst commonProperties: Array = [\r\n 'name',\r\n 'message',\r\n 'stack',\r\n 'code',\r\n]\r\n\r\nclass RejectWithValue {\r\n /*\r\n type-only property to distinguish between RejectWithValue and FulfillWithMeta\r\n does not exist at runtime\r\n */\r\n private readonly _type!: 'RejectWithValue'\r\n constructor(\r\n public readonly payload: Payload,\r\n public readonly meta: RejectedMeta\r\n ) {}\r\n}\r\n\r\nclass FulfillWithMeta {\r\n /*\r\n type-only property to distinguish between RejectWithValue and FulfillWithMeta\r\n does not exist at runtime\r\n */\r\n private readonly _type!: 'FulfillWithMeta'\r\n constructor(\r\n public readonly payload: Payload,\r\n public readonly meta: FulfilledMeta\r\n ) {}\r\n}\r\n\r\n/**\r\n * Serializes an error into a plain object.\r\n * Reworked from https://github.com/sindresorhus/serialize-error\r\n *\r\n * @public\r\n */\r\nexport const miniSerializeError = (value: any): SerializedError => {\r\n if (typeof value === 'object' && value !== null) {\r\n const simpleError: SerializedError = {}\r\n for (const property of commonProperties) {\r\n if (typeof value[property] === 'string') {\r\n simpleError[property] = value[property]\r\n }\r\n }\r\n\r\n return simpleError\r\n }\r\n\r\n return { message: String(value) }\r\n}\r\n\r\ntype AsyncThunkConfig = {\r\n state?: unknown\r\n dispatch?: Dispatch\r\n extra?: unknown\r\n rejectValue?: unknown\r\n serializedErrorType?: unknown\r\n pendingMeta?: unknown\r\n fulfilledMeta?: unknown\r\n rejectedMeta?: unknown\r\n}\r\n\r\ntype GetState = ThunkApiConfig extends {\r\n state: infer State\r\n}\r\n ? State\r\n : unknown\r\ntype GetExtra = ThunkApiConfig extends { extra: infer Extra }\r\n ? Extra\r\n : unknown\r\ntype GetDispatch = ThunkApiConfig extends {\r\n dispatch: infer Dispatch\r\n}\r\n ? FallbackIfUnknown<\r\n Dispatch,\r\n ThunkDispatch<\r\n GetState,\r\n GetExtra,\r\n AnyAction\r\n >\r\n >\r\n : ThunkDispatch, GetExtra, AnyAction>\r\n\r\ntype GetThunkAPI = BaseThunkAPI<\r\n GetState,\r\n GetExtra,\r\n GetDispatch,\r\n GetRejectValue,\r\n GetRejectedMeta,\r\n GetFulfilledMeta\r\n>\r\n\r\ntype GetRejectValue = ThunkApiConfig extends {\r\n rejectValue: infer RejectValue\r\n}\r\n ? RejectValue\r\n : unknown\r\n\r\ntype GetPendingMeta = ThunkApiConfig extends {\r\n pendingMeta: infer PendingMeta\r\n}\r\n ? PendingMeta\r\n : unknown\r\n\r\ntype GetFulfilledMeta = ThunkApiConfig extends {\r\n fulfilledMeta: infer FulfilledMeta\r\n}\r\n ? FulfilledMeta\r\n : unknown\r\n\r\ntype GetRejectedMeta = ThunkApiConfig extends {\r\n rejectedMeta: infer RejectedMeta\r\n}\r\n ? RejectedMeta\r\n : unknown\r\n\r\ntype GetSerializedErrorType = ThunkApiConfig extends {\r\n serializedErrorType: infer GetSerializedErrorType\r\n}\r\n ? GetSerializedErrorType\r\n : SerializedError\r\n\r\ntype MaybePromise = T | Promise\r\n\r\n/**\r\n * A type describing the return value of the `payloadCreator` argument to `createAsyncThunk`.\r\n * Might be useful for wrapping `createAsyncThunk` in custom abstractions.\r\n *\r\n * @public\r\n */\r\nexport type AsyncThunkPayloadCreatorReturnValue<\r\n Returned,\r\n ThunkApiConfig extends AsyncThunkConfig\r\n> = MaybePromise<\r\n | IsUnknown<\r\n GetFulfilledMeta,\r\n Returned,\r\n FulfillWithMeta>\r\n >\r\n | RejectWithValue<\r\n GetRejectValue,\r\n GetRejectedMeta\r\n >\r\n>\r\n/**\r\n * A type describing the `payloadCreator` argument to `createAsyncThunk`.\r\n * Might be useful for wrapping `createAsyncThunk` in custom abstractions.\r\n *\r\n * @public\r\n */\r\nexport type AsyncThunkPayloadCreator<\r\n Returned,\r\n ThunkArg = void,\r\n ThunkApiConfig extends AsyncThunkConfig = {}\r\n> = (\r\n arg: ThunkArg,\r\n thunkAPI: GetThunkAPI\r\n) => AsyncThunkPayloadCreatorReturnValue\r\n\r\n/**\r\n * A ThunkAction created by `createAsyncThunk`.\r\n * Dispatching it returns a Promise for either a\r\n * fulfilled or rejected action.\r\n * Also, the returned value contains an `abort()` method\r\n * that allows the asyncAction to be cancelled from the outside.\r\n *\r\n * @public\r\n */\r\nexport type AsyncThunkAction<\r\n Returned,\r\n ThunkArg,\r\n ThunkApiConfig extends AsyncThunkConfig\r\n> = (\r\n dispatch: GetDispatch,\r\n getState: () => GetState,\r\n extra: GetExtra\r\n) => Promise<\r\n | ReturnType>\r\n | ReturnType>\r\n> & {\r\n abort: (reason?: string) => void\r\n requestId: string\r\n arg: ThunkArg\r\n unwrap: () => Promise\r\n}\r\n\r\ntype AsyncThunkActionCreator<\r\n Returned,\r\n ThunkArg,\r\n ThunkApiConfig extends AsyncThunkConfig\r\n> = IsAny<\r\n ThunkArg,\r\n // any handling\r\n (arg: ThunkArg) => AsyncThunkAction,\r\n // unknown handling\r\n unknown extends ThunkArg\r\n ? (arg: ThunkArg) => AsyncThunkAction // argument not specified or specified as void or undefined\r\n : [ThunkArg] extends [void] | [undefined]\r\n ? () => AsyncThunkAction // argument contains void\r\n : [void] extends [ThunkArg] // make optional\r\n ? (arg?: ThunkArg) => AsyncThunkAction // argument contains undefined\r\n : [undefined] extends [ThunkArg]\r\n ? WithStrictNullChecks<\r\n // with strict nullChecks: make optional\r\n (\r\n arg?: ThunkArg\r\n ) => AsyncThunkAction,\r\n // without strict null checks this will match everything, so don't make it optional\r\n (arg: ThunkArg) => AsyncThunkAction\r\n > // default case: normal argument\r\n : (arg: ThunkArg) => AsyncThunkAction\r\n>\r\n\r\n/**\r\n * Options object for `createAsyncThunk`.\r\n *\r\n * @public\r\n */\r\nexport type AsyncThunkOptions<\r\n ThunkArg = void,\r\n ThunkApiConfig extends AsyncThunkConfig = {}\r\n> = {\r\n /**\r\n * A method to control whether the asyncThunk should be executed. Has access to the\r\n * `arg`, `api.getState()` and `api.extra` arguments.\r\n *\r\n * @returns `false` if it should be skipped\r\n */\r\n condition?(\r\n arg: ThunkArg,\r\n api: Pick, 'getState' | 'extra'>\r\n ): boolean | undefined\r\n /**\r\n * If `condition` returns `false`, the asyncThunk will be skipped.\r\n * This option allows you to control whether a `rejected` action with `meta.condition == false`\r\n * will be dispatched or not.\r\n *\r\n * @default `false`\r\n */\r\n dispatchConditionRejection?: boolean\r\n\r\n serializeError?: (x: unknown) => GetSerializedErrorType\r\n\r\n /**\r\n * A function to use when generating the `requestId` for the request sequence.\r\n *\r\n * @default `nanoid`\r\n */\r\n idGenerator?: () => string\r\n} & IsUnknown<\r\n GetPendingMeta,\r\n {\r\n /**\r\n * A method to generate additional properties to be added to `meta` of the pending action.\r\n *\r\n * Using this optional overload will not modify the types correctly, this overload is only in place to support JavaScript users.\r\n * Please use the `ThunkApiConfig` parameter `pendingMeta` to get access to a correctly typed overload\r\n */\r\n getPendingMeta?(\r\n base: {\r\n arg: ThunkArg\r\n requestId: string\r\n },\r\n api: Pick, 'getState' | 'extra'>\r\n ): GetPendingMeta\r\n },\r\n {\r\n /**\r\n * A method to generate additional properties to be added to `meta` of the pending action.\r\n */\r\n getPendingMeta(\r\n base: {\r\n arg: ThunkArg\r\n requestId: string\r\n },\r\n api: Pick, 'getState' | 'extra'>\r\n ): GetPendingMeta\r\n }\r\n>\r\n\r\nexport type AsyncThunkPendingActionCreator<\r\n ThunkArg,\r\n ThunkApiConfig = {}\r\n> = ActionCreatorWithPreparedPayload<\r\n [string, ThunkArg, GetPendingMeta?],\r\n undefined,\r\n string,\r\n never,\r\n {\r\n arg: ThunkArg\r\n requestId: string\r\n requestStatus: 'pending'\r\n } & GetPendingMeta\r\n>\r\n\r\nexport type AsyncThunkRejectedActionCreator<\r\n ThunkArg,\r\n ThunkApiConfig = {}\r\n> = ActionCreatorWithPreparedPayload<\r\n [\r\n Error | null,\r\n string,\r\n ThunkArg,\r\n GetRejectValue?,\r\n GetRejectedMeta?\r\n ],\r\n GetRejectValue | undefined,\r\n string,\r\n GetSerializedErrorType,\r\n {\r\n arg: ThunkArg\r\n requestId: string\r\n requestStatus: 'rejected'\r\n aborted: boolean\r\n condition: boolean\r\n } & (\r\n | ({ rejectedWithValue: false } & {\r\n [K in keyof GetRejectedMeta]?: undefined\r\n })\r\n | ({ rejectedWithValue: true } & GetRejectedMeta)\r\n )\r\n>\r\n\r\nexport type AsyncThunkFulfilledActionCreator<\r\n Returned,\r\n ThunkArg,\r\n ThunkApiConfig = {}\r\n> = ActionCreatorWithPreparedPayload<\r\n [Returned, string, ThunkArg, GetFulfilledMeta?],\r\n Returned,\r\n string,\r\n never,\r\n {\r\n arg: ThunkArg\r\n requestId: string\r\n requestStatus: 'fulfilled'\r\n } & GetFulfilledMeta\r\n>\r\n\r\n/**\r\n * A type describing the return value of `createAsyncThunk`.\r\n * Might be useful for wrapping `createAsyncThunk` in custom abstractions.\r\n *\r\n * @public\r\n */\r\nexport type AsyncThunk<\r\n Returned,\r\n ThunkArg,\r\n ThunkApiConfig extends AsyncThunkConfig\r\n> = AsyncThunkActionCreator & {\r\n pending: AsyncThunkPendingActionCreator\r\n rejected: AsyncThunkRejectedActionCreator\r\n fulfilled: AsyncThunkFulfilledActionCreator<\r\n Returned,\r\n ThunkArg,\r\n ThunkApiConfig\r\n >\r\n typePrefix: string\r\n}\r\n\r\n/**\r\n *\r\n * @param typePrefix\r\n * @param payloadCreator\r\n * @param options\r\n *\r\n * @public\r\n */\r\nexport function createAsyncThunk<\r\n Returned,\r\n ThunkArg = void,\r\n ThunkApiConfig extends AsyncThunkConfig = {}\r\n>(\r\n typePrefix: string,\r\n payloadCreator: AsyncThunkPayloadCreator,\r\n options?: AsyncThunkOptions\r\n): AsyncThunk {\r\n type RejectedValue = GetRejectValue\r\n type PendingMeta = GetPendingMeta\r\n type FulfilledMeta = GetFulfilledMeta\r\n type RejectedMeta = GetRejectedMeta\r\n\r\n const fulfilled: AsyncThunkFulfilledActionCreator<\r\n Returned,\r\n ThunkArg,\r\n ThunkApiConfig\r\n > = createAction(\r\n typePrefix + '/fulfilled',\r\n (\r\n payload: Returned,\r\n requestId: string,\r\n arg: ThunkArg,\r\n meta?: FulfilledMeta\r\n ) => ({\r\n payload,\r\n meta: {\r\n ...((meta as any) || {}),\r\n arg,\r\n requestId,\r\n requestStatus: 'fulfilled' as const,\r\n },\r\n })\r\n )\r\n\r\n const pending: AsyncThunkPendingActionCreator =\r\n createAction(\r\n typePrefix + '/pending',\r\n (requestId: string, arg: ThunkArg, meta?: PendingMeta) => ({\r\n payload: undefined,\r\n meta: {\r\n ...((meta as any) || {}),\r\n arg,\r\n requestId,\r\n requestStatus: 'pending' as const,\r\n },\r\n })\r\n )\r\n\r\n const rejected: AsyncThunkRejectedActionCreator =\r\n createAction(\r\n typePrefix + '/rejected',\r\n (\r\n error: Error | null,\r\n requestId: string,\r\n arg: ThunkArg,\r\n payload?: RejectedValue,\r\n meta?: RejectedMeta\r\n ) => ({\r\n payload,\r\n error: ((options && options.serializeError) || miniSerializeError)(\r\n error || 'Rejected'\r\n ) as GetSerializedErrorType,\r\n meta: {\r\n ...((meta as any) || {}),\r\n arg,\r\n requestId,\r\n rejectedWithValue: !!payload,\r\n requestStatus: 'rejected' as const,\r\n aborted: error?.name === 'AbortError',\r\n condition: error?.name === 'ConditionError',\r\n },\r\n })\r\n )\r\n\r\n let displayedWarning = false\r\n\r\n const AC =\r\n typeof AbortController !== 'undefined'\r\n ? AbortController\r\n : class implements AbortController {\r\n signal: AbortSignal = {\r\n aborted: false,\r\n addEventListener() {},\r\n dispatchEvent() {\r\n return false\r\n },\r\n onabort() {},\r\n removeEventListener() {},\r\n }\r\n abort() {\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (!displayedWarning) {\r\n displayedWarning = true\r\n console.info(\r\n `This platform does not implement AbortController. \r\nIf you want to use the AbortController to react to \\`abort\\` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.`\r\n )\r\n }\r\n }\r\n }\r\n }\r\n\r\n function actionCreator(\r\n arg: ThunkArg\r\n ): AsyncThunkAction {\r\n return (dispatch, getState, extra) => {\r\n const requestId = (options?.idGenerator ?? nanoid)()\r\n\r\n const abortController = new AC()\r\n let abortReason: string | undefined\r\n\r\n const abortedPromise = new Promise((_, reject) =>\r\n abortController.signal.addEventListener('abort', () =>\r\n reject({ name: 'AbortError', message: abortReason || 'Aborted' })\r\n )\r\n )\r\n\r\n let started = false\r\n function abort(reason?: string) {\r\n if (started) {\r\n abortReason = reason\r\n abortController.abort()\r\n }\r\n }\r\n\r\n const promise = (async function () {\r\n let finalAction: ReturnType\r\n try {\r\n if (\r\n options &&\r\n options.condition &&\r\n options.condition(arg, { getState, extra }) === false\r\n ) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw {\r\n name: 'ConditionError',\r\n message: 'Aborted due to condition callback returning false.',\r\n }\r\n }\r\n started = true\r\n dispatch(\r\n pending(\r\n requestId,\r\n arg,\r\n options?.getPendingMeta?.({ requestId, arg }, { getState, extra })\r\n )\r\n )\r\n finalAction = await Promise.race([\r\n abortedPromise,\r\n Promise.resolve(\r\n payloadCreator(arg, {\r\n dispatch,\r\n getState,\r\n extra,\r\n requestId,\r\n signal: abortController.signal,\r\n rejectWithValue: ((\r\n value: RejectedValue,\r\n meta?: RejectedMeta\r\n ) => {\r\n return new RejectWithValue(value, meta)\r\n }) as any,\r\n fulfillWithValue: ((value: unknown, meta?: FulfilledMeta) => {\r\n return new FulfillWithMeta(value, meta)\r\n }) as any,\r\n })\r\n ).then((result) => {\r\n if (result instanceof RejectWithValue) {\r\n throw result\r\n }\r\n if (result instanceof FulfillWithMeta) {\r\n return fulfilled(result.payload, requestId, arg, result.meta)\r\n }\r\n return fulfilled(result as any, requestId, arg)\r\n }),\r\n ])\r\n } catch (err) {\r\n finalAction =\r\n err instanceof RejectWithValue\r\n ? rejected(null, requestId, arg, err.payload, err.meta)\r\n : rejected(err as any, requestId, arg)\r\n }\r\n // We dispatch the result action _after_ the catch, to avoid having any errors\r\n // here get swallowed by the try/catch block,\r\n // per https://twitter.com/dan_abramov/status/770914221638942720\r\n // and https://github.com/reduxjs/redux-toolkit/blob/e85eb17b39a2118d859f7b7746e0f3fee523e089/docs/tutorials/advanced-tutorial.md#async-error-handling-logic-in-thunks\r\n\r\n const skipDispatch =\r\n options &&\r\n !options.dispatchConditionRejection &&\r\n rejected.match(finalAction) &&\r\n (finalAction as any).meta.condition\r\n\r\n if (!skipDispatch) {\r\n dispatch(finalAction)\r\n }\r\n return finalAction\r\n })()\r\n return Object.assign(promise as Promise, {\r\n abort,\r\n requestId,\r\n arg,\r\n unwrap() {\r\n return promise.then(unwrapResult)\r\n },\r\n })\r\n }\r\n }\r\n\r\n return Object.assign(\r\n actionCreator as AsyncThunkActionCreator<\r\n Returned,\r\n ThunkArg,\r\n ThunkApiConfig\r\n >,\r\n {\r\n pending,\r\n rejected,\r\n fulfilled,\r\n typePrefix,\r\n }\r\n )\r\n}\r\n\r\ninterface UnwrappableAction {\r\n payload: any\r\n meta?: any\r\n error?: any\r\n}\r\n\r\ntype UnwrappedActionPayload = Exclude<\r\n T,\r\n { error: any }\r\n>['payload']\r\n\r\n/**\r\n * @public\r\n */\r\nexport function unwrapResult(\r\n action: R\r\n): UnwrappedActionPayload {\r\n if (action.meta && action.meta.rejectedWithValue) {\r\n throw action.payload\r\n }\r\n if (action.error) {\r\n throw action.error\r\n }\r\n return action.payload\r\n}\r\n\r\ntype WithStrictNullChecks = undefined extends boolean\r\n ? False\r\n : True\r\n","import type { Middleware } from 'redux'\r\n\r\n/**\r\n * return True if T is `any`, otherwise return False\r\n * taken from https://github.com/joonhocho/tsdef\r\n *\r\n * @internal\r\n */\r\nexport type IsAny =\r\n // test if we are going the left AND right path in the condition\r\n true | false extends (T extends never ? true : false) ? True : False\r\n\r\n/**\r\n * return True if T is `unknown`, otherwise return False\r\n * taken from https://github.com/joonhocho/tsdef\r\n *\r\n * @internal\r\n */\r\nexport type IsUnknown = unknown extends T\r\n ? IsAny\r\n : False\r\n\r\nexport type FallbackIfUnknown = IsUnknown\r\n\r\n/**\r\n * @internal\r\n */\r\nexport type IfMaybeUndefined = [undefined] extends [P]\r\n ? True\r\n : False\r\n\r\n/**\r\n * @internal\r\n */\r\nexport type IfVoid = [void] extends [P] ? True : False\r\n\r\n/**\r\n * @internal\r\n */\r\nexport type IsEmptyObj = T extends any\r\n ? keyof T extends never\r\n ? IsUnknown>>\r\n : False\r\n : never\r\n\r\n/**\r\n * returns True if TS version is above 3.5, False if below.\r\n * uses feature detection to detect TS version >= 3.5\r\n * * versions below 3.5 will return `{}` for unresolvable interference\r\n * * versions above will return `unknown`\r\n *\r\n * @internal\r\n */\r\nexport type AtLeastTS35 = [True, False][IsUnknown<\r\n ReturnType<() => T>,\r\n 0,\r\n 1\r\n>]\r\n\r\n/**\r\n * @internal\r\n */\r\nexport type IsUnknownOrNonInferrable = AtLeastTS35<\r\n IsUnknown,\r\n IsEmptyObj>\r\n>\r\n\r\n/**\r\n * Combines all dispatch signatures of all middlewares in the array `M` into\r\n * one intersected dispatch signature.\r\n */\r\nexport type DispatchForMiddlewares = M extends ReadonlyArray\r\n ? UnionToIntersection<\r\n M[number] extends infer MiddlewareValues\r\n ? MiddlewareValues extends Middleware\r\n ? DispatchExt extends Function\r\n ? IsAny\r\n : never\r\n : never\r\n : never\r\n >\r\n : never\r\n\r\n/**\r\n * Convert a Union type `(A|B)` to an intersection type `(A&B)`\r\n */\r\nexport type UnionToIntersection = (\r\n U extends any ? (k: U) => void : never\r\n) extends (k: infer I) => void\r\n ? I\r\n : never\r\n\r\n/**\r\n * Helper type. Passes T out again, but boxes it in a way that it cannot\r\n * \"widen\" the type by accident if it is a generic that should be inferred\r\n * from elsewhere.\r\n *\r\n * @internal\r\n */\r\nexport type NoInfer = [T][T extends any ? 0 : never]\r\n\r\nexport type Omit = Pick>\r\n\r\nexport interface HasMatchFunction {\r\n match: (v: any) => v is T\r\n}\r\n\r\nexport const hasMatchFunction = (\r\n v: Matcher\r\n): v is HasMatchFunction => {\r\n return v && typeof (v as HasMatchFunction).match === 'function'\r\n}\r\n\r\n/** @public */\r\nexport type Matcher = HasMatchFunction | ((v: any) => v is T)\r\n\r\n/** @public */\r\nexport type ActionFromMatcher> = M extends Matcher<\r\n infer T\r\n>\r\n ? T\r\n : never\r\n","import type {\r\n ActionFromMatcher,\r\n Matcher,\r\n UnionToIntersection,\r\n} from './tsHelpers'\r\nimport { hasMatchFunction } from './tsHelpers'\r\nimport type {\r\n AsyncThunk,\r\n AsyncThunkFulfilledActionCreator,\r\n AsyncThunkPendingActionCreator,\r\n AsyncThunkRejectedActionCreator,\r\n} from './createAsyncThunk'\r\n\r\n/** @public */\r\nexport type ActionMatchingAnyOf<\r\n Matchers extends [Matcher, ...Matcher[]]\r\n> = ActionFromMatcher\r\n\r\n/** @public */\r\nexport type ActionMatchingAllOf<\r\n Matchers extends [Matcher, ...Matcher[]]\r\n> = UnionToIntersection>\r\n\r\nconst matches = (matcher: Matcher, action: any) => {\r\n if (hasMatchFunction(matcher)) {\r\n return matcher.match(action)\r\n } else {\r\n return matcher(action)\r\n }\r\n}\r\n\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action matches any one of the supplied type guards or action\r\n * creators.\r\n *\r\n * @param matchers The type guards or action creators to match against.\r\n *\r\n * @public\r\n */\r\nexport function isAnyOf, ...Matcher[]]>(\r\n ...matchers: Matchers\r\n) {\r\n return (action: any): action is ActionMatchingAnyOf => {\r\n return matchers.some((matcher) => matches(matcher, action))\r\n }\r\n}\r\n\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action matches all of the supplied type guards or action\r\n * creators.\r\n *\r\n * @param matchers The type guards or action creators to match against.\r\n *\r\n * @public\r\n */\r\nexport function isAllOf, ...Matcher[]]>(\r\n ...matchers: Matchers\r\n) {\r\n return (action: any): action is ActionMatchingAllOf => {\r\n return matchers.every((matcher) => matches(matcher, action))\r\n }\r\n}\r\n\r\n/**\r\n * @param action A redux action\r\n * @param validStatus An array of valid meta.requestStatus values\r\n *\r\n * @internal\r\n */\r\nexport function hasExpectedRequestMetadata(\r\n action: any,\r\n validStatus: readonly string[]\r\n) {\r\n if (!action || !action.meta) return false\r\n\r\n const hasValidRequestId = typeof action.meta.requestId === 'string'\r\n const hasValidRequestStatus =\r\n validStatus.indexOf(action.meta.requestStatus) > -1\r\n\r\n return hasValidRequestId && hasValidRequestStatus\r\n}\r\n\r\nfunction isAsyncThunkArray(a: [any] | AnyAsyncThunk[]): a is AnyAsyncThunk[] {\r\n return (\r\n typeof a[0] === 'function' &&\r\n 'pending' in a[0] &&\r\n 'fulfilled' in a[0] &&\r\n 'rejected' in a[0]\r\n )\r\n}\r\n\r\nexport type UnknownAsyncThunkPendingAction = ReturnType<\r\n AsyncThunkPendingActionCreator\r\n>\r\n\r\nexport type PendingActionFromAsyncThunk =\r\n ActionFromMatcher\r\n\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action was created by an async thunk action creator, and that\r\n * the action is pending.\r\n *\r\n * @public\r\n */\r\nexport function isPending(): (\r\n action: any\r\n) => action is UnknownAsyncThunkPendingAction\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action belongs to one of the provided async thunk action creators,\r\n * and that the action is pending.\r\n *\r\n * @param asyncThunks (optional) The async thunk action creators to match against.\r\n *\r\n * @public\r\n */\r\nexport function isPending<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(\r\n ...asyncThunks: AsyncThunks\r\n): (action: any) => action is PendingActionFromAsyncThunk\r\n/**\r\n * Tests if `action` is a pending thunk action\r\n * @public\r\n */\r\nexport function isPending(action: any): action is UnknownAsyncThunkPendingAction\r\nexport function isPending<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(...asyncThunks: AsyncThunks | [any]) {\r\n if (asyncThunks.length === 0) {\r\n return (action: any) => hasExpectedRequestMetadata(action, ['pending'])\r\n }\r\n\r\n if (!isAsyncThunkArray(asyncThunks)) {\r\n return isPending()(asyncThunks[0])\r\n }\r\n\r\n return (\r\n action: any\r\n ): action is PendingActionFromAsyncThunk => {\r\n // note: this type will be correct because we have at least 1 asyncThunk\r\n const matchers: [Matcher, ...Matcher[]] = asyncThunks.map(\r\n (asyncThunk) => asyncThunk.pending\r\n ) as any\r\n\r\n const combinedMatcher = isAnyOf(...matchers)\r\n\r\n return combinedMatcher(action)\r\n }\r\n}\r\n\r\nexport type UnknownAsyncThunkRejectedAction = ReturnType<\r\n AsyncThunkRejectedActionCreator\r\n>\r\n\r\nexport type RejectedActionFromAsyncThunk =\r\n ActionFromMatcher\r\n\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action was created by an async thunk action creator, and that\r\n * the action is rejected.\r\n *\r\n * @public\r\n */\r\nexport function isRejected(): (\r\n action: any\r\n) => action is UnknownAsyncThunkRejectedAction\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action belongs to one of the provided async thunk action creators,\r\n * and that the action is rejected.\r\n *\r\n * @param asyncThunks (optional) The async thunk action creators to match against.\r\n *\r\n * @public\r\n */\r\nexport function isRejected<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(\r\n ...asyncThunks: AsyncThunks\r\n): (action: any) => action is RejectedActionFromAsyncThunk\r\n/**\r\n * Tests if `action` is a rejected thunk action\r\n * @public\r\n */\r\nexport function isRejected(\r\n action: any\r\n): action is UnknownAsyncThunkRejectedAction\r\nexport function isRejected<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(...asyncThunks: AsyncThunks | [any]) {\r\n if (asyncThunks.length === 0) {\r\n return (action: any) => hasExpectedRequestMetadata(action, ['rejected'])\r\n }\r\n\r\n if (!isAsyncThunkArray(asyncThunks)) {\r\n return isRejected()(asyncThunks[0])\r\n }\r\n\r\n return (\r\n action: any\r\n ): action is RejectedActionFromAsyncThunk => {\r\n // note: this type will be correct because we have at least 1 asyncThunk\r\n const matchers: [Matcher, ...Matcher[]] = asyncThunks.map(\r\n (asyncThunk) => asyncThunk.rejected\r\n ) as any\r\n\r\n const combinedMatcher = isAnyOf(...matchers)\r\n\r\n return combinedMatcher(action)\r\n }\r\n}\r\n\r\nexport type UnknownAsyncThunkRejectedWithValueAction = ReturnType<\r\n AsyncThunkRejectedActionCreator\r\n>\r\n\r\nexport type RejectedWithValueActionFromAsyncThunk =\r\n ActionFromMatcher &\r\n (T extends AsyncThunk\r\n ? { payload: RejectedValue }\r\n : unknown)\r\n\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action was created by an async thunk action creator, and that\r\n * the action is rejected with value.\r\n *\r\n * @public\r\n */\r\nexport function isRejectedWithValue(): (\r\n action: any\r\n) => action is UnknownAsyncThunkRejectedAction\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action belongs to one of the provided async thunk action creators,\r\n * and that the action is rejected with value.\r\n *\r\n * @param asyncThunks (optional) The async thunk action creators to match against.\r\n *\r\n * @public\r\n */\r\nexport function isRejectedWithValue<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(\r\n ...asyncThunks: AsyncThunks\r\n): (\r\n action: any\r\n) => action is RejectedWithValueActionFromAsyncThunk\r\n/**\r\n * Tests if `action` is a rejected thunk action with value\r\n * @public\r\n */\r\nexport function isRejectedWithValue(\r\n action: any\r\n): action is UnknownAsyncThunkRejectedAction\r\nexport function isRejectedWithValue<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(...asyncThunks: AsyncThunks | [any]) {\r\n const hasFlag = (action: any): action is any => {\r\n return action && action.meta && action.meta.rejectedWithValue\r\n }\r\n\r\n if (asyncThunks.length === 0) {\r\n return (action: any) => {\r\n const combinedMatcher = isAllOf(isRejected(...asyncThunks), hasFlag)\r\n\r\n return combinedMatcher(action)\r\n }\r\n }\r\n\r\n if (!isAsyncThunkArray(asyncThunks)) {\r\n return isRejectedWithValue()(asyncThunks[0])\r\n }\r\n\r\n return (\r\n action: any\r\n ): action is RejectedActionFromAsyncThunk => {\r\n const combinedMatcher = isAllOf(isRejected(...asyncThunks), hasFlag)\r\n\r\n return combinedMatcher(action)\r\n }\r\n}\r\n\r\nexport type UnknownAsyncThunkFulfilledAction = ReturnType<\r\n AsyncThunkFulfilledActionCreator\r\n>\r\n\r\nexport type FulfilledActionFromAsyncThunk =\r\n ActionFromMatcher\r\n\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action was created by an async thunk action creator, and that\r\n * the action is fulfilled.\r\n *\r\n * @public\r\n */\r\nexport function isFulfilled(): (\r\n action: any\r\n) => action is UnknownAsyncThunkFulfilledAction\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action belongs to one of the provided async thunk action creators,\r\n * and that the action is fulfilled.\r\n *\r\n * @param asyncThunks (optional) The async thunk action creators to match against.\r\n *\r\n * @public\r\n */\r\nexport function isFulfilled<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(\r\n ...asyncThunks: AsyncThunks\r\n): (action: any) => action is FulfilledActionFromAsyncThunk\r\n/**\r\n * Tests if `action` is a fulfilled thunk action\r\n * @public\r\n */\r\nexport function isFulfilled(\r\n action: any\r\n): action is UnknownAsyncThunkFulfilledAction\r\nexport function isFulfilled<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(...asyncThunks: AsyncThunks | [any]) {\r\n if (asyncThunks.length === 0) {\r\n return (action: any) => hasExpectedRequestMetadata(action, ['fulfilled'])\r\n }\r\n\r\n if (!isAsyncThunkArray(asyncThunks)) {\r\n return isFulfilled()(asyncThunks[0])\r\n }\r\n\r\n return (\r\n action: any\r\n ): action is FulfilledActionFromAsyncThunk => {\r\n // note: this type will be correct because we have at least 1 asyncThunk\r\n const matchers: [Matcher, ...Matcher[]] = asyncThunks.map(\r\n (asyncThunk) => asyncThunk.fulfilled\r\n ) as any\r\n\r\n const combinedMatcher = isAnyOf(...matchers)\r\n\r\n return combinedMatcher(action)\r\n }\r\n}\r\n\r\nexport type UnknownAsyncThunkAction =\r\n | UnknownAsyncThunkPendingAction\r\n | UnknownAsyncThunkRejectedAction\r\n | UnknownAsyncThunkFulfilledAction\r\n\r\nexport type AnyAsyncThunk = {\r\n pending: { match: (action: any) => action is any }\r\n fulfilled: { match: (action: any) => action is any }\r\n rejected: { match: (action: any) => action is any }\r\n}\r\n\r\nexport type ActionsFromAsyncThunk =\r\n | ActionFromMatcher\r\n | ActionFromMatcher\r\n | ActionFromMatcher\r\n\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action was created by an async thunk action creator.\r\n *\r\n * @public\r\n */\r\nexport function isAsyncThunkAction(): (\r\n action: any\r\n) => action is UnknownAsyncThunkAction\r\n/**\r\n * A higher-order function that returns a function that may be used to check\r\n * whether an action belongs to one of the provided async thunk action creators.\r\n *\r\n * @param asyncThunks (optional) The async thunk action creators to match against.\r\n *\r\n * @public\r\n */\r\nexport function isAsyncThunkAction<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(\r\n ...asyncThunks: AsyncThunks\r\n): (action: any) => action is ActionsFromAsyncThunk\r\n/**\r\n * Tests if `action` is a thunk action\r\n * @public\r\n */\r\nexport function isAsyncThunkAction(\r\n action: any\r\n): action is UnknownAsyncThunkAction\r\nexport function isAsyncThunkAction<\r\n AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]\r\n>(...asyncThunks: AsyncThunks | [any]) {\r\n if (asyncThunks.length === 0) {\r\n return (action: any) =>\r\n hasExpectedRequestMetadata(action, ['pending', 'fulfilled', 'rejected'])\r\n }\r\n\r\n if (!isAsyncThunkArray(asyncThunks)) {\r\n return isAsyncThunkAction()(asyncThunks[0])\r\n }\r\n\r\n return (\r\n action: any\r\n ): action is ActionsFromAsyncThunk => {\r\n // note: this type will be correct because we have at least 1 asyncThunk\r\n const matchers: [Matcher, ...Matcher[]] = [] as any\r\n\r\n for (const asyncThunk of asyncThunks) {\r\n matchers.push(\r\n asyncThunk.pending,\r\n asyncThunk.rejected,\r\n asyncThunk.fulfilled\r\n )\r\n }\r\n\r\n const combinedMatcher = isAnyOf(...matchers)\r\n\r\n return combinedMatcher(action)\r\n }\r\n}\r\n",null]}

(\r\n type: T\r\n): PayloadActionCreator\r\n\r\n/**\r\n * A utility function to create an action creator for the given action type\r\n * string. The action creator accepts a single argument, which will be included\r\n * in the action object as a field called payload. The action creator function\r\n * will also have its toString() overriden so that it returns the action type,\r\n * allowing it to be used in reducer logic that is looking for that action type.\r\n *\r\n * @param type The action type to use for created actions.\r\n * @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }.\r\n * If this is given, the resulting action creator will pass its arguments to this method to calculate payload & meta.\r\n *\r\n * @public\r\n */\r\nexport function createAction<\r\n PA extends PrepareAction,\r\n T extends string = string\r\n>(\r\n type: T,\r\n prepareAction: PA\r\n): PayloadActionCreator['payload'], T, PA>\r\n\r\nexport function createAction(type: string, prepareAction?: Function): any {\r\n function actionCreator(...args: any[]) {\r\n if (prepareAction) {\r\n let prepared = prepareAction(...args)\r\n if (!prepared) {\r\n throw new Error('prepareAction did not return an object')\r\n }\r\n\r\n return {\r\n type,\r\n payload: prepared.payload,\r\n ...('meta' in prepared && { meta: prepared.meta }),\r\n ...('error' in prepared && { error: prepared.error }),\r\n }\r\n }\r\n return { type, payload: args[0] }\r\n }\r\n\r\n actionCreator.toString = () => `${type}`\r\n\r\n actionCreator.type = type\r\n\r\n actionCreator.match = (action: Action): action is PayloadAction =>\r\n action.type === type\r\n\r\n return actionCreator\r\n}\r\n\r\nexport function isFSA(action: unknown): action is {\r\n type: string\r\n payload?: unknown\r\n error?: unknown\r\n meta?: unknown\r\n} {\r\n return (\r\n isPlainObject(action) &&\r\n typeof (action as any).type === 'string' &&\r\n Object.keys(action).every(isValidKey)\r\n )\r\n}\r\n\r\nfunction isValidKey(key: string) {\r\n return ['type', 'payload', 'error', 'meta'].indexOf(key) > -1\r\n}\r\n\r\n/**\r\n * Returns the action type of the actions created by the passed\r\n * `createAction()`-generated action creator (arbitrary action creators\r\n * are not supported).\r\n *\r\n * @param action The action creator whose action type to get.\r\n * @returns The action type used by the action creator.\r\n *\r\n * @public\r\n */\r\nexport function getType(\r\n actionCreator: PayloadActionCreator\r\n): T {\r\n return `${actionCreator}` as T\r\n}\r\n\r\n// helper types for more readable typings\r\n\r\ntype IfPrepareActionMethodProvided<\r\n PA extends PrepareAction | void,\r\n True,\r\n False\r\n> = PA extends (...args: any[]) => any ? True : False\r\n","import type { Draft } from 'immer'\r\nimport createNextState, { isDraft, isDraftable } from 'immer'\r\nimport type { AnyAction, Action, Reducer } from 'redux'\r\nimport type { ActionReducerMapBuilder } from './mapBuilders'\r\nimport { executeReducerBuilderCallback } from './mapBuilders'\r\nimport type { NoInfer } from './tsHelpers'\r\n\r\n/**\r\n * Defines a mapping from action types to corresponding action object shapes.\r\n *\r\n * @deprecated This should not be used manually - it is only used for internal\r\n * inference purposes and should not have any further value.\r\n * It might be removed in the future.\r\n * @public\r\n */\r\nexport type Actions = Record\r\n\r\nexport interface ActionMatcher {\r\n (action: AnyAction): action is A\r\n}\r\n\r\nexport type ActionMatcherDescription = {\r\n matcher: ActionMatcher\r\n reducer: CaseReducer>\r\n}\r\n\r\nexport type ReadonlyActionMatcherDescriptionCollection = ReadonlyArray<\r\n ActionMatcherDescription\r\n>\r\n\r\nexport type ActionMatcherDescriptionCollection = Array<\r\n ActionMatcherDescription\r\n>\r\n\r\n/**\r\n * An *case reducer* is a reducer function for a specific action type. Case\r\n * reducers can be composed to full reducers using `createReducer()`.\r\n *\r\n * Unlike a normal Redux reducer, a case reducer is never called with an\r\n * `undefined` state to determine the initial state. Instead, the initial\r\n * state is explicitly specified as an argument to `createReducer()`.\r\n *\r\n * In addition, a case reducer can choose to mutate the passed-in `state`\r\n * value directly instead of returning a new state. This does not actually\r\n * cause the store state to be mutated directly; instead, thanks to\r\n * [immer](https://github.com/mweststrate/immer), the mutations are\r\n * translated to copy operations that result in a new state.\r\n *\r\n * @public\r\n */\r\nexport type CaseReducer = (\r\n state: Draft,\r\n action: A\r\n) => S | void | Draft\r\n\r\n/**\r\n * A mapping from action types to case reducers for `createReducer()`.\r\n *\r\n * @deprecated This should not be used manually - it is only used\r\n * for internal inference purposes and using it manually\r\n * would lead to type erasure.\r\n * It might be removed in the future.\r\n * @public\r\n */\r\nexport type CaseReducers = {\r\n [T in keyof AS]: AS[T] extends Action ? CaseReducer : void\r\n}\r\n\r\n/**\r\n * A utility function that allows defining a reducer as a mapping from action\r\n * type to *case reducer* functions that handle these action types. The\r\n * reducer's initial state is passed as the first argument.\r\n *\r\n * @remarks\r\n * The body of every case reducer is implicitly wrapped with a call to\r\n * `produce()` from the [immer](https://github.com/mweststrate/immer) library.\r\n * This means that rather than returning a new state object, you can also\r\n * mutate the passed-in state object directly; these mutations will then be\r\n * automatically and efficiently translated into copies, giving you both\r\n * convenience and immutability.\r\n *\r\n * @overloadSummary\r\n * This overload accepts a callback function that receives a `builder` object as its argument.\r\n * That builder provides `addCase`, `addMatcher` and `addDefaultCase` functions that may be\r\n * called to define what actions this reducer will handle.\r\n *\r\n * @param initialState - The initial state that should be used when the reducer is called the first time.\r\n * @param builderCallback - A callback that receives a *builder* object to define\r\n * case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.\r\n * @example\r\n```ts\r\nimport {\r\n createAction,\r\n createReducer,\r\n AnyAction,\r\n PayloadAction,\r\n} from \"@reduxjs/toolkit\";\r\n\r\nconst increment = createAction(\"increment\");\r\nconst decrement = createAction(\"decrement\");\r\n\r\nfunction isActionWithNumberPayload(\r\n action: AnyAction\r\n): action is PayloadAction {\r\n return typeof action.payload === \"number\";\r\n}\r\n\r\ncreateReducer(\r\n {\r\n counter: 0,\r\n sumOfNumberPayloads: 0,\r\n unhandledActions: 0,\r\n },\r\n (builder) => {\r\n builder\r\n .addCase(increment, (state, action) => {\r\n // action is inferred correctly here\r\n state.counter += action.payload;\r\n })\r\n // You can chain calls, or have separate `builder.addCase()` lines each time\r\n .addCase(decrement, (state, action) => {\r\n state.counter -= action.payload;\r\n })\r\n // You can apply a \"matcher function\" to incoming actions\r\n .addMatcher(isActionWithNumberPayload, (state, action) => {})\r\n // and provide a default case if no other handlers matched\r\n .addDefaultCase((state, action) => {});\r\n }\r\n);\r\n```\r\n * @public\r\n */\r\nexport function createReducer(\r\n initialState: S,\r\n builderCallback: (builder: ActionReducerMapBuilder) => void\r\n): Reducer\r\n\r\n/**\r\n * A utility function that allows defining a reducer as a mapping from action\r\n * type to *case reducer* functions that handle these action types. The\r\n * reducer's initial state is passed as the first argument.\r\n *\r\n * The body of every case reducer is implicitly wrapped with a call to\r\n * `produce()` from the [immer](https://github.com/mweststrate/immer) library.\r\n * This means that rather than returning a new state object, you can also\r\n * mutate the passed-in state object directly; these mutations will then be\r\n * automatically and efficiently translated into copies, giving you both\r\n * convenience and immutability.\r\n * \r\n * @overloadSummary\r\n * This overload accepts an object where the keys are string action types, and the values\r\n * are case reducer functions to handle those action types.\r\n *\r\n * @param initialState - The initial state that should be used when the reducer is called the first time.\r\n * @param actionsMap - An object mapping from action types to _case reducers_, each of which handles one specific action type.\r\n * @param actionMatchers - An array of matcher definitions in the form `{matcher, reducer}`.\r\n * All matching reducers will be executed in order, independently if a case reducer matched or not.\r\n * @param defaultCaseReducer - A \"default case\" reducer that is executed if no case reducer and no matcher\r\n * reducer was executed for this action.\r\n *\r\n * @example\r\n```js\r\nconst counterReducer = createReducer(0, {\r\n increment: (state, action) => state + action.payload,\r\n decrement: (state, action) => state - action.payload\r\n})\r\n```\r\n \r\n * Action creators that were generated using [`createAction`](./createAction) may be used directly as the keys here, using computed property syntax:\r\n\r\n```js\r\nconst increment = createAction('increment')\r\nconst decrement = createAction('decrement')\r\n\r\nconst counterReducer = createReducer(0, {\r\n [increment]: (state, action) => state + action.payload,\r\n [decrement.type]: (state, action) => state - action.payload\r\n})\r\n```\r\n * @public\r\n */\r\nexport function createReducer<\r\n S,\r\n CR extends CaseReducers = CaseReducers\r\n>(\r\n initialState: S,\r\n actionsMap: CR,\r\n actionMatchers?: ActionMatcherDescriptionCollection,\r\n defaultCaseReducer?: CaseReducer\r\n): Reducer\r\n\r\nexport function createReducer(\r\n initialState: S,\r\n mapOrBuilderCallback:\r\n | CaseReducers\r\n | ((builder: ActionReducerMapBuilder) => void),\r\n actionMatchers: ReadonlyActionMatcherDescriptionCollection = [],\r\n defaultCaseReducer?: CaseReducer\r\n): Reducer {\r\n let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] =\r\n typeof mapOrBuilderCallback === 'function'\r\n ? executeReducerBuilderCallback(mapOrBuilderCallback)\r\n : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer]\r\n\r\n const frozenInitialState = createNextState(initialState, () => {})\r\n\r\n return function (state = frozenInitialState, action): S {\r\n let caseReducers = [\r\n actionsMap[action.type],\r\n ...finalActionMatchers\r\n .filter(({ matcher }) => matcher(action))\r\n .map(({ reducer }) => reducer),\r\n ]\r\n if (caseReducers.filter((cr) => !!cr).length === 0) {\r\n caseReducers = [finalDefaultCaseReducer]\r\n }\r\n\r\n return caseReducers.reduce((previousState, caseReducer): S => {\r\n if (caseReducer) {\r\n if (isDraft(previousState)) {\r\n // If it's already a draft, we must already be inside a `createNextState` call,\r\n // likely because this is being wrapped in `createReducer`, `createSlice`, or nested\r\n // inside an existing draft. It's safe to just pass the draft to the mutator.\r\n const draft = previousState as Draft // We can assume this is already a draft\r\n const result = caseReducer(draft, action)\r\n\r\n if (typeof result === 'undefined') {\r\n return previousState\r\n }\r\n\r\n return result as S\r\n } else if (!isDraftable(previousState)) {\r\n // If state is not draftable (ex: a primitive, such as 0), we want to directly\r\n // return the caseReducer func and not wrap it with produce.\r\n const result = caseReducer(previousState as any, action)\r\n\r\n if (typeof result === 'undefined') {\r\n if (previousState === null) {\r\n return previousState\r\n }\r\n throw Error(\r\n 'A case reducer on a non-draftable value must not return undefined'\r\n )\r\n }\r\n\r\n return result as S\r\n } else {\r\n // @ts-ignore createNextState() produces an Immutable> rather\r\n // than an Immutable, and TypeScript cannot find out how to reconcile\r\n // these two types.\r\n return createNextState(previousState, (draft: Draft) => {\r\n return caseReducer(draft, action)\r\n })\r\n }\r\n }\r\n\r\n return previousState\r\n }, state)\r\n }\r\n}\r\n","import type { Action, AnyAction } from 'redux'\r\nimport type {\r\n CaseReducer,\r\n CaseReducers,\r\n ActionMatcher,\r\n ActionMatcherDescriptionCollection,\r\n} from './createReducer'\r\n\r\nexport interface TypedActionCreator {\r\n (...args: any[]): Action\r\n type: Type\r\n}\r\n\r\n/**\r\n * A builder for an action <-> reducer map.\r\n *\r\n * @public\r\n */\r\nexport interface ActionReducerMapBuilder {\r\n /**\r\n * Adds a case reducer to handle a single exact action type.\r\n * @remarks\r\n * All calls to `builder.addCase` must come before any calls to `builder.addMatcher` or `builder.addDefaultCase`.\r\n * @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.\r\n * @param reducer - The actual case reducer function.\r\n */\r\n addCase>(\r\n actionCreator: ActionCreator,\r\n reducer: CaseReducer>\r\n ): ActionReducerMapBuilder\r\n /**\r\n * Adds a case reducer to handle a single exact action type.\r\n * @remarks\r\n * All calls to `builder.addCase` must come before any calls to `builder.addMatcher` or `builder.addDefaultCase`.\r\n * @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.\r\n * @param reducer - The actual case reducer function.\r\n */\r\n addCase>(\r\n type: Type,\r\n reducer: CaseReducer\r\n ): ActionReducerMapBuilder\r\n\r\n /**\r\n * Allows you to match your incoming actions against your own filter function instead of only the `action.type` property.\r\n * @remarks\r\n * If multiple matcher reducers match, all of them will be executed in the order\r\n * they were defined in - even if a case reducer already matched.\r\n * All calls to `builder.addMatcher` must come after any calls to `builder.addCase` and before any calls to `builder.addDefaultCase`.\r\n * @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)\r\n * function\r\n * @param reducer - The actual case reducer function.\r\n *\r\n * @example\r\n```ts\r\nimport {\r\n createAction,\r\n createReducer,\r\n AsyncThunk,\r\n AnyAction,\r\n} from \"@reduxjs/toolkit\";\r\n\r\ntype GenericAsyncThunk = AsyncThunk;\r\n\r\ntype PendingAction = ReturnType;\r\ntype RejectedAction = ReturnType;\r\ntype FulfilledAction = ReturnType;\r\n\r\nconst initialState: Record = {};\r\nconst resetAction = createAction(\"reset-tracked-loading-state\");\r\n\r\nfunction isPendingAction(action: AnyAction): action is PendingAction {\r\n return action.type.endsWith(\"/pending\");\r\n}\r\n\r\nconst reducer = createReducer(initialState, (builder) => {\r\n builder\r\n .addCase(resetAction, () => initialState)\r\n // matcher can be defined outside as a type predicate function\r\n .addMatcher(isPendingAction, (state, action) => {\r\n state[action.meta.requestId] = \"pending\";\r\n })\r\n .addMatcher(\r\n // matcher can be defined inline as a type predicate function\r\n (action): action is RejectedAction => action.type.endsWith(\"/rejected\"),\r\n (state, action) => {\r\n state[action.meta.requestId] = \"rejected\";\r\n }\r\n )\r\n // matcher can just return boolean and the matcher can receive a generic argument\r\n .addMatcher(\r\n (action) => action.type.endsWith(\"/fulfilled\"),\r\n (state, action) => {\r\n state[action.meta.requestId] = \"fulfilled\";\r\n }\r\n );\r\n});\r\n```\r\n */\r\n addMatcher(\r\n matcher: ActionMatcher | ((action: AnyAction) => boolean),\r\n reducer: CaseReducer\r\n ): Omit, 'addCase'>\r\n\r\n /**\r\n * Adds a \"default case\" reducer that is executed if no case reducer and no matcher\r\n * reducer was executed for this action.\r\n * @param reducer - The fallback \"default case\" reducer function.\r\n *\r\n * @example\r\n```ts\r\nimport { createReducer } from '@reduxjs/toolkit'\r\nconst initialState = { otherActions: 0 }\r\nconst reducer = createReducer(initialState, builder => {\r\n builder\r\n // .addCase(...)\r\n // .addMatcher(...)\r\n .addDefaultCase((state, action) => {\r\n state.otherActions++\r\n })\r\n})\r\n```\r\n */\r\n addDefaultCase(reducer: CaseReducer): {}\r\n}\r\n\r\nexport function executeReducerBuilderCallback(\r\n builderCallback: (builder: ActionReducerMapBuilder) => void\r\n): [\r\n CaseReducers,\r\n ActionMatcherDescriptionCollection,\r\n CaseReducer | undefined\r\n] {\r\n const actionsMap: CaseReducers = {}\r\n const actionMatchers: ActionMatcherDescriptionCollection = []\r\n let defaultCaseReducer: CaseReducer | undefined\r\n const builder = {\r\n addCase(\r\n typeOrActionCreator: string | TypedActionCreator,\r\n reducer: CaseReducer\r\n ) {\r\n if (process.env.NODE_ENV !== 'production') {\r\n /*\r\n to keep the definition by the user in line with actual behavior, \r\n we enforce `addCase` to always be called before calling `addMatcher`\r\n as matching cases take precedence over matchers\r\n */\r\n if (actionMatchers.length > 0) {\r\n throw new Error(\r\n '`builder.addCase` should only be called before calling `builder.addMatcher`'\r\n )\r\n }\r\n if (defaultCaseReducer) {\r\n throw new Error(\r\n '`builder.addCase` should only be called before calling `builder.addDefaultCase`'\r\n )\r\n }\r\n }\r\n const type =\r\n typeof typeOrActionCreator === 'string'\r\n ? typeOrActionCreator\r\n : typeOrActionCreator.type\r\n if (type in actionsMap) {\r\n throw new Error(\r\n 'addCase cannot be called with two reducers for the same action type'\r\n )\r\n }\r\n actionsMap[type] = reducer\r\n return builder\r\n },\r\n addMatcher(\r\n matcher: ActionMatcher,\r\n reducer: CaseReducer\r\n ) {\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (defaultCaseReducer) {\r\n throw new Error(\r\n '`builder.addMatcher` should only be called before calling `builder.addDefaultCase`'\r\n )\r\n }\r\n }\r\n actionMatchers.push({ matcher, reducer })\r\n return builder\r\n },\r\n addDefaultCase(reducer: CaseReducer) {\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (defaultCaseReducer) {\r\n throw new Error('`builder.addDefaultCase` can only be called once')\r\n }\r\n }\r\n defaultCaseReducer = reducer\r\n return builder\r\n },\r\n }\r\n builderCallback(builder)\r\n return [actionsMap, actionMatchers, defaultCaseReducer]\r\n}\r\n","import type { Reducer } from 'redux'\r\nimport type {\r\n ActionCreatorWithoutPayload,\r\n PayloadAction,\r\n PayloadActionCreator,\r\n PrepareAction,\r\n _ActionCreatorWithPreparedPayload,\r\n} from './createAction'\r\nimport { createAction } from './createAction'\r\nimport type { CaseReducer, CaseReducers } from './createReducer'\r\nimport { createReducer } from './createReducer'\r\nimport type { ActionReducerMapBuilder } from './mapBuilders'\r\nimport { executeReducerBuilderCallback } from './mapBuilders'\r\nimport type { NoInfer } from './tsHelpers'\r\n\r\n/**\r\n * An action creator attached to a slice.\r\n *\r\n * @deprecated please use PayloadActionCreator directly\r\n *\r\n * @public\r\n */\r\nexport type SliceActionCreator