tailwind-styled-v4 4.0.0 → 5.0.1

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 (194) hide show
  1. package/CHANGELOG.md +398 -0
  2. package/LICENSE +21 -0
  3. package/README.md +532 -0
  4. package/dist/analyzer.d.mts +114 -0
  5. package/dist/analyzer.d.ts +114 -0
  6. package/dist/analyzer.js +1555 -0
  7. package/dist/analyzer.js.map +1 -0
  8. package/dist/analyzer.mjs +1544 -0
  9. package/dist/analyzer.mjs.map +1 -0
  10. package/dist/animate.d.mts +46 -0
  11. package/dist/animate.d.ts +41 -112
  12. package/dist/animate.js +792 -235
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +782 -0
  15. package/dist/animate.mjs.map +1 -0
  16. package/dist/atomic.d.mts +18 -0
  17. package/dist/atomic.d.ts +18 -0
  18. package/dist/atomic.js +191 -0
  19. package/dist/atomic.js.map +1 -0
  20. package/dist/atomic.mjs +185 -0
  21. package/dist/atomic.mjs.map +1 -0
  22. package/dist/cli.d.mts +1 -0
  23. package/dist/cli.d.ts +1 -0
  24. package/dist/cli.js +6063 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/cli.mjs +6053 -0
  27. package/dist/cli.mjs.map +1 -0
  28. package/dist/{compiler.d.cts → compiler.d.mts} +503 -210
  29. package/dist/compiler.d.ts +503 -210
  30. package/dist/compiler.js +1549 -566
  31. package/dist/compiler.js.map +1 -1
  32. package/dist/{compiler.cjs → compiler.mjs} +1476 -627
  33. package/dist/compiler.mjs.map +1 -0
  34. package/dist/dashboard.d.mts +272 -0
  35. package/dist/dashboard.d.ts +272 -0
  36. package/dist/dashboard.js +249 -0
  37. package/dist/dashboard.js.map +1 -0
  38. package/dist/dashboard.mjs +239 -0
  39. package/dist/dashboard.mjs.map +1 -0
  40. package/dist/devtools.js +336 -211
  41. package/dist/devtools.js.map +1 -1
  42. package/dist/{devtools.cjs → devtools.mjs} +331 -220
  43. package/dist/devtools.mjs.map +1 -0
  44. package/dist/engine.d.mts +84 -0
  45. package/dist/engine.d.ts +84 -0
  46. package/dist/engine.js +3014 -0
  47. package/dist/engine.js.map +1 -0
  48. package/dist/engine.mjs +3005 -0
  49. package/dist/engine.mjs.map +1 -0
  50. package/dist/{index.d.cts → index.d.mts} +75 -4
  51. package/dist/index.d.ts +75 -4
  52. package/dist/index.js +1341 -149
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +2162 -0
  55. package/dist/index.mjs.map +1 -0
  56. package/dist/liveTokenEngine-DYN3Zale.d.mts +34 -0
  57. package/dist/liveTokenEngine-DYN3Zale.d.ts +34 -0
  58. package/dist/next.d.mts +55 -0
  59. package/dist/next.d.ts +30 -20
  60. package/dist/next.js +6947 -149
  61. package/dist/next.js.map +1 -1
  62. package/dist/next.mjs +7050 -0
  63. package/dist/next.mjs.map +1 -0
  64. package/dist/plugin.d.mts +90 -0
  65. package/dist/plugin.d.ts +90 -0
  66. package/dist/plugin.js +185 -0
  67. package/dist/plugin.js.map +1 -0
  68. package/dist/plugin.mjs +174 -0
  69. package/dist/plugin.mjs.map +1 -0
  70. package/dist/pluginRegistry.d.mts +83 -0
  71. package/dist/pluginRegistry.d.ts +83 -0
  72. package/dist/pluginRegistry.js +303 -0
  73. package/dist/pluginRegistry.js.map +1 -0
  74. package/dist/pluginRegistry.mjs +298 -0
  75. package/dist/pluginRegistry.mjs.map +1 -0
  76. package/dist/{preset.d.cts → preset.d.mts} +29 -2
  77. package/dist/preset.d.ts +29 -2
  78. package/dist/preset.js +318 -21
  79. package/dist/preset.js.map +1 -1
  80. package/dist/preset.mjs +414 -0
  81. package/dist/preset.mjs.map +1 -0
  82. package/dist/rspack.d.mts +33 -0
  83. package/dist/rspack.d.ts +33 -0
  84. package/dist/rspack.js +55 -0
  85. package/dist/rspack.js.map +1 -0
  86. package/dist/rspack.mjs +45 -0
  87. package/dist/rspack.mjs.map +1 -0
  88. package/dist/runtime.d.mts +62 -0
  89. package/dist/runtime.d.ts +62 -0
  90. package/dist/runtime.js +207 -0
  91. package/dist/runtime.js.map +1 -0
  92. package/dist/runtime.mjs +188 -0
  93. package/dist/runtime.mjs.map +1 -0
  94. package/dist/runtimeCss.d.mts +65 -0
  95. package/dist/runtimeCss.d.ts +65 -0
  96. package/dist/runtimeCss.js +188 -0
  97. package/dist/runtimeCss.js.map +1 -0
  98. package/dist/runtimeCss.mjs +173 -0
  99. package/dist/runtimeCss.mjs.map +1 -0
  100. package/dist/scanner.d.mts +25 -0
  101. package/dist/scanner.d.ts +25 -0
  102. package/dist/scanner.js +717 -0
  103. package/dist/scanner.js.map +1 -0
  104. package/dist/scanner.mjs +703 -0
  105. package/dist/scanner.mjs.map +1 -0
  106. package/dist/shared.d.mts +85 -0
  107. package/dist/shared.d.ts +85 -0
  108. package/dist/shared.js +255 -0
  109. package/dist/shared.js.map +1 -0
  110. package/dist/shared.mjs +233 -0
  111. package/dist/shared.mjs.map +1 -0
  112. package/dist/storybookAddon.d.mts +108 -0
  113. package/dist/storybookAddon.d.ts +108 -0
  114. package/dist/storybookAddon.js +95 -0
  115. package/dist/storybookAddon.js.map +1 -0
  116. package/dist/storybookAddon.mjs +88 -0
  117. package/dist/storybookAddon.mjs.map +1 -0
  118. package/dist/svelte.d.mts +114 -0
  119. package/dist/svelte.d.ts +114 -0
  120. package/dist/svelte.js +67 -0
  121. package/dist/svelte.js.map +1 -0
  122. package/dist/svelte.mjs +59 -0
  123. package/dist/svelte.mjs.map +1 -0
  124. package/dist/testing.d.mts +185 -0
  125. package/dist/testing.d.ts +185 -0
  126. package/dist/testing.js +173 -0
  127. package/dist/testing.js.map +1 -0
  128. package/dist/testing.mjs +158 -0
  129. package/dist/testing.mjs.map +1 -0
  130. package/dist/{theme.d.cts → theme.d.mts} +18 -11
  131. package/dist/theme.d.ts +18 -11
  132. package/dist/theme.js +205 -19
  133. package/dist/theme.js.map +1 -1
  134. package/dist/theme.mjs +311 -0
  135. package/dist/theme.mjs.map +1 -0
  136. package/dist/types-DXr2PmGP.d.mts +31 -0
  137. package/dist/types-DXr2PmGP.d.ts +31 -0
  138. package/dist/vite.d.mts +51 -0
  139. package/dist/vite.d.ts +35 -6
  140. package/dist/vite.js +4254 -57
  141. package/dist/vite.js.map +1 -1
  142. package/dist/vite.mjs +4281 -0
  143. package/dist/vite.mjs.map +1 -0
  144. package/dist/vue.d.mts +89 -0
  145. package/dist/vue.d.ts +89 -0
  146. package/dist/vue.js +104 -0
  147. package/dist/vue.js.map +1 -0
  148. package/dist/vue.mjs +96 -0
  149. package/dist/vue.mjs.map +1 -0
  150. package/package.json +173 -67
  151. package/dist/animate.cjs +0 -252
  152. package/dist/animate.cjs.map +0 -1
  153. package/dist/animate.d.cts +0 -117
  154. package/dist/astTransform-ua-eapqs.d.cts +0 -41
  155. package/dist/astTransform-ua-eapqs.d.ts +0 -41
  156. package/dist/compiler.cjs.map +0 -1
  157. package/dist/css.cjs +0 -71
  158. package/dist/css.cjs.map +0 -1
  159. package/dist/css.d.cts +0 -45
  160. package/dist/css.d.ts +0 -45
  161. package/dist/css.js +0 -62
  162. package/dist/css.js.map +0 -1
  163. package/dist/devtools.cjs.map +0 -1
  164. package/dist/index.cjs +0 -1058
  165. package/dist/index.cjs.map +0 -1
  166. package/dist/next.cjs +0 -268
  167. package/dist/next.cjs.map +0 -1
  168. package/dist/next.d.cts +0 -45
  169. package/dist/plugins.cjs +0 -396
  170. package/dist/plugins.cjs.map +0 -1
  171. package/dist/plugins.d.cts +0 -231
  172. package/dist/plugins.d.ts +0 -231
  173. package/dist/plugins.js +0 -381
  174. package/dist/plugins.js.map +0 -1
  175. package/dist/preset.cjs +0 -129
  176. package/dist/preset.cjs.map +0 -1
  177. package/dist/theme.cjs +0 -154
  178. package/dist/theme.cjs.map +0 -1
  179. package/dist/turbopackLoader.cjs +0 -2689
  180. package/dist/turbopackLoader.cjs.map +0 -1
  181. package/dist/turbopackLoader.d.cts +0 -22
  182. package/dist/turbopackLoader.d.ts +0 -22
  183. package/dist/turbopackLoader.js +0 -2681
  184. package/dist/turbopackLoader.js.map +0 -1
  185. package/dist/vite.cjs +0 -105
  186. package/dist/vite.cjs.map +0 -1
  187. package/dist/vite.d.cts +0 -22
  188. package/dist/webpackLoader.cjs +0 -2670
  189. package/dist/webpackLoader.cjs.map +0 -1
  190. package/dist/webpackLoader.d.cts +0 -24
  191. package/dist/webpackLoader.d.ts +0 -24
  192. package/dist/webpackLoader.js +0 -2662
  193. package/dist/webpackLoader.js.map +0 -1
  194. /package/dist/{devtools.d.cts → devtools.d.mts} +0 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,2162 @@
