@tenphi/tasty 0.0.0-snapshot.27b6708 → 0.0.0-snapshot.28eb83c

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.
Files changed (106) hide show
  1. package/README.md +38 -54
  2. package/dist/{babel-BUQGeOXA.d.ts → babel-D6lOuSwk.d.ts} +2 -2
  3. package/dist/chunks/async-storage-DKK-wTD4.js.map +1 -0
  4. package/dist/chunks/build-config-BBThSdlo.js +45 -0
  5. package/dist/chunks/build-config-BBThSdlo.js.map +1 -0
  6. package/dist/{collector-DTahQUiV.js → chunks/collector-DcViW2ZQ.js} +28 -14
  7. package/dist/chunks/collector-DcViW2ZQ.js.map +1 -0
  8. package/dist/chunks/config-engine-DQVQK4NU.js +403 -0
  9. package/dist/chunks/config-engine-DQVQK4NU.js.map +1 -0
  10. package/dist/chunks/css-definitions-BZ9vm0ci.js +1284 -0
  11. package/dist/chunks/css-definitions-BZ9vm0ci.js.map +1 -0
  12. package/dist/chunks/css-resources-Cyl_axbI.js +149 -0
  13. package/dist/chunks/css-resources-Cyl_axbI.js.map +1 -0
  14. package/dist/chunks/debug-Vyauml7U.js +583 -0
  15. package/dist/chunks/debug-Vyauml7U.js.map +1 -0
  16. package/dist/chunks/dsl-CXvoaLnj.js +2097 -0
  17. package/dist/chunks/dsl-CXvoaLnj.js.map +1 -0
  18. package/dist/chunks/hydration-CLdVKcH2.js +59 -0
  19. package/dist/chunks/hydration-CLdVKcH2.js.map +1 -0
  20. package/dist/chunks/react-runtime-so_X_yMo.js +1526 -0
  21. package/dist/chunks/react-runtime-so_X_yMo.js.map +1 -0
  22. package/dist/chunks/runtime-engine-DQ5laRou.js +3056 -0
  23. package/dist/chunks/runtime-engine-DQ5laRou.js.map +1 -0
  24. package/dist/{merge-styles-oklji0KB.js → chunks/shared-utils-OIg0N_dp.js} +42 -3
  25. package/dist/chunks/shared-utils-OIg0N_dp.js.map +1 -0
  26. package/dist/{config-B5kHzuNz.js → chunks/style-engine-CBuOt1e4.js} +2387 -7442
  27. package/dist/chunks/style-engine-CBuOt1e4.js.map +1 -0
  28. package/dist/{css-writer-B-J87ncv.js → chunks/zero-engine-BFh7gKbK.js} +3 -3
  29. package/dist/chunks/zero-engine-BFh7gKbK.js.map +1 -0
  30. package/dist/{collector-DUaHCcTS.d.ts → collector-CAmndLXe.d.ts} +23 -3
  31. package/dist/{config-YsxGv4tq.d.ts → config-BWYrv_Aa.d.ts} +141 -37
  32. package/dist/core/index.d.ts +5 -5
  33. package/dist/core/index.js +9 -6
  34. package/dist/{index-Cd45t5NM.d.ts → index-BzAC3p06.d.ts} +118 -23
  35. package/dist/{index-PqN-DIpn.d.ts → index-D4kRLj2o.d.ts} +128 -68
  36. package/dist/index.d.ts +5 -5
  37. package/dist/index.js +10 -922
  38. package/dist/{merge-styles-CU7JbEwg.d.ts → merge-styles-BFktNP8J.d.ts} +2 -2
  39. package/dist/ssr/astro-client.js +1 -1
  40. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  41. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  42. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  43. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  44. package/dist/ssr/astro-middleware-extract.js +9 -0
  45. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  46. package/dist/ssr/astro-middleware-static.d.ts +3 -1
  47. package/dist/ssr/astro-middleware.d.ts +3 -1
  48. package/dist/ssr/astro.d.ts +45 -3
  49. package/dist/ssr/astro.js +157 -14
  50. package/dist/ssr/astro.js.map +1 -1
  51. package/dist/ssr/index.d.ts +7 -7
  52. package/dist/ssr/index.js +4 -4
  53. package/dist/ssr/index.js.map +1 -1
  54. package/dist/ssr/next-config.d.ts +66 -0
  55. package/dist/ssr/next-config.js +135 -0
  56. package/dist/ssr/next-config.js.map +1 -0
  57. package/dist/ssr/next.d.ts +9 -2
  58. package/dist/ssr/next.js +26 -10
  59. package/dist/ssr/next.js.map +1 -1
  60. package/dist/static/index.d.ts +2 -2
  61. package/dist/static/index.js +1 -1
  62. package/dist/zero/babel.d.ts +1 -1
  63. package/dist/zero/babel.js +25 -24
  64. package/dist/zero/babel.js.map +1 -1
  65. package/dist/zero/index.d.ts +1 -1
  66. package/dist/zero/index.js +1 -1
  67. package/dist/zero/next.d.ts +1 -1
  68. package/docs/README.md +5 -3
  69. package/docs/adoption.md +3 -3
  70. package/docs/ai-agents.md +83 -78
  71. package/docs/comparison.md +12 -12
  72. package/docs/configuration.md +47 -47
  73. package/docs/debug.md +19 -7
  74. package/docs/dsl.md +3 -3
  75. package/docs/getting-started.md +10 -10
  76. package/docs/injector.md +62 -25
  77. package/docs/methodology.md +3 -3
  78. package/docs/migration-v3.md +49 -49
  79. package/docs/plugins.md +37 -33
  80. package/docs/react-api.md +2 -2
  81. package/docs/runtime-benchmarks.md +351 -0
  82. package/docs/ssr.md +219 -61
  83. package/docs/styles.md +43 -11
  84. package/docs/tasty-static.md +136 -103
  85. package/package.json +80 -11
  86. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  87. package/dist/collector-DTahQUiV.js.map +0 -1
  88. package/dist/config-B5kHzuNz.js.map +0 -1
  89. package/dist/context-CA8YKeMn.js +0 -24
  90. package/dist/context-CA8YKeMn.js.map +0 -1
  91. package/dist/core-Dr4u1NVD.js +0 -1566
  92. package/dist/core-Dr4u1NVD.js.map +0 -1
  93. package/dist/css-writer-B-J87ncv.js.map +0 -1
  94. package/dist/format-global-rules-DklyaXv-.js +0 -22
  95. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  96. package/dist/format-rules-DKOA-6qu.js +0 -130
  97. package/dist/format-rules-DKOA-6qu.js.map +0 -1
  98. package/dist/hydrate-OeMX99We.js +0 -37
  99. package/dist/hydrate-OeMX99We.js.map +0 -1
  100. package/dist/index.js.map +0 -1
  101. package/dist/keyframes-CV8azJf3.js +0 -493
  102. package/dist/keyframes-CV8azJf3.js.map +0 -1
  103. package/dist/merge-styles-oklji0KB.js.map +0 -1
  104. package/dist/resolve-recipes-DTG81rzl.js +0 -144
  105. package/dist/resolve-recipes-DTG81rzl.js.map +0 -1
  106. /package/dist/{async-storage-DKK-wTD4.js → chunks/async-storage-DKK-wTD4.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-runtime-so_X_yMo.js","names":["modAttrs","getClientState"],"sources":["../../src/rsc-cache.ts","../../src/ssr/collect-auto-properties.ts","../../src/utils/has-keys.ts","../../src/compute-styles.ts","../../src/utils/filter-base-props.ts","../../src/utils/mod-attrs.ts","../../src/utils/process-tokens.ts","../../src/utils/get-display-name.ts","../../src/utils/is-valid-element-type.ts","../../src/tasty.tsx","../../src/ssr/context.ts","../../src/hooks/useStyles.ts","../../src/hooks/useGlobalStyles.ts","../../src/hooks/useRawCSS.ts","../../src/hooks/useKeyframes.ts","../../src/hooks/useProperty.ts","../../src/hooks/useFontFace.ts","../../src/hooks/useCounterStyle.ts","../../src/hooks/useFunction.ts","../../src/batch-provider.tsx"],"sourcesContent":["/**\n * Shared RSC (React Server Components) inline style cache.\n *\n * Uses React.cache for per-request memoization in Server Components.\n * Both computeStyles() and standalone style functions (useGlobalStyles,\n * useRawCSS, useKeyframes, useProperty, useFontFace, useCounterStyle)\n * share this cache so that CSS accumulated by standalone functions is\n * flushed into inline <style> tags by the next tasty() component.\n */\n\nimport { cache } from 'react';\n\nimport { getNamePrefix } from './config';\nimport type { ServerStyleCollector } from './ssr/collector';\nimport { getRegisteredSSRCollector } from './ssr/ssr-collector-ref';\nimport { hashString } from './utils/hash';\nimport { makeClassName } from './utils/name-prefix';\n\nexport interface RSCStyleCache {\n cacheKeyToClassName: Map<string, string>;\n emittedKeys: Set<string>;\n internalsEmitted: boolean;\n pendingCSS: string[];\n /** Maps dedup key -> its slot in `pendingCSS`, so slot-keyed CSS can be replaced. */\n keyToIndex: Map<string, number>;\n /** Maps dedup key -> generated name for keyframes and counter-styles in RSC mode. */\n generatedNames: Map<string, string>;\n}\n\n/**\n * Per-request RSC style cache using React.cache.\n * React.cache provides per-request memoization in Server Components,\n * so each request gets its own isolated cache.\n */\nexport const getRSCCache = cache((): RSCStyleCache => ({\n cacheKeyToClassName: new Map(),\n emittedKeys: new Set(),\n internalsEmitted: false,\n pendingCSS: [],\n keyToIndex: new Map(),\n generatedNames: new Map(),\n}));\n\nexport function rscAllocateClassName(\n rscCache: RSCStyleCache,\n cacheKey: string,\n): { className: string; isNew: boolean } {\n const existing = rscCache.cacheKeyToClassName.get(cacheKey);\n if (existing) return { className: existing, isNew: false };\n\n // Content-hash ensures stable names across all environments (RSC, SSR, client),\n // enabling cross-environment dedup and preventing class collisions.\n const className = makeClassName(getNamePrefix(), hashString(cacheKey));\n rscCache.cacheKeyToClassName.set(cacheKey, className);\n return { className, isNew: true };\n}\n\n/**\n * Flush any pending CSS accumulated by standalone functions.\n * Returns the CSS string and clears the buffer.\n */\nexport function flushPendingCSS(rscCache: RSCStyleCache): string {\n if (rscCache.pendingCSS.length === 0) return '';\n const css = rscCache.pendingCSS.join('\\n');\n rscCache.pendingCSS.length = 0;\n // The slots are gone with the buffer; a later replace has to append instead.\n rscCache.keyToIndex.clear();\n return css;\n}\n\n/**\n * Push CSS into the RSC pending buffer with dedup via emittedKeys.\n * Returns true if the CSS was added, false if it was already emitted.\n *\n * Pass `replace` for slot-keyed entries (an explicit `id`), where the last write\n * must win to match the client's update-tracking behavior. If the slot has\n * already been flushed into a `<style>` tag the new CSS is appended instead,\n * which still wins by cascade order.\n */\nexport function pushRSCCSS(\n rscCache: RSCStyleCache,\n key: string,\n css: string,\n replace?: boolean,\n): boolean {\n if (replace) {\n const pendingIndex = rscCache.keyToIndex.get(key);\n\n if (pendingIndex !== undefined) {\n rscCache.pendingCSS[pendingIndex] = css;\n return true;\n }\n } else if (rscCache.emittedKeys.has(key)) {\n return false;\n }\n\n rscCache.emittedKeys.add(key);\n rscCache.keyToIndex.set(key, rscCache.pendingCSS.length);\n rscCache.pendingCSS.push(css);\n return true;\n}\n\ntype StyleTarget =\n | { mode: 'ssr'; collector: ServerStyleCollector }\n | { mode: 'rsc'; cache: RSCStyleCache }\n | { mode: 'client' };\n\n/**\n * Determine the current style injection target.\n * Centralizes the three-way detection (SSR collector / RSC cache / client DOM)\n * used by all style functions.\n */\nexport function getStyleTarget(): StyleTarget {\n const collector = getRegisteredSSRCollector();\n if (collector) return { mode: 'ssr', collector };\n if (typeof document === 'undefined')\n return { mode: 'rsc', cache: getRSCCache() };\n return { mode: 'client' };\n}\n","/**\n * SSR / RSC auto-property inference.\n *\n * Scans rendered CSS declarations for custom properties whose types\n * can be inferred from their values (e.g. `--angle: 30deg` → `<angle>`).\n * Mirrors the client-side auto-inference in StyleInjector.inject().\n */\n\nimport type { StyleResult } from '../pipeline';\nimport { parsePropertyToken } from '../properties';\nimport { PropertyTypeResolver } from '../properties/property-type-resolver';\nimport type { RSCStyleCache } from '../rsc-cache';\nimport { pushRSCCSS } from '../rsc-cache';\nimport type { Styles } from '../styles/types';\n\nimport type { ServerStyleCollector } from './collector';\nimport { formatPropertyCSS } from './format-property';\n\n/**\n * Scan rendered rules for auto-inferable custom properties and emit\n * @property CSS via the provided callback.\n */\nfunction scanAndEmitAutoProperties(\n rules: StyleResult[],\n styles: Styles | undefined,\n emit: (name: string, css: string) => void,\n): void {\n const registered = new Set<string>();\n\n if (styles) {\n const localProps = styles['@property'];\n if (localProps && typeof localProps === 'object') {\n for (const token of Object.keys(localProps as Record<string, unknown>)) {\n const parsed = parsePropertyToken(token);\n if (parsed.isValid) {\n registered.add(parsed.cssName);\n }\n }\n }\n }\n\n const resolver = new PropertyTypeResolver();\n\n for (const rule of rules) {\n if (!rule.declarations) continue;\n resolver.scanDeclarations(\n rule.declarations,\n (name) => registered.has(name),\n (name, syntax, initialValue) => {\n registered.add(name);\n const css = formatPropertyCSS(name, {\n syntax,\n inherits: true,\n initialValue,\n });\n if (css) {\n emit(name, css);\n }\n },\n );\n }\n}\n\n/**\n * Scan rendered rules for custom property declarations and collect\n * auto-inferred @property rules via the SSR collector.\n *\n * @param rules - Rendered style rules containing CSS declarations\n * @param collector - SSR collector to emit @property CSS into\n * @param styles - Original styles object (used to skip explicit @property)\n */\nexport function collectAutoInferredProperties(\n rules: StyleResult[],\n collector: ServerStyleCollector,\n styles?: Styles,\n): void {\n scanAndEmitAutoProperties(rules, styles, (name, css) => {\n collector.collectProperty(`__auto:${name}`, css);\n });\n}\n\n/**\n * RSC variant: scan rendered rules and push auto-inferred @property CSS\n * into the RSC pending buffer.\n */\nexport function collectAutoInferredPropertiesRSC(\n rules: StyleResult[],\n rscCache: RSCStyleCache,\n styles?: Styles,\n): void {\n scanAndEmitAutoProperties(rules, styles, (name, css) => {\n pushRSCCSS(rscCache, `__auto:${name}`, css);\n });\n}\n","/**\n * Check if an object has any own enumerable keys.\n * Avoids the array allocation of Object.keys(obj).length > 0.\n */\nexport function hasKeys(obj: object): boolean {\n for (const _ in obj) return true;\n return false;\n}\n","/**\n * Hook-free, synchronous style computation.\n *\n * Extracts the core logic from useStyles() into a plain function that can\n * be called during React render without any hooks. Three code paths:\n *\n * 1. SSR collector — styles collected via ServerStyleCollector\n * 2. Client inject — styles injected synchronously into the DOM\n * 3. RSC inline — styles returned as CSS strings for inline <style> emission\n *\n * This enables tasty() components to work as React Server Components.\n */\n\nimport {\n categorizeStyleKeys,\n generateChunkCacheKey,\n renderStylesForChunk,\n} from './chunks';\nimport {\n getConfig,\n getGlobalKeyframes,\n hasGlobalKeyframes,\n isFunctionsPolyfillEnabled,\n} from './config';\nimport {\n counterStyle,\n fontFace,\n func,\n inject,\n holdKeyframes,\n ownKeyframes,\n property,\n touch,\n} from './injector';\nimport type { FontFaceDescriptors, KeyframesSteps } from './injector/types';\nimport {\n extractLocalCounterStyle,\n formatCounterStyleRule,\n hasLocalCounterStyle,\n} from './counter-style';\nimport {\n extractLocalFunctions,\n formatFunctionRule,\n hasLocalFunctions,\n parseFunctionName,\n registerLocalFunctionPolyfills,\n} from './functions';\nimport {\n extractLocalFontFace,\n fontFaceContentHash,\n formatFontFaceRule,\n hasLocalFontFace,\n} from './font-face';\nimport {\n extractAnimationNamesFromStyles,\n extractLocalKeyframes,\n filterUsedKeyframes,\n hasLocalKeyframes,\n mergeKeyframes,\n referencesAnimation,\n resolveKeyframesNames,\n replaceAnimationNames,\n} from './keyframes';\nimport type { RenderResult, StyleResult } from './pipeline';\nimport {\n flushPendingCSS,\n getRSCCache,\n rscAllocateClassName,\n} from './rsc-cache';\nimport type { RSCStyleCache } from './rsc-cache';\nimport { extractLocalProperties, hasLocalProperties } from './properties';\nimport { collectAutoInferredProperties } from './ssr/collect-auto-properties';\nimport type { ServerStyleCollector } from './ssr/collector';\nimport { formatKeyframesCSS } from './ssr/format-keyframes';\nimport { formatPropertyCSS } from './ssr/format-property';\nimport { formatRules } from './ssr/format-rules';\nimport { getRegisteredSSRCollector } from './ssr/ssr-collector-ref';\nimport type { Styles } from './styles/types';\nimport { hasKeys } from './utils/has-keys';\nimport { resolveRecipes } from './utils/resolve-recipes';\n\nexport interface ComputeStylesResult {\n className: string;\n /** CSS text to emit as an inline <style> tag (RSC mode only). */\n css?: string;\n}\n\nexport interface ComputeStylesOptions {\n ssrCollector?: ServerStyleCollector | null;\n /** Target root for style injection (client only). Defaults to `document`. */\n root?: Document | ShadowRoot;\n /**\n * Set when `styles` outlives this call and will be passed in again — a\n * `tasty()` factory's own styles object rather than a per-render merge.\n * It lets chunk cache keys be memoized on the object, which is worth the\n * bookkeeping only when there is a next render to spend it on.\n */\n stableStyles?: boolean;\n}\n\ninterface ProcessedChunk {\n name: string;\n styleKeys: string[];\n cacheKey: string;\n renderResult: RenderResult;\n className: string;\n /** Local animations this chunk runs, by their authored names. */\n animations?: string[];\n}\n\nconst EMPTY_RESULT: ComputeStylesResult = { className: '' };\n\n// ---------------------------------------------------------------------------\n// RSC (React Server Components) inline style support\n// ---------------------------------------------------------------------------\n\n/**\n * Mark internals as emitted for this RSC request.\n *\n * Internals (tokens, @property, @font-face, @counter-style) are emitted\n * exclusively by the SSR collector via ServerStyleCollector.collectInternals().\n * The SSR path is reliable because TastyRegistry is always present as a\n * client component in the root layout, guaranteeing SSR runs for every page.\n *\n * Previously this function also emitted internals and coordinated with SSR\n * via a globalThis flag, but that flag leaked across requests in the same\n * Node.js process, causing pages without RSC-rendered tasty components\n * (e.g. the playground route) to lose all token CSS.\n */\nfunction collectInternalsRSC(rscCache: RSCStyleCache): string {\n if (rscCache.internalsEmitted) return '';\n rscCache.internalsEmitted = true;\n\n return '';\n}\n\n/**\n * Collect per-component ancillary CSS (keyframes, @property, font-face,\n * counter-style) for RSC mode.\n */\nfunction collectAncillaryRSC(rscCache: RSCStyleCache, styles: Styles): string {\n const parts: string[] = [];\n\n const usedKf = getUsedKeyframes(styles);\n const rscKeyframeNames = usedKf ? resolveKeyframesNames(usedKf) : null;\n if (usedKf && rscKeyframeNames) {\n for (const [authored, steps] of Object.entries(usedKf)) {\n const name = rscKeyframeNames.get(authored) as string;\n const key = `__kf:${name}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n parts.push(formatKeyframesCSS(name, steps));\n }\n }\n }\n\n if (hasLocalProperties(styles)) {\n const localProperties = extractLocalProperties(styles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n const key = `__prop:${token}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n const css = formatPropertyCSS(token, definition);\n if (css) parts.push(css);\n }\n }\n }\n }\n\n if (hasLocalFontFace(styles)) {\n const localFontFace = extractLocalFontFace(styles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const key = `__ff:${hash}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n parts.push(formatFontFaceRule(family, desc));\n }\n }\n }\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const localCounterStyle = extractLocalCounterStyle(styles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n const key = `__cs:${name}:${JSON.stringify(descriptors)}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n parts.push(formatCounterStyleRule(name, descriptors));\n }\n }\n }\n }\n\n if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {\n const localFunctions = extractLocalFunctions(styles);\n if (localFunctions) {\n for (const [name, definition] of Object.entries(localFunctions)) {\n const key = `__func:${parseFunctionName(name)}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n parts.push(formatFunctionRule(name, definition));\n }\n }\n }\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Process all chunks in RSC mode: render CSS to strings, allocate classNames,\n * and return combined { className, css }.\n */\nfunction computeStylesRSC(\n styles: Styles,\n chunkMap: Map<string, string[]>,\n stableStyles: boolean,\n): ComputeStylesResult {\n const rscCache = getRSCCache();\n const cssParts: string[] = [];\n const classNames: string[] = [];\n const rscUsedKf = getUsedKeyframes(styles);\n const rscKeyframeNames = rscUsedKf ? resolveKeyframesNames(rscUsedKf) : null;\n\n // Flush CSS accumulated by standalone style functions\n const pendingCSS = flushPendingCSS(rscCache);\n if (pendingCSS) cssParts.push(pendingCSS);\n\n const internalsCSS = collectInternalsRSC(rscCache);\n if (internalsCSS) cssParts.push(internalsCSS);\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n if (chunkStyleKeys.length === 0) continue;\n\n const baseKey = generateChunkCacheKey(\n styles,\n chunkName,\n chunkStyleKeys,\n stableStyles,\n );\n\n // Rendered before the class is allocated, for the same reason as the other\n // two paths: the key has to carry which keyframes these rules animate.\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n chunkStyleKeys,\n );\n if (renderResult.rules.length === 0) continue;\n\n const { rules, cacheKey } = applyKeyframeNames(\n renderResult.rules,\n baseKey,\n rscKeyframeNames,\n );\n\n const { className, isNew } = rscAllocateClassName(rscCache, cacheKey);\n classNames.push(className);\n\n if (isNew) {\n const css = formatRules(rules, className);\n if (css) cssParts.push(css);\n }\n }\n\n const ancillaryCSS = collectAncillaryRSC(rscCache, styles);\n if (ancillaryCSS) cssParts.push(ancillaryCSS);\n\n if (classNames.length === 0) return EMPTY_RESULT;\n\n const css = cssParts.join('\\n');\n\n return {\n className: classNames.join(' '),\n css: css || undefined,\n };\n}\n\n/**\n * Get keyframes that are actually used in styles.\n * Returns null if no keyframes are used (fast path for zero overhead).\n */\nfunction getUsedKeyframes(\n styles: Styles,\n): Record<string, KeyframesSteps> | null {\n const hasLocal = hasLocalKeyframes(styles);\n const hasGlobal = hasGlobalKeyframes();\n if (!hasLocal && !hasGlobal) return null;\n\n const usedNames = extractAnimationNamesFromStyles(styles);\n if (usedNames.size === 0) return null;\n\n const local = hasLocal ? extractLocalKeyframes(styles) : null;\n const global = hasGlobal ? getGlobalKeyframes() : null;\n const allKeyframes = mergeKeyframes(local, global);\n\n return filterUsedKeyframes(allKeyframes, usedNames);\n}\n\n/**\n * Process a chunk on the SSR path: allocate via collector, render, collect CSS.\n */\nfunction processChunkSSR(\n collector: ServerStyleCollector,\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n stableStyles: boolean,\n keyframeNames?: Map<string, string> | null,\n): ProcessedChunk | null {\n if (styleKeys.length === 0) return null;\n\n const baseKey = generateChunkCacheKey(\n styles,\n chunkName,\n styleKeys,\n stableStyles,\n );\n\n // Rendered before the class is allocated: the key has to carry which\n // keyframes these rules animate, or two components authoring the same\n // shorthand over different definitions would share a class here and\n // disagree with the client, which does carry it.\n const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);\n if (renderResult.rules.length === 0) return null;\n\n const { animations, rules, cacheKey } = applyKeyframeNames(\n renderResult.rules,\n baseKey,\n keyframeNames,\n );\n\n const { className, isNewAllocation } = collector.allocateClassName(cacheKey);\n\n if (isNewAllocation) {\n collector.collectChunk(cacheKey, className, rules);\n return {\n name: chunkName,\n styleKeys,\n cacheKey,\n renderResult: { ...renderResult, rules },\n className,\n animations,\n };\n }\n\n return {\n name: chunkName,\n styleKeys,\n cacheKey,\n renderResult: { rules: [] },\n className,\n };\n}\n\n/**\n * Point a chunk's rules at the resolved keyframe names, and fold those names\n * into its cache key.\n *\n * Both halves matter, and both have to happen before the rules are written\n * anywhere: the declarations have to name the animation that will exist, and\n * the key has to distinguish two components that authored the same shorthand\n * over different definitions. Shared by the client and the server so they\n * cannot disagree about either.\n */\nfunction applyKeyframeNames(\n ruleset: StyleResult[],\n baseKey: string,\n keyframeNames?: Map<string, string> | null,\n): { animations: string[]; rules: StyleResult[]; cacheKey: string } {\n if (!keyframeNames || keyframeNames.size === 0) {\n return { animations: [], rules: ruleset, cacheKey: baseKey };\n }\n\n // Whole tokens only, so `crossfade` is not a use of `fade`.\n const animations = [...keyframeNames.keys()].filter((authored) =>\n ruleset.some((rule) => referencesAnimation(rule.declarations, authored)),\n );\n\n if (animations.length === 0) {\n return { animations, rules: ruleset, cacheKey: baseKey };\n }\n\n const rules = ruleset.map((rule) => ({\n ...rule,\n declarations: replaceAnimationNames(rule.declarations, keyframeNames),\n }));\n\n const cacheKey = `${baseKey}\\u0000kf:${animations\n .map((authored) => `${authored}=${keyframeNames.get(authored)}`)\n .sort()\n .join(',')}`;\n\n return { animations, rules, cacheKey };\n}\n\n/**\n * Process a chunk on the client: render, allocate className, and inject\n * CSS synchronously. The injector's cache makes this idempotent.\n */\nfunction processChunkSync(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n stableStyles: boolean,\n root?: Document | ShadowRoot,\n keyframeNames?: Map<string, string> | null,\n): ProcessedChunk | null {\n if (styleKeys.length === 0) return null;\n\n const cacheKey = generateChunkCacheKey(\n styles,\n chunkName,\n styleKeys,\n stableStyles,\n );\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n styleKeys,\n cacheKey,\n );\n if (renderResult.rules.length === 0) return null;\n\n const {\n animations,\n rules,\n cacheKey: injectKey,\n } = applyKeyframeNames(renderResult.rules, cacheKey, keyframeNames);\n\n // `pin: false` — the render path keeps no dispose handle; the DOM is the\n // record of use, and `gc()` reclaims the class once no element carries it.\n const { className } = inject(rules, {\n cacheKey: injectKey,\n root,\n pin: false,\n });\n\n return {\n name: chunkName,\n styleKeys,\n cacheKey: injectKey,\n renderResult: { ...renderResult, rules },\n className,\n animations,\n };\n}\n\n/**\n * Inject all ancillary rules (properties, font-faces, counter-styles) synchronously.\n */\nfunction injectAncillarySync(\n styles: Styles,\n root?: Document | ShadowRoot,\n): void {\n if (hasLocalProperties(styles)) {\n const localProperties = extractLocalProperties(styles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n property(token, { ...definition, root });\n }\n }\n }\n\n if (hasLocalFontFace(styles)) {\n const localFontFace = extractLocalFontFace(styles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n fontFace(family, desc, { root });\n }\n }\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const localCounterStyle = extractLocalCounterStyle(styles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n counterStyle(name, descriptors, { root });\n }\n }\n }\n\n if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {\n const localFunctions = extractLocalFunctions(styles);\n if (localFunctions) {\n for (const [name, definition] of Object.entries(localFunctions)) {\n func(name, definition, { root });\n }\n }\n }\n}\n\n/**\n * Collect all ancillary rules into the SSR collector.\n */\nfunction collectAncillarySSR(\n collector: ServerStyleCollector,\n styles: Styles,\n chunks: ProcessedChunk[],\n): void {\n const usedKf = getUsedKeyframes(styles);\n if (usedKf) {\n // Emitted under the resolved name, so two different `fade` definitions are\n // two rules rather than one deduplicated by name — and so the client\n // agrees about which one a class animates.\n const names = resolveKeyframesNames(usedKf);\n for (const [authored, steps] of Object.entries(usedKf)) {\n const name = names.get(authored) as string;\n collector.collectKeyframes(name, formatKeyframesCSS(name, steps));\n }\n }\n\n if (hasLocalProperties(styles)) {\n const localProperties = extractLocalProperties(styles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n collector.collectProperty(token, css);\n }\n }\n }\n }\n\n if (hasLocalFontFace(styles)) {\n const localFontFace = extractLocalFontFace(styles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n collector.collectFontFace(hash, css);\n }\n }\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const localCounterStyle = extractLocalCounterStyle(styles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n const css = formatCounterStyleRule(name, descriptors);\n collector.collectCounterStyle(name, css);\n }\n }\n }\n\n if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {\n const localFunctions = extractLocalFunctions(styles);\n if (localFunctions) {\n for (const [name, definition] of Object.entries(localFunctions)) {\n const css = formatFunctionRule(name, definition);\n collector.collectFunction(parseFunctionName(name), css);\n }\n }\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n const allRules = chunks.flatMap((c) => c.renderResult.rules);\n if (allRules.length > 0) {\n collectAutoInferredProperties(allRules, collector, styles);\n }\n }\n}\n\n/**\n * Synchronous, hook-free style computation.\n *\n * Resolves recipes, categorizes style keys into chunks, renders CSS rules,\n * allocates class names, and injects / collects / returns the CSS.\n *\n * Three code paths:\n * 1. SSR collector — discovered via ALS or passed explicitly; CSS collected\n * 2. RSC inline — no collector and no `document`; CSS returned as `result.css`\n * for the caller to emit as an inline `<style>` tag\n * 3. Client inject — CSS injected synchronously into the DOM (idempotent)\n *\n * @param styles - Tasty styles object (or undefined for no styles)\n * @param options - Optional SSR collector override\n */\nexport function computeStyles(\n styles: Styles | undefined,\n options?: ComputeStylesOptions,\n): ComputeStylesResult {\n if (!styles || !hasKeys(styles as Record<string, unknown>)) {\n return EMPTY_RESULT;\n }\n\n const resolved = resolveRecipes(styles);\n\n // Only the caller's own object can be declared reusable. When recipe\n // resolution rewrites it, `resolved` is a fresh per-render object and\n // memoizing on it would be pure overhead.\n const stableStyles = options?.stableStyles === true && resolved === styles;\n\n // @function polyfill: register local definitions as inline closures BEFORE\n // any chunk is rendered, so call sites in this component expand to plain CSS.\n if (isFunctionsPolyfillEnabled() && hasLocalFunctions(resolved)) {\n registerLocalFunctionPolyfills(resolved);\n }\n\n const chunkMap = categorizeStyleKeys(resolved as Record<string, unknown>);\n\n const collector =\n options?.ssrCollector !== undefined\n ? options.ssrCollector\n : getRegisteredSSRCollector();\n\n const chunks: ProcessedChunk[] = [];\n\n if (collector) {\n collector.collectInternals();\n\n const ssrKf = getUsedKeyframes(resolved);\n const ssrKeyframeNames = ssrKf ? resolveKeyframesNames(ssrKf) : null;\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n const chunk = processChunkSSR(\n collector,\n resolved,\n chunkName,\n chunkStyleKeys,\n stableStyles,\n ssrKeyframeNames,\n );\n if (chunk) chunks.push(chunk);\n }\n\n collectAncillarySSR(collector, resolved, chunks);\n } else if (typeof document === 'undefined') {\n // RSC path: render CSS to strings for inline <style> emission\n return computeStylesRSC(resolved, chunkMap, stableStyles);\n } else {\n const root = options?.root;\n\n injectAncillarySync(resolved, root);\n\n const usedKf = getUsedKeyframes(resolved);\n\n // Names first, and resolved the same way on every path: the rules that\n // animate them carry the name, and a rule written before it is known\n // cannot be corrected afterwards.\n const keyframeNames = usedKf ? resolveKeyframesNames(usedKf) : null;\n const keyframeKeys =\n usedKf && keyframeNames\n ? holdKeyframes(usedKf, keyframeNames, { root })\n : null;\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n const chunk = processChunkSync(\n resolved,\n chunkName,\n chunkStyleKeys,\n stableStyles,\n root,\n keyframeNames,\n );\n if (chunk) chunks.push(chunk);\n }\n\n // Only the classes whose rules actually name the animation own it — one\n // that merely rendered alongside would keep it alive for its own lifetime.\n // The reference is taken once however many times this renders, and released\n // when the last owner is collected.\n if (keyframeKeys) {\n for (const chunk of chunks) {\n for (const authored of chunk.animations ?? []) {\n const key = keyframeKeys.get(authored);\n if (key) ownKeyframes(key, chunk.className, { root });\n }\n }\n }\n\n for (const chunk of chunks) {\n touch(chunk.className, { root });\n }\n }\n\n if (chunks.length === 0) return EMPTY_RESULT;\n if (chunks.length === 1) return { className: chunks[0].className };\n\n return { className: chunks.map((c) => c.className).join(' ') };\n}\n","const DOMPropNames = new Set(['id']);\n\nconst BasePropNames = new Set([\n 'role',\n 'as',\n 'element',\n 'css',\n 'qa',\n 'mods',\n 'qaVal',\n 'hidden',\n 'isHidden',\n 'disabled',\n 'isDisabled',\n 'children',\n 'style',\n 'className',\n 'href',\n 'target',\n 'tabIndex',\n]);\n\nconst ignoreEventPropsNames = new Set([\n 'onPress',\n 'onHoverStart',\n 'onHoverEnd',\n 'onPressStart',\n 'onPressEnd',\n]);\n\nconst propRe = /^((data-).*)$/;\nconst eventRe = /^on[A-Z].+$/;\n\ninterface PropsFilterOptions {\n // @deprecated\n labelable?: boolean;\n propNames?: Set<string>;\n eventProps?: boolean;\n}\n\n/**\n * Filters out all props that aren't valid DOM props or defined via override prop obj.\n * @param props - The component props to be filtered.\n * @param opts - Props to override.\n */\nexport function filterBaseProps<T extends object>(\n props: T,\n opts: PropsFilterOptions = {},\n): Partial<T> {\n const { propNames, eventProps } = opts;\n const filteredProps: Partial<T> = {};\n\n for (const prop in props) {\n if (\n Object.prototype.hasOwnProperty.call(props, prop) &&\n (DOMPropNames.has(prop) ||\n BasePropNames.has(prop) ||\n // Always preserve any ARIA attributes to maintain accessibility support.\n prop.startsWith('aria-') ||\n (eventProps &&\n eventRe.test(prop) &&\n !ignoreEventPropsNames.has(prop)) ||\n propNames?.has(prop) ||\n propRe.test(prop))\n ) {\n filteredProps[prop] = props[prop];\n }\n }\n\n return filteredProps;\n}\n","/**\n * Generate data DOM attributes from modifier map.\n */\nimport type { AllBaseProps } from '../types';\n\nimport { cacheWrapper } from './cache-wrapper';\nimport { camelToKebab } from './case-converter';\n\nfunction modAttrs(map: AllBaseProps['mods']): Record<string, string> | null {\n return map\n ? Object.keys(map).reduce(\n (attrs, key) => {\n const value = map[key];\n\n // Skip null, undefined, false\n if (value == null || value === false) {\n return attrs;\n }\n\n const attrName = `data-${camelToKebab(key)}`;\n\n if (value === true) {\n // Boolean true: data-{name}=\"\"\n attrs[attrName] = '';\n } else if (typeof value === 'string') {\n // String value: data-{name}=\"value\"\n attrs[attrName] = value;\n } else if (typeof value === 'number') {\n // Number: convert to string\n attrs[attrName] = String(value);\n } else {\n // Reject other types (objects, arrays, functions)\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[Tasty] Invalid mod value for \"${key}\". Expected boolean, string, or number, got ${typeof value}`,\n );\n }\n }\n\n return attrs;\n },\n {} as Record<string, string>,\n )\n : null;\n}\n\nconst _modAttrs = cacheWrapper(modAttrs);\n\nexport { _modAttrs as modAttrs };\n","import type { Tokens, TokenValue } from '../types';\n\nimport type { CSSProperties } from './css-types';\n\nimport { normalizeDslName } from './string';\nimport { normalizeColorTokenValue, parseStyle } from './styles';\n\nexport { hslToRgbValues } from './color-math';\n\nconst devMode = process.env.NODE_ENV !== 'production';\n\n/**\n * Check if a value is a valid token value (string, number, or boolean - not object).\n * Returns false for `false` values (they mean \"skip this token\").\n */\nfunction isValidTokenValue(\n value: unknown,\n): value is Exclude<TokenValue, undefined | null | false> {\n if (value === undefined || value === null || value === false) {\n return false;\n }\n\n if (typeof value === 'object') {\n if (devMode) {\n console.warn(\n '[Tasty] Object values are not allowed in tokens prop. ' +\n 'Tokens do not support state-based styling. Use a primitive value instead.',\n );\n }\n return false;\n }\n\n return (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n );\n}\n\n/**\n * Process a single token value through the tasty parser.\n * Numbers are converted to strings; 0 stays as \"0\".\n */\nfunction processTokenValue(value: string | number): string {\n if (typeof value === 'number') {\n // 0 should remain as \"0\", not converted to any unit\n if (value === 0) {\n return '0';\n }\n return parseStyle(String(value)).output;\n }\n return parseStyle(value).output;\n}\n\n/**\n * Resolve one `$name` / `#name` entry to the custom property it declares and\n * the value to declare, or `null` when the entry declares nothing.\n *\n * The two sigils differ only in the property name they build and in how `true`\n * is read: for a custom property it is the empty value, for a color it is\n * `transparent`.\n */\nfunction resolveTokenEntry(\n key: string,\n value: Exclude<TokenValue, undefined | null | false>,\n): [name: string, value: string] | null {\n const name = `--${normalizeDslName(key.slice(1))}`;\n\n if (key[0] === '$') {\n // Boolean true for custom properties converts to empty string (valid CSS value)\n return [name, processTokenValue(value === true ? '' : value)];\n }\n\n const colorValue = normalizeColorTokenValue(value);\n // Skip if normalized to null (shouldn't happen since false is filtered by isValidTokenValue)\n if (colorValue === null) return null;\n\n return [`${name}-color`, processTokenValue(colorValue)];\n}\n\n/**\n * Process tokens object into inline style properties.\n * - `$name` -> `--name` with the parsed value\n * - `#name` -> `--name-color` with the parsed value\n *\n * @param tokens - The tokens object to process\n * @returns CSSProperties object or undefined if no tokens to process\n */\nexport function processTokens(\n tokens: Tokens | undefined,\n): CSSProperties | undefined {\n if (!tokens) {\n return undefined;\n }\n\n const keys = Object.keys(tokens);\n if (keys.length === 0) {\n return undefined;\n }\n\n let result: Record<string, string> | undefined;\n\n for (const key of keys) {\n const value = tokens[key as keyof Tokens];\n\n // Skip undefined/null values\n if (!isValidTokenValue(value)) {\n continue;\n }\n\n if (key[0] !== '$' && key[0] !== '#') continue;\n\n const entry = resolveTokenEntry(key, value);\n if (!entry) continue;\n\n if (!result) result = {};\n result[entry[0]] = entry[1];\n }\n\n return result as CSSProperties | undefined;\n}\n","import type { ElementType } from 'react';\n\nconst DEFAULT_NAME = 'Anonymous';\n\nexport function getDisplayName<T>(\n Component: ElementType<T>,\n fallbackName = DEFAULT_NAME,\n): string {\n if (typeof Component === 'function') {\n return Component.displayName ?? Component.name ?? fallbackName;\n }\n\n return fallbackName;\n}\n","/**\n * Lightweight replacement for `react-is`'s isValidElementType.\n * Detects string tags, function/class components, and React exotic types\n * (forwardRef, memo, lazy, etc.) via their internal $$typeof symbol.\n */\nexport function isValidElementType(value: unknown): boolean {\n if (typeof value === 'string' || typeof value === 'function') {\n return true;\n }\n\n if (typeof value === 'object' && value !== null) {\n return typeof (value as { $$typeof?: unknown }).$$typeof === 'symbol';\n }\n\n return false;\n}\n","import type {\n AllHTMLAttributes,\n ComponentType,\n ElementType,\n ForwardRefExoticComponent,\n JSX,\n PropsWithoutRef,\n RefAttributes,\n} from 'react';\nimport { createElement, forwardRef, Fragment } from 'react';\nimport type {\n ComputeStylesOptions,\n ComputeStylesResult,\n} from './compute-styles';\nimport { computeStyles } from './compute-styles';\nimport type { PropHandlerProps } from './prop-handlers';\nimport { propHandlerRegistry } from './prop-handlers';\nimport { baseStylePropsRegistry } from './styles/base-props';\nimport { BASE_STYLES } from './styles/list';\nimport type { Styles, StylesInterface } from './styles/types';\nimport type {\n AllBaseProps,\n BaseProps,\n BaseStyleProps,\n ExtraBaseStyleProps,\n ModValue,\n Mods,\n TastyCustomProps,\n TokenValue,\n Tokens,\n} from './types';\nimport { getDisplayName } from './utils/get-display-name';\nimport { isValidElementType } from './utils/is-valid-element-type';\nimport { isSelector } from './utils/is-selector';\nimport { mergeStyles } from './utils/merge-styles';\nimport { hasKeys } from './utils/has-keys';\nimport { modAttrs } from './utils/mod-attrs';\nimport { processTokens } from './utils/process-tokens';\nimport { getConfig } from './config';\nimport { touch } from './injector';\n\nimport type { StyleValue, StyleValueStateMap } from './utils/styles';\n\n/**\n * Mapping of is* properties to their corresponding HTML attributes\n */\nconst IS_PROPERTIES_MAP = {\n isDisabled: 'disabled',\n isHidden: 'hidden',\n isChecked: 'checked',\n} as const;\n\n/**\n * Precalculated entries for performance optimization\n */\nconst IS_PROPERTIES_ENTRIES = Object.entries(IS_PROPERTIES_MAP);\n\n/**\n * Helper function to handle is* properties consistently\n * Transforms is* props to HTML attributes and adds corresponding data-* attributes\n */\nfunction handleIsProperties(props: Record<string, unknown>) {\n for (const [isProperty, targetAttribute] of IS_PROPERTIES_ENTRIES) {\n if (isProperty in props) {\n props[targetAttribute] = props[isProperty];\n delete props[isProperty];\n }\n\n // Add data-* attribute if target attribute is truthy and doesn't already exist\n const dataAttribute = `data-${targetAttribute}`;\n if (!(dataAttribute in props) && props[targetAttribute]) {\n props[dataAttribute] = '';\n }\n }\n}\n\n/**\n * Creates a sub-element component for compound component patterns.\n * Sub-elements are lightweight components with data-element attribute for CSS targeting.\n */\nfunction createSubElement<Tag extends keyof JSX.IntrinsicElements>(\n elementName: string,\n definition: SubElementDefinition<Tag>,\n): ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<Tag>> & RefAttributes<unknown>\n> {\n // Normalize definition to object form\n const config =\n typeof definition === 'string'\n ? { as: definition as Tag }\n : (definition as { as?: Tag; qa?: string; qaVal?: string | number });\n\n const tag = config.as ?? ('div' as Tag);\n const defaultQa = config.qa;\n const defaultQaVal = config.qaVal;\n\n const SubElement = forwardRef<unknown, SubElementProps<Tag>>((props, ref) => {\n const {\n qa,\n qaVal,\n mods,\n tokens,\n isDisabled,\n isHidden,\n isChecked,\n className,\n style,\n ...htmlProps\n } = props as SubElementProps<Tag> & {\n className?: string;\n style?: Record<string, unknown>;\n };\n\n // Build mod attributes\n let modDataAttrs: Record<string, unknown> | undefined;\n if (mods) {\n modDataAttrs = modAttrs(mods as Mods) as Record<string, unknown>;\n }\n\n // Process tokens into inline style properties\n const tokenStyle = tokens\n ? (processTokens(tokens) as Record<string, unknown>)\n : undefined;\n\n // Merge token styles with explicit style prop (style has priority)\n let mergedStyle: Record<string, unknown> | undefined;\n if (tokenStyle || style) {\n mergedStyle =\n tokenStyle && style\n ? { ...tokenStyle, ...style }\n : ((tokenStyle ?? style) as Record<string, unknown>);\n }\n\n const elementProps = {\n 'data-element': elementName,\n 'data-qa': qa ?? defaultQa,\n 'data-qaval': qaVal ?? defaultQaVal,\n ...(modDataAttrs || {}),\n ...htmlProps,\n className,\n style: mergedStyle,\n isDisabled,\n isHidden,\n isChecked,\n ref,\n } as Record<string, unknown>;\n\n // Handle is* properties (isDisabled -> disabled + data-disabled, etc.)\n handleIsProperties(elementProps);\n\n // Clean up undefined data attributes\n if (elementProps['data-qa'] === undefined) delete elementProps['data-qa'];\n if (elementProps['data-qaval'] === undefined)\n delete elementProps['data-qaval'];\n\n return createElement(tag, elementProps);\n });\n\n SubElement.displayName = `SubElement(${elementName})`;\n\n return SubElement as ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<Tag>> & RefAttributes<unknown>\n >;\n}\n\ntype StyleList = readonly (keyof {\n [key in keyof StylesInterface]: StylesInterface[key];\n})[];\n\n// ============================================================================\n// Mod props types — expose modifier keys as top-level component props\n// ============================================================================\n\n/** Type descriptor for a single mod prop: a JS constructor or an enum array. */\nexport type ModPropDef =\n | BooleanConstructor\n | StringConstructor\n | NumberConstructor\n | readonly string[];\n\n/** Array form: list of mod key names (types default to ModValue). */\ntype ModPropsList = readonly string[];\n\n/** Object form: map of mod key names to type descriptors. */\ntype ModPropsMap = Readonly<Record<string, ModPropDef>>;\n\n/** Either array or object form accepted by `modProps` option. */\nexport type ModPropsInput = ModPropsList | ModPropsMap;\n\n/** Resolve a single ModPropDef to its TypeScript type. */\nexport type ResolveModPropDef<T> = T extends BooleanConstructor\n ? boolean\n : T extends StringConstructor\n ? string\n : T extends NumberConstructor\n ? number\n : T extends readonly (infer U)[]\n ? U\n : ModValue;\n\n/** Resolve an entire `modProps` definition to the component prop types it adds. */\nexport type ResolveModProps<M extends ModPropsInput> =\n M extends readonly (infer K)[]\n ? Partial<Record<K & string, ModValue>>\n : M extends Record<string, ModPropDef>\n ? { [key in keyof M & string]?: ResolveModPropDef<M[key]> }\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\n// ============================================================================\n// Token props types — expose token keys as top-level component props\n// ============================================================================\n\n/** A token key with `$` or `#` prefix. */\ntype TokenPropKey = `$${string}` | `#${string}`;\n\n/** Array form: list of prop names. Names ending in `Color` map to `#` color tokens. */\ntype TokenPropsList = readonly string[];\n\n/** Object form: prop name -> token key with explicit `$`/`#` prefix. */\ntype TokenPropsMap = Readonly<Record<string, TokenPropKey>>;\n\n/** Either array or object form accepted by `tokenProps` option. */\nexport type TokenPropsInput = TokenPropsList | TokenPropsMap;\n\n/** Resolve a `tokenProps` definition to the component prop types it adds. */\nexport type ResolveTokenProps<TP extends TokenPropsInput> =\n TP extends readonly (infer K)[]\n ? Partial<Record<K & string, TokenValue>>\n : TP extends Record<string, TokenPropKey>\n ? Partial<Record<keyof TP & string, TokenValue>>\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\n/**\n * Pre-compute the mapping from prop name to token key at component-creation time.\n * Array form: `'progress'` -> `'$progress'`, `'accentColor'` -> `'#accent'`.\n * Object form: entries used as-is.\n */\nfunction buildTokenPropsMapping(\n def: TokenPropsInput,\n): [propName: string, tokenKey: string][] {\n if (Array.isArray(def)) {\n return (def as string[]).map((propName) => {\n if (propName.endsWith('Color') && propName.length > 5) {\n return [propName, `#${propName.slice(0, -5)}`];\n }\n return [propName, `$${propName}`];\n });\n }\n return Object.entries(def);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyProps = Record<string, any>;\n\ntype PropsWithStyles = {\n styles?: Styles;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Omit<Record<string, any>, 'styles'>;\n\nexport type VariantMap = Record<string, Styles>;\n\nexport interface WithVariant<V extends VariantMap> {\n variant?: keyof V;\n}\n\n// ============================================================================\n// Sub-element types for compound components\n// ============================================================================\n\n/**\n * Definition for a sub-element. Can be either:\n * - A tag name string (e.g., 'div', 'span')\n * - An object with configuration options\n */\nexport type SubElementDefinition<\n Tag extends keyof JSX.IntrinsicElements = 'div',\n> =\n | Tag\n | {\n as?: Tag;\n qa?: string;\n qaVal?: string | number;\n };\n\n/**\n * Map of sub-element definitions.\n * Keys become the sub-component names (e.g., { Icon: 'span' } -> Component.Icon)\n */\nexport type ElementsDefinition = Record<\n string,\n SubElementDefinition<keyof JSX.IntrinsicElements>\n>;\n\n/**\n * Resolves the tag from a SubElementDefinition\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ResolveElementTag<T extends SubElementDefinition<any>> = T extends string\n ? T\n : T extends { as?: infer Tag }\n ? Tag extends keyof JSX.IntrinsicElements\n ? Tag\n : 'div'\n : 'div';\n\n/**\n * Props for sub-element components.\n * Combines HTML attributes with tasty-specific props (qa, qaVal, mods, tokens, isDisabled, etc.)\n */\nexport type SubElementProps<Tag extends keyof JSX.IntrinsicElements = 'div'> =\n Omit<\n JSX.IntrinsicElements[Tag],\n 'ref' | 'color' | 'content' | 'translate'\n > & {\n qa?: string;\n qaVal?: string | number;\n mods?: Mods;\n tokens?: Tokens;\n isDisabled?: boolean;\n isHidden?: boolean;\n isChecked?: boolean;\n };\n\n/**\n * Generates the sub-element component types from an ElementsDefinition\n */\ntype SubElementComponents<E extends ElementsDefinition> = {\n [K in keyof E]: ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<ResolveElementTag<E[K]>>> &\n RefAttributes<\n ResolveElementTag<E[K]> extends keyof HTMLElementTagNameMap\n ? HTMLElementTagNameMap[ResolveElementTag<E[K]>]\n : Element\n >\n >;\n};\n\n/**\n * Base type containing common properties shared between TastyProps and TastyElementOptions.\n * Separated to avoid code duplication while allowing different type constraints.\n */\ntype TastyBaseProps<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = {\n /** Default styles of the element. */\n styles?: Styles;\n /** The list of styles that can be provided by props */\n styleProps?: K;\n /** Modifier keys exposed as top-level component props (array or typed object form). */\n modProps?: M;\n /** Token keys exposed as top-level component props (array or typed object form). */\n tokenProps?: TP;\n element?: BaseProps['element'];\n variants?: V;\n /** Default tokens for inline CSS custom properties */\n tokens?: Tokens;\n /** Sub-element definitions for compound components */\n elements?: E;\n} & Pick<BaseProps, 'qa' | 'qaVal'> &\n WithVariant<V>;\n\nexport type TastyProps<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n DefaultProps = AnyProps,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = TastyBaseProps<K, V, E, M, TP> & {\n /** The tag name of the element or a React component. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n as?: string | ComponentType<any>;\n} & Partial<\n Omit<\n DefaultProps,\n 'as' | 'styles' | 'styleProps' | 'modProps' | 'tokenProps' | 'tokens'\n >\n >;\n\n/**\n * Resolves the props of a polymorphic `as` value (intrinsic tag or component).\n * - For intrinsic tags (`'div'`, `'button'`, ...): returns `JSX.IntrinsicElements[Tag]`.\n * - For React component types: returns the component's own props.\n * - Falls back to an empty record for anything else.\n */\nexport type ResolveAsProps<AsType extends ElementType> =\n AsType extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[AsType]\n : AsType extends ComponentType<infer P>\n ? P\n : Record<string, never>;\n\n/**\n * TastyElementOptions is used for the element-creation overload of tasty().\n * It includes an `AsType` generic that allows TypeScript to infer the correct\n * element type from the `as` prop — both for intrinsic tags and for React\n * components (so the wrapped component's prop API is preserved).\n *\n * Note: Uses a separate index signature with `unknown` instead of an `any`\n * record to ensure strict type checking for styles.\n */\nexport type TastyElementOptions<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = TastyBaseProps<K, V, E, M, TP> & {\n /** The tag name of the element or a React component. */\n as?: AsType;\n} & Record<string, unknown>;\n\nexport type AllBasePropsWithMods<\n K extends StyleList,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = AllBaseProps & {\n [key in K[number]]?:\n StyleValue<StylesInterface[key]> | StyleValueStateMap<StylesInterface[key]>;\n} & BaseStyleProps &\n ExtraBaseStyleProps &\n Partial<TastyCustomProps> &\n ResolveModProps<M> &\n ResolveTokenProps<TP>;\n\n/**\n * Keys from BasePropsWithoutChildren that should be omitted from HTML attributes.\n * This excludes event handlers so they can be properly typed from JSX.IntrinsicElements.\n */\ntype TastySpecificKeys =\n | 'as'\n | 'qa'\n | 'qaVal'\n | 'element'\n | 'styles'\n | 'mods'\n | 'isHidden'\n | 'isDisabled'\n | 'isChecked'\n | 'style'\n | 'theme'\n | 'tokens'\n | 'ref'\n | 'color';\n\n/** Extract prop key names from a ModPropsInput (array elements or object keys). */\ntype ModPropsKeys<M extends ModPropsInput> = M extends readonly (infer K)[]\n ? K & string\n : keyof M & string;\n\n/** Extract prop key names from a TokenPropsInput (array elements or object keys). */\ntype TokenPropsKeys<TP extends TokenPropsInput> =\n TP extends readonly (infer K)[] ? K & string : keyof TP & string;\n\n/**\n * Props type for tasty elements that combines:\n * - AllBasePropsWithMods for style props with strict tokens type\n * - HTML attributes for flexibility (properly typed based on `as`)\n * - Variant support\n *\n * AllBasePropsWithMods carries generic AllHTMLAttributes which can conflict\n * with element-specific types (e.g. `src` is `string` in AllHTMLAttributes but\n * `string | Blob` in ImgHTMLAttributes, or the custom props on a third-party\n * component like Next.js `Link`). To avoid intersection-narrowing, we Omit\n * element-specific keys from AllBasePropsWithMods (keeping TastySpecificKeys,\n * style props, mod props, and token props) and let the resolved `as` props\n * supply the authoritative attribute types. The `AllHTMLAttributes<HTMLElement>`\n * baseline is preserved so generic HTML attributes still work even when `as`\n * is a component type with a narrower prop API.\n */\nexport type TastyElementProps<\n K extends StyleList,\n V extends VariantMap,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = Omit<\n AllBasePropsWithMods<K, M, TP>,\n Exclude<\n keyof ResolveAsProps<AsType>,\n | TastySpecificKeys\n | keyof TastyCustomProps\n | keyof ExtraBaseStyleProps\n | K[number]\n | ModPropsKeys<M>\n | TokenPropsKeys<TP>\n >\n> &\n WithVariant<V> &\n Omit<\n Omit<AllHTMLAttributes<HTMLElement>, keyof ResolveAsProps<AsType>> &\n ResolveAsProps<AsType>,\n | TastySpecificKeys\n | keyof TastyCustomProps\n | keyof ExtraBaseStyleProps\n | K[number]\n | ModPropsKeys<M>\n | TokenPropsKeys<TP>\n >;\n\nexport type TastyComponentPropsWithDefaults<\n Props extends PropsWithStyles,\n DefaultProps extends Partial<Props>,\n> = keyof DefaultProps extends never\n ? Props\n : {\n [key in Extract<keyof Props, keyof DefaultProps>]?: Props[key];\n } & {\n [key in keyof Omit<Props, keyof DefaultProps>]: Props[key];\n };\n\n/**\n * The component type returned by the `tasty(options)` element-factory overload.\n *\n * It's a regular React forward-ref component whose props are typed from the\n * factory-time `as` value. Polymorphism is at factory time: each call to\n * `tasty({ as: X })` produces a component whose prop API includes `X`'s own\n * props (so `tasty({ as: NextLink })` exposes `href`, `replace`, `prefetch`,\n * etc.) alongside the Tasty-specific props (`mods`, `tokens`, `styleProps`,\n * `modProps`, `tokenProps`).\n *\n * Note: a render-time `<X as={SomeComponent} />` does not re-infer props from\n * `SomeComponent`; create another `tasty({ as: SomeComponent })` for that.\n */\nexport type TastyPolymorphicComponent<\n DefaultAs extends ElementType,\n K extends StyleList,\n V extends VariantMap,\n M extends ModPropsInput,\n TP extends TokenPropsInput,\n> = ForwardRefExoticComponent<\n PropsWithoutRef<TastyElementProps<K, V, DefaultAs, M, TP>> &\n RefAttributes<unknown>\n>;\n\nexport function tasty<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n options: TastyElementOptions<K, V, E, AsType, M, TP>,\n secondArg?: never,\n): TastyPolymorphicComponent<AsType, K, V, M, TP> & SubElementComponents<E>;\nexport function tasty<\n Props extends PropsWithStyles,\n DefaultProps extends Partial<Props> = Partial<Props>,\n K extends StyleList = readonly never[],\n V extends VariantMap = VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n Component: ComponentType<Props>,\n options?: TastyProps<K, V, E, Props, M, TP>,\n): ComponentType<TastyComponentPropsWithDefaults<Props, DefaultProps>>;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// Implementation\nexport function tasty<\n K extends StyleList,\n V extends VariantMap,\n _C = Record<string, unknown>,\n>(Component: any, options?: any) {\n if (isValidElementType(Component)) {\n return tastyWrap(Component as ComponentType<any>, options);\n }\n\n return tastyElement(Component as TastyProps<K, V>);\n}\n\nfunction tastyWrap<\n P extends PropsWithStyles,\n DefaultProps extends Partial<P> = Partial<P>,\n K extends StyleList = readonly never[],\n V extends VariantMap = VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n Component: ComponentType<P>,\n options?: TastyProps<K, V, E, P, M, TP>,\n): ComponentType<TastyComponentPropsWithDefaults<P, DefaultProps>> {\n // The wrap path forwards default props + merges `styles`/`*Styles` props.\n // Factory-only options (`styleProps`, `modProps`, `tokenProps`, `variants`,\n // `elements`) are stripped here, not forwarded to the wrapped component.\n const {\n as: extendTag,\n element: extendElement,\n styleProps: _styleProps,\n modProps: _modProps,\n tokenProps: _tokenProps,\n variants: _variants,\n elements: _elements,\n ...defaultProps\n } = (options ?? {}) as TastyProps<K, V, E, P, M, TP>;\n\n const propsWithStyles = ['styles'].concat(\n Object.keys(defaultProps).filter((prop) => prop.endsWith('Styles')),\n );\n\n const _WrappedComponent = forwardRef<any, any>((props, ref) => {\n const { as, element, ...restProps } = props as Record<string, unknown>;\n\n const mergedStylesMap = propsWithStyles.reduce(\n (map, prop) => {\n const restValue = (restProps as any)[prop];\n const defaultValue = (defaultProps as any)[prop];\n\n if (restValue != null && defaultValue != null) {\n (map as any)[prop] = mergeStyles(defaultValue, restValue);\n } else {\n (map as any)[prop] = restValue ?? defaultValue;\n }\n\n return map;\n },\n {} as Record<string, unknown>,\n );\n\n const elementProps = {\n ...(defaultProps as unknown as Record<string, unknown>),\n ...(restProps as unknown as Record<string, unknown>),\n ...mergedStylesMap,\n as: (as as string | undefined) ?? extendTag,\n element: (element as string | undefined) || extendElement,\n ref,\n } as unknown as P;\n\n return createElement(Component as ComponentType<P>, elementProps);\n });\n\n _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(\n Component,\n (defaultProps as any).qa ?? (extendTag as any) ?? 'Anonymous',\n )})`;\n\n return _WrappedComponent as unknown as ComponentType<\n TastyComponentPropsWithDefaults<P, DefaultProps>\n >;\n}\n\nfunction tastyElement<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition,\n>(tastyOptions: TastyProps<K, V, E>) {\n const {\n as: originalAs = 'div',\n element: defaultElement,\n styles: defaultStyles,\n styleProps,\n modProps: modPropsDef,\n tokenProps: tokenPropsDef,\n variants,\n tokens: defaultTokens,\n elements,\n ...defaultProps\n } = tastyOptions;\n\n // Pre-compute merged styles for each variant (if variants are defined)\n // This avoids creating separate component instances per variant\n let variantStylesMap: Record<string, Styles | undefined> | undefined;\n if (variants) {\n // Split defaultStyles: extend-mode state maps (no '' key, non-selector)\n // are pulled out and applied AFTER variant merge so they survive\n // replace-mode maps in variants.\n let baseStyles = defaultStyles;\n let extensionStyles: Styles | undefined;\n\n if (defaultStyles) {\n for (const key of Object.keys(defaultStyles)) {\n if (isSelector(key)) continue;\n\n const value = (defaultStyles as Record<string, unknown>)[key];\n\n if (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !('' in value)\n ) {\n if (!extensionStyles) {\n baseStyles = { ...defaultStyles } as Styles;\n extensionStyles = {} as Styles;\n }\n (extensionStyles as Record<string, unknown>)[key] = value;\n delete (baseStyles as Record<string, unknown>)[key];\n }\n }\n }\n\n const variantEntries = Object.entries(variants) as [string, Styles][];\n variantStylesMap = variantEntries.reduce(\n (map, [variant, variantStyles]) => {\n map[variant] = extensionStyles\n ? mergeStyles(baseStyles, variantStyles, extensionStyles)\n : mergeStyles(baseStyles, variantStyles);\n return map;\n },\n {} as Record<string, Styles | undefined>,\n );\n // Ensure 'default' variant always exists\n if (!variantStylesMap['default']) {\n variantStylesMap['default'] = defaultStyles;\n }\n }\n\n const {\n qa: defaultQa,\n qaVal: defaultQaVal,\n ...otherDefaultProps\n } = defaultProps ?? {};\n\n // Fixed at factory-creation time — no dependency on global config.\n const ownPropsToCheck: readonly string[] = styleProps\n ? (styleProps as StyleList).concat(BASE_STYLES)\n : BASE_STYLES;\n\n // Resolved lazily and refreshed on registry version change. `configure()` can\n // run *after* this factory was created (module eval order — see `Element` at\n // the bottom of this file), and `resetConfig()` reopens configuration, so a\n // one-shot lazy init would go stale. Starts at -1 to force first resolution.\n let propsToCheck: readonly string[] = ownPropsToCheck;\n let propsToCheckVersion = -1;\n\n const modPropsKeys: string[] | undefined = modPropsDef\n ? ((Array.isArray(modPropsDef)\n ? modPropsDef\n : Object.keys(modPropsDef)) as string[])\n : undefined;\n\n const tokenPropsMapping: [string, string][] | undefined = tokenPropsDef\n ? buildTokenPropsMapping(tokenPropsDef as TokenPropsInput)\n : undefined;\n\n // Factory-level cache: maps stable style references to computed classNames.\n // For the common case (no instance overrides), this avoids recomputation.\n const classNameCache = new Map<Styles | undefined, string>();\n\n // Passed when the styles object handed to computeStyles() is the factory's\n // own AND computeStyles() will see it again — which is only true where\n // classNameCache is unavailable, i.e. the server. On the client that cache\n // answers every render after the first, so memoizing chunk keys during that\n // first render would write entries nothing ever reads back. Hoisted so the\n // hot path does not allocate it.\n const STABLE_STYLES: ComputeStylesOptions = { stableStyles: true };\n\n const _TastyComponent = forwardRef<\n unknown,\n AllBasePropsWithMods<K> & WithVariant<V>\n >((incomingProps, ref) => {\n // Global props middleware (`configure({ propHandlers })`). Runs before any\n // destructuring so a handler can rewrite every tasty prop — `styles`, `mods`,\n // `tokens`, `variant`, `as`, `element`, `qa` — and strip its own custom props\n // so they never reach the DOM. `ref` is out of reach: forwardRef separates it.\n // Fast path while nothing is registered: one property load and one branch.\n const applyPropHandlers = propHandlerRegistry.apply;\n const allProps = applyPropHandlers\n ? (applyPropHandlers(\n incomingProps as unknown as PropHandlerProps,\n ) as unknown as typeof incomingProps)\n : incomingProps;\n\n const {\n as,\n styles: rawStyles,\n variant,\n mods,\n element,\n qa,\n qaVal,\n className: userClassName,\n tokens,\n style,\n theme,\n ...otherProps\n } = allProps as Record<string, unknown> as AllBasePropsWithMods<K> &\n WithVariant<V> & {\n className?: string;\n tokens?: Tokens;\n style?: Record<string, unknown>;\n theme?: string;\n };\n\n let styles = rawStyles;\n\n let propStyles: Styles | null = null;\n\n if (propsToCheckVersion !== baseStylePropsRegistry.version) {\n const promoted = baseStylePropsRegistry.list;\n\n propsToCheck =\n promoted.length === 0\n ? ownPropsToCheck\n : ownPropsToCheck.concat(promoted);\n propsToCheckVersion = baseStylePropsRegistry.version;\n }\n\n for (const prop of propsToCheck) {\n const key = prop as unknown as string;\n\n if (key in otherProps) {\n if (!propStyles) propStyles = {};\n const value = (otherProps as any)[key];\n (propStyles as any)[key] = value;\n delete (otherProps as any)[key];\n }\n }\n\n if (!styles || (styles && !hasKeys(styles as Record<string, unknown>))) {\n styles = undefined as unknown as Styles;\n }\n\n let propMods: Record<string, ModValue> | undefined;\n if (modPropsKeys) {\n for (const key of modPropsKeys) {\n if (key in otherProps) {\n if (!propMods) propMods = {};\n propMods[key] = (otherProps as Record<string, unknown>)[\n key\n ] as ModValue;\n delete (otherProps as Record<string, unknown>)[key];\n }\n }\n }\n\n let propTokens: Tokens | undefined;\n if (tokenPropsMapping) {\n for (const [propName, tokenKey] of tokenPropsMapping) {\n if (propName in otherProps) {\n if (!propTokens) propTokens = {} as Tokens;\n (propTokens as Record<string, TokenValue>)[tokenKey] = (\n otherProps as Record<string, unknown>\n )[propName] as TokenValue;\n delete (otherProps as Record<string, unknown>)[propName];\n }\n }\n }\n\n const baseStyles = variantStylesMap\n ? (variantStylesMap[(variant as string) || 'default'] ??\n variantStylesMap['default'])\n : defaultStyles;\n\n const hasInstanceStyles =\n styles && hasKeys(styles as Record<string, unknown>);\n const hasPropStyles = propStyles && hasKeys(propStyles);\n\n const allStyles =\n hasInstanceStyles || hasPropStyles\n ? mergeStyles(baseStyles, styles as Styles, propStyles as Styles)\n : baseStyles;\n\n // Use factory-level cache for stable style references (client only).\n // On the server the cache must be skipped: both the SSR collector and\n // the RSC inline-style paths are per-request, so every request must\n // call computeStyles() to ensure CSS is actually collected/emitted.\n const useFactoryCache = typeof document !== 'undefined';\n let stylesResult: ComputeStylesResult;\n if (\n useFactoryCache &&\n allStyles === baseStyles &&\n classNameCache.has(allStyles)\n ) {\n stylesResult = { className: classNameCache.get(allStyles)! };\n touch(stylesResult.className);\n } else {\n stylesResult = computeStyles(\n allStyles,\n !useFactoryCache && allStyles === baseStyles\n ? STABLE_STYLES\n : undefined,\n );\n if (useFactoryCache && allStyles === baseStyles) {\n classNameCache.set(allStyles, stylesResult.className);\n }\n }\n\n // Merge tokens: default -> instance -> tokenProps\n let mergedTokens: Tokens | undefined;\n if (defaultTokens || tokens || propTokens) {\n if (!defaultTokens && !propTokens) {\n mergedTokens = tokens as Tokens;\n } else if (!tokens && !propTokens) {\n mergedTokens = defaultTokens;\n } else {\n mergedTokens = {\n ...defaultTokens,\n ...(tokens as Tokens),\n ...propTokens,\n } as Tokens;\n }\n }\n\n const processedTokenStyle = processTokens(mergedTokens);\n\n let mergedStyle: Record<string, unknown> | undefined;\n if (processedTokenStyle || style) {\n if (!processedTokenStyle) {\n mergedStyle = style;\n } else if (!style) {\n mergedStyle = processedTokenStyle as Record<string, unknown>;\n } else {\n mergedStyle = {\n ...(processedTokenStyle as Record<string, unknown>),\n ...style,\n };\n }\n }\n\n const mergedMods = propMods\n ? { ...(mods as Record<string, ModValue>), ...propMods }\n : (mods as Record<string, ModValue> | undefined);\n\n let modDataAttrs: Record<string, unknown> | undefined;\n if (mergedMods) {\n modDataAttrs = modAttrs(mergedMods as unknown as Mods) as Record<\n string,\n unknown\n >;\n }\n\n const finalClassName = [\n (userClassName as string) || '',\n stylesResult.className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const elementProps = {\n 'data-element': (element as string | undefined) || defaultElement,\n 'data-qa': (qa as string | undefined) || defaultQa,\n 'data-qaval': (qaVal as string | undefined) || defaultQaVal,\n 'data-theme': theme,\n ...(otherDefaultProps as unknown as Record<string, unknown>),\n ...(modDataAttrs || {}),\n ...(otherProps as unknown as Record<string, unknown>),\n className: finalClassName,\n style: mergedStyle,\n ref,\n } as Record<string, unknown>;\n\n handleIsProperties(elementProps);\n\n if (elementProps['data-theme'] === undefined) {\n delete elementProps['data-theme'];\n }\n\n const el = createElement(\n (as as string | 'div') ?? originalAs,\n elementProps,\n );\n\n // RSC mode: wrap element with inline <style> tag.\n // Class names are extracted from these tags on the client via\n // the doubled-specificity pattern (.tXXX.tXXX), so no <script> is needed.\n if (stylesResult.css) {\n const nonce = getConfig().nonce;\n\n return createElement(\n Fragment,\n null,\n createElement('style', {\n 'data-tasty-rsc': '',\n nonce,\n dangerouslySetInnerHTML: { __html: stylesResult.css },\n }),\n el,\n );\n }\n\n return el;\n });\n\n _TastyComponent.displayName = `TastyComponent(${\n (defaultProps as any).qa || originalAs\n })`;\n\n // Attach sub-element components if elements are defined\n if (elements) {\n const subElements = Object.entries(elements).reduce(\n (acc, [name, definition]) => {\n acc[name] = createSubElement(\n name,\n definition as SubElementDefinition<keyof JSX.IntrinsicElements>,\n );\n return acc;\n },\n {} as Record<string, ForwardRefExoticComponent<any>>,\n );\n\n return Object.assign(_TastyComponent, subElements);\n }\n\n return _TastyComponent;\n}\n\nexport const Element = /* @__PURE__ */ tasty({});\n","/**\n * React context for SSR collector discovery.\n *\n * Used by Next.js TastyRegistry to provide the ServerStyleCollector\n * to useStyles() via React context (the streaming-compatible path).\n *\n * This avoids relying on globalThis for cross-layer communication,\n * which leaks between RSC and SSR module graphs in Next.js App Router.\n *\n * The context is created lazily to avoid calling createContext() at\n * module evaluation time, which would break Server Components that\n * import from `@tenphi/tasty` without using any React hooks.\n */\n\nimport { createContext, type Context } from 'react';\n\nimport type { ServerStyleCollector } from './collector';\n\nlet _ctx: Context<ServerStyleCollector | null> | undefined;\n\nexport function getTastySSRContext(): Context<ServerStyleCollector | null> {\n if (!_ctx) {\n _ctx = createContext<ServerStyleCollector | null>(null);\n }\n return _ctx;\n}\n","import { useContext } from 'react';\n\nimport { computeStyles } from '../compute-styles';\nimport { getTastySSRContext } from '../ssr/context';\nimport type { Styles } from '../styles/types';\n\nexport interface UseStylesResult {\n /**\n * Generated className(s) to apply to the element.\n * Can be empty string if no styles are provided.\n * With chunking enabled, may contain multiple space-separated class names.\n */\n className: string;\n}\n\n/**\n * Hook to generate CSS classes from Tasty styles.\n * Thin wrapper around `computeStyles()` that adds React context-based\n * SSR collector discovery for backward compatibility with TastyRegistry.\n *\n * For hook-free usage (e.g. in server components), use `computeStyles()` directly.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { className } = useStyles({\n * padding: '2x',\n * fill: '#purple',\n * radius: '1r',\n * });\n *\n * return <div className={className}>Styled content</div>;\n * }\n * ```\n */\nexport function useStyles(\n styles: Styles | undefined,\n options?: { root?: Document | ShadowRoot },\n): UseStylesResult {\n return computeStyles(styles, {\n ssrCollector: useContext(getTastySSRContext()),\n root: options?.root,\n });\n}\n","import { getConfig } from '../config';\nimport { injectGlobal } from '../injector';\nimport type { StyleResult } from '../pipeline';\nimport { renderStyles } from '../pipeline';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport {\n collectAutoInferredProperties,\n collectAutoInferredPropertiesRSC,\n} from '../ssr/collect-auto-properties';\nimport { formatGlobalRules } from '../ssr/format-global-rules';\nimport type { Styles } from '../styles/types';\nimport { createClientState } from '../utils/client-state';\nimport { hashString } from '../utils/hash';\nimport { resolveRecipes } from '../utils/resolve-recipes';\n\ninterface UseGlobalStylesOptions {\n /**\n * Stable identifier for update tracking (client-only). When provided,\n * changing the styles will dispose the previous injection and inject the\n * new one. Without an id, the selector is used as the slot key.\n * In RSC mode, renders are single-pass so update tracking does not apply.\n */\n id?: string;\n /** Shadow root or document to inject into (client only). */\n root?: Document | ShadowRoot;\n}\n\ninterface ClientGlobalEntry {\n stylesKey: string;\n dispose: () => void;\n}\n\nconst getClientGlobalSlots = /* @__PURE__ */ createClientState(\n () => new Map<string, ClientGlobalEntry>(),\n);\n\nconst noop = () => {\n /* nothing to dispose */\n};\n\n/**\n * Inject global styles for a given selector.\n * Useful for styling elements by selector without generating classNames.\n *\n * SSR-aware: when a ServerStyleCollector is available, CSS is collected\n * during the render phase instead of being injected into the DOM.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Injected styles are permanent — they are not cleaned up on component unmount.\n * Use the `id` option for update tracking when styles change over the\n * component lifecycle.\n *\n * Update tracking is per-slot and per-root: a slot (`id`, or the selector when\n * no `id` is given) holds exactly one injection per `root`. Changing the styles\n * replaces it; rendering styles that produce no CSS clears it.\n *\n * @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')\n * @param styles - Tasty styles object\n * @param options - Optional settings including `id` for update tracking\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * useGlobalStyles('.card', {\n * padding: '2x',\n * radius: '1r',\n * fill: '#white',\n * });\n *\n * return <div className=\"card\">Content</div>;\n * }\n * ```\n */\nexport function useGlobalStyles(\n selector: string,\n styles?: Styles,\n options?: UseGlobalStylesOptions,\n): void {\n if (!styles) return;\n\n if (!selector) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n '[Tasty] useGlobalStyles: selector is required and cannot be empty. ' +\n 'Styles will not be injected.',\n );\n }\n return;\n }\n\n const target = getStyleTarget();\n\n // Resolve the client slot once — both the fast path below and the injection\n // at the end need it.\n const slots =\n target.mode === 'client'\n ? getClientGlobalSlots(options?.root ?? document)\n : null;\n const slotKey = options?.id ?? selector;\n const stylesKey = slots ? JSON.stringify(styles) : '';\n const existing = slots?.get(slotKey);\n\n // Client fast path: skip resolveRecipes/renderStyles if styles haven't changed\n if (existing && existing.stylesKey === stylesKey) return;\n\n const resolvedStyles = resolveRecipes(styles);\n\n const styleResults = renderStyles(resolvedStyles, selector) as StyleResult[];\n\n if (styleResults.length === 0) {\n // An update that renders no CSS must still clear the slot's previous\n // injection, otherwise the stale rules keep applying to the selector.\n if (slots) {\n existing?.dispose();\n slots.set(slotKey, { stylesKey, dispose: noop });\n }\n return;\n }\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatGlobalRules(styleResults);\n if (css) {\n // A slot key (explicit `id`) replaces, matching client update tracking;\n // content-hashed keys only dedup.\n const key = options?.id\n ? `global:${options.id}`\n : `global:${selector}:${hashString(css)}`;\n target.collector.collectGlobalStyles(key, css, options?.id != null);\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n collectAutoInferredProperties(\n styleResults,\n target.collector,\n resolvedStyles,\n );\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatGlobalRules(styleResults);\n if (css) {\n const key = options?.id\n ? `__global:${options.id}`\n : `__global:${selector}:${hashString(css)}`;\n pushRSCCSS(target.cache, key, css, options?.id != null);\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n collectAutoInferredPropertiesRSC(\n styleResults,\n target.cache,\n resolvedStyles,\n );\n }\n return;\n }\n\n // Client path\n if (slots) {\n existing?.dispose();\n\n const { dispose } = injectGlobal(styleResults, { root: options?.root });\n slots.set(slotKey, { stylesKey, dispose });\n }\n}\n","import { injectRawCSS } from '../injector';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { createClientState } from '../utils/client-state';\nimport { depsEqual } from '../utils/deps-equal';\nimport { hashString } from '../utils/hash';\n\ninterface UseRawCSSOptions {\n /**\n * Shadow root or document to inject into. Update tracking is per-root: the\n * same id in two roots holds a separate injection in each.\n */\n root?: Document | ShadowRoot;\n /**\n * Stable identifier for update tracking (client-only). When provided,\n * changing the CSS content will dispose the previous injection and inject\n * the new one. Without an id, deduplication is purely content-based (same\n * CSS is injected only once). In RSC mode, renders are single-pass so\n * update tracking does not apply.\n */\n id?: string;\n}\n\ninterface ClientEntry {\n contentKey: string;\n dispose: () => void;\n}\n\ninterface ClientRawCSSState {\n /** id -> the single injection that slot currently owns */\n entries: Map<string, ClientEntry>;\n /** content hashes injected without an id (permanent, deduped) */\n contentDedup: Set<string>;\n /** id -> last factory deps, to skip re-evaluating the factory */\n factoryDeps: Map<string, readonly unknown[]>;\n}\n\nconst getClientState = /* @__PURE__ */ createClientState(\n (): ClientRawCSSState => ({\n entries: new Map(),\n contentDedup: new Set(),\n factoryDeps: new Map(),\n }),\n);\n\n// Overload 1: Static CSS string\nexport function useRawCSS(css: string, options?: UseRawCSSOptions): void;\n\n// Overload 2: Factory function with dependencies\nexport function useRawCSS(\n factory: () => string,\n deps: readonly unknown[],\n options?: UseRawCSSOptions,\n): void;\n\n/**\n * Inject raw CSS text directly without parsing.\n * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.\n *\n * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts\n * with tasty's chunked style sheets.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Injected styles are permanent — they are not cleaned up on component unmount.\n * Use the `id` option for update tracking when styles change over the\n * component lifecycle.\n *\n * @example Static CSS string\n * ```tsx\n * function GlobalStyles() {\n * useRawCSS(`\n * body {\n * margin: 0;\n * padding: 0;\n * font-family: sans-serif;\n * }\n * `);\n *\n * return null;\n * }\n * ```\n *\n * @example Factory function with dependencies\n * ```tsx\n * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {\n * useRawCSS(() => `\n * :root {\n * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};\n * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};\n * }\n * `, [theme], { id: 'theme-vars' });\n *\n * return null;\n * }\n * ```\n *\n * @example With options\n * ```tsx\n * function ShadowStyles({ shadowRoot }) {\n * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });\n * return null;\n * }\n * ```\n */\nexport function useRawCSS(\n cssOrFactory: string | (() => string),\n depsOrOptions?: readonly unknown[] | UseRawCSSOptions,\n options?: UseRawCSSOptions,\n): void {\n const isFactory = typeof cssOrFactory === 'function';\n\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseRawCSSOptions | undefined);\n\n const target = getStyleTarget();\n\n const state =\n target.mode === 'client' ? getClientState(opts?.root ?? document) : null;\n\n // Client deps cache: skip factory re-evaluation when deps haven't changed\n if (isFactory && deps && opts?.id && state) {\n const cachedDeps = state.factoryDeps.get(opts.id);\n if (cachedDeps && depsEqual(cachedDeps, deps)) {\n return;\n }\n }\n\n const css = isFactory\n ? (cssOrFactory as () => string)()\n : (cssOrFactory as string);\n\n if (!css.trim()) return;\n\n if (target.mode === 'ssr') {\n // A slot key (explicit `id`) replaces, matching client update tracking;\n // content-hashed keys only dedup.\n const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;\n target.collector.collectRawCSS(key, css, opts?.id != null);\n return;\n }\n\n if (target.mode === 'rsc') {\n const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;\n pushRSCCSS(target.cache, key, css, opts?.id != null);\n return;\n }\n\n // Client path\n if (!state) return;\n\n const id = opts?.id;\n\n if (id) {\n const existing = state.entries.get(id);\n if (existing) {\n if (existing.contentKey === css) return;\n existing.dispose();\n }\n\n const { dispose } = injectRawCSS(css, opts);\n state.entries.set(id, { contentKey: css, dispose });\n if (deps) state.factoryDeps.set(id, deps);\n } else {\n const contentKey = hashString(css);\n if (state.contentDedup.has(contentKey)) return;\n state.contentDedup.add(contentKey);\n injectRawCSS(css, opts);\n }\n}\n","import { getNamePrefix } from '../config';\nimport { keyframes } from '../injector';\nimport type { KeyframesSteps } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { formatKeyframesCSS } from '../ssr/format-keyframes';\nimport { createClientState } from '../utils/client-state';\nimport { depsEqual } from '../utils/deps-equal';\nimport { hashString } from '../utils/hash';\nimport { makeKeyframeName } from '../utils/name-prefix';\n\ninterface UseKeyframesOptions {\n name?: string;\n root?: Document | ShadowRoot;\n}\n\ninterface FactoryDepsEntry {\n deps: readonly unknown[];\n name: string;\n}\n\ninterface NamedSlotEntry {\n cacheKey: string;\n dispose: () => void;\n}\n\ninterface ClientKeyframesState {\n /** cacheKey (name + serialized steps) -> generated animation name */\n contentToName: Map<string, string>;\n /** provided name -> the single injection that slot currently owns */\n namedSlots: Map<string, NamedSlotEntry>;\n /** provided name -> last factory deps, to skip re-evaluating the factory */\n factoryDeps: Map<string, FactoryDepsEntry>;\n}\n\nconst getClientState = /* @__PURE__ */ createClientState(\n (): ClientKeyframesState => ({\n contentToName: new Map(),\n namedSlots: new Map(),\n factoryDeps: new Map(),\n }),\n);\n\n/**\n * Inject CSS @keyframes and return the generated animation name.\n * Deduplicates by content — identical steps always return the same name.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Passing `name` claims a slot owned by that one call site (like `useRawCSS`'s\n * `id`): when its steps change, the previous injection is disposed and the name\n * is reused, so the rules don't accumulate. Anonymous keyframes are permanent\n * and shared by content.\n *\n * @example Basic usage - steps object is the dependency\n * ```tsx\n * function MyComponent() {\n * const bounce = useKeyframes({\n * '0%': { transform: 'scale(1)' },\n * '50%': { transform: 'scale(1.1)' },\n * '100%': { transform: 'scale(1)' },\n * });\n *\n * return <div style={{ animation: `${bounce} 1s infinite` }}>Bouncing</div>;\n * }\n * ```\n *\n * @example With custom name\n * ```tsx\n * function MyComponent() {\n * const fadeIn = useKeyframes(\n * { from: { opacity: 0 }, to: { opacity: 1 } },\n * { name: 'fadeIn' }\n * );\n *\n * return <div style={{ animation: `${fadeIn} 0.3s ease-out` }}>Fading in</div>;\n * }\n * ```\n *\n * @example Factory function with dependencies\n * ```tsx\n * function MyComponent({ scale }: { scale: number }) {\n * const pulse = useKeyframes(\n * () => ({\n * '0%': { transform: 'scale(1)' },\n * '100%': { transform: `scale(${scale})` },\n * }),\n * [scale]\n * );\n *\n * return <div style={{ animation: `${pulse} 1s infinite` }}>Pulsing</div>;\n * }\n * ```\n */\n\n// Overload 1: Static steps object\nexport function useKeyframes(\n steps: KeyframesSteps,\n options?: UseKeyframesOptions,\n): string;\n\n// Overload 2: Factory function with dependencies\nexport function useKeyframes(\n factory: () => KeyframesSteps,\n deps: readonly unknown[],\n options?: UseKeyframesOptions,\n): string;\n\n// Implementation\nexport function useKeyframes(\n stepsOrFactory: KeyframesSteps | (() => KeyframesSteps),\n depsOrOptions?: readonly unknown[] | UseKeyframesOptions,\n options?: UseKeyframesOptions,\n): string {\n const isFactory = typeof stepsOrFactory === 'function';\n\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseKeyframesOptions | undefined);\n\n const target = getStyleTarget();\n\n const clientState =\n target.mode === 'client' ? getClientState(opts?.root ?? document) : null;\n\n // Client deps cache: skip factory re-evaluation when deps haven't changed\n if (isFactory && deps && opts?.name && clientState) {\n const cached = clientState.factoryDeps.get(opts.name);\n if (cached && depsEqual(cached.deps, deps)) {\n return cached.name;\n }\n }\n\n const steps = isFactory\n ? (stepsOrFactory as () => KeyframesSteps)()\n : (stepsOrFactory as KeyframesSteps);\n\n if (!steps || Object.keys(steps).length === 0) {\n return '';\n }\n\n if (target.mode === 'ssr') {\n const actualName = target.collector.allocateKeyframeName(opts?.name);\n const css = formatKeyframesCSS(actualName, steps);\n target.collector.collectKeyframes(actualName, css);\n return actualName;\n }\n\n if (target.mode === 'rsc') {\n const serializedContent = JSON.stringify(steps);\n const key = `__kf:${opts?.name ?? ''}:${serializedContent}`;\n\n const existingName = target.cache.generatedNames.get(key);\n if (existingName) return existingName;\n\n const actualName =\n opts?.name ??\n makeKeyframeName(getNamePrefix(), hashString(serializedContent));\n const css = formatKeyframesCSS(actualName, steps);\n pushRSCCSS(target.cache, key, css);\n target.cache.generatedNames.set(key, actualName);\n return actualName;\n }\n\n // Client path: stable name via content-based dedup\n const state = clientState ?? getClientState(opts?.root ?? document);\n const serializedContent = JSON.stringify(steps);\n const cacheKey = `${opts?.name ?? ''}:${serializedContent}`;\n\n const cachedName = state.contentToName.get(cacheKey);\n if (cachedName) {\n return cachedName;\n }\n\n const providedName = opts?.name;\n\n // A named slot owns exactly one injection. When its content changes, drop the\n // previous one first: disposing frees the name so the new steps can reclaim\n // it, and it keeps old @keyframes rules from piling up in the sheet.\n if (providedName) {\n const slot = state.namedSlots.get(providedName);\n\n if (slot && slot.cacheKey !== cacheKey) {\n slot.dispose();\n // Forget the stale content too, so any other call site still passing the\n // old steps re-injects instead of pointing at a removed rule.\n state.contentToName.delete(slot.cacheKey);\n state.namedSlots.delete(providedName);\n }\n }\n\n const result = keyframes(steps, {\n name: providedName,\n root: opts?.root,\n });\n\n const name = result.toString();\n state.contentToName.set(cacheKey, name);\n\n if (providedName) {\n state.namedSlots.set(providedName, { cacheKey, dispose: result.dispose });\n\n if (deps) {\n state.factoryDeps.set(providedName, { deps, name });\n }\n }\n\n return name;\n}\n","import { getGlobalInjector } from '../config';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { formatPropertyCSS } from '../ssr/format-property';\nimport type { PropertyOptions } from '../injector/types';\n\n/**\n * Options for {@link useProperty}. Extends the shared {@link PropertyOptions}\n * (which is `PropertyDefinition` plus an optional injection `root`).\n */\nexport type UsePropertyOptions = PropertyOptions;\n\n/**\n * Register a CSS @property custom property.\n * This enables advanced features like animating custom properties.\n *\n * Note: @property rules are global and persistent once defined.\n * The function ensures the property is only registered once per root.\n *\n * Accepts tasty token syntax for the property name:\n * - `$name` → defines `--name`\n * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')\n * - `--name` → defines `--name` (legacy format)\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param name - The property token ($name, #name) or CSS property name (--name)\n * @param options - Property configuration\n *\n * @example Basic property with token syntax\n * ```tsx\n * function Spinner() {\n * useProperty('$rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n *\n * return <div className=\"spinner\" />;\n * }\n * ```\n *\n * @example Color property with token syntax (auto-sets syntax)\n * ```tsx\n * function MyComponent() {\n * useProperty('#theme', {\n * initialValue: 'red', // syntax: '<color>' is auto-set\n * });\n *\n * // Now --theme-color can be animated with CSS transitions\n * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;\n * }\n * ```\n *\n * @example Legacy format (still supported)\n * ```tsx\n * function ResizableBox() {\n * useProperty('--box-size', {\n * syntax: '<length>',\n * initialValue: '100px',\n * });\n *\n * return <div style={{ width: 'var(--box-size)' }} />;\n * }\n * ```\n */\nexport function useProperty(name: string, options?: UsePropertyOptions): void {\n if (!name) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Tasty] useProperty: property name is required`);\n }\n return;\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatPropertyCSS(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n });\n if (css) {\n target.collector.collectProperty(name, css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatPropertyCSS(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n });\n if (css) {\n pushRSCCSS(target.cache, `__prop:${name}`, css);\n }\n return;\n }\n\n const injector = getGlobalInjector();\n\n if (injector.isPropertyDefined(name, { root: options?.root })) {\n return;\n }\n\n injector.property(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n root: options?.root,\n });\n}\n","import { getGlobalInjector } from '../config';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport type { FontFaceDescriptors, FontFaceInput } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\n\ninterface UseFontFaceOptions {\n root?: Document | ShadowRoot;\n}\n\n/**\n * Inject CSS @font-face rules.\n * Permanent — no cleanup on unmount. Deduplicates by content hash.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param family - The font-family name\n * @param input - Single descriptor object or array of descriptors (for multiple weights/styles)\n * @param options - Optional settings (e.g. Shadow DOM root)\n *\n * @example Single weight\n * ```tsx\n * function App() {\n * useFontFace('Brand Sans', {\n * src: 'url(\"/fonts/brand-sans.woff2\") format(\"woff2\")',\n * fontWeight: '400 700',\n * fontDisplay: 'swap',\n * });\n *\n * return <div style={{ fontFamily: '\"Brand Sans\", sans-serif' }}>Hello</div>;\n * }\n * ```\n *\n * @example Multiple weights\n * ```tsx\n * function App() {\n * useFontFace('Brand Sans', [\n * { src: 'url(\"/fonts/brand-regular.woff2\") format(\"woff2\")', fontWeight: 400, fontDisplay: 'swap' },\n * { src: 'url(\"/fonts/brand-bold.woff2\") format(\"woff2\")', fontWeight: 700, fontDisplay: 'swap' },\n * ]);\n *\n * return <div style={{ fontFamily: '\"Brand Sans\", sans-serif' }}>Hello</div>;\n * }\n * ```\n */\nexport function useFontFace(\n family: string,\n input: FontFaceInput,\n options?: UseFontFaceOptions,\n): void {\n if (!family) return;\n\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n target.collector.collectFontFace(hash, css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n pushRSCCSS(target.cache, `__ff:${hash}`, css);\n }\n return;\n }\n\n const injector = getGlobalInjector();\n for (const desc of descriptors) {\n injector.fontFace(family, desc, { root: options?.root });\n }\n}\n","import { getGlobalInjector, getNamePrefix } from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport type { CounterStyleDescriptors } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { createClientState } from '../utils/client-state';\nimport { hashString } from '../utils/hash';\nimport { makeCounterStyleName } from '../utils/name-prefix';\n\ninterface UseCounterStyleOptions {\n name?: string;\n root?: Document | ShadowRoot;\n}\n\nlet clientCounterStyleCounter = 0;\n\nconst getClientContentToName = /* @__PURE__ */ createClientState(\n () => new Map<string, string>(),\n);\n\n/**\n * Inject a CSS @counter-style rule and return the generated name.\n * Permanent — no cleanup on unmount. Deduplicates by name.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @example Basic usage\n * ```tsx\n * function EmojiList() {\n * const styleName = useCounterStyle({\n * system: 'cyclic',\n * symbols: '\"👍\"',\n * suffix: '\" \"',\n * }, { name: 'thumbs' });\n *\n * return (\n * <ol style={{ listStyleType: styleName }}>\n * <li>First</li>\n * <li>Second</li>\n * </ol>\n * );\n * }\n * ```\n *\n */\nexport function useCounterStyle(\n descriptors: CounterStyleDescriptors,\n options?: UseCounterStyleOptions,\n): string {\n if (!descriptors || !descriptors.system) {\n return '';\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n const actualName = target.collector.allocateCounterStyleName(options?.name);\n const css = formatCounterStyleRule(actualName, descriptors);\n target.collector.collectCounterStyle(actualName, css);\n return actualName;\n }\n\n if (target.mode === 'rsc') {\n const serializedContent = JSON.stringify(descriptors);\n const key = `__cs:${options?.name ?? ''}:${serializedContent}`;\n\n const existingName = target.cache.generatedNames.get(key);\n if (existingName) return existingName;\n\n const actualName =\n options?.name ??\n makeCounterStyleName(getNamePrefix(), hashString(serializedContent));\n const css = formatCounterStyleRule(actualName, descriptors);\n pushRSCCSS(target.cache, key, css);\n target.cache.generatedNames.set(key, actualName);\n return actualName;\n }\n\n // Client path: stable name via content-based dedup\n const contentToName = getClientContentToName(options?.root ?? document);\n const serializedContent = JSON.stringify(descriptors);\n const cacheKey = `${options?.name ?? ''}:${serializedContent}`;\n\n const existingName = contentToName.get(cacheKey);\n if (existingName) {\n return existingName;\n }\n\n const name =\n options?.name ??\n makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));\n contentToName.set(cacheKey, name);\n\n const injector = getGlobalInjector();\n injector.counterStyle(name, descriptors, { root: options?.root });\n\n return name;\n}\n","import { getGlobalInjector, isFunctionsPolyfillEnabled } from '../config';\nimport {\n formatFunctionRule,\n parseFunctionName,\n registerFunctionPolyfill,\n} from '../functions';\nimport type { FunctionDefinition } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\n\nexport interface UseFunctionOptions {\n /** Shadow root or document to inject into. */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Register a CSS @function (custom function).\n *\n * @function rules are global and persistent once defined. The hook ensures the\n * function is only registered once per root (deduplicated by function name).\n *\n * Accepts tasty token syntax for the function name:\n * - `$$name` → defines `--name` (matches the call site `$$name(...)`)\n * - `$name` / `--name` → also accepted\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param name - The function name token (`$$name`, `$name`, or `--name`)\n * @param definition - Function definition (args, returns, result, local vars)\n *\n * Call the function through the Tasty DSL, not a raw `style` prop: an inline\n * `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never\n * expanded and `polyfills.functions` cannot rewrite it either.\n *\n * @example\n * ```tsx\n * const Box = tasty({ styles: { marginTop: '$$negative(10px)' } });\n *\n * function Layout() {\n * useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });\n * return <Box />;\n * }\n * ```\n */\nexport function useFunction(\n name: string,\n definition: FunctionDefinition,\n options?: UseFunctionOptions,\n): void {\n if (!name) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Tasty] useFunction: function name is required`);\n }\n return;\n }\n\n // @function polyfill: register an inline closure so call sites are expanded\n // into plain CSS by the parser. No native @function rule is emitted.\n if (isFunctionsPolyfillEnabled()) {\n registerFunctionPolyfill(name, definition);\n return;\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatFunctionRule(name, definition);\n if (css) {\n target.collector.collectFunction(parseFunctionName(name), css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatFunctionRule(name, definition);\n if (css) {\n pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);\n }\n return;\n }\n\n getGlobalInjector().func(name, definition, { root: options?.root });\n}\n","import { useInsertionEffect } from 'react';\nimport type { ReactNode } from 'react';\n\nimport { closeBatchWindow, openBatchWindow } from './injector/batch';\n\nexport interface TastyBatchProviderProps {\n children?: ReactNode;\n}\n\n/**\n * Opens a *batch window* for the commit it renders in, so `batchInjection`\n * can defer stylesheet writes without ever letting a layout effect measure an\n * unstyled element.\n *\n * Every `insertRule()` on a live sheet invalidates style for that sheet's\n * scope. When components inject during React's render phase while others read\n * layout in the same pass, the two interleave and the browser recalculates\n * style between every injection. Batching collapses that into one invalidation\n * per flush — but only if the flush happens before anything can measure.\n *\n * ```\n * provider renders -> window OPEN\n * children render -> injections queued\n * provider insertionEffect -> FLUSH, window CLOSED\n * layout effects run -> rules are in the sheet\n * ```\n *\n * `useInsertionEffect` runs in React's mutation phase, after every render in\n * the commit and before any `useLayoutEffect` — which is exactly why React\n * added it for CSS-in-JS libraries. Effects fire child-first, so this\n * provider's runs after every descendant's and still before all layout\n * effects.\n *\n * A commit that does not re-render this provider gets no window, and those\n * injections are written synchronously instead. That is the point: turning\n * `batchInjection: true` on can only ever make injection cheaper, never make a\n * measurement wrong. It also means batching applies to commits this provider\n * takes part in, so mount it as high in the tree as you can.\n *\n * Requires `configure({ batchInjection: true })`; without it this component\n * only renders its children. `batchInjection: 'always'` does not need the\n * provider at all — see that option's docs for the trade-off it accepts.\n *\n * @example\n * ```tsx\n * configure({ batchInjection: true });\n *\n * createRoot(el).render(\n * <TastyBatchProvider>\n * <App />\n * </TastyBatchProvider>,\n * );\n * ```\n */\nexport function TastyBatchProvider({ children }: TastyBatchProviderProps) {\n // Opened during render on purpose: the window has to be open before children\n // render, and this is the only phase that precedes them. It is idempotent and\n // has no other side effect, so StrictMode's double render costs nothing. A\n // render that is thrown away (aborted or suspended) leaves the window open,\n // which the microtask backstop closes — and such a render mounts nothing, so\n // nothing can measure what it queued.\n openBatchWindow();\n\n // Fires in the mutation phase, before any layout effect. No dependency array:\n // it must run on every commit this provider is part of.\n useInsertionEffect(() => {\n closeBatchWindow();\n });\n\n return children;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,cAAc,aAA4B;CACrD,qCAAqB,IAAI,IAAI;CAC7B,6BAAa,IAAI,IAAI;CACrB,kBAAkB;CAClB,YAAY,CAAC;CACb,4BAAY,IAAI,IAAI;CACpB,gCAAgB,IAAI,IAAI;AAC1B,EAAE;AAEF,SAAgB,qBACd,UACA,UACuC;CACvC,MAAM,WAAW,SAAS,oBAAoB,IAAI,QAAQ;CAC1D,IAAI,UAAU,OAAO;EAAE,WAAW;EAAU,OAAO;CAAM;CAIzD,MAAM,YAAY,cAAc,cAAc,GAAG,WAAW,QAAQ,CAAC;CACrE,SAAS,oBAAoB,IAAI,UAAU,SAAS;CACpD,OAAO;EAAE;EAAW,OAAO;CAAK;AAClC;;;;;AAMA,SAAgB,gBAAgB,UAAiC;CAC/D,IAAI,SAAS,WAAW,WAAW,GAAG,OAAO;CAC7C,MAAM,MAAM,SAAS,WAAW,KAAK,IAAI;CACzC,SAAS,WAAW,SAAS;CAE7B,SAAS,WAAW,MAAM;CAC1B,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,WACd,UACA,KACA,KACA,SACS;CACT,IAAI,SAAS;EACX,M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