@styleframe/core 2.3.0 → 2.5.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.
@@ -1,55 +1,73 @@
1
- function k(e, r) {
2
- return function(t, ...i) {
3
- return {
4
- type: "css",
5
- value: t.reduce((o, u, c) => (o.push(u), c < i.length && o.push(i[c]), o), [])
6
- };
7
- };
8
- }
9
- function M(e) {
1
+ function S(e) {
10
2
  return typeof e == "object" && e !== null;
11
3
  }
12
4
  function p(e, r) {
13
- return M(e) && "type" in e && e.type === r;
5
+ return S(e) && "type" in e && e.type === r;
14
6
  }
15
- function B(e) {
7
+ function L(e) {
16
8
  return p(e, "variable");
17
9
  }
18
- function F(e) {
10
+ function A(e) {
19
11
  return p(e, "reference");
20
12
  }
21
- function Z(e) {
13
+ function be(e) {
22
14
  return p(e, "selector");
23
15
  }
24
- function ee(e) {
16
+ function ge(e) {
25
17
  return p(e, "at-rule");
26
18
  }
27
- function te(e) {
19
+ function je(e) {
28
20
  return p(e, "utility");
29
21
  }
30
- function ne(e) {
22
+ function q(e) {
31
23
  return p(e, "modifier");
32
24
  }
33
- function T(e) {
25
+ function E(e) {
34
26
  return p(e, "css");
35
27
  }
36
- function re(e) {
28
+ function ve(e) {
37
29
  return p(e, "theme");
38
30
  }
39
- function j(e) {
31
+ function O(e) {
40
32
  return p(e, "root");
41
33
  }
42
- function _(e) {
34
+ function Ae(e) {
35
+ return p(e, "recipe");
36
+ }
37
+ function G(e) {
43
38
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
44
39
  }
45
- function O(e) {
46
- return _(e) || F(e) || T(e) || Array.isArray(e) && e.every(O);
40
+ function $(e) {
41
+ return G(e) || A(e) || E(e) || Array.isArray(e) && e.every($);
47
42
  }
48
- function C(e) {
49
- return M(e) && "children" in e && "declarations" in e && "variables" in e;
43
+ function I(e) {
44
+ return S(e) && "children" in e && "declarations" in e && "variables" in e;
45
+ }
46
+ function z(e = (r) => r) {
47
+ return (r) => {
48
+ let n = r, t;
49
+ if (typeof n == "string" && n[0] === "@") {
50
+ const i = n.slice(1);
51
+ t = e(i), n = {
52
+ type: "reference",
53
+ name: i
54
+ };
55
+ } else A(n) ? t = e(n.name) : t = `[${r}]`;
56
+ return {
57
+ [t]: n
58
+ };
59
+ };
60
+ }
61
+ function W(e, r) {
62
+ return function(t, ...i) {
63
+ return {
64
+ type: "css",
65
+ value: t.reduce((o, u, s) => (o.push(u), s < i.length && o.push(i[s]), o), [])
66
+ };
67
+ };
50
68
  }
51
- function R(e, r) {
52
- return function(t, i, s) {
69
+ function C(e, r) {
70
+ return function(t, i, c) {
53
71
  const o = {
54
72
  type: "at-rule",
55
73
  identifier: t,
@@ -57,25 +75,25 @@ function R(e, r) {
57
75
  declarations: {},
58
76
  variables: [],
59
77
  children: []
60
- }, u = b(o, r);
61
- return typeof s == "function" ? o.declarations = s(u) ?? {} : s && (o.declarations = s), g(o.declarations, u), e.children.push(o), o;
78
+ }, u = v(o, r);
79
+ return typeof c == "function" ? o.declarations = c(u) ?? {} : c && (o.declarations = c), V(o.declarations, u), e.children.push(o), o;
62
80
  };
63
81
  }
64
- function S(e, r) {
65
- const n = R(e, r);
66
- return function(i, s) {
67
- return n("media", i, s);
82
+ function Y(e, r) {
83
+ const n = C(e, r);
84
+ return function(i, c) {
85
+ return n("media", i, c);
68
86
  };
69
87
  }
70
- function E(e, r) {
71
- const n = R(e, r);
72
- return function(i, s) {
73
- return n("keyframes", i, s);
88
+ function Z(e, r) {
89
+ const n = C(e, r);
90
+ return function(i, c) {
91
+ return n("keyframes", i, c);
74
92
  };
75
93
  }
76
- function P(e, r) {
94
+ function J(e, r) {
77
95
  return function(t, i) {
78
- return B(t) ? {
96
+ return L(t) ? {
79
97
  type: "reference",
80
98
  name: t.name,
81
99
  fallback: i
@@ -86,56 +104,56 @@ function P(e, r) {
86
104
  };
87
105
  };
88
106
  }
89
- function D(e, r) {
107
+ function Q(e, r) {
90
108
  return function(t, i) {
91
- const s = {
109
+ const c = {
92
110
  type: "selector",
93
111
  query: t,
94
112
  declarations: {},
95
113
  variables: [],
96
114
  children: []
97
- }, o = b(s, r);
98
- 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;
115
+ }, o = v(c, r);
116
+ return typeof i == "function" ? c.declarations = i(o) ?? {} : I(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, V(c.declarations, o), e.children.push(c), c;
99
117
  };
100
118
  }
101
- function H(e, r) {
102
- return function(t, i, s = {
119
+ function X(e, r) {
120
+ return function(t, i, c = {
103
121
  default: !1
104
122
  }) {
105
123
  const o = typeof t == "string" ? t : t.name, u = e.variables.find(
106
124
  (f) => f.name === o
107
125
  );
108
- if (s.default && u)
126
+ if (c.default && u)
109
127
  return u;
110
128
  if (u)
111
129
  return u.value = i, u;
112
- const c = {
130
+ const s = {
113
131
  type: "variable",
114
132
  name: o,
115
133
  value: i
116
134
  };
117
- return e.variables.push(c), c;
135
+ return e.variables.push(s), s;
118
136
  };
119
137
  }
120
- function b(e, r) {
121
- const n = H(e), t = D(e, r), i = R(e, r), s = E(r, r), o = S(e, r), u = P(), c = k();
138
+ function v(e, r) {
139
+ const n = X(e), t = Q(e, r), i = C(e, r), c = Z(r, r), o = Y(e, r), u = J(), s = W();
122
140
  return {
123
141
  variable: n,
124
142
  selector: t,
125
- keyframes: s,
143
+ keyframes: c,
126
144
  atRule: i,
127
145
  media: o,
128
146
  ref: u,
129
- css: c
147
+ css: s
130
148
  };
131
149
  }
132
- function g(e, r) {
150
+ function V(e, r) {
133
151
  for (const n in e)
134
152
  if (n.startsWith("@")) {
135
153
  const t = e[n];
136
- if (typeof t == "object" && t !== null && !O(t)) {
137
- const i = n.replace(/^@(\w+).*/, "$1"), s = n.replace(`@${i}`, "").trim();
138
- r.atRule(i, s, t), delete e[n];
154
+ if (typeof t == "object" && t !== null && !$(t)) {
155
+ const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
156
+ r.atRule(i, c, t), delete e[n];
139
157
  }
140
158
  } else if (/^[.&:]/.test(n)) {
141
159
  const t = e[n];
@@ -143,10 +161,10 @@ function g(e, r) {
143
161
  }
144
162
  return e;
145
163
  }
146
- function ie(e) {
164
+ function we(e) {
147
165
  return e.charAt(0).toUpperCase() + e.slice(1);
148
166
  }
149
- function m(e) {
167
+ function j(e) {
150
168
  if (e instanceof Buffer)
151
169
  return Buffer.from(e);
152
170
  const r = e.constructor;
@@ -156,9 +174,9 @@ function m(e) {
156
174
  e.byteLength / e.BYTES_PER_ELEMENT || 1
157
175
  );
158
176
  }
159
- function K(e) {
177
+ function ee(e) {
160
178
  if (e = e || {}, e.circular)
161
- return U(e);
179
+ return te(e);
162
180
  const r = /* @__PURE__ */ new Map();
163
181
  if (r.set(Date, (o) => new Date(o)), r.set(
164
182
  Map,
@@ -170,12 +188,12 @@ function K(e) {
170
188
  for (const o of e.constructorHandlers)
171
189
  r.set(o[0], o[1]);
172
190
  let n;
173
- return e.proto ? s : i;
191
+ return e.proto ? c : i;
174
192
  function t(o, u) {
175
- const c = Object.keys(o), f = Array.from({ length: c.length });
176
- for (let a = 0; a < c.length; a++) {
177
- const l = c[a], y = o[l];
178
- 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);
193
+ const s = Object.keys(o), f = Array.from({ length: s.length });
194
+ for (let l = 0; l < s.length; l++) {
195
+ const a = s[l], y = o[a];
196
+ typeof y != "object" || y === null ? f[a] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[a] = n(y, u) : ArrayBuffer.isView(y) ? f[a] = j(y) : f[a] = u(y);
179
197
  }
180
198
  return f;
181
199
  }
@@ -185,125 +203,125 @@ function K(e) {
185
203
  if (o.constructor !== Object && (n = r.get(o.constructor)))
186
204
  return n(o, i);
187
205
  const u = {};
188
- for (const c in o) {
189
- if (Object.hasOwnProperty.call(o, c) === !1) continue;
190
- const f = o[c];
191
- 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);
206
+ for (const s in o) {
207
+ if (Object.hasOwnProperty.call(o, s) === !1) continue;
208
+ const f = o[s];
209
+ typeof f != "object" || f === null ? u[s] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[s] = n(f, i) : ArrayBuffer.isView(f) ? u[s] = j(f) : u[s] = i(f);
192
210
  }
193
211
  return u;
194
212
  }
195
- function s(o) {
213
+ function c(o) {
196
214
  if (typeof o != "object" || o === null) return o;
197
- if (Array.isArray(o)) return t(o, s);
215
+ if (Array.isArray(o)) return t(o, c);
198
216
  if (o.constructor !== Object && (n = r.get(o.constructor)))
199
- return n(o, s);
217
+ return n(o, c);
200
218
  const u = {};
201
- for (const c in o) {
202
- const f = o[c];
203
- 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);
219
+ for (const s in o) {
220
+ const f = o[s];
221
+ typeof f != "object" || f === null ? u[s] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[s] = n(f, c) : ArrayBuffer.isView(f) ? u[s] = j(f) : u[s] = c(f);
204
222
  }
205
223
  return u;
206
224
  }
207
225
  }
208
- function U(e) {
226
+ function te(e) {
209
227
  const r = [], n = [], t = /* @__PURE__ */ new Map();
210
- if (t.set(Date, (c) => new Date(c)), t.set(
228
+ if (t.set(Date, (s) => new Date(s)), t.set(
211
229
  Map,
212
- (c, f) => new Map(s(Array.from(c), f))
230
+ (s, f) => new Map(c(Array.from(s), f))
213
231
  ), t.set(
214
232
  Set,
215
- (c, f) => new Set(s(Array.from(c), f))
233
+ (s, f) => new Set(c(Array.from(s), f))
216
234
  ), e.constructorHandlers)
217
- for (const c of e.constructorHandlers)
218
- t.set(c[0], c[1]);
235
+ for (const s of e.constructorHandlers)
236
+ t.set(s[0], s[1]);
219
237
  let i;
220
238
  return e.proto ? u : o;
221
- function s(c, f) {
222
- const a = Object.keys(c), l = Array.from({ length: a.length });
223
- for (let y = 0; y < a.length; y++) {
224
- const h = a[y], d = c[h];
239
+ function c(s, f) {
240
+ const l = Object.keys(s), a = Array.from({ length: l.length });
241
+ for (let y = 0; y < l.length; y++) {
242
+ const m = l[y], d = s[m];
225
243
  if (typeof d != "object" || d === null)
226
- l[h] = d;
244
+ a[m] = d;
227
245
  else if (d.constructor !== Object && (i = t.get(d.constructor)))
228
- l[h] = i(d, f);
246
+ a[m] = i(d, f);
229
247
  else if (ArrayBuffer.isView(d))
230
- l[h] = m(d);
248
+ a[m] = j(d);
231
249
  else {
232
- const v = r.indexOf(d);
233
- v !== -1 ? l[h] = n[v] : l[h] = f(d);
250
+ const h = r.indexOf(d);
251
+ h !== -1 ? a[m] = n[h] : a[m] = f(d);
234
252
  }
235
253
  }
236
- return l;
254
+ return a;
237
255
  }
238
- function o(c) {
239
- if (typeof c != "object" || c === null) return c;
240
- if (Array.isArray(c)) return s(c, o);
241
- if (c.constructor !== Object && (i = t.get(c.constructor)))
242
- return i(c, o);
256
+ function o(s) {
257
+ if (typeof s != "object" || s === null) return s;
258
+ if (Array.isArray(s)) return c(s, o);
259
+ if (s.constructor !== Object && (i = t.get(s.constructor)))
260
+ return i(s, o);
243
261
  const f = {};
244
- r.push(c), n.push(f);
245
- for (const a in c) {
246
- if (Object.hasOwnProperty.call(c, a) === !1) continue;
247
- const l = c[a];
248
- if (typeof l != "object" || l === null)
249
- f[a] = l;
250
- else if (l.constructor !== Object && (i = t.get(l.constructor)))
251
- f[a] = i(l, o);
252
- else if (ArrayBuffer.isView(l))
253
- f[a] = m(l);
262
+ r.push(s), n.push(f);
263
+ for (const l in s) {
264
+ if (Object.hasOwnProperty.call(s, l) === !1) continue;
265
+ const a = s[l];
266
+ if (typeof a != "object" || a === null)
267
+ f[l] = a;
268
+ else if (a.constructor !== Object && (i = t.get(a.constructor)))
269
+ f[l] = i(a, o);
270
+ else if (ArrayBuffer.isView(a))
271
+ f[l] = j(a);
254
272
  else {
255
- const y = r.indexOf(l);
256
- y !== -1 ? f[a] = n[y] : f[a] = o(l);
273
+ const y = r.indexOf(a);
274
+ y !== -1 ? f[l] = n[y] : f[l] = o(a);
257
275
  }
258
276
  }
259
277
  return r.pop(), n.pop(), f;
260
278
  }
261
- function u(c) {
262
- if (typeof c != "object" || c === null) return c;
263
- if (Array.isArray(c)) return s(c, u);
264
- if (c.constructor !== Object && (i = t.get(c.constructor)))
265
- return i(c, u);
279
+ function u(s) {
280
+ if (typeof s != "object" || s === null) return s;
281
+ if (Array.isArray(s)) return c(s, u);
282
+ if (s.constructor !== Object && (i = t.get(s.constructor)))
283
+ return i(s, u);
266
284
  const f = {};
267
- r.push(c), n.push(f);
268
- for (const a in c) {
269
- const l = c[a];
270
- if (typeof l != "object" || l === null)
271
- f[a] = l;
272
- else if (l.constructor !== Object && (i = t.get(l.constructor)))
273
- f[a] = i(l, u);
274
- else if (ArrayBuffer.isView(l))
275
- f[a] = m(l);
285
+ r.push(s), n.push(f);
286
+ for (const l in s) {
287
+ const a = s[l];
288
+ if (typeof a != "object" || a === null)
289
+ f[l] = a;
290
+ else if (a.constructor !== Object && (i = t.get(a.constructor)))
291
+ f[l] = i(a, u);
292
+ else if (ArrayBuffer.isView(a))
293
+ f[l] = j(a);
276
294
  else {
277
- const y = r.indexOf(l);
278
- y !== -1 ? f[a] = n[y] : f[a] = u(l);
295
+ const y = r.indexOf(a);
296
+ y !== -1 ? f[l] = n[y] : f[l] = u(a);
279
297
  }
280
298
  }
281
299
  return r.pop(), n.pop(), f;
282
300
  }
283
301
  }
284
- const A = K();
285
- function $(e, r = 8) {
302
+ const R = ee();
303
+ function ne(e, r = 8) {
286
304
  const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
287
305
  let t = "";
288
306
  for (let i = 0; i < r; i++) {
289
- const s = Math.floor(Math.random() * n.length);
290
- t += n[s];
307
+ const c = Math.floor(Math.random() * n.length);
308
+ t += n[c];
291
309
  }
292
310
  return e ? `${e}${t}` : t;
293
311
  }
294
- function oe(e, r) {
312
+ function Ve(e, r) {
295
313
  const n = e.variables.find((t) => t.name === r);
296
314
  if (!n)
297
315
  throw new Error(`Variable "${r}" not found`);
298
316
  return n;
299
317
  }
300
- function ce(e, r) {
318
+ function ke(e, r) {
301
319
  const n = e.utilities.find((t) => t.name === r);
302
320
  if (!n)
303
321
  throw new Error(`Utility "${r}" not found`);
304
322
  return n;
305
323
  }
306
- function se(e, r) {
324
+ function re(e, r) {
307
325
  const n = e.modifiers.find(
308
326
  (t) => t.key.includes(r)
309
327
  );
@@ -311,44 +329,60 @@ function se(e, r) {
311
329
  throw new Error(`Modifier "${r}" not found`);
312
330
  return n;
313
331
  }
314
- const V = "__licenseRequired";
315
- function I(e) {
316
- w(e) || Object.defineProperty(e, V, {
332
+ function M(e, r) {
333
+ if (e === r) return !0;
334
+ if (typeof e != typeof r) return !1;
335
+ if (e === null || r === null) return e === r;
336
+ if (typeof e != "object" || typeof r != "object") return !1;
337
+ if (Array.isArray(e) && Array.isArray(r))
338
+ return e.length !== r.length ? !1 : e.every((n, t) => M(n, r[t]));
339
+ if ("type" in e && "type" in r) {
340
+ if (e.type !== r.type) return !1;
341
+ if (A(e) && A(r))
342
+ return e.name === r.name && M(e.fallback, r.fallback);
343
+ if (E(e) && E(r))
344
+ return M(e.value, r.value);
345
+ }
346
+ return !1;
347
+ }
348
+ const D = "__licenseRequired";
349
+ function ie(e) {
350
+ B(e) || Object.defineProperty(e, D, {
317
351
  value: !0,
318
352
  writable: !1,
319
353
  configurable: !1,
320
354
  enumerable: !0
321
355
  });
322
356
  }
323
- function w(e) {
324
- return Object.prototype.hasOwnProperty.call(e, V);
357
+ function B(e) {
358
+ return Object.prototype.hasOwnProperty.call(e, D);
325
359
  }
326
- function L(e, r) {
360
+ function oe(e, r) {
327
361
  const n = [...e];
328
362
  for (const t of r) {
329
363
  const i = n.find(
330
- (s) => s.name === t.name
364
+ (c) => c.name === t.name
331
365
  );
332
366
  i ? i.value = t.value : n.push(t);
333
367
  }
334
368
  return n;
335
369
  }
336
- function N(e, r) {
370
+ function se(e, r) {
337
371
  const n = [...e];
338
372
  for (const t of r) {
339
373
  const i = n.find(
340
- (s) => s.name === t.name
374
+ (c) => c.name === t.name
341
375
  );
342
376
  i ? Object.assign(
343
377
  i,
344
- x(i, t)
378
+ U(i, t)
345
379
  ) : n.push(t);
346
380
  }
347
381
  return n;
348
382
  }
349
- function x(e, r) {
383
+ function U(e, r) {
350
384
  return Object.keys(e).reduce(
351
- (n, t) => (t === "variables" ? n.variables = L(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && j(n) && j(e) && j(r) ? n.themes = N(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
385
+ (n, t) => (t === "variables" ? n.variables = oe(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && O(n) && O(e) && O(r) ? n.themes = se(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
352
386
  r[t]
353
387
  )), n),
354
388
  {
@@ -357,56 +391,56 @@ function x(e, r) {
357
391
  }
358
392
  );
359
393
  }
360
- function fe(e, ...r) {
394
+ function Oe(e, ...r) {
361
395
  return r.reduce((n, t) => {
362
396
  const i = {
363
397
  ...n,
364
- root: x(n.root, t.root)
398
+ root: U(n.root, t.root)
365
399
  };
366
- return (w(n) || w(t)) && I(i), i;
400
+ return (B(n) || B(t)) && ie(i), i;
367
401
  }, e);
368
402
  }
369
- function q(e) {
403
+ function ce(e) {
370
404
  const r = [];
371
405
  function n(t, i) {
372
406
  i.length > 0 && r.push([...i].sort());
373
- for (let s = t; s < e.length; s++) {
374
- const o = e[s];
407
+ for (let c = t; c < e.length; c++) {
408
+ const o = e[c];
375
409
  if (o)
376
410
  if (o.length === 1 && o[0])
377
- n(s + 1, [...i, o[0]]);
411
+ n(c + 1, [...i, o[0]]);
378
412
  else
379
413
  for (const u of o)
380
- n(s + 1, [...i, u]);
414
+ n(c + 1, [...i, u]);
381
415
  }
382
416
  }
383
417
  return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
384
418
  }
385
- function z(e, r, n) {
419
+ function fe(e, r, n) {
386
420
  const t = {
387
421
  ...e,
388
422
  modifiers: [...n.keys()]
389
- }, i = b(t, r);
390
- for (const s of n.values())
391
- s.factory({
423
+ }, i = v(t, r);
424
+ for (const c of n.values())
425
+ c.factory({
392
426
  ...i,
393
- declarations: A(t.declarations),
394
- variables: A(t.variables),
395
- children: A(t.children)
396
- }), g(t.declarations, i);
427
+ declarations: R(t.declarations),
428
+ variables: R(t.variables),
429
+ children: R(t.children)
430
+ }), V(t.declarations, i);
397
431
  return t;
398
432
  }
399
- function W(e, r) {
433
+ function ue(e, r) {
400
434
  return function(t, i) {
401
- const s = {
435
+ const c = {
402
436
  type: "modifier",
403
437
  key: Array.isArray(t) ? t : [t],
404
438
  factory: i
405
439
  };
406
- return r.modifiers.push(s), s;
440
+ return r.modifiers.push(c), c;
407
441
  };
408
442
  }
409
- function Y() {
443
+ function ae() {
410
444
  return {
411
445
  type: "root",
412
446
  declarations: {},
@@ -418,137 +452,273 @@ function Y() {
418
452
  themes: []
419
453
  };
420
454
  }
421
- function G(e, r, n) {
422
- const t = r.map((s) => s.key);
423
- return q(t).map((s) => {
424
- const o = /* @__PURE__ */ new Map();
425
- for (const u of s) {
426
- const c = r.find(
427
- (f) => f.key.includes(u)
428
- );
429
- c && o.set(u, c);
430
- }
431
- return z(e, n, o);
432
- });
433
- }
434
- function J(e, r) {
435
- return function(t, i) {
436
- const s = {
455
+ function le(e, r) {
456
+ return function(t, i, c = {}) {
457
+ const o = {
437
458
  type: "utility",
438
459
  name: t,
439
- factory: i
440
- };
441
- return r.utilities.push(s), (o, u = []) => {
442
- for (const [c, f] of Object.entries(o)) {
443
- const a = {
444
- type: "utility",
445
- name: t,
446
- value: c,
447
- declarations: {},
448
- variables: [],
449
- children: [],
450
- modifiers: []
451
- }, l = b(
452
- a,
453
- r
454
- );
455
- a.declarations = i({
456
- ...l,
457
- value: f
458
- }) ?? {}, g(a.declarations, l), e.children.push(a), u.length > 0 && e.children.push(
459
- ...G(a, u, r)
460
- );
460
+ factory: i,
461
+ values: [],
462
+ autogenerate: c.autogenerate ?? z(),
463
+ create: (u, s = []) => {
464
+ let f = u;
465
+ if (Array.isArray(u)) {
466
+ f = {};
467
+ for (const l of u) {
468
+ const a = o.autogenerate(l);
469
+ f = {
470
+ ...f,
471
+ ...a
472
+ };
473
+ }
474
+ }
475
+ for (const [l, a] of Object.entries(f)) {
476
+ const y = o.values.find(
477
+ (h) => h.key === l && h.modifiers.length === 0
478
+ ), m = {
479
+ type: "utility",
480
+ name: t,
481
+ value: l,
482
+ declarations: {},
483
+ variables: [],
484
+ children: [],
485
+ modifiers: []
486
+ }, d = v(
487
+ m,
488
+ r
489
+ );
490
+ if (m.declarations = i({
491
+ ...d,
492
+ value: a
493
+ }) ?? {}, V(m.declarations, d), y || (o.values.push({
494
+ key: l,
495
+ value: a,
496
+ modifiers: []
497
+ }), e.children.push(m)), s && s.length > 0) {
498
+ const h = s.map((b) => b.key), H = ce(h).filter((b) => !o.values.find(
499
+ (g) => g.key === l && g.modifiers.length === b.length && g.modifiers.every((w) => b.includes(w))
500
+ )).reduce((b, g) => {
501
+ const w = /* @__PURE__ */ new Map();
502
+ for (const K of g) {
503
+ const k = s.find(
504
+ (N) => N.key.includes(K)
505
+ );
506
+ k && q(k) && w.set(K, k);
507
+ }
508
+ return o.values.push({
509
+ key: l,
510
+ value: a,
511
+ modifiers: g
512
+ }), b.push(fe(m, r, w)), b;
513
+ }, []);
514
+ e.children.push(...H);
515
+ }
516
+ }
461
517
  }
462
518
  };
519
+ return r.utilities.push(o), o.create;
463
520
  };
464
521
  }
465
- function Q(e, r) {
522
+ function ye(e, r) {
466
523
  return function(t, i) {
467
- const s = r.themes.find((c) => c.name === t), o = s ?? {
524
+ const c = r.themes.find((s) => s.name === t), o = c ?? {
468
525
  type: "theme",
469
526
  name: t,
470
527
  declarations: {},
471
528
  variables: [],
472
529
  children: []
473
530
  };
474
- s || r.themes.push(o);
475
- const u = b(o, r);
531
+ c || r.themes.push(o);
532
+ const u = v(o, r);
476
533
  return i && i(u), o;
477
534
  };
478
535
  }
479
- function X(e, r) {
480
- return function(t, i, s, o) {
481
- const u = {
536
+ function de(e, r) {
537
+ return function(t) {
538
+ const i = {
482
539
  type: "recipe",
483
- name: t,
484
- defaults: i,
485
- variants: s,
486
- ...o
540
+ ...t
487
541
  };
488
- return r.recipes.push(u), u;
542
+ return i._runtime = me(i, r), pe(i, r), r.recipes.push(i), i;
489
543
  };
490
544
  }
491
- function ue(e) {
492
- 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);
545
+ function _(e, r) {
546
+ const n = e.autogenerate(r);
547
+ return Object.keys(n)[0] ?? "default";
548
+ }
549
+ function F(e, r) {
550
+ const n = {};
551
+ for (const [t, i] of Object.entries(e))
552
+ if (P(i)) {
553
+ const c = {};
554
+ for (const [o, u] of Object.entries(i)) {
555
+ const s = T(r, o);
556
+ s && (c[o] = _(
557
+ s,
558
+ u
559
+ ));
560
+ }
561
+ n[t] = c;
562
+ } else if (typeof i == "boolean")
563
+ n[t] = i;
564
+ else {
565
+ const c = T(r, t);
566
+ c && (n[t] = _(c, i));
567
+ }
568
+ return n;
569
+ }
570
+ function me(e, r) {
571
+ const n = {};
572
+ if (e.base && (n.base = F(e.base, r)), e.variants) {
573
+ const t = {};
574
+ for (const [i, c] of Object.entries(e.variants)) {
575
+ const o = {};
576
+ for (const [u, s] of Object.entries(
577
+ c
578
+ ))
579
+ s == null ? o[u] = null : o[u] = F(
580
+ s,
581
+ r
582
+ );
583
+ t[i] = o;
584
+ }
585
+ n.variants = t;
586
+ }
587
+ return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
588
+ match: { ...t.match },
589
+ css: F(t.css, r)
590
+ }))), n;
591
+ }
592
+ function P(e) {
593
+ return !A(e) && typeof e == "object" && e !== null;
594
+ }
595
+ function x(e, r) {
596
+ const n = (t, i, c) => {
597
+ let o = r.get(t);
598
+ o || (o = [], r.set(t, o)), o.push({ value: i, modifiers: c });
599
+ };
600
+ for (const [t, i] of Object.entries(e))
601
+ if (P(i)) {
602
+ const c = t.split(":");
603
+ for (const [o, u] of Object.entries(i))
604
+ n(o, u, c);
605
+ } else
606
+ n(t, i, []);
607
+ }
608
+ function T(e, r) {
609
+ const n = e.utilities.find((i) => i.name === r);
610
+ if (n)
611
+ return n;
612
+ const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
613
+ return e.utilities.find((i) => i.name === t);
614
+ }
615
+ function pe(e, r) {
616
+ const n = /* @__PURE__ */ new Map();
617
+ if (e.base && x(e.base, n), e.variants)
618
+ for (const i of Object.values(e.variants))
619
+ for (const c of Object.values(i))
620
+ x(
621
+ c,
622
+ n
623
+ );
624
+ if (e.compoundVariants)
625
+ for (const i of e.compoundVariants)
626
+ i.css && x(i.css, n);
627
+ const t = /* @__PURE__ */ new Map();
628
+ for (const [i, c] of n) {
629
+ const o = T(r, i);
630
+ if (!o) {
631
+ console.warn(
632
+ `[styleframe] Utility "${i}" not found in registry. Skipping.`
633
+ );
634
+ continue;
635
+ }
636
+ for (const u of c) {
637
+ const s = [];
638
+ for (const f of u.modifiers) {
639
+ if (!t.has(f))
640
+ try {
641
+ t.set(f, re(r, f));
642
+ } catch {
643
+ console.warn(
644
+ `[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
645
+ ), t.set(f, null);
646
+ }
647
+ const l = t.get(f);
648
+ l && s.push(l);
649
+ }
650
+ o.create(
651
+ [u.value],
652
+ s.length > 0 ? s : void 0
653
+ );
654
+ }
655
+ }
656
+ }
657
+ function Re(e) {
658
+ const r = ne("sf-"), n = ae(), t = { ...e }, i = le(n, n), c = ue(n, n), o = de(n, n), u = ye(n, n), { variable: s, selector: f, atRule: l, keyframes: a, media: y, ref: m, css: d } = v(n, n);
493
659
  return {
494
660
  id: r,
495
661
  root: n,
496
- variable: c,
662
+ variable: s,
497
663
  selector: f,
498
664
  utility: i,
499
- modifier: s,
665
+ modifier: c,
500
666
  recipe: o,
501
667
  theme: u,
502
- atRule: a,
503
- keyframes: l,
668
+ atRule: l,
669
+ keyframes: a,
504
670
  media: y,
505
- ref: h,
671
+ ref: m,
506
672
  css: d,
507
673
  options: t
508
674
  };
509
675
  }
510
676
  export {
511
- z as applyModifiers,
512
- ie as capitalizeFirst,
513
- q as combineKeys,
514
- R as createAtRuleFunction,
515
- k as createCssFunction,
516
- b as createDeclarationsCallbackContext,
517
- E as createKeyframesFunction,
518
- S as createMediaFunction,
519
- G as createModifiedUtilityInstances,
520
- W as createModifierFunction,
521
- X as createRecipeFunction,
522
- P as createRefFunction,
523
- Y as createRoot,
524
- D as createSelectorFunction,
525
- Q as createThemeFunction,
526
- J as createUtilityFunction,
527
- H as createVariableFunction,
528
- A as deepClone,
529
- $ as generateRandomId,
530
- se as getModifier,
531
- ce as getUtility,
532
- oe as getVariable,
533
- ee as isAtRule,
534
- T as isCSS,
535
- C as isContainer,
536
- ne as isModifier,
537
- M as isObject,
538
- _ as isPrimitiveTokenValue,
539
- F as isRef,
540
- j as isRoot,
541
- Z as isSelector,
542
- re as isTheme,
677
+ fe as applyModifiers,
678
+ we as capitalizeFirst,
679
+ ce as combineKeys,
680
+ C as createAtRuleFunction,
681
+ W as createCssFunction,
682
+ v as createDeclarationsCallbackContext,
683
+ Z as createKeyframesFunction,
684
+ Y as createMediaFunction,
685
+ ue as createModifierFunction,
686
+ de as createRecipeFunction,
687
+ J as createRefFunction,
688
+ ae as createRoot,
689
+ Q as createSelectorFunction,
690
+ ye as createThemeFunction,
691
+ le as createUtilityFunction,
692
+ X as createVariableFunction,
693
+ R as deepClone,
694
+ ne as generateRandomId,
695
+ me as generateRecipeRuntime,
696
+ re as getModifier,
697
+ ke as getUtility,
698
+ Ve as getVariable,
699
+ ge as isAtRule,
700
+ E as isCSS,
701
+ I as isContainer,
702
+ q as isModifier,
703
+ S as isObject,
704
+ G as isPrimitiveTokenValue,
705
+ Ae as isRecipe,
706
+ A as isRef,
707
+ O as isRoot,
708
+ be as isSelector,
709
+ ve as isTheme,
543
710
  p as isToken,
544
- O as isTokenValue,
545
- te as isUtility,
546
- B as isVariable,
547
- fe as merge,
548
- x as mergeContainers,
549
- N as mergeThemesArray,
550
- L as mergeVariablesArray,
551
- g as parseDeclarationsBlock,
552
- K as rfdc,
553
- ue as styleframe
711
+ M as isTokenEqual,
712
+ $ as isTokenValue,
713
+ je as isUtility,
714
+ L as isVariable,
715
+ Oe as merge,
716
+ U as mergeContainers,
717
+ se as mergeThemesArray,
718
+ oe as mergeVariablesArray,
719
+ V as parseDeclarationsBlock,
720
+ pe as processRecipeUtilities,
721
+ ee as rfdc,
722
+ Re as styleframe,
723
+ z as transformUtilityKey
554
724
  };