1
+ import fs from 'fs';
2
+ import { createRequire } from 'module';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import React from 'react';
7
+ import { twMerge } from 'tailwind-merge';
8
+
9
+ /* tailwind-styled-v4 v5.0.1 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
15
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
16
+ }) : x)(function(x) {
17
+ if (typeof require !== "undefined") return require.apply(this, arguments);
18
+ throw Error('Dynamic require of "' + x + '" is not supported');
19
+ });
20
+ var __esm = (fn, res) => function __init() {
21
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
22
+ };
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // packages/shared/src/cache.ts
38
+ var LRUCache;
39
+ var init_cache = __esm({
40
+ "packages/shared/src/cache.ts"() {
41
+ LRUCache = class {
42
+ constructor(max = 256, ttlMs = null) {
43
+ this.map = /* @__PURE__ */ new Map();
44
+ this.max = max;
45
+ this.ttlMs = ttlMs;
46
+ }
47
+ get(key) {
48
+ const entry = this.map.get(key);
49
+ if (!entry) return void 0;
50
+ if (this.ttlMs !== null && Date.now() - entry.ts > this.ttlMs) {
51
+ this.map.delete(key);
52
+ return void 0;
53
+ }
54
+ this.map.delete(key);
55
+ this.map.set(key, entry);
56
+ return entry.value;
57
+ }
58
+ set(key, value) {
59
+ if (this.map.has(key)) this.map.delete(key);
60
+ else if (this.map.size >= this.max) {
61
+ this.map.delete(this.map.keys().next().value);
62
+ }
63
+ this.map.set(key, { value, ts: Date.now() });
64
+ }
65
+ has(key) {
66
+ return this.get(key) !== void 0;
67
+ }
68
+ delete(key) {
69
+ this.map.delete(key);
70
+ }
71
+ clear() {
72
+ this.map.clear();
73
+ }
74
+ get size() {
75
+ return this.map.size;
76
+ }
77
+ keys() {
78
+ return this.map.keys();
79
+ }
80
+ *values() {
81
+ for (const entry of this.map.values()) {
82
+ yield entry.value;
83
+ }
84
+ }
85
+ *entries() {
86
+ for (const [key, entry] of this.map.entries()) {
87
+ yield [key, entry.value];
88
+ }
89
+ }
90
+ };
91
+ }
92
+ });
93
+ function getPlatformExtension() {
94
+ const platform = os.platform();
95
+ switch (platform) {
96
+ case "win32":
97
+ return ".node";
98
+ case "darwin":
99
+ return ".dylib";
100
+ case "linux":
101
+ return ".so";
102
+ default:
103
+ return ".node";
104
+ }
105
+ }
106
+ function formatErrorMessage(error) {
107
+ return error instanceof Error ? error.message : String(error);
108
+ }
109
+ function resolveRuntimeDir(dirnameValue, moduleImportUrl) {
110
+ if (typeof dirnameValue === "string" && dirnameValue.length > 0) return dirnameValue;
111
+ return path.dirname(fileURLToPath(moduleImportUrl));
112
+ }
113
+ function resolveNativeBindingCandidates(options) {
114
+ const out = [];
115
+ const envVarNames = options.envVarNames ?? ["TWS_NATIVE_PATH"];
116
+ for (const envVarName of envVarNames) {
117
+ const raw = process.env[envVarName]?.trim();
118
+ if (!raw) continue;
119
+ const resolved = path.resolve(raw);
120
+ if (options.enforceNodeExtensionForEnvPath) {
121
+ if (path.extname(resolved).toLowerCase() !== ".node") {
122
+ throw new Error(
123
+ `Invalid native binding path from ${envVarName}="${raw}". Expected a .node file.`
124
+ );
125
+ }
126
+ }
127
+ out.push(resolved);
128
+ }
129
+ if (options.includeDefaultCandidates !== false) {
130
+ const ext = options.platformExtension ?? getPlatformExtension();
131
+ const defaultBindingName = `tailwind_styled_parser${ext}`;
132
+ out.push(path.resolve(process.cwd(), "native", defaultBindingName));
133
+ out.push(path.resolve(options.runtimeDir, "..", "..", "..", "native", defaultBindingName));
134
+ }
135
+ return Array.from(new Set(out));
136
+ }
137
+ function parseDebugToken(namespace, token) {
138
+ if (token === "*" || token === namespace || token === "tailwind-styled:*") return true;
139
+ return token.endsWith("*") && namespace.startsWith(token.slice(0, -1));
140
+ }
141
+ function isDebugNamespaceEnabled(namespace) {
142
+ if (process.env.TWS_DEBUG === "1" || process.env.TAILWIND_STYLED_DEBUG === "1") return true;
143
+ const raw = process.env.DEBUG;
144
+ if (!raw) return false;
145
+ return raw.split(",").map((token) => token.trim()).some((token) => parseDebugToken(namespace, token));
146
+ }
147
+ function createDebugLogger(namespace, label = namespace) {
148
+ const debugEnabled = isDebugNamespaceEnabled(namespace);
149
+ return (message) => {
150
+ if (!debugEnabled) return;
151
+ console.debug(`[${label}] ${message}`);
152
+ };
153
+ }
154
+ function loadNativeBinding(options) {
155
+ const req = createRequire(path.join(options.runtimeDir, "noop.cjs"));
156
+ const loadErrors = [];
157
+ for (const candidate of options.candidates) {
158
+ if (!fs.existsSync(candidate)) continue;
159
+ try {
160
+ const mod = req(candidate);
161
+ if (options.isValid(mod)) {
162
+ return {
163
+ binding: mod,
164
+ loadedPath: candidate,
165
+ loadErrors
166
+ };
167
+ }
168
+ loadErrors.push({
169
+ path: candidate,
170
+ message: options.invalidExportMessage
171
+ });
172
+ } catch (error) {
173
+ loadErrors.push({
174
+ path: candidate,
175
+ message: formatErrorMessage(error)
176
+ });
177
+ }
178
+ }
179
+ return {
180
+ binding: null,
181
+ loadedPath: null,
182
+ loadErrors
183
+ };
184
+ }
185
+ var init_nativeBinding = __esm({
186
+ "packages/shared/src/nativeBinding.ts"() {
187
+ }
188
+ });
189
+
190
+ // packages/shared/src/index.ts
191
+ var init_src = __esm({
192
+ "packages/shared/src/index.ts"() {
193
+ init_cache();
194
+ init_nativeBinding();
195
+ }
196
+ });
197
+
198
+ // packages/animate/src/binding.ts
199
+ function isAnimateModule(module) {
200
+ const candidate = module;
201
+ return typeof candidate?.compileAnimation === "function" && typeof candidate?.compileKeyframes === "function";
202
+ }
203
+ function resolveBindingCandidates(runtimeDir) {
204
+ return resolveNativeBindingCandidates({
205
+ runtimeDir,
206
+ envVarNames: ["TWS_ANIMATE_NATIVE_PATH", "TWS_NATIVE_PATH"],
207
+ enforceNodeExtensionForEnvPath: true
208
+ });
209
+ }
210
+ function loadAnimateBinding() {
211
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
212
+ throw new Error(
213
+ "Native animate backend is required in v5. TWS_NO_NATIVE/TWS_NO_RUST is not supported."
214
+ );
215
+ }
216
+ const runtimeDir = resolveRuntimeDir(
217
+ typeof __dirname === "string" ? __dirname : void 0,
218
+ import.meta.url
219
+ );
220
+ const candidates = resolveBindingCandidates(runtimeDir);
221
+ const { binding, loadErrors, loadedPath } = loadNativeBinding({
222
+ runtimeDir,
223
+ candidates,
224
+ isValid: isAnimateModule,
225
+ invalidExportMessage: "Module loaded but missing compileAnimation/compileKeyframes exports."
226
+ });
227
+ if (binding) {
228
+ debugLog(`native animate binding loaded from: ${loadedPath}`);
229
+ return binding;
230
+ }
231
+ if (loadErrors.length > 0) {
232
+ debugLog(
233
+ `native animate binding load failed for ${loadErrors.length} candidate(s): ${loadErrors.map((entry) => `${entry.path} (${entry.message})`).join("; ")}`
234
+ );
235
+ } else {
236
+ debugLog("native animate binding not found in any candidate path");
237
+ }
238
+ const lines = [
239
+ "Native animate backend not found. Ensure `tailwind_styled_parser.node` is built.",
240
+ "Checked paths:",
241
+ ...candidates.map((candidate) => `- ${candidate}`)
242
+ ];
243
+ if (loadErrors.length > 0) {
244
+ lines.push("Load errors:");
245
+ for (const error of loadErrors) lines.push(`- ${error.path}: ${error.message}`);
246
+ }
247
+ throw new Error(lines.join("\n"));
248
+ }
249
+ async function getAnimateBinding() {
250
+ if (!bindingPromise) {
251
+ bindingPromise = Promise.resolve().then(loadAnimateBinding);
252
+ }
253
+ return bindingPromise;
254
+ }
255
+ async function initAnimate() {
256
+ await getAnimateBinding();
257
+ }
258
+ var bindingPromise, DEBUG_NAMESPACE, debugLog;
259
+ var init_binding = __esm({
260
+ "packages/animate/src/binding.ts"() {
261
+ init_src();
262
+ bindingPromise = null;
263
+ DEBUG_NAMESPACE = "tailwind-styled:animate";
264
+ debugLog = createDebugLogger(DEBUG_NAMESPACE, "tailwind-styled/animate");
265
+ }
266
+ });
267
+
268
+ // packages/animate/src/preset.ts
269
+ function createAnimationPresets(registry) {
270
+ const cache2 = new LRUCache(DEFAULT_PRESET_CACHE_LIMIT);
271
+ const withCache = (cacheKey, factory) => async () => {
272
+ const cached = cache2.get(cacheKey);
273
+ if (cached) {
274
+ const className = await cached;
275
+ if (registry.has(className)) return className;
276
+ cache2.delete(cacheKey);
277
+ }
278
+ const pending = factory();
279
+ cache2.set(cacheKey, pending);
280
+ try {
281
+ return await pending;
282
+ } catch (error) {
283
+ cache2.delete(cacheKey);
284
+ throw error;
285
+ }
286
+ };
287
+ return {
288
+ fadeIn: withCache(
289
+ "fadeIn",
290
+ async () => (await registry.compileAnimation({ from: "opacity-0", to: "opacity-100", duration: 200 })).className
291
+ ),
292
+ fadeOut: withCache(
293
+ "fadeOut",
294
+ async () => (await registry.compileAnimation({ from: "opacity-100", to: "opacity-0", duration: 200 })).className
295
+ ),
296
+ slideUp: withCache(
297
+ "slideUp",
298
+ async () => (await registry.compileAnimation({
299
+ from: "opacity-0 translate-y-4",
300
+ to: "opacity-100 translate-y-0",
301
+ duration: 300
302
+ })).className
303
+ ),
304
+ slideDown: withCache(
305
+ "slideDown",
306
+ async () => (await registry.compileAnimation({
307
+ from: "opacity-0 -translate-y-4",
308
+ to: "opacity-100 translate-y-0",
309
+ duration: 300
310
+ })).className
311
+ ),
312
+ slideLeft: withCache(
313
+ "slideLeft",
314
+ async () => (await registry.compileAnimation({
315
+ from: "opacity-0 translate-x-4",
316
+ to: "opacity-100 translate-x-0",
317
+ duration: 300
318
+ })).className
319
+ ),
320
+ slideRight: withCache(
321
+ "slideRight",
322
+ async () => (await registry.compileAnimation({
323
+ from: "opacity-0 -translate-x-4",
324
+ to: "opacity-100 translate-x-0",
325
+ duration: 300
326
+ })).className
327
+ ),
328
+ scaleIn: withCache(
329
+ "scaleIn",
330
+ async () => (await registry.compileAnimation({
331
+ from: "opacity-0 scale-95",
332
+ to: "opacity-100 scale-100",
333
+ duration: 200,
334
+ easing: "cubic-bezier(0.16,1,0.3,1)"
335
+ })).className
336
+ ),
337
+ scaleOut: withCache(
338
+ "scaleOut",
339
+ async () => (await registry.compileAnimation({
340
+ from: "opacity-100 scale-100",
341
+ to: "opacity-0 scale-95",
342
+ duration: 150
343
+ })).className
344
+ ),
345
+ blurIn: withCache(
346
+ "blurIn",
347
+ async () => (await registry.compileAnimation({
348
+ from: "opacity-0 blur-sm",
349
+ to: "opacity-100 blur-none",
350
+ duration: 300
351
+ })).className
352
+ ),
353
+ bounceIn: withCache(
354
+ "bounceIn",
355
+ async () => (await registry.compileAnimation({
356
+ from: "opacity-0 scale-50",
357
+ to: "opacity-100 scale-100",
358
+ duration: 400,
359
+ easing: "cubic-bezier(0.34,1.56,0.64,1)"
360
+ })).className
361
+ ),
362
+ spinIn: withCache(
363
+ "spinIn",
364
+ async () => (await registry.compileAnimation({
365
+ from: "opacity-0 rotate-180 scale-50",
366
+ to: "opacity-100 rotate-0 scale-100",
367
+ duration: 400,
368
+ easing: "cubic-bezier(0.16,1,0.3,1)"
369
+ })).className
370
+ )
371
+ };
372
+ }
373
+ var DEFAULT_PRESET_CACHE_LIMIT;
374
+ var init_preset = __esm({
375
+ "packages/animate/src/preset.ts"() {
376
+ init_src();
377
+ DEFAULT_PRESET_CACHE_LIMIT = 32;
378
+ }
379
+ });
380
+ function formatErrorMessage2(error) {
381
+ return error instanceof Error ? error.message : String(error);
382
+ }
383
+ var DEBUG_NAMESPACE2, debugLog2;
384
+ var init_utils = __esm({
385
+ "packages/analyzer/src/utils.ts"() {
386
+ init_src();
387
+ DEBUG_NAMESPACE2 = "tailwind-styled:analyzer";
388
+ debugLog2 = createDebugLogger(DEBUG_NAMESPACE2, "tailwind-styled/analyzer");
389
+ }
390
+ });
391
+
392
+ // packages/analyzer/src/binding.ts
393
+ function isAnalyzerModule(module) {
394
+ const candidate = module;
395
+ return typeof candidate?.analyzeClasses === "function";
396
+ }
397
+ function getNativeBinding() {
398
+ if (bindingCache !== void 0) return bindingCache;
399
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
400
+ bindingCandidateCache = [];
401
+ bindingLoadErrorsCache = [];
402
+ loadedBindingPathCache = null;
403
+ debugLog2("native binding disabled by TWS_NO_NATIVE/TWS_NO_RUST");
404
+ bindingCache = null;
405
+ return bindingCache;
406
+ }
407
+ const runtimeDir = resolveRuntimeDir(
408
+ typeof __dirname === "string" ? __dirname : void 0,
409
+ import.meta.url
410
+ );
411
+ const candidates = resolveNativeBindingCandidates({
412
+ runtimeDir,
413
+ envVarNames: ["TWS_NATIVE_PATH"]
414
+ });
415
+ const { binding, loadErrors, loadedPath } = loadNativeBinding({
416
+ runtimeDir,
417
+ candidates,
418
+ isValid: isAnalyzerModule,
419
+ invalidExportMessage: "Module loaded but missing `analyzeClasses` export."
420
+ });
421
+ bindingCandidateCache = candidates;
422
+ bindingLoadErrorsCache = loadErrors;
423
+ loadedBindingPathCache = loadedPath;
424
+ if (binding) {
425
+ debugLog2(`native binding loaded from: ${loadedPath}`);
426
+ bindingCache = binding;
427
+ return bindingCache;
428
+ }
429
+ if (bindingLoadErrorsCache.length > 0) {
430
+ debugLog2(
431
+ `native binding load failed for ${bindingLoadErrorsCache.length} candidate(s): ${bindingLoadErrorsCache.map((entry) => `${entry.path} (${entry.message})`).join("; ")}`
432
+ );
433
+ } else {
434
+ debugLog2("native binding not found in any candidate path");
435
+ }
436
+ bindingCache = null;
437
+ return bindingCache;
438
+ }
439
+ function requireNativeBinding() {
440
+ const binding = getNativeBinding();
441
+ if (binding?.analyzeClasses) return binding;
442
+ const lines = [
443
+ "Native analyzer binding not found. Ensure `tailwind_styled_parser.node` is built."
444
+ ];
445
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
446
+ lines.push("Native loading is disabled by TWS_NO_NATIVE/TWS_NO_RUST.");
447
+ } else {
448
+ lines.push("Checked paths:");
449
+ for (const candidate of bindingCandidateCache) lines.push(`- ${candidate}`);
450
+ if (bindingLoadErrorsCache.length > 0) {
451
+ lines.push("Load errors:");
452
+ for (const failure of bindingLoadErrorsCache) {
453
+ lines.push(`- ${failure.path}: ${failure.message}`);
454
+ }
455
+ }
456
+ }
457
+ throw new Error(lines.join("\n"));
458
+ }
459
+ function requireNativeCssCompiler() {
460
+ const binding = requireNativeBinding();
461
+ if (typeof binding.compileCss === "function") return binding;
462
+ const loadedPathText = loadedBindingPathCache ? ` (${loadedBindingPathCache})` : "";
463
+ throw new Error(`Native analyzer compileCss binding is missing in v5${loadedPathText}.`);
464
+ }
465
+ var bindingCache, bindingCandidateCache, bindingLoadErrorsCache, loadedBindingPathCache;
466
+ var init_binding2 = __esm({
467
+ "packages/analyzer/src/binding.ts"() {
468
+ init_src();
469
+ init_utils();
470
+ bindingCandidateCache = [];
471
+ bindingLoadErrorsCache = [];
472
+ loadedBindingPathCache = null;
473
+ }
474
+ });
475
+
476
+ // packages/analyzer/src/classToCss.ts
477
+ function normalizeClassInput(input) {
478
+ if (typeof input === "string") {
479
+ return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
480
+ }
481
+ if (!Array.isArray(input)) {
482
+ throw new TypeError("classToCss input must be a string or an array of strings.");
483
+ }
484
+ const out = [];
485
+ for (const item of input) {
486
+ if (typeof item !== "string") {
487
+ throw new TypeError("classToCss input array must contain only strings.");
488
+ }
489
+ const value = item.trim();
490
+ if (value.length > 0) out.push(value);
491
+ }
492
+ return out;
493
+ }
494
+ function normalizeClassToCssOptions(options) {
495
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
496
+ throw new TypeError("classToCss options must be an object.");
497
+ }
498
+ const strict = options.strict ?? false;
499
+ if (typeof strict !== "boolean") {
500
+ throw new TypeError("classToCss options.strict must be a boolean when provided.");
501
+ }
502
+ const prefix = options.prefix ?? null;
503
+ if (prefix !== null && typeof prefix !== "string") {
504
+ throw new TypeError("classToCss options.prefix must be a string or null when provided.");
505
+ }
506
+ return { prefix, strict };
507
+ }
508
+ function mergeDeclarationMap(target, css) {
509
+ const ruleRegex = /\{([^}]*)\}/g;
510
+ let ruleMatch = ruleRegex.exec(css);
511
+ while (ruleMatch) {
512
+ const body = ruleMatch[1];
513
+ for (const raw of body.split(";")) {
514
+ const declaration = raw.trim();
515
+ if (declaration.length === 0) continue;
516
+ const colonIndex = declaration.indexOf(":");
517
+ if (colonIndex <= 0) continue;
518
+ const property = declaration.slice(0, colonIndex).trim();
519
+ const value = declaration.slice(colonIndex + 1).trim();
520
+ if (property.length === 0 || value.length === 0) continue;
521
+ if (target.has(property)) target.delete(property);
522
+ target.set(property, value);
523
+ }
524
+ ruleMatch = ruleRegex.exec(css);
525
+ }
526
+ }
527
+ function declarationMapToString(declarationMap) {
528
+ return Array.from(declarationMap.entries()).map(([property, value]) => `${property}: ${value}`).join("; ");
529
+ }
530
+ async function classToCss(input, options = {}) {
531
+ const inputClasses = normalizeClassInput(input);
532
+ const normalizedOptions = normalizeClassToCssOptions(options);
533
+ if (inputClasses.length === 0) {
534
+ return {
535
+ inputClasses: [],
536
+ css: "",
537
+ declarations: "",
538
+ resolvedClasses: [],
539
+ unknownClasses: [],
540
+ sizeBytes: 0
541
+ };
542
+ }
543
+ const binding = requireNativeCssCompiler();
544
+ const prefix = normalizedOptions.prefix;
545
+ const cssChunks = [];
546
+ const resolvedClasses = [];
547
+ const unknownClasses = [];
548
+ let sizeBytes = 0;
549
+ const declarationMap = /* @__PURE__ */ new Map();
550
+ for (const className of inputClasses) {
551
+ let compiled = null;
552
+ try {
553
+ compiled = binding.compileCss([className], prefix);
554
+ } catch (error) {
555
+ throw new Error(
556
+ `Native analyzer failed while compiling class "${className}": ${formatErrorMessage2(error)}`,
557
+ { cause: error }
558
+ );
559
+ }
560
+ if (!compiled) {
561
+ throw new Error(`Native analyzer returned no result for class "${className}".`);
562
+ }
563
+ cssChunks.push(compiled.css);
564
+ resolvedClasses.push(...compiled.resolvedClasses);
565
+ unknownClasses.push(...compiled.unknownClasses);
566
+ sizeBytes += compiled.sizeBytes;
567
+ mergeDeclarationMap(declarationMap, compiled.css);
568
+ }
569
+ const uniqueUnknown = Array.from(new Set(unknownClasses));
570
+ if (normalizedOptions.strict && uniqueUnknown.length > 0) {
571
+ throw new Error(`Unknown Tailwind classes: ${uniqueUnknown.join(", ")}`);
572
+ }
573
+ return {
574
+ inputClasses,
575
+ css: cssChunks.filter((chunk) => chunk.length > 0).join("\n"),
576
+ declarations: declarationMapToString(declarationMap),
577
+ resolvedClasses: Array.from(new Set(resolvedClasses)),
578
+ unknownClasses: uniqueUnknown,
579
+ sizeBytes
580
+ };
581
+ }
582
+ var init_classToCss = __esm({
583
+ "packages/analyzer/src/classToCss.ts"() {
584
+ init_binding2();
585
+ init_utils();
586
+ }
587
+ });
588
+
589
+ // packages/analyzer/src/index.ts
590
+ var init_src2 = __esm({
591
+ "packages/analyzer/src/index.ts"() {
592
+ init_classToCss();
593
+ }
594
+ });
595
+
596
+ // packages/animate/src/registry.ts
597
+ function normalizeNumber(value, fallback) {
598
+ if (!Number.isFinite(value)) return fallback;
599
+ return Math.max(0, Math.trunc(value));
600
+ }
601
+ function normalizeCacheLimit(value) {
602
+ if (!Number.isFinite(value)) return DEFAULT_CACHE_LIMIT;
603
+ return Math.max(1, Math.trunc(value));
604
+ }
605
+ function normalizeIterations(value) {
606
+ if (value === "infinite") return "infinite";
607
+ if (!Number.isFinite(value)) return String(DEFAULT_ITERATIONS);
608
+ return String(Math.max(0, Math.trunc(value)));
609
+ }
610
+ function stableKeyframesEntries(stops) {
611
+ return Object.entries(stops).map(([offset, classes]) => ({ offset, classes })).sort((left, right) => left.offset.localeCompare(right.offset));
612
+ }
613
+ function animationCacheKey(opts) {
614
+ const normalized = {
615
+ from: opts.from.trim(),
616
+ to: opts.to.trim(),
617
+ duration: normalizeNumber(opts.duration, DEFAULT_DURATION),
618
+ easing: (opts.easing ?? DEFAULT_EASING).trim(),
619
+ delay: normalizeNumber(opts.delay, DEFAULT_DELAY),
620
+ fill: opts.fill ?? DEFAULT_FILL,
621
+ iterations: normalizeIterations(opts.iterations),
622
+ direction: opts.direction ?? DEFAULT_DIRECTION,
623
+ name: opts.name ?? ""
624
+ };
625
+ return JSON.stringify(normalized);
626
+ }
627
+ function keyframesCacheKey(name, stops) {
628
+ return `${name}::${JSON.stringify(stableKeyframesEntries(stops))}`;
629
+ }
630
+ function splitClasses(classList) {
631
+ return classList.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
632
+ }
633
+ async function validateTailwindClasses(entries) {
634
+ const binding = await getAnimateBinding();
635
+ const unknownByContext = /* @__PURE__ */ new Map();
636
+ const failures = [];
637
+ for (const entry of entries) {
638
+ const classes = splitClasses(entry.classList);
639
+ if (classes.length === 0) continue;
640
+ try {
641
+ if (typeof binding.compileCss === "function") {
642
+ const compiled = binding.compileCss(classes, null);
643
+ if (!compiled) {
644
+ failures.push(
645
+ `Animation ${entry.context} failed validation: native compileCss returned no result.`
646
+ );
647
+ continue;
648
+ }
649
+ if (compiled.unknownClasses.length > 0) {
650
+ const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
651
+ for (const className of compiled.unknownClasses) bucket.add(className);
652
+ unknownByContext.set(entry.context, bucket);
653
+ }
654
+ continue;
655
+ }
656
+ const checked = await classToCss(classes, { strict: false });
657
+ if (checked.unknownClasses.length > 0) {
658
+ const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
659
+ for (const className of checked.unknownClasses) bucket.add(className);
660
+ unknownByContext.set(entry.context, bucket);
661
+ }
662
+ } catch (error) {
663
+ failures.push(`Animation ${entry.context} failed validation: ${formatErrorMessage(error)}`);
664
+ }
665
+ }
666
+ const issues = [];
667
+ for (const [context, classes] of unknownByContext.entries()) {
668
+ issues.push(
669
+ `Animation ${context} contains unknown Tailwind classes: ${Array.from(classes).join(", ")}`
670
+ );
671
+ }
672
+ issues.push(...failures);
673
+ if (issues.length > 0) {
674
+ throw new Error(issues.join("\n"));
675
+ }
676
+ }
677
+ function createAnimationRegistry(options = {}) {
678
+ return new AnimationRegistry(options);
679
+ }
680
+ var DEFAULT_DURATION, DEFAULT_EASING, DEFAULT_DELAY, DEFAULT_FILL, DEFAULT_ITERATIONS, DEFAULT_DIRECTION, DEFAULT_CACHE_LIMIT, AnimationRegistry;
681
+ var init_registry = __esm({
682
+ "packages/animate/src/registry.ts"() {
683
+ init_src2();
684
+ init_src();
685
+ init_binding();
686
+ DEFAULT_DURATION = 300;
687
+ DEFAULT_EASING = "ease-out";
688
+ DEFAULT_DELAY = 0;
689
+ DEFAULT_FILL = "both";
690
+ DEFAULT_ITERATIONS = 1;
691
+ DEFAULT_DIRECTION = "normal";
692
+ DEFAULT_CACHE_LIMIT = 512;
693
+ AnimationRegistry = class {
694
+ constructor(options = {}) {
695
+ const cacheLimit = normalizeCacheLimit(options.cacheLimit);
696
+ this.animations = new LRUCache(cacheLimit);
697
+ this.animationBySignature = new LRUCache(cacheLimit);
698
+ this.keyframesBySignature = new LRUCache(cacheLimit);
699
+ }
700
+ async compileAnimation(opts) {
701
+ const signature = animationCacheKey(opts);
702
+ const existingClassName = this.animationBySignature.get(signature);
703
+ if (existingClassName) {
704
+ const cached = this.animations.get(existingClassName);
705
+ if (cached) return cached;
706
+ this.animationBySignature.delete(signature);
707
+ }
708
+ await validateTailwindClasses([
709
+ { classList: opts.from, context: `"from" in ${opts.name ?? "anonymous animation"}` },
710
+ { classList: opts.to, context: `"to" in ${opts.name ?? "anonymous animation"}` }
711
+ ]);
712
+ const binding = await getAnimateBinding();
713
+ const duration = normalizeNumber(opts.duration, DEFAULT_DURATION);
714
+ const easing = opts.easing ?? DEFAULT_EASING;
715
+ const delay = normalizeNumber(opts.delay, DEFAULT_DELAY);
716
+ const fill = opts.fill ?? DEFAULT_FILL;
717
+ const iterations = normalizeIterations(opts.iterations);
718
+ const direction = opts.direction ?? DEFAULT_DIRECTION;
719
+ const compiled = binding.compileAnimation?.(
720
+ opts.from,
721
+ opts.to,
722
+ opts.name ?? null,
723
+ duration,
724
+ easing,
725
+ delay,
726
+ fill,
727
+ iterations,
728
+ direction
729
+ );
730
+ if (!compiled) {
731
+ throw new Error(
732
+ `Native animate backend failed to compile animation "${opts.name ?? "anonymous animation"}".`
733
+ );
734
+ }
735
+ const result = {
736
+ className: compiled.className,
737
+ keyframesCss: compiled.keyframesCss,
738
+ animationCss: compiled.animationCss
739
+ };
740
+ this.animations.set(result.className, result);
741
+ this.animationBySignature.set(signature, result.className);
742
+ return result;
743
+ }
744
+ async compileKeyframes(name, stops) {
745
+ const signature = keyframesCacheKey(name, stops);
746
+ const existingClassName = this.keyframesBySignature.get(signature);
747
+ if (existingClassName) {
748
+ const cached = this.animations.get(existingClassName);
749
+ if (cached) return cached;
750
+ this.keyframesBySignature.delete(signature);
751
+ }
752
+ await validateTailwindClasses(
753
+ Object.entries(stops).map(([offset, classes]) => ({
754
+ classList: classes,
755
+ context: `"${offset}" stop in keyframes "${name}"`
756
+ }))
757
+ );
758
+ const binding = await getAnimateBinding();
759
+ const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
760
+ const compiled = binding.compileKeyframes?.(name, stopsJson);
761
+ if (!compiled) {
762
+ throw new Error(`Native animate backend failed to compile keyframes "${name}".`);
763
+ }
764
+ const result = {
765
+ className: compiled.className,
766
+ keyframesCss: compiled.keyframesCss,
767
+ animationCss: compiled.animationCss
768
+ };
769
+ this.animations.set(result.className, result);
770
+ this.keyframesBySignature.set(signature, result.className);
771
+ return result;
772
+ }
773
+ extractCss() {
774
+ const lines = [];
775
+ for (const [, compiled] of this.animations.entries()) {
776
+ lines.push(compiled.keyframesCss);
777
+ lines.push(`.${compiled.className} { ${compiled.animationCss} }`);
778
+ }
779
+ return lines.join("\n\n");
780
+ }
781
+ reset() {
782
+ this.animations.clear();
783
+ this.animationBySignature.clear();
784
+ this.keyframesBySignature.clear();
785
+ }
786
+ has(className) {
787
+ return this.animations.has(className);
788
+ }
789
+ };
790
+ }
791
+ });
792
+
793
+ // packages/animate/src/index.ts
794
+ var src_exports = {};
795
+ __export(src_exports, {
796
+ AnimationRegistry: () => AnimationRegistry,
797
+ animate: () => animate,
798
+ animations: () => animations,
799
+ compileAnimation: () => compileAnimation,
800
+ compileKeyframes: () => compileKeyframes,
801
+ createAnimationRegistry: () => createAnimationRegistry,
802
+ extractAnimationCss: () => extractAnimationCss,
803
+ getDefaultAnimationRegistry: () => getDefaultAnimationRegistry,
804
+ initAnimate: () => initAnimate2,
805
+ injectAnimationCss: () => injectAnimationCss,
806
+ keyframes: () => keyframes,
807
+ resetAnimationRegistry: () => resetAnimationRegistry
808
+ });
809
+ async function initAnimate2() {
810
+ await initAnimate();
811
+ }
812
+ function getDefaultAnimationRegistry() {
813
+ return defaultRegistry;
814
+ }
815
+ async function compileAnimation(opts, registry = defaultRegistry) {
816
+ return registry.compileAnimation(opts);
817
+ }
818
+ async function compileKeyframes(name, stops, registry = defaultRegistry) {
819
+ return registry.compileKeyframes(name, stops);
820
+ }
821
+ async function animate(opts, registry = defaultRegistry) {
822
+ return (await registry.compileAnimation(opts)).className;
823
+ }
824
+ async function keyframes(name, stops, registry = defaultRegistry) {
825
+ return (await registry.compileKeyframes(name, stops)).className;
826
+ }
827
+ function extractAnimationCss(registry = defaultRegistry) {
828
+ return registry.extractCss();
829
+ }
830
+ function resetAnimationRegistry(registry = defaultRegistry) {
831
+ registry.reset();
832
+ }
833
+ function injectAnimationCss(registry = defaultRegistry, options = {}) {
834
+ const targetDocument = options.document ?? (typeof document !== "undefined" ? document : void 0);
835
+ if (!targetDocument) {
836
+ if (options.silent) return;
837
+ throw new Error("injectAnimationCss requires a browser Document.");
838
+ }
839
+ const styleId = options.styleId ?? "__tw_animate_styles__";
840
+ let styleEl = targetDocument.getElementById(styleId);
841
+ if (!styleEl) {
842
+ if (!targetDocument.head) {
843
+ if (options.silent) return;
844
+ throw new Error("injectAnimationCss requires document.head to exist.");
845
+ }
846
+ styleEl = targetDocument.createElement("style");
847
+ styleEl.id = styleId;
848
+ targetDocument.head.appendChild(styleEl);
849
+ }
850
+ styleEl.textContent = registry.extractCss();
851
+ }
852
+ var defaultRegistry, animations;
853
+ var init_src3 = __esm({
854
+ "packages/animate/src/index.ts"() {
855
+ init_binding();
856
+ init_preset();
857
+ init_registry();
858
+ init_registry();
859
+ defaultRegistry = createAnimationRegistry();
860
+ animations = createAnimationPresets(defaultRegistry);
861
+ }
862
+ });
863
+
864
+ // packages/core/src/containerQuery.ts
865
+ var CONTAINER_BREAKPOINTS = {
866
+ xs: "240px",
867
+ sm: "320px",
868
+ md: "640px",
869
+ lg: "1024px",
870
+ xl: "1280px",
871
+ "2xl": "1536px"
872
+ };
873
+ var containerRegistry = /* @__PURE__ */ new Map();
874
+ if (typeof window !== "undefined") {
875
+ window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
876
+ }
877
+ function hashContainer(tag, container, name) {
878
+ const key = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
879
+ let hash = 5381;
880
+ for (let i = 0; i < key.length; i++) {
881
+ hash = (hash << 5) + hash ^ key.charCodeAt(i);
882
+ }
883
+ return `tw-cq-${Math.abs(hash).toString(36).slice(0, 6)}`;
884
+ }
885
+ var LAYOUT_MAP = {
886
+ "flex-col": "flex-direction:column",
887
+ "flex-row": "flex-direction:row",
888
+ "flex-wrap": "flex-wrap:wrap",
889
+ "flex-nowrap": "flex-wrap:nowrap",
890
+ "flex-1": "flex:1 1 0%",
891
+ hidden: "display:none",
892
+ block: "display:block",
893
+ flex: "display:flex",
894
+ grid: "display:grid",
895
+ "grid-cols-1": "grid-template-columns:repeat(1,minmax(0,1fr))",
896
+ "grid-cols-2": "grid-template-columns:repeat(2,minmax(0,1fr))",
897
+ "grid-cols-3": "grid-template-columns:repeat(3,minmax(0,1fr))",
898
+ "grid-cols-4": "grid-template-columns:repeat(4,minmax(0,1fr))",
899
+ "grid-cols-6": "grid-template-columns:repeat(6,minmax(0,1fr))",
900
+ "grid-cols-12": "grid-template-columns:repeat(12,minmax(0,1fr))",
901
+ "text-sm": "font-size:0.875rem;line-height:1.25rem",
902
+ "text-base": "font-size:1rem;line-height:1.5rem",
903
+ "text-lg": "font-size:1.125rem;line-height:1.75rem",
904
+ "text-xl": "font-size:1.25rem;line-height:1.75rem",
905
+ "text-2xl": "font-size:1.5rem;line-height:2rem",
906
+ "text-xs": "font-size:0.75rem;line-height:1rem",
907
+ "p-2": "padding:0.5rem",
908
+ "p-4": "padding:1rem",
909
+ "p-6": "padding:1.5rem",
910
+ "p-8": "padding:2rem",
911
+ "px-2": "padding-left:0.5rem;padding-right:0.5rem",
912
+ "px-4": "padding-left:1rem;padding-right:1rem",
913
+ "px-6": "padding-left:1.5rem;padding-right:1.5rem",
914
+ "py-2": "padding-top:0.5rem;padding-bottom:0.5rem",
915
+ "py-4": "padding-top:1rem;padding-bottom:1rem",
916
+ "gap-2": "gap:0.5rem",
917
+ "gap-4": "gap:1rem",
918
+ "gap-6": "gap:1.5rem",
919
+ "gap-8": "gap:2rem",
920
+ "w-full": "width:100%",
921
+ "w-1/2": "width:50%",
922
+ "w-1/3": "width:33.333333%",
923
+ "w-2/3": "width:66.666667%",
924
+ "max-w-sm": "max-width:24rem",
925
+ "max-w-md": "max-width:28rem",
926
+ "max-w-lg": "max-width:32rem",
927
+ "max-w-xl": "max-width:36rem",
928
+ "items-center": "align-items:center",
929
+ "items-start": "align-items:flex-start",
930
+ "items-end": "align-items:flex-end",
931
+ "justify-center": "justify-content:center",
932
+ "justify-between": "justify-content:space-between",
933
+ "justify-start": "justify-content:flex-start",
934
+ "justify-end": "justify-content:flex-end"
935
+ };
936
+ function layoutClassesToCss(classes) {
937
+ const decls = [];
938
+ for (const cls of classes.trim().split(/\s+/)) {
939
+ if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
940
+ else if (cls.startsWith("w-[")) {
941
+ const val = cls.match(/\[(.+)\]/)?.[1];
942
+ if (val) decls.push(`width:${val}`);
943
+ } else if (cls.startsWith("max-w-[")) {
944
+ const val = cls.match(/\[(.+)\]/)?.[1];
945
+ if (val) decls.push(`max-width:${val}`);
946
+ }
947
+ }
948
+ return decls.join(";");
949
+ }
950
+ function buildContainerRules(id, container, containerName) {
951
+ const rules = [];
952
+ for (const [key, value] of Object.entries(container)) {
953
+ let minWidth;
954
+ let classes;
955
+ if (typeof value === "string") {
956
+ minWidth = CONTAINER_BREAKPOINTS[key] ?? key;
957
+ classes = value;
958
+ } else {
959
+ minWidth = value.minWidth ?? CONTAINER_BREAKPOINTS[key] ?? key;
960
+ classes = value.classes;
961
+ }
962
+ const css = layoutClassesToCss(classes);
963
+ if (!css) continue;
964
+ const query = containerName ? `@container ${containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
965
+ rules.push(`${query}{.${id}{${css}}}`);
966
+ }
967
+ return rules.join("\n");
968
+ }
969
+ function injectContainerStyles(id, container, containerName) {
970
+ if (typeof document === "undefined") return;
971
+ const styleId = `tw-cq-${id}`;
972
+ if (document.getElementById(styleId)) return;
973
+ const css = buildContainerRules(id, container, containerName);
974
+ if (!css) return;
975
+ try {
976
+ const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
977
+ for (const rule of css.split("\n").filter(Boolean)) batchedInject(rule);
978
+ return;
979
+ } catch {
980
+ }
981
+ const style = document.createElement("style");
982
+ style.id = styleId;
983
+ style.setAttribute("data-tw-container", id);
984
+ style.textContent = css;
985
+ document.head.appendChild(style);
986
+ }
987
+ function processContainer(tag, container, containerName) {
988
+ const id = hashContainer(tag, container, containerName);
989
+ if (!containerRegistry.has(id)) {
990
+ const breakpoints = Object.entries(container).map(([key, value]) => ({
991
+ minWidth: CONTAINER_BREAKPOINTS[key] ?? key,
992
+ classes: typeof value === "string" ? value : value.classes
993
+ }));
994
+ containerRegistry.set(id, {
995
+ id,
996
+ tag,
997
+ containerName,
998
+ breakpoints,
999
+ cssInjected: false
1000
+ });
1001
+ }
1002
+ injectContainerStyles(id, container, containerName);
1003
+ containerRegistry.get(id).cssInjected = true;
1004
+ return { containerClass: id, hasContainer: true };
1005
+ }
1006
+ function generateContainerCss(tag, container, containerName) {
1007
+ const id = hashContainer(tag, container, containerName);
1008
+ return buildContainerRules(id, container, containerName);
1009
+ }
1010
+ function getContainerRegistry() {
1011
+ return containerRegistry;
1012
+ }
1013
+
1014
+ // packages/core/src/stateEngine.ts
1015
+ var stateRegistry = /* @__PURE__ */ new Map();
1016
+ if (typeof window !== "undefined") {
1017
+ window.__TW_STATE_REGISTRY__ = stateRegistry;
1018
+ }
1019
+ function hashState(tag, state) {
1020
+ const key = tag + JSON.stringify(Object.entries(state).sort());
1021
+ let hash = 5381;
1022
+ for (let i = 0; i < key.length; i++) {
1023
+ hash = (hash << 5) + hash ^ key.charCodeAt(i);
1024
+ }
1025
+ return `tw-s-${Math.abs(hash).toString(36).slice(0, 6)}`;
1026
+ }
1027
+ var TW_MAP = {
1028
+ // Display
1029
+ hidden: "display:none",
1030
+ block: "display:block",
1031
+ flex: "display:flex",
1032
+ inline: "display:inline",
1033
+ "inline-flex": "display:inline-flex",
1034
+ grid: "display:grid",
1035
+ // Opacity
1036
+ "opacity-0": "opacity:0",
1037
+ "opacity-5": "opacity:0.05",
1038
+ "opacity-10": "opacity:0.1",
1039
+ "opacity-20": "opacity:0.2",
1040
+ "opacity-25": "opacity:0.25",
1041
+ "opacity-30": "opacity:0.3",
1042
+ "opacity-40": "opacity:0.4",
1043
+ "opacity-50": "opacity:0.5",
1044
+ "opacity-60": "opacity:0.6",
1045
+ "opacity-70": "opacity:0.7",
1046
+ "opacity-75": "opacity:0.75",
1047
+ "opacity-80": "opacity:0.8",
1048
+ "opacity-90": "opacity:0.9",
1049
+ "opacity-95": "opacity:0.95",
1050
+ "opacity-100": "opacity:1",
1051
+ // Cursor
1052
+ "cursor-pointer": "cursor:pointer",
1053
+ "cursor-not-allowed": "cursor:not-allowed",
1054
+ "cursor-default": "cursor:default",
1055
+ "cursor-wait": "cursor:wait",
1056
+ "cursor-move": "cursor:move",
1057
+ "cursor-grab": "cursor:grab",
1058
+ "cursor-grabbing": "cursor:grabbing",
1059
+ // Pointer events
1060
+ "pointer-events-none": "pointer-events:none",
1061
+ "pointer-events-auto": "pointer-events:auto",
1062
+ // Scale
1063
+ "scale-90": "transform:scale(0.9)",
1064
+ "scale-95": "transform:scale(0.95)",
1065
+ "scale-100": "transform:scale(1)",
1066
+ "scale-105": "transform:scale(1.05)",
1067
+ "scale-110": "transform:scale(1.1)",
1068
+ // Translate
1069
+ "translate-x-0": "transform:translateX(0)",
1070
+ "translate-y-0": "transform:translateY(0)",
1071
+ "-translate-x-1": "transform:translateX(-0.25rem)",
1072
+ "-translate-y-1": "transform:translateY(-0.25rem)",
1073
+ "translate-x-1": "transform:translateX(0.25rem)",
1074
+ "translate-y-1": "transform:translateY(0.25rem)",
1075
+ // Ring
1076
+ ring: "box-shadow:0 0 0 3px rgba(59,130,246,0.5)",
1077
+ "ring-2": "box-shadow:0 0 0 2px rgba(59,130,246,0.5)",
1078
+ "ring-4": "box-shadow:0 0 0 4px rgba(59,130,246,0.5)",
1079
+ "ring-inset": "box-shadow:inset 0 0 0 3px rgba(59,130,246,0.5)",
1080
+ // Border
1081
+ border: "border-width:1px",
1082
+ "border-2": "border-width:2px",
1083
+ "border-transparent": "border-color:transparent",
1084
+ // Outline
1085
+ "outline-none": "outline:2px solid transparent;outline-offset:2px",
1086
+ outline: "outline:2px solid currentColor",
1087
+ // Overflow
1088
+ "overflow-hidden": "overflow:hidden",
1089
+ "overflow-auto": "overflow:auto",
1090
+ "overflow-scroll": "overflow:scroll",
1091
+ // Text decoration
1092
+ underline: "text-decoration-line:underline",
1093
+ "no-underline": "text-decoration-line:none",
1094
+ "line-through": "text-decoration-line:line-through",
1095
+ // Font weight
1096
+ "font-bold": "font-weight:700",
1097
+ "font-semibold": "font-weight:600",
1098
+ "font-medium": "font-weight:500",
1099
+ "font-normal": "font-weight:400",
1100
+ // Background colors (common)
1101
+ "bg-transparent": "background-color:transparent",
1102
+ "bg-white": "background-color:#fff",
1103
+ "bg-black": "background-color:#000",
1104
+ "bg-blue-500": "background-color:rgb(59,130,246)",
1105
+ "bg-blue-600": "background-color:rgb(37,99,235)",
1106
+ "bg-red-500": "background-color:rgb(239,68,68)",
1107
+ "bg-green-500": "background-color:rgb(34,197,94)",
1108
+ "bg-yellow-500": "background-color:rgb(234,179,8)",
1109
+ "bg-zinc-900": "background-color:rgb(24,24,27)",
1110
+ "bg-zinc-800": "background-color:rgb(39,39,42)",
1111
+ // Text colors
1112
+ "text-white": "color:#fff",
1113
+ "text-black": "color:#000",
1114
+ "text-blue-500": "color:rgb(59,130,246)",
1115
+ "text-red-500": "color:rgb(239,68,68)",
1116
+ "text-zinc-400": "color:rgb(161,161,170)",
1117
+ "text-zinc-500": "color:rgb(113,113,122)"
1118
+ };
1119
+ function twClassesToCss(classes) {
1120
+ const decls = [];
1121
+ for (const cls of classes.trim().split(/\s+/)) {
1122
+ if (TW_MAP[cls]) decls.push(TW_MAP[cls]);
1123
+ else if (cls.includes("[") && cls.includes("]")) {
1124
+ const val = cls.match(/\[(.+)\]/)?.[1];
1125
+ if (!val) continue;
1126
+ if (cls.startsWith("bg-[")) decls.push(`background-color:${val}`);
1127
+ else if (cls.startsWith("text-[")) decls.push(`color:${val}`);
1128
+ else if (cls.startsWith("w-[")) decls.push(`width:${val}`);
1129
+ else if (cls.startsWith("h-[")) decls.push(`height:${val}`);
1130
+ else if (cls.startsWith("opacity-[")) decls.push(`opacity:${val}`);
1131
+ }
1132
+ }
1133
+ return decls.join(";");
1134
+ }
1135
+ function injectStateStyles(id, state) {
1136
+ if (typeof document === "undefined") return;
1137
+ const styleId = `tw-state-${id}`;
1138
+ if (document.getElementById(styleId)) return;
1139
+ const rules = [];
1140
+ for (const [stateName, classes] of Object.entries(state)) {
1141
+ const css = twClassesToCss(classes);
1142
+ if (css) {
1143
+ rules.push(`.${id}[data-${stateName}="true"]{${css}}`);
1144
+ }
1145
+ }
1146
+ if (rules.length === 0) return;
1147
+ try {
1148
+ const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
1149
+ for (const rule of rules) batchedInject(rule);
1150
+ return;
1151
+ } catch {
1152
+ }
1153
+ const style = document.createElement("style");
1154
+ style.id = styleId;
1155
+ style.setAttribute("data-tw-state", id);
1156
+ style.textContent = rules.join("\n");
1157
+ document.head.appendChild(style);
1158
+ }
1159
+ function processState(tag, state) {
1160
+ const id = hashState(tag, state);
1161
+ const stateNames = Object.keys(state);
1162
+ if (!stateRegistry.has(id)) {
1163
+ stateRegistry.set(id, {
1164
+ id,
1165
+ tag,
1166
+ states: stateNames,
1167
+ cssInjected: false
1168
+ });
1169
+ }
1170
+ injectStateStyles(id, state);
1171
+ const entry = stateRegistry.get(id);
1172
+ entry.cssInjected = true;
1173
+ return { stateClass: id, hasState: true, stateNames };
1174
+ }
1175
+ function generateStateCss(tag, state) {
1176
+ const id = hashState(tag, state);
1177
+ const rules = [];
1178
+ for (const [stateName, classes] of Object.entries(state)) {
1179
+ const css = twClassesToCss(classes);
1180
+ if (css) {
1181
+ rules.push(`.${id}[data-${stateName}="true"]{${css}}`);
1182
+ }
1183
+ }
1184
+ return rules.join("\n");
1185
+ }
1186
+ function getStateRegistry() {
1187
+ return stateRegistry;
1188
+ }
1189
+
1190
+ // packages/core/src/createComponent.ts
1191
+ var ALWAYS_BLOCKED = /* @__PURE__ */ new Set(["base", "_ref", "state", "container", "containerName"]);
1192
+ function makeFilterProps(variantKeys) {
1193
+ return function filterProps(props) {
1194
+ const out = {};
1195
+ for (const key in props) {
1196
+ if (variantKeys.has(key)) continue;
1197
+ if (key.startsWith("$")) continue;
1198
+ if (ALWAYS_BLOCKED.has(key)) continue;
1199
+ out[key] = props[key];
1200
+ }
1201
+ return out;
1202
+ };
1203
+ }
1204
+ function resolveVariants(variants, props, defaults) {
1205
+ const classes = [];
1206
+ for (const key in variants) {
1207
+ const val = props[key] ?? defaults[key];
1208
+ if (val !== void 0 && variants[key][String(val)]) {
1209
+ classes.push(variants[key][String(val)]);
1210
+ }
1211
+ }
1212
+ return classes.join(" ");
1213
+ }
1214
+ function resolveCompound(compounds, props) {
1215
+ const classes = [];
1216
+ for (const compound of compounds) {
1217
+ const { class: cls, ...conditions } = compound;
1218
+ const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
1219
+ if (match) classes.push(cls);
1220
+ }
1221
+ return classes.join(" ");
1222
+ }
1223
+ function createComponent(tag, config) {
1224
+ const isStatic = typeof config === "string";
1225
+ const base = isStatic ? config : config.base ?? "";
1226
+ const variants = isStatic ? {} : config.variants ?? {};
1227
+ const compoundVariants = isStatic ? [] : config.compoundVariants ?? [];
1228
+ const defaultVariants = isStatic ? {} : config.defaultVariants ?? {};
1229
+ const stateConfig = isStatic ? void 0 : config.state;
1230
+ const containerConfig = isStatic ? void 0 : config.container;
1231
+ const containerName = isStatic ? void 0 : config.containerName;
1232
+ const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
1233
+ const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
1234
+ const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
1235
+ const variantKeySet = new Set(Object.keys(variants));
1236
+ const filterProps = makeFilterProps(variantKeySet);
1237
+ const tagStr = typeof tag === "string" ? tag : tag.displayName ?? "Component";
1238
+ if (isStatic || Object.keys(variants).length === 0) {
1239
+ const Component2 = React.forwardRef((props, ref) => {
1240
+ const { className, ...rest } = props;
1241
+ return React.createElement(tag, {
1242
+ ref,
1243
+ ...filterProps(rest),
1244
+ className: twMerge(base, engineClasses, className)
1245
+ });
1246
+ });
1247
+ Component2.displayName = `tw.${tagStr}`;
1248
+ attachExtend(Component2, tag, base, config);
1249
+ return Component2;
1250
+ }
1251
+ const Component = React.forwardRef((props, ref) => {
1252
+ const { className } = props;
1253
+ const variantClasses = resolveVariants(variants, props, defaultVariants);
1254
+ const compoundClasses = resolveCompound(compoundVariants, props);
1255
+ return React.createElement(tag, {
1256
+ ref,
1257
+ ...filterProps(props),
1258
+ className: twMerge(base, variantClasses, compoundClasses, engineClasses, className)
1259
+ });
1260
+ });
1261
+ Component.displayName = `tw.${tagStr}`;
1262
+ attachExtend(Component, tag, base, config);
1263
+ return Component;
1264
+ }
1265
+ function attachExtend(Component, originalTag, base, config) {
1266
+ Component.extend = (strings, ..._exprs) => {
1267
+ const extra = strings.raw.join("").trim().replace(/\s+/g, " ");
1268
+ const merged = twMerge(base, extra);
1269
+ return createComponent(
1270
+ originalTag,
1271
+ typeof config === "string" ? merged : { ...config, base: merged }
1272
+ );
1273
+ };
1274
+ Component.withVariants = (newConfig) => {
1275
+ const existing = typeof config === "object" ? config : {};
1276
+ return createComponent(originalTag, {
1277
+ ...existing,
1278
+ base,
1279
+ variants: { ...existing.variants ?? void 0, ...newConfig.variants ?? void 0 },
1280
+ compoundVariants: [
1281
+ ...existing.compoundVariants ?? [],
1282
+ ...newConfig.compoundVariants ?? []
1283
+ ],
1284
+ defaultVariants: {
1285
+ ...existing.defaultVariants ?? void 0,
1286
+ ...newConfig.defaultVariants ?? void 0
1287
+ }
1288
+ });
1289
+ };
1290
+ Component.animate = async (opts) => {
1291
+ try {
1292
+ const { animate: animateFn } = (init_src3(), __toCommonJS(src_exports));
1293
+ const animClass = await animateFn(opts);
1294
+ const merged = twMerge(base, animClass);
1295
+ return createComponent(
1296
+ originalTag,
1297
+ typeof config === "string" ? merged : { ...config, base: merged }
1298
+ );
1299
+ } catch {
1300
+ console.warn("[tailwind-styled-v4] .animate() requires @tailwind-styled/animate");
1301
+ return Component;
1302
+ }
1303
+ };
1304
+ }
1305
+ function cv(config) {
1306
+ const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
1307
+ return (props = {}) => {
1308
+ const classes = [base];
1309
+ for (const key in variants) {
1310
+ const val = props[key] ?? defaultVariants[key];
1311
+ if (val !== void 0 && variants[key][String(val)]) {
1312
+ classes.push(variants[key][String(val)]);
1313
+ }
1314
+ }
1315
+ for (const compound of compoundVariants) {
1316
+ const { class: cls, ...conditions } = compound;
1317
+ const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
1318
+ if (match) classes.push(cls);
1319
+ }
1320
+ if (props.className) classes.push(props.className);
1321
+ return twMerge(...classes);
1322
+ };
1323
+ }
1324
+ function cn(...inputs) {
1325
+ return inputs.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
1326
+ }
1327
+ function cx(...inputs) {
1328
+ return twMerge(...inputs.filter(Boolean));
1329
+ }
1330
+ var cxm = cx;
1331
+ function normalizeClassInput2(classLists) {
1332
+ return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
1333
+ }
1334
+ function createTwMerge(_options = {}) {
1335
+ return function twMerge5(...classLists) {
1336
+ const clean = normalizeClassInput2(classLists);
1337
+ return twMerge(clean.join(" "));
1338
+ };
1339
+ }
1340
+ var twMerge4 = createTwMerge();
1341
+ function mergeWithRules(rules, ...classLists) {
1342
+ const base = twMerge4(...classLists);
1343
+ let classes = base.split(/\s+/).filter(Boolean);
1344
+ for (const rule of Object.values(rules)) {
1345
+ const next = rule(classes);
1346
+ classes = twMerge4(next).split(/\s+/).filter(Boolean);
1347
+ }
1348
+ return classes.join(" ");
1349
+ }
1350
+
1351
+ // packages/core/src/liveTokenEngine.ts
1352
+ var _currentTokens = {};
1353
+ var _subscribers = /* @__PURE__ */ new Set();
1354
+ var _styleEl = null;
1355
+ if (typeof window !== "undefined") {
1356
+ window.__TW_TOKEN_ENGINE__ = {
1357
+ getTokens: () => _currentTokens,
1358
+ setToken: (name, value) => setToken(name, value),
1359
+ subscribe: (fn) => subscribeTokens(fn)
1360
+ };
1361
+ }
1362
+ function tokenVar(name) {
1363
+ const normalized = name.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
1364
+ return `--tw-token-${normalized}`;
1365
+ }
1366
+ function tokenRef(name) {
1367
+ return `var(${tokenVar(name)})`;
1368
+ }
1369
+ function buildRootCss(tokens) {
1370
+ const vars = Object.entries(tokens).map(([name, value]) => ` ${tokenVar(name)}: ${value};`).join("\n");
1371
+ return `:root {
1372
+ ${vars}
1373
+ }`;
1374
+ }
1375
+ function syncStyleEl() {
1376
+ if (typeof document === "undefined") return;
1377
+ if (!_styleEl) {
1378
+ _styleEl = document.createElement("style");
1379
+ _styleEl.id = "tw-live-tokens";
1380
+ _styleEl.setAttribute("data-tw-tokens", "true");
1381
+ document.head.appendChild(_styleEl);
1382
+ }
1383
+ _styleEl.textContent = buildRootCss(_currentTokens);
1384
+ }
1385
+ function notifySubscribers() {
1386
+ const snapshot = { ..._currentTokens };
1387
+ for (const sub of _subscribers) {
1388
+ try {
1389
+ sub(snapshot);
1390
+ } catch {
1391
+ }
1392
+ }
1393
+ }
1394
+ function liveToken(tokens) {
1395
+ _currentTokens = { ..._currentTokens, ...tokens };
1396
+ syncStyleEl();
1397
+ const vars = {};
1398
+ for (const name of Object.keys(tokens)) {
1399
+ vars[name] = tokenRef(name);
1400
+ }
1401
+ return {
1402
+ vars,
1403
+ get(name) {
1404
+ return _currentTokens[name];
1405
+ },
1406
+ set(name, value) {
1407
+ setToken(name, value);
1408
+ },
1409
+ setAll(newTokens) {
1410
+ setTokens(newTokens);
1411
+ },
1412
+ snapshot() {
1413
+ return { ..._currentTokens };
1414
+ }
1415
+ };
1416
+ }
1417
+ function setToken(name, value) {
1418
+ _currentTokens = { ..._currentTokens, [name]: value };
1419
+ if (typeof document !== "undefined") {
1420
+ document.documentElement.style.setProperty(tokenVar(name), value);
1421
+ }
1422
+ notifySubscribers();
1423
+ }
1424
+ function setTokens(tokens) {
1425
+ _currentTokens = { ..._currentTokens, ...tokens };
1426
+ if (typeof document !== "undefined") {
1427
+ const root = document.documentElement;
1428
+ for (const [name, value] of Object.entries(tokens)) {
1429
+ root.style.setProperty(tokenVar(name), value);
1430
+ }
1431
+ }
1432
+ notifySubscribers();
1433
+ }
1434
+ function applyTokenSet(tokens) {
1435
+ if (typeof document !== "undefined") {
1436
+ const root = document.documentElement;
1437
+ for (const name of Object.keys(_currentTokens)) {
1438
+ if (!(name in tokens)) {
1439
+ root.style.removeProperty(tokenVar(name));
1440
+ }
1441
+ }
1442
+ }
1443
+ _currentTokens = { ...tokens };
1444
+ syncStyleEl();
1445
+ notifySubscribers();
1446
+ }
1447
+ function getToken(name) {
1448
+ return _currentTokens[name];
1449
+ }
1450
+ function getTokens() {
1451
+ return { ..._currentTokens };
1452
+ }
1453
+ function subscribeTokens(fn) {
1454
+ _subscribers.add(fn);
1455
+ return () => {
1456
+ _subscribers.delete(fn);
1457
+ };
1458
+ }
1459
+ function generateTokenCssString() {
1460
+ return buildRootCss(_currentTokens);
1461
+ }
1462
+ function createUseTokens() {
1463
+ let useState, useEffect;
1464
+ try {
1465
+ const react = __require("react");
1466
+ useState = react.useState;
1467
+ useEffect = react.useEffect;
1468
+ } catch {
1469
+ return null;
1470
+ }
1471
+ return function useTokens() {
1472
+ const [tokens, setTokens_] = useState({
1473
+ ..._currentTokens
1474
+ });
1475
+ useEffect(() => {
1476
+ setTokens_({ ..._currentTokens });
1477
+ const unsub = subscribeTokens((t2) => setTokens_({ ...t2 }));
1478
+ return unsub;
1479
+ }, []);
1480
+ return tokens;
1481
+ };
1482
+ }
1483
+
1484
+ // packages/core/src/styledSystem.ts
1485
+ function tokenVarName(prefix, group, name) {
1486
+ return `--${prefix}-${group}-${name}`;
1487
+ }
1488
+ function tokenVarRef(prefix, group, name) {
1489
+ return `var(${tokenVarName(prefix, group, name)})`;
1490
+ }
1491
+ function resolveTokenRef(tokens, prefix, value) {
1492
+ if (value.startsWith("token:")) {
1493
+ const path2 = value.slice(6);
1494
+ const [group, name] = path2.split(".");
1495
+ if (group && name && tokens[group]?.[name] !== void 0) {
1496
+ return tokenVarRef(prefix, group, name);
1497
+ }
1498
+ }
1499
+ return value;
1500
+ }
1501
+ function injectTokensToRoot(tokens, prefix) {
1502
+ if (typeof document === "undefined") return;
1503
+ const styleId = `__tw-sys-tokens-${prefix}`;
1504
+ if (document.getElementById(styleId)) return;
1505
+ const lines = [":root {"];
1506
+ for (const [group, map] of Object.entries(tokens)) {
1507
+ for (const [name, value] of Object.entries(map)) {
1508
+ lines.push(` ${tokenVarName(prefix, group, name)}: ${value};`);
1509
+ }
1510
+ }
1511
+ lines.push("}");
1512
+ const style = document.createElement("style");
1513
+ style.id = styleId;
1514
+ style.textContent = lines.join("\n");
1515
+ document.head.appendChild(style);
1516
+ }
1517
+ function resolveComponentConfig(config, tokens, prefix) {
1518
+ const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);
1519
+ const base = resolveStr(config.base ?? "");
1520
+ const systemBase = resolveStr(config.systemBase ?? "");
1521
+ const mergedBase = [systemBase, base].filter(Boolean).join(" ");
1522
+ const variants = {};
1523
+ for (const [variantKey, variantMap] of Object.entries(config.variants ?? {})) {
1524
+ variants[variantKey] = {};
1525
+ for (const [optKey, classes] of Object.entries(variantMap)) {
1526
+ variants[variantKey][optKey] = classes.split(" ").map(resolveStr).join(" ");
1527
+ }
1528
+ }
1529
+ const compoundVariants = (config.compoundVariants ?? []).map((cv2) => {
1530
+ const { class: cls, ...rest } = cv2;
1531
+ return { class: resolveStr(cls), ...rest };
1532
+ });
1533
+ return {
1534
+ base: mergedBase,
1535
+ variants,
1536
+ compoundVariants,
1537
+ defaultVariants: config.defaultVariants ?? {},
1538
+ state: config.state,
1539
+ container: config.container,
1540
+ containerName: config.containerName
1541
+ };
1542
+ }
1543
+ function createStyledSystem(config) {
1544
+ const prefix = config.prefix ?? "sys";
1545
+ const tokens = config.tokens ?? {};
1546
+ const componentDefs = config.components ?? {};
1547
+ const shouldInject = config.injectTokens !== false;
1548
+ if (shouldInject && typeof window !== "undefined") {
1549
+ injectTokensToRoot(tokens, prefix);
1550
+ }
1551
+ const resolvedConfigs = /* @__PURE__ */ new Map();
1552
+ for (const [name, compCfg] of Object.entries(componentDefs)) {
1553
+ resolvedConfigs.set(
1554
+ name,
1555
+ resolveComponentConfig(compCfg, tokens, prefix)
1556
+ );
1557
+ }
1558
+ const factories = {};
1559
+ for (const [name, compCfg] of Object.entries(componentDefs)) {
1560
+ const tag = compCfg.tag ?? "div";
1561
+ factories[name] = (overrides) => {
1562
+ const baseResolved = resolvedConfigs.get(name);
1563
+ if (!overrides || Object.keys(overrides).length === 0) {
1564
+ return createComponent(tag, baseResolved);
1565
+ }
1566
+ const overrideResolved = resolveComponentConfig(
1567
+ overrides,
1568
+ tokens,
1569
+ prefix
1570
+ );
1571
+ const merged = {
1572
+ base: [baseResolved.base, overrideResolved.base].filter(Boolean).join(" "),
1573
+ variants: {
1574
+ ...baseResolved.variants ?? void 0,
1575
+ ...overrideResolved.variants ?? void 0
1576
+ },
1577
+ compoundVariants: [
1578
+ ...baseResolved.compoundVariants ?? [],
1579
+ ...overrideResolved.compoundVariants ?? []
1580
+ ],
1581
+ defaultVariants: {
1582
+ ...baseResolved.defaultVariants ?? void 0,
1583
+ ...overrideResolved.defaultVariants ?? void 0
1584
+ },
1585
+ state: overrideResolved.state ?? baseResolved.state,
1586
+ container: overrideResolved.container ?? baseResolved.container,
1587
+ containerName: overrideResolved.containerName ?? baseResolved.containerName
1588
+ };
1589
+ return createComponent(tag, merged);
1590
+ };
1591
+ }
1592
+ function token(path2) {
1593
+ const [group, name] = path2.split(".");
1594
+ if (!group || !name) return path2;
1595
+ return tokenVarRef(prefix, group, name);
1596
+ }
1597
+ function rawToken(path2) {
1598
+ const [group, name] = path2.split(".");
1599
+ if (!group || !name) return void 0;
1600
+ return tokens[group]?.[name];
1601
+ }
1602
+ function setTokens2(updates) {
1603
+ if (typeof document === "undefined") return;
1604
+ const styleId = `__tw-sys-tokens-${prefix}`;
1605
+ let style = document.getElementById(styleId);
1606
+ if (!style) {
1607
+ style = document.createElement("style");
1608
+ style.id = styleId;
1609
+ document.head.appendChild(style);
1610
+ }
1611
+ for (const [group, map] of Object.entries(updates)) {
1612
+ if (!tokens[group]) continue;
1613
+ for (const [name, value] of Object.entries(map)) {
1614
+ tokens[group][name] = value;
1615
+ }
1616
+ }
1617
+ const lines = [":root {"];
1618
+ for (const [group, map] of Object.entries(tokens)) {
1619
+ for (const [name, value] of Object.entries(map)) {
1620
+ lines.push(` ${tokenVarName(prefix, group, name)}: ${value};`);
1621
+ }
1622
+ }
1623
+ lines.push("}");
1624
+ style.textContent = lines.join("\n");
1625
+ }
1626
+ function getConfig(name) {
1627
+ return resolvedConfigs.get(name);
1628
+ }
1629
+ return Object.assign(factories, {
1630
+ token,
1631
+ rawToken,
1632
+ setTokens: setTokens2,
1633
+ getConfig,
1634
+ tokens
1635
+ });
1636
+ }
1637
+
1638
+ // packages/core/src/styled.ts
1639
+ function resolveVariantClass(options, props) {
1640
+ const out = [];
1641
+ const variants = options.variants ?? {};
1642
+ const defaults = options.defaultVariants ?? {};
1643
+ for (const [variantName, valueMap] of Object.entries(variants)) {
1644
+ const value = props[variantName] ?? defaults[variantName];
1645
+ if (value === void 0) continue;
1646
+ const key = String(value);
1647
+ const cls = valueMap[key];
1648
+ if (cls) out.push(cls);
1649
+ }
1650
+ for (const compound of options.compoundVariants ?? []) {
1651
+ const matches = Object.entries(compound.variants).every(([k, expected]) => {
1652
+ const current = props[k] ?? defaults[k];
1653
+ return String(current) === expected;
1654
+ });
1655
+ if (matches) out.push(compound.className);
1656
+ }
1657
+ return out;
1658
+ }
1659
+ function resolveStyledClassName(options, props = {}) {
1660
+ const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
1661
+ return twMerge4(...parts);
1662
+ }
1663
+ function styled(options) {
1664
+ return function getClassName(props = {}) {
1665
+ return resolveStyledClassName(options, props);
1666
+ };
1667
+ }
1668
+
1669
+ // packages/core/src/twProxy.ts
1670
+ function parseTemplate(strings, exprs) {
1671
+ return strings.raw.reduce((acc, str, i) => {
1672
+ const expr = exprs[i];
1673
+ const exprStr = typeof expr === "function" ? "" : expr ?? "";
1674
+ return acc + str + String(exprStr);
1675
+ }, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
1676
+ }
1677
+ function makeTag(tag) {
1678
+ return ((stringsOrConfig, ...exprs) => {
1679
+ if (!Array.isArray(stringsOrConfig) && typeof stringsOrConfig === "object" && stringsOrConfig !== null && !("raw" in stringsOrConfig)) {
1680
+ return createComponent(tag, stringsOrConfig);
1681
+ }
1682
+ const classes = parseTemplate(stringsOrConfig, exprs);
1683
+ return createComponent(tag, classes);
1684
+ });
1685
+ }
1686
+ var HTML_TAGS = [
1687
+ "div",
1688
+ "section",
1689
+ "article",
1690
+ "aside",
1691
+ "header",
1692
+ "footer",
1693
+ "main",
1694
+ "nav",
1695
+ "figure",
1696
+ "figcaption",
1697
+ "details",
1698
+ "summary",
1699
+ "h1",
1700
+ "h2",
1701
+ "h3",
1702
+ "h4",
1703
+ "h5",
1704
+ "h6",
1705
+ "p",
1706
+ "span",
1707
+ "strong",
1708
+ "em",
1709
+ "b",
1710
+ "i",
1711
+ "s",
1712
+ "u",
1713
+ "small",
1714
+ "mark",
1715
+ "abbr",
1716
+ "cite",
1717
+ "code",
1718
+ "kbd",
1719
+ "samp",
1720
+ "var",
1721
+ "time",
1722
+ "address",
1723
+ "blockquote",
1724
+ "q",
1725
+ "del",
1726
+ "ins",
1727
+ "sub",
1728
+ "sup",
1729
+ "ul",
1730
+ "ol",
1731
+ "li",
1732
+ "dl",
1733
+ "dt",
1734
+ "dd",
1735
+ "table",
1736
+ "thead",
1737
+ "tbody",
1738
+ "tfoot",
1739
+ "tr",
1740
+ "th",
1741
+ "td",
1742
+ "caption",
1743
+ "colgroup",
1744
+ "col",
1745
+ "img",
1746
+ "picture",
1747
+ "video",
1748
+ "audio",
1749
+ "source",
1750
+ "track",
1751
+ "canvas",
1752
+ "svg",
1753
+ "path",
1754
+ "circle",
1755
+ "rect",
1756
+ "line",
1757
+ "polyline",
1758
+ "polygon",
1759
+ "g",
1760
+ "defs",
1761
+ "use",
1762
+ "symbol",
1763
+ "form",
1764
+ "input",
1765
+ "textarea",
1766
+ "select",
1767
+ "option",
1768
+ "optgroup",
1769
+ "button",
1770
+ "label",
1771
+ "fieldset",
1772
+ "legend",
1773
+ "output",
1774
+ "progress",
1775
+ "meter",
1776
+ "datalist",
1777
+ "a",
1778
+ "area",
1779
+ "map",
1780
+ "iframe",
1781
+ "embed",
1782
+ "object",
1783
+ "pre",
1784
+ "hr",
1785
+ "br",
1786
+ "wbr",
1787
+ "dialog",
1788
+ "menu",
1789
+ "template",
1790
+ "slot"
1791
+ ];
1792
+ function makeServerTag(tag) {
1793
+ const baseFactory = makeTag(tag);
1794
+ if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
1795
+ return ((...args) => {
1796
+ const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
1797
+ console.warn(
1798
+ `[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
1799
+ );
1800
+ return baseFactory(...args);
1801
+ });
1802
+ }
1803
+ return baseFactory;
1804
+ }
1805
+ var serverFactories = {};
1806
+ for (const tag of HTML_TAGS) {
1807
+ serverFactories[tag] = makeServerTag(tag);
1808
+ }
1809
+ var server = serverFactories;
1810
+ var tagFactories = {};
1811
+ for (const tag of HTML_TAGS) {
1812
+ tagFactories[tag] = makeTag(tag);
1813
+ }
1814
+ function twCallable(component) {
1815
+ return makeTag(component);
1816
+ }
1817
+ var tw = Object.assign(twCallable, tagFactories, {
1818
+ server
1819
+ });
1820
+
1821
+ // packages/core/src/twTheme.ts
1822
+ function cssVar(varName, fallback) {
1823
+ const name = varName.startsWith("--") ? varName : `--${varName}`;
1824
+ return fallback ? `var(${name}, ${fallback})` : `var(${name})`;
1825
+ }
1826
+ function twVar(property, varName, fallback) {
1827
+ const ref = fallback ? `var(--${varName},${fallback})` : `var(--${varName})`;
1828
+ return `${property}-[${ref}]`;
1829
+ }
1830
+ var t = {
1831
+ /** Background color from CSS variable: t.bg("color-primary") → "bg-[var(--color-primary)]" */
1832
+ bg: (v, fb) => twVar("bg", v, fb),
1833
+ /** Text color from CSS variable */
1834
+ text: (v, fb) => twVar("text", v, fb),
1835
+ /** Border color from CSS variable */
1836
+ border: (v, fb) => twVar("border", v, fb),
1837
+ /** Ring color from CSS variable */
1838
+ ring: (v, fb) => twVar("ring", v, fb),
1839
+ /** Outline color from CSS variable */
1840
+ outline: (v, fb) => twVar("outline", v, fb),
1841
+ /** Fill color from CSS variable (SVG) */
1842
+ fill: (v, fb) => twVar("fill", v, fb),
1843
+ /** Stroke color from CSS variable (SVG) */
1844
+ stroke: (v, fb) => twVar("stroke", v, fb),
1845
+ /** Font family from CSS variable */
1846
+ font: (v, fb) => twVar("font", v, fb),
1847
+ /** Shadow from CSS variable */
1848
+ shadow: (v, fb) => twVar("shadow", v, fb),
1849
+ /** Any arbitrary property from CSS variable */
1850
+ var: (property, v, fb) => twVar(property, v, fb)
1851
+ };
1852
+ function createTheme(tokenMap) {
1853
+ const resolved = {};
1854
+ for (const group in tokenMap) {
1855
+ resolved[group] = {};
1856
+ const tokens = tokenMap[group];
1857
+ for (const name in tokens) {
1858
+ const varName = tokens[name];
1859
+ const prefix = getGroupPrefix(group);
1860
+ resolved[group][name] = prefix ? twVar(prefix, varName) : cssVar(varName);
1861
+ }
1862
+ }
1863
+ return resolved;
1864
+ }
1865
+ function getGroupPrefix(group) {
1866
+ const map = {
1867
+ colors: "bg",
1868
+ // default to bg; user can use t.text() for text colors
1869
+ fonts: "font",
1870
+ spacing: "p",
1871
+ shadows: "shadow"
1872
+ };
1873
+ return map[group] ?? "";
1874
+ }
1875
+ var v4Tokens = {
1876
+ /** bg-[var(--color-background)] */
1877
+ bg: twVar("bg", "color-background"),
1878
+ /** text-[var(--color-foreground)] */
1879
+ text: twVar("text", "color-foreground"),
1880
+ /** font-[var(--font-sans)] */
1881
+ fontSans: twVar("font", "font-sans"),
1882
+ /** font-[var(--font-mono)] */
1883
+ fontMono: twVar("font", "font-mono")
1884
+ };
1885
+
1886
+ // packages/core/src/parser.ts
1887
+ var _getNodePath = () => typeof __require !== "undefined" ? __require("path") : null;
1888
+ var _getCreateRequire = () => {
1889
+ if (typeof __require !== "undefined") {
1890
+ try {
1891
+ return __require("module").createRequire;
1892
+ } catch {
1893
+ return null;
1894
+ }
1895
+ }
1896
+ return null;
1897
+ };
1898
+ var _binding;
1899
+ function getBinding() {
1900
+ if (_binding !== void 0) return _binding;
1901
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
1902
+ return _binding = null;
1903
+ }
1904
+ if (typeof process === "undefined" || typeof process.cwd !== "function") {
1905
+ return _binding = null;
1906
+ }
1907
+ const runtimeDir = typeof __dirname === "string" ? __dirname : process.cwd();
1908
+ const nodePath = _getNodePath();
1909
+ const nodeCreateRequire = _getCreateRequire();
1910
+ if (!nodePath) return _binding = null;
1911
+ const req = typeof __require === "function" ? __require : nodeCreateRequire ? nodeCreateRequire(nodePath.join(runtimeDir, "noop.cjs")) : null;
1912
+ if (!req) return _binding = null;
1913
+ const candidates = [
1914
+ nodePath.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
1915
+ nodePath.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
1916
+ nodePath.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node")
1917
+ ];
1918
+ for (const c of candidates) {
1919
+ try {
1920
+ const mod = req(c);
1921
+ if (mod?.parseClasses) return _binding = mod;
1922
+ } catch {
1923
+ }
1924
+ }
1925
+ return _binding = null;
1926
+ }
1927
+ function splitClassListJS(input) {
1928
+ const out = [];
1929
+ let token = "";
1930
+ let square = 0;
1931
+ let round = 0;
1932
+ let escaped = false;
1933
+ for (const ch of input) {
1934
+ if (escaped) {
1935
+ token += ch;
1936
+ escaped = false;
1937
+ continue;
1938
+ }
1939
+ if (ch === "\\") {
1940
+ token += ch;
1941
+ escaped = true;
1942
+ continue;
1943
+ }
1944
+ if (ch === "[") square++;
1945
+ else if (ch === "]") square = Math.max(0, square - 1);
1946
+ else if (ch === "(") round++;
1947
+ else if (ch === ")") round = Math.max(0, round - 1);
1948
+ const isSpace = /\s/.test(ch);
1949
+ if (isSpace && square === 0 && round === 0) {
1950
+ if (token.trim().length > 0) out.push(token.trim());
1951
+ token = "";
1952
+ continue;
1953
+ }
1954
+ token += ch;
1955
+ }
1956
+ if (token.trim().length > 0) out.push(token.trim());
1957
+ return out;
1958
+ }
1959
+ function parseClassTokenJS(rawToken) {
1960
+ const parts = [];
1961
+ let current = "";
1962
+ let square = 0;
1963
+ let round = 0;
1964
+ let escaped = false;
1965
+ for (const ch of rawToken) {
1966
+ if (escaped) {
1967
+ current += ch;
1968
+ escaped = false;
1969
+ continue;
1970
+ }
1971
+ if (ch === "\\") {
1972
+ current += ch;
1973
+ escaped = true;
1974
+ continue;
1975
+ }
1976
+ if (ch === "[") square++;
1977
+ else if (ch === "]") square = Math.max(0, square - 1);
1978
+ else if (ch === "(") round++;
1979
+ else if (ch === ")") round = Math.max(0, round - 1);
1980
+ if (ch === ":" && square === 0 && round === 0) {
1981
+ parts.push(current);
1982
+ current = "";
1983
+ continue;
1984
+ }
1985
+ current += ch;
1986
+ }
1987
+ parts.push(current);
1988
+ const variants = parts.slice(0, -1).filter(Boolean);
1989
+ const baseToken = parts[parts.length - 1] ?? "";
1990
+ const parsed = { raw: rawToken, base: baseToken, variants };
1991
+ const opacityMatch = baseToken.match(/^(.*)\/(\d{1,3})$/);
1992
+ if (opacityMatch && opacityMatch[1].length > 0) {
1993
+ parsed.base = opacityMatch[1];
1994
+ parsed.modifier = { type: "opacity", value: opacityMatch[2] };
1995
+ return parsed;
1996
+ }
1997
+ const arbitraryMatch = baseToken.match(/\((--[a-zA-Z0-9_-]+)\)/);
1998
+ if (arbitraryMatch) {
1999
+ parsed.modifier = { type: "arbitrary", value: arbitraryMatch[1] };
2000
+ }
2001
+ return parsed;
2002
+ }
2003
+ function splitClassList(input) {
2004
+ const binding = getBinding();
2005
+ if (binding?.parseClasses) {
2006
+ try {
2007
+ return binding.parseClasses(input).map((p) => p.raw);
2008
+ } catch {
2009
+ }
2010
+ }
2011
+ return splitClassListJS(input);
2012
+ }
2013
+ function parseClassToken(rawToken) {
2014
+ const binding = getBinding();
2015
+ if (binding?.parseClasses) {
2016
+ try {
2017
+ const results = binding.parseClasses(rawToken);
2018
+ if (results.length === 1) {
2019
+ const r = results[0];
2020
+ const parsed = {
2021
+ raw: r.raw,
2022
+ base: r.base,
2023
+ variants: r.variants
2024
+ };
2025
+ if (r.modifierType && r.modifierValue) {
2026
+ parsed.modifier = {
2027
+ type: r.modifierType,
2028
+ value: r.modifierValue
2029
+ };
2030
+ }
2031
+ return parsed;
2032
+ }
2033
+ } catch {
2034
+ }
2035
+ }
2036
+ return parseClassTokenJS(rawToken);
2037
+ }
2038
+ function parseTailwindClasses(input) {
2039
+ const binding = getBinding();
2040
+ if (binding?.parseClasses) {
2041
+ try {
2042
+ return binding.parseClasses(input).map((r) => {
2043
+ const parsed = { raw: r.raw, base: r.base, variants: r.variants };
2044
+ if (r.modifierType && r.modifierValue) {
2045
+ parsed.modifier = {
2046
+ type: r.modifierType,
2047
+ value: r.modifierValue
2048
+ };
2049
+ }
2050
+ return parsed;
2051
+ });
2052
+ } catch {
2053
+ }
2054
+ }
2055
+ return splitClassListJS(input).map(parseClassTokenJS);
2056
+ }
2057
+
2058
+ // packages/core/src/themeReader.ts
2059
+ var THEME_BLOCK_RE = /@theme\s*\{([\s\S]*?)\}/g;
2060
+ var CSS_VAR_RE = /--([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/g;
2061
+ var cache = /* @__PURE__ */ new Map();
2062
+ function createEmptyTheme() {
2063
+ return {
2064
+ colors: {},
2065
+ spacing: {},
2066
+ fonts: {},
2067
+ breakpoints: {},
2068
+ animations: {},
2069
+ raw: {}
2070
+ };
2071
+ }
2072
+ function setToken2(theme, key, value) {
2073
+ theme.raw[key] = value;
2074
+ if (key.startsWith("color-")) {
2075
+ theme.colors[key.slice("color-".length)] = value;
2076
+ return;
2077
+ }
2078
+ if (key.startsWith("spacing-")) {
2079
+ theme.spacing[key.slice("spacing-".length)] = value;
2080
+ return;
2081
+ }
2082
+ if (key.startsWith("font-")) {
2083
+ theme.fonts[key.slice("font-".length)] = value;
2084
+ return;
2085
+ }
2086
+ if (key.startsWith("breakpoint-")) {
2087
+ theme.breakpoints[key.slice("breakpoint-".length)] = value;
2088
+ return;
2089
+ }
2090
+ if (key.startsWith("animate-")) {
2091
+ theme.animations[key.slice("animate-".length)] = value;
2092
+ }
2093
+ }
2094
+ function resolveThemeValue(key, theme, visited = /* @__PURE__ */ new Set()) {
2095
+ const token = key.replace(/^--/, "");
2096
+ const raw = theme.raw[token];
2097
+ if (!raw) return "";
2098
+ if (visited.has(token)) return raw;
2099
+ const nested = raw.match(/^var\((--[a-zA-Z0-9_-]+)\)$/);
2100
+ if (!nested) return raw;
2101
+ visited.add(token);
2102
+ return resolveThemeValue(nested[1], theme, visited);
2103
+ }
2104
+ function extractThemeFromCSS(cssContent) {
2105
+ const hit = cache.get(cssContent);
2106
+ if (hit) return hit;
2107
+ const theme = createEmptyTheme();
2108
+ let blockMatch;
2109
+ while ((blockMatch = THEME_BLOCK_RE.exec(cssContent)) !== null) {
2110
+ const block = blockMatch[1];
2111
+ let varMatch;
2112
+ while ((varMatch = CSS_VAR_RE.exec(block)) !== null) {
2113
+ const key = varMatch[1];
2114
+ const value = varMatch[2].trim();
2115
+ setToken2(theme, key, value);
2116
+ }
2117
+ }
2118
+ for (const key of Object.keys(theme.raw)) {
2119
+ const resolved = resolveThemeValue(`--${key}`, theme);
2120
+ theme.raw[key] = resolved;
2121
+ if (key.startsWith("color-")) {
2122
+ theme.colors[key.slice("color-".length)] = resolved;
2123
+ } else if (key.startsWith("spacing-")) {
2124
+ theme.spacing[key.slice("spacing-".length)] = resolved;
2125
+ } else if (key.startsWith("font-")) {
2126
+ theme.fonts[key.slice("font-".length)] = resolved;
2127
+ } else if (key.startsWith("breakpoint-")) {
2128
+ theme.breakpoints[key.slice("breakpoint-".length)] = resolved;
2129
+ } else if (key.startsWith("animate-")) {
2130
+ theme.animations[key.slice("animate-".length)] = resolved;
2131
+ }
2132
+ }
2133
+ cache.set(cssContent, theme);
2134
+ return theme;
2135
+ }
2136
+ function generateTypeDefinitions(theme) {
2137
+ const toRecordType = (name, obj) => {
2138
+ const keys = Object.keys(obj);
2139
+ if (keys.length === 0) return ` ${name}: Record<string, string>`;
2140
+ const mapped = keys.map((k) => ` "${k}": string`).join("\n");
2141
+ return ` ${name}: {
2142
+ ${mapped}
2143
+ }`;
2144
+ };
2145
+ return [
2146
+ "export interface TailwindStyledThemeTokens {",
2147
+ toRecordType("colors", theme.colors),
2148
+ toRecordType("spacing", theme.spacing),
2149
+ toRecordType("fonts", theme.fonts),
2150
+ toRecordType("breakpoints", theme.breakpoints),
2151
+ toRecordType("animations", theme.animations),
2152
+ "}",
2153
+ ""
2154
+ ].join("\n");
2155
+ }
2156
+ function clearThemeReaderCache() {
2157
+ cache.clear();
2158
+ }
2159
+
2160
+ export { applyTokenSet, clearThemeReaderCache, cn, tokenRef as containerRef, createComponent, createStyledSystem, createTheme, createTwMerge, createUseTokens, cssVar, cv, cx, cxm, extractThemeFromCSS, generateContainerCss, generateStateCss, generateTokenCssString, generateTypeDefinitions, getContainerRegistry, getStateRegistry, getToken, getTokens, liveToken, mergeWithRules, parseClassToken, parseTailwindClasses, processContainer, processState, resolveStyledClassName, resolveThemeValue, server, setToken, setTokens, splitClassList, styled, subscribeTokens, t, tokenRef, tokenVar, tw, twMerge4 as twMerge, twVar, v4Tokens };
2161
+ //# sourceMappingURL=index.mjs.map
2162
+ //# sourceMappingURL=index.mjs.map