tailwind-styled-v4 5.0.35 → 5.0.36

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.
@@ -1,5 +1,3 @@
1
- import React3 from 'react';
2
-
3
1
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
4
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -8,6 +6,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
6
  throw Error('Dynamic require of "' + x + '" is not supported');
9
7
  });
10
8
 
9
+ // packages/domain/core/src/twProxy.ts
10
+ import React2 from "react";
11
+
12
+ // packages/domain/core/src/createComponent.ts
13
+ import React from "react";
14
+
11
15
  // packages/domain/core/src/native.browser.ts
12
16
  var getNativeBinding = () => null;
13
17
 
@@ -29,20 +33,26 @@ function hashContainer(tag, container, name) {
29
33
  const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
30
34
  const cached = _hashContainerCache.get(sortedKey);
31
35
  if (cached) return cached;
32
- {
36
+ const native = getNativeBinding();
37
+ if (!native?.hashContent) {
33
38
  throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
34
39
  }
40
+ const id = `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
41
+ _hashContainerCache.set(sortedKey, id);
42
+ return id;
35
43
  }
36
44
  function layoutClassesToCss(classes) {
37
- {
45
+ const native = getNativeBinding();
46
+ if (!native?.layoutClassesToCss) {
38
47
  throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
39
48
  }
49
+ return native.layoutClassesToCss(classes);
40
50
  }
41
51
  function buildContainerRules(id, container, containerName) {
42
52
  const rules = Object.entries(container).map(([key, value]) => {
43
53
  const minWidth = typeof value === "string" ? CONTAINER_BREAKPOINTS[key] ?? key : value.minWidth ?? CONTAINER_BREAKPOINTS[key] ?? key;
44
- typeof value === "string" ? value : value.classes;
45
- const css = layoutClassesToCss();
54
+ const classes = typeof value === "string" ? value : value.classes;
55
+ const css = layoutClassesToCss(classes);
46
56
  if (!css) return null;
47
57
  const query = containerName ? `@container ${containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
48
58
  return `${query}{.${id}{${css}}}`;
@@ -110,10 +120,16 @@ function processContainer(tag, container, containerName) {
110
120
  return { containerClass: id, hasContainer: true };
111
121
  }
112
122
  function generateContainerCss(tag, container, containerName) {
113
- hashContainer(tag, container, containerName);
114
- {
123
+ const id = hashContainer(tag, container, containerName);
124
+ const native = getNativeBinding();
125
+ if (!native?.buildContainerRules) {
115
126
  throw new Error("FATAL: Native binding 'buildContainerRules' is required but not available.");
116
127
  }
128
+ const breakpoints = Object.entries(container).map(([key, value]) => ({
129
+ key,
130
+ classes: typeof value === "string" ? value : value.classes
131
+ }));
132
+ return native.buildContainerRules(id, breakpoints, containerName ?? null);
117
133
  }
118
134
  function getContainerRegistry() {
119
135
  return containerRegistry;
@@ -128,9 +144,11 @@ function createTwMerge(_options = {}) {
128
144
  if (v) inputs.push(String(v));
129
145
  }
130
146
  if (inputs.length === 0) return "";
131
- {
147
+ const native = getNativeBinding();
148
+ if (!native?.twMergeRaw) {
132
149
  throw new Error("Native binding 'twMergeRaw' is required but not available.");
133
150
  }
151
+ return native.twMergeRaw(inputs);
134
152
  };
135
153
  }
136
154
  var twMerge = createTwMerge();
@@ -153,17 +171,20 @@ function hashState(tag, state) {
153
171
  const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
154
172
  const cached = _hashStateCache.get(sortedKey);
155
173
  if (cached) return cached;
156
- {
174
+ const native = getNativeBinding();
175
+ if (!native?.hashContent) {
157
176
  throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
158
177
  }
159
- }
160
- var _twClassesToCssCache = /* @__PURE__ */ new Map();
161
- function twClassesToCss(classes) {
162
- const cached = _twClassesToCssCache.get(classes);
163
- if (cached !== void 0) return cached;
164
- {
165
- throw new Error("FATAL: Native binding 'twClassesToCss' is required but not available.");
178
+ const id = `tw-s-${native.hashContent(sortedKey, "fnv", 6)}`;
179
+ _hashStateCache.set(sortedKey, id);
180
+ return id;
181
+ }
182
+ function generateStateRules(id, state) {
183
+ const native = getNativeBinding();
184
+ if (!native?.generateRuntimeStateCss) {
185
+ throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
166
186
  }
187
+ return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
167
188
  }
168
189
  var _staticCssDetected = /* @__PURE__ */ new Set();
169
190
  var _batchedInjectFn = null;
@@ -195,10 +216,7 @@ function injectStateStyles(id, state) {
195
216
  }
196
217
  }
197
218
  }
198
- const rules = Object.entries(state).map(([stateName, classes]) => {
199
- const css = twClassesToCss(classes);
200
- return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
201
- }).filter(Boolean);
219
+ const rules = generateStateRules(id, state);
202
220
  if (rules.length === 0) return;
203
221
  if (_batchedInjectFn) {
204
222
  for (const rule of rules) _batchedInjectFn(rule);
@@ -228,11 +246,7 @@ function processState(tag, state, precomputedHash) {
228
246
  }
229
247
  function generateStateCss(tag, state) {
230
248
  const id = hashState(tag, state);
231
- const rules = Object.entries(state).map(([stateName, classes]) => {
232
- const css = twClassesToCss(classes);
233
- return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
234
- }).filter(Boolean);
235
- return rules.join("\n");
249
+ return generateStateRules(id, state).join("\n");
236
250
  }
237
251
  function getStateRegistry() {
238
252
  return stateRegistry;
@@ -254,9 +268,18 @@ function _getParsedTemplate(template) {
254
268
  _templateParseCache.set(template, result2);
255
269
  return result2;
256
270
  }
257
- {
271
+ const native = getNativeBinding();
272
+ if (!native?.parseSubcomponentBlocksNapi) {
258
273
  throw new Error("FATAL: Native binding 'parseSubcomponentBlocksNapi' is required but not available.");
259
274
  }
275
+ const r = native.parseSubcomponentBlocksNapi(template, "tw");
276
+ const raw = JSON.parse(r.subMapJson);
277
+ const result = {
278
+ baseClasses: r.baseClasses.trim().replace(/\s+/g, " "),
279
+ subMap: new Map(Object.entries(raw))
280
+ };
281
+ _templateParseCache.set(template, result);
282
+ return result;
260
283
  }
261
284
  function parseSubComponentBlocks(template) {
262
285
  return _getParsedTemplate(template).subMap;
@@ -330,13 +353,13 @@ function createSubComponentAccessor(parentDisplayName, name, classes, tag = "spa
330
353
  className
331
354
  }) => {
332
355
  const mergedClass = className ? `${classes} ${className}` : classes;
333
- if (asChild && React3.isValidElement(children)) {
334
- const child = React3.Children.only(children);
335
- return React3.cloneElement(child, {
356
+ if (asChild && React.isValidElement(children)) {
357
+ const child = React.Children.only(children);
358
+ return React.cloneElement(child, {
336
359
  className: child.props.className ? `${mergedClass} ${child.props.className}` : mergedClass
337
360
  });
338
361
  }
339
- return React3.createElement(tag, { className: mergedClass }, children);
362
+ return React.createElement(tag, { className: mergedClass }, children);
340
363
  };
341
364
  SubComponent.displayName = `${parentDisplayName}[${name}]`;
342
365
  return SubComponent;
@@ -392,12 +415,17 @@ function makeFilterProps(variantKeys, stateKeys = /* @__PURE__ */ new Set()) {
392
415
  }
393
416
  function resolveVariants(variants, props, defaults) {
394
417
  const variantKeys = Object.keys(variants);
418
+ const cleanProps = {};
395
419
  for (const k of variantKeys) {
396
- props[k];
420
+ const v = props[k];
421
+ if (v !== void 0 && v !== null) cleanProps[k] = String(v);
397
422
  }
398
- {
423
+ const binding = getNativeBinding();
424
+ if (!binding?.resolveSimpleVariants) {
399
425
  throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
400
426
  }
427
+ const result = binding.resolveSimpleVariants(null, variants, defaults, cleanProps);
428
+ return result.trim().replace(/\s+/g, " ");
401
429
  }
402
430
  function resolveStates(statesConfig, stateKeys, statesLookup, props) {
403
431
  if (statesLookup && stateKeys.length > 0) {
@@ -425,6 +453,7 @@ function carryOverSubComponents(target, source) {
425
453
  const INTERNAL_KEYS = /* @__PURE__ */ new Set(["extend", "withVariants", "animate", "withSub", "displayName"]);
426
454
  for (const key of Object.keys(source)) {
427
455
  if (!INTERNAL_KEYS.has(key)) {
456
+ ;
428
457
  target[key] = source[key];
429
458
  }
430
459
  }
@@ -500,7 +529,7 @@ function createComponent(tag, config) {
500
529
  const base = typeof config === "string" ? config : config.base ?? "";
501
530
  const variants = typeof config === "string" ? {} : config.variants ?? {};
502
531
  const compoundVariants = typeof config === "string" ? [] : config.compoundVariants ?? [];
503
- typeof config === "string" ? {} : config.defaultVariants ?? {};
532
+ const defaultVariants = typeof config === "string" ? {} : config.defaultVariants ?? {};
504
533
  const stateConfig = typeof config === "string" ? void 0 : config.state;
505
534
  const containerConfig = typeof config === "string" ? void 0 : config.container;
506
535
  const containerName = typeof config === "string" ? void 0 : config.containerName;
@@ -518,7 +547,12 @@ function createComponent(tag, config) {
518
547
  } else {
519
548
  try {
520
549
  const native = getNativeBinding();
521
- if (native?.pregenerateStatesNapi) ;
550
+ if (native?.pregenerateStatesNapi) {
551
+ const result2 = native.pregenerateStatesNapi(statesConfig);
552
+ statesLookup = JSON.parse(result2.lookupJson);
553
+ stateKeys = result2.stateKeys;
554
+ _statesLookupCache.set(statesCacheKey, { lookup: statesLookup, keys: stateKeys });
555
+ }
522
556
  } catch (e) {
523
557
  console.warn("[tailwind-styled-v4] states pre-generation failed, falling back to runtime cx()", e);
524
558
  }
@@ -536,13 +570,13 @@ function createComponent(tag, config) {
536
570
  const filterProps = makeFilterProps(new Set(Object.keys(variants)), new Set(stateKeys));
537
571
  const tagLabel = typeof tag === "string" ? tag : tag.displayName ?? "Component";
538
572
  if (isStatic || Object.keys(variants).length === 0) {
539
- const baseComponent2 = React3.forwardRef((props, ref) => {
573
+ const baseComponent2 = React.forwardRef((props, ref) => {
540
574
  const { className, ...rest } = props;
541
575
  const runtimeClassName = normalizeClassName(className);
542
576
  const statesClasses = statesConfig ? resolveStates(statesConfig, stateKeys, statesLookup, props) : "";
543
577
  const mergedBase = twMerge(extractBaseClasses(base), engineClasses, runtimeClassName);
544
578
  const className2 = statesClasses ? `${mergedBase} ${statesClasses}`.trim() : mergedBase;
545
- return React3.createElement(tag, {
579
+ return React.createElement(tag, {
546
580
  ref,
547
581
  ...filterProps(rest),
548
582
  className: className2
@@ -554,15 +588,15 @@ function createComponent(tag, config) {
554
588
  registerSubComponents(result2, base, configSub);
555
589
  return wrapWithSubProxy(result2, tagLabel);
556
590
  }
557
- const baseComponent = React3.forwardRef((props, ref) => {
591
+ const baseComponent = React.forwardRef((props, ref) => {
558
592
  const { className, ...rest } = props;
559
593
  const runtimeClassName = normalizeClassName(className);
560
- const variantClasses = resolveVariants(variants, props);
594
+ const variantClasses = resolveVariants(variants, props, defaultVariants);
561
595
  const compoundClasses = resolveCompound(compoundVariants, props);
562
596
  const statesClasses = statesConfig ? resolveStates(statesConfig, stateKeys, statesLookup, props) : "";
563
597
  const mergedBase = twMerge(extractBaseClasses(base), variantClasses, compoundClasses, engineClasses, runtimeClassName);
564
598
  const className2 = statesClasses ? `${mergedBase} ${statesClasses}`.trim() : mergedBase;
565
- return React3.createElement(tag, {
599
+ return React.createElement(tag, {
566
600
  ref,
567
601
  ...filterProps(rest),
568
602
  className: className2
@@ -596,15 +630,196 @@ function wrapWithSubProxy(component, tagLabel) {
596
630
  const Fallback = ({
597
631
  children,
598
632
  className
599
- }) => React3.createElement("span", { className }, children);
633
+ }) => React.createElement("span", { className }, children);
600
634
  Fallback.displayName = `tw.${tagLabel}.${prop}(fallback)`;
601
635
  return Fallback;
602
636
  }
603
637
  });
604
638
  }
605
639
 
640
+ // packages/domain/core/src/twProxy.ts
641
+ var _parsedTemplateCache = /* @__PURE__ */ new Map();
642
+ function parseTemplate(strings, exprs) {
643
+ const raw = strings.raw.reduce((acc, str, i) => {
644
+ const expr = exprs[i];
645
+ const exprStr = typeof expr === "function" ? "" : expr ?? "";
646
+ return acc + str + String(exprStr);
647
+ }, "");
648
+ const cached = _parsedTemplateCache.get(raw);
649
+ if (cached) return cached;
650
+ const binding = getNativeBinding();
651
+ if (!binding?.parseTemplate) {
652
+ throw new Error("FATAL: Native binding 'parseTemplate' is required but not available.");
653
+ }
654
+ const r = binding.parseTemplate(raw);
655
+ const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
656
+ const result = { base: r.base, subs, hasSubs: r.hasSubs };
657
+ _parsedTemplateCache.set(raw, result);
658
+ return result;
659
+ }
660
+ function makeTag(tag) {
661
+ return ((stringsOrConfig, ...exprs) => {
662
+ if (!Array.isArray(stringsOrConfig) && typeof stringsOrConfig === "object" && stringsOrConfig !== null && !("raw" in stringsOrConfig)) {
663
+ return createComponent(tag, stringsOrConfig);
664
+ }
665
+ const parsed = parseTemplate(stringsOrConfig, exprs);
666
+ const component = createComponent(tag, parsed.base);
667
+ if (parsed.hasSubs) {
668
+ for (const [name, classes] of Object.entries(parsed.subs)) {
669
+ const SubComp = React2.forwardRef(
670
+ ({ children, className }, ref) => React2.createElement("span", {
671
+ ref,
672
+ className: className ? `${classes} ${className}` : classes
673
+ }, children)
674
+ );
675
+ SubComp.displayName = `tw.${typeof tag === "string" ? tag : "component"}.${name}`;
676
+ ;
677
+ component[name] = SubComp;
678
+ }
679
+ }
680
+ return component;
681
+ });
682
+ }
683
+ var HTML_TAGS = [
684
+ "div",
685
+ "section",
686
+ "article",
687
+ "aside",
688
+ "header",
689
+ "footer",
690
+ "main",
691
+ "nav",
692
+ "figure",
693
+ "figcaption",
694
+ "details",
695
+ "summary",
696
+ "h1",
697
+ "h2",
698
+ "h3",
699
+ "h4",
700
+ "h5",
701
+ "h6",
702
+ "p",
703
+ "span",
704
+ "strong",
705
+ "em",
706
+ "b",
707
+ "i",
708
+ "s",
709
+ "u",
710
+ "small",
711
+ "mark",
712
+ "abbr",
713
+ "cite",
714
+ "code",
715
+ "kbd",
716
+ "samp",
717
+ "var",
718
+ "time",
719
+ "address",
720
+ "blockquote",
721
+ "q",
722
+ "del",
723
+ "ins",
724
+ "sub",
725
+ "sup",
726
+ "ul",
727
+ "ol",
728
+ "li",
729
+ "dl",
730
+ "dt",
731
+ "dd",
732
+ "table",
733
+ "thead",
734
+ "tbody",
735
+ "tfoot",
736
+ "tr",
737
+ "th",
738
+ "td",
739
+ "caption",
740
+ "colgroup",
741
+ "col",
742
+ "img",
743
+ "picture",
744
+ "video",
745
+ "audio",
746
+ "source",
747
+ "track",
748
+ "canvas",
749
+ "svg",
750
+ "path",
751
+ "circle",
752
+ "rect",
753
+ "line",
754
+ "polyline",
755
+ "polygon",
756
+ "g",
757
+ "defs",
758
+ "use",
759
+ "symbol",
760
+ "form",
761
+ "input",
762
+ "textarea",
763
+ "select",
764
+ "option",
765
+ "optgroup",
766
+ "button",
767
+ "label",
768
+ "fieldset",
769
+ "legend",
770
+ "output",
771
+ "progress",
772
+ "meter",
773
+ "datalist",
774
+ "a",
775
+ "area",
776
+ "map",
777
+ "iframe",
778
+ "embed",
779
+ "object",
780
+ "pre",
781
+ "hr",
782
+ "br",
783
+ "wbr",
784
+ "dialog",
785
+ "menu",
786
+ "template",
787
+ "slot"
788
+ ];
789
+ function makeServerTag(tag) {
790
+ const baseFactory = makeTag(tag);
791
+ if (typeof window !== "undefined" && true) {
792
+ return ((stringsOrConfig, ...exprs) => {
793
+ const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
794
+ console.warn(
795
+ `[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
796
+ );
797
+ return baseFactory(stringsOrConfig, ...exprs);
798
+ });
799
+ }
800
+ return baseFactory;
801
+ }
802
+ var serverFactories = {};
803
+ for (const tag of HTML_TAGS) {
804
+ serverFactories[tag] = makeServerTag(tag);
805
+ }
806
+ var server = serverFactories;
807
+ var tagFactories = {};
808
+ for (const tag of HTML_TAGS) {
809
+ tagFactories[tag] = makeTag(tag);
810
+ }
811
+ function twCallable(component) {
812
+ return makeTag(component);
813
+ }
814
+ var tw = Object.assign(twCallable, tagFactories, {
815
+ server
816
+ });
817
+
606
818
  // packages/domain/core/src/cv.ts
607
819
  var __generatedRegistry = {};
820
+ function registerVariantTable(componentId, table) {
821
+ __generatedRegistry[componentId] = table;
822
+ }
608
823
  var _sortedVariantKeysCache = /* @__PURE__ */ new Map();
609
824
  function lookupGenerated(componentId, props, defaultVariants, variantKeys) {
610
825
  const table = __generatedRegistry[componentId];
@@ -616,18 +831,100 @@ function lookupGenerated(componentId, props, defaultVariants, variantKeys) {
616
831
  sortedKeys = [...keysToUse].sort();
617
832
  _sortedVariantKeysCache.set(componentId, sortedKeys);
618
833
  }
619
- {
620
- throw new Error("FATAL: Native binding 'buildVariantLookupKey' is required but not available.");
834
+ const binding = getNativeBinding();
835
+ if (!binding?.buildVariantLookupKey) {
836
+ const parts = [];
837
+ for (const k of sortedKeys) {
838
+ const v = props[k] ?? defaultVariants?.[k];
839
+ if (v != null) parts.push(`${k}:${String(v)}`);
840
+ }
841
+ const key2 = parts.join("|");
842
+ return table[key2];
843
+ }
844
+ const relevantDefaults = {};
845
+ const relevantProps = {};
846
+ for (const k of sortedKeys) {
847
+ const dv = defaultVariants?.[k];
848
+ if (dv !== void 0) relevantDefaults[k] = String(dv);
849
+ const pv = props[k];
850
+ if (pv !== void 0 && pv !== null) relevantProps[k] = String(pv);
621
851
  }
852
+ const key = binding.buildVariantLookupKey(
853
+ JSON.stringify(relevantDefaults),
854
+ JSON.stringify(relevantProps)
855
+ );
856
+ return table[key];
857
+ }
858
+ var _configJsonCache = /* @__PURE__ */ new WeakMap();
859
+ function _getConfigJson(config) {
860
+ let json = _configJsonCache.get(config);
861
+ if (!json) {
862
+ const cfgObj = config;
863
+ const cfgStr = JSON.stringify(cfgObj);
864
+ const parsed = JSON.parse(cfgStr);
865
+ if ("defaultVariants" in parsed && !("default_variants" in parsed)) {
866
+ parsed.default_variants = parsed.defaultVariants;
867
+ delete parsed.defaultVariants;
868
+ }
869
+ if ("compoundVariants" in parsed && !("compound_variants" in parsed)) {
870
+ parsed.compound_variants = parsed.compoundVariants;
871
+ delete parsed.compoundVariants;
872
+ }
873
+ if (!("variants" in parsed) || parsed.variants == null) {
874
+ parsed.variants = {};
875
+ }
876
+ json = JSON.stringify(parsed);
877
+ _configJsonCache.set(config, json);
878
+ }
879
+ return json;
622
880
  }
623
881
  function resolveVariantsNative(config, props) {
624
882
  const { variants = {}, defaultVariants = {} } = config;
625
- {
626
- throw new Error("FATAL: Native binding 'resolveVariants' is required but not available. Build cannot continue.");
883
+ const binding = getNativeBinding();
884
+ if (!binding?.resolveVariants) {
885
+ const variantKeys2 = Object.keys(variants);
886
+ const classes = [];
887
+ for (const key of variantKeys2) {
888
+ const value = props[key] ?? defaultVariants[key];
889
+ if (value != null) {
890
+ const variantClass = variants[key]?.[String(value)];
891
+ if (variantClass) classes.push(variantClass);
892
+ }
893
+ }
894
+ if (config.compoundVariants) {
895
+ for (const compound of config.compoundVariants) {
896
+ const { class: compoundClass, ...conditions } = compound;
897
+ const resolved = {};
898
+ for (const key of variantKeys2) {
899
+ resolved[key] = String(
900
+ props[key] ?? defaultVariants[key] ?? ""
901
+ );
902
+ }
903
+ const matches = Object.entries(conditions).every(
904
+ ([k, v]) => resolved[k] === v
905
+ );
906
+ if (matches) classes.push(compoundClass);
907
+ }
908
+ }
909
+ return classes.join(" ");
910
+ }
911
+ const variantKeys = Object.keys(variants);
912
+ const configJson = _getConfigJson(config);
913
+ const cleanProps = {};
914
+ for (const k of variantKeys) {
915
+ const dv = defaultVariants[k];
916
+ if (dv !== void 0 && dv !== null) cleanProps[k] = String(dv);
917
+ }
918
+ for (const k of variantKeys) {
919
+ const v = props[k];
920
+ if (v !== void 0 && v !== null) cleanProps[k] = String(v);
627
921
  }
922
+ const propsJson = JSON.stringify(cleanProps);
923
+ const result = binding.resolveVariants(configJson, propsJson);
924
+ return result.classes;
628
925
  }
629
926
  function cv(config, componentId) {
630
- {
927
+ if (true) {
631
928
  const { variants = {}, defaultVariants = {} } = config;
632
929
  for (const dk of Object.keys(defaultVariants)) {
633
930
  if (!(dk in variants)) {
@@ -645,9 +942,9 @@ function cv(config, componentId) {
645
942
  config.defaultVariants,
646
943
  variantKeys
647
944
  );
648
- result = generated ?? resolveVariantsNative(config);
945
+ result = generated ?? resolveVariantsNative(config, props);
649
946
  } else {
650
- result = resolveVariantsNative(config);
947
+ result = resolveVariantsNative(config, props);
651
948
  }
652
949
  return props.className ? twMerge(result, props.className) : result;
653
950
  };
@@ -666,309 +963,36 @@ function cn(...inputs) {
666
963
  }
667
964
  }
668
965
  if (strings.length === 0) return "";
669
- {
966
+ const native = getNativeBinding();
967
+ if (!native?.resolveClassNames) {
670
968
  throw new Error("Native binding 'resolveClassNames' is required but not available.");
671
969
  }
970
+ return native.resolveClassNames(strings);
672
971
  }
673
972
  function cx(...inputs) {
674
973
  const filtered = inputs.flat().filter(Boolean);
675
974
  if (filtered.length === 0) return "";
676
- {
975
+ const native = getNativeBinding();
976
+ if (!native?.twMergeMany) {
677
977
  throw new Error("Native binding 'twMergeMany' is required but not available.");
678
978
  }
979
+ return native.twMergeMany(filtered);
679
980
  }
680
981
  var cxm = cx;
681
- var TOKEN_ENGINE_KEY = "__TW_TOKEN_ENGINE__";
682
- function tokenVar(name) {
683
- const normalized = name.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
684
- return `--tw-token-${normalized}`;
982
+
983
+ // packages/domain/core/src/styledSystem.ts
984
+ function tokenVarName(prefix, group, name) {
985
+ return `--${prefix}-${group}-${name}`;
685
986
  }
686
- function tokenRef(name) {
687
- return `var(${tokenVar(name)})`;
987
+ function tokenVarRef(prefix, group, name) {
988
+ return `var(${tokenVarName(prefix, group, name)})`;
688
989
  }
689
- var buildRootCss = (tokens) => {
690
- const vars = Object.entries(tokens).map(([name, value]) => ` ${tokenVar(name)}: ${value};`).join("\n");
691
- return `:root {
692
- ${vars}
693
- }`;
694
- };
695
- var createLiveTokenEngine = () => {
696
- const state = {
697
- currentTokens: {},
698
- styleEl: null
699
- };
700
- const subscribers = /* @__PURE__ */ new Set();
701
- const syncStyleEl = () => {
702
- if (typeof document === "undefined") return;
703
- if (!state.styleEl) {
704
- const styleEl = document.createElement("style");
705
- styleEl.id = "tw-live-tokens";
706
- styleEl.setAttribute("data-tw-tokens", "true");
707
- document.head.appendChild(styleEl);
708
- state.styleEl = styleEl;
709
- }
710
- state.styleEl.textContent = buildRootCss(state.currentTokens);
711
- };
712
- const notifySubscribers = () => {
713
- const snapshot = { ...state.currentTokens };
714
- for (const subscriber of subscribers) {
715
- try {
716
- subscriber(snapshot);
717
- } catch {
718
- }
719
- }
720
- };
721
- const setToken2 = (name, value) => {
722
- state.currentTokens = { ...state.currentTokens, [name]: value };
723
- if (typeof document !== "undefined") {
724
- document.documentElement.style.setProperty(tokenVar(name), value);
725
- }
726
- syncStyleEl();
727
- notifySubscribers();
728
- };
729
- const setTokens2 = (tokens) => {
730
- state.currentTokens = { ...state.currentTokens, ...tokens };
731
- if (typeof document !== "undefined") {
732
- const root = document.documentElement;
733
- for (const [name, value] of Object.entries(tokens)) {
734
- root.style.setProperty(tokenVar(name), value);
735
- }
736
- }
737
- syncStyleEl();
738
- notifySubscribers();
739
- };
740
- const applyTokenSet2 = (tokens) => {
741
- if (typeof document !== "undefined") {
742
- const root = document.documentElement;
743
- for (const name of Object.keys(state.currentTokens)) {
744
- if (!(name in tokens)) {
745
- root.style.removeProperty(tokenVar(name));
746
- }
747
- }
748
- for (const [name, value] of Object.entries(tokens)) {
749
- root.style.setProperty(tokenVar(name), value);
750
- }
751
- }
752
- state.currentTokens = { ...tokens };
753
- syncStyleEl();
754
- notifySubscribers();
755
- };
756
- return {
757
- liveToken(tokens) {
758
- setTokens2(tokens);
759
- const vars = {};
760
- for (const name of Object.keys(tokens)) {
761
- vars[name] = tokenRef(name);
762
- }
763
- return {
764
- vars,
765
- get(name) {
766
- return state.currentTokens[name];
767
- },
768
- set(name, value) {
769
- setToken2(name, value);
770
- },
771
- setAll(nextTokens) {
772
- setTokens2(nextTokens);
773
- },
774
- snapshot() {
775
- return { ...state.currentTokens };
776
- }
777
- };
778
- },
779
- getToken(name) {
780
- return state.currentTokens[name];
781
- },
782
- getTokens() {
783
- return { ...state.currentTokens };
784
- },
785
- setToken: setToken2,
786
- setTokens: setTokens2,
787
- applyTokenSet: applyTokenSet2,
788
- generateTokenCssString() {
789
- return buildRootCss(state.currentTokens);
790
- },
791
- subscribe(fn) {
792
- subscribers.add(fn);
793
- return () => {
794
- subscribers.delete(fn);
795
- };
796
- }
797
- };
798
- };
799
- var engine = createLiveTokenEngine();
800
- function liveToken(tokens) {
801
- return engine.liveToken(tokens);
802
- }
803
- function setToken(name, value) {
804
- engine.setToken(name, value);
805
- }
806
- function setTokens(tokens) {
807
- engine.setTokens(tokens);
808
- }
809
- function applyTokenSet(tokens) {
810
- engine.applyTokenSet(tokens);
811
- }
812
- function getToken(name) {
813
- return engine.getToken(name);
814
- }
815
- function getTokens() {
816
- return engine.getTokens();
817
- }
818
- function subscribeTokens(fn) {
819
- return engine.subscribe(fn);
820
- }
821
- function generateTokenCssString() {
822
- return engine.generateTokenCssString();
823
- }
824
- function createUseTokens() {
825
- return function useTokens() {
826
- const [tokens, setTokensState] = React3.useState(engine.getTokens());
827
- React3.useEffect(() => {
828
- setTokensState(engine.getTokens());
829
- return engine.subscribe((nextTokens) => setTokensState(nextTokens));
830
- }, []);
831
- return tokens;
832
- };
833
- }
834
- var liveTokenEngine = {
835
- getToken: engine.getToken,
836
- getTokens: engine.getTokens,
837
- setToken: engine.setToken,
838
- setTokens: engine.setTokens,
839
- applyTokenSet: engine.applyTokenSet,
840
- subscribeTokens: engine.subscribe,
841
- subscribe: engine.subscribe
842
- };
843
- var globalTokenEngine = globalThis;
844
- globalTokenEngine[TOKEN_ENGINE_KEY] = liveTokenEngine;
845
- if (typeof window !== "undefined") {
846
- window.__TW_TOKEN_ENGINE__ = liveTokenEngine;
847
- }
848
- var subComponentRegistry = /* @__PURE__ */ new Map();
849
- function registerSubComponent(entry) {
850
- subComponentRegistry.set(entry.name, entry);
851
- }
852
- function getSubComponent(name) {
853
- return subComponentRegistry.get(name);
854
- }
855
- function getAllSubComponents() {
856
- return Array.from(subComponentRegistry.values());
857
- }
858
- function withSubComponents(Component, subComponentNames) {
859
- const result = { ...Component };
860
- for (const name of subComponentNames) {
861
- const entry = getSubComponent(name);
862
- if (entry) result[name] = entry.component;
863
- }
864
- return result;
865
- }
866
- registerSubComponent({
867
- name: "icon",
868
- component: ({ children, className }) => React3.createElement("span", { className }, children),
869
- defaultClasses: ""
870
- });
871
- registerSubComponent({
872
- name: "text",
873
- component: ({ children, className }) => React3.createElement("span", { className }, children),
874
- defaultClasses: ""
875
- });
876
- registerSubComponent({
877
- name: "badge",
878
- component: ({ children, className }) => React3.createElement(
879
- "span",
880
- {
881
- className: `ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500 text-white ${className || ""}`
882
- },
883
- children
884
- ),
885
- defaultClasses: "ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500 text-white"
886
- });
887
- registerSubComponent({
888
- name: "header",
889
- component: ({ children, className }) => React3.createElement("header", { className: `font-bold text-lg ${className || ""}` }, children),
890
- defaultClasses: "font-bold text-lg"
891
- });
892
- registerSubComponent({
893
- name: "body",
894
- component: ({ children, className }) => React3.createElement("div", { className: `flex-1 ${className || ""}` }, children),
895
- defaultClasses: "flex-1"
896
- });
897
- registerSubComponent({
898
- name: "footer",
899
- component: ({ children, className }) => React3.createElement("footer", { className: `border-t pt-4 ${className || ""}` }, children),
900
- defaultClasses: "border-t pt-4"
901
- });
902
- registerSubComponent({
903
- name: "content",
904
- component: ({ children, className }) => React3.createElement("div", { className }, children),
905
- defaultClasses: ""
906
- });
907
- registerSubComponent({
908
- name: "title",
909
- component: ({ children, className }) => React3.createElement("div", { className: `font-semibold ${className || ""}` }, children),
910
- defaultClasses: "font-semibold"
911
- });
912
- registerSubComponent({
913
- name: "message",
914
- component: ({ children, className }) => React3.createElement("div", { className: `text-sm ${className || ""}` }, children),
915
- defaultClasses: "text-sm"
916
- });
917
- registerSubComponent({
918
- name: "close",
919
- component: ({ children, className }) => React3.createElement("span", { className: `cursor-pointer ${className || ""}` }, children),
920
- defaultClasses: "cursor-pointer"
921
- });
922
- registerSubComponent({
923
- name: "image",
924
- component: ({ className }) => React3.createElement("img", { className }),
925
- defaultClasses: ""
926
- });
927
-
928
- // packages/domain/core/src/styled.ts
929
- function resolveVariantClass(options, props) {
930
- const out = [];
931
- const variants = options.variants ?? {};
932
- const defaults = options.defaultVariants ?? {};
933
- for (const [variantName, valueMap] of Object.entries(variants)) {
934
- const value = props[variantName] ?? defaults[variantName];
935
- if (value === void 0) continue;
936
- const key = String(value);
937
- const cls = valueMap[key];
938
- if (cls) out.push(cls);
939
- }
940
- for (const compound of options.compoundVariants ?? []) {
941
- const matches = Object.entries(compound.variants).every(([k, expected]) => {
942
- const current = props[k] ?? defaults[k];
943
- return String(current) === expected;
944
- });
945
- if (matches) out.push(compound.className);
946
- }
947
- return out;
948
- }
949
- function resolveStyledClassName(options, props = {}) {
950
- const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
951
- return twMerge(...parts);
952
- }
953
- function styled(options) {
954
- return function getClassName(props = {}) {
955
- return resolveStyledClassName(options, props);
956
- };
957
- }
958
-
959
- // packages/domain/core/src/styledSystem.ts
960
- function tokenVarName(prefix, group, name) {
961
- return `--${prefix}-${group}-${name}`;
962
- }
963
- function tokenVarRef(prefix, group, name) {
964
- return `var(${tokenVarName(prefix, group, name)})`;
965
- }
966
- function resolveTokenRef(tokens, prefix, value) {
967
- if (value.startsWith("token:")) {
968
- const path = value.slice(6);
969
- const [group, name] = path.split(".");
970
- if (group && name && tokens[group]?.[name] !== void 0) {
971
- return tokenVarRef(prefix, group, name);
990
+ function resolveTokenRef(tokens, prefix, value) {
991
+ if (value.startsWith("token:")) {
992
+ const path = value.slice(6);
993
+ const [group, name] = path.split(".");
994
+ if (group && name && tokens[group]?.[name] !== void 0) {
995
+ return tokenVarRef(prefix, group, name);
972
996
  }
973
997
  }
974
998
  return value;
@@ -979,13 +1003,15 @@ function injectTokensToRoot(tokens, prefix) {
979
1003
  if (document.getElementById(styleId)) return;
980
1004
  const style = document.createElement("style");
981
1005
  style.id = styleId;
982
- style.textContent = _buildTokenCss();
1006
+ style.textContent = _buildTokenCss(tokens, prefix);
983
1007
  document.head.appendChild(style);
984
1008
  }
985
1009
  function _buildTokenCss(tokens, prefix) {
986
- {
1010
+ const binding = getNativeBinding();
1011
+ if (!binding?.generateSystemTokenCss) {
987
1012
  throw new Error("FATAL: Native binding 'generateSystemTokenCss' is required but not available.");
988
1013
  }
1014
+ return binding.generateSystemTokenCss(JSON.stringify(tokens), prefix);
989
1015
  }
990
1016
  function resolveComponentConfig(config, tokens, prefix) {
991
1017
  const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);
@@ -1085,10 +1111,11 @@ function createStyledSystem(config) {
1085
1111
  for (const [group, map] of Object.entries(updates)) {
1086
1112
  if (!tokens[group]) continue;
1087
1113
  for (const [name, value] of Object.entries(map)) {
1114
+ ;
1088
1115
  tokens[group][name] = value;
1089
1116
  }
1090
1117
  }
1091
- style.textContent = _buildTokenCss();
1118
+ style.textContent = _buildTokenCss(tokens, prefix);
1092
1119
  }
1093
1120
  function getConfig(name) {
1094
1121
  return resolvedConfigs.get(name);
@@ -1101,175 +1128,37 @@ function createStyledSystem(config) {
1101
1128
  tokens
1102
1129
  });
1103
1130
  }
1104
- var _parsedTemplateCache = /* @__PURE__ */ new Map();
1105
- function parseTemplate(strings, exprs) {
1106
- const raw = strings.raw.reduce((acc, str, i) => {
1107
- const expr = exprs[i];
1108
- const exprStr = typeof expr === "function" ? "" : expr ?? "";
1109
- return acc + str + String(exprStr);
1110
- }, "");
1111
- const cached = _parsedTemplateCache.get(raw);
1112
- if (cached) return cached;
1113
- {
1114
- throw new Error("FATAL: Native binding 'parseTemplate' is required but not available.");
1115
- }
1116
- }
1117
- function makeTag(tag) {
1118
- return ((stringsOrConfig, ...exprs) => {
1119
- if (!Array.isArray(stringsOrConfig) && typeof stringsOrConfig === "object" && stringsOrConfig !== null && !("raw" in stringsOrConfig)) {
1120
- return createComponent(tag, stringsOrConfig);
1121
- }
1122
- const parsed = parseTemplate(stringsOrConfig, exprs);
1123
- const component = createComponent(tag, parsed.base);
1124
- if (parsed.hasSubs) {
1125
- for (const [name, classes] of Object.entries(parsed.subs)) {
1126
- const SubComp = React3.forwardRef(
1127
- ({ children, className }, ref) => React3.createElement("span", {
1128
- ref,
1129
- className: className ? `${classes} ${className}` : classes
1130
- }, children)
1131
- );
1132
- SubComp.displayName = `tw.${typeof tag === "string" ? tag : "component"}.${name}`;
1133
- component[name] = SubComp;
1134
- }
1135
- }
1136
- return component;
1137
- });
1138
- }
1139
- var HTML_TAGS = [
1140
- "div",
1141
- "section",
1142
- "article",
1143
- "aside",
1144
- "header",
1145
- "footer",
1146
- "main",
1147
- "nav",
1148
- "figure",
1149
- "figcaption",
1150
- "details",
1151
- "summary",
1152
- "h1",
1153
- "h2",
1154
- "h3",
1155
- "h4",
1156
- "h5",
1157
- "h6",
1158
- "p",
1159
- "span",
1160
- "strong",
1161
- "em",
1162
- "b",
1163
- "i",
1164
- "s",
1165
- "u",
1166
- "small",
1167
- "mark",
1168
- "abbr",
1169
- "cite",
1170
- "code",
1171
- "kbd",
1172
- "samp",
1173
- "var",
1174
- "time",
1175
- "address",
1176
- "blockquote",
1177
- "q",
1178
- "del",
1179
- "ins",
1180
- "sub",
1181
- "sup",
1182
- "ul",
1183
- "ol",
1184
- "li",
1185
- "dl",
1186
- "dt",
1187
- "dd",
1188
- "table",
1189
- "thead",
1190
- "tbody",
1191
- "tfoot",
1192
- "tr",
1193
- "th",
1194
- "td",
1195
- "caption",
1196
- "colgroup",
1197
- "col",
1198
- "img",
1199
- "picture",
1200
- "video",
1201
- "audio",
1202
- "source",
1203
- "track",
1204
- "canvas",
1205
- "svg",
1206
- "path",
1207
- "circle",
1208
- "rect",
1209
- "line",
1210
- "polyline",
1211
- "polygon",
1212
- "g",
1213
- "defs",
1214
- "use",
1215
- "symbol",
1216
- "form",
1217
- "input",
1218
- "textarea",
1219
- "select",
1220
- "option",
1221
- "optgroup",
1222
- "button",
1223
- "label",
1224
- "fieldset",
1225
- "legend",
1226
- "output",
1227
- "progress",
1228
- "meter",
1229
- "datalist",
1230
- "a",
1231
- "area",
1232
- "map",
1233
- "iframe",
1234
- "embed",
1235
- "object",
1236
- "pre",
1237
- "hr",
1238
- "br",
1239
- "wbr",
1240
- "dialog",
1241
- "menu",
1242
- "template",
1243
- "slot"
1244
- ];
1245
- function makeServerTag(tag) {
1246
- const baseFactory = makeTag(tag);
1247
- if (typeof window !== "undefined" && true) {
1248
- return ((stringsOrConfig, ...exprs) => {
1249
- const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
1250
- console.warn(
1251
- `[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
1252
- );
1253
- return baseFactory(stringsOrConfig, ...exprs);
1131
+
1132
+ // packages/domain/core/src/styled.ts
1133
+ function resolveVariantClass(options, props) {
1134
+ const out = [];
1135
+ const variants = options.variants ?? {};
1136
+ const defaults = options.defaultVariants ?? {};
1137
+ for (const [variantName, valueMap] of Object.entries(variants)) {
1138
+ const value = props[variantName] ?? defaults[variantName];
1139
+ if (value === void 0) continue;
1140
+ const key = String(value);
1141
+ const cls = valueMap[key];
1142
+ if (cls) out.push(cls);
1143
+ }
1144
+ for (const compound of options.compoundVariants ?? []) {
1145
+ const matches = Object.entries(compound.variants).every(([k, expected]) => {
1146
+ const current = props[k] ?? defaults[k];
1147
+ return String(current) === expected;
1254
1148
  });
1149
+ if (matches) out.push(compound.className);
1255
1150
  }
1256
- return baseFactory;
1257
- }
1258
- var serverFactories = {};
1259
- for (const tag of HTML_TAGS) {
1260
- serverFactories[tag] = makeServerTag(tag);
1151
+ return out;
1261
1152
  }
1262
- var server = serverFactories;
1263
- var tagFactories = {};
1264
- for (const tag of HTML_TAGS) {
1265
- tagFactories[tag] = makeTag(tag);
1153
+ function resolveStyledClassName(options, props = {}) {
1154
+ const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
1155
+ return twMerge(...parts);
1266
1156
  }
1267
- function twCallable(component) {
1268
- return makeTag(component);
1157
+ function styled(options) {
1158
+ return function getClassName(props = {}) {
1159
+ return resolveStyledClassName(options, props);
1160
+ };
1269
1161
  }
1270
- var tw = Object.assign(twCallable, tagFactories, {
1271
- server
1272
- });
1273
1162
 
1274
1163
  // packages/domain/core/src/twTheme.ts
1275
1164
  function cssVar(varName, fallback) {
@@ -1336,6 +1225,298 @@ var v4Tokens = {
1336
1225
  fontMono: twVar("font", "font-mono")
1337
1226
  };
1338
1227
 
1339
- export { applyTokenSet, cn, tokenRef as containerRef, createComponent, createStyledSystem, createTheme, createTwMerge, createUseTokens, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, generateTokenCssString, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, getToken, getTokens, liveToken, mergeWithRules, processContainer, processState, registerSubComponent, resolveStyledClassName, server, setToken, setTokens, styled, subscribeTokens, t, tokenRef, tokenVar, tw, twMerge, twVar, v4Tokens, withSubComponents };
1340
- //# sourceMappingURL=index.browser.mjs.map
1228
+ // packages/domain/theme/src/liveTokenEngine.ts
1229
+ import React3 from "react";
1230
+ var TOKEN_ENGINE_KEY = "__TW_TOKEN_ENGINE__";
1231
+ function tokenVar(name) {
1232
+ const normalized = name.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
1233
+ return `--tw-token-${normalized}`;
1234
+ }
1235
+ function tokenRef(name) {
1236
+ return `var(${tokenVar(name)})`;
1237
+ }
1238
+ var buildRootCss = (tokens) => {
1239
+ const vars = Object.entries(tokens).map(([name, value]) => ` ${tokenVar(name)}: ${value};`).join("\n");
1240
+ return `:root {
1241
+ ${vars}
1242
+ }`;
1243
+ };
1244
+ var createLiveTokenEngine = () => {
1245
+ const state = {
1246
+ currentTokens: {},
1247
+ styleEl: null
1248
+ };
1249
+ const subscribers = /* @__PURE__ */ new Set();
1250
+ const syncStyleEl = () => {
1251
+ if (typeof document === "undefined") return;
1252
+ if (!state.styleEl) {
1253
+ const styleEl = document.createElement("style");
1254
+ styleEl.id = "tw-live-tokens";
1255
+ styleEl.setAttribute("data-tw-tokens", "true");
1256
+ document.head.appendChild(styleEl);
1257
+ state.styleEl = styleEl;
1258
+ }
1259
+ state.styleEl.textContent = buildRootCss(state.currentTokens);
1260
+ };
1261
+ const notifySubscribers = () => {
1262
+ const snapshot = { ...state.currentTokens };
1263
+ for (const subscriber of subscribers) {
1264
+ try {
1265
+ subscriber(snapshot);
1266
+ } catch {
1267
+ }
1268
+ }
1269
+ };
1270
+ const setToken2 = (name, value) => {
1271
+ state.currentTokens = { ...state.currentTokens, [name]: value };
1272
+ if (typeof document !== "undefined") {
1273
+ document.documentElement.style.setProperty(tokenVar(name), value);
1274
+ }
1275
+ syncStyleEl();
1276
+ notifySubscribers();
1277
+ };
1278
+ const setTokens2 = (tokens) => {
1279
+ state.currentTokens = { ...state.currentTokens, ...tokens };
1280
+ if (typeof document !== "undefined") {
1281
+ const root = document.documentElement;
1282
+ for (const [name, value] of Object.entries(tokens)) {
1283
+ root.style.setProperty(tokenVar(name), value);
1284
+ }
1285
+ }
1286
+ syncStyleEl();
1287
+ notifySubscribers();
1288
+ };
1289
+ const applyTokenSet2 = (tokens) => {
1290
+ if (typeof document !== "undefined") {
1291
+ const root = document.documentElement;
1292
+ for (const name of Object.keys(state.currentTokens)) {
1293
+ if (!(name in tokens)) {
1294
+ root.style.removeProperty(tokenVar(name));
1295
+ }
1296
+ }
1297
+ for (const [name, value] of Object.entries(tokens)) {
1298
+ root.style.setProperty(tokenVar(name), value);
1299
+ }
1300
+ }
1301
+ state.currentTokens = { ...tokens };
1302
+ syncStyleEl();
1303
+ notifySubscribers();
1304
+ };
1305
+ return {
1306
+ liveToken(tokens) {
1307
+ setTokens2(tokens);
1308
+ const vars = {};
1309
+ for (const name of Object.keys(tokens)) {
1310
+ vars[name] = tokenRef(name);
1311
+ }
1312
+ return {
1313
+ vars,
1314
+ get(name) {
1315
+ return state.currentTokens[name];
1316
+ },
1317
+ set(name, value) {
1318
+ setToken2(name, value);
1319
+ },
1320
+ setAll(nextTokens) {
1321
+ setTokens2(nextTokens);
1322
+ },
1323
+ snapshot() {
1324
+ return { ...state.currentTokens };
1325
+ }
1326
+ };
1327
+ },
1328
+ getToken(name) {
1329
+ return state.currentTokens[name];
1330
+ },
1331
+ getTokens() {
1332
+ return { ...state.currentTokens };
1333
+ },
1334
+ setToken: setToken2,
1335
+ setTokens: setTokens2,
1336
+ applyTokenSet: applyTokenSet2,
1337
+ generateTokenCssString() {
1338
+ return buildRootCss(state.currentTokens);
1339
+ },
1340
+ subscribe(fn) {
1341
+ subscribers.add(fn);
1342
+ return () => {
1343
+ subscribers.delete(fn);
1344
+ };
1345
+ }
1346
+ };
1347
+ };
1348
+ var engine = createLiveTokenEngine();
1349
+ function liveToken(tokens) {
1350
+ return engine.liveToken(tokens);
1351
+ }
1352
+ function setToken(name, value) {
1353
+ engine.setToken(name, value);
1354
+ }
1355
+ function setTokens(tokens) {
1356
+ engine.setTokens(tokens);
1357
+ }
1358
+ function applyTokenSet(tokens) {
1359
+ engine.applyTokenSet(tokens);
1360
+ }
1361
+ function getToken(name) {
1362
+ return engine.getToken(name);
1363
+ }
1364
+ function getTokens() {
1365
+ return engine.getTokens();
1366
+ }
1367
+ function subscribeTokens(fn) {
1368
+ return engine.subscribe(fn);
1369
+ }
1370
+ function generateTokenCssString() {
1371
+ return engine.generateTokenCssString();
1372
+ }
1373
+ function createUseTokens() {
1374
+ return function useTokens() {
1375
+ const [tokens, setTokensState] = React3.useState(engine.getTokens());
1376
+ React3.useEffect(() => {
1377
+ setTokensState(engine.getTokens());
1378
+ return engine.subscribe((nextTokens) => setTokensState(nextTokens));
1379
+ }, []);
1380
+ return tokens;
1381
+ };
1382
+ }
1383
+ var liveTokenEngine = {
1384
+ getToken: engine.getToken,
1385
+ getTokens: engine.getTokens,
1386
+ setToken: engine.setToken,
1387
+ setTokens: engine.setTokens,
1388
+ applyTokenSet: engine.applyTokenSet,
1389
+ subscribeTokens: engine.subscribe,
1390
+ subscribe: engine.subscribe
1391
+ };
1392
+ var globalTokenEngine = globalThis;
1393
+ globalTokenEngine[TOKEN_ENGINE_KEY] = liveTokenEngine;
1394
+ if (typeof window !== "undefined") {
1395
+ window.__TW_TOKEN_ENGINE__ = liveTokenEngine;
1396
+ }
1397
+
1398
+ // packages/domain/core/src/registry.ts
1399
+ import React4 from "react";
1400
+ var subComponentRegistry = /* @__PURE__ */ new Map();
1401
+ function registerSubComponent(entry) {
1402
+ subComponentRegistry.set(entry.name, entry);
1403
+ }
1404
+ function getSubComponent(name) {
1405
+ return subComponentRegistry.get(name);
1406
+ }
1407
+ function getAllSubComponents() {
1408
+ return Array.from(subComponentRegistry.values());
1409
+ }
1410
+ function withSubComponents(Component, subComponentNames) {
1411
+ const result = { ...Component };
1412
+ for (const name of subComponentNames) {
1413
+ const entry = getSubComponent(name);
1414
+ if (entry) result[name] = entry.component;
1415
+ }
1416
+ return result;
1417
+ }
1418
+ registerSubComponent({
1419
+ name: "icon",
1420
+ component: ({ children, className }) => React4.createElement("span", { className }, children),
1421
+ defaultClasses: ""
1422
+ });
1423
+ registerSubComponent({
1424
+ name: "text",
1425
+ component: ({ children, className }) => React4.createElement("span", { className }, children),
1426
+ defaultClasses: ""
1427
+ });
1428
+ registerSubComponent({
1429
+ name: "badge",
1430
+ component: ({ children, className }) => React4.createElement(
1431
+ "span",
1432
+ {
1433
+ className: `ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500 text-white ${className || ""}`
1434
+ },
1435
+ children
1436
+ ),
1437
+ defaultClasses: "ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500 text-white"
1438
+ });
1439
+ registerSubComponent({
1440
+ name: "header",
1441
+ component: ({ children, className }) => React4.createElement("header", { className: `font-bold text-lg ${className || ""}` }, children),
1442
+ defaultClasses: "font-bold text-lg"
1443
+ });
1444
+ registerSubComponent({
1445
+ name: "body",
1446
+ component: ({ children, className }) => React4.createElement("div", { className: `flex-1 ${className || ""}` }, children),
1447
+ defaultClasses: "flex-1"
1448
+ });
1449
+ registerSubComponent({
1450
+ name: "footer",
1451
+ component: ({ children, className }) => React4.createElement("footer", { className: `border-t pt-4 ${className || ""}` }, children),
1452
+ defaultClasses: "border-t pt-4"
1453
+ });
1454
+ registerSubComponent({
1455
+ name: "content",
1456
+ component: ({ children, className }) => React4.createElement("div", { className }, children),
1457
+ defaultClasses: ""
1458
+ });
1459
+ registerSubComponent({
1460
+ name: "title",
1461
+ component: ({ children, className }) => React4.createElement("div", { className: `font-semibold ${className || ""}` }, children),
1462
+ defaultClasses: "font-semibold"
1463
+ });
1464
+ registerSubComponent({
1465
+ name: "message",
1466
+ component: ({ children, className }) => React4.createElement("div", { className: `text-sm ${className || ""}` }, children),
1467
+ defaultClasses: "text-sm"
1468
+ });
1469
+ registerSubComponent({
1470
+ name: "close",
1471
+ component: ({ children, className }) => React4.createElement("span", { className: `cursor-pointer ${className || ""}` }, children),
1472
+ defaultClasses: "cursor-pointer"
1473
+ });
1474
+ registerSubComponent({
1475
+ name: "image",
1476
+ component: ({ className }) => React4.createElement("img", { className }),
1477
+ defaultClasses: ""
1478
+ });
1479
+ export {
1480
+ applyTokenSet,
1481
+ cn,
1482
+ tokenRef as containerRef,
1483
+ createComponent,
1484
+ createStyledSystem,
1485
+ createTheme,
1486
+ createTwMerge,
1487
+ createUseTokens,
1488
+ cssVar,
1489
+ cv,
1490
+ cx,
1491
+ cxm,
1492
+ generateContainerCss,
1493
+ generateStateCss,
1494
+ generateTokenCssString,
1495
+ getAllSubComponents,
1496
+ getContainerRegistry,
1497
+ getStateRegistry,
1498
+ getSubComponent,
1499
+ getToken,
1500
+ getTokens,
1501
+ liveToken,
1502
+ mergeWithRules,
1503
+ processContainer,
1504
+ processState,
1505
+ registerSubComponent,
1506
+ registerVariantTable,
1507
+ resolveStyledClassName,
1508
+ server,
1509
+ setToken,
1510
+ setTokens,
1511
+ styled,
1512
+ subscribeTokens,
1513
+ t,
1514
+ tokenRef,
1515
+ tokenVar,
1516
+ tw,
1517
+ twMerge,
1518
+ twVar,
1519
+ v4Tokens,
1520
+ withSubComponents
1521
+ };
1341
1522
  //# sourceMappingURL=index.browser.mjs.map