{"version":3,"names":["createContext","createMemo","useContext","createPopupCore","readOption","SNAPSHOT_KEYS","snapshotKeys","PreviewCardContext","usePreviewCard","optional","ctx","Error","createPreviewCard","options","core","open","disabled","onOpenChange","delay","name","closeDelay","api","setOpen","toggle","Provider","props","children","PREVIEW_CARD_SNAPSHOT_KEYS"],"sources":["create-preview-card.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport { type Accessor, createContext, createMemo, useContext } from \"solid-js\";\nimport { createPopupCore } from \"../internals/create-popup-core\";\nimport { type MaybeAccessor, readOption } from \"../internals/maybe-accessor\";\nimport {\n\tSNAPSHOT_KEYS,\n\ttype Snapshottable,\n\tsnapshotKeys,\n} from \"../internals/observability/snapshot\";\n\n/**\n * Why the preview card's open state changed.\n *\n * - `\"trigger-hover\"` — pointer entered / left the trigger.\n * - `\"trigger-focus\"` — keyboard focus moved to / from the trigger.\n * - `\"escape-key\"` — Escape dismissed the card.\n * - `\"outside-press\"` — pointer pressed outside.\n * - `\"imperative\"` — `pc.setOpen()` called programmatically.\n */\nexport type PreviewCardChangeReason =\n\t| \"trigger-hover\"\n\t| \"trigger-focus\"\n\t| \"escape-key\"\n\t| \"outside-press\"\n\t| \"imperative\";\n\n/**\n * Options for {@link createPreviewCard}.\n */\nexport interface CreatePreviewCardOptions {\n\t/**\n\t * Open state. Consumer-owned signal.\n\t */\n\topen: MaybeAccessor<boolean>;\n\t/**\n\t * Whether interaction is suppressed.\n\t * @default false\n\t */\n\tdisabled?: MaybeAccessor<boolean>;\n\t/**\n\t * Pre-change callback fired via `runWithOwner(null, ...)`.\n\t */\n\tonOpenChange?: (\n\t\topen: boolean,\n\t\tevent: Event,\n\t\treason: PreviewCardChangeReason,\n\t) => void;\n\t/**\n\t * Delay before opening (ms).\n\t * @default 600\n\t */\n\tdelay?: MaybeAccessor<number>;\n\t/**\n\t * Delay before closing on hover-out (ms).\n\t * @default 300\n\t */\n\tcloseDelay?: MaybeAccessor<number>;\n}\n\n/**\n * Public API returned by {@link createPreviewCard}.\n */\nexport interface PreviewCardApi {\n\t/** Reactive accessor for the current open state. */\n\topen: Accessor<boolean>;\n\t/** Whether interaction is suppressed. */\n\tdisabled: Accessor<boolean>;\n\t/** Open delay in ms. */\n\tdelay: Accessor<number>;\n\t/** Close delay in ms. */\n\tcloseDelay: Accessor<number>;\n\n\t/** Imperative open setter. */\n\tsetOpen: (\n\t\tnext: boolean,\n\t\tevent?: Event,\n\t\treason?: PreviewCardChangeReason,\n\t) => void;\n\t/** Flip open (no-op when disabled). */\n\ttoggle: (event?: Event, reason?: PreviewCardChangeReason) => void;\n\n\t/** Context provider. */\n\tProvider: (props: { children: JSX.Element }) => JSX.Element;\n}\n\nconst PreviewCardContext = createContext<PreviewCardApi | null>(null);\n\n/**\n * Read the nearest {@link PreviewCardApi}. Throws unless `optional` is true.\n */\nexport function usePreviewCard(): PreviewCardApi;\nexport function usePreviewCard(optional: true): PreviewCardApi | null;\nexport function usePreviewCard(optional?: boolean): PreviewCardApi | null {\n\tconst ctx = useContext(PreviewCardContext);\n\tif (ctx == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: usePreviewCard() must be called inside a <pc.Provider>.\",\n\t\t);\n\t}\n\treturn ctx;\n}\n\n/**\n * Headless primitive for a preview-card compound. Hover-triggered with open\n * and close delays. DOM machinery lives in `<PreviewCard.Root>`.\n */\nexport function createPreviewCard(\n\toptions: CreatePreviewCardOptions,\n): PreviewCardApi {\n\tconst core = createPopupCore<PreviewCardChangeReason>({\n\t\topen: options.open,\n\t\tdisabled: options.disabled,\n\t\tonOpenChange: options.onOpenChange,\n\t});\n\n\tconst delay = createMemo<number>(() => readOption(options.delay) ?? 600, {\n\t\tname: \"previewCard.delay\",\n\t});\n\n\tconst closeDelay = createMemo<number>(\n\t\t() => readOption(options.closeDelay) ?? 300,\n\t\t{ name: \"previewCard.closeDelay\" },\n\t);\n\n\tconst api: PreviewCardApi = {\n\t\topen: core.open,\n\t\tdisabled: core.disabled,\n\t\tdelay,\n\t\tcloseDelay,\n\t\tsetOpen: core.setOpen,\n\t\ttoggle: core.toggle,\n\t\tProvider: (props) => (\n\t\t\t<PreviewCardContext value={api}>{props.children}</PreviewCardContext>\n\t\t),\n\t};\n\n\t(api as PreviewCardApi & Snapshottable)[SNAPSHOT_KEYS] =\n\t\tPREVIEW_CARD_SNAPSHOT_KEYS;\n\n\treturn api;\n}\n\nconst PREVIEW_CARD_SNAPSHOT_KEYS = snapshotKeys<PreviewCardApi>(\n\t\"open\",\n\t\"disabled\",\n\t\"delay\",\n\t\"closeDelay\",\n);\n"],"mappings":"AACA,SAAwBA,aAAa,EAAEC,UAAU,EAAEC,UAAU,QAAQ,UAAU;AAC/E,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAA6BC,UAAU,QAAQ,6BAA6B;AAC5E,SACCC,aAAa,EAEbC,YAAY,QACN,qCAAqC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;;AA+BA;AACA;AACA;;AAwBA,MAAMC,kBAAkB,GAAGP,aAAa,CAAwB,IAAI,CAAC;;AAErE;AACA;AACA;;AAGA,OAAO,SAASQ,cAAcA,CAACC,QAAkB,EAAyB;EACzE,MAAMC,GAAG,GAAGR,UAAU,CAACK,kBAAkB,CAAC;EAC1C,IAAIG,GAAG,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IAC7B,MAAM,IAAIE,KAAK,CACd,kEACD,CAAC;EACF;EACA,OAAOD,GAAG;AACX;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,iBAAiBA,CAChCC,OAAiC,EAChB;EACjB,MAAMC,IAAI,GAAGX,eAAe,CAA0B;IACrDY,IAAI,EAAEF,OAAO,CAACE,IAAI;IAClBC,QAAQ,EAAEH,OAAO,CAACG,QAAQ;IAC1BC,YAAY,EAAEJ,OAAO,CAACI;EACvB,CAAC,CAAC;EAEF,MAAMC,KAAK,GAAGjB,UAAU,CAAS,MAAMG,UAAU,CAACS,OAA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