{"version":3,"names":["dynamic","createSignal","omit","createControlledState","readOption","mergeRootProps","createMountTransition","createCollapsible","CollapsibleRoot","props","resolvedOpen","setUncontrolledOpen","controlled","open","undefined","Boolean","default","defaultOpen","fallback","name","state","c","api","disabled","onOpenChange","next","event","reason","defaultPrevented","keepMounted","hiddenUntilFound","rootEl","setRootEl","m","panelElement","rootInternal","ref","data-open","data-closed","data-starting-style","transitionStatus","data-ending-style","userHtmlProps","merged","Tag","as","children"],"sources":["collapsible-root.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { createSignal, omit } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\nimport { createControlledState } from \"../../internals/create-controlled-state\";\nimport { type MaybeAccessor, readOption } from \"../../internals/maybe-accessor\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { createMountTransition } from \"../../internals/use-mount-transition/use-mount-transition\";\nimport type { TransitionStatus } from \"../../internals/use-transition-status/use-transition-status\";\nimport {\n\ttype CollapsibleApi,\n\ttype CollapsibleChangeReason,\n\tcreateCollapsible,\n} from \"../create-collapsible.tsx\";\n\n/**\n * Change-reason namespace for `Collapsible.Root` (shipped public type).\n * Mirrors Base UI React: explicit trigger presses use {@link REASONS.triggerPress};\n * indirect flows (e.g. `beforematch` from `hiddenUntilFound`) use {@link REASONS.none}.\n *\n * NOTE: the new primitive's `onOpenChange(next, event, reason)` signature uses\n * the `CollapsibleChangeReason` taxonomy directly. This `BaseUIChangeEventDetails`-\n * shaped type is kept as a public re-export for downstream consumers that\n * imported it from `quoin` before the primitive rewrite.\n */\nexport type CollapsibleRootChangeEventReason =\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.none;\n\nexport type CollapsibleRootChangeEventDetails =\n\tBaseUIChangeEventDetails<CollapsibleRootChangeEventReason>;\n\n/**\n * Public state surface — kept as a shipped type for any consumer projecting\n * accordion/collapsible state through their own `data-*` mappings. Stage-01c\n * cleanup: the wrapper itself no longer reads `transitionStatus` (it's now\n * owned by the panel's local `createMountTransition`); this type still\n * surfaces it for `accordionItemStateAttributesMapping` and any consumer-side\n * mappings that rely on the same shape.\n */\nexport interface CollapsibleRootState {\n\topen: boolean;\n\tdisabled: boolean;\n\ttransitionStatus: TransitionStatus;\n}\n\n/**\n * Props for {@link CollapsibleRoot}.\n *\n * Stage-01 spike rewire: the wrapper is a structural adapter over the\n * `createCollapsible` primitive (axes A + P).\n *\n * - `onOpenChange` is `(open, event, reason)` — cancel via\n *   `event.preventDefault()` (axis C). Reason is the third argument:\n *   `\"trigger-press\"` / `\"beforematch\"` / `\"imperative\"`.\n * - `render={(p) => ...}` is replaced by `as=\"...\"` (axis G).\n * - Optional `api` prop lets a consumer pre-build the primitive (so they can\n *   `createEffect(c.open, ...)` outside the wrapper) and pass it back in.\n */\nexport interface CollapsibleRootProps {\n\t/**\n\t * Pre-built primitive. When supplied, the root uses it instead of\n\t * calling `createCollapsible(...)` itself. The pre-built primitive\n\t * already owns its own `open` accessor; consumers can ignore the\n\t * `open` / `onOpenChange` props on this component when supplying one.\n\t */\n\tapi?: CollapsibleApi;\n\t/**\n\t * Controlled open state. When provided (resolved value not\n\t * `undefined`), the consumer owns the state — pair with\n\t * {@link onOpenChange}. When omitted, the collapsible manages its own\n\t * open state (seeded from {@link defaultOpen}). Ignored when `api` is\n\t * supplied (the pre-built primitive owns the accessor).\n\t */\n\topen?: MaybeAccessor<boolean | undefined>;\n\t/**\n\t * Initial open state when uncontrolled. Read once at mount.\n\t * @default false\n\t */\n\tdefaultOpen?: MaybeAccessor<boolean | undefined>;\n\t/** Whether interaction is suppressed. */\n\tdisabled?: MaybeAccessor<boolean | undefined>;\n\t/**\n\t * Pre-change callback. Fired before the uncontrolled state write;\n\t * calling `event.preventDefault()` vetoes the write so an\n\t * uncontrolled collapsible keeps its current state (the quoin\n\t * equivalent of React Base UI's `eventDetails.cancel()`). Controlled\n\t * consumers simply don't update their signal. Third argument is the\n\t * {@link CollapsibleChangeReason}.\n\t */\n\tonOpenChange?: (\n\t\topen: boolean,\n\t\tevent: Event,\n\t\treason: CollapsibleChangeReason,\n\t) => void;\n\t/** Keep the panel mounted while closed (passes through to the primitive). */\n\tkeepMounted?: MaybeAccessor<boolean | undefined>;\n\t/** Browser-page-search expansion (passes through to the primitive). */\n\thiddenUntilFound?: MaybeAccessor<boolean | undefined>;\n\t/** Tag/component to render. Defaults to `\"div\"`. */\n\tas?: ValidComponent;\n\tchildren?: JSX.Element;\n\t[key: string]: unknown;\n}\n\n/**\n * Groups all parts of the collapsible. Renders a `<div>` (or `as` override).\n *\n * Implementation notes:\n *\n * - Calls `createCollapsible` (or reuses `props.api`) once at setup.\n * - Provides the `CollapsibleContext` (consumed by `<Collapsible.Trigger>`,\n *   `<Collapsible.Panel>`, the directives, and any inline `useCollapsible()`).\n * - Owns its own `createMountTransition(c.open)` instance bound to the root\n *   element. Emits `data-open` / `data-closed` plus `data-starting-style` /\n *   `data-ending-style` so consumers can drive root-level CSS transitions\n *   independently from the panel's own lifecycle. The Panel wrapper has its\n *   own instance for panel-anchored animation — the two are independent\n *   (each tracks the CSS animations on its own element).\n */\nexport function CollapsibleRoot(props: CollapsibleRootProps): JSX.Element {\n\t// Controlled / uncontrolled open state (Base UI `open` / `defaultOpen`\n\t// contract): the `open` prop wins while its resolved value is defined;\n\t// otherwise an internal signal (seeded once from `defaultOpen`) backs\n\t// the state. Unused when a pre-built `api` is supplied.\n\tconst [resolvedOpen, setUncontrolledOpen] = createControlledState<boolean>({\n\t\tcontrolled: () => {\n\t\t\tconst controlled = readOption(props.open);\n\t\t\treturn controlled === undefined ? undefined : Boolean(controlled);\n\t\t},\n\t\tdefault: () => readOption(props.defaultOpen),\n\t\tfallback: false,\n\t\tname: \"<Collapsible.Root>\",\n\t\tstate: \"open\",\n\t});\n\n\tconst c =\n\t\tprops.api ??\n\t\tcreateCollapsible({\n\t\t\topen: resolvedOpen,\n\t\t\tdisabled: (): boolean => Boolean(readOption(props.disabled)),\n\t\t\tonOpenChange: (next, event, reason) => {\n\t\t\t\t// Mirror React's `useCollapsibleRoot.handleTrigger`: fire the\n\t\t\t\t// consumer callback first, honor the veto (quoin's cancel\n\t\t\t\t// channel is `event.preventDefault()`), then write the\n\t\t\t\t// uncontrolled state (ignored for reads while the `open`\n\t\t\t\t// prop is controlled — the consumer's signal write is the\n\t\t\t\t// source of truth).\n\t\t\t\tprops.onOpenChange?.(next, event, reason);\n\t\t\t\tif (event.defaultPrevented) return;\n\t\t\t\tsetUncontrolledOpen(next);\n\t\t\t},\n\t\t\tkeepMounted: (): boolean => Boolean(readOption(props.keepMounted)),\n\t\t\thiddenUntilFound: (): boolean =>\n\t\t\t\tBoolean(readOption(props.hiddenUntilFound)),\n\t\t});\n\n\t// Root-level animation lifecycle. Bound to the root element so\n\t// `data-starting-style` / `data-ending-style` track the root's own CSS\n\t// transitions (independent from the panel's instance).\n\tconst [rootEl, setRootEl] = createSignal<HTMLElement | null>(null);\n\tconst m = createMountTransition(c.open, {\n\t\tpanelElement: rootEl,\n\t\tkeepMounted: true,\n\t});\n\n\t// Root-level reactive data attrs.\n\tconst rootInternal = {\n\t\tref: setRootEl,\n\t\tget \"data-open\"(): \"\" | undefined {\n\t\t\treturn c.open() ? \"\" : undefined;\n\t\t},\n\t\tget \"data-closed\"(): \"\" | undefined {\n\t\t\treturn c.open() ? undefined : \"\";\n\t\t},\n\t\tget \"data-starting-style\"(): \"\" | undefined {\n\t\t\treturn m.transitionStatus() === \"starting\" ? \"\" : undefined;\n\t\t},\n\t\tget \"data-ending-style\"(): \"\" | undefined {\n\t\t\treturn m.transitionStatus() === \"ending\" ? \"\" : undefined;\n\t\t},\n\t};\n\n\t// Strip our own keys before spreading user HTML attributes through.\n\tconst userHtmlProps = omit(\n\t\tprops,\n\t\t\"api\",\n\t\t\"as\",\n\t\t\"children\",\n\t\t\"defaultOpen\",\n\t\t\"disabled\",\n\t\t\"hiddenUntilFound\",\n\t\t\"keepMounted\",\n\t\t\"onOpenChange\",\n\t\t\"open\",\n\t) as Record<string, unknown>;\n\n\t// Bind the merged slot bag to a `const` BEFORE the JSX spread. This is\n\t// hydration-critical, not cosmetic: when the Solid SSR compiler sees a spread\n\t// of an inline *call expression* (`<Tag {...mergeRootProps(...)}>`) it\n\t// wraps it in a lazy thunk `() => mergeRootProps(...)`. The server's\n\t// `dynamic()` runtime resolves that thunk on a DIFFERENT child-id allocation\n\t// path than the client does, which (a) drops every merged attribute from the\n\t// SSR markup and (b) shifts the hydration keys by one slot — throwing\n\t// \"Hydration Mismatch\". Spreading a pre-bound *variable* (`{...merged}`) makes\n\t// the compiler pass the object straight through, exactly as `<Tabs.Root>`\n\t// does (which is why Tabs already hydrated cleanly). See\n\t// `merge-root-props.ts` for the getter-bag shape.\n\tconst merged = mergeRootProps(rootInternal, userHtmlProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"div\");\n\treturn (\n\t\t<c.Provider>\n\t\t\t<Tag {...merged}>{props.children}</Tag>\n\t\t</c.Provider>\n\t);\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,YAAY,EAAEC,IAAI,QAAQ,UAAU;AAK7C,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAA6BC,UAAU,QAAQ,gCAAgC;AAC/E,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,qBAAqB,QAAQ,2DAA2D;AAEjG,SAGCC,iBAAiB,QACX,2BAA2B;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAA2B,EAAe;EACzE;EACA;EACA;EAC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