@kbach/react-native 1.0.0-beta.8 → 1.0.0

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 (51) hide show
  1. package/AGENTS.md +495 -0
  2. package/LICENSE +21 -0
  3. package/README.md +209 -249
  4. package/THIRD_PARTY_NOTICES.md +41 -0
  5. package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
  6. package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
  7. package/dist/chunk-7CNURQSH.mjs +112 -0
  8. package/dist/{chunk-OIW7OQWO.mjs → chunk-HYQFT32E.mjs} +2 -2
  9. package/dist/chunk-MUPEQJRT.mjs +623 -0
  10. package/dist/darkModeStore.d.ts +73 -0
  11. package/dist/darkModeStore.js +118 -0
  12. package/dist/dynamicTokens.d.ts +53 -0
  13. package/dist/dynamicTokens.js +75 -0
  14. package/dist/index.d.ts +90 -71
  15. package/dist/index.js +1433 -606
  16. package/dist/index.web.d.ts +91 -1
  17. package/dist/index.web.js +323 -428
  18. package/dist/index.web.mjs +297 -11
  19. package/dist/jsx-dev-runtime.d.ts +2 -2
  20. package/dist/jsx-dev-runtime.js +1540 -589
  21. package/dist/jsx-dev-runtime.web.d.ts +2 -2
  22. package/dist/jsx-dev-runtime.web.js +20 -340
  23. package/dist/jsx-dev-runtime.web.mjs +18 -6
  24. package/dist/jsx-runtime.d.ts +3 -3
  25. package/dist/jsx-runtime.js +1530 -579
  26. package/dist/jsx-runtime.web.d.ts +3 -3
  27. package/dist/jsx-runtime.web.js +17 -340
  28. package/dist/jsx-runtime.web.mjs +2 -3
  29. package/dist/semanticElements-Bk3TB-vt.d.ts +334 -0
  30. package/dist/theme.d.ts +79 -0
  31. package/dist/{chunk-4BXM3QUV.mjs → theme.js} +120 -17
  32. package/llms.txt +38 -0
  33. package/package.json +15 -13
  34. package/src/babel-plugin.js +144 -2
  35. package/dist/ThemeContext-Dc5AC-m0.d.mts +0 -98
  36. package/dist/ThemeContext-Dc5AC-m0.d.ts +0 -98
  37. package/dist/chunk-CGU7UM2F.mjs +0 -66
  38. package/dist/chunk-DLIXI5OW.mjs +0 -53
  39. package/dist/chunk-JR3BLUAV.mjs +0 -1204
  40. package/dist/chunk-JS5KIGAB.mjs +0 -192
  41. package/dist/chunk-KV3ZIXSH.mjs +0 -14
  42. package/dist/chunk-Z664AKW7.mjs +0 -54
  43. package/dist/index.d.mts +0 -84
  44. package/dist/index.mjs +0 -34
  45. package/dist/index.web.d.mts +0 -15
  46. package/dist/jsx-dev-runtime.d.mts +0 -10
  47. package/dist/jsx-dev-runtime.mjs +0 -18
  48. package/dist/jsx-dev-runtime.web.d.mts +0 -10
  49. package/dist/jsx-runtime.d.mts +0 -7
  50. package/dist/jsx-runtime.mjs +0 -15
  51. package/dist/jsx-runtime.web.d.mts +0 -7
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,420 +17,55 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
31
  var src_exports = {};
22
32
  __export(src_exports, {
33
+ Button: () => Button,
34
+ H1: () => H1,
35
+ H2: () => H2,
36
+ H3: () => H3,
37
+ H4: () => H4,
38
+ H5: () => H5,
39
+ H6: () => H6,
40
+ Paragraph: () => Paragraph,
23
41
  ThemeProvider: () => ThemeProvider,
24
- defaultTheme: () => defaultTheme,
25
- getGlobalDarkMode: () => getGlobalDarkMode,
26
- getGlobalThemeMode: () => getGlobalThemeMode,
27
- getTheme: () => getTheme,
42
+ applyKbachConfig: () => applyKbachConfig,
43
+ clsx: () => clsx,
44
+ defaultTheme: () => import_theme4.defaultTheme,
45
+ deleteDynamicToken: () => import_dynamicTokens2.deleteDynamicToken,
46
+ getDynamicToken: () => import_dynamicTokens2.getDynamicToken,
47
+ getGlobalDarkMode: () => import_darkModeStore5.getGlobalDarkMode,
48
+ getGlobalThemeMode: () => import_darkModeStore5.getGlobalThemeMode,
49
+ getTheme: () => import_theme4.getTheme,
50
+ resolveKbachConfig: () => resolveKbachConfig,
28
51
  resolveStyle: () => resolveStyle,
29
- setGlobalThemeMode: () => setGlobalThemeMode,
30
- setTheme: () => setTheme,
31
- subscribeGlobalDarkMode: () => subscribeGlobalDarkMode,
32
- toggleGlobalDarkMode: () => toggleGlobalDarkMode,
33
- useGlobalDarkMode: () => useGlobalDarkMode,
52
+ setDynamicToken: () => import_dynamicTokens2.setDynamicToken,
53
+ setGlobalThemeMode: () => import_darkModeStore5.setGlobalThemeMode,
54
+ setTheme: () => import_theme4.setTheme,
55
+ subscribeDynamicTokens: () => import_dynamicTokens2.subscribeDynamicTokens,
56
+ subscribeGlobalDarkMode: () => import_darkModeStore5.subscribeGlobalDarkMode,
57
+ toggleGlobalDarkMode: () => import_darkModeStore5.toggleGlobalDarkMode,
58
+ useColors: () => useColors,
59
+ useDynamicToken: () => useDynamicToken,
34
60
  useTheme: () => useTheme
35
61
  });
36
62
  module.exports = __toCommonJS(src_exports);
37
-
38
- // src/generatedPalette.ts
39
- var PALETTE = {
40
- "amber-1": "#fffbeb",
41
- "amber-10": "#78350f",
42
- "amber-11": "#451a03",
43
- "amber-12": "#291002",
44
- "amber-2": "#fef3c7",
45
- "amber-3": "#fde68a",
46
- "amber-4": "#fcd34d",
47
- "amber-5": "#fbbf24",
48
- "amber-6": "#f59e0b",
49
- "amber-7": "#d97706",
50
- "amber-8": "#b45309",
51
- "amber-9": "#92400e",
52
- "black": "#000000",
53
- "blue-1": "#eff6ff",
54
- "blue-10": "#1e3a8a",
55
- "blue-11": "#172554",
56
- "blue-12": "#0d1633",
57
- "blue-2": "#dbeafe",
58
- "blue-3": "#bfdbfe",
59
- "blue-4": "#93c5fd",
60
- "blue-5": "#60a5fa",
61
- "blue-6": "#3b82f6",
62
- "blue-7": "#2563eb",
63
- "blue-8": "#1d4ed8",
64
- "blue-9": "#1e40af",
65
- "bronze": "#cd7f32",
66
- "coal": "#1c1c1c",
67
- "copper": "#b87333",
68
- "current": "currentColor",
69
- "cyan-1": "#ecfeff",
70
- "cyan-10": "#164e63",
71
- "cyan-11": "#083344",
72
- "cyan-12": "#041e28",
73
- "cyan-2": "#cffafe",
74
- "cyan-3": "#a5f3fc",
75
- "cyan-4": "#67e8f9",
76
- "cyan-5": "#22d3ee",
77
- "cyan-6": "#06b6d4",
78
- "cyan-7": "#0891b2",
79
- "cyan-8": "#0e7490",
80
- "cyan-9": "#155e75",
81
- "emerald-1": "#ecfdf5",
82
- "emerald-10": "#064e3b",
83
- "emerald-11": "#022c22",
84
- "emerald-12": "#011a14",
85
- "emerald-2": "#d1fae5",
86
- "emerald-3": "#a7f3d0",
87
- "emerald-4": "#6ee7b7",
88
- "emerald-5": "#34d399",
89
- "emerald-6": "#10b981",
90
- "emerald-7": "#059669",
91
- "emerald-8": "#047857",
92
- "emerald-9": "#065f46",
93
- "fuchsia-1": "#fdf4ff",
94
- "fuchsia-10": "#701a75",
95
- "fuchsia-11": "#4a044e",
96
- "fuchsia-12": "#2d022f",
97
- "fuchsia-2": "#fae8ff",
98
- "fuchsia-3": "#f5d0fe",
99
- "fuchsia-4": "#f0abfc",
100
- "fuchsia-5": "#e879f9",
101
- "fuchsia-6": "#d946ef",
102
- "fuchsia-7": "#c026d3",
103
- "fuchsia-8": "#a21caf",
104
- "fuchsia-9": "#86198f",
105
- "gold": "#d4af37",
106
- "gray-1": "#f9fafb",
107
- "gray-10": "#111827",
108
- "gray-11": "#030712",
109
- "gray-12": "#020409",
110
- "gray-2": "#f3f4f6",
111
- "gray-3": "#e5e7eb",
112
- "gray-4": "#d1d5db",
113
- "gray-5": "#9ca3af",
114
- "gray-6": "#6b7280",
115
- "gray-7": "#4b5563",
116
- "gray-8": "#374151",
117
- "gray-9": "#1f2937",
118
- "green-1": "#f0fdf4",
119
- "green-10": "#14532d",
120
- "green-11": "#052e16",
121
- "green-12": "#031b0d",
122
- "green-2": "#dcfce7",
123
- "green-3": "#bbf7d0",
124
- "green-4": "#86efac",
125
- "green-5": "#4ade80",
126
- "green-6": "#22c55e",
127
- "green-7": "#16a34a",
128
- "green-8": "#15803d",
129
- "green-9": "#166534",
130
- "indigo-1": "#eef2ff",
131
- "indigo-10": "#312e81",
132
- "indigo-11": "#1e1b4b",
133
- "indigo-12": "#12102d",
134
- "indigo-2": "#e0e7ff",
135
- "indigo-3": "#c7d2fe",
136
- "indigo-4": "#a5b4fc",
137
- "indigo-5": "#818cf8",
138
- "indigo-6": "#6366f1",
139
- "indigo-7": "#4f46e5",
140
- "indigo-8": "#4338ca",
141
- "indigo-9": "#3730a3",
142
- "lime-1": "#f7fee7",
143
- "lime-10": "#365314",
144
- "lime-11": "#1a2e05",
145
- "lime-12": "#0f1b03",
146
- "lime-2": "#ecfccb",
147
- "lime-3": "#d9f99d",
148
- "lime-4": "#bef264",
149
- "lime-5": "#a3e635",
150
- "lime-6": "#84cc16",
151
- "lime-7": "#65a30d",
152
- "lime-8": "#4d7c0f",
153
- "lime-9": "#3f6212",
154
- "neutral-1": "#fafafa",
155
- "neutral-10": "#171717",
156
- "neutral-11": "#0a0a0a",
157
- "neutral-12": "#050505",
158
- "neutral-2": "#f5f5f5",
159
- "neutral-3": "#e5e5e5",
160
- "neutral-4": "#d4d4d4",
161
- "neutral-5": "#a3a3a3",
162
- "neutral-6": "#737373",
163
- "neutral-7": "#525252",
164
- "neutral-8": "#404040",
165
- "neutral-9": "#262626",
166
- "orange-1": "#fff7ed",
167
- "orange-10": "#7c2d12",
168
- "orange-11": "#431407",
169
- "orange-12": "#270c04",
170
- "orange-2": "#ffedd5",
171
- "orange-3": "#fed7aa",
172
- "orange-4": "#fdba74",
173
- "orange-5": "#fb923c",
174
- "orange-6": "#f97316",
175
- "orange-7": "#ea580c",
176
- "orange-8": "#c2410c",
177
- "orange-9": "#9a3412",
178
- "pink-1": "#fdf2f8",
179
- "pink-10": "#831843",
180
- "pink-11": "#500724",
181
- "pink-12": "#300415",
182
- "pink-2": "#fce7f3",
183
- "pink-3": "#fbcfe8",
184
- "pink-4": "#f9a8d4",
185
- "pink-5": "#f472b6",
186
- "pink-6": "#ec4899",
187
- "pink-7": "#db2777",
188
- "pink-8": "#be185d",
189
- "pink-9": "#9d174d",
190
- "purple-1": "#faf5ff",
191
- "purple-10": "#581c87",
192
- "purple-11": "#3b0764",
193
- "purple-12": "#23043c",
194
- "purple-2": "#f3e8ff",
195
- "purple-3": "#e9d5ff",
196
- "purple-4": "#d8b4fe",
197
- "purple-5": "#c084fc",
198
- "purple-6": "#a855f7",
199
- "purple-7": "#9333ea",
200
- "purple-8": "#7e22ce",
201
- "purple-9": "#6b21a8",
202
- "red-1": "#fef2f2",
203
- "red-10": "#7f1d1d",
204
- "red-11": "#450a0a",
205
- "red-12": "#280606",
206
- "red-2": "#fee2e2",
207
- "red-3": "#fecaca",
208
- "red-4": "#fca5a5",
209
- "red-5": "#f87171",
210
- "red-6": "#ef4444",
211
- "red-7": "#dc2626",
212
- "red-8": "#b91c1c",
213
- "red-9": "#991b1b",
214
- "rose-1": "#fff1f2",
215
- "rose-10": "#881337",
216
- "rose-11": "#4c0519",
217
- "rose-12": "#2d030e",
218
- "rose-2": "#ffe4e6",
219
- "rose-3": "#fecdd3",
220
- "rose-4": "#fda4af",
221
- "rose-5": "#fb7185",
222
- "rose-6": "#f43f5e",
223
- "rose-7": "#e11d48",
224
- "rose-8": "#be123c",
225
- "rose-9": "#9f1239",
226
- "silver": "#c0c0c0",
227
- "sky-1": "#f0f9ff",
228
- "sky-10": "#0c4a6e",
229
- "sky-11": "#082f49",
230
- "sky-12": "#041b2b",
231
- "sky-2": "#e0f2fe",
232
- "sky-3": "#bae6fd",
233
- "sky-4": "#7dd3fc",
234
- "sky-5": "#38bdf8",
235
- "sky-6": "#0ea5e9",
236
- "sky-7": "#0284c7",
237
- "sky-8": "#0369a1",
238
- "sky-9": "#075985",
239
- "slate-1": "#f8fafc",
240
- "slate-10": "#0f172a",
241
- "slate-11": "#020617",
242
- "slate-12": "#01020a",
243
- "slate-2": "#f1f5f9",
244
- "slate-3": "#e2e8f0",
245
- "slate-4": "#cbd5e1",
246
- "slate-5": "#94a3b8",
247
- "slate-6": "#64748b",
248
- "slate-7": "#475569",
249
- "slate-8": "#334155",
250
- "slate-9": "#1e293b",
251
- "stone-1": "#fafaf9",
252
- "stone-10": "#1c1917",
253
- "stone-11": "#0c0a09",
254
- "stone-12": "#070605",
255
- "stone-2": "#f5f5f4",
256
- "stone-3": "#e7e5e4",
257
- "stone-4": "#d6d3d1",
258
- "stone-5": "#a8a29e",
259
- "stone-6": "#78716c",
260
- "stone-7": "#57534e",
261
- "stone-8": "#44403c",
262
- "stone-9": "#292524",
263
- "teal-1": "#f0fdfa",
264
- "teal-10": "#134e4a",
265
- "teal-11": "#042f2e",
266
- "teal-12": "#021c1b",
267
- "teal-2": "#ccfbf1",
268
- "teal-3": "#99f6e4",
269
- "teal-4": "#5eead4",
270
- "teal-5": "#2dd4bf",
271
- "teal-6": "#14b8a6",
272
- "teal-7": "#0d9488",
273
- "teal-8": "#0f766e",
274
- "teal-9": "#115e59",
275
- "transparent": "transparent",
276
- "violet-1": "#f5f3ff",
277
- "violet-10": "#4c1d95",
278
- "violet-11": "#2e1065",
279
- "violet-12": "#1c0a3d",
280
- "violet-2": "#ede9fe",
281
- "violet-3": "#ddd6fe",
282
- "violet-4": "#c4b5fd",
283
- "violet-5": "#a78bfa",
284
- "violet-6": "#8b5cf6",
285
- "violet-7": "#7c3aed",
286
- "violet-8": "#6d28d9",
287
- "violet-9": "#5b21b6",
288
- "white": "#ffffff",
289
- "yellow-1": "#fefce8",
290
- "yellow-10": "#713f12",
291
- "yellow-11": "#422006",
292
- "yellow-12": "#271304",
293
- "yellow-2": "#fef9c3",
294
- "yellow-3": "#fef08a",
295
- "yellow-4": "#fde047",
296
- "yellow-5": "#facc15",
297
- "yellow-6": "#eab308",
298
- "yellow-7": "#ca8a04",
299
- "yellow-8": "#a16207",
300
- "yellow-9": "#854d0e",
301
- "zinc-1": "#fafafa",
302
- "zinc-10": "#18181b",
303
- "zinc-11": "#09090b",
304
- "zinc-12": "#050506",
305
- "zinc-2": "#f4f4f5",
306
- "zinc-3": "#e4e4e7",
307
- "zinc-4": "#d4d4d8",
308
- "zinc-5": "#a1a1aa",
309
- "zinc-6": "#71717a",
310
- "zinc-7": "#52525b",
311
- "zinc-8": "#3f3f46",
312
- "zinc-9": "#27272a"
313
- };
314
-
315
- // src/theme.ts
316
- var defaultTheme = {
317
- colors: PALETTE,
318
- // Real Tailwind's default spacing scale in full — every step is exactly
319
- // `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
320
- // 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Previously
321
- // this only had {0,1,2,4,6,8} — a handful of spot-checked values, not
322
- // the real scale — so anything else (`p-3`, `w-5`, `border-2`,
323
- // `gap-10`, ...) silently failed to resolve. Mirrors @kbach/react's
324
- // theme.ts exactly.
325
- spacing: {
326
- "0": 0,
327
- "px": 1,
328
- "0.5": 2,
329
- "1": 4,
330
- "1.5": 6,
331
- "2": 8,
332
- "2.5": 10,
333
- "3": 12,
334
- "3.5": 14,
335
- "4": 16,
336
- "5": 20,
337
- "6": 24,
338
- "7": 28,
339
- "8": 32,
340
- "9": 36,
341
- "10": 40,
342
- "11": 44,
343
- "12": 48,
344
- "14": 56,
345
- "16": 64,
346
- "20": 80,
347
- "24": 96,
348
- "28": 112,
349
- "32": 128,
350
- "36": 144,
351
- "40": 160,
352
- "44": 176,
353
- "48": 192,
354
- "52": 208,
355
- "56": 224,
356
- "60": 240,
357
- "64": 256,
358
- "72": 288,
359
- "80": 320,
360
- "96": 384
361
- },
362
- screens: {
363
- sm: 640,
364
- md: 768,
365
- lg: 1024,
366
- xl: 1280,
367
- "2xl": 1536
368
- },
369
- darkMode: "attribute"
370
- };
371
- var activeTheme = defaultTheme;
372
- var activeThemeJson = JSON.stringify(defaultTheme);
373
- function setTheme(theme) {
374
- activeTheme = theme;
375
- activeThemeJson = JSON.stringify(theme);
376
- }
377
- function getTheme() {
378
- return activeTheme;
379
- }
380
- function getThemeJson() {
381
- return activeThemeJson;
382
- }
63
+ var import_theme4 = require("./theme");
383
64
 
