@styleframe/core 3.0.1 → 3.2.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,812 +1,965 @@
1
- function C(e) {
1
+ function $(e) {
2
2
  return typeof e == "object" && e !== null;
3
3
  }
4
- function h(e, r) {
5
- return C(e) && "type" in e && e.type === r;
4
+ function g(e, t) {
5
+ return $(e) && "type" in e && e.type === t;
6
6
  }
7
- function G(e) {
8
- return h(e, "variable");
7
+ function H(e) {
8
+ return g(e, "variable");
9
9
  }
10
- function j(e) {
11
- return h(e, "reference");
10
+ function A(e) {
11
+ return g(e, "reference");
12
12
  }
13
- function je(e) {
14
- return h(e, "selector");
13
+ function _e(e) {
14
+ return g(e, "selector");
15
15
  }
16
- function ve(e) {
17
- return h(e, "at-rule");
16
+ function te(e) {
17
+ return g(e, "at-rule");
18
18
  }
19
- function we(e) {
20
- return h(e, "utility");
19
+ function Oe(e) {
20
+ return g(e, "utility");
21
21
  }
22
- function I(e) {
23
- return h(e, "modifier");
22
+ function ne(e) {
23
+ return g(e, "modifier");
24
24
  }
25
- function E(e) {
26
- return h(e, "css");
25
+ function N(e) {
26
+ return g(e, "css");
27
27
  }
28
- function ke(e) {
29
- return h(e, "theme");
28
+ function Se(e) {
29
+ return g(e, "theme");
30
30
  }
31
- function V(e) {
32
- return h(e, "root");
31
+ function M(e) {
32
+ return g(e, "root");
33
33
  }
34
- function Ve(e) {
35
- return h(e, "recipe");
34
+ function Te(e) {
35
+ return g(e, "recipe");
36
36
  }
37
- function z(e) {
37
+ function re(e) {
38
38
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
39
39
  }
40
- function D(e) {
41
- return z(e) || j(e) || E(e) || Array.isArray(e) && e.every(D);
40
+ function B(e) {
41
+ return re(e) || A(e) || N(e) || Array.isArray(e) && e.every(B);
42
42
  }
43
- function Y(e) {
44
- return C(e) && "children" in e && "declarations" in e && "variables" in e;
43
+ function Ne(e) {
44
+ return $(e) && "id" in e && "children" in e && "declarations" in e && "variables" in e;
45
45
  }
46
- function Re(e) {
47
- return C(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && V(e.root);
46
+ function L(e) {
47
+ return $(e) && "children" in e && "declarations" in e && "variables" in e;
48
48
  }
49
- function Z(e) {
50
- let r = 5381;
51
- for (let n = 0; n < e.length; n++)
52
- r = (r << 5) + r + e.charCodeAt(n) & 4294967295;
53
- return (r >>> 0).toString(16).padStart(7, "0").slice(0, 7);
49
+ function ie(e) {
50
+ return typeof e == "string" && e.startsWith("@");
54
51
  }
55
- function P(e) {
56
- const r = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: n = (c) => c, namespace: t } = r, i = Array.isArray(t) ? t : t ? [t] : [];
57
- return (c) => {
58
- let s = c, a;
59
- if (typeof s == "string" && s[0] === "@") {
60
- const o = s.slice(1), f = i.find(
61
- (y) => o === y || o.startsWith(`${y}.`)
52
+ function Be(e) {
53
+ return $(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && M(e.root);
54
+ }
55
+ function se(e) {
56
+ let t = 5381;
57
+ for (let r = 0; r < e.length; r++)
58
+ t = (t << 5) + t + e.charCodeAt(r) & 4294967295;
59
+ return (t >>> 0).toString(16).padStart(7, "0").slice(0, 7);
60
+ }
61
+ function G(e) {
62
+ const t = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: r = (o) => o, namespace: n } = t, s = Array.isArray(n) ? n : n ? [n] : [];
63
+ return (o) => {
64
+ let i = o, f;
65
+ if (typeof i == "string" && i[0] === "@") {
66
+ const c = i.slice(1), a = s.find(
67
+ (d) => c === d || c.startsWith(`${d}.`)
62
68
  );
63
69
  let l, u;
64
- f ? (l = o, u = o.startsWith(`${f}.`) ? o.slice(f.length + 1) : o) : i.length > 0 ? (l = `${i[0]}.${o}`, u = o) : (l = o, u = o), a = n(u), s = {
70
+ a ? (l = c, u = c.startsWith(`${a}.`) ? c.slice(a.length + 1) : c) : s.length > 0 ? (l = `${s[0]}.${c}`, u = c) : (l = c, u = c), f = r(u), i = {
65
71
  type: "reference",
66
72
  name: l
67
73
  };
68
- } else if (j(s)) {
69
- let o = s.name;
70
- for (const f of i)
71
- if (o.startsWith(`${f}.`)) {
72
- o = o.slice(f.length + 1);
74
+ } else if (A(i)) {
75
+ let c = i.name;
76
+ for (const a of s)
77
+ if (c.startsWith(`${a}.`)) {
78
+ c = c.slice(a.length + 1);
73
79
  break;
74
80
  }
75
- a = n(o);
81
+ f = r(c);
76
82
  } else {
77
- const o = String(c).trim();
78
- /\s/.test(o) ? a = Z(o) : a = `[${o}]`;
83
+ const c = String(o).trim();
84
+ /\s/.test(c) ? f = se(c) : f = `[${c}]`;
79
85
  }
80
86
  return {
81
- [a]: s
87
+ [f]: i
82
88
  };
83
89
  };
84
90
  }
85
- function J(e, r) {
86
- return function(t, ...i) {
87
- return {
88
- type: "css",
89
- value: t.reduce((s, a, o) => (s.push(a), o < i.length && s.push(i[o]), s), [])
90
- };
91
- };
92
- }
93
- function K(e, r) {
94
- return function(t, i, c) {
95
- const s = {
96
- type: "at-rule",
97
- identifier: t,
98
- rule: i,
99
- declarations: {},
100
- variables: [],
101
- children: []
102
- }, a = v(s, r);
103
- return typeof c == "function" ? s.declarations = c(a) ?? {} : c && (s.declarations = c), R(s.declarations, a), e.children.push(s), s;
104
- };
91
+ const Pe = ({
92
+ name: e,
93
+ value: t,
94
+ modifiers: r
95
+ }) => `_${[
96
+ ...r,
97
+ e,
98
+ ...t === "default" ? [] : [t]
99
+ ].filter(Boolean).join(":")}`, _ = /@([\w.-]+)/g;
100
+ function z(e) {
101
+ const t = [];
102
+ let r = 0, n;
103
+ for (_.lastIndex = 0; (n = _.exec(e)) !== null; )
104
+ t.push(e.slice(r, n.index)), t.push({ type: "reference", name: n[1] }), r = _.lastIndex;
105
+ return t.push(e.slice(r)), t;
106
+ }
107
+ function oe(e, t, r) {
108
+ let n = t;
109
+ for (; n; ) {
110
+ if (n.variables.some((s) => s.name === e))
111
+ return !0;
112
+ if (n.parentId)
113
+ n = r._registry.get(n.parentId);
114
+ else
115
+ break;
116
+ }
117
+ return !1;
105
118
  }
106
- function Q(e, r) {
107
- const n = K(e, r);
108
- return function(i, c) {
109
- return n("media", i, c);
110
- };
119
+ function ce(e, t, r) {
120
+ if (!oe(e, t, r))
121
+ throw new Error(
122
+ `[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`
123
+ );
111
124
  }
112
- function X(e, r) {
113
- const n = K(e, r);
114
- return function(i, c) {
115
- return n("keyframes", i, c);
125
+ function C(e, t) {
126
+ return function(n) {
127
+ if (typeof n != "string" || !n.includes("@"))
128
+ return n;
129
+ if (ie(n) && /^@[\w.-]+$/.test(n)) {
130
+ const i = n.slice(1);
131
+ return ce(i, e, t), { type: "reference", name: i };
132
+ }
133
+ const s = z(n);
134
+ return s.some((i) => A(i)) ? { type: "css", value: s } : n;
116
135
  };
117
136
  }
118
- function ee(e, r) {
119
- return function(t, i) {
120
- return G(t) ? {
121
- type: "reference",
122
- name: t.name,
123
- fallback: i
124
- } : {
137
+ function q(e, t) {
138
+ return function(n, s) {
139
+ const o = C(e, t), i = s != null ? o(s) : s;
140
+ if (H(n))
141
+ return {
142
+ type: "reference",
143
+ name: n.name,
144
+ fallback: i
145
+ };
146
+ if (n == null)
147
+ throw new Error(
148
+ `[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`
149
+ );
150
+ return {
125
151
  type: "reference",
126
- name: t,
152
+ name: n,
127
153
  fallback: i
128
154
  };
129
155
  };
130
156
  }
131
- function te(e, r) {
132
- return function(t, i) {
133
- const c = {
134
- type: "selector",
135
- query: t,
136
- declarations: {},
137
- variables: [],
138
- children: []
139
- }, s = v(c, r);
140
- return typeof i == "function" ? c.declarations = i(s) ?? {} : Y(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, R(c.declarations, s), e.children.push(c), c;
141
- };
142
- }
143
- function ne(e, r) {
144
- return function(t, i, c = {
145
- default: !1
146
- }) {
147
- const s = typeof t == "string" ? t : t.name, a = e.variables.find(
148
- (f) => f.name === s
149
- );
150
- if (c.default && a)
151
- return a;
152
- if (a)
153
- return a.value = i, a;
154
- const o = {
155
- type: "variable",
156
- name: s,
157
- value: i
157
+ function fe(e, t) {
158
+ const r = q(e, t);
159
+ return function(s, ...o) {
160
+ return {
161
+ type: "css",
162
+ value: s.reduce((f, c, a) => {
163
+ if (f.push(...z(c)), a < o.length) {
164
+ const l = o[a];
165
+ H(l) ? f.push(r(l)) : te(l) ? f.push(l.rule) : f.push(l);
166
+ }
167
+ return f;
168
+ }, [])
158
169
  };
159
- return e.variables.push(o), o;
160
- };
161
- }
162
- function v(e, r) {
163
- const n = ne(e), t = te(e, r), i = K(e, r), c = X(r, r), s = Q(e, r), a = ee(), o = J();
164
- return {
165
- variable: n,
166
- selector: t,
167
- keyframes: c,
168
- atRule: i,
169
- media: s,
170
- ref: a,
171
- css: o
172
170
  };
173
171
  }
174
- function R(e, r) {
175
- for (const n in e)
176
- if (n.startsWith("@")) {
177
- const t = e[n];
178
- if (typeof t == "object" && t !== null && !D(t)) {
179
- const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
180
- r.atRule(i, c, t), delete e[n];
181
- }
182
- } else if (/^[.&:]/.test(n) || /^\d+%$/.test(n) || n === "from" || n === "to") {
183
- const t = e[n];
184
- typeof t == "object" && (r.selector(n, t), delete e[n]);
185
- }
186
- for (const n in e) {
187
- const t = e[n];
188
- typeof t == "string" && t[0] === "@" && (e[n] = r.ref(t.slice(1)));
189
- }
190
- return e;
191
- }
192
- function $e(e) {
172
+ function Ue(e) {
193
173
  return e.charAt(0).toUpperCase() + e.slice(1);
194
174
  }
195
- function A(e) {
175
+ function De(e) {
176
+ return `.${e.replace(/[[\].#()%,:/]/g, "\\$&")}`;
177
+ }
178
+ function j(e) {
196
179
  if (e instanceof Buffer)
197
180
  return Buffer.from(e);
198
- const r = e.constructor;
199
- return new r(
181
+ const t = e.constructor;
182
+ return new t(
200
183
  e.buffer.slice(0),
201
184
  e.byteOffset,
202
185
  e.byteLength / e.BYTES_PER_ELEMENT || 1
203
186
  );
204
187
  }
205
- function re(e) {
188
+ function ae(e) {
206
189
  if (e = e || {}, e.circular)
207
- return ie(e);
208
- const r = /* @__PURE__ */ new Map();
209
- if (r.set(Date, (s) => new Date(s)), r.set(
190
+ return ue(e);
191
+ const t = /* @__PURE__ */ new Map();
192
+ if (t.set(Date, (i) => new Date(i)), t.set(
210
193
  Map,
211
- (s, a) => new Map(t(Array.from(s), a))
212
- ), r.set(
194
+ (i, f) => new Map(n(Array.from(i), f))
195
+ ), t.set(
213
196
  Set,
214
- (s, a) => new Set(t(Array.from(s), a))
197
+ (i, f) => new Set(n(Array.from(i), f))
215
198
  ), e.constructorHandlers)
216
- for (const s of e.constructorHandlers)
217
- r.set(s[0], s[1]);
218
- let n;
219
- return e.proto ? c : i;
220
- function t(s, a) {
221
- const o = Object.keys(s), f = Array.from({ length: o.length });
222
- for (let l = 0; l < o.length; l++) {
223
- const u = o[l], y = s[u];
224
- typeof y != "object" || y === null ? f[u] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[u] = n(y, a) : ArrayBuffer.isView(y) ? f[u] = A(y) : f[u] = a(y);
199
+ for (const i of e.constructorHandlers)
200
+ t.set(i[0], i[1]);
201
+ let r;
202
+ return e.proto ? o : s;
203
+ function n(i, f) {
204
+ const c = Object.keys(i), a = Array.from({ length: c.length });
205
+ for (let l = 0; l < c.length; l++) {
206
+ const u = c[l], d = i[u];
207
+ typeof d != "object" || d === null ? a[u] = d : d.constructor !== Object && (r = t.get(d.constructor)) ? a[u] = r(d, f) : ArrayBuffer.isView(d) ? a[u] = j(d) : a[u] = f(d);
225
208
  }
226
- return f;
209
+ return a;
227
210
  }
228
- function i(s) {
229
- if (typeof s != "object" || s === null) return s;
230
- if (Array.isArray(s)) return t(s, i);
231
- if (s.constructor !== Object && (n = r.get(s.constructor)))
232
- return n(s, i);
233
- const a = {};
234
- for (const o in s) {
235
- if (Object.hasOwnProperty.call(s, o) === !1) continue;
236
- const f = s[o];
237
- typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, i) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = i(f);
211
+ function s(i) {
212
+ if (typeof i != "object" || i === null) return i;
213
+ if (Array.isArray(i)) return n(i, s);
214
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
215
+ return r(i, s);
216
+ const f = {};
217
+ for (const c in i) {
218
+ if (Object.hasOwnProperty.call(i, c) === !1) continue;
219
+ const a = i[c];
220
+ typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, s) : ArrayBuffer.isView(a) ? f[c] = j(a) : f[c] = s(a);
238
221
  }
239
- return a;
222
+ return f;
240
223
  }
241
- function c(s) {
242
- if (typeof s != "object" || s === null) return s;
243
- if (Array.isArray(s)) return t(s, c);
244
- if (s.constructor !== Object && (n = r.get(s.constructor)))
245
- return n(s, c);
246
- const a = {};
247
- for (const o in s) {
248
- const f = s[o];
249
- typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, c) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = c(f);
224
+ function o(i) {
225
+ if (typeof i != "object" || i === null) return i;
226
+ if (Array.isArray(i)) return n(i, o);
227
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
228
+ return r(i, o);
229
+ const f = {};
230
+ for (const c in i) {
231
+ const a = i[c];
232
+ typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, o) : ArrayBuffer.isView(a) ? f[c] = j(a) : f[c] = o(a);
250
233
  }
251
- return a;
234
+ return f;
252
235
  }
253
236
  }
254
- function ie(e) {
255
- const r = [], n = [], t = /* @__PURE__ */ new Map();
256
- if (t.set(Date, (o) => new Date(o)), t.set(
237
+ function ue(e) {
238
+ const t = [], r = [], n = /* @__PURE__ */ new Map();
239
+ if (n.set(Date, (c) => new Date(c)), n.set(
257
240
  Map,
258
- (o, f) => new Map(c(Array.from(o), f))
259
- ), t.set(
241
+ (c, a) => new Map(o(Array.from(c), a))
242
+ ), n.set(
260
243
  Set,
261
- (o, f) => new Set(c(Array.from(o), f))
244
+ (c, a) => new Set(o(Array.from(c), a))
262
245
  ), e.constructorHandlers)
263
- for (const o of e.constructorHandlers)
264
- t.set(o[0], o[1]);
265
- let i;
266
- return e.proto ? a : s;
267
- function c(o, f) {
268
- const l = Object.keys(o), u = Array.from({ length: l.length });
269
- for (let y = 0; y < l.length; y++) {
270
- const p = l[y], d = o[p];
271
- if (typeof d != "object" || d === null)
272
- u[p] = d;
273
- else if (d.constructor !== Object && (i = t.get(d.constructor)))
274
- u[p] = i(d, f);
275
- else if (ArrayBuffer.isView(d))
276
- u[p] = A(d);
246
+ for (const c of e.constructorHandlers)
247
+ n.set(c[0], c[1]);
248
+ let s;
249
+ return e.proto ? f : i;
250
+ function o(c, a) {
251
+ const l = Object.keys(c), u = Array.from({ length: l.length });
252
+ for (let d = 0; d < l.length; d++) {
253
+ const y = l[d], p = c[y];
254
+ if (typeof p != "object" || p === null)
255
+ u[y] = p;
256
+ else if (p.constructor !== Object && (s = n.get(p.constructor)))
257
+ u[y] = s(p, a);
258
+ else if (ArrayBuffer.isView(p))
259
+ u[y] = j(p);
277
260
  else {
278
- const w = r.indexOf(d);
279
- w !== -1 ? u[p] = n[w] : u[p] = f(d);
261
+ const h = t.indexOf(p);
262
+ h !== -1 ? u[y] = r[h] : u[y] = a(p);
280
263
  }
281
264
  }
282
265
  return u;
283
266
  }
284
- function s(o) {
285
- if (typeof o != "object" || o === null) return o;
286
- if (Array.isArray(o)) return c(o, s);
287
- if (o.constructor !== Object && (i = t.get(o.constructor)))
288
- return i(o, s);
289
- const f = {};
290
- r.push(o), n.push(f);
291
- for (const l in o) {
292
- if (Object.hasOwnProperty.call(o, l) === !1) continue;
293
- const u = o[l];
267
+ function i(c) {
268
+ if (typeof c != "object" || c === null) return c;
269
+ if (Array.isArray(c)) return o(c, i);
270
+ if (c.constructor !== Object && (s = n.get(c.constructor)))
271
+ return s(c, i);
272
+ const a = {};
273
+ t.push(c), r.push(a);
274
+ for (const l in c) {
275
+ if (Object.hasOwnProperty.call(c, l) === !1) continue;
276
+ const u = c[l];
294
277
  if (typeof u != "object" || u === null)
295
- f[l] = u;
296
- else if (u.constructor !== Object && (i = t.get(u.constructor)))
297
- f[l] = i(u, s);
278
+ a[l] = u;
279
+ else if (u.constructor !== Object && (s = n.get(u.constructor)))
280
+ a[l] = s(u, i);
298
281
  else if (ArrayBuffer.isView(u))
299
- f[l] = A(u);
282
+ a[l] = j(u);
300
283
  else {
301
- const y = r.indexOf(u);
302
- y !== -1 ? f[l] = n[y] : f[l] = s(u);
284
+ const d = t.indexOf(u);
285
+ d !== -1 ? a[l] = r[d] : a[l] = i(u);
303
286
  }
304
287
  }
305
- return r.pop(), n.pop(), f;
288
+ return t.pop(), r.pop(), a;
306
289
  }
307
- function a(o) {
308
- if (typeof o != "object" || o === null) return o;
309
- if (Array.isArray(o)) return c(o, a);
310
- if (o.constructor !== Object && (i = t.get(o.constructor)))
311
- return i(o, a);
312
- const f = {};
313
- r.push(o), n.push(f);
314
- for (const l in o) {
315
- const u = o[l];
290
+ function f(c) {
291
+ if (typeof c != "object" || c === null) return c;
292
+ if (Array.isArray(c)) return o(c, f);
293
+ if (c.constructor !== Object && (s = n.get(c.constructor)))
294
+ return s(c, f);
295
+ const a = {};
296
+ t.push(c), r.push(a);
297
+ for (const l in c) {
298
+ const u = c[l];
316
299
  if (typeof u != "object" || u === null)
317
- f[l] = u;
318
- else if (u.constructor !== Object && (i = t.get(u.constructor)))
319
- f[l] = i(u, a);
300
+ a[l] = u;
301
+ else if (u.constructor !== Object && (s = n.get(u.constructor)))
302
+ a[l] = s(u, f);
320
303
  else if (ArrayBuffer.isView(u))
321
- f[l] = A(u);
304
+ a[l] = j(u);
322
305
  else {
323
- const y = r.indexOf(u);
324
- y !== -1 ? f[l] = n[y] : f[l] = a(u);
306
+ const d = t.indexOf(u);
307
+ d !== -1 ? a[l] = r[d] : a[l] = f(u);
325
308
  }
326
309
  }
327
- return r.pop(), n.pop(), f;
310
+ return t.pop(), r.pop(), a;
328
311
  }
329
312
  }
330
- const F = re();
331
- function se(e, r = 8) {
332
- const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
333
- let t = "";
334
- for (let i = 0; i < r; i++) {
335
- const c = Math.floor(Math.random() * n.length);
336
- t += n[c];
313
+ const k = ae();
314
+ function b(e, t = 8) {
315
+ const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
316
+ let n = "";
317
+ for (let s = 0; s < t; s++) {
318
+ const o = Math.floor(Math.random() * r.length);
319
+ n += r[o];
337
320
  }
338
- return e ? `${e}${t}` : t;
339
- }
340
- function Oe(e, r) {
341
- const n = e.variables.find((t) => t.name === r);
342
- if (!n)
343
- throw new Error(`Variable "${r}" not found`);
344
- return n;
345
- }
346
- function Me(e, r) {
347
- const n = e.utilities.find((t) => t.name === r);
348
- if (!n)
349
- throw new Error(`Utility "${r}" not found`);
350
- return n;
351
- }
352
- function oe(e, r) {
353
- const n = e.modifiers.find(
354
- (t) => t.key.includes(r)
321
+ return e ? `${e}${n}` : n;
322
+ }
323
+ function Ce(e, t) {
324
+ const r = e.variables.find((n) => n.name === t);
325
+ if (!r)
326
+ throw new Error(`Variable "${t}" not found`);
327
+ return r;
328
+ }
329
+ function Ie(e, t) {
330
+ const r = e.utilities.find((n) => n.name === t);
331
+ if (!r)
332
+ throw new Error(`Utility "${t}" not found`);
333
+ return r;
334
+ }
335
+ function le(e, t) {
336
+ const r = e.modifiers.find(
337
+ (n) => n.key.includes(t)
355
338
  );
356
- if (!n)
357
- throw new Error(`Modifier "${r}" not found`);
358
- return n;
359
- }
360
- function S(e, r) {
361
- if (e === r) return !0;
362
- if (typeof e != typeof r) return !1;
363
- if (e === null || r === null) return e === r;
364
- if (typeof e != "object" || typeof r != "object") return !1;
365
- if (Array.isArray(e) && Array.isArray(r))
366
- return e.length !== r.length ? !1 : e.every((n, t) => S(n, r[t]));
367
- if ("type" in e && "type" in r) {
368
- if (e.type !== r.type) return !1;
369
- if (j(e) && j(r))
370
- return e.name === r.name && S(e.fallback, r.fallback);
371
- if (E(e) && E(r))
372
- return S(e.value, r.value);
339
+ if (!r)
340
+ throw new Error(`Modifier "${t}" not found`);
341
+ return r;
342
+ }
343
+ function O(e, t) {
344
+ if (e === t) return !0;
345
+ if (typeof e != typeof t) return !1;
346
+ if (e === null || t === null) return e === t;
347
+ if (typeof e != "object" || typeof t != "object") return !1;
348
+ if (Array.isArray(e) && Array.isArray(t))
349
+ return e.length !== t.length ? !1 : e.every((r, n) => O(r, t[n]));
350
+ if ("type" in e && "type" in t) {
351
+ if (e.type !== t.type) return !1;
352
+ if (A(e) && A(t))
353
+ return e.name === t.name && O(e.fallback, t.fallback);
354
+ if (N(e) && N(t))
355
+ return O(e.value, t.value);
373
356
  }
374
357
  return !1;
375
358
  }
376
- const H = "__licenseRequired";
377
- function ce(e) {
378
- T(e) || Object.defineProperty(e, H, {
359
+ const X = "__licenseRequired";
360
+ function de(e) {
361
+ P(e) || Object.defineProperty(e, X, {
379
362
  value: !0,
380
363
  writable: !1,
381
364
  configurable: !1,
382
365
  enumerable: !0
383
366
  });
384
367
  }
385
- function T(e) {
386
- return Object.prototype.hasOwnProperty.call(e, H);
368
+ function P(e) {
369
+ return Object.prototype.hasOwnProperty.call(e, X);
387
370
  }
388
- function fe(e, r) {
389
- const n = [...e];
390
- for (const t of r) {
391
- const i = n.find(
392
- (c) => c.name === t.name
371
+ function ye(e, t) {
372
+ const r = [...e];
373
+ for (const n of t) {
374
+ const s = r.find(
375
+ (o) => o.name === n.name
393
376
  );
394
- i ? i.value = t.value : n.push(t);
377
+ s ? s.value = n.value : r.push(n);
395
378
  }
396
- return n;
379
+ return r;
397
380
  }
398
- function ae(e, r) {
399
- const n = [...e];
400
- for (const t of r) {
401
- const i = n.find(
402
- (c) => c.name === t.name
381
+ function pe(e, t) {
382
+ const r = [...e];
383
+ for (const n of t) {
384
+ const s = r.find(
385
+ (o) => o.name === n.name
403
386
  );
404
- i ? Object.assign(
405
- i,
406
- W(i, t)
407
- ) : n.push(t);
387
+ s ? Object.assign(
388
+ s,
389
+ Y(s, n)
390
+ ) : r.push(n);
408
391
  }
409
- return n;
392
+ return r;
410
393
  }
411
- function W(e, r) {
394
+ function Y(e, t) {
412
395
  return Object.keys(e).reduce(
413
- (n, t) => (t === "variables" ? n.variables = fe(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && V(n) && V(e) && V(r) ? n.themes = ae(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
414
- r[t]
415
- )), n),
396
+ (r, n) => (n === "variables" ? r.variables = ye(e.variables, t.variables) : n === "declarations" ? r.declarations = { ...e.declarations, ...t.declarations } : n === "themes" && M(r) && M(e) && M(t) ? r.themes = pe(e.themes, t.themes) : Array.isArray(e[n]) && (r[n] = e[n].concat(
397
+ t[n]
398
+ )), r),
416
399
  {
417
400
  ...e,
418
- ...r
401
+ ...t
419
402
  }
420
403
  );
421
404
  }
422
- function Fe(e, ...r) {
423
- return r.reduce((n, t) => {
424
- const i = {
425
- ...n,
426
- root: W(n.root, t.root)
405
+ function U(e, t) {
406
+ for (const r of e)
407
+ "id" in r && typeof r.id == "string" && (t._registry.set(r.id, r), "children" in r && U(r.children, t));
408
+ }
409
+ function me(e) {
410
+ e._registry = /* @__PURE__ */ new Map(), e._registry.set(e.id, e), U(e.children, e);
411
+ for (const t of e.themes)
412
+ e._registry.set(t.id, t), U(t.children, e);
413
+ }
414
+ function Ke(e, ...t) {
415
+ return t.reduce((r, n) => {
416
+ const s = {
417
+ ...r,
418
+ root: Y(r.root, n.root)
427
419
  };
428
- return (T(n) || T(t)) && ce(i), i;
420
+ return me(s.root), (P(r) || P(n)) && de(s), s;
429
421
  }, e);
430
422
  }
431
- function ue(e) {
432
- const r = [];
433
- function n(t, i) {
434
- i.length > 0 && r.push([...i].sort());
435
- for (let c = t; c < e.length; c++) {
436
- const s = e[c];
437
- if (s)
438
- if (s.length === 1 && s[0])
439
- n(c + 1, [...i, s[0]]);
440
- else
441
- for (const a of s)
442
- n(c + 1, [...i, a]);
423
+ function I(e, t) {
424
+ return function(n, s, o) {
425
+ const i = {
426
+ type: "at-rule",
427
+ id: b("ar-"),
428
+ parentId: e.id,
429
+ identifier: n,
430
+ rule: s,
431
+ declarations: {},
432
+ variables: [],
433
+ children: []
434
+ };
435
+ t._registry.set(i.id, i);
436
+ const f = w(i, t);
437
+ return typeof o == "function" ? i.declarations = o(f) ?? {} : L(o) ? (i.variables = o.variables, i.declarations = o.declarations, i.children = o.children) : o && (i.declarations = o), x(
438
+ i.declarations,
439
+ f,
440
+ i,
441
+ t
442
+ ), e.children.push(i), i;
443
+ };
444
+ }
445
+ function he(e, t) {
446
+ const r = I(e, t);
447
+ return function(s, o) {
448
+ return r("media", s, o);
449
+ };
450
+ }
451
+ function ge(e, t) {
452
+ const r = I(e, t);
453
+ return function(s, o) {
454
+ return r("keyframes", s, o);
455
+ };
456
+ }
457
+ function be(e, t) {
458
+ return function(n, s) {
459
+ const o = {
460
+ type: "selector",
461
+ id: b("sel-"),
462
+ parentId: e.id,
463
+ query: n,
464
+ declarations: {},
465
+ variables: [],
466
+ children: []
467
+ };
468
+ t._registry.set(o.id, o);
469
+ const i = w(o, t);
470
+ return typeof s == "function" ? o.declarations = s(i) ?? {} : L(s) ? (o.variables = s.variables, o.declarations = s.declarations, o.children = s.children) : o.declarations = s, x(
471
+ o.declarations,
472
+ i,
473
+ o,
474
+ t
475
+ ), e.children.push(o), o;
476
+ };
477
+ }
478
+ function Ae(e, t) {
479
+ return function(n, s, o = {
480
+ default: !1
481
+ }) {
482
+ const i = typeof n == "string" ? n : n.name, c = C(e, t)(s), a = e.variables.find(
483
+ (u) => u.name === i
484
+ );
485
+ if (o.default && a)
486
+ return a;
487
+ if (a)
488
+ return a.value = c, a;
489
+ const l = {
490
+ type: "variable",
491
+ id: b("var-"),
492
+ parentId: e.id,
493
+ name: i,
494
+ value: c
495
+ };
496
+ return e.variables.push(l), l;
497
+ };
498
+ }
499
+ function w(e, t) {
500
+ const r = Ae(e, t), n = be(e, t), s = I(e, t), o = ge(t, t), i = he(e, t), f = q(t, t), c = fe(t, t);
501
+ return {
502
+ variable: r,
503
+ selector: n,
504
+ keyframes: o,
505
+ atRule: s,
506
+ media: i,
507
+ ref: f,
508
+ css: c
509
+ };
510
+ }
511
+ function x(e, t, r, n) {
512
+ for (const o in e)
513
+ if (o.startsWith("@")) {
514
+ const i = e[o];
515
+ if (typeof i == "object" && i !== null && !B(i)) {
516
+ const f = o.replace(/^@(\w+).*/, "$1"), c = o.replace(`@${f}`, "").trim();
517
+ t.atRule(f, c, i), delete e[o];
518
+ }
519
+ } else if (/^[.&:]/.test(o) || /^\d+%$/.test(o) || o === "from" || o === "to") {
520
+ const i = e[o];
521
+ typeof i == "object" && (t.selector(o, i), delete e[o]);
522
+ }
523
+ const s = C(r, n);
524
+ for (const o in e) {
525
+ const i = e[o];
526
+ if (B(i)) {
527
+ const f = s(i);
528
+ f !== i && (e[o] = f);
443
529
  }
444
530
  }
445
- return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
531
+ return e;
446
532
  }
447
- function le(e, r, n) {
448
- const t = {
533
+ function we(e, t, r) {
534
+ const n = {
449
535
  ...e,
450
- modifiers: [...n.keys()]
451
- }, i = v(t, r);
452
- for (const c of n.values())
453
- c.factory({
454
- ...i,
455
- declarations: F(t.declarations),
456
- variables: F(t.variables),
457
- children: F(t.children)
458
- }), R(t.declarations, i);
459
- return t;
460
- }
461
- function ye(e, r) {
462
- return function(t, i) {
463
- const c = {
536
+ id: b("ut-"),
537
+ parentId: e.parentId,
538
+ declarations: { ...e.declarations },
539
+ variables: [...e.variables],
540
+ children: [...e.children],
541
+ modifiers: [...r.keys()]
542
+ };
543
+ if (t._registry.set(n.id, n), r.size > 0) {
544
+ const s = [...r.values()];
545
+ let o = k(e.declarations);
546
+ n.declarations = {}, n.variables = [], n.children = [];
547
+ for (let f = s.length - 1; f >= 0; f--) {
548
+ const c = w(n, t), a = s[f]?.factory({
549
+ ...c,
550
+ declarations: k(o),
551
+ variables: k(e.variables),
552
+ children: k(e.children)
553
+ });
554
+ a && (o = a);
555
+ }
556
+ n.declarations = o;
557
+ const i = w(n, t);
558
+ x(
559
+ n.declarations,
560
+ i,
561
+ n,
562
+ t
563
+ );
564
+ }
565
+ return n;
566
+ }
567
+ function ve(e, t) {
568
+ return function(n, s) {
569
+ const o = {
464
570
  type: "modifier",
465
- key: Array.isArray(t) ? t : [t],
466
- factory: i
571
+ key: Array.isArray(n) ? n : [n],
572
+ factory: s
467
573
  };
468
- return r.modifiers.push(c), c;
574
+ return t.modifiers.push(o), o;
469
575
  };
470
576
  }
471
- function de() {
472
- return {
577
+ function je() {
578
+ const e = {
473
579
  type: "root",
580
+ id: b("rt-"),
474
581
  declarations: {},
475
582
  utilities: [],
476
583
  modifiers: [],
477
584
  recipes: [],
478
585
  variables: [],
479
586
  children: [],
480
- themes: []
587
+ themes: [],
588
+ _registry: /* @__PURE__ */ new Map()
481
589
  };
482
- }
483
- function me(e, r) {
484
- const n = P({ namespace: e });
485
- return (t) => {
486
- if (typeof t == "string" && t[0] === "@") {
487
- const i = t.slice(1), c = e.find(
488
- (s) => i === s || i.startsWith(`${s}.`)
590
+ return e._registry.set(e.id, e), e;
591
+ }
592
+ function Ve(e, t) {
593
+ const r = G({ namespace: e });
594
+ return (n) => {
595
+ if (typeof n == "string" && n[0] === "@") {
596
+ const s = n.slice(1), o = e.find(
597
+ (i) => s === i || s.startsWith(`${i}.`)
489
598
  );
490
- if (c) {
491
- const s = i.slice(c.length + 1) || i;
492
- if (r.variables.some((a) => a.name === i))
599
+ if (o) {
600
+ const i = s.slice(o.length + 1) || s;
601
+ if (t.variables.some((f) => f.name === s))
493
602
  return {
494
- [s]: {
603
+ [i]: {
495
604
  type: "reference",
496
- name: i
605
+ name: s
497
606
  }
498
607
  };
499
608
  } else
500
- for (const s of e) {
501
- const a = `${s}.${i}`;
502
- if (r.variables.some((o) => o.name === a))
609
+ for (const i of e) {
610
+ const f = `${i}.${s}`;
611
+ if (t.variables.some((c) => c.name === f))
503
612
  return {
504
- [i]: {
613
+ [s]: {
505
614
  type: "reference",
506
- name: a
615
+ name: f
507
616
  }
508
617
  };
509
618
  }
510
- return n(t);
619
+ return r(n);
511
620
  }
512
- return n(t);
621
+ return r(n);
513
622
  };
514
623
  }
515
- function pe(e, r) {
516
- return function(t, i, c = {}) {
517
- const s = {
624
+ function Re(e) {
625
+ let t = [/* @__PURE__ */ new Map()];
626
+ for (const r of e) {
627
+ if (!ne(r)) continue;
628
+ const n = [];
629
+ for (const s of r.key)
630
+ for (const o of t) {
631
+ const i = new Map(o);
632
+ i.set(s, r), n.push(i);
633
+ }
634
+ t = n;
635
+ }
636
+ return t.filter((r) => r.size > 0);
637
+ }
638
+ function ke(e, t) {
639
+ return function(n, s, o = {}) {
640
+ const i = t.utilities.find((c) => c.name === n);
641
+ if (i)
642
+ return i.create;
643
+ const f = {
518
644
  type: "utility",
519
- name: t,
520
- factory: i,
645
+ name: n,
646
+ factory: s,
521
647
  values: [],
522
- autogenerate: c.autogenerate ?? (Array.isArray(c.namespace) ? me(c.namespace, r) : P(
523
- c.namespace ? { namespace: c.namespace } : void 0
648
+ autogenerate: o.autogenerate ?? (Array.isArray(o.namespace) ? Ve(o.namespace, t) : G(
649
+ o.namespace ? { namespace: o.namespace } : void 0
524
650
  )),
525
- namespace: c.namespace,
526
- create: (a, o = []) => {
527
- let f = a;
528
- if (Array.isArray(a)) {
529
- f = {};
530
- for (const l of a) {
531
- const u = s.autogenerate(l);
532
- f = {
533
- ...f,
534
- ...u
651
+ namespace: o.namespace,
652
+ create: (c, a = []) => {
653
+ let l = c;
654
+ if (Array.isArray(c)) {
655
+ l = {};
656
+ for (const u of c) {
657
+ const d = f.autogenerate(u);
658
+ l = {
659
+ ...l,
660
+ ...d
535
661
  };
536
662
  }
537
663
  }
538
- for (const [l, u] of Object.entries(f)) {
539
- let y = u;
540
- if (s.namespace && j(u))
541
- if (r.variables.some((g) => g.name === u.name))
542
- y = u;
664
+ for (const [u, d] of Object.entries(l)) {
665
+ let y = d;
666
+ if (typeof d == "string" && d[0] === "@") {
667
+ const m = d.slice(1);
668
+ !Array.isArray(l) && m in l && (y = l[m]);
669
+ }
670
+ if (f.namespace && A(d))
671
+ if (t.variables.some((m) => m.name === d.name))
672
+ y = d;
543
673
  else {
544
- const g = Array.isArray(s.namespace) ? s.namespace : [s.namespace];
545
- let $ = !1;
546
- for (const O of g) {
547
- const m = `${O}.${l}`;
548
- if (m !== u.name && r.variables.some((b) => b.name === m)) {
674
+ const m = Array.isArray(f.namespace) ? f.namespace : [f.namespace];
675
+ let R = !1;
676
+ for (const E of m) {
677
+ const v = `${E}.${u}`;
678
+ if (v !== d.name && t.variables.some((V) => V.name === v)) {
549
679
  y = {
550
680
  type: "reference",
551
- name: m
552
- }, $ = !0;
681
+ name: v
682
+ }, R = !0;
553
683
  break;
554
684
  }
555
685
  }
556
- $ || (y = l);
686
+ R || (y = u);
557
687
  }
558
- const p = s.values.find(
559
- (g) => g.key === l && g.modifiers.length === 0
560
- ), d = {
688
+ const p = f.values.find(
689
+ (m) => m.key === u && m.modifiers.length === 0
690
+ ), h = {
561
691
  type: "utility",
562
- name: t,
563
- value: l,
692
+ id: b("ut-"),
693
+ parentId: e.id,
694
+ name: n,
695
+ value: u,
564
696
  declarations: {},
565
697
  variables: [],
566
698
  children: [],
567
699
  modifiers: []
568
- }, w = v(
569
- d,
570
- r
700
+ };
701
+ t._registry.set(h.id, h);
702
+ const K = w(
703
+ h,
704
+ t
571
705
  );
572
- if (d.declarations = i({
573
- ...w,
706
+ if (h.declarations = s({
707
+ ...K,
574
708
  value: y
575
- }) ?? {}, R(d.declarations, w), p || (s.values.push({
576
- key: l,
709
+ }) ?? {}, x(
710
+ h.declarations,
711
+ K,
712
+ h,
713
+ t
714
+ ), p || (f.values.push({
715
+ key: u,
577
716
  value: y,
578
717
  modifiers: []
579
- }), e.children.push(d)), o && o.length > 0) {
580
- const g = o.map((m) => m.key), O = ue(g).filter((m) => !s.values.find(
581
- (b) => b.key === l && b.modifiers.length === m.length && b.modifiers.every((k) => m.includes(k))
582
- )).reduce((m, b) => {
583
- const k = /* @__PURE__ */ new Map();
584
- for (const U of b) {
585
- const M = o.find(
586
- (q) => q.key.includes(U)
587
- );
588
- M && I(M) && k.set(U, M);
718
+ }), e.children.push(h)), a && a.length > 0)
719
+ for (const m of a) {
720
+ const R = Array.isArray(m) ? m : [m], E = Re(R);
721
+ for (const v of E) {
722
+ const V = [...v.keys()];
723
+ f.values.find(
724
+ (F) => F.key === u && F.modifiers.length === V.length && F.modifiers.every(
725
+ (Q, ee) => Q === V[ee]
726
+ )
727
+ ) || (f.values.push({
728
+ key: u,
729
+ value: y,
730
+ modifiers: V
731
+ }), e.children.push(
732
+ we(h, t, v)
733
+ ));
589
734
  }
590
- return s.values.push({
591
- key: l,
592
- value: y,
593
- modifiers: b
594
- }), m.push(le(d, r, k)), m;
595
- }, []);
596
- e.children.push(...O);
597
- }
735
+ }
598
736
  }
599
737
  }
600
738
  };
601
- return r.utilities.push(s), s.create;
739
+ return t.utilities.push(f), f.create;
602
740
  };
603
741
  }
604
- function he(e, r) {
605
- return function(t, i) {
606
- const c = r.themes.find((o) => o.name === t), s = c ?? {
742
+ function Me(e, t) {
743
+ return function(n, s) {
744
+ const o = t.themes.find((c) => c.name === n), i = o ?? {
607
745
  type: "theme",
608
- name: t,
746
+ id: b("th-"),
747
+ parentId: t.id,
748
+ name: n,
609
749
  declarations: {},
610
750
  variables: [],
611
751
  children: []
612
752
  };
613
- c || r.themes.push(s);
614
- const a = v(s, r);
615
- return i && i(a), s;
753
+ o || (t._registry.set(i.id, i), t.themes.push(i));
754
+ const f = w(i, t);
755
+ return s && s(f), i;
616
756
  };
617
757
  }
618
- function ge(e, r) {
619
- return function(t) {
620
- const i = {
758
+ function $e(e, t) {
759
+ return function(n) {
760
+ const s = {
621
761
  type: "recipe",
622
- ...t
762
+ ...n
623
763
  };
624
- return i._runtime = be(i, r), Ae(i, r), r.recipes.push(i), i;
764
+ return s._runtime = xe(s, t), Ee(s, t), t.recipes.push(s), s;
625
765
  };
626
766
  }
627
- function _(e, r) {
628
- const n = e.autogenerate(r);
629
- return Object.keys(n)[0] ?? "default";
630
- }
631
- function N(e, r) {
632
- const n = {};
633
- for (const [t, i] of Object.entries(e))
634
- if (L(i)) {
635
- const c = {};
636
- for (const [s, a] of Object.entries(i)) {
637
- const o = B(r, s);
638
- o ? c[s] = _(
639
- o,
640
- a
641
- ) : console.warn(
642
- `[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`
767
+ function W(e, t) {
768
+ const r = e.autogenerate(t);
769
+ return Object.keys(r)[0] ?? "default";
770
+ }
771
+ function S(e, t) {
772
+ const r = {};
773
+ for (const [n, s] of Object.entries(e))
774
+ if (Z(s)) {
775
+ const o = {};
776
+ for (const [i, f] of Object.entries(s)) {
777
+ const c = D(t, i);
778
+ if (!c)
779
+ throw new Error(
780
+ `[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`
781
+ );
782
+ o[i] = W(
783
+ c,
784
+ f
643
785
  );
644
786
  }
645
- n[t] = c;
646
- } else if (typeof i == "boolean")
647
- n[t] = i;
787
+ r[J(n)] = o;
788
+ } else if (typeof s == "boolean")
789
+ r[n] = s;
648
790
  else {
649
- const c = B(r, t);
650
- c ? n[t] = _(c, i) : console.warn(
651
- `[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`
652
- );
791
+ const o = D(t, n);
792
+ if (!o)
793
+ throw new Error(
794
+ `[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`
795
+ );
796
+ r[n] = W(o, s);
653
797
  }
654
- return n;
655
- }
656
- function be(e, r) {
657
- const n = {};
658
- if (e.base && (n.base = N(e.base, r)), e.variants) {
659
- const t = {};
660
- for (const [i, c] of Object.entries(e.variants)) {
661
- const s = {};
662
- for (const [a, o] of Object.entries(
663
- c
798
+ return r;
799
+ }
800
+ function xe(e, t) {
801
+ const r = {};
802
+ if (e.base && (r.base = S(e.base, t)), e.variants) {
803
+ const n = {};
804
+ for (const [s, o] of Object.entries(e.variants)) {
805
+ const i = {};
806
+ for (const [f, c] of Object.entries(
807
+ o
664
808
  ))
665
- o == null ? s[a] = null : s[a] = N(
666
- o,
667
- r
809
+ c == null ? i[f] = null : i[f] = S(
810
+ c,
811
+ t
668
812
  );
669
- t[i] = s;
813
+ n[s] = i;
670
814
  }
671
- n.variants = t;
815
+ r.variants = n;
672
816
  }
673
- return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
674
- match: { ...t.match },
675
- css: N(t.css, r)
676
- }))), n;
817
+ return e.defaultVariants && (r.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (r.compoundVariants = e.compoundVariants.map((n) => ({
818
+ match: { ...n.match },
819
+ css: S(n.css, t)
820
+ }))), r;
677
821
  }
678
- function L(e) {
679
- return !j(e) && typeof e == "object" && e !== null;
822
+ function Z(e) {
823
+ return !A(e) && typeof e == "object" && e !== null;
824
+ }
825
+ function J(e) {
826
+ return e.startsWith("&::") ? e.slice(3) : e.startsWith("&:") ? e.slice(2) : e;
680
827
  }
681
- function x(e, r) {
682
- const n = (t, i, c) => {
683
- let s = r.get(t);
684
- s || (s = [], r.set(t, s)), s.push({ value: i, modifiers: c });
828
+ function T(e, t) {
829
+ const r = (n, s, o) => {
830
+ let i = t.get(n);
831
+ i || (i = [], t.set(n, i)), i.push({ value: s, modifiers: o });
685
832
  };
686
- for (const [t, i] of Object.entries(e))
687
- if (L(i)) {
688
- const c = t.split(":");
689
- for (const [s, a] of Object.entries(i))
690
- n(s, a, c);
833
+ for (const [n, s] of Object.entries(e))
834
+ if (Z(s)) {
835
+ const o = J(n).split(":");
836
+ for (const [i, f] of Object.entries(s))
837
+ r(i, f, o);
691
838
  } else
692
- n(t, i, []);
839
+ r(n, s, []);
693
840
  }
694
- function B(e, r) {
695
- const n = e.utilities.find((i) => i.name === r);
696
- if (n)
697
- return n;
698
- const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
699
- return e.utilities.find((i) => i.name === t);
841
+ function D(e, t) {
842
+ const r = e.utilities.find((s) => s.name === t);
843
+ if (r)
844
+ return r;
845
+ const n = t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
846
+ return e.utilities.find((s) => s.name === n);
700
847
  }
701
- function Ae(e, r) {
702
- const n = /* @__PURE__ */ new Map();
703
- if (e.base && x(e.base, n), e.variants)
704
- for (const i of Object.values(e.variants))
705
- for (const c of Object.values(i))
706
- x(
707
- c,
708
- n
848
+ function Ee(e, t) {
849
+ const r = /* @__PURE__ */ new Map();
850
+ if (e.base && T(e.base, r), e.variants)
851
+ for (const s of Object.values(e.variants))
852
+ for (const o of Object.values(s))
853
+ T(
854
+ o,
855
+ r
709
856
  );
710
857
  if (e.compoundVariants)
711
- for (const i of e.compoundVariants)
712
- i.css && x(i.css, n);
713
- const t = /* @__PURE__ */ new Map();
714
- for (const [i, c] of n) {
715
- const s = B(r, i);
716
- if (!s) {
717
- console.warn(
718
- `[styleframe] Utility "${i}" not found in registry. Skipping.`
858
+ for (const s of e.compoundVariants)
859
+ s.css && T(s.css, r);
860
+ const n = /* @__PURE__ */ new Map();
861
+ for (const [s, o] of r) {
862
+ const i = D(t, s);
863
+ if (!i)
864
+ throw new Error(
865
+ `[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`
719
866
  );
720
- continue;
721
- }
722
- for (const a of c) {
723
- const o = [];
724
- for (const f of a.modifiers) {
725
- if (!t.has(f))
867
+ for (const f of o) {
868
+ const c = [];
869
+ for (const a of f.modifiers) {
870
+ if (!n.has(a))
726
871
  try {
727
- t.set(f, oe(r, f));
872
+ n.set(a, le(t, a));
728
873
  } catch {
729
- console.warn(
730
- `[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
731
- ), t.set(f, null);
874
+ throw new Error(
875
+ `[styleframe] Modifier "${a}" not found in registry. Make sure the modifier is registered before using it in a recipe.`
876
+ );
732
877
  }
733
- const l = t.get(f);
734
- l && o.push(l);
878
+ const l = n.get(a);
879
+ l && c.push(l);
735
880
  }
736
- s.create(
737
- [a.value],
738
- o.length > 0 ? o : void 0
881
+ i.create(
882
+ [f.value],
883
+ c.length > 0 ? c.length > 1 ? [c] : c : void 0
739
884
  );
740
885
  }
741
886
  }
742
887
  }
743
- function Se(e) {
744
- const r = se("sf-"), n = de(), t = { ...e }, i = pe(n, n), c = ye(n, n), s = ge(n, n), a = he(n, n), { variable: o, selector: f, atRule: l, keyframes: u, media: y, ref: p, css: d } = v(n, n);
888
+ function We(e) {
889
+ const t = b("sf-"), r = je(), n = { ...e }, s = ke(r, r), o = ve(r, r), i = $e(r, r), f = Me(r, r), { variable: c, selector: a, atRule: l, keyframes: u, media: d, ref: y, css: p } = w(r, r);
745
890
  return {
746
- id: r,
747
- root: n,
748
- variable: o,
749
- selector: f,
750
- utility: i,
751
- modifier: c,
752
- recipe: s,
753
- theme: a,
891
+ id: t,
892
+ root: r,
893
+ variable: c,
894
+ selector: a,
895
+ utility: s,
896
+ modifier: o,
897
+ recipe: i,
898
+ theme: f,
754
899
  atRule: l,
755
900
  keyframes: u,
756
- media: y,
757
- ref: p,
758
- css: d,
759
- options: t
901
+ media: d,
902
+ ref: y,
903
+ css: p,
904
+ options: n
760
905
  };
761
906
  }
762
907
  export {
763
- le as applyModifiers,
764
- $e as capitalizeFirst,
765
- ue as combineKeys,
766
- K as createAtRuleFunction,
767
- J as createCssFunction,
768
- v as createDeclarationsCallbackContext,
769
- X as createKeyframesFunction,
770
- Q as createMediaFunction,
771
- ye as createModifierFunction,
772
- ge as createRecipeFunction,
773
- ee as createRefFunction,
774
- de as createRoot,
775
- te as createSelectorFunction,
776
- he as createThemeFunction,
777
- pe as createUtilityFunction,
778
- ne as createVariableFunction,
779
- F as deepClone,
780
- se as generateRandomId,
781
- be as generateRecipeRuntime,
782
- oe as getModifier,
783
- Me as getUtility,
784
- Oe as getVariable,
785
- Z as hashValue,
786
- ve as isAtRule,
787
- E as isCSS,
788
- Y as isContainer,
789
- I as isModifier,
790
- C as isObject,
791
- z as isPrimitiveTokenValue,
792
- Ve as isRecipe,
793
- j as isRef,
794
- V as isRoot,
795
- je as isSelector,
796
- Re as isStyleframe,
797
- ke as isTheme,
798
- h as isToken,
799
- S as isTokenEqual,
800
- D as isTokenValue,
801
- we as isUtility,
802
- G as isVariable,
803
- Fe as merge,
804
- W as mergeContainers,
805
- ae as mergeThemesArray,
806
- fe as mergeVariablesArray,
807
- R as parseDeclarationsBlock,
808
- Ae as processRecipeUtilities,
809
- re as rfdc,
810
- Se as styleframe,
811
- P as transformUtilityKey
908
+ we as applyModifiers,
909
+ Ue as capitalizeFirst,
910
+ De as classNameToCssSelector,
911
+ I as createAtRuleFunction,
912
+ fe as createCssFunction,
913
+ w as createDeclarationsCallbackContext,
914
+ ge as createKeyframesFunction,
915
+ he as createMediaFunction,
916
+ ve as createModifierFunction,
917
+ C as createPropertyValueResolver,
918
+ $e as createRecipeFunction,
919
+ q as createRefFunction,
920
+ je as createRoot,
921
+ be as createSelectorFunction,
922
+ Me as createThemeFunction,
923
+ ke as createUtilityFunction,
924
+ Ae as createVariableFunction,
925
+ k as deepClone,
926
+ Pe as defaultUtilitySelectorFn,
927
+ oe as findVariableInScope,
928
+ b as generateRandomId,
929
+ xe as generateRecipeRuntime,
930
+ le as getModifier,
931
+ Ie as getUtility,
932
+ Ce as getVariable,
933
+ se as hashValue,
934
+ te as isAtRule,
935
+ N as isCSS,
936
+ Ne as isContainer,
937
+ L as isContainerInput,
938
+ ie as isKeyReferenceValue,
939
+ ne as isModifier,
940
+ $ as isObject,
941
+ re as isPrimitiveTokenValue,
942
+ Te as isRecipe,
943
+ A as isRef,
944
+ M as isRoot,
945
+ _e as isSelector,
946
+ Be as isStyleframe,
947
+ Se as isTheme,
948
+ g as isToken,
949
+ O as isTokenEqual,
950
+ B as isTokenValue,
951
+ Oe as isUtility,
952
+ H as isVariable,
953
+ Ke as merge,
954
+ Y as mergeContainers,
955
+ pe as mergeThemesArray,
956
+ ye as mergeVariablesArray,
957
+ z as parseAtReferences,
958
+ x as parseDeclarationsBlock,
959
+ Ee as processRecipeUtilities,
960
+ me as rebuildRegistry,
961
+ ae as rfdc,
962
+ We as styleframe,
963
+ G as transformUtilityKey,
964
+ ce as validateReference
812
965
  };