@tenphi/tasty 2.6.2 → 2.6.4

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 (45) hide show
  1. package/dist/async-storage-B7_o6FKt.js.map +1 -1
  2. package/dist/{collector-mnshMqSq.js → collector-C-keQH9m.js} +3 -3
  3. package/dist/{collector-mnshMqSq.js.map → collector-C-keQH9m.js.map} +1 -1
  4. package/dist/{config-r9Wc94ks.js → config-BBiyxMCe.js} +182 -54
  5. package/dist/config-BBiyxMCe.js.map +1 -0
  6. package/dist/context-CkSg-kDT.js.map +1 -1
  7. package/dist/core/index.d.ts +1 -1
  8. package/dist/core/index.js +5 -5
  9. package/dist/{core-ZlQf3x-x.js → core-BO4319td.js} +5 -5
  10. package/dist/{core-ZlQf3x-x.js.map → core-BO4319td.js.map} +1 -1
  11. package/dist/{css-writer-Bkf5A_Sm.js → css-writer-BWvwQzz0.js} +3 -3
  12. package/dist/{css-writer-Bkf5A_Sm.js.map → css-writer-BWvwQzz0.js.map} +1 -1
  13. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -1
  14. package/dist/{format-rules-Cy70prSz.js → format-rules-BSjeH4Z7.js} +2 -2
  15. package/dist/{format-rules-Cy70prSz.js.map → format-rules-BSjeH4Z7.js.map} +1 -1
  16. package/dist/{hydrate-2BQlSO9P.js → hydrate-CcvrP4qJ.js} +2 -2
  17. package/dist/{hydrate-2BQlSO9P.js.map → hydrate-CcvrP4qJ.js.map} +1 -1
  18. package/dist/{index-J7y6BV89.d.ts → index-B_k47mc_.d.ts} +40 -16
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +6 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/{keyframes-C15dNGU3.js → keyframes-BUQhdOSJ.js} +2 -2
  23. package/dist/{keyframes-C15dNGU3.js.map → keyframes-BUQhdOSJ.js.map} +1 -1
  24. package/dist/{merge-styles-Bl0X9hSR.js → merge-styles-Cd2vBl9b.js} +2 -2
  25. package/dist/{merge-styles-Bl0X9hSR.js.map → merge-styles-Cd2vBl9b.js.map} +1 -1
  26. package/dist/{resolve-recipes-D76rfxNo.js → resolve-recipes-C1nrvnYh.js} +3 -3
  27. package/dist/{resolve-recipes-D76rfxNo.js.map → resolve-recipes-C1nrvnYh.js.map} +1 -1
  28. package/dist/ssr/astro-client.js +1 -1
  29. package/dist/ssr/astro-client.js.map +1 -1
  30. package/dist/ssr/astro-middleware.js.map +1 -1
  31. package/dist/ssr/astro.js +3 -3
  32. package/dist/ssr/astro.js.map +1 -1
  33. package/dist/ssr/index.js +3 -3
  34. package/dist/ssr/next.js +4 -4
  35. package/dist/ssr/next.js.map +1 -1
  36. package/dist/static/index.js +1 -1
  37. package/dist/static/index.js.map +1 -1
  38. package/dist/static/inject.js.map +1 -1
  39. package/dist/zero/babel.js +4 -4
  40. package/dist/zero/babel.js.map +1 -1
  41. package/dist/zero/index.js +1 -1
  42. package/dist/zero/next.js.map +1 -1
  43. package/docs/pipeline.md +40 -14
  44. package/package.json +2 -2
  45. package/dist/config-r9Wc94ks.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"async-storage-B7_o6FKt.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,SACL,GAAE,WAAW,IAAI,mBAAyC;AAE5D,QAAO,EAAE;;;;;;;AAQX,SAAgB,iBACd,WACA,IACG;AACH,QAAO,kBAAkB,CAAC,IAAI,WAAW,GAAG;;;;;;AAO9C,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,kBAAkB;AAClC,KAAI,OAAO,SAAS,aAAa,WAAY,QAAO;AACpD,QAAO,QAAQ,UAAU,IAAI"}
