{"version":3,"names":["createMemo","createSignal","DrawerProviderContext","createVisualStateStore","state","swipeProgress","frontmostHeight","listeners","Set","getSnapshot","set","nextState","nextSwipeProgress","undefined","Number","isFinite","nextFrontmostHeight","listener","subscribe","add","delete","DrawerProvider","props","openById","Map","version","setVersion","ownedWrite","visualStateStore","setDrawerOpen","drawerId","open","prev","get","v","removeDrawer","has","active","values","contextValue","children"],"sources":["drawer-provider.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\n/**\n * `<Drawer.Provider>` — global coordinator used by multi-drawer layouts\n * (e.g. apps where a side sheet + bottom sheet share the same page chrome).\n *\n * 1:1 port of Base UI React's `DrawerProvider`\n * (`packages/react/src/drawer/provider/DrawerProvider.tsx`). Solid notes:\n *\n * - `openById` lives in a mutable `Map` + a \"version\" signal — React's\n *   `setOpenById(prev => new Map(...))` is a React-render-trigger trick\n *   that doesn't translate. We keep the map in place, bump the version\n *   on every write, and derive `active` from the version signal.\n * - `visualStateStore` is imperative / non-reactive (React's version uses\n *   `useSyncExternalStore` semantics) — preserved verbatim.\n */\n\nimport { createMemo, createSignal } from \"solid-js\";\nimport {\n\tDrawerProviderContext,\n\ttype DrawerProviderContextValue,\n\ttype DrawerVisualState,\n\ttype DrawerVisualStateStore,\n} from \"./drawer-provider-context\";\n\nexport interface DrawerProviderProps {\n\tchildren?: JSX.Element;\n}\n\nfunction createVisualStateStore(): DrawerVisualStateStore {\n\tlet state: DrawerVisualState = { swipeProgress: 0, frontmostHeight: 0 };\n\tconst listeners = new Set<() => void>();\n\n\treturn {\n\t\tgetSnapshot: () => state,\n\t\tset(nextState) {\n\t\t\tlet nextSwipeProgress = state.swipeProgress;\n\t\t\tif (nextState.swipeProgress !== undefined) {\n\t\t\t\tnextSwipeProgress = Number.isFinite(nextState.swipeProgress)\n\t\t\t\t\t? nextState.swipeProgress\n\t\t\t\t\t: 0;\n\t\t\t}\n\t\t\tlet nextFrontmostHeight = state.frontmostHeight;\n\t\t\tif (nextState.frontmostHeight !== undefined) {\n\t\t\t\tnextFrontmostHeight = Number.isFinite(nextState.frontmostHeight)\n\t\t\t\t\t? nextState.frontmostHeight\n\t\t\t\t\t: 0;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnextSwipeProgress === state.swipeProgress &&\n\t\t\t\tnextFrontmostHeight === state.frontmostHeight\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstate = {\n\t\t\t\tswipeProgress: nextSwipeProgress,\n\t\t\t\tfrontmostHeight: nextFrontmostHeight,\n\t\t\t};\n\t\t\tfor (const listener of listeners) listener();\n\t\t},\n\t\tsubscribe(listener) {\n\t\t\tlisteners.add(listener);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Provides a shared context for coordinating global Drawer UI (indent /\n * background effects based on whether any drawer is open). Doesn't render\n * its own HTML element.\n */\nexport function DrawerProvider(props: DrawerProviderProps): JSX.Element {\n\tconst openById = new Map<string, boolean>();\n\tconst [version, setVersion] = createSignal(0, { ownedWrite: true });\n\tconst visualStateStore = createVisualStateStore();\n\n\t// Functional setter avoids reading `version()` — `setDrawerOpen` can be\n\t// called from any scope (event handlers, `<Drawer.Root>`'s effect-apply\n\t// callbacks downstream of open transitions); a direct read would trip\n\t// `[STRICT_READ_UNTRACKED]` from those callers.\n\tconst setDrawerOpen = (drawerId: string, open: boolean): void => {\n\t\tconst prev = openById.get(drawerId);\n\t\tif (prev === open) return;\n\t\topenById.set(drawerId, open);\n\t\tsetVersion((v) => v + 1);\n\t};\n\n\tconst removeDrawer = (drawerId: string): void => {\n\t\tif (!openById.has(drawerId)) return;\n\t\topenById.delete(drawerId);\n\t\tsetVersion((v) => v + 1);\n\t};\n\n\tconst active = createMemo<boolean>(() => {\n\t\t// Read `version` so we re-compute on every change.\n\t\tversion();\n\t\tfor (const open of openById.values()) if (open) return true;\n\t\treturn false;\n\t});\n\n\tconst contextValue: DrawerProviderContextValue = {\n\t\tsetDrawerOpen,\n\t\tremoveDrawer,\n\t\tactive,\n\t\tvisualStateStore,\n\t};\n\n\treturn (\n\t\t<DrawerProviderContext value={contextValue}>\n\t\t\t{props.children}\n\t\t</DrawerProviderContext>\n\t);\n}\n"],"mappings":"AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,YAAY,QAAQ,UAAU;AACnD,SACCC,qBAAqB,QAIf,2BAA2B;AAMlC,SAASC,sBAAsBA,CAAA,EAA2B;EACzD,IAAIC,KAAwB,GAAG;IAAEC,aAAa,EAAE,CAAC;IAAEC,eAAe,EAAE;EAAE,CAAC;EACvE,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;EAEvC,OAAO;IACNC,WAAW,EAAEA,CAAA,KAAML,KAAK;IACxBM,GAAGA,CAACC,SAAS,EAAE;MACd,IAAIC,iBAAiB,GAAGR,KAAK,CAACC,aAAa;MAC3C,IAAIM,SAAS,CAACN,aAAa,KAAKQ,SAAS,EAAE;QAC1CD,iBAAiB,GAAGE,MAAM,CAACC,QAAQ,CAACJ,SAAS,CAACN,aAAa,CAAC,GACzDM,SAAS,CAACN,aAAa,GACvB,CAAC;MACL;MACA,IAAIW,mBAAmB,GAAGZ,KAAK,CAACE,eAAe;MAC/C,IAAIK,SAAS,CAACL,eAAe,KAAKO,SAAS,EAAE;QAC5CG,mBAAmB,GAAGF,MAAM,CAACC,QAAQ,CAACJ,SAAS,CAACL,eAAe,CAAC,GAC7DK,SAAS,CAACL,eAAe,GACzB,CAAC;MACL;MACA,IACCM,iBAAiB,KAAKR,KAAK,CAACC,aAAa,IACzCW,mBAAmB,KAAKZ,KAAK,CAACE,eAAe,EAC5C;QACD;MACD;MACAF,KAAK,GAAG;QACPC,aAAa,EAAEO,iBAAiB;QAChCN,eAAe,EAAEU;MAClB,CAAC;MACD,KAAK,MAAMC,QAAQ,IAAIV,SAAS,EAAEU,QAAQ,CAAC,CAA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