tailwind-styled-v4 1.0.0 → 4.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 (89) hide show
  1. package/dist/animate.cjs +252 -0
  2. package/dist/animate.cjs.map +1 -0
  3. package/dist/animate.d.cts +117 -0
  4. package/dist/animate.d.ts +117 -0
  5. package/dist/animate.js +245 -0
  6. package/dist/animate.js.map +1 -0
  7. package/dist/astTransform-ua-eapqs.d.cts +41 -0
  8. package/dist/astTransform-ua-eapqs.d.ts +41 -0
  9. package/dist/compiler.cjs +3594 -0
  10. package/dist/compiler.cjs.map +1 -0
  11. package/dist/compiler.d.cts +716 -0
  12. package/dist/compiler.d.ts +716 -0
  13. package/dist/compiler.js +3535 -0
  14. package/dist/compiler.js.map +1 -0
  15. package/dist/css.cjs +71 -0
  16. package/dist/css.cjs.map +1 -0
  17. package/dist/css.d.cts +45 -0
  18. package/dist/css.d.ts +45 -0
  19. package/dist/css.js +62 -0
  20. package/dist/css.js.map +1 -0
  21. package/dist/devtools.cjs +959 -0
  22. package/dist/devtools.cjs.map +1 -0
  23. package/dist/devtools.d.cts +22 -0
  24. package/dist/devtools.d.ts +22 -0
  25. package/dist/devtools.js +952 -0
  26. package/dist/devtools.js.map +1 -0
  27. package/dist/index.cjs +1058 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +584 -0
  30. package/dist/index.d.ts +456 -958
  31. package/dist/index.js +1021 -8
  32. package/dist/index.js.map +1 -1
  33. package/dist/next.cjs +268 -0
  34. package/dist/next.cjs.map +1 -0
  35. package/dist/next.d.cts +45 -0
  36. package/dist/next.d.ts +45 -0
  37. package/dist/next.js +261 -0
  38. package/dist/next.js.map +1 -0
  39. package/dist/plugins.cjs +396 -0
  40. package/dist/plugins.cjs.map +1 -0
  41. package/dist/plugins.d.cts +231 -0
  42. package/dist/plugins.d.ts +231 -0
  43. package/dist/plugins.js +381 -0
  44. package/dist/plugins.js.map +1 -0
  45. package/dist/preset.cjs +129 -0
  46. package/dist/preset.cjs.map +1 -0
  47. package/dist/preset.d.cts +249 -0
  48. package/dist/preset.d.ts +249 -0
  49. package/dist/preset.js +124 -0
  50. package/dist/preset.js.map +1 -0
  51. package/dist/theme.cjs +154 -0
  52. package/dist/theme.cjs.map +1 -0
  53. package/dist/theme.d.cts +181 -0
  54. package/dist/theme.d.ts +181 -0
  55. package/dist/theme.js +148 -0
  56. package/dist/theme.js.map +1 -0
  57. package/dist/turbopackLoader.cjs +2689 -0
  58. package/dist/turbopackLoader.cjs.map +1 -0
  59. package/dist/turbopackLoader.d.cts +22 -0
  60. package/dist/turbopackLoader.d.ts +22 -0
  61. package/dist/turbopackLoader.js +2681 -0
  62. package/dist/turbopackLoader.js.map +1 -0
  63. package/dist/vite.cjs +105 -0
  64. package/dist/vite.cjs.map +1 -0
  65. package/dist/vite.d.cts +22 -0
  66. package/dist/vite.d.ts +22 -0
  67. package/dist/vite.js +96 -0
  68. package/dist/vite.js.map +1 -0
  69. package/dist/webpackLoader.cjs +2670 -0
  70. package/dist/webpackLoader.cjs.map +1 -0
  71. package/dist/webpackLoader.d.cts +24 -0
  72. package/dist/webpackLoader.d.ts +24 -0
  73. package/dist/webpackLoader.js +2662 -0
  74. package/dist/webpackLoader.js.map +1 -0
  75. package/package.json +66 -90
  76. package/CHANGELOG.md +0 -75
  77. package/LICENSE +0 -21
  78. package/README.md +0 -330
  79. package/dist/compiler/index.d.mts +0 -214
  80. package/dist/compiler/index.d.ts +0 -214
  81. package/dist/compiler/index.js +0 -546
  82. package/dist/compiler/index.js.map +0 -1
  83. package/dist/compiler/index.mjs +0 -504
  84. package/dist/compiler/index.mjs.map +0 -1
  85. package/dist/index.d.mts +0 -1086
  86. package/dist/index.mjs +0 -9
  87. package/dist/index.mjs.map +0 -1
  88. package/dist/turbopack-loader.js +0 -232
  89. package/dist/webpack-loader.js +0 -213
