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,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC;AAxCD,kCAwCC","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport { chainSlice } from './chain';\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { trackablesSlice } from './trackables';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n  const sagaMiddleware = createSagaMiddleware();\n  const store = configureStore({\n    reducer: {\n      mocks: mocksSlice.reducer,\n      notifications: notificationsSlice.reducer,\n      state: stateSlice.reducer,\n      trackables: trackablesSlice.reducer,\n      ui: uiSlice.reducer,\n      chain: chainSlice.reducer,\n    },\n    middleware: (getDefaultMiddleware) =>\n      getDefaultMiddleware({ thunk: false, serializableCheck: false }).concat(\n        sagaMiddleware,\n      ),\n  });\n\n  // Set initial state for the Snap.\n  if (state) {\n    store.dispatch(\n      setState({\n        state: JSON.stringify(state),\n        encrypted: true,\n      }),\n    );\n  }\n\n  if (unencryptedState) {\n    store.dispatch(\n      setState({\n        state: JSON.stringify(unencryptedState),\n        encrypted: false,\n      }),\n    );\n  }\n\n  return {\n    store,\n    runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n  };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}