tailwind-styled-v4 5.1.11 → 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
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
2
3
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
4
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -223,22 +224,27 @@ if (typeof window !== "undefined") {
223
224
  window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
224
225
  }
225
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
+ }
226
235
  function hashContainer(tag, container, name) {
227
236
  const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
228
237
  const cached = _hashContainerCache.get(sortedKey);
229
238
  if (cached) return cached;
230
239
  const native = getNativeBinding();
231
- if (!native?.hashContent) {
232
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
233
- }
234
- 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)}`;
235
241
  _hashContainerCache.set(sortedKey, id);
236
242
  return id;
237
243
  }
238
244
  function layoutClassesToCss(classes) {
239
245
  const native = getNativeBinding();
240
246
  if (!native?.layoutClassesToCss) {
241
- throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
247
+ return "";
242
248
  }
243
249
  return native.layoutClassesToCss(classes);
244
250
  }
@@ -399,96 +405,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
399
405
  var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
400
406
  var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
401
407
  var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
402
- function conflictGroup(base) {
403
- 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("[");
404
411
  if (bracket !== -1) {
405
- const prefix = base.slice(0, bracket).replace(/-+$/, "");
406
- return prefix.length > 0 ? prefix : "arbitrary";
407
- }
408
- if (DISPLAY_VALUES.has(base)) return "display";
409
- if (POSITION_VALUES.has(base)) return "position";
410
- if (base.startsWith("overflow-x-")) return "overflow-x";
411
- if (base.startsWith("overflow-y-")) return "overflow-y";
412
- if (base.startsWith("overflow-")) return "overflow";
413
- if (base.startsWith("flex-")) return "flex";
414
- if (base.startsWith("grid-cols-")) return "grid-cols";
415
- if (base.startsWith("grid-rows-")) return "grid-rows";
416
- if (base.startsWith("grid-flow-")) return "grid-flow";
417
- if (base.startsWith("col-")) return "col";
418
- if (base.startsWith("row-")) return "row";
419
- if (base === "grow" || base.startsWith("grow-")) return "grow";
420
- if (base === "shrink" || base.startsWith("shrink-")) return "shrink";
421
- if (base.startsWith("gap-x-")) return "gap-x";
422
- if (base.startsWith("gap-y-")) return "gap-y";
423
- if (base.startsWith("gap-")) return "gap";
424
- if (base.startsWith("justify-items-")) return "justify-items";
425
- if (base.startsWith("justify-self-")) return "justify-self";
426
- if (base.startsWith("justify-")) return "justify";
427
- if (base.startsWith("items-")) return "items";
428
- if (base.startsWith("self-")) return "self";
429
- if (base.startsWith("place-content-")) return "place-content";
430
- if (base.startsWith("place-items-")) return "place-items";
431
- if (base.startsWith("place-self-")) return "place-self";
432
- if (base.startsWith("content-")) return "content";
433
- if (base.startsWith("px-")) return "px";
434
- if (base.startsWith("py-")) return "py";
435
- if (base.startsWith("pt-")) return "pt";
436
- if (base.startsWith("pr-")) return "pr";
437
- if (base.startsWith("pb-")) return "pb";
438
- if (base.startsWith("pl-")) return "pl";
439
- if (base.startsWith("ps-")) return "ps";
440
- if (base.startsWith("pe-")) return "pe";
441
- if (base.startsWith("p-")) return "p";
442
- if (base.startsWith("mx-")) return "mx";
443
- if (base.startsWith("my-")) return "my";
444
- if (base.startsWith("mt-")) return "mt";
445
- if (base.startsWith("mr-")) return "mr";
446
- if (base.startsWith("mb-")) return "mb";
447
- if (base.startsWith("ml-")) return "ml";
448
- if (base.startsWith("ms-")) return "ms";
449
- if (base.startsWith("me-")) return "me";
450
- if (base === "-m" || base.startsWith("m-") || base.startsWith("-m-")) return "m";
451
- if (base.startsWith("space-x-")) return "space-x";
452
- if (base.startsWith("space-y-")) return "space-y";
453
- if (base.startsWith("size-")) return "size";
454
- if (base.startsWith("min-w-")) return "min-w";
455
- if (base.startsWith("max-w-")) return "max-w";
456
- if (base.startsWith("w-")) return "w";
457
- if (base.startsWith("min-h-")) return "min-h";
458
- if (base.startsWith("max-h-")) return "max-h";
459
- if (base.startsWith("h-")) return "h";
460
- if (base.startsWith("inset-x-")) return "inset-x";
461
- if (base.startsWith("inset-y-")) return "inset-y";
462
- if (base.startsWith("inset-")) return "inset";
463
- if (base.startsWith("top-")) return "top";
464
- if (base.startsWith("right-") || base.startsWith("end-")) return "right";
465
- if (base.startsWith("bottom-")) return "bottom";
466
- if (base.startsWith("left-") || base.startsWith("start-")) return "left";
467
- if (base.startsWith("z-")) return "z";
468
- if (base.startsWith("opacity-")) return "opacity";
469
- if (base.startsWith("bg-")) {
470
- 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";
471
478
  return "bg";
472
479
  }
473
- if (base.startsWith("from-")) return "from";
474
- if (base.startsWith("via-")) return "via";
475
- if (base.startsWith("to-")) return "to";
476
- if (base.startsWith("text-")) {
477
- 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);
478
485
  if (isTextSize(suffix)) return "text-size";
479
486
  if (suffix.startsWith("opacity-")) return "text-opacity";
480
487
  if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
481
488
  return "text-color";
482
489
  }
483
- if (base.startsWith("font-")) {
484
- const suffix = base.slice("font-".length);
490
+ if (b.startsWith("font-")) {
491
+ const suffix = b.slice("font-".length);
485
492
  if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
486
493
  return "font-family";
487
494
  }
488
- if (base.startsWith("leading-")) return "leading";
489
- if (base.startsWith("tracking-")) return "tracking";
490
- if (base.startsWith("border-")) {
491
- 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);
492
499
  const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
493
500
  if (sidePrefix) {
494
501
  const side = suffix.slice(0, 1);
@@ -502,67 +509,67 @@ function conflictGroup(base) {
502
509
  if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
503
510
  return "border-color";
504
511
  }
505
- if (base === "border") return "border-width";
506
- if (base.startsWith("outline-")) return "outline";
507
- if (base === "outline") return "outline";
508
- 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")) {
509
- 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";
510
517
  return `rounded-${firstChar}`;
511
518
  }
512
- if (base === "rounded" || base.startsWith("rounded-")) return "rounded";
513
- if (base === "shadow" || base.startsWith("shadow-")) return "shadow";
514
- if (base.startsWith("ring-offset-")) return "ring-offset";
515
- if (base === "ring") return "ring-width";
516
- if (base.startsWith("ring-")) {
517
- 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);
518
525
  const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
519
526
  if (isWidth) return "ring-width";
520
527
  if (rest === "inset") return "ring-inset";
521
528
  return "ring-color";
522
529
  }
523
- if (base.startsWith("rotate-")) return "rotate";
524
- if (base.startsWith("scale-x-")) return "scale-x";
525
- if (base.startsWith("scale-y-")) return "scale-y";
526
- if (base.startsWith("scale-")) return "scale";
527
- if (base.startsWith("translate-x-")) return "translate-x";
528
- if (base.startsWith("translate-y-")) return "translate-y";
529
- if (base.startsWith("skew-x-")) return "skew-x";
530
- if (base.startsWith("skew-y-")) return "skew-y";
531
- if (base === "transition" || base.startsWith("transition-")) return "transition";
532
- if (base.startsWith("duration-")) return "duration";
533
- if (base.startsWith("ease-")) return "ease";
534
- if (base.startsWith("delay-")) return "delay";
535
- if (base === "animate" || base.startsWith("animate-")) return "animate";
536
- if (base.startsWith("cursor-")) return "cursor";
537
- if (base.startsWith("pointer-events-")) return "pointer-events";
538
- if (base.startsWith("select-")) return "select";
539
- if (base === "visible" || base === "invisible" || base === "collapse") return "visibility";
540
- if (base.startsWith("object-")) return "object";
541
- if (base.startsWith("aspect-")) return "aspect";
542
- if (base.startsWith("order-")) return "order";
543
- if (base.startsWith("whitespace-")) return "whitespace";
544
- if (base.startsWith("list-")) return "list";
545
- if (base.startsWith("fill-")) return "fill";
546
- if (base.startsWith("stroke-")) return "stroke";
547
- if (base.startsWith("backdrop-")) {
548
- 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);
549
556
  const seg = rest.split("-")[0] || "x";
550
557
  return `backdrop-${seg}`;
551
558
  }
552
- if (base.startsWith("scroll-")) return "scroll";
553
- if (base.startsWith("snap-")) return "snap";
554
- if (base.startsWith("touch-")) return "touch";
555
- if (base.startsWith("decoration-")) return "text-decoration";
556
- if (base.startsWith("caret-")) return "caret";
557
- if (base.startsWith("accent-")) return "accent";
558
- if (base.startsWith("appearance-")) return "appearance";
559
- if (base === "isolate" || base === "isolation-auto") return "isolation";
560
- if (base.startsWith("mix-blend-")) return "mix-blend";
561
- if (base.startsWith("bg-blend-")) return "bg-blend";
562
- if (base.startsWith("float-")) return "float";
563
- if (base.startsWith("clear-")) return "clear";
564
- if (base.startsWith("break-")) return "break";
565
- 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";
566
573
  return null;
567
574
  }
568
575
  function splitVariants(klass) {
@@ -577,7 +584,7 @@ function splitVariants(klass) {
577
584
  if (lastColon === 0) return ["", klass];
578
585
  return [klass.slice(0, lastColon), klass.slice(lastColon)];
579
586
  }
580
- function mergeClassStringJs(input) {
587
+ function mergeClassStringJs(input, prefix = "") {
581
588
  const tokens = input.split(/\s+/).filter(Boolean);
582
589
  if (tokens.length === 0) return "";
583
590
  if (tokens.length === 1) return tokens[0];
@@ -585,7 +592,7 @@ function mergeClassStringJs(input) {
585
592
  const slots = [];
586
593
  for (const token of tokens) {
587
594
  const [variants, base] = splitVariants(token);
588
- const group = conflictGroup(base);
595
+ const group = conflictGroup(base, prefix);
589
596
  if (group !== null) {
590
597
  const key = `${variants}::${group}`;
591
598
  const prevIdx = groupOwner.get(key);
@@ -598,10 +605,10 @@ function mergeClassStringJs(input) {
598
605
  }
599
606
  return slots.filter((s) => s !== null).join(" ");
600
607
  }
601
- function twMergeRawJs(classLists) {
608
+ function twMergeRawJs(classLists, prefix = "") {
602
609
  const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
603
610
  if (joined.length === 0) return "";
604
- return mergeClassStringJs(joined);
611
+ return mergeClassStringJs(joined, prefix);
605
612
  }
606
613
 
607
614
  // packages/domain/core/src/merge.ts
@@ -616,6 +623,7 @@ function warnFallbackOnce() {
616
623
  }
617
624
  }
618
625
  function createTwMerge(options = {}) {
626
+ const prefix = options.prefix ?? "";
619
627
  return function twMerge2(...classLists) {
620
628
  const inputs = [];
621
629
  for (let i = 0; i < classLists.length; i++) {
@@ -624,11 +632,16 @@ function createTwMerge(options = {}) {
624
632
  }
625
633
  if (inputs.length === 0) return "";
626
634
  const native = getNativeBinding();
627
- if (native?.twMergeRaw) {
628
- 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
+ }
629
642
  }
630
643
  warnFallbackOnce();
631
- return twMergeRawJs(inputs);
644
+ return twMergeRawJs(inputs, prefix);
632
645
  };
633
646
  }
634
647
  var twMerge = createTwMerge();
@@ -641,6 +654,37 @@ function mergeWithRules(rules, ...classLists) {
641
654
  return classes.join(" ");
642
655
  }
643
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
+
644
688
  // packages/domain/core/src/stateEngine.ts
645
689
  init_esm_shims();
646
690
  var stateRegistry = /* @__PURE__ */ new Map();
@@ -648,22 +692,27 @@ if (typeof window !== "undefined") {
648
692
  window.__TW_STATE_REGISTRY__ = stateRegistry;
649
693
  }
650
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
+ }
651
703
  function hashState(tag, state) {
652
704
  const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
653
705
  const cached = _hashStateCache.get(sortedKey);
654
706
  if (cached) return cached;
655
707
  const native = getNativeBinding();
656
- if (!native?.hashContent) {
657
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
658
- }
659
- 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)}`;
660
709
  _hashStateCache.set(sortedKey, id);