@@ -0,0 +1,3594 @@
1
+ 'use strict';
2
+
3
+ var module$1 = require('module');
4
+ var tailwindMerge = require('tailwind-merge');
5
+ var fs2 = require('fs');
6
+ var path4 = require('path');
7
+ var crypto = require('crypto');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var fs2__default = /*#__PURE__*/_interopDefault(fs2);
12
+ var path4__default = /*#__PURE__*/_interopDefault(path4);
13
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
14
+
15
+ /* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
16
+ var __defProp = Object.defineProperty;
17
+ var __defProps = Object.defineProperties;
18
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
20
+ var __getOwnPropNames = Object.getOwnPropertyNames;
21
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
22
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
23
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
24
+ var __typeError = (msg) => {
25
+ throw TypeError(msg);
26
+ };
27
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
28
+ var __spreadValues = (a, b) => {
29
+ for (var prop in b || (b = {}))
30
+ if (__hasOwnProp.call(b, prop))
31
+ __defNormalProp(a, prop, b[prop]);
32
+ if (__getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(b)) {
34
+ if (__propIsEnum.call(b, prop))
35
+ __defNormalProp(a, prop, b[prop]);
36
+ }
37
+ return a;
38
+ };
39
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
40
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
41
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
42
+ }) : x)(function(x) {
43
+ if (typeof require !== "undefined") return require.apply(this, arguments);
44
+ throw Error('Dynamic require of "' + x + '" is not supported');
45
+ });
46
+ var __esm = (fn, res) => function __init() {
47
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
48
+ };
49
+ var __export = (target, all) => {
50
+ for (var name in all)
51
+ __defProp(target, name, { get: all[name], enumerable: true });
52
+ };
53
+ var __copyProps = (to, from, except, desc) => {
54
+ if (from && typeof from === "object" || typeof from === "function") {
55
+ for (let key of __getOwnPropNames(from))
56
+ if (!__hasOwnProp.call(to, key) && key !== except)
57
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
58
+ }
59
+ return to;
60
+ };
61
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
62
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
63
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), member.get(obj));
64
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
65
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
66
+ function requireNative() {
67
+ var _a2, _b2, _c, _d;
68
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
69
+ try {
70
+ return require2(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
71
+ } catch (err) {
72
+ loadErrors.push(err);
73
+ }
74
+ } else if (process.platform === "android") {
75
+ if (process.arch === "arm64") {
76
+ try {
77
+ return require2("./parser.android-arm64.node");
78
+ } catch (e) {
79
+ loadErrors.push(e);
80
+ }
81
+ try {
82
+ const binding = require2("@oxc-parser/binding-android-arm64");
83
+ const bindingPackageVersion = require2("@oxc-parser/binding-android-arm64/package.json").version;
84
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
85
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
86
+ }
87
+ return binding;
88
+ } catch (e) {
89
+ loadErrors.push(e);
90
+ }
91
+ } else if (process.arch === "arm") {
92
+ try {
93
+ return require2("./parser.android-arm-eabi.node");
94
+ } catch (e) {
95
+ loadErrors.push(e);
96
+ }
97
+ try {
98
+ const binding = require2("@oxc-parser/binding-android-arm-eabi");
99
+ const bindingPackageVersion = require2("@oxc-parser/binding-android-arm-eabi/package.json").version;
100
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
101
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
102
+ }
103
+ return binding;
104
+ } catch (e) {
105
+ loadErrors.push(e);
106
+ }
107
+ } else {
108
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
109
+ }
110
+ } else if (process.platform === "win32") {
111
+ if (process.arch === "x64") {
112
+ if (((_b2 = (_a2 = process.config) == null ? void 0 : _a2.variables) == null ? void 0 : _b2.shlib_suffix) === "dll.a" || ((_d = (_c = process.config) == null ? void 0 : _c.variables) == null ? void 0 : _d.node_target_type) === "shared_library") {
113
+ try {
114
+ return require2("./parser.win32-x64-gnu.node");
115
+ } catch (e) {
116
+ loadErrors.push(e);
117
+ }
118
+ try {
119
+ const binding = require2("@oxc-parser/binding-win32-x64-gnu");
120
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-gnu/package.json").version;
121
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
122
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
123
+ }
124
+ return binding;
125
+ } catch (e) {
126
+ loadErrors.push(e);
127
+ }
128
+ } else {
129
+ try {
130
+ return require2("./parser.win32-x64-msvc.node");
131
+ } catch (e) {
132
+ loadErrors.push(e);
133
+ }
134
+ try {
135
+ const binding = require2("@oxc-parser/binding-win32-x64-msvc");
136
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-msvc/package.json").version;
137
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
138
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
139
+ }
140
+ return binding;
141
+ } catch (e) {
142
+ loadErrors.push(e);
143
+ }
144
+ }
145
+ } else if (process.arch === "ia32") {
146
+ try {
147
+ return require2("./parser.win32-ia32-msvc.node");
148
+ } catch (e) {
149
+ loadErrors.push(e);
150
+ }
151
+ try {
152
+ const binding = require2("@oxc-parser/binding-win32-ia32-msvc");
153
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-ia32-msvc/package.json").version;
154
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
155
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
156
+ }
157
+ return binding;
158
+ } catch (e) {
159
+ loadErrors.push(e);
160
+ }
161
+ } else if (process.arch === "arm64") {
162
+ try {
163
+ return require2("./parser.win32-arm64-msvc.node");
164
+ } catch (e) {
165
+ loadErrors.push(e);
166
+ }
167
+ try {
168
+ const binding = require2("@oxc-parser/binding-win32-arm64-msvc");
169
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-arm64-msvc/package.json").version;
170
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
171
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
172
+ }
173
+ return binding;
174
+ } catch (e) {
175
+ loadErrors.push(e);
176
+ }
177
+ } else {
178
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
179
+ }
180
+ } else if (process.platform === "darwin") {
181
+ try {
182
+ return require2("./parser.darwin-universal.node");
183
+ } catch (e) {
184
+ loadErrors.push(e);
185
+ }
186
+ try {
187
+ const binding = require2("@oxc-parser/binding-darwin-universal");
188
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-universal/package.json").version;
189
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
190
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
191
+ }
192
+ return binding;
193
+ } catch (e) {
194
+ loadErrors.push(e);
195
+ }
196
+ if (process.arch === "x64") {
197
+ try {
198
+ return require2("./parser.darwin-x64.node");
199
+ } catch (e) {
200
+ loadErrors.push(e);
201
+ }
202
+ try {
203
+ const binding = require2("@oxc-parser/binding-darwin-x64");
204
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-x64/package.json").version;
205
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
206
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
207
+ }
208
+ return binding;
209
+ } catch (e) {
210
+ loadErrors.push(e);
211
+ }
212
+ } else if (process.arch === "arm64") {
213
+ try {
214
+ return require2("./parser.darwin-arm64.node");
215
+ } catch (e) {
216
+ loadErrors.push(e);
217
+ }
218
+ try {
219
+ const binding = require2("@oxc-parser/binding-darwin-arm64");
220
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-arm64/package.json").version;
221
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
222
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
223
+ }
224
+ return binding;
225
+ } catch (e) {
226
+ loadErrors.push(e);
227
+ }
228
+ } else {
229
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
230
+ }
231
+ } else if (process.platform === "freebsd") {
232
+ if (process.arch === "x64") {
233
+ try {
234
+ return require2("./parser.freebsd-x64.node");
235
+ } catch (e) {
236
+ loadErrors.push(e);
237
+ }
238
+ try {
239
+ const binding = require2("@oxc-parser/binding-freebsd-x64");
240
+ const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-x64/package.json").version;
241
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
242
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
243
+ }
244
+ return binding;
245
+ } catch (e) {
246
+ loadErrors.push(e);
247
+ }
248
+ } else if (process.arch === "arm64") {
249
+ try {
250
+ return require2("./parser.freebsd-arm64.node");
251
+ } catch (e) {
252
+ loadErrors.push(e);
253
+ }
254
+ try {
255
+ const binding = require2("@oxc-parser/binding-freebsd-arm64");
256
+ const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-arm64/package.json").version;
257
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
258
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
259
+ }
260
+ return binding;
261
+ } catch (e) {
262
+ loadErrors.push(e);
263
+ }
264
+ } else {
265
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
266
+ }
267
+ } else if (process.platform === "linux") {
268
+ if (process.arch === "x64") {
269
+ if (isMusl()) {
270
+ try {
271
+ return require2("./parser.linux-x64-musl.node");
272
+ } catch (e) {
273
+ loadErrors.push(e);
274
+ }
275
+ try {
276
+ const binding = require2("@oxc-parser/binding-linux-x64-musl");
277
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-musl/package.json").version;
278
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
279
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
280
+ }
281
+ return binding;
282
+ } catch (e) {
283
+ loadErrors.push(e);
284
+ }
285
+ } else {
286
+ try {
287
+ return require2("./parser.linux-x64-gnu.node");
288
+ } catch (e) {
289
+ loadErrors.push(e);
290
+ }
291
+ try {
292
+ const binding = require2("@oxc-parser/binding-linux-x64-gnu");
293
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-gnu/package.json").version;
294
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
295
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
296
+ }
297
+ return binding;
298
+ } catch (e) {
299
+ loadErrors.push(e);
300
+ }
301
+ }
302
+ } else if (process.arch === "arm64") {
303
+ if (isMusl()) {
304
+ try {
305
+ return require2("./parser.linux-arm64-musl.node");
306
+ } catch (e) {
307
+ loadErrors.push(e);
308
+ }
309
+ try {
310
+ const binding = require2("@oxc-parser/binding-linux-arm64-musl");
311
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-musl/package.json").version;
312
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
313
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
314
+ }
315
+ return binding;
316
+ } catch (e) {
317
+ loadErrors.push(e);
318
+ }
319
+ } else {
320
+ try {
321
+ return require2("./parser.linux-arm64-gnu.node");
322
+ } catch (e) {
323
+ loadErrors.push(e);
324
+ }
325
+ try {
326
+ const binding = require2("@oxc-parser/binding-linux-arm64-gnu");
327
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-gnu/package.json").version;
328
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
329
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
330
+ }
331
+ return binding;
332
+ } catch (e) {
333
+ loadErrors.push(e);
334
+ }
335
+ }
336
+ } else if (process.arch === "arm") {
337
+ if (isMusl()) {
338
+ try {
339
+ return require2("./parser.linux-arm-musleabihf.node");
340
+ } catch (e) {
341
+ loadErrors.push(e);
342
+ }
343
+ try {
344
+ const binding = require2("@oxc-parser/binding-linux-arm-musleabihf");
345
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-musleabihf/package.json").version;
346
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
347
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
348
+ }
349
+ return binding;
350
+ } catch (e) {
351
+ loadErrors.push(e);
352
+ }
353
+ } else {
354
+ try {
355
+ return require2("./parser.linux-arm-gnueabihf.node");
356
+ } catch (e) {
357
+ loadErrors.push(e);
358
+ }
359
+ try {
360
+ const binding = require2("@oxc-parser/binding-linux-arm-gnueabihf");
361
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-gnueabihf/package.json").version;
362
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
363
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
364
+ }
365
+ return binding;
366
+ } catch (e) {
367
+ loadErrors.push(e);
368
+ }
369
+ }
370
+ } else if (process.arch === "loong64") {
371
+ if (isMusl()) {
372
+ try {
373
+ return require2("./parser.linux-loong64-musl.node");
374
+ } catch (e) {
375
+ loadErrors.push(e);
376
+ }
377
+ try {
378
+ const binding = require2("@oxc-parser/binding-linux-loong64-musl");
379
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-musl/package.json").version;
380
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
381
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
382
+ }
383
+ return binding;
384
+ } catch (e) {
385
+ loadErrors.push(e);
386
+ }
387
+ } else {
388
+ try {
389
+ return require2("./parser.linux-loong64-gnu.node");
390
+ } catch (e) {
391
+ loadErrors.push(e);
392
+ }
393
+ try {
394
+ const binding = require2("@oxc-parser/binding-linux-loong64-gnu");
395
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-gnu/package.json").version;
396
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
397
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
398
+ }
399
+ return binding;
400
+ } catch (e) {
401
+ loadErrors.push(e);
402
+ }
403
+ }
404
+ } else if (process.arch === "riscv64") {
405
+ if (isMusl()) {
406
+ try {
407
+ return require2("./parser.linux-riscv64-musl.node");
408
+ } catch (e) {
409
+ loadErrors.push(e);
410
+ }
411
+ try {
412
+ const binding = require2("@oxc-parser/binding-linux-riscv64-musl");
413
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-musl/package.json").version;
414
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
415
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
416
+ }
417
+ return binding;
418
+ } catch (e) {
419
+ loadErrors.push(e);
420
+ }
421
+ } else {
422
+ try {
423
+ return require2("./parser.linux-riscv64-gnu.node");
424
+ } catch (e) {
425
+ loadErrors.push(e);
426
+ }
427
+ try {
428
+ const binding = require2("@oxc-parser/binding-linux-riscv64-gnu");
429
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-gnu/package.json").version;
430
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
431
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
432
+ }
433
+ return binding;
434
+ } catch (e) {
435
+ loadErrors.push(e);
436
+ }
437
+ }
438
+ } else if (process.arch === "ppc64") {
439
+ try {
440
+ return require2("./parser.linux-ppc64-gnu.node");
441
+ } catch (e) {
442
+ loadErrors.push(e);
443
+ }
444
+ try {
445
+ const binding = require2("@oxc-parser/binding-linux-ppc64-gnu");
446
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-ppc64-gnu/package.json").version;
447
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
448
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
449
+ }
450
+ return binding;
451
+ } catch (e) {
452
+ loadErrors.push(e);
453
+ }
454
+ } else if (process.arch === "s390x") {
455
+ try {
456
+ return require2("./parser.linux-s390x-gnu.node");
457
+ } catch (e) {
458
+ loadErrors.push(e);
459
+ }
460
+ try {
461
+ const binding = require2("@oxc-parser/binding-linux-s390x-gnu");
462
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-s390x-gnu/package.json").version;
463
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
464
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
465
+ }
466
+ return binding;
467
+ } catch (e) {
468
+ loadErrors.push(e);
469
+ }
470
+ } else {
471
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
472
+ }
473
+ } else if (process.platform === "openharmony") {
474
+ if (process.arch === "arm64") {
475
+ try {
476
+ return require2("./parser.openharmony-arm64.node");
477
+ } catch (e) {
478
+ loadErrors.push(e);
479
+ }
480
+ try {
481
+ const binding = require2("@oxc-parser/binding-openharmony-arm64");
482
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm64/package.json").version;
483
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
484
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
485
+ }
486
+ return binding;
487
+ } catch (e) {
488
+ loadErrors.push(e);
489
+ }
490
+ } else if (process.arch === "x64") {
491
+ try {
492
+ return require2("./parser.openharmony-x64.node");
493
+ } catch (e) {
494
+ loadErrors.push(e);
495
+ }
496
+ try {
497
+ const binding = require2("@oxc-parser/binding-openharmony-x64");
498
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-x64/package.json").version;
499
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
500
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
501
+ }
502
+ return binding;
503
+ } catch (e) {
504
+ loadErrors.push(e);
505
+ }
506
+ } else if (process.arch === "arm") {
507
+ try {
508
+ return require2("./parser.openharmony-arm.node");
509
+ } catch (e) {
510
+ loadErrors.push(e);
511
+ }
512
+ try {
513
+ const binding = require2("@oxc-parser/binding-openharmony-arm");
514
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm/package.json").version;
515
+ if (bindingPackageVersion !== "0.118.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
516
+ throw new Error(`Native binding package version mismatch, expected 0.118.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
517
+ }
518
+ return binding;
519
+ } catch (e) {
520
+ loadErrors.push(e);
521
+ }
522
+ } else {
523
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
524
+ }
525
+ } else {
526
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
527
+ }
528
+ }
529
+ var import_meta, require2, readFileSync, nativeBinding, loadErrors, isMusl, isFileMusl, isMuslFromFilesystem, isMuslFromReport, isMuslFromChildProcess, _a, _b, Severity, ParseResult, ExportExportNameKind, ExportImportNameKind, ExportLocalNameKind, ImportNameKind, parse, parseSync, rawTransferSupported, getBufferOffset, parseRaw, parseRawSync;
530
+ var init_bindings = __esm({
531
+ "../../node_modules/oxc-parser/src-js/bindings.js"() {
532
+ import_meta = {};
533
+ require2 = module$1.createRequire(import_meta.url);
534
+ new URL(".", import_meta.url).pathname;
535
+ ({ readFileSync } = require2("node:fs"));
536
+ nativeBinding = null;
537
+ loadErrors = [];
538
+ isMusl = () => {
539
+ let musl = false;
540
+ if (process.platform === "linux") {
541
+ musl = isMuslFromFilesystem();
542
+ if (musl === null) {
543
+ musl = isMuslFromReport();
544
+ }
545
+ if (musl === null) {
546
+ musl = isMuslFromChildProcess();
547
+ }
548
+ }
549
+ return musl;
550
+ };
551
+ isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
552
+ isMuslFromFilesystem = () => {
553
+ try {
554
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
555
+ } catch (e) {
556
+ return null;
557
+ }
558
+ };
559
+ isMuslFromReport = () => {
560
+ var _a2;
561
+ let report = null;
562
+ if (typeof ((_a2 = process.report) == null ? void 0 : _a2.getReport) === "function") {
563
+ process.report.excludeNetwork = true;
564
+ report = process.report.getReport();
565
+ }
566
+ if (!report) {
567
+ return null;
568
+ }
569
+ if (report.header && report.header.glibcVersionRuntime) {
570
+ return false;
571
+ }
572
+ if (Array.isArray(report.sharedObjects)) {
573
+ if (report.sharedObjects.some(isFileMusl)) {
574
+ return true;
575
+ }
576
+ }
577
+ return false;
578
+ };
579
+ isMuslFromChildProcess = () => {
580
+ try {
581
+ return require2("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
582
+ } catch (e) {
583
+ return false;
584
+ }
585
+ };
586
+ nativeBinding = requireNative();
587
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
588
+ let wasiBinding = null;
589
+ let wasiBindingError = null;
590
+ try {
591
+ wasiBinding = require2("./parser.wasi.cjs");
592
+ nativeBinding = wasiBinding;
593
+ } catch (err) {
594
+ if (process.env.NAPI_RS_FORCE_WASI) {
595
+ wasiBindingError = err;
596
+ }
597
+ }
598
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
599
+ try {
600
+ wasiBinding = require2("@oxc-parser/binding-wasm32-wasi");
601
+ nativeBinding = wasiBinding;
602
+ } catch (err) {
603
+ if (process.env.NAPI_RS_FORCE_WASI) {
604
+ if (!wasiBindingError) {
605
+ wasiBindingError = err;
606
+ } else {
607
+ wasiBindingError.cause = err;
608
+ }
609
+ loadErrors.push(err);
610
+ }
611
+ }
612
+ }
613
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
614
+ const error = new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
615
+ error.cause = wasiBindingError;
616
+ throw error;
617
+ }
618
+ }
619
+ if (!nativeBinding && ((_b = (_a = globalThis.process) == null ? void 0 : _a.versions) == null ? void 0 : _b["webcontainer"])) {
620
+ try {
621
+ nativeBinding = require2("./webcontainer-fallback.cjs");
622
+ } catch (err) {
623
+ loadErrors.push(err);
624
+ }
625
+ }
626
+ if (!nativeBinding) {
627
+ if (loadErrors.length > 0) {
628
+ throw new Error(
629
+ `Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try \`npm i\` again after removing both package-lock.json and node_modules directory.`,
630
+ {
631
+ cause: loadErrors.reduce((err, cur) => {
632
+ cur.cause = err;
633
+ return cur;
634
+ })
635
+ }
636
+ );
637
+ }
638
+ throw new Error(`Failed to load native binding`);
639
+ }
640
+ ({ Severity, ParseResult, ExportExportNameKind, ExportImportNameKind, ExportLocalNameKind, ImportNameKind, parse, parseSync, rawTransferSupported } = nativeBinding);
641
+ ({ getBufferOffset, parseRaw, parseRawSync } = nativeBinding);
642
+ }
643
+ });
644
+
645
+ // ../../node_modules/oxc-parser/src-js/wrap.js
646
+ function wrap(result) {
647
+ let program, module, comments, errors;
648
+ return {
649
+ get program() {
650
+ if (!program) program = jsonParseAst(result.program);
651
+ return program;
652
+ },
653
+ get module() {
654
+ if (!module) module = result.module;
655
+ return module;
656
+ },
657
+ get comments() {
658
+ if (!comments) comments = result.comments;
659
+ return comments;
660
+ },
661
+ get errors() {
662
+ if (!errors) errors = result.errors;
663
+ return errors;
664
+ }
665
+ };
666
+ }
667
+ function jsonParseAst(programJson) {
668
+ const { node: program, fixes } = JSON.parse(programJson);
669
+ for (const fixPath of fixes) {
670
+ applyFix(program, fixPath);
671
+ }
672
+ return program;
673
+ }
674
+ function applyFix(program, fixPath) {
675
+ let node = program;
676
+ for (const key of fixPath) {
677
+ node = node[key];
678
+ }
679
+ if (node.bigint) {
680
+ node.value = BigInt(node.bigint);
681
+ } else {
682
+ try {
683
+ node.value = RegExp(node.regex.pattern, node.regex.flags);
684
+ } catch (e) {
685
+ }
686
+ }
687
+ }
688
+ var init_wrap = __esm({
689
+ "../../node_modules/oxc-parser/src-js/wrap.js"() {
690
+ }
691
+ });
692
+
693
+ // ../../node_modules/oxc-parser/src-js/generated/visit/keys.js
694
+ var freeze, $EMPTY, DECORATORS__KEY__TYPE_ANNOTATION__VALUE, LEFT__RIGHT, ARGUMENT, BODY, LABEL, CALLEE__TYPE_ARGUMENTS__ARGUMENTS, EXPRESSION, DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY, TEST__CONSEQUENT__ALTERNATE, LEFT__RIGHT__BODY, ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY, KEY__VALUE, LOCAL, OBJECT__PROPERTY, DECORATORS__KEY__TYPE_ANNOTATION, EXPRESSION__TYPE_ANNOTATION, TYPE_PARAMETERS__PARAMS__RETURN_TYPE, EXPRESSION__TYPE_ARGUMENTS, MEMBERS, ID__BODY, TYPES, TYPE_ANNOTATION, PARAMS, keys_default;
695
+ var init_keys = __esm({
696
+ "../../node_modules/oxc-parser/src-js/generated/visit/keys.js"() {
697
+ ({ freeze } = Object);
698
+ $EMPTY = freeze([]);
699
+ DECORATORS__KEY__TYPE_ANNOTATION__VALUE = freeze([
700
+ "decorators",
701
+ "key",
702
+ "typeAnnotation",
703
+ "value"
704
+ ]);
705
+ LEFT__RIGHT = freeze(["left", "right"]);
706
+ ARGUMENT = freeze(["argument"]);
707
+ BODY = freeze(["body"]);
708
+ LABEL = freeze(["label"]);
709
+ CALLEE__TYPE_ARGUMENTS__ARGUMENTS = freeze(["callee", "typeArguments", "arguments"]);
710
+ EXPRESSION = freeze(["expression"]);
711
+ DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY = freeze([
712
+ "decorators",
713
+ "id",
714
+ "typeParameters",
715
+ "superClass",
716
+ "superTypeArguments",
717
+ "implements",
718
+ "body"
719
+ ]);
720
+ TEST__CONSEQUENT__ALTERNATE = freeze(["test", "consequent", "alternate"]);
721
+ LEFT__RIGHT__BODY = freeze(["left", "right", "body"]);
722
+ ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY = freeze([
723
+ "id",
724
+ "typeParameters",
725
+ "params",
726
+ "returnType",
727
+ "body"
728
+ ]);
729
+ KEY__VALUE = freeze(["key", "value"]);
730
+ LOCAL = freeze(["local"]);
731
+ OBJECT__PROPERTY = freeze(["object", "property"]);
732
+ DECORATORS__KEY__TYPE_ANNOTATION = freeze(["decorators", "key", "typeAnnotation"]);
733
+ EXPRESSION__TYPE_ANNOTATION = freeze(["expression", "typeAnnotation"]);
734
+ TYPE_PARAMETERS__PARAMS__RETURN_TYPE = freeze(["typeParameters", "params", "returnType"]);
735
+ EXPRESSION__TYPE_ARGUMENTS = freeze(["expression", "typeArguments"]);
736
+ MEMBERS = freeze(["members"]);
737
+ ID__BODY = freeze(["id", "body"]);
738
+ TYPES = freeze(["types"]);
739
+ TYPE_ANNOTATION = freeze(["typeAnnotation"]);
740
+ PARAMS = freeze(["params"]);
741
+ keys_default = freeze({
742
+ // Leaf nodes
743
+ DebuggerStatement: $EMPTY,
744
+ EmptyStatement: $EMPTY,
745
+ Literal: $EMPTY,
746
+ PrivateIdentifier: $EMPTY,
747
+ Super: $EMPTY,
748
+ TemplateElement: $EMPTY,
749
+ ThisExpression: $EMPTY,
750
+ JSXClosingFragment: $EMPTY,
751
+ JSXEmptyExpression: $EMPTY,
752
+ JSXIdentifier: $EMPTY,
753
+ JSXOpeningFragment: $EMPTY,
754
+ JSXText: $EMPTY,
755
+ TSAnyKeyword: $EMPTY,
756
+ TSBigIntKeyword: $EMPTY,
757
+ TSBooleanKeyword: $EMPTY,
758
+ TSIntrinsicKeyword: $EMPTY,
759
+ TSJSDocUnknownType: $EMPTY,
760
+ TSNeverKeyword: $EMPTY,
761
+ TSNullKeyword: $EMPTY,
762
+ TSNumberKeyword: $EMPTY,
763
+ TSObjectKeyword: $EMPTY,
764
+ TSStringKeyword: $EMPTY,
765
+ TSSymbolKeyword: $EMPTY,
766
+ TSThisType: $EMPTY,
767
+ TSUndefinedKeyword: $EMPTY,
768
+ TSUnknownKeyword: $EMPTY,
769
+ TSVoidKeyword: $EMPTY,
770
+ // Non-leaf nodes
771
+ AccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
772
+ ArrayExpression: freeze(["elements"]),
773
+ ArrayPattern: freeze(["decorators", "elements", "typeAnnotation"]),
774
+ ArrowFunctionExpression: freeze(["typeParameters", "params", "returnType", "body"]),
775
+ AssignmentExpression: LEFT__RIGHT,
776
+ AssignmentPattern: freeze(["decorators", "left", "right", "typeAnnotation"]),
777
+ AwaitExpression: ARGUMENT,
778
+ BinaryExpression: LEFT__RIGHT,
779
+ BlockStatement: BODY,
780
+ BreakStatement: LABEL,
781
+ CallExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
782
+ CatchClause: freeze(["param", "body"]),
783
+ ChainExpression: EXPRESSION,
784
+ ClassBody: BODY,
785
+ ClassDeclaration: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
786
+ ClassExpression: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
787
+ ConditionalExpression: TEST__CONSEQUENT__ALTERNATE,
788
+ ContinueStatement: LABEL,
789
+ Decorator: EXPRESSION,
790
+ DoWhileStatement: freeze(["body", "test"]),
791
+ ExportAllDeclaration: freeze(["exported", "source", "attributes"]),
792
+ ExportDefaultDeclaration: freeze(["declaration"]),
793
+ ExportNamedDeclaration: freeze(["declaration", "specifiers", "source", "attributes"]),
794
+ ExportSpecifier: freeze(["local", "exported"]),
795
+ ExpressionStatement: EXPRESSION,
796
+ ForInStatement: LEFT__RIGHT__BODY,
797
+ ForOfStatement: LEFT__RIGHT__BODY,
798
+ ForStatement: freeze(["init", "test", "update", "body"]),
799
+ FunctionDeclaration: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
800
+ FunctionExpression: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
801
+ Identifier: freeze(["decorators", "typeAnnotation"]),
802
+ IfStatement: TEST__CONSEQUENT__ALTERNATE,
803
+ ImportAttribute: KEY__VALUE,
804
+ ImportDeclaration: freeze(["specifiers", "source", "attributes"]),
805
+ ImportDefaultSpecifier: LOCAL,
806
+ ImportExpression: freeze(["source", "options"]),
807
+ ImportNamespaceSpecifier: LOCAL,
808
+ ImportSpecifier: freeze(["imported", "local"]),
809
+ LabeledStatement: freeze(["label", "body"]),
810
+ LogicalExpression: LEFT__RIGHT,
811
+ MemberExpression: OBJECT__PROPERTY,
812
+ MetaProperty: freeze(["meta", "property"]),
813
+ MethodDefinition: freeze(["decorators", "key", "value"]),
814
+ NewExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
815
+ ObjectExpression: freeze(["properties"]),
816
+ ObjectPattern: freeze(["decorators", "properties", "typeAnnotation"]),
817
+ ParenthesizedExpression: EXPRESSION,
818
+ Program: BODY,
819
+ Property: KEY__VALUE,
820
+ PropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
821
+ RestElement: freeze(["decorators", "argument", "typeAnnotation"]),
822
+ ReturnStatement: ARGUMENT,
823
+ SequenceExpression: freeze(["expressions"]),
824
+ SpreadElement: ARGUMENT,
825
+ StaticBlock: BODY,
826
+ SwitchCase: freeze(["test", "consequent"]),
827
+ SwitchStatement: freeze(["discriminant", "cases"]),
828
+ TaggedTemplateExpression: freeze(["tag", "typeArguments", "quasi"]),
829
+ TemplateLiteral: freeze(["quasis", "expressions"]),
830
+ ThrowStatement: ARGUMENT,
831
+ TryStatement: freeze(["block", "handler", "finalizer"]),
832
+ UnaryExpression: ARGUMENT,
833
+ UpdateExpression: ARGUMENT,
834
+ V8IntrinsicExpression: freeze(["name", "arguments"]),
835
+ VariableDeclaration: freeze(["declarations"]),
836
+ VariableDeclarator: freeze(["id", "init"]),
837
+ WhileStatement: freeze(["test", "body"]),
838
+ WithStatement: freeze(["object", "body"]),
839
+ YieldExpression: ARGUMENT,
840
+ JSXAttribute: freeze(["name", "value"]),
841
+ JSXClosingElement: freeze(["name"]),
842
+ JSXElement: freeze(["openingElement", "children", "closingElement"]),
843
+ JSXExpressionContainer: EXPRESSION,
844
+ JSXFragment: freeze(["openingFragment", "children", "closingFragment"]),
845
+ JSXMemberExpression: OBJECT__PROPERTY,
846
+ JSXNamespacedName: freeze(["namespace", "name"]),
847
+ JSXOpeningElement: freeze(["name", "typeArguments", "attributes"]),
848
+ JSXSpreadAttribute: ARGUMENT,
849
+ JSXSpreadChild: EXPRESSION,
850
+ TSAbstractAccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION,
851
+ TSAbstractMethodDefinition: KEY__VALUE,
852
+ TSAbstractPropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION,
853
+ TSArrayType: freeze(["elementType"]),
854
+ TSAsExpression: EXPRESSION__TYPE_ANNOTATION,
855
+ TSCallSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
856
+ TSClassImplements: EXPRESSION__TYPE_ARGUMENTS,
857
+ TSConditionalType: freeze(["checkType", "extendsType", "trueType", "falseType"]),
858
+ TSConstructSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
859
+ TSConstructorType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
860
+ TSDeclareFunction: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
861
+ TSEmptyBodyFunctionExpression: freeze(["id", "typeParameters", "params", "returnType"]),
862
+ TSEnumBody: MEMBERS,
863
+ TSEnumDeclaration: ID__BODY,
864
+ TSEnumMember: freeze(["id", "initializer"]),
865
+ TSExportAssignment: EXPRESSION,
866
+ TSExternalModuleReference: EXPRESSION,
867
+ TSFunctionType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
868
+ TSImportEqualsDeclaration: freeze(["id", "moduleReference"]),
869
+ TSImportType: freeze(["source", "options", "qualifier", "typeArguments"]),
870
+ TSIndexSignature: freeze(["parameters", "typeAnnotation"]),
871
+ TSIndexedAccessType: freeze(["objectType", "indexType"]),
872
+ TSInferType: freeze(["typeParameter"]),
873
+ TSInstantiationExpression: EXPRESSION__TYPE_ARGUMENTS,
874
+ TSInterfaceBody: BODY,
875
+ TSInterfaceDeclaration: freeze(["id", "typeParameters", "extends", "body"]),
876
+ TSInterfaceHeritage: EXPRESSION__TYPE_ARGUMENTS,
877
+ TSIntersectionType: TYPES,
878
+ TSJSDocNonNullableType: TYPE_ANNOTATION,
879
+ TSJSDocNullableType: TYPE_ANNOTATION,
880
+ TSLiteralType: freeze(["literal"]),
881
+ TSMappedType: freeze(["key", "constraint", "nameType", "typeAnnotation"]),
882
+ TSMethodSignature: freeze(["key", "typeParameters", "params", "returnType"]),
883
+ TSModuleBlock: BODY,
884
+ TSModuleDeclaration: ID__BODY,
885
+ TSNamedTupleMember: freeze(["label", "elementType"]),
886
+ TSNamespaceExportDeclaration: freeze(["id"]),
887
+ TSNonNullExpression: EXPRESSION,
888
+ TSOptionalType: TYPE_ANNOTATION,
889
+ TSParameterProperty: freeze(["decorators", "parameter"]),
890
+ TSParenthesizedType: TYPE_ANNOTATION,
891
+ TSPropertySignature: freeze(["key", "typeAnnotation"]),
892
+ TSQualifiedName: LEFT__RIGHT,
893
+ TSRestType: TYPE_ANNOTATION,
894
+ TSSatisfiesExpression: EXPRESSION__TYPE_ANNOTATION,
895
+ TSTemplateLiteralType: freeze(["quasis", "types"]),
896
+ TSTupleType: freeze(["elementTypes"]),
897
+ TSTypeAliasDeclaration: freeze(["id", "typeParameters", "typeAnnotation"]),
898
+ TSTypeAnnotation: TYPE_ANNOTATION,
899
+ TSTypeAssertion: freeze(["typeAnnotation", "expression"]),
900
+ TSTypeLiteral: MEMBERS,
901
+ TSTypeOperator: TYPE_ANNOTATION,
902
+ TSTypeParameter: freeze(["name", "constraint", "default"]),
903
+ TSTypeParameterDeclaration: PARAMS,
904
+ TSTypeParameterInstantiation: PARAMS,
905
+ TSTypePredicate: freeze(["parameterName", "typeAnnotation"]),
906
+ TSTypeQuery: freeze(["exprName", "typeArguments"]),
907
+ TSTypeReference: freeze(["typeName", "typeArguments"]),
908
+ TSUnionType: TYPES
909
+ });
910
+ }
911
+ });
912
+ var import_meta2, walkProgram, addVisitorToCompiled, createCompiledVisitor, finalizeCompiledVisitor, _compiledVisitor, Visitor;
913
+ var init_visit = __esm({
914
+ "../../node_modules/oxc-parser/src-js/visit/index.js"() {
915
+ import_meta2 = {};
916
+ walkProgram = null;
917
+ Visitor = class {
918
+ constructor(visitor) {
919
+ __privateAdd(this, _compiledVisitor, null);
920
+ if (walkProgram === null) {
921
+ const require4 = module$1.createRequire(import_meta2.url);
922
+ ({ walkProgram } = require4("../generated/visit/walk.js"));
923
+ ({
924
+ addVisitorToCompiled,
925
+ createCompiledVisitor,
926
+ finalizeCompiledVisitor
927
+ } = require4("./visitor.js"));
928
+ }
929
+ const compiledVisitor = createCompiledVisitor();
930
+ addVisitorToCompiled(visitor);
931
+ const needsVisit = finalizeCompiledVisitor();
932
+ if (needsVisit) __privateSet(this, _compiledVisitor, compiledVisitor);
933
+ }
934
+ /**
935
+ * Visit AST.
936
+ * @param program - The AST to visit.
937
+ * @returns {undefined}
938
+ */
939
+ visit(program) {
940
+ const compiledVisitor = __privateGet(this, _compiledVisitor);
941
+ if (compiledVisitor !== null) walkProgram(program, compiledVisitor);
942
+ }
943
+ };
944
+ _compiledVisitor = new WeakMap();
945
+ }
946
+ });
947
+
948
+ // ../../node_modules/oxc-parser/src-js/raw-transfer/supported.js
949
+ function rawTransferSupported2() {
950
+ if (rawTransferIsSupported === null) {
951
+ rawTransferIsSupported = rawTransferRuntimeSupported() && rawTransferSupported();
952
+ }
953
+ return rawTransferIsSupported;
954
+ }
955
+ function rawTransferRuntimeSupported() {
956
+ var _a2, _b2, _c, _d, _e, _f, _g;
957
+ let global;
958
+ try {
959
+ global = globalThis;
960
+ } catch (e) {
961
+ return false;
962
+ }
963
+ const isBun = !!global.Bun || !!((_b2 = (_a2 = global.process) == null ? void 0 : _a2.versions) == null ? void 0 : _b2.bun);
964
+ if (isBun) return false;
965
+ const isDeno = !!global.Deno;
966
+ if (isDeno) {
967
+ const match2 = (_d = (_c = Deno.version) == null ? void 0 : _c.deno) == null ? void 0 : _d.match(/^(\d+)\./);
968
+ return !!match2 && match2[1] * 1 >= 2;
969
+ }
970
+ const isNode = ((_f = (_e = global.process) == null ? void 0 : _e.release) == null ? void 0 : _f.name) === "node";
971
+ if (!isNode) return false;
972
+ const match = (_g = process.version) == null ? void 0 : _g.match(/^v(\d+)\./);
973
+ return !!match && match[1] * 1 >= 22;
974
+ }
975
+ var rawTransferIsSupported;
976
+ var init_supported = __esm({
977
+ "../../node_modules/oxc-parser/src-js/raw-transfer/supported.js"() {
978
+ init_bindings();
979
+ rawTransferIsSupported = null;
980
+ }
981
+ });
982
+
983
+ // ../../node_modules/oxc-parser/src-js/index.js
984
+ var src_js_exports = {};
985
+ __export(src_js_exports, {
986
+ ExportExportNameKind: () => ExportExportNameKind,
987
+ ExportImportNameKind: () => ExportImportNameKind,
988
+ ExportLocalNameKind: () => ExportLocalNameKind,
989
+ ImportNameKind: () => ImportNameKind,
990
+ ParseResult: () => ParseResult,
991
+ Severity: () => Severity,
992
+ Visitor: () => Visitor,
993
+ experimentalGetLazyVisitor: () => experimentalGetLazyVisitor,
994
+ parse: () => parse2,
995
+ parseSync: () => parseSync2,
996
+ rawTransferSupported: () => rawTransferSupported2,
997
+ visitorKeys: () => keys_default
998
+ });
999
+ function loadRawTransfer() {
1000
+ if (parseSyncRaw === null) {
1001
+ ({ parseSyncRaw, parse: parseRaw2 } = require3("./raw-transfer/eager.js"));
1002
+ }
1003
+ }
1004
+ function loadRawTransferLazy() {
1005
+ if (parseSyncLazy === null) {
1006
+ ({ parseSyncLazy, parse: parseLazy, Visitor: LazyVisitor } = require3("./raw-transfer/lazy.js"));
1007
+ }
1008
+ }
1009
+ function parseSync2(filename, sourceText, options) {
1010
+ if (options == null ? void 0 : options.experimentalRawTransfer) {
1011
+ loadRawTransfer();
1012
+ return parseSyncRaw(filename, sourceText, options);
1013
+ }
1014
+ if (options == null ? void 0 : options.experimentalLazy) {
1015
+ loadRawTransferLazy();
1016
+ return parseSyncLazy(filename, sourceText, options);
1017
+ }
1018
+ return wrap(parseSync(filename, sourceText, options));
1019
+ }
1020
+ async function parse2(filename, sourceText, options) {
1021
+ if (options == null ? void 0 : options.experimentalRawTransfer) {
1022
+ loadRawTransfer();
1023
+ return await parseRaw2(filename, sourceText, options);
1024
+ }
1025
+ if (options == null ? void 0 : options.experimentalLazy) {
1026
+ loadRawTransferLazy();
1027
+ return await parseLazy(filename, sourceText, options);
1028
+ }
1029
+ return wrap(await parse(filename, sourceText, options));
1030
+ }
1031
+ function experimentalGetLazyVisitor() {
1032
+ loadRawTransferLazy();
1033
+ return LazyVisitor;
1034
+ }
1035
+ var import_meta3, require3, parseSyncRaw, parseRaw2, parseSyncLazy, parseLazy, LazyVisitor;
1036
+ var init_src_js = __esm({
1037
+ "../../node_modules/oxc-parser/src-js/index.js"() {
1038
+ init_bindings();
1039
+ init_wrap();
1040
+ init_keys();
1041
+ init_visit();
1042
+ init_bindings();
1043
+ init_supported();
1044
+ import_meta3 = {};
1045
+ require3 = module$1.createRequire(import_meta3.url);
1046
+ parseSyncRaw = null;
1047
+ parseSyncLazy = null;
1048
+ }
1049
+ });
1050
+
1051
+ // ../compiler/src/atomicCss.ts
1052
+ var atomicCss_exports = {};
1053
+ __export(atomicCss_exports, {
1054
+ clearAtomicRegistry: () => clearAtomicRegistry,
1055
+ generateAtomicCss: () => generateAtomicCss,
1056
+ getAtomicRegistry: () => getAtomicRegistry,
1057
+ parseAtomicClass: () => parseAtomicClass,
1058
+ toAtomicClasses: () => toAtomicClasses
1059
+ });
1060
+ function sizeValue(v) {
1061
+ var _a2;
1062
+ const num = Number(v);
1063
+ if (!Number.isNaN(num)) return `${num * 0.25}rem`;
1064
+ const special = {
1065
+ full: "100%",
1066
+ screen: "100vw",
1067
+ auto: "auto",
1068
+ min: "min-content",
1069
+ max: "max-content",
1070
+ fit: "fit-content",
1071
+ svw: "100svw",
1072
+ svh: "100svh"
1073
+ };
1074
+ return (_a2 = special[v]) != null ? _a2 : v;
1075
+ }
1076
+ function textSize(v) {
1077
+ var _a2;
1078
+ const map = {
1079
+ xs: "0.75rem",
1080
+ sm: "0.875rem",
1081
+ base: "1rem",
1082
+ lg: "1.125rem",
1083
+ xl: "1.25rem",
1084
+ "2xl": "1.5rem",
1085
+ "3xl": "1.875rem",
1086
+ "4xl": "2.25rem",
1087
+ "5xl": "3rem",
1088
+ "6xl": "3.75rem",
1089
+ "7xl": "4.5rem",
1090
+ "8xl": "6rem",
1091
+ "9xl": "8rem"
1092
+ };
1093
+ return (_a2 = map[v]) != null ? _a2 : v;
1094
+ }
1095
+ function fontWeight(v) {
1096
+ var _a2;
1097
+ const map = {
1098
+ thin: "100",
1099
+ extralight: "200",
1100
+ light: "300",
1101
+ normal: "400",
1102
+ medium: "500",
1103
+ semibold: "600",
1104
+ bold: "700",
1105
+ extrabold: "800",
1106
+ black: "900"
1107
+ };
1108
+ return (_a2 = map[v]) != null ? _a2 : v;
1109
+ }
1110
+ function leadingValue(v) {
1111
+ var _a2;
1112
+ const map = {
1113
+ none: "1",
1114
+ tight: "1.25",
1115
+ snug: "1.375",
1116
+ normal: "1.5",
1117
+ relaxed: "1.625",
1118
+ loose: "2"
1119
+ };
1120
+ return (_a2 = map[v]) != null ? _a2 : v;
1121
+ }
1122
+ function roundedValue(v) {
1123
+ var _a2;
1124
+ const map = {
1125
+ "": "0.25rem",
1126
+ sm: "0.125rem",
1127
+ md: "0.375rem",
1128
+ lg: "0.5rem",
1129
+ xl: "0.75rem",
1130
+ "2xl": "1rem",
1131
+ "3xl": "1.5rem",
1132
+ full: "9999px",
1133
+ none: "0"
1134
+ };
1135
+ return (_a2 = map[v]) != null ? _a2 : `${v}rem`;
1136
+ }
1137
+ function sanitizeClassName(cls) {
1138
+ return cls.replace(/[/:[\].!%]/g, "_");
1139
+ }
1140
+ function parseAtomicClass(twClass) {
1141
+ if (REGISTRY.has(twClass)) return REGISTRY.get(twClass);
1142
+ const colonIdx = twClass.lastIndexOf(":");
1143
+ const modifier = colonIdx > -1 ? twClass.slice(0, colonIdx) : void 0;
1144
+ const base = colonIdx > -1 ? twClass.slice(colonIdx + 1) : twClass;
1145
+ const dashIdx = base.indexOf("-");
1146
+ if (dashIdx === -1) return null;
1147
+ const prefix = base.slice(0, dashIdx);
1148
+ const value = base.slice(dashIdx + 1);
1149
+ const mapping = TW_PROPERTY_MAP[prefix];
1150
+ if (!mapping) return null;
1151
+ const cssValue = mapping.transform ? mapping.transform(value) : value;
1152
+ const atomicName = `_tw_${sanitizeClassName(twClass)}`;
1153
+ const rule = {
1154
+ twClass,
1155
+ atomicName,
1156
+ property: mapping.prop,
1157
+ value: cssValue,
1158
+ modifier
1159
+ };
1160
+ REGISTRY.set(twClass, rule);
1161
+ return rule;
1162
+ }
1163
+ function generateAtomicCss(rules) {
1164
+ const lines = [];
1165
+ for (const rule of rules) {
1166
+ const selector = `.${rule.atomicName}`;
1167
+ if (rule.modifier) {
1168
+ const breakpoints = {
1169
+ sm: "640px",
1170
+ md: "768px",
1171
+ lg: "1024px",
1172
+ xl: "1280px",
1173
+ "2xl": "1536px"
1174
+ };
1175
+ if (breakpoints[rule.modifier]) {
1176
+ lines.push(
1177
+ `@media (min-width: ${breakpoints[rule.modifier]}) {`,
1178
+ ` ${selector} { ${rule.property}: ${rule.value}; }`,
1179
+ `}`
1180
+ );
1181
+ continue;
1182
+ }
1183
+ lines.push(`${selector}:${rule.modifier} { ${rule.property}: ${rule.value}; }`);
1184
+ } else {
1185
+ lines.push(`${selector} { ${rule.property}: ${rule.value}; }`);
1186
+ }
1187
+ }
1188
+ return lines.join("\n");
1189
+ }
1190
+ function toAtomicClasses(twClasses) {
1191
+ const parts = twClasses.split(/\s+/).filter(Boolean);
1192
+ const atomicNames = [];
1193
+ const rules = [];
1194
+ const unknownClasses = [];
1195
+ for (const cls of parts) {
1196
+ const rule = parseAtomicClass(cls);
1197
+ if (rule) {
1198
+ atomicNames.push(rule.atomicName);
1199
+ rules.push(rule);
1200
+ } else {
1201
+ unknownClasses.push(cls);
1202
+ atomicNames.push(cls);
1203
+ }
1204
+ }
1205
+ return {
1206
+ atomicClasses: atomicNames.join(" "),
1207
+ rules,
1208
+ unknownClasses
1209
+ };
1210
+ }
1211
+ function getAtomicRegistry() {
1212
+ return REGISTRY;
1213
+ }
1214
+ function clearAtomicRegistry() {
1215
+ REGISTRY.clear();
1216
+ }
1217
+ var REGISTRY, TW_PROPERTY_MAP;
1218
+ var init_atomicCss = __esm({
1219
+ "../compiler/src/atomicCss.ts"() {
1220
+ REGISTRY = /* @__PURE__ */ new Map();
1221
+ TW_PROPERTY_MAP = {
1222
+ // Spacing
1223
+ p: { prop: "padding", transform: (v) => `${Number(v) * 0.25}rem` },
1224
+ px: { prop: "padding-inline", transform: (v) => `${Number(v) * 0.25}rem` },
1225
+ py: { prop: "padding-block", transform: (v) => `${Number(v) * 0.25}rem` },
1226
+ pt: { prop: "padding-top", transform: (v) => `${Number(v) * 0.25}rem` },
1227
+ pb: { prop: "padding-bottom", transform: (v) => `${Number(v) * 0.25}rem` },
1228
+ pl: { prop: "padding-left", transform: (v) => `${Number(v) * 0.25}rem` },
1229
+ pr: { prop: "padding-right", transform: (v) => `${Number(v) * 0.25}rem` },
1230
+ m: { prop: "margin", transform: (v) => `${Number(v) * 0.25}rem` },
1231
+ mx: { prop: "margin-inline", transform: (v) => `${Number(v) * 0.25}rem` },
1232
+ my: { prop: "margin-block", transform: (v) => `${Number(v) * 0.25}rem` },
1233
+ mt: { prop: "margin-top", transform: (v) => `${Number(v) * 0.25}rem` },
1234
+ mb: { prop: "margin-bottom", transform: (v) => `${Number(v) * 0.25}rem` },
1235
+ ml: { prop: "margin-left", transform: (v) => `${Number(v) * 0.25}rem` },
1236
+ mr: { prop: "margin-right", transform: (v) => `${Number(v) * 0.25}rem` },
1237
+ gap: { prop: "gap", transform: (v) => `${Number(v) * 0.25}rem` },
1238
+ // Sizing
1239
+ w: { prop: "width", transform: sizeValue },
1240
+ h: { prop: "height", transform: sizeValue },
1241
+ // Typography
1242
+ text: { prop: "font-size", transform: textSize },
1243
+ font: { prop: "font-weight", transform: fontWeight },
1244
+ leading: { prop: "line-height", transform: leadingValue },
1245
+ // Misc
1246
+ opacity: { prop: "opacity", transform: (v) => String(Number(v) / 100) },
1247
+ z: { prop: "z-index" },
1248
+ rounded: { prop: "border-radius", transform: (v) => roundedValue(v) }
1249
+ };
1250
+ }
1251
+ });
1252
+
1253
+ // ../preset/src/defaultPreset.ts
1254
+ var defaultPreset_exports = {};
1255
+ __export(defaultPreset_exports, {
1256
+ defaultGlobalCss: () => defaultGlobalCss,
1257
+ defaultPreset: () => defaultPreset,
1258
+ designTokens: () => designTokens,
1259
+ generateTailwindConfig: () => generateTailwindConfig
1260
+ });
1261
+ function generateTailwindConfig(safelistPath = ".tailwind-styled-safelist.json", contentPaths = STANDARD_CONTENT_PATHS) {
1262
+ return `import type { Config } from "tailwindcss"
1263
+ import { defaultPreset } from "tailwind-styled-v4/preset"
1264
+
1265
+ // Auto-generated safelist dari tailwind-styled-v4 compiler
1266
+ const safelist = (() => {
1267
+ try { return require(${JSON.stringify(safelistPath)}) as string[] }
1268
+ catch { return [] }
1269
+ })()
1270
+
1271
+ export default {
1272
+ presets: [defaultPreset],
1273
+ content: ${JSON.stringify(contentPaths, null, 2)},
1274
+ safelist,
1275
+ } satisfies Config
1276
+ `;
1277
+ }
1278
+ var STANDARD_CONTENT_PATHS, designTokens, defaultPreset, defaultGlobalCss;
1279
+ var init_defaultPreset = __esm({
1280
+ "../preset/src/defaultPreset.ts"() {
1281
+ STANDARD_CONTENT_PATHS = [
1282
+ // Next.js App Router
1283
+ "./src/**/*.{tsx,ts,jsx,js,mdx}",
1284
+ "./app/**/*.{tsx,ts,jsx,js,mdx}",
1285
+ "./pages/**/*.{tsx,ts,jsx,js,mdx}",
1286
+ "./components/**/*.{tsx,ts,jsx,js,mdx}",
1287
+ // Vite / React
1288
+ "./src/**/*.{tsx,ts,jsx,js}",
1289
+ "./index.html",
1290
+ // Monorepo
1291
+ "../../packages/**/src/**/*.{tsx,ts,jsx,js}"
1292
+ ];
1293
+ designTokens = {
1294
+ colors: {
1295
+ // Brand
1296
+ primary: { DEFAULT: "#3b82f6", hover: "#2563eb", active: "#1d4ed8", foreground: "#ffffff" },
1297
+ secondary: { DEFAULT: "#6366f1", hover: "#4f46e5", active: "#4338ca", foreground: "#ffffff" },
1298
+ accent: { DEFAULT: "#f59e0b", hover: "#d97706", active: "#b45309", foreground: "#000000" },
1299
+ // Semantic
1300
+ success: { DEFAULT: "#10b981", foreground: "#ffffff" },
1301
+ warning: { DEFAULT: "#f59e0b", foreground: "#000000" },
1302
+ danger: { DEFAULT: "#ef4444", foreground: "#ffffff" },
1303
+ info: { DEFAULT: "#3b82f6", foreground: "#ffffff" },
1304
+ // Neutral
1305
+ surface: "#18181b",
1306
+ border: "#27272a",
1307
+ muted: "#71717a",
1308
+ subtle: "#3f3f46"
1309
+ },
1310
+ fontFamily: {
1311
+ sans: ["InterVariable", "Inter", "system-ui", "sans-serif"],
1312
+ mono: ["JetBrains Mono", "Fira Code", "Consolas", "monospace"]
1313
+ },
1314
+ borderRadius: {
1315
+ sm: "0.25rem",
1316
+ DEFAULT: "0.5rem",
1317
+ md: "0.5rem",
1318
+ lg: "0.75rem",
1319
+ xl: "1rem",
1320
+ "2xl": "1.5rem",
1321
+ full: "9999px"
1322
+ },
1323
+ animation: {
1324
+ "fade-in": "fadeIn 0.2s ease-out",
1325
+ "fade-out": "fadeOut 0.2s ease-in",
1326
+ "slide-up": "slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",
1327
+ "slide-down": "slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1)",
1328
+ "scale-in": "scaleIn 0.2s ease-out"
1329
+ },
1330
+ keyframes: {
1331
+ fadeIn: { from: { opacity: "0" }, to: { opacity: "1" } },
1332
+ fadeOut: { from: { opacity: "1" }, to: { opacity: "0" } },
1333
+ slideUp: {
1334
+ from: { transform: "translateY(8px)", opacity: "0" },
1335
+ to: { transform: "translateY(0)", opacity: "1" }
1336
+ },
1337
+ slideDown: {
1338
+ from: { transform: "translateY(-8px)", opacity: "0" },
1339
+ to: { transform: "translateY(0)", opacity: "1" }
1340
+ },
1341
+ scaleIn: {
1342
+ from: { transform: "scale(0.95)", opacity: "0" },
1343
+ to: { transform: "scale(1)", opacity: "1" }
1344
+ }
1345
+ }
1346
+ };
1347
+ defaultPreset = {
1348
+ content: STANDARD_CONTENT_PATHS,
1349
+ darkMode: "class",
1350
+ theme: {
1351
+ extend: {
1352
+ colors: designTokens.colors,
1353
+ fontFamily: designTokens.fontFamily,
1354
+ borderRadius: designTokens.borderRadius,
1355
+ animation: designTokens.animation,
1356
+ keyframes: designTokens.keyframes
1357
+ }
1358
+ },
1359
+ plugins: []
1360
+ };
1361
+ defaultGlobalCss = `@import "tailwindcss";
1362
+
1363
+ /* tailwind-styled-v4 \u2014 zero-config base styles */
1364
+ *, *::before, *::after {
1365
+ box-sizing: border-box;
1366
+ }
1367
+
1368
+ html {
1369
+ -webkit-font-smoothing: antialiased;
1370
+ -moz-osx-font-smoothing: grayscale;
1371
+ text-rendering: optimizeLegibility;
1372
+ }
1373
+
1374
+ body {
1375
+ margin: 0;
1376
+ font-family: var(--font-sans, system-ui, sans-serif);
1377
+ background: var(--color-background, #09090b);
1378
+ color: var(--color-foreground, #fafafa);
1379
+ }
1380
+ `;
1381
+ }
1382
+ });
1383
+ function mergeClassesStatic(classes) {
1384
+ return tailwindMerge.twMerge(classes);
1385
+ }
1386
+ function normalizeClasses(raw) {
1387
+ return raw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
1388
+ }
1389
+
1390
+ // ../compiler/src/componentHoister.ts
1391
+ var INDENTED_TW_DECL_RE = /^([ \t]+)(const|let)\s+([A-Z]\w*)\s*=\s*tw\.[\w]+[`(]/gm;
1392
+ function hoistComponents(source) {
1393
+ const hoisted = [];
1394
+ const warnings = [];
1395
+ const indentedDecls = [];
1396
+ let m;
1397
+ const re = new RegExp(INDENTED_TW_DECL_RE.source, "gm");
1398
+ while ((m = re.exec(source)) !== null) {
1399
+ const indent = m[1];
1400
+ const keyword = m[2];
1401
+ const name = m[3];
1402
+ if (!/^[A-Z]/.test(name)) continue;
1403
+ if (indent.length === 0) continue;
1404
+ indentedDecls.push({
1405
+ fullMatch: m[0],
1406
+ indent,
1407
+ keyword,
1408
+ name,
1409
+ startIndex: m.index
1410
+ });
1411
+ }
1412
+ if (indentedDecls.length === 0) {
1413
+ return { code: source, hoisted: [], warnings: [] };
1414
+ }
1415
+ let code = source;
1416
+ const hoistedDecls = [];
1417
+ for (const decl of [...indentedDecls].reverse()) {
1418
+ const { startIndex, indent, name } = decl;
1419
+ const lineStart = code.lastIndexOf("\n", startIndex) + 1;
1420
+ const restFromDecl = code.slice(lineStart);
1421
+ const fullStmt = extractFullStatement(restFromDecl);
1422
+ if (!fullStmt) continue;
1423
+ const dedented = fullStmt.split("\n").map((line) => line.startsWith(indent) ? line.slice(indent.length) : line).join("\n").trim();
1424
+ code = code.slice(0, lineStart) + code.slice(lineStart + fullStmt.length);
1425
+ hoistedDecls.unshift(dedented);
1426
+ hoisted.push(name);
1427
+ warnings.push(
1428
+ `[tw-hoist] '${name}' moved to module scope for better performance. Avoid defining tw components inside render functions.`
1429
+ );
1430
+ }
1431
+ if (hoistedDecls.length > 0) {
1432
+ const insertPoint = findAfterImports(code);
1433
+ const hoistBlock = `
1434
+ ${hoistedDecls.join("\n\n")}
1435
+ `;
1436
+ code = code.slice(0, insertPoint) + hoistBlock + code.slice(insertPoint);
1437
+ }
1438
+ return { code, hoisted, warnings };
1439
+ }
1440
+ function extractFullStatement(source) {
1441
+ const templateRe = /^[ \t]*(const|let)\s+\w+\s*=\s*tw\.\w+`[^`]*`.*\n?/;
1442
+ const templateMatch = source.match(templateRe);
1443
+ if (templateMatch) return templateMatch[0];
1444
+ const objStart = source.indexOf("tw.");
1445
+ if (objStart === -1) return null;
1446
+ const parenStart = source.indexOf("(", objStart);
1447
+ if (parenStart === -1) return null;
1448
+ let depth = 0;
1449
+ let i = parenStart;
1450
+ while (i < source.length) {
1451
+ if (source[i] === "(") depth++;
1452
+ if (source[i] === ")") {
1453
+ depth--;
1454
+ if (depth === 0) {
1455
+ const end = source.indexOf("\n", i);
1456
+ return source.slice(0, end === -1 ? i + 1 : end + 1);
1457
+ }
1458
+ }
1459
+ i++;
1460
+ }
1461
+ return null;
1462
+ }
1463
+ function findAfterImports(source) {
1464
+ const lines = source.split("\n");
1465
+ let lastImportLine = 0;
1466
+ for (let i = 0; i < lines.length; i++) {
1467
+ const line = lines[i].trim();
1468
+ if (line.startsWith("import ") || line.startsWith("'use client'") || line.startsWith('"use client"')) {
1469
+ lastImportLine = i;
1470
+ } else if (line && !line.startsWith("//") && !line.startsWith("/*") && lastImportLine > 0) {
1471
+ break;
1472
+ }
1473
+ }
1474
+ return lines.slice(0, lastImportLine + 1).join("\n").length + 1;
1475
+ }
1476
+
1477
+ // ../compiler/src/rscAnalyzer.ts
1478
+ var CSS_INTERACTIVE_OK = [
1479
+ /^hover:/,
1480
+ // CSS :hover — no JS needed
1481
+ /^focus:/,
1482
+ // CSS :focus — no JS needed
1483
+ /^focus-within:/,
1484
+ // CSS :focus-within
1485
+ /^focus-visible:/,
1486
+ // CSS :focus-visible
1487
+ /^active:/,
1488
+ // CSS :active
1489
+ /^group-hover:/,
1490
+ // Tailwind group variant — CSS only
1491
+ /^group-focus:/,
1492
+ // CSS only
1493
+ /^peer-/,
1494
+ // Tailwind peer — CSS only
1495
+ /^first:/,
1496
+ // CSS :first-child
1497
+ /^last:/,
1498
+ // CSS :last-child
1499
+ /^odd:/,
1500
+ // CSS :nth-child(odd)
1501
+ /^even:/,
1502
+ // CSS :nth-child(even)
1503
+ /^disabled:/,
1504
+ // CSS :disabled
1505
+ /^placeholder:/,
1506
+ // CSS ::placeholder
1507
+ /^dark:/,
1508
+ // CSS @media prefers-color-scheme
1509
+ /^print:/,
1510
+ // CSS @media print
1511
+ /^md:|^sm:|^lg:|^xl:|^2xl:/
1512
+ // Responsive breakpoints — CSS only
1513
+ ];
1514
+ var REQUIRES_JS_PATTERNS = [
1515
+ // React hooks
1516
+ /\buseState\b/,
1517
+ /\buseEffect\b/,
1518
+ /\buseRef\b/,
1519
+ /\buseCallback\b/,
1520
+ /\buseMemo\b/,
1521
+ /\buseReducer\b/,
1522
+ /\buseContext\b/,
1523
+ // Event handlers
1524
+ /\bon[A-Z][a-zA-Z]+\s*[=:]/,
1525
+ // onClick=, onMouseEnter:, etc.
1526
+ // Browser APIs
1527
+ /\bwindow\./,
1528
+ /\bdocument\./,
1529
+ /\blocalStorage\b/,
1530
+ /\bsessionStorage\b/,
1531
+ // Dynamic imports
1532
+ /import\s*\(/
1533
+ ];
1534
+ function analyzeFile(source, _filename = "") {
1535
+ const clientReasons = [];
1536
+ const interactiveClasses = [];
1537
+ const hasClientDirective = source.trimStart().startsWith('"use client"') || source.trimStart().startsWith("'use client'");
1538
+ if (hasClientDirective) {
1539
+ clientReasons.push("explicit 'use client' directive");
1540
+ }
1541
+ for (const pattern of REQUIRES_JS_PATTERNS) {
1542
+ if (pattern.test(source)) {
1543
+ const match = source.match(pattern);
1544
+ if (match) clientReasons.push(`uses ${match[0].trim()}`);
1545
+ }
1546
+ }
1547
+ const hasServerMarker = source.includes("tw.server.");
1548
+ const templateRe = /\btw\.(?:server\.)?(\w+)`((?:[^`\\]|\\.)*)`/g;
1549
+ let m;
1550
+ while ((m = templateRe.exec(source)) !== null) {
1551
+ const classes = m[2];
1552
+ const parts = classes.split(/\s+/).filter(Boolean);
1553
+ for (const cls of parts) {
1554
+ const isOk = CSS_INTERACTIVE_OK.some((re) => re.test(cls));
1555
+ if (!isOk && /^[a-z-]+:/.test(cls)) {
1556
+ interactiveClasses.push(cls);
1557
+ clientReasons.push(`uses JS-interactive class: ${cls}`);
1558
+ }
1559
+ }
1560
+ }
1561
+ const needsClientDirective = !hasServerMarker && (hasClientDirective || clientReasons.length > 0);
1562
+ const isServer = !needsClientDirective || hasServerMarker;
1563
+ return {
1564
+ isServer,
1565
+ needsClientDirective,
1566
+ clientReasons: [...new Set(clientReasons)],
1567
+ interactiveClasses: [...new Set(interactiveClasses)],
1568
+ canStaticResolveVariants: isServer
1569
+ };
1570
+ }
1571
+ function analyzeVariantUsage(source, componentName, variantKeys) {
1572
+ const resolved = {};
1573
+ const dynamic = [];
1574
+ for (const key of variantKeys) {
1575
+ const staticRe = new RegExp(`<${componentName}[^>]*\\b${key}=["']([^"']+)["'][^>]*>`, "g");
1576
+ const dynamicRe = new RegExp(`<${componentName}[^>]*\\b${key}=\\{[^"'][^}]*\\}[^>]*>`, "g");
1577
+ const staticMatch = source.match(staticRe);
1578
+ const dynamicMatch = source.match(dynamicRe);
1579
+ if (dynamicMatch) {
1580
+ dynamic.push(key);
1581
+ } else if (staticMatch) {
1582
+ const valMatch = staticMatch[0].match(new RegExp(`${key}=["']([^"']+)["']`));
1583
+ if (valMatch) resolved[key] = valMatch[1];
1584
+ }
1585
+ }
1586
+ return { resolved, dynamic };
1587
+ }
1588
+ function resolveServerVariant(base, table, defaults, resolved) {
1589
+ var _a2;
1590
+ const parts = [base];
1591
+ for (const key in table) {
1592
+ const val = (_a2 = resolved[key]) != null ? _a2 : defaults[key];
1593
+ if (val && table[key][val]) {
1594
+ parts.push(table[key][val]);
1595
+ }
1596
+ }
1597
+ const seen = /* @__PURE__ */ new Map();
1598
+ for (const part of parts) {
1599
+ for (const cls of part.split(/\s+/).filter(Boolean)) {
1600
+ const prefix = cls.replace(/^(?:[\w-]+:)*/, "").split("-")[0];
1601
+ seen.set(prefix, cls);
1602
+ }
1603
+ }
1604
+ return Array.from(seen.values()).join(" ");
1605
+ }
1606
+ function injectClientDirective(code) {
1607
+ if (code.startsWith('"use client"') || code.startsWith("'use client'")) {
1608
+ return code;
1609
+ }
1610
+ return `"use client";
1611
+ ${code}`;
1612
+ }
1613
+ function injectServerOnlyComment(code) {
1614
+ return `/* @tw-server-only */
1615
+ ${code}`;
1616
+ }
1617
+
1618
+ // ../compiler/src/twDetector.ts
1619
+ var TEMPLATE_RE = /\btw\.(server\.)?(\w+)`((?:[^`\\]|\\.)*)`/g;
1620
+ var OBJECT_RE = /\btw\.(server\.)?(\w+)\(\s*(\{[\s\S]*?\})\s*\)/g;
1621
+ var EXTEND_RE = /(\w+)\.extend`((?:[^`\\]|\\.)*)`/g;
1622
+ var IMPORT_RE = /from\s*["']tailwind-styled-v4["']/;
1623
+ var TRANSFORM_MARKER = "/* @tw-transformed */";
1624
+ function hasTwUsage(source) {
1625
+ return IMPORT_RE.test(source) || source.includes("tw.");
1626
+ }
1627
+ function isAlreadyTransformed(source) {
1628
+ return source.includes(TRANSFORM_MARKER);
1629
+ }
1630
+ function isDynamic(content) {
1631
+ return content.includes("${");
1632
+ }
1633
+ function isServerComponent(source) {
1634
+ return !source.includes('"use client"') && !source.includes("'use client'");
1635
+ }
1636
+ function hasInteractiveFeatures(content) {
1637
+ return /\b(hover:|focus:|active:|group-hover:|peer-|on[A-Z]|useState|useEffect|useRef)\b/.test(
1638
+ content
1639
+ );
1640
+ }
1641
+
1642
+ // ../compiler/src/astParser.ts
1643
+ function oxcKey(node) {
1644
+ if (!node) return null;
1645
+ if (node.type === "Identifier") return node.name;
1646
+ if (node.type === "Literal" && typeof node.value === "string") return node.value;
1647
+ return null;
1648
+ }
1649
+ function oxcStringVal(node) {
1650
+ var _a2;
1651
+ if (!node) return null;
1652
+ if (node.type === "Literal" && typeof node.value === "string") return node.value;
1653
+ if (node.type === "TemplateLiteral" && ((_a2 = node.expressions) == null ? void 0 : _a2.length) === 0) {
1654
+ return node.quasis.map((q) => {
1655
+ var _a3, _b2, _c, _d;
1656
+ return (_d = (_c = (_a3 = q.value) == null ? void 0 : _a3.cooked) != null ? _c : (_b2 = q.value) == null ? void 0 : _b2.raw) != null ? _d : "";
1657
+ }).join("");
1658
+ }
1659
+ return null;
1660
+ }
1661
+ function oxcWalkObject(node) {
1662
+ var _a2;
1663
+ const result = {};
1664
+ if ((node == null ? void 0 : node.type) !== "ObjectExpression") return result;
1665
+ for (const prop of (_a2 = node.properties) != null ? _a2 : []) {
1666
+ if (prop.type !== "Property") continue;
1667
+ const key = oxcKey(prop.key);
1668
+ if (!key) continue;
1669
+ const val = prop.value;
1670
+ const strVal = oxcStringVal(val);
1671
+ if (strVal !== null) {
1672
+ result[key] = strVal;
1673
+ } else if ((val == null ? void 0 : val.type) === "ObjectExpression") {
1674
+ result[key] = oxcWalkObject(val);
1675
+ } else if ((val == null ? void 0 : val.type) === "ArrayExpression") {
1676
+ result[key] = val.elements.filter((el) => (el == null ? void 0 : el.type) === "ObjectExpression").map((el) => oxcWalkObject(el));
1677
+ }
1678
+ }
1679
+ return result;
1680
+ }
1681
+ function parseWithOxc(objectStr) {
1682
+ var _a2, _b2, _c;
1683
+ let parseSync3;
1684
+ try {
1685
+ parseSync3 = (init_src_js(), __toCommonJS(src_js_exports)).parseSync;
1686
+ } catch (e) {
1687
+ return null;
1688
+ }
1689
+ try {
1690
+ const source = `const __c = ${objectStr}`;
1691
+ const { program, errors } = parseSync3("config.ts", source, { sourceType: "script" });
1692
+ if ((errors == null ? void 0 : errors.length) > 0 || !((_a2 = program == null ? void 0 : program.body) == null ? void 0 : _a2[0])) return null;
1693
+ const varDecl = program.body[0];
1694
+ if (varDecl.type !== "VariableDeclaration") return null;
1695
+ const init = (_c = (_b2 = varDecl.declarations) == null ? void 0 : _b2[0]) == null ? void 0 : _c.init;
1696
+ if ((init == null ? void 0 : init.type) !== "ObjectExpression") return null;
1697
+ const raw = oxcWalkObject(init);
1698
+ const base = typeof raw.base === "string" ? raw.base.trim() : "";
1699
+ const variants = {};
1700
+ const rawVariants = raw.variants;
1701
+ if (rawVariants && typeof rawVariants === "object" && !Array.isArray(rawVariants)) {
1702
+ for (const [vName, vMap] of Object.entries(rawVariants)) {
1703
+ if (vMap && typeof vMap === "object" && !Array.isArray(vMap)) {
1704
+ variants[vName] = {};
1705
+ for (const [vVal, cls] of Object.entries(vMap)) {
1706
+ if (typeof cls === "string") variants[vName][vVal] = cls.trim();
1707
+ }
1708
+ }
1709
+ }
1710
+ }
1711
+ const compounds = [];
1712
+ const rawCompounds = raw.compoundVariants;
1713
+ if (Array.isArray(rawCompounds)) {
1714
+ for (const item of rawCompounds) {
1715
+ if (item && typeof item.class === "string") {
1716
+ compounds.push(item);
1717
+ }
1718
+ }
1719
+ }
1720
+ const defaults = {};
1721
+ const rawDefaults = raw.defaultVariants;
1722
+ if (rawDefaults && typeof rawDefaults === "object" && !Array.isArray(rawDefaults)) {
1723
+ for (const [k, v] of Object.entries(rawDefaults)) {
1724
+ if (typeof v === "string") defaults[k] = v;
1725
+ }
1726
+ }
1727
+ return { base, variants, compounds, defaults };
1728
+ } catch (e) {
1729
+ return null;
1730
+ }
1731
+ }
1732
+ function tokenize(src) {
1733
+ const tokens = [];
1734
+ let i = 0;
1735
+ while (i < src.length) {
1736
+ const ch = src[i];
1737
+ if (/\s/.test(ch)) {
1738
+ i++;
1739
+ continue;
1740
+ }
1741
+ if (ch === '"' || ch === "'" || ch === "`") {
1742
+ const quote = ch;
1743
+ let j = i + 1;
1744
+ let str = ch;
1745
+ while (j < src.length) {
1746
+ if (src[j] === "\\" && quote !== "`") {
1747
+ str += src[j] + src[j + 1];
1748
+ j += 2;
1749
+ continue;
1750
+ }
1751
+ if (src[j] === "\\" && quote === "`") {
1752
+ str += src[j] + src[j + 1];
1753
+ j += 2;
1754
+ continue;
1755
+ }
1756
+ str += src[j];
1757
+ if (src[j] === quote) {
1758
+ j++;
1759
+ break;
1760
+ }
1761
+ j++;
1762
+ }
1763
+ tokens.push({ type: "string", value: str.slice(1, -1), pos: i });
1764
+ i = j;
1765
+ continue;
1766
+ }
1767
+ if (ch === ":") {
1768
+ tokens.push({ type: "colon", value: ":", pos: i });
1769
+ i++;
1770
+ continue;
1771
+ }
1772
+ if (ch === ",") {
1773
+ tokens.push({ type: "comma", value: ",", pos: i });
1774
+ i++;
1775
+ continue;
1776
+ }
1777
+ if (ch === "{") {
1778
+ tokens.push({ type: "lbrace", value: "{", pos: i });
1779
+ i++;
1780
+ continue;
1781
+ }
1782
+ if (ch === "}") {
1783
+ tokens.push({ type: "rbrace", value: "}", pos: i });
1784
+ i++;
1785
+ continue;
1786
+ }
1787
+ if (ch === "[") {
1788
+ tokens.push({ type: "lbracket", value: "[", pos: i });
1789
+ i++;
1790
+ continue;
1791
+ }
1792
+ if (ch === "]") {
1793
+ tokens.push({ type: "rbracket", value: "]", pos: i });
1794
+ i++;
1795
+ continue;
1796
+ }
1797
+ if (/[\w$]/.test(ch)) {
1798
+ let j = i;
1799
+ while (j < src.length && /[\w$]/.test(src[j])) j++;
1800
+ tokens.push({ type: "key", value: src.slice(i, j), pos: i });
1801
+ i = j;
1802
+ continue;
1803
+ }
1804
+ tokens.push({ type: "other", value: ch, pos: i });
1805
+ i++;
1806
+ }
1807
+ return tokens;
1808
+ }
1809
+ function parseObject(tokens, startIdx) {
1810
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
1811
+ const obj = {};
1812
+ let i = startIdx;
1813
+ if (((_a2 = tokens[i]) == null ? void 0 : _a2.type) !== "lbrace") return { obj, endIdx: i };
1814
+ i++;
1815
+ while (i < tokens.length && ((_b2 = tokens[i]) == null ? void 0 : _b2.type) !== "rbrace") {
1816
+ if (((_c = tokens[i]) == null ? void 0 : _c.type) === "comma") {
1817
+ i++;
1818
+ continue;
1819
+ }
1820
+ let key = null;
1821
+ if (((_d = tokens[i]) == null ? void 0 : _d.type) === "string") {
1822
+ key = tokens[i].value;
1823
+ i++;
1824
+ } else if (((_e = tokens[i]) == null ? void 0 : _e.type) === "key") {
1825
+ key = tokens[i].value;
1826
+ i++;
1827
+ } else {
1828
+ i++;
1829
+ continue;
1830
+ }
1831
+ if (((_f = tokens[i]) == null ? void 0 : _f.type) !== "colon") continue;
1832
+ i++;
1833
+ if (((_g = tokens[i]) == null ? void 0 : _g.type) === "lbrace") {
1834
+ const { obj: nested, endIdx } = parseObject(tokens, i);
1835
+ obj[key] = nested;
1836
+ i = endIdx + 1;
1837
+ } else if (((_h = tokens[i]) == null ? void 0 : _h.type) === "lbracket") {
1838
+ const { arr, endIdx } = parseArray(tokens, i);
1839
+ obj[key] = arr;
1840
+ i = endIdx + 1;
1841
+ } else if (((_i = tokens[i]) == null ? void 0 : _i.type) === "string") {
1842
+ obj[key] = tokens[i].value;
1843
+ i++;
1844
+ } else if (((_j = tokens[i]) == null ? void 0 : _j.type) === "key") {
1845
+ obj[key] = tokens[i].value;
1846
+ i++;
1847
+ } else {
1848
+ i++;
1849
+ }
1850
+ }
1851
+ return { obj, endIdx: i };
1852
+ }
1853
+ function parseArray(tokens, startIdx) {
1854
+ var _a2, _b2, _c, _d;
1855
+ const arr = [];
1856
+ let i = startIdx;
1857
+ if (((_a2 = tokens[i]) == null ? void 0 : _a2.type) !== "lbracket") return { arr, endIdx: i };
1858
+ i++;
1859
+ while (i < tokens.length && ((_b2 = tokens[i]) == null ? void 0 : _b2.type) !== "rbracket") {
1860
+ if (((_c = tokens[i]) == null ? void 0 : _c.type) === "comma") {
1861
+ i++;
1862
+ continue;
1863
+ }
1864
+ if (((_d = tokens[i]) == null ? void 0 : _d.type) === "lbrace") {
1865
+ const { obj, endIdx } = parseObject(tokens, i);
1866
+ arr.push(obj);
1867
+ i = endIdx + 1;
1868
+ } else {
1869
+ i++;
1870
+ }
1871
+ }
1872
+ return { arr, endIdx: i };
1873
+ }
1874
+ function parseComponentConfigFallback(objectStr) {
1875
+ const tokens = tokenize(objectStr);
1876
+ const { obj } = parseObject(tokens, 0);
1877
+ const base = typeof obj.base === "string" ? obj.base.trim() : "";
1878
+ const variants = {};
1879
+ const rawVariants = obj.variants;
1880
+ if (rawVariants && typeof rawVariants === "object" && !Array.isArray(rawVariants)) {
1881
+ for (const [variantName, variantValues] of Object.entries(rawVariants)) {
1882
+ if (typeof variantValues === "object" && !Array.isArray(variantValues)) {
1883
+ variants[variantName] = {};
1884
+ for (const [valueName, cls] of Object.entries(variantValues)) {
1885
+ if (typeof cls === "string") variants[variantName][valueName] = cls.trim();
1886
+ }
1887
+ }
1888
+ }
1889
+ }
1890
+ const compounds = [];
1891
+ const rawCompounds = obj.compoundVariants;
1892
+ if (Array.isArray(rawCompounds)) {
1893
+ for (const item of rawCompounds) {
1894
+ if (item && typeof item.class === "string") compounds.push(item);
1895
+ }
1896
+ }
1897
+ const defaults = {};
1898
+ const rawDefaults = obj.defaultVariants;
1899
+ if (rawDefaults && typeof rawDefaults === "object" && !Array.isArray(rawDefaults)) {
1900
+ for (const [k, v] of Object.entries(rawDefaults)) {
1901
+ if (typeof v === "string") defaults[k] = v;
1902
+ }
1903
+ }
1904
+ return { base, variants, compounds, defaults };
1905
+ }
1906
+ function parseComponentConfig(objectStr) {
1907
+ const oxcResult = parseWithOxc(objectStr);
1908
+ if (oxcResult !== null) return oxcResult;
1909
+ return parseComponentConfigFallback(objectStr);
1910
+ }
1911
+
1912
+ // ../compiler/src/variantCompiler.ts
1913
+ function compileVariants(base, variants, compounds = [], defaults = {}) {
1914
+ const table = {};
1915
+ for (const key in variants) {
1916
+ table[key] = {};
1917
+ for (const val in variants[key]) {
1918
+ table[key][val] = normalizeClasses(variants[key][val]);
1919
+ }
1920
+ }
1921
+ return { base, table, compounds, defaults };
1922
+ }
1923
+ function generateVariantCode(id, compiled) {
1924
+ const { table, compounds, defaults } = compiled;
1925
+ const tableJson = JSON.stringify(table, null, 2);
1926
+ const compoundsJson = JSON.stringify(compounds, null, 2);
1927
+ const defaultsJson = JSON.stringify(defaults, null, 2);
1928
+ return `const __vt_${id} = ${tableJson};
1929
+ const __vc_${id} = ${compoundsJson};
1930
+ const __vd_${id} = ${defaultsJson};`;
1931
+ }
1932
+ function parseObjectConfig(objectStr) {
1933
+ return parseComponentConfig(objectStr);
1934
+ }
1935
+
1936
+ // ../compiler/src/astTransform.ts
1937
+ var TEMPLATE_RE2 = /\btw\.(server\.)?(\w+)`((?:[^`\\]|\\.)*)`/g;
1938
+ var OBJECT_RE2 = /\btw\.(server\.)?(\w+)\(\s*(\{[\s\S]*?\})\s*\)/g;
1939
+ var EXTEND_RE2 = /(\w+)\.extend`((?:[^`\\]|\\.)*)`/g;
1940
+ var WRAP_RE = /\btw\((\w+)\)`((?:[^`\\]|\\.)*)`/g;
1941
+ var _idCounter = 0;
1942
+ function genId() {
1943
+ return `c${(++_idCounter).toString(36)}`;
1944
+ }
1945
+ function renderStaticComponent(tag, classes, opts) {
1946
+ const { addDataAttr, compName } = opts;
1947
+ const fnName = compName ? `_Tw_${compName}` : `_Tw_${tag}`;
1948
+ const dataAttr = addDataAttr ? `, "data-tw": "${fnName}:${classes.split(" ").slice(0, 3).join(" ")}${classes.split(" ").length > 3 ? "..." : ""}"` : "";
1949
+ return `React.forwardRef(function ${fnName}(props, ref) {
1950
+ var _c = props.className;
1951
+ var _r = Object.assign({}, props);
1952
+ delete _r.className;
1953
+ return React.createElement("${tag}", Object.assign({ ref }, _r${dataAttr}, { className: [${JSON.stringify(classes)}, _c].filter(Boolean).join(" ") }));
1954
+ })`;
1955
+ }
1956
+ function renderVariantComponent(tag, id, base, variantKeys, defaults, opts) {
1957
+ const { addDataAttr } = opts;
1958
+ const fnName = `_TwV_${tag}_${id}`;
1959
+ const dataAttr = addDataAttr ? `, "data-tw": "${fnName}"` : "";
1960
+ const vKeys = variantKeys.map((k) => `"${k}"`).join(", ");
1961
+ const destructure = variantKeys.length > 0 ? `var _vp = {}; [${vKeys}].forEach(function(k){ _vp[k] = props[k]; delete _rest[k]; });` : "";
1962
+ const variantLookup = variantKeys.length > 0 ? variantKeys.map(
1963
+ (k) => {
1964
+ var _a2;
1965
+ return `(__vt_${id}["${k}"] && __vt_${id}["${k}"][_vp["${k}"] ?? ${JSON.stringify((_a2 = defaults[k]) != null ? _a2 : "")}] || "")`;
1966
+ }
1967
+ ).join(", ") : "";
1968
+ const classParts = variantKeys.length > 0 ? `[${JSON.stringify(base)}, ${variantLookup}, _rest.className]` : `[${JSON.stringify(base)}, _rest.className]`;
1969
+ return `React.forwardRef(function ${fnName}(props, ref) {
1970
+ var _rest = Object.assign({}, props);
1971
+ delete _rest.className;
1972
+ ${destructure}
1973
+ return React.createElement("${tag}", Object.assign({ ref }, _rest${dataAttr}, { className: ${classParts}.filter(Boolean).join(" ") }));
1974
+ })`;
1975
+ }
1976
+ function transformSource(source, opts = {}) {
1977
+ const {
1978
+ mode = "zero-runtime",
1979
+ autoClientBoundary = true,
1980
+ addDataAttr = false,
1981
+ hoist = true,
1982
+ filename = ""
1983
+ } = opts;
1984
+ if (!hasTwUsage(source)) {
1985
+ return { code: source, classes: [], changed: false };
1986
+ }
1987
+ if (isAlreadyTransformed(source)) {
1988
+ return { code: source, classes: [], changed: false };
1989
+ }
1990
+ if (mode === "runtime" || mode === "extract-only") {
1991
+ return { code: source, classes: [], changed: false };
1992
+ }
1993
+ const rscAnalysis = analyzeFile(source, filename);
1994
+ let code = source;
1995
+ if (hoist) {
1996
+ const hoistResult = hoistComponents(source);
1997
+ if (hoistResult.hoisted.length > 0) {
1998
+ code = hoistResult.code;
1999
+ if (process.env.NODE_ENV !== "production") {
2000
+ for (const w of hoistResult.warnings) {
2001
+ console.warn(w);
2002
+ }
2003
+ }
2004
+ }
2005
+ }
2006
+ let changed = false;
2007
+ const allClasses = [];
2008
+ const prelude = [];
2009
+ let needsReact = false;
2010
+ code = code.replace(
2011
+ TEMPLATE_RE2,
2012
+ (match, serverMark, tag, content) => {
2013
+ if (isDynamic(content)) return match;
2014
+ const classes = normalizeClasses(content);
2015
+ if (!classes) return match;
2016
+ const isServerOnly = !!serverMark;
2017
+ allClasses.push(...classes.split(/\s+/).filter(Boolean));
2018
+ changed = true;
2019
+ needsReact = true;
2020
+ const rendered = renderStaticComponent(tag, classes, {
2021
+ addDataAttr,
2022
+ isServer: rscAnalysis.isServer || isServerOnly
2023
+ });
2024
+ return isServerOnly ? `/* @server-only */ ${rendered}` : rendered;
2025
+ }
2026
+ );
2027
+ code = code.replace(
2028
+ OBJECT_RE2,
2029
+ (match, serverMark, tag, objectStr) => {
2030
+ const { base, variants, compounds, defaults } = parseObjectConfig(objectStr);
2031
+ if (!base && Object.keys(variants).length === 0) return match;
2032
+ const isServerOnly = !!serverMark;
2033
+ allClasses.push(...base.split(/\s+/).filter(Boolean));
2034
+ for (const vMap of Object.values(variants)) {
2035
+ for (const cls of Object.values(vMap)) {
2036
+ allClasses.push(...cls.split(/\s+/).filter(Boolean));
2037
+ }
2038
+ }
2039
+ changed = true;
2040
+ needsReact = true;
2041
+ const id = genId();
2042
+ const compiled = compileVariants(base, variants, compounds, defaults);
2043
+ prelude.push(generateVariantCode(id, compiled));
2044
+ const variantKeys = Object.keys(variants);
2045
+ const rendered = renderVariantComponent(tag, id, base, variantKeys, defaults, {
2046
+ addDataAttr,
2047
+ isServer: rscAnalysis.isServer || isServerOnly
2048
+ });
2049
+ return isServerOnly ? `/* @server-only */ ${rendered}` : rendered;
2050
+ }
2051
+ );
2052
+ code = code.replace(WRAP_RE, (match, compName, content) => {
2053
+ if (isDynamic(content)) return match;
2054
+ const classes = normalizeClasses(content);
2055
+ if (!classes) return match;
2056
+ allClasses.push(...classes.split(/\s+/).filter(Boolean));
2057
+ changed = true;
2058
+ needsReact = true;
2059
+ return `React.forwardRef(function _TwWrap_${compName}(props, ref) {
2060
+ var _c = [${JSON.stringify(classes)}, props.className].filter(Boolean).join(" ");
2061
+ return React.createElement(${compName}, Object.assign({}, props, { ref, className: _c }));
2062
+ })`;
2063
+ });
2064
+ code = code.replace(EXTEND_RE2, (match, compName, content) => {
2065
+ if (isDynamic(content)) return match;
2066
+ const extra = normalizeClasses(content);
2067
+ if (!extra) return match;
2068
+ allClasses.push(...extra.split(/\s+/).filter(Boolean));
2069
+ changed = true;
2070
+ needsReact = true;
2071
+ return `React.forwardRef(function _TwExt_${compName}(props, ref) {
2072
+ var _c = [${JSON.stringify(extra)}, props.className].filter(Boolean).join(" ");
2073
+ return React.createElement(${compName}, Object.assign({}, props, { ref, className: _c }));
2074
+ })`;
2075
+ });
2076
+ if (!changed) {
2077
+ return { code: source, classes: [], rsc: rscAnalysis, changed: false };
2078
+ }
2079
+ if (prelude.length > 0) {
2080
+ const importEnd = findAfterImports2(code);
2081
+ code = `${code.slice(0, importEnd)}
2082
+ ${prelude.join("\n")}
2083
+ ${code.slice(importEnd)}`;
2084
+ }
2085
+ if (needsReact && !hasReactImport(source)) {
2086
+ code = `import React from "react";
2087
+ ${code}`;
2088
+ }
2089
+ if (autoClientBoundary && rscAnalysis.needsClientDirective) {
2090
+ code = injectClientDirective(code);
2091
+ }
2092
+ const stillUsesTw = /\btw\.(server\.)?\w+[`(]/.test(code) || /\btw\(\w+\)/.test(code);
2093
+ if (!stillUsesTw) {
2094
+ code = code.replace(
2095
+ /import\s*\{[^}]*\btw\b[^}]*\}\s*from\s*["']tailwind-styled-v4["'];?\n?/g,
2096
+ ""
2097
+ );
2098
+ }
2099
+ code = `${TRANSFORM_MARKER}
2100
+ ${code}`;
2101
+ return {
2102
+ code,
2103
+ classes: Array.from(new Set(allClasses)),
2104
+ rsc: {
2105
+ isServer: rscAnalysis.isServer,
2106
+ needsClientDirective: rscAnalysis.needsClientDirective,
2107
+ clientReasons: rscAnalysis.clientReasons
2108
+ },
2109
+ changed: true
2110
+ };
2111
+ }
2112
+ function hasReactImport(source) {
2113
+ return source.includes("import React") || source.includes("from 'react'") || source.includes('from "react"');
2114
+ }
2115
+ function findAfterImports2(source) {
2116
+ const lines = source.split("\n");
2117
+ let lastImportIdx = 0;
2118
+ for (let i = 0; i < lines.length; i++) {
2119
+ const line = lines[i].trim();
2120
+ if (line.startsWith("import ") || line.startsWith('"use client"') || line.startsWith("'use client'") || line.startsWith(TRANSFORM_MARKER) || line === "") {
2121
+ lastImportIdx = i;
2122
+ } else if (line && !line.startsWith("//") && !line.startsWith("/*")) {
2123
+ break;
2124
+ }
2125
+ }
2126
+ return lines.slice(0, lastImportIdx + 1).join("\n").length + 1;
2127
+ }
2128
+
2129
+ // ../compiler/src/index.ts
2130
+ init_atomicCss();
2131
+
2132
+ // ../compiler/src/classExtractor.ts
2133
+ var VALID_CLASS_RE = /^[-a-z0-9:/[\]!.()+%]+$/;
2134
+ function parseClasses(raw) {
2135
+ return raw.split(/[\n\s]+/).map((c) => c.trim()).filter((c) => c.length > 0 && VALID_CLASS_RE.test(c));
2136
+ }
2137
+ function extractAllClasses(source) {
2138
+ const classes = /* @__PURE__ */ new Set();
2139
+ const add = (str) => {
2140
+ for (const c of parseClasses(str)) classes.add(c);
2141
+ };
2142
+ let m;
2143
+ const re1 = new RegExp(TEMPLATE_RE.source, "g");
2144
+ while ((m = re1.exec(source)) !== null) {
2145
+ add(m[3]);
2146
+ }
2147
+ const re2 = new RegExp(OBJECT_RE.source, "g");
2148
+ while ((m = re2.exec(source)) !== null) {
2149
+ const parsed = parseComponentConfig(m[3]);
2150
+ if (parsed.base) add(parsed.base);
2151
+ for (const vMap of Object.values(parsed.variants)) {
2152
+ for (const cls of Object.values(vMap)) add(cls);
2153
+ }
2154
+ for (const compound of parsed.compounds) {
2155
+ if (compound.class) add(compound.class);
2156
+ }
2157
+ }
2158
+ const re3 = new RegExp(EXTEND_RE.source, "g");
2159
+ while ((m = re3.exec(source)) !== null) add(m[2]);
2160
+ const classNameRe = /className\s*=\s*["']([^"']+)["']/g;
2161
+ while ((m = classNameRe.exec(source)) !== null) add(m[1]);
2162
+ return Array.from(classes).sort();
2163
+ }
2164
+ function extractComponentUsage(source) {
2165
+ const usage = {};
2166
+ const jsxRe = /<([A-Z][A-Za-z0-9]*)\s([^>]*?)(?:\/?>)/g;
2167
+ let m;
2168
+ while ((m = jsxRe.exec(source)) !== null) {
2169
+ const compName = m[1];
2170
+ const propsStr = m[2];
2171
+ if (!usage[compName]) usage[compName] = {};
2172
+ const propRe = /(\w+)=["']([^"']+)["']/g;
2173
+ let p;
2174
+ while ((p = propRe.exec(propsStr)) !== null) {
2175
+ const [, propName, propValue] = p;
2176
+ if (["className", "style", "id", "href", "src", "alt", "type"].includes(propName)) continue;
2177
+ if (!usage[compName][propName]) {
2178
+ usage[compName][propName] = /* @__PURE__ */ new Set();
2179
+ }
2180
+ usage[compName][propName].add(propValue);
2181
+ }
2182
+ }
2183
+ return usage;
2184
+ }
2185
+ var SCAN_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
2186
+ var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".next", "dist", ".git", "out"]);
2187
+ function scanFiles(dir) {
2188
+ const files = [];
2189
+ function walk(current) {
2190
+ if (!fs2__default.default.existsSync(current)) return;
2191
+ const entries = fs2__default.default.readdirSync(current, { withFileTypes: true });
2192
+ for (const entry of entries) {
2193
+ if (SKIP_DIRS.has(entry.name)) continue;
2194
+ const fullPath = path4__default.default.join(current, entry.name);
2195
+ if (entry.isDirectory()) {
2196
+ walk(fullPath);
2197
+ } else if (SCAN_EXTENSIONS.some((ext) => entry.name.endsWith(ext))) {
2198
+ files.push(fullPath);
2199
+ }
2200
+ }
2201
+ }
2202
+ walk(dir);
2203
+ return files;
2204
+ }
2205
+ function scanProjectUsage(dirs, cwd = process.cwd()) {
2206
+ const combined = {};
2207
+ for (const dir of dirs) {
2208
+ const absDir = path4__default.default.isAbsolute(dir) ? dir : path4__default.default.resolve(cwd, dir);
2209
+ const files = scanFiles(absDir);
2210
+ for (const file of files) {
2211
+ try {
2212
+ const source = fs2__default.default.readFileSync(file, "utf-8");
2213
+ const usage = extractComponentUsage(source);
2214
+ for (const [comp, props] of Object.entries(usage)) {
2215
+ if (!combined[comp]) combined[comp] = {};
2216
+ for (const [prop, values] of Object.entries(props)) {
2217
+ if (!combined[comp][prop]) combined[comp][prop] = /* @__PURE__ */ new Set();
2218
+ values.forEach((v) => combined[comp][prop].add(v));
2219
+ }
2220
+ }
2221
+ } catch (e) {
2222
+ }
2223
+ }
2224
+ }
2225
+ return combined;
2226
+ }
2227
+ function findDeadVariants(registered, projectUsage) {
2228
+ var _a2, _b2;
2229
+ const report = {
2230
+ unusedCount: 0,
2231
+ bytesSaved: 0,
2232
+ components: {}
2233
+ };
2234
+ for (const component of registered) {
2235
+ const usage = (_a2 = projectUsage[component.name]) != null ? _a2 : {};
2236
+ const usedVariants = {};
2237
+ const unusedVariants = {};
2238
+ for (const [variantKey, variantValues] of Object.entries(component.variants)) {
2239
+ usedVariants[variantKey] = [];
2240
+ unusedVariants[variantKey] = [];
2241
+ const usedValueSet = (_b2 = usage[variantKey]) != null ? _b2 : /* @__PURE__ */ new Set();
2242
+ for (const [valueName, classes] of Object.entries(variantValues)) {
2243
+ if (usedValueSet.has(valueName)) {
2244
+ usedVariants[variantKey].push(valueName);
2245
+ } else {
2246
+ unusedVariants[variantKey].push(valueName);
2247
+ report.unusedCount++;
2248
+ report.bytesSaved += classes.split(/\s+/).length * 20;
2249
+ }
2250
+ }
2251
+ }
2252
+ if (report.unusedCount > 0) {
2253
+ report.components[component.name] = { usedVariants, unusedVariants };
2254
+ }
2255
+ }
2256
+ return report;
2257
+ }
2258
+ function eliminateDeadCss(css, deadClasses) {
2259
+ if (deadClasses.size === 0) return css;
2260
+ const lines = css.split("\n");
2261
+ const kept = [];
2262
+ let inBlock = false;
2263
+ let removeBlock = false;
2264
+ let depth = 0;
2265
+ for (const line of lines) {
2266
+ if (!inBlock) {
2267
+ const isDead = Array.from(deadClasses).some((cls) => {
2268
+ const escaped = cls.replace(/[:/[\].!%]/g, "\\$&");
2269
+ return line.includes(`.${escaped}`) || line.includes(`.${cls}`);
2270
+ });
2271
+ if (isDead && line.includes("{")) {
2272
+ removeBlock = true;
2273
+ inBlock = true;
2274
+ depth = 1;
2275
+ continue;
2276
+ } else if (line.includes("{") && !line.trim().startsWith("@")) {
2277
+ inBlock = true;
2278
+ depth = 1;
2279
+ removeBlock = false;
2280
+ }
2281
+ } else {
2282
+ if (line.includes("{")) depth++;
2283
+ if (line.includes("}")) {
2284
+ depth--;
2285
+ if (depth <= 0) {
2286
+ inBlock = false;
2287
+ if (removeBlock) {
2288
+ removeBlock = false;
2289
+ continue;
2290
+ }
2291
+ }
2292
+ }
2293
+ if (removeBlock) continue;
2294
+ }
2295
+ kept.push(line);
2296
+ }
2297
+ return kept.join("\n");
2298
+ }
2299
+ function optimizeCss(css) {
2300
+ const ruleMap = /* @__PURE__ */ new Map();
2301
+ const ruleRe = /^(\.[\w-]+)\s*\{([^}]+)\}$/gm;
2302
+ const mediaRe = /@media[^{]+\{[\s\S]*?\}\s*\}/g;
2303
+ let m;
2304
+ let remaining = css;
2305
+ const mediaBlocks = [];
2306
+ remaining = remaining.replace(mediaRe, (block) => {
2307
+ mediaBlocks.push(block);
2308
+ return "";
2309
+ });
2310
+ while ((m = ruleRe.exec(remaining)) !== null) {
2311
+ const selector = m[1].trim();
2312
+ const declaration = m[2].trim();
2313
+ if (!ruleMap.has(declaration)) {
2314
+ ruleMap.set(declaration, /* @__PURE__ */ new Set());
2315
+ }
2316
+ ruleMap.get(declaration).add(selector);
2317
+ }
2318
+ const lines = [];
2319
+ for (const [declaration, selectors] of ruleMap) {
2320
+ lines.push(`${Array.from(selectors).join(",")} { ${declaration} }`);
2321
+ }
2322
+ lines.push(...mediaBlocks);
2323
+ return lines.join("\n");
2324
+ }
2325
+ function runElimination(opts) {
2326
+ const { dirs = ["src"], cwd = process.cwd(), registered = [], inputCss, verbose = false } = opts;
2327
+ const usage = scanProjectUsage(dirs, cwd);
2328
+ const report = findDeadVariants(registered, usage);
2329
+ const deadClasses = /* @__PURE__ */ new Set();
2330
+ for (const [, { unusedVariants }] of Object.entries(report.components)) {
2331
+ for (const values of Object.values(unusedVariants)) {
2332
+ values.forEach((v) => deadClasses.add(v));
2333
+ }
2334
+ }
2335
+ let css = eliminateDeadCss(inputCss, deadClasses);
2336
+ css = optimizeCss(css);
2337
+ if (verbose) {
2338
+ const saved = (report.bytesSaved / 1024).toFixed(1);
2339
+ console.log(`[tailwind-styled-v4] Dead style elimination:`);
2340
+ console.log(` Unused variants: ${report.unusedCount}`);
2341
+ console.log(` Estimated savings: ~${saved}KB`);
2342
+ for (const [comp, { unusedVariants }] of Object.entries(report.components)) {
2343
+ for (const [variant, values] of Object.entries(unusedVariants)) {
2344
+ if (values.length > 0) {
2345
+ console.log(` ${comp}.${variant}: ${values.join(", ")} (unused)`);
2346
+ }
2347
+ }
2348
+ }
2349
+ }
2350
+ return { css, report };
2351
+ }
2352
+ var CACHE_DIR = ".tw-cache";
2353
+ var HASH_CACHE_FILE = path4__default.default.join(CACHE_DIR, "file-hashes.json");
2354
+ var GRAPH_CACHE_FILE = path4__default.default.join(CACHE_DIR, "dep-graph.json");
2355
+ function ensureCacheDir() {
2356
+ if (!fs2__default.default.existsSync(CACHE_DIR)) {
2357
+ fs2__default.default.mkdirSync(CACHE_DIR, { recursive: true });
2358
+ }
2359
+ }
2360
+ function loadHashCache() {
2361
+ try {
2362
+ if (fs2__default.default.existsSync(HASH_CACHE_FILE)) {
2363
+ const raw = fs2__default.default.readFileSync(HASH_CACHE_FILE, "utf-8");
2364
+ return new Map(Object.entries(JSON.parse(raw)));
2365
+ }
2366
+ } catch (e) {
2367
+ }
2368
+ return /* @__PURE__ */ new Map();
2369
+ }
2370
+ function saveHashCache(cache) {
2371
+ try {
2372
+ ensureCacheDir();
2373
+ const obj = Object.fromEntries(cache);
2374
+ fs2__default.default.writeFileSync(HASH_CACHE_FILE, JSON.stringify(obj, null, 2));
2375
+ } catch (e) {
2376
+ }
2377
+ }
2378
+ function loadGraphCache() {
2379
+ try {
2380
+ if (fs2__default.default.existsSync(GRAPH_CACHE_FILE)) {
2381
+ const raw = fs2__default.default.readFileSync(GRAPH_CACHE_FILE, "utf-8");
2382
+ const data = JSON.parse(raw);
2383
+ return new Map(Object.entries(data));
2384
+ }
2385
+ } catch (e) {
2386
+ }
2387
+ return /* @__PURE__ */ new Map();
2388
+ }
2389
+ function saveGraphCache(graph) {
2390
+ try {
2391
+ ensureCacheDir();
2392
+ const obj = Object.fromEntries(graph);
2393
+ fs2__default.default.writeFileSync(GRAPH_CACHE_FILE, JSON.stringify(obj, null, 2));
2394
+ } catch (e) {
2395
+ }
2396
+ }
2397
+ function fnv1a(str) {
2398
+ let h = 2166136261;
2399
+ for (let i = 0; i < str.length; i++) {
2400
+ h ^= str.charCodeAt(i);
2401
+ h = h * 16777619 >>> 0;
2402
+ }
2403
+ return h;
2404
+ }
2405
+ function toBase36(n, len = 4) {
2406
+ const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
2407
+ let result = "";
2408
+ let num = n;
2409
+ for (let i = 0; i < len; i++) {
2410
+ result = chars[num % 36] + result;
2411
+ num = Math.floor(num / 36);
2412
+ }
2413
+ return result;
2414
+ }
2415
+ function hashFileContent(content) {
2416
+ return crypto__default.default.createHash("md5").update(content).digest("hex").slice(0, 8);
2417
+ }
2418
+ function makeAtomicClass(declaration, modifier) {
2419
+ const key = modifier ? `${declaration}::${modifier}` : declaration;
2420
+ return `tw-${toBase36(fnv1a(key))}`;
2421
+ }
2422
+ function computeDiff(oldNodes, newNodes) {
2423
+ const oldMap = new Map(oldNodes.map((n) => [n.atomicClass, n]));
2424
+ const newMap = new Map(newNodes.map((n) => [n.atomicClass, n]));
2425
+ const added = [];
2426
+ const removed = [];
2427
+ for (const [cls, node] of newMap) {
2428
+ if (!oldMap.has(cls)) added.push(node);
2429
+ }
2430
+ for (const cls of oldMap.keys()) {
2431
+ if (!newMap.has(cls)) removed.push(cls);
2432
+ }
2433
+ return {
2434
+ added,
2435
+ removed,
2436
+ noChange: added.length === 0 && removed.length === 0
2437
+ };
2438
+ }
2439
+ var GlobalAtomicRegistry = class {
2440
+ constructor() {
2441
+ this.entries = /* @__PURE__ */ new Map();
2442
+ }
2443
+ /** Tambah node dari file tertentu */
2444
+ add(filepath, node) {
2445
+ const existing = this.entries.get(node.atomicClass);
2446
+ if (existing) {
2447
+ existing.sources.add(filepath);
2448
+ } else {
2449
+ this.entries.set(node.atomicClass, {
2450
+ node,
2451
+ sources: /* @__PURE__ */ new Set([filepath])
2452
+ });
2453
+ }
2454
+ }
2455
+ /** Hapus referensi dari file tertentu; jika tidak ada source lain, rule dihapus */
2456
+ remove(filepath, atomicClass) {
2457
+ const entry = this.entries.get(atomicClass);
2458
+ if (!entry) return false;
2459
+ entry.sources.delete(filepath);
2460
+ if (entry.sources.size === 0) {
2461
+ this.entries.delete(atomicClass);
2462
+ return true;
2463
+ }
2464
+ return false;
2465
+ }
2466
+ /** Cek apakah rule ada di registry global */
2467
+ has(atomicClass) {
2468
+ return this.entries.has(atomicClass);
2469
+ }
2470
+ /** Semua entries untuk CSS generation */
2471
+ all() {
2472
+ return Array.from(this.entries.values()).map((e) => e.node);
2473
+ }
2474
+ /** Total unique rules */
2475
+ size() {
2476
+ return this.entries.size;
2477
+ }
2478
+ };
2479
+ function nodeToCSS(node) {
2480
+ const { atomicClass, declaration, modifier } = node;
2481
+ if (!modifier) {
2482
+ return `.${atomicClass}{${declaration}}`;
2483
+ }
2484
+ if (modifier.startsWith("@")) {
2485
+ return `${modifier}{.${atomicClass}{${declaration}}}`;
2486
+ }
2487
+ return `.${atomicClass}${modifier}{${declaration}}`;
2488
+ }
2489
+ var CssDiffWriter = class {
2490
+ constructor(outputPath) {
2491
+ this.ruleMap = /* @__PURE__ */ new Map();
2492
+ this.dirty = false;
2493
+ this.outputPath = outputPath;
2494
+ this.loadFromDisk();
2495
+ }
2496
+ loadFromDisk() {
2497
+ try {
2498
+ if (fs2__default.default.existsSync(this.outputPath)) {
2499
+ const css = fs2__default.default.readFileSync(this.outputPath, "utf-8");
2500
+ const ruleRe = /(\.tw-[a-z0-9]+(?::[\w-]+)?)\{([^}]+)\}|(@[^{]+)\{(\.tw-[a-z0-9]+)\{([^}]+)\}\}/g;
2501
+ let m;
2502
+ while ((m = ruleRe.exec(css)) !== null) {
2503
+ if (m[1]) {
2504
+ const cls = m[1].replace(/\.[^:]+:.*/, (match) => match.split(".")[1].split(":")[0]);
2505
+ this.ruleMap.set(cls, m[0]);
2506
+ }
2507
+ }
2508
+ }
2509
+ } catch (e) {
2510
+ }
2511
+ }
2512
+ /** Apply diff ke internal map */
2513
+ applyDiff(diff) {
2514
+ if (diff.noChange) return;
2515
+ for (const node of diff.added) {
2516
+ this.ruleMap.set(node.atomicClass, nodeToCSS(node));
2517
+ }
2518
+ for (const cls of diff.removed) {
2519
+ this.ruleMap.delete(cls);
2520
+ }
2521
+ this.dirty = true;
2522
+ }
2523
+ /** Write ke disk jika ada perubahan. Async untuk tidak block loader. */
2524
+ async flush() {
2525
+ if (!this.dirty) return;
2526
+ try {
2527
+ ensureCacheDir();
2528
+ const css = Array.from(this.ruleMap.values()).join("\n");
2529
+ await fs2__default.default.promises.writeFile(this.outputPath, css, "utf-8");
2530
+ this.dirty = false;
2531
+ } catch (e) {
2532
+ }
2533
+ }
2534
+ /** Sync flush untuk build end */
2535
+ flushSync() {
2536
+ if (!this.dirty) return;
2537
+ try {
2538
+ ensureCacheDir();
2539
+ const css = Array.from(this.ruleMap.values()).join("\n");
2540
+ fs2__default.default.writeFileSync(this.outputPath, css, "utf-8");
2541
+ this.dirty = false;
2542
+ } catch (e) {
2543
+ }
2544
+ }
2545
+ size() {
2546
+ return this.ruleMap.size;
2547
+ }
2548
+ };
2549
+ var IncrementalEngine = class {
2550
+ constructor(opts = {}) {
2551
+ // Stats untuk current build session
2552
+ this.stats = {
2553
+ totalFiles: 0,
2554
+ changedFiles: 0,
2555
+ skippedFiles: 0,
2556
+ addedRules: 0,
2557
+ removedRules: 0,
2558
+ buildTimeMs: 0
2559
+ };
2560
+ this.sessionStart = Date.now();
2561
+ var _a2, _b2, _c;
2562
+ this.opts = {
2563
+ outputPath: (_a2 = opts.outputPath) != null ? _a2 : path4__default.default.join(CACHE_DIR, "atomic.css"),
2564
+ persistCache: (_b2 = opts.persistCache) != null ? _b2 : true,
2565
+ verbose: (_c = opts.verbose) != null ? _c : false
2566
+ };
2567
+ this.hashCache = this.opts.persistCache ? loadHashCache() : /* @__PURE__ */ new Map();
2568
+ this.depGraph = this.opts.persistCache ? loadGraphCache() : /* @__PURE__ */ new Map();
2569
+ this.globalReg = new GlobalAtomicRegistry();
2570
+ this.cssWriter = new CssDiffWriter(this.opts.outputPath);
2571
+ for (const [filepath, nodes] of this.depGraph) {
2572
+ for (const node of nodes) {
2573
+ this.globalReg.add(filepath, node);
2574
+ }
2575
+ }
2576
+ }
2577
+ /**
2578
+ * Proses satu file. Core method dipanggil oleh webpack/turbopack loader.
2579
+ *
2580
+ * @param filepath - Absolute path ke file
2581
+ * @param source - Source code file (untuk hashing)
2582
+ * @param extractedNodes - Style nodes yang di-extract compiler dari file ini
2583
+ * @returns ProcessResult dengan diff dan stats
2584
+ */
2585
+ processFile(filepath, source, extractedNodes) {
2586
+ var _a2;
2587
+ const t0 = Date.now();
2588
+ this.stats.totalFiles++;
2589
+ const currentHash = hashFileContent(source);
2590
+ const cachedHash = this.hashCache.get(filepath);
2591
+ if (cachedHash === currentHash) {
2592
+ this.stats.skippedFiles++;
2593
+ this.log(`[skip] ${path4__default.default.relative(process.cwd(), filepath)}`);
2594
+ return {
2595
+ filepath,
2596
+ changed: false,
2597
+ diff: { added: [], removed: [], noChange: true },
2598
+ durationMs: Date.now() - t0
2599
+ };
2600
+ }
2601
+ this.hashCache.set(filepath, currentHash);
2602
+ this.stats.changedFiles++;
2603
+ this.log(`[change] ${path4__default.default.relative(process.cwd(), filepath)}`);
2604
+ const oldNodes = (_a2 = this.depGraph.get(filepath)) != null ? _a2 : [];
2605
+ const diff = computeDiff(oldNodes, extractedNodes);
2606
+ this.depGraph.set(filepath, extractedNodes);
2607
+ const trulyRemoved = [];
2608
+ for (const cls of diff.removed) {
2609
+ const wasRemoved = this.globalReg.remove(filepath, cls);
2610
+ if (wasRemoved) trulyRemoved.push(cls);
2611
+ }
2612
+ const trulyAdded = [];
2613
+ for (const node of diff.added) {
2614
+ if (!this.globalReg.has(node.atomicClass)) {
2615
+ trulyAdded.push(node);
2616
+ }
2617
+ this.globalReg.add(filepath, node);
2618
+ }
2619
+ const finalDiff = {
2620
+ added: trulyAdded,
2621
+ removed: trulyRemoved,
2622
+ noChange: trulyAdded.length === 0 && trulyRemoved.length === 0
2623
+ };
2624
+ this.cssWriter.applyDiff(finalDiff);
2625
+ this.stats.addedRules += trulyAdded.length;
2626
+ this.stats.removedRules += trulyRemoved.length;
2627
+ return {
2628
+ filepath,
2629
+ changed: true,
2630
+ diff: finalDiff,
2631
+ durationMs: Date.now() - t0
2632
+ };
2633
+ }
2634
+ /**
2635
+ * Dipanggil di akhir build. Flush CSS ke disk, persist cache.
2636
+ */
2637
+ async buildEnd() {
2638
+ this.stats.buildTimeMs = Date.now() - this.sessionStart;
2639
+ await this.cssWriter.flush();
2640
+ if (this.opts.persistCache) {
2641
+ saveHashCache(this.hashCache);
2642
+ saveGraphCache(this.depGraph);
2643
+ }
2644
+ this.log(
2645
+ `[build] done in ${this.stats.buildTimeMs}ms | changed: ${this.stats.changedFiles}/${this.stats.totalFiles} files | +${this.stats.addedRules} -${this.stats.removedRules} rules | total rules: ${this.cssWriter.size()}`
2646
+ );
2647
+ }
2648
+ /** Sync version untuk webpack buildEnd hook */
2649
+ buildEndSync() {
2650
+ this.stats.buildTimeMs = Date.now() - this.sessionStart;
2651
+ this.cssWriter.flushSync();
2652
+ if (this.opts.persistCache) {
2653
+ saveHashCache(this.hashCache);
2654
+ saveGraphCache(this.depGraph);
2655
+ }
2656
+ }
2657
+ /**
2658
+ * Invalidate satu file (untuk hot reload — file dihapus atau renamed).
2659
+ */
2660
+ invalidateFile(filepath) {
2661
+ var _a2;
2662
+ const oldNodes = (_a2 = this.depGraph.get(filepath)) != null ? _a2 : [];
2663
+ for (const node of oldNodes) {
2664
+ this.globalReg.remove(filepath, node.atomicClass);
2665
+ }
2666
+ this.depGraph.delete(filepath);
2667
+ this.hashCache.delete(filepath);
2668
+ this.log(`[invalidate] ${path4__default.default.relative(process.cwd(), filepath)}`);
2669
+ }
2670
+ /** Get all active style nodes — untuk full CSS generation */
2671
+ getAllNodes() {
2672
+ return this.globalReg.all();
2673
+ }
2674
+ /** Get stats untuk current build session */
2675
+ getStats() {
2676
+ return __spreadProps(__spreadValues({}, this.stats), { buildTimeMs: Date.now() - this.sessionStart });
2677
+ }
2678
+ /** Get output CSS path */
2679
+ getOutputPath() {
2680
+ return this.opts.outputPath;
2681
+ }
2682
+ /** Reset stats untuk build session baru */
2683
+ resetStats() {
2684
+ this.stats = {
2685
+ totalFiles: 0,
2686
+ changedFiles: 0,
2687
+ skippedFiles: 0,
2688
+ addedRules: 0,
2689
+ removedRules: 0,
2690
+ buildTimeMs: 0
2691
+ };
2692
+ this.sessionStart = Date.now();
2693
+ }
2694
+ /** Reset semua cache — untuk clean build */
2695
+ reset() {
2696
+ this.hashCache.clear();
2697
+ this.depGraph.clear();
2698
+ this.globalReg = new GlobalAtomicRegistry();
2699
+ this.cssWriter = new CssDiffWriter(this.opts.outputPath);
2700
+ this.resetStats();
2701
+ this.log("[reset] incremental cache cleared");
2702
+ }
2703
+ log(msg) {
2704
+ if (this.opts.verbose) {
2705
+ console.log(`[tailwind-styled/incremental] ${msg}`);
2706
+ }
2707
+ }
2708
+ };
2709
+ function parseClassesToNodes(classes) {
2710
+ const nodes = [];
2711
+ for (const cls of classes) {
2712
+ const node = parseOneClass(cls);
2713
+ if (node) nodes.push(node);
2714
+ }
2715
+ return nodes;
2716
+ }
2717
+ function parseOneClass(cls) {
2718
+ const colonIdx = cls.lastIndexOf(":");
2719
+ let modifier;
2720
+ let utility;
2721
+ if (colonIdx > 0) {
2722
+ const modStr = cls.slice(0, colonIdx);
2723
+ utility = cls.slice(colonIdx + 1);
2724
+ modifier = resolveModifier(modStr);
2725
+ } else {
2726
+ utility = cls;
2727
+ }
2728
+ const declaration = twToDeclaration(utility);
2729
+ if (!declaration) return null;
2730
+ const atomicClass = makeAtomicClass(declaration, modifier);
2731
+ return { twClass: cls, declaration, modifier, atomicClass };
2732
+ }
2733
+ function resolveModifier(mod) {
2734
+ var _a2, _b2;
2735
+ const pseudoMap = {
2736
+ hover: ":hover",
2737
+ focus: ":focus",
2738
+ active: ":active",
2739
+ disabled: ":disabled",
2740
+ visited: ":visited",
2741
+ checked: ":checked",
2742
+ first: ":first-child",
2743
+ last: ":last-child",
2744
+ odd: ":nth-child(odd)",
2745
+ even: ":nth-child(even)"
2746
+ };
2747
+ const mediaMap = {
2748
+ sm: "@media (min-width: 640px)",
2749
+ md: "@media (min-width: 768px)",
2750
+ lg: "@media (min-width: 1024px)",
2751
+ xl: "@media (min-width: 1280px)",
2752
+ "2xl": "@media (min-width: 1536px)",
2753
+ dark: "@media (prefers-color-scheme: dark)",
2754
+ print: "@media print"
2755
+ };
2756
+ return (_b2 = (_a2 = pseudoMap[mod]) != null ? _a2 : mediaMap[mod]) != null ? _b2 : `:${mod}`;
2757
+ }
2758
+ function twToDeclaration(cls) {
2759
+ var _a2;
2760
+ const sp = cls.match(/^(p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)-([\d.]+)$/);
2761
+ if (sp) {
2762
+ const propMap = {
2763
+ p: "padding",
2764
+ px: "padding-inline",
2765
+ py: "padding-block",
2766
+ pt: "padding-top",
2767
+ pb: "padding-bottom",
2768
+ pl: "padding-left",
2769
+ pr: "padding-right",
2770
+ m: "margin",
2771
+ mx: "margin-inline",
2772
+ my: "margin-block",
2773
+ mt: "margin-top",
2774
+ mb: "margin-bottom",
2775
+ ml: "margin-left",
2776
+ mr: "margin-right",
2777
+ gap: "gap"
2778
+ };
2779
+ return `${propMap[sp[1]]}: ${parseFloat(sp[2]) * 0.25}rem`;
2780
+ }
2781
+ const w = cls.match(/^w-(.+)$/);
2782
+ if (w) return `width: ${sizeVal(w[1])}`;
2783
+ const h = cls.match(/^h-(.+)$/);
2784
+ if (h) return `height: ${sizeVal(h[1])}`;
2785
+ const op = cls.match(/^opacity-(\d+)$/);
2786
+ if (op) return `opacity: ${parseInt(op[1], 10) / 100}`;
2787
+ const z = cls.match(/^z-(\d+)$/);
2788
+ if (z) return `z-index: ${z[1]}`;
2789
+ const map = {
2790
+ block: "display: block",
2791
+ "inline-block": "display: inline-block",
2792
+ flex: "display: flex",
2793
+ "inline-flex": "display: inline-flex",
2794
+ grid: "display: grid",
2795
+ hidden: "display: none",
2796
+ relative: "position: relative",
2797
+ absolute: "position: absolute",
2798
+ fixed: "position: fixed",
2799
+ sticky: "position: sticky",
2800
+ "flex-row": "flex-direction: row",
2801
+ "flex-col": "flex-direction: column",
2802
+ "items-center": "align-items: center",
2803
+ "items-start": "align-items: flex-start",
2804
+ "items-end": "align-items: flex-end",
2805
+ "justify-center": "justify-content: center",
2806
+ "justify-between": "justify-content: space-between",
2807
+ "justify-start": "justify-content: flex-start",
2808
+ "justify-end": "justify-content: flex-end",
2809
+ "font-thin": "font-weight: 100",
2810
+ "font-light": "font-weight: 300",
2811
+ "font-normal": "font-weight: 400",
2812
+ "font-medium": "font-weight: 500",
2813
+ "font-semibold": "font-weight: 600",
2814
+ "font-bold": "font-weight: 700",
2815
+ "font-extrabold": "font-weight: 800",
2816
+ "text-xs": "font-size: 0.75rem",
2817
+ "text-sm": "font-size: 0.875rem",
2818
+ "text-base": "font-size: 1rem",
2819
+ "text-lg": "font-size: 1.125rem",
2820
+ "text-xl": "font-size: 1.25rem",
2821
+ "text-2xl": "font-size: 1.5rem",
2822
+ "text-3xl": "font-size: 1.875rem",
2823
+ "text-4xl": "font-size: 2.25rem",
2824
+ rounded: "border-radius: 0.25rem",
2825
+ "rounded-md": "border-radius: 0.375rem",
2826
+ "rounded-lg": "border-radius: 0.5rem",
2827
+ "rounded-xl": "border-radius: 0.75rem",
2828
+ "rounded-full": "border-radius: 9999px",
2829
+ "overflow-hidden": "overflow: hidden",
2830
+ "overflow-auto": "overflow: auto",
2831
+ "cursor-pointer": "cursor: pointer",
2832
+ "cursor-default": "cursor: default",
2833
+ "select-none": "user-select: none",
2834
+ "pointer-events-none": "pointer-events: none",
2835
+ truncate: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap",
2836
+ transition: "transition-property: color,background-color,border-color,opacity,box-shadow,transform; transition-duration: 150ms"
2837
+ };
2838
+ return (_a2 = map[cls]) != null ? _a2 : null;
2839
+ }
2840
+ function sizeVal(v) {
2841
+ var _a2;
2842
+ const num = parseFloat(v);
2843
+ if (!Number.isNaN(num)) return `${num * 0.25}rem`;
2844
+ const special = {
2845
+ full: "100%",
2846
+ screen: "100vw",
2847
+ auto: "auto",
2848
+ min: "min-content",
2849
+ max: "max-content",
2850
+ fit: "fit-content"
2851
+ };
2852
+ return (_a2 = special[v]) != null ? _a2 : v;
2853
+ }
2854
+ var _engine = null;
2855
+ function getIncrementalEngine(opts) {
2856
+ if (!_engine) {
2857
+ _engine = new IncrementalEngine(opts);
2858
+ }
2859
+ return _engine;
2860
+ }
2861
+ function resetIncrementalEngine() {
2862
+ _engine = null;
2863
+ }
2864
+ var CONFIG_FILES = [
2865
+ "tailwind.config.ts",
2866
+ "tailwind.config.js",
2867
+ "tailwind.config.mjs",
2868
+ "tailwind.config.cjs"
2869
+ ];
2870
+ var _cachedConfig = null;
2871
+ var _cachedCwd = "";
2872
+ function loadTailwindConfig(cwd = process.cwd()) {
2873
+ var _a2;
2874
+ if (_cachedConfig && _cachedCwd === cwd) return _cachedConfig;
2875
+ _cachedCwd = cwd;
2876
+ for (const file of CONFIG_FILES) {
2877
+ const fullPath = path4__default.default.join(cwd, file);
2878
+ if (fs2__default.default.existsSync(fullPath)) {
2879
+ try {
2880
+ const mod = __require(fullPath);
2881
+ const config = (_a2 = mod.default) != null ? _a2 : mod;
2882
+ _cachedConfig = config;
2883
+ console.log(`[tailwind-styled-v4] Using config: ${file}`);
2884
+ return config;
2885
+ } catch (e) {
2886
+ }
2887
+ }
2888
+ }
2889
+ console.log("[tailwind-styled-v4] No tailwind config found \u2192 using built-in preset");
2890
+ const { defaultPreset: defaultPreset2 } = (init_defaultPreset(), __toCommonJS(defaultPreset_exports));
2891
+ _cachedConfig = defaultPreset2;
2892
+ return defaultPreset2;
2893
+ }
2894
+ function getContentPaths(config, cwd = process.cwd()) {
2895
+ var _a2;
2896
+ const paths = [];
2897
+ if (Array.isArray(config.content)) {
2898
+ for (const item of config.content) {
2899
+ if (typeof item === "string") paths.push(item);
2900
+ else if (typeof item === "object" && item.raw) ;
2901
+ }
2902
+ return paths;
2903
+ }
2904
+ if ((_a2 = config.content) == null ? void 0 : _a2.files) {
2905
+ return config.content.files.filter((f) => typeof f === "string");
2906
+ }
2907
+ return ["src", "app", "pages", "components"].filter((d) => fs2__default.default.existsSync(path4__default.default.join(cwd, d))).map((d) => `./${d}/**/*.{tsx,ts,jsx,js}`);
2908
+ }
2909
+ function invalidateConfigCache() {
2910
+ _cachedConfig = null;
2911
+ _cachedCwd = "";
2912
+ }
2913
+ function isZeroConfig(cwd = process.cwd()) {
2914
+ return !CONFIG_FILES.some((f) => fs2__default.default.existsSync(path4__default.default.join(cwd, f)));
2915
+ }
2916
+ function bootstrapZeroConfig(cwd = process.cwd()) {
2917
+ let generatedConfig = false;
2918
+ let generatedCss = false;
2919
+ generatedConfig = false;
2920
+ const cssPaths = [
2921
+ "src/app/globals.css",
2922
+ "app/globals.css",
2923
+ "src/index.css",
2924
+ "src/styles/globals.css"
2925
+ ];
2926
+ const hasGlobalCss = cssPaths.some((p) => fs2__default.default.existsSync(path4__default.default.join(cwd, p)));
2927
+ if (!hasGlobalCss) {
2928
+ const { defaultGlobalCss: defaultGlobalCss2 } = (init_defaultPreset(), __toCommonJS(defaultPreset_exports));
2929
+ const appDir = fs2__default.default.existsSync(path4__default.default.join(cwd, "src/app")) ? "src/app" : fs2__default.default.existsSync(path4__default.default.join(cwd, "app")) ? "app" : "src";
2930
+ const cssPath = path4__default.default.join(cwd, appDir, "globals.css");
2931
+ if (fs2__default.default.existsSync(path4__default.default.dirname(cssPath))) {
2932
+ fs2__default.default.writeFileSync(cssPath, defaultGlobalCss2);
2933
+ generatedCss = true;
2934
+ console.log(`[tailwind-styled-v4] Generated ${cssPath}`);
2935
+ }
2936
+ }
2937
+ return { generatedConfig, generatedCss };
2938
+ }
2939
+
2940
+ // ../compiler/src/routeCssCollector.ts
2941
+ var _collector = {
2942
+ files: /* @__PURE__ */ new Map(),
2943
+ routes: /* @__PURE__ */ new Map(),
2944
+ global: /* @__PURE__ */ new Set()
2945
+ };
2946
+ function registerFileClasses(filepath, classes) {
2947
+ if (!_collector.files.has(filepath)) {
2948
+ _collector.files.set(filepath, /* @__PURE__ */ new Set());
2949
+ }
2950
+ const fileSet = _collector.files.get(filepath);
2951
+ classes.forEach((c) => fileSet.add(c));
2952
+ const route = fileToRoute(filepath);
2953
+ if (route) {
2954
+ if (!_collector.routes.has(route)) {
2955
+ _collector.routes.set(route, /* @__PURE__ */ new Set());
2956
+ }
2957
+ _collector.routes.get(route).add(filepath);
2958
+ }
2959
+ }
2960
+ function registerGlobalClasses(classes) {
2961
+ classes.forEach((c) => _collector.global.add(c));
2962
+ }
2963
+ function getRouteClasses(route) {
2964
+ var _a2, _b2;
2965
+ const result = new Set(_collector.global);
2966
+ const routeFiles = (_a2 = _collector.routes.get(route)) != null ? _a2 : /* @__PURE__ */ new Set();
2967
+ for (const filepath of routeFiles) {
2968
+ const fileClasses = (_b2 = _collector.files.get(filepath)) != null ? _b2 : /* @__PURE__ */ new Set();
2969
+ fileClasses.forEach((c) => result.add(c));
2970
+ }
2971
+ return result;
2972
+ }
2973
+ function getAllRoutes() {
2974
+ return Array.from(_collector.routes.keys()).sort();
2975
+ }
2976
+ function getCollector() {
2977
+ return _collector;
2978
+ }
2979
+ function resetCollector() {
2980
+ _collector = {
2981
+ files: /* @__PURE__ */ new Map(),
2982
+ routes: /* @__PURE__ */ new Map(),
2983
+ global: /* @__PURE__ */ new Set()
2984
+ };
2985
+ }
2986
+ function fileToRoute(filepath) {
2987
+ const normalized = filepath.replace(/\\/g, "/");
2988
+ if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
2989
+ return "__global";
2990
+ }
2991
+ const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
2992
+ if (pageMatch) return `/${pageMatch[1]}`;
2993
+ const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
2994
+ if (rootPage) return "/";
2995
+ const pagesMatch = normalized.match(/\/pages\/(.+?)\.[tj]sx?$/);
2996
+ if (pagesMatch) {
2997
+ const route = pagesMatch[1].replace(/\/index$/, "");
2998
+ return `/${route}`;
2999
+ }
3000
+ if (normalized.includes("/components/") || normalized.includes("/ui/") || normalized.includes("/shared/")) {
3001
+ return "__global";
3002
+ }
3003
+ return null;
3004
+ }
3005
+ function getCollectorSummary() {
3006
+ const routes = getAllRoutes();
3007
+ const totalFiles = _collector.files.size;
3008
+ const totalGlobal = _collector.global.size;
3009
+ const lines = [
3010
+ `[tailwind-styled-v4] Route CSS Summary:`,
3011
+ ` Files processed: ${totalFiles}`,
3012
+ ` Global classes: ${totalGlobal}`,
3013
+ ` Routes found: ${routes.length}`,
3014
+ ...routes.map((r) => {
3015
+ const cls = getRouteClasses(r).size;
3016
+ return ` ${r} \u2192 ${cls} classes`;
3017
+ })
3018
+ ];
3019
+ return lines.join("\n");
3020
+ }
3021
+ var SCAN_EXTENSIONS2 = [".tsx", ".ts", ".jsx", ".js"];
3022
+ function scanDir(dir, files = []) {
3023
+ if (!fs2__default.default.existsSync(dir)) return files;
3024
+ const entries = fs2__default.default.readdirSync(dir, { withFileTypes: true });
3025
+ for (const entry of entries) {
3026
+ if (entry.name === "node_modules" || entry.name === ".next" || entry.name === "dist") continue;
3027
+ const fullPath = path4__default.default.join(dir, entry.name);
3028
+ if (entry.isDirectory()) {
3029
+ scanDir(fullPath, files);
3030
+ } else if (SCAN_EXTENSIONS2.some((ext) => entry.name.endsWith(ext))) {
3031
+ files.push(fullPath);
3032
+ }
3033
+ }
3034
+ return files;
3035
+ }
3036
+ function generateSafelist(scanDirs, outputPath = ".tailwind-styled-safelist.json", cwd = process.cwd()) {
3037
+ const allClasses = /* @__PURE__ */ new Set();
3038
+ for (const dir of scanDirs) {
3039
+ const absDir = path4__default.default.isAbsolute(dir) ? dir : path4__default.default.resolve(cwd, dir);
3040
+ const files = scanDir(absDir);
3041
+ for (const file of files) {
3042
+ try {
3043
+ const source = fs2__default.default.readFileSync(file, "utf-8");
3044
+ const classes = extractAllClasses(source);
3045
+ classes.forEach((c) => allClasses.add(c));
3046
+ } catch (e) {
3047
+ }
3048
+ }
3049
+ }
3050
+ const sorted = Array.from(allClasses).sort();
3051
+ const absOutput = path4__default.default.isAbsolute(outputPath) ? outputPath : path4__default.default.resolve(cwd, outputPath);
3052
+ fs2__default.default.writeFileSync(absOutput, JSON.stringify(sorted, null, 2));
3053
+ console.log(`[tailwind-styled-v4] Safelist: ${sorted.length} classes \u2192 ${absOutput}`);
3054
+ return sorted;
3055
+ }
3056
+ function loadSafelist(safelistPath) {
3057
+ try {
3058
+ const content = fs2__default.default.readFileSync(safelistPath, "utf-8");
3059
+ return JSON.parse(content);
3060
+ } catch (e) {
3061
+ return [];
3062
+ }
3063
+ }
3064
+ function generateSafelistCss(scanDirs, outputPath = "src/app/__tw-safelist.css", cwd = process.cwd()) {
3065
+ const allClasses = /* @__PURE__ */ new Set();
3066
+ for (const dir of scanDirs) {
3067
+ const absDir = path4__default.default.isAbsolute(dir) ? dir : path4__default.default.resolve(cwd, dir);
3068
+ const files = scanDir(absDir);
3069
+ for (const file of files) {
3070
+ try {
3071
+ const source = fs2__default.default.readFileSync(file, "utf-8");
3072
+ const classes = extractAllClasses(source);
3073
+ classes.forEach((c) => allClasses.add(c));
3074
+ } catch (e) {
3075
+ }
3076
+ }
3077
+ }
3078
+ const sorted = Array.from(allClasses).sort();
3079
+ const absOutput = path4__default.default.isAbsolute(outputPath) ? outputPath : path4__default.default.resolve(cwd, outputPath);
3080
+ fs2__default.default.mkdirSync(path4__default.default.dirname(absOutput), { recursive: true });
3081
+ const css = sorted.length > 0 ? `/* Auto-generated by tailwind-styled-v4 \u2014 DO NOT EDIT */
3082
+ @source inline("${sorted.join(" ")}");
3083
+ ` : `/* Auto-generated by tailwind-styled-v4 \u2014 DO NOT EDIT */
3084
+ /* No safelist classes found */
3085
+ `;
3086
+ fs2__default.default.writeFileSync(absOutput, css);
3087
+ console.log(`[tailwind-styled-v4] Safelist: ${sorted.length} classes \u2192 ${absOutput}`);
3088
+ return sorted;
3089
+ }
3090
+
3091
+ // ../compiler/src/styleBucketSystem.ts
3092
+ var BUCKET_ORDER = [
3093
+ "reset",
3094
+ "layout",
3095
+ "spacing",
3096
+ "sizing",
3097
+ "typography",
3098
+ "visual",
3099
+ "interaction",
3100
+ "responsive",
3101
+ "unknown"
3102
+ ];
3103
+ var PROPERTY_BUCKET_MAP = {
3104
+ // Layout
3105
+ display: "layout",
3106
+ position: "layout",
3107
+ flex: "layout",
3108
+ "flex-direction": "layout",
3109
+ "flex-wrap": "layout",
3110
+ "flex-grow": "layout",
3111
+ "flex-shrink": "layout",
3112
+ "flex-basis": "layout",
3113
+ grid: "layout",
3114
+ "grid-template": "layout",
3115
+ "grid-column": "layout",
3116
+ "grid-row": "layout",
3117
+ "align-items": "layout",
3118
+ "align-self": "layout",
3119
+ "align-content": "layout",
3120
+ "justify-content": "layout",
3121
+ "justify-items": "layout",
3122
+ "justify-self": "layout",
3123
+ "place-items": "layout",
3124
+ "place-content": "layout",
3125
+ overflow: "layout",
3126
+ "overflow-x": "layout",
3127
+ "overflow-y": "layout",
3128
+ "z-index": "layout",
3129
+ float: "layout",
3130
+ clear: "layout",
3131
+ visibility: "layout",
3132
+ // Spacing
3133
+ padding: "spacing",
3134
+ "padding-top": "spacing",
3135
+ "padding-bottom": "spacing",
3136
+ "padding-left": "spacing",
3137
+ "padding-right": "spacing",
3138
+ "padding-inline": "spacing",
3139
+ "padding-block": "spacing",
3140
+ margin: "spacing",
3141
+ "margin-top": "spacing",
3142
+ "margin-bottom": "spacing",
3143
+ "margin-left": "spacing",
3144
+ "margin-right": "spacing",
3145
+ "margin-inline": "spacing",
3146
+ "margin-block": "spacing",
3147
+ gap: "spacing",
3148
+ "column-gap": "spacing",
3149
+ "row-gap": "spacing",
3150
+ inset: "spacing",
3151
+ "inset-inline": "spacing",
3152
+ "inset-block": "spacing",
3153
+ top: "spacing",
3154
+ bottom: "spacing",
3155
+ left: "spacing",
3156
+ right: "spacing",
3157
+ // Sizing
3158
+ width: "sizing",
3159
+ height: "sizing",
3160
+ "max-width": "sizing",
3161
+ "min-width": "sizing",
3162
+ "max-height": "sizing",
3163
+ "min-height": "sizing",
3164
+ "aspect-ratio": "sizing",
3165
+ // Typography
3166
+ "font-size": "typography",
3167
+ "font-weight": "typography",
3168
+ "font-family": "typography",
3169
+ "font-style": "typography",
3170
+ "line-height": "typography",
3171
+ "letter-spacing": "typography",
3172
+ "text-align": "typography",
3173
+ "text-decoration": "typography",
3174
+ "text-transform": "typography",
3175
+ "text-overflow": "typography",
3176
+ "white-space": "typography",
3177
+ "word-break": "typography",
3178
+ "word-wrap": "typography",
3179
+ "vertical-align": "typography",
3180
+ // Visual
3181
+ color: "visual",
3182
+ background: "visual",
3183
+ "background-color": "visual",
3184
+ "background-image": "visual",
3185
+ "background-size": "visual",
3186
+ "background-position": "visual",
3187
+ "background-repeat": "visual",
3188
+ border: "visual",
3189
+ "border-top": "visual",
3190
+ "border-bottom": "visual",
3191
+ "border-left": "visual",
3192
+ "border-right": "visual",
3193
+ "border-inline": "visual",
3194
+ "border-block": "visual",
3195
+ "border-color": "visual",
3196
+ "border-width": "visual",
3197
+ "border-style": "visual",
3198
+ "border-radius": "visual",
3199
+ "box-shadow": "visual",
3200
+ opacity: "visual",
3201
+ outline: "visual",
3202
+ "outline-color": "visual",
3203
+ "outline-width": "visual",
3204
+ fill: "visual",
3205
+ stroke: "visual",
3206
+ "text-shadow": "visual",
3207
+ "mix-blend-mode": "visual",
3208
+ "object-fit": "visual",
3209
+ "object-position": "visual",
3210
+ // Interaction
3211
+ cursor: "interaction",
3212
+ "pointer-events": "interaction",
3213
+ "user-select": "interaction",
3214
+ transition: "interaction",
3215
+ "transition-property": "interaction",
3216
+ "transition-duration": "interaction",
3217
+ "transition-timing-function": "interaction",
3218
+ "transition-delay": "interaction",
3219
+ transform: "interaction",
3220
+ translate: "interaction",
3221
+ rotate: "interaction",
3222
+ scale: "interaction",
3223
+ animation: "interaction",
3224
+ "will-change": "interaction",
3225
+ "scroll-behavior": "interaction",
3226
+ "scroll-snap-type": "interaction",
3227
+ // Reset (jarang dipakai langsung tapi handle untuk completeness)
3228
+ "box-sizing": "reset",
3229
+ appearance: "reset",
3230
+ all: "reset"
3231
+ };
3232
+ function classifyNode(node) {
3233
+ var _a2, _b2, _c;
3234
+ if ((_a2 = node.modifier) == null ? void 0 : _a2.startsWith("@")) return "responsive";
3235
+ const declarations = node.declaration.split(";").map((d) => d.trim()).filter(Boolean);
3236
+ const firstProp = (_c = (_b2 = declarations[0]) == null ? void 0 : _b2.split(":")[0]) == null ? void 0 : _c.trim();
3237
+ if (!firstProp) return "unknown";
3238
+ if (PROPERTY_BUCKET_MAP[firstProp]) return PROPERTY_BUCKET_MAP[firstProp];
3239
+ for (const [prefix, bucket] of Object.entries(PROPERTY_BUCKET_MAP)) {
3240
+ if (firstProp.startsWith(prefix)) return bucket;
3241
+ }
3242
+ return "unknown";
3243
+ }
3244
+ var BucketEngine = class {
3245
+ constructor() {
3246
+ this.buckets = /* @__PURE__ */ new Map();
3247
+ for (const b of BUCKET_ORDER) {
3248
+ this.buckets.set(b, /* @__PURE__ */ new Map());
3249
+ }
3250
+ }
3251
+ /**
3252
+ * Tambah StyleNode ke bucket yang tepat.
3253
+ * Idempotent — atomic class yang sama tidak akan duplikat.
3254
+ */
3255
+ add(node) {
3256
+ const bucket = classifyNode(node);
3257
+ this.buckets.get(bucket).set(node.atomicClass, node);
3258
+ }
3259
+ /**
3260
+ * Hapus node dari bucket (untuk incremental update).
3261
+ */
3262
+ remove(atomicClass) {
3263
+ for (const bucket of this.buckets.values()) {
3264
+ if (bucket.delete(atomicClass)) break;
3265
+ }
3266
+ }
3267
+ /**
3268
+ * Apply CssDiff dari incremental engine.
3269
+ */
3270
+ applyDiff(diff) {
3271
+ for (const node of diff.added) this.add(node);
3272
+ for (const cls of diff.removed) this.remove(cls);
3273
+ }
3274
+ /**
3275
+ * Emit seluruh CSS dalam urutan bucket yang deterministic.
3276
+ *
3277
+ * @param comments - Tambahkan komentar section per bucket. Default: true
3278
+ * @returns CSS string yang siap di-write ke file
3279
+ */
3280
+ emit(comments = true) {
3281
+ const sections = [];
3282
+ for (const bucketName of BUCKET_ORDER) {
3283
+ const nodes = this.buckets.get(bucketName);
3284
+ if (nodes.size === 0) continue;
3285
+ const rules = [];
3286
+ for (const node of nodes.values()) {
3287
+ rules.push(nodeToCSS2(node));
3288
+ }
3289
+ if (rules.length === 0) continue;
3290
+ if (comments) {
3291
+ sections.push(`/* \u2500\u2500 ${bucketName} \u2500\u2500 */`);
3292
+ }
3293
+ sections.push(...rules);
3294
+ }
3295
+ return sections.join("\n");
3296
+ }
3297
+ /**
3298
+ * Emit dengan @layer CSS untuk native browser layering.
3299
+ * Lebih powerful — browser respects layer order untuk specificity.
3300
+ *
3301
+ * @example output:
3302
+ * @layer tw-layout, tw-spacing, tw-visual, tw-responsive;
3303
+ * @layer tw-layout { .tw-a1 { display: flex } }
3304
+ */
3305
+ emitLayered() {
3306
+ const layerNames = BUCKET_ORDER.filter(
3307
+ (b) => b !== "unknown" && this.buckets.get(b).size > 0
3308
+ ).map((b) => `tw-${b}`);
3309
+ if (layerNames.length === 0) return "";
3310
+ const parts = [`@layer ${layerNames.join(", ")};`, ""];
3311
+ for (const bucketName of BUCKET_ORDER) {
3312
+ const nodes = this.buckets.get(bucketName);
3313
+ if (nodes.size === 0) continue;
3314
+ const rules = Array.from(nodes.values()).map(nodeToCSS2).join("\n ");
3315
+ parts.push(`@layer tw-${bucketName} {
3316
+ ${rules}
3317
+ }`);
3318
+ }
3319
+ return parts.join("\n");
3320
+ }
3321
+ /** Semua nodes dari semua bucket (untuk full registry access) */
3322
+ allNodes() {
3323
+ const all = [];
3324
+ for (const bucket of this.buckets.values()) {
3325
+ for (const node of bucket.values()) {
3326
+ all.push(node);
3327
+ }
3328
+ }
3329
+ return all;
3330
+ }
3331
+ /** Stats per bucket */
3332
+ stats() {
3333
+ const perBucket = {};
3334
+ let total = 0;
3335
+ for (const [name, nodes] of this.buckets) {
3336
+ perBucket[name] = nodes.size;
3337
+ total += nodes.size;
3338
+ }
3339
+ return { totalNodes: total, perBucket };
3340
+ }
3341
+ /** Clear semua bucket */
3342
+ clear() {
3343
+ for (const bucket of this.buckets.values()) {
3344
+ bucket.clear();
3345
+ }
3346
+ }
3347
+ };
3348
+ function bucketSort(nodes) {
3349
+ const bucketIndex = Object.fromEntries(BUCKET_ORDER.map((b, i) => [b, i]));
3350
+ return [...nodes].sort((a, b) => {
3351
+ const ai = bucketIndex[classifyNode(a)];
3352
+ const bi = bucketIndex[classifyNode(b)];
3353
+ return ai - bi;
3354
+ });
3355
+ }
3356
+ function nodeToCSS2(node) {
3357
+ const { atomicClass, declaration, modifier } = node;
3358
+ if (!modifier) {
3359
+ return `.${atomicClass}{${declaration}}`;
3360
+ }
3361
+ if (modifier.startsWith("@")) {
3362
+ return `${modifier}{.${atomicClass}{${declaration}}}`;
3363
+ }
3364
+ return `.${atomicClass}${modifier}{${declaration}}`;
3365
+ }
3366
+ function detectConflicts(nodes) {
3367
+ var _a2, _b2, _c;
3368
+ const seen = /* @__PURE__ */ new Map();
3369
+ const warnings = [];
3370
+ for (const node of nodes) {
3371
+ if ((_a2 = node.modifier) == null ? void 0 : _a2.startsWith("@")) continue;
3372
+ const firstProp = (_b2 = node.declaration.split(":")[0]) == null ? void 0 : _b2.trim();
3373
+ if (!firstProp) continue;
3374
+ const key = `${firstProp}::${(_c = node.modifier) != null ? _c : ""}`;
3375
+ const prev = seen.get(key);
3376
+ if (prev) {
3377
+ warnings.push({
3378
+ property: firstProp,
3379
+ classes: [prev.twClass, node.twClass],
3380
+ bucket: classifyNode(node),
3381
+ message: `Possible conflict: "${prev.twClass}" and "${node.twClass}" both set "${firstProp}"`
3382
+ });
3383
+ } else {
3384
+ seen.set(key, node);
3385
+ }
3386
+ }
3387
+ return warnings;
3388
+ }
3389
+ var _bucketEngine = null;
3390
+ function getBucketEngine() {
3391
+ if (!_bucketEngine) _bucketEngine = new BucketEngine();
3392
+ return _bucketEngine;
3393
+ }
3394
+ function resetBucketEngine() {
3395
+ _bucketEngine = null;
3396
+ }
3397
+ async function generateCssForClasses(classes, config, cwd = process.cwd()) {
3398
+ const twConfig = config != null ? config : loadTailwindConfig(cwd);
3399
+ try {
3400
+ return await generateViaTailwindV4(classes, twConfig, cwd);
3401
+ } catch (e) {
3402
+ }
3403
+ try {
3404
+ return await generateViaTailwindV3(classes, twConfig);
3405
+ } catch (e) {
3406
+ }
3407
+ return generateManualCss(classes);
3408
+ }
3409
+ async function generateViaTailwindV4(classes, _config, cwd) {
3410
+ const virtualCss = [
3411
+ `@import "tailwindcss";`,
3412
+ `@layer utilities {`,
3413
+ ` /* Generated by tailwind-styled-v4 */`,
3414
+ `}`
3415
+ ].join("\n");
3416
+ const postcss = __require("postcss");
3417
+ const tailwindcss = __require("@tailwindcss/postcss");
3418
+ const result = await postcss([
3419
+ tailwindcss({
3420
+ optimize: { minify: false }
3421
+ })
3422
+ ]).process(virtualCss, {
3423
+ from: path4__default.default.join(cwd, "virtual.css")
3424
+ });
3425
+ return filterCssForClasses(result.css, classes);
3426
+ }
3427
+ async function generateViaTailwindV3(classes, config) {
3428
+ const postcss = __require("postcss");
3429
+ const tailwindcss = __require("tailwindcss");
3430
+ const virtualContent = classes.map((c) => `<div class="${c}">`).join("\n");
3431
+ const twConfigWithContent = __spreadProps(__spreadValues({}, config), {
3432
+ content: [{ raw: virtualContent, extension: "html" }],
3433
+ safelist: classes
3434
+ });
3435
+ const inputCss = `@tailwind base;
3436
+ @tailwind components;
3437
+ @tailwind utilities;`;
3438
+ const result = await postcss([tailwindcss(twConfigWithContent)]).process(inputCss, {
3439
+ from: void 0
3440
+ });
3441
+ return result.css;
3442
+ }
3443
+ function generateManualCss(classes) {
3444
+ const { generateAtomicCss: generateAtomicCss2, parseAtomicClass: parseAtomicClass2 } = (init_atomicCss(), __toCommonJS(atomicCss_exports));
3445
+ const rules = classes.map((c) => parseAtomicClass2(c)).filter(Boolean);
3446
+ if (rules.length === 0) return "";
3447
+ const header = `/* Generated by tailwind-styled-v4 \u2014 ${(/* @__PURE__ */ new Date()).toISOString()} */
3448
+ `;
3449
+ return header + generateAtomicCss2(rules);
3450
+ }
3451
+ function filterCssForClasses(fullCss, classes) {
3452
+ new Set(classes);
3453
+ const lines = fullCss.split("\n");
3454
+ const kept = [];
3455
+ let inBlock = false;
3456
+ let keepBlock = false;
3457
+ let braceDepth = 0;
3458
+ for (const line of lines) {
3459
+ if (line.includes("@layer base") || line.includes("*, *::before")) {
3460
+ kept.push(line);
3461
+ continue;
3462
+ }
3463
+ if (!inBlock) {
3464
+ const isOurClass = classes.some((cls) => {
3465
+ const escaped = cls.replace(/[:/[\].!%]/g, "\\$&");
3466
+ return line.includes(`.${escaped}`) || line.includes(`.${cls}`);
3467
+ });
3468
+ if (isOurClass) {
3469
+ keepBlock = true;
3470
+ inBlock = true;
3471
+ braceDepth = 0;
3472
+ }
3473
+ }
3474
+ if (inBlock) {
3475
+ if (keepBlock) kept.push(line);
3476
+ if (line.includes("{")) braceDepth++;
3477
+ if (line.includes("}")) {
3478
+ braceDepth--;
3479
+ if (braceDepth <= 0) {
3480
+ inBlock = false;
3481
+ keepBlock = false;
3482
+ }
3483
+ }
3484
+ }
3485
+ }
3486
+ return kept.join("\n");
3487
+ }
3488
+ async function generateAllRouteCss(opts = {}) {
3489
+ const { cwd = process.cwd(), outputDir, config, minify = true } = opts;
3490
+ const results = [];
3491
+ const routes = getAllRoutes();
3492
+ const twConfig = config != null ? config : loadTailwindConfig(cwd);
3493
+ for (const route of routes) {
3494
+ const classes = Array.from(getRouteClasses(route));
3495
+ if (classes.length === 0) continue;
3496
+ try {
3497
+ let css = await generateCssForClasses(classes, twConfig, cwd);
3498
+ if (minify) {
3499
+ css = minifyCss(css);
3500
+ }
3501
+ results.push({
3502
+ route,
3503
+ css,
3504
+ classes,
3505
+ sizeBytes: Buffer.byteLength(css, "utf8")
3506
+ });
3507
+ } catch (e) {
3508
+ console.warn(`[tailwind-styled-v4] CSS generation failed for route ${route}:`, e);
3509
+ }
3510
+ }
3511
+ if (outputDir) {
3512
+ const fs5 = __require("fs");
3513
+ fs5.mkdirSync(outputDir, { recursive: true });
3514
+ for (const result of results) {
3515
+ const filename = routeToFilename(result.route);
3516
+ const filepath = path4__default.default.join(outputDir, filename);
3517
+ fs5.mkdirSync(path4__default.default.dirname(filepath), { recursive: true });
3518
+ fs5.writeFileSync(filepath, result.css);
3519
+ }
3520
+ const totalSize = results.reduce((sum, r) => sum + r.sizeBytes, 0);
3521
+ console.log(
3522
+ `[tailwind-styled-v4] Route CSS generated: ${results.length} routes, ${formatBytes(totalSize)} total`
3523
+ );
3524
+ }
3525
+ return results;
3526
+ }
3527
+ function routeToFilename(route) {
3528
+ if (route === "/") return "index.css";
3529
+ if (route === "__global") return "_global.css";
3530
+ return `${route.replace(/^\//, "").replace(/\//g, "_")}.css`;
3531
+ }
3532
+ function minifyCss(css) {
3533
+ return css.replace(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g, "").replace(/\s+/g, " ").replace(/\s*{\s*/g, "{").replace(/\s*}\s*/g, "}").replace(/\s*:\s*/g, ":").replace(/\s*;\s*/g, ";").trim();
3534
+ }
3535
+ function formatBytes(bytes) {
3536
+ if (bytes < 1024) return `${bytes}B`;
3537
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
3538
+ return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
3539
+ }
3540
+
3541
+ exports.BucketEngine = BucketEngine;
3542
+ exports.IncrementalEngine = IncrementalEngine;
3543
+ exports.analyzeFile = analyzeFile;
3544
+ exports.analyzeVariantUsage = analyzeVariantUsage;
3545
+ exports.bootstrapZeroConfig = bootstrapZeroConfig;
3546
+ exports.bucketSort = bucketSort;
3547
+ exports.classifyNode = classifyNode;
3548
+ exports.clearAtomicRegistry = clearAtomicRegistry;
3549
+ exports.compileVariants = compileVariants;
3550
+ exports.detectConflicts = detectConflicts;
3551
+ exports.extractAllClasses = extractAllClasses;
3552
+ exports.extractComponentUsage = extractComponentUsage;
3553
+ exports.fileToRoute = fileToRoute;
3554
+ exports.generateAllRouteCss = generateAllRouteCss;
3555
+ exports.generateAtomicCss = generateAtomicCss;
3556
+ exports.generateCssForClasses = generateCssForClasses;
3557
+ exports.generateSafelist = generateSafelist;
3558
+ exports.generateSafelistCss = generateSafelistCss;
3559
+ exports.getAllRoutes = getAllRoutes;
3560
+ exports.getAtomicRegistry = getAtomicRegistry;
3561
+ exports.getBucketEngine = getBucketEngine;
3562
+ exports.getCollector = getCollector;
3563
+ exports.getCollectorSummary = getCollectorSummary;
3564
+ exports.getContentPaths = getContentPaths;
3565
+ exports.getIncrementalEngine = getIncrementalEngine;
3566
+ exports.getRouteClasses = getRouteClasses;
3567
+ exports.hasInteractiveFeatures = hasInteractiveFeatures;
3568
+ exports.hasTwUsage = hasTwUsage;
3569
+ exports.hoistComponents = hoistComponents;
3570
+ exports.injectClientDirective = injectClientDirective;
3571
+ exports.injectServerOnlyComment = injectServerOnlyComment;
3572
+ exports.invalidateConfigCache = invalidateConfigCache;
3573
+ exports.isDynamic = isDynamic;
3574
+ exports.isServerComponent = isServerComponent;
3575
+ exports.isZeroConfig = isZeroConfig;
3576
+ exports.loadSafelist = loadSafelist;
3577
+ exports.loadTailwindConfig = loadTailwindConfig;
3578
+ exports.mergeClassesStatic = mergeClassesStatic;
3579
+ exports.normalizeClasses = normalizeClasses;
3580
+ exports.parseAtomicClass = parseAtomicClass;
3581
+ exports.parseClassesToNodes = parseClassesToNodes;
3582
+ exports.registerFileClasses = registerFileClasses;
3583
+ exports.registerGlobalClasses = registerGlobalClasses;
3584
+ exports.resetBucketEngine = resetBucketEngine;
3585
+ exports.resetCollector = resetCollector;
3586
+ exports.resetIncrementalEngine = resetIncrementalEngine;
3587
+ exports.resolveServerVariant = resolveServerVariant;
3588
+ exports.runElimination = runElimination;
3589
+ exports.scanProjectUsage = scanProjectUsage;
3590
+ exports.shouldProcess = hasTwUsage;
3591
+ exports.toAtomicClasses = toAtomicClasses;
3592
+ exports.transformSource = transformSource;
3593
+ //# sourceMappingURL=compiler.cjs.map
3594
+ //# sourceMappingURL=compiler.cjs.map