384
65
  // src/nativeBridge.ts
385
- var import_react_native2 = require("react-native");
386
-
387
- // src/darkModeStore.ts
388
66
  var import_react_native = require("react-native");
389
- var listeners = /* @__PURE__ */ new Set();
390
- function systemPrefersDark() {
391
- return import_react_native.Appearance.getColorScheme() === "dark";
392
- }
393
- function resolveIsDark(m) {
394
- return m === "system" ? systemPrefersDark() : m === "dark";
395
- }
396
- var mode = "system";
397
- var isDark = resolveIsDark(mode);
398
- var hasExplicitChoice = false;
399
- var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
400
- if (mode !== "system") return;
401
- isDark = colorScheme === "dark";
402
- notify();
403
- });
404
- function notify() {
405
- for (const listener of listeners) listener();
406
- }
407
- function getGlobalDarkMode() {
408
- return isDark;
409
- }
410
- function getGlobalThemeMode() {
411
- return mode;
412
- }
413
- function setGlobalThemeMode(nextMode) {
414
- mode = nextMode;
415
- isDark = resolveIsDark(nextMode);
416
- hasExplicitChoice = true;
417
- notify();
418
- }
419
- function toggleGlobalDarkMode() {
420
- setGlobalThemeMode(isDark ? "light" : "dark");
421
- }
422
- function subscribeGlobalDarkMode(listener) {
423
- listeners.add(listener);
424
- return () => listeners.delete(listener);
425
- }
426
- function seedDefaultMode(fallback) {
427
- if (hasExplicitChoice || mode === fallback) return;
428
- mode = fallback;
429
- isDark = resolveIsDark(fallback);
430
- notify();
431
- }
67
+ var import_theme = require("./theme");
68
+ var import_darkModeStore = require("./darkModeStore");
432
69
 
433
70
  // src/jsEngine/parser.ts
