tailwind-styled-v4 5.1.12 → 5.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,22 +28,27 @@ if (typeof window !== "undefined") {
28
28
  window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
29
29
  }
30
30
  var _hashContainerCache = /* @__PURE__ */ new Map();
31
+ function _fnvHash6(s) {
32
+ let h = 2166136261;
33
+ for (let i = 0; i < s.length; i++) {
34
+ h ^= s.charCodeAt(i);
35
+ h = Math.imul(h, 16777619) >>> 0;
36
+ }
37
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
38
+ }
31
39
  function hashContainer(tag, container, name) {
32
40
  const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
33
41
  const cached = _hashContainerCache.get(sortedKey);
34
42
  if (cached) return cached;
35
43
  const native = getNativeBinding();
36
- if (!native?.hashContent) {
37
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
38
- }
39
- const id = `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
44
+ const id = native?.hashContent ? `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-cq-${_fnvHash6(sortedKey)}`;
40
45
  _hashContainerCache.set(sortedKey, id);
41
46
  return id;
42
47
  }
43
48
  function layoutClassesToCss(classes) {
44
49
  const native = getNativeBinding();
45
50
  if (!native?.layoutClassesToCss) {
46
- throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
51
+ return "";
47
52
  }
48
53
  return native.layoutClassesToCss(classes);
49
54
  }
@@ -200,96 +205,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
200
205
  var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
201
206
  var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
202
207
  var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
203
- function conflictGroup(base) {
204
- const bracket = base.indexOf("[");
208
+ function conflictGroup(base, prefix = "") {
209
+ const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
210
+ const bracket = b.indexOf("[");
205
211
  if (bracket !== -1) {
206
- const prefix = base.slice(0, bracket).replace(/-+$/, "");
207
- return prefix.length > 0 ? prefix : "arbitrary";
208
- }
209
- if (DISPLAY_VALUES.has(base)) return "display";
210
- if (POSITION_VALUES.has(base)) return "position";
211
- if (base.startsWith("overflow-x-")) return "overflow-x";
212
- if (base.startsWith("overflow-y-")) return "overflow-y";
213
- if (base.startsWith("overflow-")) return "overflow";
214
- if (base.startsWith("flex-")) return "flex";
215
- if (base.startsWith("grid-cols-")) return "grid-cols";
216
- if (base.startsWith("grid-rows-")) return "grid-rows";
217
- if (base.startsWith("grid-flow-")) return "grid-flow";
218
- if (base.startsWith("col-")) return "col";
219
- if (base.startsWith("row-")) return "row";
220
- if (base === "grow" || base.startsWith("grow-")) return "grow";
221
- if (base === "shrink" || base.startsWith("shrink-")) return "shrink";
222
- if (base.startsWith("gap-x-")) return "gap-x";
223
- if (base.startsWith("gap-y-")) return "gap-y";
224
- if (base.startsWith("gap-")) return "gap";
225
- if (base.startsWith("justify-items-")) return "justify-items";
226
- if (base.startsWith("justify-self-")) return "justify-self";
227
- if (base.startsWith("justify-")) return "justify";
228
- if (base.startsWith("items-")) return "items";
229
- if (base.startsWith("self-")) return "self";
230
- if (base.startsWith("place-content-")) return "place-content";
231
- if (base.startsWith("place-items-")) return "place-items";
232
- if (base.startsWith("place-self-")) return "place-self";
233
- if (base.startsWith("content-")) return "content";
234
- if (base.startsWith("px-")) return "px";
235
- if (base.startsWith("py-")) return "py";
236
- if (base.startsWith("pt-")) return "pt";
237
- if (base.startsWith("pr-")) return "pr";
238
- if (base.startsWith("pb-")) return "pb";
239
- if (base.startsWith("pl-")) return "pl";
240
- if (base.startsWith("ps-")) return "ps";
241
- if (base.startsWith("pe-")) return "pe";
242
- if (base.startsWith("p-")) return "p";
243
- if (base.startsWith("mx-")) return "mx";
244
- if (base.startsWith("my-")) return "my";
245
- if (base.startsWith("mt-")) return "mt";
246
- if (base.startsWith("mr-")) return "mr";
247
- if (base.startsWith("mb-")) return "mb";
248
- if (base.startsWith("ml-")) return "ml";
249
- if (base.startsWith("ms-")) return "ms";
250
- if (base.startsWith("me-")) return "me";
251
- if (base === "-m" || base.startsWith("m-") || base.startsWith("-m-")) return "m";
252
- if (base.startsWith("space-x-")) return "space-x";
253
- if (base.startsWith("space-y-")) return "space-y";
254
- if (base.startsWith("size-")) return "size";
255
- if (base.startsWith("min-w-")) return "min-w";
256
- if (base.startsWith("max-w-")) return "max-w";
257
- if (base.startsWith("w-")) return "w";
258
- if (base.startsWith("min-h-")) return "min-h";
259
- if (base.startsWith("max-h-")) return "max-h";
260
- if (base.startsWith("h-")) return "h";
261
- if (base.startsWith("inset-x-")) return "inset-x";
262
- if (base.startsWith("inset-y-")) return "inset-y";
263
- if (base.startsWith("inset-")) return "inset";
264
- if (base.startsWith("top-")) return "top";
265
- if (base.startsWith("right-") || base.startsWith("end-")) return "right";
266
- if (base.startsWith("bottom-")) return "bottom";
267
- if (base.startsWith("left-") || base.startsWith("start-")) return "left";
268
- if (base.startsWith("z-")) return "z";
269
- if (base.startsWith("opacity-")) return "opacity";
270
- if (base.startsWith("bg-")) {
271
- if (base.startsWith("bg-opacity-")) return "bg-opacity";
212
+ const grp = b.slice(0, bracket).replace(/-+$/, "");
213
+ return grp.length > 0 ? grp : "arbitrary";
214
+ }
215
+ if (DISPLAY_VALUES.has(b)) return "display";
216
+ if (POSITION_VALUES.has(b)) return "position";
217
+ if (b.startsWith("overflow-x-")) return "overflow-x";
218
+ if (b.startsWith("overflow-y-")) return "overflow-y";
219
+ if (b.startsWith("overflow-")) return "overflow";
220
+ if (b.startsWith("flex-")) return "flex";
221
+ if (b.startsWith("grid-cols-")) return "grid-cols";
222
+ if (b.startsWith("grid-rows-")) return "grid-rows";
223
+ if (b.startsWith("grid-flow-")) return "grid-flow";
224
+ if (b.startsWith("col-")) return "col";
225
+ if (b.startsWith("row-")) return "row";
226
+ if (b === "grow" || b.startsWith("grow-")) return "grow";
227
+ if (b === "shrink" || b.startsWith("shrink-")) return "shrink";
228
+ if (b.startsWith("gap-x-")) return "gap-x";
229
+ if (b.startsWith("gap-y-")) return "gap-y";
230
+ if (b.startsWith("gap-")) return "gap";
231
+ if (b.startsWith("justify-items-")) return "justify-items";
232
+ if (b.startsWith("justify-self-")) return "justify-self";
233
+ if (b.startsWith("justify-")) return "justify";
234
+ if (b.startsWith("items-")) return "items";
235
+ if (b.startsWith("self-")) return "self";
236
+ if (b.startsWith("place-content-")) return "place-content";
237
+ if (b.startsWith("place-items-")) return "place-items";
238
+ if (b.startsWith("place-self-")) return "place-self";
239
+ if (b.startsWith("content-")) return "content";
240
+ if (b.startsWith("px-")) return "px";
241
+ if (b.startsWith("py-")) return "py";
242
+ if (b.startsWith("pt-")) return "pt";
243
+ if (b.startsWith("pr-")) return "pr";
244
+ if (b.startsWith("pb-")) return "pb";
245
+ if (b.startsWith("pl-")) return "pl";
246
+ if (b.startsWith("ps-")) return "ps";
247
+ if (b.startsWith("pe-")) return "pe";
248
+ if (b.startsWith("p-")) return "p";
249
+ if (b.startsWith("mx-")) return "mx";
250
+ if (b.startsWith("my-")) return "my";
251
+ if (b.startsWith("mt-")) return "mt";
252
+ if (b.startsWith("mr-")) return "mr";
253
+ if (b.startsWith("mb-")) return "mb";
254
+ if (b.startsWith("ml-")) return "ml";
255
+ if (b.startsWith("ms-")) return "ms";
256
+ if (b.startsWith("me-")) return "me";
257
+ if (b === "-m" || b.startsWith("m-") || b.startsWith("-m-")) return "m";
258
+ if (b.startsWith("space-x-")) return "space-x";
259
+ if (b.startsWith("space-y-")) return "space-y";
260
+ if (b.startsWith("size-")) return "size";
261
+ if (b.startsWith("min-w-")) return "min-w";
262
+ if (b.startsWith("max-w-")) return "max-w";
263
+ if (b.startsWith("w-")) return "w";
264
+ if (b.startsWith("min-h-")) return "min-h";
265
+ if (b.startsWith("max-h-")) return "max-h";
266
+ if (b.startsWith("h-")) return "h";
267
+ if (b.startsWith("inset-x-")) return "inset-x";
268
+ if (b.startsWith("inset-y-")) return "inset-y";
269
+ if (b.startsWith("inset-")) return "inset";
270
+ if (b.startsWith("top-")) return "top";
271
+ if (b.startsWith("right-") || b.startsWith("end-")) return "right";
272
+ if (b.startsWith("bottom-")) return "bottom";
273
+ if (b.startsWith("left-") || b.startsWith("start-")) return "left";
274
+ if (b.startsWith("z-")) return "z";
275
+ if (b.startsWith("opacity-")) return "opacity";
276
+ if (b.startsWith("bg-")) {
277
+ if (b.startsWith("bg-opacity-")) return "bg-opacity";
272
278
  return "bg";
273
279
  }
274
- if (base.startsWith("from-")) return "from";
275
- if (base.startsWith("via-")) return "via";
276
- if (base.startsWith("to-")) return "to";
277
- if (base.startsWith("text-")) {
278
- const suffix = base.slice("text-".length);
280
+ if (b.startsWith("from-")) return "from";
281
+ if (b.startsWith("via-")) return "via";
282
+ if (b.startsWith("to-")) return "to";
283
+ if (b.startsWith("text-")) {
284
+ const suffix = b.slice("text-".length);
279
285
  if (isTextSize(suffix)) return "text-size";
280
286
  if (suffix.startsWith("opacity-")) return "text-opacity";
281
287
  if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
282
288
  return "text-color";
283
289
  }
284
- if (base.startsWith("font-")) {
285
- const suffix = base.slice("font-".length);
290
+ if (b.startsWith("font-")) {
291
+ const suffix = b.slice("font-".length);
286
292
  if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
287
293
  return "font-family";
288
294
  }
289
- if (base.startsWith("leading-")) return "leading";
290
- if (base.startsWith("tracking-")) return "tracking";
291
- if (base.startsWith("border-")) {
292
- const suffix = base.slice("border-".length);
295
+ if (b.startsWith("leading-")) return "leading";
296
+ if (b.startsWith("tracking-")) return "tracking";
297
+ if (b.startsWith("border-")) {
298
+ const suffix = b.slice("border-".length);
293
299
  const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
294
300
  if (sidePrefix) {
295
301
  const side = suffix.slice(0, 1);
@@ -303,67 +309,67 @@ function conflictGroup(base) {
303
309
  if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
304
310
  return "border-color";
305
311
  }
306
- if (base === "border") return "border-width";
307
- if (base.startsWith("outline-")) return "outline";
308
- if (base === "outline") return "outline";
309
- 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")) {
310
- const firstChar = base.slice("rounded-".length).charAt(0) || "x";
312
+ if (b === "border") return "border-width";
313
+ if (b.startsWith("outline-")) return "outline";
314
+ if (b === "outline") return "outline";
315
+ 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")) {
316
+ const firstChar = b.slice("rounded-".length).charAt(0) || "x";
311
317
  return `rounded-${firstChar}`;
312
318
  }
313
- if (base === "rounded" || base.startsWith("rounded-")) return "rounded";
314
- if (base === "shadow" || base.startsWith("shadow-")) return "shadow";
315
- if (base.startsWith("ring-offset-")) return "ring-offset";
316
- if (base === "ring") return "ring-width";
317
- if (base.startsWith("ring-")) {
318
- const rest = base.slice("ring-".length);
319
+ if (b === "rounded" || b.startsWith("rounded-")) return "rounded";
320
+ if (b === "shadow" || b.startsWith("shadow-")) return "shadow";
321
+ if (b.startsWith("ring-offset-")) return "ring-offset";
322
+ if (b === "ring") return "ring-width";
323
+ if (b.startsWith("ring-")) {
324
+ const rest = b.slice("ring-".length);
319
325
  const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
320
326
  if (isWidth) return "ring-width";
321
327
  if (rest === "inset") return "ring-inset";
322
328
  return "ring-color";
323
329
  }
324
- if (base.startsWith("rotate-")) return "rotate";
325
- if (base.startsWith("scale-x-")) return "scale-x";
326
- if (base.startsWith("scale-y-")) return "scale-y";
327
- if (base.startsWith("scale-")) return "scale";
328
- if (base.startsWith("translate-x-")) return "translate-x";
329
- if (base.startsWith("translate-y-")) return "translate-y";
330
- if (base.startsWith("skew-x-")) return "skew-x";
331
- if (base.startsWith("skew-y-")) return "skew-y";
332
- if (base === "transition" || base.startsWith("transition-")) return "transition";
333
- if (base.startsWith("duration-")) return "duration";
334
- if (base.startsWith("ease-")) return "ease";
335
- if (base.startsWith("delay-")) return "delay";
336
- if (base === "animate" || base.startsWith("animate-")) return "animate";
337
- if (base.startsWith("cursor-")) return "cursor";
338
- if (base.startsWith("pointer-events-")) return "pointer-events";
339
- if (base.startsWith("select-")) return "select";
340
- if (base === "visible" || base === "invisible" || base === "collapse") return "visibility";
341
- if (base.startsWith("object-")) return "object";
342
- if (base.startsWith("aspect-")) return "aspect";
343
- if (base.startsWith("order-")) return "order";
344
- if (base.startsWith("whitespace-")) return "whitespace";
345
- if (base.startsWith("list-")) return "list";
346
- if (base.startsWith("fill-")) return "fill";
347
- if (base.startsWith("stroke-")) return "stroke";
348
- if (base.startsWith("backdrop-")) {
349
- const rest = base.slice("backdrop-".length);
330
+ if (b.startsWith("rotate-")) return "rotate";
331
+ if (b.startsWith("scale-x-")) return "scale-x";
332
+ if (b.startsWith("scale-y-")) return "scale-y";
333
+ if (b.startsWith("scale-")) return "scale";
334
+ if (b.startsWith("translate-x-")) return "translate-x";
335
+ if (b.startsWith("translate-y-")) return "translate-y";
336
+ if (b.startsWith("skew-x-")) return "skew-x";
337
+ if (b.startsWith("skew-y-")) return "skew-y";
338
+ if (b === "transition" || b.startsWith("transition-")) return "transition";
339
+ if (b.startsWith("duration-")) return "duration";
340
+ if (b.startsWith("ease-")) return "ease";
341
+ if (b.startsWith("delay-")) return "delay";
342
+ if (b === "animate" || b.startsWith("animate-")) return "animate";
343
+ if (b.startsWith("cursor-")) return "cursor";
344
+ if (b.startsWith("pointer-events-")) return "pointer-events";
345
+ if (b.startsWith("select-")) return "select";
346
+ if (b === "visible" || b === "invisible" || b === "collapse") return "visibility";
347
+ if (b.startsWith("object-")) return "object";
348
+ if (b.startsWith("aspect-")) return "aspect";
349
+ if (b.startsWith("order-")) return "order";
350
+ if (b.startsWith("whitespace-")) return "whitespace";
351
+ if (b.startsWith("list-")) return "list";
352
+ if (b.startsWith("fill-")) return "fill";
353
+ if (b.startsWith("stroke-")) return "stroke";
354
+ if (b.startsWith("backdrop-")) {
355
+ const rest = b.slice("backdrop-".length);
350
356
  const seg = rest.split("-")[0] || "x";
351
357
  return `backdrop-${seg}`;
352
358
  }
353
- if (base.startsWith("scroll-")) return "scroll";
354
- if (base.startsWith("snap-")) return "snap";
355
- if (base.startsWith("touch-")) return "touch";
356
- if (base.startsWith("decoration-")) return "text-decoration";
357
- if (base.startsWith("caret-")) return "caret";
358
- if (base.startsWith("accent-")) return "accent";
359
- if (base.startsWith("appearance-")) return "appearance";
360
- if (base === "isolate" || base === "isolation-auto") return "isolation";
361
- if (base.startsWith("mix-blend-")) return "mix-blend";
362
- if (base.startsWith("bg-blend-")) return "bg-blend";
363
- if (base.startsWith("float-")) return "float";
364
- if (base.startsWith("clear-")) return "clear";
365
- if (base.startsWith("break-")) return "break";
366
- if (base.startsWith("columns-")) return "columns";
359
+ if (b.startsWith("scroll-")) return "scroll";
360
+ if (b.startsWith("snap-")) return "snap";
361
+ if (b.startsWith("touch-")) return "touch";
362
+ if (b.startsWith("decoration-")) return "text-decoration";
363
+ if (b.startsWith("caret-")) return "caret";
364
+ if (b.startsWith("accent-")) return "accent";
365
+ if (b.startsWith("appearance-")) return "appearance";
366
+ if (b === "isolate" || b === "isolation-auto") return "isolation";
367
+ if (b.startsWith("mix-blend-")) return "mix-blend";
368
+ if (b.startsWith("bg-blend-")) return "bg-blend";
369
+ if (b.startsWith("float-")) return "float";
370
+ if (b.startsWith("clear-")) return "clear";
371
+ if (b.startsWith("break-")) return "break";
372
+ if (b.startsWith("columns-")) return "columns";
367
373
  return null;
368
374
  }
369
375
  function splitVariants(klass) {
@@ -378,7 +384,7 @@ function splitVariants(klass) {
378
384
  if (lastColon === 0) return ["", klass];
379
385
  return [klass.slice(0, lastColon), klass.slice(lastColon)];
380
386
  }
381
- function mergeClassStringJs(input) {
387
+ function mergeClassStringJs(input, prefix = "") {
382
388
  const tokens = input.split(/\s+/).filter(Boolean);
383
389
  if (tokens.length === 0) return "";
384
390
  if (tokens.length === 1) return tokens[0];
@@ -386,7 +392,7 @@ function mergeClassStringJs(input) {
386
392
  const slots = [];
387
393
  for (const token of tokens) {
388
394
  const [variants, base] = splitVariants(token);
389
- const group = conflictGroup(base);
395
+ const group = conflictGroup(base, prefix);
390
396
  if (group !== null) {
391
397
  const key = `${variants}::${group}`;
392
398
  const prevIdx = groupOwner.get(key);
@@ -399,10 +405,10 @@ function mergeClassStringJs(input) {
399
405
  }
400
406
  return slots.filter((s) => s !== null).join(" ");
401
407
  }
402
- function twMergeRawJs(classLists) {
408
+ function twMergeRawJs(classLists, prefix = "") {
403
409
  const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
404
410
  if (joined.length === 0) return "";
405
- return mergeClassStringJs(joined);
411
+ return mergeClassStringJs(joined, prefix);
406
412
  }
407
413
 
408
414
  // packages/domain/core/src/merge.ts
@@ -417,6 +423,7 @@ function warnFallbackOnce() {
417
423
  }
418
424
  }
419
425
  function createTwMerge(options = {}) {
426
+ const prefix = options.prefix ?? "";
420
427
  return function twMerge2(...classLists) {
421
428
  const inputs = [];
422
429
  for (let i = 0; i < classLists.length; i++) {
@@ -425,11 +432,16 @@ function createTwMerge(options = {}) {
425
432
  }
426
433
  if (inputs.length === 0) return "";
427
434
  const native = getNativeBinding();
428
- if (native?.twMergeRaw) {
429
- return native.twMergeRaw(inputs);
435
+ if (native) {
436
+ if (prefix && native.twMergeRawWithOptions) {
437
+ return native.twMergeRawWithOptions(inputs, { prefix });
438
+ }
439
+ if (native.twMergeRaw) {
440
+ return native.twMergeRaw(inputs);
441
+ }
430
442
  }
431
443
  warnFallbackOnce();
432
- return twMergeRawJs(inputs);
444
+ return twMergeRawJs(inputs, prefix);
433
445
  };
434
446
  }
435
447
  var twMerge = createTwMerge();
@@ -442,28 +454,63 @@ function mergeWithRules(rules, ...classLists) {
442
454
  return classes.join(" ");
443
455
  }
444
456
 
457
+ // packages/domain/core/src/parseTemplateFallback.ts
458
+ var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
459
+ var COMMENT_RE = /\/\/[^\n]*/g;
460
+ function collapseSpaces(s) {
461
+ return s.replace(/\s+/g, " ").trim();
462
+ }
463
+ function cleanBlock(raw) {
464
+ const noComments = raw.replace(COMMENT_RE, "");
465
+ const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
466
+ return collapseSpaces(lines.join(" "));
467
+ }
468
+ function parseTemplateJs(raw) {
469
+ const subs = {};
470
+ let base = raw;
471
+ for (const match of raw.matchAll(SUB_RE)) {
472
+ const fullMatch = match[0];
473
+ const name = match[1] ?? match[2] ?? "";
474
+ const innerRaw = match[3] ?? "";
475
+ if (name) {
476
+ subs[name] = cleanBlock(innerRaw);
477
+ }
478
+ base = base.replace(fullMatch, "");
479
+ }
480
+ return {
481
+ base: collapseSpaces(base),
482
+ subs,
483
+ hasSubs: Object.keys(subs).length > 0
484
+ };
485
+ }
486
+
445
487
  // packages/domain/core/src/stateEngine.ts
446
488
  var stateRegistry = /* @__PURE__ */ new Map();
447
489
  if (typeof window !== "undefined") {
448
490
  window.__TW_STATE_REGISTRY__ = stateRegistry;
449
491
  }
450
492
  var _hashStateCache = /* @__PURE__ */ new Map();
493
+ function _fnvHash62(s) {
494
+ let h = 2166136261;
495
+ for (let i = 0; i < s.length; i++) {
496
+ h ^= s.charCodeAt(i);
497
+ h = Math.imul(h, 16777619) >>> 0;
498
+ }
499
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
500
+ }
451
501
  function hashState(tag, state) {
452
502
  const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
453
503
  const cached = _hashStateCache.get(sortedKey);
454
504
  if (cached) return cached;
455
505
  const native = getNativeBinding();
456
- if (!native?.hashContent) {
457
- throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
458
- }
459
- const id = `tw-s-${native.hashContent(sortedKey, "fnv", 6)}`;
506
+ const id = native?.hashContent ? `tw-s-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-s-${_fnvHash62(sortedKey)}`;
460
507
  _hashStateCache.set(sortedKey, id);
461
508
  return id;
462
509
  }
463
510
  function generateStateRules(id, state) {
464
511
  const native = getNativeBinding();
465
512
  if (!native?.generateRuntimeStateCss) {
466
- throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
513
+ return [];
467
514
  }
468
515
  return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
469
516
  }
@@ -551,7 +598,13 @@ function _getParsedTemplate(template) {
551
598
  }
552
599
  const native = getNativeBinding();
553
600
  if (!native?.parseSubcomponentBlocksNapi) {
554
- throw new Error("FATAL: Native binding 'parseSubcomponentBlocksNapi' is required but not available.");
601
+ const fb = parseTemplateJs(template);
602
+ const result2 = {
603
+ baseClasses: fb.base,
604
+ subMap: new Map(Object.entries(fb.subs))
605
+ };
606
+ _templateParseCache.set(template, result2);
607
+ return result2;
555
608
  }
556
609
  const r = native.parseSubcomponentBlocksNapi(template, "tw");
557
610
  const raw = JSON.parse(r.subMapJson);
@@ -703,10 +756,16 @@ function resolveVariants(variants, props, defaults) {
703
756
  }
704
757
  const binding = getNativeBinding();
705
758
  if (!binding?.resolveSimpleVariants) {
706
- throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
759
+ const classes = [];
760
+ for (const key of Object.keys(variants)) {
761
+ const propValue = cleanProps[key] ?? defaults[key];
762
+ if (propValue !== void 0 && variants[key]?.[propValue]) {
763
+ classes.push(variants[key][propValue]);
764
+ }
765
+ }
766
+ return classes.join(" ").trim().replace(/\s+/g, " ");
707
767
  }
708
- const result = binding.resolveSimpleVariants(null, variants, defaults, cleanProps);
709
- return result.trim().replace(/\s+/g, " ");
768
+ return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
710
769
  }
711
770
  function resolveStates(statesConfig, stateKeys, statesLookup, props) {
712
771
  if (statesLookup && stateKeys.length > 0) {
@@ -918,48 +977,8 @@ function wrapWithSubProxy(component, tagLabel) {
918
977
  });
919
978
  }
920
979
 
921
- // packages/domain/core/src/parseTemplateFallback.ts
922
- var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
923
- var COMMENT_RE = /\/\/[^\n]*/g;
924
- function collapseSpaces(s) {
925
- return s.replace(/\s+/g, " ").trim();
926
- }
927
- function cleanBlock(raw) {
928
- const noComments = raw.replace(COMMENT_RE, "");
929
- const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
930
- return collapseSpaces(lines.join(" "));
931
- }
932
- function parseTemplateJs(raw) {
933
- const subs = {};
934
- let base = raw;
935
- for (const match of raw.matchAll(SUB_RE)) {
936
- const fullMatch = match[0];
937
- const name = match[1] ?? match[2] ?? "";
938
- const innerRaw = match[3] ?? "";
939
- if (name) {
940
- subs[name] = cleanBlock(innerRaw);
941
- }
942
- base = base.replace(fullMatch, "");
943
- }
944
- return {
945
- base: cleanBlock(base),
946
- subs,
947
- hasSubs: Object.keys(subs).length > 0
948
- };
949
- }
950
-
951
980
  // packages/domain/core/src/twProxy.ts
952
981
  var _parsedTemplateCache = /* @__PURE__ */ new Map();
953
- var warnedParseTemplateFallback = false;
954
- function warnParseTemplateFallbackOnce() {
955
- if (warnedParseTemplateFallback) return;
956
- warnedParseTemplateFallback = true;
957
- if (typeof console !== "undefined") {
958
- console.warn(
959
- "[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."
960
- );
961
- }
962
- }
963
982
  function parseTemplate(strings, exprs) {
964
983
  const raw = strings.raw.reduce((acc, str, i) => {
965
984
  const expr = exprs[i];
@@ -969,15 +988,15 @@ function parseTemplate(strings, exprs) {
969
988
  const cached = _parsedTemplateCache.get(raw);
970
989
  if (cached) return cached;
971
990
  const binding = getNativeBinding();
972
- let result;
973
- if (binding?.parseTemplate) {
974
- const r = binding.parseTemplate(raw);
975
- const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
976
- result = { base: r.base, subs, hasSubs: r.hasSubs };
977
- } else {
978
- warnParseTemplateFallbackOnce();
979
- result = parseTemplateJs(raw);
991
+ if (!binding?.parseTemplate) {
992
+ const fb = parseTemplateJs(raw);
993
+ const result2 = { base: fb.base, subs: fb.subs, hasSubs: fb.hasSubs };
994
+ _parsedTemplateCache.set(raw, result2);
995
+ return result2;
980
996
  }
997
+ const r = binding.parseTemplate(raw);
998
+ const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
999
+ const result = { base: r.base, subs, hasSubs: r.hasSubs };
981
1000
  _parsedTemplateCache.set(raw, result);
982
1001
  return result;
983
1002
  }
@@ -1288,19 +1307,25 @@ function cn(...inputs) {
1288
1307
  }
1289
1308
  if (strings.length === 0) return "";
1290
1309
  const native = getNativeBinding();
1291
- if (!native?.resolveClassNames) {
1310
+ if (native?.resolveClassNames) {
1311
+ return native.resolveClassNames(strings);
1312
+ }
1313
+ if (native !== null) {
1292
1314
  throw new Error("Native binding 'resolveClassNames' is required but not available.");
1293
1315
  }
1294
- return native.resolveClassNames(strings);
1316
+ return strings.filter(Boolean).join(" ");
1295
1317
  }
1296
1318
  function cx(...inputs) {
1297
1319
  const filtered = inputs.flat().filter(Boolean);
1298
1320
  if (filtered.length === 0) return "";
1299
1321
  const native = getNativeBinding();
1300
- if (!native?.twMergeMany) {
1322
+ if (native?.twMergeMany) {
1323
+ return native.twMergeMany(filtered);
1324
+ }
1325
+ if (native !== null) {
1301
1326
  throw new Error("Native binding 'twMergeMany' is required but not available.");
1302
1327
  }
1303
- return native.twMergeMany(filtered);
1328
+ return twMergeRawJs(filtered);
1304
1329
  }
1305
1330
  var cxm = cx;
1306
1331