();\n\n if (thunk) {\n if (isBoolean(thunk)) {\n middlewareArray.push(thunkMiddleware);\n } else {\n middlewareArray.push(withExtraArgument(thunk.extraArgument));\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (immutableCheck) {\n /* PROD_START_REMOVE_UMD */\n let immutableOptions: ImmutableStateInvariantMiddlewareOptions = {};\n\n if (!isBoolean(immutableCheck)) {\n immutableOptions = immutableCheck;\n }\n\n middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));\n /* PROD_STOP_REMOVE_UMD */\n }\n\n if (serializableCheck) {\n let serializableOptions: SerializableStateInvariantMiddlewareOptions = {};\n\n if (!isBoolean(serializableCheck)) {\n serializableOptions = serializableCheck;\n }\n\n middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));\n }\n\n if (actionCreatorCheck) {\n let actionCreatorOptions: ActionCreatorInvariantMiddlewareOptions = {};\n\n if (!isBoolean(actionCreatorCheck)) {\n actionCreatorOptions = actionCreatorCheck;\n }\n\n middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));\n }\n }\n\n return (middlewareArray as any);\n};","import { formatProdErrorMessage as _formatProdErrorMessage } from \"@reduxjs/toolkit\";\nimport { isAction } from 'redux';\nimport type { IsUnknownOrNonInferrable, IfMaybeUndefined, IfVoid, IsAny } from './tsHelpers';\nimport { hasMatchFunction } from './tsHelpers';\n/**\n * An action with a string type and an associated payload. This is the\n * type of action returned by `createAction()` action creators.\n *\n * @template P The type of the action's payload.\n * @template T the type used for the action type.\n * @template M The type of the action's meta (optional)\n * @template E The type of the action's error (optional)\n *\n * @public\n */\n\nexport type PayloadAction = {\n payload: P;\n type: T;\n} & ([M] extends [never] ? {} : {\n meta: M;\n}) & ([E] extends [never] ? {} : {\n error: E;\n});\n/**\n * A \"prepare\" method to be used as the second parameter of `createAction`.\n * Takes any number of arguments and returns a Flux Standard Action without\n * type (will be added later) that *must* contain a payload (might be undefined).\n *\n * @public\n */\n\nexport type PrepareAction
= ((...args: any[]) => {\n payload: P;\n}) | ((...args: any[]) => {\n payload: P;\n meta: any;\n}) | ((...args: any[]) => {\n payload: P;\n error: any;\n}) | ((...args: any[]) => {\n payload: P;\n meta: any;\n error: any;\n});\n/**\n * Internal version of `ActionCreatorWithPreparedPayload`. Not to be used externally.\n *\n * @internal\n */\n\nexport type _ActionCreatorWithPreparedPayload | void, T extends string = string> = PA extends PrepareAction ? ActionCreatorWithPreparedPayload, P, T, ReturnType extends {\n error: infer E;\n} ? E : never, ReturnType extends {\n meta: infer M;\n} ? M : never> : void;\n/**\n * Basic type for all action creators.\n *\n * @inheritdoc {redux#ActionCreator}\n */\n\nexport interface BaseActionCreator {\n type: T;\n match: (action: unknown) => action is PayloadAction
;\n}\n/**\n * An action creator that takes multiple arguments that are passed\n * to a `PrepareAction` method to create the final Action.\n * @typeParam Args arguments for the action creator function\n * @typeParam P `payload` type\n * @typeParam T `type` name\n * @typeParam E optional `error` type\n * @typeParam M optional `meta` type\n *\n * @inheritdoc {redux#ActionCreator}\n *\n * @public\n */\n\nexport interface ActionCreatorWithPreparedPayload extends BaseActionCreator {\n /**\n * Calling this {@link redux#ActionCreator} with `Args` will return\n * an Action with a payload of type `P` and (depending on the `PrepareAction`\n * method used) a `meta`- and `error` property of types `M` and `E` respectively.\n */\n (...args: Args): PayloadAction
;\n}\n/**\n * An action creator of type `T` that takes an optional payload of type `P`.\n *\n * @inheritdoc {redux#ActionCreator}\n *\n * @public\n */\n\nexport interface ActionCreatorWithOptionalPayload
extends BaseActionCreator
{\n /**\n * Calling this {@link redux#ActionCreator} with an argument will\n * return a {@link PayloadAction} of type `T` with a payload of `P`.\n * Calling it without an argument will return a PayloadAction with a payload of `undefined`.\n */\n (payload?: P): PayloadAction
;\n}\n/**\n * An action creator of type `T` that takes no payload.\n *\n * @inheritdoc {redux#ActionCreator}\n *\n * @public\n */\n\nexport interface ActionCreatorWithoutPayload extends BaseActionCreator {\n /**\n * Calling this {@link redux#ActionCreator} will\n * return a {@link PayloadAction} of type `T` with a payload of `undefined`\n */\n (noArgument: void): PayloadAction;\n}\n/**\n * An action creator of type `T` that requires a payload of type P.\n *\n * @inheritdoc {redux#ActionCreator}\n *\n * @public\n */\n\nexport interface ActionCreatorWithPayload extends BaseActionCreator
{\n /**\n * Calling this {@link redux#ActionCreator} with an argument will\n * return a {@link PayloadAction} of type `T` with a payload of `P`\n */\n (payload: P): PayloadAction
;\n}\n/**\n * An action creator of type `T` whose `payload` type could not be inferred. Accepts everything as `payload`.\n *\n * @inheritdoc {redux#ActionCreator}\n *\n * @public\n */\n\nexport interface ActionCreatorWithNonInferrablePayload extends BaseActionCreator {\n /**\n * Calling this {@link redux#ActionCreator} with an argument will\n * return a {@link PayloadAction} of type `T` with a payload\n * of exactly the type of the argument.\n */\n (payload: PT): PayloadAction;\n}\n/**\n * An action creator that produces actions with a `payload` attribute.\n *\n * @typeParam P the `payload` type\n * @typeParam T the `type` of the resulting action\n * @typeParam PA if the resulting action is preprocessed by a `prepare` method, the signature of said method.\n *\n * @public\n */\n\nexport type PayloadActionCreator | void = void> = IfPrepareActionMethodProvided, // else\nIsAny, IsUnknownOrNonInferrable
, // else\nIfVoid
, // else\nIfMaybeUndefined
, // else\nActionCreatorWithPayload
>>>>>;\n/**\n * A utility function to create an action creator for the given action type\n * string. The action creator accepts a single argument, which will be included\n * in the action object as a field called payload. The action creator function\n * will also have its toString() overridden so that it returns the action type.\n *\n * @param type The action type to use for created actions.\n * @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }.\n * If this is given, the resulting action creator will pass its arguments to this method to calculate payload & meta.\n *\n * @public\n */\n\nexport function createAction
(type: T): PayloadActionCreator
;\n/**\n * A utility function to create an action creator for the given action type\n * string. The action creator accepts a single argument, which will be included\n * in the action object as a field called payload. The action creator function\n * will also have its toString() overridden so that it returns the action type.\n *\n * @param type The action type to use for created actions.\n * @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }.\n * If this is given, the resulting action creator will pass its arguments to this method to calculate payload & meta.\n *\n * @public\n */\n\nexport function createAction, T extends string = string>(type: T, prepareAction: PA): PayloadActionCreator['payload'], T, PA>;\nexport function createAction(type: string, prepareAction?: Function): any {\n function actionCreator(...args: any[]) {\n if (prepareAction) {\n let prepared = prepareAction(...args);\n\n if (!prepared) {\n throw new Error(process.env.NODE_ENV === \"production\" ? _formatProdErrorMessage(0) : 'prepareAction did not return an object');\n }\n\n return {\n type,\n payload: prepared.payload,\n ...('meta' in prepared && {\n meta: prepared.meta\n }),\n ...('error' in prepared && {\n error: prepared.error\n })\n };\n }\n\n return {\n type,\n payload: args[0]\n };\n }\n\n actionCreator.toString = () => `${type}`;\n\n actionCreator.type = type;\n\n actionCreator.match = (action: unknown): action is PayloadAction => isAction(action) && action.type === type;\n\n return actionCreator;\n}\n/**\n * Returns true if value is an RTK-like action creator, with a static type property and match method.\n */\n\nexport function isActionCreator(action: unknown): action is BaseActionCreator & Function {\n return typeof action === 'function' && 'type' in action && // hasMatchFunction only wants Matchers but I don't see the point in rewriting it\n hasMatchFunction((action as any));\n}\n/**\n * Returns true if value is an action with a string type and valid Flux Standard Action keys.\n */\n\nexport function isFSA(action: unknown): action is {\n type: string;\n payload?: unknown;\n error?: unknown;\n meta?: unknown;\n} {\n return isAction(action) && Object.keys(action).every(isValidKey);\n}\n\nfunction isValidKey(key: string) {\n return ['type', 'payload', 'error', 'meta'].indexOf(key) > -1;\n} // helper types for more readable typings\n\n\ntype IfPrepareActionMethodProvided | void, True, False> = PA extends (...args: any[]) => any ? True : False;","import type { Middleware, StoreEnhancer } from 'redux';\nimport type { Tuple } from './utils';\nexport function safeAssign(target: T, ...args: Array>>) {\n Object.assign(target, ...args);\n}\n/**\n * return True if T is `any`, otherwise return False\n * taken from https://github.com/joonhocho/tsdef\n *\n * @internal\n */\n\nexport type IsAny = // test if we are going the left AND right path in the condition\ntrue | false extends (T extends never ? true : false) ? True : False;\nexport type CastAny = IsAny;\n/**\n * return True if T is `unknown`, otherwise return False\n * taken from https://github.com/joonhocho/tsdef\n *\n * @internal\n */\n\nexport type IsUnknown = unknown extends T ? IsAny : False;\nexport type FallbackIfUnknown = IsUnknown;\n/**\n * @internal\n */\n\nexport type IfMaybeUndefined = [undefined] extends [P] ? True : False;\n/**\n * @internal\n */\n\nexport type IfVoid
= [void] extends [P] ? True : False;\n/**\n * @internal\n */\n\nexport type IsEmptyObj = T extends any ? keyof T extends never ? IsUnknown>> : False : never;\n/**\n * returns True if TS version is above 3.5, False if below.\n * uses feature detection to detect TS version >= 3.5\n * * versions below 3.5 will return `{}` for unresolvable interference\n * * versions above will return `unknown`\n *\n * @internal\n */\n\nexport type AtLeastTS35 = [True, False][IsUnknown() => T>, 0, 1>];\n/**\n * @internal\n */\n\nexport type IsUnknownOrNonInferrable = AtLeastTS35, IsEmptyObj>>;\n/**\n * Convert a Union type `(A|B)` to an intersection type `(A&B)`\n */\n\nexport type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; // Appears to have a convenient side effect of ignoring `never` even if that's not what you specified\n\nexport type ExcludeFromTuple = T extends [infer Head, ...infer Tail] ? ExcludeFromTuple : Acc;\ntype ExtractDispatchFromMiddlewareTuple = MiddlewareTuple extends [infer Head, ...infer Tail] ? ExtractDispatchFromMiddlewareTuple ? IsAny : {})> : Acc;\nexport type ExtractDispatchExtensions = M extends Tuple ? ExtractDispatchFromMiddlewareTuple : M extends ReadonlyArray ? ExtractDispatchFromMiddlewareTuple<[...M], {}> : never;\ntype ExtractStoreExtensionsFromEnhancerTuple = EnhancerTuple extends [infer Head, ...infer Tail] ? ExtractStoreExtensionsFromEnhancerTuple ? IsAny : {})> : Acc;\nexport type ExtractStoreExtensions = E extends Tuple ? ExtractStoreExtensionsFromEnhancerTuple : E extends ReadonlyArray ? UnionToIntersection ? Ext extends {} ? IsAny : {} : {}> : never;\ntype ExtractStateExtensionsFromEnhancerTuple = EnhancerTuple extends [infer Head, ...infer Tail] ? ExtractStateExtensionsFromEnhancerTuple ? IsAny : {})> : Acc;\nexport type ExtractStateExtensions = E extends Tuple ? ExtractStateExtensionsFromEnhancerTuple : E extends ReadonlyArray ? UnionToIntersection ? StateExt extends {} ? IsAny : {} : {}> : never;\n/**\n * Helper type. Passes T out again, but boxes it in a way that it cannot\n * \"widen\" the type by accident if it is a generic that should be inferred\n * from elsewhere.\n *\n * @internal\n */\n\nexport type NoInfer = [T][T extends any ? 0 : never];\nexport type NonUndefined = T extends undefined ? never : T;\nexport type Omit = Pick>;\nexport type WithRequiredProp = Omit & Required>;\nexport type WithOptionalProp = Omit & Partial>;\nexport interface TypeGuard {\n (value: any): value is T;\n}\nexport interface HasMatchFunction {\n match: TypeGuard;\n}\nexport const hasMatchFunction = (v: Matcher): v is HasMatchFunction => {\n return v && typeof (v as HasMatchFunction).match === 'function';\n};\n/** @public */\n\nexport type Matcher = HasMatchFunction | TypeGuard;\n/** @public */\n\nexport type ActionFromMatcher> = M extends Matcher ? T : never;\nexport type Id = { [K in keyof T]: T[K] } & {};\nexport type Tail = T extends [any, ...infer Tail] ? Tail : never;\nexport type UnknownIfNonSpecific = {} extends T ? unknown : T;\n/**\n * A Promise that will never reject.\n * @see https://github.com/reduxjs/redux-toolkit/issues/4101\n */\n\nexport type SafePromise = Promise & {\n __linterBrands: 'SafePromise';\n};\n/**\n * Properly wraps a Promise as a {@link SafePromise} with .catch(fallback).\n */\n\nexport function asSafePromise(promise: Promise, fallback: (error: unknown) => Rejected) {\n return (promise.catch(fallback) as SafePromise);\n}","import type { Middleware } from 'redux';\nimport { isActionCreator as isRTKAction } from './createAction';\nexport interface ActionCreatorInvariantMiddlewareOptions {\n /**\n * The function to identify whether a value is an action creator.\n * The default checks for a function with a static type property and match method.\n */\n isActionCreator?: (action: unknown) => action is Function & {\n type?: unknown;\n };\n}\nexport function getMessage(type?: unknown) {\n const splitType = type ? `${type}`.split('/') : [];\n const actionName = splitType[splitType.length - 1] || 'actionCreator';\n return `Detected an action creator with type \"${type || 'unknown'}\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \\`dispatch(${actionName}())\\` instead of \\`dispatch(${actionName})\\`. This is necessary even if the action has no payload.`;\n}\nexport function createActionCreatorInvariantMiddleware(options: ActionCreatorInvariantMiddlewareOptions = {}): Middleware {\n if (process.env.NODE_ENV === 'production') {\n return () => next => action => next(action);\n }\n\n const {\n isActionCreator = isRTKAction\n } = options;\n return () => next => action => {\n if (isActionCreator(action)) {\n console.warn(getMessage(action.type));\n }\n\n return next(action);\n };\n}","import { formatProdErrorMessage as _formatProdErrorMessage } from \"@reduxjs/toolkit\";\nimport { produce as createNextState, isDraftable } from 'immer';\nimport type { Middleware, StoreEnhancer } from 'redux';\nexport function getTimeMeasureUtils(maxDelay: number, fnName: string) {\n let elapsed = 0;\n return {\n measureTime(fn: () => T): T {\n const started = Date.now();\n\n try {\n return fn();\n } finally {\n const finished = Date.now();\n elapsed += finished - started;\n }\n },\n\n warnIfExceeded() {\n if (elapsed > maxDelay) {\n console.warn(`${fnName} took ${elapsed}ms, which is more than the warning threshold of ${maxDelay}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`);\n }\n }\n\n };\n}\nexport function delay(ms: number) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\nexport function find(iterable: Iterable, comparator: (item: T) => boolean): T | undefined {\n for (const entry of iterable) {\n if (comparator(entry)) {\n return entry;\n }\n }\n\n return undefined;\n}\nexport class Tuple = []> extends Array {\n constructor(length: number);\n constructor(...items: Items);\n\n constructor(...items: any[]) {\n super(...items);\n Object.setPrototypeOf(this, Tuple.prototype);\n }\n\n static get [Symbol.species]() {\n return (Tuple as any);\n }\n\n concat>(items: Tuple): Tuple<[...Items, ...AdditionalItems]>;\n concat>(items: AdditionalItems): Tuple<[...Items, ...AdditionalItems]>;\n concat>(...items: AdditionalItems): Tuple<[...Items, ...AdditionalItems]>;\n\n concat(...arr: any[]) {\n return super.concat.apply(this, arr);\n }\n\n prepend>(items: Tuple): Tuple<[...AdditionalItems, ...Items]>;\n prepend>(items: AdditionalItems): Tuple<[...AdditionalItems, ...Items]>;\n prepend>(...items: AdditionalItems): Tuple<[...AdditionalItems, ...Items]>;\n\n prepend(...arr: any[]) {\n if (arr.length === 1 && Array.isArray(arr[0])) {\n return new Tuple(...arr[0].concat(this));\n }\n\n return new Tuple(...arr.concat(this));\n }\n\n}\nexport function freezeDraftable(val: T) {\n return isDraftable(val) ? createNextState(val, () => {}) : val;\n}\ninterface WeakMapEmplaceHandler {\n /**\n * Will be called to get value, if no value is currently in map.\n */\n insert?(key: K, map: WeakMap): V;\n /**\n * Will be called to update a value, if one exists already.\n */\n\n update?(previous: V, key: K, map: WeakMap): V;\n}\ninterface MapEmplaceHandler {\n /**\n * Will be called to get value, if no value is currently in map.\n */\n insert?(key: K, map: Map): V;\n /**\n * Will be called to update a value, if one exists already.\n */\n\n update?(previous: V, key: K, map: Map): V;\n}\nexport function emplace(map: Map, key: K, handler: MapEmplaceHandler): V;\nexport function emplace(map: WeakMap, key: K, handler: WeakMapEmplaceHandler): V;\n/**\n * Allow inserting a new value, or updating an existing one\n * @throws if called for a key with no current value and no `insert` handler is provided\n * @returns current value in map (after insertion/updating)\n * ```ts\n * // return current value if already in map, otherwise initialise to 0 and return that\n * const num = emplace(map, key, {\n * insert: () => 0\n * })\n *\n * // increase current value by one if already in map, otherwise initialise to 0\n * const num = emplace(map, key, {\n * update: (n) => n + 1,\n * insert: () => 0,\n * })\n *\n * // only update if value's already in the map - and increase it by one\n * if (map.has(key)) {\n * const num = emplace(map, key, {\n * update: (n) => n + 1,\n * })\n * }\n * ```\n *\n * @remarks\n * Based on https://github.com/tc39/proposal-upsert currently in Stage 2 - maybe in a few years we'll be able to replace this with direct method calls\n */\n\nexport function emplace(map: WeakMap, key: K, handler: WeakMapEmplaceHandler): V {\n if (map.has(key)) {\n let value = (map.get(key) as V);\n\n if (handler.update) {\n value = handler.update(value, key, map);\n map.set(key, value);\n }\n\n return value;\n }\n\n if (!handler.insert) throw new Error(process.env.NODE_ENV === \"production\" ? _formatProdErrorMessage(10) : 'No insert provided for key not already in map');\n const inserted = handler.insert(key, map);\n map.set(key, inserted);\n return inserted;\n}","import { formatProdErrorMessage as _formatProdErrorMessage2 } from \"@reduxjs/toolkit\";\nimport { formatProdErrorMessage as _formatProdErrorMessage } from \"@reduxjs/toolkit\";\nimport type { Middleware } from 'redux';\nimport { getTimeMeasureUtils } from './utils';\ntype EntryProcessor = (key: string, value: any) => any;\n/**\n * The default `isImmutable` function.\n *\n * @public\n */\n\nexport function isImmutableDefault(value: unknown): boolean {\n return typeof value !== 'object' || value == null || Object.isFrozen(value);\n}\nexport function trackForMutations(isImmutable: IsImmutableFunc, ignorePaths: IgnorePaths | undefined, obj: any) {\n const trackedProperties = trackProperties(isImmutable, ignorePaths, obj);\n return {\n detectMutations() {\n return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);\n }\n\n };\n}\ninterface TrackedProperty {\n value: any;\n children: Record;\n}\n\nfunction trackProperties(isImmutable: IsImmutableFunc, ignorePaths: IgnorePaths = [], obj: Record, path: string = '', checkedObjects: Set> = new Set()) {\n const tracked: Partial = {\n value: obj\n };\n\n if (!isImmutable(obj) && !checkedObjects.has(obj)) {\n checkedObjects.add(obj);\n tracked.children = {};\n\n for (const key in obj) {\n const childPath = path ? path + '.' + key : key;\n\n if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {\n continue;\n }\n\n tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);\n }\n }\n\n return (tracked as TrackedProperty);\n}\n\ntype IgnorePaths = readonly (string | RegExp)[];\n\nfunction detectMutations(isImmutable: IsImmutableFunc, ignoredPaths: IgnorePaths = [], trackedProperty: TrackedProperty, obj: any, sameParentRef: boolean = false, path: string = ''): {\n wasMutated: boolean;\n path?: string;\n} {\n const prevObj = trackedProperty ? trackedProperty.value : undefined;\n const sameRef = prevObj === obj;\n\n if (sameParentRef && !sameRef && !Number.isNaN(obj)) {\n return {\n wasMutated: true,\n path\n };\n }\n\n if (isImmutable(prevObj) || isImmutable(obj)) {\n return {\n wasMutated: false\n };\n } // Gather all keys from prev (tracked) and after objs\n\n\n const keysToDetect: Record = {};\n\n for (let key in trackedProperty.children) {\n keysToDetect[key] = true;\n }\n\n for (let key in obj) {\n keysToDetect[key] = true;\n }\n\n const hasIgnoredPaths = ignoredPaths.length > 0;\n\n for (let key in keysToDetect) {\n const nestedPath = path ? path + '.' + key : key;\n\n if (hasIgnoredPaths) {\n const hasMatches = ignoredPaths.some(ignored => {\n if (ignored instanceof RegExp) {\n return ignored.test(nestedPath);\n }\n\n return nestedPath === ignored;\n });\n\n if (hasMatches) {\n continue;\n }\n }\n\n const result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);\n\n if (result.wasMutated) {\n return result;\n }\n }\n\n return {\n wasMutated: false\n };\n}\n\ntype IsImmutableFunc = (value: any) => boolean;\n/**\n * Options for `createImmutableStateInvariantMiddleware()`.\n *\n * @public\n */\n\nexport interface ImmutableStateInvariantMiddlewareOptions {\n /**\n Callback function to check if a value is considered to be immutable.\n This function is applied recursively to every value contained in the state.\n The default implementation will return true for primitive types \n (like numbers, strings, booleans, null and undefined).\n */\n isImmutable?: IsImmutableFunc;\n /** \n An array of dot-separated path strings that match named nodes from \n the root state to ignore when checking for immutability.\n Defaults to undefined\n */\n\n ignoredPaths?: IgnorePaths;\n /** Print a warning if checks take longer than N ms. Default: 32ms */\n\n warnAfter?: number;\n}\n/**\n * Creates a middleware that checks whether any state was mutated in between\n * dispatches or during a dispatch. If any mutations are detected, an error is\n * thrown.\n *\n * @param options Middleware options.\n *\n * @public\n */\n\nexport function createImmutableStateInvariantMiddleware(options: ImmutableStateInvariantMiddlewareOptions = {}): Middleware {\n if (process.env.NODE_ENV === 'production') {\n return () => next => action => next(action);\n } else {\n function stringify(obj: any, serializer?: EntryProcessor, indent?: string | number, decycler?: EntryProcessor): string {\n return JSON.stringify(obj, getSerialize(serializer, decycler), indent);\n }\n\n function getSerialize(serializer?: EntryProcessor, decycler?: EntryProcessor): EntryProcessor {\n let stack: any[] = [],\n keys: any[] = [];\n if (!decycler) decycler = function (_: string, value: any) {\n if (stack[0] === value) return '[Circular ~]';\n return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';\n };\n return function (this: any, key: string, value: any) {\n if (stack.length > 0) {\n var thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) value = decycler!.call(this, key, value);\n } else stack.push(value);\n\n return serializer == null ? value : serializer.call(this, key, value);\n };\n }\n\n let {\n isImmutable = isImmutableDefault,\n ignoredPaths,\n warnAfter = 32\n } = options;\n const track = trackForMutations.bind(null, isImmutable, ignoredPaths);\n return ({\n getState\n }) => {\n let state = getState();\n let tracker = track(state);\n let result;\n return next => action => {\n const measureUtils = getTimeMeasureUtils(warnAfter, 'ImmutableStateInvariantMiddleware');\n measureUtils.measureTime(() => {\n state = getState();\n result = tracker.detectMutations(); // Track before potentially not meeting the invariant\n\n tracker = track(state);\n\n if (result.wasMutated) {\n throw new Error(process.env.NODE_ENV === \"production\" ? _formatProdErrorMessage(19) : `A state mutation was detected between dispatches, in the path '${result.path || ''}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`);\n }\n });\n const dispatchedAction = next(action);\n measureUtils.measureTime(() => {\n state = getState();\n result = tracker.detectMutations(); // Track before potentially not meeting the invariant\n\n tracker = track(state);\n\n if (result.wasMutated) {\n throw new Error(process.env.NODE_ENV === \"production\" ? _formatProdErrorMessage2(20) : `A state mutation was detected inside a dispatch, in the path: ${result.path || ''}. Take a look at the reducer(s) handling the action ${stringify(action)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`);\n }\n });\n measureUtils.warnIfExceeded();\n return dispatchedAction;\n };\n };\n }\n}","import type { Middleware } from 'redux';\nimport { isAction, isPlainObject } from 'redux';\nimport { getTimeMeasureUtils } from './utils';\n/**\n * Returns true if the passed value is \"plain\", i.e. a value that is either\n * directly JSON-serializable (boolean, number, string, array, plain object)\n * or `undefined`.\n *\n * @param val The value to check.\n *\n * @public\n */\n\nexport function isPlain(val: any) {\n const type = typeof val;\n return val == null || type === 'string' || type === 'boolean' || type === 'number' || Array.isArray(val) || isPlainObject(val);\n}\ninterface NonSerializableValue {\n keyPath: string;\n value: unknown;\n}\ntype IgnorePaths = readonly (string | RegExp)[];\n/**\n * @public\n */\n\nexport function findNonSerializableValue(value: unknown, path: string = '', isSerializable: (value: unknown) => boolean = isPlain, getEntries?: (value: unknown) => [string, any][], ignoredPaths: IgnorePaths = [], cache?: WeakSet