434
71
  var VALUE_PREFIXES = [
@@ -516,12 +153,23 @@ var VALUE_PREFIXES = [
516
153
  "leading-",
517
154
  "tracking-",
518
155
  "font-",
156
+ "align-",
519
157
  "z-",
158
+ "inset-x-",
159
+ "inset-y-",
520
160
  "inset-",
521
161
  "top-",
522
162
  "right-",
523
163
  "bottom-",
524
164
  "left-",
165
+ "start-",
166
+ "end-",
167
+ "overflow-x-",
168
+ "overflow-y-",
169
+ "overscroll-x-",
170
+ "overscroll-y-",
171
+ "overscroll-",
172
+ "aspect-",
525
173
  "divide-color-",
526
174
  "space-x-",
527
175
  "space-y-",
@@ -549,12 +197,23 @@ var VALUE_PREFIXES = [
549
197
  "justify-self-",
550
198
  "scale-x-",
551
199
  "scale-y-",
200
+ "scale-z-",
552
201
  "scale-",
202
+ "rotate-x-",
203
+ "rotate-y-",
204
+ "rotate-z-",
553
205
  "rotate-",
206
+ // Bare 'translate-'/'skew-' (both axes) after their per-axis forms, same
207
+ // longer-before-shorter rule as resolvers/parser.rs.
554
208
  "translate-x-",
555
209
  "translate-y-",
210
+ "translate-z-",
211
+ "translate-",
556
212
  "skew-x-",
557
213
  "skew-y-",
214
+ "skew-",
215
+ "perspective-origin-",
216
+ "perspective-",
558
217
  "origin-",
559
218
  "blur-",
560
219
  "brightness-",
@@ -587,14 +246,200 @@ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
587
246
  function isSafeArbitraryValue(value) {
588
247
  return !value.includes("{") && !value.includes("}") && !value.includes(";");
589
248
  }
249
+ function normalizeMathWhitespace(raw) {
250
+ if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
251
+ return raw;
252
+ }
253
+ const chars = Array.from(raw);
254
+ let out = "";
255
+ let i = 0;
256
+ let prevEndsValue = false;
257
+ while (i < chars.length) {
258
+ const c = chars[i];
259
+ if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
260
+ const start = i;
261
+ let depth = 0;
262
+ while (i < chars.length) {
263
+ if (chars[i] === "(") depth++;
264
+ else if (chars[i] === ")") {
265
+ depth--;
266
+ if (depth === 0) {
267
+ i++;
268
+ break;
269
+ }
270
+ }
271
+ i++;
272
+ }
273
+ out += chars.slice(start, i).join("");
274
+ prevEndsValue = true;
275
+ continue;
276
+ }
277
+ if (c === "+" || c === "-") {
278
+ if (prevEndsValue) {
279
+ out += ` ${c} `;
280
+ i++;
281
+ while (i < chars.length && /\s/.test(chars[i])) i++;
282
+ prevEndsValue = false;
283
+ continue;
284
+ }
285
+ out += c;
286
+ prevEndsValue = false;
287
+ } else if (c === "(" || c === ",") {
288
+ out += c;
289
+ if (c === ",") out += " ";
290
+ prevEndsValue = false;
291
+ } else if (c === ")") {
292
+ out += c;
293
+ prevEndsValue = true;
294
+ } else if (/\s/.test(c)) {
295
+ } else if (c === "*" || c === "/") {
296
+ out += c;
297
+ prevEndsValue = false;
298
+ } else {
299
+ out += c;
300
+ prevEndsValue = true;
301
+ }
302
+ i++;
303
+ }
304
+ return out;
305
+ }
306
+ var TYPE_HINTS = /* @__PURE__ */ new Set([
307
+ "color",
308
+ "length",
309
+ "size",
310
+ "line-width",
311
+ "percentage",
312
+ "number",
313
+ "integer",
314
+ "image",
315
+ "url",
316
+ "position",
317
+ "bg-size",
318
+ "family-name",
319
+ "generic-name",
320
+ "absolute-size",
321
+ "relative-size",
322
+ "angle",
323
+ "shadow",
324
+ "any"
325
+ ]);
326
+ function arbitraryModifier(modifier) {
327
+ const bracketed = parenVarShorthand(modifier) ?? modifier;
328
+ if (!(bracketed.length > 2 && bracketed.startsWith("[") && bracketed.endsWith("]"))) return null;
329
+ const raw = bracketed.slice(1, -1);
330
+ if (!isSafeArbitraryValue(raw)) return null;
331
+ return normalizeMathWhitespace(raw.replace(/_/g, " "));
332
+ }
333
+ function splitTypeHint(raw) {
334
+ const i = raw.indexOf(":");
335
+ if (i > 0 && i < raw.length - 1 && TYPE_HINTS.has(raw.slice(0, i))) return [raw.slice(0, i), raw.slice(i + 1)];
336
+ return [null, raw];
337
+ }
338
+ function parenVarShorthand(value) {
339
+ const m = /^\((?:([a-z-]+):)?--([A-Za-z0-9_-]+)\)(\/.*)?$/.exec(value);
340
+ if (!m) return null;
341
+ const [, hint, name, tail = ""] = m;
342
+ if (hint !== void 0 && !TYPE_HINTS.has(hint)) return null;
343
+ return hint ? `[${hint}:var(--${name})]${tail}` : `[var(--${name})]${tail}`;
344
+ }
345
+ function splitBracketModifier(value) {
346
+ if (!value.startsWith("[")) return [value, null];
347
+ let depth = 0;
348
+ for (let i = 0; i < value.length; i++) {
349
+ const ch = value[i];
350
+ if (ch === "[") depth += 1;
351
+ else if (ch === "]") {
352
+ depth -= 1;
353
+ if (depth === 0) {
354
+ const after = value.slice(i + 1);
355
+ return after.startsWith("/") && after.length > 1 ? [value.slice(0, i + 1), after.slice(1)] : [value, null];
356
+ }
357
+ }
358
+ }
359
+ return [value, null];
360
+ }
361
+ function trimNumber(n) {
362
+ return `${Math.round(n * 1e6) / 1e6}`;
363
+ }
364
+ function parseAlpha(modifier) {
365
+ const raw = arbitraryModifier(modifier);
366
+ if (raw !== null) {
367
+ if (raw.endsWith("%")) {
368
+ const n3 = strictNumber(raw.slice(0, -1));
369
+ return n3 !== null && n3 >= 0 && n3 <= 100 ? { fraction: n3 / 100 } : null;
370
+ }
371
+ const n2 = strictNumber(raw);
372
+ if (n2 !== null) return n2 >= 0 && n2 <= 1 ? { fraction: n2 } : null;
373
+ return raw.startsWith("var(") || raw.startsWith("calc(") ? { raw } : null;
374
+ }
375
+ if (!/^(?:\d+\.?\d*|\.\d+)$/.test(modifier)) return null;
376
+ const n = Number(modifier);
377
+ return n <= 100 ? { fraction: n / 100 } : null;
378
+ }
379
+ function strictNumber(text) {
380
+ return /^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(text) ? Number(text) : null;
381
+ }
382
+ function expandThemeFunctions(raw) {
383
+ if (!raw.includes("--spacing(") && !raw.includes("--alpha(")) return raw;
384
+ let out = "";
385
+ let rest = raw;
386
+ for (; ; ) {
387
+ const found = ["--spacing(", "--alpha("].map((name) => ({ name, at: rest.indexOf(name) })).filter((f) => f.at !== -1).sort((a, b) => a.at - b.at)[0];
388
+ if (found === void 0) break;
389
+ const argsFrom = found.at + found.name.length;
390
+ let depth = 1;
391
+ let close = -1;
392
+ for (let i = argsFrom; i < rest.length; i++) {
393
+ if (rest[i] === "(") depth += 1;
394
+ else if (rest[i] === ")") {
395
+ depth -= 1;
396
+ if (depth === 0) {
397
+ close = i;
398
+ break;
399
+ }
400
+ }
401
+ }
402
+ if (close === -1) break;
403
+ const arg = expandThemeFunctions(rest.slice(argsFrom, close).trim());
404
+ out += rest.slice(0, found.at);
405
+ if (found.name === "--spacing(") {
406
+ const n = strictNumber(arg);
407
+ out += n !== null ? `${trimNumber(n * 4)}px` : `calc(4px * ${arg})`;
408
+ } else {
409
+ const slash = arg.lastIndexOf("/");
410
+ if (slash === -1) {
411
+ out += arg;
412
+ } else {
413
+ const alpha = arg.slice(slash + 1).trim();
414
+ const n = strictNumber(alpha);
415
+ out += `color-mix(in srgb, ${arg.slice(0, slash).trim()} ${n !== null ? `${trimNumber(n * 100)}%` : alpha}, transparent)`;
416
+ }
417
+ }
418
+ rest = rest.slice(close + 1);
419
+ }
420
+ return out + rest;
421
+ }
422
+ var COLOR_FUNCTIONS = ["rgb(", "rgba(", "hsl(", "hsla(", "hwb(", "lab(", "lch(", "oklab(", "oklch(", "color(", "color-mix(", "var("];
423
+ function looksLikeColor(value) {
424
+ return value.startsWith("#") || COLOR_FUNCTIONS.some((f) => value.startsWith(f)) || /^[A-Za-z]+$/.test(value);
425
+ }
426
+ function colorWithOpacity(color, alpha) {
427
+ const m = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color);
428
+ if (m && "fraction" in alpha) {
429
+ const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
430
+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
431
+ return `rgba(${r},${g},${b},${trimNumber(alpha.fraction)})`;
432
+ }
433
+ return `color-mix(in srgb, ${color} ${"fraction" in alpha ? `${trimNumber(alpha.fraction * 100)}%` : alpha.raw}, transparent)`;
434
+ }
590
435
  function splitRespectingBrackets(token) {
591
436
  const parts = [];
592
437
  let depth = 0;
593
438
  let start = 0;
594
439
  for (let i = 0; i < token.length; i++) {
595
440
  const ch = token[i];
596
- if (ch === "[") depth += 1;
597
- else if (ch === "]") depth -= 1;
441
+ if (ch === "[" || ch === "(") depth += 1;
442
+ else if (ch === "]" || ch === ")") depth -= 1;
598
443
  else if (ch === ":" && depth <= 0) {
599
444
  parts.push(token.slice(start, i));
600
445
  start = i + 1;
@@ -607,9 +452,11 @@ function parseClass(token) {
607
452
  const parts = splitRespectingBrackets(token);
608
453
  let base = parts.pop() ?? token;
609
454
  const modifiers = parts;
610
- const important = base.startsWith("!");
611
- if (important) {
455
+ const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
456
+ if (base.startsWith("!")) {
612
457
  base = base.slice(1);
458
+ } else if (important) {
459
+ base = base.slice(0, -1);
613
460
  }
614
461
  const negative = base.startsWith("-");
615
462
  if (negative) {
@@ -622,7 +469,7 @@ function parseClass(token) {
622
469
  const property = raw.slice(0, colonIdx);
623
470
  const rawValue = raw.slice(colonIdx + 1);
624
471
  if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
625
- const value = rawValue.replace(/_/g, " ");
472
+ const value = normalizeMathWhitespace(expandThemeFunctions(rawValue.replace(/_/g, " ")));
626
473
  return {
627
474
  modifiers,
628
475
  utility: ARBITRARY_PROPERTY_SENTINEL,
@@ -637,28 +484,46 @@ function parseClass(token) {
637
484
  }
638
485
  for (const prefix of VALUE_PREFIXES) {
639
486
  if (!base.startsWith(prefix)) continue;
640
- const value = base.slice(prefix.length);
641
- if (value === "") continue;
487
+ const written = base.slice(prefix.length);
488
+ if (written === "") continue;
489
+ const [value, tail] = splitBracketModifier(parenVarShorthand(written) ?? written);
642
490
  if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
643
491
  const raw = value.slice(1, -1);
644
492
  if (!isSafeArbitraryValue(raw)) {
645
493
  continue;
646
494
  }
647
- const spaced = raw.replace(/_/g, " ");
495
+ const spaced = normalizeMathWhitespace(expandThemeFunctions(raw.replace(/_/g, " ")));
496
+ let [typeHint, hinted] = splitTypeHint(spaced);
497
+ let modifier = null;
498
+ if (tail !== null) {
499
+ const isColor = typeHint === "color" || typeHint === null && looksLikeColor(hinted);
500
+ const alpha = isColor ? parseAlpha(tail) : null;
501
+ if (alpha !== null) {
502
+ hinted = colorWithOpacity(hinted, alpha);
503
+ typeHint = "color";
504
+ } else if (prefix === "text-") {
505
+ modifier = tail;
506
+ } else {
507
+ continue;
508
+ }
509
+ }
648
510
  return {
649
511
  modifiers,
650
512
  utility: prefix.slice(0, -1),
651
- value: spaced,
513
+ value: hinted,
514
+ typeHint,
652
515
  isArbitrary: true,
653
516
  important,
654
517
  negative,
655
- original: token
518
+ original: token,
519
+ modifier
656
520
  };
657
521
  }
658
522
  return {
659
523
  modifiers,
660
524
  utility: prefix.slice(0, -1),
661
- value,
525
+ // a named value keeps its own /opacity (`bg-blue-6/50`)
526
+ value: tail === null ? value : `${value}/${tail}`,
662
527
  isArbitrary: false,
663
528
  important,
664
529
  negative,
@@ -680,6 +545,13 @@ function parseClass(token) {
680
545
  function decl(property, value) {
681
546
  return { property, value };
682
547
  }
548
+ function spacingPx(theme, value) {
549
+ const fromTable = theme.spacing[value];
550
+ if (fromTable !== void 0) return fromTable;
551
+ if (value === "px") return 1;
552
+ const n = Number(value);
553
+ return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
554
+ }
683
555
  function resolveLength(theme, parsed) {
684
556
  if (parsed.negative) return null;
685
557
  const value = parsed.value;
@@ -687,24 +559,87 @@ function resolveLength(theme, parsed) {
687
559
  if (parsed.isArbitrary) return value;
688
560
  if (value === "full") return "100%";
689
561
  if (value === "auto") return "auto";
690
- const px = theme.spacing[value];
562
+ const px = spacingPx(theme, value);
691
563
  return px === void 0 ? null : `${px}px`;
692
564
  }
693
565
  function resolveNegatableLength(theme, parsed) {
694
566
  if (!parsed.negative) return resolveLength(theme, parsed);
695
- if (parsed.isArbitrary) return null;
567
+ if (parsed.isArbitrary) {
568
+ const value2 = parsed.value;
569
+ return value2 === null ? null : `calc(${value2} * -1)`;
570
+ }
696
571
  const value = parsed.value;
697
572
  if (value === null) return null;
698
- const px = theme.spacing[value];
573
+ const px = spacingPx(theme, value);
699
574
  if (px === void 0) return null;
700
575
  if (px === 0) return "0px";
701
576
  return `-${px}px`;
702
577
  }
578
+ function fractionPercent(value) {
579
+ const slashIdx = value.indexOf("/");
580
+ if (slashIdx === -1) return null;
581
+ const numStr = value.slice(0, slashIdx);
582
+ const denStr = value.slice(slashIdx + 1);
583
+ const num = Number(numStr);
584
+ const den = Number(denStr);
585
+ if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
586
+ if (den === 0) return null;
587
+ const pct = num / den * 100;
588
+ const formatted = pct.toFixed(6);
589
+ const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
590
+ return `${trimmed}%`;
591
+ }
592
+ function resolveNegatableSize(theme, parsed) {
593
+ if (!parsed.isArbitrary && parsed.value !== null) {
594
+ if (parsed.negative && parsed.value === "full") return "-100%";
595
+ const pct = fractionPercent(parsed.value);
596
+ if (pct !== null) return parsed.negative ? `-${pct}` : pct;
597
+ }
598
+ return resolveNegatableLength(theme, parsed);
599
+ }
600
+ function negate(value) {
601
+ const numeric = (v) => /^[\d.]/.test(v);
602
+ if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
603
+ return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
604
+ }
605
+ function resolvePercent(parsed) {
606
+ if (parsed.negative) return null;
607
+ const value = parsed.value;
608
+ if (value === null) return null;
609
+ if (parsed.isArbitrary) return value;
610
+ const pct = Number(value);
611
+ if (!Number.isFinite(pct) || value.trim() === "") return null;
612
+ return String(pct / 100);
613
+ }
703
614
 
704
615
  // src/jsEngine/resolvers/layout.ts
705
616
  function negateRaw(value, negative) {
706
617
  return negative ? `-${value}` : value;
707
618
  }
619
+ var WHOLE = /^\d+$/;
620
+ var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
621
+ function overflowAxisValue(property, value) {
622
+ switch (value) {
623
+ case "auto":
624
+ case "hidden":
625
+ case "clip":
626
+ case "visible":
627
+ case "scroll":
628
+ return [decl(property, value)];
629
+ default:
630
+ return null;
631
+ }
632
+ }
633
+ function overscrollValue(property, value) {
634
+ switch (value) {
635
+ case "auto":
636
+ case "contain":
637
+ case "none":
638
+ return [decl(property, value)];
639
+ default:
640
+ return null;
641
+ }
642
+ }
708
643
  function resolve(parsed, theme) {
709
644
  switch (parsed.utility) {
710
645
  case "flex":
@@ -751,6 +686,12 @@ function resolve(parsed, theme) {
751
686
  return [decl("justify-content", "space-around")];
752
687
  case "justify-evenly":
753
688
  return [decl("justify-content", "space-evenly")];
689
+ case "justify-normal":
690
+ return [decl("justify-content", "normal")];
691
+ case "justify-stretch":
692
+ return [decl("justify-content", "stretch")];
693
+ case "content-normal":
694
+ return [decl("align-content", "normal")];
754
695
  case "content-start":
755
696
  return [decl("align-content", "flex-start")];
756
697
  case "content-end":
@@ -785,6 +726,18 @@ function resolve(parsed, theme) {
785
726
  return [decl("overflow", "scroll")];
786
727
  case "overflow-visible":
787
728
  return [decl("overflow", "visible")];
729
+ case "overflow-clip":
730
+ return [decl("overflow", "clip")];
731
+ case "overflow-x":
732
+ return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
733
+ case "overflow-y":
734
+ return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
735
+ case "overscroll":
736
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
737
+ case "overscroll-x":
738
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
739
+ case "overscroll-y":
740
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
788
741
  case "static":
789
742
  return [decl("position", "static")];
790
743
  case "relative":
@@ -795,40 +748,91 @@ function resolve(parsed, theme) {
795
748
  return [decl("position", "fixed")];
796
749
  case "sticky":
797
750
  return [decl("position", "sticky")];
798
- case "z":
799
- return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
800
- case "order":
801
- return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
751
+ // Only real values, mirroring layout.rs: a whole number, z-auto, the
752
+ // order-first/-last/-none keywords, or an arbitrary [...]. Anything
753
+ // else used to pass straight through (z-banana -> z-index: banana).
754
+ case "z": {
755
+ const v = parsed.value;
756
+ if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
757
+ return [decl("z-index", negateRaw(v, parsed.negative))];
758
+ }
759
+ case "order": {
760
+ const v = parsed.value;
761
+ if (v === null) return null;
762
+ if (v === "first") return [decl("order", "-9999")];
763
+ if (v === "last") return [decl("order", "9999")];
764
+ if (v === "none") return [decl("order", "0")];
765
+ if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
766
+ return [decl("order", negateRaw(v, parsed.negative))];
767
+ }
802
768
  case "grow":
803
- return [decl("flex-grow", parsed.value ?? "1")];
804
- case "shrink":
805
- return [decl("flex-shrink", parsed.value ?? "1")];
769
+ case "shrink": {
770
+ const v = parsed.value ?? "1";
771
+ if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
772
+ return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
773
+ }
806
774
  // top/right/bottom/left/inset support real Tailwind's negative-value
807
- // convention ("-top-4") — see resolveNegatableLength's own doc comment.
775
+ // convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
776
+ // "-inset-1/3") — see resolveNegatableSize's own doc comment.
808
777
  case "top": {
809
- const v = resolveNegatableLength(theme, parsed);
778
+ const v = resolveNegatableSize(theme, parsed);
810
779
  return v === null ? null : [decl("top", v)];
811
780
  }
812
781
  case "right": {
813
- const v = resolveNegatableLength(theme, parsed);
782
+ const v = resolveNegatableSize(theme, parsed);
814
783
  return v === null ? null : [decl("right", v)];
815
784
  }
816
785
  case "bottom": {
817
- const v = resolveNegatableLength(theme, parsed);
786
+ const v = resolveNegatableSize(theme, parsed);
818
787
  return v === null ? null : [decl("bottom", v)];
819
788
  }
820
789
  case "left": {
821
- const v = resolveNegatableLength(theme, parsed);
790
+ const v = resolveNegatableSize(theme, parsed);
822
791
  return v === null ? null : [decl("left", v)];
823
792
  }
824
793
  case "inset": {
825
- const v = resolveNegatableLength(theme, parsed);
794
+ const v = resolveNegatableSize(theme, parsed);
826
795
  return v === null ? null : [decl("inset", v)];
827
796
  }
828
- case "aspect-square":
829
- return [decl("aspect-ratio", "1 / 1")];
830
- case "aspect-video":
831
- return [decl("aspect-ratio", "16 / 9")];
797
+ case "inset-x": {
798
+ const v = resolveNegatableSize(theme, parsed);
799
+ return v === null ? null : [decl("left", v), decl("right", v)];
800
+ }
801
+ case "inset-y": {
802
+ const v = resolveNegatableSize(theme, parsed);
803
+ return v === null ? null : [decl("top", v), decl("bottom", v)];
804
+ }
805
+ // Logical inset — just a different CSS property name, same reasoning
806
+ // as Rust's layout.rs (no direction-tracking logic needed here).
807
+ case "start": {
808
+ const v = resolveNegatableSize(theme, parsed);
809
+ return v === null ? null : [decl("inset-inline-start", v)];
810
+ }
811
+ case "end": {
812
+ const v = resolveNegatableSize(theme, parsed);
813
+ return v === null ? null : [decl("inset-inline-end", v)];
814
+ }
815
+ // "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
816
+ // "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
817
+ // here as utility="aspect" + a value, mirroring layout.rs's own
818
+ // "aspect" arm.
819
+ case "aspect": {
820
+ const value = parsed.value;
821
+ if (value === null) return null;
822
+ if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
823
+ switch (value) {
824
+ case "square":
825
+ return [decl("aspect-ratio", "1 / 1")];
826
+ case "video":
827
+ return [decl("aspect-ratio", "16 / 9")];
828
+ case "auto":
829
+ return [decl("aspect-ratio", "auto")];
830
+ default: {
831
+ const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
832
+ return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
833
+ }
834
+ }
835
+ }
832
836
  default:
833
837
  return null;
834
838
  }
@@ -870,7 +874,7 @@ function resolveFlex(parsed, web) {
870
874
  case "shrink-0":
871
875
  return [decl("flex-shrink", "0")];
872
876
  default:
873
- return null;
877
+ return /^\d+$/.test(value) ? [decl("flex", value)] : null;
874
878
  }
875
879
  }
876
880
 
@@ -905,20 +909,6 @@ function namedSize(key) {
905
909
  return null;
906
910
  }
907
911
  }
908
- function fractionPercent(value) {
909
- const slashIdx = value.indexOf("/");
910
- if (slashIdx === -1) return null;
911
- const numStr = value.slice(0, slashIdx);
912
- const denStr = value.slice(slashIdx + 1);
913
- const num = Number(numStr);
914
- const den = Number(denStr);
915
- if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
916
- if (den === 0) return null;
917
- const pct = num / den * 100;
918
- const formatted = pct.toFixed(6);
919
- const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
920
- return `${trimmed}%`;
921
- }
922
912
  function cssSizeKeyword(key) {
923
913
  switch (key) {
924
914
  case "min":
@@ -1054,7 +1044,85 @@ function resolve2(parsed, theme) {
1054
1044
 
1055
1045
  // src/jsEngine/resolvers/color.ts
1056
1046
  function lookupHex(theme, key) {
1057
- return theme.colors[key] ?? null;
1047
+ const entry = theme.colors[key];
1048
+ return typeof entry === "string" ? entry : null;
1049
+ }
1050
+ var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
1051
+ function findModeAwareColor(base, theme) {
1052
+ const important = base.startsWith("!") ? "!" : "";
1053
+ const rest = important ? base.slice(1) : base;
1054
+ for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
1055
+ if (!rest.startsWith(prefix)) continue;
1056
+ const [name, opacity] = splitOpacity(rest.slice(prefix.length));
1057
+ const entry = theme.colors[name];
1058
+ if (typeof entry === "object" && entry !== null) {
1059
+ return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
1060
+ }
1061
+ }
1062
+ return null;
1063
+ }
1064
+ function applyOpacityToHex(hex, opacity) {
1065
+ if (opacity === null) return hex;
1066
+ if (hexToRgb(hex) === null) return hex;
1067
+ return colorWithOpacity(hex.trim(), opacity).replace(/ /g, "_");
1068
+ }
1069
+ function substituteModeAwareColorToken(token, theme, colorScheme) {
1070
+ const segments = token.split(":");
1071
+ const base = segments.pop() ?? token;
1072
+ const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
1073
+ const found = findModeAwareColor(base, theme);
1074
+ if (found === null) return token;
1075
+ const hex = colorScheme === "dark" ? found.dark : found.light;
1076
+ return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
1077
+ }
1078
+ function hexToRgb(hex) {
1079
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
1080
+ if (!m) return null;
1081
+ let h = m[1];
1082
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
1083
+ const n = parseInt(h, 16);
1084
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
1085
+ }
1086
+ function splitOpacity(value) {
1087
+ const slash = value.indexOf("/");
1088
+ if (slash === -1) return [value, null];
1089
+ const alpha = parseAlpha(value.slice(slash + 1));
1090
+ return alpha === null ? [value, null] : [value.slice(0, slash), alpha];
1091
+ }
1092
+ function colorValue(theme, parsed) {
1093
+ const value = parsed.value;
1094
+ if (value === null) return null;
1095
+ if (parsed.isArbitrary) return value;
1096
+ const [name, opacity] = splitOpacity(value);
1097
+ const hex = lookupHex(theme, name);
1098
+ if (hex === null) return null;
1099
+ return opacity === null ? hex : colorWithOpacity(hex, opacity);
1100
+ }
1101
+ var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
1102
+ function looksLikeLength(value) {
1103
+ const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
1104
+ const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
1105
+ if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
1106
+ if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
1107
+ return MATH_LENGTH_UNIT.test(value);
1108
+ }
1109
+ var MATH_LENGTH_UNIT = /\d(?:px|rem|em|%|vh|vw|vmin|vmax|dvh|dvw|svh|svw|lvh|lvw|ch|ex|lh|cqw|cqh|cqi|cqb)(?![A-Za-z])/;
1110
+ function isLength(parsed, value) {
1111
+ switch (parsed.typeHint ?? null) {
1112
+ case null:
1113
+ return looksLikeLength(value);
1114
+ case "length":
1115
+ case "size":
1116
+ case "line-width":
1117
+ case "percentage":
1118
+ case "number":
1119
+ case "integer":
1120
+ case "absolute-size":
1121
+ case "relative-size":
1122
+ return true;
1123
+ default:
1124
+ return false;
1125
+ }
1058
1126
  }
1059
1127
 
1060
1128
  // src/jsEngine/resolvers/border.ts
@@ -1062,8 +1130,11 @@ function radiusSize(key) {
1062
1130
  switch (key) {
1063
1131
  case "none":
1064
1132
  return "0px";
1065
- case "sm":
1133
+ // Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
1134
+ case "xs":
1066
1135
  return "0.125rem";
1136
+ case "sm":
1137
+ return "0.25rem";
1067
1138
  case "md":
1068
1139
  return "0.375rem";
1069
1140
  case "lg":
@@ -1074,12 +1145,19 @@ function radiusSize(key) {
1074
1145
  return "1rem";
1075
1146
  case "3xl":
1076
1147
  return "1.5rem";
1148
+ case "4xl":
1149
+ return "2rem";
1077
1150
  case "full":
1078
1151
  return "9999px";
1079
1152
  default:
1080
1153
  return null;
1081
1154
  }
1082
1155
  }
1156
+ function borderWidthPx(parsed) {
1157
+ if (parsed.negative || parsed.isArbitrary || parsed.value === null) return null;
1158
+ const n = Number(parsed.value);
1159
+ return Number.isFinite(n) && n >= 0 && parsed.value.trim() !== "" ? `${n}px` : null;
1160
+ }
1083
1161
  function borderSideProperty(side) {
1084
1162
  switch (side) {
1085
1163
  case "t":
@@ -1102,49 +1180,68 @@ function borderValue(theme, parsed) {
1102
1180
  if (side !== null) {
1103
1181
  return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
1104
1182
  }
1183
+ const pair = value === "x" ? ["border-left", "border-right"] : value === "y" ? ["border-top", "border-bottom"] : null;
1184
+ if (pair !== null) {
1185
+ return [
1186
+ decl(`${pair[0]}-width`, "1px"),
1187
+ decl(`${pair[1]}-width`, "1px"),
1188
+ decl(`${pair[0]}-style`, "solid"),
1189
+ decl(`${pair[1]}-style`, "solid")
1190
+ ];
1191
+ }
1105
1192
  if (value === "collapse") return [decl("border-collapse", "collapse")];
1106
1193
  if (value === "separate") return [decl("border-collapse", "separate")];
1107
1194
  }
1108
1195
  if (parsed.isArbitrary) {
1109
- return [decl("border-width", value)];
1196
+ if (isLength(parsed, value)) return [decl("border-width", value)];
1197
+ const color2 = colorValue(theme, parsed);
1198
+ return color2 === null ? null : [decl("border-color", color2)];
1110
1199
  }
1111
1200
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1112
- const v = resolveLength(theme, parsed);
1201
+ const v = borderWidthPx(parsed);
1113
1202
  return v === null ? null : [decl("border-width", v)];
1114
1203
  }
1115
1204
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1116
1205
  return [decl("border-style", value)];
1117
1206
  }
1118
- const hex = lookupHex(theme, value);
1119
- return hex === null ? null : [decl("border-color", hex)];
1207
+ const color = colorValue(theme, parsed);
1208
+ return color === null ? null : [decl("border-color", color)];
1120
1209
  }
1121
1210
  function borderSideValue(theme, parsed, sideProperty) {
1122
1211
  const value = parsed.value;
1123
1212
  if (value === null) return null;
1124
- if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
1213
+ if (parsed.isArbitrary) {
1214
+ if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
1215
+ const color2 = colorValue(theme, parsed);
1216
+ return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
1217
+ }
1125
1218
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1126
- const v = resolveLength(theme, parsed);
1219
+ const v = borderWidthPx(parsed);
1127
1220
  return v === null ? null : [decl(`${sideProperty}-width`, v)];
1128
1221
  }
1129
1222
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1130
1223
  return [decl(`${sideProperty}-style`, value)];
1131
1224
  }
1132
- const hex = lookupHex(theme, value);
1133
- return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
1225
+ const color = colorValue(theme, parsed);
1226
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
1134
1227
  }
1135
1228
  function borderAxisValue(theme, parsed, sideA, sideB) {
1136
1229
  const value = parsed.value;
1137
1230
  if (value === null) return null;
1138
- if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1231
+ if (parsed.isArbitrary) {
1232
+ if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1233
+ const color2 = colorValue(theme, parsed);
1234
+ return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
1235
+ }
1139
1236
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1140
- const v = resolveLength(theme, parsed);
1237
+ const v = borderWidthPx(parsed);
1141
1238
  return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
1142
1239
  }
1143
1240
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1144
1241
  return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
1145
1242
  }
1146
- const hex = lookupHex(theme, value);
1147
- return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
1243
+ const color = colorValue(theme, parsed);
1244
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
1148
1245
  }
1149
1246
  function radiusProperties(side) {
1150
1247
  switch (side) {
@@ -1184,79 +1281,28 @@ function resolveRadiusSide(theme, parsed, side) {
1184
1281
  }
1185
1282
  var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
1186
1283
  function outlineWidthValue(key) {
1187
- switch (key) {
1188
- case "0":
1189
- return "0px";
1190
- case "1":
1191
- return "1px";
1192
- case "2":
1193
- return "2px";
1194
- case "4":
1195
- return "4px";
1196
- case "8":
1197
- return "8px";
1198
- default:
1199
- return null;
1200
- }
1284
+ return /^\d+$/.test(key) ? `${Number(key)}px` : null;
1201
1285
  }
1202
1286
  function outlineValue(theme, parsed) {
1203
1287
  const value = parsed.value;
1204
1288
  if (value === null) return null;
1205
- if (parsed.isArbitrary) return [decl("outline-width", value)];
1289
+ if (parsed.isArbitrary) {
1290
+ if (isLength(parsed, value)) return [decl("outline-width", value)];
1291
+ const color2 = colorValue(theme, parsed);
1292
+ return color2 === null ? null : [decl("outline-color", color2)];
1293
+ }
1206
1294
  const w = outlineWidthValue(value);
1207
1295
  if (w !== null) return [decl("outline-width", w)];
1208
1296
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
1209
- const hex = lookupHex(theme, value);
1210
- return hex === null ? null : [decl("outline-color", hex)];
1297
+ const color = colorValue(theme, parsed);
1298
+ return color === null ? null : [decl("outline-color", color)];
1211
1299
  }
1212
1300
  function outlineOffsetValue(parsed) {
1213
1301
  const value = parsed.value;
1214
1302
  if (value === null) return null;
1215
- if (parsed.isArbitrary) return [decl("outline-offset", value)];
1216
- const w = outlineWidthValue(value);
1217
- return w === null ? null : [decl("outline-offset", w)];
1218
- }
1219
- 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))";
1220
- function ringWidth(key) {
1221
- switch (key) {
1222
- case "0":
1223
- return "0px";
1224
- case "1":
1225
- return "1px";
1226
- case "2":
1227
- return "2px";
1228
- case "4":
1229
- return "4px";
1230
- case "8":
1231
- return "8px";
1232
- default:
1233
- return null;
1234
- }
1235
- }
1236
- function ringValue(theme, parsed) {
1237
- const value = parsed.value;
1238
- if (value === null) return null;
1239
- if (value === "inset") {
1240
- return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
1241
- }
1242
- if (!parsed.isArbitrary) {
1243
- const w = ringWidth(value);
1244
- if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1245
- }
1246
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1247
- if (color === null) return null;
1248
- return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1249
- }
1250
- function ringOffsetValue(theme, parsed) {
1251
- const value = parsed.value;
1252
- if (value === null) return null;
1253
- if (!parsed.isArbitrary) {
1254
- const w = ringWidth(value);
1255
- if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1256
- }
1257
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1258
- if (color === null) return null;
1259
- return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1303
+ const v = parsed.isArbitrary ? value : outlineWidthValue(value);
1304
+ if (v === null) return null;
1305
+ return [decl("outline-offset", parsed.negative ? negate(v) : v)];
1260
1306
  }
1261
1307
  var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
1262
1308
  function resolve3(parsed, theme) {
@@ -1286,14 +1332,19 @@ function resolve3(parsed, theme) {
1286
1332
  const v = resolveLength(theme, parsed);
1287
1333
  return v === null ? null : [decl("border-radius", v)];
1288
1334
  }
1335
+ // Rings are web-only (a var()-composed CSS box-shadow React Native can't
1336
+ // parse) — same as resolvers/mod.rs's native dispatcher.
1289
1337
  case "ring":
1290
- if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
1291
- return ringValue(theme, parsed);
1292
1338
  case "ring-offset":
1293
- return ringOffsetValue(theme, parsed);
1339
+ return null;
1340
+ // Outlines: the same final native style the Rust engine produces once
1341
+ // its var()-based web declarations are filtered out (resolve_style.rs):
1342
+ // bare `outline` is a 1px width, `outline-none` is outline-style: none,
1343
+ // `outline-hidden` keeps only its offset (RN has no `outline` shorthand).
1294
1344
  case "outline":
1295
- if (parsed.value === null) return [decl("outline-style", "solid")];
1296
- if (parsed.value === "none") return [decl("outline", "none")];
1345
+ if (parsed.value === null) return [decl("outline-width", "1px")];
1346
+ if (parsed.value === "none") return [decl("outline-style", "none")];
1347
+ if (!parsed.isArbitrary && parsed.value === "hidden") return [decl("outline-offset", "2px")];
1297
1348
  return outlineValue(theme, parsed);
1298
1349
  case "outline-offset":
1299
1350
  return outlineOffsetValue(parsed);
@@ -1324,32 +1375,75 @@ function textSize(key) {
1324
1375
  return "1.875rem";
1325
1376
  case "4xl":
1326
1377
  return "2.25rem";
1378
+ case "5xl":
1379
+ return "3rem";
1380
+ case "6xl":
1381
+ return "3.75rem";
1382
+ case "7xl":
1383
+ return "4.5rem";
1384
+ case "8xl":
1385
+ return "6rem";
1386
+ case "9xl":
1387
+ return "8rem";
1327
1388
  default:
1328
1389
  return null;
1329
1390
  }
1330
1391
  }
1331
1392
  function lineHeightSize(key) {
1393
+ if (key === "px") return "1px";
1394
+ if (key.trim() === "") return null;
1395
+ const n = Number(key);
1396
+ return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
1397
+ }
1398
+ function leadingNamed(key) {
1332
1399
  switch (key) {
1333
- case "3":
1334
- return "0.75rem";
1335
- case "4":
1336
- return "1rem";
1337
- case "5":
1338
- return "1.25rem";
1339
- case "6":
1340
- return "1.5rem";
1341
- case "7":
1342
- return "1.75rem";
1343
- case "8":
1344
- return "2rem";
1345
- case "9":
1346
- return "2.25rem";
1347
- case "10":
1348
- return "2.5rem";
1400
+ case "none":
1401
+ return 1;
1402
+ case "tight":
1403
+ return 1.25;
1404
+ case "snug":
1405
+ return 1.375;
1406
+ case "normal":
1407
+ return 1.5;
1408
+ case "relaxed":
1409
+ return 1.625;
1410
+ case "loose":
1411
+ return 2;
1349
1412
  default:
1350
1413
  return null;
1351
1414
  }
1352
1415
  }
1416
+ function splitSizeLeading(value) {
1417
+ const i = value.indexOf("/");
1418
+ if (i === -1) return null;
1419
+ const size = textSize(value.slice(0, i));
1420
+ const leading = value.slice(i + 1);
1421
+ return size === null || leading === "" ? null : [size, leading];
1422
+ }
1423
+ function sizeLeadingNative(size, leading) {
1424
+ const rem = (n) => {
1425
+ const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
1426
+ if (unit === null) return null;
1427
+ const number = size.slice(0, -unit.length);
1428
+ const s = Number(number);
1429
+ return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
1430
+ };
1431
+ const arbitrary = arbitraryModifier(leading);
1432
+ if (arbitrary !== null) {
1433
+ if (arbitrary.startsWith("var(")) return null;
1434
+ const n = Number(arbitrary);
1435
+ return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
1436
+ }
1437
+ const scale = lineHeightSize(leading);
1438
+ if (scale !== null) return scale;
1439
+ const m = leadingNamed(leading);
1440
+ return m === null ? null : rem(m);
1441
+ }
1442
+ function arbitraryFontIsWeight(parsed, value) {
1443
+ const hint = parsed.typeHint ?? null;
1444
+ if (hint !== null) return hint === "number" || hint === "integer";
1445
+ return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
1446
+ }
1353
1447
  function textAlign(key) {
1354
1448
  switch (key) {
1355
1449
  case "left":
@@ -1360,6 +1454,12 @@ function textAlign(key) {
1360
1454
  return "right";
1361
1455
  case "justify":
1362
1456
  return "justify";
1457
+ // Logical alignment — same "no direction-tracking logic needed" reasoning
1458
+ // as layout.rs's start/end inset properties.
1459
+ case "start":
1460
+ return "start";
1461
+ case "end":
1462
+ return "end";
1363
1463
  default:
1364
1464
  return null;
1365
1465
  }
@@ -1368,6 +1468,10 @@ function fontWeight(key) {
1368
1468
  switch (key) {
1369
1469
  case "thin":
1370
1470
  return "100";
1471
+ case "extralight":
1472
+ return "200";
1473
+ case "light":
1474
+ return "300";
1371
1475
  case "normal":
1372
1476
  return "400";
1373
1477
  case "medium":
@@ -1378,6 +1482,22 @@ function fontWeight(key) {
1378
1482
  return "700";
1379
1483
  case "extrabold":
1380
1484
  return "800";
1485
+ case "black":
1486
+ return "900";
1487
+ default:
1488
+ return null;
1489
+ }
1490
+ }
1491
+ function fontFamilyValue(theme, key) {
1492
+ const fromTheme = theme.fontFamily?.[key];
1493
+ if (fromTheme !== void 0) return fromTheme;
1494
+ switch (key) {
1495
+ case "sans":
1496
+ return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
1497
+ case "serif":
1498
+ return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
1499
+ case "mono":
1500
+ return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
1381
1501
  default:
1382
1502
  return null;
1383
1503
  }
@@ -1386,8 +1506,14 @@ function fontWeight(key) {
1386
1506
  // src/jsEngine/resolvers/effects.ts
1387
1507
  function nativeShadowValue(key) {
1388
1508
  switch (key) {
1389
- case "sm":
1509
+ // Tailwind v4.3's scale, like effects.rs: `sm` is the default shadow,
1510
+ // v3's `sm` is `xs`.
1511
+ case "2xs":
1512
+ return { offsetY: 1, radius: 0, opacity: 0.05, elevation: 1 };
1513
+ case "xs":
1390
1514
  return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
1515
+ case "sm":
1516
+ return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
1391
1517
  case "DEFAULT":
1392
1518
  return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
1393
1519
  case "md":
@@ -1419,13 +1545,115 @@ function nativeShadowDeclarations(parsed) {
1419
1545
  ];
1420
1546
  }
1421
1547
 
1548
+ // src/jsEngine/resolvers/transform.ts
1549
+ function scaleFactor(parsed) {
1550
+ if (parsed.value === null || parsed.value.trim() === "") return null;
1551
+ const n = Number(parsed.value);
1552
+ if (!Number.isFinite(n)) return null;
1553
+ const factor = parsed.isArbitrary ? n : n / 100;
1554
+ return parsed.negative ? -factor : factor;
1555
+ }
1556
+ function angle(parsed) {
1557
+ if (parsed.value === null) return null;
1558
+ if (parsed.isArbitrary) {
1559
+ if (!parsed.negative) return parsed.value;
1560
+ if (parsed.value.startsWith("-")) return parsed.value.slice(1);
1561
+ if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
1562
+ return `calc(${parsed.value} * -1)`;
1563
+ }
1564
+ const n = Number(parsed.value);
1565
+ if (!Number.isFinite(n)) return null;
1566
+ return `${parsed.negative ? -n : n}deg`;
1567
+ }
1568
+ function resolveNative(parsed, theme) {
1569
+ switch (parsed.utility) {
1570
+ case "transform-none":
1571
+ return [decl("transform-op-none", "1")];
1572
+ // Both axes at once (`translate-4`, `-skew-3`); mirrors transform.rs.
1573
+ case "translate": {
1574
+ if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-translate-x", "0"), decl("transform-op-translate-y", "0")];
1575
+ const v = resolveNegatableSize(theme, parsed);
1576
+ return v === null ? null : [decl("transform-op-translate-x", v), decl("transform-op-translate-y", v)];
1577
+ }
1578
+ case "skew": {
1579
+ const deg = angle(parsed);
1580
+ return deg === null ? null : [decl("transform-op-skew-x", deg), decl("transform-op-skew-y", deg)];
1581
+ }
1582
+ case "backface-visible":
1583
+ return [decl("backface-visibility", "visible")];
1584
+ case "backface-hidden":
1585
+ return [decl("backface-visibility", "hidden")];
1586
+ case "translate-x": {
1587
+ const v = resolveNegatableSize(theme, parsed);
1588
+ return v === null ? null : [decl("transform-op-translate-x", v)];
1589
+ }
1590
+ case "translate-y": {
1591
+ const v = resolveNegatableSize(theme, parsed);
1592
+ return v === null ? null : [decl("transform-op-translate-y", v)];
1593
+ }
1594
+ case "scale": {
1595
+ if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-scale-x", "1"), decl("transform-op-scale-y", "1")];
1596
+ const n = scaleFactor(parsed);
1597
+ return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
1598
+ }
1599
+ case "scale-x": {
1600
+ const n = scaleFactor(parsed);
1601
+ return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
1602
+ }
1603
+ case "scale-y": {
1604
+ const n = scaleFactor(parsed);
1605
+ return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
1606
+ }
1607
+ case "rotate": {
1608
+ if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-rotate", "0deg")];
1609
+ const deg = angle(parsed);
1610
+ return deg === null ? null : [decl("transform-op-rotate", deg)];
1611
+ }
1612
+ case "rotate-x": {
1613
+ const deg = angle(parsed);
1614
+ return deg === null ? null : [decl("transform-op-rotate-x", deg)];
1615
+ }
1616
+ case "rotate-y": {
1617
+ const deg = angle(parsed);
1618
+ return deg === null ? null : [decl("transform-op-rotate-y", deg)];
1619
+ }
1620
+ case "rotate-z": {
1621
+ const deg = angle(parsed);
1622
+ return deg === null ? null : [decl("transform-op-rotate-z", deg)];
1623
+ }
1624
+ case "skew-x": {
1625
+ const deg = angle(parsed);
1626
+ return deg === null ? null : [decl("transform-op-skew-x", deg)];
1627
+ }
1628
+ case "skew-y": {
1629
+ const deg = angle(parsed);
1630
+ return deg === null ? null : [decl("transform-op-skew-y", deg)];
1631
+ }
1632
+ default:
1633
+ return null;
1634
+ }
1635
+ }
1636
+
1422
1637
  // src/jsEngine/resolveUtilityNative.ts
1423
- function resolveTypographyNative(parsed) {
1638
+ function firstFontName(stack) {
1639
+ const first = stack.split(",")[0] ?? stack;
1640
+ return first.trim().replace(/^["']|["']$/g, "");
1641
+ }
1642
+ function resolveTypographyNative(parsed, theme) {
1424
1643
  switch (parsed.utility) {
1425
1644
  case "font": {
1426
1645
  if (parsed.value === null) return null;
1646
+ if (parsed.isArbitrary) {
1647
+ if (arbitraryFontIsWeight(parsed, parsed.value)) {
1648
+ const n = Number(parsed.value);
1649
+ return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
1650
+ }
1651
+ return [decl("font-family", firstFontName(parsed.value))];
1652
+ }
1427
1653
  const w = fontWeight(parsed.value);
1428
- return w === null ? null : [decl("font-weight", w)];
1654
+ if (w !== null) return [decl("font-weight", w)];
1655
+ const family = fontFamilyValue(theme, parsed.value);
1656
+ return family === null ? null : [decl("font-family", firstFontName(family))];
1429
1657
  }
1430
1658
  case "uppercase":
1431
1659
  return [decl("text-transform", "uppercase")];
@@ -1461,16 +1689,27 @@ function resolveLeadingTrackingNative(parsed) {
1461
1689
  return null;
1462
1690
  }
1463
1691
  function nativeHexColor(parsed, theme) {
1464
- const value = parsed.value;
1465
- if (value === null) return null;
1466
- return parsed.isArbitrary ? value : lookupHex(theme, value);
1692
+ return colorValue(theme, parsed);
1467
1693
  }
1468
1694
  function resolveTextNative(parsed, theme) {
1469
1695
  if (!parsed.isArbitrary && parsed.value !== null) {
1470
1696
  const size = textSize(parsed.value);
1471
1697
  if (size !== null) return [decl("font-size", size)];
1698
+ const sized = splitSizeLeading(parsed.value);
1699
+ if (sized !== null) {
1700
+ const lh = sizeLeadingNative(sized[0], sized[1]);
1701
+ return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
1702
+ }
1472
1703
  const align = textAlign(parsed.value);
1473
1704
  if (align !== null) return [decl("text-align", align)];
1705
+ } else if (parsed.isArbitrary && parsed.value !== null) {
1706
+ const leading = parsed.modifier ?? null;
1707
+ if (isLength(parsed, parsed.value)) {
1708
+ if (leading === null) return [decl("font-size", parsed.value)];
1709
+ const lh = sizeLeadingNative(parsed.value, leading);
1710
+ return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
1711
+ }
1712
+ if (leading !== null) return null;
1474
1713
  }
1475
1714
  const hex = nativeHexColor(parsed, theme);
1476
1715
  return hex === null ? null : [decl("color", hex)];
@@ -1487,13 +1726,167 @@ function resolveColorNative(parsed, theme) {
1487
1726
  return null;
1488
1727
  }
1489
1728
  }
1729
+ function resolveOpacityNative(parsed) {
1730
+ if (parsed.utility !== "opacity") return null;
1731
+ const v = resolvePercent(parsed);
1732
+ return v === null ? null : [decl("opacity", v)];
1733
+ }
1490
1734
  function resolveUtilityNative(parsed, theme) {
1491
- return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
1735
+ 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);
1492
1736
  }
1493
1737
 
1738
+ // src/jsEngine/calc.ts
1739
+ function reduceConstantMath(raw) {
1740
+ const trimmed = raw.trim();
1741
+ const calc = stripCall(trimmed, "calc");
1742
+ if (calc !== null) {
1743
+ return new Evaluator(calc).parseExprToEnd();
1744
+ }
1745
+ const clamp = stripCall(trimmed, "clamp");
1746
+ if (clamp !== null) {
1747
+ const args = splitTopLevelCommas(clamp);
1748
+ if (args.length !== 3) return null;
1749
+ const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
1750
+ if (min2 === null || preferred === null || max2 === null) return null;
1751
+ return Math.max(min2, Math.min(preferred, max2));
1752
+ }
1753
+ const min = stripCall(trimmed, "min");
1754
+ if (min !== null) {
1755
+ const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
1756
+ return values.some((v) => v === null) ? null : Math.min(...values);
1757
+ }
1758
+ const max = stripCall(trimmed, "max");
1759
+ if (max !== null) {
1760
+ const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
1761
+ return values.some((v) => v === null) ? null : Math.max(...values);
1762
+ }
1763
+ return null;
1764
+ }
1765
+ function stripCall(raw, name) {
1766
+ if (!raw.startsWith(name)) return null;
1767
+ const afterName = raw.slice(name.length).trimStart();
1768
+ if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
1769
+ return afterName.slice(1, -1);
1770
+ }
1771
+ function splitTopLevelCommas(s) {
1772
+ const parts = [];
1773
+ let depth = 0;
1774
+ let start = 0;
1775
+ for (let i = 0; i < s.length; i++) {
1776
+ const ch = s[i];
1777
+ if (ch === "(") depth++;
1778
+ else if (ch === ")") depth--;
1779
+ else if (ch === "," && depth === 0) {
1780
+ parts.push(s.slice(start, i).trim());
1781
+ start = i + 1;
1782
+ }
1783
+ }
1784
+ parts.push(s.slice(start).trim());
1785
+ return parts;
1786
+ }
1787
+ var Evaluator = class {
1788
+ constructor(s) {
1789
+ this.pos = 0;
1790
+ this.s = s;
1791
+ }
1792
+ parseExprToEnd() {
1793
+ const value = this.expr();
1794
+ if (value === null) return null;
1795
+ this.skipWs();
1796
+ return this.pos === this.s.length ? value : null;
1797
+ }
1798
+ skipWs() {
1799
+ while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
1800
+ }
1801
+ peek() {
1802
+ this.skipWs();
1803
+ return this.s[this.pos];
1804
+ }
1805
+ expr() {
1806
+ let value = this.term();
1807
+ if (value === null) return null;
1808
+ for (; ; ) {
1809
+ const ch = this.peek();
1810
+ if (ch === "+") {
1811
+ this.pos++;
1812
+ const rhs = this.term();
1813
+ if (rhs === null) return null;
1814
+ value += rhs;
1815
+ } else if (ch === "-") {
1816
+ this.pos++;
1817
+ const rhs = this.term();
1818
+ if (rhs === null) return null;
1819
+ value -= rhs;
1820
+ } else {
1821
+ return value;
1822
+ }
1823
+ }
1824
+ }
1825
+ term() {
1826
+ let value = this.factor();
1827
+ if (value === null) return null;
1828
+ for (; ; ) {
1829
+ const ch = this.peek();
1830
+ if (ch === "*") {
1831
+ this.pos++;
1832
+ const rhs = this.factor();
1833
+ if (rhs === null) return null;
1834
+ value *= rhs;
1835
+ } else if (ch === "/") {
1836
+ this.pos++;
1837
+ const divisor = this.factor();
1838
+ if (divisor === null || divisor === 0) return null;
1839
+ value /= divisor;
1840
+ } else {
1841
+ return value;
1842
+ }
1843
+ }
1844
+ }
1845
+ factor() {
1846
+ const ch = this.peek();
1847
+ if (ch === void 0) return null;
1848
+ if (ch === "(") {
1849
+ this.pos++;
1850
+ const value = this.expr();
1851
+ if (value === null || this.peek() !== ")") return null;
1852
+ this.pos++;
1853
+ return value;
1854
+ }
1855
+ if (ch === "-") {
1856
+ this.pos++;
1857
+ const value = this.factor();
1858
+ return value === null ? null : -value;
1859
+ }
1860
+ return this.numberWithUnit();
1861
+ }
1862
+ numberWithUnit() {
1863
+ this.skipWs();
1864
+ const start = this.pos;
1865
+ while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
1866
+ if (this.pos === start) return null;
1867
+ const n = Number(this.s.slice(start, this.pos));
1868
+ if (!Number.isFinite(n)) return null;
1869
+ const unitStart = this.pos;
1870
+ while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
1871
+ const unit = this.s.slice(unitStart, this.pos);
1872
+ switch (unit) {
1873
+ case "":
1874
+ return n;
1875
+ case "px":
1876
+ return n;
1877
+ case "rem":
1878
+ return n * 16;
1879
+ default:
1880
+ return null;
1881
+ }
1882
+ }
1883
+ };
1884
+
1494
1885
  // src/jsEngine/resolveStyle.ts
1495
1886
  var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1887
+ var STATE_HOLD_MARKER = "_kbon";
1496
1888
  function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
1889
+ if (modifier === STATE_HOLD_MARKER) return true;
1497
1890
  if (modifier === "dark") return colorScheme === "dark";
1498
1891
  if (modifier === "active") return pressed;
1499
1892
  if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
@@ -1501,6 +1894,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
1501
1894
  if (minWidth === void 0) return null;
1502
1895
  return width >= minWidth;
1503
1896
  }
1897
+ if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
1898
+ const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
1899
+ return px === null ? null : width >= px;
1900
+ }
1901
+ if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
1902
+ const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
1903
+ return px === null ? null : width < px;
1904
+ }
1905
+ const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
1906
+ const custom = screen(modifier);
1907
+ if (typeof custom === "number") return width >= custom;
1908
+ if (modifier.startsWith("max-")) {
1909
+ const max = screen(modifier.slice(4));
1910
+ if (typeof max === "number") return width < max;
1911
+ }
1912
+ if (modifier.startsWith("min-")) {
1913
+ const min = screen(modifier.slice(4));
1914
+ if (typeof min === "number") return width >= min;
1915
+ }
1916
+ if (modifier.startsWith("not-")) {
1917
+ const rest = modifier.slice(4);
1918
+ if (rest === "dark") return colorScheme !== "dark";
1919
+ const isBreakpoint = (name) => typeof screen(name) === "number";
1920
+ if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
1921
+ const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
1922
+ return holds === null ? null : !holds;
1923
+ }
1924
+ }
1504
1925
  return null;
1505
1926
  }
1506
1927
  function kebabToCamel(s) {
@@ -1545,6 +1966,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
1545
1966
  "shadow-opacity",
1546
1967
  "shadow-radius",
1547
1968
  "elevation",
1969
+ "opacity",
1548
1970
  // Per-side border width + per-corner radius — see resolvers/border.ts's
1549
1971
  // new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
1550
1972
  // style system wants plain numbers for these exactly like the generic
@@ -1558,29 +1980,104 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
1558
1980
  "border-bottom-right-radius",
1559
1981
  "border-bottom-left-radius",
1560
1982
  "outline-width",
1561
- "outline-offset"
1983
+ "outline-offset",
1984
+ // The transform ops whose RN value is a plain JS number — translate takes
1985
+ // a length (px/percentage, same as top/left/etc. above) and scale takes a
1986
+ // bare decimal factor (parsed by the same "raw value" fallback branch
1987
+ // below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
1988
+ // purpose, since RN wants those as literal "45deg"-shaped strings, not
1989
+ // numbers. See the transform-ops accumulator below for how these markers
1990
+ // get collected into the final array.
1991
+ "transform-op-translate-x",
1992
+ "transform-op-translate-y",
1993
+ "transform-op-scale-x",
1994
+ "transform-op-scale-y"
1562
1995
  ]);
1996
+ var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
1997
+ ["transform-op-translate-x", "translateX"],
1998
+ ["transform-op-translate-y", "translateY"],
1999
+ ["transform-op-rotate", "rotate"],
2000
+ ["transform-op-rotate-x", "rotateX"],
2001
+ ["transform-op-rotate-y", "rotateY"],
2002
+ ["transform-op-rotate-z", "rotateZ"],
2003
+ ["transform-op-skew-x", "skewX"],
2004
+ ["transform-op-skew-y", "skewY"],
2005
+ ["transform-op-scale-x", "scaleX"],
2006
+ ["transform-op-scale-y", "scaleY"]
2007
+ ]);
2008
+ var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
2009
+ function isPlainPercentage(value) {
2010
+ if (!value.endsWith("%")) return false;
2011
+ let digits = value.slice(0, -1);
2012
+ if (digits.startsWith("-")) digits = digits.slice(1);
2013
+ return digits.length > 0 && /^[0-9.]+$/.test(digits);
2014
+ }
2015
+ function sanitizeForWarning(value) {
2016
+ const MAX_CHARS = 60;
2017
+ const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
2018
+ if (escaped.length <= MAX_CHARS) return escaped;
2019
+ return `${escaped.slice(0, MAX_CHARS)}\u2026`;
2020
+ }
1563
2021
  function rnStyleValue(property, value) {
1564
- if (NUMERIC_LENGTH_PROPS.has(property)) {
1565
- let px = null;
1566
- if (value.endsWith("px")) {
1567
- const n = Number(value.slice(0, -2));
1568
- px = Number.isFinite(n) ? n : null;
1569
- } else if (value.endsWith("rem")) {
1570
- const n = Number(value.slice(0, -3));
1571
- px = Number.isFinite(n) ? n * 16 : null;
1572
- } else {
1573
- const n = Number(value);
1574
- px = value.trim() !== "" && Number.isFinite(n) ? n : null;
2022
+ if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
2023
+ const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
2024
+ const space = inner.lastIndexOf(" ");
2025
+ if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
2026
+ }
2027
+ if (property === "aspect-ratio") {
2028
+ if (value.trim() === "auto") return { value: null, warning: null };
2029
+ const parts = value.split("/").map((s) => s.trim());
2030
+ let n = null;
2031
+ if (parts.length === 1) {
2032
+ const a = Number(parts[0]);
2033
+ n = Number.isFinite(a) ? a : null;
2034
+ } else if (parts.length === 2) {
2035
+ const a = Number(parts[0]);
2036
+ const b = Number(parts[1]);
2037
+ n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
1575
2038
  }
1576
- if (px !== null) return px;
2039
+ return { value: n, warning: null };
2040
+ }
2041
+ if (!NUMERIC_LENGTH_PROPS.has(property)) {
2042
+ return { value, warning: null };
1577
2043
  }
1578
- return value;
2044
+ if (value === "auto") {
2045
+ return { value: "auto", warning: null };
2046
+ }
2047
+ let px = null;
2048
+ if (value.endsWith("px")) {
2049
+ const n = Number(value.slice(0, -2));
2050
+ px = Number.isFinite(n) ? n : null;
2051
+ } else if (value.endsWith("rem")) {
2052
+ const n = Number(value.slice(0, -3));
2053
+ px = Number.isFinite(n) ? n * 16 : null;
2054
+ } else {
2055
+ const n = Number(value);
2056
+ px = value.trim() !== "" && Number.isFinite(n) ? n : null;
2057
+ }
2058
+ if (px !== null) return { value: px, warning: null };
2059
+ if (isPlainPercentage(value)) {
2060
+ return { value, warning: null };
2061
+ }
2062
+ const reduced = reduceConstantMath(value);
2063
+ if (reduced !== null) {
2064
+ return { value: reduced, warning: null };
2065
+ }
2066
+ const sanitizedValue = sanitizeForWarning(value);
2067
+ const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
2068
+ 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).
2069
+ Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
2070
+ return { value: null, warning };
1579
2071
  }
1580
- function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
2072
+ function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
1581
2073
  const style = {};
2074
+ const warnings = [];
1582
2075
  let shadowOffset = null;
1583
- for (const token of classString.split(/\s+/).filter(Boolean)) {
2076
+ const transformOps = /* @__PURE__ */ new Map();
2077
+ const keySpecificity = /* @__PURE__ */ new Map();
2078
+ const transformSpecificity = /* @__PURE__ */ new Map();
2079
+ for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
2080
+ const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
1584
2081
  const parsed = parseClass(token);
1585
2082
  const allModifiersHold = parsed.modifiers.every(
1586
2083
  (m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
@@ -1588,103 +2085,433 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
1588
2085
  if (!allModifiersHold) continue;
1589
2086
  const decls = resolveUtilityNative(parsed, theme);
1590
2087
  if (decls === null) continue;
2088
+ const spec = parsed.modifiers.length;
1591
2089
  for (const d of decls) {
1592
2090
  if (d.property.startsWith("__")) {
1593
2091
  continue;
1594
2092
  }
2093
+ if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
2094
+ continue;
2095
+ }
1595
2096
  if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
2097
+ if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
1596
2098
  const n = Number(d.value);
1597
2099
  if (!Number.isFinite(n)) continue;
1598
2100
  if (shadowOffset === null) shadowOffset = {};
1599
2101
  shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
2102
+ keySpecificity.set("shadowOffset", spec);
1600
2103
  continue;
1601
2104
  }
1602
- style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
2105
+ if (d.property === "transform-op-none") {
2106
+ transformOps.clear();
2107
+ transformSpecificity.clear();
2108
+ continue;
2109
+ }
2110
+ const opKey = TRANSFORM_OP_KEYS.get(d.property);
2111
+ if (opKey !== void 0) {
2112
+ if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
2113
+ const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
2114
+ if (warning2 !== null) warnings.push(warning2);
2115
+ if (value2 !== null) {
2116
+ transformOps.set(opKey, value2);
2117
+ transformSpecificity.set(opKey, spec);
2118
+ }
2119
+ continue;
2120
+ }
2121
+ const key = kebabToCamel(d.property);
2122
+ if (spec < (keySpecificity.get(key) ?? 0)) continue;
2123
+ const { value, warning } = rnStyleValue(d.property, d.value);
2124
+ if (warning !== null) warnings.push(warning);
2125
+ if (value !== null) {
2126
+ style[key] = value;
2127
+ keySpecificity.set(key, spec);
2128
+ }
1603
2129
  }
1604
2130
  }
1605
2131
  if (shadowOffset !== null) {
1606
2132
  style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
1607
2133
  }
1608
- return style;
2134
+ if (transformOps.size > 0) {
2135
+ style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
2136
+ [key]: transformOps.get(key)
2137
+ }));
2138
+ }
2139
+ return { style, warnings };
1609
2140
  }
1610
2141
 
1611
2142
  // src/nativeBridge.ts
2143
+ var RESOLVE_STYLE_CACHE_MAX = 500;
2144
+ var resolveStyleCache = /* @__PURE__ */ new Map();
2145
+ var cachedForThemeJson = null;
1612
2146
  function resolveStyle(classString, pressed = false) {
1613
- const colorScheme = getGlobalDarkMode() ? "dark" : "light";
1614
- const width = import_react_native2.Dimensions.get("window").width;
1615
- const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
2147
+ const colorScheme = (0, import_darkModeStore.getGlobalDarkMode)() ? "dark" : "light";
2148
+ const width = import_react_native.Dimensions.get("window").width;
2149
+ const themeJson = (0, import_theme.getThemeJson)();
2150
+ if (themeJson !== cachedForThemeJson) {
2151
+ resolveStyleCache.clear();
2152
+ cachedForThemeJson = themeJson;
2153
+ }
2154
+ const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
2155
+ const cached = resolveStyleCache.get(cacheKey);
2156
+ if (cached !== void 0) return { ...cached };
2157
+ const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
2158
+ if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
2159
+ resolveStyleCache.set(cacheKey, style);
2160
+ return { ...style };
2161
+ }
2162
+ function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
2163
+ const KbachModule = import_react_native.TurboModuleRegistry.get("KbachModule");
1616
2164
  if (!KbachModule) {
1617
- return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
2165
+ const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
2166
+ warnIfDev(classString, warnings2);
2167
+ return style2;
1618
2168
  }
1619
- const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
1620
- return JSON.parse(json);
2169
+ const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
2170
+ const style = JSON.parse(json);
2171
+ const warnings = style.__kbachWarnings;
2172
+ if (warnings !== void 0) {
2173
+ delete style.__kbachWarnings;
2174
+ warnIfDev(classString, warnings);
2175
+ }
2176
+ return style;
1621
2177
  }
1622
-
1623
- // src/useGlobalDarkMode.ts
1624
- var import_react = require("react");
1625
- function useGlobalDarkMode() {
1626
- return (0, import_react.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalDarkMode);
2178
+ var WARNED_MESSAGES_MAX = 500;
2179
+ var warnedMessages = /* @__PURE__ */ new Set();
2180
+ var QUOTED_TOKEN_RE = /"([^"]*)"/;
2181
+ function highlightToken(classString, warning) {
2182
+ const match = QUOTED_TOKEN_RE.exec(warning);
2183
+ if (match === null) return classString;
2184
+ const quoted = match[1].replace(/\s+/g, "");
2185
+ if (quoted === "") return classString;
2186
+ const parts = classString.split(/(\s+)/);
2187
+ const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
2188
+ if (idx === -1) return classString;
2189
+ parts[idx] = `\xBB${parts[idx]}\xAB`;
2190
+ return parts.join("");
2191
+ }
2192
+ function warnIfDev(classString, warnings) {
2193
+ if (warnings.length === 0) return;
2194
+ if (typeof __DEV__ !== "undefined" && !__DEV__) return;
2195
+ for (const warning of warnings) {
2196
+ const message = `${warning}
2197
+ From className: "${highlightToken(classString, warning)}"`;
2198
+ if (warnedMessages.has(message)) continue;
2199
+ if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
2200
+ warnedMessages.add(message);
2201
+ console.warn(message);
2202
+ }
1627
2203
  }
1628
2204
 
1629
- // src/ThemeProvider.tsx
1630
- var import_react3 = require("react");
2205
+ // src/config.ts
2206
+ var import_theme2 = require("./theme");
2207
+ var import_darkModeStore2 = require("./darkModeStore");
2208
+ function parseHexRgb(hex) {
2209
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
2210
+ if (!m) return null;
2211
+ let h = m[1];
2212
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
2213
+ const n = parseInt(h, 16);
2214
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
2215
+ }
2216
+ function applyOpacityToHex2(hex, opacityText) {
2217
+ const rgb = parseHexRgb(hex);
2218
+ if (!rgb) return hex;
2219
+ const a = Number(opacityText) / 100;
2220
+ const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
2221
+ return `rgba(${rgb.join(",")},${clamped})`;
2222
+ }
2223
+ function resolveColorEntry(value, lookup) {
2224
+ const slash = value.indexOf("/");
2225
+ const name = slash === -1 ? value : value.slice(0, slash);
2226
+ const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
2227
+ const base = lookup(name);
2228
+ if (base === void 0) return value;
2229
+ return opacity === void 0 ? base : applyOpacityToHex2(base, opacity);
2230
+ }
2231
+ function resolveColors(extend, existing) {
2232
+ const { dark: darkExtend, ...lightExtend } = extend;
2233
+ const resolvedLight = {};
2234
+ const lookupLight = (name) => {
2235
+ const found = resolvedLight[name] ?? existing[name];
2236
+ return typeof found === "string" ? found : void 0;
2237
+ };
2238
+ for (const [name, value] of Object.entries(lightExtend)) {
2239
+ if (typeof value !== "string") continue;
2240
+ resolvedLight[name] = resolveColorEntry(value, lookupLight);
2241
+ }
2242
+ const result = { ...resolvedLight };
2243
+ if (darkExtend) {
2244
+ const resolvedDark = {};
2245
+ const lookupDark = (name) => {
2246
+ const found = resolvedDark[name] ?? existing[name];
2247
+ return typeof found === "string" ? found : void 0;
2248
+ };
2249
+ for (const [name, value] of Object.entries(darkExtend)) {
2250
+ resolvedDark[name] = resolveColorEntry(value, lookupDark);
2251
+ }
2252
+ for (const [name, darkValue] of Object.entries(resolvedDark)) {
2253
+ const lightValue = resolvedLight[name];
2254
+ if (lightValue === void 0) continue;
2255
+ result[name] = { light: lightValue, dark: darkValue };
2256
+ }
2257
+ }
2258
+ return result;
2259
+ }
2260
+ function resolveKbachConfig(config) {
2261
+ let theme = { ...import_theme2.defaultTheme, ...config.theme };
2262
+ if (config.extend?.colors) {
2263
+ theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
2264
+ }
2265
+ if (config.extend?.spacing) {
2266
+ theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
2267
+ }
2268
+ if (config.extend?.screens) {
2269
+ theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
2270
+ }
2271
+ if (config.extend?.fontFamily) {
2272
+ theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
2273
+ }
2274
+ if (config.extend?.container) {
2275
+ theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
2276
+ }
2277
+ if (config.darkMode) {
2278
+ theme = { ...theme, darkMode: config.darkMode };
2279
+ }
2280
+ return theme;
2281
+ }
2282
+ function applyKbachConfig(config) {
2283
+ const theme = resolveKbachConfig(config);
2284
+ (0, import_theme2.setTheme)(theme);
2285
+ (0, import_darkModeStore2.resyncDomWithActiveTheme)();
2286
+ return theme;
2287
+ }
1631
2288
 
1632
- // src/ThemeContext.tsx
1633
- var import_react2 = require("react");
1634
- var ThemeContext = (0, import_react2.createContext)(null);
2289
+ // src/useTheme.ts
2290
+ var import_react = require("react");
2291
+ var import_darkModeStore3 = require("./darkModeStore");
1635
2292
  function useTheme() {
1636
- const ctx = (0, import_react2.useContext)(ThemeContext);
1637
- if (!ctx) {
1638
- throw new Error(
1639
- 'useTheme() must be called within a <ThemeProvider>. For dark-mode state without a provider, use useGlobalDarkMode() (read) or toggleGlobalDarkMode()/setGlobalThemeMode() (write) from "@kbach/react-native" instead.'
1640
- );
1641
- }
1642
- return ctx;
2293
+ const isDark = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalDarkMode);
2294
+ const mode = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalThemeMode);
2295
+ return (0, import_react.useMemo)(
2296
+ () => ({ mode, isDark, setMode: import_darkModeStore3.setGlobalThemeMode, toggle: import_darkModeStore3.toggleGlobalDarkMode }),
2297
+ [mode, isDark]
2298
+ );
1643
2299
  }
1644
2300
 
1645
2301
  // src/ThemeProvider.tsx
2302
+ var import_react2 = require("react");
2303
+ var import_darkModeStore4 = require("./darkModeStore");
1646
2304
  var import_jsx_runtime = require("react/jsx-runtime");
2305
+ var PERSIST_STORAGE_KEY = "kbach-theme";
2306
+ function isThemeMode(value) {
2307
+ return value === "light" || value === "dark" || value === "system";
2308
+ }
1647
2309
  var mountedProviderCount = 0;
1648
2310
  var warnedMultipleProviders = false;
1649
- function ThemeProvider({ children, defaultMode = "system" }) {
1650
- (0, import_react3.useEffect)(() => {
2311
+ function ThemeProvider({ children, defaultMode = "system", persist = false }) {
2312
+ (0, import_react2.useEffect)(() => {
1651
2313
  mountedProviderCount++;
1652
2314
  if (mountedProviderCount > 1 && !warnedMultipleProviders) {
1653
2315
  warnedMultipleProviders = true;
1654
2316
  console.warn(
1655
- "[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store (the same one useGlobalDarkMode()/toggleGlobalDarkMode() read and write), not scoped per-provider, so they will fight over the same state instead of each getting their own."
2317
+ "[Kbach] Multiple <ThemeProvider> instances are mounted at once.\nDark mode is one global store \u2014 useTheme() reads it everywhere, not scoped per provider \u2014 so their defaultMode/persist seeds will fight over the same state.\nMount exactly one <ThemeProvider>, as high in the tree as convenient."
1656
2318
  );
1657
2319
  }
1658
2320
  return () => {
1659
2321
  mountedProviderCount--;
1660
2322
  };
1661
2323
  }, []);
1662
- const seeded = (0, import_react3.useRef)(false);
1663
- (0, import_react3.useEffect)(() => {
2324
+ const seeded = (0, import_react2.useRef)(false);
2325
+ (0, import_react2.useEffect)(() => {
1664
2326
  if (seeded.current) return;
1665
2327
  seeded.current = true;
1666
- seedDefaultMode(defaultMode);
2328
+ if (!persist) {
2329
+ (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
2330
+ return;
2331
+ }
2332
+ let cancelled = false;
2333
+ persist.getItem(PERSIST_STORAGE_KEY).then((stored) => {
2334
+ if (cancelled) return;
2335
+ if (isThemeMode(stored)) (0, import_darkModeStore4.seedDefaultMode)(stored);
2336
+ else (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
2337
+ }).catch(() => {
2338
+ if (!cancelled) (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
2339
+ });
2340
+ return () => {
2341
+ cancelled = true;
2342
+ };
1667
2343
  }, []);
1668
- const isDark2 = (0, import_react3.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalDarkMode);
1669
- const mode2 = (0, import_react3.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalThemeMode);
1670
- const value = (0, import_react3.useMemo)(
1671
- () => ({ mode: mode2, isDark: isDark2, setMode: setGlobalThemeMode, toggle: toggleGlobalDarkMode }),
1672
- [mode2, isDark2]
1673
- );
1674
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value, children });
2344
+ (0, import_react2.useEffect)(() => {
2345
+ if (!persist) return;
2346
+ return (0, import_darkModeStore4.subscribeGlobalDarkMode)(() => {
2347
+ persist.setItem(PERSIST_STORAGE_KEY, (0, import_darkModeStore4.getGlobalThemeMode)()).catch(() => {
2348
+ });
2349
+ });
2350
+ }, [persist]);
2351
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
2352
+ }
2353
+
2354
+ // src/index.ts
2355
+ var import_darkModeStore5 = require("./darkModeStore");
2356
+
2357
+ // src/useColors.ts
2358
+ var import_react3 = require("react");
2359
+ var import_theme3 = require("./theme");
2360
+ function parseHexRgb2(hex) {
2361
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
2362
+ if (!m) return null;
2363
+ let h = m[1];
2364
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
2365
+ const n = parseInt(h, 16);
2366
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
2367
+ }
2368
+ function applyOpacity(color, opacity) {
2369
+ const a = Math.max(0, Math.min(1, opacity / 100));
2370
+ if (color.startsWith("#")) {
2371
+ const rgb = parseHexRgb2(color);
2372
+ return rgb ? `rgba(${rgb.join(",")},${a})` : color;
2373
+ }
2374
+ if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
2375
+ if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
2376
+ return color;
2377
+ }
2378
+ function resolveEntry(entry, isDark) {
2379
+ return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
2380
+ }
2381
+ function makeColorsProxy(theme, isDark) {
2382
+ const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
2383
+ const cache = /* @__PURE__ */ new Map();
2384
+ function resolveNamed(key) {
2385
+ let name = key;
2386
+ let opacity;
2387
+ if (key.includes("/")) {
2388
+ const slash = key.indexOf("/");
2389
+ name = key.slice(0, slash);
2390
+ opacity = Number(key.slice(slash + 1));
2391
+ }
2392
+ const entry = theme.colors[name];
2393
+ if (entry === void 0) return void 0;
2394
+ const value = resolveEntry(entry, isDark);
2395
+ return opacity === void 0 ? value : applyOpacity(value, opacity);
2396
+ }
2397
+ function makeFamilyProxy(family) {
2398
+ return new Proxy({}, {
2399
+ get(_, prop) {
2400
+ const key = String(prop);
2401
+ if (key === "then") return void 0;
2402
+ return resolveNamed(`${family}-${key}`);
2403
+ }
2404
+ });
2405
+ }
2406
+ const get = (name) => resolveNamed(name) ?? name;
2407
+ return new Proxy({ alpha, get }, {
2408
+ get(_, prop) {
2409
+ const key = String(prop);
2410
+ if (key === "then") return void 0;
2411
+ if (key === "alpha") return alpha;
2412
+ if (key === "get") return get;
2413
+ const direct = resolveNamed(key);
2414
+ if (direct !== void 0) return direct;
2415
+ if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
2416
+ return cache.get(key);
2417
+ }
2418
+ });
2419
+ }
2420
+ function useColors() {
2421
+ const { isDark } = useTheme();
2422
+ const theme = (0, import_theme3.getTheme)();
2423
+ return (0, import_react3.useMemo)(() => makeColorsProxy(theme, isDark), [theme, isDark]);
2424
+ }
2425
+
2426
+ // src/index.ts
2427
+ var import_dynamicTokens2 = require("./dynamicTokens");
2428
+
2429
+ // src/useDynamicToken.ts
2430
+ var import_react4 = require("react");
2431
+ var import_dynamicTokens = require("./dynamicTokens");
2432
+ function useDynamicToken(name) {
2433
+ return (0, import_react4.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
2434
+ }
2435
+
2436
+ // src/clsx.ts
2437
+ function clsx(...inputs) {
2438
+ let out = "";
2439
+ for (const input of inputs) {
2440
+ const piece = resolveClassValue(input);
2441
+ if (piece) out = out ? `${out} ${piece}` : piece;
2442
+ }
2443
+ return out;
2444
+ }
2445
+ function resolveClassValue(value) {
2446
+ if (!value) return "";
2447
+ const type = typeof value;
2448
+ if (type === "string" || type === "number" || type === "bigint") return String(value);
2449
+ if (Array.isArray(value)) return clsx(...value);
2450
+ if (type === "object") {
2451
+ let out = "";
2452
+ for (const key in value) {
2453
+ if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
2454
+ out = out ? `${out} ${key}` : key;
2455
+ }
2456
+ }
2457
+ return out;
2458
+ }
2459
+ return "";
2460
+ }
2461
+
2462
+ // src/semanticElements.tsx
2463
+ var React = __toESM(require("react"));
2464
+ var import_react_native2 = require("react-native");
2465
+ var import_jsx_runtime2 = require("react/jsx-runtime");
2466
+ var Button = React.forwardRef(function Button2(props, ref) {
2467
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Pressable, { ref, accessibilityRole: "button", ...props });
2468
+ });
2469
+ var PARAGRAPH_ROLE = "paragraph";
2470
+ var Paragraph = React.forwardRef(function Paragraph2(props, ref) {
2471
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { ref, role: PARAGRAPH_ROLE, ...props });
2472
+ });
2473
+ function makeHeading(level) {
2474
+ const extra = { "aria-level": level };
2475
+ const Heading = React.forwardRef(function Heading2(props, ref) {
2476
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { ref, accessibilityRole: "header", ...extra, ...props });
2477
+ });
2478
+ Heading.displayName = `H${level}`;
2479
+ return Heading;
1675
2480
  }
2481
+ var H1 = makeHeading(1);
2482
+ var H2 = makeHeading(2);
2483
+ var H3 = makeHeading(3);
2484
+ var H4 = makeHeading(4);
2485
+ var H5 = makeHeading(5);
2486
+ var H6 = makeHeading(6);
1676
2487
  // Annotate the CommonJS export names for ESM import in node:
1677
2488
  0 && (module.exports = {
2489
+ Button,
2490
+ H1,
2491
+ H2,
2492
+ H3,
2493
+ H4,
2494
+ H5,
2495
+ H6,
2496
+ Paragraph,
1678
2497
  ThemeProvider,
2498
+ applyKbachConfig,
2499
+ clsx,
1679
2500
  defaultTheme,
2501
+ deleteDynamicToken,
2502
+ getDynamicToken,
1680
2503
  getGlobalDarkMode,
1681
2504
  getGlobalThemeMode,
1682
2505
  getTheme,
2506
+ resolveKbachConfig,
1683
2507
  resolveStyle,
2508
+ setDynamicToken,
1684
2509
  setGlobalThemeMode,
1685
2510
  setTheme,
2511
+ subscribeDynamicTokens,
1686
2512
  subscribeGlobalDarkMode,
1687
2513
  toggleGlobalDarkMode,
1688
- useGlobalDarkMode,
2514
+ useColors,
2515
+ useDynamicToken,
1689
2516
  useTheme
1690
2517
  });