@tenphi/tasty 3.7.0 → 3.9.0

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 (103) hide show
  1. package/dist/{babel-DWCsafYw.d.ts → babel-Zs1Q03qt.d.ts} +2 -2
  2. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  4. package/dist/chunks/build-config-CUQVwdWF.js +42 -0
  5. package/dist/chunks/build-config-CUQVwdWF.js.map +1 -0
  6. package/dist/{collector-B3OsM252.js → chunks/collector-B0LTHw6Z.js} +6 -125
  7. package/dist/chunks/collector-B0LTHw6Z.js.map +1 -0
  8. package/dist/chunks/config-engine-C3pF9EK9.js +267 -0
  9. package/dist/chunks/config-engine-C3pF9EK9.js.map +1 -0
  10. package/dist/chunks/css-definitions-D_it4XZH.js +875 -0
  11. package/dist/chunks/css-definitions-D_it4XZH.js.map +1 -0
  12. package/dist/{css-resources-Cyl_axbI.js → chunks/css-resources-BN8apgxt.js} +1 -8
  13. package/dist/chunks/css-resources-BN8apgxt.js.map +1 -0
  14. package/dist/chunks/debug-C9LeNVoJ.js +501 -0
  15. package/dist/chunks/debug-C9LeNVoJ.js.map +1 -0
  16. package/dist/chunks/dsl-C5yuAn41.js +1373 -0
  17. package/dist/chunks/dsl-C5yuAn41.js.map +1 -0
  18. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  20. package/dist/chunks/react-runtime-O-OUrKLH.js +557 -0
  21. package/dist/chunks/react-runtime-O-OUrKLH.js.map +1 -0
  22. package/dist/chunks/runtime-engine-DvnE2g-E.js +2437 -0
  23. package/dist/chunks/runtime-engine-DvnE2g-E.js.map +1 -0
  24. package/dist/chunks/runtime-state-BTDqSYBk.js +127 -0
  25. package/dist/chunks/runtime-state-BTDqSYBk.js.map +1 -0
  26. package/dist/{merge-styles-DuoZEsm9.js → chunks/shared-utils-DWA4LjIa.js} +55 -54
  27. package/dist/chunks/shared-utils-DWA4LjIa.js.map +1 -0
  28. package/dist/chunks/style-engine-C1ECBZxR.js +5131 -0
  29. package/dist/chunks/style-engine-C1ECBZxR.js.map +1 -0
  30. package/dist/{css-writer-Bgowobbx.js → chunks/zero-engine-B6EnYcXY.js} +3 -120
  31. package/dist/chunks/zero-engine-B6EnYcXY.js.map +1 -0
  32. package/dist/{collector-BTVXj2hS.d.ts → collector-hl5KNH7k.d.ts} +6 -4
  33. package/dist/{config-LfIDmVHx.d.ts → config-DWL1ZYue.d.ts} +20 -25
  34. package/dist/core/index.d.ts +5 -5
  35. package/dist/core/index.js +9 -6
  36. package/dist/{index-Bm9ltvdH.d.ts → index-D9N9GV24.d.ts} +96 -82
  37. package/dist/index.d.ts +5 -5
  38. package/dist/index.js +11 -922
  39. package/dist/{merge-styles-BcLl1u_d.d.ts → merge-styles-C_oMoJVd.d.ts} +2 -2
  40. package/dist/ssr/astro-client.js +1 -14
  41. package/dist/ssr/astro-client.js.map +1 -1
  42. package/dist/ssr/astro-middleware-extract-static.js +1 -1
  43. package/dist/ssr/astro-middleware-extract.js +1 -1
  44. package/dist/ssr/astro-middleware-static.js +1 -12
  45. package/dist/ssr/astro-middleware-static.js.map +1 -1
  46. package/dist/ssr/astro-middleware.js +1 -13
  47. package/dist/ssr/astro-middleware.js.map +1 -1
  48. package/dist/ssr/astro.js +219 -1
  49. package/dist/ssr/astro.js.map +1 -0
  50. package/dist/ssr/index.d.ts +6 -6
  51. package/dist/ssr/index.js +4 -4
  52. package/dist/ssr/next-config.d.ts +1 -1
  53. package/dist/ssr/next-config.js +29 -20
  54. package/dist/ssr/next-config.js.map +1 -1
  55. package/dist/ssr/next.d.ts +1 -1
  56. package/dist/ssr/next.js +5 -37
  57. package/dist/ssr/next.js.map +1 -1
  58. package/dist/static/index.d.ts +2 -2
  59. package/dist/static/index.js +1 -19
  60. package/dist/static/index.js.map +1 -1
  61. package/dist/{index-BmogEzTo.d.ts → types-jKZNpias.d.ts} +845 -804
  62. package/dist/zero/babel.d.ts +1 -1
  63. package/dist/zero/babel.js +25 -96
  64. package/dist/zero/babel.js.map +1 -1
  65. package/dist/zero/index.d.ts +1 -1
  66. package/dist/zero/index.js +1 -1
  67. package/dist/zero/next.d.ts +1 -1
  68. package/dist/zero/next.js +0 -31
  69. package/dist/zero/next.js.map +1 -1
  70. package/docs/ai-agents.md +8 -3
  71. package/docs/debug.md +2 -5
  72. package/docs/methodology.md +3 -3
  73. package/docs/pipeline.md +3 -0
  74. package/docs/runtime-benchmarks.md +105 -68
  75. package/docs/styles.md +43 -11
  76. package/package.json +48 -5
  77. package/dist/astro-CeYENy2x.js +0 -301
  78. package/dist/astro-CeYENy2x.js.map +0 -1
  79. package/dist/async-storage-DKK-wTD4.js +0 -44
  80. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  81. package/dist/collector-B3OsM252.js.map +0 -1
  82. package/dist/config-B3gPdCqd.js +0 -12421
  83. package/dist/config-B3gPdCqd.js.map +0 -1
  84. package/dist/context-CA8YKeMn.js +0 -24
  85. package/dist/context-CA8YKeMn.js.map +0 -1
  86. package/dist/core-DGm0CFHP.js +0 -1732
  87. package/dist/core-DGm0CFHP.js.map +0 -1
  88. package/dist/css-resources-Cyl_axbI.js.map +0 -1
  89. package/dist/css-writer-Bgowobbx.js.map +0 -1
  90. package/dist/format-global-rules-DklyaXv-.js +0 -22
  91. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  92. package/dist/format-rules-XRw9u7d4.js +0 -104
  93. package/dist/format-rules-XRw9u7d4.js.map +0 -1
  94. package/dist/hydrate-CNOmZprz.js +0 -37
  95. package/dist/hydrate-CNOmZprz.js.map +0 -1
  96. package/dist/index.js.map +0 -1
  97. package/dist/keyframes-DE-OE76F.js +0 -535
  98. package/dist/keyframes-DE-OE76F.js.map +0 -1
  99. package/dist/merge-styles-DuoZEsm9.js.map +0 -1
  100. package/dist/resolve-recipes-H9NqOQuP.js +0 -144
  101. package/dist/resolve-recipes-H9NqOQuP.js.map +0 -1
  102. package/dist/ssr-collector-ref-COs_ioWl.js +0 -29
  103. package/dist/ssr-collector-ref-COs_ioWl.js.map +0 -1
