@tenphi/tasty 0.0.0-snapshot.1c5dff6 → 0.0.0-snapshot.1f1c00a

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 (331) hide show
  1. package/README.md +377 -238
  2. package/dist/babel-rZcEwPLM.d.ts +82 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-CL4eRu2z.js +42 -0
  6. package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
  7. package/dist/chunks/collector-D2ARGT2L.js +208 -0
  8. package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
  9. package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
  10. package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
  11. package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
  12. package/dist/chunks/css-definitions-DotDkIXt.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-D8pg9RGI.js +502 -0
  16. package/dist/chunks/debug-D8pg9RGI.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-BpxlOTbO.js +562 -0
  22. package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
  24. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
  25. package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
  26. package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
  27. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-BBbBuSkT.js +5260 -0
  30. package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
  31. package/dist/{zero/extractor.js → chunks/zero-engine-gJrKBRiw.js} +126 -66
  32. package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
  33. package/dist/collector-w4mBj5gd.d.ts +164 -0
  34. package/dist/config-CZWCzBr6.d.ts +1349 -0
  35. package/dist/core/index.d.ts +5 -33
  36. package/dist/core/index.js +9 -26
  37. package/dist/index-G9JuwM9p.d.ts +1920 -0
  38. package/dist/index.d.ts +5 -48
  39. package/dist/index.js +11 -33
  40. package/dist/{utils/merge-styles.d.ts → merge-styles-VXwJ0Frr.d.ts} +3 -4
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +6 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +18 -0
  54. package/dist/ssr/astro-middleware.js +7 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +127 -0
  57. package/dist/ssr/astro.js +221 -0
  58. package/dist/ssr/astro.js.map +1 -0
  59. package/dist/ssr/index.d.ts +36 -0
  60. package/dist/ssr/index.js +10 -0
  61. package/dist/ssr/index.js.map +1 -0
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +128 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +46 -0
  66. package/dist/ssr/next.js +60 -0
  67. package/dist/ssr/next.js.map +1 -0
  68. package/dist/static/index.d.ts +90 -5
  69. package/dist/static/index.js +31 -4
  70. package/dist/static/index.js.map +1 -0
  71. package/dist/static/inject.d.ts +4 -0
  72. package/dist/static/inject.js +17 -0
  73. package/dist/static/inject.js.map +1 -0
  74. package/dist/types-JEY8PVYP.d.ts +1567 -0
  75. package/dist/zero/babel.d.ts +2 -113
  76. package/dist/zero/babel.js +230 -106
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +80 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +57 -33
  81. package/dist/zero/next.js +93 -59
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +323 -0
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +448 -0
  87. package/docs/configuration.md +684 -56
  88. package/docs/debug.md +170 -343
  89. package/docs/design-system.md +455 -0
  90. package/docs/dsl.md +1065 -0
  91. package/docs/getting-started.md +240 -0
  92. package/docs/injector.md +159 -53
  93. package/docs/methodology.md +648 -0
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +765 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +683 -0
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +610 -0
  100. package/docs/styles.md +211 -63
  101. package/docs/tasty-static.md +273 -67
  102. package/package.json +182 -58
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -70
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -260
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -61
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -288
  113. package/dist/config.js +0 -403
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  119. package/dist/hooks/useGlobalStyles.js +0 -56
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -54
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -91
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -28
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -40
  131. package/dist/hooks/useStyles.js +0 -169
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -157
  134. package/dist/injector/index.js +0 -154
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -139
  137. package/dist/injector/injector.js +0 -417
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -135
  140. package/dist/injector/sheet-manager.js +0 -728
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -319
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -660
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -856
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -451
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -371
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -69
  180. package/dist/properties/index.js +0 -221
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -83
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/states/index.d.ts +0 -49
  186. package/dist/states/index.js +0 -416
  187. package/dist/states/index.js.map +0 -1
  188. package/dist/static/tastyStatic.d.ts +0 -46
  189. package/dist/static/tastyStatic.js +0 -31
  190. package/dist/static/tastyStatic.js.map +0 -1
  191. package/dist/static/types.d.ts +0 -49
  192. package/dist/static/types.js +0 -24
  193. package/dist/static/types.js.map +0 -1
  194. package/dist/styles/align.d.ts +0 -15
  195. package/dist/styles/align.js +0 -14
  196. package/dist/styles/align.js.map +0 -1
  197. package/dist/styles/border.d.ts +0 -25
  198. package/dist/styles/border.js +0 -114
  199. package/dist/styles/border.js.map +0 -1
  200. package/dist/styles/color.d.ts +0 -14
  201. package/dist/styles/color.js +0 -23
  202. package/dist/styles/color.js.map +0 -1
  203. package/dist/styles/createStyle.js +0 -77
  204. package/dist/styles/createStyle.js.map +0 -1
  205. package/dist/styles/dimension.js +0 -97
  206. package/dist/styles/dimension.js.map +0 -1
  207. package/dist/styles/display.d.ts +0 -37
  208. package/dist/styles/display.js +0 -67
  209. package/dist/styles/display.js.map +0 -1
  210. package/dist/styles/fade.d.ts +0 -15
  211. package/dist/styles/fade.js +0 -58
  212. package/dist/styles/fade.js.map +0 -1
  213. package/dist/styles/fill.d.ts +0 -42
  214. package/dist/styles/fill.js +0 -52
  215. package/dist/styles/fill.js.map +0 -1
  216. package/dist/styles/flow.d.ts +0 -16
  217. package/dist/styles/flow.js +0 -12
  218. package/dist/styles/flow.js.map +0 -1
  219. package/dist/styles/gap.d.ts +0 -31
  220. package/dist/styles/gap.js +0 -37
  221. package/dist/styles/gap.js.map +0 -1
  222. package/dist/styles/height.d.ts +0 -17
  223. package/dist/styles/height.js +0 -20
  224. package/dist/styles/height.js.map +0 -1
  225. package/dist/styles/index.d.ts +0 -2
  226. package/dist/styles/index.js +0 -9
  227. package/dist/styles/index.js.map +0 -1
  228. package/dist/styles/inset.d.ts +0 -52
  229. package/dist/styles/inset.js +0 -150
  230. package/dist/styles/inset.js.map +0 -1
  231. package/dist/styles/justify.d.ts +0 -15
  232. package/dist/styles/justify.js +0 -14
  233. package/dist/styles/justify.js.map +0 -1
  234. package/dist/styles/list.d.ts +0 -16
  235. package/dist/styles/list.js +0 -98
  236. package/dist/styles/list.js.map +0 -1
  237. package/dist/styles/margin.d.ts +0 -24
  238. package/dist/styles/margin.js +0 -104
  239. package/dist/styles/margin.js.map +0 -1
  240. package/dist/styles/outline.d.ts +0 -29
  241. package/dist/styles/outline.js +0 -65
  242. package/dist/styles/outline.js.map +0 -1
  243. package/dist/styles/padding.d.ts +0 -24
  244. package/dist/styles/padding.js +0 -104
  245. package/dist/styles/padding.js.map +0 -1
  246. package/dist/styles/predefined.d.ts +0 -73
  247. package/dist/styles/predefined.js +0 -241
  248. package/dist/styles/predefined.js.map +0 -1
  249. package/dist/styles/preset.d.ts +0 -47
  250. package/dist/styles/preset.js +0 -126
  251. package/dist/styles/preset.js.map +0 -1
  252. package/dist/styles/radius.d.ts +0 -14
  253. package/dist/styles/radius.js +0 -51
  254. package/dist/styles/radius.js.map +0 -1
  255. package/dist/styles/scrollbar.d.ts +0 -23
  256. package/dist/styles/scrollbar.js +0 -34
  257. package/dist/styles/scrollbar.js.map +0 -1
  258. package/dist/styles/shadow.d.ts +0 -14
  259. package/dist/styles/shadow.js +0 -24
  260. package/dist/styles/shadow.js.map +0 -1
  261. package/dist/styles/styledScrollbar.d.ts +0 -47
  262. package/dist/styles/styledScrollbar.js +0 -38
  263. package/dist/styles/styledScrollbar.js.map +0 -1
  264. package/dist/styles/transition.d.ts +0 -14
  265. package/dist/styles/transition.js +0 -158
  266. package/dist/styles/transition.js.map +0 -1
  267. package/dist/styles/types.d.ts +0 -498
  268. package/dist/styles/width.d.ts +0 -17
  269. package/dist/styles/width.js +0 -20
  270. package/dist/styles/width.js.map +0 -1
  271. package/dist/tasty.d.ts +0 -982
  272. package/dist/tasty.js +0 -206
  273. package/dist/tasty.js.map +0 -1
  274. package/dist/tokens/typography.d.ts +0 -19
  275. package/dist/tokens/typography.js +0 -237
  276. package/dist/tokens/typography.js.map +0 -1
  277. package/dist/types.d.ts +0 -184
  278. package/dist/utils/cache-wrapper.js +0 -26
  279. package/dist/utils/cache-wrapper.js.map +0 -1
  280. package/dist/utils/case-converter.js +0 -8
  281. package/dist/utils/case-converter.js.map +0 -1
  282. package/dist/utils/colors.d.ts +0 -5
  283. package/dist/utils/colors.js +0 -9
  284. package/dist/utils/colors.js.map +0 -1
  285. package/dist/utils/css-types.d.ts +0 -7
  286. package/dist/utils/dotize.d.ts +0 -26
  287. package/dist/utils/dotize.js +0 -122
  288. package/dist/utils/dotize.js.map +0 -1
  289. package/dist/utils/filter-base-props.d.ts +0 -15
  290. package/dist/utils/filter-base-props.js +0 -45
  291. package/dist/utils/filter-base-props.js.map +0 -1
  292. package/dist/utils/get-display-name.d.ts +0 -7
  293. package/dist/utils/get-display-name.js +0 -10
  294. package/dist/utils/get-display-name.js.map +0 -1
  295. package/dist/utils/hsl-to-rgb.js +0 -38
  296. package/dist/utils/hsl-to-rgb.js.map +0 -1
  297. package/dist/utils/is-dev-env.js +0 -19
  298. package/dist/utils/is-dev-env.js.map +0 -1
  299. package/dist/utils/is-valid-element-type.js +0 -15
  300. package/dist/utils/is-valid-element-type.js.map +0 -1
  301. package/dist/utils/merge-styles.js.map +0 -1
  302. package/dist/utils/mod-attrs.d.ts +0 -8
  303. package/dist/utils/mod-attrs.js +0 -21
  304. package/dist/utils/mod-attrs.js.map +0 -1
  305. package/dist/utils/okhsl-to-rgb.js +0 -296
  306. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  307. package/dist/utils/process-tokens.d.ts +0 -31
  308. package/dist/utils/process-tokens.js +0 -171
  309. package/dist/utils/process-tokens.js.map +0 -1
  310. package/dist/utils/resolve-recipes.d.ts +0 -17
  311. package/dist/utils/resolve-recipes.js +0 -147
  312. package/dist/utils/resolve-recipes.js.map +0 -1
  313. package/dist/utils/selector-transform.js +0 -32
  314. package/dist/utils/selector-transform.js.map +0 -1
  315. package/dist/utils/string.js +0 -8
  316. package/dist/utils/string.js.map +0 -1
  317. package/dist/utils/styles.d.ts +0 -177
  318. package/dist/utils/styles.js +0 -730
  319. package/dist/utils/styles.js.map +0 -1
  320. package/dist/utils/typography.d.ts +0 -36
  321. package/dist/utils/typography.js +0 -53
  322. package/dist/utils/typography.js.map +0 -1
  323. package/dist/utils/warnings.d.ts +0 -16
  324. package/dist/utils/warnings.js +0 -16
  325. package/dist/utils/warnings.js.map +0 -1
  326. package/dist/zero/css-writer.d.ts +0 -45
  327. package/dist/zero/css-writer.js +0 -74
  328. package/dist/zero/css-writer.js.map +0 -1
  329. package/dist/zero/extractor.d.ts +0 -24
  330. package/dist/zero/extractor.js.map +0 -1
  331. package/docs/usage.md +0 -695