661
710
  return id;
662
711
  }
663
712
  function generateStateRules(id, state) {
664
713
  const native = getNativeBinding();
665
714
  if (!native?.generateRuntimeStateCss) {
666
- throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
715
+ return [];
667
716
  }
668
717
  return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
669
718
  }
@@ -751,7 +800,13 @@ function _getParsedTemplate(template) {
751
800
  }
752
801
  const native = getNativeBinding();
753
802
  if (!native?.parseSubcomponentBlocksNapi) {
754
- 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;
755
810
  }
756
811
  const r = native.parseSubcomponentBlocksNapi(template, "tw");
757
812
  const raw = JSON.parse(r.subMapJson);
@@ -903,10 +958,16 @@ function resolveVariants(variants, props, defaults) {
903
958
  }
904
959
  const binding = getNativeBinding();
905
960
  if (!binding?.resolveSimpleVariants) {
906
- 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, " ");
907
969
  }
908
- const result = binding.resolveSimpleVariants(null, variants, defaults, cleanProps);
909
- return result.trim().replace(/\s+/g, " ");
970
+ return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
910
971
  }
911
972
  function resolveStates(statesConfig, stateKeys, statesLookup, props) {
912
973
  if (statesLookup && stateKeys.length > 0) {
@@ -1130,7 +1191,10 @@ function parseTemplate(strings, exprs) {
1130
1191
  if (cached) return cached;
1131
1192
  const binding = getNativeBinding();
1132
1193
  if (!binding?.parseTemplate) {
1133
- throw new Error("FATAL: Native binding 'parseTemplate' is required but not available.");
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;
1134
1198
  }
1135
1199
  const r = binding.parseTemplate(raw);
1136
1200
  const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
@@ -1447,19 +1511,25 @@ function cn(...inputs) {
1447
1511
  }
1448
1512
  if (strings.length === 0) return "";
1449
1513
  const native = getNativeBinding();
1450
- if (!native?.resolveClassNames) {
1514
+ if (native?.resolveClassNames) {
1515
+ return native.resolveClassNames(strings);
1516
+ }
1517
+ if (native !== null) {
1451
1518
  throw new Error("Native binding 'resolveClassNames' is required but not available.");
1452
1519
  }
1453
- return native.resolveClassNames(strings);
1520
+ return strings.filter(Boolean).join(" ");
1454
1521
  }
1455
1522
  function cx(...inputs) {
1456
1523
  const filtered = inputs.flat().filter(Boolean);
1457
1524
  if (filtered.length === 0) return "";
1458
1525
  const native = getNativeBinding();
1459
- if (!native?.twMergeMany) {
1526
+ if (native?.twMergeMany) {
1527
+ return native.twMergeMany(filtered);
1528
+ }
1529
+ if (native !== null) {
1460
1530
  throw new Error("Native binding 'twMergeMany' is required but not available.");
1461
1531
  }
1462
- return native.twMergeMany(filtered);
1532
+ return twMergeRawJs(filtered);
1463
1533
  }
1464
1534
  var cxm = cx;
1465
1535