{"version":3,"names":["createContext","useContext","PreviewCardRootContext","usePreviewCardRootContext","optional","context","Error"],"sources":["preview-card-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../internals/change-event-details\";\nimport type { FloatingRootStore } from \"../internals/floating-ui/components/floating-root-store\";\nimport type { UseInteractionsReturn } from \"../internals/floating-ui/hooks/use-interactions\";\nimport type { MutableRef } from \"../internals/floating-ui/types\";\nimport type { TransitionStatus } from \"../internals/use-transition-status/use-transition-status\";\nimport type { PreviewCardStore } from \"./store/preview-card-store\";\n\n/**\n * Reasons a preview card's open state can change. Mirrors Base UI React's\n * `PreviewCardRoot.ChangeEventReason` union.\n */\nexport type PreviewCardRootChangeEventReason =\n\t| typeof REASONS.triggerHover\n\t| typeof REASONS.triggerFocus\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.outsidePress\n\t| typeof REASONS.escapeKey\n\t| typeof REASONS.imperativeAction\n\t| typeof REASONS.none;\n\nexport type PreviewCardRootChangeEventDetails =\n\tBaseUIChangeEventDetails<PreviewCardRootChangeEventReason>;\n\n/** Public projected state — surfaces via `data-*` attrs on the root/parts. */\nexport interface PreviewCardRootState {\n\topen: boolean;\n}\n\n/**\n * `instant` is the string flag that Base UI emits as `data-instant` on the\n * popup / arrow / positioner so CSS can disable animations for specific\n * programmatic transitions.\n *\n * Only `\"dismiss\"` and `\"focus\"` are emitted on preview cards (no delay-group\n * instant-phase, since preview-card has no delay-group integration).\n */\nexport type PreviewCardInstantType = \"dismiss\" | \"focus\" | undefined;\n\n/**\n * Context shape shared between `<PreviewCard.Root>` and every preview-card\n * sub-part. Every reactive field is an `Accessor<T>` so consumers don't need\n * to guard against top-level reactive reads.\n */\nexport interface PreviewCardRootContextValue {\n\topen: Accessor<boolean>;\n\tmounted: Accessor<boolean>;\n\ttransitionStatus: Accessor<TransitionStatus>;\n\tinstantType: Accessor<PreviewCardInstantType>;\n\tsetInstantType: (value: PreviewCardInstantType) => void;\n\t/** Public projected state (used by `renderElement`). */\n\tstate: Accessor<PreviewCardRootState>;\n\t/** Imperative open setter. */\n\tsetOpen: (next: boolean, details: PreviewCardRootChangeEventDetails) => void;\n\t/** Floating-UI shared store. */\n\tfloatingRootContext: FloatingRootStore;\n\t/** Interaction prop bags produced by the root's `useInteractions`. */\n\tinteractions: UseInteractionsReturn;\n\t/** Setter / accessor for the active trigger DOM element. */\n\tsetTriggerElement: (node: HTMLElement | null) => void;\n\ttriggerElement: Accessor<HTMLElement | null>;\n\t/** Setter / accessor for the popup DOM element. */\n\tsetPopupElement: (node: HTMLElement | null) => void;\n\tpopupElement: Accessor<HTMLElement | null>;\n\t/** Plain-ref mirror of popup element — consumed by `useOpenChangeComplete`. */\n\tpopupRef: MutableRef<HTMLElement | null>;\n\t/** The shared `PreviewCardStore` owned by this root (or by its `handle`). */\n\tstore: PreviewCardStore<unknown>;\n\t/** Active trigger id. */\n\tactiveTriggerId: Accessor<string | null>;\n\tsetActiveTriggerId: (id: string | null) => void;\n\t/** Payload written by the active trigger. */\n\tpayload: Accessor<unknown>;\n\tsetPayload: (payload: unknown) => void;\n\t/**\n\t * Mutable ref holding the currently-active trigger's `closeDelay`. Read by\n\t * `<PreviewCard.Popup>`'s hover-floating handler (so moving off the popup\n\t * starts the right close timer).\n\t */\n\tcloseDelayRef: MutableRef<number>;\n}\n\n/**\n * Solid 2's `useContext` throws `ContextNotFoundError` when the resolved\n * value is `undefined`, so the \"no provider\" sentinel is `null` here — the\n * helper below turns that into the Base UI error.\n */\nexport const PreviewCardRootContext =\n\tcreateContext<PreviewCardRootContextValue | null>(null);\n\n/**\n * Read the current `<PreviewCard.Root>` context. Throws unless `optional` is\n * `true`.\n */\nexport function usePreviewCardRootContext(): PreviewCardRootContextValue;\nexport function usePreviewCardRootContext(\n\toptional: true,\n): PreviewCardRootContextValue | null;\nexport function usePreviewCardRootContext(\n\toptional?: boolean,\n): PreviewCardRootContextValue | null {\n\tconst context = useContext(PreviewCardRootContext);\n\tif (context == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: PreviewCardRootContext is missing. PreviewCard parts must be placed within <PreviewCard.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAWnE;AACA;AACA;AACA;;AAaA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAClCF,aAAa,CAAqC,IAAI,CAAC;;AAExD;AACA;AACA;AACA;;AAKA,OAAO,SAASG,yBAAyBA,CACxCC,QAAkB,EACmB;EACrC,MAAMC,OAAO,GAAGJ,UAAU,CAACC,sBAAsB,CAAC;EAClD,IAAIG,OAAO,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IACjC,MAAM,IAAIE,KAAK,CACd,yGACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}