tailwind-styled-v4 5.1.12 → 5.1.13

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.mjs CHANGED
@@ -224,22 +224,27 @@ if (typeof window !== "undefined") {
224
224
  window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
225
225
  }
226
226
  var _hashContainerCache = /* @__PURE__ */ new Map();
227
+ function _fnvHash6(s) {
228
+ let h = 2166136261;
229
+ for (let i = 0; i < s.length; i++) {
230
+ h ^= s.charCodeAt(i);
231
+ h = Math.imul(h, 16777619) >>> 0;
232
+ }
233
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
234
+ }
227
235
  function hashContainer(tag, container, name) {
228
236
  const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
229
237
  const cached = _hashContainerCache.get(sortedKey);
230
238
  if (cached) return cached;
231
239
  const native = getNativeBinding();
232
- if (!native?.hashContent) {
233
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
234
- }
235
- const id = `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
240
+ const id = native?.hashContent ? `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-cq-${_fnvHash6(sortedKey)}`;
236
241
  _hashContainerCache.set(sortedKey, id);
237
242
  return id;
238
243
  }
239
244
  function layoutClassesToCss(classes) {
240
245
  const native = getNativeBinding();
241
246
  if (!native?.layoutClassesToCss) {
242
- throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
247
+ return "";
243
248
  }
244
249
  return native.layoutClassesToCss(classes);
245
250
  }
@@ -400,96 +405,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
400
405
  var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
401
406
  var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
402
407
  var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
403
- function conflictGroup(base) {
404
- const bracket = base.indexOf("[");
408
+ function conflictGroup(base, prefix = "") {
409
+ const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
410
+ const bracket = b.indexOf("[");
405
411
  if (bracket !== -1) {
406
- const prefix = base.slice(0, bracket).replace(/-+$/, "");
407
- return prefix.length > 0 ? prefix : "arbitrary";
408
- }
409
- if (DISPLAY_VALUES.has(base)) return "display";
410
- if (POSITION_VALUES.has(base)) return "position";
411
- if (base.startsWith("overflow-x-")) return "overflow-x";
412
- if (base.startsWith("overflow-y-")) return "overflow-y";
413
- if (base.startsWith("overflow-")) return "overflow";
414
- if (base.startsWith("flex-")) return "flex";
415
- if (base.startsWith("grid-cols-")) return "grid-cols";
416
- if (base.startsWith("grid-rows-")) return "grid-rows";
417
- if (base.startsWith("grid-flow-")) return "grid-flow";
418
- if (base.startsWith("col-")) return "col";
419
- if (base.startsWith("row-")) return "row";
420
- if (base === "grow" || base.startsWith("grow-")) return "grow";
421
- if (base === "shrink" || base.startsWith("shrink-")) return "shrink";
422
- if (base.startsWith("gap-x-")) return "gap-x";
423
- if (base.startsWith("gap-y-")) return "gap-y";
424
- if (base.startsWith("gap-")) return "gap";
425
- if (base.startsWith("justify-items-")) return "justify-items";
426
- if (base.startsWith("justify-self-")) return "justify-self";
427
- if (base.startsWith("justify-")) return "justify";
428
- if (base.startsWith("items-")) return "items";
429
- if (base.startsWith("self-")) return "self";
430
- if (base.startsWith("place-content-")) return "place-content";
431
- if (base.startsWith("place-items-")) return "place-items";
432
- if (base.startsWith("place-self-")) return "place-self";
433
- if (base.startsWith("content-")) return "content";
434
- if (base.startsWith("px-")) return "px";
435
- if (base.startsWith("py-")) return "py";
436
- if (base.startsWith("pt-")) return "pt";
437
- if (base.startsWith("pr-")) return "pr";
438
- if (base.startsWith("pb-")) return "pb";
439
- if (base.startsWith("pl-")) return "pl";
440
- if (base.startsWith("ps-")) return "ps";
441
- if (base.startsWith("pe-")) return "pe";
442
- if (base.startsWith("p-")) return "p";
443
- if (base.startsWith("mx-")) return "mx";
444
- if (base.startsWith("my-")) return "my";
445
- if (base.startsWith("mt-")) return "mt";
446
- if (base.startsWith("mr-")) return "mr";
447
- if (base.startsWith("mb-")) return "mb";
448
- if (base.startsWith("ml-")) return "ml";
449
- if (base.startsWith("ms-")) return "ms";
450
- if (base.startsWith("me-")) return "me";
451
- if (base === "-m" || base.startsWith("m-") || base.startsWith("-m-")) return "m";
452
- if (base.startsWith("space-x-")) return "space-x";
453
- if (base.startsWith("space-y-")) return "space-y";
454
- if (base.startsWith("size-")) return "size";
455
- if (base.startsWith("min-w-")) return "min-w";
456
- if (base.startsWith("max-w-")) return "max-w";
457
- if (base.startsWith("w-")) return "w";
458
- if (base.startsWith("min-h-")) return "min-h";
459
- if (base.startsWith("max-h-")) return "max-h";
460
- if (base.startsWith("h-")) return "h";
461
- if (base.startsWith("inset-x-")) return "inset-x";
462
- if (base.startsWith("inset-y-")) return "inset-y";
463
- if (base.startsWith("inset-")) return "inset";
464
- if (base.startsWith("top-")) return "top";
465
- if (base.startsWith("right-") || base.startsWith("end-")) return "right";
466
- if (base.startsWith("bottom-")) return "bottom";
467
- if (base.startsWith("left-") || base.startsWith("start-")) return "left";
468
- if (base.startsWith("z-")) return "z";
469
- if (base.startsWith("opacity-")) return "opacity";
470
- if (base.startsWith("bg-")) {
471
- if (base.startsWith("bg-opacity-")) return "bg-opacity";
412
+ const grp = b.slice(0, bracket).replace(/-+$/, "");
413
+ return grp.length > 0 ? grp : "arbitrary";
414
+ }
415
+ if (DISPLAY_VALUES.has(b)) return "display";
416
+ if (POSITION_VALUES.has(b)) return "position";
417
+ if (b.startsWith("overflow-x-")) return "overflow-x";
418
+ if (b.startsWith("overflow-y-")) return "overflow-y";
419
+ if (b.startsWith("overflow-")) return "overflow";
420
+ if (b.startsWith("flex-")) return "flex";
421
+ if (b.startsWith("grid-cols-")) return "grid-cols";
422
+ if (b.startsWith("grid-rows-")) return "grid-rows";
423
+ if (b.startsWith("grid-flow-")) return "grid-flow";
424
+ if (b.startsWith("col-")) return "col";
425
+ if (b.startsWith("row-")) return "row";
426
+ if (b === "grow" || b.startsWith("grow-")) return "grow";
427
+ if (b === "shrink" || b.startsWith("shrink-")) return "shrink";
428
+ if (b.startsWith("gap-x-")) return "gap-x";
429
+ if (b.startsWith("gap-y-")) return "gap-y";
430
+ if (b.startsWith("gap-")) return "gap";
431
+ if (b.startsWith("justify-items-")) return "justify-items";
432
+ if (b.startsWith("justify-self-")) return "justify-self";
433
+ if (b.startsWith("justify-")) return "justify";
434
+ if (b.startsWith("items-")) return "items";
435
+ if (b.startsWith("self-")) return "self";
436
+ if (b.startsWith("place-content-")) return "place-content";
437
+ if (b.startsWith("place-items-")) return "place-items";
438
+ if (b.startsWith("place-self-")) return "place-self";
439
+ if (b.startsWith("content-")) return "content";
440
+ if (b.startsWith("px-")) return "px";
441
+ if (b.startsWith("py-")) return "py";
442
+ if (b.startsWith("pt-")) return "pt";
443
+ if (b.startsWith("pr-")) return "pr";
444
+ if (b.startsWith("pb-")) return "pb";
445
+ if (b.startsWith("pl-")) return "pl";
446
+ if (b.startsWith("ps-")) return "ps";
447
+ if (b.startsWith("pe-")) return "pe";
448
+ if (b.startsWith("p-")) return "p";
449
+ if (b.startsWith("mx-")) return "mx";
450
+ if (b.startsWith("my-")) return "my";
451
+ if (b.startsWith("mt-")) return "mt";
452
+ if (b.startsWith("mr-")) return "mr";
453
+ if (b.startsWith("mb-")) return "mb";
454
+ if (b.startsWith("ml-")) return "ml";
455
+ if (b.startsWith("ms-")) return "ms";
456
+ if (b.startsWith("me-")) return "me";
457
+ if (b === "-m" || b.startsWith("m-") || b.startsWith("-m-")) return "m";
458
+ if (b.startsWith("space-x-")) return "space-x";
459
+ if (b.startsWith("space-y-")) return "space-y";
460
+ if (b.startsWith("size-")) return "size";
461
+ if (b.startsWith("min-w-")) return "min-w";
462
+ if (b.startsWith("max-w-")) return "max-w";
463
+ if (b.startsWith("w-")) return "w";
464
+ if (b.startsWith("min-h-")) return "min-h";
465
+ if (b.startsWith("max-h-")) return "max-h";
466
+ if (b.startsWith("h-")) return "h";
467
+ if (b.startsWith("inset-x-")) return "inset-x";
468
+ if (b.startsWith("inset-y-")) return "inset-y";
469
+ if (b.startsWith("inset-")) return "inset";
470
+ if (b.startsWith("top-")) return "top";
471
+ if (b.startsWith("right-") || b.startsWith("end-")) return "right";
472
+ if (b.startsWith("bottom-")) return "bottom";
473
+ if (b.startsWith("left-") || b.startsWith("start-")) return "left";
474
+ if (b.startsWith("z-")) return "z";
475
+ if (b.startsWith("opacity-")) return "opacity";
476
+ if (b.startsWith("bg-")) {
477
+ if (b.startsWith("bg-opacity-")) return "bg-opacity";
472
478
  return "bg";
473
479
  }
474
- if (base.startsWith("from-")) return "from";
475
- if (base.startsWith("via-")) return "via";
476
- if (base.startsWith("to-")) return "to";
477
- if (base.startsWith("text-")) {
478
- const suffix = base.slice("text-".length);
480
+ if (b.startsWith("from-")) return "from";
481
+ if (b.startsWith("via-")) return "via";
482
+ if (b.startsWith("to-")) return "to";
483
+ if (b.startsWith("text-")) {
484
+ const suffix = b.slice("text-".length);
479
485
  if (isTextSize(suffix)) return "text-size";
480
486
  if (suffix.startsWith("opacity-")) return "text-opacity";
481
487
  if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
482
488
  return "text-color";
483
489
  }
484
- if (base.startsWith("font-")) {
485
- const suffix = base.slice("font-".length);
490
+ if (b.startsWith("font-")) {
491
+ const suffix = b.slice("font-".length);
486
492
  if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
487
493
  return "font-family";
488
494
  }
489
- if (base.startsWith("leading-")) return "leading";
490
- if (base.startsWith("tracking-")) return "tracking";
491
- if (base.startsWith("border-")) {
492
- const suffix = base.slice("border-".length);
495
+ if (b.startsWith("leading-")) return "leading";
496
+ if (b.startsWith("tracking-")) return "tracking";
497
+ if (b.startsWith("border-")) {
498
+ const suffix = b.slice("border-".length);
493
499
  const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
494
500
  if (sidePrefix) {
495
501
  const side = suffix.slice(0, 1);
@@ -503,67 +509,67 @@ function conflictGroup(base) {
503
509
  if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
504
510
  return "border-color";
505
511
  }
506
- if (base === "border") return "border-width";
507
- if (base.startsWith("outline-")) return "outline";
508
- if (base === "outline") return "outline";
509
- if (base.startsWith("rounded-t") || base.startsWith("rounded-r") || base.startsWith("rounded-b") || base.startsWith("rounded-l") || base.startsWith("rounded-s") || base.startsWith("rounded-e")) {
510
- const firstChar = base.slice("rounded-".length).charAt(0) || "x";
512
+ if (b === "border") return "border-width";
513
+ if (b.startsWith("outline-")) return "outline";
514
+ if (b === "outline") return "outline";
515
+ if (b.startsWith("rounded-t") || b.startsWith("rounded-r") || b.startsWith("rounded-b") || b.startsWith("rounded-l") || b.startsWith("rounded-s") || b.startsWith("rounded-e")) {
516
+ const firstChar = b.slice("rounded-".length).charAt(0) || "x";
511
517
  return `rounded-${firstChar}`;
512
518
  }
513
- if (base === "rounded" || base.startsWith("rounded-")) return "rounded";
514
- if (base === "shadow" || base.startsWith("shadow-")) return "shadow";
515
- if (base.startsWith("ring-offset-")) return "ring-offset";
516
- if (base === "ring") return "ring-width";
517
- if (base.startsWith("ring-")) {
518
- const rest = base.slice("ring-".length);
519
+ if (b === "rounded" || b.startsWith("rounded-")) return "rounded";
520
+ if (b === "shadow" || b.startsWith("shadow-")) return "shadow";
521
+ if (b.startsWith("ring-offset-")) return "ring-offset";
522
+ if (b === "ring") return "ring-width";
523
+ if (b.startsWith("ring-")) {
524
+ const rest = b.slice("ring-".length);
519
525
  const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
520
526
  if (isWidth) return "ring-width";
521
527
  if (rest === "inset") return "ring-inset";
522
528
  return "ring-color";
523
529
  }
524
- if (base.startsWith("rotate-")) return "rotate";
525
- if (base.startsWith("scale-x-")) return "scale-x";
526
- if (base.startsWith("scale-y-")) return "scale-y";
527
- if (base.startsWith("scale-")) return "scale";
528
- if (base.startsWith("translate-x-")) return "translate-x";
529
- if (base.startsWith("translate-y-")) return "translate-y";
530
- if (base.startsWith("skew-x-")) return "skew-x";
531
- if (base.startsWith("skew-y-")) return "skew-y";
532
- if (base === "transition" || base.startsWith("transition-")) return "transition";
533
- if (base.startsWith("duration-")) return "duration";
534
- if (base.startsWith("ease-")) return "ease";
535
- if (base.startsWith("delay-")) return "delay";
536
- if (base === "animate" || base.startsWith("animate-")) return "animate";
537
- if (base.startsWith("cursor-")) return "cursor";
538
- if (base.startsWith("pointer-events-")) return "pointer-events";
539
- if (base.startsWith("select-")) return "select";
540
- if (base === "visible" || base === "invisible" || base === "collapse") return "visibility";
541
- if (base.startsWith("object-")) return "object";
542
- if (base.startsWith("aspect-")) return "aspect";
543
- if (base.startsWith("order-")) return "order";
544
- if (base.startsWith("whitespace-")) return "whitespace";
545
- if (base.startsWith("list-")) return "list";
546
- if (base.startsWith("fill-")) return "fill";
547
- if (base.startsWith("stroke-")) return "stroke";
548
- if (base.startsWith("backdrop-")) {
549
- const rest = base.slice("backdrop-".length);
530
+ if (b.startsWith("rotate-")) return "rotate";
531
+ if (b.startsWith("scale-x-")) return "scale-x";
532
+ if (b.startsWith("scale-y-")) return "scale-y";
533
+ if (b.startsWith("scale-")) return "scale";
534
+ if (b.startsWith("translate-x-")) return "translate-x";
535
+ if (b.startsWith("translate-y-")) return "translate-y";
536
+ if (b.startsWith("skew-x-")) return "skew-x";
537
+ if (b.startsWith("skew-y-")) return "skew-y";
538
+ if (b === "transition" || b.startsWith("transition-")) return "transition";
539
+ if (b.startsWith("duration-")) return "duration";
540
+ if (b.startsWith("ease-")) return "ease";
541
+ if (b.startsWith("delay-")) return "delay";
542
+ if (b === "animate" || b.startsWith("animate-")) return "animate";
543
+ if (b.startsWith("cursor-")) return "cursor";
544
+ if (b.startsWith("pointer-events-")) return "pointer-events";
545
+ if (b.startsWith("select-")) return "select";
546
+ if (b === "visible" || b === "invisible" || b === "collapse") return "visibility";
547
+ if (b.startsWith("object-")) return "object";
548
+ if (b.startsWith("aspect-")) return "aspect";
549
+ if (b.startsWith("order-")) return "order";
550
+ if (b.startsWith("whitespace-")) return "whitespace";
551
+ if (b.startsWith("list-")) return "list";
552
+ if (b.startsWith("fill-")) return "fill";
553
+ if (b.startsWith("stroke-")) return "stroke";
554
+ if (b.startsWith("backdrop-")) {
555
+ const rest = b.slice("backdrop-".length);
550
556
  const seg = rest.split("-")[0] || "x";
551
557
  return `backdrop-${seg}`;
552
558
  }
553
- if (base.startsWith("scroll-")) return "scroll";
554
- if (base.startsWith("snap-")) return "snap";
555
- if (base.startsWith("touch-")) return "touch";
556
- if (base.startsWith("decoration-")) return "text-decoration";
557
- if (base.startsWith("caret-")) return "caret";
558
- if (base.startsWith("accent-")) return "accent";
559
- if (base.startsWith("appearance-")) return "appearance";
560
- if (base === "isolate" || base === "isolation-auto") return "isolation";
561
- if (base.startsWith("mix-blend-")) return "mix-blend";
562
- if (base.startsWith("bg-blend-")) return "bg-blend";
563
- if (base.startsWith("float-")) return "float";
564
- if (base.startsWith("clear-")) return "clear";
565
- if (base.startsWith("break-")) return "break";
566
- if (base.startsWith("columns-")) return "columns";
559
+ if (b.startsWith("scroll-")) return "scroll";
560
+ if (b.startsWith("snap-")) return "snap";
561
+ if (b.startsWith("touch-")) return "touch";
562
+ if (b.startsWith("decoration-")) return "text-decoration";
563
+ if (b.startsWith("caret-")) return "caret";
564
+ if (b.startsWith("accent-")) return "accent";
565
+ if (b.startsWith("appearance-")) return "appearance";
566
+ if (b === "isolate" || b === "isolation-auto") return "isolation";
567
+ if (b.startsWith("mix-blend-")) return "mix-blend";
568
+ if (b.startsWith("bg-blend-")) return "bg-blend";
569
+ if (b.startsWith("float-")) return "float";
570
+ if (b.startsWith("clear-")) return "clear";
571
+ if (b.startsWith("break-")) return "break";
572
+ if (b.startsWith("columns-")) return "columns";
567
573
  return null;
568
574
  }
569
575
  function splitVariants(klass) {
@@ -578,7 +584,7 @@ function splitVariants(klass) {
578
584
  if (lastColon === 0) return ["", klass];
579
585
  return [klass.slice(0, lastColon), klass.slice(lastColon)];
580
586
  }
581
- function mergeClassStringJs(input) {
587
+ function mergeClassStringJs(input, prefix = "") {
582
588
  const tokens = input.split(/\s+/).filter(Boolean);
583
589
  if (tokens.length === 0) return "";
584
590
  if (tokens.length === 1) return tokens[0];
@@ -586,7 +592,7 @@ function mergeClassStringJs(input) {
586
592
  const slots = [];
587
593
  for (const token of tokens) {
588
594
  const [variants, base] = splitVariants(token);
589
- const group = conflictGroup(base);
595
+ const group = conflictGroup(base, prefix);
590
596
  if (group !== null) {
591
597
  const key = `${variants}::${group}`;
592
598
  const prevIdx = groupOwner.get(key);
@@ -599,10 +605,10 @@ function mergeClassStringJs(input) {
599
605
  }
600
606
  return slots.filter((s) => s !== null).join(" ");
601
607
  }
602
- function twMergeRawJs(classLists) {
608
+ function twMergeRawJs(classLists, prefix = "") {
603
609
  const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
604
610
  if (joined.length === 0) return "";
605
- return mergeClassStringJs(joined);
611
+ return mergeClassStringJs(joined, prefix);
606
612
  }
607
613
 
608
614
  // packages/domain/core/src/merge.ts
@@ -617,6 +623,7 @@ function warnFallbackOnce() {
617
623
  }
618
624
  }
619
625
  function createTwMerge(options = {}) {
626
+ const prefix = options.prefix ?? "";
620
627
  return function twMerge2(...classLists) {
621
628
  const inputs = [];
622
629
  for (let i = 0; i < classLists.length; i++) {
@@ -625,11 +632,16 @@ function createTwMerge(options = {}) {
625
632
  }
626
633
  if (inputs.length === 0) return "";
627
634
  const native = getNativeBinding();
628
- if (native?.twMergeRaw) {
629
- return native.twMergeRaw(inputs);
635
+ if (native) {
636
+ if (prefix && native.twMergeRawWithOptions) {
637
+ return native.twMergeRawWithOptions(inputs, { prefix });
638
+ }
639
+ if (native.twMergeRaw) {
640
+ return native.twMergeRaw(inputs);
641
+ }
630
642
  }
631
643
  warnFallbackOnce();
632
- return twMergeRawJs(inputs);
644
+ return twMergeRawJs(inputs, prefix);
633
645
  };
634
646
  }
635
647
  var twMerge = createTwMerge();
@@ -642,6 +654,37 @@ function mergeWithRules(rules, ...classLists) {
642
654
  return classes.join(" ");
643
655
  }
644
656
 
657
+ // packages/domain/core/src/parseTemplateFallback.ts
658
+ init_esm_shims();
659
+ var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
660
+ var COMMENT_RE = /\/\/[^\n]*/g;
661
+ function collapseSpaces(s) {
662
+ return s.replace(/\s+/g, " ").trim();
663
+ }
664
+ function cleanBlock(raw) {
665
+ const noComments = raw.replace(COMMENT_RE, "");
666
+ const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
667
+ return collapseSpaces(lines.join(" "));
668
+ }
669
+ function parseTemplateJs(raw) {
670
+ const subs = {};
671
+ let base = raw;
672
+ for (const match of raw.matchAll(SUB_RE)) {
673
+ const fullMatch = match[0];
674
+ const name = match[1] ?? match[2] ?? "";
675
+ const innerRaw = match[3] ?? "";
676
+ if (name) {
677
+ subs[name] = cleanBlock(innerRaw);
678
+ }
679
+ base = base.replace(fullMatch, "");
680
+ }
681
+ return {
682
+ base: collapseSpaces(base),
683
+ subs,
684
+ hasSubs: Object.keys(subs).length > 0
685
+ };
686
+ }
687
+
645
688
  // packages/domain/core/src/stateEngine.ts
646
689
  init_esm_shims();
647
690
  var stateRegistry = /* @__PURE__ */ new Map();
@@ -649,22 +692,27 @@ if (typeof window !== "undefined") {
649
692
  window.__TW_STATE_REGISTRY__ = stateRegistry;
650
693
  }
651
694
  var _hashStateCache = /* @__PURE__ */ new Map();
695
+ function _fnvHash62(s) {
696
+ let h = 2166136261;
697
+ for (let i = 0; i < s.length; i++) {
698
+ h ^= s.charCodeAt(i);
699
+ h = Math.imul(h, 16777619) >>> 0;
700
+ }
701
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
702
+ }
652
703
  function hashState(tag, state) {
653
704
  const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
654
705
  const cached = _hashStateCache.get(sortedKey);
655
706
  if (cached) return cached;
656
707
  const native = getNativeBinding();
657
- if (!native?.hashContent) {
658
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
659
- }
660
- const id = `tw-s-${native.hashContent(sortedKey, "fnv", 6)}`;
708
+ const id = native?.hashContent ? `tw-s-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-s-${_fnvHash62(sortedKey)}`;
661
709
  _hashStateCache.set(sortedKey, id);
662
710
  return id;
663
711
  }
664
712
  function generateStateRules(id, state) {
665
713
  const native = getNativeBinding();
666
714
  if (!native?.generateRuntimeStateCss) {
667
- throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
715
+ return [];
668
716
  }
669
717
  return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
670
718
  }
@@ -752,7 +800,13 @@ function _getParsedTemplate(template) {
752
800
  }
753
801
  const native = getNativeBinding();
754
802
  if (!native?.parseSubcomponentBlocksNapi) {
755
- throw new Error("FATAL: Native binding 'parseSubcomponentBlocksNapi' is required but not available.");
803
+ const fb = parseTemplateJs(template);
804
+ const result2 = {
805
+ baseClasses: fb.base,
806
+ subMap: new Map(Object.entries(fb.subs))
807
+ };
808
+ _templateParseCache.set(template, result2);
809
+ return result2;
756
810
  }
757
811
  const r = native.parseSubcomponentBlocksNapi(template, "tw");
758
812
  const raw = JSON.parse(r.subMapJson);
@@ -904,10 +958,16 @@ function resolveVariants(variants, props, defaults) {
904
958
  }
905
959
  const binding = getNativeBinding();
906
960
  if (!binding?.resolveSimpleVariants) {
907
- throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
961
+ const classes = [];
962
+ for (const key of Object.keys(variants)) {
963
+ const propValue = cleanProps[key] ?? defaults[key];
964
+ if (propValue !== void 0 && variants[key]?.[propValue]) {
965
+ classes.push(variants[key][propValue]);
966
+ }
967
+ }
968
+ return classes.join(" ").trim().replace(/\s+/g, " ");
908
969
  }
909
- const result = binding.resolveSimpleVariants(null, variants, defaults, cleanProps);
910
- return result.trim().replace(/\s+/g, " ");
970
+ return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
911
971
  }
912
972
  function resolveStates(statesConfig, stateKeys, statesLookup, props) {
913
973
  if (statesLookup && stateKeys.length > 0) {
@@ -1119,49 +1179,8 @@ function wrapWithSubProxy(component, tagLabel) {
1119
1179
  });
1120
1180
  }
1121
1181
 
1122
- // packages/domain/core/src/parseTemplateFallback.ts
1123
- init_esm_shims();
1124
- var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
1125
- var COMMENT_RE = /\/\/[^\n]*/g;
1126
- function collapseSpaces(s) {
1127
- return s.replace(/\s+/g, " ").trim();
1128
- }
1129
- function cleanBlock(raw) {
1130
- const noComments = raw.replace(COMMENT_RE, "");
1131
- const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
1132
- return collapseSpaces(lines.join(" "));
1133
- }
1134
- function parseTemplateJs(raw) {
1135
- const subs = {};
1136
- let base = raw;
1137
- for (const match of raw.matchAll(SUB_RE)) {
1138
- const fullMatch = match[0];
1139
- const name = match[1] ?? match[2] ?? "";
1140
- const innerRaw = match[3] ?? "";
1141
- if (name) {
1142
- subs[name] = cleanBlock(innerRaw);
1143
- }
1144
- base = base.replace(fullMatch, "");
1145
- }
1146
- return {
1147
- base: cleanBlock(base),
1148
- subs,
1149
- hasSubs: Object.keys(subs).length > 0
1150
- };
1151
- }
1152
-
1153
1182
  // packages/domain/core/src/twProxy.ts
1154
1183
  var _parsedTemplateCache = /* @__PURE__ */ new Map();
1155
- var warnedParseTemplateFallback = false;
1156
- function warnParseTemplateFallbackOnce() {
1157
- if (warnedParseTemplateFallback) return;
1158
- warnedParseTemplateFallback = true;
1159
- if (typeof console !== "undefined") {
1160
- console.warn(
1161
- "[tailwind-styled-v4] Native binding 'parseTemplate' tidak tersedia (normal di browser, untuk komponen yang di-chain dengan .extend/.withVariants/.animate/.withSub) \u2014 pakai pure-TS port dari algoritma Rust-nya. Hasil tetap benar; ini cuma informasi, bukan error."
1162
- );
1163
- }
1164
- }
1165
1184
  function parseTemplate(strings, exprs) {
1166
1185
  const raw = strings.raw.reduce((acc, str, i) => {
1167
1186
  const expr = exprs[i];
@@ -1171,15 +1190,15 @@ function parseTemplate(strings, exprs) {
1171
1190
  const cached = _parsedTemplateCache.get(raw);
1172
1191
  if (cached) return cached;
1173
1192
  const binding = getNativeBinding();
1174
- let result;
1175
- if (binding?.parseTemplate) {
1176
- const r = binding.parseTemplate(raw);
1177
- const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
1178
- result = { base: r.base, subs, hasSubs: r.hasSubs };
1179
- } else {
1180
- warnParseTemplateFallbackOnce();
1181
- result = parseTemplateJs(raw);
1193
+ if (!binding?.parseTemplate) {
1194
+ const fb = parseTemplateJs(raw);
1195
+ const result2 = { base: fb.base, subs: fb.subs, hasSubs: fb.hasSubs };
1196
+ _parsedTemplateCache.set(raw, result2);
1197
+ return result2;
1182
1198
  }
1199
+ const r = binding.parseTemplate(raw);
1200
+ const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
1201
+ const result = { base: r.base, subs, hasSubs: r.hasSubs };
1183
1202
  _parsedTemplateCache.set(raw, result);
1184
1203
  return result;
1185
1204
  }
@@ -1492,19 +1511,25 @@ function cn(...inputs) {
1492
1511
  }
1493
1512
  if (strings.length === 0) return "";
1494
1513
  const native = getNativeBinding();
1495
- if (!native?.resolveClassNames) {
1514
+ if (native?.resolveClassNames) {
1515
+ return native.resolveClassNames(strings);
1516
+ }
1517
+ if (native !== null) {
1496
1518
  throw new Error("Native binding 'resolveClassNames' is required but not available.");
1497
1519
  }
1498
- return native.resolveClassNames(strings);
1520
+ return strings.filter(Boolean).join(" ");
1499
1521
  }
1500
1522
  function cx(...inputs) {
1501
1523
  const filtered = inputs.flat().filter(Boolean);
1502
1524
  if (filtered.length === 0) return "";
1503
1525
  const native = getNativeBinding();
1504
- if (!native?.twMergeMany) {
1526
+ if (native?.twMergeMany) {
1527
+ return native.twMergeMany(filtered);
1528
+ }
1529
+ if (native !== null) {
1505
1530
  throw new Error("Native binding 'twMergeMany' is required but not available.");
1506
1531
  }
1507
- return native.twMergeMany(filtered);
1532
+ return twMergeRawJs(filtered);
1508
1533
  }
1509
1534
  var cxm = cx;
1510
1535