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6.esm.mjs","webpack://@affine/web/../../../node_modules/jotai-devtools/dist/index.esm.mjs"],"sourcesContent":["// src/utils/useAtomsSnapshot.ts\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\n// src/utils/hooks/useDevToolsStore.ts\nimport { useStore } from \"jotai\";\n\n// src/utils/internals/compose-with-devtools.ts\nvar isStoreV2 = (store) => {\n return store ? \"dev4_get_internal_weak_map\" in store : false;\n};\nvar isStoreV1 = (store) => {\n return !isStoreV2(store);\n};\nvar isDevToolsStore = (store) => {\n return \"subscribeStore\" in store;\n};\nvar __composeV2StoreWithDevTools = (store) => {\n const { sub, set, get } = store;\n const storeListeners = /* @__PURE__ */ new Set();\n const recentlySetAtomsMap = /* @__PURE__ */ new WeakMap();\n const reduceCountOrRemoveRecentlySetAtom = (atom, onFound) => {\n const foundCount = recentlySetAtomsMap.get(atom);\n if (typeof foundCount === \"number\") {\n if (foundCount > 1) {\n recentlySetAtomsMap.set(atom, foundCount - 1);\n } else {\n recentlySetAtomsMap.delete(atom);\n }\n onFound?.();\n }\n };\n const increaseCountRecentlySetAtom = (atom) => {\n const foundCount = recentlySetAtomsMap.get(atom);\n recentlySetAtomsMap.set(atom, (foundCount || 0) + 1);\n };\n store.sub = (...args) => {\n const unsub = sub(...args);\n storeListeners.forEach((l) => l({ type: \"sub\" }));\n return () => {\n unsub();\n reduceCountOrRemoveRecentlySetAtom(args[0]);\n storeListeners.forEach((l) => l({ type: \"unsub\" }));\n };\n };\n store.get = (...args) => {\n const value = get(...args);\n reduceCountOrRemoveRecentlySetAtom(args[0], () => {\n if (value instanceof Promise) {\n value.then(() => {\n Promise.resolve().then(() => {\n storeListeners.forEach((l) => l({ type: \"async-get\" }));\n });\n });\n }\n });\n storeListeners.forEach((l) => l({ type: \"get\" }));\n return value;\n };\n store.set = (...args) => {\n const value = set(...args);\n increaseCountRecentlySetAtom(args[0]);\n storeListeners.forEach((l) => l({ type: \"set\" }));\n return value;\n };\n store.subscribeStore = (l) => {\n storeListeners.add(l);\n return () => {\n storeListeners.delete(l);\n };\n };\n store.getMountedAtoms = () => {\n return store.dev4_get_mounted_atoms();\n };\n store.getAtomState = (atom) => {\n const aState = store.dev4_get_internal_weak_map().get(atom);\n if (aState) {\n return { v: aState.v, e: aState.e, d: new Set(aState.d.keys()) };\n }\n return void 0;\n };\n store.getMountedAtomState = (atom) => {\n const aState = store.dev4_get_internal_weak_map().get(atom);\n if (aState && aState.m) {\n return {\n l: aState.m.l,\n t: aState.m.t\n };\n }\n return void 0;\n };\n store.restoreAtoms = (values) => {\n store.dev4_restore_atoms(values);\n storeListeners.forEach((l) => l({ type: \"restore\" }));\n };\n return store;\n};\nvar __composeV1StoreWithDevTools = (store) => {\n if (\"dev_subscribe_store\" in store && \"dev_get_mounted_atoms\" in store && \"dev_get_atom_state\" in store && \"dev_get_mounted\" in store && \"dev_restore_atoms\" in store) {\n const {\n dev_subscribe_store,\n dev_get_mounted_atoms,\n dev_get_atom_state,\n dev_get_mounted,\n dev_restore_atoms\n } = store;\n store.subscribeStore = (l) => {\n const cb = (action) => {\n if (action.type === \"write\" || action.type === \"async-write\") {\n l({ type: \"set\" });\n }\n if (action.type === \"sub\") {\n l({ type: \"sub\" });\n }\n if (action.type === \"unsub\") {\n l({ type: \"unsub\" });\n }\n if (action.type === \"restore\") {\n l({ type: \"restore\" });\n }\n };\n return dev_subscribe_store(cb, 2);\n };\n store.getMountedAtoms = () => {\n return dev_get_mounted_atoms();\n };\n store.getAtomState = (atom) => {\n const aState = dev_get_atom_state(atom);\n if (aState) {\n const d = new Set(aState.d.keys());\n d.delete(atom);\n if (\"v\" in aState) {\n return { v: aState.v, d };\n }\n if (\"e\" in aState) {\n return { e: aState.e, d };\n }\n return void 0;\n }\n };\n store.getMountedAtomState = (atom) => {\n const mounted = dev_get_mounted(atom);\n return mounted;\n };\n store.restoreAtoms = (values) => {\n dev_restore_atoms(values);\n };\n return store;\n }\n return store;\n};\nvar composeWithDevTools = (store) => {\n if (isDevToolsStore(store)) {\n return store;\n }\n if (isStoreV2(store)) {\n return __composeV2StoreWithDevTools(store);\n }\n if (isStoreV1(store)) {\n return __composeV1StoreWithDevTools(store);\n }\n return store;\n};\n\n// src/utils/hooks/useDevToolsStore.ts\nvar useDevToolsStore = (options) => {\n const store = useStore(options);\n return composeWithDevTools(store);\n};\n\n// src/utils/useAtomsSnapshot.ts\nvar isEqualAtomsValues = (left, right) => left.size === right.size && Array.from(left).every(([left2, v]) => Object.is(right.get(left2), v));\nvar isEqualAtomsDependents = (left, right) => left.size === right.size && Array.from(left).every(([a, dLeft]) => {\n const dRight = right.get(a);\n return dRight && dLeft.size === dRight.size && Array.from(dLeft).every((d) => dRight.has(d));\n});\nfunction useAtomsSnapshot({\n shouldShowPrivateAtoms = false,\n ...options\n} = {}) {\n const store = useDevToolsStore(options);\n const [atomsSnapshot, setAtomsSnapshot] = useState(() => ({\n values: /* @__PURE__ */ new Map(),\n dependents: /* @__PURE__ */ new Map()\n }));\n const duringReactRenderPhase = useRef(true);\n duringReactRenderPhase.current = true;\n useLayoutEffect(() => {\n duringReactRenderPhase.current = false;\n });\n useEffect(() => {\n if (!isDevToolsStore(store)) return;\n let prevValues = /* @__PURE__ */ new Map();\n let prevDependents = /* @__PURE__ */ new Map();\n const callback = () => {\n const values = /* @__PURE__ */ new Map();\n const dependents = /* @__PURE__ */ new Map();\n for (const atom of store.getMountedAtoms() || []) {\n if (!shouldShowPrivateAtoms && atom.debugPrivate) {\n continue;\n }\n const atomState = store.getAtomState(atom);\n if (atomState) {\n if (\"v\" in atomState) {\n values.set(atom, atomState.v);\n }\n }\n const mounted = store.getMountedAtomState(atom);\n if (mounted) {\n let atomDependents = mounted.t;\n if (!shouldShowPrivateAtoms) {\n atomDependents = new Set(\n Array.from(atomDependents.values()).filter(\n /* NOTE: This just removes private atoms from the dependents list,\n instead of hiding them from the dependency chain and showing\n the nested dependents of the private atoms. */\n (dependent) => !dependent.debugPrivate\n )\n );\n }\n dependents.set(atom, atomDependents);\n }\n }\n if (isEqualAtomsValues(prevValues, values) && isEqualAtomsDependents(prevDependents, dependents)) {\n return;\n }\n prevValues = values;\n prevDependents = dependents;\n const deferrableAtomSetAction = () => setAtomsSnapshot({ values, dependents });\n if (duringReactRenderPhase.current) {\n Promise.resolve().then(deferrableAtomSetAction);\n } else {\n deferrableAtomSetAction();\n }\n };\n const unsubscribe = store.subscribeStore(callback);\n callback();\n return unsubscribe;\n }, [store, shouldShowPrivateAtoms]);\n return atomsSnapshot;\n}\n\n// src/utils/useGotoAtomsSnapshot.ts\nimport { useCallback } from \"react\";\nfunction useGotoAtomsSnapshot(options) {\n const store = useDevToolsStore(options);\n return useCallback(\n (snapshot) => {\n if (isDevToolsStore(store)) {\n store.restoreAtoms(snapshot.values);\n }\n },\n [store]\n );\n}\n\n// src/utils/useAtomsDebugValue.ts\nimport {\n useDebugValue,\n useEffect as useEffect2,\n useLayoutEffect as useLayoutEffect2,\n useRef as useRef2,\n useState as useState2\n} from \"react\";\nvar atomToPrintable = (atom) => atom.debugLabel || atom.toString();\nvar stateToPrintable = ([store, atoms]) => Object.fromEntries(\n atoms.flatMap((atom) => {\n const mounted = isDevToolsStore(store) && store.getMountedAtomState(atom);\n if (!mounted) {\n return [];\n }\n const dependents = mounted.t;\n const atomState = store.getAtomState(atom) || {};\n return [\n [\n atomToPrintable(atom),\n {\n ...\"e\" in atomState && { error: atomState.e },\n ...\"v\" in atomState && { value: atomState.v },\n dependents: Array.from(dependents).map(atomToPrintable)\n }\n ]\n ];\n })\n);\nvar useAtomsDebugValue = (options) => {\n const enabled = options?.enabled ?? process.env.NODE_ENV !== \"production\";\n const store = useDevToolsStore(options);\n const [atoms, setAtoms] = useState2([]);\n const duringReactRenderPhase = useRef2(true);\n duringReactRenderPhase.current = true;\n useLayoutEffect2(() => {\n duringReactRenderPhase.current = false;\n });\n useEffect2(() => {\n if (!enabled || !isDevToolsStore(store)) {\n return;\n }\n const callback = () => {\n const deferrableAtomSetAction = () => setAtoms(Array.from(store.getMountedAtoms() || []));\n if (duringReactRenderPhase.current) {\n Promise.resolve().then(deferrableAtomSetAction);\n } else {\n deferrableAtomSetAction();\n }\n };\n const unsubscribe = store.subscribeStore(callback);\n callback();\n return unsubscribe;\n }, [enabled, store]);\n useDebugValue([store, atoms], stateToPrintable);\n};\n\n// src/utils/useAtomDevtools.ts\nimport { useEffect as useEffect3, useRef as useRef3 } from \"react\";\nimport { useAtom } from \"jotai/react\";\n\n// src/utils/redux-extension/createReduxConnection.ts\nvar createReduxConnection = (extension, name) => {\n if (!extension) return void 0;\n const connection = extension.connect({ name });\n return Object.assign(connection, {\n shouldInit: true\n });\n};\n\n// src/utils/redux-extension/getReduxExtension.ts\nvar getReduxExtension = (enabled = process.env.NODE_ENV !== \"production\") => {\n if (!enabled) {\n return void 0;\n }\n const reduxExtension = window.__REDUX_DEVTOOLS_EXTENSION__;\n if (!reduxExtension && process.env.NODE_ENV !== \"production\") {\n console.warn(\"Please install/enable Redux devtools extension\");\n return void 0;\n }\n return reduxExtension;\n};\n\n// src/utils/useAtomDevtools.ts\nfunction useAtomDevtools(anAtom, options) {\n const { enabled, name } = options || {};\n const extension = getReduxExtension(enabled);\n const [value, setValue] = useAtom(anAtom, options);\n const lastValue = useRef3(value);\n const isTimeTraveling = useRef3(false);\n const devtools = useRef3();\n const atomName = name || anAtom.debugLabel || anAtom.toString();\n useEffect3(() => {\n if (!extension) {\n return;\n }\n const setValueIfWritable = (value2) => {\n if (typeof setValue === \"function\") {\n setValue(value2);\n return;\n }\n console.warn(\n \"[Warn] you cannot do write operations (Time-travelling, etc) in read-only atoms\\n\",\n anAtom\n );\n };\n devtools.current = createReduxConnection(extension, atomName);\n const unsubscribe = devtools.current?.subscribe((message) => {\n if (message.type === \"ACTION\" && message.payload) {\n try {\n setValueIfWritable(JSON.parse(message.payload));\n } catch (e) {\n console.error(\n \"please dispatch a serializable value that JSON.parse() support\\n\",\n e\n );\n }\n } else if (message.type === \"DISPATCH\" && message.state) {\n if (message.payload?.type === \"JUMP_TO_ACTION\" || message.payload?.type === \"JUMP_TO_STATE\") {\n isTimeTraveling.current = true;\n setValueIfWritable(JSON.parse(message.state));\n }\n } else if (message.type === \"DISPATCH\" && message.payload?.type === \"COMMIT\") {\n devtools.current?.init(lastValue.current);\n } else if (message.type === \"DISPATCH\" && message.payload?.type === \"IMPORT_STATE\") {\n const computedStates = message.payload.nextLiftedState?.computedStates || [];\n computedStates.forEach(({ state }, index) => {\n if (index === 0) {\n devtools.current?.init(state);\n } else {\n setValueIfWritable(state);\n }\n });\n }\n });\n return unsubscribe;\n }, [anAtom, extension, atomName, setValue]);\n useEffect3(() => {\n if (!devtools.current) {\n return;\n }\n lastValue.current = value;\n if (devtools.current.shouldInit) {\n devtools.current.init(value);\n devtools.current.shouldInit = false;\n } else if (isTimeTraveling.current) {\n isTimeTraveling.current = false;\n } else {\n devtools.current.send(\n `${atomName} - ${(/* @__PURE__ */ new Date()).toLocaleString()}`,\n value\n );\n }\n }, [anAtom, extension, atomName, value]);\n}\n\n// src/utils/useAtomsDevtools.ts\nimport { useEffect as useEffect4, useRef as useRef4 } from \"react\";\nvar atomToPrintable2 = (atom) => atom.debugLabel ? `${atom}:${atom.debugLabel}` : `${atom}`;\nvar getDevtoolsState = (atomsSnapshot) => {\n const values = {};\n atomsSnapshot.values.forEach((v, atom) => {\n values[atomToPrintable2(atom)] = v;\n });\n const dependents = {};\n atomsSnapshot.dependents.forEach((d, atom) => {\n dependents[atomToPrintable2(atom)] = Array.from(d).map(atomToPrintable2);\n });\n return {\n values,\n dependents\n };\n};\nfunction useAtomsDevtools(name, options) {\n const { enabled } = options || {};\n const extension = getReduxExtension(enabled);\n const atomsSnapshot = useAtomsSnapshot(options);\n const goToSnapshot = useGotoAtomsSnapshot(options);\n const isTimeTraveling = useRef4(false);\n const isRecording = useRef4(true);\n const devtools = useRef4();\n const snapshots = useRef4([]);\n useEffect4(() => {\n if (!extension) {\n return;\n }\n const getSnapshotAt = (index = snapshots.current.length - 1) => {\n const snapshot = snapshots.current[index >= 0 ? index : 0];\n if (!snapshot) {\n throw new Error(\"snapshot index out of bounds\");\n }\n return snapshot;\n };\n devtools.current = createReduxConnection(extension, name);\n const devtoolsUnsubscribe = devtools.current?.subscribe((message) => {\n switch (message.type) {\n case \"DISPATCH\":\n switch (message.payload?.type) {\n case \"RESET\":\n break;\n case \"COMMIT\":\n devtools.current?.init(getDevtoolsState(getSnapshotAt()));\n snapshots.current = [];\n break;\n case \"JUMP_TO_ACTION\":\n case \"JUMP_TO_STATE\":\n isTimeTraveling.current = true;\n goToSnapshot(getSnapshotAt(message.payload.actionId - 1));\n break;\n case \"PAUSE_RECORDING\":\n isRecording.current = !isRecording.current;\n break;\n }\n }\n });\n return () => {\n extension?.disconnect?.();\n devtoolsUnsubscribe?.();\n };\n }, [extension, goToSnapshot, name]);\n useEffect4(() => {\n if (!devtools.current) {\n return;\n }\n if (devtools.current.shouldInit) {\n devtools.current.init(void 0);\n devtools.current.shouldInit = false;\n return;\n }\n if (isTimeTraveling.current) {\n isTimeTraveling.current = false;\n } else if (isRecording.current) {\n snapshots.current.push(atomsSnapshot);\n devtools.current.send(\n {\n type: `${snapshots.current.length}`,\n updatedAt: (/* @__PURE__ */ new Date()).toLocaleString()\n },\n getDevtoolsState(atomsSnapshot)\n );\n }\n }, [atomsSnapshot]);\n}\n\nexport {\n isDevToolsStore,\n useDevToolsStore,\n useAtomsSnapshot,\n useGotoAtomsSnapshot,\n useAtomsDebugValue,\n useAtomDevtools,\n useAtomsDevtools\n};\n","import {\n InternalDevTools\n} from \"./chunk-YF3ARTE5.esm.mjs\";\nimport {\n useAtomDevtools,\n useAtomsDebugValue,\n useAtomsDevtools,\n useAtomsSnapshot,\n useGotoAtomsSnapshot\n} from \"./chunk-2JP4LGQ6.esm.mjs\";\n\n// src/index.ts\nvar DevTools = process.env.NODE_ENV !== \"production\" ? InternalDevTools : () => null;\nexport {\n DevTools,\n useAtomDevtools,\n useAtomsDebugValue,\n useAtomsDevtools,\n useAtomsSnapshot,\n useGotoAtomsSnapshot\n};\n"],"names":["isStoreV2","store","isStoreV1","isDevToolsStore","__composeV2StoreWithDevTools","sub","set","get","storeListeners","Set","recentlySetAtomsMap","WeakMap","reduceCountOrRemoveRecentlySetAtom","atom","onFound","foundCount","delete","increaseCountRecentlySetAtom","args","unsub","forEach","l","type","value","Promise","then","resolve","subscribeStore","add","getMountedAtoms","dev4_get_mounted_atoms","getAtomState","aState","dev4_get_internal_weak_map","v","e","d","keys","getMountedAtomState","m","t","restoreAtoms","dev4_restore_atoms","values","__composeV1StoreWithDevTools","dev_subscribe_store","dev_get_mounted_atoms","dev_get_atom_state","dev_get_mounted","dev_restore_atoms","action","composeWithDevTools","useDevToolsStore","options","isEqualAtomsValues","left","right","size","Array","from","every","left2","Object","is","isEqualAtomsDependents","a","dLeft","dRight","has","useAtomsSnapshot","shouldShowPrivateAtoms","atomsSnapshot","setAtomsSnapshot","useState","Map","dependents","duringReactRenderPhase","useRef","current","useLayoutEffect","useEffect","prevValues","prevDependents","callback","debugPrivate","atomState","mounted","atomDependents","filter","dependent","deferrableAtomSetAction","unsubscribe","useGotoAtomsSnapshot","useCallback","snapshot","atomToPrintable","debugLabel","toString","stateToPrintable","atoms","fromEntries","flatMap","error","map","useAtomsDebugValue","enabled","setAtoms","useDebugValue","createReduxConnection","extension","name","assign","connect","shouldInit","getReduxExtension","window","__REDUX_DEVTOOLS_EXTENSION__","useAtomDevtools","anAtom","setValue","lastValue","isTimeTraveling","devtools","atomName","setValueIfWritable","value2","console","warn","subscribe","message","payload","JSON","parse","state","init","computedStates","nextLiftedState","index","send","Date","toLocaleString","atomToPrintable2","getDevtoolsState","useAtomsDevtools","goToSnapshot","isRecording","snapshots","getSnapshotAt","length","devtoolsUnsubscribe","actionId","disconnect","push","updatedAt","DevTools"],"sourceRoot":""}