clava 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # clava
2
2
 
3
+ ## 0.6.2
4
+
5
+ - Fixed `TS2590` and `TS2345` type errors when a framework style value, such as React's `CSSProperties` or Solid's `JSX.CSSProperties`, is passed to a [`cv`](https://clava.style/docs/reference/cv) component.
6
+
3
7
  ## 0.6.1
4
8
 
5
9
  - Reduced the production bundle size and improved tree-shaking for standalone imports.
package/README.md CHANGED
@@ -549,7 +549,7 @@ The package also exports `ClassValue`, `StyleValue`, `StyleClassProps`, `StyleCl
549
549
 
550
550
  ## Comparison
551
551
 
552
- This table compares Clava with the packages used by the repository's alternative benchmark: `class-variance-authority@0.7.1`, `cva@1.0.0-beta.4`, `tailwind-variants/lite@3.2.2`, `tailwind-variants@3.2.2`, and `tailwind-merge@3.6.0` through Clava's `transformClass`.
552
+ This table compares Clava with the packages used by the repository's alternative benchmark: `class-variance-authority@0.7.1`, `cva@1.0.0-beta.6`, `tailwind-variants/lite@3.2.2`, `tailwind-variants@3.2.2`, and `tailwind-merge@3.6.0` through Clava's `transformClass`.
553
553
 
554
554
  | Feature | Clava | CVA v0 | CVA v1 beta | TV Lite | TV |
555
555
  | ---------------------------------------------------- | -------------- | ------------------ | ------------------ | ------------------ | ------------------ |
@@ -565,16 +565,16 @@ This table compares Clava with the packages used by the repository's alternative
565
565
  | Dedicated slots API | No | No | No | Yes | Yes |
566
566
  | Built-in Tailwind conflict merging | No | No | No | No | Yes |
567
567
 
568
- The `pnpm perf-alternatives` benchmark resolves a composed Tailwind-style button with inherited variants, defaults, and cross-variant conditions. On Node v24.14.1, Vitest reported these results, where higher ops/sec is better:
568
+ The `pnpm perf-alternatives` benchmark resolves a composed Tailwind-style button with inherited variants, defaults, and cross-variant conditions. On Node v24.18.0, Vitest reported these results, where higher ops/sec is better:
569
569
 
570
570
  | Package | Ops/sec | Relative to Clava |
571
571
  | ------------------------------------ | --------: | ----------------: |
572
- | `clava@0.6.0` | 1,093,632 | 1.00x |
573
- | `clava@0.6.0 + tailwind-merge@3.6.0` | 535,392 | 2.04x slower |
574
- | `class-variance-authority@0.7.1` | 445,527 | 2.45x slower |
575
- | `tailwind-variants/lite@3.2.2` | 377,985 | 2.89x slower |
576
- | `tailwind-variants@3.2.2` | 286,653 | 3.82x slower |
577
- | `cva@1.0.0-beta.4` | 218,829 | 5.00x slower |
572
+ | `clava@0.6.1` | 1,064,359 | 1.00x |
573
+ | `clava@0.6.1 + tailwind-merge@3.6.0` | 505,454 | 2.11x slower |
574
+ | `class-variance-authority@0.7.1` | 435,382 | 2.44x slower |
575
+ | `tailwind-variants/lite@3.2.2` | 371,763 | 2.86x slower |
576
+ | `cva@1.0.0-beta.6` | 328,566 | 3.24x slower |
577
+ | `tailwind-variants@3.2.2` | 274,351 | 3.88x slower |
578
578
 
579
579
  Benchmark results vary by runtime and hardware, so treat them as a reproducible snapshot of this repository's composed-variant case rather than a universal ranking.
580
580
 
package/dist/index.d.ts CHANGED
@@ -17,13 +17,12 @@ import * as CSS from "csstype";
17
17
  * ```
18
18
  */
19
19
  type ClassValue = string | number | boolean | null | undefined | void | ClassValue[];
20
- interface JSXCSSProperties extends CSS.Properties<string | number> {
20
+ interface CustomProperties {
21
21
  [key: `--${string}`]: string | number;
22
22
  }
23
- interface HTMLCSSProperties extends CSS.PropertiesHyphen<string | number> {
24
- [key: `--${string}`]: string | number;
25
- }
26
- type StyleProperty = JSXCSSProperties | HTMLCSSProperties | string;
23
+ interface JSXCSSProperties extends CSS.Properties<string | number>, CustomProperties {}
24
+ interface HTMLCSSProperties extends CSS.PropertiesHyphen<string | number>, CustomProperties {}
25
+ type StyleProperty = JSXCSSProperties | HTMLCSSProperties | CSS.Properties<string | number> | CSS.PropertiesHyphen<string | number> | string;
27
26
  /**
28
27
  * The prop object returned by a component's `.jsx()` mode.
29
28
  *
@@ -181,9 +180,7 @@ type DefaultVariants<V> = { [K in keyof V]?: DefaultVariantValue<V, K> | undefin
181
180
  * };
182
181
  * ```
183
182
  */
184
- interface StyleValue extends CSS.Properties {
185
- [key: `--${string}`]: string | number;
186
- }
183
+ interface StyleValue extends CSS.Properties, CustomProperties {}
187
184
  /**
188
185
  * A value that contributes both class and style output from a base config,
189
186
  * variant value, function variant, or refine callback.
@@ -241,7 +238,7 @@ type ExtendableVariants<V extends Variants, E extends AnyComponent[]> = V & { [K
241
238
  * };
242
239
  * ```
243
240
  */
244
- type VariantProps<T extends Pick<AnyComponent, "getVariants">> = ReturnType<T["getVariants"]>;
241
+ export type VariantProps<T extends Pick<AnyComponent, "getVariants">> = ReturnType<T["getVariants"]>;
245
242
  type VariantKey<T> = T extends boolean ? "true" | "false" : Extract<T, string>;
246
243
  /**
247
244
  * Constrains a variant map to the same value keys as a variant on another
@@ -269,7 +266,7 @@ type VariantKey<T> = T extends boolean ? "true" | "false" : Extract<T, string>;
269
266
  * });
270
267
  * ```
271
268
  */
272
- type Variant<T extends Pick<AnyComponent, "getVariants">, K extends keyof VariantProps<T>> = Record<VariantKey<NonNullable<VariantProps<T>[K]>>, ClassValue | StyleClassValue>;
269
+ export type Variant<T extends Pick<AnyComponent, "getVariants">, K extends keyof VariantProps<T>> = Record<VariantKey<NonNullable<VariantProps<T>[K]>>, ClassValue | StyleClassValue>;
273
270
  /**
274
271
  * The configuration object accepted by `cv()`. It defines base class/style
275
272
  * output, variants, default variants, component extensions, and refinement
@@ -296,7 +293,7 @@ type Variant<T extends Pick<AnyComponent, "getVariants">, K extends keyof Varian
296
293
  * const alert = cv(config);
297
294
  * ```
298
295
  */
299
- interface CVConfig<V extends Variants = {}, E extends AnyComponent[] = []> {
296
+ export interface CVConfig<V extends Variants = {}, E extends AnyComponent[] = []> {
300
297
  extend?: E;
301
298
  class?: ClassValue;
302
299
  style?: StyleValue;
@@ -315,21 +312,21 @@ interface CreateParams {
315
312
  * styling props. The last element is always the "rest" containing keys not
316
313
  * claimed by any source.
317
314
  */
318
- declare const splitProps: SplitPropsFunction;
315
+ export declare const splitProps: SplitPropsFunction;
319
316
  /**
320
317
  * Creates the cv and cx functions.
321
318
  */
322
- declare function create({ transformClass }?: CreateParams): {
319
+ export declare function create({ transformClass }?: CreateParams): {
323
320
  cv: <V extends Variants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, E>) => CVComponent<V, E>;
324
321
  cx: (...classes: ClassValue$1[]) => string;
325
322
  };
326
- declare const cv: <V extends Variants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, E>) => CVComponent<V, E>;
323
+ export declare const cv: <V extends Variants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, E>) => CVComponent<V, E>;
327
324
  /**
328
325
  * Joins class values without applying a class transform.
329
326
  *
330
327
  * This behaves like the `cx` function returned by `create()` with no options.
331
328
  */
332
- declare function cx(...classes: ClassValue$1[]): string;
329
+ export declare function cx(...classes: ClassValue$1[]): string;
333
330
  //#endregion
334
- export { type CVComponent, CVConfig, type ClassValue, type HTMLObjProps, type HTMLProps, type JSXProps, type StyleClassProps, type StyleClassValue, type StyleValue, Variant, VariantProps, create, cv, cx, splitProps };
331
+ export type { CVComponent, ClassValue, HTMLObjProps, HTMLProps, JSXProps, StyleClassProps, StyleClassValue, StyleValue };
335
332
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/utils.ts","../src/refine-warning.ts","../src/index.ts"],"sourcesContent":["import type { HTMLCSSProperties, StyleValue } from \"./types.ts\";\n\nexport const hasOwn = Object.hasOwn;\n\n// Keep this explicit so normalization does not depend on browser globals.\n// Vendor-prefixed variants are derived below instead of duplicating the list.\nconst unitlessNumberProperties = new Set([\n \"animationIterationCount\",\n \"aspectRatio\",\n \"borderImage\",\n \"borderImageOutset\",\n \"borderImageSlice\",\n \"borderImageWidth\",\n \"boxFlex\",\n \"boxFlexGroup\",\n \"boxOrdinalGroup\",\n \"columnCount\",\n \"columns\",\n \"fillOpacity\",\n \"flex\",\n \"flexGrow\",\n \"flexNegative\",\n \"flexOrder\",\n \"flexPositive\",\n \"flexShrink\",\n \"floodOpacity\",\n \"fontSizeAdjust\",\n \"fontWeight\",\n \"gridArea\",\n \"gridColumn\",\n \"gridColumnEnd\",\n \"gridColumnSpan\",\n \"gridColumnStart\",\n \"gridRow\",\n \"gridRowEnd\",\n \"gridRowSpan\",\n \"gridRowStart\",\n \"hyphenateLimitChars\",\n \"initialLetter\",\n \"lineClamp\",\n \"lineHeight\",\n \"maskBorder\",\n \"maskBorderOutset\",\n \"maskBorderSlice\",\n \"maskBorderWidth\",\n \"mathDepth\",\n \"maxLines\",\n \"opacity\",\n \"order\",\n \"orphans\",\n \"scale\",\n \"shapeImageThreshold\",\n \"stopOpacity\",\n \"strokeDasharray\",\n \"strokeDashoffset\",\n \"strokeMiterlimit\",\n \"strokeOpacity\",\n \"strokeWidth\",\n \"tabSize\",\n \"widows\",\n \"zIndex\",\n \"zoom\",\n]);\n\nfunction isCustomProperty(property: string) {\n return property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45;\n}\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"-ms-transition\") // \"msTransition\" (lowercase \"ms\" prefix)\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n // Fast path: no hyphen -> return as-is\n let hyphenIndex = str.indexOf(\"-\");\n if (hyphenIndex === -1) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n while (hyphenIndex !== -1) {\n result += str.slice(lastIndex, hyphenIndex);\n\n const nextIndex = hyphenIndex + 1;\n if (nextIndex >= str.length) {\n result += \"-\";\n lastIndex = nextIndex;\n break;\n }\n\n const code = str.charCodeAt(nextIndex);\n const isAsciiLetter =\n (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n if (isAsciiLetter) {\n const isMicrosoftPrefix = hyphenIndex === 0 && str.startsWith(\"ms-\", 1);\n result += isMicrosoftPrefix\n ? str[nextIndex]\n : str[nextIndex].toUpperCase();\n lastIndex = nextIndex + 1;\n } else {\n result += \"-\";\n lastIndex = nextIndex;\n }\n\n hyphenIndex = str.indexOf(\"-\", lastIndex);\n }\n\n return result + str.slice(lastIndex);\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"msTransition\") // \"-ms-transition\" (lowercase \"ms\" prefix)\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n if (code < 65 || code > 90) continue;\n const isMicrosoftPrefix = i === 2 && str.startsWith(\"ms\");\n if (isMicrosoftPrefix) {\n result += \"-\";\n }\n result += str.slice(lastIndex, i);\n result += \"-\";\n result += str[i].toLowerCase();\n lastIndex = i + 1;\n }\n\n if (lastIndex === 0) {\n return str;\n }\n return result + str.slice(lastIndex);\n}\n\nfunction hasVendorPrefix(property: string, prefix: string) {\n const nextCode = property.charCodeAt(prefix.length);\n if (nextCode < 65 || nextCode > 90) return false;\n return property.startsWith(prefix);\n}\n\n// \"ms\" is used in JSX, while camelizing hyphenated properties produces \"Ms\".\nconst vendorPrefixes = [\"Webkit\", \"Moz\", \"ms\", \"Ms\", \"O\"];\n\nfunction isUnitlessNumberProperty(property: string) {\n if (unitlessNumberProperties.has(property)) return true;\n\n for (const prefix of vendorPrefixes) {\n if (!hasVendorPrefix(property, prefix)) continue;\n const firstCode = property.charCodeAt(prefix.length);\n const unprefixedProperty =\n String.fromCharCode(firstCode + 32) + property.slice(prefix.length + 1);\n return unitlessNumberProperties.has(unprefixedProperty);\n }\n return false;\n}\n\nfunction normalizeStyleValue(property: string, value: string | number) {\n if (typeof value === \"string\") {\n return value;\n }\n if (isCustomProperty(property)) {\n return value;\n }\n if (isUnitlessNumberProperty(property)) {\n return value;\n }\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(\n styleString: string,\n result: StyleValue = {},\n) {\n if (!styleString) return result;\n const len = styleString.length;\n let i = 0;\n while (i < len) {\n // Skip leading whitespace and stray semicolons\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13 && c !== 59) break;\n i++;\n }\n if (i >= len) break;\n // Read property name until ':' or ';'\n const propStart = i;\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c === 58 || c === 59) break;\n i++;\n }\n if (i >= len || styleString.charCodeAt(i) === 59) {\n // No colon found - skip this declaration\n if (i < len) {\n // Skip ';'.\n i++;\n }\n continue;\n }\n let propEnd = i;\n // Trim trailing whitespace from property name\n while (propEnd > propStart) {\n const c = styleString.charCodeAt(propEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n propEnd--;\n }\n if (propEnd === propStart) {\n // Empty property - skip\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n if (i < len) {\n i++;\n }\n continue;\n }\n const property = styleString.slice(propStart, propEnd);\n // Skip ':'.\n i++;\n // Skip whitespace before value\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n i++;\n }\n const valStart = i;\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n let valEnd = i;\n while (valEnd > valStart) {\n const c = styleString.charCodeAt(valEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n valEnd--;\n }\n if (i < len) {\n // Skip ';'.\n i++;\n }\n if (valEnd === valStart) continue;\n const value = styleString.slice(valStart, valEnd);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(property)] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(\n style: object,\n result: StyleValue = {},\n): StyleValue {\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n const property = hyphenToCamel(key);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string | number>)[property] = normalizeStyleValue(\n property,\n value as string | number,\n );\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n let result = \"\";\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n if (result) {\n result += \"; \";\n }\n result += camelToHyphen(key);\n result += \": \";\n result += value as string | number;\n }\n if (!result) return \"\";\n return `${result};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: HTMLCSSProperties = {};\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n (result as Record<string, unknown>)[camelToHyphen(key)] = value;\n }\n return result;\n}\n","import { hasOwn } from \"./utils.ts\";\n\nexport interface CreationFrame {\n stack?: string;\n}\n\nexport interface VariantChange {\n from: unknown;\n to: unknown;\n}\n\n// Once a refine loop is within this many iterations of the cap, start tracking\n// the latest value transition for every variant key that changes between\n// iterations so the warning can report every key that contributed to the\n// oscillation, not just the keys that happened to flip on the final step.\n// Convergent loops (the common case) exit well before this threshold and pay no\n// per-iteration tracking cost.\nexport const REFINE_UNSTABLE_TRACKING_WINDOW = 10;\n\n// Captures the call site of the function passed in `skipFn` so refine-limit\n// warnings can point developers at the originating `cv()` call. Returns\n// `undefined` in production so bundlers that replace `process.env.NODE_ENV` at\n// build time can drop the entire warning machinery. The underlying `.stack`\n// string is formatted lazily on first access in every major engine (V8,\n// SpiderMonkey, JavaScriptCore), so holding the captured frame for the\n// lifetime of the component is cheap when no warning fires.\nexport function captureCreationFrame(\n skipFn: Function,\n): CreationFrame | undefined {\n if (process.env.NODE_ENV === \"production\") return undefined;\n if (typeof Error.captureStackTrace === \"function\") {\n const holder: CreationFrame = {};\n Error.captureStackTrace(holder, skipFn);\n return holder;\n }\n // Engines without `Error.captureStackTrace` (SpiderMonkey, JavaScriptCore)\n // can't strip internal frames, but their `Error.stack` getter is still\n // lazy, so returning the Error instance defers the format cost. The\n // resulting trace includes 1–2 extra frames at the top from this helper and\n // `cv` itself.\n return new Error();\n}\n\nexport function formatCreationStack(frame: CreationFrame): string | undefined {\n let stack = frame.stack;\n if (!stack) return undefined;\n // V8 prefixes the stack with a leading \"Error\" / \"Error: message\" line that\n // isn't meaningful for a captured location — drop it.\n const newlineIdx = stack.indexOf(\"\\n\");\n if (newlineIdx > 0) {\n const firstLine = stack.slice(0, newlineIdx);\n if (firstLine === \"Error\" || firstLine.startsWith(\"Error:\")) {\n stack = stack.slice(newlineIdx + 1);\n }\n }\n const frames = stack.split(\"\\n\");\n for (let i = 0; i < frames.length; i++) {\n const line = frames[i]?.trim();\n if (!line) continue;\n if (isInternalCreationFrame(line)) continue;\n if (line.includes(\"/node_modules/\")) continue;\n if (line.includes(\"\\\\node_modules\\\\\")) continue;\n if (line.includes(\"node:internal\")) continue;\n return ` ${line}`;\n }\n return undefined;\n}\n\nfunction isInternalCreationFrame(line: string): boolean {\n if (line.includes(\"captureCreationFrame\")) return true;\n if (line.startsWith(\"at cv \")) return true;\n if (line.startsWith(\"at cv(\")) return true;\n if (line.startsWith(\"cv@\")) return true;\n return false;\n}\n\nfunction formatVariantValue(value: unknown): string {\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return \"NaN\";\n return String(value);\n }\n if (typeof value === \"bigint\") return `${value}n`;\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (typeof value === \"boolean\") return String(value);\n if (typeof value === \"symbol\") return String(value);\n if (typeof value === \"function\") return \"[function]\";\n return \"[object]\";\n}\n\nfunction setVariantChange(\n into: Map<string, VariantChange>,\n key: string,\n from: unknown,\n to: unknown,\n): void {\n into.set(key, { from, to });\n}\n\nexport function accumulateUnstableVariantChanges(\n into: Map<string, VariantChange>,\n prev: Record<string, unknown>,\n next: Record<string, unknown>,\n): void {\n for (const key in next) {\n if (!hasOwn(next, key)) continue;\n if (!Object.is(prev[key], next[key])) {\n setVariantChange(into, key, prev[key], next[key]);\n }\n }\n for (const key in prev) {\n if (!hasOwn(prev, key)) continue;\n if (hasOwn(next, key)) continue;\n setVariantChange(into, key, prev[key], undefined);\n }\n}\n\nfunction formatVariantChanges(changes: Map<string, VariantChange>): string {\n return Array.from(changes)\n .map(([key, { from, to }]) => {\n return `${key}: ${formatVariantValue(from)} -> ${formatVariantValue(to)}`;\n })\n .join(\", \");\n}\n\ninterface WarnRefineLimitParams {\n creationFrame: CreationFrame | undefined;\n unstableChanges: Map<string, VariantChange> | null;\n}\n\nexport function warnRefineLimit({\n creationFrame,\n unstableChanges,\n}: WarnRefineLimitParams): void {\n // Bundlers are expected to replace this branch with a production literal,\n // allowing warning-only code below to be removed from consumer bundles.\n if (process.env.NODE_ENV === \"production\") return;\n let message =\n \"Clava: Maximum refine iterations exceeded. This can happen when a \" +\n \"computed default variant or refine callback changes one of the \" +\n \"variants on every run.\";\n if (unstableChanges && unstableChanges.size > 0) {\n message += `\\nVariant(s) that did not stabilize: ${Array.from(unstableChanges.keys()).join(\", \")}.`;\n message += `\\nLatest variant changes before warning: ${formatVariantChanges(unstableChanges)}.`;\n }\n if (creationFrame) {\n const creationStack = formatCreationStack(creationFrame);\n if (creationStack) {\n message += `\\nComponent created at:\\n${creationStack}`;\n }\n }\n console.warn(message);\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\nimport {\n REFINE_UNSTABLE_TRACKING_WINDOW,\n type VariantChange,\n accumulateUnstableVariantChanges,\n captureCreationFrame,\n warnRefineLimit,\n} from \"./refine-warning.ts\";\nimport type {\n AnyComponent,\n CVComponent,\n ClassValue,\n ComponentProps,\n ComponentResult,\n DefaultVariants,\n ExtendableVariants,\n HTMLObjProps,\n HTMLProps,\n JSXProps,\n KeySourceComponent,\n MergeVariants,\n ModalComponent,\n Refine,\n SplitPropsFunction,\n StyleClassProps,\n StyleClassValue,\n StyleValue,\n VariantValues,\n Variants,\n} from \"./types.ts\";\nimport {\n hasOwn,\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n} from \"./utils.ts\";\n\n// Internal compute path: pushes the variant classes contributed by this\n// component (and its extends chain) into `classesOut` and merges any styles\n// into `styleOut`. Base class is handled by callers via ComponentMeta.baseClass\n// to avoid string-parsing round trips. Both outputs are mutated in place to\n// avoid intermediate allocations.\ntype ComputeFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n) => Record<string, unknown>;\n\ntype ComputeOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n protectedVariants?: Record<string, unknown> | null,\n protectedVariantKeys?: Set<string> | null,\n defaultResolved?: Record<string, unknown>,\n renderOnly?: boolean,\n) => Record<string, unknown>;\n\ntype ResolveRefineFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n) => Record<string, unknown>;\n\ntype ResolveRefineOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n protectedVariants?: Record<string, unknown> | null,\n protectedVariantKeys?: Set<string> | null,\n defaultResolved?: Record<string, unknown>,\n) => Record<string, unknown>;\n\ntype ComputedDefaultVariantFn = (\n defaultValue: unknown,\n variants: Readonly<Record<string, unknown>>,\n) => unknown;\n\n// Internal metadata stored on components but hidden from public types.\ninterface ComponentMeta {\n baseClass: string;\n staticDefaults: Record<string, unknown>;\n // Performs a single compute pass for extending components, returning the\n // resolved variants while pushing classes and styles into the output values.\n compute: ComputeOnceFn;\n resolveRefine: ResolveRefineOnceFn | null;\n // Reference identity is used to detect mixed-factory `extend`. When a\n // component is extended by a parent from a different `create()` call, the\n // parent applies this transform to the extend's contribution before joining,\n // preserving each factory's transform boundary.\n transformClass: (className: string) => string;\n // Variant keys whose effective definition in this component's chain is a\n // function. An extending component that supplies a non-function variant for\n // the same key uses this to tell us to skip that key (matching the\n // type-level \"function variant is replaced by anything in the child\" rule).\n // Empty when no key in this chain is a function variant.\n functionVariantKeys: Set<string>;\n // Variant keys with computed defaults anywhere in this component's chain.\n // Child components use this to preserve inherited computed defaults through\n // `defaultValue` without preserving their own prior computed result.\n computedDefaultKeys: Set<string>;\n}\n\nconst META_KEY = \"__meta\";\n\ninterface ComponentWithMeta {\n [META_KEY]?: ComponentMeta;\n}\n\nconst EMPTY_DEFAULTS: Record<string, unknown> = {};\n\nconst MAX_REFINE_RUNS = 50;\n\nfunction areVariantsEqual(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n): boolean {\n for (const key in a) {\n if (!hasOwn(a, key)) continue;\n if (!Object.is(a[key], b[key])) return false;\n }\n for (const key in b) {\n if (!hasOwn(b, key)) continue;\n if (!hasOwn(a, key)) return false;\n }\n return true;\n}\n\nfunction getExtUserVariantProps(\n userVariantProps: Record<string, unknown>,\n protectedVariants: Record<string, unknown> | null,\n): Record<string, unknown> {\n return Object.assign({}, userVariantProps, protectedVariants);\n}\n\nfunction mergeProtectedIntoBase(\n baseResolved: Record<string, unknown>,\n protectedVariants: Record<string, unknown>,\n protectedVariantKeys: Set<string>,\n): Record<string, unknown> {\n if (protectedVariantKeys.size === 0) return baseResolved;\n return Object.assign({}, baseResolved, protectedVariants);\n}\n\nexport type {\n ClassValue,\n StyleValue,\n StyleClassProps,\n StyleClassValue,\n JSXProps,\n HTMLProps,\n HTMLObjProps,\n CVComponent,\n};\n\n/**\n * Extracts the variant props inferred for a Clava component. Use it to add a\n * component's variant props to framework component props.\n *\n * @example\n * ```ts\n * import { type VariantProps, cv } from \"clava\";\n * import type { ComponentProps } from \"react\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * disabled: { true: \"button-disabled\", false: \"\" },\n * },\n * });\n *\n * interface ButtonProps\n * extends ComponentProps<\"button\">,\n * VariantProps<typeof button> {}\n *\n * const props: ButtonProps = {\n * size: \"lg\",\n * disabled: true,\n * };\n * ```\n */\nexport type VariantProps<T extends Pick<AnyComponent, \"getVariants\">> =\n ReturnType<T[\"getVariants\"]>;\n\n// Variant props expose booleans, but variant object keys are always strings.\ntype VariantKey<T> = T extends boolean ? \"true\" | \"false\" : Extract<T, string>;\n\n/**\n * Constrains a variant map to the same value keys as a variant on another\n * component. Boolean variants are represented with `\"true\"` and `\"false\"`\n * object keys.\n *\n * @example\n * ```ts\n * import { type Variant, cv } from \"clava\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * },\n * });\n *\n * const icon = cv({\n * extend: [button],\n * variants: {\n * size: {\n * sm: \"icon-sm\",\n * lg: \"icon-lg\",\n * } satisfies Variant<typeof button, \"size\">,\n * },\n * });\n * ```\n */\nexport type Variant<\n T extends Pick<AnyComponent, \"getVariants\">,\n K extends keyof VariantProps<T>,\n> = Record<\n VariantKey<NonNullable<VariantProps<T>[K]>>,\n ClassValue | StyleClassValue\n>;\n\n/**\n * The configuration object accepted by `cv()`. It defines base class/style\n * output, variants, default variants, component extensions, and refinement\n * logic.\n *\n * @example\n * ```ts\n * import { type CVConfig, cv } from \"clava\";\n *\n * const config: CVConfig<{\n * tone: { info: string; danger: string };\n * }> = {\n * variants: {\n * tone: {\n * info: \"alert-info\",\n * danger: \"alert-danger\",\n * },\n * },\n * defaultVariants: {\n * tone: \"info\",\n * },\n * };\n *\n * const alert = cv(config);\n * ```\n */\nexport interface CVConfig<\n V extends Variants = {},\n E extends AnyComponent[] = [],\n> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n defaultVariants?: DefaultVariants<MergeVariants<V, E>>;\n refine?: Refine<MergeVariants<V, E>>;\n}\n\ninterface CreateParams {\n transformClass?: (className: string) => string;\n}\n\nfunction isRecordObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a normalized\n * StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n return htmlObjStyleToStyleValue(style);\n }\n return {};\n}\n\n/**\n * Pre-extracts the class and (normalized) style from a variant value once at\n * component creation time. Returns `null` if the value contributes nothing.\n */\ninterface PrebuiltValue {\n class: ClassValue;\n style: StyleValue | null;\n}\n\nfunction extractClassAndStylePrebuilt(value: unknown): PrebuiltValue {\n if (!isRecordObject(value)) {\n return { class: value as ClassValue, style: null };\n }\n if (!(\"style\" in value || \"class\" in value)) {\n return { class: null, style: null };\n }\n const styleClassValue = value as StyleClassValue;\n const style = normalizeStyle(styleClassValue.style);\n return {\n class: styleClassValue.class ?? null,\n style: Object.keys(style).length > 0 ? style : null,\n };\n}\n\nfunction getVariantValueKey(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\") {\n return String(value);\n }\n if (typeof value === \"boolean\") {\n return String(value);\n }\n return undefined;\n}\n\nconst EMPTY_KEYS: readonly string[] = [];\n\nfunction isComponentKeySource(source: unknown): source is KeySourceComponent {\n if (!source) return false;\n if (typeof source !== \"object\" && typeof source !== \"function\") {\n return false;\n }\n const typed = source as Record<string, unknown>;\n if (typeof typed.getVariants !== \"function\") return false;\n if (!Array.isArray(typed.propKeys)) return false;\n return Array.isArray(typed.variantKeys);\n}\n\n/**\n * Splits props into multiple groups based on key sources. Only the first\n * component claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays always receive their listed keys but don't\n * claim styling props.\n */\nfunction splitPropsImpl(\n selfKeys: readonly string[],\n selfIsComponent: boolean,\n props: Record<string, unknown>,\n sources: unknown[],\n): Record<string, unknown>[] {\n const sourcesLength = sources.length;\n const results: Record<string, unknown>[] = [];\n let stylingClaimed = selfIsComponent;\n\n const selfResult: Record<string, unknown> = {};\n const selfKeysLength = selfKeys.length;\n for (let i = 0; i < selfKeysLength; i++) {\n const key = selfKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n\n // Track effective key arrays for the rest computation — for typical inputs\n // a linear scan beats building a Set up-front.\n const effectiveKeyArrays: Array<readonly string[]> = [selfKeys];\n\n for (let s = 0; s < sourcesLength; s++) {\n const source = sources[s];\n const sourceResult: Record<string, unknown> = {};\n let sourceIsComponent = false;\n let effectiveKeys: readonly string[];\n if (Array.isArray(source)) {\n effectiveKeys = source;\n } else if (isComponentKeySource(source)) {\n sourceIsComponent = true;\n effectiveKeys = stylingClaimed ? source.variantKeys : source.propKeys;\n } else {\n effectiveKeys = EMPTY_KEYS;\n }\n\n const effectiveKeysLength = effectiveKeys.length;\n for (let i = 0; i < effectiveKeysLength; i++) {\n const key = effectiveKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n effectiveKeyArrays.push(effectiveKeys);\n\n if (sourceIsComponent && !stylingClaimed) {\n stylingClaimed = true;\n }\n }\n\n const rest: Record<string, unknown> = {};\n const propKeys = Object.keys(props);\n const propKeysLength = propKeys.length;\n const groupCount = sourcesLength + 1;\n outer: for (let i = 0; i < propKeysLength; i++) {\n const key = propKeys[i];\n if (key === undefined) continue;\n for (let g = 0; g < groupCount; g++) {\n const arr = effectiveKeyArrays[g];\n if (arr === undefined) continue;\n const arrLength = arr.length;\n for (let j = 0; j < arrLength; j++) {\n if (arr[j] === key) continue outer;\n }\n }\n rest[key] = props[key];\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources. Each source gets its\n * own result object containing all its matching keys. The first component\n * source claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays receive their listed keys but don't claim\n * styling props. The last element is always the \"rest\" containing keys not\n * claimed by any source.\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n if (Array.isArray(source1)) {\n return splitPropsImpl(source1, false, props, sources);\n }\n if (isComponentKeySource(source1)) {\n return splitPropsImpl(source1.propKeys, true, props, sources);\n }\n return splitPropsImpl(EMPTY_KEYS, false, props, sources);\n}) as SplitPropsFunction;\n\n/**\n * A pre-built variant. Maps variant value keys (or the literal \"true\"/\"false\"\n * strings for boolean variants) to PrebuiltValue. Includes a \"shorthand\"\n * fallback when the variant is a single class value (treated as `{ true: ... }`).\n */\ninterface PrebuiltVariant {\n // For object variants: map of value -> prebuilt class/style\n values: Record<string, PrebuiltValue> | null;\n // For shorthand variants: the value to use when selectedValue is true\n shorthand: PrebuiltValue | null;\n // Set of value keys that are disabled (value === null in the original variant\n // definition)\n disabledValues: Set<string> | null;\n}\n\nfunction buildPrebuiltVariant(variantDef: unknown): PrebuiltVariant {\n if (!isRecordObject(variantDef)) {\n return {\n values: null,\n shorthand: extractClassAndStylePrebuilt(variantDef),\n disabledValues: null,\n };\n }\n const values: Record<string, PrebuiltValue> = {};\n let disabledValues: Set<string> | null = null;\n for (const key in variantDef) {\n if (!hasOwn(variantDef, key)) continue;\n const value = variantDef[key];\n if (value === null) {\n if (!disabledValues) {\n disabledValues = new Set<string>();\n }\n disabledValues.add(key);\n continue;\n }\n values[key] = extractClassAndStylePrebuilt(value);\n }\n return {\n values,\n shorthand: null,\n disabledValues,\n };\n}\n\n/**\n * Creates the cv and cx functions.\n */\nexport function create({\n transformClass = (className) => className,\n}: CreateParams = {}) {\n const cx = (...classes: ClsxClassValue[]) => transformClass(clsx(classes));\n\n const cv = <V extends Variants = {}, const E extends AnyComponent[] = []>(\n config: CVConfig<V, E> = {},\n ): CVComponent<V, E> => {\n type MergedVariants = MergeVariants<V, E>;\n\n // ----- Pre-computed at creation time -----\n const extend = config.extend;\n const hasExtend = !!extend && extend.length > 0;\n const variants = config.variants;\n const refine = config.refine;\n const baseStyle = config.style;\n const hasBaseStyle = !!baseStyle;\n\n const variantKeySet = new Set<string>();\n const staticDefaults: Record<string, unknown> = {};\n\n // Pre-build extended component info, so the render path doesn't need to\n // read component metadata. Extends from a different `create()`\n // factory (different `transformClass` identity) need their contribution\n // transformed by their own `transformClass` before being joined into our\n // class string.\n const extMetas: ComponentMeta[] = [];\n const extBaseClassesArr: string[] = [];\n const extIsolated: boolean[] = [];\n let hasIsolatedExt = false;\n if (hasExtend) {\n for (const ext of extend) {\n const extKeys = ext.variantKeys as readonly string[];\n for (let i = 0; i < extKeys.length; i++) {\n const key = extKeys[i];\n if (key === undefined) continue;\n variantKeySet.add(key);\n }\n\n const meta = (ext as AnyComponent & ComponentWithMeta)[META_KEY];\n if (!meta) continue;\n extMetas.push(meta);\n Object.assign(staticDefaults, meta.staticDefaults);\n\n const isolated = meta.transformClass !== transformClass;\n extIsolated.push(isolated);\n if (isolated) {\n hasIsolatedExt = true;\n extBaseClassesArr.push(meta.transformClass(meta.baseClass));\n } else {\n extBaseClassesArr.push(meta.baseClass);\n }\n }\n }\n const extCount = extMetas.length;\n\n // Build all own variant metadata in one pass. Disabled value sets are\n // shared with their prebuilt variants instead of scanning and allocating\n // them twice.\n const disabledVariantKeys = new Set<string>();\n const disabledVariantValues: Record<string, Set<string>> = {};\n let hasDisabledVariantValues = false;\n const variantEntryNames: string[] = [];\n const variantEntryDefs: PrebuiltVariant[] = [];\n const functionVariantNames: string[] = [];\n const functionVariantFns: Array<(value: unknown) => unknown> = [];\n if (variants) {\n for (const name in variants) {\n if (!hasOwn(variants, name)) continue;\n const variant = (variants as Record<string, unknown>)[name];\n if (variant === null) {\n variantKeySet.delete(name);\n disabledVariantKeys.add(name);\n continue;\n }\n variantKeySet.add(name);\n if (typeof variant === \"function\") {\n functionVariantNames.push(name);\n functionVariantFns.push(variant as (value: unknown) => unknown);\n continue;\n }\n const prebuiltVariant = buildPrebuiltVariant(variant);\n variantEntryNames.push(name);\n variantEntryDefs.push(prebuiltVariant);\n if (prebuiltVariant.disabledValues) {\n disabledVariantValues[name] = prebuiltVariant.disabledValues;\n hasDisabledVariantValues = true;\n }\n if (\n prebuiltVariant.values &&\n hasOwn(prebuiltVariant.values, \"false\") &&\n staticDefaults[name] === undefined\n ) {\n staticDefaults[name] = false;\n }\n }\n }\n const variantKeys = Array.from(variantKeySet);\n const variantKeysLength = variantKeys.length;\n const variantEntryCount = variantEntryNames.length;\n const functionVariantCount = functionVariantNames.length;\n const hasDisabledVariantKeys = disabledVariantKeys.size > 0;\n const hasAnyDisabled = hasDisabledVariantKeys || hasDisabledVariantValues;\n\n const inputPropsKeys = [\"class\", \"className\", \"style\", ...variantKeys];\n\n const computedDefaultNames: string[] = [];\n const computedDefaultFns: ComputedDefaultVariantFn[] = [];\n const defaultVariants = config.defaultVariants as\n | Record<string, unknown>\n | undefined;\n\n // Pre-compute static defaults. Includes:\n // - extended components' static defaults\n // - implicit boolean defaults (variants with a `false` key default to false)\n // - this config's literal defaultVariants (overriding the above)\n //\n // Function entries in defaultVariants are computed defaults. They run in\n // the refine loop so they can react to setVariants updates.\n // Then filtered through disabled-variants.\n if (defaultVariants) {\n for (const name in defaultVariants) {\n if (!hasOwn(defaultVariants, name)) continue;\n const value = defaultVariants[name];\n if (typeof value === \"function\") {\n computedDefaultNames.push(name);\n computedDefaultFns.push(value as ComputedDefaultVariantFn);\n continue;\n }\n if (value === undefined) {\n delete staticDefaults[name];\n continue;\n }\n staticDefaults[name] = value;\n }\n }\n const computedDefaultCount = computedDefaultNames.length;\n if (hasAnyDisabled) {\n // Filter disabled variants in-place\n for (const key in staticDefaults) {\n if (!hasOwn(staticDefaults, key)) continue;\n if (disabledVariantKeys.has(key)) {\n delete staticDefaults[key];\n continue;\n }\n if (hasDisabledVariantValues) {\n const value = staticDefaults[key];\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n delete staticDefaults[key];\n }\n }\n }\n }\n\n const inheritedComputedDefaultKeys = new Set<string>();\n for (let i = 0; i < extCount; i++) {\n const keys = extMetas[i].computedDefaultKeys;\n for (const key of keys) {\n inheritedComputedDefaultKeys.add(key);\n }\n }\n\n // Filter to only extends with computed default or refine work in their\n // chain. Those are the components that can change resolved variants across\n // fixed-point iterations.\n const extMetasWithRefine: ComponentMeta[] = [];\n for (let i = 0; i < extCount; i++) {\n const meta = extMetas[i];\n if (meta.resolveRefine) {\n extMetasWithRefine.push(meta);\n }\n }\n const extMetasWithRefineCount = extMetasWithRefine.length;\n\n // Call-site frame captured at the `cv()` call site so refine-limit warnings\n // can point developers at the component definition. Skipped entirely for\n // components that can never enter the refine loop, and stripped in\n // production via the NODE_ENV guard inside `captureCreationFrame`. The\n // frame is captured at creation time but the underlying `.stack` string is\n // formatted lazily on first access, so component creation stays cheap\n // unless the warning actually fires.\n const canTriggerRefineWarning =\n !!refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0;\n const creationFrame =\n canTriggerRefineWarning && process.env.NODE_ENV !== \"production\"\n ? captureCreationFrame(cv)\n : undefined;\n\n // Function variant keys inherited from extends, filtered through this\n // component's own variants: a static (object/shorthand) variant in this\n // component replaces an inherited function variant for the same key.\n // The closure is exposed on `ComponentMeta` so any further extending\n // component can detect \"ancestor's effective variant for K is a function\"\n // and skip it when overriding K with a non-function.\n const functionVariantKeys = new Set<string>();\n for (let i = 0; i < extCount; i++) {\n const fnKeys = extMetas[i].functionVariantKeys;\n for (const k of fnKeys) {\n if (disabledVariantKeys.has(k)) continue;\n functionVariantKeys.add(k);\n }\n }\n for (let i = 0; i < functionVariantCount; i++) {\n functionVariantKeys.add(functionVariantNames[i]);\n }\n for (let i = 0; i < variantEntryCount; i++) {\n // A static variant in this component replaces an inherited function\n // variant for the same key; from this component onward, the key is no\n // longer a function variant.\n functionVariantKeys.delete(variantEntryNames[i]);\n }\n\n const computedDefaultKeys = new Set(inheritedComputedDefaultKeys);\n for (let i = 0; i < computedDefaultCount; i++) {\n computedDefaultKeys.add(computedDefaultNames[i]);\n }\n\n // Pre-compute static skip key/value sets to pass to extends. These never\n // change across calls — when caller passes no skip sets, we reuse the same\n // object and avoid Set allocation.\n let staticExtSkipKeys: Set<string> | null = null;\n if (hasDisabledVariantKeys || functionVariantCount > 0) {\n staticExtSkipKeys = new Set<string>();\n for (const k of disabledVariantKeys) {\n staticExtSkipKeys.add(k);\n }\n for (let i = 0; i < functionVariantCount; i++) {\n staticExtSkipKeys.add(functionVariantNames[i]);\n }\n }\n\n // A static variant in this component replaces an inherited function\n // variant, so the ancestor must skip that key.\n if (variantEntryCount > 0 && extCount > 0) {\n for (let i = 0; i < variantEntryCount; i++) {\n const name = variantEntryNames[i];\n for (let j = 0; j < extCount; j++) {\n if (extMetas[j].functionVariantKeys.has(name)) {\n staticExtSkipKeys ??= new Set<string>();\n staticExtSkipKeys.add(name);\n break;\n }\n }\n }\n }\n // Skip values are passed directly to extends. We can reuse the same object\n // when no caller-provided values need merging.\n const staticExtSkipValues: Record<string, Set<string>> | null =\n hasDisabledVariantValues ? disabledVariantValues : null;\n\n // Callers use this only when disabled keys or values exist.\n function filterDisabledInto(\n input: Record<string, unknown>,\n out: Record<string, unknown>,\n ): void {\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n if (disabledVariantKeys.has(key)) continue;\n const value = input[key];\n if (hasDisabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n continue;\n }\n }\n out[key] = value;\n }\n }\n\n const isOwnDisabledValue = (key: string, value: unknown): boolean => {\n if (disabledVariantKeys.has(key)) {\n return true;\n }\n if (hasDisabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n return true;\n }\n }\n return false;\n };\n\n const filterOwnDisabledVariants = (\n input: Record<string, unknown>,\n fallback: Record<string, unknown>,\n ): Record<string, unknown> => {\n if (!hasAnyDisabled) {\n return input;\n }\n\n let hasOwnDisabledValue = false;\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (isOwnDisabledValue(key, value)) {\n hasOwnDisabledValue = true;\n break;\n }\n }\n if (!hasOwnDisabledValue) {\n return input;\n }\n\n const filtered: Record<string, unknown> = {};\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (!isOwnDisabledValue(key, value)) {\n filtered[key] = value;\n continue;\n }\n const fallbackValue = fallback[key];\n if (\n fallbackValue !== undefined &&\n !isOwnDisabledValue(key, fallbackValue)\n ) {\n filtered[key] = fallbackValue;\n }\n }\n\n return filtered;\n };\n\n // Hot path: resolve variants by merging static defaults + extends'\n // static defaults + user-provided props.\n function resolveVariantsHot(\n propsVariants: Record<string, unknown>,\n ): Record<string, unknown> {\n // Start with static defaults\n const defaults = Object.assign({}, staticDefaults);\n\n // Apply propsVariants on top (filter undefined).\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (!hasOwn(propsVariants, k)) continue;\n const v = propsVariants[k];\n if (v === undefined) continue;\n defaults[k] = v;\n }\n\n if (!hasAnyDisabled) {\n return defaults;\n }\n\n // Filter disabled\n const result: Record<string, unknown> = {};\n filterDisabledInto(defaults, result);\n return result;\n }\n\n const runComputedDefaults = (\n resolved: Record<string, unknown>,\n defaultResolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants: boolean,\n protectedVariantKeys: Set<string> | null | undefined,\n ): Record<string, unknown> => {\n let ownVariants = filterOwnVariants ? null : resolved;\n const getOwnVariants = (): Record<string, unknown> => {\n if (ownVariants) {\n return ownVariants;\n }\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(resolved, key)) {\n filteredVariants[key] = resolved[key];\n }\n }\n ownVariants = filteredVariants;\n return filteredVariants;\n };\n\n let updatedVariants: Record<string, unknown> | null = null;\n const ensureUpdated = (): Record<string, unknown> => {\n if (updatedVariants) {\n return updatedVariants;\n }\n const updated = Object.assign({}, resolved);\n updatedVariants = updated;\n return updated;\n };\n\n for (let i = 0; i < computedDefaultCount; i++) {\n const key = computedDefaultNames[i];\n if (hasOwn(userVariantProps, key)) {\n if (userVariantProps[key] !== undefined) continue;\n }\n if (protectedVariantKeys?.has(key)) continue;\n\n const variantSnapshot = getOwnVariants();\n const defaultValue = inheritedComputedDefaultKeys.has(key)\n ? variantSnapshot[key]\n : defaultResolved[key];\n const value = computedDefaultFns[i](defaultValue, variantSnapshot);\n if (hasAnyDisabled) {\n if (disabledVariantKeys.has(key)) continue;\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n continue;\n }\n }\n\n if (value === undefined) {\n if (!hasOwn(variantSnapshot, key)) continue;\n delete ensureUpdated()[key];\n continue;\n }\n if (Object.is(variantSnapshot[key], value)) continue;\n ensureUpdated()[key] = value;\n }\n\n return updatedVariants ?? resolved;\n };\n\n const runRefineContext = (\n resolved: Record<string, unknown>,\n filterOwnVariants: boolean,\n collectOutput: boolean,\n applyVariantUpdates: boolean,\n protectedVariants: Record<string, unknown> | null | undefined,\n protectedVariantKeys: Set<string> | null | undefined,\n ): {\n workingResolved: Record<string, unknown>;\n classes: ClassValue[] | null;\n style: StyleValue | null;\n } => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n if (refine) {\n let ownVariants = resolved;\n if (filterOwnVariants) {\n // When this component is being extended, `resolved` is the parent's\n // workingResolved (a superset of our variant keys). Filter to our own\n // keys for `ctx.variants` so the user's `refine` callback sees the\n // shape declared by `VariantValues<V>` and not foreign parent keys.\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (hasOwn(resolved, k)) {\n filteredVariants[k] = resolved[k];\n }\n }\n ownVariants = filteredVariants;\n }\n // Lazy-init updatedVariants — many refine callbacks only inspect\n // `variants`, so the copy is unnecessary in the common case.\n let updatedVariants: Record<string, unknown> | null = null;\n const localCClasses: ClassValue[] | null = collectOutput ? [] : null;\n let localCStyle: StyleValue | null = null;\n const ensureUpdated = (): Record<string, unknown> => {\n if (updatedVariants) {\n return updatedVariants;\n }\n const u = Object.assign({}, ownVariants);\n updatedVariants = u;\n return u;\n };\n const protectVariant = (key: string, value: unknown) => {\n if (protectedVariants) {\n protectedVariants[key] = value;\n protectedVariantKeys?.add(key);\n }\n };\n const ctx = {\n variants: ownVariants as VariantValues<Record<string, unknown>>,\n setVariants: (\n newVariants: VariantValues<Record<string, unknown>>,\n ) => {\n if (!applyVariantUpdates) {\n return;\n }\n if (!hasAnyDisabled) {\n for (const key in newVariants) {\n if (!hasOwn(newVariants, key)) continue;\n const value = (newVariants as Record<string, unknown>)[key];\n protectVariant(key, value);\n if (Object.is((updatedVariants ?? ownVariants)[key], value)) {\n continue;\n }\n ensureUpdated()[key] = value;\n }\n return;\n }\n for (const key in newVariants) {\n if (!hasOwn(newVariants, key)) continue;\n if (disabledVariantKeys.has(key)) continue;\n const value = (newVariants as Record<string, unknown>)[key];\n if (hasDisabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n disabledVariantValues[key]?.has(valueKey)\n ) {\n continue;\n }\n }\n protectVariant(key, value);\n if (Object.is((updatedVariants ?? ownVariants)[key], value)) {\n continue;\n }\n ensureUpdated()[key] = value;\n }\n },\n addClass: (className: ClassValue) => {\n localCClasses?.push(className);\n },\n addStyle: (newStyle: StyleValue) => {\n if (!collectOutput) return;\n if (!localCStyle) {\n localCStyle = {};\n }\n Object.assign(localCStyle, newStyle);\n },\n };\n const result = refine(ctx);\n if (collectOutput && result != null) {\n const r = extractClassAndStylePrebuilt(result);\n if (r.class != null) {\n localCClasses?.push(r.class);\n }\n if (r.style) {\n if (!localCStyle) {\n localCStyle = {};\n }\n Object.assign(localCStyle, r.style);\n }\n }\n cClasses = localCClasses;\n cStyle = localCStyle;\n if (updatedVariants) {\n const nextResolved = Object.assign({}, workingResolved);\n if (hasAnyDisabled) {\n filterDisabledInto(updatedVariants, nextResolved);\n } else {\n Object.assign(nextResolved, updatedVariants);\n }\n workingResolved = nextResolved;\n }\n }\n\n return {\n workingResolved,\n classes: cClasses,\n style: cStyle,\n };\n };\n\n // Core compute path. Called both for top-level rendering (via\n // `computeResult`) and recursively when this component is used as an\n // `extend` target by another component. Pushes variant classes (excluding\n // base class) into `classesOut` and merges styles into `styleOut`.\n const computeOnce: ComputeOnceFn = (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved = resolved,\n renderOnly = false,\n ) => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n // Run extends' contributions first (their full classes + styles) so our\n // own base style and variants apply on top, matching the original\n // ext1 → ext2 → … → current ordering.\n if (hasExtend) {\n // Build skip sets to pass to extends. Reuse precomputed values when no\n // caller-provided sets need merging.\n let extSkipKeys: Set<string> | null;\n if (skipKeys === null) {\n extSkipKeys = staticExtSkipKeys;\n } else if (staticExtSkipKeys === null) {\n extSkipKeys = skipKeys;\n } else {\n extSkipKeys = new Set(skipKeys);\n for (const k of staticExtSkipKeys) {\n extSkipKeys.add(k);\n }\n }\n\n let extSkipVals: Record<string, Set<string>> | null;\n if (skipValues === null) {\n extSkipVals = staticExtSkipValues;\n } else if (staticExtSkipValues === null) {\n extSkipVals = skipValues;\n } else {\n extSkipVals = {};\n for (const k in skipValues) {\n extSkipVals[k] = skipValues[k];\n }\n for (const k in staticExtSkipValues) {\n const existing = extSkipVals[k];\n if (existing) {\n const merged = new Set<string>(existing);\n for (const v of staticExtSkipValues[k]) {\n merged.add(v);\n }\n extSkipVals[k] = merged;\n } else {\n extSkipVals[k] = staticExtSkipValues[k];\n }\n }\n }\n\n const extUserVariantProps =\n extMetasWithRefineCount > 0\n ? getExtUserVariantProps(\n userVariantProps,\n protectedVariants ?? null,\n )\n : userVariantProps;\n for (let i = 0; i < extCount; i++) {\n if (hasIsolatedExt && extIsolated[i]) {\n // Isolated extend (different factory): gather its variant classes\n // into a scratch array, then push the joined string after applying\n // its own transformClass. Our outer transform applies on top.\n const extClasses: ClsxClassValue[] = [];\n workingResolved = extMetas[i].compute(\n workingResolved,\n extUserVariantProps,\n extSkipKeys,\n extSkipVals,\n extClasses,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n renderOnly,\n );\n if (extClasses.length > 0) {\n const joined = clsx(extClasses);\n if (joined.length > 0) {\n classesOut.push(extMetas[i].transformClass(joined));\n }\n }\n } else {\n workingResolved = extMetas[i].compute(\n workingResolved,\n extUserVariantProps,\n extSkipKeys,\n extSkipVals,\n classesOut,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n renderOnly,\n );\n }\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n // Only sync protected variants when a child refine resolver can\n // observe them. Otherwise extUserVariantProps may alias caller props.\n if (protectedVariants && extMetasWithRefineCount > 0) {\n Object.assign(extUserVariantProps, protectedVariants);\n }\n }\n }\n\n // Run own computed defaults after extended components so defaults resolve\n // from base to child. They still run before this component's `refine`.\n if (!renderOnly && computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n true,\n protectedVariantKeys,\n );\n }\n\n // Run own `refine` (if any). May modify resolved variants and emit\n // classes and styles that are applied after this component's variants.\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n true,\n true,\n !renderOnly,\n protectedVariants,\n protectedVariantKeys,\n );\n workingResolved = refineResult.workingResolved;\n cClasses = refineResult.classes;\n cStyle = refineResult.style;\n }\n\n // Apply own base style (after extends' styles, matching original order).\n if (hasBaseStyle) {\n Object.assign(styleOut, baseStyle);\n }\n\n // Apply own variants. Skip keys/values come from caller (e.g., parent\n // wants its own function variant to override this variant).\n // `variantEntryNames` already excludes disabled keys (those with `null`\n // value in config) and function variants, so we don't re-check\n // `disabledVariantKeys` here.\n const ownSkipKeys = skipKeys;\n const ownSkipValues = skipValues;\n for (let i = 0; i < variantEntryCount; i++) {\n const variantName = variantEntryNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n const variant = variantEntryDefs[i];\n if (\n variant.disabledValues &&\n selectedKey != null &&\n variant.disabledValues.has(selectedKey)\n ) {\n continue;\n }\n if (\n ownSkipValues &&\n selectedKey != null &&\n ownSkipValues[variantName]?.has(selectedKey)\n ) {\n continue;\n }\n\n let value: PrebuiltValue | null | undefined;\n if (variant.values) {\n if (selectedKey == null) continue;\n value = variant.values[selectedKey];\n } else if (selectedValue === true) {\n value = variant.shorthand;\n }\n if (!value) continue;\n if (value.class != null) {\n classesOut.push(value.class);\n }\n if (value.style) {\n Object.assign(styleOut, value.style);\n }\n }\n\n // Apply function variants — entries in `variants` whose value is a\n // function. They run after static variants and override any same-key\n // inherited variant via `staticExtSkipKeys`.\n for (let i = 0; i < functionVariantCount; i++) {\n const variantName = functionVariantNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n if (\n ownSkipValues &&\n selectedKey != null &&\n ownSkipValues[variantName]?.has(selectedKey)\n ) {\n continue;\n }\n const fn = functionVariantFns[i];\n const computedResult = fn(selectedValue);\n if (computedResult == null) continue;\n const r = extractClassAndStylePrebuilt(computedResult);\n if (r.class != null) {\n classesOut.push(r.class);\n }\n if (r.style) {\n Object.assign(styleOut, r.style);\n }\n }\n\n // Apply `refine` results — must come after own variants (static and\n // function).\n if (cClasses) {\n for (let i = 0; i < cClasses.length; i++) {\n classesOut.push(cClasses[i] as ClsxClassValue);\n }\n }\n if (cStyle) {\n Object.assign(styleOut, cStyle);\n }\n\n return workingResolved;\n };\n\n const compute: ComputeFn =\n !refine && computedDefaultCount === 0 && extMetasWithRefineCount === 0\n ? computeOnce\n : (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n ) => {\n let remaining = MAX_REFINE_RUNS;\n const protectedVariants: Record<string, unknown> = {};\n const protectedVariantKeys = new Set<string>();\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. Lazy-init keeps convergent loops allocation-free.\n let unstableChanges: Map<string, VariantChange> | null = null;\n let lastClasses: ClsxClassValue[] = [];\n let lastStyle: StyleValue = {};\n let isFirstRun = true;\n\n while (remaining > 0) {\n remaining -= 1;\n const useDirectOutput = isFirstRun;\n const classCount = classesOut.length;\n const nextClasses: ClsxClassValue[] = useDirectOutput\n ? classesOut\n : [];\n const nextStyle: StyleValue = useDirectOutput ? styleOut : {};\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protectedVariants,\n protectedVariantKeys,\n );\n const nextResolved = computeOnce(\n workingResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n nextClasses,\n nextStyle,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n );\n\n if (\n nextResolved === workingResolved ||\n areVariantsEqual(workingResolved, nextResolved)\n ) {\n if (nextResolved !== workingResolved) {\n if (useDirectOutput) {\n classesOut.length = classCount;\n for (const key in styleOut) {\n if (hasOwn(styleOut, key)) {\n Reflect.deleteProperty(styleOut, key);\n }\n }\n }\n computeOnce(\n nextResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n true,\n );\n } else if (!useDirectOutput) {\n for (let i = 0; i < nextClasses.length; i++) {\n classesOut.push(nextClasses[i]);\n }\n Object.assign(styleOut, nextStyle);\n }\n return nextResolved;\n }\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n\n if (useDirectOutput) {\n classesOut.length = classCount;\n for (const key in styleOut) {\n if (hasOwn(styleOut, key)) {\n Reflect.deleteProperty(styleOut, key);\n }\n }\n } else {\n lastClasses = nextClasses;\n lastStyle = nextStyle;\n }\n\n workingResolved = nextResolved;\n isFirstRun = false;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n for (let i = 0; i < lastClasses.length; i++) {\n classesOut.push(lastClasses[i]);\n }\n Object.assign(styleOut, lastStyle);\n return workingResolved;\n };\n\n const resolveRefineOnce: ResolveRefineOnceFn = (\n resolved,\n userVariantProps,\n filterOwnVariants = true,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved = resolved,\n ) => {\n let workingResolved = resolved;\n\n if (extMetasWithRefineCount > 0) {\n const extUserVariantProps = getExtUserVariantProps(\n userVariantProps,\n protectedVariants ?? null,\n );\n for (let i = 0; i < extMetasWithRefineCount; i++) {\n const meta = extMetasWithRefine[i];\n const resolveRefine = meta.resolveRefine;\n if (!resolveRefine) continue;\n workingResolved = resolveRefine(\n workingResolved,\n extUserVariantProps,\n true,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n );\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n if (protectedVariants) {\n Object.assign(extUserVariantProps, protectedVariants);\n }\n }\n }\n\n if (computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n filterOwnVariants,\n protectedVariantKeys,\n );\n }\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n filterOwnVariants,\n false,\n true,\n protectedVariants,\n protectedVariantKeys,\n );\n workingResolved = refineResult.workingResolved;\n }\n\n return workingResolved;\n };\n\n const resolveRefine: ResolveRefineFn | null =\n refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0\n ? (resolved, userVariantProps, filterOwnVariants = true) => {\n let remaining = MAX_REFINE_RUNS;\n const protectedVariants: Record<string, unknown> = {};\n const protectedVariantKeys = new Set<string>();\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. See the compute loop above for the shared\n // rationale.\n let unstableChanges: Map<string, VariantChange> | null = null;\n\n while (remaining > 0) {\n remaining -= 1;\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protectedVariants,\n protectedVariantKeys,\n );\n const nextResolved = resolveRefineOnce(\n workingResolved,\n userVariantProps,\n filterOwnVariants,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n );\n\n if (\n nextResolved === workingResolved ||\n areVariantsEqual(workingResolved, nextResolved)\n ) {\n return nextResolved;\n }\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n workingResolved = nextResolved;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n return workingResolved;\n }\n : null;\n\n // Top-level: resolves variants from user props, calls compute, then\n // assembles className and style with user-provided class/style overrides.\n const computeResult = (\n props: ComponentProps<MergedVariants> = EMPTY_DEFAULTS as ComponentProps<MergedVariants>,\n ): { className: string; style: StyleValue } => {\n const propsRecord = props as Record<string, unknown>;\n\n let resolved: Record<string, unknown> = {};\n Object.assign(resolved, staticDefaults);\n\n let userVariantProps: Record<string, unknown>;\n if (refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0) {\n const variantProps: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(propsRecord, key)) {\n variantProps[key] = propsRecord[key];\n }\n }\n for (const k in variantProps) {\n if (!hasOwn(variantProps, k)) continue;\n const v = variantProps[k];\n if (v === undefined) continue;\n resolved[k] = v;\n }\n userVariantProps = variantProps;\n } else {\n // Fast path: walk variantKeys directly against propsRecord.\n // Own-property checks ensure a polluted Object.prototype can't add\n // values the user didn't pass.\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (!hasOwn(propsRecord, key)) continue;\n const v = propsRecord[key];\n if (v === undefined) continue;\n resolved[key] = v;\n }\n userVariantProps = propsRecord;\n }\n\n if (hasAnyDisabled) {\n const filtered: Record<string, unknown> = {};\n filterDisabledInto(resolved, filtered);\n resolved = filtered;\n }\n\n // Build allClasses directly. computedBaseClass already has all extend\n // bases joined with config.class — `compute` only adds variant classes\n // on top.\n const allClasses: ClsxClassValue[] = [computedBaseClass];\n const style: StyleValue = {};\n compute(resolved, userVariantProps, null, null, allClasses, style);\n\n // Apply user-provided class / className.\n if (\"class\" in propsRecord) {\n allClasses.push(propsRecord.class as ClsxClassValue);\n }\n if (\"className\" in propsRecord) {\n allClasses.push(propsRecord.className as ClsxClassValue);\n }\n\n // Apply user-provided style.\n const psv = propsRecord.style;\n if (psv != null) {\n if (typeof psv === \"string\") {\n if (psv.length > 0) {\n htmlStyleToStyleValue(psv, style);\n }\n } else if (typeof psv === \"object\") {\n htmlObjStyleToStyleValue(psv, style);\n }\n }\n\n return {\n className: transformClass(clsx(allClasses)),\n style,\n };\n };\n\n const getVariants = (variants?: VariantValues<MergedVariants>) => {\n const variantsRecord = variants ?? EMPTY_DEFAULTS;\n let variantProps = variantsRecord;\n // Extended refinement copies user props, so filter before unknown\n // accessors or prototype keys can be observed by Object.assign.\n if (variants && extMetasWithRefineCount > 0) {\n variantProps = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(variantsRecord, key)) {\n variantProps[key] = variantsRecord[key];\n }\n }\n }\n let resolvedVariants = resolveVariantsHot(variantProps);\n if (resolveRefine) {\n resolvedVariants = resolveRefine(resolvedVariants, variantProps, false);\n }\n return resolvedVariants as VariantValues<MergedVariants>;\n };\n\n // Compute base class (without variants) — includes extended base classes.\n // Plain `clsx` (no `transformClass`): `meta.baseClass` flows back into\n // parent extends as `clsx` input and then through the single\n // `transformClass(clsx(allClasses))` at render time, so applying it here\n // would compound (double for own-render, triple+ for extend chains) and\n // misbehave for non-idempotent transforms.\n const computedBaseClass = hasExtend\n ? clsx(extBaseClassesArr, config.class as ClsxClassValue)\n : clsx(config.class as ClsxClassValue);\n\n // Shared closures across the default and modal components.\n const classFn = (props: ComponentProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n const meta: ComponentMeta = {\n baseClass: computedBaseClass,\n staticDefaults,\n compute: computeOnce,\n resolveRefine: resolveRefine ? resolveRefineOnce : null,\n transformClass,\n functionVariantKeys,\n computedDefaultKeys,\n };\n\n const initComponent = <\n R extends ComponentResult,\n T extends ModalComponent<MergedVariants, R>,\n >(\n c: T,\n propKeys: string[],\n style: T[\"style\"],\n ): T => {\n c.class = classFn;\n c.style = style;\n c.getVariants = getVariants;\n c.variantKeys = variantKeys;\n c.propKeys = propKeys;\n (c as AnyComponent & ComponentWithMeta)[META_KEY] = meta;\n return c;\n };\n\n // Default component\n const defaultComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style };\n }) as CVComponent<V, E>;\n initComponent(defaultComponent, inputPropsKeys, (props = {}) => {\n return computeResult(props).style;\n });\n\n // JSX component\n const jsxComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { className, style };\n }) as ModalComponent<MergedVariants, JSXProps>;\n initComponent(\n jsxComponent,\n [\"className\", \"style\", ...variantKeys],\n (props = {}) => computeResult(props).style,\n );\n\n // HTML component\n const htmlComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style: styleValueToHTMLStyle(style) };\n }) as ModalComponent<MergedVariants, HTMLProps>;\n initComponent(\n htmlComponent,\n [\"class\", \"style\", ...variantKeys],\n (props = {}) => styleValueToHTMLStyle(computeResult(props).style),\n );\n\n // HTMLObj component\n const htmlObjComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style: styleValueToHTMLObjStyle(style) };\n }) as ModalComponent<MergedVariants, HTMLObjProps>;\n initComponent(\n htmlObjComponent,\n [\"class\", \"style\", ...variantKeys],\n (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style),\n );\n\n defaultComponent.jsx = jsxComponent;\n defaultComponent.html = htmlComponent;\n defaultComponent.htmlObj = htmlObjComponent;\n\n return defaultComponent;\n };\n\n return { cv, cx };\n}\n\nexport const cv = /* @__PURE__ */ (() => create().cv)();\n\n/**\n * Joins class values without applying a class transform.\n *\n * This behaves like the `cx` function returned by `create()` with no options.\n */\nexport function cx(...classes: ClsxClassValue[]) {\n return clsx(classes);\n}\n"],"mappings":";;AAEA,MAAa,SAAS,OAAO;AAI7B,MAAM,2CAA2B,IAAI,IAAI;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,iBAAiB,UAAkB;CAC1C,OAAO,SAAS,WAAW,CAAC,MAAM,MAAM,SAAS,WAAW,CAAC,MAAM;AACrE;AASA,SAAgB,cAAc,KAAa;CAEzC,IAAI,iBAAiB,GAAG,GACtB,OAAO;CAGT,IAAI,cAAc,IAAI,QAAQ,GAAG;CACjC,IAAI,gBAAgB,IAClB,OAAO;CAGT,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,OAAO,gBAAgB,IAAI;EACzB,UAAU,IAAI,MAAM,WAAW,WAAW;EAE1C,MAAM,YAAY,cAAc;EAChC,IAAI,aAAa,IAAI,QAAQ;GAC3B,UAAU;GACV,YAAY;GACZ;EACF;EAEA,MAAM,OAAO,IAAI,WAAW,SAAS;EAGrC,IADG,QAAQ,MAAM,QAAQ,MAAQ,QAAQ,MAAM,QAAQ,KACpC;GACjB,MAAM,oBAAoB,gBAAgB,KAAK,IAAI,WAAW,OAAO,CAAC;GACtE,UAAU,oBACN,IAAI,aACJ,IAAI,UAAU,CAAC,YAAY;GAC/B,YAAY,YAAY;EAC1B,OAAO;GACL,UAAU;GACV,YAAY;EACd;EAEA,cAAc,IAAI,QAAQ,KAAK,SAAS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C,QAAQ,CAAC,MAAM,cAAc,KAAK,CAAC,CAAC,KACvC;EAGA,MAAM,kBAAkB,QAAwC,CAAC,MAAM;GACrE,MAAM,EAAE,WAAW,UAAU,cAAc,KAAK;GAChD,OAAO;IAAE,OAAO;IAAW,OAAO,sBAAsB,KAAK;GAAE;EACjE;EACA,cACE,eACA;GAAC;GAAS;GAAS,GAAG;EAAW,IAChC,QAAQ,CAAC,MAAM,sBAAsB,cAAc,KAAK,CAAC,CAAC,KAAK,CAClE;EAGA,MAAM,qBAAqB,QAAwC,CAAC,MAAM;GACxE,MAAM,EAAE,WAAW,UAAU,cAAc,KAAK;GAChD,OAAO;IAAE,OAAO;IAAW,OAAO,yBAAyB,KAAK;GAAE;EACpE;EACA,cACE,kBACA;GAAC;GAAS;GAAS,GAAG;EAAW,IAChC,QAAQ,CAAC,MAAM,yBAAyB,cAAc,KAAK,CAAC,CAAC,KAAK,CACrE;EAEA,iBAAiB,MAAM;EACvB,iBAAiB,OAAO;EACxB,iBAAiB,UAAU;EAE3B,OAAO;CACT;CAEA,OAAO;EAAE;EAAI;CAAG;AAClB;AAEA,MAAa,KAAqB,uBAAO,OAAO,CAAC,CAAC,GAAA,CAAI;AAOtD,SAAgB,GAAG,GAAG,SAA2B;CAC/C,OAAO,KAAK,OAAO;AACrB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/utils.ts","../src/refine-warning.ts","../src/index.ts"],"sourcesContent":["import type { HTMLCSSProperties, StyleValue } from \"./types.ts\";\n\nexport const hasOwn = Object.hasOwn;\n\n// Keep this explicit so normalization does not depend on browser globals.\n// Vendor-prefixed variants are derived below instead of duplicating the list.\nconst unitlessNumberProperties = new Set([\n \"animationIterationCount\",\n \"aspectRatio\",\n \"borderImage\",\n \"borderImageOutset\",\n \"borderImageSlice\",\n \"borderImageWidth\",\n \"boxFlex\",\n \"boxFlexGroup\",\n \"boxOrdinalGroup\",\n \"columnCount\",\n \"columns\",\n \"fillOpacity\",\n \"flex\",\n \"flexGrow\",\n \"flexNegative\",\n \"flexOrder\",\n \"flexPositive\",\n \"flexShrink\",\n \"floodOpacity\",\n \"fontSizeAdjust\",\n \"fontWeight\",\n \"gridArea\",\n \"gridColumn\",\n \"gridColumnEnd\",\n \"gridColumnSpan\",\n \"gridColumnStart\",\n \"gridRow\",\n \"gridRowEnd\",\n \"gridRowSpan\",\n \"gridRowStart\",\n \"hyphenateLimitChars\",\n \"initialLetter\",\n \"lineClamp\",\n \"lineHeight\",\n \"maskBorder\",\n \"maskBorderOutset\",\n \"maskBorderSlice\",\n \"maskBorderWidth\",\n \"mathDepth\",\n \"maxLines\",\n \"opacity\",\n \"order\",\n \"orphans\",\n \"scale\",\n \"shapeImageThreshold\",\n \"stopOpacity\",\n \"strokeDasharray\",\n \"strokeDashoffset\",\n \"strokeMiterlimit\",\n \"strokeOpacity\",\n \"strokeWidth\",\n \"tabSize\",\n \"widows\",\n \"zIndex\",\n \"zoom\",\n]);\n\nfunction isCustomProperty(property: string) {\n return property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45;\n}\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"-ms-transition\") // \"msTransition\" (lowercase \"ms\" prefix)\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n // Fast path: no hyphen -> return as-is\n let hyphenIndex = str.indexOf(\"-\");\n if (hyphenIndex === -1) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n while (hyphenIndex !== -1) {\n result += str.slice(lastIndex, hyphenIndex);\n\n const nextIndex = hyphenIndex + 1;\n if (nextIndex >= str.length) {\n result += \"-\";\n lastIndex = nextIndex;\n break;\n }\n\n const code = str.charCodeAt(nextIndex);\n const isAsciiLetter =\n (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n if (isAsciiLetter) {\n const isMicrosoftPrefix = hyphenIndex === 0 && str.startsWith(\"ms-\", 1);\n result += isMicrosoftPrefix\n ? str[nextIndex]\n : str[nextIndex].toUpperCase();\n lastIndex = nextIndex + 1;\n } else {\n result += \"-\";\n lastIndex = nextIndex;\n }\n\n hyphenIndex = str.indexOf(\"-\", lastIndex);\n }\n\n return result + str.slice(lastIndex);\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"msTransition\") // \"-ms-transition\" (lowercase \"ms\" prefix)\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n if (code < 65 || code > 90) continue;\n const isMicrosoftPrefix = i === 2 && str.startsWith(\"ms\");\n if (isMicrosoftPrefix) {\n result += \"-\";\n }\n result += str.slice(lastIndex, i);\n result += \"-\";\n result += str[i].toLowerCase();\n lastIndex = i + 1;\n }\n\n if (lastIndex === 0) {\n return str;\n }\n return result + str.slice(lastIndex);\n}\n\nfunction hasVendorPrefix(property: string, prefix: string) {\n const nextCode = property.charCodeAt(prefix.length);\n if (nextCode < 65 || nextCode > 90) return false;\n return property.startsWith(prefix);\n}\n\n// \"ms\" is used in JSX, while camelizing hyphenated properties produces \"Ms\".\nconst vendorPrefixes = [\"Webkit\", \"Moz\", \"ms\", \"Ms\", \"O\"];\n\nfunction isUnitlessNumberProperty(property: string) {\n if (unitlessNumberProperties.has(property)) return true;\n\n for (const prefix of vendorPrefixes) {\n if (!hasVendorPrefix(property, prefix)) continue;\n const firstCode = property.charCodeAt(prefix.length);\n const unprefixedProperty =\n String.fromCharCode(firstCode + 32) + property.slice(prefix.length + 1);\n return unitlessNumberProperties.has(unprefixedProperty);\n }\n return false;\n}\n\nfunction normalizeStyleValue(property: string, value: string | number) {\n if (typeof value === \"string\") {\n return value;\n }\n if (isCustomProperty(property)) {\n return value;\n }\n if (isUnitlessNumberProperty(property)) {\n return value;\n }\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(\n styleString: string,\n result: StyleValue = {},\n) {\n if (!styleString) return result;\n const len = styleString.length;\n let i = 0;\n while (i < len) {\n // Skip leading whitespace and stray semicolons\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13 && c !== 59) break;\n i++;\n }\n if (i >= len) break;\n // Read property name until ':' or ';'\n const propStart = i;\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c === 58 || c === 59) break;\n i++;\n }\n if (i >= len || styleString.charCodeAt(i) === 59) {\n // No colon found - skip this declaration\n if (i < len) {\n // Skip ';'.\n i++;\n }\n continue;\n }\n let propEnd = i;\n // Trim trailing whitespace from property name\n while (propEnd > propStart) {\n const c = styleString.charCodeAt(propEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n propEnd--;\n }\n if (propEnd === propStart) {\n // Empty property - skip\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n if (i < len) {\n i++;\n }\n continue;\n }\n const property = styleString.slice(propStart, propEnd);\n // Skip ':'.\n i++;\n // Skip whitespace before value\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n i++;\n }\n const valStart = i;\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n let valEnd = i;\n while (valEnd > valStart) {\n const c = styleString.charCodeAt(valEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n valEnd--;\n }\n if (i < len) {\n // Skip ';'.\n i++;\n }\n if (valEnd === valStart) continue;\n const value = styleString.slice(valStart, valEnd);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(property)] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(\n style: object,\n result: StyleValue = {},\n): StyleValue {\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n const property = hyphenToCamel(key);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string | number>)[property] = normalizeStyleValue(\n property,\n value as string | number,\n );\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n let result = \"\";\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n if (result) {\n result += \"; \";\n }\n result += camelToHyphen(key);\n result += \": \";\n result += value as string | number;\n }\n if (!result) return \"\";\n return `${result};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: HTMLCSSProperties = {};\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n (result as Record<string, unknown>)[camelToHyphen(key)] = value;\n }\n return result;\n}\n","import { hasOwn } from \"./utils.ts\";\n\nexport interface CreationFrame {\n stack?: string;\n}\n\nexport interface VariantChange {\n from: unknown;\n to: unknown;\n}\n\n// Once a refine loop is within this many iterations of the cap, start tracking\n// the latest value transition for every variant key that changes between\n// iterations so the warning can report every key that contributed to the\n// oscillation, not just the keys that happened to flip on the final step.\n// Convergent loops (the common case) exit well before this threshold and pay no\n// per-iteration tracking cost.\nexport const REFINE_UNSTABLE_TRACKING_WINDOW = 10;\n\n// Captures the call site of the function passed in `skipFn` so refine-limit\n// warnings can point developers at the originating `cv()` call. Returns\n// `undefined` in production so bundlers that replace `process.env.NODE_ENV` at\n// build time can drop the entire warning machinery. The underlying `.stack`\n// string is formatted lazily on first access in every major engine (V8,\n// SpiderMonkey, JavaScriptCore), so holding the captured frame for the\n// lifetime of the component is cheap when no warning fires.\nexport function captureCreationFrame(\n skipFn: Function,\n): CreationFrame | undefined {\n if (process.env.NODE_ENV === \"production\") return undefined;\n if (typeof Error.captureStackTrace === \"function\") {\n const holder: CreationFrame = {};\n Error.captureStackTrace(holder, skipFn);\n return holder;\n }\n // Engines without `Error.captureStackTrace` (SpiderMonkey, JavaScriptCore)\n // can't strip internal frames, but their `Error.stack` getter is still\n // lazy, so returning the Error instance defers the format cost. The\n // resulting trace includes 1–2 extra frames at the top from this helper and\n // `cv` itself.\n return new Error();\n}\n\nexport function formatCreationStack(frame: CreationFrame): string | undefined {\n let stack = frame.stack;\n if (!stack) return undefined;\n // V8 prefixes the stack with a leading \"Error\" / \"Error: message\" line that\n // isn't meaningful for a captured location — drop it.\n const newlineIdx = stack.indexOf(\"\\n\");\n if (newlineIdx > 0) {\n const firstLine = stack.slice(0, newlineIdx);\n if (firstLine === \"Error\" || firstLine.startsWith(\"Error:\")) {\n stack = stack.slice(newlineIdx + 1);\n }\n }\n const frames = stack.split(\"\\n\");\n for (let i = 0; i < frames.length; i++) {\n const line = frames[i]?.trim();\n if (!line) continue;\n if (isInternalCreationFrame(line)) continue;\n if (line.includes(\"/node_modules/\")) continue;\n if (line.includes(\"\\\\node_modules\\\\\")) continue;\n if (line.includes(\"node:internal\")) continue;\n return ` ${line}`;\n }\n return undefined;\n}\n\nfunction isInternalCreationFrame(line: string): boolean {\n if (line.includes(\"captureCreationFrame\")) return true;\n if (line.startsWith(\"at cv \")) return true;\n if (line.startsWith(\"at cv(\")) return true;\n if (line.startsWith(\"cv@\")) return true;\n return false;\n}\n\nfunction formatVariantValue(value: unknown): string {\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return \"NaN\";\n return String(value);\n }\n if (typeof value === \"bigint\") return `${value}n`;\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (typeof value === \"boolean\") return String(value);\n if (typeof value === \"symbol\") return String(value);\n if (typeof value === \"function\") return \"[function]\";\n return \"[object]\";\n}\n\nfunction setVariantChange(\n into: Map<string, VariantChange>,\n key: string,\n from: unknown,\n to: unknown,\n): void {\n into.set(key, { from, to });\n}\n\nexport function accumulateUnstableVariantChanges(\n into: Map<string, VariantChange>,\n prev: Record<string, unknown>,\n next: Record<string, unknown>,\n): void {\n for (const key in next) {\n if (!hasOwn(next, key)) continue;\n if (!Object.is(prev[key], next[key])) {\n setVariantChange(into, key, prev[key], next[key]);\n }\n }\n for (const key in prev) {\n if (!hasOwn(prev, key)) continue;\n if (hasOwn(next, key)) continue;\n setVariantChange(into, key, prev[key], undefined);\n }\n}\n\nfunction formatVariantChanges(changes: Map<string, VariantChange>): string {\n return Array.from(changes)\n .map(([key, { from, to }]) => {\n return `${key}: ${formatVariantValue(from)} -> ${formatVariantValue(to)}`;\n })\n .join(\", \");\n}\n\ninterface WarnRefineLimitParams {\n creationFrame: CreationFrame | undefined;\n unstableChanges: Map<string, VariantChange> | null;\n}\n\nexport function warnRefineLimit({\n creationFrame,\n unstableChanges,\n}: WarnRefineLimitParams): void {\n // Bundlers are expected to replace this branch with a production literal,\n // allowing warning-only code below to be removed from consumer bundles.\n if (process.env.NODE_ENV === \"production\") return;\n let message =\n \"Clava: Maximum refine iterations exceeded. This can happen when a \" +\n \"computed default variant or refine callback changes one of the \" +\n \"variants on every run.\";\n if (unstableChanges && unstableChanges.size > 0) {\n message += `\\nVariant(s) that did not stabilize: ${Array.from(unstableChanges.keys()).join(\", \")}.`;\n message += `\\nLatest variant changes before warning: ${formatVariantChanges(unstableChanges)}.`;\n }\n if (creationFrame) {\n const creationStack = formatCreationStack(creationFrame);\n if (creationStack) {\n message += `\\nComponent created at:\\n${creationStack}`;\n }\n }\n console.warn(message);\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\nimport {\n REFINE_UNSTABLE_TRACKING_WINDOW,\n type VariantChange,\n accumulateUnstableVariantChanges,\n captureCreationFrame,\n warnRefineLimit,\n} from \"./refine-warning.ts\";\nimport type {\n AnyComponent,\n CVComponent,\n ClassValue,\n ComponentProps,\n ComponentResult,\n DefaultVariants,\n ExtendableVariants,\n HTMLObjProps,\n HTMLProps,\n JSXProps,\n KeySourceComponent,\n MergeVariants,\n ModalComponent,\n Refine,\n SplitPropsFunction,\n StyleClassProps,\n StyleClassValue,\n StyleValue,\n VariantValues,\n Variants,\n} from \"./types.ts\";\nimport {\n hasOwn,\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n} from \"./utils.ts\";\n\n// Internal compute path: pushes the variant classes contributed by this\n// component (and its extends chain) into `classesOut` and merges any styles\n// into `styleOut`. Base class is handled by callers via ComponentMeta.baseClass\n// to avoid string-parsing round trips. Both outputs are mutated in place to\n// avoid intermediate allocations.\ntype ComputeFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n) => Record<string, unknown>;\n\ntype ComputeOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n protectedVariants?: Record<string, unknown> | null,\n protectedVariantKeys?: Set<string> | null,\n defaultResolved?: Record<string, unknown>,\n renderOnly?: boolean,\n) => Record<string, unknown>;\n\ntype ResolveRefineFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n) => Record<string, unknown>;\n\ntype ResolveRefineOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n protectedVariants?: Record<string, unknown> | null,\n protectedVariantKeys?: Set<string> | null,\n defaultResolved?: Record<string, unknown>,\n) => Record<string, unknown>;\n\ntype ComputedDefaultVariantFn = (\n defaultValue: unknown,\n variants: Readonly<Record<string, unknown>>,\n) => unknown;\n\n// Internal metadata stored on components but hidden from public types.\ninterface ComponentMeta {\n baseClass: string;\n staticDefaults: Record<string, unknown>;\n // Performs a single compute pass for extending components, returning the\n // resolved variants while pushing classes and styles into the output values.\n compute: ComputeOnceFn;\n resolveRefine: ResolveRefineOnceFn | null;\n // Reference identity is used to detect mixed-factory `extend`. When a\n // component is extended by a parent from a different `create()` call, the\n // parent applies this transform to the extend's contribution before joining,\n // preserving each factory's transform boundary.\n transformClass: (className: string) => string;\n // Variant keys whose effective definition in this component's chain is a\n // function. An extending component that supplies a non-function variant for\n // the same key uses this to tell us to skip that key (matching the\n // type-level \"function variant is replaced by anything in the child\" rule).\n // Empty when no key in this chain is a function variant.\n functionVariantKeys: Set<string>;\n // Variant keys with computed defaults anywhere in this component's chain.\n // Child components use this to preserve inherited computed defaults through\n // `defaultValue` without preserving their own prior computed result.\n computedDefaultKeys: Set<string>;\n}\n\nconst META_KEY = \"__meta\";\n\ninterface ComponentWithMeta {\n [META_KEY]?: ComponentMeta;\n}\n\nconst EMPTY_DEFAULTS: Record<string, unknown> = {};\n\nconst MAX_REFINE_RUNS = 50;\n\nfunction areVariantsEqual(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n): boolean {\n for (const key in a) {\n if (!hasOwn(a, key)) continue;\n if (!Object.is(a[key], b[key])) return false;\n }\n for (const key in b) {\n if (!hasOwn(b, key)) continue;\n if (!hasOwn(a, key)) return false;\n }\n return true;\n}\n\nfunction getExtUserVariantProps(\n userVariantProps: Record<string, unknown>,\n protectedVariants: Record<string, unknown> | null,\n): Record<string, unknown> {\n return Object.assign({}, userVariantProps, protectedVariants);\n}\n\nfunction mergeProtectedIntoBase(\n baseResolved: Record<string, unknown>,\n protectedVariants: Record<string, unknown>,\n protectedVariantKeys: Set<string>,\n): Record<string, unknown> {\n if (protectedVariantKeys.size === 0) return baseResolved;\n return Object.assign({}, baseResolved, protectedVariants);\n}\n\nexport type {\n ClassValue,\n StyleValue,\n StyleClassProps,\n StyleClassValue,\n JSXProps,\n HTMLProps,\n HTMLObjProps,\n CVComponent,\n};\n\n/**\n * Extracts the variant props inferred for a Clava component. Use it to add a\n * component's variant props to framework component props.\n *\n * @example\n * ```ts\n * import { type VariantProps, cv } from \"clava\";\n * import type { ComponentProps } from \"react\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * disabled: { true: \"button-disabled\", false: \"\" },\n * },\n * });\n *\n * interface ButtonProps\n * extends ComponentProps<\"button\">,\n * VariantProps<typeof button> {}\n *\n * const props: ButtonProps = {\n * size: \"lg\",\n * disabled: true,\n * };\n * ```\n */\nexport type VariantProps<T extends Pick<AnyComponent, \"getVariants\">> =\n ReturnType<T[\"getVariants\"]>;\n\n// Variant props expose booleans, but variant object keys are always strings.\ntype VariantKey<T> = T extends boolean ? \"true\" | \"false\" : Extract<T, string>;\n\n/**\n * Constrains a variant map to the same value keys as a variant on another\n * component. Boolean variants are represented with `\"true\"` and `\"false\"`\n * object keys.\n *\n * @example\n * ```ts\n * import { type Variant, cv } from \"clava\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * },\n * });\n *\n * const icon = cv({\n * extend: [button],\n * variants: {\n * size: {\n * sm: \"icon-sm\",\n * lg: \"icon-lg\",\n * } satisfies Variant<typeof button, \"size\">,\n * },\n * });\n * ```\n */\nexport type Variant<\n T extends Pick<AnyComponent, \"getVariants\">,\n K extends keyof VariantProps<T>,\n> = Record<\n VariantKey<NonNullable<VariantProps<T>[K]>>,\n ClassValue | StyleClassValue\n>;\n\n/**\n * The configuration object accepted by `cv()`. It defines base class/style\n * output, variants, default variants, component extensions, and refinement\n * logic.\n *\n * @example\n * ```ts\n * import { type CVConfig, cv } from \"clava\";\n *\n * const config: CVConfig<{\n * tone: { info: string; danger: string };\n * }> = {\n * variants: {\n * tone: {\n * info: \"alert-info\",\n * danger: \"alert-danger\",\n * },\n * },\n * defaultVariants: {\n * tone: \"info\",\n * },\n * };\n *\n * const alert = cv(config);\n * ```\n */\nexport interface CVConfig<\n V extends Variants = {},\n E extends AnyComponent[] = [],\n> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n defaultVariants?: DefaultVariants<MergeVariants<V, E>>;\n refine?: Refine<MergeVariants<V, E>>;\n}\n\ninterface CreateParams {\n transformClass?: (className: string) => string;\n}\n\nfunction isRecordObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a normalized\n * StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n return htmlObjStyleToStyleValue(style);\n }\n return {};\n}\n\n/**\n * Pre-extracts the class and (normalized) style from a variant value once at\n * component creation time. Returns `null` if the value contributes nothing.\n */\ninterface PrebuiltValue {\n class: ClassValue;\n style: StyleValue | null;\n}\n\nfunction extractClassAndStylePrebuilt(value: unknown): PrebuiltValue {\n if (!isRecordObject(value)) {\n return { class: value as ClassValue, style: null };\n }\n if (!(\"style\" in value || \"class\" in value)) {\n return { class: null, style: null };\n }\n const styleClassValue = value as StyleClassValue;\n const style = normalizeStyle(styleClassValue.style);\n return {\n class: styleClassValue.class ?? null,\n style: Object.keys(style).length > 0 ? style : null,\n };\n}\n\nfunction getVariantValueKey(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\") {\n return String(value);\n }\n if (typeof value === \"boolean\") {\n return String(value);\n }\n return undefined;\n}\n\nconst EMPTY_KEYS: readonly string[] = [];\n\nfunction isComponentKeySource(source: unknown): source is KeySourceComponent {\n if (!source) return false;\n if (typeof source !== \"object\" && typeof source !== \"function\") {\n return false;\n }\n const typed = source as Record<string, unknown>;\n if (typeof typed.getVariants !== \"function\") return false;\n if (!Array.isArray(typed.propKeys)) return false;\n return Array.isArray(typed.variantKeys);\n}\n\n/**\n * Splits props into multiple groups based on key sources. Only the first\n * component claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays always receive their listed keys but don't\n * claim styling props.\n */\nfunction splitPropsImpl(\n selfKeys: readonly string[],\n selfIsComponent: boolean,\n props: Record<string, unknown>,\n sources: unknown[],\n): Record<string, unknown>[] {\n const sourcesLength = sources.length;\n const results: Record<string, unknown>[] = [];\n let stylingClaimed = selfIsComponent;\n\n const selfResult: Record<string, unknown> = {};\n const selfKeysLength = selfKeys.length;\n for (let i = 0; i < selfKeysLength; i++) {\n const key = selfKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n\n // Track effective key arrays for the rest computation — for typical inputs\n // a linear scan beats building a Set up-front.\n const effectiveKeyArrays: Array<readonly string[]> = [selfKeys];\n\n for (let s = 0; s < sourcesLength; s++) {\n const source = sources[s];\n const sourceResult: Record<string, unknown> = {};\n let sourceIsComponent = false;\n let effectiveKeys: readonly string[];\n if (Array.isArray(source)) {\n effectiveKeys = source;\n } else if (isComponentKeySource(source)) {\n sourceIsComponent = true;\n effectiveKeys = stylingClaimed ? source.variantKeys : source.propKeys;\n } else {\n effectiveKeys = EMPTY_KEYS;\n }\n\n const effectiveKeysLength = effectiveKeys.length;\n for (let i = 0; i < effectiveKeysLength; i++) {\n const key = effectiveKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n effectiveKeyArrays.push(effectiveKeys);\n\n if (sourceIsComponent && !stylingClaimed) {\n stylingClaimed = true;\n }\n }\n\n const rest: Record<string, unknown> = {};\n const propKeys = Object.keys(props);\n const propKeysLength = propKeys.length;\n const groupCount = sourcesLength + 1;\n outer: for (let i = 0; i < propKeysLength; i++) {\n const key = propKeys[i];\n if (key === undefined) continue;\n for (let g = 0; g < groupCount; g++) {\n const arr = effectiveKeyArrays[g];\n if (arr === undefined) continue;\n const arrLength = arr.length;\n for (let j = 0; j < arrLength; j++) {\n if (arr[j] === key) continue outer;\n }\n }\n rest[key] = props[key];\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources. Each source gets its\n * own result object containing all its matching keys. The first component\n * source claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays receive their listed keys but don't claim\n * styling props. The last element is always the \"rest\" containing keys not\n * claimed by any source.\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n if (Array.isArray(source1)) {\n return splitPropsImpl(source1, false, props, sources);\n }\n if (isComponentKeySource(source1)) {\n return splitPropsImpl(source1.propKeys, true, props, sources);\n }\n return splitPropsImpl(EMPTY_KEYS, false, props, sources);\n}) as SplitPropsFunction;\n\n/**\n * A pre-built variant. Maps variant value keys (or the literal \"true\"/\"false\"\n * strings for boolean variants) to PrebuiltValue. Includes a \"shorthand\"\n * fallback when the variant is a single class value (treated as `{ true: ... }`).\n */\ninterface PrebuiltVariant {\n // For object variants: map of value -> prebuilt class/style\n values: Record<string, PrebuiltValue> | null;\n // For shorthand variants: the value to use when selectedValue is true\n shorthand: PrebuiltValue | null;\n // Set of value keys that are disabled (value === null in the original variant\n // definition)\n disabledValues: Set<string> | null;\n}\n\nfunction buildPrebuiltVariant(variantDef: unknown): PrebuiltVariant {\n if (!isRecordObject(variantDef)) {\n return {\n values: null,\n shorthand: extractClassAndStylePrebuilt(variantDef),\n disabledValues: null,\n };\n }\n const values: Record<string, PrebuiltValue> = {};\n let disabledValues: Set<string> | null = null;\n for (const key in variantDef) {\n if (!hasOwn(variantDef, key)) continue;\n const value = variantDef[key];\n if (value === null) {\n if (!disabledValues) {\n disabledValues = new Set<string>();\n }\n disabledValues.add(key);\n continue;\n }\n values[key] = extractClassAndStylePrebuilt(value);\n }\n return {\n values,\n shorthand: null,\n disabledValues,\n };\n}\n\n/**\n * Creates the cv and cx functions.\n */\nexport function create({\n transformClass = (className) => className,\n}: CreateParams = {}) {\n const cx = (...classes: ClsxClassValue[]) => transformClass(clsx(classes));\n\n const cv = <V extends Variants = {}, const E extends AnyComponent[] = []>(\n config: CVConfig<V, E> = {},\n ): CVComponent<V, E> => {\n type MergedVariants = MergeVariants<V, E>;\n\n // ----- Pre-computed at creation time -----\n const extend = config.extend;\n const hasExtend = !!extend && extend.length > 0;\n const variants = config.variants;\n const refine = config.refine;\n const baseStyle = config.style;\n const hasBaseStyle = !!baseStyle;\n\n const variantKeySet = new Set<string>();\n const staticDefaults: Record<string, unknown> = {};\n\n // Pre-build extended component info, so the render path doesn't need to\n // read component metadata. Extends from a different `create()`\n // factory (different `transformClass` identity) need their contribution\n // transformed by their own `transformClass` before being joined into our\n // class string.\n const extMetas: ComponentMeta[] = [];\n const extBaseClassesArr: string[] = [];\n const extIsolated: boolean[] = [];\n let hasIsolatedExt = false;\n if (hasExtend) {\n for (const ext of extend) {\n const extKeys = ext.variantKeys as readonly string[];\n for (let i = 0; i < extKeys.length; i++) {\n const key = extKeys[i];\n if (key === undefined) continue;\n variantKeySet.add(key);\n }\n\n const meta = (ext as AnyComponent & ComponentWithMeta)[META_KEY];\n if (!meta) continue;\n extMetas.push(meta);\n Object.assign(staticDefaults, meta.staticDefaults);\n\n const isolated = meta.transformClass !== transformClass;\n extIsolated.push(isolated);\n if (isolated) {\n hasIsolatedExt = true;\n extBaseClassesArr.push(meta.transformClass(meta.baseClass));\n } else {\n extBaseClassesArr.push(meta.baseClass);\n }\n }\n }\n const extCount = extMetas.length;\n\n // Build all own variant metadata in one pass. Disabled value sets are\n // shared with their prebuilt variants instead of scanning and allocating\n // them twice.\n const disabledVariantKeys = new Set<string>();\n const disabledVariantValues: Record<string, Set<string>> = {};\n let hasDisabledVariantValues = false;\n const variantEntryNames: string[] = [];\n const variantEntryDefs: PrebuiltVariant[] = [];\n const functionVariantNames: string[] = [];\n const functionVariantFns: Array<(value: unknown) => unknown> = [];\n if (variants) {\n for (const name in variants) {\n if (!hasOwn(variants, name)) continue;\n const variant = (variants as Record<string, unknown>)[name];\n if (variant === null) {\n variantKeySet.delete(name);\n disabledVariantKeys.add(name);\n continue;\n }\n variantKeySet.add(name);\n if (typeof variant === \"function\") {\n functionVariantNames.push(name);\n functionVariantFns.push(variant as (value: unknown) => unknown);\n continue;\n }\n const prebuiltVariant = buildPrebuiltVariant(variant);\n variantEntryNames.push(name);\n variantEntryDefs.push(prebuiltVariant);\n if (prebuiltVariant.disabledValues) {\n disabledVariantValues[name] = prebuiltVariant.disabledValues;\n hasDisabledVariantValues = true;\n }\n if (\n prebuiltVariant.values &&\n hasOwn(prebuiltVariant.values, \"false\") &&\n staticDefaults[name] === undefined\n ) {\n staticDefaults[name] = false;\n }\n }\n }\n const variantKeys = Array.from(variantKeySet);\n const variantKeysLength = variantKeys.length;\n const variantEntryCount = variantEntryNames.length;\n const functionVariantCount = functionVariantNames.length;\n const hasDisabledVariantKeys = disabledVariantKeys.size > 0;\n const hasAnyDisabled = hasDisabledVariantKeys || hasDisabledVariantValues;\n\n const inputPropsKeys = [\"class\", \"className\", \"style\", ...variantKeys];\n\n const computedDefaultNames: string[] = [];\n const computedDefaultFns: ComputedDefaultVariantFn[] = [];\n const defaultVariants = config.defaultVariants as\n | Record<string, unknown>\n | undefined;\n\n // Pre-compute static defaults. Includes:\n // - extended components' static defaults\n // - implicit boolean defaults (variants with a `false` key default to false)\n // - this config's literal defaultVariants (overriding the above)\n //\n // Function entries in defaultVariants are computed defaults. They run in\n // the refine loop so they can react to setVariants updates.\n // Then filtered through disabled-variants.\n if (defaultVariants) {\n for (const name in defaultVariants) {\n if (!hasOwn(defaultVariants, name)) continue;\n const value = defaultVariants[name];\n if (typeof value === \"function\") {\n computedDefaultNames.push(name);\n computedDefaultFns.push(value as ComputedDefaultVariantFn);\n continue;\n }\n if (value === undefined) {\n delete staticDefaults[name];\n continue;\n }\n staticDefaults[name] = value;\n }\n }\n const computedDefaultCount = computedDefaultNames.length;\n if (hasAnyDisabled) {\n // Filter disabled variants in-place\n for (const key in staticDefaults) {\n if (!hasOwn(staticDefaults, key)) continue;\n if (disabledVariantKeys.has(key)) {\n delete staticDefaults[key];\n continue;\n }\n if (hasDisabledVariantValues) {\n const value = staticDefaults[key];\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n delete staticDefaults[key];\n }\n }\n }\n }\n\n const inheritedComputedDefaultKeys = new Set<string>();\n for (let i = 0; i < extCount; i++) {\n const keys = extMetas[i].computedDefaultKeys;\n for (const key of keys) {\n inheritedComputedDefaultKeys.add(key);\n }\n }\n\n // Filter to only extends with computed default or refine work in their\n // chain. Those are the components that can change resolved variants across\n // fixed-point iterations.\n const extMetasWithRefine: ComponentMeta[] = [];\n for (let i = 0; i < extCount; i++) {\n const meta = extMetas[i];\n if (meta.resolveRefine) {\n extMetasWithRefine.push(meta);\n }\n }\n const extMetasWithRefineCount = extMetasWithRefine.length;\n\n // Call-site frame captured at the `cv()` call site so refine-limit warnings\n // can point developers at the component definition. Skipped entirely for\n // components that can never enter the refine loop, and stripped in\n // production via the NODE_ENV guard inside `captureCreationFrame`. The\n // frame is captured at creation time but the underlying `.stack` string is\n // formatted lazily on first access, so component creation stays cheap\n // unless the warning actually fires.\n const canTriggerRefineWarning =\n !!refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0;\n const creationFrame =\n canTriggerRefineWarning && process.env.NODE_ENV !== \"production\"\n ? captureCreationFrame(cv)\n : undefined;\n\n // Function variant keys inherited from extends, filtered through this\n // component's own variants: a static (object/shorthand) variant in this\n // component replaces an inherited function variant for the same key.\n // The closure is exposed on `ComponentMeta` so any further extending\n // component can detect \"ancestor's effective variant for K is a function\"\n // and skip it when overriding K with a non-function.\n const functionVariantKeys = new Set<string>();\n for (let i = 0; i < extCount; i++) {\n const fnKeys = extMetas[i].functionVariantKeys;\n for (const k of fnKeys) {\n if (disabledVariantKeys.has(k)) continue;\n functionVariantKeys.add(k);\n }\n }\n for (let i = 0; i < functionVariantCount; i++) {\n functionVariantKeys.add(functionVariantNames[i]);\n }\n for (let i = 0; i < variantEntryCount; i++) {\n // A static variant in this component replaces an inherited function\n // variant for the same key; from this component onward, the key is no\n // longer a function variant.\n functionVariantKeys.delete(variantEntryNames[i]);\n }\n\n const computedDefaultKeys = new Set(inheritedComputedDefaultKeys);\n for (let i = 0; i < computedDefaultCount; i++) {\n computedDefaultKeys.add(computedDefaultNames[i]);\n }\n\n // Pre-compute static skip key/value sets to pass to extends. These never\n // change across calls — when caller passes no skip sets, we reuse the same\n // object and avoid Set allocation.\n let staticExtSkipKeys: Set<string> | null = null;\n if (hasDisabledVariantKeys || functionVariantCount > 0) {\n staticExtSkipKeys = new Set<string>();\n for (const k of disabledVariantKeys) {\n staticExtSkipKeys.add(k);\n }\n for (let i = 0; i < functionVariantCount; i++) {\n staticExtSkipKeys.add(functionVariantNames[i]);\n }\n }\n\n // A static variant in this component replaces an inherited function\n // variant, so the ancestor must skip that key.\n if (variantEntryCount > 0 && extCount > 0) {\n for (let i = 0; i < variantEntryCount; i++) {\n const name = variantEntryNames[i];\n for (let j = 0; j < extCount; j++) {\n if (extMetas[j].functionVariantKeys.has(name)) {\n staticExtSkipKeys ??= new Set<string>();\n staticExtSkipKeys.add(name);\n break;\n }\n }\n }\n }\n // Skip values are passed directly to extends. We can reuse the same object\n // when no caller-provided values need merging.\n const staticExtSkipValues: Record<string, Set<string>> | null =\n hasDisabledVariantValues ? disabledVariantValues : null;\n\n // Callers use this only when disabled keys or values exist.\n function filterDisabledInto(\n input: Record<string, unknown>,\n out: Record<string, unknown>,\n ): void {\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n if (disabledVariantKeys.has(key)) continue;\n const value = input[key];\n if (hasDisabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n continue;\n }\n }\n out[key] = value;\n }\n }\n\n const isOwnDisabledValue = (key: string, value: unknown): boolean => {\n if (disabledVariantKeys.has(key)) {\n return true;\n }\n if (hasDisabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n return true;\n }\n }\n return false;\n };\n\n const filterOwnDisabledVariants = (\n input: Record<string, unknown>,\n fallback: Record<string, unknown>,\n ): Record<string, unknown> => {\n if (!hasAnyDisabled) {\n return input;\n }\n\n let hasOwnDisabledValue = false;\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (isOwnDisabledValue(key, value)) {\n hasOwnDisabledValue = true;\n break;\n }\n }\n if (!hasOwnDisabledValue) {\n return input;\n }\n\n const filtered: Record<string, unknown> = {};\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (!isOwnDisabledValue(key, value)) {\n filtered[key] = value;\n continue;\n }\n const fallbackValue = fallback[key];\n if (\n fallbackValue !== undefined &&\n !isOwnDisabledValue(key, fallbackValue)\n ) {\n filtered[key] = fallbackValue;\n }\n }\n\n return filtered;\n };\n\n // Hot path: resolve variants by merging static defaults + extends'\n // static defaults + user-provided props.\n function resolveVariantsHot(\n propsVariants: Record<string, unknown>,\n ): Record<string, unknown> {\n // Start with static defaults\n const defaults = Object.assign({}, staticDefaults);\n\n // Apply propsVariants on top (filter undefined).\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (!hasOwn(propsVariants, k)) continue;\n const v = propsVariants[k];\n if (v === undefined) continue;\n defaults[k] = v;\n }\n\n if (!hasAnyDisabled) {\n return defaults;\n }\n\n // Filter disabled\n const result: Record<string, unknown> = {};\n filterDisabledInto(defaults, result);\n return result;\n }\n\n const runComputedDefaults = (\n resolved: Record<string, unknown>,\n defaultResolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants: boolean,\n protectedVariantKeys: Set<string> | null | undefined,\n ): Record<string, unknown> => {\n let ownVariants = filterOwnVariants ? null : resolved;\n const getOwnVariants = (): Record<string, unknown> => {\n if (ownVariants) {\n return ownVariants;\n }\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(resolved, key)) {\n filteredVariants[key] = resolved[key];\n }\n }\n ownVariants = filteredVariants;\n return filteredVariants;\n };\n\n let updatedVariants: Record<string, unknown> | null = null;\n const ensureUpdated = (): Record<string, unknown> => {\n if (updatedVariants) {\n return updatedVariants;\n }\n const updated = Object.assign({}, resolved);\n updatedVariants = updated;\n return updated;\n };\n\n for (let i = 0; i < computedDefaultCount; i++) {\n const key = computedDefaultNames[i];\n if (hasOwn(userVariantProps, key)) {\n if (userVariantProps[key] !== undefined) continue;\n }\n if (protectedVariantKeys?.has(key)) continue;\n\n const variantSnapshot = getOwnVariants();\n const defaultValue = inheritedComputedDefaultKeys.has(key)\n ? variantSnapshot[key]\n : defaultResolved[key];\n const value = computedDefaultFns[i](defaultValue, variantSnapshot);\n if (hasAnyDisabled) {\n if (disabledVariantKeys.has(key)) continue;\n const valueKey = getVariantValueKey(value);\n if (valueKey != null && disabledVariantValues[key]?.has(valueKey)) {\n continue;\n }\n }\n\n if (value === undefined) {\n if (!hasOwn(variantSnapshot, key)) continue;\n delete ensureUpdated()[key];\n continue;\n }\n if (Object.is(variantSnapshot[key], value)) continue;\n ensureUpdated()[key] = value;\n }\n\n return updatedVariants ?? resolved;\n };\n\n const runRefineContext = (\n resolved: Record<string, unknown>,\n filterOwnVariants: boolean,\n collectOutput: boolean,\n applyVariantUpdates: boolean,\n protectedVariants: Record<string, unknown> | null | undefined,\n protectedVariantKeys: Set<string> | null | undefined,\n ): {\n workingResolved: Record<string, unknown>;\n classes: ClassValue[] | null;\n style: StyleValue | null;\n } => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n if (refine) {\n let ownVariants = resolved;\n if (filterOwnVariants) {\n // When this component is being extended, `resolved` is the parent's\n // workingResolved (a superset of our variant keys). Filter to our own\n // keys for `ctx.variants` so the user's `refine` callback sees the\n // shape declared by `VariantValues<V>` and not foreign parent keys.\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (hasOwn(resolved, k)) {\n filteredVariants[k] = resolved[k];\n }\n }\n ownVariants = filteredVariants;\n }\n // Lazy-init updatedVariants — many refine callbacks only inspect\n // `variants`, so the copy is unnecessary in the common case.\n let updatedVariants: Record<string, unknown> | null = null;\n const localCClasses: ClassValue[] | null = collectOutput ? [] : null;\n let localCStyle: StyleValue | null = null;\n const ensureUpdated = (): Record<string, unknown> => {\n if (updatedVariants) {\n return updatedVariants;\n }\n const u = Object.assign({}, ownVariants);\n updatedVariants = u;\n return u;\n };\n const protectVariant = (key: string, value: unknown) => {\n if (protectedVariants) {\n protectedVariants[key] = value;\n protectedVariantKeys?.add(key);\n }\n };\n const ctx = {\n variants: ownVariants as VariantValues<Record<string, unknown>>,\n setVariants: (\n newVariants: VariantValues<Record<string, unknown>>,\n ) => {\n if (!applyVariantUpdates) {\n return;\n }\n if (!hasAnyDisabled) {\n for (const key in newVariants) {\n if (!hasOwn(newVariants, key)) continue;\n const value = (newVariants as Record<string, unknown>)[key];\n protectVariant(key, value);\n if (Object.is((updatedVariants ?? ownVariants)[key], value)) {\n continue;\n }\n ensureUpdated()[key] = value;\n }\n return;\n }\n for (const key in newVariants) {\n if (!hasOwn(newVariants, key)) continue;\n if (disabledVariantKeys.has(key)) continue;\n const value = (newVariants as Record<string, unknown>)[key];\n if (hasDisabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n disabledVariantValues[key]?.has(valueKey)\n ) {\n continue;\n }\n }\n protectVariant(key, value);\n if (Object.is((updatedVariants ?? ownVariants)[key], value)) {\n continue;\n }\n ensureUpdated()[key] = value;\n }\n },\n addClass: (className: ClassValue) => {\n localCClasses?.push(className);\n },\n addStyle: (newStyle: StyleValue) => {\n if (!collectOutput) return;\n if (!localCStyle) {\n localCStyle = {};\n }\n Object.assign(localCStyle, newStyle);\n },\n };\n const result = refine(ctx);\n if (collectOutput && result != null) {\n const r = extractClassAndStylePrebuilt(result);\n if (r.class != null) {\n localCClasses?.push(r.class);\n }\n if (r.style) {\n if (!localCStyle) {\n localCStyle = {};\n }\n Object.assign(localCStyle, r.style);\n }\n }\n cClasses = localCClasses;\n cStyle = localCStyle;\n if (updatedVariants) {\n const nextResolved = Object.assign({}, workingResolved);\n if (hasAnyDisabled) {\n filterDisabledInto(updatedVariants, nextResolved);\n } else {\n Object.assign(nextResolved, updatedVariants);\n }\n workingResolved = nextResolved;\n }\n }\n\n return {\n workingResolved,\n classes: cClasses,\n style: cStyle,\n };\n };\n\n // Core compute path. Called both for top-level rendering (via\n // `computeResult`) and recursively when this component is used as an\n // `extend` target by another component. Pushes variant classes (excluding\n // base class) into `classesOut` and merges styles into `styleOut`.\n const computeOnce: ComputeOnceFn = (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved = resolved,\n renderOnly = false,\n ) => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n // Run extends' contributions first (their full classes + styles) so our\n // own base style and variants apply on top, matching the original\n // ext1 → ext2 → … → current ordering.\n if (hasExtend) {\n // Build skip sets to pass to extends. Reuse precomputed values when no\n // caller-provided sets need merging.\n let extSkipKeys: Set<string> | null;\n if (skipKeys === null) {\n extSkipKeys = staticExtSkipKeys;\n } else if (staticExtSkipKeys === null) {\n extSkipKeys = skipKeys;\n } else {\n extSkipKeys = new Set(skipKeys);\n for (const k of staticExtSkipKeys) {\n extSkipKeys.add(k);\n }\n }\n\n let extSkipVals: Record<string, Set<string>> | null;\n if (skipValues === null) {\n extSkipVals = staticExtSkipValues;\n } else if (staticExtSkipValues === null) {\n extSkipVals = skipValues;\n } else {\n extSkipVals = {};\n for (const k in skipValues) {\n extSkipVals[k] = skipValues[k];\n }\n for (const k in staticExtSkipValues) {\n const existing = extSkipVals[k];\n if (existing) {\n const merged = new Set<string>(existing);\n for (const v of staticExtSkipValues[k]) {\n merged.add(v);\n }\n extSkipVals[k] = merged;\n } else {\n extSkipVals[k] = staticExtSkipValues[k];\n }\n }\n }\n\n const extUserVariantProps =\n extMetasWithRefineCount > 0\n ? getExtUserVariantProps(\n userVariantProps,\n protectedVariants ?? null,\n )\n : userVariantProps;\n for (let i = 0; i < extCount; i++) {\n if (hasIsolatedExt && extIsolated[i]) {\n // Isolated extend (different factory): gather its variant classes\n // into a scratch array, then push the joined string after applying\n // its own transformClass. Our outer transform applies on top.\n const extClasses: ClsxClassValue[] = [];\n workingResolved = extMetas[i].compute(\n workingResolved,\n extUserVariantProps,\n extSkipKeys,\n extSkipVals,\n extClasses,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n renderOnly,\n );\n if (extClasses.length > 0) {\n const joined = clsx(extClasses);\n if (joined.length > 0) {\n classesOut.push(extMetas[i].transformClass(joined));\n }\n }\n } else {\n workingResolved = extMetas[i].compute(\n workingResolved,\n extUserVariantProps,\n extSkipKeys,\n extSkipVals,\n classesOut,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n renderOnly,\n );\n }\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n // Only sync protected variants when a child refine resolver can\n // observe them. Otherwise extUserVariantProps may alias caller props.\n if (protectedVariants && extMetasWithRefineCount > 0) {\n Object.assign(extUserVariantProps, protectedVariants);\n }\n }\n }\n\n // Run own computed defaults after extended components so defaults resolve\n // from base to child. They still run before this component's `refine`.\n if (!renderOnly && computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n true,\n protectedVariantKeys,\n );\n }\n\n // Run own `refine` (if any). May modify resolved variants and emit\n // classes and styles that are applied after this component's variants.\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n true,\n true,\n !renderOnly,\n protectedVariants,\n protectedVariantKeys,\n );\n workingResolved = refineResult.workingResolved;\n cClasses = refineResult.classes;\n cStyle = refineResult.style;\n }\n\n // Apply own base style (after extends' styles, matching original order).\n if (hasBaseStyle) {\n Object.assign(styleOut, baseStyle);\n }\n\n // Apply own variants. Skip keys/values come from caller (e.g., parent\n // wants its own function variant to override this variant).\n // `variantEntryNames` already excludes disabled keys (those with `null`\n // value in config) and function variants, so we don't re-check\n // `disabledVariantKeys` here.\n const ownSkipKeys = skipKeys;\n const ownSkipValues = skipValues;\n for (let i = 0; i < variantEntryCount; i++) {\n const variantName = variantEntryNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n const variant = variantEntryDefs[i];\n if (\n variant.disabledValues &&\n selectedKey != null &&\n variant.disabledValues.has(selectedKey)\n ) {\n continue;\n }\n if (\n ownSkipValues &&\n selectedKey != null &&\n ownSkipValues[variantName]?.has(selectedKey)\n ) {\n continue;\n }\n\n let value: PrebuiltValue | null | undefined;\n if (variant.values) {\n if (selectedKey == null) continue;\n value = variant.values[selectedKey];\n } else if (selectedValue === true) {\n value = variant.shorthand;\n }\n if (!value) continue;\n if (value.class != null) {\n classesOut.push(value.class);\n }\n if (value.style) {\n Object.assign(styleOut, value.style);\n }\n }\n\n // Apply function variants — entries in `variants` whose value is a\n // function. They run after static variants and override any same-key\n // inherited variant via `staticExtSkipKeys`.\n for (let i = 0; i < functionVariantCount; i++) {\n const variantName = functionVariantNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n if (\n ownSkipValues &&\n selectedKey != null &&\n ownSkipValues[variantName]?.has(selectedKey)\n ) {\n continue;\n }\n const fn = functionVariantFns[i];\n const computedResult = fn(selectedValue);\n if (computedResult == null) continue;\n const r = extractClassAndStylePrebuilt(computedResult);\n if (r.class != null) {\n classesOut.push(r.class);\n }\n if (r.style) {\n Object.assign(styleOut, r.style);\n }\n }\n\n // Apply `refine` results — must come after own variants (static and\n // function).\n if (cClasses) {\n for (let i = 0; i < cClasses.length; i++) {\n classesOut.push(cClasses[i] as ClsxClassValue);\n }\n }\n if (cStyle) {\n Object.assign(styleOut, cStyle);\n }\n\n return workingResolved;\n };\n\n const compute: ComputeFn =\n !refine && computedDefaultCount === 0 && extMetasWithRefineCount === 0\n ? computeOnce\n : (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n ) => {\n let remaining = MAX_REFINE_RUNS;\n const protectedVariants: Record<string, unknown> = {};\n const protectedVariantKeys = new Set<string>();\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. Lazy-init keeps convergent loops allocation-free.\n let unstableChanges: Map<string, VariantChange> | null = null;\n let lastClasses: ClsxClassValue[] = [];\n let lastStyle: StyleValue = {};\n let isFirstRun = true;\n\n while (remaining > 0) {\n remaining -= 1;\n const useDirectOutput = isFirstRun;\n const classCount = classesOut.length;\n const nextClasses: ClsxClassValue[] = useDirectOutput\n ? classesOut\n : [];\n const nextStyle: StyleValue = useDirectOutput ? styleOut : {};\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protectedVariants,\n protectedVariantKeys,\n );\n const nextResolved = computeOnce(\n workingResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n nextClasses,\n nextStyle,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n );\n\n if (\n nextResolved === workingResolved ||\n areVariantsEqual(workingResolved, nextResolved)\n ) {\n if (nextResolved !== workingResolved) {\n if (useDirectOutput) {\n classesOut.length = classCount;\n for (const key in styleOut) {\n if (hasOwn(styleOut, key)) {\n Reflect.deleteProperty(styleOut, key);\n }\n }\n }\n computeOnce(\n nextResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n true,\n );\n } else if (!useDirectOutput) {\n for (let i = 0; i < nextClasses.length; i++) {\n classesOut.push(nextClasses[i]);\n }\n Object.assign(styleOut, nextStyle);\n }\n return nextResolved;\n }\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n\n if (useDirectOutput) {\n classesOut.length = classCount;\n for (const key in styleOut) {\n if (hasOwn(styleOut, key)) {\n Reflect.deleteProperty(styleOut, key);\n }\n }\n } else {\n lastClasses = nextClasses;\n lastStyle = nextStyle;\n }\n\n workingResolved = nextResolved;\n isFirstRun = false;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n for (let i = 0; i < lastClasses.length; i++) {\n classesOut.push(lastClasses[i]);\n }\n Object.assign(styleOut, lastStyle);\n return workingResolved;\n };\n\n const resolveRefineOnce: ResolveRefineOnceFn = (\n resolved,\n userVariantProps,\n filterOwnVariants = true,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved = resolved,\n ) => {\n let workingResolved = resolved;\n\n if (extMetasWithRefineCount > 0) {\n const extUserVariantProps = getExtUserVariantProps(\n userVariantProps,\n protectedVariants ?? null,\n );\n for (let i = 0; i < extMetasWithRefineCount; i++) {\n const meta = extMetasWithRefine[i];\n const resolveRefine = meta.resolveRefine;\n if (!resolveRefine) continue;\n workingResolved = resolveRefine(\n workingResolved,\n extUserVariantProps,\n true,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n );\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n if (protectedVariants) {\n Object.assign(extUserVariantProps, protectedVariants);\n }\n }\n }\n\n if (computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n filterOwnVariants,\n protectedVariantKeys,\n );\n }\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n filterOwnVariants,\n false,\n true,\n protectedVariants,\n protectedVariantKeys,\n );\n workingResolved = refineResult.workingResolved;\n }\n\n return workingResolved;\n };\n\n const resolveRefine: ResolveRefineFn | null =\n refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0\n ? (resolved, userVariantProps, filterOwnVariants = true) => {\n let remaining = MAX_REFINE_RUNS;\n const protectedVariants: Record<string, unknown> = {};\n const protectedVariantKeys = new Set<string>();\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. See the compute loop above for the shared\n // rationale.\n let unstableChanges: Map<string, VariantChange> | null = null;\n\n while (remaining > 0) {\n remaining -= 1;\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protectedVariants,\n protectedVariantKeys,\n );\n const nextResolved = resolveRefineOnce(\n workingResolved,\n userVariantProps,\n filterOwnVariants,\n protectedVariants,\n protectedVariantKeys,\n defaultResolved,\n );\n\n if (\n nextResolved === workingResolved ||\n areVariantsEqual(workingResolved, nextResolved)\n ) {\n return nextResolved;\n }\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n workingResolved = nextResolved;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n return workingResolved;\n }\n : null;\n\n // Top-level: resolves variants from user props, calls compute, then\n // assembles className and style with user-provided class/style overrides.\n const computeResult = (\n props: ComponentProps<MergedVariants> = EMPTY_DEFAULTS as ComponentProps<MergedVariants>,\n ): { className: string; style: StyleValue } => {\n const propsRecord = props as Record<string, unknown>;\n\n let resolved: Record<string, unknown> = {};\n Object.assign(resolved, staticDefaults);\n\n let userVariantProps: Record<string, unknown>;\n if (refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0) {\n const variantProps: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(propsRecord, key)) {\n variantProps[key] = propsRecord[key];\n }\n }\n for (const k in variantProps) {\n if (!hasOwn(variantProps, k)) continue;\n const v = variantProps[k];\n if (v === undefined) continue;\n resolved[k] = v;\n }\n userVariantProps = variantProps;\n } else {\n // Fast path: walk variantKeys directly against propsRecord.\n // Own-property checks ensure a polluted Object.prototype can't add\n // values the user didn't pass.\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (!hasOwn(propsRecord, key)) continue;\n const v = propsRecord[key];\n if (v === undefined) continue;\n resolved[key] = v;\n }\n userVariantProps = propsRecord;\n }\n\n if (hasAnyDisabled) {\n const filtered: Record<string, unknown> = {};\n filterDisabledInto(resolved, filtered);\n resolved = filtered;\n }\n\n // Build allClasses directly. computedBaseClass already has all extend\n // bases joined with config.class — `compute` only adds variant classes\n // on top.\n const allClasses: ClsxClassValue[] = [computedBaseClass];\n const style: StyleValue = {};\n compute(resolved, userVariantProps, null, null, allClasses, style);\n\n // Apply user-provided class / className.\n if (\"class\" in propsRecord) {\n allClasses.push(propsRecord.class as ClsxClassValue);\n }\n if (\"className\" in propsRecord) {\n allClasses.push(propsRecord.className as ClsxClassValue);\n }\n\n // Apply user-provided style.\n const psv = propsRecord.style;\n if (psv != null) {\n if (typeof psv === \"string\") {\n if (psv.length > 0) {\n htmlStyleToStyleValue(psv, style);\n }\n } else if (typeof psv === \"object\") {\n htmlObjStyleToStyleValue(psv, style);\n }\n }\n\n return {\n className: transformClass(clsx(allClasses)),\n style,\n };\n };\n\n const getVariants = (variants?: VariantValues<MergedVariants>) => {\n const variantsRecord = variants ?? EMPTY_DEFAULTS;\n let variantProps = variantsRecord;\n // Extended refinement copies user props, so filter before unknown\n // accessors or prototype keys can be observed by Object.assign.\n if (variants && extMetasWithRefineCount > 0) {\n variantProps = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(variantsRecord, key)) {\n variantProps[key] = variantsRecord[key];\n }\n }\n }\n let resolvedVariants = resolveVariantsHot(variantProps);\n if (resolveRefine) {\n resolvedVariants = resolveRefine(resolvedVariants, variantProps, false);\n }\n return resolvedVariants as VariantValues<MergedVariants>;\n };\n\n // Compute base class (without variants) — includes extended base classes.\n // Plain `clsx` (no `transformClass`): `meta.baseClass` flows back into\n // parent extends as `clsx` input and then through the single\n // `transformClass(clsx(allClasses))` at render time, so applying it here\n // would compound (double for own-render, triple+ for extend chains) and\n // misbehave for non-idempotent transforms.\n const computedBaseClass = hasExtend\n ? clsx(extBaseClassesArr, config.class as ClsxClassValue)\n : clsx(config.class as ClsxClassValue);\n\n // Shared closures across the default and modal components.\n const classFn = (props: ComponentProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n const meta: ComponentMeta = {\n baseClass: computedBaseClass,\n staticDefaults,\n compute: computeOnce,\n resolveRefine: resolveRefine ? resolveRefineOnce : null,\n transformClass,\n functionVariantKeys,\n computedDefaultKeys,\n };\n\n const initComponent = <\n R extends ComponentResult,\n T extends ModalComponent<MergedVariants, R>,\n >(\n c: T,\n propKeys: string[],\n style: T[\"style\"],\n ): T => {\n c.class = classFn;\n c.style = style;\n c.getVariants = getVariants;\n c.variantKeys = variantKeys;\n c.propKeys = propKeys;\n (c as AnyComponent & ComponentWithMeta)[META_KEY] = meta;\n return c;\n };\n\n // Default component\n const defaultComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style };\n }) as CVComponent<V, E>;\n initComponent(defaultComponent, inputPropsKeys, (props = {}) => {\n return computeResult(props).style;\n });\n\n // JSX component\n const jsxComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { className, style };\n }) as ModalComponent<MergedVariants, JSXProps>;\n initComponent(\n jsxComponent,\n [\"className\", \"style\", ...variantKeys],\n (props = {}) => computeResult(props).style,\n );\n\n // HTML component\n const htmlComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style: styleValueToHTMLStyle(style) };\n }) as ModalComponent<MergedVariants, HTMLProps>;\n initComponent(\n htmlComponent,\n [\"class\", \"style\", ...variantKeys],\n (props = {}) => styleValueToHTMLStyle(computeResult(props).style),\n );\n\n // HTMLObj component\n const htmlObjComponent = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style: styleValueToHTMLObjStyle(style) };\n }) as ModalComponent<MergedVariants, HTMLObjProps>;\n initComponent(\n htmlObjComponent,\n [\"class\", \"style\", ...variantKeys],\n (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style),\n );\n\n defaultComponent.jsx = jsxComponent;\n defaultComponent.html = htmlComponent;\n defaultComponent.htmlObj = htmlObjComponent;\n\n return defaultComponent;\n };\n\n return { cv, cx };\n}\n\nexport const cv = /* @__PURE__ */ (() => create().cv)();\n\n/**\n * Joins class values without applying a class transform.\n *\n * This behaves like the `cx` function returned by `create()` with no options.\n */\nexport function cx(...classes: ClsxClassValue[]) {\n return clsx(classes);\n}\n"],"mappings":";;AAEA,MAAa,SAAS,OAAO;AAI7B,MAAM,2CAA2B,IAAI,IAAI;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,iBAAiB,UAAkB;CAC1C,OAAO,SAAS,WAAW,CAAC,MAAM,MAAM,SAAS,WAAW,CAAC,MAAM;AACrE;AASA,SAAgB,cAAc,KAAa;CAEzC,IAAI,iBAAiB,GAAG,GACtB,OAAO;CAGT,IAAI,cAAc,IAAI,QAAQ,GAAG;CACjC,IAAI,gBAAgB,IAClB,OAAO;CAGT,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,OAAO,gBAAgB,IAAI;EACzB,UAAU,IAAI,MAAM,WAAW,WAAW;EAE1C,MAAM,YAAY,cAAc;EAChC,IAAI,aAAa,IAAI,QAAQ;GAC3B,UAAU;GACV,YAAY;GACZ;EACF;EAEA,MAAM,OAAO,IAAI,WAAW,SAAS;EAGrC,IADG,QAAQ,MAAM,QAAQ,MAAQ,QAAQ,MAAM,QAAQ,KACpC;GACjB,MAAM,oBAAoB,gBAAgB,KAAK,IAAI,WAAW,OAAO,CAAC;GACtE,UAAU,oBACN,IAAI,aACJ,IAAI,UAAU,CAAC,YAAY;GAC/B,YAAY,YAAY;EAC1B,OAAO;GACL,UAAU;GACV,YAAY;EACd;EAEA,cAAc,IAAI,QAAQ,KAAK,SAAS;CAC1C;CAEA,OAAO,SAAS,IAAI,MAAM,SAAS;AACrC;AASA,SAAgB,cAAc,KA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ACvC;EAGA,MAAM,kBAAkB,QAAwC,CAAC,MAAM;GACrE,MAAM,EAAE,WAAW,UAAU,cAAc,KAAK;GAChD,OAAO;IAAE,OAAO;IAAW,OAAO,sBAAsB,KAAK;GAAE;EACjE;EACA,cACE,eACA;GAAC;GAAS;GAAS,GAAG;EAAW,IAChC,QAAQ,CAAC,MAAM,sBAAsB,cAAc,KAAK,CAAC,CAAC,KAAK,CAClE;EAGA,MAAM,qBAAqB,QAAwC,CAAC,MAAM;GACxE,MAAM,EAAE,WAAW,UAAU,cAAc,KAAK;GAChD,OAAO;IAAE,OAAO;IAAW,OAAO,yBAAyB,KAAK;GAAE;EACpE;EACA,cACE,kBACA;GAAC;GAAS;GAAS,GAAG;EAAW,IAChC,QAAQ,CAAC,MAAM,yBAAyB,cAAc,KAAK,CAAC,CAAC,KAAK,CACrE;EAEA,iBAAiB,MAAM;EACvB,iBAAiB,OAAO;EACxB,iBAAiB,UAAU;EAE3B,OAAO;CACT;CAEA,OAAO;EAAE;EAAI;CAAG;AAClB;AAEA,MAAa,KAAqB,uBAAO,OAAO,CAAC,CAAC,GAAA,CAAI;AAOtD,SAAgB,GAAG,GAAG,SAA2B;CAC/C,OAAO,KAAK,OAAO;AACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clava",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Clava library",
5
5
  "keywords": [
6
6
  "class variance",
@@ -47,16 +47,16 @@
47
47
  "csstype": "^3.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/node": "25.9.4",
51
- "@types/react": "19.2.17",
52
- "rolldown": "1.1.4",
53
- "rolldown-plugin-dts": "0.27.1",
54
- "solid-js": "1.9.14",
55
- "typescript": "6.0.3",
56
- "vite": "8.1.3",
57
- "vitest": "4.1.10",
50
+ "@types/node": "25.9.5",
51
+ "@types/react": "19.2.18",
52
+ "rolldown": "1.2.5",
53
+ "rolldown-plugin-dts": "0.28.2",
58
54
  "scripts": "0.0.0",
59
- "test-utils": "0.0.0"
55
+ "solid-js": "1.9.15",
56
+ "test-utils": "0.0.0",
57
+ "typescript": "npm:@typescript/typescript6@6.0.2",
58
+ "vite": "8.2.2",
59
+ "vitest": "4.1.11"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "rolldown -c",
package/src/types.ts CHANGED
@@ -24,19 +24,28 @@ export type ClassValue =
24
24
  | void
25
25
  | ClassValue[];
26
26
 
27
- export interface JSXCSSProperties extends CSS.Properties<string | number> {
27
+ interface CustomProperties {
28
28
  [key: `--${string}`]: string | number;
29
29
  }
30
30
 
31
- export interface HTMLCSSProperties extends CSS.PropertiesHyphen<
32
- string | number
33
- > {
34
- [key: `--${string}`]: string | number;
35
- }
31
+ export interface JSXCSSProperties
32
+ extends CSS.Properties<string | number>, CustomProperties {}
33
+
34
+ export interface HTMLCSSProperties
35
+ extends CSS.PropertiesHyphen<string | number>, CustomProperties {}
36
36
 
37
37
  export type CSSProperties = CSS.Properties;
38
38
 
39
- export type StyleProperty = JSXCSSProperties | HTMLCSSProperties | string;
39
+ // Indexed members keep custom properties known to fresh style literals, one
40
+ // per input mode. Index-free members keep framework style types assignable:
41
+ // an all-indexed union rejects React's `CSSProperties`, surfacing as TS2590.
42
+ // https://github.com/ariakit/clava/issues/483#issuecomment-5447514407
43
+ export type StyleProperty =
44
+ | JSXCSSProperties
45
+ | HTMLCSSProperties
46
+ | CSS.Properties<string | number>
47
+ | CSS.PropertiesHyphen<string | number>
48
+ | string;
40
49
 
41
50
  /**
42
51
  * The prop object returned by a component's `.jsx()` mode.
@@ -375,9 +384,7 @@ export type DefaultVariants<V> = {
375
384
  * };
376
385
  * ```
377
386
  */
378
- export interface StyleValue extends CSS.Properties {
379
- [key: `--${string}`]: string | number;
380
- }
387
+ export interface StyleValue extends CSS.Properties, CustomProperties {}
381
388
 
382
389
  /**
383
390
  * A value that contributes both class and style output from a base config,