@csszyx/compiler 0.1.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,2873 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ COLOR_PROPERTIES: () => COLOR_PROPERTIES,
34
+ CsszyxCompiler: () => CsszyxCompiler,
35
+ DEFAULT_COMPILER_OPTIONS: () => DEFAULT_COMPILER_OPTIONS,
36
+ ManifestBuilder: () => ManifestBuilder,
37
+ PROPERTY_CATEGORY_MAP: () => PROPERTY_CATEGORY_MAP,
38
+ PropertyCategory: () => PropertyCategory,
39
+ VERSION: () => VERSION,
40
+ buildParentMap: () => buildParentMap,
41
+ createRecoveryToken: () => createRecoveryToken,
42
+ generateRecoveryToken: () => generateRecoveryToken,
43
+ getCSSVariableName: () => getCSSVariableName,
44
+ getPropertyCategory: () => getPropertyCategory,
45
+ hoistCSSVariables: () => hoistCSSVariables,
46
+ injectRecoveryToken: () => injectRecoveryToken,
47
+ isValidRecoveryMode: () => isValidRecoveryMode,
48
+ isValidSzProp: () => isValidSzProp,
49
+ mergeOptions: () => mergeOptions,
50
+ normalizeClassName: () => normalizeClassName,
51
+ parseManifest: () => parseManifest,
52
+ serializeManifest: () => serializeManifest,
53
+ transform: () => transform,
54
+ transformSourceCode: () => transformSourceCode,
55
+ validateManifest: () => validateManifest,
56
+ validateSzRecover: () => validateSzRecover
57
+ });
58
+ module.exports = __toCommonJS(index_exports);
59
+
60
+ // src/compiler.ts
61
+ var import_core = require("@csszyx/core");
62
+
63
+ // src/transform.ts
64
+ var babel = __toESM(require("@babel/core"), 1);
65
+ var t = __toESM(require("@babel/types"), 1);
66
+
67
+ // src/property-types.ts
68
+ var PropertyCategory = /* @__PURE__ */ ((PropertyCategory2) => {
69
+ PropertyCategory2[PropertyCategory2["SPACING"] = 0] = "SPACING";
70
+ PropertyCategory2[PropertyCategory2["COLOR"] = 1] = "COLOR";
71
+ PropertyCategory2[PropertyCategory2["FRACTION"] = 2] = "FRACTION";
72
+ PropertyCategory2[PropertyCategory2["UNITLESS"] = 3] = "UNITLESS";
73
+ PropertyCategory2[PropertyCategory2["ANGLE"] = 4] = "ANGLE";
74
+ PropertyCategory2[PropertyCategory2["DURATION"] = 5] = "DURATION";
75
+ PropertyCategory2[PropertyCategory2["ARBITRARY"] = 6] = "ARBITRARY";
76
+ PropertyCategory2[PropertyCategory2["PASSTHROUGH"] = 7] = "PASSTHROUGH";
77
+ return PropertyCategory2;
78
+ })(PropertyCategory || {});
79
+ var PROPERTY_CATEGORY_MAP = {
80
+ // ---- SPACING ----
81
+ p: 0 /* SPACING */,
82
+ pt: 0 /* SPACING */,
83
+ pr: 0 /* SPACING */,
84
+ pb: 0 /* SPACING */,
85
+ pl: 0 /* SPACING */,
86
+ px: 0 /* SPACING */,
87
+ py: 0 /* SPACING */,
88
+ ps: 0 /* SPACING */,
89
+ pe: 0 /* SPACING */,
90
+ m: 0 /* SPACING */,
91
+ mt: 0 /* SPACING */,
92
+ mr: 0 /* SPACING */,
93
+ mb: 0 /* SPACING */,
94
+ ml: 0 /* SPACING */,
95
+ mx: 0 /* SPACING */,
96
+ my: 0 /* SPACING */,
97
+ ms: 0 /* SPACING */,
98
+ me: 0 /* SPACING */,
99
+ spaceX: 0 /* SPACING */,
100
+ spaceY: 0 /* SPACING */,
101
+ gap: 0 /* SPACING */,
102
+ gapX: 0 /* SPACING */,
103
+ gapY: 0 /* SPACING */,
104
+ inset: 0 /* SPACING */,
105
+ insetX: 0 /* SPACING */,
106
+ insetY: 0 /* SPACING */,
107
+ top: 0 /* SPACING */,
108
+ right: 0 /* SPACING */,
109
+ bottom: 0 /* SPACING */,
110
+ left: 0 /* SPACING */,
111
+ start: 0 /* SPACING */,
112
+ end: 0 /* SPACING */,
113
+ w: 0 /* SPACING */,
114
+ minW: 0 /* SPACING */,
115
+ maxW: 0 /* SPACING */,
116
+ h: 0 /* SPACING */,
117
+ minH: 0 /* SPACING */,
118
+ maxH: 0 /* SPACING */,
119
+ size: 0 /* SPACING */,
120
+ basis: 0 /* SPACING */,
121
+ indent: 0 /* SPACING */,
122
+ scrollM: 0 /* SPACING */,
123
+ scrollMt: 0 /* SPACING */,
124
+ scrollMr: 0 /* SPACING */,
125
+ scrollMb: 0 /* SPACING */,
126
+ scrollMl: 0 /* SPACING */,
127
+ scrollMs: 0 /* SPACING */,
128
+ scrollMe: 0 /* SPACING */,
129
+ scrollMx: 0 /* SPACING */,
130
+ scrollMy: 0 /* SPACING */,
131
+ scrollP: 0 /* SPACING */,
132
+ scrollPt: 0 /* SPACING */,
133
+ scrollPr: 0 /* SPACING */,
134
+ scrollPb: 0 /* SPACING */,
135
+ scrollPl: 0 /* SPACING */,
136
+ scrollPs: 0 /* SPACING */,
137
+ scrollPe: 0 /* SPACING */,
138
+ scrollPx: 0 /* SPACING */,
139
+ scrollPy: 0 /* SPACING */,
140
+ translateX: 0 /* SPACING */,
141
+ translateY: 0 /* SPACING */,
142
+ borderSpacing: 0 /* SPACING */,
143
+ borderSpacingX: 0 /* SPACING */,
144
+ borderSpacingY: 0 /* SPACING */,
145
+ outlineOffset: 0 /* SPACING */,
146
+ ringOffset: 0 /* SPACING */,
147
+ underlineOffset: 0 /* SPACING */,
148
+ // ---- COLOR ----
149
+ bg: 1 /* COLOR */,
150
+ color: 1 /* COLOR */,
151
+ borderColor: 1 /* COLOR */,
152
+ divideColor: 1 /* COLOR */,
153
+ outlineColor: 1 /* COLOR */,
154
+ ringColor: 1 /* COLOR */,
155
+ ringOffsetColor: 1 /* COLOR */,
156
+ shadowColor: 1 /* COLOR */,
157
+ textShadowColor: 1 /* COLOR */,
158
+ decorationColor: 1 /* COLOR */,
159
+ accent: 1 /* COLOR */,
160
+ caret: 1 /* COLOR */,
161
+ fill: 1 /* COLOR */,
162
+ stroke: 1 /* COLOR */,
163
+ from: 1 /* COLOR */,
164
+ via: 1 /* COLOR */,
165
+ to: 1 /* COLOR */,
166
+ dropShadowColor: 1 /* COLOR */,
167
+ // ---- UNITLESS ----
168
+ opacity: 3 /* UNITLESS */,
169
+ z: 3 /* UNITLESS */,
170
+ order: 3 /* UNITLESS */,
171
+ columns: 3 /* UNITLESS */,
172
+ gridCols: 3 /* UNITLESS */,
173
+ gridRows: 3 /* UNITLESS */,
174
+ col: 3 /* UNITLESS */,
175
+ colSpan: 3 /* UNITLESS */,
176
+ colStart: 3 /* UNITLESS */,
177
+ colEnd: 3 /* UNITLESS */,
178
+ row: 3 /* UNITLESS */,
179
+ rowSpan: 3 /* UNITLESS */,
180
+ rowStart: 3 /* UNITLESS */,
181
+ rowEnd: 3 /* UNITLESS */,
182
+ lineClamp: 3 /* UNITLESS */,
183
+ grow: 3 /* UNITLESS */,
184
+ shrink: 3 /* UNITLESS */,
185
+ scale: 3 /* UNITLESS */,
186
+ scaleX: 3 /* UNITLESS */,
187
+ scaleY: 3 /* UNITLESS */,
188
+ brightness: 3 /* UNITLESS */,
189
+ contrast: 3 /* UNITLESS */,
190
+ saturate: 3 /* UNITLESS */,
191
+ hueRotate: 3 /* UNITLESS */,
192
+ backdropBrightness: 3 /* UNITLESS */,
193
+ backdropContrast: 3 /* UNITLESS */,
194
+ backdropSaturate: 3 /* UNITLESS */,
195
+ backdropHueRotate: 3 /* UNITLESS */,
196
+ backdropOpacity: 3 /* UNITLESS */,
197
+ strokeWidth: 3 /* UNITLESS */,
198
+ border: 3 /* UNITLESS */,
199
+ borderT: 3 /* UNITLESS */,
200
+ borderR: 3 /* UNITLESS */,
201
+ borderB: 3 /* UNITLESS */,
202
+ borderL: 3 /* UNITLESS */,
203
+ borderX: 3 /* UNITLESS */,
204
+ borderY: 3 /* UNITLESS */,
205
+ borderS: 3 /* UNITLESS */,
206
+ borderE: 3 /* UNITLESS */,
207
+ ring: 3 /* UNITLESS */,
208
+ outline: 3 /* UNITLESS */,
209
+ leading: 3 /* UNITLESS */,
210
+ decorationThickness: 3 /* UNITLESS */,
211
+ // ---- ANGLE ----
212
+ rotate: 4 /* ANGLE */,
213
+ skewX: 4 /* ANGLE */,
214
+ skewY: 4 /* ANGLE */,
215
+ // ---- DURATION ----
216
+ duration: 5 /* DURATION */,
217
+ delay: 5 /* DURATION */
218
+ };
219
+ function getPropertyCategory(property) {
220
+ return PROPERTY_CATEGORY_MAP[property] ?? 7 /* PASSTHROUGH */;
221
+ }
222
+ var COLOR_PROPERTIES = new Set(
223
+ Object.entries(PROPERTY_CATEGORY_MAP).filter(([, cat]) => cat === 1 /* COLOR */).map(([key]) => key)
224
+ );
225
+ function getCSSVariableName(property, variantPrefix) {
226
+ const prop = property.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
227
+ if (variantPrefix) {
228
+ return `--_sz-${variantPrefix}-${prop}`;
229
+ }
230
+ return `--_sz-${prop}`;
231
+ }
232
+
233
+ // src/transform-core.ts
234
+ var PROPERTY_MAP = {
235
+ // Background
236
+ bg: "bg",
237
+ bgAttach: "bg",
238
+ bgClip: "bg-clip",
239
+ bgImg: "bg",
240
+ bgOrigin: "bg-origin",
241
+ bgPos: "bg",
242
+ bgRepeat: "bg",
243
+ bgSize: "bg",
244
+ // Gradient color stops
245
+ from: "from",
246
+ via: "via",
247
+ to: "to",
248
+ // Border Radius
249
+ rounded: "rounded",
250
+ roundedT: "rounded-t",
251
+ roundedR: "rounded-r",
252
+ roundedB: "rounded-b",
253
+ roundedL: "rounded-l",
254
+ roundedTl: "rounded-tl",
255
+ roundedTr: "rounded-tr",
256
+ roundedBl: "rounded-bl",
257
+ roundedBr: "rounded-br",
258
+ roundedS: "rounded-s",
259
+ roundedE: "rounded-e",
260
+ roundedSs: "rounded-ss",
261
+ roundedSe: "rounded-se",
262
+ roundedEs: "rounded-es",
263
+ roundedEe: "rounded-ee",
264
+ // Border
265
+ border: "border",
266
+ borderColor: "border",
267
+ borderStyle: "border",
268
+ borderT: "border-t",
269
+ borderR: "border-r",
270
+ borderB: "border-b",
271
+ borderL: "border-l",
272
+ borderX: "border-x",
273
+ borderY: "border-y",
274
+ borderS: "border-s",
275
+ borderE: "border-e",
276
+ // Divide
277
+ divideX: "divide-x",
278
+ divideY: "divide-y",
279
+ divideColor: "divide",
280
+ divideStyle: "divide",
281
+ // Outline
282
+ outline: "outline",
283
+ outlineColor: "outline",
284
+ outlineOffset: "outline-offset",
285
+ outlineStyle: "outline",
286
+ // Ring (v3 — keep for future v3 support)
287
+ ring: "ring",
288
+ ringColor: "ring",
289
+ ringOffset: "ring-offset",
290
+ ringOffsetColor: "ring-offset",
291
+ // Spacing (canonical shorthand only)
292
+ p: "p",
293
+ pt: "pt",
294
+ pr: "pr",
295
+ pb: "pb",
296
+ pl: "pl",
297
+ px: "px",
298
+ py: "py",
299
+ ps: "ps",
300
+ pe: "pe",
301
+ m: "m",
302
+ mt: "mt",
303
+ mr: "mr",
304
+ mb: "mb",
305
+ ml: "ml",
306
+ mx: "mx",
307
+ my: "my",
308
+ ms: "ms",
309
+ me: "me",
310
+ // Space between
311
+ spaceX: "space-x",
312
+ spaceY: "space-y",
313
+ // Sizing (canonical shorthand only)
314
+ w: "w",
315
+ minW: "min-w",
316
+ maxW: "max-w",
317
+ h: "h",
318
+ minH: "min-h",
319
+ maxH: "max-h",
320
+ size: "size",
321
+ // Layout
322
+ aspect: "aspect",
323
+ columns: "columns",
324
+ breakAfter: "break-after",
325
+ breakBefore: "break-before",
326
+ breakInside: "break-inside",
327
+ boxDecoration: "box-decoration",
328
+ box: "box",
329
+ float: "float",
330
+ clear: "clear",
331
+ isolation: "isolation",
332
+ objectFit: "object",
333
+ objectPos: "object",
334
+ overflowX: "overflow-x",
335
+ overflowY: "overflow-y",
336
+ overscroll: "overscroll",
337
+ overscrollX: "overscroll-x",
338
+ overscrollY: "overscroll-y",
339
+ z: "z",
340
+ position: "position",
341
+ display: "display",
342
+ // Inset
343
+ inset: "inset",
344
+ insetX: "inset-x",
345
+ insetY: "inset-y",
346
+ top: "top",
347
+ right: "right",
348
+ bottom: "bottom",
349
+ left: "left",
350
+ start: "start",
351
+ end: "end",
352
+ // Visibility
353
+ visibility: "visibility",
354
+ // Typography
355
+ color: "text",
356
+ text: "text",
357
+ fontWeight: "font",
358
+ font: "font",
359
+ fontFamily: "font",
360
+ fontStretch: "font-stretch",
361
+ textAlign: "text",
362
+ decoration: "decoration",
363
+ decorationColor: "decoration",
364
+ decorationStyle: "decoration",
365
+ decorationThickness: "decoration",
366
+ underlineOffset: "underline-offset",
367
+ textTransform: "text",
368
+ textOverflow: "text",
369
+ textWrap: "text",
370
+ wrap: "wrap",
371
+ indent: "indent",
372
+ align: "align",
373
+ whitespace: "whitespace",
374
+ break: "break",
375
+ hyphens: "hyphens",
376
+ content: "content",
377
+ leading: "leading",
378
+ tracking: "tracking",
379
+ lineClamp: "line-clamp",
380
+ list: "list",
381
+ listPos: "list",
382
+ listImg: "list-image",
383
+ // Flex & Grid
384
+ basis: "basis",
385
+ flexDir: "flex",
386
+ flexWrap: "flex",
387
+ grow: "grow",
388
+ shrink: "shrink",
389
+ order: "order",
390
+ items: "items",
391
+ self: "self",
392
+ justify: "justify",
393
+ justifyItems: "justify-items",
394
+ justifySelf: "justify-self",
395
+ placeContent: "place-content",
396
+ placeItems: "place-items",
397
+ placeSelf: "place-self",
398
+ gap: "gap",
399
+ gapX: "gap-x",
400
+ gapY: "gap-y",
401
+ // Grid
402
+ gridCols: "grid-cols",
403
+ gridRows: "grid-rows",
404
+ col: "col",
405
+ colSpan: "col-span",
406
+ colStart: "col-start",
407
+ colEnd: "col-end",
408
+ row: "row",
409
+ rowSpan: "row-span",
410
+ rowStart: "row-start",
411
+ rowEnd: "row-end",
412
+ gridFlow: "grid-flow",
413
+ autoCols: "auto-cols",
414
+ autoRows: "auto-rows",
415
+ // Effects
416
+ shadow: "shadow",
417
+ shadowColor: "shadow",
418
+ insetShadow: "inset-shadow",
419
+ textShadow: "text-shadow",
420
+ textShadowColor: "text-shadow",
421
+ opacity: "opacity",
422
+ mixBlend: "mix-blend",
423
+ bgBlend: "bg-blend",
424
+ // Filters
425
+ blur: "blur",
426
+ brightness: "brightness",
427
+ contrast: "contrast",
428
+ dropShadow: "drop-shadow",
429
+ dropShadowColor: "drop-shadow",
430
+ grayscale: "grayscale",
431
+ hueRotate: "hue-rotate",
432
+ invert: "invert",
433
+ saturate: "saturate",
434
+ sepia: "sepia",
435
+ backdropBlur: "backdrop-blur",
436
+ backdropBrightness: "backdrop-brightness",
437
+ backdropContrast: "backdrop-contrast",
438
+ backdropGrayscale: "backdrop-grayscale",
439
+ backdropHueRotate: "backdrop-hue-rotate",
440
+ backdropInvert: "backdrop-invert",
441
+ backdropOpacity: "backdrop-opacity",
442
+ backdropSaturate: "backdrop-saturate",
443
+ backdropSepia: "backdrop-sepia",
444
+ // Transforms
445
+ scale: "scale",
446
+ scaleX: "scale-x",
447
+ scaleY: "scale-y",
448
+ rotate: "rotate",
449
+ translateX: "translate-x",
450
+ translateY: "translate-y",
451
+ skewX: "skew-x",
452
+ skewY: "skew-y",
453
+ origin: "origin",
454
+ backface: "backface",
455
+ perspective: "perspective",
456
+ perspectiveOrigin: "perspective-origin",
457
+ transformStyle: "transform",
458
+ // Transitions & Animation
459
+ transition: "transition",
460
+ transitionBehavior: "transition",
461
+ duration: "duration",
462
+ ease: "ease",
463
+ delay: "delay",
464
+ animate: "animate",
465
+ // Masks
466
+ mask: "mask",
467
+ maskSize: "mask-size",
468
+ maskPos: "mask-position",
469
+ maskRepeat: "mask-repeat",
470
+ maskShape: "mask",
471
+ // Interactivity
472
+ cursor: "cursor",
473
+ caret: "caret",
474
+ pointerEvents: "pointer-events",
475
+ resize: "resize",
476
+ scroll: "scroll",
477
+ scrollM: "scroll-m",
478
+ scrollMt: "scroll-mt",
479
+ scrollMr: "scroll-mr",
480
+ scrollMb: "scroll-mb",
481
+ scrollMl: "scroll-ml",
482
+ scrollMs: "scroll-ms",
483
+ scrollMe: "scroll-me",
484
+ scrollMx: "scroll-mx",
485
+ scrollMy: "scroll-my",
486
+ scrollP: "scroll-p",
487
+ scrollPt: "scroll-pt",
488
+ scrollPr: "scroll-pr",
489
+ scrollPb: "scroll-pb",
490
+ scrollPl: "scroll-pl",
491
+ scrollPs: "scroll-ps",
492
+ scrollPe: "scroll-pe",
493
+ scrollPx: "scroll-px",
494
+ scrollPy: "scroll-py",
495
+ snapAlign: "snap",
496
+ snapStop: "snap",
497
+ snapType: "snap",
498
+ touch: "touch",
499
+ select: "select",
500
+ willChange: "will-change",
501
+ appearance: "appearance",
502
+ accent: "accent",
503
+ forcedColorAdjust: "forced-color-adjust",
504
+ // SVG
505
+ fill: "fill",
506
+ stroke: "stroke",
507
+ strokeWidth: "stroke",
508
+ // Tables
509
+ borderCollapse: "border",
510
+ borderSpacing: "border-spacing",
511
+ borderSpacingX: "border-spacing-x",
512
+ borderSpacingY: "border-spacing-y",
513
+ tableLayout: "table",
514
+ caption: "caption",
515
+ // Overflow
516
+ overflow: "overflow"
517
+ };
518
+ var SUGGESTION_MAP = {
519
+ // Background
520
+ backgroundColor: "bg",
521
+ backgroundImage: "bgImg",
522
+ backgroundSize: "bgSize",
523
+ backgroundPosition: "bgPos",
524
+ backgroundRepeat: "bgRepeat",
525
+ bgAttachment: "bgAttach",
526
+ bgImage: "bgImg",
527
+ // Border Radius
528
+ borderRadius: "rounded",
529
+ borderTopLeftRadius: "roundedTl",
530
+ borderTopRightRadius: "roundedTr",
531
+ borderBottomLeftRadius: "roundedBl",
532
+ borderBottomRightRadius: "roundedBr",
533
+ // Border
534
+ borderWidth: "border",
535
+ // Spacing
536
+ padding: "p",
537
+ paddingTop: "pt",
538
+ paddingRight: "pr",
539
+ paddingBottom: "pb",
540
+ paddingLeft: "pl",
541
+ paddingX: "px",
542
+ paddingY: "py",
543
+ margin: "m",
544
+ marginTop: "mt",
545
+ marginRight: "mr",
546
+ marginBottom: "mb",
547
+ marginLeft: "ml",
548
+ marginX: "mx",
549
+ marginY: "my",
550
+ // Sizing
551
+ width: "w",
552
+ height: "h",
553
+ minWidth: "minW",
554
+ maxWidth: "maxW",
555
+ minHeight: "minH",
556
+ maxHeight: "maxH",
557
+ // Layout
558
+ aspectRatio: "aspect",
559
+ boxSizing: "box",
560
+ boxDecorationBreak: "boxDecoration",
561
+ objectPosition: "objectPos",
562
+ zIndex: "z",
563
+ // Typography
564
+ fontStyle: "italic/notItalic (boolean)",
565
+ weight: "fontWeight",
566
+ textDecoration: "decoration or underline/lineThrough/noUnderline (boolean)",
567
+ textDecorationColor: "decorationColor",
568
+ textDecorationStyle: "decorationStyle",
569
+ textDecorationThickness: "decorationThickness",
570
+ textUnderlineOffset: "underlineOffset",
571
+ lineHeight: "leading",
572
+ letterSpacing: "tracking",
573
+ textIndent: "indent",
574
+ verticalAlign: "align",
575
+ wordBreak: "break",
576
+ overflowWrap: "wrap",
577
+ textWrap: "textWrap",
578
+ listStyleType: "list",
579
+ listStylePosition: "listPos",
580
+ listStyleImage: "listImg",
581
+ listStyle: "list",
582
+ listPosition: "listPos",
583
+ listImage: "listImg",
584
+ // Flex & Grid
585
+ flexBasis: "basis",
586
+ flexDirection: "flexDir",
587
+ flexGrow: "grow",
588
+ flexShrink: "shrink",
589
+ alignItems: "items",
590
+ alignContent: "content",
591
+ alignSelf: "self",
592
+ justifyContent: "justify",
593
+ gridTemplateColumns: "gridCols",
594
+ gridTemplateRows: "gridRows",
595
+ gridColumn: "col",
596
+ gridRow: "row",
597
+ gridAutoFlow: "gridFlow",
598
+ gridAutoColumns: "autoCols",
599
+ gridAutoRows: "autoRows",
600
+ // Effects
601
+ boxShadow: "shadow",
602
+ mixBlendMode: "mixBlend",
603
+ backgroundBlendMode: "bgBlend",
604
+ // Transitions
605
+ transitionProperty: "transition",
606
+ transitionDuration: "duration",
607
+ transitionTimingFunction: "ease",
608
+ transitionDelay: "delay",
609
+ animation: "animate",
610
+ transformOrigin: "origin",
611
+ // Interactivity
612
+ caretColor: "caret",
613
+ accentColor: "accent",
614
+ scrollBehavior: "scroll",
615
+ scrollMargin: "scrollM",
616
+ scrollPadding: "scrollP",
617
+ scrollSnapAlign: "snapAlign",
618
+ scrollSnapStop: "snapStop",
619
+ scrollSnapType: "snapType",
620
+ touchAction: "touch",
621
+ userSelect: "select",
622
+ captionSide: "caption",
623
+ // Boolean remaps
624
+ flexWrapReverse: "flexWrap: 'wrap-reverse'",
625
+ flexNowrap: "flexWrap: 'nowrap'"
626
+ };
627
+ var VARIANT_MAP = {
628
+ // Focus variants
629
+ focusWithin: "focus-within",
630
+ focusVisible: "focus-visible",
631
+ // Structural variants
632
+ firstOfType: "first-of-type",
633
+ lastOfType: "last-of-type",
634
+ onlyOfType: "only-of-type",
635
+ onlyChild: "only",
636
+ firstChild: "first",
637
+ lastChild: "last",
638
+ // Motion variants
639
+ motionReduce: "motion-reduce",
640
+ motionSafe: "motion-safe",
641
+ // Contrast variants
642
+ contrastMore: "contrast-more",
643
+ contrastLess: "contrast-less",
644
+ // Pseudo-element variants
645
+ firstLine: "first-line",
646
+ firstLetter: "first-letter",
647
+ // Form variants
648
+ placeholderShown: "placeholder-shown",
649
+ inRange: "in-range",
650
+ outOfRange: "out-of-range",
651
+ readOnly: "read-only",
652
+ // Pointer variants
653
+ pointerFine: "pointer-fine",
654
+ pointerCoarse: "pointer-coarse",
655
+ pointerNone: "pointer-none",
656
+ // Screen orientation
657
+ screenPortrait: "portrait",
658
+ screenLandscape: "landscape",
659
+ // Container query max variants
660
+ "@maxSm": "@max-sm",
661
+ "@maxMd": "@max-md",
662
+ "@maxLg": "@max-lg",
663
+ "@maxXl": "@max-xl",
664
+ "@max2xl": "@max-2xl"
665
+ };
666
+ var KNOWN_VARIANTS = /* @__PURE__ */ new Set([
667
+ // Responsive
668
+ "sm",
669
+ "md",
670
+ "lg",
671
+ "xl",
672
+ "2xl",
673
+ // Container queries
674
+ "@sm",
675
+ "@md",
676
+ "@lg",
677
+ "@xl",
678
+ "@2xl",
679
+ // Dark mode
680
+ "dark",
681
+ "light",
682
+ // Print/Media
683
+ "print",
684
+ "portrait",
685
+ "landscape",
686
+ // Motion
687
+ "motion-reduce",
688
+ "motion-safe",
689
+ "motionReduce",
690
+ "motionSafe",
691
+ // Contrast
692
+ "contrast-more",
693
+ "contrast-less",
694
+ "contrastMore",
695
+ "contrastLess",
696
+ // States
697
+ "hover",
698
+ "focus",
699
+ "focus-within",
700
+ "focus-visible",
701
+ "focusWithin",
702
+ "focusVisible",
703
+ "active",
704
+ "visited",
705
+ "target",
706
+ "disabled",
707
+ "enabled",
708
+ "checked",
709
+ "indeterminate",
710
+ "default",
711
+ "required",
712
+ "valid",
713
+ "invalid",
714
+ "in-range",
715
+ "out-of-range",
716
+ "inRange",
717
+ "outOfRange",
718
+ "placeholder-shown",
719
+ "placeholderShown",
720
+ "autofill",
721
+ "read-only",
722
+ "readOnly",
723
+ // Structure
724
+ "first",
725
+ "last",
726
+ "only",
727
+ "odd",
728
+ "even",
729
+ "empty",
730
+ "first-of-type",
731
+ "last-of-type",
732
+ "only-of-type",
733
+ "firstOfType",
734
+ "lastOfType",
735
+ "onlyOfType",
736
+ "first-child",
737
+ "last-child",
738
+ "only-child",
739
+ "firstChild",
740
+ "lastChild",
741
+ "onlyChild",
742
+ // Pseudo-elements
743
+ "before",
744
+ "after",
745
+ "placeholder",
746
+ "file",
747
+ "marker",
748
+ "selection",
749
+ "first-line",
750
+ "first-letter",
751
+ "firstLine",
752
+ "firstLetter",
753
+ "backdrop",
754
+ // Pointer
755
+ "pointer-fine",
756
+ "pointer-coarse",
757
+ "pointer-none",
758
+ "pointerFine",
759
+ "pointerCoarse",
760
+ "pointerNone",
761
+ // Open
762
+ "open",
763
+ // RTL/LTR
764
+ "ltr",
765
+ "rtl"
766
+ ]);
767
+ var ARIA_STATES = /* @__PURE__ */ new Set([
768
+ "checked",
769
+ "disabled",
770
+ "expanded",
771
+ "hidden",
772
+ "pressed",
773
+ "readonly",
774
+ "required",
775
+ "selected",
776
+ "busy",
777
+ "current",
778
+ "invalid",
779
+ "live",
780
+ "atomic",
781
+ "modal"
782
+ ]);
783
+ var BOOLEAN_SHORTHANDS = /* @__PURE__ */ new Set([
784
+ // Display
785
+ "block",
786
+ "inline",
787
+ "inlineBlock",
788
+ "flex",
789
+ "inlineFlex",
790
+ "grid",
791
+ "inlineGrid",
792
+ "hidden",
793
+ "contents",
794
+ "table",
795
+ "tableRow",
796
+ "tableCell",
797
+ "flowRoot",
798
+ "listItem",
799
+ // Position
800
+ "static",
801
+ "fixed",
802
+ "absolute",
803
+ "relative",
804
+ "sticky",
805
+ // Visibility
806
+ "visible",
807
+ "invisible",
808
+ "collapse",
809
+ // Typography
810
+ "truncate",
811
+ "uppercase",
812
+ "lowercase",
813
+ "capitalize",
814
+ "normalCase",
815
+ "underline",
816
+ "overline",
817
+ "lineThrough",
818
+ "noUnderline",
819
+ "italic",
820
+ "notItalic",
821
+ "antialiased",
822
+ "subpixelAntialiased",
823
+ // Flexbox (grow/shrink only — flexWrap uses string values)
824
+ "grow",
825
+ "shrink",
826
+ // Filters (default values)
827
+ "blur",
828
+ "grayscale",
829
+ "invert",
830
+ "sepia",
831
+ "backdropBlur",
832
+ "backdropGrayscale",
833
+ "backdropInvert",
834
+ "backdropSepia",
835
+ // Misc
836
+ "container",
837
+ "prose",
838
+ "srOnly",
839
+ "notSrOnly",
840
+ "isolate",
841
+ "ordinal",
842
+ "slashedZero",
843
+ // Font variant numeric
844
+ "liningNums",
845
+ "oldstyleNums",
846
+ "proportionalNums",
847
+ "tabularNums",
848
+ "diagonalFractions",
849
+ "stackedFractions",
850
+ // Divide/Space reverse
851
+ "divideXReverse",
852
+ "divideYReverse",
853
+ "spaceXReverse",
854
+ "spaceYReverse",
855
+ // Ring (v3 future)
856
+ "ring",
857
+ // Outline
858
+ "outline",
859
+ // Transforms
860
+ "scale3d",
861
+ "rotate3d",
862
+ "translate3d",
863
+ "transformGpu",
864
+ "transformCpu",
865
+ "transformNone"
866
+ ]);
867
+ var BOOLEAN_TO_CLASS = {
868
+ inlineBlock: "inline-block",
869
+ inlineFlex: "inline-flex",
870
+ inlineGrid: "inline-grid",
871
+ tableRow: "table-row",
872
+ tableCell: "table-cell",
873
+ flowRoot: "flow-root",
874
+ listItem: "list-item",
875
+ normalCase: "normal-case",
876
+ lineThrough: "line-through",
877
+ noUnderline: "no-underline",
878
+ notItalic: "not-italic",
879
+ subpixelAntialiased: "subpixel-antialiased",
880
+ backdropBlur: "backdrop-blur",
881
+ backdropGrayscale: "backdrop-grayscale",
882
+ backdropInvert: "backdrop-invert",
883
+ backdropSepia: "backdrop-sepia",
884
+ srOnly: "sr-only",
885
+ notSrOnly: "not-sr-only",
886
+ divideXReverse: "divide-x-reverse",
887
+ divideYReverse: "divide-y-reverse",
888
+ spaceXReverse: "space-x-reverse",
889
+ spaceYReverse: "space-y-reverse",
890
+ // Font variant numeric
891
+ liningNums: "lining-nums",
892
+ oldstyleNums: "oldstyle-nums",
893
+ proportionalNums: "proportional-nums",
894
+ tabularNums: "tabular-nums",
895
+ diagonalFractions: "diagonal-fractions",
896
+ stackedFractions: "stacked-fractions",
897
+ // Transforms
898
+ scale3d: "scale-3d",
899
+ rotate3d: "rotate-3d",
900
+ translate3d: "translate-3d",
901
+ transformGpu: "transform-gpu",
902
+ transformCpu: "transform-cpu",
903
+ transformNone: "transform-none"
904
+ };
905
+ var SNAP_DIRECT_MAP = {
906
+ snapAlign: {
907
+ start: "snap-start",
908
+ end: "snap-end",
909
+ center: "snap-center",
910
+ none: "snap-align-none"
911
+ },
912
+ snapStop: {
913
+ normal: "snap-normal",
914
+ always: "snap-always"
915
+ },
916
+ snapType: {
917
+ none: "snap-none",
918
+ x: "snap-x",
919
+ y: "snap-y",
920
+ both: "snap-both"
921
+ },
922
+ snapStrictness: {
923
+ mandatory: "snap-mandatory",
924
+ proximity: "snap-proximity"
925
+ }
926
+ };
927
+ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
928
+ "m",
929
+ "mt",
930
+ "mr",
931
+ "mb",
932
+ "ml",
933
+ "mx",
934
+ "my",
935
+ "ms",
936
+ "me",
937
+ "top",
938
+ "right",
939
+ "bottom",
940
+ "left",
941
+ "inset",
942
+ "inset-x",
943
+ "inset-y",
944
+ "start",
945
+ "end",
946
+ "z",
947
+ "order",
948
+ "col",
949
+ "col-start",
950
+ "col-end",
951
+ "row",
952
+ "row-start",
953
+ "row-end",
954
+ "rotate",
955
+ "skew-x",
956
+ "skew-y",
957
+ "translate-x",
958
+ "translate-y",
959
+ "space-x",
960
+ "space-y",
961
+ "tracking",
962
+ "indent",
963
+ "scroll-m",
964
+ "scroll-mx",
965
+ "scroll-my",
966
+ "scroll-mt",
967
+ "scroll-mr",
968
+ "scroll-mb",
969
+ "scroll-ml",
970
+ "hue-rotate",
971
+ "backdrop-hue-rotate"
972
+ ]);
973
+ function handleImportant(value) {
974
+ if (typeof value === "string" && value.endsWith("!")) {
975
+ return { value: value.slice(0, -1), important: true };
976
+ }
977
+ return { value, important: false };
978
+ }
979
+ function formatOpacity(op) {
980
+ if (typeof op === "number") {
981
+ return String(op);
982
+ }
983
+ if (typeof op === "string") {
984
+ if (op.startsWith("--")) {
985
+ return `(${op})`;
986
+ }
987
+ return `[${op}]`;
988
+ }
989
+ return String(op);
990
+ }
991
+ function isArbitraryVariant(key) {
992
+ return key.startsWith("[") && key.endsWith("]");
993
+ }
994
+ function normalizeArbitraryVariant(key) {
995
+ return key.replace(/\s+/g, "");
996
+ }
997
+ function normalizeArbitraryValue(value) {
998
+ return value.trim().replace(/\s*([+*/(),:])\s*/g, "$1").replace(/\s+/g, "_");
999
+ }
1000
+ var FRACTION_SUPPORTED_PROPS = /* @__PURE__ */ new Set([
1001
+ // Sizing (both rawKey and resolved key forms)
1002
+ "w",
1003
+ "width",
1004
+ "min-w",
1005
+ "minW",
1006
+ "minWidth",
1007
+ "max-w",
1008
+ "maxW",
1009
+ "maxWidth",
1010
+ "h",
1011
+ "height",
1012
+ "min-h",
1013
+ "minH",
1014
+ "minHeight",
1015
+ "max-h",
1016
+ "maxH",
1017
+ "maxHeight",
1018
+ "size",
1019
+ // Flex
1020
+ "basis",
1021
+ "flexBasis",
1022
+ "flex",
1023
+ // Inset
1024
+ "inset",
1025
+ "inset-x",
1026
+ "insetX",
1027
+ "inset-y",
1028
+ "insetY",
1029
+ "top",
1030
+ "right",
1031
+ "bottom",
1032
+ "left",
1033
+ "start",
1034
+ "end",
1035
+ // Translate
1036
+ "translate-x",
1037
+ "translateX",
1038
+ "translate-y",
1039
+ "translateY"
1040
+ ]);
1041
+ function needsArbitraryBrackets(value) {
1042
+ return /^\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || // Units
1043
+ /^\.\d+(px|rem|em|%|vh|vw|ch)?$/.test(value) || // Values starting with . like .25em
1044
+ value.startsWith("#") || // Hex colors
1045
+ value.startsWith("rgb") || // RGB colors
1046
+ value.startsWith("hsl") || // HSL colors
1047
+ value.includes("calc(") || // Calculations
1048
+ value.includes("var(") || // CSS variables (old syntax)
1049
+ value.includes("attr(") || // attr() function
1050
+ value.includes("url(") || // URLs
1051
+ value.includes("clamp(") || // Clamp
1052
+ value.includes("min(") || // Min
1053
+ value.includes("max(") || // Max
1054
+ value.includes(" ");
1055
+ }
1056
+ var LIST_STYLE_STANDARD = /* @__PURE__ */ new Set(["none", "disc", "decimal"]);
1057
+ var FONT_STRETCH_KEYWORDS = /* @__PURE__ */ new Set([
1058
+ "ultra-condensed",
1059
+ "extra-condensed",
1060
+ "condensed",
1061
+ "semi-condensed",
1062
+ "normal",
1063
+ "semi-expanded",
1064
+ "expanded",
1065
+ "extra-expanded",
1066
+ "ultra-expanded"
1067
+ ]);
1068
+ var NEEDS_ARBITRARY_PROPERTY = /* @__PURE__ */ new Set([
1069
+ "mask-type",
1070
+ "mask-composite",
1071
+ "mask-mode"
1072
+ ]);
1073
+ function getVariantPrefix(key) {
1074
+ if (VARIANT_MAP[key]) {
1075
+ return VARIANT_MAP[key];
1076
+ }
1077
+ return key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1078
+ }
1079
+ function handleGroupPeer(type, nestedObj, prefix) {
1080
+ const classes = [];
1081
+ for (const [nestedKey, nestedValue] of Object.entries(nestedObj)) {
1082
+ if (nestedValue === null || nestedValue === void 0 || nestedValue === false) {
1083
+ continue;
1084
+ }
1085
+ if (nestedKey === "has" && typeof nestedValue === "object") {
1086
+ for (const [selector, selectorValue] of Object.entries(nestedValue)) {
1087
+ if (selectorValue === null || selectorValue === void 0 || selectorValue === false) {
1088
+ continue;
1089
+ }
1090
+ const variantPrefix = `${prefix}${type}-has-[${selector}]:`;
1091
+ const result = transform(selectorValue, variantPrefix);
1092
+ if (result.className) {
1093
+ classes.push(result.className);
1094
+ }
1095
+ }
1096
+ continue;
1097
+ }
1098
+ const isVariant = KNOWN_VARIANTS.has(nestedKey) || KNOWN_VARIANTS.has(getVariantPrefix(nestedKey));
1099
+ const isArbitrary = nestedKey.startsWith(".") || nestedKey.startsWith("#") || nestedKey.startsWith("[") || nestedKey.startsWith(":");
1100
+ if (isArbitrary) {
1101
+ const variantPrefix = `${prefix}${type}-[${nestedKey}]:`;
1102
+ const result = transform(nestedValue, variantPrefix);
1103
+ if (result.className) {
1104
+ classes.push(result.className);
1105
+ }
1106
+ } else if (isVariant) {
1107
+ const mappedVariant = getVariantPrefix(nestedKey);
1108
+ const variantPrefix = `${prefix}${type}-${mappedVariant}:`;
1109
+ const result = transform(nestedValue, variantPrefix);
1110
+ if (result.className) {
1111
+ classes.push(result.className);
1112
+ }
1113
+ } else if (typeof nestedValue === "object" && nestedValue !== null) {
1114
+ for (const [state, stateValue] of Object.entries(nestedValue)) {
1115
+ if (stateValue === null || stateValue === void 0 || stateValue === false) {
1116
+ continue;
1117
+ }
1118
+ const mappedState = getVariantPrefix(state);
1119
+ const variantPrefix = `${prefix}${type}-${mappedState}/${nestedKey}:`;
1120
+ const result = transform(stateValue, variantPrefix);
1121
+ if (result.className) {
1122
+ classes.push(result.className);
1123
+ }
1124
+ }
1125
+ }
1126
+ }
1127
+ return classes;
1128
+ }
1129
+ function handleHas(hasObj, prefix) {
1130
+ const classes = [];
1131
+ for (const [selector, value] of Object.entries(hasObj)) {
1132
+ if (value === null || value === void 0 || value === false) {
1133
+ continue;
1134
+ }
1135
+ let selectorStr;
1136
+ if (KNOWN_VARIANTS.has(selector) || selector.startsWith(":")) {
1137
+ selectorStr = selector.startsWith(":") ? selector : `:${selector}`;
1138
+ } else {
1139
+ selectorStr = selector;
1140
+ }
1141
+ const variantPrefix = `${prefix}has-[${selectorStr}]:`;
1142
+ const result = transform(value, variantPrefix);
1143
+ if (result.className) {
1144
+ classes.push(result.className);
1145
+ }
1146
+ }
1147
+ return classes;
1148
+ }
1149
+ function handleNot(notObj, prefix) {
1150
+ const classes = [];
1151
+ for (const [key, value] of Object.entries(notObj)) {
1152
+ if (value === null || value === void 0 || value === false) {
1153
+ continue;
1154
+ }
1155
+ if (key === "supports" && typeof value === "object") {
1156
+ for (const [condition, condValue] of Object.entries(value)) {
1157
+ const variantPrefix = `${prefix}not-supports-[${condition}]:`;
1158
+ const result = transform(condValue, variantPrefix);
1159
+ if (result.className) {
1160
+ classes.push(result.className);
1161
+ }
1162
+ }
1163
+ } else {
1164
+ const mappedVariant = getVariantPrefix(key);
1165
+ const variantPrefix = `${prefix}not-${mappedVariant}:`;
1166
+ const result = transform(value, variantPrefix);
1167
+ if (result.className) {
1168
+ classes.push(result.className);
1169
+ }
1170
+ }
1171
+ }
1172
+ return classes;
1173
+ }
1174
+ function handleData(dataObj, prefix) {
1175
+ const classes = [];
1176
+ for (const [key, value] of Object.entries(dataObj)) {
1177
+ if (value === null || value === void 0 || value === false) {
1178
+ continue;
1179
+ }
1180
+ const variantPrefix = `${prefix}data-[${key}]:`;
1181
+ const result = transform(value, variantPrefix);
1182
+ if (result.className) {
1183
+ classes.push(result.className);
1184
+ }
1185
+ }
1186
+ return classes;
1187
+ }
1188
+ function handleAria(ariaObj, prefix) {
1189
+ const classes = [];
1190
+ for (const [key, value] of Object.entries(ariaObj)) {
1191
+ if (value === null || value === void 0 || value === false) {
1192
+ continue;
1193
+ }
1194
+ let variantPrefix;
1195
+ if (ARIA_STATES.has(key)) {
1196
+ variantPrefix = `${prefix}aria-${key}:`;
1197
+ } else {
1198
+ variantPrefix = `${prefix}aria-[${key}]:`;
1199
+ }
1200
+ const result = transform(value, variantPrefix);
1201
+ if (result.className) {
1202
+ classes.push(result.className);
1203
+ }
1204
+ }
1205
+ return classes;
1206
+ }
1207
+ function handleSupports(supportsObj, prefix) {
1208
+ const classes = [];
1209
+ for (const [condition, value] of Object.entries(supportsObj)) {
1210
+ if (value === null || value === void 0 || value === false) {
1211
+ continue;
1212
+ }
1213
+ const variantPrefix = `${prefix}supports-[${condition}]:`;
1214
+ const result = transform(value, variantPrefix);
1215
+ if (result.className) {
1216
+ classes.push(result.className);
1217
+ }
1218
+ }
1219
+ return classes;
1220
+ }
1221
+ function transform(szProp, prefix = "", mangleMap) {
1222
+ if (!szProp || typeof szProp !== "object") {
1223
+ return { className: "", attributes: {} };
1224
+ }
1225
+ const classes = [];
1226
+ const attributes = {};
1227
+ for (const [rawKey, value] of Object.entries(szProp)) {
1228
+ if (value === false) {
1229
+ if (rawKey === "italic") {
1230
+ classes.push(`${prefix}not-italic`);
1231
+ } else if (rawKey === "antialiased") {
1232
+ classes.push(`${prefix}subpixel-antialiased`);
1233
+ }
1234
+ continue;
1235
+ }
1236
+ if (value === null || value === void 0) {
1237
+ continue;
1238
+ }
1239
+ if (rawKey.startsWith("@") && typeof value === "string") {
1240
+ const mappedKey = VARIANT_MAP[rawKey] || rawKey;
1241
+ classes.push(`${prefix}${mappedKey}/${value}`);
1242
+ continue;
1243
+ }
1244
+ if (rawKey === "bgImg" && typeof value === "object" && value !== null && !Array.isArray(value)) {
1245
+ const grad = value;
1246
+ const gradType = grad.gradient;
1247
+ if (!gradType) {
1248
+ continue;
1249
+ }
1250
+ let cls = "";
1251
+ if (gradType === "linear") {
1252
+ const dir = grad.dir ?? "to-r";
1253
+ if (typeof dir === "number") {
1254
+ if (dir < 0) {
1255
+ cls = `-bg-linear-${Math.abs(dir)}`;
1256
+ } else {
1257
+ cls = `bg-linear-${dir}`;
1258
+ }
1259
+ } else if (typeof dir === "string") {
1260
+ if (dir.startsWith("--")) {
1261
+ cls = `bg-linear-(${dir})`;
1262
+ } else if (dir.startsWith("to-")) {
1263
+ cls = `bg-linear-${dir}`;
1264
+ } else {
1265
+ cls = `bg-linear-[${normalizeArbitraryValue(dir)}]`;
1266
+ }
1267
+ }
1268
+ } else if (gradType === "radial") {
1269
+ const dir = grad.dir;
1270
+ if (dir === void 0 || dir === null) {
1271
+ cls = "bg-radial";
1272
+ } else if (typeof dir === "string") {
1273
+ if (dir.startsWith("--")) {
1274
+ cls = `bg-radial-(${dir})`;
1275
+ } else {
1276
+ cls = `bg-radial-[${normalizeArbitraryValue(dir)}]`;
1277
+ }
1278
+ }
1279
+ } else if (gradType === "conic") {
1280
+ const dir = grad.dir;
1281
+ if (dir === void 0 || dir === null) {
1282
+ cls = "bg-conic";
1283
+ } else if (typeof dir === "number") {
1284
+ if (dir < 0) {
1285
+ cls = `-bg-conic-${Math.abs(dir)}`;
1286
+ } else {
1287
+ cls = `bg-conic-${dir}`;
1288
+ }
1289
+ } else if (typeof dir === "string") {
1290
+ if (dir.startsWith("--")) {
1291
+ cls = `bg-conic-(${dir})`;
1292
+ } else {
1293
+ cls = `bg-conic-[${normalizeArbitraryValue(dir)}]`;
1294
+ }
1295
+ }
1296
+ }
1297
+ if (grad.in) {
1298
+ cls += `/${grad.in}`;
1299
+ }
1300
+ if (cls) {
1301
+ classes.push(`${prefix}${cls}`);
1302
+ }
1303
+ continue;
1304
+ }
1305
+ if ((rawKey === "group" || rawKey === "peer") && typeof value === "string") {
1306
+ classes.push(`${prefix}${rawKey}/${value}`);
1307
+ continue;
1308
+ }
1309
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && "color" in value) {
1310
+ const colorObj = value;
1311
+ const twPrefix = PROPERTY_MAP[rawKey] || rawKey.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1312
+ const colorBase = String(colorObj.color);
1313
+ if (colorObj.op !== void 0) {
1314
+ const opStr = formatOpacity(colorObj.op);
1315
+ classes.push(`${prefix}${twPrefix}-${colorBase}/${opStr}`);
1316
+ } else {
1317
+ classes.push(`${prefix}${twPrefix}-${colorBase}`);
1318
+ }
1319
+ continue;
1320
+ }
1321
+ if (typeof value === "object" && !Array.isArray(value)) {
1322
+ if (rawKey === "group") {
1323
+ const groupClasses = handleGroupPeer("group", value, prefix);
1324
+ classes.push(...groupClasses);
1325
+ continue;
1326
+ }
1327
+ if (rawKey === "peer") {
1328
+ const peerClasses = handleGroupPeer("peer", value, prefix);
1329
+ classes.push(...peerClasses);
1330
+ continue;
1331
+ }
1332
+ if (rawKey === "has") {
1333
+ const hasClasses = handleHas(value, prefix);
1334
+ classes.push(...hasClasses);
1335
+ continue;
1336
+ }
1337
+ if (rawKey === "not") {
1338
+ const notClasses = handleNot(value, prefix);
1339
+ classes.push(...notClasses);
1340
+ continue;
1341
+ }
1342
+ if (rawKey === "data") {
1343
+ const dataClasses = handleData(value, prefix);
1344
+ classes.push(...dataClasses);
1345
+ continue;
1346
+ }
1347
+ if (rawKey === "aria") {
1348
+ const ariaClasses = handleAria(value, prefix);
1349
+ classes.push(...ariaClasses);
1350
+ continue;
1351
+ }
1352
+ if (rawKey === "supports") {
1353
+ const supportsClasses = handleSupports(value, prefix);
1354
+ classes.push(...supportsClasses);
1355
+ continue;
1356
+ }
1357
+ if (rawKey === "min" || rawKey === "max") {
1358
+ const KNOWN_BP = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1359
+ for (const [breakpoint, breakpointValue] of Object.entries(value)) {
1360
+ if (breakpointValue === null || breakpointValue === void 0 || breakpointValue === false) {
1361
+ continue;
1362
+ }
1363
+ let bpStr;
1364
+ if (isArbitraryVariant(breakpoint)) {
1365
+ bpStr = `${rawKey}-${breakpoint}`;
1366
+ } else if (KNOWN_BP.has(breakpoint)) {
1367
+ bpStr = `${rawKey}-${breakpoint}`;
1368
+ } else {
1369
+ bpStr = `${rawKey}-[${breakpoint}]`;
1370
+ }
1371
+ const nestedPrefix2 = `${prefix}${bpStr}:`;
1372
+ const result = transform(breakpointValue, nestedPrefix2);
1373
+ if (result.className) {
1374
+ classes.push(result.className);
1375
+ }
1376
+ }
1377
+ continue;
1378
+ }
1379
+ if (rawKey.startsWith("@")) {
1380
+ const mappedKey = VARIANT_MAP[rawKey] || rawKey;
1381
+ if (typeof value === "string") {
1382
+ classes.push(`${prefix}${mappedKey}/${value}`);
1383
+ continue;
1384
+ }
1385
+ const KNOWN_BP = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1386
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
1387
+ if (nestedValue === null || nestedValue === void 0 || nestedValue === false) {
1388
+ continue;
1389
+ }
1390
+ if (isArbitraryVariant(nestedKey)) {
1391
+ const nestedPrefix2 = `${prefix}${mappedKey}-${nestedKey}:`;
1392
+ const result = transform(nestedValue, nestedPrefix2);
1393
+ if (result.className) {
1394
+ classes.push(result.className);
1395
+ }
1396
+ } else if ((mappedKey === "@min" || mappedKey === "@max") && typeof nestedValue === "object" && nestedValue !== null && !KNOWN_BP.has(nestedKey) && !PROPERTY_MAP[nestedKey] && !BOOLEAN_SHORTHANDS.has(nestedKey)) {
1397
+ const nestedPrefix2 = `${prefix}${mappedKey}-[${nestedKey}]:`;
1398
+ const result = transform(nestedValue, nestedPrefix2);
1399
+ if (result.className) {
1400
+ classes.push(result.className);
1401
+ }
1402
+ } else if (PROPERTY_MAP[nestedKey] || BOOLEAN_SHORTHANDS.has(nestedKey) || nestedKey.startsWith("@")) {
1403
+ const nestedPrefix2 = `${prefix}${mappedKey}:`;
1404
+ const result = transform({ [nestedKey]: nestedValue }, nestedPrefix2);
1405
+ if (result.className) {
1406
+ classes.push(result.className);
1407
+ }
1408
+ } else if (typeof nestedValue === "object" && nestedValue !== null) {
1409
+ const nestedPrefix2 = `${prefix}${mappedKey}/${nestedKey}:`;
1410
+ const result = transform(nestedValue, nestedPrefix2);
1411
+ if (result.className) {
1412
+ classes.push(result.className);
1413
+ }
1414
+ } else {
1415
+ const nestedPrefix2 = `${prefix}${mappedKey}:`;
1416
+ const result = transform({ [nestedKey]: nestedValue }, nestedPrefix2);
1417
+ if (result.className) {
1418
+ classes.push(result.className);
1419
+ }
1420
+ }
1421
+ }
1422
+ continue;
1423
+ }
1424
+ if (isArbitraryVariant(rawKey)) {
1425
+ const normalizedKey = normalizeArbitraryVariant(rawKey);
1426
+ const nestedPrefix2 = `${prefix}${normalizedKey}:`;
1427
+ const nestedResult2 = transform(value, nestedPrefix2);
1428
+ if (nestedResult2.className) {
1429
+ classes.push(nestedResult2.className);
1430
+ }
1431
+ continue;
1432
+ }
1433
+ const variantName = getVariantPrefix(rawKey);
1434
+ const nestedPrefix = `${prefix}${variantName}:`;
1435
+ const nestedResult = transform(value, nestedPrefix);
1436
+ if (nestedResult.className) {
1437
+ classes.push(nestedResult.className);
1438
+ }
1439
+ continue;
1440
+ }
1441
+ if (SNAP_DIRECT_MAP[rawKey] && typeof value === "string") {
1442
+ const mapped = SNAP_DIRECT_MAP[rawKey][value];
1443
+ if (mapped) {
1444
+ classes.push(`${prefix}${mapped}`);
1445
+ continue;
1446
+ }
1447
+ }
1448
+ if (typeof value === "string" && KNOWN_VARIANTS.has(rawKey)) {
1449
+ const variantName = getVariantPrefix(rawKey);
1450
+ classes.push(`${prefix}${variantName}:${value}`);
1451
+ continue;
1452
+ }
1453
+ if (rawKey.startsWith("--")) {
1454
+ classes.push(`${prefix}[${rawKey}:${value}]`);
1455
+ continue;
1456
+ }
1457
+ if (rawKey === "container") {
1458
+ if (value === true) {
1459
+ classes.push(`${prefix}container`);
1460
+ } else if (typeof value === "string") {
1461
+ classes.push(`${prefix}@container/${value}`);
1462
+ }
1463
+ continue;
1464
+ }
1465
+ let key = rawKey;
1466
+ if (PROPERTY_MAP[key]) {
1467
+ key = PROPERTY_MAP[key];
1468
+ } else {
1469
+ key = key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1470
+ }
1471
+ let className = prefix;
1472
+ if (rawKey === "willChange" && typeof value === "string") {
1473
+ if (value === "scroll") {
1474
+ classes.push(`${prefix}will-change-scroll-position`);
1475
+ } else if (value.startsWith("--")) {
1476
+ classes.push(`${prefix}will-change-(${value})`);
1477
+ } else {
1478
+ classes.push(`${prefix}will-change-${value}`);
1479
+ }
1480
+ continue;
1481
+ }
1482
+ if (key === "display") {
1483
+ if (typeof value === "string") {
1484
+ if (value === "none") {
1485
+ className += "hidden";
1486
+ } else {
1487
+ className += value;
1488
+ }
1489
+ classes.push(className);
1490
+ continue;
1491
+ }
1492
+ }
1493
+ if (key === "position") {
1494
+ if (typeof value === "string") {
1495
+ className += value;
1496
+ classes.push(className);
1497
+ continue;
1498
+ }
1499
+ }
1500
+ if (key === "visibility") {
1501
+ if (typeof value === "string") {
1502
+ if (value === "hidden") {
1503
+ className += "invisible";
1504
+ } else {
1505
+ className += value;
1506
+ }
1507
+ classes.push(className);
1508
+ continue;
1509
+ }
1510
+ }
1511
+ if (key === "isolation") {
1512
+ if (typeof value === "string") {
1513
+ if (value === "isolate") {
1514
+ className += "isolate";
1515
+ } else {
1516
+ className += `isolation-${value}`;
1517
+ }
1518
+ classes.push(className);
1519
+ continue;
1520
+ }
1521
+ }
1522
+ if ((rawKey === "fromPos" || rawKey === "viaPos" || rawKey === "toPos") && typeof value === "number") {
1523
+ const gradPrefix = rawKey.replace("Pos", "");
1524
+ classes.push(`${prefix}${gradPrefix}-${value}%`);
1525
+ continue;
1526
+ }
1527
+ if (typeof value === "string") {
1528
+ if (rawKey === "decoration") {
1529
+ if (["underline", "overline", "line-through", "no-underline", "none"].includes(value)) {
1530
+ className += value === "none" ? "no-underline" : value;
1531
+ classes.push(className);
1532
+ continue;
1533
+ }
1534
+ }
1535
+ if (rawKey === "textTransform") {
1536
+ if (["uppercase", "lowercase", "capitalize", "normal-case"].includes(value)) {
1537
+ className += value;
1538
+ classes.push(className);
1539
+ continue;
1540
+ }
1541
+ }
1542
+ if (rawKey === "fontVariant") {
1543
+ const FONT_VARIANT_CLASSES = /* @__PURE__ */ new Set([
1544
+ "normal-nums",
1545
+ "ordinal",
1546
+ "slashed-zero",
1547
+ "lining-nums",
1548
+ "oldstyle-nums",
1549
+ "proportional-nums",
1550
+ "tabular-nums",
1551
+ "diagonal-fractions",
1552
+ "stacked-fractions"
1553
+ ]);
1554
+ if (FONT_VARIANT_CLASSES.has(value)) {
1555
+ className += value;
1556
+ classes.push(className);
1557
+ continue;
1558
+ }
1559
+ }
1560
+ if (rawKey === "textWrap") {
1561
+ className += `text-${value}`;
1562
+ classes.push(className);
1563
+ continue;
1564
+ }
1565
+ if (rawKey === "break") {
1566
+ const wbMap = {
1567
+ "normal": "break-normal",
1568
+ "all": "break-all",
1569
+ "keep": "break-keep",
1570
+ "break-normal": "break-normal",
1571
+ "break-all": "break-all",
1572
+ "break-keep": "break-keep"
1573
+ };
1574
+ className += wbMap[value] || `break-${value}`;
1575
+ classes.push(className);
1576
+ continue;
1577
+ }
1578
+ if (rawKey === "wrap") {
1579
+ const owMap = {
1580
+ "normal": "wrap-normal",
1581
+ "break-word": "wrap-break-word",
1582
+ "anywhere": "wrap-anywhere",
1583
+ "wrap-normal": "wrap-normal",
1584
+ "wrap-break-word": "wrap-break-word",
1585
+ "wrap-anywhere": "wrap-anywhere"
1586
+ };
1587
+ className += owMap[value] || `wrap-${value}`;
1588
+ classes.push(className);
1589
+ continue;
1590
+ }
1591
+ if (rawKey === "textOverflow") {
1592
+ if (value === "ellipsis") {
1593
+ classes.push(`${prefix}truncate`);
1594
+ } else {
1595
+ classes.push(`${prefix}text-${value}`);
1596
+ }
1597
+ continue;
1598
+ }
1599
+ if (rawKey === "lineClamp") {
1600
+ const sValue = String(value);
1601
+ if (sValue.startsWith("--")) {
1602
+ className += `line-clamp-(${sValue})`;
1603
+ } else {
1604
+ const numVal = Number(sValue);
1605
+ if (!isNaN(numVal) && Number.isInteger(numVal)) {
1606
+ className += `line-clamp-${sValue}`;
1607
+ } else {
1608
+ className += `line-clamp-[${sValue}]`;
1609
+ }
1610
+ }
1611
+ classes.push(className);
1612
+ continue;
1613
+ }
1614
+ if (rawKey === "list" || rawKey === "listStyle") {
1615
+ const sValue = String(value);
1616
+ if (sValue.startsWith("--")) {
1617
+ className += `list-(${sValue})`;
1618
+ } else if (LIST_STYLE_STANDARD.has(sValue)) {
1619
+ className += `list-${sValue}`;
1620
+ } else {
1621
+ className += `list-[${sValue}]`;
1622
+ }
1623
+ classes.push(className);
1624
+ continue;
1625
+ }
1626
+ if (rawKey === "listPos") {
1627
+ className += `list-${value}`;
1628
+ classes.push(className);
1629
+ continue;
1630
+ }
1631
+ if (rawKey === "divideStyle") {
1632
+ className += `divide-${value}`;
1633
+ classes.push(className);
1634
+ continue;
1635
+ }
1636
+ if (rawKey === "decorationStyle" || rawKey === "textDecorationStyle") {
1637
+ className += `decoration-${value}`;
1638
+ classes.push(className);
1639
+ continue;
1640
+ }
1641
+ if (rawKey === "decorationColor" || rawKey === "textDecorationColor") {
1642
+ className += `decoration-${value}`;
1643
+ classes.push(className);
1644
+ continue;
1645
+ }
1646
+ if (rawKey === "decorationThickness" || rawKey === "textDecorationThickness") {
1647
+ if (needsArbitraryBrackets(value)) {
1648
+ className += `decoration-[${value}]`;
1649
+ } else if (value.startsWith("--")) {
1650
+ className += `decoration-(${value})`;
1651
+ } else {
1652
+ className += `decoration-${value}`;
1653
+ }
1654
+ classes.push(className);
1655
+ continue;
1656
+ }
1657
+ if (rawKey === "fontStretch") {
1658
+ const sValue = String(value);
1659
+ if (FONT_STRETCH_KEYWORDS.has(sValue)) {
1660
+ className += `font-${sValue}`;
1661
+ } else if (sValue.startsWith("--")) {
1662
+ className += `font-stretch-(${sValue})`;
1663
+ } else if (/^\d+%$/.test(sValue)) {
1664
+ className += `font-stretch-${sValue}`;
1665
+ } else {
1666
+ className += `font-stretch-[${sValue}]`;
1667
+ }
1668
+ classes.push(className);
1669
+ continue;
1670
+ }
1671
+ if (rawKey === "maxW" && value === "container") {
1672
+ classes.push("container");
1673
+ continue;
1674
+ }
1675
+ if (rawKey === "shadowColor") {
1676
+ if (String(value).startsWith("--")) {
1677
+ classes.push(`shadow-(color:${value})`);
1678
+ } else {
1679
+ classes.push(`shadow-${value}`);
1680
+ }
1681
+ continue;
1682
+ }
1683
+ if (rawKey === "brightness" || rawKey === "contrast" || rawKey === "saturate" || rawKey === "scale" || rawKey === "backdropBrightness" || rawKey === "backdropContrast" || rawKey === "backdropSaturate") {
1684
+ const prop = rawKey.startsWith("backdrop") ? `backdrop-${rawKey.slice(8).toLowerCase()}` : rawKey;
1685
+ const sValue = String(value);
1686
+ if (sValue.startsWith("--")) {
1687
+ classes.push(`${prop}-(${sValue})`);
1688
+ } else {
1689
+ classes.push(`${prop}-[${sValue}]`);
1690
+ }
1691
+ continue;
1692
+ }
1693
+ if (rawKey === "textShadow") {
1694
+ if (value === "none") {
1695
+ className += "text-shadow-none";
1696
+ } else if (value === "") {
1697
+ className += "text-shadow";
1698
+ } else if (needsArbitraryBrackets(value)) {
1699
+ className += `text-shadow-[${normalizeArbitraryValue(value)}]`;
1700
+ } else {
1701
+ className += `text-shadow-${value}`;
1702
+ }
1703
+ classes.push(className);
1704
+ continue;
1705
+ }
1706
+ if (rawKey === "textShadowColor") {
1707
+ className += `text-shadow-${value}`;
1708
+ classes.push(className);
1709
+ continue;
1710
+ }
1711
+ if (rawKey === "fromPos" || rawKey === "viaPos" || rawKey === "toPos") {
1712
+ const gradPrefix = rawKey.replace("Pos", "");
1713
+ const sValue = String(value);
1714
+ if (value.startsWith("--")) {
1715
+ classes.push(`${gradPrefix}-(${value})`);
1716
+ } else if (/^\d+%$/.test(sValue)) {
1717
+ classes.push(`${gradPrefix}-${sValue}`);
1718
+ } else {
1719
+ classes.push(`${gradPrefix}-[${sValue}]`);
1720
+ }
1721
+ continue;
1722
+ }
1723
+ if (rawKey === "bgImg") {
1724
+ const v = String(value).trim();
1725
+ if (v === "none") {
1726
+ classes.push("bg-none");
1727
+ continue;
1728
+ }
1729
+ const vNorm = v.startsWith("-") ? v.slice(1) : v;
1730
+ if (vNorm.startsWith("linear-") || vNorm.startsWith("radial") || vNorm.startsWith("conic") || vNorm.startsWith("gradient-to-")) {
1731
+ const vMapped = vNorm.startsWith("gradient-to-") ? vNorm.replace("gradient-to-", "linear-to-") : vNorm;
1732
+ if (v.startsWith("-")) {
1733
+ classes.push(`-bg-${vMapped}`);
1734
+ } else {
1735
+ classes.push(`bg-${vMapped}`);
1736
+ }
1737
+ continue;
1738
+ }
1739
+ if (v.startsWith("--")) {
1740
+ classes.push(`bg-(image:${v})`);
1741
+ continue;
1742
+ }
1743
+ if (v.startsWith("url(")) {
1744
+ classes.push(`bg-[${v}]`);
1745
+ continue;
1746
+ }
1747
+ classes.push(`bg-[url(${v})]`);
1748
+ continue;
1749
+ }
1750
+ if (rawKey === "bgPos") {
1751
+ const sVal = String(value);
1752
+ if (sVal.startsWith("--")) {
1753
+ classes.push(`bg-(${sVal})`);
1754
+ } else if (sVal.includes("_") || needsArbitraryBrackets(sVal)) {
1755
+ classes.push(`bg-[${normalizeArbitraryValue(sVal)}]`);
1756
+ } else {
1757
+ classes.push(`bg-${sVal}`);
1758
+ }
1759
+ continue;
1760
+ }
1761
+ if (rawKey === "maskPos") {
1762
+ className += `mask-${value}`;
1763
+ classes.push(className);
1764
+ continue;
1765
+ }
1766
+ if (rawKey === "maskRepeat") {
1767
+ if (value === "repeat") {
1768
+ className += "mask-repeat";
1769
+ } else if (value === "no-repeat") {
1770
+ className += "mask-no-repeat";
1771
+ } else {
1772
+ className += `mask-${value}`;
1773
+ }
1774
+ classes.push(className);
1775
+ continue;
1776
+ }
1777
+ if (rawKey === "maskSize") {
1778
+ className += `mask-${value}`;
1779
+ classes.push(className);
1780
+ continue;
1781
+ }
1782
+ if (rawKey === "maskShape") {
1783
+ className += `mask-${value}`;
1784
+ classes.push(className);
1785
+ continue;
1786
+ }
1787
+ if (rawKey === "maskComposite") {
1788
+ className += `mask-${value}`;
1789
+ classes.push(className);
1790
+ continue;
1791
+ }
1792
+ if (rawKey === "maskMode") {
1793
+ className += `mask-${value}`;
1794
+ classes.push(className);
1795
+ continue;
1796
+ }
1797
+ if (rawKey === "maskType") {
1798
+ className += `mask-type-${value}`;
1799
+ classes.push(className);
1800
+ continue;
1801
+ }
1802
+ if (rawKey === "content") {
1803
+ if (value.startsWith("--")) {
1804
+ className += `content-(${value})`;
1805
+ } else if (!["none", "empty"].includes(value)) {
1806
+ className += `content-[${value}]`;
1807
+ } else {
1808
+ className += `content-${value}`;
1809
+ }
1810
+ classes.push(className);
1811
+ continue;
1812
+ }
1813
+ if (rawKey === "borderTColor") {
1814
+ className += `border-t-${value}`;
1815
+ classes.push(className);
1816
+ continue;
1817
+ }
1818
+ if (rawKey === "borderRColor") {
1819
+ className += `border-r-${value}`;
1820
+ classes.push(className);
1821
+ continue;
1822
+ }
1823
+ if (rawKey === "borderBColor") {
1824
+ className += `border-b-${value}`;
1825
+ classes.push(className);
1826
+ continue;
1827
+ }
1828
+ if (rawKey === "borderLColor") {
1829
+ className += `border-l-${value}`;
1830
+ classes.push(className);
1831
+ continue;
1832
+ }
1833
+ if (rawKey === "borderXColor") {
1834
+ className += `border-x-${value}`;
1835
+ classes.push(className);
1836
+ continue;
1837
+ }
1838
+ if (rawKey === "borderYColor") {
1839
+ className += `border-y-${value}`;
1840
+ classes.push(className);
1841
+ continue;
1842
+ }
1843
+ if (rawKey === "transitionBehavior") {
1844
+ className += `transition-${value}`;
1845
+ classes.push(className);
1846
+ continue;
1847
+ }
1848
+ if (rawKey === "dropShadowColor") {
1849
+ if (value.startsWith("--")) {
1850
+ className += `drop-shadow-(color:${value})`;
1851
+ } else {
1852
+ className += `drop-shadow-${value}`;
1853
+ }
1854
+ classes.push(className);
1855
+ continue;
1856
+ }
1857
+ if (rawKey === "origin" || rawKey === "ease" || rawKey === "animate" || rawKey === "filter" || rawKey === "backdropFilter" || rawKey === "dropShadow") {
1858
+ const sVal = String(value);
1859
+ const prop = PROPERTY_MAP[rawKey] || rawKey;
1860
+ if (needsArbitraryBrackets(sVal) || sVal.includes("(") || sVal.includes("_") || sVal.includes("%")) {
1861
+ classes.push(`${prop}-[${normalizeArbitraryValue(sVal)}]`);
1862
+ continue;
1863
+ }
1864
+ }
1865
+ if (rawKey === "transformStyle") {
1866
+ if (value === "preserve-3d" || value === "3d") {
1867
+ className += "transform-3d";
1868
+ } else {
1869
+ className += `transform-${value}`;
1870
+ }
1871
+ classes.push(className);
1872
+ continue;
1873
+ }
1874
+ if (rawKey === "perspective") {
1875
+ const STANDARD_PERSPECTIVE = /* @__PURE__ */ new Set(["none", "normal", "dramatic", "midrange"]);
1876
+ if (STANDARD_PERSPECTIVE.has(value)) {
1877
+ className += `perspective-${value}`;
1878
+ } else if (value.startsWith("--")) {
1879
+ className += `perspective-(${value})`;
1880
+ } else if (needsArbitraryBrackets(value)) {
1881
+ className += `perspective-[${value}]`;
1882
+ } else {
1883
+ className += `perspective-${value}`;
1884
+ }
1885
+ classes.push(className);
1886
+ continue;
1887
+ }
1888
+ if (rawKey === "perspectiveOrigin") {
1889
+ const STANDARD_ORIGINS = /* @__PURE__ */ new Set(["center", "top", "right", "bottom", "left", "top-left", "top-right", "bottom-left", "bottom-right"]);
1890
+ if (STANDARD_ORIGINS.has(value)) {
1891
+ className += `perspective-origin-${value}`;
1892
+ } else {
1893
+ className += `perspective-origin-[${value}]`;
1894
+ }
1895
+ classes.push(className);
1896
+ continue;
1897
+ }
1898
+ if (rawKey === "backface") {
1899
+ className += `backface-${value}`;
1900
+ classes.push(className);
1901
+ continue;
1902
+ }
1903
+ }
1904
+ if (process.env.NODE_ENV !== "production" && typeof window === "undefined") {
1905
+ const isKnown = PROPERTY_MAP[rawKey] || BOOLEAN_SHORTHANDS.has(rawKey) || SNAP_DIRECT_MAP[rawKey] || NEEDS_ARBITRARY_PROPERTY.has(key) || rawKey === "fromPos" || rawKey === "viaPos" || rawKey === "toPos" || rawKey.startsWith("--") || rawKey.startsWith("[") || rawKey.startsWith("@") || // Variants that fell through (e.g. empty object)
1906
+ KNOWN_VARIANTS.has(rawKey) || // Groups/Peers
1907
+ rawKey === "group" || rawKey === "peer" || // Special variant objects
1908
+ rawKey === "has" || rawKey === "not" || rawKey === "data" || rawKey === "aria" || rawKey === "supports" || rawKey === "min" || rawKey === "max";
1909
+ if (!isKnown) {
1910
+ const suggestion = SUGGESTION_MAP[rawKey];
1911
+ if (suggestion) {
1912
+ console.warn(
1913
+ `[csszyx] Use the canonical key "${suggestion}" instead of "${rawKey}".`
1914
+ );
1915
+ } else {
1916
+ console.warn(
1917
+ `[csszyx] Unknown property "${rawKey}" in sz prop. This will be ignored. Check for typos.`
1918
+ );
1919
+ }
1920
+ }
1921
+ }
1922
+ if (value === true) {
1923
+ if (BOOLEAN_SHORTHANDS.has(rawKey)) {
1924
+ const mappedClass = BOOLEAN_TO_CLASS[rawKey] || key;
1925
+ className += mappedClass;
1926
+ } else {
1927
+ className += key;
1928
+ }
1929
+ classes.push(className);
1930
+ continue;
1931
+ }
1932
+ if (typeof value === "number") {
1933
+ if (value < 0 && NEGATIVE_ALLOWED.has(key)) {
1934
+ className += `-${key}-${Math.abs(value)}`;
1935
+ } else {
1936
+ className += `${key}-${value}`;
1937
+ }
1938
+ classes.push(className);
1939
+ continue;
1940
+ }
1941
+ if (typeof value === "string") {
1942
+ const { value: cleanValue, important } = handleImportant(value);
1943
+ let finalValue = cleanValue;
1944
+ if (NEEDS_ARBITRARY_PROPERTY.has(key)) {
1945
+ const arbitraryProp = `[${key}:${finalValue}]`;
1946
+ className += arbitraryProp;
1947
+ if (important) {
1948
+ className += "!";
1949
+ }
1950
+ classes.push(className);
1951
+ continue;
1952
+ }
1953
+ const isAspectRatio = key === "aspect" && /^\d+\/\d+$/.test(finalValue);
1954
+ if (finalValue.startsWith("--")) {
1955
+ finalValue = `(${finalValue})`;
1956
+ } else if (finalValue.startsWith("var(")) {
1957
+ finalValue = `[${normalizeArbitraryValue(finalValue)}]`;
1958
+ } else if (/^\d+\/\d+$/.test(finalValue)) {
1959
+ if (!FRACTION_SUPPORTED_PROPS.has(rawKey)) {
1960
+ finalValue = `[${finalValue}]`;
1961
+ }
1962
+ } else if (needsArbitraryBrackets(finalValue) || isAspectRatio || /^\d+\.\d+%$/.test(finalValue)) {
1963
+ finalValue = `[${normalizeArbitraryValue(finalValue)}]`;
1964
+ }
1965
+ className += `${key}-${finalValue}`;
1966
+ if (important) {
1967
+ className += "!";
1968
+ }
1969
+ classes.push(className);
1970
+ }
1971
+ }
1972
+ const finalClasses = classes.filter(Boolean);
1973
+ if (mangleMap) {
1974
+ const mangledClasses = finalClasses.map((cls) => mangleMap[cls] || cls);
1975
+ return {
1976
+ className: mangledClasses.join(" "),
1977
+ attributes
1978
+ };
1979
+ }
1980
+ return {
1981
+ className: finalClasses.join(" "),
1982
+ attributes
1983
+ };
1984
+ }
1985
+ function isValidSzProp(szProp) {
1986
+ return szProp !== null && szProp !== void 0 && typeof szProp === "object" && !Array.isArray(szProp);
1987
+ }
1988
+ function normalizeClassName(className) {
1989
+ return className.split(/\s+/).filter(Boolean).join(" ");
1990
+ }
1991
+
1992
+ // src/transform.ts
1993
+ function transformSourceCode(source) {
1994
+ let usesRuntime = false;
1995
+ let usesColorVar = false;
1996
+ let transformed = false;
1997
+ if (!source.includes("sz")) {
1998
+ return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
1999
+ }
2000
+ try {
2001
+ const result = babel.transformSync(source, {
2002
+ filename: "file.tsx",
2003
+ // Enable TS/JSX parsing
2004
+ ast: true,
2005
+ code: true,
2006
+ configFile: false,
2007
+ babelrc: false,
2008
+ parserOpts: {
2009
+ plugins: ["typescript", "jsx"]
2010
+ },
2011
+ plugins: [
2012
+ function() {
2013
+ return {
2014
+ visitor: {
2015
+ JSXAttribute(path) {
2016
+ if (path.node.name.name !== "sz") {
2017
+ return;
2018
+ }
2019
+ const value = path.node.value;
2020
+ if (t.isStringLiteral(value)) {
2021
+ path.node.name.name = "className";
2022
+ transformed = true;
2023
+ return;
2024
+ }
2025
+ if (t.isJSXExpressionContainer(value)) {
2026
+ const expression = value.expression;
2027
+ if (t.isObjectExpression(expression)) {
2028
+ const staticObject = evaluateStaticObject(expression);
2029
+ if (staticObject !== null) {
2030
+ const { className, attributes } = transform(staticObject);
2031
+ path.node.name.name = "className";
2032
+ path.node.value = t.stringLiteral(className);
2033
+ Object.entries(attributes).forEach(([key, val]) => {
2034
+ if (path.parentPath?.isJSXOpeningElement()) {
2035
+ path.parentPath.node.attributes.push(
2036
+ t.jsxAttribute(
2037
+ t.jsxIdentifier(key),
2038
+ t.stringLiteral(val)
2039
+ )
2040
+ );
2041
+ }
2042
+ });
2043
+ transformed = true;
2044
+ return;
2045
+ }
2046
+ const partial = evaluatePartialObject(expression);
2047
+ if (partial !== null && !partial.hasSpread && partial.dynamicProps.size > 0) {
2048
+ const staticClasses = [];
2049
+ if (Object.keys(partial.staticProps).length > 0) {
2050
+ const { className: sc } = transform(partial.staticProps);
2051
+ if (sc) {
2052
+ staticClasses.push(sc);
2053
+ }
2054
+ }
2055
+ const cssVarClasses = [];
2056
+ const styleProps = [];
2057
+ for (const [, info] of partial.dynamicProps) {
2058
+ if (!info.skipClass) {
2059
+ cssVarClasses.push(buildCSSVarClassName(info));
2060
+ }
2061
+ styleProps.push(
2062
+ t.objectProperty(
2063
+ t.stringLiteral(info.varName),
2064
+ generateStyleValueExpression(info)
2065
+ )
2066
+ );
2067
+ }
2068
+ const allClasses = [...staticClasses, ...partial.rawClasses, ...cssVarClasses].join(" ");
2069
+ path.node.name.name = "className";
2070
+ path.node.value = t.stringLiteral(allClasses);
2071
+ if (styleProps.length > 0 && path.parentPath?.isJSXOpeningElement()) {
2072
+ const styleAttr = t.jsxAttribute(
2073
+ t.jsxIdentifier("style"),
2074
+ t.jsxExpressionContainer(
2075
+ t.objectExpression(styleProps)
2076
+ )
2077
+ );
2078
+ path.parentPath.node.attributes.push(styleAttr);
2079
+ }
2080
+ if (partial.usesColorVar) {
2081
+ usesColorVar = true;
2082
+ }
2083
+ transformed = true;
2084
+ return;
2085
+ }
2086
+ }
2087
+ if (t.isIdentifier(expression) && !t.isJSXEmptyExpression(expression)) {
2088
+ const binding = path.scope.getBinding(expression.name);
2089
+ if (binding && binding.path.isVariableDeclarator()) {
2090
+ const init2 = binding.path.node.init;
2091
+ if (init2) {
2092
+ const resolved = tryStaticTransformNode(init2);
2093
+ if (resolved !== null) {
2094
+ path.node.name.name = "className";
2095
+ if (t.isStringLiteral(resolved)) {
2096
+ path.node.value = resolved;
2097
+ } else {
2098
+ value.expression = resolved;
2099
+ }
2100
+ transformed = true;
2101
+ return;
2102
+ }
2103
+ }
2104
+ }
2105
+ }
2106
+ if (t.isConditionalExpression(expression)) {
2107
+ const resolved = tryStaticTransformNode(expression);
2108
+ if (resolved !== null) {
2109
+ path.node.name.name = "className";
2110
+ if (t.isStringLiteral(resolved)) {
2111
+ path.node.value = resolved;
2112
+ } else {
2113
+ value.expression = resolved;
2114
+ }
2115
+ transformed = true;
2116
+ return;
2117
+ }
2118
+ }
2119
+ path.node.name.name = "className";
2120
+ const szCall = t.callExpression(
2121
+ t.identifier("_sz"),
2122
+ [expression]
2123
+ );
2124
+ value.expression = szCall;
2125
+ usesRuntime = true;
2126
+ transformed = true;
2127
+ }
2128
+ }
2129
+ }
2130
+ };
2131
+ }
2132
+ ]
2133
+ });
2134
+ return {
2135
+ code: result?.code || source,
2136
+ transformed,
2137
+ usesRuntime,
2138
+ usesColorVar
2139
+ };
2140
+ } catch (e) {
2141
+ console.warn("[csszyx] AST transform failed, falling back to original code:", e);
2142
+ return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
2143
+ }
2144
+ }
2145
+ function tryStaticTransformNode(node) {
2146
+ if (t.isObjectExpression(node)) {
2147
+ const staticObj = evaluateStaticObject(node);
2148
+ if (staticObj !== null) {
2149
+ const { className } = transform(staticObj);
2150
+ return t.stringLiteral(className);
2151
+ }
2152
+ return null;
2153
+ }
2154
+ if (t.isStringLiteral(node)) {
2155
+ return node;
2156
+ }
2157
+ if (t.isConditionalExpression(node)) {
2158
+ const consequent = tryStaticTransformNode(node.consequent);
2159
+ const alternate = tryStaticTransformNode(node.alternate);
2160
+ if (consequent !== null && alternate !== null) {
2161
+ return t.conditionalExpression(node.test, consequent, alternate);
2162
+ }
2163
+ return null;
2164
+ }
2165
+ return null;
2166
+ }
2167
+ function evaluateStaticObject(node) {
2168
+ const result = {};
2169
+ for (const prop of node.properties) {
2170
+ if (!t.isObjectProperty(prop)) {
2171
+ return null;
2172
+ }
2173
+ if (prop.computed) {
2174
+ return null;
2175
+ }
2176
+ let key;
2177
+ if (t.isIdentifier(prop.key)) {
2178
+ key = prop.key.name;
2179
+ } else if (t.isStringLiteral(prop.key)) {
2180
+ key = prop.key.value;
2181
+ } else {
2182
+ return null;
2183
+ }
2184
+ const value = prop.value;
2185
+ if (t.isStringLiteral(value)) {
2186
+ result[key] = value.value;
2187
+ } else if (t.isNumericLiteral(value)) {
2188
+ result[key] = value.value;
2189
+ } else if (t.isBooleanLiteral(value)) {
2190
+ result[key] = value.value;
2191
+ } else if (t.isUnaryExpression(value) && value.operator === "-" && t.isNumericLiteral(value.argument)) {
2192
+ result[key] = -value.argument.value;
2193
+ } else if (t.isObjectExpression(value)) {
2194
+ const nested = evaluateStaticObject(value);
2195
+ if (nested === null) {
2196
+ return null;
2197
+ }
2198
+ result[key] = nested;
2199
+ } else {
2200
+ return null;
2201
+ }
2202
+ }
2203
+ return result;
2204
+ }
2205
+ function evaluatePartialObject(node, variantChain = "") {
2206
+ const staticProps = {};
2207
+ const dynamicProps = /* @__PURE__ */ new Map();
2208
+ const rawClasses = [];
2209
+ let usesColorVar = false;
2210
+ for (const prop of node.properties) {
2211
+ if (t.isSpreadElement(prop)) {
2212
+ return null;
2213
+ }
2214
+ if (!t.isObjectProperty(prop)) {
2215
+ return null;
2216
+ }
2217
+ if (prop.computed) {
2218
+ return null;
2219
+ }
2220
+ let key;
2221
+ if (t.isIdentifier(prop.key)) {
2222
+ key = prop.key.name;
2223
+ } else if (t.isStringLiteral(prop.key)) {
2224
+ key = prop.key.value;
2225
+ } else {
2226
+ return null;
2227
+ }
2228
+ const value = prop.value;
2229
+ if (t.isStringLiteral(value)) {
2230
+ staticProps[key] = value.value;
2231
+ } else if (t.isNumericLiteral(value)) {
2232
+ staticProps[key] = value.value;
2233
+ } else if (t.isBooleanLiteral(value)) {
2234
+ staticProps[key] = value.value;
2235
+ } else if (t.isUnaryExpression(value) && value.operator === "-" && t.isNumericLiteral(value.argument)) {
2236
+ staticProps[key] = -value.argument.value;
2237
+ } else if (t.isObjectExpression(value)) {
2238
+ const nested = evaluateStaticObject(value);
2239
+ if (nested !== null) {
2240
+ staticProps[key] = nested;
2241
+ } else {
2242
+ const colorObjProps = /* @__PURE__ */ new Map();
2243
+ for (const p of value.properties) {
2244
+ if (t.isObjectProperty(p) && !p.computed && t.isIdentifier(p.key)) {
2245
+ colorObjProps.set(p.key.name, p);
2246
+ }
2247
+ }
2248
+ if (colorObjProps.has("color") && COLOR_PROPERTIES.has(key)) {
2249
+ const colorProp = colorObjProps.get("color");
2250
+ if (!colorProp) {
2251
+ continue;
2252
+ }
2253
+ const opProp = colorObjProps.get("op");
2254
+ const twPrefix = PROPERTY_MAP[key] || key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
2255
+ let colorStr = null;
2256
+ if (t.isStringLiteral(colorProp.value)) {
2257
+ colorStr = colorProp.value.value;
2258
+ }
2259
+ if (colorStr && opProp) {
2260
+ const opVarName = getCSSVariableName(`${key}-op`, variantChain || void 0);
2261
+ const uniqueKey = variantChain ? `${variantChain}-${key}-op` : `${key}-op`;
2262
+ if (t.isStringLiteral(opProp.value) || t.isNumericLiteral(opProp.value)) {
2263
+ const opVal = t.isStringLiteral(opProp.value) ? opProp.value.value : opProp.value.value;
2264
+ staticProps[key] = { color: colorStr, op: opVal };
2265
+ } else if (t.isExpression(opProp.value)) {
2266
+ const variantPfx = variantChain ? `${variantChain}:` : "";
2267
+ rawClasses.push(`${variantPfx}${twPrefix}-${colorStr}/[var(${opVarName})]`);
2268
+ dynamicProps.set(uniqueKey, {
2269
+ expression: opProp.value,
2270
+ category: 3 /* UNITLESS */,
2271
+ varName: opVarName,
2272
+ twPrefix: `${twPrefix}-op`,
2273
+ variantChain: variantChain || "",
2274
+ skipClass: true
2275
+ });
2276
+ }
2277
+ } else if (!colorStr && opProp) {
2278
+ const varName = getCSSVariableName(key, variantChain || void 0);
2279
+ const uniqueKey = variantChain ? `${variantChain}-${key}` : key;
2280
+ usesColorVar = true;
2281
+ dynamicProps.set(uniqueKey, {
2282
+ expression: t.isExpression(colorProp.value) ? colorProp.value : t.stringLiteral(""),
2283
+ category: 1 /* COLOR */,
2284
+ varName,
2285
+ twPrefix,
2286
+ variantChain: variantChain || ""
2287
+ });
2288
+ } else if (colorStr && !opProp) {
2289
+ staticProps[key] = colorStr;
2290
+ }
2291
+ } else {
2292
+ const isVariant = KNOWN_VARIANTS.has(key) || KNOWN_VARIANTS.has(getVariantPrefix(key));
2293
+ if (isVariant) {
2294
+ const variantKey = variantChain ? `${variantChain}-${key}` : key;
2295
+ const nestedResult = evaluatePartialObject(value, variantKey);
2296
+ if (nestedResult === null) {
2297
+ return null;
2298
+ }
2299
+ if (Object.keys(nestedResult.staticProps).length > 0) {
2300
+ staticProps[key] = nestedResult.staticProps;
2301
+ }
2302
+ for (const [k, v] of nestedResult.dynamicProps) {
2303
+ dynamicProps.set(k, v);
2304
+ }
2305
+ rawClasses.push(...nestedResult.rawClasses);
2306
+ if (nestedResult.usesColorVar) {
2307
+ usesColorVar = true;
2308
+ }
2309
+ } else {
2310
+ return null;
2311
+ }
2312
+ }
2313
+ }
2314
+ } else if (t.isExpression(value)) {
2315
+ const twPrefix = PROPERTY_MAP[key] || key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
2316
+ const category = getPropertyCategory(key);
2317
+ const varName = getCSSVariableName(key, variantChain || void 0);
2318
+ const uniqueKey = variantChain ? `${variantChain}-${key}` : key;
2319
+ if (COLOR_PROPERTIES.has(key)) {
2320
+ usesColorVar = true;
2321
+ }
2322
+ dynamicProps.set(uniqueKey, {
2323
+ expression: value,
2324
+ category,
2325
+ varName,
2326
+ twPrefix,
2327
+ variantChain: variantChain || ""
2328
+ });
2329
+ } else {
2330
+ return null;
2331
+ }
2332
+ }
2333
+ return { staticProps, dynamicProps, rawClasses, hasSpread: false, usesColorVar };
2334
+ }
2335
+ function generateStyleValueExpression(info) {
2336
+ const { expression, category } = info;
2337
+ switch (category) {
2338
+ case 0 /* SPACING */:
2339
+ return t.templateLiteral(
2340
+ [
2341
+ t.templateElement({ raw: "calc(", cooked: "calc(" }, false),
2342
+ t.templateElement({ raw: " * var(--spacing))", cooked: " * var(--spacing))" }, true)
2343
+ ],
2344
+ [expression]
2345
+ );
2346
+ case 1 /* COLOR */:
2347
+ return t.callExpression(
2348
+ t.identifier("__szColorVar"),
2349
+ [expression]
2350
+ );
2351
+ case 4 /* ANGLE */:
2352
+ return t.templateLiteral(
2353
+ [
2354
+ t.templateElement({ raw: "", cooked: "" }, false),
2355
+ t.templateElement({ raw: "deg", cooked: "deg" }, true)
2356
+ ],
2357
+ [expression]
2358
+ );
2359
+ case 5 /* DURATION */:
2360
+ return t.templateLiteral(
2361
+ [
2362
+ t.templateElement({ raw: "", cooked: "" }, false),
2363
+ t.templateElement({ raw: "ms", cooked: "ms" }, true)
2364
+ ],
2365
+ [expression]
2366
+ );
2367
+ case 3 /* UNITLESS */:
2368
+ case 7 /* PASSTHROUGH */:
2369
+ case 2 /* FRACTION */:
2370
+ case 6 /* ARBITRARY */:
2371
+ default:
2372
+ return t.templateLiteral(
2373
+ [
2374
+ t.templateElement({ raw: "", cooked: "" }, false),
2375
+ t.templateElement({ raw: "", cooked: "" }, true)
2376
+ ],
2377
+ [expression]
2378
+ );
2379
+ }
2380
+ }
2381
+ function buildCSSVarClassName(info) {
2382
+ const { twPrefix, varName, variantChain } = info;
2383
+ const variantPrefix = variantChain ? `${getVariantPrefix(variantChain)}:` : "";
2384
+ return `${variantPrefix}${twPrefix}-[var(${varName})]`;
2385
+ }
2386
+
2387
+ // src/compiler.ts
2388
+ var CsszyxCompiler = class _CsszyxCompiler {
2389
+ /**
2390
+ * Private constructor to enforce singleton pattern.
2391
+ */
2392
+ constructor() {
2393
+ this.wasmLoaded = false;
2394
+ }
2395
+ /**
2396
+ * Gets the singleton instance of the compiler.
2397
+ *
2398
+ * @returns {CsszyxCompiler} The compiler instance.
2399
+ */
2400
+ static getInstance() {
2401
+ if (!_CsszyxCompiler.instance) {
2402
+ _CsszyxCompiler.instance = new _CsszyxCompiler();
2403
+ }
2404
+ return _CsszyxCompiler.instance;
2405
+ }
2406
+ /**
2407
+ * Initializes the WASM core.
2408
+ *
2409
+ * @returns {Promise<void>} Resolves when WASM is ready.
2410
+ */
2411
+ async init() {
2412
+ if (this.wasmLoaded) {
2413
+ return;
2414
+ }
2415
+ try {
2416
+ (0, import_core.init)();
2417
+ this.wasmLoaded = true;
2418
+ console.info(`[csszyx] WASM Core initialized (v${(0, import_core.version)()})`);
2419
+ } catch (error) {
2420
+ console.warn(
2421
+ "[csszyx] Failed to initialize WASM core, falling back to JavaScript transformer",
2422
+ error
2423
+ );
2424
+ this.wasmLoaded = false;
2425
+ }
2426
+ }
2427
+ /**
2428
+ * Transforms an sz object into Tailwind classes.
2429
+ *
2430
+ * @param {SzObject} sz - The object to transform.
2431
+ * @returns {string} The transformed class string.
2432
+ */
2433
+ transform(sz) {
2434
+ if (this.wasmLoaded) {
2435
+ try {
2436
+ return (0, import_core.transform_sz)(sz);
2437
+ } catch (error) {
2438
+ console.warn(
2439
+ "[csszyx] WASM transformation failed, using JS fallback",
2440
+ error
2441
+ );
2442
+ return transform(sz).className;
2443
+ }
2444
+ }
2445
+ return transform(sz).className;
2446
+ }
2447
+ /**
2448
+ * Checks if the WASM core is currently active.
2449
+ *
2450
+ * @returns {boolean} True if WASM is loaded.
2451
+ */
2452
+ isWasmActive() {
2453
+ return this.wasmLoaded;
2454
+ }
2455
+ /**
2456
+ * Generates a recovery token using WASM or JS fallback.
2457
+ *
2458
+ * @param {object} metadata - Token metadata
2459
+ * @param metadata.component - Component name
2460
+ * @param metadata.filePath - File path source
2461
+ * @param metadata.line - Line number
2462
+ * @param metadata.column - Column number
2463
+ * @param metadata.mode - Build mode (dev/prod)
2464
+ * @param metadata.buildId - Unique build identifier
2465
+ * @returns {string} The generated token
2466
+ */
2467
+ generateRecoveryToken(metadata) {
2468
+ if (this.wasmLoaded) {
2469
+ try {
2470
+ const { generate_token } = require("@csszyx/core");
2471
+ return generate_token(
2472
+ metadata.component,
2473
+ metadata.filePath,
2474
+ metadata.line,
2475
+ metadata.column,
2476
+ metadata.mode,
2477
+ metadata.buildId
2478
+ );
2479
+ } catch (error) {
2480
+ console.warn("[csszyx] WASM token generation failed", error);
2481
+ }
2482
+ }
2483
+ const str = `${metadata.component}:${metadata.filePath}:${metadata.line}:${metadata.column}:${metadata.mode}:${metadata.buildId}`;
2484
+ let hash = 0;
2485
+ for (let i = 0; i < str.length; i++) {
2486
+ hash = (hash << 5) - hash + str.charCodeAt(i) | 0;
2487
+ }
2488
+ return Math.abs(hash).toString(16).padStart(12, "0").slice(0, 12);
2489
+ }
2490
+ };
2491
+
2492
+ // src/recovery.ts
2493
+ function isValidRecoveryMode(value) {
2494
+ return value === "csr" || value === "dev-only";
2495
+ }
2496
+ function generateRecoveryToken(metadata) {
2497
+ return CsszyxCompiler.getInstance().generateRecoveryToken(metadata);
2498
+ }
2499
+ function createRecoveryToken(metadata, buildId) {
2500
+ const fullMetadata = {
2501
+ ...metadata,
2502
+ buildId
2503
+ };
2504
+ const token = generateRecoveryToken(fullMetadata);
2505
+ return {
2506
+ token,
2507
+ metadata: fullMetadata
2508
+ };
2509
+ }
2510
+ function validateSzRecover(value, componentName) {
2511
+ if (!isValidRecoveryMode(value)) {
2512
+ return {
2513
+ valid: false,
2514
+ error: `szRecover in ${componentName} must be static literal "csr" or "dev-only", got: ${JSON.stringify(value)}`
2515
+ };
2516
+ }
2517
+ return { valid: true };
2518
+ }
2519
+ function injectRecoveryToken(attributes, token) {
2520
+ return {
2521
+ ...attributes,
2522
+ "data-sz-recovery-token": token
2523
+ };
2524
+ }
2525
+
2526
+ // src/manifest.ts
2527
+ var import_crypto = require("crypto");
2528
+ var ManifestBuilder = class {
2529
+ /**
2530
+ * Creates a new manifest builder.
2531
+ *
2532
+ * @param {string} buildId - Build ID (git hash or timestamp)
2533
+ *
2534
+ * @example
2535
+ * ```typescript
2536
+ * const builder = new ManifestBuilder('abc123');
2537
+ * ```
2538
+ */
2539
+ constructor(buildId) {
2540
+ this.tokens = /* @__PURE__ */ new Map();
2541
+ this.buildId = buildId;
2542
+ }
2543
+ /**
2544
+ * Adds a token to the manifest.
2545
+ *
2546
+ * @param {string} token - The recovery token
2547
+ * @param {TokenMetadata} metadata - Token metadata
2548
+ *
2549
+ * @example
2550
+ * ```typescript
2551
+ * builder.addToken('a94f1c2e8b3d', {
2552
+ * mode: 'csr',
2553
+ * component: 'Button',
2554
+ * filePath: '/app/Button.tsx',
2555
+ * line: 10,
2556
+ * column: 5,
2557
+ * buildId: 'abc123'
2558
+ * });
2559
+ * ```
2560
+ */
2561
+ addToken(token, metadata) {
2562
+ const relativePath = this.toRelativePath(metadata.filePath);
2563
+ this.tokens.set(token, {
2564
+ mode: metadata.mode,
2565
+ component: metadata.component,
2566
+ path: relativePath
2567
+ });
2568
+ }
2569
+ /**
2570
+ * Converts absolute path to relative path.
2571
+ *
2572
+ * @param {string} absolutePath - Absolute file path
2573
+ * @returns {string} Relative path
2574
+ */
2575
+ toRelativePath(absolutePath) {
2576
+ if (absolutePath.startsWith("/")) {
2577
+ const parts = absolutePath.split("/");
2578
+ const rootIndex = parts.findIndex(
2579
+ (p) => p === "src" || p === "app" || p === "components"
2580
+ );
2581
+ if (rootIndex > 0) {
2582
+ return parts.slice(rootIndex).join("/");
2583
+ }
2584
+ }
2585
+ return absolutePath;
2586
+ }
2587
+ /**
2588
+ * Computes checksum of the tokens object.
2589
+ *
2590
+ * @param {Record<string, TokenData>} tokens - Tokens object
2591
+ * @returns {string} SHA-256 checksum
2592
+ */
2593
+ computeChecksum(tokens) {
2594
+ const sortedKeys = Object.keys(tokens).sort();
2595
+ const sortedTokens = {};
2596
+ for (const key of sortedKeys) {
2597
+ sortedTokens[key] = tokens[key];
2598
+ }
2599
+ const content = JSON.stringify(sortedTokens);
2600
+ return (0, import_crypto.createHash)("sha256").update(content).digest("hex");
2601
+ }
2602
+ /**
2603
+ * Builds the final recovery manifest.
2604
+ *
2605
+ * @returns {RecoveryManifest} The complete recovery manifest
2606
+ *
2607
+ * @example
2608
+ * ```typescript
2609
+ * const manifest = builder.build();
2610
+ * // Returns: { buildId: 'abc123', checksum: '...', tokens: {...} }
2611
+ * ```
2612
+ */
2613
+ build() {
2614
+ const tokensObject = {};
2615
+ for (const [token, data] of this.tokens.entries()) {
2616
+ tokensObject[token] = data;
2617
+ }
2618
+ const checksum = this.computeChecksum(tokensObject);
2619
+ return {
2620
+ buildId: this.buildId,
2621
+ checksum,
2622
+ tokens: tokensObject
2623
+ };
2624
+ }
2625
+ /**
2626
+ * Gets the number of tokens in the manifest.
2627
+ *
2628
+ * @returns {number} Token count
2629
+ */
2630
+ size() {
2631
+ return this.tokens.size;
2632
+ }
2633
+ /**
2634
+ * Checks if a token exists in the manifest.
2635
+ *
2636
+ * @param {string} token - Token to check
2637
+ * @returns {boolean} True if token exists
2638
+ */
2639
+ hasToken(token) {
2640
+ return this.tokens.has(token);
2641
+ }
2642
+ /**
2643
+ * Clears all tokens from the manifest.
2644
+ */
2645
+ clear() {
2646
+ this.tokens.clear();
2647
+ }
2648
+ };
2649
+ function serializeManifest(manifest, pretty = false) {
2650
+ return JSON.stringify(manifest, null, pretty ? 2 : 0);
2651
+ }
2652
+ function parseManifest(json) {
2653
+ const parsed = JSON.parse(json);
2654
+ if (!parsed.buildId || !parsed.checksum || !parsed.tokens) {
2655
+ throw new Error("Invalid recovery manifest format");
2656
+ }
2657
+ return parsed;
2658
+ }
2659
+ function validateManifest(manifest) {
2660
+ if (!manifest || typeof manifest !== "object") {
2661
+ return { valid: false, error: "Manifest must be an object" };
2662
+ }
2663
+ const m = manifest;
2664
+ if (typeof m.buildId !== "string") {
2665
+ return { valid: false, error: "buildId must be a string" };
2666
+ }
2667
+ if (typeof m.checksum !== "string") {
2668
+ return { valid: false, error: "checksum must be a string" };
2669
+ }
2670
+ if (!m.tokens || typeof m.tokens !== "object") {
2671
+ return { valid: false, error: "tokens must be an object" };
2672
+ }
2673
+ return { valid: true };
2674
+ }
2675
+
2676
+ // src/hoisting.ts
2677
+ var t2 = __toESM(require("@babel/types"), 1);
2678
+ function findLCA(nodeA, nodeB, parentMap) {
2679
+ const ancestorsA = /* @__PURE__ */ new Set();
2680
+ let current = nodeA;
2681
+ while (current) {
2682
+ ancestorsA.add(current);
2683
+ current = parentMap.get(current);
2684
+ }
2685
+ current = nodeB;
2686
+ while (current) {
2687
+ if (ancestorsA.has(current) && t2.isJSXOpeningElement(current) && current !== nodeA && current !== nodeB) {
2688
+ return current;
2689
+ }
2690
+ current = parentMap.get(current);
2691
+ }
2692
+ return null;
2693
+ }
2694
+ function isFragment(node) {
2695
+ if (t2.isJSXIdentifier(node.name)) {
2696
+ return node.name.name === "Fragment";
2697
+ }
2698
+ if (t2.isJSXMemberExpression(node.name)) {
2699
+ return t2.isJSXIdentifier(node.name.property) && node.name.property.name === "Fragment";
2700
+ }
2701
+ return false;
2702
+ }
2703
+ function removeStyleVar(element, varName) {
2704
+ for (const attr of element.attributes) {
2705
+ if (!t2.isJSXAttribute(attr)) {
2706
+ continue;
2707
+ }
2708
+ if (!t2.isJSXIdentifier(attr.name) || attr.name.name !== "style") {
2709
+ continue;
2710
+ }
2711
+ if (!t2.isJSXExpressionContainer(attr.value)) {
2712
+ continue;
2713
+ }
2714
+ const styleObj = attr.value.expression;
2715
+ if (!t2.isObjectExpression(styleObj)) {
2716
+ continue;
2717
+ }
2718
+ styleObj.properties = styleObj.properties.filter((prop) => {
2719
+ if (!t2.isObjectProperty(prop)) {
2720
+ return true;
2721
+ }
2722
+ if (t2.isStringLiteral(prop.key)) {
2723
+ return prop.key.value !== varName;
2724
+ }
2725
+ return true;
2726
+ });
2727
+ if (styleObj.properties.length === 0) {
2728
+ const idx = element.attributes.indexOf(attr);
2729
+ if (idx !== -1) {
2730
+ element.attributes.splice(idx, 1);
2731
+ }
2732
+ }
2733
+ break;
2734
+ }
2735
+ }
2736
+ function addStyleVar(element, varName, valueExpr) {
2737
+ for (const attr of element.attributes) {
2738
+ if (!t2.isJSXAttribute(attr)) {
2739
+ continue;
2740
+ }
2741
+ if (!t2.isJSXIdentifier(attr.name) || attr.name.name !== "style") {
2742
+ continue;
2743
+ }
2744
+ if (!t2.isJSXExpressionContainer(attr.value)) {
2745
+ continue;
2746
+ }
2747
+ const styleObj = attr.value.expression;
2748
+ if (!t2.isObjectExpression(styleObj)) {
2749
+ continue;
2750
+ }
2751
+ const existing = styleObj.properties.find(
2752
+ (prop) => t2.isObjectProperty(prop) && t2.isStringLiteral(prop.key) && prop.key.value === varName
2753
+ );
2754
+ if (!existing) {
2755
+ styleObj.properties.push(
2756
+ t2.objectProperty(t2.stringLiteral(varName), valueExpr)
2757
+ );
2758
+ }
2759
+ return;
2760
+ }
2761
+ element.attributes.push(
2762
+ t2.jsxAttribute(
2763
+ t2.jsxIdentifier("style"),
2764
+ t2.jsxExpressionContainer(
2765
+ t2.objectExpression([
2766
+ t2.objectProperty(t2.stringLiteral(varName), valueExpr)
2767
+ ])
2768
+ )
2769
+ )
2770
+ );
2771
+ }
2772
+ function hoistCSSVariables(usages, parentMap) {
2773
+ if (usages.length < 2) {
2774
+ return;
2775
+ }
2776
+ const groups = /* @__PURE__ */ new Map();
2777
+ for (const usage of usages) {
2778
+ if (usage.serializedValue === null) {
2779
+ continue;
2780
+ }
2781
+ const groupKey = `${usage.varName}::${usage.serializedValue}`;
2782
+ const group = groups.get(groupKey) || [];
2783
+ group.push(usage);
2784
+ groups.set(groupKey, group);
2785
+ }
2786
+ for (const [, group] of groups) {
2787
+ if (group.length < 2) {
2788
+ continue;
2789
+ }
2790
+ let lca = group[0].element;
2791
+ for (let i = 1; i < group.length; i++) {
2792
+ const newLca = findLCA(lca, group[i].element, parentMap);
2793
+ if (newLca === null || isFragment(newLca)) {
2794
+ lca = null;
2795
+ break;
2796
+ }
2797
+ lca = newLca;
2798
+ }
2799
+ if (!lca) {
2800
+ continue;
2801
+ }
2802
+ addStyleVar(lca, group[0].varName, group[0].valueExpr);
2803
+ for (const usage of group) {
2804
+ removeStyleVar(usage.element, usage.varName);
2805
+ }
2806
+ }
2807
+ }
2808
+ function buildParentMap(ast) {
2809
+ const map = /* @__PURE__ */ new Map();
2810
+ function traverse(node, parent) {
2811
+ if (parent) {
2812
+ map.set(node, parent);
2813
+ }
2814
+ for (const key of Object.keys(node)) {
2815
+ const value = node[key];
2816
+ if (value && typeof value === "object") {
2817
+ if (Array.isArray(value)) {
2818
+ for (const item of value) {
2819
+ if (item && typeof item === "object" && "type" in item) {
2820
+ traverse(item, node);
2821
+ }
2822
+ }
2823
+ } else if ("type" in value) {
2824
+ traverse(value, node);
2825
+ }
2826
+ }
2827
+ }
2828
+ }
2829
+ traverse(ast);
2830
+ return map;
2831
+ }
2832
+
2833
+ // src/index.ts
2834
+ var VERSION = "0.0.0";
2835
+ var DEFAULT_COMPILER_OPTIONS = {
2836
+ buildId: Date.now().toString(),
2837
+ development: process.env.NODE_ENV !== "production",
2838
+ autoInjectRecovery: false,
2839
+ strictMode: false
2840
+ };
2841
+ function mergeOptions(options = {}) {
2842
+ return {
2843
+ ...DEFAULT_COMPILER_OPTIONS,
2844
+ ...options
2845
+ };
2846
+ }
2847
+ // Annotate the CommonJS export names for ESM import in node:
2848
+ 0 && (module.exports = {
2849
+ COLOR_PROPERTIES,
2850
+ CsszyxCompiler,
2851
+ DEFAULT_COMPILER_OPTIONS,
2852
+ ManifestBuilder,
2853
+ PROPERTY_CATEGORY_MAP,
2854
+ PropertyCategory,
2855
+ VERSION,
2856
+ buildParentMap,
2857
+ createRecoveryToken,
2858
+ generateRecoveryToken,
2859
+ getCSSVariableName,
2860
+ getPropertyCategory,
2861
+ hoistCSSVariables,
2862
+ injectRecoveryToken,
2863
+ isValidRecoveryMode,
2864
+ isValidSzProp,
2865
+ mergeOptions,
2866
+ normalizeClassName,
2867
+ parseManifest,
2868
+ serializeManifest,
2869
+ transform,
2870
+ transformSourceCode,
2871
+ validateManifest,
2872
+ validateSzRecover
2873
+ });