@kbach/react-native 1.0.0-beta.5 → 1.0.0-beta.50

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.
Files changed (42) hide show
  1. package/AGENTS.md +347 -0
  2. package/README.md +143 -137
  3. package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
  4. package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
  5. package/dist/chunk-3KLOVONL.mjs +564 -0
  6. package/dist/chunk-SC3L5I7H.mjs +40 -0
  7. package/dist/chunk-XOH25F3E.mjs +112 -0
  8. package/dist/clsx-BLLSnqAa.d.ts +277 -0
  9. package/dist/darkModeStore.d.ts +73 -0
  10. package/dist/darkModeStore.js +118 -0
  11. package/dist/dynamicTokens.d.ts +53 -0
  12. package/dist/dynamicTokens.js +75 -0
  13. package/dist/index.d.ts +92 -151
  14. package/dist/index.js +2119 -393
  15. package/dist/index.web.d.ts +101 -4
  16. package/dist/index.web.js +438 -401
  17. package/dist/index.web.mjs +268 -14
  18. package/dist/jsx-dev-runtime.js +2238 -332
  19. package/dist/jsx-dev-runtime.web.js +207 -361
  20. package/dist/jsx-dev-runtime.web.mjs +19 -7
  21. package/dist/jsx-runtime.js +2238 -332
  22. package/dist/jsx-runtime.web.js +191 -353
  23. package/dist/jsx-runtime.web.mjs +3 -6
  24. package/dist/theme.d.ts +54 -0
  25. package/dist/{chunk-AEVOM2NB.mjs → theme.js} +86 -61
  26. package/package.json +44 -14
  27. package/src/babel-plugin.js +144 -2
  28. package/dist/chunk-4KCCEMEN.mjs +0 -66
  29. package/dist/chunk-DLIXI5OW.mjs +0 -53
  30. package/dist/chunk-FG5E4NLJ.mjs +0 -18
  31. package/dist/chunk-KSDFO34H.mjs +0 -32
  32. package/dist/chunk-OJQAJLYT.mjs +0 -14
  33. package/dist/chunk-ZUE6SCTE.mjs +0 -14
  34. package/dist/index.d.mts +0 -161
  35. package/dist/index.mjs +0 -32
  36. package/dist/index.web.d.mts +0 -7
  37. package/dist/jsx-dev-runtime.d.mts +0 -10
  38. package/dist/jsx-dev-runtime.mjs +0 -17
  39. package/dist/jsx-dev-runtime.web.d.mts +0 -10
  40. package/dist/jsx-runtime.d.mts +0 -7
  41. package/dist/jsx-runtime.mjs +0 -14
  42. package/dist/jsx-runtime.web.d.mts +0 -7
@@ -29,11 +29,820 @@ module.exports = __toCommonJS(jsx_dev_runtime_exports);
29
29
  var import_jsx_runtime = require("react/jsx-runtime");
30
30
  var import_react = require("react");
31
31
  var import_react_native = require("react-native");
