{"version":3,"names":["dynamic","omit","useDirection","CompositeList","createControlledState","mergeRootProps","resolveClassStyle","AccordionRootContext","createAccordion","AccordionRoot","props","direction","hiddenUntilFound","keepMounted","loopFocus","resolvedValue","setUncontrolledValue","controlled","value","default","defaultValue","fallback","name","state","c","multiple","disabled","orientation","onValueChange","next","details","isCanceled","handleValueChange","newValue","nextOpen","_incoming","toggle","accordionItemRefs","contextValue","userStyling","userHtmlProps","internalProps","role","dir","data-orientation","data-disabled","undefined","styledUserProps","merged","Tag","as","children"],"sources":["accordion-root.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { omit } from \"solid-js\";\nimport { useDirection } from \"../../direction-provider/direction-provider-context.ts\";\nimport { CompositeList } from \"../../internals/composite/composite-list.tsx\";\nimport { createControlledState } from \"../../internals/create-controlled-state\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type { BaseUIComponentProps, Orientation } from \"../../internals/types\";\nimport {\n\ttype AccordionRootChangeEventDetails,\n\ttype AccordionRootChangeEventReason,\n\tAccordionRootContext,\n\ttype AccordionRootContextValue,\n\ttype AccordionRootState,\n\ttype AccordionValue,\n} from \"../accordion-root-context.ts\";\nimport { createAccordion } from \"../create-accordion.tsx\";\n\nexport type {\n\tAccordionRootChangeEventDetails,\n\tAccordionRootChangeEventReason,\n\tAccordionRootState,\n\tAccordionValue,\n};\n\nexport interface AccordionRootProps<Value = unknown>\n\textends Omit<\n\t\tBaseUIComponentProps<\"div\", AccordionRootState<Value>>,\n\t\t\"value\"\n\t> {\n\t/**\n\t * Controlled open values. When provided (any defined value — an\n\t * explicitly passed empty array counts), the consumer owns the state —\n\t * pair with {@link onValueChange}. When omitted, the accordion manages\n\t * its own open set (seeded from {@link defaultValue}). An empty array\n\t * means \"no item open\".\n\t */\n\tvalue?: AccordionValue<Value> | undefined;\n\t/**\n\t * Initial open values when uncontrolled. Read once at mount.\n\t * @default []\n\t */\n\tdefaultValue?: AccordionValue<Value> | undefined;\n\t/** Tag/component to render. Defaults to `\"div\"`. */\n\tas?: ValidComponent;\n\t/**\n\t * Whether the component should ignore user interaction.\n\t * @default false\n\t */\n\tdisabled?: boolean | undefined;\n\t/**\n\t * Allows the browser's built-in page search to find and expand closed\n\t * panels via `hidden=\"until-found\"`. Forces panels to stay mounted.\n\t * @default false\n\t */\n\thiddenUntilFound?: boolean | undefined;\n\t/**\n\t * Whether panels stay mounted when closed. Ignored when\n\t * {@link hiddenUntilFound} is `true`.\n\t * @default false\n\t */\n\tkeepMounted?: boolean | undefined;\n\t/**\n\t * Whether arrow-key navigation between triggers wraps around at the\n\t * extents.\n\t * @default true\n\t */\n\tloopFocus?: boolean | undefined;\n\t/**\n\t * Fired when an item expands or collapses. The first argument is the new\n\t * array of open values; the second is a cancel-capable details bag —\n\t * calling `eventDetails.cancel()` keeps the accordion's own\n\t * (uncontrolled) state unchanged, mirroring React Base UI; controlled\n\t * consumers simply don't update their signal.\n\t */\n\tonValueChange?:\n\t\t| ((\n\t\t\t\tvalue: AccordionValue<Value>,\n\t\t\t\teventDetails: AccordionRootChangeEventDetails,\n\t\t  ) => void)\n\t\t| undefined;\n\t/**\n\t * Whether multiple items can be open at the same time.\n\t * @default false\n\t */\n\tmultiple?: boolean | undefined;\n\t/**\n\t * Visual orientation — controls whether arrow-up/down or arrow-left/right\n\t * move roving focus between triggers.\n\t * @default \"vertical\"\n\t */\n\torientation?: Orientation | undefined;\n}\n\n/**\n * Groups all parts of the accordion. Renders a `<div role=\"region\">`.\n *\n * Solid 2 notes:\n *\n * - Accessor-form reads for every reactive input — no top-level reactive\n *   reads, no destructuring of `props`.\n * - `value` is always stored internally as an array: single-expand mode is\n *   encoded as `[]` or `[currentlyOpenValue]`, multi-expand as the full\n *   open set. This lets the item's `isOpen` predicate be the same regardless\n *   of mode.\n * - Context provider sits INSIDE `get children()` (not wrapped around the\n *   root element) so the attribute getters and the `state` memo stay owned\n *   by this component's setup scope — matches `radio-group.tsx`.\n * - Items register with a `<CompositeList>`. The trigger's keyboard handler\n *   walks that list to find sibling triggers (see `accordion-trigger.tsx`).\n */\nexport function AccordionRoot<Value = unknown>(\n\tprops: AccordionRootProps<Value>,\n): JSX.Element {\n\tconst direction = useDirection();\n\n\tconst hiddenUntilFound = (): boolean => props.hiddenUntilFound ?? false;\n\tconst keepMounted = (): boolean => props.keepMounted ?? false;\n\tconst loopFocus = (): boolean => props.loopFocus ?? true;\n\n\t// Controlled / uncontrolled value state (Base UI `value` / `defaultValue`\n\t// contract): the `value` prop wins while it is defined — an explicitly\n\t// passed empty array IS controlled; otherwise an internal signal (seeded\n\t// once from `defaultValue`, else `[]`) backs the state.\n\tconst [resolvedValue, setUncontrolledValue] = createControlledState<\n\t\tAccordionValue<Value>\n\t>({\n\t\tcontrolled: () => props.value,\n\t\tdefault: () => props.defaultValue,\n\t\tfallback: [] as AccordionValue<Value>,\n\t\tname: \"<Accordion.Root>\",\n\t\tstate: \"value\",\n\t});\n\n\t// Compose the headless primitive — it owns value-array normalization and\n\t// the single/multi toggle logic. The wrapper layers CompositeList +\n\t// region role + direction-provider on top. Change flow mirrors React's\n\t// `AccordionRoot.handleValueChange`: fire `onValueChange` first, honor\n\t// `details.cancel()`, then write the uncontrolled state (ignored for\n\t// reads while the `value` prop is controlled).\n\tconst c = createAccordion<Value>({\n\t\tvalue: resolvedValue,\n\t\tmultiple: () => props.multiple === true,\n\t\tdisabled: () => props.disabled === true,\n\t\torientation: () => props.orientation ?? \"vertical\",\n\t\tonValueChange: (next, details) => {\n\t\t\tprops.onValueChange?.(next, details as AccordionRootChangeEventDetails);\n\t\t\tif (details.isCanceled) return;\n\t\t\tsetUncontrolledValue(next);\n\t\t},\n\t});\n\tconst value = c.value;\n\tconst disabled = c.disabled;\n\tconst orientation = c.orientation;\n\n\tconst handleValueChange = (\n\t\tnewValue: unknown,\n\t\tnextOpen: boolean,\n\t\t// Incoming details from the item is reference-only for the legacy\n\t\t// signature; the primitive constructs its own fresh details bag for\n\t\t// the onValueChange dispatch (matches React's \"two separate signals\"\n\t\t// shape — cancelling onOpenChange doesn't veto onValueChange).\n\t\t_incoming: AccordionRootChangeEventDetails,\n\t): void => {\n\t\tc.toggle(newValue as Value, nextOpen);\n\t};\n\n\tconst state: () => AccordionRootState<Value> = () => ({\n\t\tvalue: value(),\n\t\tdisabled: disabled(),\n\t\torientation: orientation(),\n\t});\n\n\t// Shared array that `<CompositeList>` keeps in DOM order. The trigger's\n\t// keyboard handler reads it synchronously during event dispatch, so it\n\t// must be a plain mutable array (no signal indirection).\n\tconst accordionItemRefs: Array<HTMLElement | null> = [];\n\n\tconst contextValue: AccordionRootContextValue<Value> = {\n\t\taccordionItemRefs,\n\t\tdirection,\n\t\tdisabled,\n\t\thandleValueChange,\n\t\thiddenUntilFound,\n\t\tkeepMounted,\n\t\tloopFocus,\n\t\torientation,\n\t\tstate,\n\t\tvalue,\n\t};\n\n\tconst userStyling = resolveClassStyle(props, () => state());\n\n\tconst userHtmlProps = omit(\n\t\tprops,\n\t\t\"class\",\n\t\t\"style\",\n\t\t\"attrs\",\n\t\t\"as\",\n\t\t\"children\",\n\t\t\"defaultValue\",\n\t\t\"disabled\",\n\t\t\"hiddenUntilFound\",\n\t\t\"keepMounted\",\n\t\t\"loopFocus\",\n\t\t\"multiple\",\n\t\t\"onValueChange\",\n\t\t\"orientation\",\n\t\t\"value\",\n\t) as Record<string, unknown>;\n\n\tconst internalProps = {\n\t\trole: \"region\" as const,\n\t\tget dir() {\n\t\t\treturn direction();\n\t\t},\n\t\tget \"data-orientation\"() {\n\t\t\treturn orientation();\n\t\t},\n\t\tget \"data-disabled\"(): \"\" | undefined {\n\t\t\treturn disabled() ? \"\" : undefined;\n\t\t},\n\t};\n\n\tconst styledUserProps = mergeRootProps(userStyling, userHtmlProps);\n\n\tconst merged = mergeRootProps(internalProps, styledUserProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"div\");\n\treturn (\n\t\t<Tag {...merged}>\n\t\t\t<AccordionRootContext\n\t\t\t\tvalue={contextValue as AccordionRootContextValue<unknown>}\n\t\t\t>\n\t\t\t\t<CompositeList<unknown> elementsRef={accordionItemRefs}>\n\t\t\t\t\t{props.children}\n\t\t\t\t</CompositeList>\n\t\t\t</AccordionRootContext>\n\t\t</Tag>\n\t);\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,IAAI,QAAQ,UAAU;AAC/B,SAASC,YAAY,QAAQ,wDAAwD;AACrF,SAASC,aAAa,QAAQ,8CAA8C;AAC5E,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,iBAAiB,QAAQ,qCAAqC;AAEvE,SAGCC,oBAAoB,QAId,8BAA8B;AACrC,SAASC,eAAe,QAAQ,yBAAyB;AA8EzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC5BC,KAAgC,EAClB;EACd,MAAMC,SAAS,GAAGT,YAAY,CAAC,CAAC;EAEhC,MAAMU,gBAAgB,GAAGA,CAAA,KAAeF,KAAK,CAACE,gBAAgB,IAAI,KAAK;EACvE,MAAMC,WAAW,GAAGA,CAAA,KAAeH,KAAK,CAACG,WAAW,IAAI,KAAK;EAC7D,MAAMC,SAAS,GAAGA,CAAA,KAAeJ,KAAK,CAACI,SAAS,IAAI,IAAI;;EAExD;EACA;EACA;EACA;EACA,MAAM,CAACC,aAAa,EAAEC,oBAAoB,CAAC,GAAGZ,qBAAqB,CAEjE;IACDa,UAAU,EAAEA,CAAA,KAAMP,KAAK,CAACQ,KAAK;IAC7BC,OAAO,EAAEA,CAAA,KAAMT,KAAK,CAACU,YAAY;IACjCC,QAAQ,EAAE,EAA2B;IACrCC,IAAI,EAAE,kBAAkB;IACxBC,KAAK,EAAE;EACR,CAAC,CAAC;;EAEF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