{"version":3,"names":["createContext","useContext","NOOP","EMPTY_IDS","Object","freeze","NOOP_FIELD_MESSAGES_CONTEXT","registerMessageId","getMessageIds","present","FieldMessagesContext","useFieldMessagesContext"],"sources":["field-messages-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\n\n/**\n * Registry for description/error message ids rendered inside a `<Field.Root>`.\n *\n * `<Field.Description>` and `<Field.Error>` each generate a unique id, register\n * it here on setup, and unregister on cleanup. `<Field.Control>` reads\n * `getMessageIds()` and composes them into `aria-describedby` so assistive tech\n * announces the related help text / error messages.\n *\n * Keyed by a per-consumer `symbol` so multiple simultaneous messages (e.g. a\n * description AND an error) can coexist without stepping on each other.\n *\n * Registration order is preserved: `getMessageIds()` returns ids in the order\n * they were registered, which matches render order for typical\n * \"description before error\" layouts.\n *\n * ### Why a dedicated registry?\n *\n * The shared `<LabelableProvider>` already exposes a `registerLabelId` / label\n * registry (used by `<Field.Label>`), plus a `controlId` slot. React's version\n * had a third slot — `messageIds` — that Description/Error wrote into. The\n * Solid port's `LabelableProvider` hasn't followed that design: keeping the\n * message-id channel here keeps the labelable provider focused on the\n * labelled/controlId pair, and avoids touching shared internals.\n */\nexport interface FieldMessagesContextValue {\n\t/**\n\t * Register a description/error id. Pass `undefined` to unregister. Multiple\n\t * calls with the same `source` replace the prior registration. Safe to\n\t * invoke from owned scope (the backing signal opts into `ownedWrite`).\n\t */\n\tregisterMessageId: (source: symbol, id: string | undefined) => void;\n\t/**\n\t * Snapshot of currently registered message ids, in registration order.\n\t * Reading this accessor subscribes to message registrations — when a\n\t * description/error mounts or unmounts, the consuming memo/effect re-runs.\n\t */\n\tgetMessageIds: Accessor<readonly string[]>;\n\t/** Marker — `true` when this context was provided by a real `<Field.Root>`. */\n\treadonly present: boolean;\n}\n\nconst NOOP = (): void => {};\nconst EMPTY_IDS: readonly string[] = Object.freeze([]);\n\n/**\n * Returned when no `<Field.Root>` is above a `<Field.Description>` /\n * `<Field.Error>` — the registry is a no-op and the registered ids list is\n * empty.\n */\nexport const NOOP_FIELD_MESSAGES_CONTEXT: FieldMessagesContextValue = {\n\tregisterMessageId: NOOP,\n\tgetMessageIds: () => EMPTY_IDS,\n\tpresent: false,\n};\n\nexport const FieldMessagesContext = createContext<FieldMessagesContextValue>(\n\tNOOP_FIELD_MESSAGES_CONTEXT,\n);\n\n/**\n * Read the nearest `<Field.Root>` message-id registry. Returns the noop\n * context when no `<Field.Root>` is above — callers can branch on `.present`.\n */\nexport function useFieldMessagesContext(): FieldMessagesContextValue {\n\treturn useContext(FieldMessagesContext);\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;AACA;AACA;AACA;AACA;;AAkBA,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,2BAAsD,GAAG;EACrEC,iBAAiB,EAAEL,IAAI;EACvBM,aAAa,EAAEA,CAAA,KAAML,SAAS;EAC9BM,OAAO,EAAE;AACV,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAGV,aAAa,CAChDM,2BACD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASK,uBAAuBA,CAAA,EAA8B;EACpE,OAAOV,UAAU,CAACS,oBAAoB,CAAC;AACxC","ignoreList":[]}