@@ -0,0 +1,876 @@
1
+ import { F as RE_RAW_UNIT, P as RE_NUMBER, a as customFunction, f as parseStyle } from "./dsl-DRhFWQzo.js";
2
+ import { A as createStyle, w as STYLE_HANDLER_MAP } from "./style-engine-BBbBuSkT.js";
3
+ //#region src/functions/index.ts
4
+ const FUNCTION_KEY = "@function";
5
+ const RESERVED_KEYS = /* @__PURE__ */ new Set([
6
+ "args",
7
+ "returns",
8
+ "result"
9
+ ]);
10
+ function hasLocalFunctions(styles) {
11
+ return FUNCTION_KEY in styles;
12
+ }
13
+ function extractLocalFunctions(styles) {
14
+ const functions = styles[FUNCTION_KEY];
15
+ if (!functions || typeof functions !== "object") return null;
16
+ return functions;
17
+ }
18
+ function parseFunctionName(token) {
19
+ if (token.startsWith("$$")) return `--${token.slice(2)}`;
20
+ if (token.startsWith("$")) return `--${token.slice(1)}`;
21
+ if (token.startsWith("--")) return token;
22
+ return `--${token}`;
23
+ }
24
+ function parseParamName(token) {
25
+ if (token.startsWith("$")) return `--${token.slice(1)}`;
26
+ if (token.startsWith("--")) return token;
27
+ return `--${token}`;
28
+ }
29
+ function formatParameter(token, param) {
30
+ const name = parseParamName(token);
31
+ if (param === true) return name;
32
+ if (typeof param === "string") return param ? `${name} ${param}` : name;
33
+ let out = name;
34
+ if (param.syntax) out += ` ${param.syntax}`;
35
+ if (param.default !== void 0) out += `: ${parseStyle(param.default).output}`;
36
+ return out;
37
+ }
38
+ function formatFunctionPrelude(name, args, returns) {
39
+ const cssName = parseFunctionName(name);
40
+ let params = "";
41
+ if (Array.isArray(args)) params = args.map((token) => formatParameter(token, true)).join(", ");
42
+ else if (args) params = Object.entries(args).map(([token, param]) => formatParameter(token, param)).join(", ");
43
+ const returnsPart = returns ? ` returns ${returns}` : "";
44
+ return `@function ${cssName}(${params})${returnsPart}`;
45
+ }
46
+ function formatFunctionDeclarations(def) {
47
+ const parts = [];
48
+ for (const key of Object.keys(def)) {
49
+ if (RESERVED_KEYS.has(key) || !key.startsWith("$")) continue;
50
+ const value = def[key];
51
+ if (value === void 0) continue;
52
+ parts.push(`${parseParamName(key)}: ${parseStyle(value).output};`);
53
+ }
54
+ parts.push(`result: ${parseStyle(def.result).output};`);
55
+ return parts.join(" ");
56
+ }
57
+ function formatFunctionRule(name, def) {
58
+ return `${formatFunctionPrelude(name, def.args, def.returns)} { ${formatFunctionDeclarations(def)} }`;
59
+ }
60
+ function isCssFunctionKey(key) {
61
+ return key.startsWith("$") || key.startsWith("--");
62
+ }
63
+ function isParseFunction(value) {
64
+ return typeof value === "function";
65
+ }
66
+ function splitFunctions(map, onMismatch) {
67
+ const parseFuncs = {};
68
+ const functionDefs = {};
69
+ for (const [key, value] of Object.entries(map)) {
70
+ const cssKey = isCssFunctionKey(key);
71
+ if (isParseFunction(value)) {
72
+ if (cssKey) {
73
+ onMismatch?.(key, "expected-definition");
74
+ continue;
75
+ }
76
+ parseFuncs[key] = value;
77
+ } else {
78
+ if (!cssKey) {
79
+ onMismatch?.(key, "expected-parse-function");
80
+ continue;
81
+ }
82
+ functionDefs[key] = value;
83
+ }
84
+ }
85
+ return {
86
+ parseFuncs,
87
+ functionDefs
88
+ };
89
+ }
90
+ function escapeRegExp(str) {
91
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
92
+ }
93
+ const paramBareName = (token) => parseParamName(token).slice(2);
94
+ function prefixDeclaredVars(template, declared, prefixOf) {
95
+ let out = template;
96
+ for (const bare of declared) {
97
+ const re = new RegExp(`var\\(\\s*--${escapeRegExp(bare)}(?![\\w-])`, "g");
98
+ out = out.replace(re, `var(--${prefixOf(bare)}`);
99
+ }
100
+ return out;
101
+ }
102
+ function substituteVars(template, valueMap) {
103
+ let out = template;
104
+ for (let iter = 0; iter < 30; iter++) {
105
+ let changed = false;
106
+ for (const [name, value] of valueMap) {
107
+ const re = new RegExp(`var\\(\\s*--${escapeRegExp(name)}\\s*(?:,[^)]*)?\\)`, "g");
108
+ out = out.replace(re, () => {
109
+ changed = true;
110
+ return value;
111
+ });
112
+ }
113
+ if (!changed) break;
114
+ }
115
+ return out;
116
+ }
117
+ const inProgress = /* @__PURE__ */ new Set();
118
+ function compileFunctionClosure(name, def) {
119
+ const cssName = parseFunctionName(name);
120
+ const prefixOf = (bare) => `tf-${cssName.slice(2)}-${bare}`;
121
+ const params = [];
122
+ if (Array.isArray(def.args)) for (const token of def.args) params.push({ prefixed: prefixOf(paramBareName(token)) });
123
+ else if (def.args) for (const [token, param] of Object.entries(def.args)) {
124
+ let dflt;
125
+ if (param && typeof param === "object" && param.default !== void 0) dflt = parseStyle(param.default).output;
126
+ params.push({
127
+ prefixed: prefixOf(paramBareName(token)),
128
+ default: dflt
129
+ });
130
+ }
131
+ const localKeys = Object.keys(def).filter((key) => !RESERVED_KEYS.has(key) && key.startsWith("$"));
132
+ const declared = [...Array.isArray(def.args) ? def.args.map(paramBareName) : def.args ? Object.keys(def.args).map(paramBareName) : [], ...localKeys.map(paramBareName)];
133
+ let built = false;
134
+ let resultTemplate = "";
135
+ const localTemplates = [];
136
+ const build = () => {
137
+ built = true;
138
+ resultTemplate = prefixDeclaredVars(parseStyle(def.result).output, declared, prefixOf);
139
+ for (const key of localKeys) {
140
+ const value = def[key];
141
+ if (value === void 0) continue;
142
+ localTemplates.push({
143
+ prefixed: prefixOf(paramBareName(key)),
144
+ value: prefixDeclaredVars(parseStyle(value).output, declared, prefixOf)
145
+ });
146
+ }
147
+ };
148
+ return (groups) => {
149
+ if (inProgress.has(cssName)) return "";
150
+ inProgress.add(cssName);
151
+ try {
152
+ if (!built) build();
153
+ const valueMap = /* @__PURE__ */ new Map();
154
+ params.forEach((param, index) => {
155
+ const arg = groups[index]?.output?.trim();
156
+ valueMap.set(param.prefixed, arg || param.default || "");
157
+ });
158
+ for (const local of localTemplates) valueMap.set(local.prefixed, local.value);
159
+ return substituteVars(resultTemplate, valueMap);
160
+ } finally {
161
+ inProgress.delete(cssName);
162
+ }
163
+ };
164
+ }
165
+ const registeredFunctionDefs = /* @__PURE__ */ new Map();
166
+ function registerFunctionPolyfill(name, definition) {
167
+ const cssName = parseFunctionName(name);
168
+ const serialized = JSON.stringify(definition);
169
+ if (registeredFunctionDefs.get(cssName) === serialized) return;
170
+ registeredFunctionDefs.set(cssName, serialized);
171
+ customFunction(cssName, compileFunctionClosure(name, definition));
172
+ }
173
+ function registerLocalFunctionPolyfills(styles) {
174
+ const local = extractLocalFunctions(styles);
175
+ if (!local) return;
176
+ for (const [name, definition] of Object.entries(local)) registerFunctionPolyfill(name, definition);
177
+ }
178
+ function resetFunctionPolyfills() {
179
+ registeredFunctionDefs.clear();
180
+ }
181
+ //#endregion
182
+ //#region src/properties/defaults.ts
183
+ const DEFAULT_PROPERTIES = {
184
+ "#tasty-second-fill": {
185
+ inherits: false,
186
+ initialValue: "transparent"
187
+ },
188
+ "#current": {
189
+ inherits: true,
190
+ initialValue: "currentcolor"
191
+ },
192
+ "#white": {
193
+ inherits: true,
194
+ initialValue: "rgb(255 255 255)"
195
+ },
196
+ "#black": {
197
+ inherits: true,
198
+ initialValue: "rgb(0 0 0)"
199
+ },
200
+ "#clear": {
201
+ inherits: true,
202
+ initialValue: "transparent"
203
+ },
204
+ "#border": {
205
+ inherits: true,
206
+ initialValue: "rgb(0 0 0)"
207
+ },
208
+ $gap: {
209
+ syntax: "<length>",
210
+ inherits: true,
211
+ initialValue: "4px"
212
+ },
213
+ $radius: {
214
+ syntax: "<length>",
215
+ inherits: true,
216
+ initialValue: "6px"
217
+ },
218
+ "$border-width": {
219
+ syntax: "<length>",
220
+ inherits: true,
221
+ initialValue: "1px"
222
+ },
223
+ "$outline-width": {
224
+ syntax: "<length>",
225
+ inherits: true,
226
+ initialValue: "3px"
227
+ },
228
+ $transition: {
229
+ syntax: "<time>",
230
+ inherits: true,
231
+ initialValue: "80ms"
232
+ },
233
+ "$sharp-radius": {
234
+ syntax: "<length>",
235
+ inherits: true,
236
+ initialValue: "0px"
237
+ },
238
+ "$bold-font-weight": {
239
+ syntax: "<number>",
240
+ inherits: true,
241
+ initialValue: "700"
242
+ },
243
+ "$font-sans-fallback": {
244
+ syntax: "*",
245
+ inherits: true,
246
+ initialValue: "system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, \"Apple Color Emoji\", \"Segoe UI Emoji\", sans-serif"
247
+ },
248
+ "$font-mono-fallback": {
249
+ syntax: "*",
250
+ inherits: true,
251
+ initialValue: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace"
252
+ }
253
+ };
254
+ //#endregion
255
+ //#region src/properties/index.ts
256
+ const PROPERTIES_KEY = "@property";
257
+ const VALID_PROPERTY_NAME_PATTERN = /^[a-z_][a-z0-9-_]*$/i;
258
+ function isValidPropertyName(name) {
259
+ return VALID_PROPERTY_NAME_PATTERN.test(name);
260
+ }
261
+ function hasLocalProperties(styles) {
262
+ return PROPERTIES_KEY in styles;
263
+ }
264
+ function extractLocalProperties(styles) {
265
+ const properties = styles[PROPERTIES_KEY];
266
+ if (!properties || typeof properties !== "object") return null;
267
+ return properties;
268
+ }
269
+ function parsePropertyToken(token) {
270
+ if (!token || typeof token !== "string") return {
271
+ cssName: "",
272
+ isColor: false,
273
+ isValid: false,
274
+ error: "Property token must be a non-empty string"
275
+ };
276
+ let name;
277
+ let isColor;
278
+ if (token.startsWith("$")) {
279
+ name = token.slice(1);
280
+ isColor = false;
281
+ } else if (token.startsWith("#")) {
282
+ name = token.slice(1);
283
+ isColor = true;
284
+ } else if (token.startsWith("--")) {
285
+ name = token.slice(2);
286
+ isColor = token.endsWith("-color");
287
+ } else {
288
+ name = token;
289
+ isColor = token.endsWith("-color");
290
+ }
291
+ if (!name) return {
292
+ cssName: "",
293
+ isColor,
294
+ isValid: false,
295
+ error: "Property name cannot be empty"
296
+ };
297
+ if (!isValidPropertyName(name)) return {
298
+ cssName: "",
299
+ isColor,
300
+ isValid: false,
301
+ error: `Invalid property name "${name}". Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.`
302
+ };
303
+ let cssName;
304
+ if (token.startsWith("#")) cssName = `--${name}-color`;
305
+ else cssName = `--${name}`;
306
+ return {
307
+ cssName,
308
+ isColor,
309
+ isValid: true
310
+ };
311
+ }
312
+ function normalizePropertyDefinition(def) {
313
+ const normalized = {};
314
+ if (def.inherits !== void 0) normalized.inherits = def.inherits;
315
+ if (def.syntax !== void 0) normalized.syntax = def.syntax;
316
+ return JSON.stringify(normalized);
317
+ }
318
+ function getEffectiveDefinition(token, userDefinition) {
319
+ const parsed = parsePropertyToken(token);
320
+ if (!parsed.isValid) return {
321
+ cssName: "",
322
+ definition: userDefinition,
323
+ isValid: false,
324
+ error: parsed.error
325
+ };
326
+ if (parsed.isColor) return {
327
+ cssName: parsed.cssName,
328
+ definition: {
329
+ syntax: "<color>",
330
+ inherits: userDefinition.inherits,
331
+ initialValue: userDefinition.initialValue ?? "transparent"
332
+ },
333
+ isValid: true
334
+ };
335
+ return {
336
+ cssName: parsed.cssName,
337
+ definition: userDefinition,
338
+ isValid: true
339
+ };
340
+ }
341
+ const UNIT_TO_SYNTAX = {};
342
+ const LENGTH_UNITS = [
343
+ "px",
344
+ "em",
345
+ "rem",
346
+ "vw",
347
+ "vh",
348
+ "vmin",
349
+ "vmax",
350
+ "ch",
351
+ "ex",
352
+ "cap",
353
+ "ic",
354
+ "lh",
355
+ "rlh",
356
+ "svw",
357
+ "svh",
358
+ "lvw",
359
+ "lvh",
360
+ "dvw",
361
+ "dvh",
362
+ "cqw",
363
+ "cqh",
364
+ "cqi",
365
+ "cqb",
366
+ "cqmin",
367
+ "cqmax"
368
+ ];
369
+ const ANGLE_UNITS = [
370
+ "deg",
371
+ "rad",
372
+ "grad",
373
+ "turn"
374
+ ];
375
+ const TIME_UNITS = ["ms", "s"];
376
+ for (const u of LENGTH_UNITS) UNIT_TO_SYNTAX[u] = {
377
+ syntax: "<length-percentage>",
378
+ initialValue: "0px"
379
+ };
380
+ UNIT_TO_SYNTAX["%"] = {
381
+ syntax: "<length-percentage>",
382
+ initialValue: "0px"
383
+ };
384
+ for (const u of ANGLE_UNITS) UNIT_TO_SYNTAX[u] = {
385
+ syntax: "<angle>",
386
+ initialValue: "0deg"
387
+ };
388
+ for (const u of TIME_UNITS) UNIT_TO_SYNTAX[u] = {
389
+ syntax: "<time>",
390
+ initialValue: "0s"
391
+ };
392
+ function inferSyntaxFromValue(value) {
393
+ if (!value || typeof value !== "string") return null;
394
+ const trimmed = value.trim();
395
+ if (!trimmed) return null;
396
+ if (RE_NUMBER.test(trimmed)) {
397
+ if (parseFloat(trimmed) === 0) return null;
398
+ return {
399
+ syntax: "<number>",
400
+ initialValue: "0"
401
+ };
402
+ }
403
+ const unitMatch = trimmed.match(RE_RAW_UNIT);
404
+ if (unitMatch) {
405
+ const unit = unitMatch[2];
406
+ const mapping = UNIT_TO_SYNTAX[unit];
407
+ if (mapping) return mapping;
408
+ }
409
+ return null;
410
+ }
411
+ //#endregion
412
+ //#region src/utils/hash.ts
413
+ function hashString(str) {
414
+ let hash = 5381;
415
+ for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i) | 0;
416
+ return (hash >>> 0).toString(36);
417
+ }
418
+ //#endregion
419
+ //#region src/utils/name-prefix.ts
420
+ const DEFAULT_NAME_PREFIX = "t";
421
+ const DEFAULT_ZERO_NAME_PREFIX = "ts";
422
+ const NAME_PREFIX_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$/;
423
+ function validateNamePrefix(prefix) {
424
+ if (typeof prefix !== "string") throw new TypeError(`[Tasty] namePrefix must be a string, got ${typeof prefix}.`);
425
+ if (!NAME_PREFIX_PATTERN.test(prefix)) throw new TypeError(`[Tasty] namePrefix "${prefix}" is invalid. It must start with a letter (a-z, A-Z) or "_", contain only letters, digits, "_" or "-", and be 1-32 characters long. Examples: "t", "ts", "myapp-", "_foo".`);
426
+ }
427
+ function makeClassName(prefix, hash) {
428
+ return `${prefix}${hash}`;
429
+ }
430
+ function makeKeyframeName(prefix, suffix) {
431
+ return `${prefix}k${suffix}`;
432
+ }
433
+ function makeCounterStyleName(prefix, suffix) {
434
+ return `${prefix}c${suffix}`;
435
+ }
436
+ function escapeRegex(str) {
437
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
438
+ }
439
+ function tastyClassRegex(prefix) {
440
+ return new RegExp(`^${escapeRegex(prefix)}[a-z0-9]+$`);
441
+ }
442
+ function rscClassRegexGlobal(prefix) {
443
+ return new RegExp(`\\.(${escapeRegex(prefix)}[a-z0-9]+)\\.\\1`, "g");
444
+ }
445
+ //#endregion
446
+ //#region src/properties/property-type-resolver.ts
447
+ const CUSTOM_PROP_DECL = /^\s*(--[a-z0-9_-]+)\s*:\s*(\S|\S.*\S)\s*$/i;
448
+ const SINGLE_VAR_REF = /^var\((--[a-z0-9_-]+)\)$/i;
449
+ var PropertyTypeResolver = class {
450
+ pendingDeps = /* @__PURE__ */ new Map();
451
+ reverseDeps = /* @__PURE__ */ new Map();
452
+ scanDeclarations(declarations, isPropertyDefined, registerProperty) {
453
+ if (!declarations.includes("--")) return;
454
+ const parts = declarations.split(/;+/);
455
+ for (const part of parts) {
456
+ if (!part.trim()) continue;
457
+ const match = CUSTOM_PROP_DECL.exec(part);
458
+ if (!match) continue;
459
+ const propName = match[1];
460
+ const value = match[2].trim();
461
+ if (isPropertyDefined(propName)) continue;
462
+ if (propName.endsWith("-color")) {
463
+ registerProperty(propName, "<color>", "transparent");
464
+ continue;
465
+ }
466
+ if (propName.endsWith("-line-height")) {
467
+ registerProperty(propName, "<number> | <length-percentage>", "0");
468
+ continue;
469
+ }
470
+ if (propName.endsWith("-opacity")) {
471
+ registerProperty(propName, "<number> | <percentage>", "0");
472
+ continue;
473
+ }
474
+ const varMatch = SINGLE_VAR_REF.exec(value);
475
+ if (varMatch) {
476
+ const depName = varMatch[1];
477
+ this.addDependency(propName, depName);
478
+ continue;
479
+ }
480
+ if (this.isComplexValue(value)) continue;
481
+ const inferred = inferSyntaxFromValue(value);
482
+ if (!inferred) continue;
483
+ this.resolve(propName, inferred.syntax, inferred.initialValue, isPropertyDefined, registerProperty);
484
+ }
485
+ }
486
+ addDependency(propName, depName) {
487
+ if (propName === depName) return;
488
+ this.pendingDeps.set(propName, depName);
489
+ let dependents = this.reverseDeps.get(depName);
490
+ if (!dependents) {
491
+ dependents = [];
492
+ this.reverseDeps.set(depName, dependents);
493
+ }
494
+ if (!dependents.includes(propName)) dependents.push(propName);
495
+ }
496
+ resolve(propName, syntax, initialValue, isPropertyDefined, registerProperty, resolving) {
497
+ if (!resolving) resolving = /* @__PURE__ */ new Set();
498
+ if (resolving.has(propName)) return;
499
+ resolving.add(propName);
500
+ if (!isPropertyDefined(propName)) registerProperty(propName, syntax, initialValue);
501
+ const dependents = this.reverseDeps.get(propName);
502
+ if (dependents) {
503
+ this.reverseDeps.delete(propName);
504
+ for (const dependent of dependents) {
505
+ this.pendingDeps.delete(dependent);
506
+ if (isPropertyDefined(dependent)) continue;
507
+ this.resolve(dependent, syntax, initialValue, isPropertyDefined, registerProperty, resolving);
508
+ }
509
+ }
510
+ }
511
+ isComplexValue(value) {
512
+ if (value.includes("calc(")) return true;
513
+ const firstVar = value.indexOf("var(");
514
+ if (firstVar === -1) return false;
515
+ if (value.indexOf("var(", firstVar + 4) !== -1) return true;
516
+ return !SINGLE_VAR_REF.test(value);
517
+ }
518
+ };
519
+ //#endregion
520
+ //#region src/font-face/index.ts
521
+ const FONT_FACE_KEY = "@font-face";
522
+ function hasLocalFontFace(styles) {
523
+ return FONT_FACE_KEY in styles;
524
+ }
525
+ function extractLocalFontFace(styles) {
526
+ const fontFace = styles[FONT_FACE_KEY];
527
+ if (!fontFace || typeof fontFace !== "object") return null;
528
+ return fontFace;
529
+ }
530
+ const FONT_FACE_DESCRIPTOR_MAP = {
531
+ fontWeight: "font-weight",
532
+ fontStyle: "font-style",
533
+ fontStretch: "font-stretch",
534
+ fontDisplay: "font-display",
535
+ unicodeRange: "unicode-range",
536
+ ascentOverride: "ascent-override",
537
+ descentOverride: "descent-override",
538
+ lineGapOverride: "line-gap-override",
539
+ sizeAdjust: "size-adjust",
540
+ fontFeatureSettings: "font-feature-settings",
541
+ fontVariationSettings: "font-variation-settings"
542
+ };
543
+ function formatFontFaceDeclarations(family, descriptors) {
544
+ const parts = [];
545
+ parts.push(`font-family: "${family}";`);
546
+ parts.push(`src: ${descriptors.src};`);
547
+ for (const [key, cssName] of Object.entries(FONT_FACE_DESCRIPTOR_MAP)) {
548
+ const value = descriptors[key];
549
+ if (value !== void 0) parts.push(`${cssName}: ${value};`);
550
+ }
551
+ return parts.join(" ");
552
+ }
553
+ function formatFontFaceRule(family, descriptors) {
554
+ return `@font-face { ${formatFontFaceDeclarations(family, descriptors)} }`;
555
+ }
556
+ function fontFaceContentHash(family, descriptors) {
557
+ return JSON.stringify({
558
+ family,
559
+ ...descriptors
560
+ });
561
+ }
562
+ //#endregion
563
+ //#region src/counter-style/index.ts
564
+ const COUNTER_STYLE_KEY = "@counter-style";
565
+ function hasLocalCounterStyle(styles) {
566
+ return COUNTER_STYLE_KEY in styles;
567
+ }
568
+ function extractLocalCounterStyle(styles) {
569
+ const counterStyle = styles[COUNTER_STYLE_KEY];
570
+ if (!counterStyle || typeof counterStyle !== "object") return null;
571
+ return counterStyle;
572
+ }
573
+ const COUNTER_STYLE_DESCRIPTOR_MAP = {
574
+ system: "system",
575
+ symbols: "symbols",
576
+ additiveSymbols: "additive-symbols",
577
+ prefix: "prefix",
578
+ suffix: "suffix",
579
+ negative: "negative",
580
+ range: "range",
581
+ pad: "pad",
582
+ fallback: "fallback",
583
+ speakAs: "speak-as"
584
+ };
585
+ function formatCounterStyleDeclarations(descriptors) {
586
+ const parts = [];
587
+ for (const [key, cssName] of Object.entries(COUNTER_STYLE_DESCRIPTOR_MAP)) {
588
+ const value = descriptors[key];
589
+ if (value !== void 0) parts.push(`${cssName}: ${value};`);
590
+ }
591
+ return parts.join(" ");
592
+ }
593
+ function formatCounterStyleRule(name, descriptors) {
594
+ return `@counter-style ${name} { ${formatCounterStyleDeclarations(descriptors)} }`;
595
+ }
596
+ //#endregion
597
+ //#region src/keyframes/index.ts
598
+ const KEYFRAMES_KEY = "@keyframes";
599
+ const NON_NAME_KEYWORDS = new Set("none initial inherit unset revert auto normal running paused reverse alternate alternate-reverse forwards backwards both ease linear ease-in ease-out ease-in-out step-start step-end".split(" "));
600
+ function hasLocalKeyframes(styles) {
601
+ return KEYFRAMES_KEY in styles;
602
+ }
603
+ function extractLocalKeyframes(styles) {
604
+ const keyframes = styles[KEYFRAMES_KEY];
605
+ if (!keyframes || typeof keyframes !== "object") return null;
606
+ return keyframes;
607
+ }
608
+ function mergeKeyframes(local, global) {
609
+ if (!local && !global) return null;
610
+ if (!local) return global;
611
+ if (!global) return local;
612
+ return {
613
+ ...global,
614
+ ...local
615
+ };
616
+ }
617
+ function extractAnimationNameFromValue(value) {
618
+ for (const part of value.trim().split(/\s+/)) {
619
+ const lower = part.toLowerCase();
620
+ if (NON_NAME_KEYWORDS.has(lower)) continue;
621
+ if (part === "infinite" || /^(?:-?[\d.]+m?s|\d+|(?:cubic-bezier|steps)\()/i.test(part)) continue;
622
+ const match = /^([a-zA-Z_-][a-zA-Z0-9_-]*)/.exec(part);
623
+ if (match) return match[1];
624
+ }
625
+ return null;
626
+ }
627
+ function collectAnimationNamesFromValue(value, names) {
628
+ for (const animation of value.split(",")) {
629
+ const name = extractAnimationNameFromValue(animation);
630
+ if (name) names.add(name);
631
+ }
632
+ }
633
+ function extractAnimationNamesFromStyleValue(value, names) {
634
+ if (typeof value === "string") collectAnimationNamesFromValue(value, names);
635
+ else if (Array.isArray(value)) for (const v of value) extractAnimationNamesFromStyleValue(v, names);
636
+ else if (value && typeof value === "object") for (const v of Object.values(value)) extractAnimationNamesFromStyleValue(v, names);
637
+ }
638
+ function collectAnimationNamesFromStyles(styles, names) {
639
+ if ("animation" in styles) extractAnimationNamesFromStyleValue(styles.animation, names);
640
+ if ("animationName" in styles) extractAnimationNamesFromStyleValue(styles.animationName, names);
641
+ for (const [key, value] of Object.entries(styles)) {
642
+ if (key === "$" || key === KEYFRAMES_KEY) continue;
643
+ if ((key.startsWith("&") || key.startsWith(".") || /^[A-Z]/.test(key)) && value && typeof value === "object") collectAnimationNamesFromStyles(value, names);
644
+ }
645
+ }
646
+ function extractAnimationNamesFromStyles(styles) {
647
+ const names = /* @__PURE__ */ new Set();
648
+ collectAnimationNamesFromStyles(styles, names);
649
+ return names;
650
+ }
651
+ function resolveKeyframesName(authored, steps) {
652
+ return `${authored}-${hashString(JSON.stringify(steps))}`;
653
+ }
654
+ function resolveKeyframesNames(used) {
655
+ const names = /* @__PURE__ */ new Map();
656
+ for (const [authored, steps] of Object.entries(used)) names.set(authored, resolveKeyframesName(authored, steps));
657
+ return names;
658
+ }
659
+ function replaceAnimationNames(declarations, nameMap, usedNames) {
660
+ if (nameMap.size === 0 || !declarations.includes("animation")) return declarations;
661
+ const parts = declarations.split(";");
662
+ let modified = false;
663
+ for (let i = 0; i < parts.length; i++) {
664
+ const part = parts[i];
665
+ const colonIdx = part.indexOf(":");
666
+ if (colonIdx === -1) continue;
667
+ const prop = part.slice(0, colonIdx).trim().toLowerCase();
668
+ if (prop === "animation" || prop === "animation-name") {
669
+ const prefix = part.slice(0, colonIdx + 1);
670
+ let value = part.slice(colonIdx + 1);
671
+ for (const original of nameMap.keys()) if (findWord(value, original) !== -1) usedNames.add(original);
672
+ for (const [original, injected] of nameMap) {
673
+ if (original === injected) continue;
674
+ const next = replaceWord(value, original, injected);
675
+ if (next !== value) {
676
+ value = next;
677
+ modified = true;
678
+ }
679
+ }
680
+ parts[i] = prefix + value;
681
+ }
682
+ }
683
+ return modified ? parts.join(";") : declarations;
684
+ }
685
+ function replaceWord(str, word, replacement) {
686
+ let result = str;
687
+ let idx = 0;
688
+ while ((idx = findWord(result, word, idx)) !== -1) {
689
+ result = result.slice(0, idx) + replacement + result.slice(idx + word.length);
690
+ idx += replacement.length;
691
+ }
692
+ return result;
693
+ }
694
+ function findWord(str, word, from = 0) {
695
+ let idx = from;
696
+ while ((idx = str.indexOf(word, idx)) !== -1) {
697
+ const before = idx === 0 ? " " : str[idx - 1];
698
+ const end = idx + word.length;
699
+ const after = end === str.length ? " " : str[end];
700
+ if (!/[\w-]/.test(before + after)) return idx;
701
+ idx = end;
702
+ }
703
+ return -1;
704
+ }
705
+ function filterUsedKeyframes(keyframes, usedNames) {
706
+ if (!keyframes || usedNames.size === 0) return null;
707
+ const used = {};
708
+ let hasAny = false;
709
+ for (const name of usedNames) if (keyframes[name]) {
710
+ used[name] = keyframes[name];
711
+ hasAny = true;
712
+ }
713
+ return hasAny ? used : null;
714
+ }
715
+ //#endregion
716
+ //#region src/ssr/format-property.ts
717
+ function formatPropertyCSS(token, definition) {
718
+ const result = getEffectiveDefinition(token, definition);
719
+ if (!result.isValid) return "";
720
+ return buildPropertyRule(result.cssName, result.definition);
721
+ }
722
+ function buildPropertyRule(cssName, definition) {
723
+ const parts = [];
724
+ if (definition.syntax != null) {
725
+ let syntax = String(definition.syntax).trim();
726
+ if (!/^['"]/u.test(syntax)) syntax = `"${syntax}"`;
727
+ parts.push(`syntax: ${syntax};`);
728
+ }
729
+ const inherits = definition.inherits ?? true;
730
+ parts.push(`inherits: ${inherits ? "true" : "false"};`);
731
+ if (definition.initialValue != null) {
732
+ let initialValueStr;
733
+ if (typeof definition.initialValue === "number") initialValueStr = String(definition.initialValue);
734
+ else initialValueStr = parseStyle(definition.initialValue).output;
735
+ parts.push(`initial-value: ${initialValueStr};`);
736
+ }
737
+ return `@property ${cssName} { ${parts.join(" ").trim()} }`;
738
+ }
739
+ //#endregion
740
+ //#region src/ssr/format-keyframes.ts
741
+ function stepsToCSS(steps) {
742
+ const rules = [];
743
+ for (const [key, value] of Object.entries(steps)) {
744
+ if (typeof value === "string") {
745
+ rules.push(`${key} { ${value.trim()} }`);
746
+ continue;
747
+ }
748
+ const styleMap = value || {};
749
+ const styleNames = Object.keys(styleMap).sort();
750
+ const handlerQueue = [];
751
+ const seenHandlers = /* @__PURE__ */ new Set();
752
+ styleNames.forEach((styleName) => {
753
+ let handlers = STYLE_HANDLER_MAP[styleName];
754
+ if (!handlers) handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];
755
+ handlers.forEach((handler) => {
756
+ if (!seenHandlers.has(handler)) {
757
+ seenHandlers.add(handler);
758
+ handlerQueue.push(handler);
759
+ }
760
+ });
761
+ });
762
+ const declarationPairs = [];
763
+ handlerQueue.forEach((handler) => {
764
+ const result = handler(handler.__lookupStyles.reduce((acc, name) => {
765
+ const v = styleMap[name];
766
+ if (v !== void 0) acc[name] = v;
767
+ return acc;
768
+ }, {}));
769
+ if (!result) return;
770
+ (Array.isArray(result) ? result : [result]).forEach((cssMap) => {
771
+ if (!cssMap || typeof cssMap !== "object") return;
772
+ const { $: _$, ...props } = cssMap;
773
+ Object.entries(props).forEach(([prop, val]) => {
774
+ if (val == null || val === "") return;
775
+ if (Array.isArray(val)) val.forEach((v) => {
776
+ if (v != null && v !== "") declarationPairs.push({
777
+ prop,
778
+ value: String(v)
779
+ });
780
+ });
781
+ else declarationPairs.push({
782
+ prop,
783
+ value: String(val)
784
+ });
785
+ });
786
+ });
787
+ });
788
+ const declarations = declarationPairs.map((d) => `${d.prop}: ${d.value}`).join("; ");
789
+ rules.push(`${key} { ${declarations.trim()} }`);
790
+ }
791
+ return rules.join(" ");
792
+ }
793
+ function formatKeyframesCSS(name, steps) {
794
+ return `@keyframes ${name} { ${stepsToCSS(steps)} }`;
795
+ }
796
+ //#endregion
797
+ //#region src/ssr/format-rules.ts
798
+ function resolveSelector(rule, className) {
799
+ let selector = rule.selector;
800
+ if (rule.needsClassName) {
801
+ const selectorParts = selector ? selector.split("|||") : [""];
802
+ const classPrefix = `.${className}.${className}`;
803
+ selector = selectorParts.map((part) => {
804
+ const classSelector = part ? `${classPrefix}${part}` : classPrefix;
805
+ if (rule.rootPrefix) return `${rule.rootPrefix} ${classSelector}`;
806
+ return classSelector;
807
+ }).join(", ");
808
+ }
809
+ return selector;
810
+ }
811
+ function groupRules(rules) {
812
+ const groupMap = /* @__PURE__ */ new Map();
813
+ const order = [];
814
+ const atKey = (at) => at && at.length ? at.join("|") : "";
815
+ for (const r of rules) {
816
+ const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? "1" : "0"}`;
817
+ const existing = groupMap.get(key);
818
+ if (existing) existing.declarations = existing.declarations ? `${existing.declarations} ${r.declarations}` : r.declarations;
819
+ else {
820
+ groupMap.set(key, {
821
+ selector: r.selector,
822
+ atRules: r.atRules,
823
+ startingStyle: r.startingStyle,
824
+ declarations: r.declarations
825
+ });
826
+ order.push(key);
827
+ }
828
+ }
829
+ return order.map((key) => groupMap.get(key));
830
+ }
831
+ function formatRules(rules, className) {
832
+ if (rules.length === 0) return "";
833
+ const grouped = groupRules(rules.map((rule) => ({
834
+ selector: resolveSelector(rule, className),
835
+ declarations: rule.declarations,
836
+ atRules: rule.atRules,
837
+ startingStyle: rule.startingStyle
838
+ })));
839
+ const cssRules = [];
840
+ for (const rule of grouped) {
841
+ const innerContent = rule.startingStyle ? `@starting-style { ${rule.declarations} }` : rule.declarations;
842
+ const baseRule = `${rule.selector} { ${innerContent} }`;
843
+ let fullRule = baseRule;
844
+ if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
845
+ cssRules.push(fullRule);
846
+ }
847
+ return cssRules.join("\n");
848
+ }
849
+ //#endregion
850
+ //#region src/ssr/format-global-rules.ts
851
+ function formatGlobalRules(rules) {
852
+ if (rules.length === 0) return "";
853
+ const cssRules = [];
854
+ for (const rule of rules) {
855
+ const baseRule = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.declarations} }`;
856
+ let fullRule = baseRule;
857
+ if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
858
+ cssRules.push(fullRule);
859
+ }
860
+ return cssRules.join("\n");
861
+ }
862
+ //#endregion
863
+ //#region src/ssr/artifacts.ts
864
+ function createServerStyleArtifact(kind, key, css, order) {
865
+ const content = `${kind}\0${key}\0${css}`;
866
+ return {
867
+ id: `${kind}:${hashString(content)}:${content.length.toString(36)}`,
868
+ kind,
869
+ css,
870
+ order
871
+ };
872
+ }
873
+ //#endregion
874
+ export { validateNamePrefix as A, formatFunctionPrelude as B, DEFAULT_NAME_PREFIX as C, makeKeyframeName as D, makeCounterStyleName as E, normalizePropertyDefinition as F, registerLocalFunctionPolyfills as G, hasLocalFunctions as H, parsePropertyToken as I, resetFunctionPolyfills as K, DEFAULT_PROPERTIES as L, extractLocalProperties as M, getEffectiveDefinition as N, rscClassRegexGlobal as O, hasLocalProperties as P, extractLocalFunctions as R, PropertyTypeResolver as S, makeClassName as T, parseFunctionName as U, formatFunctionRule as V, registerFunctionPolyfill as W, extractLocalFontFace as _, formatPropertyCSS as a, formatFontFaceRule as b, filterUsedKeyframes as c, replaceAnimationNames as d, resolveKeyframesNames as f, hasLocalCounterStyle as g, formatCounterStyleRule as h, formatKeyframesCSS as i, hashString as j, tastyClassRegex as k, hasLocalKeyframes as l, formatCounterStyleDeclarations as m, formatGlobalRules as n, extractAnimationNamesFromStyles as o, extractLocalCounterStyle as p, splitFunctions as q, formatRules as r, extractLocalKeyframes as s, createServerStyleArtifact as t, mergeKeyframes as u, fontFaceContentHash as v, DEFAULT_ZERO_NAME_PREFIX as w, hasLocalFontFace as x, formatFontFaceDeclarations as y, formatFunctionDeclarations as z };
875
+
876
+ //# sourceMappingURL=css-definitions-DotDkIXt.js.map