{"version":3,"sources":["../../src/react/index.ts","../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["// This must remain here so that the `mangleErrors.cjs` build script\n// does not have to import this into each source file it rewrites.\nimport { formatProdErrorMessage } from '@reduxjs/toolkit';\nexport * from '@reduxjs/toolkit';\nexport { createDynamicMiddleware } from '../dynamicMiddleware/react';","import type { Action as ReduxAction, UnknownAction, Dispatch as ReduxDispatch, Middleware } from 'redux';\nimport type { TSHelpersExtractDispatchExtensions } from '@reduxjs/toolkit';\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit';\nimport type { ReactReduxContextValue } from 'react-redux';\nimport { ReactReduxContext, useDispatch as useDefaultDispatch, createDispatchHook } from 'react-redux';\nimport type { Context } from 'react';\nimport type { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig } from '@reduxjs/toolkit';\nexport type UseDispatchWithMiddlewareHook[] = [], State = any, Dispatch extends ReduxDispatch = ReduxDispatch> = () => TSHelpersExtractDispatchExtensions & Dispatch;\nexport type CreateDispatchWithMiddlewareHook = ReduxDispatch> = {\n , ...Middleware[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook;\n withTypes(): CreateDispatchWithMiddlewareHook, GetDispatch>;\n};\ntype ActionFromDispatch> = Dispatch extends ReduxDispatch ? Action : never;\ninterface ReactDynamicMiddlewareInstance = ReduxDispatch> extends DynamicMiddlewareInstance {\n createDispatchWithMiddlewareHookFactory: (context?: Context> | null>) => CreateDispatchWithMiddlewareHook;\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook;\n}\nexport const createDynamicMiddleware = = ReduxDispatch>(): ReactDynamicMiddlewareInstance => {\n const instance = cDM();\n\n const createDispatchWithMiddlewareHookFactory = ( // @ts-ignore\n context: Context> | null> = ReactReduxContext) => {\n const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);\n\n function createDispatchWithMiddlewareHook[]>(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares);\n return useDispatch;\n }\n\n createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;\n\n return (createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook);\n };\n\n const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();\n return { ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook\n };\n};"],"mappings":";AAGA,cAAc;;;ACDd,SAAS,2BAA2B,WAAW;AAE/C,SAAS,mBAAmB,eAAe,oBAAoB,0BAA0B;AAalF,IAAM,0BAA0B,MAAkJ;AACvL,QAAM,WAAW,IAAqB;AAEtC,QAAM,0CAA0C,CAChD,UAAuF,sBAAsB;AAC3G,UAAM,cAAc,YAAY,oBAAoB,qBAAqB,mBAAmB,OAAO;AAEnG,aAASA,qCAA4F,aAA0B;AAC7H,eAAS,cAAc,GAAG,WAAW;AACrC,aAAO;AAAA,IACT;AAEA,IAAAA,kCAAiC,YAAY,MAAMA;AAEnD,WAAQA;AAAA,EACV;AAEA,QAAM,mCAAmC,wCAAwC;AACjF,SAAO;AAAA,IAAE,GAAG;AAAA,IACV;AAAA,IACA;AAAA,EACF;AACF;","names":["createDispatchWithMiddlewareHook"]}