tailwind-styled-v4 5.1.12 → 5.1.14

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.js CHANGED
@@ -290,22 +290,27 @@ if (typeof window !== "undefined") {
290
290
  window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
291
291
  }
292
292
  var _hashContainerCache = /* @__PURE__ */ new Map();
293
+ function _fnvHash6(s) {
294
+ let h = 2166136261;
295
+ for (let i = 0; i < s.length; i++) {
296
+ h ^= s.charCodeAt(i);
297
+ h = Math.imul(h, 16777619) >>> 0;
298
+ }
299
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
300
+ }
293
301
  function hashContainer(tag, container, name) {
294
302
  const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
295
303
  const cached = _hashContainerCache.get(sortedKey);
296
304
  if (cached) return cached;
297
305
  const native = getNativeBinding();
298
- if (!native?.hashContent) {
299
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
300
- }
301
- const id = `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
306
+ const id = native?.hashContent ? `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-cq-${_fnvHash6(sortedKey)}`;
302
307
  _hashContainerCache.set(sortedKey, id);
303
308
  return id;
304
309
  }
305
310
  function layoutClassesToCss(classes) {
306
311
  const native = getNativeBinding();
307
312
  if (!native?.layoutClassesToCss) {
308
- throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
313
+ return "";
309
314
  }
310
315
  return native.layoutClassesToCss(classes);
311
316
  }
@@ -466,96 +471,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
466
471
  var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
467
472
  var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
468
473
  var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
469
- function conflictGroup(base) {
470
- const bracket = base.indexOf("[");
474
+ function conflictGroup(base, prefix = "") {
475
+ const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
476
+ const bracket = b.indexOf("[");
471
477
  if (bracket !== -1) {
472
- const prefix = base.slice(0, bracket).replace(/-+$/, "");
473
- return prefix.length > 0 ? prefix : "arbitrary";
474
- }
475
- if (DISPLAY_VALUES.has(base)) return "display";
476
- if (POSITION_VALUES.has(base)) return "position";
477
- if (base.startsWith("overflow-x-")) return "overflow-x";
478
- if (base.startsWith("overflow-y-")) return "overflow-y";
479
- if (base.startsWith("overflow-")) return "overflow";
480
- if (base.startsWith("flex-")) return "flex";
481
- if (base.startsWith("grid-cols-")) return "grid-cols";
482
- if (base.startsWith("grid-rows-")) return "grid-rows";
483
- if (base.startsWith("grid-flow-")) return "grid-flow";
484
- if (base.startsWith("col-")) return "col";
485
- if (base.startsWith("row-")) return "row";
486
- if (base === "grow" || base.startsWith("grow-")) return "grow";
487
- if (base === "shrink" || base.startsWith("shrink-")) return "shrink";
488
- if (base.startsWith("gap-x-")) return "gap-x";
489
- if (base.startsWith("gap-y-")) return "gap-y";
490
- if (base.startsWith("gap-")) return "gap";
491
- if (base.startsWith("justify-items-")) return "justify-items";
492
- if (base.startsWith("justify-self-")) return "justify-self";
493
- if (base.startsWith("justify-")) return "justify";
494
- if (base.startsWith("items-")) return "items";
495
- if (base.startsWith("self-")) return "self";
496
- if (base.startsWith("place-content-")) return "place-content";
497
- if (base.startsWith("place-items-")) return "place-items";
498
- if (base.startsWith("place-self-")) return "place-self";
499
- if (base.startsWith("content-")) return "content";
500
- if (base.startsWith("px-")) return "px";
501
- if (base.startsWith("py-")) return "py";
502
- if (base.startsWith("pt-")) return "pt";
503
- if (base.startsWith("pr-")) return "pr";
504
- if (base.startsWith("pb-")) return "pb";
505
- if (base.startsWith("pl-")) return "pl";
506
- if (base.startsWith("ps-")) return "ps";
507
- if (base.startsWith("pe-")) return "pe";
508
- if (base.startsWith("p-")) return "p";
509
- if (base.startsWith("mx-")) return "mx";
510
- if (base.startsWith("my-")) return "my";
511
- if (base.startsWith("mt-")) return "mt";
512
- if (base.startsWith("mr-")) return "mr";
513
- if (base.startsWith("mb-")) return "mb";
514
- if (base.startsWith("ml-")) return "ml";
515
- if (base.startsWith("ms-")) return "ms";
516
- if (base.startsWith("me-")) return "me";
517
- if (base === "-m" || base.startsWith("m-") || base.startsWith("-m-")) return "m";
518
- if (base.startsWith("space-x-")) return "space-x";
519
- if (base.startsWith("space-y-")) return "space-y";
520
- if (base.startsWith("size-")) return "size";
521
- if (base.startsWith("min-w-")) return "min-w";
522
- if (base.startsWith("max-w-")) return "max-w";
523
- if (base.startsWith("w-")) return "w";
524
- if (base.startsWith("min-h-")) return "min-h";
525
- if (base.startsWith("max-h-")) return "max-h";
526
- if (base.startsWith("h-")) return "h";
527
- if (base.startsWith("inset-x-")) return "inset-x";
528
- if (base.startsWith("inset-y-")) return "inset-y";
529
- if (base.startsWith("inset-")) return "inset";
530
- if (base.startsWith("top-")) return "top";
531
- if (base.startsWith("right-") || base.startsWith("end-")) return "right";
532
- if (base.startsWith("bottom-")) return "bottom";
533
- if (base.startsWith("left-") || base.startsWith("start-")) return "left";
534
- if (base.startsWith("z-")) return "z";
535
- if (base.startsWith("opacity-")) return "opacity";
536
- if (base.startsWith("bg-")) {
537
- if (base.startsWith("bg-opacity-")) return "bg-opacity";
478
+ const grp = b.slice(0, bracket).replace(/-+$/, "");
479
+ return grp.length > 0 ? grp : "arbitrary";
480
+ }
481
+ if (DISPLAY_VALUES.has(b)) return "display";
482
+ if (POSITION_VALUES.has(b)) return "position";
483
+ if (b.startsWith("overflow-x-")) return "overflow-x";
484
+ if (b.startsWith("overflow-y-")) return "overflow-y";
485
+ if (b.startsWith("overflow-")) return "overflow";
486
+ if (b.startsWith("flex-")) return "flex";
487
+ if (b.startsWith("grid-cols-")) return "grid-cols";
488
+ if (b.startsWith("grid-rows-")) return "grid-rows";
489
+ if (b.startsWith("grid-flow-")) return "grid-flow";
490
+ if (b.startsWith("col-")) return "col";
491
+ if (b.startsWith("row-")) return "row";
492
+ if (b === "grow" || b.startsWith("grow-")) return "grow";
493
+ if (b === "shrink" || b.startsWith("shrink-")) return "shrink";
494
+ if (b.startsWith("gap-x-")) return "gap-x";
495
+ if (b.startsWith("gap-y-")) return "gap-y";
496
+ if (b.startsWith("gap-")) return "gap";
497
+ if (b.startsWith("justify-items-")) return "justify-items";
498
+ if (b.startsWith("justify-self-")) return "justify-self";
499
+ if (b.startsWith("justify-")) return "justify";
500
+ if (b.startsWith("items-")) return "items";
501
+ if (b.startsWith("self-")) return "self";
502
+ if (b.startsWith("place-content-")) return "place-content";
503
+ if (b.startsWith("place-items-")) return "place-items";
504
+ if (b.startsWith("place-self-")) return "place-self";
505
+ if (b.startsWith("content-")) return "content";
506
+ if (b.startsWith("px-")) return "px";
507
+ if (b.startsWith("py-")) return "py";
508
+ if (b.startsWith("pt-")) return "pt";
509
+ if (b.startsWith("pr-")) return "pr";
510
+ if (b.startsWith("pb-")) return "pb";
511
+ if (b.startsWith("pl-")) return "pl";
512
+ if (b.startsWith("ps-")) return "ps";
513
+ if (b.startsWith("pe-")) return "pe";
514
+ if (b.startsWith("p-")) return "p";
515
+ if (b.startsWith("mx-")) return "mx";
516
+ if (b.startsWith("my-")) return "my";
517
+ if (b.startsWith("mt-")) return "mt";
518
+ if (b.startsWith("mr-")) return "mr";
519
+ if (b.startsWith("mb-")) return "mb";
520
+ if (b.startsWith("ml-")) return "ml";
521
+ if (b.startsWith("ms-")) return "ms";
522
+ if (b.startsWith("me-")) return "me";
523
+ if (b === "-m" || b.startsWith("m-") || b.startsWith("-m-")) return "m";
524
+ if (b.startsWith("space-x-")) return "space-x";
525
+ if (b.startsWith("space-y-")) return "space-y";
526
+ if (b.startsWith("size-")) return "size";
527
+ if (b.startsWith("min-w-")) return "min-w";
528
+ if (b.startsWith("max-w-")) return "max-w";
529
+ if (b.startsWith("w-")) return "w";
530
+ if (b.startsWith("min-h-")) return "min-h";
531
+ if (b.startsWith("max-h-")) return "max-h";
532
+ if (b.startsWith("h-")) return "h";
533
+ if (b.startsWith("inset-x-")) return "inset-x";
534
+ if (b.startsWith("inset-y-")) return "inset-y";
535
+ if (b.startsWith("inset-")) return "inset";
536
+ if (b.startsWith("top-")) return "top";
537
+ if (b.startsWith("right-") || b.startsWith("end-")) return "right";
538
+ if (b.startsWith("bottom-")) return "bottom";
539
+ if (b.startsWith("left-") || b.startsWith("start-")) return "left";
540
+ if (b.startsWith("z-")) return "z";
541
+ if (b.startsWith("opacity-")) return "opacity";
542
+ if (b.startsWith("bg-")) {
543
+ if (b.startsWith("bg-opacity-")) return "bg-opacity";
538
544
  return "bg";
539
545
  }
540
- if (base.startsWith("from-")) return "from";
541
- if (base.startsWith("via-")) return "via";
542
- if (base.startsWith("to-")) return "to";
543
- if (base.startsWith("text-")) {
544
- const suffix = base.slice("text-".length);
546
+ if (b.startsWith("from-")) return "from";
547
+ if (b.startsWith("via-")) return "via";
548
+ if (b.startsWith("to-")) return "to";
549
+ if (b.startsWith("text-")) {
550
+ const suffix = b.slice("text-".length);
545
551
  if (isTextSize(suffix)) return "text-size";
546
552
  if (suffix.startsWith("opacity-")) return "text-opacity";
547
553
  if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
548
554
  return "text-color";
549
555
  }
550
- if (base.startsWith("font-")) {
551
- const suffix = base.slice("font-".length);
556
+ if (b.startsWith("font-")) {
557
+ const suffix = b.slice("font-".length);
552
558
  if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
553
559
  return "font-family";
554
560
  }
555
- if (base.startsWith("leading-")) return "leading";
556
- if (base.startsWith("tracking-")) return "tracking";
557
- if (base.startsWith("border-")) {
558
- const suffix = base.slice("border-".length);
561
+ if (b.startsWith("leading-")) return "leading";
562
+ if (b.startsWith("tracking-")) return "tracking";
563
+ if (b.startsWith("border-")) {
564
+ const suffix = b.slice("border-".length);
559
565
  const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
560
566
  if (sidePrefix) {
561
567
  const side = suffix.slice(0, 1);
@@ -569,67 +575,67 @@ function conflictGroup(base) {
569
575
  if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
570
576
  return "border-color";
571
577
  }
572
- if (base === "border") return "border-width";
573
- if (base.startsWith("outline-")) return "outline";
574
- if (base === "outline") return "outline";
575
- 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")) {
576
- const firstChar = base.slice("rounded-".length).charAt(0) || "x";
578
+ if (b === "border") return "border-width";
579
+ if (b.startsWith("outline-")) return "outline";
580
+ if (b === "outline") return "outline";
581
+ 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")) {
582
+ const firstChar = b.slice("rounded-".length).charAt(0) || "x";
577
583
  return `rounded-${firstChar}`;
578
584
  }
579
- if (base === "rounded" || base.startsWith("rounded-")) return "rounded";
580
- if (base === "shadow" || base.startsWith("shadow-")) return "shadow";
581
- if (base.startsWith("ring-offset-")) return "ring-offset";
582
- if (base === "ring") return "ring-width";
583
- if (base.startsWith("ring-")) {
584
- const rest = base.slice("ring-".length);
585
+ if (b === "rounded" || b.startsWith("rounded-")) return "rounded";
586
+ if (b === "shadow" || b.startsWith("shadow-")) return "shadow";
587
+ if (b.startsWith("ring-offset-")) return "ring-offset";
588
+ if (b === "ring") return "ring-width";
589
+ if (b.startsWith("ring-")) {
590
+ const rest = b.slice("ring-".length);
585
591
  const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
586
592
  if (isWidth) return "ring-width";
587
593
  if (rest === "inset") return "ring-inset";
588
594
  return "ring-color";
589
595
  }
590
- if (base.startsWith("rotate-")) return "rotate";
591
- if (base.startsWith("scale-x-")) return "scale-x";
592
- if (base.startsWith("scale-y-")) return "scale-y";
593
- if (base.startsWith("scale-")) return "scale";
594
- if (base.startsWith("translate-x-")) return "translate-x";
595
- if (base.startsWith("translate-y-")) return "translate-y";
596
- if (base.startsWith("skew-x-")) return "skew-x";
597
- if (base.startsWith("skew-y-")) return "skew-y";
598
- if (base === "transition" || base.startsWith("transition-")) return "transition";
599
- if (base.startsWith("duration-")) return "duration";
600
- if (base.startsWith("ease-")) return "ease";
601
- if (base.startsWith("delay-")) return "delay";
602
- if (base === "animate" || base.startsWith("animate-")) return "animate";
603
- if (base.startsWith("cursor-")) return "cursor";
604
- if (base.startsWith("pointer-events-")) return "pointer-events";
605
- if (base.startsWith("select-")) return "select";
606
- if (base === "visible" || base === "invisible" || base === "collapse") return "visibility";
607
- if (base.startsWith("object-")) return "object";
608
- if (base.startsWith("aspect-")) return "aspect";
609
- if (base.startsWith("order-")) return "order";
610
- if (base.startsWith("whitespace-")) return "whitespace";
611
- if (base.startsWith("list-")) return "list";
612
- if (base.startsWith("fill-")) return "fill";
613
- if (base.startsWith("stroke-")) return "stroke";
614
- if (base.startsWith("backdrop-")) {
615
- const rest = base.slice("backdrop-".length);
596
+ if (b.startsWith("rotate-")) return "rotate";
597
+ if (b.startsWith("scale-x-")) return "scale-x";
598
+ if (b.startsWith("scale-y-")) return "scale-y";
599
+ if (b.startsWith("scale-")) return "scale";
600
+ if (b.startsWith("translate-x-")) return "translate-x";
601
+ if (b.startsWith("translate-y-")) return "translate-y";
602
+ if (b.startsWith("skew-x-")) return "skew-x";
603
+ if (b.startsWith("skew-y-")) return "skew-y";
604
+ if (b === "transition" || b.startsWith("transition-")) return "transition";
605
+ if (b.startsWith("duration-")) return "duration";
606
+ if (b.startsWith("ease-")) return "ease";
607
+ if (b.startsWith("delay-")) return "delay";
608
+ if (b === "animate" || b.startsWith("animate-")) return "animate";
609
+ if (b.startsWith("cursor-")) return "cursor";
610
+ if (b.startsWith("pointer-events-")) return "pointer-events";
611
+ if (b.startsWith("select-")) return "select";
612
+ if (b === "visible" || b === "invisible" || b === "collapse") return "visibility";
613
+ if (b.startsWith("object-")) return "object";
614
+ if (b.startsWith("aspect-")) return "aspect";
615
+ if (b.startsWith("order-")) return "order";
616
+ if (b.startsWith("whitespace-")) return "whitespace";
617
+ if (b.startsWith("list-")) return "list";
618
+ if (b.startsWith("fill-")) return "fill";
619
+ if (b.startsWith("stroke-")) return "stroke";
620
+ if (b.startsWith("backdrop-")) {
621
+ const rest = b.slice("backdrop-".length);
616
622
  const seg = rest.split("-")[0] || "x";
617
623
  return `backdrop-${seg}`;
618
624
  }
619
- if (base.startsWith("scroll-")) return "scroll";
620
- if (base.startsWith("snap-")) return "snap";
621
- if (base.startsWith("touch-")) return "touch";
622
- if (base.startsWith("decoration-")) return "text-decoration";
623
- if (base.startsWith("caret-")) return "caret";
624
- if (base.startsWith("accent-")) return "accent";
625
- if (base.startsWith("appearance-")) return "appearance";
626
- if (base === "isolate" || base === "isolation-auto") return "isolation";
627
- if (base.startsWith("mix-blend-")) return "mix-blend";
628
- if (base.startsWith("bg-blend-")) return "bg-blend";
629
- if (base.startsWith("float-")) return "float";
630
- if (base.startsWith("clear-")) return "clear";
631
- if (base.startsWith("break-")) return "break";
632
- if (base.startsWith("columns-")) return "columns";
625
+ if (b.startsWith("scroll-")) return "scroll";
626
+ if (b.startsWith("snap-")) return "snap";
627
+ if (b.startsWith("touch-")) return "touch";
628
+ if (b.startsWith("decoration-")) return "text-decoration";
629
+ if (b.startsWith("caret-")) return "caret";
630
+ if (b.startsWith("accent-")) return "accent";
631
+ if (b.startsWith("appearance-")) return "appearance";
632
+ if (b === "isolate" || b === "isolation-auto") return "isolation";
633
+ if (b.startsWith("mix-blend-")) return "mix-blend";
634
+ if (b.startsWith("bg-blend-")) return "bg-blend";
635
+ if (b.startsWith("float-")) return "float";
636
+ if (b.startsWith("clear-")) return "clear";
637
+ if (b.startsWith("break-")) return "break";
638
+ if (b.startsWith("columns-")) return "columns";
633
639
  return null;
634
640
  }
635
641
  function splitVariants(klass) {
@@ -644,7 +650,7 @@ function splitVariants(klass) {
644
650
  if (lastColon === 0) return ["", klass];
645
651
  return [klass.slice(0, lastColon), klass.slice(lastColon)];
646
652
  }
647
- function mergeClassStringJs(input) {
653
+ function mergeClassStringJs(input, prefix = "") {
648
654
  const tokens = input.split(/\s+/).filter(Boolean);
649
655
  if (tokens.length === 0) return "";
650
656
  if (tokens.length === 1) return tokens[0];
@@ -652,7 +658,7 @@ function mergeClassStringJs(input) {
652
658
  const slots = [];
653
659
  for (const token of tokens) {
654
660
  const [variants, base] = splitVariants(token);
655
- const group = conflictGroup(base);
661
+ const group = conflictGroup(base, prefix);
656
662
  if (group !== null) {
657
663
  const key = `${variants}::${group}`;
658
664
  const prevIdx = groupOwner.get(key);
@@ -665,10 +671,10 @@ function mergeClassStringJs(input) {
665
671
  }
666
672
  return slots.filter((s) => s !== null).join(" ");
667
673
  }
668
- function twMergeRawJs(classLists) {
674
+ function twMergeRawJs(classLists, prefix = "") {
669
675
  const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
670
676
  if (joined.length === 0) return "";
671
- return mergeClassStringJs(joined);
677
+ return mergeClassStringJs(joined, prefix);
672
678
  }
673
679
 
674
680
  // packages/domain/core/src/merge.ts
@@ -683,6 +689,7 @@ function warnFallbackOnce() {
683
689
  }
684
690
  }
685
691
  function createTwMerge(options = {}) {
692
+ const prefix = options.prefix ?? "";
686
693
  return function twMerge2(...classLists) {
687
694
  const inputs = [];
688
695
  for (let i = 0; i < classLists.length; i++) {
@@ -691,11 +698,16 @@ function createTwMerge(options = {}) {
691
698
  }
692
699
  if (inputs.length === 0) return "";
693
700
  const native = getNativeBinding();
694
- if (native?.twMergeRaw) {
695
- return native.twMergeRaw(inputs);
701
+ if (native) {
702
+ if (prefix && native.twMergeRawWithOptions) {
703
+ return native.twMergeRawWithOptions(inputs, { prefix });
704
+ }
705
+ if (native.twMergeRaw) {
706
+ return native.twMergeRaw(inputs);
707
+ }
696
708
  }
697
709
  warnFallbackOnce();
698
- return twMergeRawJs(inputs);
710
+ return twMergeRawJs(inputs, prefix);
699
711
  };
700
712
  }
701
713
  var twMerge = createTwMerge();
@@ -708,6 +720,37 @@ function mergeWithRules(rules, ...classLists) {
708
720
  return classes.join(" ");
709
721
  }
710
722
 
723
+ // packages/domain/core/src/parseTemplateFallback.ts
724
+ init_cjs_shims();
725
+ var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
726
+ var COMMENT_RE = /\/\/[^\n]*/g;
727
+ function collapseSpaces(s) {
728
+ return s.replace(/\s+/g, " ").trim();
729
+ }
730
+ function cleanBlock(raw) {
731
+ const noComments = raw.replace(COMMENT_RE, "");
732
+ const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
733
+ return collapseSpaces(lines.join(" "));
734
+ }
735
+ function parseTemplateJs(raw) {
736
+ const subs = {};
737
+ let base = raw;
738
+ for (const match of raw.matchAll(SUB_RE)) {
739
+ const fullMatch = match[0];
740
+ const name = match[1] ?? match[2] ?? "";
741
+ const innerRaw = match[3] ?? "";
742
+ if (name) {
743
+ subs[name] = cleanBlock(innerRaw);
744
+ }
745
+ base = base.replace(fullMatch, "");
746
+ }
747
+ return {
748
+ base: collapseSpaces(base),
749
+ subs,
750
+ hasSubs: Object.keys(subs).length > 0
751
+ };
752
+ }
753
+
711
754
  // packages/domain/core/src/stateEngine.ts
712
755
  init_cjs_shims();
713
756
  var stateRegistry = /* @__PURE__ */ new Map();
@@ -715,22 +758,27 @@ if (typeof window !== "undefined") {
715
758
  window.__TW_STATE_REGISTRY__ = stateRegistry;
716
759
  }
717
760
  var _hashStateCache = /* @__PURE__ */ new Map();
761
+ function _fnvHash62(s) {
762
+ let h = 2166136261;
763
+ for (let i = 0; i < s.length; i++) {
764
+ h ^= s.charCodeAt(i);
765
+ h = Math.imul(h, 16777619) >>> 0;
766
+ }
767
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
768
+ }
718
769
  function hashState(tag, state) {
719
770
  const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
720
771
  const cached = _hashStateCache.get(sortedKey);
721
772
  if (cached) return cached;
722
773
  const native = getNativeBinding();
723
- if (!native?.hashContent) {
724
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
725
- }
726
- const id = `tw-s-${native.hashContent(sortedKey, "fnv", 6)}`;
774
+ const id = native?.hashContent ? `tw-s-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-s-${_fnvHash62(sortedKey)}`;
727
775
  _hashStateCache.set(sortedKey, id);
728
776
  return id;
729
777
  }
730
778
  function generateStateRules(id, state) {
731
779
  const native = getNativeBinding();
732
780
  if (!native?.generateRuntimeStateCss) {
733
- throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
781
+ return [];
734
782
  }
735
783
  return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
736
784
  }
@@ -818,7 +866,13 @@ function _getParsedTemplate(template) {
818
866
  }
819
867
  const native = getNativeBinding();
820
868
  if (!native?.parseSubcomponentBlocksNapi) {
821
- throw new Error("FATAL: Native binding 'parseSubcomponentBlocksNapi' is required but not available.");
869
+ const fb = parseTemplateJs(template);
870
+ const result2 = {
871
+ baseClasses: fb.base,
872
+ subMap: new Map(Object.entries(fb.subs))
873
+ };
874
+ _templateParseCache.set(template, result2);
875
+ return result2;
822
876
  }
823
877
  const r = native.parseSubcomponentBlocksNapi(template, "tw");
824
878
  const raw = JSON.parse(r.subMapJson);
@@ -970,10 +1024,16 @@ function resolveVariants(variants, props, defaults) {
970
1024
  }
971
1025
  const binding = getNativeBinding();
972
1026
  if (!binding?.resolveSimpleVariants) {
973
- throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
1027
+ const classes = [];
1028
+ for (const key of Object.keys(variants)) {
1029
+ const propValue = cleanProps[key] ?? defaults[key];
1030
+ if (propValue !== void 0 && variants[key]?.[propValue]) {
1031
+ classes.push(variants[key][propValue]);
1032
+ }
1033
+ }
1034
+ return classes.join(" ").trim().replace(/\s+/g, " ");
974
1035
  }
975
- const result = binding.resolveSimpleVariants(null, variants, defaults, cleanProps);
976
- return result.trim().replace(/\s+/g, " ");
1036
+ return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
977
1037
  }
978
1038
  function resolveStates(statesConfig, stateKeys, statesLookup, props) {
979
1039
  if (statesLookup && stateKeys.length > 0) {
@@ -1185,49 +1245,8 @@ function wrapWithSubProxy(component, tagLabel) {
1185
1245
  });
1186
1246
  }
1187
1247
 
1188
- // packages/domain/core/src/parseTemplateFallback.ts
1189
- init_cjs_shims();
1190
- var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
1191
- var COMMENT_RE = /\/\/[^\n]*/g;
1192
- function collapseSpaces(s) {
1193
- return s.replace(/\s+/g, " ").trim();
1194
- }
1195
- function cleanBlock(raw) {
1196
- const noComments = raw.replace(COMMENT_RE, "");
1197
- const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
1198
- return collapseSpaces(lines.join(" "));
1199
- }
1200
- function parseTemplateJs(raw) {
1201
- const subs = {};
1202
- let base = raw;
1203
- for (const match of raw.matchAll(SUB_RE)) {
1204
- const fullMatch = match[0];
1205
- const name = match[1] ?? match[2] ?? "";
1206
- const innerRaw = match[3] ?? "";
1207
- if (name) {
1208
- subs[name] = cleanBlock(innerRaw);
1209
- }
1210
- base = base.replace(fullMatch, "");
1211
- }
1212
- return {
1213
- base: cleanBlock(base),
1214
- subs,
1215
- hasSubs: Object.keys(subs).length > 0
1216
- };
1217
- }
1218
-
1219
1248
  // packages/domain/core/src/twProxy.ts
1220
1249
  var _parsedTemplateCache = /* @__PURE__ */ new Map();
1221
- var warnedParseTemplateFallback = false;
1222
- function warnParseTemplateFallbackOnce() {
1223
- if (warnedParseTemplateFallback) return;
1224
- warnedParseTemplateFallback = true;
1225
- if (typeof console !== "undefined") {
1226
- console.warn(
1227
- "[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."
1228
- );
1229
- }
1230
- }
1231
1250
  function parseTemplate(strings, exprs) {
1232
1251
  const raw = strings.raw.reduce((acc, str, i) => {
1233
1252
  const expr = exprs[i];
@@ -1237,15 +1256,15 @@ function parseTemplate(strings, exprs) {
1237
1256
  const cached = _parsedTemplateCache.get(raw);
1238
1257
  if (cached) return cached;
1239
1258
  const binding = getNativeBinding();
1240
- let result;
1241
- if (binding?.parseTemplate) {
1242
- const r = binding.parseTemplate(raw);
1243
- const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
1244
- result = { base: r.base, subs, hasSubs: r.hasSubs };
1245
- } else {
1246
- warnParseTemplateFallbackOnce();
1247
- result = parseTemplateJs(raw);
1259
+ if (!binding?.parseTemplate) {
1260
+ const fb = parseTemplateJs(raw);
1261
+ const result2 = { base: fb.base, subs: fb.subs, hasSubs: fb.hasSubs };
1262
+ _parsedTemplateCache.set(raw, result2);
1263
+ return result2;
1248
1264
  }
1265
+ const r = binding.parseTemplate(raw);
1266
+ const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
1267
+ const result = { base: r.base, subs, hasSubs: r.hasSubs };
1249
1268
  _parsedTemplateCache.set(raw, result);
1250
1269
  return result;
1251
1270
  }
@@ -1558,19 +1577,25 @@ function cn(...inputs) {
1558
1577
  }
1559
1578
  if (strings.length === 0) return "";
1560
1579
  const native = getNativeBinding();
1561
- if (!native?.resolveClassNames) {
1580
+ if (native?.resolveClassNames) {
1581
+ return native.resolveClassNames(strings);
1582
+ }
1583
+ if (native !== null) {
1562
1584
  throw new Error("Native binding 'resolveClassNames' is required but not available.");
1563
1585
  }
1564
- return native.resolveClassNames(strings);
1586
+ return strings.filter(Boolean).join(" ");
1565
1587
  }
1566
1588
  function cx(...inputs) {
1567
1589
  const filtered = inputs.flat().filter(Boolean);
1568
1590
  if (filtered.length === 0) return "";
1569
1591
  const native = getNativeBinding();
1570
- if (!native?.twMergeMany) {
1592
+ if (native?.twMergeMany) {
1593
+ return native.twMergeMany(filtered);
1594
+ }
1595
+ if (native !== null) {
1571
1596
  throw new Error("Native binding 'twMergeMany' is required but not available.");
1572
1597
  }
1573
- return native.twMergeMany(filtered);
1598
+ return twMergeRawJs(filtered);
1574
1599
  }
1575
1600
  var cxm = cx;
1576
1601