32
+ var import_darkModeStore = require("./darkModeStore");
33
+ var import_theme = require("./theme");
34
+
35
+ // src/jsEngine/resolvers/color.ts
36
+ function lookupHex(theme, key) {
37
+ const entry = theme.colors[key];
38
+ return typeof entry === "string" ? entry : null;
39
+ }
40
+ var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
41
+ function findModeAwareColor(base, theme) {
42
+ const important = base.startsWith("!") ? "!" : "";
43
+ const rest = important ? base.slice(1) : base;
44
+ for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
45
+ if (!rest.startsWith(prefix)) continue;
46
+ const [name, opacity] = splitOpacity(rest.slice(prefix.length));
47
+ const entry = theme.colors[name];
48
+ if (typeof entry === "object" && entry !== null) {
49
+ return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+ function applyOpacityToHex(hex, opacity) {
55
+ if (opacity === null) return hex;
56
+ const rgb = hexToRgb(hex);
57
+ if (rgb === null) return hex;
58
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
59
+ }
60
+ function substituteModeAwareColorToken(token, theme, colorScheme) {
61
+ const segments = token.split(":");
62
+ const base = segments.pop() ?? token;
63
+ const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
64
+ const found = findModeAwareColor(base, theme);
65
+ if (found === null) return token;
66
+ const hex = colorScheme === "dark" ? found.dark : found.light;
67
+ return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
68
+ }
69
+ function classStringUsesModeAwareColor(classString, theme) {
70
+ return classString.split(/\s+/).some((rawToken) => {
71
+ if (!rawToken) return false;
72
+ const segments = rawToken.split(":");
73
+ const base = segments.pop() ?? rawToken;
74
+ return findModeAwareColor(base, theme) !== null;
75
+ });
76
+ }
77
+ function hexToRgb(hex) {
78
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
79
+ if (!m) return null;
80
+ let h = m[1];
81
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
82
+ const n = parseInt(h, 16);
83
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
84
+ }
85
+ function splitOpacity(value) {
86
+ const slash = value.lastIndexOf("/");
87
+ if (slash === -1) return [value, null];
88
+ const opacityText = value.slice(slash + 1);
89
+ const n = Number(opacityText);
90
+ if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
91
+ return [value.slice(0, slash), n];
92
+ }
93
+ return [value, null];
94
+ }
95
+ function colorValue(theme, parsed) {
96
+ const value = parsed.value;
97
+ if (value === null) return null;
98
+ if (parsed.isArbitrary) return value;
99
+ const [name, opacity] = splitOpacity(value);
100
+ const hex = lookupHex(theme, name);
101
+ if (hex === null) return null;
102
+ if (opacity === null) return hex;
103
+ const rgb = hexToRgb(hex);
104
+ if (rgb === null) return hex;
105
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
106
+ }
107
+ var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
108
+ function looksLikeLength(value) {
109
+ const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
110
+ const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
111
+ return withoutUnit !== "" && Number.isFinite(Number(withoutUnit));
112
+ }
113
+
114
+ // src/jsxRuntimeCore.ts
115
+ var import_dynamicTokens = require("./dynamicTokens");
116
+
117
+ // src/jsEngine/calc.ts
118
+ function reduceConstantMath(raw) {
119
+ const trimmed = raw.trim();
120
+ const calc = stripCall(trimmed, "calc");
121
+ if (calc !== null) {
122
+ return new Evaluator(calc).parseExprToEnd();
123
+ }
124
+ const clamp = stripCall(trimmed, "clamp");
125
+ if (clamp !== null) {
126
+ const args = splitTopLevelCommas(clamp);
127
+ if (args.length !== 3) return null;
128
+ const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
129
+ if (min2 === null || preferred === null || max2 === null) return null;
130
+ return Math.max(min2, Math.min(preferred, max2));
131
+ }
132
+ const min = stripCall(trimmed, "min");
133
+ if (min !== null) {
134
+ const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
135
+ return values.some((v) => v === null) ? null : Math.min(...values);
136
+ }
137
+ const max = stripCall(trimmed, "max");
138
+ if (max !== null) {
139
+ const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
140
+ return values.some((v) => v === null) ? null : Math.max(...values);
141
+ }
142
+ return null;
143
+ }
144
+ function stripCall(raw, name) {
145
+ if (!raw.startsWith(name)) return null;
146
+ const afterName = raw.slice(name.length).trimStart();
147
+ if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
148
+ return afterName.slice(1, -1);
149
+ }
150
+ function splitTopLevelCommas(s) {
151
+ const parts = [];
152
+ let depth = 0;
153
+ let start = 0;
154
+ for (let i = 0; i < s.length; i++) {
155
+ const ch = s[i];
156
+ if (ch === "(") depth++;
157
+ else if (ch === ")") depth--;
158
+ else if (ch === "," && depth === 0) {
159
+ parts.push(s.slice(start, i).trim());
160
+ start = i + 1;
161
+ }
162
+ }
163
+ parts.push(s.slice(start).trim());
164
+ return parts;
165
+ }
166
+ var Evaluator = class {
167
+ constructor(s) {
168
+ this.pos = 0;
169
+ this.s = s;
170
+ }
171
+ parseExprToEnd() {
172
+ const value = this.expr();
173
+ if (value === null) return null;
174
+ this.skipWs();
175
+ return this.pos === this.s.length ? value : null;
176
+ }
177
+ skipWs() {
178
+ while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
179
+ }
180
+ peek() {
181
+ this.skipWs();
182
+ return this.s[this.pos];
183
+ }
184
+ expr() {
185
+ let value = this.term();
186
+ if (value === null) return null;
187
+ for (; ; ) {
188
+ const ch = this.peek();
189
+ if (ch === "+") {
190
+ this.pos++;
191
+ const rhs = this.term();
192
+ if (rhs === null) return null;
193
+ value += rhs;
194
+ } else if (ch === "-") {
195
+ this.pos++;
196
+ const rhs = this.term();
197
+ if (rhs === null) return null;
198
+ value -= rhs;
199
+ } else {
200
+ return value;
201
+ }
202
+ }
203
+ }
204
+ term() {
205
+ let value = this.factor();
206
+ if (value === null) return null;
207
+ for (; ; ) {
208
+ const ch = this.peek();
209
+ if (ch === "*") {
210
+ this.pos++;
211
+ const rhs = this.factor();
212
+ if (rhs === null) return null;
213
+ value *= rhs;
214
+ } else if (ch === "/") {
215
+ this.pos++;
216
+ const divisor = this.factor();
217
+ if (divisor === null || divisor === 0) return null;
218
+ value /= divisor;
219
+ } else {
220
+ return value;
221
+ }
222
+ }
223
+ }
224
+ factor() {
225
+ const ch = this.peek();
226
+ if (ch === void 0) return null;
227
+ if (ch === "(") {
228
+ this.pos++;
229
+ const value = this.expr();
230
+ if (value === null || this.peek() !== ")") return null;
231
+ this.pos++;
232
+ return value;
233
+ }
234
+ if (ch === "-") {
235
+ this.pos++;
236
+ const value = this.factor();
237
+ return value === null ? null : -value;
238
+ }
239
+ return this.numberWithUnit();
240
+ }
241
+ numberWithUnit() {
242
+ this.skipWs();
243
+ const start = this.pos;
244
+ while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
245
+ if (this.pos === start) return null;
246
+ const n = Number(this.s.slice(start, this.pos));
247
+ if (!Number.isFinite(n)) return null;
248
+ const unitStart = this.pos;
249
+ while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
250
+ const unit = this.s.slice(unitStart, this.pos);
251
+ switch (unit) {
252
+ case "":
253
+ return n;
254
+ case "px":
255
+ return n;
256
+ case "rem":
257
+ return n * 16;
258
+ default:
259
+ return null;
260
+ }
261
+ }
262
+ };
263
+
264
+ // src/layoutCalc.ts
265
+ var NEG = (v) => ({ percent: -v.percent, px: -v.px });
266
+ var ADD = (a, b) => ({ percent: a.percent + b.percent, px: a.px + b.px });
267
+ var SUB = (a, b) => ({ percent: a.percent - b.percent, px: a.px - b.px });
268
+ function MUL(a, b) {
269
+ if (a.percent === 0) return { percent: b.percent * a.px, px: b.px * a.px };
270
+ if (b.percent === 0) return { percent: a.percent * b.px, px: a.px * b.px };
271
+ return null;
272
+ }
273
+ function DIV(a, b) {
274
+ if (b.percent !== 0 || b.px === 0) return null;
275
+ return { percent: a.percent / b.px, px: a.px / b.px };
276
+ }
277
+ var PercentAwareEvaluator = class {
278
+ constructor(s) {
279
+ this.pos = 0;
280
+ this.s = s;
281
+ }
282
+ parseExprToEnd() {
283
+ const value = this.expr();
284
+ if (value === null) return null;
285
+ this.skipWs();
286
+ return this.pos === this.s.length ? value : null;
287
+ }
288
+ skipWs() {
289
+ while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
290
+ }
291
+ peek() {
292
+ this.skipWs();
293
+ return this.s[this.pos];
294
+ }
295
+ expr() {
296
+ let value = this.term();
297
+ if (value === null) return null;
298
+ for (; ; ) {
299
+ const ch = this.peek();
300
+ if (ch === "+") {
301
+ this.pos++;
302
+ const rhs = this.term();
303
+ if (rhs === null) return null;
304
+ value = ADD(value, rhs);
305
+ } else if (ch === "-") {
306
+ this.pos++;
307
+ const rhs = this.term();
308
+ if (rhs === null) return null;
309
+ value = SUB(value, rhs);
310
+ } else {
311
+ return value;
312
+ }
313
+ }
314
+ }
315
+ term() {
316
+ let value = this.factor();
317
+ if (value === null) return null;
318
+ for (; ; ) {
319
+ const ch = this.peek();
320
+ if (ch === "*") {
321
+ this.pos++;
322
+ const rhs = this.factor();
323
+ if (rhs === null) return null;
324
+ const result = MUL(value, rhs);
325
+ if (result === null) return null;
326
+ value = result;
327
+ } else if (ch === "/") {
328
+ this.pos++;
329
+ const rhs = this.factor();
330
+ if (rhs === null) return null;
331
+ const result = DIV(value, rhs);
332
+ if (result === null) return null;
333
+ value = result;
334
+ } else {
335
+ return value;
336
+ }
337
+ }
338
+ }
339
+ factor() {
340
+ const ch = this.peek();
341
+ if (ch === void 0) return null;
342
+ if (ch === "(") {
343
+ this.pos++;
344
+ const value = this.expr();
345
+ if (value === null || this.peek() !== ")") return null;
346
+ this.pos++;
347
+ return value;
348
+ }
349
+ if (ch === "-") {
350
+ this.pos++;
351
+ const value = this.factor();
352
+ return value === null ? null : NEG(value);
353
+ }
354
+ return this.numberWithUnit();
355
+ }
356
+ numberWithUnit() {
357
+ this.skipWs();
358
+ const start = this.pos;
359
+ while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
360
+ if (this.pos === start) return null;
361
+ const n = Number(this.s.slice(start, this.pos));
362
+ if (!Number.isFinite(n)) return null;
363
+ if (this.s[this.pos] === "%") {
364
+ this.pos++;
365
+ return { percent: n, px: 0 };
366
+ }
367
+ const unitStart = this.pos;
368
+ while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
369
+ const unit = this.s.slice(unitStart, this.pos);
370
+ switch (unit) {
371
+ case "":
372
+ return { percent: 0, px: n };
373
+ case "px":
374
+ return { percent: 0, px: n };
375
+ case "rem":
376
+ return { percent: 0, px: n * 16 };
377
+ default:
378
+ return null;
379
+ }
380
+ }
381
+ };
382
+ var PERCENT_TOKEN_OUTER_RE = /^(w|h)-\[(.+)\]$/;
383
+ function parsePercentRelativeCalc(token) {
384
+ const m = PERCENT_TOKEN_OUTER_RE.exec(token);
385
+ if (!m) return null;
386
+ const property = m[1] === "w" ? "width" : "height";
387
+ const inner = stripCall(m[2].replace(/_/g, " ").trim(), "calc");
388
+ if (inner === null) return null;
389
+ const result = new PercentAwareEvaluator(inner).parseExprToEnd();
390
+ if (result === null || result.percent === 0) return null;
391
+ return { property, percentCoefficient: result.percent, constantPx: result.px };
392
+ }
393
+ function resolvePercentRelativeCalc(basisPx, calc) {
394
+ return basisPx * calc.percentCoefficient / 100 + calc.constantPx;
395
+ }
396
+ function parsePercentRelativeMinMaxClamp(token) {
397
+ const m = PERCENT_TOKEN_OUTER_RE.exec(token);
398
+ if (!m) return null;
399
+ const property = m[1] === "w" ? "width" : "height";
400
+ const spaced = m[2].replace(/_/g, " ");
401
+ let kind;
402
+ let inner;
403
+ if ((inner = stripCall(spaced, "min")) !== null) kind = "min";
404
+ else if ((inner = stripCall(spaced, "max")) !== null) kind = "max";
405
+ else if ((inner = stripCall(spaced, "clamp")) !== null) kind = "clamp";
406
+ else return null;
407
+ const args = splitTopLevelCommas(inner);
408
+ if (kind === "clamp" && args.length !== 3) return null;
409
+ if (kind !== "clamp" && args.length < 1) return null;
410
+ const operands = args.map((arg) => new PercentAwareEvaluator(arg.trim()).parseExprToEnd());
411
+ if (operands.some((o) => o === null)) return null;
412
+ const resolved = operands;
413
+ if (!resolved.some((o) => o.percent !== 0)) return null;
414
+ return {
415
+ property,
416
+ resolve(basisPx) {
417
+ const values = resolved.map((o) => basisPx * o.percent / 100 + o.px);
418
+ if (kind === "min") return Math.min(...values);
419
+ if (kind === "max") return Math.max(...values);
420
+ const [min, preferred, max] = values;
421
+ return Math.max(min, Math.min(preferred, max));
422
+ }
423
+ };
424
+ }
425
+ function parsePercentRelativeExpr(token) {
426
+ const calc = parsePercentRelativeCalc(token);
427
+ if (calc) return { property: calc.property, resolve: (basisPx) => resolvePercentRelativeCalc(basisPx, calc) };
428
+ return parsePercentRelativeMinMaxClamp(token);
429
+ }
430
+
431
+ // src/jsEngine/parser.ts
432
+ var VALUE_PREFIXES = [
433
+ "bg-opacity-",
434
+ "text-opacity-",
435
+ "bg-blend-",
436
+ "text-shadow-",
437
+ "bg-",
438
+ "text-",
439
+ "border-x-",
440
+ "border-y-",
441
+ "border-t-",
442
+ "border-r-",
443
+ "border-b-",
444
+ "border-l-",
445
+ "border-",
446
+ "caret-",
447
+ "accent-",
448
+ "fill-",
449
+ "stroke-width-",
450
+ "stroke-",
451
+ "resize-",
452
+ "touch-",
453
+ "will-change-",
454
+ "scroll-mx-",
455
+ "scroll-my-",
456
+ "scroll-mt-",
457
+ "scroll-mr-",
458
+ "scroll-mb-",
459
+ "scroll-ml-",
460
+ "scroll-m-",
461
+ "scroll-px-",
462
+ "scroll-py-",
463
+ "scroll-pt-",
464
+ "scroll-pr-",
465
+ "scroll-pb-",
466
+ "scroll-pl-",
467
+ "scroll-p-",
468
+ "px-",
469
+ "py-",
470
+ "pt-",
471
+ "pr-",
472
+ "pb-",
473
+ "pl-",
474
+ "p-",
475
+ "mx-",
476
+ "my-",
477
+ "mt-",
478
+ "mr-",
479
+ "mb-",
480
+ "ml-",
481
+ "m-",
482
+ "gap-x-",
483
+ "gap-y-",
484
+ "gap-",
485
+ "min-w-",
486
+ "max-w-",
487
+ "w-",
488
+ "min-h-",
489
+ "max-h-",
490
+ "h-",
491
+ "size-",
492
+ "basis-",
493
+ "rounded-tl-",
494
+ "rounded-tr-",
495
+ "rounded-br-",
496
+ "rounded-bl-",
497
+ "rounded-t-",
498
+ "rounded-r-",
499
+ "rounded-b-",
500
+ "rounded-l-",
501
+ "rounded-",
502
+ "ring-offset-",
503
+ "ring-",
504
+ "outline-offset-",
505
+ "outline-",
506
+ "shadow-",
507
+ "opacity-",
508
+ "duration-",
509
+ "delay-",
510
+ "ease-",
511
+ "cursor-",
512
+ "mix-blend-",
513
+ "animate-",
514
+ "leading-",
515
+ "tracking-",
516
+ "font-",
517
+ "z-",
518
+ "inset-x-",
519
+ "inset-y-",
520
+ "inset-",
521
+ "top-",
522
+ "right-",
523
+ "bottom-",
524
+ "left-",
525
+ "start-",
526
+ "end-",
527
+ "overflow-x-",
528
+ "overflow-y-",
529
+ "overscroll-x-",
530
+ "overscroll-y-",
531
+ "overscroll-",
532
+ "aspect-",
533
+ "divide-color-",
534
+ "space-x-",
535
+ "space-y-",
536
+ "flex-",
537
+ "grow-",
538
+ "shrink-",
539
+ "order-",
540
+ "grid-cols-",
541
+ "grid-rows-",
542
+ "grid-flow-",
543
+ "auto-cols-",
544
+ "auto-rows-",
545
+ "col-span-",
546
+ "col-start-",
547
+ "col-end-",
548
+ "col-",
549
+ "row-span-",
550
+ "row-start-",
551
+ "row-end-",
552
+ "row-",
553
+ "place-items-",
554
+ "place-content-",
555
+ "place-self-",
556
+ "justify-items-",
557
+ "justify-self-",
558
+ "scale-x-",
559
+ "scale-y-",
560
+ "scale-z-",
561
+ "scale-",
562
+ "rotate-x-",
563
+ "rotate-y-",
564
+ "rotate-z-",
565
+ "rotate-",
566
+ "translate-x-",
567
+ "translate-y-",
568
+ "translate-z-",
569
+ "skew-x-",
570
+ "skew-y-",
571
+ "perspective-origin-",
572
+ "perspective-",
573
+ "origin-",
574
+ "blur-",
575
+ "brightness-",
576
+ "contrast-",
577
+ "grayscale-",
578
+ "hue-rotate-",
579
+ "invert-",
580
+ "saturate-",
581
+ "sepia-",
582
+ "drop-shadow-",
583
+ "filter-",
584
+ "backdrop-blur-",
585
+ "backdrop-brightness-",
586
+ "backdrop-contrast-",
587
+ "backdrop-grayscale-",
588
+ "backdrop-hue-rotate-",
589
+ "backdrop-invert-",
590
+ "backdrop-opacity-",
591
+ "backdrop-saturate-",
592
+ "backdrop-sepia-",
593
+ "backdrop-filter-",
594
+ "decoration-",
595
+ "underline-offset-",
596
+ "indent-",
597
+ "from-",
598
+ "via-",
599
+ "to-"
600
+ ];
601
+ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
602
+ function isSafeArbitraryValue(value) {
603
+ return !value.includes("{") && !value.includes("}") && !value.includes(";");
604
+ }
605
+ function normalizeMathWhitespace(raw) {
606
+ if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
607
+ return raw;
608
+ }
609
+ const chars = Array.from(raw);
610
+ let out = "";
611
+ let i = 0;
612
+ let prevEndsValue = false;
613
+ while (i < chars.length) {
614
+ const c = chars[i];
615
+ if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
616
+ const start = i;
617
+ let depth = 0;
618
+ while (i < chars.length) {
619
+ if (chars[i] === "(") depth++;
620
+ else if (chars[i] === ")") {
621
+ depth--;
622
+ if (depth === 0) {
623
+ i++;
624
+ break;
625
+ }
626
+ }
627
+ i++;
628
+ }
629
+ out += chars.slice(start, i).join("");
630
+ prevEndsValue = true;
631
+ continue;
632
+ }
633
+ if (c === "+" || c === "-") {
634
+ if (prevEndsValue) {
635
+ out += ` ${c} `;
636
+ i++;
637
+ while (i < chars.length && /\s/.test(chars[i])) i++;
638
+ prevEndsValue = false;
639
+ continue;
640
+ }
641
+ out += c;
642
+ prevEndsValue = false;
643
+ } else if (c === "(" || c === ",") {
644
+ out += c;
645
+ if (c === ",") out += " ";
646
+ prevEndsValue = false;
647
+ } else if (c === ")") {
648
+ out += c;
649
+ prevEndsValue = true;
650
+ } else if (/\s/.test(c)) {
651
+ } else if (c === "*" || c === "/") {
652
+ out += c;
653
+ prevEndsValue = false;
654
+ } else {
655
+ out += c;
656
+ prevEndsValue = true;
657
+ }
658
+ i++;
659
+ }
660
+ return out;
661
+ }
662
+ function splitRespectingBrackets(token) {
663
+ const parts = [];
664
+ let depth = 0;
665
+ let start = 0;
666
+ for (let i = 0; i < token.length; i++) {
667
+ const ch = token[i];
668
+ if (ch === "[") depth += 1;
669
+ else if (ch === "]") depth -= 1;
670
+ else if (ch === ":" && depth <= 0) {
671
+ parts.push(token.slice(start, i));
672
+ start = i + 1;
673
+ }
674
+ }
675
+ parts.push(token.slice(start));
676
+ return parts;
677
+ }
678
+ function parseClass(token) {
679
+ const parts = splitRespectingBrackets(token);
680
+ let base = parts.pop() ?? token;
681
+ const modifiers = parts;
682
+ const important = base.startsWith("!");
683
+ if (important) {
684
+ base = base.slice(1);
685
+ }
686
+ const negative = base.startsWith("-");
687
+ if (negative) {
688
+ base = base.slice(1);
689
+ }
690
+ if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
691
+ const raw = base.slice(1, -1);
692
+ const colonIdx = raw.indexOf(":");
693
+ if (colonIdx !== -1) {
694
+ const property = raw.slice(0, colonIdx);
695
+ const rawValue = raw.slice(colonIdx + 1);
696
+ if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
697
+ const value = normalizeMathWhitespace(rawValue.replace(/_/g, " "));
698
+ return {
699
+ modifiers,
700
+ utility: ARBITRARY_PROPERTY_SENTINEL,
701
+ value: `${property}:${value}`,
702
+ isArbitrary: true,
703
+ important,
704
+ negative,
705
+ original: token
706
+ };
707
+ }
708
+ }
709
+ }
710
+ for (const prefix of VALUE_PREFIXES) {
711
+ if (!base.startsWith(prefix)) continue;
712
+ const value = base.slice(prefix.length);
713
+ if (value === "") continue;
714
+ if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
715
+ const raw = value.slice(1, -1);
716
+ if (!isSafeArbitraryValue(raw)) {
717
+ continue;
718
+ }
719
+ const spaced = normalizeMathWhitespace(raw.replace(/_/g, " "));
720
+ return {
721
+ modifiers,
722
+ utility: prefix.slice(0, -1),
723
+ value: spaced,
724
+ isArbitrary: true,
725
+ important,
726
+ negative,
727
+ original: token
728
+ };
729
+ }
730
+ return {
731
+ modifiers,
732
+ utility: prefix.slice(0, -1),
733
+ value,
734
+ isArbitrary: false,
735
+ important,
736
+ negative,
737
+ original: token
738
+ };
739
+ }
740
+ return {
741
+ modifiers,
742
+ utility: base,
743
+ value: null,
744
+ isArbitrary: false,
745
+ important,
746
+ negative,
747
+ original: token
748
+ };
749
+ }
750
+
751
+ // src/jsxRuntimeCore.ts
752
+ var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
753
+ function substituteDynamicTokens(classStrRaw) {
754
+ if (!classStrRaw.includes("var(--")) return classStrRaw;
755
+ return classStrRaw.replace(DYNAMIC_TOKEN_MATCH_RE, (whole, name) => {
756
+ const value = (0, import_dynamicTokens.getDynamicToken)(name);
757
+ return value ?? whole;
758
+ });
759
+ }
760
+ var PERCENT_RELATIVE_CALC_HINT_RE = /[wh]-\[(calc|min|max|clamp)\(.*%.*\)\]/;
761
+ function extractPercentRelativeCalcs(classStrRaw) {
762
+ const found = [];
763
+ for (const token of classStrRaw.split(/\s+/)) {
764
+ const parsed = parsePercentRelativeExpr(token);
765
+ if (parsed) found.push(parsed);
766
+ }
767
+ return found;
768
+ }
769
+ function stripPercentRelativeCalcTokens(classStrRaw) {
770
+ return classStrRaw.split(/\s+/).filter((token) => token && parsePercentRelativeExpr(token) === null).join(" ");
771
+ }
772
+ var STATE_MODIFIER_NAMES = /* @__PURE__ */ new Set(["hover", "focus", "disabled"]);
773
+ var STATIC_ARIA_SHORTCUT_NAMES = /* @__PURE__ */ new Set([
774
+ "aria-checked",
775
+ "aria-disabled",
776
+ "aria-expanded",
777
+ "aria-hidden",
778
+ "aria-pressed",
779
+ "aria-readonly",
780
+ "aria-required",
781
+ "aria-selected",
782
+ "aria-busy"
783
+ ]);
784
+ var STATE_MODIFIER_HINT_RE = /(^|\s|:)(hover|focus|disabled|aria-checked|aria-disabled|aria-expanded|aria-hidden|aria-pressed|aria-readonly|aria-required|aria-selected|aria-busy):|data-\[|aria-\[/;
785
+ function bracketContent(name, prefix) {
786
+ if (!name.startsWith(prefix)) return null;
787
+ const rest = name.slice(prefix.length);
788
+ if (!rest.startsWith("[") || !rest.endsWith("]")) return null;
789
+ return rest.slice(1, -1);
790
+ }
791
+ function evalAttrCondition(hostRest, attrPrefix, inner) {
792
+ const eqIdx = inner.indexOf("=");
793
+ if (eqIdx === -1) return Boolean(hostRest[`${attrPrefix}${inner}`]);
794
+ const key = inner.slice(0, eqIdx);
795
+ const value = inner.slice(eqIdx + 1);
796
+ return String(hostRest[`${attrPrefix}${key}`]) === value;
797
+ }
798
+ function isAriaTruthy(value) {
799
+ return value === true || value === "true";
800
+ }
801
+ function propBasedModifierState(name, states, hostRest) {
802
+ if (STATE_MODIFIER_NAMES.has(name)) return states[name];
803
+ if (STATIC_ARIA_SHORTCUT_NAMES.has(name)) return isAriaTruthy(hostRest[name]);
804
+ const dataInner = bracketContent(name, "data-");
805
+ if (dataInner !== null) return evalAttrCondition(hostRest, "data-", dataInner);
806
+ const ariaInner = bracketContent(name, "aria-");
807
+ if (ariaInner !== null) return evalAttrCondition(hostRest, "aria-", ariaInner);
808
+ return null;
809
+ }
810
+ var STATE_HOLD_MARKER = "_kbon";
811
+ function markSatisfiedStateModifiers(parts, namesToReplace) {
812
+ const utility = parts[parts.length - 1] ?? "";
813
+ const modifiers = parts.slice(0, -1).map((m) => namesToReplace.has(m) ? STATE_HOLD_MARKER : m);
814
+ return [...modifiers, utility].join(":");
815
+ }
816
+ function substituteStateModifiers(classStrRaw, states, hostRest) {
817
+ if (!STATE_MODIFIER_HINT_RE.test(classStrRaw)) return classStrRaw;
818
+ const kept = [];
819
+ for (const token of classStrRaw.split(/\s+/)) {
820
+ if (!token) continue;
821
+ const parts = splitRespectingBrackets(token);
822
+ const modifiers = parts.slice(0, -1);
823
+ const resolved = modifiers.map((m) => [m, propBasedModifierState(m, states, hostRest)]);
824
+ const required = resolved.filter(([, v]) => v !== null);
825
+ if (required.length === 0) {
826
+ kept.push(token);
827
+ continue;
828
+ }
829
+ if (required.every(([, v]) => v === true)) {
830
+ const requiredNames = new Set(required.map(([m]) => m));
831
+ kept.push(markSatisfiedStateModifiers(parts, requiredNames));
832
+ }
833
+ }
834
+ return kept.join(" ");
835
+ }
32
836
  function makeElement(isStaticChildren, type, props, key) {
33
837
  return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
34
838
  }
35
- function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
36
- const resolved = resolveStyle2(classStrRaw, pressed);
839
+ function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed, hostRest, layoutOverrides, states = { hover: false, focus: false, disabled: false }) {
840
+ const stateResolved = substituteStateModifiers(classStrRaw, states, hostRest);
841
+ const cleaned = stripPercentRelativeCalcTokens(substituteDynamicTokens(stateResolved));
842
+ const resolved = resolveStyle2(cleaned, pressed);
843
+ if (layoutOverrides) {
844
+ Object.assign(resolved, layoutOverrides);
845
+ }
37
846
  if (userStyle === void 0) {
38
847
  return resolved;
39
848
  }
@@ -42,6 +851,96 @@ function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
42
851
  }
43
852
  return [resolved, userStyle];
44
853
  }