1
+ {"version":3,"file":"async-storage-B7_o6FKt.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,UACL,EAAE,WAAW,IAAI,mBAAyC;CAE5D,OAAO,EAAE;;;;;;;AAQX,SAAgB,iBACd,WACA,IACG;CACH,OAAO,kBAAkB,CAAC,IAAI,WAAW,GAAG;;;;;;AAO9C,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,kBAAkB;CAClC,IAAI,OAAO,SAAS,aAAa,YAAY,OAAO;CACpD,OAAO,QAAQ,UAAU,IAAI"}
@@ -1,5 +1,5 @@
1
- import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, dt as makeCounterStyleName, ft as makeKeyframeName, gt as hashString, i as getGlobalConfigTokens, mt as validateNamePrefix, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, ut as makeClassName } from "./config-r9Wc94ks.js";
2
- import { n as formatPropertyCSS, t as formatRules } from "./format-rules-Cy70prSz.js";
1
+ import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, dt as makeCounterStyleName, ft as makeKeyframeName, gt as hashString, i as getGlobalConfigTokens, mt as validateNamePrefix, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, ut as makeClassName } from "./config-BBiyxMCe.js";
2
+ import { n as formatPropertyCSS, t as formatRules } from "./format-rules-BSjeH4Z7.js";
3
3
  import { t as formatGlobalRules } from "./format-global-rules-Dbc_1tc3.js";
4
4
  //#region src/ssr/collector.ts
5
5
  /**
@@ -240,4 +240,4 @@ var ServerStyleCollector = class {
240
240
  //#endregion
241
241
  export { ServerStyleCollector as t };
242
242
 
243
- //# sourceMappingURL=collector-mnshMqSq.js.map
243
+ //# sourceMappingURL=collector-C-keQH9m.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collector-mnshMqSq.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,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ector-C-keQH9m.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,+BAAuB,IAAI,KAAqB;CAChD,oCAA4B,IAAI,KAAa;CAC7C,yBAAiB,IAAI,KAAqB;CAC1C,iCAAyB,IAAI,KAAa;CAC1C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,oCAA4B,IAAI,KAAqB;CACrD,0CAAkC,IAAI,KAAa;CACnD,mBAA2B;CAC3B,sBAA8B;CAC9B,qBAA6B;CAC7B;;;;;;;;CASA,YAAY,YAAqB;EAC/B,IAAI,eAAe,KAAA,GACjB,mBAAmB,WAAW;EAEhC,KAAK,aAAa,cAAc,eAAe;;CAGjD,kBAA0B,UAA0B;EAClD,OAAO,cAAc,KAAK,YAAY,WAAW,SAAS,CAAC;;;;;;;;;;;CAY7D,mBAAyB;EACvB,IAAI,KAAK,oBAAoB;EAC7B,KAAK,qBAAqB;EAE1B,KAAK,MAAM,CAAC,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C,KAAK,kBAAkB,IAAI,IAAI,EAAE;GACpC,MAAM,KAAK,IAAI;GACf,KAAK,kBAAkB,IAAI,IAAI;;EAInC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,QAC5B,IAAI,CAAC,KAAK,YAAY,IAAI,IAAI,EAAE;GAC9B,MAAM,KAAK,IAAI;GACf,KAAK,YAAY,IAAI,IAAI;;EAI7B,KAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,eAC7B,IAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;GACvC,MAAM,KAAK,IAAI;GACf,KAAK,oBAAoB,IAAI,KAAK;;EAItC,OAAO,MAAM,KAAK,KAAK;;CAGzB,oCAA4B,IAAI,KAAa;;;;;CAM7C,wBAAkC;EAChC,MAAM,QAAkB,EAAE;EAC1B,KAAK,MAAM,aAAa,KAAK,oBAAoB,QAAQ,EACvD,IAAI,CAAC,KAAK,kBAAkB,IAAI,UAAU,EAAE;GAC1C,KAAK,kBAAkB,IAAI,UAAU;GACrC,MAAM,KAAK,UAAU;;EAGzB,OAAO"}
@@ -57,6 +57,7 @@ function canonicalFuncName(lowered) {
57
57
  //#endregion
58
58
  //#region src/parser/lru.ts
59
59
  var Lru = class {
60
+ limit;
60
61
  map = /* @__PURE__ */ new Map();
