{"version":3,"names":["dynamic","omit","userRef","isHydrating","mergeRootProps","resolveClassStyle","valueToPercent","useSliderRootContext","sliderDataAttrs","getCenteredStyles","vertical","range","startPercent","endPercent","startEdge","mainSide","crossSide","styles","position","getInsetStyles","start","end","renderBeforeHydration","visibility","undefined","SliderIndicator","props","context","userClassStyle","state","userProps","internalSlot","data-quoin-slider-indicator","style","values","min","max","orientation","length","inset","indicatorPosition","merged","Tag","as"],"sources":["slider-indicator.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { omit } from \"solid-js\";\nimport { userRef } from \"../../internals/compose-refs\";\nimport { isHydrating } from \"../../internals/is-hydrating.ts\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type { BaseUIComponentProps } from \"../../internals/types\";\nimport { valueToPercent } from \"../../internals/value-to-percent\";\nimport {\n\ttype SliderRootState,\n\tuseSliderRootContext,\n} from \"../slider-root-context.ts\";\nimport { sliderDataAttrs } from \"../utils/state-attrs.ts\";\n\nexport interface SliderIndicatorState extends SliderRootState {}\n\nexport interface SliderIndicatorProps\n\textends BaseUIComponentProps<\"div\", SliderIndicatorState> {\n\t/** Tag/component to render. Defaults to `\"div\"`. */\n\tas?: ValidComponent;\n}\n\nfunction getCenteredStyles(\n\tvertical: boolean,\n\trange: boolean,\n\tstartPercent: number,\n\tendPercent: number,\n): JSX.CSSProperties {\n\tconst startEdge = vertical ? \"bottom\" : \"inset-inline-start\";\n\tconst mainSide = vertical ? \"height\" : \"width\";\n\tconst crossSide = vertical ? \"width\" : \"height\";\n\n\tconst styles: JSX.CSSProperties = {\n\t\tposition: vertical ? \"absolute\" : \"relative\",\n\t\t[crossSide]: \"inherit\",\n\t};\n\n\tif (!range) {\n\t\tstyles[startEdge] = 0;\n\t\tstyles[mainSide] = `${startPercent}%`;\n\t\treturn styles;\n\t}\n\n\tstyles[startEdge] = `${startPercent}%`;\n\tstyles[mainSide] = `${endPercent - startPercent}%`;\n\treturn styles;\n}\n\nfunction getInsetStyles(\n\tvertical: boolean,\n\trange: boolean,\n\tstart: number | undefined,\n\tend: number | undefined,\n\trenderBeforeHydration: boolean,\n\tisHydrating: boolean,\n): JSX.CSSProperties {\n\tconst visibility =\n\t\tstart === undefined || (range && end === undefined) ? \"hidden\" : undefined;\n\n\tconst startEdge = vertical ? \"bottom\" : \"inset-inline-start\";\n\tconst mainSide = vertical ? \"height\" : \"width\";\n\tconst crossSide = vertical ? \"width\" : \"height\";\n\n\tconst styles: JSX.CSSProperties = {\n\t\tvisibility: renderBeforeHydration && isHydrating ? \"hidden\" : visibility,\n\t\tposition: vertical ? \"absolute\" : \"relative\",\n\t\t[crossSide]: \"inherit\",\n\t\t\"--start-position\": `${start ?? 0}%`,\n\t};\n\n\tif (!range) {\n\t\tstyles[startEdge] = 0;\n\t\tstyles[mainSide] = \"var(--start-position)\";\n\t\treturn styles;\n\t}\n\n\tstyles[\"--relative-size\"] = `${(end ?? 0) - (start ?? 0)}%`;\n\tstyles[startEdge] = \"var(--start-position)\";\n\tstyles[mainSide] = \"var(--relative-size)\";\n\treturn styles;\n}\n\n/**\n * Visualizes the current value of the slider. Renders a `<div>` (or `as`\n * override).\n *\n * Center-aligned indicators use pure-CSS percent math (`(value - min) /\n * (max - min)`). Edge-aligned indicators pull positions from the root's\n * `indicatorPosition` signal, which is written from `<Slider.Thumb>`'s\n * ResizeObserver — this compensates for the thumb's own width so its edge\n * (not its center) aligns with the control endpoints.\n *\n * §1 wave 3: replaces `renderElement` with `dynamic(() => props.as ?? \"div\")`.\n */\nexport function SliderIndicator(props: SliderIndicatorProps): JSX.Element {\n\tconst context = useSliderRootContext();\n\n\t// Resolve `class`/`style` here so function values (stateful styling) are\n\t// invoked with the slider state instead of being spread to the DOM raw.\n\t// The internal `style` (the indicator position) is merged first below, so\n\t// a user-supplied style composes with it rather than replacing it.\n\tconst userClassStyle = resolveClassStyle(props, () => context.state());\n\tconst userProps = omit(props, \"as\", \"class\", \"style\", \"attrs\");\n\n\tconst internalSlot = {\n\t\t// SSR hook for the deferred prehydration script (see\n\t\t// `slider-control.tsx` for the symmetric attr on the control).\n\t\t// Seed `\"\"` so Solid 2's DOM spread keeps the key in `ownKeys`\n\t\t// per `test/internals/merge-props-undefined-attr.test.tsx`.\n\t\tget \"data-quoin-slider-indicator\"() {\n\t\t\treturn context.renderBeforeHydration() ? \"\" : \"\";\n\t\t},\n\t\tget style(): JSX.CSSProperties {\n\t\t\tconst values = context.values();\n\t\t\tconst min = context.min();\n\t\t\tconst max = context.max();\n\t\t\tconst vertical = context.orientation() === \"vertical\";\n\t\t\tconst range = values.length > 1;\n\n\t\t\tif (context.inset()) {\n\t\t\t\tconst [start, end] = context.indicatorPosition();\n\t\t\t\treturn getInsetStyles(\n\t\t\t\t\tvertical,\n\t\t\t\t\trange,\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\tcontext.renderBeforeHydration(),\n\t\t\t\t\tisHydrating(),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst start = valueToPercent(values[0] ?? min, min, max);\n\t\t\tconst end = valueToPercent(values[values.length - 1] ?? max, min, max);\n\t\t\treturn getCenteredStyles(vertical, range, start, end);\n\t\t},\n\t};\n\n\tlet merged: Record<string, unknown> = mergeRootProps(\n\t\tinternalSlot,\n\t\tsliderDataAttrs(context.state),\n\t);\n\tmerged = mergeRootProps(merged, userClassStyle);\n\tmerged = mergeRootProps(merged, userProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"div\");\n\treturn <Tag {...merged} ref={userRef(props)} />;\n}\n\nexport namespace SliderIndicator {\n\texport type State = SliderIndicatorState;\n\texport type Props = SliderIndicatorProps;\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,IAAI,QAAQ,UAAU;AAC/B,SAASC,OAAO,QAAQ,8BAA8B;AACtD,SAASC,WAAW,QAAQ,iCAAiC;AAC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