@@ -0,0 +1,875 @@
1
+ import { F as RE_RAW_UNIT, P as RE_NUMBER, a as customFunction, f as parseStyle } from "./dsl-C5yuAn41.js";
2
+ import { C as STYLE_HANDLER_MAP, k as createStyle } from "./style-engine-C1ECBZxR.js";
3
+ //#region src/functions/index.ts
4
+ const FUNCTION_KEY = "@function";
5
+ const RESERVED_KEYS = 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 mapping = UNIT_TO_SYNTAX[unitMatch[2]];
406
+ if (mapping) return mapping;
407
+ }
408
+ return null;
409
+ }
410
+ //#endregion
411
+ //#region src/utils/hash.ts
412
+ function hashString(str) {
413
+ let hash = 5381;
414
+ for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i) | 0;
415
+ return (hash >>> 0).toString(36);
416
+ }
417
+ //#endregion
418
+ //#region src/utils/name-prefix.ts
419
+ const DEFAULT_NAME_PREFIX = "t";
420
+ const DEFAULT_ZERO_NAME_PREFIX = "ts";
421
+ const NAME_PREFIX_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$/;
422
+ function validateNamePrefix(prefix) {
423
+ if (typeof prefix !== "string") throw new TypeError(`[Tasty] namePrefix must be a string, got ${typeof prefix}.`);
424
+ 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".`);
425
+ }
426
+ function makeClassName(prefix, hash) {
427
+ return `${prefix}${hash}`;
428
+ }
429
+ function makeKeyframeName(prefix, suffix) {
430
+ return `${prefix}k${suffix}`;
431
+ }
432
+ function makeCounterStyleName(prefix, suffix) {
433
+ return `${prefix}c${suffix}`;
434
+ }
435
+ function escapeRegex(str) {
436
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
437
+ }
438
+ function tastyClassRegex(prefix) {
439
+ return new RegExp(`^${escapeRegex(prefix)}[a-z0-9]+$`);
440
+ }
441
+ function rscClassRegexGlobal(prefix) {
442
+ return new RegExp(`\\.(${escapeRegex(prefix)}[a-z0-9]+)\\.\\1`, "g");
443
+ }
444
+ //#endregion
445
+ //#region src/properties/property-type-resolver.ts
446
+ const CUSTOM_PROP_DECL = /^\s*(--[a-z0-9_-]+)\s*:\s*(\S|\S.*\S)\s*$/i;
447
+ const SINGLE_VAR_REF = /^var\((--[a-z0-9_-]+)\)$/i;
448
+ var PropertyTypeResolver = class {
449
+ pendingDeps = /* @__PURE__ */ new Map();
450
+ reverseDeps = /* @__PURE__ */ new Map();
451
+ scanDeclarations(declarations, isPropertyDefined, registerProperty) {
452
+ if (!declarations.includes("--")) return;
453
+ const parts = declarations.split(/;+/);
454
+ for (const part of parts) {
455
+ if (!part.trim()) continue;
456
+ const match = CUSTOM_PROP_DECL.exec(part);
457
+ if (!match) continue;
458
+ const propName = match[1];
459
+ const value = match[2].trim();
460
+ if (isPropertyDefined(propName)) continue;
461
+ if (propName.endsWith("-color")) {
462
+ registerProperty(propName, "<color>", "transparent");
463
+ continue;
464
+ }
465
+ if (propName.endsWith("-line-height")) {
466
+ registerProperty(propName, "<number> | <length-percentage>", "0");
467
+ continue;
468
+ }
469
+ if (propName.endsWith("-opacity")) {
470
+ registerProperty(propName, "<number> | <percentage>", "0");
471
+ continue;
472
+ }
473
+ const varMatch = SINGLE_VAR_REF.exec(value);
474
+ if (varMatch) {
475
+ const depName = varMatch[1];
476
+ this.addDependency(propName, depName);
477
+ continue;
478
+ }
479
+ if (this.isComplexValue(value)) continue;
480
+ const inferred = inferSyntaxFromValue(value);
481
+ if (!inferred) continue;
482
+ this.resolve(propName, inferred.syntax, inferred.initialValue, isPropertyDefined, registerProperty);
483
+ }
484
+ }
485
+ addDependency(propName, depName) {
486
+ if (propName === depName) return;
487
+ this.pendingDeps.set(propName, depName);
488
+ let dependents = this.reverseDeps.get(depName);
489
+ if (!dependents) {
490
+ dependents = [];
491
+ this.reverseDeps.set(depName, dependents);
492
+ }
493
+ if (!dependents.includes(propName)) dependents.push(propName);
494
+ }
495
+ resolve(propName, syntax, initialValue, isPropertyDefined, registerProperty, resolving) {
496
+ if (!resolving) resolving = /* @__PURE__ */ new Set();
497
+ if (resolving.has(propName)) return;
498
+ resolving.add(propName);
499
+ if (!isPropertyDefined(propName)) registerProperty(propName, syntax, initialValue);
500
+ const dependents = this.reverseDeps.get(propName);
501
+ if (dependents) {
502
+ this.reverseDeps.delete(propName);
503
+ for (const dependent of dependents) {
504
+ this.pendingDeps.delete(dependent);
505
+ if (isPropertyDefined(dependent)) continue;
506
+ this.resolve(dependent, syntax, initialValue, isPropertyDefined, registerProperty, resolving);
507
+ }
508
+ }
509
+ }
510
+ isComplexValue(value) {
511
+ if (value.includes("calc(")) return true;
512
+ const firstVar = value.indexOf("var(");
513
+ if (firstVar === -1) return false;
514
+ if (value.indexOf("var(", firstVar + 4) !== -1) return true;
515
+ return !SINGLE_VAR_REF.test(value);
516
+ }
517
+ };
518
+ //#endregion
519
+ //#region src/font-face/index.ts
520
+ const FONT_FACE_KEY = "@font-face";
521
+ function hasLocalFontFace(styles) {
522
+ return FONT_FACE_KEY in styles;
523
+ }
524
+ function extractLocalFontFace(styles) {
525
+ const fontFace = styles[FONT_FACE_KEY];
526
+ if (!fontFace || typeof fontFace !== "object") return null;
527
+ return fontFace;
528
+ }
529
+ const FONT_FACE_DESCRIPTOR_MAP = {
530
+ fontWeight: "font-weight",
531
+ fontStyle: "font-style",
532
+ fontStretch: "font-stretch",
533
+ fontDisplay: "font-display",
534
+ unicodeRange: "unicode-range",
535
+ ascentOverride: "ascent-override",
536
+ descentOverride: "descent-override",
537
+ lineGapOverride: "line-gap-override",
538
+ sizeAdjust: "size-adjust",
539
+ fontFeatureSettings: "font-feature-settings",
540
+ fontVariationSettings: "font-variation-settings"
541
+ };
542
+ function formatFontFaceDeclarations(family, descriptors) {
543
+ const parts = [];
544
+ parts.push(`font-family: "${family}";`);
545
+ parts.push(`src: ${descriptors.src};`);
546
+ for (const [key, cssName] of Object.entries(FONT_FACE_DESCRIPTOR_MAP)) {
547
+ const value = descriptors[key];
548
+ if (value !== void 0) parts.push(`${cssName}: ${value};`);
549
+ }
550
+ return parts.join(" ");
551
+ }
552
+ function formatFontFaceRule(family, descriptors) {
553
+ return `@font-face { ${formatFontFaceDeclarations(family, descriptors)} }`;
554
+ }
555
+ function fontFaceContentHash(family, descriptors) {
556
+ return JSON.stringify({
557
+ family,
558
+ ...descriptors
559
+ });
560
+ }
561
+ //#endregion
562
+ //#region src/counter-style/index.ts
563
+ const COUNTER_STYLE_KEY = "@counter-style";
564
+ function hasLocalCounterStyle(styles) {
565
+ return COUNTER_STYLE_KEY in styles;
566
+ }
567
+ function extractLocalCounterStyle(styles) {
568
+ const counterStyle = styles[COUNTER_STYLE_KEY];
569
+ if (!counterStyle || typeof counterStyle !== "object") return null;
570
+ return counterStyle;
571
+ }
572
+ const COUNTER_STYLE_DESCRIPTOR_MAP = {
573
+ system: "system",
574
+ symbols: "symbols",
575
+ additiveSymbols: "additive-symbols",
576
+ prefix: "prefix",
577
+ suffix: "suffix",
578
+ negative: "negative",
579
+ range: "range",
580
+ pad: "pad",
581
+ fallback: "fallback",
582
+ speakAs: "speak-as"
583
+ };
584
+ function formatCounterStyleDeclarations(descriptors) {
585
+ const parts = [];
586
+ for (const [key, cssName] of Object.entries(COUNTER_STYLE_DESCRIPTOR_MAP)) {
587
+ const value = descriptors[key];
588
+ if (value !== void 0) parts.push(`${cssName}: ${value};`);
589
+ }
590
+ return parts.join(" ");
591
+ }
592
+ function formatCounterStyleRule(name, descriptors) {
593
+ return `@counter-style ${name} { ${formatCounterStyleDeclarations(descriptors)} }`;
594
+ }
595
+ //#endregion
596
+ //#region src/keyframes/index.ts
597
+ const KEYFRAMES_KEY = "@keyframes";
598
+ 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(" "));
599
+ function hasLocalKeyframes(styles) {
600
+ return KEYFRAMES_KEY in styles;
601
+ }
602
+ function extractLocalKeyframes(styles) {
603
+ const keyframes = styles[KEYFRAMES_KEY];
604
+ if (!keyframes || typeof keyframes !== "object") return null;
605
+ return keyframes;
606
+ }
607
+ function mergeKeyframes(local, global) {
608
+ if (!local && !global) return null;
609
+ if (!local) return global;
610
+ if (!global) return local;
611
+ return {
612
+ ...global,
613
+ ...local
614
+ };
615
+ }
616
+ function extractAnimationNameFromValue(value) {
617
+ for (const part of value.trim().split(/\s+/)) {
618
+ const lower = part.toLowerCase();
619
+ if (NON_NAME_KEYWORDS.has(lower)) continue;
620
+ if (part === "infinite" || /^(?:-?[\d.]+m?s|\d+|(?:cubic-bezier|steps)\()/i.test(part)) continue;
621
+ const match = /^([a-zA-Z_-][a-zA-Z0-9_-]*)/.exec(part);
622
+ if (match) return match[1];
623
+ }
624
+ return null;
625
+ }
626
+ function collectAnimationNamesFromValue(value, names) {
627
+ for (const animation of value.split(",")) {
628
+ const name = extractAnimationNameFromValue(animation);
629
+ if (name) names.add(name);
630
+ }
631
+ }
632
+ function extractAnimationNamesFromStyleValue(value, names) {
633
+ if (typeof value === "string") collectAnimationNamesFromValue(value, names);
634
+ else if (Array.isArray(value)) for (const v of value) extractAnimationNamesFromStyleValue(v, names);
635
+ else if (value && typeof value === "object") for (const v of Object.values(value)) extractAnimationNamesFromStyleValue(v, names);
636
+ }
637
+ function collectAnimationNamesFromStyles(styles, names) {
638
+ if ("animation" in styles) extractAnimationNamesFromStyleValue(styles.animation, names);
639
+ if ("animationName" in styles) extractAnimationNamesFromStyleValue(styles.animationName, names);
640
+ for (const [key, value] of Object.entries(styles)) {
641
+ if (key === "$" || key === KEYFRAMES_KEY) continue;
642
+ if ((key.startsWith("&") || key.startsWith(".") || /^[A-Z]/.test(key)) && value && typeof value === "object") collectAnimationNamesFromStyles(value, names);
643
+ }
644
+ }
645
+ function extractAnimationNamesFromStyles(styles) {
646
+ const names = /* @__PURE__ */ new Set();
647
+ collectAnimationNamesFromStyles(styles, names);
648
+ return names;
649
+ }
650
+ function resolveKeyframesName(authored, steps) {
651
+ return `${authored}-${hashString(JSON.stringify(steps))}`;
652
+ }
653
+ function resolveKeyframesNames(used) {
654
+ const names = /* @__PURE__ */ new Map();
655
+ for (const [authored, steps] of Object.entries(used)) names.set(authored, resolveKeyframesName(authored, steps));
656
+ return names;
657
+ }
658
+ function replaceAnimationNames(declarations, nameMap, usedNames) {
659
+ if (nameMap.size === 0 || !declarations.includes("animation")) return declarations;
660
+ const parts = declarations.split(";");
661
+ let modified = false;
662
+ for (let i = 0; i < parts.length; i++) {
663
+ const part = parts[i];
664
+ const colonIdx = part.indexOf(":");
665
+ if (colonIdx === -1) continue;
666
+ const prop = part.slice(0, colonIdx).trim().toLowerCase();
667
+ if (prop === "animation" || prop === "animation-name") {
668
+ const prefix = part.slice(0, colonIdx + 1);
669
+ let value = part.slice(colonIdx + 1);
670
+ for (const original of nameMap.keys()) if (findWord(value, original) !== -1) usedNames.add(original);
671
+ for (const [original, injected] of nameMap) {
672
+ if (original === injected) continue;
673
+ const next = replaceWord(value, original, injected);
674
+ if (next !== value) {
675
+ value = next;
676
+ modified = true;
677
+ }
678
+ }
679
+ parts[i] = prefix + value;
680
+ }
681
+ }
682
+ return modified ? parts.join(";") : declarations;
683
+ }
684
+ function replaceWord(str, word, replacement) {
685
+ let result = str;
686
+ let idx = 0;
687
+ while ((idx = findWord(result, word, idx)) !== -1) {
688
+ result = result.slice(0, idx) + replacement + result.slice(idx + word.length);
689
+ idx += replacement.length;
690
+ }
691
+ return result;
692
+ }
693
+ function findWord(str, word, from = 0) {
694
+ let idx = from;
695
+ while ((idx = str.indexOf(word, idx)) !== -1) {
696
+ const before = idx === 0 ? " " : str[idx - 1];
697
+ const end = idx + word.length;
698
+ const after = end === str.length ? " " : str[end];
699
+ if (!/[\w-]/.test(before + after)) return idx;
700
+ idx = end;
701
+ }
702
+ return -1;
703
+ }
704
+ function filterUsedKeyframes(keyframes, usedNames) {
705
+ if (!keyframes || usedNames.size === 0) return null;
706
+ const used = {};
707
+ let hasAny = false;
708
+ for (const name of usedNames) if (keyframes[name]) {
709
+ used[name] = keyframes[name];
710
+ hasAny = true;
711
+ }
712
+ return hasAny ? used : null;
713
+ }
714
+ //#endregion
715
+ //#region src/ssr/format-property.ts
716
+ function formatPropertyCSS(token, definition) {
717
+ const result = getEffectiveDefinition(token, definition);
718
+ if (!result.isValid) return "";
719
+ return buildPropertyRule(result.cssName, result.definition);
720
+ }
721
+ function buildPropertyRule(cssName, definition) {
722
+ const parts = [];
723
+ if (definition.syntax != null) {
724
+ let syntax = String(definition.syntax).trim();
725
+ if (!/^['"]/u.test(syntax)) syntax = `"${syntax}"`;
726
+ parts.push(`syntax: ${syntax};`);
727
+ }
728
+ const inherits = definition.inherits ?? true;
729
+ parts.push(`inherits: ${inherits ? "true" : "false"};`);
730
+ if (definition.initialValue != null) {
731
+ let initialValueStr;
732
+ if (typeof definition.initialValue === "number") initialValueStr = String(definition.initialValue);
733
+ else initialValueStr = parseStyle(definition.initialValue).output;
734
+ parts.push(`initial-value: ${initialValueStr};`);
735
+ }
736
+ return `@property ${cssName} { ${parts.join(" ").trim()} }`;
737
+ }
738
+ //#endregion
739
+ //#region src/ssr/format-keyframes.ts
740
+ function stepsToCSS(steps) {
741
+ const rules = [];
742
+ for (const [key, value] of Object.entries(steps)) {
743
+ if (typeof value === "string") {
744
+ rules.push(`${key} { ${value.trim()} }`);
745
+ continue;
746
+ }
747
+ const styleMap = value || {};
748
+ const styleNames = Object.keys(styleMap).sort();
749
+ const handlerQueue = [];
750
+ const seenHandlers = /* @__PURE__ */ new Set();
751
+ styleNames.forEach((styleName) => {
752
+ let handlers = STYLE_HANDLER_MAP[styleName];
753
+ if (!handlers) handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];
754
+ handlers.forEach((handler) => {
755
+ if (!seenHandlers.has(handler)) {
756
+ seenHandlers.add(handler);
757
+ handlerQueue.push(handler);
758
+ }
759
+ });
760
+ });
761
+ const declarationPairs = [];
762
+ handlerQueue.forEach((handler) => {
763
+ const result = handler(handler.__lookupStyles.reduce((acc, name) => {
764
+ const v = styleMap[name];
765
+ if (v !== void 0) acc[name] = v;
766
+ return acc;
767
+ }, {}));
768
+ if (!result) return;
769
+ (Array.isArray(result) ? result : [result]).forEach((cssMap) => {
770
+ if (!cssMap || typeof cssMap !== "object") return;
771
+ const { $: _$, ...props } = cssMap;
772
+ Object.entries(props).forEach(([prop, val]) => {
773
+ if (val == null || val === "") return;
774
+ if (Array.isArray(val)) val.forEach((v) => {
775
+ if (v != null && v !== "") declarationPairs.push({
776
+ prop,
777
+ value: String(v)
778
+ });
779
+ });
780
+ else declarationPairs.push({
781
+ prop,
782
+ value: String(val)
783
+ });
784
+ });
785
+ });
786
+ });
787
+ const declarations = declarationPairs.map((d) => `${d.prop}: ${d.value}`).join("; ");
788
+ rules.push(`${key} { ${declarations.trim()} }`);
789
+ }
790
+ return rules.join(" ");
791
+ }
792
+ function formatKeyframesCSS(name, steps) {
793
+ return `@keyframes ${name} { ${stepsToCSS(steps)} }`;
794
+ }
795
+ //#endregion
796
+ //#region src/ssr/format-rules.ts
797
+ function resolveSelector(rule, className) {
798
+ let selector = rule.selector;
799
+ if (rule.needsClassName) {
800
+ const selectorParts = selector ? selector.split("|||") : [""];
801
+ const classPrefix = `.${className}.${className}`;
802
+ selector = selectorParts.map((part) => {
803
+ const classSelector = part ? `${classPrefix}${part}` : classPrefix;
804
+ if (rule.rootPrefix) return `${rule.rootPrefix} ${classSelector}`;
805
+ return classSelector;
806
+ }).join(", ");
807
+ }
808
+ return selector;
809
+ }
810
+ function groupRules(rules) {
811
+ const groupMap = /* @__PURE__ */ new Map();
812
+ const order = [];
813
+ const atKey = (at) => at && at.length ? at.join("|") : "";
814
+ for (const r of rules) {
815
+ const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? "1" : "0"}`;
816
+ const existing = groupMap.get(key);
817
+ if (existing) existing.declarations = existing.declarations ? `${existing.declarations} ${r.declarations}` : r.declarations;
818
+ else {
819
+ groupMap.set(key, {
820
+ selector: r.selector,
821
+ atRules: r.atRules,
822
+ startingStyle: r.startingStyle,
823
+ declarations: r.declarations
824
+ });
825
+ order.push(key);
826
+ }
827
+ }
828
+ return order.map((key) => groupMap.get(key));
829
+ }
830
+ function formatRules(rules, className) {
831
+ if (rules.length === 0) return "";
832
+ const grouped = groupRules(rules.map((rule) => ({
833
+ selector: resolveSelector(rule, className),
834
+ declarations: rule.declarations,
835
+ atRules: rule.atRules,
836
+ startingStyle: rule.startingStyle
837
+ })));
838
+ const cssRules = [];
839
+ for (const rule of grouped) {
840
+ const innerContent = rule.startingStyle ? `@starting-style { ${rule.declarations} }` : rule.declarations;
841
+ const baseRule = `${rule.selector} { ${innerContent} }`;
842
+ let fullRule = baseRule;
843
+ if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
844
+ cssRules.push(fullRule);
845
+ }
846
+ return cssRules.join("\n");
847
+ }
848
+ //#endregion
849
+ //#region src/ssr/format-global-rules.ts
850
+ function formatGlobalRules(rules) {
851
+ if (rules.length === 0) return "";
852
+ const cssRules = [];
853
+ for (const rule of rules) {
854
+ const baseRule = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.declarations} }`;
855
+ let fullRule = baseRule;
856
+ if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
857
+ cssRules.push(fullRule);
858
+ }
859
+ return cssRules.join("\n");
860
+ }
861
+ //#endregion
862
+ //#region src/ssr/artifacts.ts
863
+ function createServerStyleArtifact(kind, key, css, order) {
864
+ const content = `${kind}\0${key}\0${css}`;
865
+ return {
866
+ id: `${kind}:${hashString(content)}:${content.length.toString(36)}`,
867
+ kind,
868
+ css,
869
+ order
870
+ };
871
+ }
872
+ //#endregion
873
+ 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 };
874
+
875
+ //# sourceMappingURL=css-definitions-D_it4XZH.js.map