61
62
  head = null;
62
63
  tail = null;
@@ -1875,6 +1876,7 @@ function scan(src, cb) {
1875
1876
  //#endregion
1876
1877
  //#region src/parser/parser.ts
1877
1878
  var StyleParser = class {
1879
+ opts;
1878
1880
  cache;
1879
1881
  constructor(opts = {}) {
1880
1882
  this.opts = opts;
@@ -6203,9 +6205,13 @@ function simplifyInner(node) {
6203
6205
  return node;
6204
6206
  }
6205
6207
  if (node.kind === "compound") {
6208
+ const key = getConditionUniqueId(node);
6209
+ const cached = simplifyCache.get(key);
6210
+ if (cached) return cached;
6206
6211
  const simplifiedChildren = node.children.map((c) => simplifyInner(c));
6207
- if (node.operator === "AND") return simplifyAnd(simplifiedChildren);
6208
- else return simplifyOr(simplifiedChildren);
6212
+ const result = node.operator === "AND" ? simplifyAnd(simplifiedChildren) : simplifyOr(simplifiedChildren);
6213
+ simplifyCache.set(key, result);
6214
+ return result;
6209
6215
  }
6210
6216
  return node;
6211
6217
  }
@@ -6223,13 +6229,23 @@ function simplifyAnd(children) {
6223
6229
  if (hasRangeContradiction(terms)) return falseCondition();
6224
6230
  if (hasAttributeConflict(terms)) return falseCondition();
6225
6231
  if (hasContainerStyleConflict(terms)) return falseCondition();
6226
- terms = removeImpliedNegations(terms);
6227
- terms = deduplicateTerms(terms);
6228
- terms = mergeRanges(terms);
6229
- terms = sortTerms(terms);
6230
- terms = applyAbsorptionAnd(terms);
6231
- terms = applyConsensusAnd(terms);
6232
- terms = pruneContradictedOrBranches(terms);
6232
+ const MAX_SIMPLIFY_PASSES = 4;
6233
+ for (let pass = 0; pass < MAX_SIMPLIFY_PASSES; pass++) {
6234
+ const lengthBefore = terms.length;
6235
+ const keyBefore = simplifyTermsKey(terms);
6236
+ terms = removeImpliedNegations(terms);
6237
+ terms = deduplicateTerms(terms);
6238
+ terms = mergeRanges(terms);
6239
+ terms = sortTerms(terms);
6240
+ terms = applyAbsorptionAnd(terms);
6241
+ terms = applyConsensusAnd(terms);
6242
+ terms = pruneContradictedOrBranches(terms);
6243
+ if (terms.length === 0) break;
6244
+ if (terms.length === 1) break;
6245
+ if (hasContradiction(terms)) return falseCondition();
6246
+ if (hasAttributeConflict(terms)) return falseCondition();
6247
+ if (terms.length === lengthBefore && simplifyTermsKey(terms) === keyBefore) break;
6248
+ }
6233
6249
  if (terms.length === 0) return trueCondition();
6234
6250
  if (terms.length === 1) return terms[0];
6235
6251
  return {
@@ -6544,6 +6560,13 @@ function removeImpliedNegations(terms) {
6544
6560
  const isImplied = buildImpliedNegationCheck(terms);
6545
6561
  return terms.filter((t) => !isImplied(t));
6546
6562
  }
6563
+ /**
6564
+ * Build a stable, order-insensitive key for a list of AND terms.
6565
+ * Used to detect fixpoint convergence in `simplifyAnd`.
6566
+ */
6567
+ function simplifyTermsKey(terms) {
6568
+ return terms.map((t) => getConditionUniqueId(t)).sort().join("&");
6569
+ }
6547
6570
  function deduplicateTerms(terms) {
6548
6571
  const seen = /* @__PURE__ */ new Set();
6549
6572
  const result = [];
@@ -7934,7 +7957,69 @@ function branchesProduceDifferentContexts(branches) {
7934
7957
  * so here we just collect all variants. Any remaining ORs in the condition
7935
7958
  * tree (e.g., from De Morgan expansion) are handled as simple alternatives.
7936
7959
  */
7960
+ /**
7961
+ * Serialize a single negated own-element selector leaf (modifier or pseudo)
7962
+ * to its *positive* selector string, for use inside a combined `:not(...)`.
7963
+ *
7964
+ * Returns `null` when the node is not a negated, own-element selector leaf
7965
+ * (e.g. positive, or a media/container/parent/root/own/supports/starting
7966
+ * wrapper, or a compound), which means it cannot participate in De Morgan
7967
+ * recombination.
7968
+ */
7969
+ function negatedSelectorLeafToPositiveSelector(node) {
7970
+ if (node.kind !== "state" || !node.negated) return null;
7971
+ if (node.type === "modifier") return modifierToCSS({
7972
+ attribute: node.attribute,
7973
+ value: node.value,
7974
+ operator: node.operator,
7975
+ negated: false
7976
+ });
7977
+ if (node.type === "pseudo") {
7978
+ const p = node.pseudo;
7979
+ if ((p.startsWith(":is(") || p.startsWith(":where(")) && !p.includes(",")) {
7980
+ const inner = p.slice(p.indexOf("(") + 1, -1);
7981
+ if (!/\s/.test(inner)) return inner;
7982
+ return `:is(${inner})`;
7983
+ }
7984
+ return p;
7985
+ }
7986
+ return null;
7987
+ }
7988
+ /**
7989
+ * De Morgan recombination for an OR whose every branch is a negated
7990
+ * own-element selector leaf:
7991
+ *
7992
+ * OR(¬a, ¬b, ¬c) ≡ ¬(a ∧ b ∧ c) → single `:not(a b c)`
7993
+ *
7994
+ * This keeps the catch-all/default exclusive condition (which has no
7995
+ * positive terms to prune against) from exploding into a Cartesian product
7996
+ * of OR branches at `andToCSS`. Returns `null` when recombination does not
7997
+ * apply, so genuine unions (e.g. `:hover | :focus`) fall through to the
7998
+ * normal per-branch materialization.
7999
+ */
8000
+ function tryRecombineNegatedSelectorOr(children) {
8001
+ if (children.length < 2) return null;
8002
+ const positiveSelectors = [];
8003
+ for (const child of children) {
8004
+ const sel = negatedSelectorLeafToPositiveSelector(child);
8005
+ if (sel === null) return null;
8006
+ positiveSelectors.push(sel);
8007
+ }
8008
+ positiveSelectors.sort();
8009
+ const compound = positiveSelectors.join("");
8010
+ const v = emptyVariant();
8011
+ v.pseudoConditions.push({
8012
+ pseudo: `:is(${compound})`,
8013
+ negated: true
8014
+ });
8015
+ return {
8016
+ variants: [v],
8017
+ isImpossible: false
8018
+ };
8019
+ }
7937
8020
  function orToCSS(children) {
8021
+ const recombined = tryRecombineNegatedSelectorOr(children);
8022
+ if (recombined !== null) return recombined;
7938
8023
  const allVariants = [];
7939
8024
  for (const child of children) {
7940
8025
  const childCSS = conditionToCSSInner(child);
@@ -8163,7 +8248,11 @@ function buildExclusiveConditions(entries) {
8163
8248
  const priorConditions = [];
8164
8249
  for (const entry of entries) {
8165
8250
  let exclusive = entry.condition;
8166
- for (const prior of priorConditions) if (prior.kind !== "true") exclusive = and(exclusive, not(prior));
8251
+ for (const prior of priorConditions) {
8252
+ if (prior.kind === "true") continue;
8253
+ if (entry.condition.kind !== "true" && simplifyCondition(and(entry.condition, prior)).kind === "false") continue;
8254
+ exclusive = and(exclusive, not(prior));
8255
+ }
8167
8256
  const simplified = simplifyCondition(exclusive);
8168
8257
  if (simplified.kind === "false") continue;
8169
8258
  result.push({
@@ -8206,58 +8295,89 @@ function parseStyleEntries(styleKey, valueMap, parseCondition) {
8206
8295
  * This must happen **before** exclusive expansion and OR branch splitting
8207
8296
  * to avoid combinatorial explosion and duplicate CSS output.
8208
8297
  *
8209
- * Default (TRUE) entries are **never** merged with non-default entries.
8298
+ * **Merging must preserve the authored cascade.** Merging two same-value
8299
+ * entries with priorities `p_h > p_l` lifts the lower-priority entry up
8300
+ * to `p_h` and changes the "blocker" for intermediate-priority entries
8301
+ * from `!C_h` to `!(C_h | C_l) = !C_h & !C_l`. The added `!C_l`
8302
+ * constraint can incorrectly block an intermediate entry that should
8303
+ * have won.
8304
+ *
8305
+ * Two same-value entries with conditions `C_h` (higher priority) and
8306
+ * `C_l` (lower priority) are safe to merge iff for every entry
8307
+ * `e_m` strictly between them in priority with a different value,
8308
+ *
8309
+ * simplify(C_m & C_l & !C_h) = FALSE
8310
+ *
8311
+ * i.e. there is no scenario where the intermediate state could have
8312
+ * matched (`C_m`), the lower-priority same-value entry would also have
8313
+ * matched (`C_l`), and the higher-priority entry would not (`!C_h`).
8314
+ * In such scenarios the intermediate is supposed to win; the merge
8315
+ * would block it by introducing `!C_l`.
8316
+ *
8317
+ * Example (UNSAFE — must not merge):
8318
+ * `{ hovered: 'red', pressed: 'blue', disabled: 'red' }`.
8319
+ * C_h = disabled, C_l = hovered, C_m = pressed. `pressed & hovered &
8320
+ * !disabled` is satisfiable (three independent modifiers), so the
8321
+ * intermediate `pressed` would lose to a merged red rule when both
8322
+ * `pressed` and `hovered` are active — breaking the cascade
8323
+ * `disabled > pressed > hovered`.
8324
+ *
8325
+ * Example (SAFE — still merges):
8326
+ * `{ '': light, '@dark': dark, '@hc': hc, '@dark & @hc': dark }`.
8327
+ * C_h = `@dark & @hc`, C_l = `@dark`, C_m = `@hc`.
8328
+ * `@hc & @dark & !(@dark & @hc) = @hc & @dark & (!@dark | !@hc)`
8329
+ * simplifies to FALSE, so merging the two darks into one `@dark` rule
8330
+ * at the higher priority does not affect the `@hc` rule.
8331
+ *
8332
+ * Default (TRUE) entries are never merged with non-default entries.
8210
8333
  * Merging `TRUE | X` collapses to `TRUE`, destroying the non-default
8211
- * condition's participation in exclusive building. That causes
8212
- * intermediate-priority states to lose their `:not(X)` negation,
8213
- * breaking mutual exclusivity when X and an intermediate state are
8214
- * both active. Stage 6 `mergeByValue` handles combining rules with
8215
- * identical CSS output after exclusive conditions are correctly built.
8216
- *
8217
- * Example: `{ '@dark': 'red', '@dark & @hc': 'red' }` merges into a
8218
- * single entry with condition `@dark | (@dark & @hc)` = `@dark`.
8334
+ * condition's participation in exclusive building. Stage 6
8335
+ * `mergeByValue` handles combining rules with identical CSS output
8336
+ * after exclusive conditions are correctly built.
8219
8337
  *
8220
- * Entries are ordered highest-priority-first. The merged entry keeps the
8221
- * highest priority of the group.
8338
+ * The merged entry keeps the highest priority of the merged entries.
8222
8339
  */
8223
8340
  function mergeEntriesByValue(entries) {
8224
8341
  if (entries.length <= 1) return entries;
8225
- const groups = /* @__PURE__ */ new Map();
8226
- for (const entry of entries) {
8227
- const valueKey = serializeValue(entry.value);
8228
- const group = groups.get(valueKey);
8229
- if (group) {
8230
- group.entries.push(entry);
8231
- group.maxPriority = Math.max(group.maxPriority, entry.priority);
8232
- } else groups.set(valueKey, {
8233
- entries: [entry],
8234
- maxPriority: entry.priority
8235
- });
8236
- }
8237
- if (groups.size === entries.length) return entries;
8238
8342
  const merged = [];
8239
- for (const [, group] of groups) {
8240
- if (group.entries.length === 1) {
8241
- merged.push(group.entries[0]);
8343
+ for (const entry of entries) {
8344
+ if (entry.condition.kind === "true") {
8345
+ merged.push(entry);
8242
8346
  continue;
8243
8347
  }
8244
- const defaultEntries = group.entries.filter((e) => e.condition.kind === "true");
8245
- const nonDefaultEntries = group.entries.filter((e) => e.condition.kind !== "true");
8246
- for (const entry of defaultEntries) merged.push(entry);
8247
- if (nonDefaultEntries.length === 1) merged.push(nonDefaultEntries[0]);
8248
- else if (nonDefaultEntries.length >= 2) {
8249
- const combinedCondition = simplifyCondition(or(...nonDefaultEntries.map((e) => e.condition)));
8250
- const combinedStateKey = nonDefaultEntries.map((e) => e.stateKey).join(" | ");
8251
- merged.push({
8252
- styleKey: nonDefaultEntries[0].styleKey,
8253
- stateKey: combinedStateKey,
8254
- value: nonDefaultEntries[0].value,
8255
- condition: combinedCondition,
8256
- priority: group.maxPriority
8257
- });
8348
+ const valueKey = serializeValue(entry.value);
8349
+ let mergeIdx = -1;
8350
+ for (let j = merged.length - 1; j >= 0; j--) {
8351
+ const prev = merged[j];
8352
+ if (prev.condition.kind === "true") continue;
8353
+ if (serializeValue(prev.value) !== valueKey) continue;
8354
+ let safe = true;
8355
+ for (let k = j + 1; k < merged.length; k++) {
8356
+ const inter = merged[k];
8357
+ if (inter.condition.kind === "true") continue;
8358
+ if (serializeValue(inter.value) === valueKey) continue;
8359
+ if (simplifyCondition(and(inter.condition, entry.condition, not(prev.condition))).kind !== "false") {
8360
+ safe = false;
8361
+ break;
8362
+ }
8363
+ }
8364
+ if (safe) {
8365
+ mergeIdx = j;
8366
+ break;
8367
+ }
8258
8368
  }
8369
+ if (mergeIdx >= 0) {
8370
+ const prev = merged[mergeIdx];
8371
+ const newCondition = simplifyCondition(or(prev.condition, entry.condition));
8372
+ merged[mergeIdx] = {
8373
+ styleKey: prev.styleKey,
8374
+ stateKey: `${prev.stateKey} | ${entry.stateKey}`,
8375
+ value: prev.value,
8376
+ condition: newCondition,
8377
+ priority: Math.max(prev.priority, entry.priority)
8378
+ };
8379
+ } else merged.push(entry);
8259
8380
  }
8260
- merged.sort((a, b) => b.priority - a.priority);
8261
8381
  return merged;
8262
8382
  }
8263
8383
  function serializeValue(value) {
@@ -8794,7 +8914,15 @@ var Parser = class {
8794
8914
  return createPseudoCondition(value, false, value);
8795
8915
  }
8796
8916
  if (value.startsWith(".")) return createPseudoCondition(value, false, value);
8797
- if (value.startsWith("[")) return createPseudoCondition(value, false, value);
8917
+ if (value.startsWith("[")) {
8918
+ const attrMatch = /^\[\s*([a-zA-Z_][\w-]*)\s*(?:(=|\^=|\$=|\*=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]+)))?\s*\]$/.exec(value);
8919
+ if (attrMatch) {
8920
+ const [, attribute, operator, dq, sq, bare] = attrMatch;
8921
+ if (operator === void 0) return createModifierCondition(attribute, void 0, "=", false, value);
8922
+ return createModifierCondition(attribute, dq ?? sq ?? bare, operator, false, value);
8923
+ }
8924
+ return createPseudoCondition(value, false, value);
8925
+ }
8798
8926
  if (value.includes("=")) return this.parseValueModifier(value);
8799
8927
  return this.parseBooleanModifier(value);
8800
8928
  }
@@ -10428,4 +10556,4 @@ function resetConfig() {
10428
10556
  //#endregion
10429
10557
  export { parseColor as $, StyleInjector as A, strToRgb as At, styleHandlers as B, parseStateKey as C, getColorSpaceFunc as Ct, extractPredefinedStateRefs as D, getRgbValuesFromRgbaString as Dt, extractLocalPredefinedStates as E, getNamedColorHex as Et, fontFaceContentHash as F, CUSTOM_UNITS as G, warn as H, formatFontFaceRule as I, filterMods as J, DIRECTIONS as K, hasLocalFontFace as L, formatCounterStyleRule as M, hasLocalCounterStyle as N, getGlobalPredefinedStates as O, hexToRgb as Ot, extractLocalFontFace as P, normalizeColorTokenValue as Q, SheetManager as R, renderStyles as S, getColorSpaceComponents as St, createStateParserContext as T, getComponentPropertySyntax as Tt, createStyle as U, deprecationWarning as V, PropertyTypeResolver as W, getGlobalParser as X, getGlobalFuncs as Y, getGlobalPredefinedTokens as Z, markStylesGenerated as _, extractLocalProperties as _t, getGlobalCounterStyle as a, okhslPlugin as at, hasPipelineCacheEntry as b, parsePropertyToken as bt, getGlobalKeyframes as c, DEFAULT_NAME_PREFIX as ct, getNamePrefix as d, makeCounterStyleName as dt, parseStyle as et, hasGlobalKeyframes as f, makeKeyframeName as ft, isTestEnvironment as g, hashString as gt, isConfigLocked as h, isDevEnv as ht, getGlobalConfigTokens as i, okhslFunc as it, extractLocalCounterStyle as j, Lru as jt, setGlobalPredefinedStates as k, hslToRgbValues as kt, getGlobalRecipes as l, DEFAULT_ZERO_NAME_PREFIX as lt, hasStylesGenerated as m, validateNamePrefix as mt, getConfig as n, setGlobalPredefinedTokens as nt, getGlobalFontFace as o, StyleParser as ot, hasGlobalRecipes as p, tastyClassRegex as pt, customFunc as q, getEffectiveProperties as r, stringifyStyles as rt, getGlobalInjector as s, Bucket as st, configure as t, resetGlobalPredefinedTokens as tt, getGlobalStyles as u, makeClassName as ut, resetConfig as v, getEffectiveDefinition as vt, camelToKebab as w, getColorSpaceSuffix as wt, isSelector as x, colorInitialValueToComponents as xt, generateTypographyTokens as y, hasLocalProperties as yt, STYLE_HANDLER_MAP as z };
10430
10558
 
10431
- //# sourceMappingURL=config-r9Wc94ks.js.map
10559
+ //# sourceMappingURL=config-BBiyxMCe.js.map