@styleframe/loader 1.0.3 → 1.1.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.
package/dist/index.js CHANGED
@@ -1,164 +1,165 @@
1
1
  import { stat, rm, mkdir, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { validateInstanceLicense, getLicenseKeyFromEnv } from "@styleframe/license";
3
4
  import { loadConfig, watchConfig } from "c12";
4
- const N$1 = ["charset", "import", "namespace"], E$1 = ["layer"], V$1 = ({ name: e }) => `[data-theme="${e}"]`, _$1 = ({
5
+ const N = ["charset", "import", "namespace"], R$1 = ["layer"], D$1 = ({ name: e }) => `[data-theme="${e}"]`, I = ({
5
6
  name: e,
6
7
  value: t,
7
- modifiers: s
8
- }) => `._${[...s, e, t].filter(Boolean).join("\\:")}`, O$1 = ({ name: e }) => e;
9
- function D$1(e, t) {
8
+ modifiers: r
9
+ }) => `._${[...r, e, t].filter(Boolean).join("\\:")}`, w = ({ name: e }) => e;
10
+ function L(e, t) {
10
11
  return `@${e}${t ? " " : ""}${t}`;
11
12
  }
12
- const B$1 = /\d/, L$1 = ["-", "_", "/", "."];
13
- function M$1(e = "") {
14
- if (!B$1.test(e))
13
+ const P$1 = /\d/, M$1 = ["-", "_", "/", "."];
14
+ function $$1(e = "") {
15
+ if (!P$1.test(e))
15
16
  return e !== e.toLowerCase();
16
17
  }
17
- function U(e, t) {
18
- const s = L$1, r = [];
18
+ function U$1(e, t) {
19
+ const r = M$1, n = [];
19
20
  if (!e || typeof e != "string")
20
- return r;
21
- let c = "", l, u;
22
- for (const i of e) {
23
- const n = s.includes(i);
24
- if (n === true) {
25
- r.push(c), c = "", l = void 0;
21
+ return n;
22
+ let u = "", a, i;
23
+ for (const s of e) {
24
+ const o = r.includes(s);
25
+ if (o === true) {
26
+ n.push(u), u = "", a = void 0;
26
27
  continue;
27
28
  }
28
- const o = M$1(i);
29
- if (u === false) {
30
- if (l === false && o === true) {
31
- r.push(c), c = i, l = o;
29
+ const c = $$1(s);
30
+ if (i === false) {
31
+ if (a === false && c === true) {
32
+ n.push(u), u = s, a = c;
32
33
  continue;
33
34
  }
34
- if (l === true && o === false && c.length > 1) {
35
- const f = c.at(-1);
36
- r.push(c.slice(0, Math.max(0, c.length - 1))), c = f + i, l = o;
35
+ if (a === true && c === false && u.length > 1) {
36
+ const f = u.at(-1);
37
+ n.push(u.slice(0, Math.max(0, u.length - 1))), u = f + s, a = c;
37
38
  continue;
38
39
  }
39
40
  }
40
- c += i, l = o, u = n;
41
+ u += s, a = c, i = o;
41
42
  }
42
- return r.push(c), r;
43
+ return n.push(u), n;
43
44
  }
44
- function P(e, t) {
45
- return e ? (Array.isArray(e) ? e : U(e)).map((s) => s.toLowerCase()).join("-") : "";
45
+ function _$1(e, t) {
46
+ return e ? (Array.isArray(e) ? e : U$1(e)).map((r) => r.toLowerCase()).join("-") : "";
46
47
  }
47
48
  function k$1(e) {
48
49
  return ` ${e}`;
49
50
  }
50
- function x(e) {
51
+ function V(e) {
51
52
  return e.split(`
52
53
  `).map((t) => k$1(t)).join(`
53
54
  `);
54
55
  }
55
- function z$1(e) {
56
- return P(e);
56
+ function x(e) {
57
+ return _$1(e);
57
58
  }
58
- function H$1(e) {
59
- return z$1(e);
59
+ function K$1(e) {
60
+ return x(e);
60
61
  }
61
- function T$1(e, t) {
62
- return `${e.startsWith("--") ? e : H$1(e)}: ${t};`;
62
+ function B$1(e, t) {
63
+ return `${e.startsWith("--") ? e : K$1(e)}: ${t};`;
63
64
  }
64
- function I$1(e) {
65
+ function q$1(e) {
65
66
  return `{${e.length > 0 ? `
66
- ` : ""}${e.map((t) => `${x(`${t}`)}
67
+ ` : ""}${e.map((t) => `${V(`${t}`)}
67
68
  `).join("")}}`;
68
69
  }
69
- function $$1(e) {
70
+ function O$1(e) {
70
71
  return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
71
72
  }
72
- function K$1(e, t) {
73
- return T$1($$1(e), t);
73
+ function z$1(e, t) {
74
+ return B$1(O$1(e), t);
74
75
  }
75
- function Q(e, t) {
76
- return `var(${$$1(e)}${t ? `, ${t}` : ""})`;
76
+ function H$1(e, t) {
77
+ return `var(${O$1(e)}${t ? `, ${t}` : ""})`;
77
78
  }
78
79
  function C$1(e, t) {
79
- return `${e} ${I$1(t)}`;
80
+ return `${e} ${q$1(t)}`;
80
81
  }
81
- function W$1(e) {
82
- return function(s, r) {
83
- return Object.entries(s).map(([c, l]) => T$1(c, e(l, r)));
82
+ function Q$1(e) {
83
+ return function(r, n) {
84
+ return Object.entries(r).map(([u, a]) => B$1(u, e(a, n)));
84
85
  };
85
86
  }
86
- function w$1(e) {
87
- return function(s, r) {
88
- const l = (r.variables?.name ?? O$1)({ name: s.name });
89
- return K$1(l, e(s.value, r));
87
+ function E$1(e) {
88
+ return function(r, n) {
89
+ const a = (n.variables?.name ?? w)({ name: r.name });
90
+ return z$1(a, e(r.value, n));
90
91
  };
91
92
  }
92
- function A(e) {
93
- const t = w$1(e), s = W$1(e);
94
- return function(c, l, u) {
95
- const { variables: i, declarations: n, children: o } = l, f = c === ":root", a = (i ?? []).map(
96
- (g2) => t(g2, u)
97
- ), m2 = s(
98
- n ?? {},
99
- u
100
- ), b2 = (o ?? []).map(
101
- (g2) => e(g2, u)
102
- ), p2 = a.length > 0, h = m2.length > 0, S2 = b2.length > 0;
103
- return f ? `${p2 || h ? C$1(c, [
104
- ...a,
105
- ...p2 && h ? [""] : [],
93
+ function S$1(e) {
94
+ const t = E$1(e), r = Q$1(e);
95
+ return function(u, a, i) {
96
+ const { variables: s, declarations: o, children: c } = a, f = u === ":root", l = (s ?? []).map(
97
+ (A2) => t(A2, i)
98
+ ), m2 = r(
99
+ o ?? {},
100
+ i
101
+ ), y = (c ?? []).map(
102
+ (A2) => e(A2, i)
103
+ ), d = l.length > 0, h = m2.length > 0, v = y.length > 0;
104
+ return f ? `${d || h ? C$1(u, [
105
+ ...l,
106
+ ...d && h ? [""] : [],
106
107
  ...m2
107
- ]) : ""}${S2 && (p2 || h) ? `
108
+ ]) : ""}${v && (d || h) ? `
108
109
 
109
- ` : ""}${b2.join(`
110
+ ` : ""}${y.join(`
110
111
 
111
- `)}` : C$1(c, [
112
- ...a,
113
- ...p2 && (S2 || h) ? [""] : [],
112
+ `)}` : C$1(u, [
113
+ ...l,
114
+ ...d && (v || h) ? [""] : [],
114
115
  ...m2,
115
- ...h && S2 ? [""] : [],
116
- ...b2.flatMap(
117
- (g2, F2) => F2 === b2.length - 1 ? [g2] : [g2, ""]
116
+ ...h && v ? [""] : [],
117
+ ...y.flatMap(
118
+ (A2, F2) => F2 === y.length - 1 ? [A2] : [A2, ""]
118
119
  )
119
120
  ]);
120
121
  };
121
122
  }
122
123
  function Z(e) {
123
- const t = A(e);
124
- return function(r, c) {
125
- const l = N$1.includes(r.identifier), u = E$1.includes(
126
- r.identifier
127
- ), i = Object.keys(r.declarations).length > 0, n = r.variables.length > 0, o = r.children.length > 0, f = D$1(r.identifier, r.rule);
128
- return l || u && !(i || n || o) ? `${f};` : t(f, r, c);
124
+ const t = S$1(e);
125
+ return function(n, u) {
126
+ const a = N.includes(n.identifier), i = R$1.includes(
127
+ n.identifier
128
+ ), s = Object.keys(n.declarations).length > 0, o = n.variables.length > 0, c = n.children.length > 0, f = L(n.identifier, n.rule);
129
+ return a || i && !(s || o || c) ? `${f};` : t(f, n, u);
129
130
  };
130
131
  }
131
- function q$1(e) {
132
+ function W$1(e) {
132
133
  return typeof e == "object" && e !== null;
133
134
  }
134
- function d(e, t) {
135
- return q$1(e) && "type" in e && e.type === t;
135
+ function b$1(e, t) {
136
+ return W$1(e) && "type" in e && e.type === t;
136
137
  }
137
- function G(e) {
138
- return d(e, "variable");
138
+ function J$1(e) {
139
+ return b$1(e, "variable");
139
140
  }
140
- function J(e) {
141
- return d(e, "reference");
141
+ function G$1(e) {
142
+ return b$1(e, "reference");
142
143
  }
143
144
  function Y$1(e) {
144
- return d(e, "selector");
145
+ return b$1(e, "selector");
145
146
  }
146
- function X(e) {
147
- return d(e, "at-rule");
147
+ function X$1(e) {
148
+ return b$1(e, "at-rule");
148
149
  }
149
150
  function ee(e) {
150
- return d(e, "utility");
151
+ return b$1(e, "utility");
151
152
  }
152
153
  function te(e) {
153
- return d(e, "css");
154
- }
155
- function re(e) {
156
- return d(e, "theme");
154
+ return b$1(e, "css");
157
155
  }
158
156
  function ne(e) {
159
- return d(e, "root");
157
+ return b$1(e, "theme");
160
158
  }
161
- function j$1(e) {
159
+ function re(e) {
160
+ return b$1(e, "root");
161
+ }
162
+ function g$1(e) {
162
163
  if (e instanceof Buffer)
163
164
  return Buffer.from(e);
164
165
  const t = e.constructor;
@@ -168,157 +169,157 @@ function j$1(e) {
168
169
  e.byteLength / e.BYTES_PER_ELEMENT || 1
169
170
  );
170
171
  }
171
- function oe$1(e) {
172
+ function oe(e) {
172
173
  if (e = e || {}, e.circular)
173
- return ue(e);
174
+ return ce(e);
174
175
  const t = /* @__PURE__ */ new Map();
175
- if (t.set(Date, (u) => new Date(u)), t.set(
176
+ if (t.set(Date, (i) => new Date(i)), t.set(
176
177
  Map,
177
- (u, i) => new Map(r(Array.from(u), i))
178
+ (i, s) => new Map(n(Array.from(i), s))
178
179
  ), t.set(
179
180
  Set,
180
- (u, i) => new Set(r(Array.from(u), i))
181
+ (i, s) => new Set(n(Array.from(i), s))
181
182
  ), e.constructorHandlers)
182
- for (const u of e.constructorHandlers)
183
- t.set(u[0], u[1]);
184
- let s;
185
- return e.proto ? l : c;
186
- function r(u, i) {
187
- const n = Object.keys(u), o = Array.from({ length: n.length });
188
- for (let f = 0; f < n.length; f++) {
189
- const a = n[f], m2 = u[a];
190
- typeof m2 != "object" || m2 === null ? o[a] = m2 : m2.constructor !== Object && (s = t.get(m2.constructor)) ? o[a] = s(m2, i) : ArrayBuffer.isView(m2) ? o[a] = j$1(m2) : o[a] = i(m2);
183
+ for (const i of e.constructorHandlers)
184
+ t.set(i[0], i[1]);
185
+ let r;
186
+ return e.proto ? a : u;
187
+ function n(i, s) {
188
+ const o = Object.keys(i), c = Array.from({ length: o.length });
189
+ for (let f = 0; f < o.length; f++) {
190
+ const l = o[f], m2 = i[l];
191
+ typeof m2 != "object" || m2 === null ? c[l] = m2 : m2.constructor !== Object && (r = t.get(m2.constructor)) ? c[l] = r(m2, s) : ArrayBuffer.isView(m2) ? c[l] = g$1(m2) : c[l] = s(m2);
191
192
  }
192
- return o;
193
+ return c;
193
194
  }
194
- function c(u) {
195
- if (typeof u != "object" || u === null) return u;
196
- if (Array.isArray(u)) return r(u, c);
197
- if (u.constructor !== Object && (s = t.get(u.constructor)))
198
- return s(u, c);
199
- const i = {};
200
- for (const n in u) {
201
- if (Object.hasOwnProperty.call(u, n) === false) continue;
202
- const o = u[n];
203
- typeof o != "object" || o === null ? i[n] = o : o.constructor !== Object && (s = t.get(o.constructor)) ? i[n] = s(o, c) : ArrayBuffer.isView(o) ? i[n] = j$1(o) : i[n] = c(o);
195
+ function u(i) {
196
+ if (typeof i != "object" || i === null) return i;
197
+ if (Array.isArray(i)) return n(i, u);
198
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
199
+ return r(i, u);
200
+ const s = {};
201
+ for (const o in i) {
202
+ if (Object.hasOwnProperty.call(i, o) === false) continue;
203
+ const c = i[o];
204
+ typeof c != "object" || c === null ? s[o] = c : c.constructor !== Object && (r = t.get(c.constructor)) ? s[o] = r(c, u) : ArrayBuffer.isView(c) ? s[o] = g$1(c) : s[o] = u(c);
204
205
  }
205
- return i;
206
+ return s;
206
207
  }
207
- function l(u) {
208
- if (typeof u != "object" || u === null) return u;
209
- if (Array.isArray(u)) return r(u, l);
210
- if (u.constructor !== Object && (s = t.get(u.constructor)))
211
- return s(u, l);
212
- const i = {};
213
- for (const n in u) {
214
- const o = u[n];
215
- typeof o != "object" || o === null ? i[n] = o : o.constructor !== Object && (s = t.get(o.constructor)) ? i[n] = s(o, l) : ArrayBuffer.isView(o) ? i[n] = j$1(o) : i[n] = l(o);
208
+ function a(i) {
209
+ if (typeof i != "object" || i === null) return i;
210
+ if (Array.isArray(i)) return n(i, a);
211
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
212
+ return r(i, a);
213
+ const s = {};
214
+ for (const o in i) {
215
+ const c = i[o];
216
+ typeof c != "object" || c === null ? s[o] = c : c.constructor !== Object && (r = t.get(c.constructor)) ? s[o] = r(c, a) : ArrayBuffer.isView(c) ? s[o] = g$1(c) : s[o] = a(c);
216
217
  }
217
- return i;
218
+ return s;
218
219
  }
219
220
  }
220
- function ue(e) {
221
- const t = [], s = [], r = /* @__PURE__ */ new Map();
222
- if (r.set(Date, (n) => new Date(n)), r.set(
221
+ function ce(e) {
222
+ const t = [], r = [], n = /* @__PURE__ */ new Map();
223
+ if (n.set(Date, (o) => new Date(o)), n.set(
223
224
  Map,
224
- (n, o) => new Map(l(Array.from(n), o))
225
- ), r.set(
225
+ (o, c) => new Map(a(Array.from(o), c))
226
+ ), n.set(
226
227
  Set,
227
- (n, o) => new Set(l(Array.from(n), o))
228
+ (o, c) => new Set(a(Array.from(o), c))
228
229
  ), e.constructorHandlers)
229
- for (const n of e.constructorHandlers)
230
- r.set(n[0], n[1]);
231
- let c;
232
- return e.proto ? i : u;
233
- function l(n, o) {
234
- const f = Object.keys(n), a = Array.from({ length: f.length });
230
+ for (const o of e.constructorHandlers)
231
+ n.set(o[0], o[1]);
232
+ let u;
233
+ return e.proto ? s : i;
234
+ function a(o, c) {
235
+ const f = Object.keys(o), l = Array.from({ length: f.length });
235
236
  for (let m2 = 0; m2 < f.length; m2++) {
236
- const b2 = f[m2], p2 = n[b2];
237
- if (typeof p2 != "object" || p2 === null)
238
- a[b2] = p2;
239
- else if (p2.constructor !== Object && (c = r.get(p2.constructor)))
240
- a[b2] = c(p2, o);
241
- else if (ArrayBuffer.isView(p2))
242
- a[b2] = j$1(p2);
237
+ const y = f[m2], d = o[y];
238
+ if (typeof d != "object" || d === null)
239
+ l[y] = d;
240
+ else if (d.constructor !== Object && (u = n.get(d.constructor)))
241
+ l[y] = u(d, c);
242
+ else if (ArrayBuffer.isView(d))
243
+ l[y] = g$1(d);
243
244
  else {
244
- const h = t.indexOf(p2);
245
- h !== -1 ? a[b2] = s[h] : a[b2] = o(p2);
245
+ const h = t.indexOf(d);
246
+ h !== -1 ? l[y] = r[h] : l[y] = c(d);
246
247
  }
247
248
  }
248
- return a;
249
+ return l;
249
250
  }
250
- function u(n) {
251
- if (typeof n != "object" || n === null) return n;
252
- if (Array.isArray(n)) return l(n, u);
253
- if (n.constructor !== Object && (c = r.get(n.constructor)))
254
- return c(n, u);
255
- const o = {};
256
- t.push(n), s.push(o);
257
- for (const f in n) {
258
- if (Object.hasOwnProperty.call(n, f) === false) continue;
259
- const a = n[f];
260
- if (typeof a != "object" || a === null)
261
- o[f] = a;
262
- else if (a.constructor !== Object && (c = r.get(a.constructor)))
263
- o[f] = c(a, u);
264
- else if (ArrayBuffer.isView(a))
265
- o[f] = j$1(a);
251
+ function i(o) {
252
+ if (typeof o != "object" || o === null) return o;
253
+ if (Array.isArray(o)) return a(o, i);
254
+ if (o.constructor !== Object && (u = n.get(o.constructor)))
255
+ return u(o, i);
256
+ const c = {};
257
+ t.push(o), r.push(c);
258
+ for (const f in o) {
259
+ if (Object.hasOwnProperty.call(o, f) === false) continue;
260
+ const l = o[f];
261
+ if (typeof l != "object" || l === null)
262
+ c[f] = l;
263
+ else if (l.constructor !== Object && (u = n.get(l.constructor)))
264
+ c[f] = u(l, i);
265
+ else if (ArrayBuffer.isView(l))
266
+ c[f] = g$1(l);
266
267
  else {
267
- const m2 = t.indexOf(a);
268
- m2 !== -1 ? o[f] = s[m2] : o[f] = u(a);
268
+ const m2 = t.indexOf(l);
269
+ m2 !== -1 ? c[f] = r[m2] : c[f] = i(l);
269
270
  }
270
271
  }
271
- return t.pop(), s.pop(), o;
272
+ return t.pop(), r.pop(), c;
272
273
  }
273
- function i(n) {
274
- if (typeof n != "object" || n === null) return n;
275
- if (Array.isArray(n)) return l(n, i);
276
- if (n.constructor !== Object && (c = r.get(n.constructor)))
277
- return c(n, i);
278
- const o = {};
279
- t.push(n), s.push(o);
280
- for (const f in n) {
281
- const a = n[f];
282
- if (typeof a != "object" || a === null)
283
- o[f] = a;
284
- else if (a.constructor !== Object && (c = r.get(a.constructor)))
285
- o[f] = c(a, i);
286
- else if (ArrayBuffer.isView(a))
287
- o[f] = j$1(a);
274
+ function s(o) {
275
+ if (typeof o != "object" || o === null) return o;
276
+ if (Array.isArray(o)) return a(o, s);
277
+ if (o.constructor !== Object && (u = n.get(o.constructor)))
278
+ return u(o, s);
279
+ const c = {};
280
+ t.push(o), r.push(c);
281
+ for (const f in o) {
282
+ const l = o[f];
283
+ if (typeof l != "object" || l === null)
284
+ c[f] = l;
285
+ else if (l.constructor !== Object && (u = n.get(l.constructor)))
286
+ c[f] = u(l, s);
287
+ else if (ArrayBuffer.isView(l))
288
+ c[f] = g$1(l);
288
289
  else {
289
- const m2 = t.indexOf(a);
290
- m2 !== -1 ? o[f] = s[m2] : o[f] = i(a);
290
+ const m2 = t.indexOf(l);
291
+ m2 !== -1 ? c[f] = r[m2] : c[f] = s(l);
291
292
  }
292
293
  }
293
- return t.pop(), s.pop(), o;
294
+ return t.pop(), r.pop(), c;
294
295
  }
295
296
  }
296
- oe$1();
297
- function ce(e) {
298
- return function(s, r) {
299
- return s.value.map((c) => e(c, r)).join("").trim();
297
+ oe();
298
+ function ue$1(e) {
299
+ return function(r, n) {
300
+ return r.value.map((u) => e(u, n)).join("").trim();
300
301
  };
301
302
  }
302
- function se(e) {
303
- return function(s, r) {
304
- return s != null ? `${s}` : "";
303
+ function ie(e) {
304
+ return function(r, n) {
305
+ return r != null ? `${r}` : "";
305
306
  };
306
307
  }
307
- function ie(e) {
308
- return function(s, r) {
309
- const l = (r.variables?.name ?? O$1)({ name: s.name });
310
- return Q(
311
- l,
312
- s.fallback ? e(s.fallback, r) : void 0
308
+ function se(e) {
309
+ return function(r, n) {
310
+ const a = (n.variables?.name ?? w)({ name: r.name });
311
+ return H$1(
312
+ a,
313
+ r.fallback ? e(r.fallback, n) : void 0
313
314
  );
314
315
  };
315
316
  }
316
317
  function ae(e) {
317
- const t = A(e);
318
- return function(r, c) {
319
- return r.themes.reduce(
320
- (l, u) => (l.push(e(u, c)), l),
321
- [t(":root", r, c)]
318
+ const t = S$1(e);
319
+ return function(n, u) {
320
+ return n.themes.reduce(
321
+ (a, i) => (a.push(e(i, u)), a),
322
+ [t(":root", n, u)]
322
323
  // Default theme (root)
323
324
  ).join(`
324
325
 
@@ -326,58 +327,58 @@ function ae(e) {
326
327
  };
327
328
  }
328
329
  function le(e) {
329
- const t = A(e);
330
- return function(r, c) {
331
- return t(r.query, r, c);
330
+ const t = S$1(e);
331
+ return function(n, u) {
332
+ return t(n.query, n, u);
332
333
  };
333
334
  }
334
335
  function fe(e) {
335
- const t = A(e);
336
- return function(r, c) {
337
- const u = (c.theme?.selector ?? V$1)({ name: r.name });
338
- return t(u, r, c);
336
+ const t = S$1(e);
337
+ return function(n, u) {
338
+ const i = (u.theme?.selector ?? D$1)({ name: n.name });
339
+ return t(i, n, u);
339
340
  };
340
341
  }
341
342
  function me(e) {
342
- const t = A(e);
343
- return function(r, c) {
344
- const l = [], i = (c.utilities?.selector ?? _$1)({
345
- name: r.name,
346
- value: r.value,
347
- modifiers: r.modifiers
343
+ const t = S$1(e);
344
+ return function(n, u) {
345
+ const a = [], s = (u.utilities?.selector ?? I)({
346
+ name: n.name,
347
+ value: n.value,
348
+ modifiers: n.modifiers
348
349
  });
349
- return l.push(t(i, r, c)), l.join(`
350
+ return a.push(t(s, n, u)), a.join(`
350
351
 
351
352
  `);
352
353
  };
353
354
  }
354
- function y(e, t) {
355
- const s = ae(y), r = le(y), c = me(y), l = Z(y), u = fe(y), i = w$1(y), n = ie(y), o = ce(y), f = se();
355
+ function p$1(e, t) {
356
+ const r = ae(p$1), n = le(p$1), u = me(p$1), a = Z(p$1), i = fe(p$1), s = E$1(p$1), o = se(p$1), c = ue$1(p$1), f = ie();
356
357
  switch (true) {
357
358
  case Y$1(e):
358
- return r(e, t);
359
+ return n(e, t);
359
360
  case ee(e):
360
- return c(e, t);
361
- case X(e):
362
- return l(e, t);
363
- case ne(e):
364
- return s(e, t);
365
- case re(e):
366
361
  return u(e, t);
367
- case G(e):
362
+ case X$1(e):
363
+ return a(e, t);
364
+ case re(e):
365
+ return r(e, t);
366
+ case ne(e):
368
367
  return i(e, t);
369
- case J(e):
370
- return n(e, t);
371
- case te(e):
368
+ case J$1(e):
369
+ return s(e, t);
370
+ case G$1(e):
372
371
  return o(e, t);
372
+ case te(e):
373
+ return c(e, t);
373
374
  default:
374
375
  return f(e, t);
375
376
  }
376
377
  }
377
- function R$1(e, t) {
378
+ function T$1(e, t) {
378
379
  switch (true) {
379
380
  case Array.isArray(e):
380
- return e.map((s) => R$1(s)).join(`
381
+ return e.map((r) => T$1(r)).join(`
381
382
  `);
382
383
  // case isRecipe(instance):
383
384
  // return consumeRecipe(instance, options);
@@ -386,26 +387,132 @@ function R$1(e, t) {
386
387
  return "";
387
388
  }
388
389
  }
389
- function v(e, t = "") {
390
+ const de = `-----BEGIN PUBLIC KEY-----
391
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
392
+ qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
393
+ BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
394
+ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
395
+ hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
396
+ 4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
397
+ GwIDAQAB
398
+ -----END PUBLIC KEY-----`, ye = "__licenseRequired", pe = "__licenseValidated";
399
+ async function he(e) {
400
+ const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (n) => n.charCodeAt(0));
401
+ return await crypto.subtle.importKey(
402
+ "spki",
403
+ r,
404
+ {
405
+ name: "RSASSA-PKCS1-v1_5",
406
+ hash: "SHA-256"
407
+ },
408
+ true,
409
+ ["verify"]
410
+ );
411
+ }
412
+ async function be({
413
+ payload: e,
414
+ signature: t
415
+ }) {
416
+ const r = new TextEncoder().encode(e), n = Uint8Array.from(
417
+ atob(t),
418
+ (a) => a.charCodeAt(0)
419
+ ), u = await he(de);
420
+ if (!await crypto.subtle.verify(
421
+ { name: "RSASSA-PKCS1-v1_5" },
422
+ u,
423
+ n,
424
+ r
425
+ ))
426
+ throw new Error(
427
+ "License validation failed: Invalid signature detected. The license may have been modified or corrupted."
428
+ );
429
+ return JSON.parse(e);
430
+ }
431
+ function Ae(e) {
432
+ return Object.prototype.hasOwnProperty.call(e, ye);
433
+ }
434
+ async function ge(e) {
435
+ const t = Object.getOwnPropertyDescriptor(
436
+ e,
437
+ pe
438
+ );
439
+ if (!t?.value)
440
+ return {
441
+ key: "",
442
+ instanceId: "",
443
+ environment: "",
444
+ valid: false
445
+ };
446
+ const r = t.value;
447
+ if (typeof r != "object" || r === null || !("payload" in r) || !("signature" in r) || typeof r.payload != "string" || typeof r.signature != "string")
448
+ return {
449
+ key: "",
450
+ instanceId: "",
451
+ environment: "",
452
+ valid: false
453
+ };
454
+ try {
455
+ return await be(
456
+ r
457
+ );
458
+ } catch {
459
+ return {
460
+ key: "",
461
+ instanceId: "",
462
+ environment: "",
463
+ valid: false
464
+ };
465
+ }
466
+ }
467
+ function Se(e) {
468
+ const t = Math.floor(Math.random() * 100);
469
+ e.root.children.push({
470
+ type: "selector",
471
+ query: `html:nth-of-type(${t}n+1)::after`,
472
+ variables: [],
473
+ children: [],
474
+ declarations: {
475
+ content: '"Styleframe Pro: Development Mode – License required for production use"',
476
+ zIndex: 99999,
477
+ position: "fixed",
478
+ display: "block !important",
479
+ opacity: "1 !important",
480
+ bottom: 0,
481
+ left: 0,
482
+ background: "rgba(0, 0, 0, 0.5)",
483
+ color: "white",
484
+ fontSize: "12px",
485
+ lineHeight: "1",
486
+ padding: "0.5rem",
487
+ fontFamily: "sans-serif"
488
+ }
489
+ });
490
+ }
491
+ function j(e, t = "") {
390
492
  return {
391
493
  name: e,
392
494
  content: t
393
495
  };
394
496
  }
395
- function be(e, {
497
+ async function Ce(e, {
396
498
  type: t = "all",
397
- consumers: s = { css: y, ts: R$1 }
499
+ consumers: r = { css: p$1, ts: T$1 }
398
500
  } = {}) {
399
- const r = { files: [] }, c = e.options, { recipes: l, ...u } = e.root;
501
+ const n = { files: [] }, u = e.options;
502
+ if (Ae(e)) {
503
+ const s = await ge(e);
504
+ (!s.valid || s.instanceId !== e.id) && Se(e);
505
+ }
506
+ const { recipes: a, ...i } = e.root;
400
507
  if (t === "all" || t === "css") {
401
- const i = v("index.css", s.css(u, c));
402
- r.files.push(i);
508
+ const s = j("index.css", r.css(i, u));
509
+ n.files.push(s);
403
510
  }
404
511
  if (t === "all" || t === "ts") {
405
- const i = v("index.ts", s.ts([], c));
406
- r.files.push(i);
512
+ const s = j("index.ts", r.ts([], u));
513
+ n.files.push(s);
407
514
  }
408
- return r;
515
+ return console.log(n.files), n;
409
516
  }
410
517
  async function directoryExists(path2) {
411
518
  try {
@@ -416,7 +523,12 @@ async function directoryExists(path2) {
416
523
  }
417
524
  }
418
525
  async function build(instance, { clean = true, outputDir = "./styleframe", transpiler } = {}) {
419
- const output = be(instance, transpiler);
526
+ await validateInstanceLicense(instance, {
527
+ licenseKey: getLicenseKeyFromEnv() || "",
528
+ environment: process.env.NODE_ENV || "development",
529
+ isBuild: true
530
+ });
531
+ const output = await Ce(instance, transpiler);
420
532
  const outputDirExists = await directoryExists(outputDir);
421
533
  if (clean && outputDirExists) {
422
534
  await rm(outputDir, { recursive: true });
@@ -431,310 +543,319 @@ async function build(instance, { clean = true, outputDir = "./styleframe", trans
431
543
  await writeFile(filePath, file.content);
432
544
  }
433
545
  }
434
- function M(e, t) {
435
- return function(n, ...o) {
546
+ function k(e, r) {
547
+ return function(t, ...i) {
436
548
  return {
437
549
  type: "css",
438
- value: n.reduce((i, u, c) => (i.push(u), c < o.length && i.push(o[c]), i), [])
550
+ value: t.reduce((o, u, c) => (o.push(u), c < i.length && o.push(i[c]), o), [])
439
551
  };
440
552
  };
441
553
  }
442
- function V(e) {
554
+ function M(e) {
443
555
  return typeof e == "object" && e !== null;
444
556
  }
445
- function p(e, t) {
446
- return V(e) && "type" in e && e.type === t;
557
+ function p(e, r) {
558
+ return M(e) && "type" in e && e.type === r;
447
559
  }
448
- function k(e) {
560
+ function B(e) {
449
561
  return p(e, "variable");
450
562
  }
451
- function O(e) {
563
+ function F(e) {
452
564
  return p(e, "reference");
453
565
  }
454
- function B(e) {
566
+ function T(e) {
455
567
  return p(e, "css");
456
568
  }
457
- function F(e) {
569
+ function _(e) {
458
570
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
459
571
  }
460
- function R(e) {
461
- return F(e) || O(e) || B(e) || Array.isArray(e) && e.every(R);
572
+ function O(e) {
573
+ return _(e) || F(e) || T(e) || Array.isArray(e) && e.every(O);
462
574
  }
463
- function T(e) {
464
- return V(e) && "children" in e && "declarations" in e && "variables" in e;
575
+ function C(e) {
576
+ return M(e) && "children" in e && "declarations" in e && "variables" in e;
465
577
  }
466
- function w(e, t) {
467
- return function(n, o, s) {
468
- const i = {
578
+ function R(e, r) {
579
+ return function(t, i, s) {
580
+ const o = {
469
581
  type: "at-rule",
470
- identifier: n,
471
- rule: o,
582
+ identifier: t,
583
+ rule: i,
472
584
  declarations: {},
473
585
  variables: [],
474
586
  children: []
475
- }, u = b(i, t);
476
- return typeof s == "function" ? i.declarations = s(u) ?? {} : s && (i.declarations = s), g(i.declarations, u), e.children.push(i), i;
587
+ }, u = b(o, r);
588
+ return typeof s == "function" ? o.declarations = s(u) ?? {} : s && (o.declarations = s), g(o.declarations, u), e.children.push(o), o;
477
589
  };
478
590
  }
479
- function C(e, t) {
480
- const r = w(e, t);
481
- return function(o, s) {
482
- return r("media", o, s);
591
+ function S(e, r) {
592
+ const n = R(e, r);
593
+ return function(i, s) {
594
+ return n("media", i, s);
483
595
  };
484
596
  }
485
- function _(e, t) {
486
- const r = w(e, t);
487
- return function(o, s) {
488
- return r("keyframes", o, s);
597
+ function E(e, r) {
598
+ const n = R(e, r);
599
+ return function(i, s) {
600
+ return n("keyframes", i, s);
489
601
  };
490
602
  }
491
- function S(e, t) {
492
- return function(n, o) {
493
- return k(n) ? {
603
+ function P(e, r) {
604
+ return function(t, i) {
605
+ return B(t) ? {
494
606
  type: "reference",
495
- name: n.name,
496
- fallback: o
607
+ name: t.name,
608
+ fallback: i
497
609
  } : {
498
610
  type: "reference",
499
- name: n,
500
- fallback: o
611
+ name: t,
612
+ fallback: i
501
613
  };
502
614
  };
503
615
  }
504
- function E(e, t) {
505
- return function(n, o) {
616
+ function D(e, r) {
617
+ return function(t, i) {
506
618
  const s = {
507
619
  type: "selector",
508
- query: n,
620
+ query: t,
509
621
  declarations: {},
510
622
  variables: [],
511
623
  children: []
512
- }, i = b(s, t);
513
- return typeof o == "function" ? s.declarations = o(i) ?? {} : T(o) ? (s.variables = o.variables, s.declarations = o.declarations, s.children = o.children) : s.declarations = o, g(s.declarations, i), e.children.push(s), s;
624
+ }, o = b(s, r);
625
+ return typeof i == "function" ? s.declarations = i(o) ?? {} : C(i) ? (s.variables = i.variables, s.declarations = i.declarations, s.children = i.children) : s.declarations = i, g(s.declarations, o), e.children.push(s), s;
514
626
  };
515
627
  }
516
- function D(e, t) {
517
- return function(n, o, s = {
628
+ function H(e, r) {
629
+ return function(t, i, s = {
518
630
  default: false
519
631
  }) {
520
- const i = typeof n == "string" ? n : n.name, u = e.variables.find(
521
- (f) => f.name === i
632
+ const o = typeof t == "string" ? t : t.name, u = e.variables.find(
633
+ (f) => f.name === o
522
634
  );
523
635
  if (s.default && u)
524
636
  return u;
525
637
  if (u)
526
- return u.value = o, u;
638
+ return u.value = i, u;
527
639
  const c = {
528
640
  type: "variable",
529
- name: i,
530
- value: o
641
+ name: o,
642
+ value: i
531
643
  };
532
644
  return e.variables.push(c), c;
533
645
  };
534
646
  }
535
- function b(e, t) {
536
- const r = D(e), n = E(e, t), o = w(e, t), s = _(t, t), i = C(e, t), u = S(), c = M();
647
+ function b(e, r) {
648
+ const n = H(e), t = D(e, r), i = R(e, r), s = E(r, r), o = S(e, r), u = P(), c = k();
537
649
  return {
538
- variable: r,
539
- selector: n,
650
+ variable: n,
651
+ selector: t,
540
652
  keyframes: s,
541
- atRule: o,
542
- media: i,
653
+ atRule: i,
654
+ media: o,
543
655
  ref: u,
544
656
  css: c
545
657
  };
546
658
  }
547
- function g(e, t) {
548
- for (const r in e)
549
- if (r.startsWith("@")) {
550
- const n = e[r];
551
- if (typeof n == "object" && n !== null && !R(n)) {
552
- const o = r.replace(/^@(\w+).*/, "$1"), s = r.replace(`@${o}`, "").trim();
553
- t.atRule(o, s, n), delete e[r];
659
+ function g(e, r) {
660
+ for (const n in e)
661
+ if (n.startsWith("@")) {
662
+ const t = e[n];
663
+ if (typeof t == "object" && t !== null && !O(t)) {
664
+ const i = n.replace(/^@(\w+).*/, "$1"), s = n.replace(`@${i}`, "").trim();
665
+ r.atRule(i, s, t), delete e[n];
554
666
  }
555
- } else if (/^[.&:]/.test(r)) {
556
- const n = e[r];
557
- typeof n == "object" && (t.selector(r, n), delete e[r]);
667
+ } else if (/^[.&:]/.test(n)) {
668
+ const t = e[n];
669
+ typeof t == "object" && (r.selector(n, t), delete e[n]);
558
670
  }
559
671
  return e;
560
672
  }
561
673
  function m(e) {
562
674
  if (e instanceof Buffer)
563
675
  return Buffer.from(e);
564
- const t = e.constructor;
565
- return new t(
676
+ const r = e.constructor;
677
+ return new r(
566
678
  e.buffer.slice(0),
567
679
  e.byteOffset,
568
680
  e.byteLength / e.BYTES_PER_ELEMENT || 1
569
681
  );
570
682
  }
571
- function H(e) {
683
+ function K(e) {
572
684
  if (e = e || {}, e.circular)
573
- return K(e);
574
- const t = /* @__PURE__ */ new Map();
575
- if (t.set(Date, (i) => new Date(i)), t.set(
685
+ return U(e);
686
+ const r = /* @__PURE__ */ new Map();
687
+ if (r.set(Date, (o) => new Date(o)), r.set(
576
688
  Map,
577
- (i, u) => new Map(n(Array.from(i), u))
578
- ), t.set(
689
+ (o, u) => new Map(t(Array.from(o), u))
690
+ ), r.set(
579
691
  Set,
580
- (i, u) => new Set(n(Array.from(i), u))
692
+ (o, u) => new Set(t(Array.from(o), u))
581
693
  ), e.constructorHandlers)
582
- for (const i of e.constructorHandlers)
583
- t.set(i[0], i[1]);
584
- let r;
585
- return e.proto ? s : o;
586
- function n(i, u) {
587
- const c = Object.keys(i), f = Array.from({ length: c.length });
694
+ for (const o of e.constructorHandlers)
695
+ r.set(o[0], o[1]);
696
+ let n;
697
+ return e.proto ? s : i;
698
+ function t(o, u) {
699
+ const c = Object.keys(o), f = Array.from({ length: c.length });
588
700
  for (let a = 0; a < c.length; a++) {
589
- const l = c[a], y2 = i[l];
590
- typeof y2 != "object" || y2 === null ? f[l] = y2 : y2.constructor !== Object && (r = t.get(y2.constructor)) ? f[l] = r(y2, u) : ArrayBuffer.isView(y2) ? f[l] = m(y2) : f[l] = u(y2);
701
+ const l = c[a], y = o[l];
702
+ typeof y != "object" || y === null ? f[l] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[l] = n(y, u) : ArrayBuffer.isView(y) ? f[l] = m(y) : f[l] = u(y);
591
703
  }
592
704
  return f;
593
705
  }
594
- function o(i) {
595
- if (typeof i != "object" || i === null) return i;
596
- if (Array.isArray(i)) return n(i, o);
597
- if (i.constructor !== Object && (r = t.get(i.constructor)))
598
- return r(i, o);
706
+ function i(o) {
707
+ if (typeof o != "object" || o === null) return o;
708
+ if (Array.isArray(o)) return t(o, i);
709
+ if (o.constructor !== Object && (n = r.get(o.constructor)))
710
+ return n(o, i);
599
711
  const u = {};
600
- for (const c in i) {
601
- if (Object.hasOwnProperty.call(i, c) === false) continue;
602
- const f = i[c];
603
- typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (r = t.get(f.constructor)) ? u[c] = r(f, o) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = o(f);
712
+ for (const c in o) {
713
+ if (Object.hasOwnProperty.call(o, c) === false) continue;
714
+ const f = o[c];
715
+ typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[c] = n(f, i) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = i(f);
604
716
  }
605
717
  return u;
606
718
  }
607
- function s(i) {
608
- if (typeof i != "object" || i === null) return i;
609
- if (Array.isArray(i)) return n(i, s);
610
- if (i.constructor !== Object && (r = t.get(i.constructor)))
611
- return r(i, s);
719
+ function s(o) {
720
+ if (typeof o != "object" || o === null) return o;
721
+ if (Array.isArray(o)) return t(o, s);
722
+ if (o.constructor !== Object && (n = r.get(o.constructor)))
723
+ return n(o, s);
612
724
  const u = {};
613
- for (const c in i) {
614
- const f = i[c];
615
- typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (r = t.get(f.constructor)) ? u[c] = r(f, s) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = s(f);
725
+ for (const c in o) {
726
+ const f = o[c];
727
+ typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[c] = n(f, s) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = s(f);
616
728
  }
617
729
  return u;
618
730
  }
619
731
  }
620
- function K(e) {
621
- const t = [], r = [], n = /* @__PURE__ */ new Map();
622
- if (n.set(Date, (c) => new Date(c)), n.set(
732
+ function U(e) {
733
+ const r = [], n = [], t = /* @__PURE__ */ new Map();
734
+ if (t.set(Date, (c) => new Date(c)), t.set(
623
735
  Map,
624
736
  (c, f) => new Map(s(Array.from(c), f))
625
- ), n.set(
737
+ ), t.set(
626
738
  Set,
627
739
  (c, f) => new Set(s(Array.from(c), f))
628
740
  ), e.constructorHandlers)
629
741
  for (const c of e.constructorHandlers)
630
- n.set(c[0], c[1]);
631
- let o;
632
- return e.proto ? u : i;
742
+ t.set(c[0], c[1]);
743
+ let i;
744
+ return e.proto ? u : o;
633
745
  function s(c, f) {
634
746
  const a = Object.keys(c), l = Array.from({ length: a.length });
635
- for (let y2 = 0; y2 < a.length; y2++) {
636
- const h = a[y2], d2 = c[h];
637
- if (typeof d2 != "object" || d2 === null)
638
- l[h] = d2;
639
- else if (d2.constructor !== Object && (o = n.get(d2.constructor)))
640
- l[h] = o(d2, f);
641
- else if (ArrayBuffer.isView(d2))
642
- l[h] = m(d2);
747
+ for (let y = 0; y < a.length; y++) {
748
+ const h = a[y], d = c[h];
749
+ if (typeof d != "object" || d === null)
750
+ l[h] = d;
751
+ else if (d.constructor !== Object && (i = t.get(d.constructor)))
752
+ l[h] = i(d, f);
753
+ else if (ArrayBuffer.isView(d))
754
+ l[h] = m(d);
643
755
  else {
644
- const v2 = t.indexOf(d2);
645
- v2 !== -1 ? l[h] = r[v2] : l[h] = f(d2);
756
+ const v = r.indexOf(d);
757
+ v !== -1 ? l[h] = n[v] : l[h] = f(d);
646
758
  }
647
759
  }
648
760
  return l;
649
761
  }
650
- function i(c) {
762
+ function o(c) {
651
763
  if (typeof c != "object" || c === null) return c;
652
- if (Array.isArray(c)) return s(c, i);
653
- if (c.constructor !== Object && (o = n.get(c.constructor)))
654
- return o(c, i);
764
+ if (Array.isArray(c)) return s(c, o);
765
+ if (c.constructor !== Object && (i = t.get(c.constructor)))
766
+ return i(c, o);
655
767
  const f = {};
656
- t.push(c), r.push(f);
768
+ r.push(c), n.push(f);
657
769
  for (const a in c) {
658
770
  if (Object.hasOwnProperty.call(c, a) === false) continue;
659
771
  const l = c[a];
660
772
  if (typeof l != "object" || l === null)
661
773
  f[a] = l;
662
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
663
- f[a] = o(l, i);
774
+ else if (l.constructor !== Object && (i = t.get(l.constructor)))
775
+ f[a] = i(l, o);
664
776
  else if (ArrayBuffer.isView(l))
665
777
  f[a] = m(l);
666
778
  else {
667
- const y2 = t.indexOf(l);
668
- y2 !== -1 ? f[a] = r[y2] : f[a] = i(l);
779
+ const y = r.indexOf(l);
780
+ y !== -1 ? f[a] = n[y] : f[a] = o(l);
669
781
  }
670
782
  }
671
- return t.pop(), r.pop(), f;
783
+ return r.pop(), n.pop(), f;
672
784
  }
673
785
  function u(c) {
674
786
  if (typeof c != "object" || c === null) return c;
675
787
  if (Array.isArray(c)) return s(c, u);
676
- if (c.constructor !== Object && (o = n.get(c.constructor)))
677
- return o(c, u);
788
+ if (c.constructor !== Object && (i = t.get(c.constructor)))
789
+ return i(c, u);
678
790
  const f = {};
679
- t.push(c), r.push(f);
791
+ r.push(c), n.push(f);
680
792
  for (const a in c) {
681
793
  const l = c[a];
682
794
  if (typeof l != "object" || l === null)
683
795
  f[a] = l;
684
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
685
- f[a] = o(l, u);
796
+ else if (l.constructor !== Object && (i = t.get(l.constructor)))
797
+ f[a] = i(l, u);
686
798
  else if (ArrayBuffer.isView(l))
687
799
  f[a] = m(l);
688
800
  else {
689
- const y2 = t.indexOf(l);
690
- y2 !== -1 ? f[a] = r[y2] : f[a] = u(l);
801
+ const y = r.indexOf(l);
802
+ y !== -1 ? f[a] = n[y] : f[a] = u(l);
691
803
  }
692
804
  }
693
- return t.pop(), r.pop(), f;
805
+ return r.pop(), n.pop(), f;
694
806
  }
695
807
  }
696
- const j = H();
697
- function $(e) {
698
- const t = [];
699
- function r(n, o) {
700
- o.length > 0 && t.push([...o].sort());
701
- for (let s = n; s < e.length; s++) {
702
- const i = e[s];
703
- if (i)
704
- if (i.length === 1 && i[0])
705
- r(s + 1, [...o, i[0]]);
808
+ const A = K();
809
+ function $(e, r = 8) {
810
+ const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
811
+ let t = "";
812
+ for (let i = 0; i < r; i++) {
813
+ const s = Math.floor(Math.random() * n.length);
814
+ t += n[s];
815
+ }
816
+ return e ? `${e}${t}` : t;
817
+ }
818
+ function q(e) {
819
+ const r = [];
820
+ function n(t, i) {
821
+ i.length > 0 && r.push([...i].sort());
822
+ for (let s = t; s < e.length; s++) {
823
+ const o = e[s];
824
+ if (o)
825
+ if (o.length === 1 && o[0])
826
+ n(s + 1, [...i, o[0]]);
706
827
  else
707
- for (const u of i)
708
- r(s + 1, [...o, u]);
828
+ for (const u of o)
829
+ n(s + 1, [...i, u]);
709
830
  }
710
831
  }
711
- return r(0, []), t.sort((n, o) => n.length !== o.length ? n.length - o.length : n.join(",").localeCompare(o.join(",")));
832
+ return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
712
833
  }
713
- function L(e, t, r) {
714
- const n = {
834
+ function z(e, r, n) {
835
+ const t = {
715
836
  ...e,
716
- modifiers: [...r.keys()]
717
- }, o = b(n, t);
718
- for (const s of r.values())
837
+ modifiers: [...n.keys()]
838
+ }, i = b(t, r);
839
+ for (const s of n.values())
719
840
  s.factory({
720
- ...o,
721
- declarations: j(n.declarations),
722
- variables: j(n.variables),
723
- children: j(n.children)
724
- }), g(n.declarations, o);
725
- return n;
726
- }
727
- function N(e, t) {
728
- return function(n, o) {
841
+ ...i,
842
+ declarations: A(t.declarations),
843
+ variables: A(t.variables),
844
+ children: A(t.children)
845
+ }), g(t.declarations, i);
846
+ return t;
847
+ }
848
+ function W(e, r) {
849
+ return function(t, i) {
729
850
  const s = {
730
851
  type: "modifier",
731
- key: Array.isArray(n) ? n : [n],
732
- factory: o
852
+ key: Array.isArray(t) ? t : [t],
853
+ factory: i
733
854
  };
734
- return t.modifiers.push(s), s;
855
+ return r.modifiers.push(s), s;
735
856
  };
736
857
  }
737
- function z() {
858
+ function Y() {
738
859
  return {
739
860
  type: "root",
740
861
  declarations: {},
@@ -746,31 +867,31 @@ function z() {
746
867
  themes: []
747
868
  };
748
869
  }
749
- function I(e, t, r) {
750
- const n = t.map((s) => s.key);
751
- return $(n).map((s) => {
752
- const i = /* @__PURE__ */ new Map();
870
+ function G(e, r, n) {
871
+ const t = r.map((s) => s.key);
872
+ return q(t).map((s) => {
873
+ const o = /* @__PURE__ */ new Map();
753
874
  for (const u of s) {
754
- const c = t.find(
875
+ const c = r.find(
755
876
  (f) => f.key.includes(u)
756
877
  );
757
- c && i.set(u, c);
878
+ c && o.set(u, c);
758
879
  }
759
- return L(e, r, i);
880
+ return z(e, n, o);
760
881
  });
761
882
  }
762
- function W(e, t) {
763
- return function(n, o) {
883
+ function J(e, r) {
884
+ return function(t, i) {
764
885
  const s = {
765
886
  type: "utility",
766
- name: n,
767
- factory: o
887
+ name: t,
888
+ factory: i
768
889
  };
769
- return t.utilities.push(s), (i, u = []) => {
770
- for (const [c, f] of Object.entries(i)) {
890
+ return r.utilities.push(s), (o, u = []) => {
891
+ for (const [c, f] of Object.entries(o)) {
771
892
  const a = {
772
893
  type: "utility",
773
- name: n,
894
+ name: t,
774
895
  value: c,
775
896
  declarations: {},
776
897
  variables: [],
@@ -778,60 +899,61 @@ function W(e, t) {
778
899
  modifiers: []
779
900
  }, l = b(
780
901
  a,
781
- t
902
+ r
782
903
  );
783
- a.declarations = o({
904
+ a.declarations = i({
784
905
  ...l,
785
906
  value: f
786
907
  }) ?? {}, g(a.declarations, l), e.children.push(a), u.length > 0 && e.children.push(
787
- ...I(a, u, t)
908
+ ...G(a, u, r)
788
909
  );
789
910
  }
790
911
  };
791
912
  };
792
913
  }
793
- function Y(e, t) {
794
- return function(n, o) {
795
- const s = t.themes.find((c) => c.name === n), i = s ?? {
914
+ function Q(e, r) {
915
+ return function(t, i) {
916
+ const s = r.themes.find((c) => c.name === t), o = s ?? {
796
917
  type: "theme",
797
- name: n,
918
+ name: t,
798
919
  declarations: {},
799
920
  variables: [],
800
921
  children: []
801
922
  };
802
- s || t.themes.push(i);
803
- const u = b(i, t);
804
- return o && o(u), i;
923
+ s || r.themes.push(o);
924
+ const u = b(o, r);
925
+ return i && i(u), o;
805
926
  };
806
927
  }
807
- function q(e, t) {
808
- return function(n, o, s, i) {
928
+ function X(e, r) {
929
+ return function(t, i, s, o) {
809
930
  const u = {
810
931
  type: "recipe",
811
- name: n,
812
- defaults: o,
932
+ name: t,
933
+ defaults: i,
813
934
  variants: s,
814
- ...i
935
+ ...o
815
936
  };
816
- return t.recipes.push(u), u;
937
+ return r.recipes.push(u), u;
817
938
  };
818
939
  }
819
- function oe(e) {
820
- const t = z(), r = { ...e }, n = W(t, t), o = N(t, t), s = q(t, t), i = Y(t, t), { variable: u, selector: c, atRule: f, keyframes: a, media: l, ref: y2, css: h } = b(t, t);
940
+ function ue(e) {
941
+ const r = $("sf-"), n = Y(), t = { ...e }, i = J(n, n), s = W(n, n), o = X(n, n), u = Q(n, n), { variable: c, selector: f, atRule: a, keyframes: l, media: y, ref: h, css: d } = b(n, n);
821
942
  return {
822
- root: t,
823
- variable: u,
824
- selector: c,
825
- utility: n,
826
- modifier: o,
827
- recipe: s,
828
- theme: i,
829
- atRule: f,
830
- keyframes: a,
831
- media: l,
832
- ref: y2,
833
- css: h,
834
- options: r
943
+ id: r,
944
+ root: n,
945
+ variable: c,
946
+ selector: f,
947
+ utility: i,
948
+ modifier: s,
949
+ recipe: o,
950
+ theme: u,
951
+ atRule: a,
952
+ keyframes: l,
953
+ media: y,
954
+ ref: h,
955
+ css: d,
956
+ options: t
835
957
  };
836
958
  }
837
959
  async function loadConfiguration({
@@ -841,7 +963,7 @@ async function loadConfiguration({
841
963
  const { config } = await loadConfig({
842
964
  cwd,
843
965
  name,
844
- defaults: oe()
966
+ defaults: ue()
845
967
  });
846
968
  return config;
847
969
  }