@tachui/core 0.8.19 → 0.8.21

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,11 +1,11 @@
1
- import { A as g } from "../index-JQ1sW1SK.js";
2
- import { L as rt, R as st, k as nt } from "../index-JQ1sW1SK.js";
3
- import { J as S, K as C, k as N } from "../theme-CRLPHryV.js";
1
+ import { A as p } from "../index-JQ1sW1SK.js";
2
+ import { L as it, R as ot, k as lt } from "../index-JQ1sW1SK.js";
3
+ import { J as C, K as S, k as x } from "../theme-CRLPHryV.js";
4
4
  export * from "@tachui/types/assets";
5
- var G = Object.defineProperty, H = (i, t, e) => t in i ? G(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, b = (i, t, e) => H(i, typeof t != "symbol" ? t + "" : t, e);
6
- const E = class a extends g {
5
+ var H = Object.defineProperty, M = (i, t, e) => t in i ? H(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, y = (i, t, e) => M(i, typeof t != "symbol" ? t + "" : t, e);
6
+ const E = class a extends p {
7
7
  constructor(t) {
8
- if (super(t.name), b(this, "default"), b(this, "light"), b(this, "dark"), !t.default)
8
+ if (super(t.name), y(this, "default"), y(this, "light"), y(this, "dark"), !t.default)
9
9
  throw new Error(
10
10
  `ColorAsset "${t.name}" must specify a default color`
11
11
  );
@@ -15,17 +15,17 @@ const E = class a extends g {
15
15
  `Invalid default color format for asset "${t.name}": ${e.error}`
16
16
  );
17
17
  if (t.light) {
18
- const s = a.validateColor(t.light);
19
- if (!s.isValid)
18
+ const r = a.validateColor(t.light);
19
+ if (!r.isValid)
20
20
  throw new Error(
21
- `Invalid light color format for asset "${t.name}": ${s.error}`
21
+ `Invalid light color format for asset "${t.name}": ${r.error}`
22
22
  );
23
23
  }
24
24
  if (t.dark) {
25
- const s = a.validateColor(t.dark);
26
- if (!s.isValid)
25
+ const r = a.validateColor(t.dark);
26
+ if (!r.isValid)
27
27
  throw new Error(
28
- `Invalid dark color format for asset "${t.name}": ${s.error}`
28
+ `Invalid dark color format for asset "${t.name}": ${r.error}`
29
29
  );
30
30
  }
31
31
  this.default = t.default, this.light = t.light, this.dark = t.dark;
@@ -47,29 +47,29 @@ const E = class a extends g {
47
47
  if (a.HEX_REGEX.test(e))
48
48
  return { isValid: !0, format: "hex" };
49
49
  if (a.RGB_REGEX.test(e)) {
50
- const n = e.match(a.RGB_REGEX), [, r, o, u] = n.map(Number);
51
- return r <= 255 && o <= 255 && u <= 255 ? { isValid: !0, format: "rgb" } : {
50
+ const n = e.match(a.RGB_REGEX), [, s, o, c] = n.map(Number);
51
+ return s <= 255 && o <= 255 && c <= 255 ? { isValid: !0, format: "rgb" } : {
52
52
  isValid: !1,
53
53
  error: "RGB values must be between 0 and 255"
54
54
  };
55
55
  }
56
56
  if (a.RGBA_REGEX.test(e)) {
57
- const n = e.match(a.RGBA_REGEX), [, r, o, u, l] = n, f = Number(r), c = Number(o), h = Number(u), m = Number(l);
58
- return f <= 255 && c <= 255 && h <= 255 && m >= 0 && m <= 1 ? { isValid: !0, format: "rgba" } : {
57
+ const n = e.match(a.RGBA_REGEX), [, s, o, c, l] = n, u = Number(s), h = Number(o), f = Number(c), d = Number(l);
58
+ return u <= 255 && h <= 255 && f <= 255 && d >= 0 && d <= 1 ? { isValid: !0, format: "rgba" } : {
59
59
  isValid: !1,
60
60
  error: "RGBA values must be: RGB 0-255, alpha 0-1"
61
61
  };
62
62
  }
63
63
  if (a.HSL_REGEX.test(e)) {
64
- const n = e.match(a.HSL_REGEX), [, r, o, u] = n.map(Number);
65
- return r <= 360 && o <= 100 && u <= 100 ? { isValid: !0, format: "hsl" } : {
64
+ const n = e.match(a.HSL_REGEX), [, s, o, c] = n.map(Number);
65
+ return s <= 360 && o <= 100 && c <= 100 ? { isValid: !0, format: "hsl" } : {
66
66
  isValid: !1,
67
67
  error: "HSL values must be: H 0-360, S/L 0-100%"
68
68
  };
69
69
  }
70
70
  if (a.HSLA_REGEX.test(e)) {
71
- const n = e.match(a.HSLA_REGEX), [, r, o, u, l] = n, f = Number(r), c = Number(o), h = Number(u), m = Number(l);
72
- return f <= 360 && c <= 100 && h <= 100 && m >= 0 && m <= 1 ? { isValid: !0, format: "hsla" } : {
71
+ const n = e.match(a.HSLA_REGEX), [, s, o, c, l] = n, u = Number(s), h = Number(o), f = Number(c), d = Number(l);
72
+ return u <= 360 && h <= 100 && f <= 100 && d >= 0 && d <= 1 ? { isValid: !0, format: "hsla" } : {
73
73
  isValid: !1,
74
74
  error: "HSLA values must be: H 0-360, S/L 0-100%, alpha 0-1"
75
75
  };
@@ -102,220 +102,250 @@ const E = class a extends g {
102
102
  "silver",
103
103
  "aqua",
104
104
  "fuchsia"
105
- ].includes(e.toLowerCase()) ? { isValid: !0, format: "named" } : e.startsWith("var(--") && e.endsWith(")") ? { isValid: !0, format: "named" } : {
105
+ ].includes(e.toLowerCase()) ? { isValid: !0, format: "named" } : e.startsWith("var(--") && e.endsWith(")") ? { isValid: !0, format: "named" } : e.startsWith("color-mix(") ? { isValid: !0, format: "named" } : {
106
106
  isValid: !1,
107
- error: "Unsupported color format. Supported: hex, rgb, rgba, hsl, hsla, named colors, CSS custom properties"
107
+ error: "Unsupported color format. Supported: hex, rgb, rgba, hsl, hsla, named colors, CSS custom properties, color-mix()"
108
108
  };
109
109
  }
110
110
  static getCurrentTheme() {
111
- return S();
111
+ return C();
112
112
  }
113
113
  opacity(t) {
114
114
  if (!this.isFiniteInput(t, "opacity(alpha)"))
115
- return this.resolve();
115
+ return this;
116
116
  const e = a.clamp(t, 0, 1);
117
- return a.applyAlpha(this.resolve(), e);
117
+ return new a({
118
+ name: this.name,
119
+ default: a.applyAlpha(this.default, e),
120
+ light: this.light ? a.applyAlpha(this.light, e) : void 0,
121
+ dark: this.dark ? a.applyAlpha(this.dark, e) : void 0
122
+ });
118
123
  }
119
124
  saturate(t) {
120
125
  if (!this.isFiniteInput(t, "saturate(amount)"))
121
- return this.resolve();
126
+ return this;
122
127
  const e = a.clamp(t, -1, 1);
123
- return a.applySaturation(this.resolve(), e);
128
+ return new a({
129
+ name: this.name,
130
+ default: a.applySaturation(this.default, e),
131
+ light: this.light ? a.applySaturation(this.light, e) : void 0,
132
+ dark: this.dark ? a.applySaturation(this.dark, e) : void 0
133
+ });
124
134
  }
125
135
  brighten(t) {
126
136
  if (!this.isFiniteInput(t, "brighten(amount)"))
127
- return this.resolve();
137
+ return this;
128
138
  const e = a.clamp(t, -1, 1);
129
- return a.applyBrightness(this.resolve(), e);
139
+ return new a({
140
+ name: this.name,
141
+ default: a.applyBrightness(this.default, e),
142
+ light: this.light ? a.applyBrightness(this.light, e) : void 0,
143
+ dark: this.dark ? a.applyBrightness(this.dark, e) : void 0
144
+ });
130
145
  }
131
146
  contrast(t) {
132
147
  if (!this.isFiniteInput(t, "contrast(amount)"))
133
- return this.resolve();
148
+ return this;
134
149
  const e = a.clamp(t, -1, 1);
135
- return a.applyContrast(this.resolve(), e);
150
+ return new a({
151
+ name: this.name,
152
+ default: a.applyContrast(this.default, e),
153
+ light: this.light ? a.applyContrast(this.light, e) : void 0,
154
+ dark: this.dark ? a.applyContrast(this.dark, e) : void 0
155
+ });
136
156
  }
137
157
  rotateHue(t) {
138
158
  if (!this.isFiniteInput(t, "rotateHue(degrees)"))
139
- return this.resolve();
159
+ return this;
140
160
  const e = (t % 360 + 360) % 360;
141
- return a.applyHueRotation(this.resolve(), e);
161
+ return new a({
162
+ name: this.name,
163
+ default: a.applyHueRotation(this.default, e),
164
+ light: this.light ? a.applyHueRotation(this.light, e) : void 0,
165
+ dark: this.dark ? a.applyHueRotation(this.dark, e) : void 0
166
+ });
142
167
  }
143
168
  resolve() {
144
- const t = N() !== null;
169
+ const t = x() !== null;
145
170
  let e;
146
- return t ? e = C()() : e = a.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
171
+ return t ? e = S()() : e = a.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
147
172
  }
148
173
  isFiniteInput(t, e) {
149
174
  if (Number.isFinite(t))
150
175
  return !0;
151
- const s = `ColorAsset.${e} requires a finite number for asset "${this.name}"`;
176
+ const r = `ColorAsset.${e} requires a finite number for asset "${this.name}"`;
152
177
  if (process.env.NODE_ENV === "development")
153
- throw new Error(s);
178
+ throw new Error(r);
154
179
  return !1;
155
180
  }
156
- static clamp(t, e, s) {
157
- return Math.min(s, Math.max(e, t));
181
+ static clamp(t, e, r) {
182
+ return Math.min(r, Math.max(e, t));
158
183
  }
159
184
  static formatAlpha(t) {
160
185
  return t === 0 || t === 1 ? String(t) : Number(t.toFixed(4)).toString();
161
186
  }
162
187
  static toColorMix(t, e) {
163
- const s = Number((e * 100).toFixed(2)).toString();
164
- return `color-mix(in srgb, ${t} ${s}%, transparent)`;
188
+ const r = Number((e * 100).toFixed(2)).toString();
189
+ return `color-mix(in srgb, ${t} ${r}%, transparent)`;
165
190
  }
166
191
  static applyAlpha(t, e) {
167
- const s = t.trim(), n = a.formatAlpha(e);
168
- if (s.match(a.HEX_REGEX)) {
169
- const [c, h, m] = a.parseHex(s);
170
- return `rgba(${c}, ${h}, ${m}, ${n})`;
192
+ const r = t.trim(), n = a.formatAlpha(e);
193
+ if (r.match(a.HEX_REGEX)) {
194
+ const [f, d, m] = a.parseHex(r);
195
+ return `rgba(${f}, ${d}, ${m}, ${n})`;
171
196
  }
172
- const o = s.match(a.RGB_REGEX);
197
+ const o = r.match(a.RGB_REGEX);
173
198
  if (o) {
174
- const [, c, h, m] = o.map(Number);
175
- return `rgba(${c}, ${h}, ${m}, ${n})`;
199
+ const [, f, d, m] = o.map(Number);
200
+ return `rgba(${f}, ${d}, ${m}, ${n})`;
176
201
  }
177
- const u = s.match(a.RGBA_REGEX);
178
- if (u) {
179
- const [, c, h, m] = u.map(Number);
180
- return `rgba(${c}, ${h}, ${m}, ${n})`;
202
+ const c = r.match(a.RGBA_REGEX);
203
+ if (c) {
204
+ const [, f, d, m] = c.map(Number);
205
+ return `rgba(${f}, ${d}, ${m}, ${n})`;
181
206
  }
182
- const l = s.match(a.HSL_REGEX);
207
+ const l = r.match(a.HSL_REGEX);
183
208
  if (l) {
184
- const [, c, h, m] = l.map(Number);
185
- return `hsla(${c}, ${h}%, ${m}%, ${n})`;
209
+ const [, f, d, m] = l.map(Number);
210
+ return `hsla(${f}, ${d}%, ${m}%, ${n})`;
211
+ }
212
+ const u = r.match(a.HSLA_REGEX);
213
+ if (u) {
214
+ const [, f, d, m] = u.map(Number);
215
+ return `hsla(${f}, ${d}%, ${m}%, ${n})`;
186
216
  }
187
- const f = s.match(a.HSLA_REGEX);
188
- if (f) {
189
- const [, c, h, m] = f.map(Number);
190
- return `hsla(${c}, ${h}%, ${m}%, ${n})`;
217
+ const h = a.NAMED_COLOR_RGB[r.toLowerCase()];
218
+ if (h) {
219
+ const [f, d, m] = h;
220
+ return `rgba(${f}, ${d}, ${m}, ${n})`;
191
221
  }
192
- return a.toColorMix(s, e);
222
+ return a.toColorMix(r, e);
193
223
  }
194
224
  static parseHex(t) {
195
- const [e, s, n] = a.parseHexWithAlpha(t);
196
- return [e, s, n];
225
+ const [e, r, n] = a.parseHexWithAlpha(t);
226
+ return [e, r, n];
197
227
  }
198
228
  static parseHexWithAlpha(t) {
199
- const e = t.slice(1), s = e.length === 3 ? e.split("").map((l) => `${l}${l}`).join("") : e.length === 8 ? e.slice(0, 6) : e, n = e.length === 8 ? Number.parseInt(e.slice(6, 8), 16) / 255 : 1, r = Number.parseInt(s.slice(0, 2), 16), o = Number.parseInt(s.slice(2, 4), 16), u = Number.parseInt(s.slice(4, 6), 16);
200
- return [r, o, u, n];
229
+ const e = t.slice(1), r = e.length === 3 ? e.split("").map((l) => `${l}${l}`).join("") : e.length === 8 ? e.slice(0, 6) : e, n = e.length === 8 ? Number.parseInt(e.slice(6, 8), 16) / 255 : 1, s = Number.parseInt(r.slice(0, 2), 16), o = Number.parseInt(r.slice(2, 4), 16), c = Number.parseInt(r.slice(4, 6), 16);
230
+ return [s, o, c, n];
201
231
  }
202
232
  static applySaturation(t, e) {
203
- const s = a.parseColorToHsla(t);
204
- if (!s)
233
+ const r = a.parseColorToHsla(t);
234
+ if (!r)
205
235
  return t;
206
- const n = e >= 0 ? s.s + (1 - s.s) * e : s.s * (1 + e), r = a.clamp(n, 0, 1), [o, u, l] = a.hslToRgb(s.h, r, s.l);
207
- return s.a < 1 ? `rgba(${o}, ${u}, ${l}, ${a.formatAlpha(s.a)})` : a.rgbToHex(o, u, l);
236
+ const n = e >= 0 ? r.s + (1 - r.s) * e : r.s * (1 + e), s = a.clamp(n, 0, 1), [o, c, l] = a.hslToRgb(r.h, s, r.l);
237
+ return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, c, l);
208
238
  }
209
239
  static applyBrightness(t, e) {
210
- const s = a.parseColorToRgba(t);
211
- if (!s)
240
+ const r = a.parseColorToRgba(t);
241
+ if (!r)
212
242
  return t;
213
243
  const n = (l) => {
214
- const f = e >= 0 ? l + (255 - l) * e : l * (1 + e);
215
- return Math.round(a.clamp(f, 0, 255));
216
- }, r = n(s.r), o = n(s.g), u = n(s.b);
217
- return s.a < 1 ? `rgba(${r}, ${o}, ${u}, ${a.formatAlpha(s.a)})` : a.rgbToHex(r, o, u);
244
+ const u = e >= 0 ? l + (255 - l) * e : l * (1 + e);
245
+ return Math.round(a.clamp(u, 0, 255));
246
+ }, s = n(r.r), o = n(r.g), c = n(r.b);
247
+ return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, c);
218
248
  }
219
249
  static applyContrast(t, e) {
220
- const s = a.parseColorToRgba(t);
221
- if (!s)
250
+ const r = a.parseColorToRgba(t);
251
+ if (!r)
222
252
  return t;
223
- const n = 1 + e, r = (f) => {
224
- const h = (f / 255 - 0.5) * n + 0.5;
225
- return Math.round(a.clamp(h, 0, 1) * 255);
226
- }, o = r(s.r), u = r(s.g), l = r(s.b);
227
- return s.a < 1 ? `rgba(${o}, ${u}, ${l}, ${a.formatAlpha(s.a)})` : a.rgbToHex(o, u, l);
253
+ const n = 1 + e, s = (u) => {
254
+ const f = (u / 255 - 0.5) * n + 0.5;
255
+ return Math.round(a.clamp(f, 0, 1) * 255);
256
+ }, o = s(r.r), c = s(r.g), l = s(r.b);
257
+ return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, c, l);
228
258
  }
229
259
  static applyHueRotation(t, e) {
230
- const s = a.parseColorToHsla(t);
231
- if (!s)
260
+ const r = a.parseColorToHsla(t);
261
+ if (!r)
232
262
  return t;
233
- const n = (s.h + e) % 360, [r, o, u] = a.hslToRgb(n, s.s, s.l);
234
- return s.a < 1 ? `rgba(${r}, ${o}, ${u}, ${a.formatAlpha(s.a)})` : a.rgbToHex(r, o, u);
263
+ const n = (r.h + e) % 360, [s, o, c] = a.hslToRgb(n, r.s, r.l);
264
+ return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, c);
235
265
  }
236
266
  static parseColorToRgba(t) {
237
267
  const e = t.trim();
238
268
  if (a.HEX_REGEX.test(e)) {
239
- const [l, f, c, h] = a.parseHexWithAlpha(e);
240
- return { r: l, g: f, b: c, a: h };
269
+ const [l, u, h, f] = a.parseHexWithAlpha(e);
270
+ return { r: l, g: u, b: h, a: f };
241
271
  }
242
- const s = e.match(a.RGB_REGEX);
243
- if (s) {
244
- const [, l, f, c] = s.map(Number);
245
- return { r: l, g: f, b: c, a: 1 };
272
+ const r = e.match(a.RGB_REGEX);
273
+ if (r) {
274
+ const [, l, u, h] = r.map(Number);
275
+ return { r: l, g: u, b: h, a: 1 };
246
276
  }
247
277
  const n = e.match(a.RGBA_REGEX);
248
278
  if (n) {
249
- const [, l, f, c, h] = n;
250
- return { r: Number(l), g: Number(f), b: Number(c), a: Number(h) };
279
+ const [, l, u, h, f] = n;
280
+ return { r: Number(l), g: Number(u), b: Number(h), a: Number(f) };
251
281
  }
252
- const r = e.match(a.HSL_REGEX);
253
- if (r) {
254
- const [, l, f, c] = r.map(Number), [h, m, w] = a.hslToRgb(l, f / 100, c / 100);
255
- return { r: h, g: m, b: w, a: 1 };
282
+ const s = e.match(a.HSL_REGEX);
283
+ if (s) {
284
+ const [, l, u, h] = s.map(Number), [f, d, m] = a.hslToRgb(l, u / 100, h / 100);
285
+ return { r: f, g: d, b: m, a: 1 };
256
286
  }
257
287
  const o = e.match(a.HSLA_REGEX);
258
288
  if (o) {
259
- const [, l, f, c, h] = o, [m, w, x] = a.hslToRgb(
289
+ const [, l, u, h, f] = o, [d, m, G] = a.hslToRgb(
260
290
  Number(l),
261
- Number(f) / 100,
262
- Number(c) / 100
291
+ Number(u) / 100,
292
+ Number(h) / 100
263
293
  );
264
- return { r: m, g: w, b: x, a: Number(h) };
294
+ return { r: d, g: m, b: G, a: Number(f) };
265
295
  }
266
- const u = a.NAMED_COLOR_RGB[e.toLowerCase()];
267
- if (u) {
268
- const [l, f, c, h] = u;
269
- return { r: l, g: f, b: c, a: h };
296
+ const c = a.NAMED_COLOR_RGB[e.toLowerCase()];
297
+ if (c) {
298
+ const [l, u, h, f] = c;
299
+ return { r: l, g: u, b: h, a: f };
270
300
  }
271
301
  return null;
272
302
  }
273
303
  static parseColorToHsla(t) {
274
- const e = t.trim(), s = e.match(a.HSL_REGEX);
275
- if (s) {
276
- const [, f, c, h] = s.map(Number);
277
- return { h: f, s: c / 100, l: h / 100, a: 1 };
304
+ const e = t.trim(), r = e.match(a.HSL_REGEX);
305
+ if (r) {
306
+ const [, u, h, f] = r.map(Number);
307
+ return { h: u, s: h / 100, l: f / 100, a: 1 };
278
308
  }
279
309
  const n = e.match(a.HSLA_REGEX);
280
310
  if (n) {
281
- const [, f, c, h, m] = n;
311
+ const [, u, h, f, d] = n;
282
312
  return {
283
- h: Number(f),
284
- s: Number(c) / 100,
285
- l: Number(h) / 100,
286
- a: Number(m)
313
+ h: Number(u),
314
+ s: Number(h) / 100,
315
+ l: Number(f) / 100,
316
+ a: Number(d)
287
317
  };
288
318
  }
289
- const r = a.parseColorToRgba(e);
290
- if (!r)
319
+ const s = a.parseColorToRgba(e);
320
+ if (!s)
291
321
  return null;
292
- const [o, u, l] = a.rgbToHsl(r.r, r.g, r.b);
293
- return { h: o, s: u, l, a: r.a };
294
- }
295
- static rgbToHsl(t, e, s) {
296
- const n = t / 255, r = e / 255, o = s / 255, u = Math.max(n, r, o), l = Math.min(n, r, o), f = u - l;
297
- let c = 0;
298
- const h = (u + l) / 2, m = f === 0 ? 0 : f / (1 - Math.abs(2 * h - 1));
299
- return f !== 0 && (u === n ? c = (r - o) / f % 6 : u === r ? c = (o - n) / f + 2 : c = (n - r) / f + 4, c *= 60, c < 0 && (c += 360)), [c, m, h];
300
- }
301
- static hslToRgb(t, e, s) {
302
- const n = (t % 360 + 360) % 360, r = (1 - Math.abs(2 * s - 1)) * e, o = r * (1 - Math.abs(n / 60 % 2 - 1)), u = s - r / 2;
303
- let l = 0, f = 0, c = 0;
304
- n < 60 ? (l = r, f = o) : n < 120 ? (l = o, f = r) : n < 180 ? (f = r, c = o) : n < 240 ? (f = o, c = r) : n < 300 ? (l = o, c = r) : (l = r, c = o);
305
- const h = Math.round((l + u) * 255), m = Math.round((f + u) * 255), w = Math.round((c + u) * 255);
306
- return [h, m, w];
307
- }
308
- static rgbToHex(t, e, s) {
309
- const n = (r) => r.toString(16).padStart(2, "0");
310
- return `#${n(t)}${n(e)}${n(s)}`.toUpperCase();
322
+ const [o, c, l] = a.rgbToHsl(s.r, s.g, s.b);
323
+ return { h: o, s: c, l, a: s.a };
324
+ }
325
+ static rgbToHsl(t, e, r) {
326
+ const n = t / 255, s = e / 255, o = r / 255, c = Math.max(n, s, o), l = Math.min(n, s, o), u = c - l;
327
+ let h = 0;
328
+ const f = (c + l) / 2, d = u === 0 ? 0 : u / (1 - Math.abs(2 * f - 1));
329
+ return u !== 0 && (c === n ? h = (s - o) / u % 6 : c === s ? h = (o - n) / u + 2 : h = (n - s) / u + 4, h *= 60, h < 0 && (h += 360)), [h, d, f];
330
+ }
331
+ static hslToRgb(t, e, r) {
332
+ const n = (t % 360 + 360) % 360, s = (1 - Math.abs(2 * r - 1)) * e, o = s * (1 - Math.abs(n / 60 % 2 - 1)), c = r - s / 2;
333
+ let l = 0, u = 0, h = 0;
334
+ n < 60 ? (l = s, u = o) : n < 120 ? (l = o, u = s) : n < 180 ? (u = s, h = o) : n < 240 ? (u = o, h = s) : n < 300 ? (l = o, h = s) : (l = s, h = o);
335
+ const f = Math.round((l + c) * 255), d = Math.round((u + c) * 255), m = Math.round((h + c) * 255);
336
+ return [f, d, m];
337
+ }
338
+ static rgbToHex(t, e, r) {
339
+ const n = (s) => s.toString(16).padStart(2, "0");
340
+ return `#${n(t)}${n(e)}${n(r)}`.toUpperCase();
311
341
  }
312
342
  };
313
- b(E, "HEX_REGEX", /^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/);
314
- b(E, "RGB_REGEX", /^rgb\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)$/i);
315
- b(E, "RGBA_REGEX", /^rgba\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);
316
- b(E, "HSL_REGEX", /^hsl\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*\)$/i);
317
- b(E, "HSLA_REGEX", /^hsla\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);
318
- b(E, "NAMED_COLOR_RGB", {
343
+ y(E, "HEX_REGEX", /^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/);
344
+ y(E, "RGB_REGEX", /^rgb\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)$/i);
345
+ y(E, "RGBA_REGEX", /^rgba\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);
346
+ y(E, "HSL_REGEX", /^hsl\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*\)$/i);
347
+ y(E, "HSLA_REGEX", /^hsla\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);
348
+ y(E, "NAMED_COLOR_RGB", {
319
349
  transparent: [0, 0, 0, 0],
320
350
  black: [0, 0, 0, 1],
321
351
  white: [255, 255, 255, 1],
@@ -340,11 +370,11 @@ b(E, "NAMED_COLOR_RGB", {
340
370
  aqua: [0, 255, 255, 1],
341
371
  fuchsia: [255, 0, 255, 1]
342
372
  });
343
- let d = E;
344
- var k = Object.defineProperty, M = (i, t, e) => t in i ? k(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, v = (i, t, e) => M(i, typeof t != "symbol" ? t + "" : t, e);
345
- class F extends g {
373
+ let g = E;
374
+ var L = Object.defineProperty, P = (i, t, e) => t in i ? L(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, A = (i, t, e) => P(i, typeof t != "symbol" ? t + "" : t, e);
375
+ class F extends p {
346
376
  constructor(t) {
347
- if (super(t.name), v(this, "default"), v(this, "light"), v(this, "dark"), v(this, "alt"), v(this, "placeholder"), !t.default)
377
+ if (super(t.name), A(this, "default"), A(this, "light"), A(this, "dark"), A(this, "alt"), A(this, "placeholder"), !t.default)
348
378
  throw new Error(`ImageAsset "${t.name}" must specify a default image path`);
349
379
  this.default = t.default, this.light = t.light, this.dark = t.dark, this.alt = t.options?.alt, this.placeholder = t.options?.placeholder;
350
380
  }
@@ -352,12 +382,12 @@ class F extends g {
352
382
  return new F(t);
353
383
  }
354
384
  static getCurrentTheme() {
355
- return S();
385
+ return C();
356
386
  }
357
387
  resolve() {
358
- const t = N() !== null;
388
+ const t = x() !== null;
359
389
  let e;
360
- return t ? e = C()() : e = F.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
390
+ return t ? e = S()() : e = F.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
361
391
  }
362
392
  // Additional accessors
363
393
  get src() {
@@ -373,10 +403,10 @@ class F extends g {
373
403
  return this.default;
374
404
  }
375
405
  }
376
- var P = Object.defineProperty, L = (i, t, e) => t in i ? P(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, A = (i, t, e) => L(i, typeof t != "symbol" ? t + "" : t, e);
377
- class y extends g {
378
- constructor(t, e = [], s = "", n = {}) {
379
- super(s || t), A(this, "family"), A(this, "fallbacks"), A(this, "options"), A(this, "loaded", !1), A(this, "loadPromise", null), this.family = t, this.fallbacks = e, this.options = {
406
+ var X = Object.defineProperty, T = (i, t, e) => t in i ? X(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, v = (i, t, e) => T(i, typeof t != "symbol" ? t + "" : t, e);
407
+ class w extends p {
408
+ constructor(t, e = [], r = "", n = {}) {
409
+ super(r || t), v(this, "family"), v(this, "fallbacks"), v(this, "options"), v(this, "loaded", !1), v(this, "loadPromise", null), this.family = t, this.fallbacks = e, this.options = {
380
410
  loading: "lazy",
381
411
  fontDisplay: "swap",
382
412
  preconnect: !0,
@@ -386,8 +416,8 @@ class y extends g {
386
416
  /**
387
417
  * Static factory method for SwiftUI-style initialization
388
418
  */
389
- static init(t, e = [], s, n = {}) {
390
- return new y(t, e, s, n);
419
+ static init(t, e = [], r, n = {}) {
420
+ return new w(t, e, r, n);
391
421
  }
392
422
  /**
393
423
  * Get the full font-family CSS value including fallbacks
@@ -415,8 +445,8 @@ class y extends g {
415
445
  try {
416
446
  const n = new URL(t).origin;
417
447
  if (!document.querySelector(`link[rel="preconnect"][href="${n}"]`)) {
418
- const r = document.createElement("link");
419
- r.rel = "preconnect", r.href = n, r.crossOrigin = "anonymous", document.head.appendChild(r);
448
+ const s = document.createElement("link");
449
+ s.rel = "preconnect", s.href = n, s.crossOrigin = "anonymous", document.head.appendChild(s);
420
450
  }
421
451
  } catch {
422
452
  }
@@ -433,44 +463,44 @@ class y extends g {
433
463
  * Load a CSS file containing @font-face rules
434
464
  */
435
465
  async loadFontCSS(t) {
436
- return new Promise((e, s) => {
466
+ return new Promise((e, r) => {
437
467
  if (document.querySelector(`link[href="${t}"]`)) {
438
468
  e();
439
469
  return;
440
470
  }
441
- const r = document.createElement("link");
442
- r.rel = "stylesheet", r.href = t, r.onload = () => {
471
+ const s = document.createElement("link");
472
+ s.rel = "stylesheet", s.href = t, s.onload = () => {
443
473
  e();
444
- }, r.onerror = (o) => {
474
+ }, s.onerror = (o) => {
445
475
  console.warn(`⚠️ Failed to load font CSS for ${this.family}:`, t), e();
446
- }, document.head.appendChild(r);
476
+ }, document.head.appendChild(s);
447
477
  });
448
478
  }
449
479
  /**
450
480
  * Load a font file directly and create @font-face rule
451
481
  */
452
482
  async loadFontFile(t) {
453
- const { fontFormat: e, fontDisplay: s, weightRange: n, widthRange: r } = this.options;
483
+ const { fontFormat: e, fontDisplay: r, weightRange: n, widthRange: s } = this.options;
454
484
  let o = "";
455
485
  e ? o = `format('${e}')` : t.endsWith(".woff2") ? o = "format('woff2')" : t.endsWith(".woff") ? o = "format('woff')" : t.endsWith(".ttf") && (o = "format('truetype')");
456
- let u = `
486
+ let c = `
457
487
  @font-face {
458
488
  font-family: "${this.family}";
459
489
  src: url("${t}") ${o};
460
- font-display: ${s || "swap"};
490
+ font-display: ${r || "swap"};
461
491
  `;
462
- n && (u += `font-weight: ${n[0]} ${n[1]};
463
- `), r && (u += `font-stretch: ${r[0]}% ${r[1]}%;
464
- `), u += "}";
492
+ n && (c += `font-weight: ${n[0]} ${n[1]};
493
+ `), s && (c += `font-stretch: ${s[0]}% ${s[1]}%;
494
+ `), c += "}";
465
495
  const l = document.createElement("style");
466
- if (l.textContent = u, document.head.appendChild(l), "FontFace" in window)
496
+ if (l.textContent = c, document.head.appendChild(l), "FontFace" in window)
467
497
  try {
468
- const f = new FontFace(this.family, `url(${t})`, {
469
- display: s || "swap",
498
+ const u = new FontFace(this.family, `url(${t})`, {
499
+ display: r || "swap",
470
500
  weight: n ? `${n[0]} ${n[1]}` : void 0,
471
- stretch: r ? `${r[0]}% ${r[1]}%` : void 0
501
+ stretch: s ? `${s[0]}% ${s[1]}%` : void 0
472
502
  });
473
- await f.load(), document.fonts.add(f);
503
+ await u.load(), document.fonts.add(u);
474
504
  } catch {
475
505
  }
476
506
  }
@@ -493,7 +523,7 @@ class y extends g {
493
523
  return this.options.loading === "lazy" && !this.loaded && this.options.fontUrl && this.load(), this.value;
494
524
  }
495
525
  }
496
- const D = {
526
+ const q = {
497
527
  ultraLight: 100,
498
528
  thin: 200,
499
529
  light: 300,
@@ -503,7 +533,7 @@ const D = {
503
533
  bold: 700,
504
534
  heavy: 800,
505
535
  black: 900
506
- }, q = {
536
+ }, z = {
507
537
  ultraCondensed: 50,
508
538
  extraCondensed: 62.5,
509
539
  condensed: 75,
@@ -520,36 +550,36 @@ const D = {
520
550
  cursive: ["cursive"],
521
551
  fantasy: ["fantasy"]
522
552
  };
523
- function z(i = "sansSerif", t) {
524
- return new y("", [...R[i]], t || `system-${i}`);
553
+ function U(i = "sansSerif", t) {
554
+ return new w("", [...R[i]], t || `system-${i}`);
525
555
  }
526
- function U(i, t = [400], e, s = {}) {
556
+ function j(i, t = [400], e, r = {}) {
527
557
  const n = t.join(";"), o = `https://fonts.googleapis.com/css2?family=${i.replace(/\s+/g, "+")}:wght@${n}&display=swap`;
528
- return new y(
558
+ return new w(
529
559
  i,
530
560
  [...R.sansSerif],
531
561
  e || i.toLowerCase().replace(/\s+/g, "-"),
532
562
  {
533
- ...s,
563
+ ...r,
534
564
  fontUrl: o,
535
565
  preconnect: !0
536
566
  }
537
567
  );
538
568
  }
539
- function j(i, t, e, s = [...R.sansSerif], n) {
540
- const r = {};
541
- return e.slant && (r.slnt = e.slant), e.optical && (r.opsz = e.optical), e.custom && Object.assign(r, e.custom), new y(i, s, n, {
569
+ function K(i, t, e, r = [...R.sansSerif], n) {
570
+ const s = {};
571
+ return e.slant && (s.slnt = e.slant), e.optical && (s.opsz = e.optical), e.custom && Object.assign(s, e.custom), new w(i, r, n, {
542
572
  fontUrl: t,
543
573
  weightRange: e.weight,
544
574
  widthRange: e.width,
545
- variableAxes: r,
575
+ variableAxes: s,
546
576
  fontDisplay: "swap"
547
577
  });
548
578
  }
549
- var X = Object.defineProperty, T = (i, t, e) => t in i ? X(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, V = (i, t, e) => T(i, t + "", e);
550
- class B {
579
+ var B = Object.defineProperty, V = (i, t, e) => t in i ? B(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, I = (i, t, e) => V(i, t + "", e);
580
+ class O {
551
581
  constructor() {
552
- V(this, "assets", /* @__PURE__ */ new Map());
582
+ I(this, "assets", /* @__PURE__ */ new Map());
553
583
  }
554
584
  add(t, e) {
555
585
  this.assets.set(t, e);
@@ -568,18 +598,18 @@ class B {
568
598
  get: (t, e) => {
569
599
  if (e === "toString" || e === "valueOf")
570
600
  return () => "[Assets]";
571
- const s = this.assets.get(e);
572
- if (s)
573
- return s instanceof d ? new Proxy(s, {
574
- get: (n, r) => r === "light" || r === "dark" ? n[r] : r === "resolve" ? () => n.resolve() : r === "toString" || r === "valueOf" ? () => n.resolve() : n[r],
575
- has: (n, r) => r === "resolve" ? !0 : r in n
576
- }) : s instanceof F ? new Proxy(s, {
577
- get: (n, r) => r === "lightSrc" || r === "darkSrc" || r === "src" || r === "defaultSrc" ? n[r] : r === "resolve" ? () => n.resolve() : r === "toString" || r === "valueOf" ? () => n.resolve() : n[r],
578
- has: (n, r) => r === "resolve" ? !0 : r in n
579
- }) : s instanceof y ? new Proxy(s, {
580
- get: (n, r) => r === "family" || r === "fallbacks" || r === "options" ? n[r] : r === "resolve" ? () => n.resolve() : r === "toString" || r === "valueOf" ? () => n.resolve() : n[r],
581
- has: (n, r) => r === "resolve" ? !0 : r in n
582
- }) : s;
601
+ const r = this.assets.get(e);
602
+ if (r)
603
+ return r instanceof g ? new Proxy(r, {
604
+ get: (n, s) => s === "light" || s === "dark" ? n[s] : s === "resolve" ? () => n.resolve() : s === "toString" || s === "valueOf" ? () => n.resolve() : n[s],
605
+ has: (n, s) => s === "resolve" ? !0 : s in n
606
+ }) : r instanceof F ? new Proxy(r, {
607
+ get: (n, s) => s === "lightSrc" || s === "darkSrc" || s === "src" || s === "defaultSrc" ? n[s] : s === "resolve" ? () => n.resolve() : s === "toString" || s === "valueOf" ? () => n.resolve() : n[s],
608
+ has: (n, s) => s === "resolve" ? !0 : s in n
609
+ }) : r instanceof w ? new Proxy(r, {
610
+ get: (n, s) => s === "family" || s === "fallbacks" || s === "options" ? n[s] : s === "resolve" ? () => n.resolve() : s === "toString" || s === "valueOf" ? () => n.resolve() : n[s],
611
+ has: (n, s) => s === "resolve" ? !0 : s in n
612
+ }) : r;
583
613
  },
584
614
  // Add ownKeys handler to support Object.keys() enumeration
585
615
  ownKeys: (t) => Array.from(this.assets.keys()),
@@ -589,137 +619,162 @@ class B {
589
619
  );
590
620
  }
591
621
  }
592
- const $ = new B(), I = $.asProxy(), K = I;
593
- function p(...i) {
622
+ const b = new O(), N = b.asProxy(), J = N;
623
+ function $(...i) {
594
624
  if (i.length === 0)
595
625
  throw new Error("registerAsset requires at least one argument");
596
626
  const t = i[0], e = i[1];
597
- if (typeof t == "string" && e instanceof g && i.length === 2)
598
- $.add(t, e);
599
- else if (t instanceof g && typeof e == "string" && i.length === 2)
600
- $.add(e, t);
601
- else if (t instanceof g && i.length === 1)
602
- $.add(t.name, t);
603
- else if (t instanceof g && e === void 0 && i.length === 2)
604
- $.add(t.name, t);
605
- else if (t instanceof g && i.length > 1) {
606
- const s = [];
607
- i.forEach((n, r) => {
608
- if (!(n instanceof g))
627
+ if (typeof t == "string" && e instanceof p && i.length === 2)
628
+ return b.add(t, e), e;
629
+ if (t instanceof p && typeof e == "string" && i.length === 2)
630
+ return b.add(e, t), t;
631
+ if (t instanceof p && i.length === 1)
632
+ return b.add(t.name, t), t;
633
+ if (t instanceof p && e === void 0 && i.length === 2)
634
+ return b.add(t.name, t), t;
635
+ if (t instanceof p && i.length > 1) {
636
+ const r = [];
637
+ i.forEach((n, s) => {
638
+ if (!(n instanceof p))
609
639
  throw new Error(
610
- `registerAsset variadic argument at index ${r} must be an Asset`
640
+ `registerAsset variadic argument at index ${s} must be an Asset`
611
641
  );
612
- s.push(n);
613
- }), s.forEach((n) => {
614
- $.add(n.name, n);
642
+ r.push(n);
643
+ }), r.forEach((n) => {
644
+ b.add(n.name, n);
615
645
  });
646
+ return;
616
647
  } else
617
648
  throw new Error(
618
649
  "registerAsset requires either (name, asset), (asset), (asset, overrideName), or (...assets)"
619
650
  );
620
651
  }
621
- function J(i, t, e = "") {
622
- return d.init({
652
+ function Q(i, t, e = "") {
653
+ return g.init({
623
654
  default: i,
624
655
  light: i,
625
656
  dark: t,
626
657
  name: e
627
658
  });
628
659
  }
629
- function Q(i, t, e, s = "", n) {
660
+ function Y(i, t, e, r = "", n) {
630
661
  return F.init({
631
662
  default: i,
632
663
  light: t,
633
664
  dark: e,
634
- name: s,
665
+ name: r,
635
666
  options: n
636
667
  });
637
668
  }
638
- function Y(i, t = [], e = "", s) {
639
- return y.init(i, t, e, s);
669
+ function Z(i, t = [], e = "", r) {
670
+ return w.init(i, t, e, r);
640
671
  }
641
- function Z() {
642
- const i = $.getAll(), t = [];
643
- for (const [e, s] of i) {
672
+ function _() {
673
+ const i = b.getAll(), t = [];
674
+ for (const [e, r] of i) {
644
675
  let n = "custom";
645
- s instanceof d ? n = "color" : s instanceof F ? n = "image" : s instanceof y && (n = "font"), t.push({
676
+ r instanceof g ? n = "color" : r instanceof F ? n = "image" : r instanceof w && (n = "font"), t.push({
646
677
  name: e,
647
678
  type: n,
648
- asset: s
679
+ asset: r
649
680
  });
650
681
  }
651
- return t.sort((e, s) => e.name.localeCompare(s.name));
682
+ return t.sort((e, r) => e.name.localeCompare(r.name));
652
683
  }
653
- function _() {
654
- return Array.from($.getAll().keys()).sort();
684
+ function tt(i) {
685
+ return b.get(i);
686
+ }
687
+ function k(i) {
688
+ if (i instanceof g)
689
+ return !0;
690
+ if (!i || typeof i != "object")
691
+ return !1;
692
+ const t = i;
693
+ return typeof t.resolve == "function" && typeof t.opacity == "function" && typeof t.saturate == "function" && typeof t.brighten == "function" && typeof t.contrast == "function" && typeof t.rotateHue == "function";
694
+ }
695
+ function et(i) {
696
+ const t = N[i];
697
+ return k(t) ? t : void 0;
698
+ }
699
+ function rt(i, t = "asset") {
700
+ if (!k(i))
701
+ throw new Error(`Asset "${t}" is not a ColorAsset`);
702
+ return i;
703
+ }
704
+ function st() {
705
+ return Array.from(b.getAll().keys()).sort();
655
706
  }
656
- p(d.init({
707
+ $(g.init({
657
708
  default: "#007AFF",
658
709
  light: "#007AFF",
659
710
  dark: "#0A84FF",
660
711
  name: "systemBlue"
661
712
  }));
662
- p(d.init({
713
+ $(g.init({
663
714
  default: "#34C759",
664
715
  light: "#34C759",
665
716
  dark: "#30D158",
666
717
  name: "systemGreen"
667
718
  }));
668
- p(d.init({
719
+ $(g.init({
669
720
  default: "#FF3B30",
670
721
  light: "#FF3B30",
671
722
  dark: "#FF453A",
672
723
  name: "systemRed"
673
724
  }));
674
- p(d.init({
725
+ $(g.init({
675
726
  default: "#FF9500",
676
727
  light: "#FF9500",
677
728
  dark: "#FF9F0A",
678
729
  name: "systemOrange"
679
730
  }));
680
- p(d.init({
731
+ $(g.init({
681
732
  default: "#5856D6",
682
733
  light: "#5856D6",
683
734
  dark: "#5E5CE6",
684
735
  name: "systemPurple"
685
736
  }));
686
- p(d.init({
737
+ $(g.init({
687
738
  default: "#FF2D55",
688
739
  light: "#FF2D55",
689
740
  dark: "#FF375F",
690
741
  name: "systemPink"
691
742
  }));
692
- p(d.init({
743
+ $(g.init({
693
744
  default: "#8E8E93",
694
745
  name: "systemGray"
695
746
  }));
696
- p(d.init({
747
+ $(g.init({
697
748
  default: "#000000",
698
749
  name: "systemBlack"
699
750
  }));
700
- p(d.init({
751
+ $(g.init({
701
752
  default: "#FFFFFF",
702
753
  name: "systemWhite"
703
754
  }));
704
755
  export {
705
- g as Asset,
706
- K as Assets,
707
- d as ColorAsset,
708
- y as FontAsset,
709
- D as FontWeight,
710
- q as FontWidth,
756
+ p as Asset,
757
+ J as Assets,
758
+ g as ColorAsset,
759
+ w as FontAsset,
760
+ q as FontWeight,
761
+ z as FontWidth,
711
762
  F as ImageAsset,
712
- rt as LinearGradient,
713
- st as RadialGradient,
714
- nt as StateGradient,
763
+ it as LinearGradient,
764
+ ot as RadialGradient,
765
+ lt as StateGradient,
715
766
  R as SystemFonts,
716
- J as createColorAsset,
717
- Y as createFontAsset,
718
- U as createGoogleFont,
719
- Q as createImageAsset,
720
- z as createSystemFont,
721
- j as createVariableFont,
722
- Z as getAssetInfo,
723
- _ as listAssetNames,
724
- p as registerAsset
767
+ rt as asColorAsset,
768
+ Q as createColorAsset,
769
+ Z as createFontAsset,
770
+ j as createGoogleFont,
771
+ Y as createImageAsset,
772
+ U as createSystemFont,
773
+ K as createVariableFont,
774
+ tt as getAsset,
775
+ _ as getAssetInfo,
776
+ et as getColorAsset,
777
+ k as isColorAsset,
778
+ st as listAssetNames,
779
+ $ as registerAsset
725
780
  };