854
+ var DARK_MODIFIER_RE = /(^|\s|:)dark:/;
855
+ var BREAKPOINT_MODIFIER_RE = /(^|\s|:)(sm|md|lg|xl|2xl):|(^|\s|:)(min|max)-\[[^\]]*\]:/;
856
+ var HOVER_MODIFIER_RE = /(^|\s|:)hover:/;
857
+ var FOCUS_MODIFIER_RE = /(^|\s|:)focus:/;
858
+ function usesModeAwareColor(classStrRaw) {
859
+ return classStringUsesModeAwareColor(classStrRaw, (0, import_theme.getTheme)());
860
+ }
861
+ function ReactiveElement({
862
+ hostType,
863
+ hostRest,
864
+ classStrRaw,
865
+ userStyle,
866
+ resolveStyle: resolveStyle2,
867
+ elementKey,
868
+ isStaticChildren
869
+ }) {
870
+ (0, import_react.useSyncExternalStore)(import_darkModeStore.subscribeGlobalDarkMode, import_darkModeStore.getGlobalDarkMode);
871
+ (0, import_react.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, import_dynamicTokens.getDynamicTokensVersion);
872
+ const windowSize = (0, import_react_native.useWindowDimensions)();
873
+ const [measuredBasis, setMeasuredBasis] = (0, import_react.useState)(null);
874
+ const lastWindowSizeRef = (0, import_react.useRef)(windowSize);
875
+ if (lastWindowSizeRef.current.width !== windowSize.width || lastWindowSizeRef.current.height !== windowSize.height) {
876
+ lastWindowSizeRef.current = windowSize;
877
+ if (measuredBasis !== null) {
878
+ setMeasuredBasis(null);
879
+ }
880
+ }
881
+ const measure = (0, import_react.useCallback)((e) => {
882
+ const { width: w, height: h } = e.nativeEvent.layout;
883
+ setMeasuredBasis((prev) => prev === null ? { width: w, height: h } : prev);
884
+ }, []);
885
+ const [isHovered, setIsHovered] = (0, import_react.useState)(false);
886
+ const [isFocused, setIsFocused] = (0, import_react.useState)(false);
887
+ const percentCalcs = extractPercentRelativeCalcs(classStrRaw);
888
+ let layoutOverrides;
889
+ let hostRestWithLayout = hostRest;
890
+ if (percentCalcs.length > 0) {
891
+ layoutOverrides = {};
892
+ for (const calc of percentCalcs) {
893
+ const basis = measuredBasis?.[calc.property];
894
+ layoutOverrides[calc.property] = basis === void 0 ? "100%" : calc.resolve(basis);
895
+ }
896
+ const userOnLayout = hostRest.onLayout;
897
+ hostRestWithLayout = {
898
+ ...hostRest,
899
+ onLayout: userOnLayout ? (e) => {
900
+ measure(e);
901
+ userOnLayout(e);
902
+ } : measure
903
+ };
904
+ }
905
+ if (HOVER_MODIFIER_RE.test(classStrRaw)) {
906
+ const userOnHoverIn = hostRestWithLayout.onHoverIn;
907
+ const userOnHoverOut = hostRestWithLayout.onHoverOut;
908
+ hostRestWithLayout = {
909
+ ...hostRestWithLayout,
910
+ onHoverIn: (e) => {
911
+ setIsHovered(true);
912
+ userOnHoverIn?.(e);
913
+ },
914
+ onHoverOut: (e) => {
915
+ setIsHovered(false);
916
+ userOnHoverOut?.(e);
917
+ }
918
+ };
919
+ }
920
+ if (FOCUS_MODIFIER_RE.test(classStrRaw)) {
921
+ const userOnFocus = hostRestWithLayout.onFocus;
922
+ const userOnBlur = hostRestWithLayout.onBlur;
923
+ hostRestWithLayout = {
924
+ ...hostRestWithLayout,
925
+ onFocus: (e) => {
926
+ setIsFocused(true);
927
+ userOnFocus?.(e);
928
+ },
929
+ onBlur: (e) => {
930
+ setIsFocused(false);
931
+ userOnBlur?.(e);
932
+ }
933
+ };
934
+ }
935
+ const states = { hover: isHovered, focus: isFocused, disabled: hostRest.disabled === true };
936
+ const finalStyle = hostType === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, hostRest, layoutOverrides, states) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, hostRest, layoutOverrides, states);
937
+ return makeElement(
938
+ isStaticChildren,
939
+ hostType,
940
+ { ...hostRestWithLayout, className: classStrRaw, style: finalStyle },
941
+ elementKey
942
+ );
943
+ }
45
944
  function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
46
945
  if (type === null || typeof type === "symbol" || !rawProps) {
47
946
  return makeElement(isStaticChildren, type, rawProps ?? {}, key);
@@ -50,8 +949,16 @@ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
50
949
  if (typeof classStrRaw !== "string") {
51
950
  return makeElement(isStaticChildren, type, rawProps, key);
52
951
  }
53
- const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
54
- return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
952
+ if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw) || HOVER_MODIFIER_RE.test(classStrRaw) || FOCUS_MODIFIER_RE.test(classStrRaw) || classStrRaw.includes("var(--") || PERCENT_RELATIVE_CALC_HINT_RE.test(classStrRaw) || usesModeAwareColor(classStrRaw)) {
953
+ return (0, import_jsx_runtime.jsx)(
954
+ ReactiveElement,
955
+ { hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
956
+ key
957
+ );
958
+ }
959
+ const staticStates = { hover: false, focus: false, disabled: rest.disabled === true };
960
+ const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, rest, void 0, staticStates) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, rest, void 0, staticStates);
961
+ return makeElement(isStaticChildren, type, { ...rest, className: classStrRaw, style: finalStyle }, key);
55
962
  }
