{"version":3,"names":["createContext","useContext","NOOP","EMPTY_IDS","Object","freeze","NOOP_LABELABLE_CONTEXT","controlId","undefined","registerControlId","registerLabelId","getLabelIds","present","LabelableContext","useLabelableContext"],"sources":["labelable-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\n\n/**\n * The value handed down by `<LabelableProvider>` to its descendants.\n *\n * Solid 2 adaptations from Base UI React's `LabelableContext`:\n *\n * - All reactive values are exposed as `Accessor<T>` so callers pull on demand\n *   and don't trip the top-level reactive read rule (RFC 01).\n * - The single `labelId` from React is generalized to a registry keyed by a\n *   per-consumer source `symbol`. Multiple labels can register into the same\n *   provider — `getLabelIds()` returns them in registration order, which\n *   `useAriaLabelledBy` joins with spaces. This is the multi-label superset of\n *   `use-registered-label-id.ts` (which progress/meter still use for their\n *   simpler single-id case).\n * - Setters are plain functions that may be called from owned scope on setup\n *   or from cleanup. The underlying signals opt into `ownedWrite` where\n *   appropriate so those writes don't trip `SIGNAL_WRITE_IN_OWNED_SCOPE`.\n * - `controlId` follows React's semantics: explicit `null` means \"no\n *   association\" (implicit label), `undefined` means \"no registration yet\",\n *   any string is the resolved control id.\n */\nexport interface LabelableContextValue {\n\t/**\n\t * The `id` of the labelable (control) element.\n\t * `null` when the association is implicit (control wrapped by a native\n\t * `<label>`); `undefined` when nothing has registered yet.\n\t */\n\tcontrolId: Accessor<string | null | undefined>;\n\t/**\n\t * Register a control id from a labelable control. Pass `undefined` to\n\t * unregister. Multiple calls with the same `source` replace the previous\n\t * registration for that source.\n\t */\n\tregisterControlId: (source: symbol, id: string | null | undefined) => void;\n\t/**\n\t * Register a label id from a label component. Pass `undefined` to\n\t * unregister. Labels are returned by {@link getLabelIds} in the order they\n\t * registered.\n\t */\n\tregisterLabelId: (source: symbol, id: string | undefined) => void;\n\t/**\n\t * Snapshot of currently registered label ids in registration order. Reading\n\t * this accessor subscribes to label registrations — when a label mounts or\n\t * unmounts, the consuming memo/effect re-runs.\n\t */\n\tgetLabelIds: Accessor<readonly string[]>;\n\t/** Marker — `true` when this context was provided by a real `<LabelableProvider>`. */\n\treadonly present: boolean;\n}\n\nconst NOOP = (): void => {};\nconst EMPTY_IDS: readonly string[] = Object.freeze([]);\n\n/**\n * The noop context used when no `<LabelableProvider>` is an ancestor. All\n * accessors return \"nothing\" and setters are no-ops, so consumers don't need\n * to branch on presence for correctness — they can just call through.\n */\nexport const NOOP_LABELABLE_CONTEXT: LabelableContextValue = {\n\tcontrolId: () => undefined,\n\tregisterControlId: NOOP,\n\tregisterLabelId: NOOP,\n\tgetLabelIds: () => EMPTY_IDS,\n\tpresent: false,\n};\n\n/**\n * Context for [labelable elements](https://html.spec.whatwg.org/multipage/forms.html#category-label)\n * — provides a two-way channel between label components and the control they\n * label, so each side can discover the other's id without the consumer having\n * to thread them manually.\n *\n * Provide with `<LabelableContext value={...}>` (Solid 2 context-as-provider\n * pattern — RFC 02). In practice, use `<LabelableProvider>` which constructs\n * the context internally.\n */\nexport const LabelableContext = createContext<LabelableContextValue>(\n\tNOOP_LABELABLE_CONTEXT,\n);\n\n/**\n * Read the nearest `<LabelableProvider>` context. Returns the noop context\n * when no provider is an ancestor; callers can branch on `.present` if they\n * need to detect that case, or just call through (setters are no-ops, the\n * id accessor returns `undefined`).\n */\nexport function useLabelableContext(): LabelableContextValue {\n\treturn useContext(LabelableContext);\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8BA,MAAMC,IAAI,GAAGA,CAAA,KAAY,CAAC,CAAC;AAC3B,MAAMC,SAA4B,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;;AAEtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAA6C,GAAG;EAC5DC,SAAS,EAAEA,CAAA,KAAMC,SAAS;EAC1BC,iBAAiB,EAAEP,IAAI;EACvBQ,eAAe,EAAER,IAAI;EACrBS,WAAW,EAAEA,CAAA,KAAMR,SAAS;EAC5BS,OAAO,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGb,aAAa,CAC5CM,sBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,mBAAmBA,CAAA,EAA0B;EAC5D,OAAOb,UAAU,CAACY,gBAAgB,CAAC;AACpC","ignoreList":[]}