56
963
  function createJsxFunctions(resolveStyle2) {
57
964
  function jsx2(type, props, key) {
@@ -74,343 +981,1342 @@ function createJsxDEV(jsx2, jsxs2) {
74
981
  }
75
982
 
76
983
  // src/nativeBridge.ts
77
- var import_react_native3 = require("react-native");
984
+ var import_react_native2 = require("react-native");
985
+ var import_theme2 = require("./theme");
986
+ var import_darkModeStore2 = require("./darkModeStore");
78
987
 
79
- // src/generatedPalette.ts
80
- var PALETTE = {
81
- "amber-1": "#fffbeb",
82
- "amber-10": "#78350f",
83
- "amber-11": "#451a03",
84
- "amber-12": "#291002",
85
- "amber-2": "#fef3c7",
86
- "amber-3": "#fde68a",
87
- "amber-4": "#fcd34d",
88
- "amber-5": "#fbbf24",
89
- "amber-6": "#f59e0b",
90
- "amber-7": "#d97706",
91
- "amber-8": "#b45309",
92
- "amber-9": "#92400e",
93
- "black": "#000000",
94
- "blue-1": "#eff6ff",
95
- "blue-10": "#1e3a8a",
96
- "blue-11": "#172554",
97
- "blue-12": "#0d1633",
98
- "blue-2": "#dbeafe",
99
- "blue-3": "#bfdbfe",
100
- "blue-4": "#93c5fd",
101
- "blue-5": "#60a5fa",
102
- "blue-6": "#3b82f6",
103
- "blue-7": "#2563eb",
104
- "blue-8": "#1d4ed8",
105
- "blue-9": "#1e40af",
106
- "bronze": "#cd7f32",
107
- "coal": "#1c1c1c",
108
- "copper": "#b87333",
109
- "current": "currentColor",
110
- "cyan-1": "#ecfeff",
111
- "cyan-10": "#164e63",
112
- "cyan-11": "#083344",
113
- "cyan-12": "#041e28",
114
- "cyan-2": "#cffafe",
115
- "cyan-3": "#a5f3fc",
116
- "cyan-4": "#67e8f9",
117
- "cyan-5": "#22d3ee",
118
- "cyan-6": "#06b6d4",
119
- "cyan-7": "#0891b2",
120
- "cyan-8": "#0e7490",
121
- "cyan-9": "#155e75",
122
- "emerald-1": "#ecfdf5",
123
- "emerald-10": "#064e3b",
124
- "emerald-11": "#022c22",
125
- "emerald-12": "#011a14",
126
- "emerald-2": "#d1fae5",
127
- "emerald-3": "#a7f3d0",
128
- "emerald-4": "#6ee7b7",
129
- "emerald-5": "#34d399",
130
- "emerald-6": "#10b981",
131
- "emerald-7": "#059669",
132
- "emerald-8": "#047857",
133
- "emerald-9": "#065f46",
134
- "fuchsia-1": "#fdf4ff",
135
- "fuchsia-10": "#701a75",
136
- "fuchsia-11": "#4a044e",
137
- "fuchsia-12": "#2d022f",
138
- "fuchsia-2": "#fae8ff",
139
- "fuchsia-3": "#f5d0fe",
140
- "fuchsia-4": "#f0abfc",
141
- "fuchsia-5": "#e879f9",
142
- "fuchsia-6": "#d946ef",
143
- "fuchsia-7": "#c026d3",
144
- "fuchsia-8": "#a21caf",
145
- "fuchsia-9": "#86198f",
146
- "gold": "#d4af37",
147
- "gray-1": "#f9fafb",
148
- "gray-10": "#111827",
149
- "gray-11": "#030712",
150
- "gray-12": "#020409",
151
- "gray-2": "#f3f4f6",
152
- "gray-3": "#e5e7eb",
153
- "gray-4": "#d1d5db",
154
- "gray-5": "#9ca3af",
155
- "gray-6": "#6b7280",
156
- "gray-7": "#4b5563",
157
- "gray-8": "#374151",
158
- "gray-9": "#1f2937",
159
- "green-1": "#f0fdf4",
160
- "green-10": "#14532d",
161
- "green-11": "#052e16",
162
- "green-12": "#031b0d",
163
- "green-2": "#dcfce7",
164
- "green-3": "#bbf7d0",
165
- "green-4": "#86efac",
166
- "green-5": "#4ade80",
167
- "green-6": "#22c55e",
168
- "green-7": "#16a34a",
169
- "green-8": "#15803d",
170
- "green-9": "#166534",
171
- "indigo-1": "#eef2ff",
172
- "indigo-10": "#312e81",
173
- "indigo-11": "#1e1b4b",
174
- "indigo-12": "#12102d",
175
- "indigo-2": "#e0e7ff",
176
- "indigo-3": "#c7d2fe",
177
- "indigo-4": "#a5b4fc",
178
- "indigo-5": "#818cf8",
179
- "indigo-6": "#6366f1",
180
- "indigo-7": "#4f46e5",
181
- "indigo-8": "#4338ca",
182
- "indigo-9": "#3730a3",
183
- "lime-1": "#f7fee7",
184
- "lime-10": "#365314",
185
- "lime-11": "#1a2e05",
186
- "lime-12": "#0f1b03",
187
- "lime-2": "#ecfccb",
188
- "lime-3": "#d9f99d",
189
- "lime-4": "#bef264",
190
- "lime-5": "#a3e635",
191
- "lime-6": "#84cc16",
192
- "lime-7": "#65a30d",
193
- "lime-8": "#4d7c0f",
194
- "lime-9": "#3f6212",
195
- "neutral-1": "#fafafa",
196
- "neutral-10": "#171717",
197
- "neutral-11": "#0a0a0a",
198
- "neutral-12": "#050505",
199
- "neutral-2": "#f5f5f5",
200
- "neutral-3": "#e5e5e5",
201
- "neutral-4": "#d4d4d4",
202
- "neutral-5": "#a3a3a3",
203
- "neutral-6": "#737373",
204
- "neutral-7": "#525252",
205
- "neutral-8": "#404040",
206
- "neutral-9": "#262626",
207
- "orange-1": "#fff7ed",
208
- "orange-10": "#7c2d12",
209
- "orange-11": "#431407",
210
- "orange-12": "#270c04",
211
- "orange-2": "#ffedd5",
212
- "orange-3": "#fed7aa",
213
- "orange-4": "#fdba74",
214
- "orange-5": "#fb923c",
215
- "orange-6": "#f97316",
216
- "orange-7": "#ea580c",
217
- "orange-8": "#c2410c",
218
- "orange-9": "#9a3412",
219
- "pink-1": "#fdf2f8",
220
- "pink-10": "#831843",
221
- "pink-11": "#500724",
222
- "pink-12": "#300415",
223
- "pink-2": "#fce7f3",
224
- "pink-3": "#fbcfe8",
225
- "pink-4": "#f9a8d4",
226
- "pink-5": "#f472b6",
227
- "pink-6": "#ec4899",
228
- "pink-7": "#db2777",
229
- "pink-8": "#be185d",
230
- "pink-9": "#9d174d",
231
- "purple-1": "#faf5ff",
232
- "purple-10": "#581c87",
233
- "purple-11": "#3b0764",
234
- "purple-12": "#23043c",
235
- "purple-2": "#f3e8ff",
236
- "purple-3": "#e9d5ff",
237
- "purple-4": "#d8b4fe",
238
- "purple-5": "#c084fc",
239
- "purple-6": "#a855f7",
240
- "purple-7": "#9333ea",
241
- "purple-8": "#7e22ce",
242
- "purple-9": "#6b21a8",
243
- "red-1": "#fef2f2",
244
- "red-10": "#7f1d1d",
245
- "red-11": "#450a0a",
246
- "red-12": "#280606",
247
- "red-2": "#fee2e2",
248
- "red-3": "#fecaca",
249
- "red-4": "#fca5a5",
250
- "red-5": "#f87171",
251
- "red-6": "#ef4444",
252
- "red-7": "#dc2626",
253
- "red-8": "#b91c1c",
254
- "red-9": "#991b1b",
255
- "rose-1": "#fff1f2",
256
- "rose-10": "#881337",
257
- "rose-11": "#4c0519",
258
- "rose-12": "#2d030e",
259
- "rose-2": "#ffe4e6",
260
- "rose-3": "#fecdd3",
261
- "rose-4": "#fda4af",
262
- "rose-5": "#fb7185",
263
- "rose-6": "#f43f5e",
264
- "rose-7": "#e11d48",
265
- "rose-8": "#be123c",
266
- "rose-9": "#9f1239",
267
- "silver": "#c0c0c0",
268
- "sky-1": "#f0f9ff",
269
- "sky-10": "#0c4a6e",
270
- "sky-11": "#082f49",
271
- "sky-12": "#041b2b",
272
- "sky-2": "#e0f2fe",
273
- "sky-3": "#bae6fd",
274
- "sky-4": "#7dd3fc",
275
- "sky-5": "#38bdf8",
276
- "sky-6": "#0ea5e9",
277
- "sky-7": "#0284c7",
278
- "sky-8": "#0369a1",
279
- "sky-9": "#075985",
280
- "slate-1": "#f8fafc",
281
- "slate-10": "#0f172a",
282
- "slate-11": "#020617",
283
- "slate-12": "#01020a",
284
- "slate-2": "#f1f5f9",
285
- "slate-3": "#e2e8f0",
286
- "slate-4": "#cbd5e1",
287
- "slate-5": "#94a3b8",
288
- "slate-6": "#64748b",
289
- "slate-7": "#475569",
290
- "slate-8": "#334155",
291
- "slate-9": "#1e293b",
292
- "stone-1": "#fafaf9",
293
- "stone-10": "#1c1917",
294
- "stone-11": "#0c0a09",
295
- "stone-12": "#070605",
296
- "stone-2": "#f5f5f4",
297
- "stone-3": "#e7e5e4",
298
- "stone-4": "#d6d3d1",
299
- "stone-5": "#a8a29e",
300
- "stone-6": "#78716c",
301
- "stone-7": "#57534e",
302
- "stone-8": "#44403c",
303
- "stone-9": "#292524",
304
- "teal-1": "#f0fdfa",
305
- "teal-10": "#134e4a",
306
- "teal-11": "#042f2e",
307
- "teal-12": "#021c1b",
308
- "teal-2": "#ccfbf1",
309
- "teal-3": "#99f6e4",
310
- "teal-4": "#5eead4",
311
- "teal-5": "#2dd4bf",
312
- "teal-6": "#14b8a6",
313
- "teal-7": "#0d9488",
314
- "teal-8": "#0f766e",
315
- "teal-9": "#115e59",
316
- "transparent": "transparent",
317
- "violet-1": "#f5f3ff",
318
- "violet-10": "#4c1d95",
319
- "violet-11": "#2e1065",
320
- "violet-12": "#1c0a3d",
321
- "violet-2": "#ede9fe",
322
- "violet-3": "#ddd6fe",
323
- "violet-4": "#c4b5fd",
324
- "violet-5": "#a78bfa",
325
- "violet-6": "#8b5cf6",
326
- "violet-7": "#7c3aed",
327
- "violet-8": "#6d28d9",
328
- "violet-9": "#5b21b6",
329
- "white": "#ffffff",
330
- "yellow-1": "#fefce8",
331
- "yellow-10": "#713f12",
332
- "yellow-11": "#422006",
333
- "yellow-12": "#271304",
334
- "yellow-2": "#fef9c3",
335
- "yellow-3": "#fef08a",
336
- "yellow-4": "#fde047",
337
- "yellow-5": "#facc15",
338
- "yellow-6": "#eab308",
339
- "yellow-7": "#ca8a04",
340
- "yellow-8": "#a16207",
341
- "yellow-9": "#854d0e",
342
- "zinc-1": "#fafafa",
343
- "zinc-10": "#18181b",
344
- "zinc-11": "#09090b",
345
- "zinc-12": "#050506",
346
- "zinc-2": "#f4f4f5",
347
- "zinc-3": "#e4e4e7",
348
- "zinc-4": "#d4d4d8",
349
- "zinc-5": "#a1a1aa",
350
- "zinc-6": "#71717a",
351
- "zinc-7": "#52525b",
352
- "zinc-8": "#3f3f46",
353
- "zinc-9": "#27272a"
354
- };
988
+ // src/jsEngine/shared.ts
989
+ function decl(property, value) {
990
+ return { property, value };
991
+ }
992
+ function spacingPx(theme, value) {
993
+ const fromTable = theme.spacing[value];
994
+ if (fromTable !== void 0) return fromTable;
995
+ const n = Number(value);
996
+ return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
997
+ }
998
+ function resolveLength(theme, parsed) {
999
+ if (parsed.negative) return null;
1000
+ const value = parsed.value;
1001
+ if (value === null) return null;
1002
+ if (parsed.isArbitrary) return value;
1003
+ if (value === "full") return "100%";
1004
+ if (value === "auto") return "auto";
1005
+ const px = spacingPx(theme, value);
1006
+ return px === void 0 ? null : `${px}px`;
1007
+ }
1008
+ function resolveNegatableLength(theme, parsed) {
1009
+ if (!parsed.negative) return resolveLength(theme, parsed);
1010
+ if (parsed.isArbitrary) {
1011
+ const value2 = parsed.value;
1012
+ return value2 === null ? null : `calc(${value2} * -1)`;
1013
+ }
1014
+ const value = parsed.value;
1015
+ if (value === null) return null;
1016
+ const px = spacingPx(theme, value);
1017
+ if (px === void 0) return null;
1018
+ if (px === 0) return "0px";
1019
+ return `-${px}px`;
1020
+ }
1021
+ function fractionPercent(value) {
1022
+ const slashIdx = value.indexOf("/");
1023
+ if (slashIdx === -1) return null;
1024
+ const numStr = value.slice(0, slashIdx);
1025
+ const denStr = value.slice(slashIdx + 1);
1026
+ const num = Number(numStr);
1027
+ const den = Number(denStr);
1028
+ if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
1029
+ if (den === 0) return null;
1030
+ const pct = num / den * 100;
1031
+ const formatted = pct.toFixed(6);
1032
+ const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
1033
+ return `${trimmed}%`;
1034
+ }
1035
+ function resolveNegatableSize(theme, parsed) {
1036
+ if (!parsed.isArbitrary && parsed.value !== null) {
1037
+ const pct = fractionPercent(parsed.value);
1038
+ if (pct !== null) return parsed.negative ? `-${pct}` : pct;
1039
+ }
1040
+ return resolveNegatableLength(theme, parsed);
1041
+ }
1042
+ function resolvePercent(parsed) {
1043
+ if (parsed.negative) return null;
1044
+ const value = parsed.value;
1045
+ if (value === null) return null;
1046
+ if (parsed.isArbitrary) return value;
1047
+ const pct = Number(value);
1048
+ if (!Number.isFinite(pct) || value.trim() === "") return null;
1049
+ return String(pct / 100);
1050
+ }
355
1051
 
356
- // src/theme.ts
357
- var defaultTheme = {
358
- colors: PALETTE,
359
- spacing: {
360
- // "0" is always a hardcoded zero in real Tailwind's own scale too,
361
- // regardless of the base spacing unit — needed for `p-0`/`m-0`/etc.
362
- // Mirrors the identical fix in @kbach/react's theme.ts.
363
- "0": 0,
364
- "1": 4,
365
- "2": 8,
366
- "4": 16,
367
- "6": 24,
368
- "8": 32
369
- },
370
- screens: {
371
- sm: 640,
372
- md: 768,
373
- lg: 1024,
374
- xl: 1280,
375
- "2xl": 1536
376
- },
377
- darkMode: "attribute"
378
- };
379
- var activeThemeJson = JSON.stringify(defaultTheme);
380
- function getThemeJson() {
381
- return activeThemeJson;
1052
+ // src/jsEngine/resolvers/layout.ts
1053
+ function negateRaw(value, negative) {
1054
+ return negative ? `-${value}` : value;
1055
+ }
1056
+ function overflowAxisValue(property, value) {
1057
+ switch (value) {
1058
+ case "auto":
1059
+ case "hidden":
1060
+ case "clip":
1061
+ case "visible":
1062
+ case "scroll":
1063
+ return [decl(property, value)];
1064
+ default:
1065
+ return null;
1066
+ }
1067
+ }
1068
+ function overscrollValue(property, value) {
1069
+ switch (value) {
1070
+ case "auto":
1071
+ case "contain":
1072
+ case "none":
1073
+ return [decl(property, value)];
1074
+ default:
1075
+ return null;
1076
+ }
1077
+ }
1078
+ function resolve(parsed, theme) {
1079
+ switch (parsed.utility) {
1080
+ case "flex":
1081
+ return parsed.value === null ? [decl("display", "flex")] : null;
1082
+ case "grid":
1083
+ return [decl("display", "grid")];
1084
+ case "block":
1085
+ return [decl("display", "block")];
1086
+ case "inline-block":
1087
+ return [decl("display", "inline-block")];
1088
+ case "inline":
1089
+ return [decl("display", "inline")];
1090
+ case "inline-flex":
1091
+ return [decl("display", "inline-flex")];
1092
+ case "inline-grid":
1093
+ return [decl("display", "inline-grid")];
1094
+ case "contents":
1095
+ return [decl("display", "contents")];
1096
+ case "flow-root":
1097
+ return [decl("display", "flow-root")];
1098
+ case "hidden":
1099
+ return [decl("display", "none")];
1100
+ case "@container":
1101
+ return [decl("container-type", "inline-size")];
1102
+ case "items-center":
1103
+ return [decl("align-items", "center")];
1104
+ case "items-start":
1105
+ return [decl("align-items", "flex-start")];
1106
+ case "items-end":
1107
+ return [decl("align-items", "flex-end")];
1108
+ case "items-baseline":
1109
+ return [decl("align-items", "baseline")];
1110
+ case "items-stretch":
1111
+ return [decl("align-items", "stretch")];
1112
+ case "justify-center":
1113
+ return [decl("justify-content", "center")];
1114
+ case "justify-start":
1115
+ return [decl("justify-content", "flex-start")];
1116
+ case "justify-end":
1117
+ return [decl("justify-content", "flex-end")];
1118
+ case "justify-between":
1119
+ return [decl("justify-content", "space-between")];
1120
+ case "justify-around":
1121
+ return [decl("justify-content", "space-around")];
1122
+ case "justify-evenly":
1123
+ return [decl("justify-content", "space-evenly")];
1124
+ case "justify-normal":
1125
+ return [decl("justify-content", "normal")];
1126
+ case "justify-stretch":
1127
+ return [decl("justify-content", "stretch")];
1128
+ case "content-normal":
1129
+ return [decl("align-content", "normal")];
1130
+ case "content-start":
1131
+ return [decl("align-content", "flex-start")];
1132
+ case "content-end":
1133
+ return [decl("align-content", "flex-end")];
1134
+ case "content-center":
1135
+ return [decl("align-content", "center")];
1136
+ case "content-between":
1137
+ return [decl("align-content", "space-between")];
1138
+ case "content-around":
1139
+ return [decl("align-content", "space-around")];
1140
+ case "content-evenly":
1141
+ return [decl("align-content", "space-evenly")];
1142
+ case "content-stretch":
1143
+ return [decl("align-content", "stretch")];
1144
+ case "self-auto":
1145
+ return [decl("align-self", "auto")];
1146
+ case "self-center":
1147
+ return [decl("align-self", "center")];
1148
+ case "self-start":
1149
+ return [decl("align-self", "flex-start")];
1150
+ case "self-end":
1151
+ return [decl("align-self", "flex-end")];
1152
+ case "self-stretch":
1153
+ return [decl("align-self", "stretch")];
1154
+ case "self-baseline":
1155
+ return [decl("align-self", "baseline")];
1156
+ case "overflow-hidden":
1157
+ return [decl("overflow", "hidden")];
1158
+ case "overflow-auto":
1159
+ return [decl("overflow", "auto")];
1160
+ case "overflow-scroll":
1161
+ return [decl("overflow", "scroll")];
1162
+ case "overflow-visible":
1163
+ return [decl("overflow", "visible")];
1164
+ case "overflow-clip":
1165
+ return [decl("overflow", "clip")];
1166
+ case "overflow-x":
1167
+ return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
1168
+ case "overflow-y":
1169
+ return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
1170
+ case "overscroll":
1171
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
1172
+ case "overscroll-x":
1173
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
1174
+ case "overscroll-y":
1175
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
1176
+ case "static":
1177
+ return [decl("position", "static")];
1178
+ case "relative":
1179
+ return [decl("position", "relative")];
1180
+ case "absolute":
1181
+ return [decl("position", "absolute")];
1182
+ case "fixed":
1183
+ return [decl("position", "fixed")];
1184
+ case "sticky":
1185
+ return [decl("position", "sticky")];
1186
+ case "z":
1187
+ return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
1188
+ case "order":
1189
+ return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
1190
+ case "grow":
1191
+ return [decl("flex-grow", parsed.value ?? "1")];
1192
+ case "shrink":
1193
+ return [decl("flex-shrink", parsed.value ?? "1")];
1194
+ // top/right/bottom/left/inset support real Tailwind's negative-value
1195
+ // convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
1196
+ // "-inset-1/3") — see resolveNegatableSize's own doc comment.
1197
+ case "top": {
1198
+ const v = resolveNegatableSize(theme, parsed);
1199
+ return v === null ? null : [decl("top", v)];
1200
+ }
1201
+ case "right": {
1202
+ const v = resolveNegatableSize(theme, parsed);
1203
+ return v === null ? null : [decl("right", v)];
1204
+ }
1205
+ case "bottom": {
1206
+ const v = resolveNegatableSize(theme, parsed);
1207
+ return v === null ? null : [decl("bottom", v)];
1208
+ }
1209
+ case "left": {
1210
+ const v = resolveNegatableSize(theme, parsed);
1211
+ return v === null ? null : [decl("left", v)];
1212
+ }
1213
+ case "inset": {
1214
+ const v = resolveNegatableSize(theme, parsed);
1215
+ return v === null ? null : [decl("inset", v)];
1216
+ }
1217
+ case "inset-x": {
1218
+ const v = resolveNegatableSize(theme, parsed);
1219
+ return v === null ? null : [decl("left", v), decl("right", v)];
1220
+ }
1221
+ case "inset-y": {
1222
+ const v = resolveNegatableSize(theme, parsed);
1223
+ return v === null ? null : [decl("top", v), decl("bottom", v)];
1224
+ }
1225
+ // Logical inset — just a different CSS property name, same reasoning
1226
+ // as Rust's layout.rs (no direction-tracking logic needed here).
1227
+ case "start": {
1228
+ const v = resolveNegatableSize(theme, parsed);
1229
+ return v === null ? null : [decl("inset-inline-start", v)];
1230
+ }
1231
+ case "end": {
1232
+ const v = resolveNegatableSize(theme, parsed);
1233
+ return v === null ? null : [decl("inset-inline-end", v)];
1234
+ }
1235
+ // "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
1236
+ // "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
1237
+ // here as utility="aspect" + a value, mirroring layout.rs's own
1238
+ // "aspect" arm.
1239
+ case "aspect": {
1240
+ const value = parsed.value;
1241
+ if (value === null) return null;
1242
+ if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
1243
+ switch (value) {
1244
+ case "square":
1245
+ return [decl("aspect-ratio", "1 / 1")];
1246
+ case "video":
1247
+ return [decl("aspect-ratio", "16 / 9")];
1248
+ case "auto":
1249
+ return [decl("aspect-ratio", "auto")];
1250
+ default:
1251
+ return null;
1252
+ }
1253
+ }
1254
+ default:
1255
+ return null;
1256
+ }
1257
+ }
1258
+ function resolveFlex(parsed, web) {
1259
+ if (parsed.utility !== "flex") return null;
1260
+ const value = parsed.value;
1261
+ if (value === null) return null;
1262
+ if (parsed.isArbitrary) return [decl("flex", value)];
1263
+ switch (value) {
1264
+ case "row":
1265
+ return [decl("flex-direction", "row")];
1266
+ case "col":
1267
+ return [decl("flex-direction", "column")];
1268
+ case "row-reverse":
1269
+ return [decl("flex-direction", "row-reverse")];
1270
+ case "col-reverse":
1271
+ return [decl("flex-direction", "column-reverse")];
1272
+ case "wrap":
1273
+ return [decl("flex-wrap", "wrap")];
1274
+ case "wrap-reverse":
1275
+ return [decl("flex-wrap", "wrap-reverse")];
1276
+ case "nowrap":
1277
+ return [decl("flex-wrap", "nowrap")];
1278
+ case "1":
1279
+ return [decl("flex", "1")];
1280
+ case "auto":
1281
+ return [decl("flex", web ? "auto" : "1")];
1282
+ case "initial":
1283
+ return [decl("flex", web ? "initial" : "1")];
1284
+ case "none":
1285
+ return [decl("flex", web ? "none" : "0")];
1286
+ case "grow":
1287
+ return [decl("flex-grow", "1")];
1288
+ case "grow-0":
1289
+ return [decl("flex-grow", "0")];
1290
+ case "shrink":
1291
+ return [decl("flex-shrink", "1")];
1292
+ case "shrink-0":
1293
+ return [decl("flex-shrink", "0")];
1294
+ default:
1295
+ return null;
1296
+ }
382
1297
  }
383
1298
 
384
- // src/darkModeStore.ts
385
- var import_react_native2 = require("react-native");
386
- var listeners = /* @__PURE__ */ new Set();
387
- function systemPrefersDark() {
388
- return import_react_native2.Appearance.getColorScheme() === "dark";
389
- }
390
- function resolveIsDark(m) {
391
- return m === "system" ? systemPrefersDark() : m === "dark";
392
- }
393
- var mode = "system";
394
- var isDark = resolveIsDark(mode);
395
- var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
396
- if (mode !== "system") return;
397
- isDark = colorScheme === "dark";
398
- notify();
399
- });
400
- function notify() {
401
- for (const listener of listeners) listener();
1299
+ // src/jsEngine/resolvers/spacing.ts
1300
+ function namedSize(key) {
1301
+ switch (key) {
1302
+ case "sm":
1303
+ return "24rem";
1304
+ case "md":
1305
+ return "28rem";
1306
+ case "lg":
1307
+ return "32rem";
1308
+ case "xl":
1309
+ return "36rem";
1310
+ case "2xl":
1311
+ return "42rem";
1312
+ case "3xl":
1313
+ return "48rem";
1314
+ case "4xl":
1315
+ return "56rem";
1316
+ case "5xl":
1317
+ return "64rem";
1318
+ case "6xl":
1319
+ return "72rem";
1320
+ case "7xl":
1321
+ return "80rem";
1322
+ case "8xl":
1323
+ return "88rem";
1324
+ case "9xl":
1325
+ return "96rem";
1326
+ default:
1327
+ return null;
1328
+ }
1329
+ }
1330
+ function cssSizeKeyword(key) {
1331
+ switch (key) {
1332
+ case "min":
1333
+ return "min-content";
1334
+ case "max":
1335
+ return "max-content";
1336
+ case "fit":
1337
+ return "fit-content";
1338
+ default:
1339
+ return null;
1340
+ }
402
1341
  }
403
- function getGlobalDarkMode() {
404
- return isDark;
1342
+ function resolveSize(theme, parsed) {
1343
+ if (!parsed.isArbitrary && parsed.value !== null) {
1344
+ const named = namedSize(parsed.value);
1345
+ if (named !== null) return named;
1346
+ const kw = cssSizeKeyword(parsed.value);
1347
+ if (kw !== null) return kw;
1348
+ const fraction = fractionPercent(parsed.value);
1349
+ if (fraction !== null) return fraction;
1350
+ }
1351
+ return resolveLength(theme, parsed);
1352
+ }
1353
+ function resolve2(parsed, theme) {
1354
+ const length = () => resolveLength(theme, parsed);
1355
+ const size = () => resolveSize(theme, parsed);
1356
+ const negatableLength = () => resolveNegatableLength(theme, parsed);
1357
+ switch (parsed.utility) {
1358
+ case "p": {
1359
+ const v = length();
1360
+ return v === null ? null : [decl("padding", v)];
1361
+ }
1362
+ case "px": {
1363
+ const v = length();
1364
+ return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
1365
+ }
1366
+ case "py": {
1367
+ const v = length();
1368
+ return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
1369
+ }
1370
+ case "pt": {
1371
+ const v = length();
1372
+ return v === null ? null : [decl("padding-top", v)];
1373
+ }
1374
+ case "pr": {
1375
+ const v = length();
1376
+ return v === null ? null : [decl("padding-right", v)];
1377
+ }
1378
+ case "pb": {
1379
+ const v = length();
1380
+ return v === null ? null : [decl("padding-bottom", v)];
1381
+ }
1382
+ case "pl": {
1383
+ const v = length();
1384
+ return v === null ? null : [decl("padding-left", v)];
1385
+ }
1386
+ case "m": {
1387
+ const v = negatableLength();
1388
+ return v === null ? null : [decl("margin", v)];
1389
+ }
1390
+ case "mx": {
1391
+ const v = negatableLength();
1392
+ return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
1393
+ }
1394
+ case "my": {
1395
+ const v = negatableLength();
1396
+ return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
1397
+ }
1398
+ case "mt": {
1399
+ const v = negatableLength();
1400
+ return v === null ? null : [decl("margin-top", v)];
1401
+ }
1402
+ case "mr": {
1403
+ const v = negatableLength();
1404
+ return v === null ? null : [decl("margin-right", v)];
1405
+ }
1406
+ case "mb": {
1407
+ const v = negatableLength();
1408
+ return v === null ? null : [decl("margin-bottom", v)];
1409
+ }
1410
+ case "ml": {
1411
+ const v = negatableLength();
1412
+ return v === null ? null : [decl("margin-left", v)];
1413
+ }
1414
+ case "gap": {
1415
+ const v = length();
1416
+ return v === null ? null : [decl("gap", v)];
1417
+ }
1418
+ case "gap-x": {
1419
+ const v = length();
1420
+ return v === null ? null : [decl("column-gap", v)];
1421
+ }
1422
+ case "gap-y": {
1423
+ const v = length();
1424
+ return v === null ? null : [decl("row-gap", v)];
1425
+ }
1426
+ case "w": {
1427
+ const v = size();
1428
+ return v === null ? null : [decl("width", v)];
1429
+ }
1430
+ case "h": {
1431
+ const v = size();
1432
+ return v === null ? null : [decl("height", v)];
1433
+ }
1434
+ case "min-w": {
1435
+ const v = size();
1436
+ return v === null ? null : [decl("min-width", v)];
1437
+ }
1438
+ case "max-w": {
1439
+ const v = size();
1440
+ return v === null ? null : [decl("max-width", v)];
1441
+ }
1442
+ case "min-h": {
1443
+ const v = size();
1444
+ return v === null ? null : [decl("min-height", v)];
1445
+ }
1446
+ case "max-h": {
1447
+ const v = size();
1448
+ return v === null ? null : [decl("max-height", v)];
1449
+ }
1450
+ case "size": {
1451
+ const v = size();
1452
+ return v === null ? null : [decl("width", v), decl("height", v)];
1453
+ }
1454
+ case "basis": {
1455
+ const v = size();
1456
+ return v === null ? null : [decl("flex-basis", v)];
1457
+ }
1458
+ default:
1459
+ return null;
1460
+ }
1461
+ }
1462
+
1463
+ // src/jsEngine/resolvers/border.ts
1464
+ function radiusSize(key) {
1465
+ switch (key) {
1466
+ case "none":
1467
+ return "0px";
1468
+ case "sm":
1469
+ return "0.125rem";
1470
+ case "md":
1471
+ return "0.375rem";
1472
+ case "lg":
1473
+ return "0.5rem";
1474
+ case "xl":
1475
+ return "0.75rem";
1476
+ case "2xl":
1477
+ return "1rem";
1478
+ case "3xl":
1479
+ return "1.5rem";
1480
+ case "full":
1481
+ return "9999px";
1482
+ default:
1483
+ return null;
1484
+ }
1485
+ }
1486
+ function borderSideProperty(side) {
1487
+ switch (side) {
1488
+ case "t":
1489
+ return "border-top";
1490
+ case "r":
1491
+ return "border-right";
1492
+ case "b":
1493
+ return "border-bottom";
1494
+ case "l":
1495
+ return "border-left";
1496
+ default:
1497
+ return null;
1498
+ }
1499
+ }
1500
+ function borderValue(theme, parsed) {
1501
+ const value = parsed.value;
1502
+ if (value === null) return null;
1503
+ if (!parsed.isArbitrary) {
1504
+ const side = borderSideProperty(value);
1505
+ if (side !== null) {
1506
+ return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
1507
+ }
1508
+ if (value === "collapse") return [decl("border-collapse", "collapse")];
1509
+ if (value === "separate") return [decl("border-collapse", "separate")];
1510
+ }
1511
+ if (parsed.isArbitrary) {
1512
+ if (looksLikeLength(value)) return [decl("border-width", value)];
1513
+ const color2 = colorValue(theme, parsed);
1514
+ return color2 === null ? null : [decl("border-color", color2)];
1515
+ }
1516
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1517
+ const v = resolveLength(theme, parsed);
1518
+ return v === null ? null : [decl("border-width", v)];
1519
+ }
1520
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1521
+ return [decl("border-style", value)];
1522
+ }
1523
+ const color = colorValue(theme, parsed);
1524
+ return color === null ? null : [decl("border-color", color)];
1525
+ }
1526
+ function borderSideValue(theme, parsed, sideProperty) {
1527
+ const value = parsed.value;
1528
+ if (value === null) return null;
1529
+ if (parsed.isArbitrary) {
1530
+ if (looksLikeLength(value)) return [decl(`${sideProperty}-width`, value)];
1531
+ const color2 = colorValue(theme, parsed);
1532
+ return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
1533
+ }
1534
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1535
+ const v = resolveLength(theme, parsed);
1536
+ return v === null ? null : [decl(`${sideProperty}-width`, v)];
1537
+ }
1538
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1539
+ return [decl(`${sideProperty}-style`, value)];
1540
+ }
1541
+ const color = colorValue(theme, parsed);
1542
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
1543
+ }
1544
+ function borderAxisValue(theme, parsed, sideA, sideB) {
1545
+ const value = parsed.value;
1546
+ if (value === null) return null;
1547
+ if (parsed.isArbitrary) {
1548
+ if (looksLikeLength(value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1549
+ const color2 = colorValue(theme, parsed);
1550
+ return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
1551
+ }
1552
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1553
+ const v = resolveLength(theme, parsed);
1554
+ return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
1555
+ }
1556
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1557
+ return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
1558
+ }
1559
+ const color = colorValue(theme, parsed);
1560
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
1561
+ }
1562
+ function radiusProperties(side) {
1563
+ switch (side) {
1564
+ case "t":
1565
+ return ["border-top-left-radius", "border-top-right-radius"];
1566
+ case "r":
1567
+ return ["border-top-right-radius", "border-bottom-right-radius"];
1568
+ case "b":
1569
+ return ["border-bottom-right-radius", "border-bottom-left-radius"];
1570
+ case "l":
1571
+ return ["border-top-left-radius", "border-bottom-left-radius"];
1572
+ case "tl":
1573
+ return ["border-top-left-radius"];
1574
+ case "tr":
1575
+ return ["border-top-right-radius"];
1576
+ case "br":
1577
+ return ["border-bottom-right-radius"];
1578
+ case "bl":
1579
+ return ["border-bottom-left-radius"];
1580
+ default:
1581
+ return null;
1582
+ }
1583
+ }
1584
+ function resolveRadiusValue(theme, parsed) {
1585
+ if (!parsed.isArbitrary && parsed.value !== null) {
1586
+ const size = radiusSize(parsed.value);
1587
+ if (size !== null) return size;
1588
+ }
1589
+ return resolveLength(theme, parsed);
1590
+ }
1591
+ function resolveRadiusSide(theme, parsed, side) {
1592
+ const properties = radiusProperties(side);
1593
+ if (properties === null) return null;
1594
+ const value = resolveRadiusValue(theme, parsed);
1595
+ if (value === null) return null;
1596
+ return properties.map((p) => decl(p, value));
1597
+ }
1598
+ var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
1599
+ function outlineWidthValue(key) {
1600
+ switch (key) {
1601
+ case "0":
1602
+ return "0px";
1603
+ case "1":
1604
+ return "1px";
1605
+ case "2":
1606
+ return "2px";
1607
+ case "4":
1608
+ return "4px";
1609
+ case "8":
1610
+ return "8px";
1611
+ default:
1612
+ return null;
1613
+ }
1614
+ }
1615
+ function outlineValue(theme, parsed) {
1616
+ const value = parsed.value;
1617
+ if (value === null) return null;
1618
+ if (parsed.isArbitrary) {
1619
+ if (looksLikeLength(value)) return [decl("outline-width", value)];
1620
+ const color2 = colorValue(theme, parsed);
1621
+ return color2 === null ? null : [decl("outline-color", color2)];
1622
+ }
1623
+ const w = outlineWidthValue(value);
1624
+ if (w !== null) return [decl("outline-width", w)];
1625
+ if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
1626
+ const color = colorValue(theme, parsed);
1627
+ return color === null ? null : [decl("outline-color", color)];
1628
+ }
1629
+ function outlineOffsetValue(parsed) {
1630
+ const value = parsed.value;
1631
+ if (value === null) return null;
1632
+ if (parsed.isArbitrary) return [decl("outline-offset", value)];
1633
+ const w = outlineWidthValue(value);
1634
+ return w === null ? null : [decl("outline-offset", w)];
1635
+ }
1636
+ var RING_BOX_SHADOW = "var(--kb-ring-inset,) 0 0 0 var(--kb-ring-offset-width, 0px) var(--kb-ring-offset-color, #fff), var(--kb-ring-inset,) 0 0 0 calc(var(--kb-ring-width, 0px) + var(--kb-ring-offset-width, 0px)) var(--kb-ring-color, rgba(59,130,246,0.5))";
1637
+ function ringWidth(key) {
1638
+ switch (key) {
1639
+ case "0":
1640
+ return "0px";
1641
+ case "1":
1642
+ return "1px";
1643
+ case "2":
1644
+ return "2px";
1645
+ case "4":
1646
+ return "4px";
1647
+ case "8":
1648
+ return "8px";
1649
+ default:
1650
+ return null;
1651
+ }
1652
+ }
1653
+ function ringValue(theme, parsed) {
1654
+ const value = parsed.value;
1655
+ if (value === null) return null;
1656
+ if (value === "inset") {
1657
+ return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
1658
+ }
1659
+ if (!parsed.isArbitrary) {
1660
+ const w = ringWidth(value);
1661
+ if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1662
+ }
1663
+ const color = colorValue(theme, parsed);
1664
+ if (color === null) return null;
1665
+ return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1666
+ }
1667
+ function ringOffsetValue(theme, parsed) {
1668
+ const value = parsed.value;
1669
+ if (value === null) return null;
1670
+ if (!parsed.isArbitrary) {
1671
+ const w = ringWidth(value);
1672
+ if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1673
+ }
1674
+ const color = colorValue(theme, parsed);
1675
+ if (color === null) return null;
1676
+ return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1677
+ }
1678
+ var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
1679
+ function resolve3(parsed, theme) {
1680
+ switch (parsed.utility) {
1681
+ case "border":
1682
+ if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
1683
+ return borderValue(theme, parsed);
1684
+ case "border-t":
1685
+ return borderSideValue(theme, parsed, "border-top");
1686
+ case "border-r":
1687
+ return borderSideValue(theme, parsed, "border-right");
1688
+ case "border-b":
1689
+ return borderSideValue(theme, parsed, "border-bottom");
1690
+ case "border-l":
1691
+ return borderSideValue(theme, parsed, "border-left");
1692
+ case "border-x":
1693
+ return borderAxisValue(theme, parsed, "border-left", "border-right");
1694
+ case "border-y":
1695
+ return borderAxisValue(theme, parsed, "border-top", "border-bottom");
1696
+ case "rounded": {
1697
+ if (parsed.value === null) return [decl("border-radius", "0.25rem")];
1698
+ const value = parsed.value;
1699
+ if (!parsed.isArbitrary) {
1700
+ const size = radiusSize(value);
1701
+ if (size !== null) return [decl("border-radius", size)];
1702
+ }
1703
+ const v = resolveLength(theme, parsed);
1704
+ return v === null ? null : [decl("border-radius", v)];
1705
+ }
1706
+ case "ring":
1707
+ if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
1708
+ return ringValue(theme, parsed);
1709
+ case "ring-offset":
1710
+ return ringOffsetValue(theme, parsed);
1711
+ case "outline":
1712
+ if (parsed.value === null) return [decl("outline-style", "solid")];
1713
+ if (parsed.value === "none") return [decl("outline", "none")];
1714
+ return outlineValue(theme, parsed);
1715
+ case "outline-offset":
1716
+ return outlineOffsetValue(parsed);
1717
+ default:
1718
+ if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
1719
+ return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
1720
+ }
1721
+ return null;
1722
+ }
1723
+ }
1724
+
1725
+ // src/jsEngine/resolvers/typography.ts
1726
+ function textSize(key) {
1727
+ switch (key) {
1728
+ case "xs":
1729
+ return "0.75rem";
1730
+ case "sm":
1731
+ return "0.875rem";
1732
+ case "base":
1733
+ return "1rem";
1734
+ case "lg":
1735
+ return "1.125rem";
1736
+ case "xl":
1737
+ return "1.25rem";
1738
+ case "2xl":
1739
+ return "1.5rem";
1740
+ case "3xl":
1741
+ return "1.875rem";
1742
+ case "4xl":
1743
+ return "2.25rem";
1744
+ case "5xl":
1745
+ return "3rem";
1746
+ case "6xl":
1747
+ return "3.75rem";
1748
+ case "7xl":
1749
+ return "4.5rem";
1750
+ case "8xl":
1751
+ return "6rem";
1752
+ case "9xl":
1753
+ return "8rem";
1754
+ default:
1755
+ return null;
1756
+ }
1757
+ }
1758
+ function lineHeightSize(key) {
1759
+ switch (key) {
1760
+ case "3":
1761
+ return "0.75rem";
1762
+ case "4":
1763
+ return "1rem";
1764
+ case "5":
1765
+ return "1.25rem";
1766
+ case "6":
1767
+ return "1.5rem";
1768
+ case "7":
1769
+ return "1.75rem";
1770
+ case "8":
1771
+ return "2rem";
1772
+ case "9":
1773
+ return "2.25rem";
1774
+ case "10":
1775
+ return "2.5rem";
1776
+ default:
1777
+ return null;
1778
+ }
1779
+ }
1780
+ function textAlign(key) {
1781
+ switch (key) {
1782
+ case "left":
1783
+ return "left";
1784
+ case "center":
1785
+ return "center";
1786
+ case "right":
1787
+ return "right";
1788
+ case "justify":
1789
+ return "justify";
1790
+ // Logical alignment — same "no direction-tracking logic needed" reasoning
1791
+ // as layout.rs's start/end inset properties.
1792
+ case "start":
1793
+ return "start";
1794
+ case "end":
1795
+ return "end";
1796
+ default:
1797
+ return null;
1798
+ }
1799
+ }
1800
+ function fontWeight(key) {
1801
+ switch (key) {
1802
+ case "thin":
1803
+ return "100";
1804
+ case "extralight":
1805
+ return "200";
1806
+ case "light":
1807
+ return "300";
1808
+ case "normal":
1809
+ return "400";
1810
+ case "medium":
1811
+ return "500";
1812
+ case "semibold":
1813
+ return "600";
1814
+ case "bold":
1815
+ return "700";
1816
+ case "extrabold":
1817
+ return "800";
1818
+ case "black":
1819
+ return "900";
1820
+ default:
1821
+ return null;
1822
+ }
1823
+ }
1824
+ function fontFamilyValue(theme, key) {
1825
+ const fromTheme = theme.fontFamily?.[key];
1826
+ if (fromTheme !== void 0) return fromTheme;
1827
+ switch (key) {
1828
+ case "sans":
1829
+ return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
1830
+ case "serif":
1831
+ return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
1832
+ case "mono":
1833
+ return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
1834
+ default:
1835
+ return null;
1836
+ }
1837
+ }
1838
+
1839
+ // src/jsEngine/resolvers/effects.ts
1840
+ function nativeShadowValue(key) {
1841
+ switch (key) {
1842
+ case "sm":
1843
+ return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
1844
+ case "DEFAULT":
1845
+ return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
1846
+ case "md":
1847
+ return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
1848
+ case "lg":
1849
+ return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
1850
+ case "xl":
1851
+ return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
1852
+ case "2xl":
1853
+ return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
1854
+ case "none":
1855
+ return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
1856
+ default:
1857
+ return null;
1858
+ }
1859
+ }
1860
+ function nativeShadowDeclarations(parsed) {
1861
+ if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
1862
+ const key = parsed.value ?? "DEFAULT";
1863
+ const s = nativeShadowValue(key);
1864
+ if (s === null) return null;
1865
+ return [
1866
+ decl("shadow-color", "#000000"),
1867
+ decl("shadow-offset-x", "0"),
1868
+ decl("shadow-offset-y", String(s.offsetY)),
1869
+ decl("shadow-opacity", String(s.opacity)),
1870
+ decl("shadow-radius", String(s.radius)),
1871
+ decl("elevation", String(s.elevation))
1872
+ ];
1873
+ }
1874
+
1875
+ // src/jsEngine/resolvers/transform.ts
1876
+ function scaleFactor(parsed) {
1877
+ if (parsed.value === null) return null;
1878
+ const n = Number(parsed.value);
1879
+ if (!Number.isFinite(n)) return null;
1880
+ return parsed.isArbitrary ? n : n / 100;
1881
+ }
1882
+ function angle(parsed) {
1883
+ if (parsed.value === null) return null;
1884
+ if (parsed.isArbitrary) return parsed.value;
1885
+ const n = Number(parsed.value);
1886
+ if (!Number.isFinite(n)) return null;
1887
+ return `${parsed.negative ? -n : n}deg`;
1888
+ }
1889
+ function resolveNative(parsed, theme) {
1890
+ switch (parsed.utility) {
1891
+ case "transform-none":
1892
+ return [decl("transform-op-none", "1")];
1893
+ case "backface-visible":
1894
+ return [decl("backface-visibility", "visible")];
1895
+ case "backface-hidden":
1896
+ return [decl("backface-visibility", "hidden")];
1897
+ case "translate-x": {
1898
+ const v = resolveNegatableSize(theme, parsed);
1899
+ return v === null ? null : [decl("transform-op-translate-x", v)];
1900
+ }
1901
+ case "translate-y": {
1902
+ const v = resolveNegatableSize(theme, parsed);
1903
+ return v === null ? null : [decl("transform-op-translate-y", v)];
1904
+ }
1905
+ case "scale": {
1906
+ const n = scaleFactor(parsed);
1907
+ return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
1908
+ }
1909
+ case "scale-x": {
1910
+ const n = scaleFactor(parsed);
1911
+ return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
1912
+ }
1913
+ case "scale-y": {
1914
+ const n = scaleFactor(parsed);
1915
+ return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
1916
+ }
1917
+ case "rotate": {
1918
+ const deg = angle(parsed);
1919
+ return deg === null ? null : [decl("transform-op-rotate", deg)];
1920
+ }
1921
+ case "rotate-x": {
1922
+ const deg = angle(parsed);
1923
+ return deg === null ? null : [decl("transform-op-rotate-x", deg)];
1924
+ }
1925
+ case "rotate-y": {
1926
+ const deg = angle(parsed);
1927
+ return deg === null ? null : [decl("transform-op-rotate-y", deg)];
1928
+ }
1929
+ case "rotate-z": {
1930
+ const deg = angle(parsed);
1931
+ return deg === null ? null : [decl("transform-op-rotate-z", deg)];
1932
+ }
1933
+ case "skew-x": {
1934
+ const deg = angle(parsed);
1935
+ return deg === null ? null : [decl("transform-op-skew-x", deg)];
1936
+ }
1937
+ case "skew-y": {
1938
+ const deg = angle(parsed);
1939
+ return deg === null ? null : [decl("transform-op-skew-y", deg)];
1940
+ }
1941
+ default:
1942
+ return null;
1943
+ }
1944
+ }
1945
+
1946
+ // src/jsEngine/resolveUtilityNative.ts
1947
+ function firstFontName(stack) {
1948
+ const first = stack.split(",")[0] ?? stack;
1949
+ return first.trim().replace(/^["']|["']$/g, "");
1950
+ }
1951
+ function resolveTypographyNative(parsed, theme) {
1952
+ switch (parsed.utility) {
1953
+ case "font": {
1954
+ if (parsed.value === null) return null;
1955
+ if (parsed.isArbitrary) {
1956
+ return [decl("font-family", firstFontName(parsed.value))];
1957
+ }
1958
+ const w = fontWeight(parsed.value);
1959
+ if (w !== null) return [decl("font-weight", w)];
1960
+ const family = fontFamilyValue(theme, parsed.value);
1961
+ return family === null ? null : [decl("font-family", firstFontName(family))];
1962
+ }
1963
+ case "uppercase":
1964
+ return [decl("text-transform", "uppercase")];
1965
+ case "lowercase":
1966
+ return [decl("text-transform", "lowercase")];
1967
+ case "capitalize":
1968
+ return [decl("text-transform", "capitalize")];
1969
+ case "underline":
1970
+ return [decl("text-decoration-line", "underline")];
1971
+ case "line-through":
1972
+ return [decl("text-decoration-line", "line-through")];
1973
+ case "no-underline":
1974
+ return [decl("text-decoration-line", "none")];
1975
+ case "italic":
1976
+ return [decl("font-style", "italic")];
1977
+ case "not-italic":
1978
+ return [decl("font-style", "normal")];
1979
+ default:
1980
+ return null;
1981
+ }
1982
+ }
1983
+ function resolveLeadingTrackingNative(parsed) {
1984
+ const value = parsed.value;
1985
+ if (value === null) return null;
1986
+ if (parsed.utility === "leading") {
1987
+ if (parsed.isArbitrary) return [decl("line-height", value)];
1988
+ const v = lineHeightSize(value);
1989
+ return v === null ? null : [decl("line-height", v)];
1990
+ }
1991
+ if (parsed.utility === "tracking" && parsed.isArbitrary) {
1992
+ return [decl("letter-spacing", value)];
1993
+ }
1994
+ return null;
1995
+ }
1996
+ function nativeHexColor(parsed, theme) {
1997
+ return colorValue(theme, parsed);
1998
+ }
1999
+ function resolveTextNative(parsed, theme) {
2000
+ if (!parsed.isArbitrary && parsed.value !== null) {
2001
+ const size = textSize(parsed.value);
2002
+ if (size !== null) return [decl("font-size", size)];
2003
+ const align = textAlign(parsed.value);
2004
+ if (align !== null) return [decl("text-align", align)];
2005
+ }
2006
+ const hex = nativeHexColor(parsed, theme);
2007
+ return hex === null ? null : [decl("color", hex)];
2008
+ }
2009
+ function resolveColorNative(parsed, theme) {
2010
+ switch (parsed.utility) {
2011
+ case "bg": {
2012
+ const hex = nativeHexColor(parsed, theme);
2013
+ return hex === null ? null : [decl("background-color", hex)];
2014
+ }
2015
+ case "text":
2016
+ return resolveTextNative(parsed, theme);
2017
+ default:
2018
+ return null;
2019
+ }
2020
+ }
2021
+ function resolveOpacityNative(parsed) {
2022
+ if (parsed.utility !== "opacity") return null;
2023
+ const v = resolvePercent(parsed);
2024
+ return v === null ? null : [decl("opacity", v)];
2025
+ }
2026
+ function resolveUtilityNative(parsed, theme) {
2027
+ return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed, theme) ?? resolveOpacityNative(parsed) ?? nativeShadowDeclarations(parsed) ?? resolveNative(parsed, theme);
2028
+ }
2029
+
2030
+ // src/jsEngine/resolveStyle.ts
2031
+ var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
2032
+ var STATE_HOLD_MARKER2 = "_kbon";
2033
+ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
2034
+ if (modifier === STATE_HOLD_MARKER2) return true;
2035
+ if (modifier === "dark") return colorScheme === "dark";
2036
+ if (modifier === "active") return pressed;
2037
+ if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
2038
+ const minWidth = theme.screens[modifier];
2039
+ if (minWidth === void 0) return null;
2040
+ return width >= minWidth;
2041
+ }
2042
+ if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
2043
+ const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
2044
+ return px === null ? null : width >= px;
2045
+ }
2046
+ if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
2047
+ const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
2048
+ return px === null ? null : width <= px;
2049
+ }
2050
+ return null;
2051
+ }
2052
+ function kebabToCamel(s) {
2053
+ return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
2054
+ }
2055
+ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
2056
+ "padding",
2057
+ "padding-top",
2058
+ "padding-right",
2059
+ "padding-bottom",
2060
+ "padding-left",
2061
+ "margin",
2062
+ "margin-top",
2063
+ "margin-right",
2064
+ "margin-bottom",
2065
+ "margin-left",
2066
+ "gap",
2067
+ "column-gap",
2068
+ "row-gap",
2069
+ "width",
2070
+ "height",
2071
+ "min-width",
2072
+ "max-width",
2073
+ "min-height",
2074
+ "max-height",
2075
+ "top",
2076
+ "right",
2077
+ "bottom",
2078
+ "left",
2079
+ "inset",
2080
+ "border-radius",
2081
+ "border-width",
2082
+ "font-size",
2083
+ "z-index",
2084
+ "line-height",
2085
+ "letter-spacing",
2086
+ "flex",
2087
+ "flex-grow",
2088
+ "flex-shrink",
2089
+ "order",
2090
+ "flex-basis",
2091
+ "shadow-opacity",
2092
+ "shadow-radius",
2093
+ "elevation",
2094
+ "opacity",
2095
+ // Per-side border width + per-corner radius — see resolvers/border.ts's
2096
+ // new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
2097
+ // style system wants plain numbers for these exactly like the generic
2098
+ // "border-width"/"border-radius" forms above.
2099
+ "border-top-width",
2100
+ "border-right-width",
2101
+ "border-bottom-width",
2102
+ "border-left-width",
2103
+ "border-top-left-radius",
2104
+ "border-top-right-radius",
2105
+ "border-bottom-right-radius",
2106
+ "border-bottom-left-radius",
2107
+ "outline-width",
2108
+ "outline-offset",
2109
+ // The transform ops whose RN value is a plain JS number — translate takes
2110
+ // a length (px/percentage, same as top/left/etc. above) and scale takes a
2111
+ // bare decimal factor (parsed by the same "raw value" fallback branch
2112
+ // below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
2113
+ // purpose, since RN wants those as literal "45deg"-shaped strings, not
2114
+ // numbers. See the transform-ops accumulator below for how these markers
2115
+ // get collected into the final array.
2116
+ "transform-op-translate-x",
2117
+ "transform-op-translate-y",
2118
+ "transform-op-scale-x",
2119
+ "transform-op-scale-y"
2120
+ ]);
2121
+ var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
2122
+ ["transform-op-translate-x", "translateX"],
2123
+ ["transform-op-translate-y", "translateY"],
2124
+ ["transform-op-rotate", "rotate"],
2125
+ ["transform-op-rotate-x", "rotateX"],
2126
+ ["transform-op-rotate-y", "rotateY"],
2127
+ ["transform-op-rotate-z", "rotateZ"],
2128
+ ["transform-op-skew-x", "skewX"],
2129
+ ["transform-op-skew-y", "skewY"],
2130
+ ["transform-op-scale-x", "scaleX"],
2131
+ ["transform-op-scale-y", "scaleY"]
2132
+ ]);
2133
+ var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
2134
+ function isPlainPercentage(value) {
2135
+ if (!value.endsWith("%")) return false;
2136
+ let digits = value.slice(0, -1);
2137
+ if (digits.startsWith("-")) digits = digits.slice(1);
2138
+ return digits.length > 0 && /^[0-9.]+$/.test(digits);
2139
+ }
2140
+ function sanitizeForWarning(value) {
2141
+ const MAX_CHARS = 60;
2142
+ const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
2143
+ if (escaped.length <= MAX_CHARS) return escaped;
2144
+ return `${escaped.slice(0, MAX_CHARS)}\u2026`;
2145
+ }
2146
+ function rnStyleValue(property, value) {
2147
+ if (property === "aspect-ratio") {
2148
+ if (value.trim() === "auto") return { value: null, warning: null };
2149
+ const parts = value.split("/").map((s) => s.trim());
2150
+ let n = null;
2151
+ if (parts.length === 1) {
2152
+ const a = Number(parts[0]);
2153
+ n = Number.isFinite(a) ? a : null;
2154
+ } else if (parts.length === 2) {
2155
+ const a = Number(parts[0]);
2156
+ const b = Number(parts[1]);
2157
+ n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
2158
+ }
2159
+ return { value: n, warning: null };
2160
+ }
2161
+ if (!NUMERIC_LENGTH_PROPS.has(property)) {
2162
+ return { value, warning: null };
2163
+ }
2164
+ if (value === "auto") {
2165
+ return { value: "auto", warning: null };
2166
+ }
2167
+ let px = null;
2168
+ if (value.endsWith("px")) {
2169
+ const n = Number(value.slice(0, -2));
2170
+ px = Number.isFinite(n) ? n : null;
2171
+ } else if (value.endsWith("rem")) {
2172
+ const n = Number(value.slice(0, -3));
2173
+ px = Number.isFinite(n) ? n * 16 : null;
2174
+ } else {
2175
+ const n = Number(value);
2176
+ px = value.trim() !== "" && Number.isFinite(n) ? n : null;
2177
+ }
2178
+ if (px !== null) return { value: px, warning: null };
2179
+ if (isPlainPercentage(value)) {
2180
+ return { value, warning: null };
2181
+ }
2182
+ const reduced = reduceConstantMath(value);
2183
+ if (reduced !== null) {
2184
+ return { value: reduced, warning: null };
2185
+ }
2186
+ const sanitizedValue = sanitizeForWarning(value);
2187
+ const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
2188
+ calc()/min()/max()/clamp() only resolve on native when every operand is a constant px/rem length (no %, vw, vh, var(), or other viewport/CSS-variable units \u2014 those need real layout/DOM, which doesn't exist on native at paint time).
2189
+ Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
2190
+ return { value: null, warning };
2191
+ }
2192
+ function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
2193
+ const style = {};
2194
+ const warnings = [];
2195
+ let shadowOffset = null;
2196
+ const transformOps = /* @__PURE__ */ new Map();
2197
+ const keySpecificity = /* @__PURE__ */ new Map();
2198
+ const transformSpecificity = /* @__PURE__ */ new Map();
2199
+ for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
2200
+ const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
2201
+ const parsed = parseClass(token);
2202
+ const allModifiersHold = parsed.modifiers.every(
2203
+ (m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
2204
+ );
2205
+ if (!allModifiersHold) continue;
2206
+ const decls = resolveUtilityNative(parsed, theme);
2207
+ if (decls === null) continue;
2208
+ const spec = parsed.modifiers.length;
2209
+ for (const d of decls) {
2210
+ if (d.property.startsWith("__")) {
2211
+ continue;
2212
+ }
2213
+ if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
2214
+ if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
2215
+ const n = Number(d.value);
2216
+ if (!Number.isFinite(n)) continue;
2217
+ if (shadowOffset === null) shadowOffset = {};
2218
+ shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
2219
+ keySpecificity.set("shadowOffset", spec);
2220
+ continue;
2221
+ }
2222
+ if (d.property === "transform-op-none") {
2223
+ transformOps.clear();
2224
+ transformSpecificity.clear();
2225
+ continue;
2226
+ }
2227
+ const opKey = TRANSFORM_OP_KEYS.get(d.property);
2228
+ if (opKey !== void 0) {
2229
+ if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
2230
+ const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
2231
+ if (warning2 !== null) warnings.push(warning2);
2232
+ if (value2 !== null) {
2233
+ transformOps.set(opKey, value2);
2234
+ transformSpecificity.set(opKey, spec);
2235
+ }
2236
+ continue;
2237
+ }
2238
+ const key = kebabToCamel(d.property);
2239
+ if (spec < (keySpecificity.get(key) ?? 0)) continue;
2240
+ const { value, warning } = rnStyleValue(d.property, d.value);
2241
+ if (warning !== null) warnings.push(warning);
2242
+ if (value !== null) {
2243
+ style[key] = value;
2244
+ keySpecificity.set(key, spec);
2245
+ }
2246
+ }
2247
+ }
2248
+ if (shadowOffset !== null) {
2249
+ style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
2250
+ }
2251
+ if (transformOps.size > 0) {
2252
+ style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
2253
+ [key]: transformOps.get(key)
2254
+ }));
2255
+ }
2256
+ return { style, warnings };
405
2257
  }
406
2258
 
407
2259
  // src/nativeBridge.ts
2260
+ var RESOLVE_STYLE_CACHE_MAX = 500;
2261
+ var resolveStyleCache = /* @__PURE__ */ new Map();
2262
+ var cachedForThemeJson = null;
408
2263
  function resolveStyle(classString, pressed = false) {
409
- const KbachModule = import_react_native3.TurboModuleRegistry.getEnforcing("KbachModule");
410
- const colorScheme = getGlobalDarkMode() ? "dark" : "light";
411
- const width = import_react_native3.Dimensions.get("window").width;
412
- const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
413
- return JSON.parse(json);
2264
+ const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
2265
+ const width = import_react_native2.Dimensions.get("window").width;
2266
+ const themeJson = (0, import_theme2.getThemeJson)();
2267
+ if (themeJson !== cachedForThemeJson) {
2268
+ resolveStyleCache.clear();
2269
+ cachedForThemeJson = themeJson;
2270
+ }
2271
+ const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
2272
+ const cached = resolveStyleCache.get(cacheKey);
2273
+ if (cached !== void 0) return { ...cached };
2274
+ const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
2275
+ if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
2276
+ resolveStyleCache.set(cacheKey, style);
2277
+ return { ...style };
2278
+ }
2279
+ function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
2280
+ const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
2281
+ if (!KbachModule) {
2282
+ const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme2.getTheme)(), colorScheme, pressed, width);
2283
+ warnIfDev(classString, warnings2);
2284
+ return style2;
2285
+ }
2286
+ const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
2287
+ const style = JSON.parse(json);
2288
+ const warnings = style.__kbachWarnings;
2289
+ if (warnings !== void 0) {
2290
+ delete style.__kbachWarnings;
2291
+ warnIfDev(classString, warnings);
2292
+ }
2293
+ return style;
2294
+ }
2295
+ var WARNED_MESSAGES_MAX = 500;
2296
+ var warnedMessages = /* @__PURE__ */ new Set();
2297
+ var QUOTED_TOKEN_RE = /"([^"]*)"/;
2298
+ function highlightToken(classString, warning) {
2299
+ const match = QUOTED_TOKEN_RE.exec(warning);
2300
+ if (match === null) return classString;
2301
+ const quoted = match[1].replace(/\s+/g, "");
2302
+ if (quoted === "") return classString;
2303
+ const parts = classString.split(/(\s+)/);
2304
+ const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
2305
+ if (idx === -1) return classString;
2306
+ parts[idx] = `\xBB${parts[idx]}\xAB`;
2307
+ return parts.join("");
2308
+ }
2309
+ function warnIfDev(classString, warnings) {
2310
+ if (warnings.length === 0) return;
2311
+ if (typeof __DEV__ !== "undefined" && !__DEV__) return;
2312
+ for (const warning of warnings) {
2313
+ const message = `${warning}
2314
+ From className: "${highlightToken(classString, warning)}"`;
2315
+ if (warnedMessages.has(message)) continue;
2316
+ if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
2317
+ warnedMessages.add(message);
2318
+ console.warn(message);
2319
+ }
414
2320
  }
415
2321
 
416
2322
  // src/jsx-runtime.tsx