@projectwallace/css-design-tokens 0.5.0 → 0.7.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,1814 +1,85 @@
1
- import { analyze as Mt } from "@projectwallace/css-analyzer";
2
- import { convert as $t } from "css-time-sort";
3
- import { convert as kt } from "color-sorter";
4
- import { parse as re } from "css-tree";
5
- const Ke = 0, Ve = 1, We = 2, pe = 3, Ue = 4, Je = 5, Qe = 6, et = 7, tt = 8, rt = 9, nt = 10, W = 11, vt = /* @__PURE__ */ new Map([
6
- [Ke, "white"],
7
- [Ve, "black"],
8
- [We, "grey"],
9
- [pe, "red"],
10
- [Ue, "orange"],
11
- [Je, "yellow"],
12
- [Qe, "green"],
13
- [et, "cyan"],
14
- [tt, "blue"],
15
- [rt, "magenta"],
16
- [nt, "pink"],
17
- [W, "unknown"]
1
+ import { cssKeywords as Y, colorKeywords as F, namedColors as B, systemColors as G, colorFunctions as T, analyze as W } from "@projectwallace/css-analyzer";
2
+ import { convert as k } from "css-time-sort";
3
+ import { convert as K } from "color-sorter";
4
+ import { parse as d } from "css-tree";
5
+ import { ColorSpace as o, sRGB as M, XYZ_D65 as Z, XYZ_D50 as U, XYZ_ABS_D65 as V, Lab_D65 as J, Lab as Q, LCH as ee, sRGB_Linear as te, HSL as re, HWB as ne, HSV as le, P3_Linear as ie, P3 as se, A98RGB_Linear as oe, A98RGB as ue, ProPhoto_Linear as ae, ProPhoto as ce, REC_2020_Linear as fe, REC_2020 as pe, OKLab as me, OKLCH as he, OKLrab as ge, parse as _e } from "colorjs.io/fn";
6
+ const N = 0, L = 1, E = 2, b = 3, q = 4, C = 5, j = 6, z = 7, A = 8, I = 9, R = 10, _ = 11, de = /* @__PURE__ */ new Map([
7
+ [N, "white"],
8
+ [L, "black"],
9
+ [E, "grey"],
10
+ [b, "red"],
11
+ [q, "orange"],
12
+ [C, "yellow"],
13
+ [j, "green"],
14
+ [z, "cyan"],
15
+ [A, "blue"],
16
+ [I, "magenta"],
17
+ [R, "pink"],
18
+ [_, "unknown"]
18
19
  ]);
19
- function _t(t) {
20
- let e = /* @__PURE__ */ new Map();
21
- for (let r in t) {
22
- let n = W;
20
+ function ve(n) {
21
+ let t = /* @__PURE__ */ new Map();
22
+ for (let r in n) {
23
+ let e = _;
23
24
  if (!r.includes("var(") && !r.includes("calc(")) {
24
- let a = kt(r), { hue: i, saturation: s, lightness: l } = a;
25
- s < 10 && l === 100 ? n = Ke : s < 10 && l === 0 ? n = Ve : s < 5 ? n = We : i < 22 ? n = pe : i < 50 ? n = Ue : i < 72 ? n = Je : i < 144 ? n = Qe : i < 180 ? n = et : i < 250 ? n = tt : i < 300 ? n = rt : i < 350 ? n = nt : n = pe;
25
+ let s = K(r), { hue: l, saturation: i, lightness: m } = s;
26
+ i < 10 && m === 100 ? e = N : i < 10 && m === 0 ? e = L : i < 5 ? e = E : l < 22 ? e = b : l < 50 ? e = q : l < 72 ? e = C : l < 144 ? e = j : l < 180 ? e = z : l < 250 ? e = A : l < 300 ? e = I : l < 350 ? e = R : e = b;
26
27
  }
27
- e.has(n) ? e.get(n).push(r) : e.set(n, [r]);
28
+ t.has(e) ? t.get(e).push(r) : t.set(e, [r]);
28
29
  }
29
- return Array.from(e).sort(
30
- (r, n) => r[0] === W || n[0] === W ? -1 : n[1].length - r[1].length
30
+ return Array.from(t).sort(
31
+ (r, e) => r[0] === _ || e[0] === _ ? -1 : e[1].length - r[1].length
31
32
  );
32
33
  }
33
- class ne {
34
- set;
35
- constructor(e) {
36
- this.set = new Set(e);
37
- }
38
- has(e) {
39
- return this.set.has(e.toLowerCase());
40
- }
41
- }
42
- const $ = "com.projectwallace.css-authored-as";
43
- function he(t, e) {
44
- return t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
45
- }
46
- function S(t, e, r = [0, 0, 0]) {
47
- const n = he(t, e[0]), a = he(t, e[1]), i = he(t, e[2]);
48
- return r[0] = n, r[1] = a, r[2] = i, r;
49
- }
50
- function xt(t) {
51
- return U(t) === "string";
52
- }
53
- function U(t) {
54
- return (Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1] || "").toLowerCase();
55
- }
56
- function Bt(t, { precision: e = 16, unit: r }) {
57
- return C(t) ? "none" : (t = +Rt(t, e), t + (r ?? ""));
58
- }
59
- function C(t) {
60
- return t === null;
61
- }
62
- function Rt(t, e) {
63
- if (t === 0)
64
- return 0;
65
- let r = ~~t, n = 0;
66
- r && e && (n = ~~Math.log10(Math.abs(r)) + 1);
67
- const a = 10 ** (e - n);
68
- return Math.floor(t * a + 0.5) / a;
69
- }
70
- function St(t, e, r) {
71
- return isNaN(t) ? e : isNaN(e) ? t : t + (e - t) * r;
72
- }
73
- function Lt(t, e, r) {
74
- return (r - t) / (e - t);
75
- }
76
- function Oe(t, e, r) {
77
- return !t || !e || t === e || t[0] === e[0] && t[1] === e[1] || isNaN(r) || r === null ? r : St(e[0], e[1], Lt(t[0], t[1], r));
78
- }
79
- function Nt(t, e, r) {
80
- return Math.max(Math.min(r, e), t);
81
- }
82
- function Ot(t, e) {
83
- return Math.sign(t) === Math.sign(e) ? t : -t;
84
- }
85
- function It(t, e) {
86
- return Ot(Math.abs(t) ** e, t);
87
- }
88
- function $e(t, e) {
89
- if (t instanceof e)
90
- return !0;
91
- const r = e.name;
92
- for (; t; ) {
93
- const n = Object.getPrototypeOf(t), a = n?.constructor?.name;
94
- if (a === r)
95
- return !0;
96
- if (!a || a === "Object")
97
- return !1;
98
- t = n;
99
- }
100
- return !1;
101
- }
102
- class Ie {
103
- // Class properties - declared here so that type inference works
104
- type;
105
- coordMeta;
106
- coordRange;
107
- /** @type {[number, number]} */
108
- range;
109
- /**
110
- * @param {any} type
111
- * @param {import("./types.js").CoordMeta} coordMeta
112
- */
113
- constructor(e, r) {
114
- if (typeof e == "object" && (this.coordMeta = e), r && (this.coordMeta = r, this.coordRange = r.range ?? r.refRange), typeof e == "string") {
115
- let n = e.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);
116
- if (!n)
117
- throw new TypeError(`Cannot parse ${e} as a type definition.`);
118
- this.type = n.groups.type;
119
- let { min: a, max: i } = n.groups;
120
- (a || i) && (this.range = [+a, +i]);
121
- }
122
- }
123
- /** @returns {[number, number]} */
124
- get computedRange() {
125
- return this.range ? this.range : this.type === "<percentage>" ? this.percentageRange() : this.type === "<angle>" ? [0, 360] : null;
126
- }
127
- get unit() {
128
- return this.type === "<percentage>" ? "%" : this.type === "<angle>" ? "deg" : "";
129
- }
130
- /**
131
- * Map a number to the internal representation
132
- * @param {number} number
133
- */
134
- resolve(e) {
135
- if (this.type === "<angle>")
136
- return e;
137
- let r = this.computedRange, n = this.coordRange;
138
- return this.type === "<percentage>" && (n ??= this.percentageRange()), Oe(r, n, e);
139
- }
140
- /**
141
- * Serialize a number from the internal representation to a string
142
- * @param {number} number
143
- * @param {number} [precision]
144
- */
145
- serialize(e, r) {
146
- let n = this.type === "<percentage>" ? this.percentageRange(100) : this.computedRange, a = this.unit;
147
- return e = Oe(this.coordRange, n, e), Bt(e, { unit: a, precision: r });
148
- }
149
- toString() {
150
- let e = this.type;
151
- if (this.range) {
152
- let [r = "", n = ""] = this.range;
153
- e += `[${r},${n}]`;
154
- }
155
- return e;
156
- }
157
- /**
158
- * Returns a percentage range for values of this type
159
- * @param {number} scale
160
- * @returns {[number, number]}
161
- */
162
- percentageRange(e = 1) {
163
- let r;
164
- return this.coordMeta && this.coordMeta.range || this.coordRange && this.coordRange[0] >= 0 ? r = [0, 1] : r = [-1, 1], [r[0] * e, r[1] * e];
165
- }
166
- static get(e, ...r) {
167
- return $e(e, this) ? e : new this(e, ...r);
168
- }
169
- }
170
- const fe = Symbol("instance");
171
- class J {
172
- // Class properties - declared here so that type inference works
173
- type;
174
- name;
175
- spaceCoords;
176
- /** @type {Type[][]} */
177
- coords;
178
- /**
179
- * @param {FormatInterface} format
180
- * @param {ColorSpace} space
181
- */
182
- constructor(e, r = e.space) {
183
- e[fe] = this, this.type = "function", this.name = "color", Object.assign(this, e), this.space = r, this.type !== "custom" && (this.spaceCoords = Object.values(r.coords), this.coords || (this.coords = this.spaceCoords.map((n) => {
184
- let a = ["<number>", "<percentage>"];
185
- return n.type === "angle" && a.push("<angle>"), a;
186
- })), this.coords = this.coords.map(
187
- /** @param {string | string[] | Type[]} types */
188
- (n, a) => {
189
- let i = this.spaceCoords[a];
190
- return typeof n == "string" && (n = n.trim().split(/\s*\|\s*/)), n.map((s) => Ie.get(s, i));
191
- }
192
- ));
193
- }
194
- /**
195
- * @param {Coords} coords
196
- * @param {number} precision
197
- * @param {Type[]} types
198
- */
199
- serializeCoords(e, r, n) {
200
- return n = e.map((a, i) => Ie.get(n?.[i] ?? this.coords[i][0], this.spaceCoords[i])), e.map((a, i) => n[i].serialize(a, r));
201
- }
202
- /**
203
- * Validates the coordinates of a color against a format's coord grammar and
204
- * maps the coordinates to the range or refRange of the coordinates.
205
- * @param {Coords} coords
206
- * @param {[string, string, string]} types
207
- */
208
- coerceCoords(e, r) {
209
- return Object.entries(this.space.coords).map(([n, a], i) => {
210
- let s = e[i];
211
- if (C(s) || isNaN(s))
212
- return s;
213
- let l = r[i], o = this.coords[i].find((c) => c.type == l);
214
- if (!o) {
215
- let c = a.name || n;
216
- throw new TypeError(`${l ?? /** @type {any} */
217
- s?.raw ?? s} not allowed for ${c} in ${this.name}()`);
218
- }
219
- return s = o.resolve(s), o.range && (r[i] = o.toString()), s;
220
- });
221
- }
222
- /**
223
- * @returns {boolean | Required<FormatInterface>["serialize"]}
224
- */
225
- canSerialize() {
226
- return this.type === "function" || /** @type {any} */
227
- this.serialize;
228
- }
229
- /**
230
- * @param {Format | FormatInterface} format
231
- * @param {RemoveFirstElement<ConstructorParameters<typeof Format>>} args
232
- * @returns {Format}
233
- */
234
- static get(e, ...r) {
235
- return !e || $e(e, this) ? (
236
- /** @type {Format} */
237
- e
238
- ) : e[fe] ? e[fe] : new J(e, ...r);
239
- }
240
- }
241
- class zt {
242
- add(e, r, n) {
243
- if (typeof arguments[0] != "string") {
244
- for (var e in arguments[0])
245
- this.add(e, arguments[0][e], arguments[1]);
246
- return;
247
- }
248
- (Array.isArray(e) ? e : [e]).forEach(function(a) {
249
- this[a] = this[a] || [], r && this[a][n ? "unshift" : "push"](r);
250
- }, this);
251
- }
252
- run(e, r) {
253
- this[e] = this[e] || [], this[e].forEach(function(n) {
254
- n.call(r && r.context ? r.context : r, r);
255
- });
256
- }
257
- }
258
- const Q = new zt(), O = {
259
- // for compatibility, the four-digit chromaticity-derived ones everyone else uses
260
- D50: [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585],
261
- D65: [0.3127 / 0.329, 1, (1 - 0.3127 - 0.329) / 0.329]
262
- };
263
- function be(t) {
264
- return Array.isArray(t) ? t : O[t];
265
- }
266
- function ee(t, e, r, n = {}) {
267
- if (t = be(t), e = be(e), !t || !e)
268
- throw new TypeError(`Missing white point to convert ${t ? "" : "from"}${!t && !e ? "/" : ""}${e ? "" : "to"}`);
269
- if (t === e)
270
- return r;
271
- let a = { W1: t, W2: e, XYZ: r, options: n };
272
- if (Q.run("chromatic-adaptation-start", a), a.M || (a.W1 === O.D65 && a.W2 === O.D50 ? a.M = [
273
- [1.0479297925449969, 0.022946870601609652, -0.05019226628920524],
274
- [0.02962780877005599, 0.9904344267538799, -0.017073799063418826],
275
- [-0.009243040646204504, 0.015055191490298152, 0.7518742814281371]
276
- ] : a.W1 === O.D50 && a.W2 === O.D65 && (a.M = [
277
- [0.955473421488075, -0.02309845494876471, 0.06325924320057072],
278
- [-0.0283697093338637, 1.0099953980813041, 0.021041441191917323],
279
- [0.012314014864481998, -0.020507649298898964, 1.330365926242124]
280
- ])), Q.run("chromatic-adaptation-end", a), a.M)
281
- return S(a.XYZ, a.M);
282
- throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.");
283
- }
284
- const ze = {
285
- gamut_mapping: "css",
286
- precision: 5,
287
- deltaE: "76",
288
- // Default deltaE method
289
- verbose: globalThis?.process?.env?.NODE_ENV?.toLowerCase() !== "test",
290
- warn: function(e) {
291
- this.verbose && globalThis?.console?.warn?.(e);
292
- }
293
- };
294
- function at(t, e) {
295
- let r = {
296
- str: String(t)?.trim(),
297
- options: e
298
- };
299
- if (Q.run("parse-start", r), r.color)
300
- return r.color;
301
- r.parsed = Ct(r.str);
302
- let n, a = r.options ? r.options.parseMeta ?? r.options.meta : null;
303
- if (r.parsed) {
304
- let i = r.parsed.name, s, l, o = r.parsed.args, c = o.map((h, m) => r.parsed.argMeta[m]?.type);
305
- if (i === "color") {
306
- let h = o.shift();
307
- c.shift();
308
- let m = h.startsWith("--") ? h.substring(2) : `--${h}`, g = [h, m];
309
- if (s = u.findFormat({ name: i, id: g, type: "function" }), !s) {
310
- let k, p = h in u.registry ? h : m;
311
- if (p in u.registry) {
312
- let w = u.registry[p].formats?.color?.id;
313
- w && (k = `Did you mean ${t.replace("color(" + h, "color(" + w)}?`);
314
- }
315
- throw new TypeError(`Cannot parse ${r.str}. ` + (k ?? "Missing a plugin?"));
316
- }
317
- l = s.space, s.id.startsWith("--") && !h.startsWith("--") && ze.warn(`${l.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${h}).`), h.startsWith("--") && !s.id.startsWith("--") && ze.warn(`${l.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${h}).`);
318
- } else
319
- s = u.findFormat({ name: i, type: "function" }), l = s.space;
320
- a && Object.assign(a, { format: s, formatId: s.name, types: c, commas: r.parsed.commas });
321
- let f = 1;
322
- (s.alpha === !0 || r.parsed.lastAlpha) && (f = r.parsed.args.pop(), a && (a.alphaType = c.pop()));
323
- let d = s.coords.length;
324
- if (o.length !== d)
325
- throw new TypeError(`Expected ${d} coordinates for ${l.id} in ${r.str}), got ${o.length}`);
326
- o = s.coerceCoords(o, c), n = { spaceId: l.id, coords: o, alpha: f };
327
- } else
328
- for (let i of u.all)
329
- for (let s in i.formats) {
330
- let l = i.formats[s];
331
- if (l.type !== "custom" || l.test && !l.test(r.str))
332
- continue;
333
- l = i.getFormat(l);
334
- let o = l.parse(r.str);
335
- if (o) {
336
- a && Object.assign(a, { format: l, formatId: s }), n = o;
337
- break;
338
- }
339
- }
340
- if (!n)
341
- throw new TypeError(`Could not parse ${t} as a color. Missing a plugin?`);
342
- return n.alpha = C(n.alpha) ? n.alpha : n.alpha === void 0 ? 1 : Nt(0, n.alpha, 1), n;
343
- }
344
- const it = {
345
- "%": 0.01,
346
- deg: 1,
347
- grad: 0.9,
348
- rad: 180 / Math.PI,
349
- turn: 360
350
- }, te = {
351
- // Need to list calc(NaN) explicitly as otherwise its ending paren would terminate the function call
352
- function: /^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,
353
- number: /^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,
354
- unitValue: RegExp(`(${Object.keys(it).join("|")})$`),
355
- // NOTE The -+ are not just for prefix, but also for idents, and e+N notation!
356
- singleArgument: /\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g
357
- };
358
- function Et(t) {
359
- let e = {}, r = t.match(te.unitValue)?.[0], n = e.raw = t;
360
- return r ? (e.type = r === "%" ? "<percentage>" : "<angle>", e.unit = r, e.unitless = Number(n.slice(0, -r.length)), n = e.unitless * it[r]) : te.number.test(n) ? (n = Number(n), e.type = "<number>") : n === "none" ? n = null : n === "NaN" || n === "calc(NaN)" ? (n = NaN, e.type = "<number>") : e.type = "<ident>", { value: (
361
- /** @type {number} */
362
- n
363
- ), meta: (
364
- /** @type {ArgumentMeta} */
365
- e
366
- ) };
367
- }
368
- function Ct(t) {
369
- if (!t)
370
- return;
371
- t = t.trim();
372
- let e = t.match(te.function);
373
- if (e) {
374
- let r = [], n = [], a = !1, i = e[2].replace(te.singleArgument, (s, l) => {
375
- let { value: o, meta: c } = Et(l);
376
- return s.startsWith("/") && (a = !0), r.push(o), n.push(c), "";
377
- });
34
+ const u = "com.projectwallace.css-authored-as", a = "com.projectwallace.usage-count", be = "com.projectwallace.css-properties";
35
+ o.register(M);
36
+ o.register(Z);
37
+ o.register(U);
38
+ o.register(V);
39
+ o.register(J);
40
+ o.register(Q);
41
+ o.register(ee);
42
+ o.register(te);
43
+ o.register(re);
44
+ o.register(ne);
45
+ o.register(le);
46
+ o.register(ie);
47
+ o.register(se);
48
+ o.register(oe);
49
+ o.register(ue);
50
+ o.register(ae);
51
+ o.register(ce);
52
+ o.register(fe);
53
+ o.register(pe);
54
+ o.register(me);
55
+ o.register(he);
56
+ o.register(ge);
57
+ function h(n) {
58
+ let t = n.toLowerCase();
59
+ if (t === "transparent")
378
60
  return {
379
- name: e[1].toLowerCase(),
380
- args: r,
381
- argMeta: n,
382
- lastAlpha: a,
383
- commas: i.includes(","),
384
- rawName: e[1],
385
- rawArgs: e[2]
61
+ colorSpace: "srgb",
62
+ components: [0, 0, 0],
63
+ alpha: 0
386
64
  };
387
- }
388
- }
389
- function ye(t, e) {
390
- if (Array.isArray(t))
391
- return t.map((n) => ye(n, e));
392
- if (!t)
393
- throw new TypeError("Empty color reference");
394
- xt(t) && (t = at(t, e));
395
- let r = t.space || t.spaceId;
396
- return typeof r == "string" && (t.space = u.get(r)), t.alpha === void 0 && (t.alpha = 1), t;
397
- }
398
- const Dt = 75e-6;
399
- class u {
400
- constructor(e) {
401
- this.id = e.id, this.name = e.name, this.base = e.base ? u.get(e.base) : null, this.aliases = e.aliases, this.base && (this.fromBase = e.fromBase, this.toBase = e.toBase);
402
- let r = e.coords ?? this.base.coords;
403
- for (let a in r)
404
- "name" in r[a] || (r[a].name = a);
405
- this.coords = r;
406
- let n = e.white ?? this.base.white ?? "D65";
407
- this.white = be(n), this.formats = e.formats ?? {};
408
- for (let a in this.formats) {
409
- let i = this.formats[a];
410
- i.type ||= "function", i.name ||= a;
411
- }
412
- this.formats.color?.id || (this.formats.color = {
413
- ...this.formats.color ?? {},
414
- id: e.cssId || this.id
415
- }), e.gamutSpace ? this.gamutSpace = e.gamutSpace === "self" ? this : u.get(e.gamutSpace) : this.isPolar ? this.gamutSpace = this.base : this.gamutSpace = this, this.gamutSpace.isUnbounded && (this.inGamut = (a, i) => !0), this.referred = e.referred, Object.defineProperty(this, "path", {
416
- value: qt(this).reverse(),
417
- writable: !1,
418
- enumerable: !0,
419
- configurable: !0
420
- }), Q.run("colorspace-init-end", this);
421
- }
422
- inGamut(e, { epsilon: r = Dt } = {}) {
423
- if (!this.equals(this.gamutSpace))
424
- return e = this.to(this.gamutSpace, e), this.gamutSpace.inGamut(e, { epsilon: r });
425
- let n = Object.values(this.coords);
426
- return e.every((a, i) => {
427
- let s = n[i];
428
- if (s.type !== "angle" && s.range) {
429
- if (C(a))
430
- return !0;
431
- let [l, o] = s.range;
432
- return (l === void 0 || a >= l - r) && (o === void 0 || a <= o + r);
433
- }
434
- return !0;
435
- });
436
- }
437
- get isUnbounded() {
438
- return Object.values(this.coords).every((e) => !("range" in e));
439
- }
440
- get cssId() {
441
- return this.formats?.color?.id || this.id;
442
- }
443
- get isPolar() {
444
- for (let e in this.coords)
445
- if (this.coords[e].type === "angle")
446
- return !0;
447
- return !1;
448
- }
449
- /**
450
- * Lookup a format in this color space
451
- * @param {string | object | Format} format - Format id if string. If object, it's converted to a `Format` object and returned.
452
- * @returns {Format}
453
- */
454
- getFormat(e) {
455
- if (!e)
456
- return null;
457
- e === "default" ? e = Object.values(this.formats)[0] : typeof e == "string" && (e = this.formats[e]);
458
- let r = J.get(e, this);
459
- return r !== e && e.name in this.formats && (this.formats[e.name] = r), r;
460
- }
461
- /**
462
- * Check if this color space is the same as another color space reference.
463
- * Allows proxying color space objects and comparing color spaces with ids.
464
- * @param {string | ColorSpace} space ColorSpace object or id to compare to
465
- * @returns {boolean}
466
- */
467
- equals(e) {
468
- return e ? this === e || this.id === e || this.id === e.id : !1;
469
- }
470
- to(e, r) {
471
- if (arguments.length === 1) {
472
- const l = ye(e);
473
- [e, r] = [l.space, l.coords];
474
- }
475
- if (e = u.get(e), this.equals(e))
476
- return r;
477
- r = r.map((l) => C(l) ? 0 : l);
478
- let n = this.path, a = e.path, i, s;
479
- for (let l = 0; l < n.length && n[l].equals(a[l]); l++)
480
- i = n[l], s = l;
481
- if (!i)
482
- throw new Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);
483
- for (let l = n.length - 1; l > s; l--)
484
- r = n[l].toBase(r);
485
- for (let l = s + 1; l < a.length; l++)
486
- r = a[l].fromBase(r);
487
- return r;
488
- }
489
- from(e, r) {
490
- if (arguments.length === 1) {
491
- const n = ye(e);
492
- [e, r] = [n.space, n.coords];
493
- }
494
- return e = u.get(e), e.to(this, r);
495
- }
496
- toString() {
497
- return `${this.name} (${this.id})`;
498
- }
499
- getMinCoords() {
500
- let e = [];
501
- for (let r in this.coords) {
502
- let n = this.coords[r], a = n.range || n.refRange;
503
- e.push(a?.min ?? 0);
504
- }
505
- return e;
506
- }
507
- static registry = {};
508
- // Returns array of unique color spaces
509
- static get all() {
510
- return [...new Set(Object.values(u.registry))];
511
- }
512
- static register(e, r) {
513
- if (arguments.length === 1 && (r = arguments[0], e = r.id), r = this.get(r), this.registry[e] && this.registry[e] !== r)
514
- throw new Error(`Duplicate color space registration: '${e}'`);
515
- if (this.registry[e] = r, arguments.length === 1 && r.aliases)
516
- for (let n of r.aliases)
517
- this.register(n, r);
518
- return r;
519
- }
520
- /**
521
- * Lookup ColorSpace object by name
522
- * @param {ColorSpace | string} name
523
- */
524
- static get(e, ...r) {
525
- if (!e || $e(e, this))
526
- return e;
527
- if (U(e) === "string") {
528
- let a = u.registry[e.toLowerCase()];
529
- if (!a)
530
- throw new TypeError(`No color space found with id = "${e}"`);
531
- return a;
532
- }
533
- if (r.length)
534
- return u.get(...r);
535
- throw new TypeError(`${e} is not a valid color space`);
536
- }
537
- /**
538
- * Look up all color spaces for a format that matches certain criteria
539
- * @param {object | string} filters
540
- * @param {Array<ColorSpace>} [spaces=ColorSpace.all]
541
- * @returns {Format | null}
542
- */
543
- static findFormat(e, r = u.all) {
544
- if (!e)
545
- return null;
546
- typeof e == "string" && (e = { name: e });
547
- for (let n of r)
548
- for (let [a, i] of Object.entries(n.formats)) {
549
- i.name ??= a, i.type ??= "function";
550
- let s = (!e.name || i.name === e.name) && (!e.type || i.type === e.type);
551
- if (e.id) {
552
- let l = i.ids || [i.id], o = Array.isArray(e.id) ? e.id : [e.id];
553
- s &&= o.some((c) => l.includes(c));
554
- }
555
- if (s) {
556
- let l = J.get(i, n);
557
- return l !== i && (n.formats[i.name] = l), l;
558
- }
559
- }
560
- return null;
561
- }
562
- /**
563
- * Get metadata about a coordinate of a color space
564
- *
565
- * @static
566
- * @param {Array | string} ref
567
- * @param {ColorSpace | string} [workingSpace]
568
- * @return {Object}
569
- */
570
- static resolveCoord(e, r) {
571
- let n = U(e), a, i;
572
- if (n === "string" ? e.includes(".") ? [a, i] = e.split(".") : [a, i] = [, e] : Array.isArray(e) ? [a, i] = e : (a = e.space, i = e.coordId), a = u.get(a), a || (a = r), !a)
573
- throw new TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);
574
- if (n = U(i), n === "number" || n === "string" && i >= 0) {
575
- let o = Object.entries(a.coords)[i];
576
- if (o)
577
- return { space: a, id: o[0], index: i, ...o[1] };
578
- }
579
- a = u.get(a);
580
- let s = i.toLowerCase(), l = 0;
581
- for (let o in a.coords) {
582
- let c = a.coords[o];
583
- if (o.toLowerCase() === s || c.name?.toLowerCase() === s)
584
- return { space: a, id: o, index: l, ...c };
585
- l++;
586
- }
587
- throw new TypeError(`No "${i}" coordinate found in ${a.name}. Its coordinates are: ${Object.keys(a.coords).join(", ")}`);
588
- }
589
- static DEFAULT_FORMAT = {
590
- type: "functions",
591
- name: "color"
592
- };
593
- }
594
- function qt(t) {
595
- let e = [t];
596
- for (let r = t; r = r.base; )
597
- e.push(r);
598
- return e;
599
- }
600
- const L = new u({
601
- id: "xyz-d65",
602
- name: "XYZ D65",
603
- coords: {
604
- x: {
605
- refRange: [0, 1],
606
- name: "X"
607
- },
608
- y: {
609
- refRange: [0, 1],
610
- name: "Y"
611
- },
612
- z: {
613
- refRange: [0, 1],
614
- name: "Z"
615
- }
616
- },
617
- white: "D65",
618
- formats: {
619
- color: {
620
- ids: ["xyz-d65", "xyz"]
621
- }
622
- },
623
- aliases: ["xyz"]
624
- });
625
- class x extends u {
626
- /**
627
- * Creates a new RGB ColorSpace.
628
- * If coords are not specified, they will use the default RGB coords.
629
- * Instead of `fromBase()` and `toBase()` functions,
630
- * you can specify to/from XYZ matrices and have `toBase()` and `fromBase()` automatically generated.
631
- * @param {RGBOptions} options
632
- */
633
- constructor(e) {
634
- e.coords || (e.coords = {
635
- r: {
636
- range: [0, 1],
637
- name: "Red"
638
- },
639
- g: {
640
- range: [0, 1],
641
- name: "Green"
642
- },
643
- b: {
644
- range: [0, 1],
645
- name: "Blue"
646
- }
647
- }), e.base || (e.base = L), e.toXYZ_M && e.fromXYZ_M && (e.toBase ??= (r) => {
648
- let n = S(r, e.toXYZ_M);
649
- return this.white !== this.base.white && (n = ee(this.white, this.base.white, n)), n;
650
- }, e.fromBase ??= (r) => (r = ee(this.base.white, this.white, r), S(r, e.fromXYZ_M))), e.referred ??= "display", super(e);
651
- }
652
- }
653
- const ke = new u({
654
- id: "xyz-d50",
655
- name: "XYZ D50",
656
- white: "D50",
657
- base: L,
658
- fromBase: (t) => ee(L.white, "D50", t),
659
- toBase: (t) => ee("D50", L.white, t)
660
- }), Yt = 216 / 24389, Ee = 24 / 116, T = 24389 / 27;
661
- let de = O.D50;
662
- const st = new u({
663
- id: "lab",
664
- name: "Lab",
665
- coords: {
666
- l: {
667
- refRange: [0, 100],
668
- name: "Lightness"
669
- },
670
- a: {
671
- refRange: [-125, 125]
672
- },
673
- b: {
674
- refRange: [-125, 125]
675
- }
676
- },
677
- // Assuming XYZ is relative to D50, convert to CIE Lab
678
- // from CIE standard, which now defines these as a rational fraction
679
- white: de,
680
- base: ke,
681
- // Convert D50-adapted XYX to Lab
682
- // CIE 15.3:2004 section 8.2.1.1
683
- fromBase(t) {
684
- let r = t.map((s, l) => s / de[l]).map((s) => s > Yt ? Math.cbrt(s) : (T * s + 16) / 116), n = 116 * r[1] - 16, a = 500 * (r[0] - r[1]), i = 200 * (r[1] - r[2]);
685
- return [n, a, i];
686
- },
687
- // Convert Lab to D50-adapted XYZ
688
- // Same result as CIE 15.3:2004 Appendix D although the derivation is different
689
- // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
690
- toBase(t) {
691
- let [e, r, n] = t, a = [];
692
- return a[1] = (e + 16) / 116, a[0] = r / 500 + a[1], a[2] = a[1] - n / 200, [
693
- a[0] > Ee ? Math.pow(a[0], 3) : (116 * a[0] - 16) / T,
694
- t[0] > 8 ? Math.pow((t[0] + 16) / 116, 3) : t[0] / T,
695
- a[2] > Ee ? Math.pow(a[2], 3) : (116 * a[2] - 16) / T
696
- ].map((s, l) => s * de[l]);
697
- },
698
- formats: {
699
- lab: {
700
- coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <percentage>"]
701
- }
702
- }
703
- });
704
- function ve(t) {
705
- return typeof t != "number" ? t : (t % 360 + 360) % 360;
706
- }
707
- const we = new u({
708
- id: "lch",
709
- name: "LCH",
710
- coords: {
711
- l: {
712
- refRange: [0, 100],
713
- name: "Lightness"
714
- },
715
- c: {
716
- refRange: [0, 150],
717
- name: "Chroma"
718
- },
719
- h: {
720
- refRange: [0, 360],
721
- type: "angle",
722
- name: "Hue"
723
- }
724
- },
725
- base: st,
726
- fromBase(t) {
727
- if (this.ε === void 0) {
728
- let l = Object.values(this.base.coords)[1].refRange, o = l[1] - l[0];
729
- this.ε = o / 1e5;
730
- }
731
- let [e, r, n] = t, a = Math.abs(r) < this.ε && Math.abs(n) < this.ε, i = a ? null : ve(Math.atan2(n, r) * 180 / Math.PI), s = a ? 0 : Math.sqrt(r ** 2 + n ** 2);
732
- return [e, s, i];
733
- },
734
- toBase(t) {
735
- let [e, r, n] = t, a = null, i = null;
736
- return C(n) || (r = r < 0 ? 0 : r, a = r * Math.cos(n * Math.PI / 180), i = r * Math.sin(n * Math.PI / 180)), [e, a, i];
737
- },
738
- formats: {
739
- lch: {
740
- coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
741
- }
742
- }
743
- }), Xt = [
744
- [0.819022437996703, 0.3619062600528904, -0.1288737815209879],
745
- [0.0329836539323885, 0.9292868615863434, 0.0361446663506424],
746
- [0.0481771893596242, 0.2642395317527308, 0.6335478284694309]
747
- ], At = [
748
- [1.2268798758459243, -0.5578149944602171, 0.2813910456659647],
749
- [-0.0405757452148008, 1.112286803280317, -0.0717110580655164],
750
- [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816]
751
- ], jt = [
752
- [0.210454268309314, 0.7936177747023054, -0.0040720430116193],
753
- [1.9779985324311684, -2.42859224204858, 0.450593709617411],
754
- [0.0259040424655478, 0.7827717124575296, -0.8086757549230774]
755
- ], N = [
756
- [1, 0.3963377773761749, 0.2158037573099136],
757
- [1, -0.1055613458156586, -0.0638541728258133],
758
- [1, -0.0894841775298119, -1.2914855480194092]
759
- ], ae = new u({
760
- id: "oklab",
761
- name: "Oklab",
762
- coords: {
763
- l: {
764
- refRange: [0, 1],
765
- name: "Lightness"
766
- },
767
- a: {
768
- refRange: [-0.4, 0.4]
769
- },
770
- b: {
771
- refRange: [-0.4, 0.4]
772
- }
773
- },
774
- // Note that XYZ is relative to D65
775
- white: "D65",
776
- base: L,
777
- fromBase(t) {
778
- let e = S(t, Xt);
779
- return e[0] = Math.cbrt(e[0]), e[1] = Math.cbrt(e[1]), e[2] = Math.cbrt(e[2]), S(e, jt, e);
780
- },
781
- toBase(t) {
782
- let e = S(t, N);
783
- return e[0] = e[0] ** 3, e[1] = e[1] ** 3, e[2] = e[2] ** 3, S(e, At, e);
784
- },
785
- formats: {
786
- oklab: {
787
- coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <percentage>"]
788
- }
789
- }
790
- }), Ce = 203, Zt = new u({
791
- // Absolute CIE XYZ, with a D65 whitepoint,
792
- // as used in most HDR colorspaces as a starting point.
793
- // SDR spaces are converted per BT.2048
794
- // so that diffuse, media white is 203 cd/m²
795
- id: "xyz-abs-d65",
796
- cssId: "--xyz-abs-d65",
797
- name: "Absolute XYZ D65",
798
- coords: {
799
- x: {
800
- refRange: [0, 9504.7],
801
- name: "Xa"
802
- },
803
- y: {
804
- refRange: [0, 1e4],
805
- name: "Ya"
806
- },
807
- z: {
808
- refRange: [0, 10888.3],
809
- name: "Za"
810
- }
811
- },
812
- base: L,
813
- fromBase(t) {
814
- return t.map((e) => Math.max(e * Ce, 0));
815
- },
816
- toBase(t) {
817
- return t.map((e) => Math.max(e / Ce, 0));
818
- }
819
- }), Pt = [
820
- [0.6369580483012914, 0.14461690358620832, 0.1688809751641721],
821
- [0.2627002120112671, 0.6779980715188708, 0.05930171646986196],
822
- [0, 0.028072693049087428, 1.060985057710791]
823
- ], Gt = [
824
- [1.716651187971268, -0.355670783776392, -0.25336628137366],
825
- [-0.666684351832489, 1.616481236634939, 0.0157685458139111],
826
- [0.017639857445311, -0.042770613257809, 0.942103121235474]
827
- ], lt = new x({
828
- id: "rec2020-linear",
829
- cssId: "--rec2020-linear",
830
- name: "Linear REC.2020",
831
- white: "D65",
832
- toXYZ_M: Pt,
833
- fromXYZ_M: Gt
834
- }), F = 1.09929682680944, De = 0.018053968510807, Ht = new x({
835
- id: "rec2020",
836
- name: "REC.2020",
837
- base: lt,
838
- // Non-linear transfer function from Rec. ITU-R BT.2020-2 table 4
839
- toBase(t) {
840
- return t.map(function(e) {
841
- return e < De * 4.5 ? e / 4.5 : Math.pow((e + F - 1) / F, 1 / 0.45);
842
- });
843
- },
844
- fromBase(t) {
845
- return t.map(function(e) {
846
- return e >= De ? F * Math.pow(e, 0.45) - (F - 1) : 4.5 * e;
847
- });
848
- }
849
- }), Tt = [
850
- [0.4865709486482162, 0.26566769316909306, 0.1982172852343625],
851
- [0.2289745640697488, 0.6917385218365064, 0.079286914093745],
852
- [0, 0.04511338185890264, 1.043944368900976]
853
- ], Ft = [
854
- [2.493496911941425, -0.9313836179191239, -0.40271078445071684],
855
- [-0.8294889695615747, 1.7626640603183463, 0.023624685841943577],
856
- [0.03584583024378447, -0.07617238926804182, 0.9568845240076872]
857
- ], ot = new x({
858
- id: "p3-linear",
859
- cssId: "--display-p3-linear",
860
- name: "Linear P3",
861
- white: "D65",
862
- toXYZ_M: Tt,
863
- fromXYZ_M: Ft
864
- }), Kt = [
865
- [0.41239079926595934, 0.357584339383878, 0.1804807884018343],
866
- [0.21263900587151027, 0.715168678767756, 0.07219231536073371],
867
- [0.01933081871559182, 0.11919477979462598, 0.9505321522496607]
868
- ], Vt = [
869
- [3.2409699419045226, -1.537383177570094, -0.4986107602930034],
870
- [-0.9692436362808796, 1.8759675015077202, 0.04155505740717559],
871
- [0.05563007969699366, -0.20397695888897652, 1.0569715142428786]
872
- ], ut = new x({
873
- id: "srgb-linear",
874
- name: "Linear sRGB",
875
- white: "D65",
876
- toXYZ_M: Kt,
877
- fromXYZ_M: Vt
878
- }), qe = {
879
- aliceblue: [240 / 255, 248 / 255, 1],
880
- antiquewhite: [250 / 255, 235 / 255, 215 / 255],
881
- aqua: [0, 1, 1],
882
- aquamarine: [127 / 255, 1, 212 / 255],
883
- azure: [240 / 255, 1, 1],
884
- beige: [245 / 255, 245 / 255, 220 / 255],
885
- bisque: [1, 228 / 255, 196 / 255],
886
- black: [0, 0, 0],
887
- blanchedalmond: [1, 235 / 255, 205 / 255],
888
- blue: [0, 0, 1],
889
- blueviolet: [138 / 255, 43 / 255, 226 / 255],
890
- brown: [165 / 255, 42 / 255, 42 / 255],
891
- burlywood: [222 / 255, 184 / 255, 135 / 255],
892
- cadetblue: [95 / 255, 158 / 255, 160 / 255],
893
- chartreuse: [127 / 255, 1, 0],
894
- chocolate: [210 / 255, 105 / 255, 30 / 255],
895
- coral: [1, 127 / 255, 80 / 255],
896
- cornflowerblue: [100 / 255, 149 / 255, 237 / 255],
897
- cornsilk: [1, 248 / 255, 220 / 255],
898
- crimson: [220 / 255, 20 / 255, 60 / 255],
899
- cyan: [0, 1, 1],
900
- darkblue: [0, 0, 139 / 255],
901
- darkcyan: [0, 139 / 255, 139 / 255],
902
- darkgoldenrod: [184 / 255, 134 / 255, 11 / 255],
903
- darkgray: [169 / 255, 169 / 255, 169 / 255],
904
- darkgreen: [0, 100 / 255, 0],
905
- darkgrey: [169 / 255, 169 / 255, 169 / 255],
906
- darkkhaki: [189 / 255, 183 / 255, 107 / 255],
907
- darkmagenta: [139 / 255, 0, 139 / 255],
908
- darkolivegreen: [85 / 255, 107 / 255, 47 / 255],
909
- darkorange: [1, 140 / 255, 0],
910
- darkorchid: [153 / 255, 50 / 255, 204 / 255],
911
- darkred: [139 / 255, 0, 0],
912
- darksalmon: [233 / 255, 150 / 255, 122 / 255],
913
- darkseagreen: [143 / 255, 188 / 255, 143 / 255],
914
- darkslateblue: [72 / 255, 61 / 255, 139 / 255],
915
- darkslategray: [47 / 255, 79 / 255, 79 / 255],
916
- darkslategrey: [47 / 255, 79 / 255, 79 / 255],
917
- darkturquoise: [0, 206 / 255, 209 / 255],
918
- darkviolet: [148 / 255, 0, 211 / 255],
919
- deeppink: [1, 20 / 255, 147 / 255],
920
- deepskyblue: [0, 191 / 255, 1],
921
- dimgray: [105 / 255, 105 / 255, 105 / 255],
922
- dimgrey: [105 / 255, 105 / 255, 105 / 255],
923
- dodgerblue: [30 / 255, 144 / 255, 1],
924
- firebrick: [178 / 255, 34 / 255, 34 / 255],
925
- floralwhite: [1, 250 / 255, 240 / 255],
926
- forestgreen: [34 / 255, 139 / 255, 34 / 255],
927
- fuchsia: [1, 0, 1],
928
- gainsboro: [220 / 255, 220 / 255, 220 / 255],
929
- ghostwhite: [248 / 255, 248 / 255, 1],
930
- gold: [1, 215 / 255, 0],
931
- goldenrod: [218 / 255, 165 / 255, 32 / 255],
932
- gray: [128 / 255, 128 / 255, 128 / 255],
933
- green: [0, 128 / 255, 0],
934
- greenyellow: [173 / 255, 1, 47 / 255],
935
- grey: [128 / 255, 128 / 255, 128 / 255],
936
- honeydew: [240 / 255, 1, 240 / 255],
937
- hotpink: [1, 105 / 255, 180 / 255],
938
- indianred: [205 / 255, 92 / 255, 92 / 255],
939
- indigo: [75 / 255, 0, 130 / 255],
940
- ivory: [1, 1, 240 / 255],
941
- khaki: [240 / 255, 230 / 255, 140 / 255],
942
- lavender: [230 / 255, 230 / 255, 250 / 255],
943
- lavenderblush: [1, 240 / 255, 245 / 255],
944
- lawngreen: [124 / 255, 252 / 255, 0],
945
- lemonchiffon: [1, 250 / 255, 205 / 255],
946
- lightblue: [173 / 255, 216 / 255, 230 / 255],
947
- lightcoral: [240 / 255, 128 / 255, 128 / 255],
948
- lightcyan: [224 / 255, 1, 1],
949
- lightgoldenrodyellow: [250 / 255, 250 / 255, 210 / 255],
950
- lightgray: [211 / 255, 211 / 255, 211 / 255],
951
- lightgreen: [144 / 255, 238 / 255, 144 / 255],
952
- lightgrey: [211 / 255, 211 / 255, 211 / 255],
953
- lightpink: [1, 182 / 255, 193 / 255],
954
- lightsalmon: [1, 160 / 255, 122 / 255],
955
- lightseagreen: [32 / 255, 178 / 255, 170 / 255],
956
- lightskyblue: [135 / 255, 206 / 255, 250 / 255],
957
- lightslategray: [119 / 255, 136 / 255, 153 / 255],
958
- lightslategrey: [119 / 255, 136 / 255, 153 / 255],
959
- lightsteelblue: [176 / 255, 196 / 255, 222 / 255],
960
- lightyellow: [1, 1, 224 / 255],
961
- lime: [0, 1, 0],
962
- limegreen: [50 / 255, 205 / 255, 50 / 255],
963
- linen: [250 / 255, 240 / 255, 230 / 255],
964
- magenta: [1, 0, 1],
965
- maroon: [128 / 255, 0, 0],
966
- mediumaquamarine: [102 / 255, 205 / 255, 170 / 255],
967
- mediumblue: [0, 0, 205 / 255],
968
- mediumorchid: [186 / 255, 85 / 255, 211 / 255],
969
- mediumpurple: [147 / 255, 112 / 255, 219 / 255],
970
- mediumseagreen: [60 / 255, 179 / 255, 113 / 255],
971
- mediumslateblue: [123 / 255, 104 / 255, 238 / 255],
972
- mediumspringgreen: [0, 250 / 255, 154 / 255],
973
- mediumturquoise: [72 / 255, 209 / 255, 204 / 255],
974
- mediumvioletred: [199 / 255, 21 / 255, 133 / 255],
975
- midnightblue: [25 / 255, 25 / 255, 112 / 255],
976
- mintcream: [245 / 255, 1, 250 / 255],
977
- mistyrose: [1, 228 / 255, 225 / 255],
978
- moccasin: [1, 228 / 255, 181 / 255],
979
- navajowhite: [1, 222 / 255, 173 / 255],
980
- navy: [0, 0, 128 / 255],
981
- oldlace: [253 / 255, 245 / 255, 230 / 255],
982
- olive: [128 / 255, 128 / 255, 0],
983
- olivedrab: [107 / 255, 142 / 255, 35 / 255],
984
- orange: [1, 165 / 255, 0],
985
- orangered: [1, 69 / 255, 0],
986
- orchid: [218 / 255, 112 / 255, 214 / 255],
987
- palegoldenrod: [238 / 255, 232 / 255, 170 / 255],
988
- palegreen: [152 / 255, 251 / 255, 152 / 255],
989
- paleturquoise: [175 / 255, 238 / 255, 238 / 255],
990
- palevioletred: [219 / 255, 112 / 255, 147 / 255],
991
- papayawhip: [1, 239 / 255, 213 / 255],
992
- peachpuff: [1, 218 / 255, 185 / 255],
993
- peru: [205 / 255, 133 / 255, 63 / 255],
994
- pink: [1, 192 / 255, 203 / 255],
995
- plum: [221 / 255, 160 / 255, 221 / 255],
996
- powderblue: [176 / 255, 224 / 255, 230 / 255],
997
- purple: [128 / 255, 0, 128 / 255],
998
- rebeccapurple: [102 / 255, 51 / 255, 153 / 255],
999
- red: [1, 0, 0],
1000
- rosybrown: [188 / 255, 143 / 255, 143 / 255],
1001
- royalblue: [65 / 255, 105 / 255, 225 / 255],
1002
- saddlebrown: [139 / 255, 69 / 255, 19 / 255],
1003
- salmon: [250 / 255, 128 / 255, 114 / 255],
1004
- sandybrown: [244 / 255, 164 / 255, 96 / 255],
1005
- seagreen: [46 / 255, 139 / 255, 87 / 255],
1006
- seashell: [1, 245 / 255, 238 / 255],
1007
- sienna: [160 / 255, 82 / 255, 45 / 255],
1008
- silver: [192 / 255, 192 / 255, 192 / 255],
1009
- skyblue: [135 / 255, 206 / 255, 235 / 255],
1010
- slateblue: [106 / 255, 90 / 255, 205 / 255],
1011
- slategray: [112 / 255, 128 / 255, 144 / 255],
1012
- slategrey: [112 / 255, 128 / 255, 144 / 255],
1013
- snow: [1, 250 / 255, 250 / 255],
1014
- springgreen: [0, 1, 127 / 255],
1015
- steelblue: [70 / 255, 130 / 255, 180 / 255],
1016
- tan: [210 / 255, 180 / 255, 140 / 255],
1017
- teal: [0, 128 / 255, 128 / 255],
1018
- thistle: [216 / 255, 191 / 255, 216 / 255],
1019
- tomato: [1, 99 / 255, 71 / 255],
1020
- turquoise: [64 / 255, 224 / 255, 208 / 255],
1021
- violet: [238 / 255, 130 / 255, 238 / 255],
1022
- wheat: [245 / 255, 222 / 255, 179 / 255],
1023
- white: [1, 1, 1],
1024
- whitesmoke: [245 / 255, 245 / 255, 245 / 255],
1025
- yellow: [1, 1, 0],
1026
- yellowgreen: [154 / 255, 205 / 255, 50 / 255]
1027
- };
1028
- let Ye = Array(3).fill("<percentage> | <number>[0, 255]"), Xe = Array(3).fill("<number>[0, 255]");
1029
- const H = new x({
1030
- id: "srgb",
1031
- name: "sRGB",
1032
- base: ut,
1033
- fromBase: (t) => t.map((e) => {
1034
- let r = e < 0 ? -1 : 1, n = e * r;
1035
- return n > 31308e-7 ? r * (1.055 * n ** (1 / 2.4) - 0.055) : 12.92 * e;
1036
- }),
1037
- toBase: (t) => t.map((e) => {
1038
- let r = e < 0 ? -1 : 1, n = e * r;
1039
- return n <= 0.04045 ? e / 12.92 : r * ((n + 0.055) / 1.055) ** 2.4;
1040
- }),
1041
- formats: {
1042
- rgb: {
1043
- coords: Ye
1044
- },
1045
- rgb_number: {
1046
- name: "rgb",
1047
- commas: !0,
1048
- coords: Xe,
1049
- alpha: !1
1050
- },
1051
- color: {
1052
- /* use defaults */
1053
- },
1054
- rgba: {
1055
- coords: Ye,
1056
- commas: !0,
1057
- alpha: !0
1058
- },
1059
- rgba_number: {
1060
- name: "rgba",
1061
- commas: !0,
1062
- coords: Xe
1063
- },
1064
- hex: {
1065
- type: "custom",
1066
- toGamut: !0,
1067
- test: (t) => /^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(t),
1068
- parse(t) {
1069
- t.length <= 5 && (t = t.replace(/[a-f0-9]/gi, "$&$&"));
1070
- let e = [];
1071
- return t.replace(/[a-f0-9]{2}/gi, (r) => {
1072
- e.push(parseInt(r, 16) / 255);
1073
- }), {
1074
- spaceId: "srgb",
1075
- coords: (
1076
- /** @type {Coords} */
1077
- e.slice(0, 3)
1078
- ),
1079
- alpha: (
1080
- /** @type {number} */
1081
- e.slice(3)[0]
1082
- )
1083
- };
1084
- },
1085
- serialize: (t, e, {
1086
- collapse: r = !0,
1087
- // collapse to 3-4 digit hex when possible?
1088
- alpha: n
1089
- } = {}) => {
1090
- (n !== !1 && e < 1 || n === !0) && t.push(e), t = /** @type {[number, number, number]} */
1091
- t.map((s) => Math.round(s * 255));
1092
- let a = r && t.every((s) => s % 17 === 0);
1093
- return "#" + t.map((s) => a ? (s / 17).toString(16) : s.toString(16).padStart(2, "0")).join("");
1094
- }
1095
- },
1096
- keyword: {
1097
- type: "custom",
1098
- test: (t) => /^[a-z]+$/i.test(t),
1099
- parse(t) {
1100
- t = t.toLowerCase();
1101
- let e = { spaceId: "srgb", coords: null, alpha: 1 };
1102
- if (t === "transparent" ? (e.coords = qe.black, e.alpha = 0) : e.coords = qe[t], e.coords)
1103
- return e;
1104
- }
1105
- }
1106
- }
1107
- }), Wt = new x({
1108
- id: "p3",
1109
- cssId: "display-p3",
1110
- name: "P3",
1111
- base: ot,
1112
- // Gamma encoding/decoding is the same as sRGB
1113
- fromBase: H.fromBase,
1114
- toBase: H.toBase
1115
- }), Ut = 216 / 24389, Ae = 24 / 116, K = 24389 / 27;
1116
- let me = O.D65;
1117
- const Jt = new u({
1118
- id: "lab-d65",
1119
- name: "Lab D65",
1120
- coords: {
1121
- l: {
1122
- refRange: [0, 100],
1123
- name: "Lightness"
1124
- },
1125
- a: {
1126
- refRange: [-125, 125]
1127
- },
1128
- b: {
1129
- refRange: [-125, 125]
1130
- }
1131
- },
1132
- // Assuming XYZ is relative to D65, convert to CIE Lab
1133
- // from CIE standard, which now defines these as a rational fraction
1134
- white: me,
1135
- base: L,
1136
- // Convert D65-adapted XYZ to Lab
1137
- // CIE 15.3:2004 section 8.2.1.1
1138
- fromBase(t) {
1139
- let r = t.map((n, a) => n / me[a]).map((n) => n > Ut ? Math.cbrt(n) : (K * n + 16) / 116);
1140
- return [
1141
- 116 * r[1] - 16,
1142
- // L
1143
- 500 * (r[0] - r[1]),
1144
- // a
1145
- 200 * (r[1] - r[2])
1146
- // b
1147
- ];
1148
- },
1149
- // Convert Lab to D65-adapted XYZ
1150
- // Same result as CIE 15.3:2004 Appendix D although the derivation is different
1151
- // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
1152
- toBase(t) {
1153
- let e = [];
1154
- return e[1] = (t[0] + 16) / 116, e[0] = t[1] / 500 + e[1], e[2] = e[1] - t[2] / 200, [
1155
- e[0] > Ae ? Math.pow(e[0], 3) : (116 * e[0] - 16) / K,
1156
- t[0] > 8 ? Math.pow((t[0] + 16) / 116, 3) : t[0] / K,
1157
- e[2] > Ae ? Math.pow(e[2], 3) : (116 * e[2] - 16) / K
1158
- ].map((n, a) => n * me[a]);
1159
- },
1160
- formats: {
1161
- "lab-d65": {
1162
- coords: ["<number> | <percentage>", "<number> | <percentage>", "<number> | <percentage>"]
1163
- }
1164
- }
1165
- }), Qt = new u({
1166
- id: "hsl",
1167
- name: "HSL",
1168
- coords: {
1169
- h: {
1170
- refRange: [0, 360],
1171
- type: "angle",
1172
- name: "Hue"
1173
- },
1174
- s: {
1175
- range: [0, 100],
1176
- name: "Saturation"
1177
- },
1178
- l: {
1179
- range: [0, 100],
1180
- name: "Lightness"
1181
- }
1182
- },
1183
- base: H,
1184
- // Adapted from https://drafts.csswg.org/css-color-4/better-rgbToHsl.js
1185
- fromBase: (t) => {
1186
- let e = Math.max(...t), r = Math.min(...t), [n, a, i] = t, [s, l, o] = [null, 0, (r + e) / 2], c = e - r;
1187
- if (c !== 0) {
1188
- switch (l = o === 0 || o === 1 ? 0 : (e - o) / Math.min(o, 1 - o), e) {
1189
- case n:
1190
- s = (a - i) / c + (a < i ? 6 : 0);
1191
- break;
1192
- case a:
1193
- s = (i - n) / c + 2;
1194
- break;
1195
- case i:
1196
- s = (n - a) / c + 4;
1197
- }
1198
- s = s * 60;
1199
- }
1200
- return l < 0 && (s += 180, l = Math.abs(l)), s >= 360 && (s -= 360), [s, l * 100, o * 100];
1201
- },
1202
- // Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative
1203
- toBase: (t) => {
1204
- let [e, r, n] = t;
1205
- e = e % 360, e < 0 && (e += 360), r /= 100, n /= 100;
1206
- function a(i) {
1207
- let s = (i + e / 30) % 12, l = r * Math.min(n, 1 - n);
1208
- return n - l * Math.max(-1, Math.min(s - 3, 9 - s, 1));
1209
- }
1210
- return [a(0), a(8), a(4)];
1211
- },
1212
- formats: {
1213
- hsl: {
1214
- coords: ["<number> | <angle>", "<percentage>", "<percentage>"]
1215
- },
1216
- hsla: {
1217
- coords: ["<number> | <angle>", "<percentage>", "<percentage>"],
1218
- commas: !0,
1219
- alpha: !0
1220
- }
1221
- }
1222
- }), ct = new u({
1223
- id: "hsv",
1224
- name: "HSV",
1225
- coords: {
1226
- h: {
1227
- refRange: [0, 360],
1228
- type: "angle",
1229
- name: "Hue"
1230
- },
1231
- s: {
1232
- range: [0, 100],
1233
- name: "Saturation"
1234
- },
1235
- v: {
1236
- range: [0, 100],
1237
- name: "Value"
1238
- }
1239
- },
1240
- base: H,
1241
- // https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
1242
- fromBase(t) {
1243
- let e = Math.max(...t), r = Math.min(...t), [n, a, i] = t, [s, l, o] = [null, 0, e], c = e - r;
1244
- if (c !== 0) {
1245
- switch (e) {
1246
- case n:
1247
- s = (a - i) / c + (a < i ? 6 : 0);
1248
- break;
1249
- case a:
1250
- s = (i - n) / c + 2;
1251
- break;
1252
- case i:
1253
- s = (n - a) / c + 4;
1254
- }
1255
- s = s * 60;
1256
- }
1257
- return o && (l = c / o), s >= 360 && (s -= 360), [s, l * 100, o * 100];
1258
- },
1259
- // Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative
1260
- toBase(t) {
1261
- let [e, r, n] = t;
1262
- e = e % 360, e < 0 && (e += 360), r /= 100, n /= 100;
1263
- function a(i) {
1264
- let s = (i + e / 60) % 6;
1265
- return n - n * r * Math.max(0, Math.min(s, 4 - s, 1));
1266
- }
1267
- return [a(5), a(3), a(1)];
1268
- },
1269
- formats: {
1270
- color: {
1271
- id: "--hsv",
1272
- coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
1273
- }
1274
- }
1275
- }), er = new u({
1276
- id: "hwb",
1277
- name: "HWB",
1278
- coords: {
1279
- h: {
1280
- refRange: [0, 360],
1281
- type: "angle",
1282
- name: "Hue"
1283
- },
1284
- w: {
1285
- range: [0, 100],
1286
- name: "Whiteness"
1287
- },
1288
- b: {
1289
- range: [0, 100],
1290
- name: "Blackness"
1291
- }
1292
- },
1293
- base: ct,
1294
- fromBase(t) {
1295
- let [e, r, n] = t;
1296
- return [e, n * (100 - r) / 100, 100 - n];
1297
- },
1298
- toBase(t) {
1299
- let [e, r, n] = t;
1300
- r /= 100, n /= 100;
1301
- let a = r + n;
1302
- if (a >= 1) {
1303
- let l = r / a;
1304
- return [e, 0, l * 100];
1305
- }
1306
- let i = 1 - n, s = i === 0 ? 0 : 1 - r / i;
1307
- return [e, s * 100, i * 100];
1308
- },
1309
- formats: {
1310
- hwb: {
1311
- coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
1312
- }
1313
- }
1314
- }), tr = [
1315
- [0.5766690429101305, 0.1855582379065463, 0.1882286462349947],
1316
- [0.29734497525053605, 0.6273635662554661, 0.07529145849399788],
1317
- [0.02703136138641234, 0.07068885253582723, 0.9913375368376388]
1318
- ], rr = [
1319
- [2.0415879038107465, -0.5650069742788596, -0.34473135077832956],
1320
- [-0.9692436362808795, 1.8759675015077202, 0.04155505740717557],
1321
- [0.013444280632031142, -0.11836239223101838, 1.0151749943912054]
1322
- ], ht = new x({
1323
- id: "a98rgb-linear",
1324
- cssId: "--a98-rgb-linear",
1325
- name: "Linear Adobe® 98 RGB compatible",
1326
- white: "D65",
1327
- toXYZ_M: tr,
1328
- fromXYZ_M: rr
1329
- }), nr = new x({
1330
- id: "a98rgb",
1331
- cssId: "a98-rgb",
1332
- name: "Adobe® 98 RGB compatible",
1333
- base: ht,
1334
- toBase: (t) => t.map((e) => Math.pow(Math.abs(e), 563 / 256) * Math.sign(e)),
1335
- fromBase: (t) => t.map((e) => Math.pow(Math.abs(e), 256 / 563) * Math.sign(e))
1336
- }), ar = [
1337
- [0.7977666449006423, 0.13518129740053308, 0.0313477341283922],
1338
- [0.2880748288194013, 0.711835234241873, 8993693872564e-17],
1339
- [0, 0, 0.8251046025104602]
1340
- ], ir = [
1341
- [1.3457868816471583, -0.25557208737979464, -0.05110186497554526],
1342
- [-0.5446307051249019, 1.5082477428451468, 0.02052744743642139],
1343
- [0, 0, 1.2119675456389452]
1344
- ], ft = new x({
1345
- id: "prophoto-linear",
1346
- cssId: "--prophoto-rgb-linear",
1347
- name: "Linear ProPhoto",
1348
- white: "D50",
1349
- base: ke,
1350
- toXYZ_M: ar,
1351
- fromXYZ_M: ir
1352
- }), sr = 1 / 512, lr = 16 / 512, or = new x({
1353
- id: "prophoto",
1354
- cssId: "prophoto-rgb",
1355
- name: "ProPhoto",
1356
- base: ft,
1357
- toBase(t) {
1358
- return t.map((e) => e < lr ? e / 16 : e ** 1.8);
1359
- },
1360
- fromBase(t) {
1361
- return t.map((e) => e >= sr ? e ** (1 / 1.8) : 16 * e);
1362
- }
1363
- }), ur = new u({
1364
- id: "oklch",
1365
- name: "OkLCh",
1366
- coords: {
1367
- l: {
1368
- refRange: [0, 1],
1369
- name: "Lightness"
1370
- },
1371
- c: {
1372
- refRange: [0, 0.4],
1373
- name: "Chroma"
1374
- },
1375
- h: {
1376
- refRange: [0, 360],
1377
- type: "angle",
1378
- name: "Hue"
1379
- }
1380
- },
1381
- white: "D65",
1382
- base: ae,
1383
- fromBase: we.fromBase,
1384
- toBase: we.toBase,
1385
- formats: {
1386
- oklch: {
1387
- coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
1388
- }
1389
- }
1390
- }), Me = 2 * Math.PI, je = [
1391
- [4.076741636075958, -3.307711539258063, 0.2309699031821043],
1392
- [-1.2684379732850315, 2.609757349287688, -0.341319376002657],
1393
- [-0.0041960761386756, -0.7034186179359362, 1.7076146940746117]
1394
- ], Ze = [
1395
- // Red
1396
- [
1397
- // Limit
1398
- [-1.8817031, -0.80936501],
1399
- // `Kn` coefficients
1400
- [1.19086277, 1.76576728, 0.59662641, 0.75515197, 0.56771245]
1401
- ],
1402
- // Green
1403
- [
1404
- // Limit
1405
- [1.8144408, -1.19445267],
1406
- // `Kn` coefficients
1407
- [0.73956515, -0.45954404, 0.08285427, 0.12541073, -0.14503204]
1408
- ],
1409
- // Blue
1410
- [
1411
- // Limit
1412
- [0.13110758, 1.81333971],
1413
- // `Kn` coefficients
1414
- [1.35733652, -915799e-8, -1.1513021, -0.50559606, 692167e-8]
1415
- ]
1416
- ], ge = Number.MAX_VALUE, G = 0.206, _e = 0.03, P = (1 + G) / (1 + _e);
1417
- function y(t, e) {
1418
- let r = t.length;
1419
- if (r !== e.length)
1420
- throw new Error(`Vectors of size ${r} and ${e.length} are not aligned`);
1421
- let n = 0;
1422
- return t.forEach((a, i) => {
1423
- n += a * e[i];
1424
- }), n;
1425
- }
1426
- function dt(t) {
1427
- return 0.5 * (P * t - G + Math.sqrt((P * t - G) * (P * t - G) + 4 * _e * P * t));
1428
- }
1429
- function mt(t) {
1430
- return (t ** 2 + G * t) / (P * (t + _e));
1431
- }
1432
- function cr(t) {
1433
- let [e, r] = t;
1434
- return [r / e, r / (1 - e)];
1435
- }
1436
- function hr(t, e) {
1437
- let r = 0.11516993 + 1 / (7.4477897 + 4.1590124 * e + t * (-2.19557347 + 1.75198401 * e + t * (-2.13704948 - 10.02301043 * e + t * (-4.24894561 + 5.38770819 * e + 4.69891013 * t)))), n = 0.11239642 + 1 / (1.6132032 - 0.68124379 * e + t * (0.40370612 + 0.90148123 * e + t * (-0.27087943 + 0.6122399 * e + t * (299215e-8 - 0.45399568 * e - 0.14661872 * t))));
1438
- return [r, n];
1439
- }
1440
- function fr(t, e) {
1441
- let r = S(t, N);
1442
- return r[0] = r[0] ** 3, r[1] = r[1] ** 3, r[2] = r[2] ** 3, S(r, e, r);
1443
- }
1444
- function gt(t, e, r, n) {
1445
- let a = mr(t, e, r, n), i = fr([1, a * t, a * e], r), s = It(1 / Math.max(...i), 1 / 3), l = s * a;
1446
- return [s, l];
1447
- }
1448
- function dr(t, e, r, n, a, i, s, l) {
1449
- let o;
1450
- if (l === void 0 && (l = gt(t, e, i, s)), (r - a) * l[1] - (l[0] - a) * n <= 0)
1451
- o = l[1] * a / (n * l[0] + l[1] * (a - r));
1452
- else {
1453
- o = l[1] * (a - 1) / (n * (l[0] - 1) + l[1] * (a - r));
1454
- let c = r - a, f = n, d = y(N[0].slice(1), [t, e]), h = y(N[1].slice(1), [t, e]), m = y(N[2].slice(1), [t, e]), g = c + f * d, k = c + f * h, p = c + f * m, w = a * (1 - o) + o * r, b = o * n, M = w + b * d, v = w + b * h, _ = w + b * m, D = M ** 3, q = v ** 3, Y = _ ** 3, X = 3 * g * M ** 2, A = 3 * k * v ** 2, j = 3 * p * _ ** 2, I = 6 * g ** 2 * M, z = 6 * k ** 2 * v, Z = 6 * p ** 2 * _, xe = y(i[0], [D, q, Y]) - 1, ie = y(i[0], [X, A, j]), bt = y(i[0], [I, z, Z]), Be = ie / (ie * ie - 0.5 * xe * bt), se = -xe * Be, Re = y(i[1], [D, q, Y]) - 1, le = y(i[1], [X, A, j]), yt = y(i[1], [I, z, Z]), Se = le / (le * le - 0.5 * Re * yt), oe = -Re * Se, Le = y(i[2], [D, q, Y]) - 1, ue = y(i[2], [X, A, j]), wt = y(i[2], [I, z, Z]), Ne = ue / (ue * ue - 0.5 * Le * wt), ce = -Le * Ne;
1455
- se = Be >= 0 ? se : ge, oe = Se >= 0 ? oe : ge, ce = Ne >= 0 ? ce : ge, o += Math.min(se, Math.min(oe, ce));
1456
- }
1457
- return o;
1458
- }
1459
- function pt(t, e, r) {
1460
- let [n, a, i] = t, s = gt(a, i, e, r), l = dr(a, i, n, 1, n, e, r, s), o = cr(s), c = l / Math.min(n * o[0], (1 - n) * o[1]), f = hr(a, i), d = n * f[0], h = (1 - n) * f[1], m = 0.9 * c * Math.sqrt(Math.sqrt(1 / (1 / d ** 4 + 1 / h ** 4)));
1461
- return d = n * 0.4, h = (1 - n) * 0.8, [Math.sqrt(1 / (1 / d ** 2 + 1 / h ** 2)), m, l];
1462
- }
1463
- function mr(t, e, r, n) {
1464
- let a, i, s, l, o, c, f, d;
1465
- y(n[0][0], [t, e]) > 1 ? ([a, i, s, l, o] = n[0][1], [c, f, d] = r[0]) : y(n[1][0], [t, e]) > 1 ? ([a, i, s, l, o] = n[1][1], [c, f, d] = r[1]) : ([a, i, s, l, o] = n[2][1], [c, f, d] = r[2]);
1466
- let h = a + i * t + s * e + l * t ** 2 + o * t * e, m = y(N[0].slice(1), [t, e]), g = y(N[1].slice(1), [t, e]), k = y(N[2].slice(1), [t, e]), p = 1 + h * m, w = 1 + h * g, b = 1 + h * k, M = p ** 3, v = w ** 3, _ = b ** 3, D = 3 * m * p ** 2, q = 3 * g * w ** 2, Y = 3 * k * b ** 2, X = 6 * m ** 2 * p, A = 6 * g ** 2 * w, j = 6 * k ** 2 * b, I = c * M + f * v + d * _, z = c * D + f * q + d * Y, Z = c * X + f * A + d * j;
1467
- return h = h - I * z / (z ** 2 - 0.5 * I * Z), h;
1468
- }
1469
- function gr(t, e, r) {
1470
- let [n, a, i] = t, s = mt(i), l = null, o = null;
1471
- if (n = ve(n) / 360, s !== 0 && s !== 1 && a !== 0) {
1472
- let c = Math.cos(Me * n), f = Math.sin(Me * n), [d, h, m] = pt([s, c, f], e, r), g = 0.8, k = 1.25, p, w, b, M;
1473
- a < g ? (p = k * a, w = 0, b = g * d, M = 1 - b / h) : (p = 5 * (a - 0.8), w = h, b = 0.2 * h ** 2 * 1.25 ** 2 / d, M = 1 - b / (m - h));
1474
- let v = w + p * b / (1 - M * p);
1475
- l = v * c, o = v * f;
1476
- }
1477
- return [s, l, o];
1478
- }
1479
- function pr(t, e, r) {
1480
- let n = 1e-7, a = 1e-4, i = t[0], s = 0, l = dt(i), o = Math.sqrt(t[1] ** 2 + t[2] ** 2), c = 0.5 + Math.atan2(-t[2], -t[1]) / Me;
1481
- if (l !== 0 && l !== 1 && o !== 0) {
1482
- let d = t[1] / o, h = t[2] / o, [m, g, k] = pt([i, d, h], e, r), p = 0.8, w = 1.25, b, M, v, _;
1483
- o < g ? (M = p * m, v = 1 - M / g, _ = o / (M + v * o), s = _ * p) : (b = g, M = 0.2 * g ** 2 * w ** 2 / m, v = 1 - M / (k - g), _ = (o - b) / (M + v * (o - b)), s = p + 0.2 * _);
1484
- }
1485
- const f = Math.abs(s) < a;
1486
- return f || l === 0 || Math.abs(1 - l) < n ? (c = null, f || (s = 0)) : c = ve(c * 360), [c, s, l];
1487
- }
1488
- new u({
1489
- id: "okhsl",
1490
- name: "Okhsl",
1491
- coords: {
1492
- h: {
1493
- refRange: [0, 360],
1494
- type: "angle",
1495
- name: "Hue"
1496
- },
1497
- s: {
1498
- range: [0, 1],
1499
- name: "Saturation"
1500
- },
1501
- l: {
1502
- range: [0, 1],
1503
- name: "Lightness"
1504
- }
1505
- },
1506
- base: ae,
1507
- gamutSpace: "self",
1508
- // Convert Oklab to Okhsl
1509
- fromBase(t) {
1510
- return pr(t, je, Ze);
1511
- },
1512
- // Convert Okhsl to Oklab
1513
- toBase(t) {
1514
- return gr(t, je, Ze);
1515
- },
1516
- formats: {
1517
- color: {
1518
- id: "--okhsl",
1519
- coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
1520
- }
1521
- }
1522
- });
1523
- const br = new u({
1524
- id: "oklrab",
1525
- name: "Oklrab",
1526
- coords: {
1527
- l: {
1528
- refRange: [0, 1],
1529
- name: "Lightness"
1530
- },
1531
- a: {
1532
- refRange: [-0.4, 0.4]
1533
- },
1534
- b: {
1535
- refRange: [-0.4, 0.4]
1536
- }
1537
- },
1538
- // Note that XYZ is relative to D65
1539
- white: "D65",
1540
- base: ae,
1541
- fromBase(t) {
1542
- return [dt(t[0]), t[1], t[2]];
1543
- },
1544
- toBase(t) {
1545
- return [mt(t[0]), t[1], t[2]];
1546
- },
1547
- formats: {
1548
- color: {
1549
- coords: ["<percentage> | <number>", "<number> | <percentage>[-1,1]", "<number> | <percentage>[-1,1]"]
1550
- }
1551
- }
1552
- });
1553
- u.register(H);
1554
- u.register(L);
1555
- u.register(ke);
1556
- u.register(Zt);
1557
- u.register(Jt);
1558
- u.register(st);
1559
- u.register(we);
1560
- u.register(ut);
1561
- u.register(Qt);
1562
- u.register(er);
1563
- u.register(ct);
1564
- u.register(ot);
1565
- u.register(Wt);
1566
- u.register(ht);
1567
- u.register(nr);
1568
- u.register(ft);
1569
- u.register(or);
1570
- u.register(lt);
1571
- u.register(Ht);
1572
- u.register(ae);
1573
- u.register(ur);
1574
- u.register(br);
1575
- const yr = new ne([
1576
- // CSS Named Colors
1577
- // Spec: https://drafts.csswg.org/css-color/#named-colors
1578
- // Heuristic: popular names first for quick finding in set.has()
1579
- // See: https://docs.google.com/spreadsheets/d/1OU8ahxC5oYU8VRryQs9BzHToaXcOntVlh6KUHjm15G4/edit#gid=2096495459
1580
- "white",
1581
- "black",
1582
- "red",
1583
- "gray",
1584
- "silver",
1585
- "grey",
1586
- "green",
1587
- "orange",
1588
- "blue",
1589
- "dimgray",
1590
- "whitesmoke",
1591
- "lightgray",
1592
- "lightgrey",
1593
- "yellow",
1594
- "gold",
1595
- "pink",
1596
- "gainsboro",
1597
- "magenta",
1598
- "purple",
1599
- "darkgray",
1600
- "navy",
1601
- "darkred",
1602
- "teal",
1603
- "maroon",
1604
- "darkgrey",
1605
- "tomato",
1606
- "darkorange",
1607
- "brown",
1608
- "crimson",
1609
- "lightyellow",
1610
- "slategray",
1611
- "salmon",
1612
- "lightgreen",
1613
- "lightblue",
1614
- "orangered",
1615
- "aliceblue",
1616
- "dodgerblue",
1617
- "lime",
1618
- "darkblue",
1619
- "darkgoldenrod",
1620
- "skyblue",
1621
- "royalblue",
1622
- "darkgreen",
1623
- "ivory",
1624
- "olive",
1625
- "aqua",
1626
- "turquoise",
1627
- "cyan",
1628
- "khaki",
1629
- "beige",
1630
- "snow",
1631
- "ghostwhite",
1632
- "limegreen",
1633
- "coral",
1634
- "dimgrey",
1635
- "hotpink",
1636
- "midnightblue",
1637
- "firebrick",
1638
- "indigo",
1639
- "wheat",
1640
- "mediumblue",
1641
- "lightpink",
1642
- "plum",
1643
- "azure",
1644
- "violet",
1645
- "lavender",
1646
- "deepskyblue",
1647
- "darkslategrey",
1648
- "goldenrod",
1649
- "cornflowerblue",
1650
- "lightskyblue",
1651
- "indianred",
1652
- "yellowgreen",
1653
- "saddlebrown",
1654
- "palegreen",
1655
- "bisque",
1656
- "tan",
1657
- "antiquewhite",
1658
- "steelblue",
1659
- "forestgreen",
1660
- "fuchsia",
1661
- "mediumaquamarine",
1662
- "seagreen",
1663
- "sienna",
1664
- "deeppink",
1665
- "mediumseagreen",
1666
- "peru",
1667
- "greenyellow",
1668
- "lightgoldenrodyellow",
1669
- "orchid",
1670
- "cadetblue",
1671
- "navajowhite",
1672
- "lightsteelblue",
1673
- "slategrey",
1674
- "linen",
1675
- "lightseagreen",
1676
- "darkcyan",
1677
- "lightcoral",
1678
- "aquamarine",
1679
- "blueviolet",
1680
- "cornsilk",
1681
- "lightsalmon",
1682
- "chocolate",
1683
- "lightslategray",
1684
- "floralwhite",
1685
- "darkturquoise",
1686
- "darkslategray",
1687
- "rebeccapurple",
1688
- "burlywood",
1689
- "chartreuse",
1690
- "lightcyan",
1691
- "lemonchiffon",
1692
- "palevioletred",
1693
- "darkslateblue",
1694
- "mediumpurple",
1695
- "lawngreen",
1696
- "slateblue",
1697
- "darkseagreen",
1698
- "blanchedalmond",
1699
- "mistyrose",
1700
- "darkolivegreen",
1701
- "seashell",
1702
- "olivedrab",
1703
- "peachpuff",
1704
- "darkviolet",
1705
- "powderblue",
1706
- "darkmagenta",
1707
- "lightslategrey",
1708
- "honeydew",
1709
- "palegoldenrod",
1710
- "darkkhaki",
1711
- "oldlace",
1712
- "mintcream",
1713
- "sandybrown",
1714
- "mediumturquoise",
1715
- "papayawhip",
1716
- "paleturquoise",
1717
- "mediumvioletred",
1718
- "thistle",
1719
- "springgreen",
1720
- "moccasin",
1721
- "rosybrown",
1722
- "lavenderblush",
1723
- "mediumslateblue",
1724
- "darkorchid",
1725
- "mediumorchid",
1726
- "darksalmon",
1727
- "mediumspringgreen"
1728
- ]), wr = new ne([
1729
- // CSS System Colors
1730
- // Spec: https://drafts.csswg.org/css-color/#css-system-colors
1731
- "accentcolor",
1732
- "accentcolortext",
1733
- "activetext",
1734
- "buttonborder",
1735
- "buttonface",
1736
- "buttontext",
1737
- "canvas",
1738
- "canvastext",
1739
- "field",
1740
- "fieldtext",
1741
- "graytext",
1742
- "highlight",
1743
- "highlighttext",
1744
- "linktext",
1745
- "mark",
1746
- "marktext",
1747
- "selecteditem",
1748
- "selecteditemtext",
1749
- "visitedtext"
1750
- ]), Mr = new ne([
1751
- "rgba",
1752
- "rgb",
1753
- "hsla",
1754
- "hsl",
1755
- "oklch",
1756
- "color",
1757
- "hwb",
1758
- "lch",
1759
- "lab",
1760
- "oklab"
1761
- ]), $r = new ne([
1762
- "currentcolor",
1763
- "inherit",
1764
- "initial",
1765
- "unset",
1766
- "revert",
1767
- "revert-layer"
1768
- ]);
1769
- function E(t) {
1770
- let e = t.toLowerCase();
1771
- if (e === "transparent")
1772
- return {
1773
- $type: "color",
1774
- $value: {
1775
- colorSpace: "srgb",
1776
- components: [0, 0, 0],
1777
- alpha: 0
1778
- },
1779
- $extensions: {
1780
- [$]: t
1781
- }
1782
- };
1783
- if ($r.has(e) || e.includes("var("))
65
+ if (Y.has(t) || F.has(t) || t.includes("var("))
1784
66
  return null;
1785
67
  try {
1786
- let r = at(t), [n, a, i] = r.coords;
68
+ let r = _e(n), [e, s, l] = r.coords;
1787
69
  return {
1788
- $type: "color",
1789
- $value: {
1790
- colorSpace: r.spaceId,
1791
- components: [
1792
- n ?? "none",
1793
- a ?? "none",
1794
- i ?? "none"
1795
- ],
1796
- alpha: r.alpha ?? 0
1797
- },
1798
- $extensions: {
1799
- [$]: t
1800
- }
70
+ colorSpace: r.spaceId,
71
+ components: [
72
+ e ?? "none",
73
+ s ?? "none",
74
+ l ?? "none"
75
+ ],
76
+ alpha: r.alpha ?? 0
1801
77
  };
1802
78
  } catch {
1803
- return {
1804
- $value: t,
1805
- $extensions: {
1806
- [$]: t
1807
- }
1808
- };
79
+ return null;
1809
80
  }
1810
81
  }
1811
- function Pe() {
82
+ function x() {
1812
83
  return {
1813
84
  color: void 0,
1814
85
  offsetX: void 0,
@@ -1818,117 +89,117 @@ function Pe() {
1818
89
  inset: !1
1819
90
  };
1820
91
  }
1821
- function kr(t) {
1822
- let e = re(t, {
92
+ function $e(n) {
93
+ let t = d(n, {
1823
94
  context: "value",
1824
95
  positions: !0
1825
96
  });
1826
- function r(i) {
1827
- return i.loc ? t.slice(i.loc.start.offset, i.loc.end.offset) : "";
1828
- }
1829
- let n = Pe(), a = [n];
1830
- return e.children.size < 2 ? null : (e.children.forEach((i) => {
1831
- if (i.type === "Identifier") {
1832
- if (i.name.toLowerCase() === "inset")
1833
- n.inset = !0;
1834
- else if (yr.has(i.name) || wr.has(i.name)) {
1835
- let s = E(i.name);
1836
- if (s === null)
97
+ function r(l) {
98
+ return l.loc ? n.slice(l.loc.start.offset, l.loc.end.offset) : "";
99
+ }
100
+ let e = x(), s = [e];
101
+ return t.children.size < 2 ? null : (t.children.forEach((l) => {
102
+ if (l.type === "Identifier") {
103
+ if (l.name.toLowerCase() === "inset")
104
+ e.inset = !0;
105
+ else if (B.has(l.name) || G.has(l.name)) {
106
+ let i = h(l.name);
107
+ if (i === null)
1837
108
  return;
1838
- n.color = s;
109
+ e.color = i;
1839
110
  }
1840
- } else if (i.type === "Dimension" || i.type === "Number" && i.value === "0") {
1841
- let s = i.type === "Dimension" ? {
1842
- $type: "dimension",
1843
- value: Number(i.value),
1844
- unit: i.unit
111
+ } else if (l.type === "Dimension" || l.type === "Number" && l.value === "0") {
112
+ let i = l.type === "Dimension" ? {
113
+ value: Number(l.value),
114
+ unit: l.unit
1845
115
  } : {
1846
- $type: "dimension",
1847
116
  value: 0,
1848
117
  unit: "px"
1849
118
  };
1850
- n.offsetX ? n.offsetY ? n.blur ? n.spread || (n.spread = s) : n.blur = s : n.offsetY = s : n.offsetX = s;
1851
- } else if (i.type === "Function") {
1852
- if (Mr.has(i.name)) {
1853
- let s = E(r(i));
1854
- if (s === null)
119
+ e.offsetX ? e.offsetY ? e.blur ? e.spread || (e.spread = i) : e.blur = i : e.offsetY = i : e.offsetX = i;
120
+ } else if (l.type === "Function") {
121
+ if (T.has(l.name)) {
122
+ let i = h(r(l));
123
+ if (i === null)
1855
124
  return;
1856
- n.color = s;
1857
- } else if (i.name.toLowerCase() === "var" && !n.color) {
1858
- let s = E(r(i));
1859
- if (s === null)
125
+ e.color = i;
126
+ } else if (l.name.toLowerCase() === "var" && !e.color) {
127
+ let i = h(r(l));
128
+ if (i === null)
1860
129
  return;
1861
- n.color = s;
130
+ e.color = i;
1862
131
  }
1863
- } else if (i.type === "Hash") {
1864
- let s = E(r(i));
1865
- if (s === null)
132
+ } else if (l.type === "Hash") {
133
+ let i = h(r(l));
134
+ if (i === null)
1866
135
  return;
1867
- n.color = s;
1868
- } else i.type === "Operator" && i.value === "," && (Ge(n), n = Pe(), a.push(n));
1869
- }), Ge(n), a);
136
+ e.color = i;
137
+ } else l.type === "Operator" && l.value === "," && (y(e), e = x(), s.push(e));
138
+ }), y(e), s);
1870
139
  }
1871
- const V = {
1872
- $type: "dimension",
140
+ const g = {
1873
141
  value: 0,
1874
142
  unit: "px"
1875
143
  };
1876
- function Ge(t) {
1877
- return t.offsetX || (t.offsetX = V), t.offsetY || (t.offsetY = V), t.blur || (t.blur = V), t.spread || (t.spread = V), t.color || (t.color = E("#000")), t;
144
+ function y(n) {
145
+ return n.offsetX || (n.offsetX = g), n.offsetY || (n.offsetY = g), n.blur || (n.blur = g), n.spread || (n.spread = g), n.color || (n.color = h("#000")), n;
1878
146
  }
1879
- const He = /* @__PURE__ */ new Map([
147
+ const w = /* @__PURE__ */ new Map([
1880
148
  ["linear", [0, 0, 1, 1]],
1881
149
  ["ease", [0.25, 0.1, 0.25, 1]],
1882
150
  ["ease-in", [0.42, 0, 1, 1]],
1883
151
  ["ease-out", [0, 0, 0.58, 1]],
1884
152
  ["ease-in-out", [0.42, 0, 0.58, 1]]
1885
153
  ]);
1886
- function vr(t) {
1887
- if (t = t.trim().toLowerCase(), He.has(t))
1888
- return He.get(t);
1889
- if (!t.includes("var(") && t.startsWith("cubic-bezier(")) {
1890
- let e = t.replace("cubic-bezier(", "").replace(")", "").split(",").map((r) => Number(r.trim()));
1891
- if (e.length === 4 && e.every((r) => Number.isFinite(r)))
1892
- return e;
154
+ function xe(n) {
155
+ if (n = n.trim().toLowerCase(), w.has(n))
156
+ return w.get(n);
157
+ if (n.includes("var("))
158
+ return null;
159
+ if (n.startsWith("cubic-bezier(")) {
160
+ let t = n.replace("cubic-bezier(", "").replace(")", "").split(",").map((r) => Number(r.trim()));
161
+ if (t.length === 4 && t.every((r) => Number.isFinite(r)))
162
+ return t;
1893
163
  }
164
+ return null;
1894
165
  }
1895
- function Te(t) {
1896
- return t.replaceAll(/^['"]|['"]$/g, "");
166
+ function S(n) {
167
+ return n.replaceAll(/^['"]|['"]$/g, "");
1897
168
  }
1898
- function _r(t) {
1899
- let e = re(t, {
169
+ function ye(n) {
170
+ let t = d(n, {
1900
171
  context: "value",
1901
172
  positions: !0
1902
173
  });
1903
- function r(s) {
1904
- return s.loc ? t.slice(s.loc.start.offset, s.loc.end.offset) : "";
174
+ function r(i) {
175
+ return i.loc ? n.slice(i.loc.start.offset, i.loc.end.offset) : "";
1905
176
  }
1906
- let n = [];
1907
- if (!e.children || e.children.size === 0)
1908
- return n;
1909
- let a = "", i;
1910
- for (let s of e.children) {
1911
- if (s.type === "Operator" && s.value === ",") {
1912
- n.push(Te(a)), a = "", i = s.type;
177
+ let e = [];
178
+ if (!t.children || t.children.size === 0)
179
+ return e;
180
+ let s = "", l;
181
+ for (let i of t.children) {
182
+ if (i.type === "Operator" && i.value === ",") {
183
+ e.push(S(s)), s = "", l = i.type;
1913
184
  continue;
1914
185
  }
1915
- i === "Identifier" && s.type === "Identifier" && (a += " "), a += r(s), i = s.type;
186
+ l === "Identifier" && i.type === "Identifier" && (s += " "), s += r(i), l = i.type;
1916
187
  }
1917
- return n.push(Te(a)), n;
188
+ return e.push(S(s)), e;
1918
189
  }
1919
- function B(t) {
1920
- if (t === void 0 || typeof t == "number" && isNaN(t))
190
+ function c(n) {
191
+ if (n === void 0 || typeof n == "number" && isNaN(n))
1921
192
  return "0";
1922
- typeof t != "string" && (t = t.toString());
1923
- let e = 0;
1924
- for (let r of t)
1925
- e = (e << 5) - e + r.charCodeAt(0), e |= 0;
1926
- return (e >>> 0).toString(16);
1927
- }
1928
- function xr(t) {
1929
- let e = re(t, { context: "value" });
1930
- if (e.children === null || e.children.size !== 1) return null;
1931
- let r = e.children.first;
193
+ typeof n != "string" && (n = n.toString());
194
+ let t = 0;
195
+ for (let r of n)
196
+ t = (t << 5) - t + r.charCodeAt(0), t |= 0;
197
+ return (t >>> 0).toString(16);
198
+ }
199
+ function we(n) {
200
+ let t = d(n, { context: "value" });
201
+ if (t.children === null || t.children.size !== 1) return null;
202
+ let r = t.children.first;
1932
203
  switch (r.type) {
1933
204
  case "Dimension":
1934
205
  return {
@@ -1945,7 +216,7 @@ function xr(t) {
1945
216
  }
1946
217
  return null;
1947
218
  }
1948
- let Fe = /* @__PURE__ */ new Map([
219
+ let O = /* @__PURE__ */ new Map([
1949
220
  ["xx-small", 0.6],
1950
221
  ["x-small", 0.75],
1951
222
  ["small", 0.89],
@@ -1955,10 +226,10 @@ let Fe = /* @__PURE__ */ new Map([
1955
226
  ["xx-large", 2],
1956
227
  ["xxx-large", 3]
1957
228
  ]);
1958
- function Br(t) {
1959
- let e = re(t, { context: "value" });
1960
- if (e.children === null || e.children.size !== 1) return null;
1961
- let r = e.children.first;
229
+ function Se(n) {
230
+ let t = d(n, { context: "value" });
231
+ if (t.children === null || t.children.size !== 1) return null;
232
+ let r = t.children.first;
1962
233
  switch (r.type) {
1963
234
  case "Dimension": {
1964
235
  if (r.unit === "px" || r.unit === "rem")
@@ -1969,181 +240,192 @@ function Br(t) {
1969
240
  break;
1970
241
  }
1971
242
  case "Identifier": {
1972
- let n = r.name.toLowerCase();
1973
- if (Fe.has(n))
243
+ let e = r.name.toLowerCase();
244
+ if (O.has(e))
1974
245
  return {
1975
- value: Fe.get(n),
246
+ value: O.get(e),
1976
247
  unit: "rem"
1977
248
  };
1978
249
  }
1979
250
  }
1980
251
  return null;
1981
252
  }
1982
- function Ir(t) {
1983
- let e = Mt(t);
1984
- return Rr(e);
253
+ function je(n) {
254
+ let t = W(n);
255
+ return Oe(t);
256
+ }
257
+ function f(n) {
258
+ return "uniqueWithLocations" in n ? n.uniqueWithLocations : n.unique;
1985
259
  }
1986
- function R(t) {
1987
- return "uniqueWithLocations" in t ? t.uniqueWithLocations : t.unique;
260
+ function p(n) {
261
+ return Array.isArray(n) ? n.length : n;
1988
262
  }
1989
- function Rr(t) {
263
+ function Oe(n) {
1990
264
  return {
1991
265
  color: (() => {
1992
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.colors), n = _t(r);
1993
- for (let [a, i] of n)
1994
- for (let s of i) {
1995
- let l = E(s);
1996
- if (l !== null) {
1997
- let o = `${vt.get(a)}-${B(s)}`;
1998
- e[o] = l;
266
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.colors), e = ve(r);
267
+ for (let [s, l] of e)
268
+ for (let i of l) {
269
+ let m = h(i);
270
+ if (m !== null) {
271
+ let X = `${de.get(s)}-${c(i)}`, D = n.values.colors.itemsPerContext, P = Object.entries(D).reduce(($, [H, v]) => ((i in v.unique || v.uniqueWithLocations && i in v.uniqueWithLocations) && $.push(H), $), []);
272
+ t[X] = {
273
+ $type: "color",
274
+ $value: m,
275
+ $extensions: {
276
+ [u]: i,
277
+ [a]: p(r[i]),
278
+ [be]: P
279
+ }
280
+ };
1999
281
  }
2000
282
  }
2001
- return e;
283
+ return t;
2002
284
  })(),
2003
285
  font_size: (() => {
2004
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.fontSizes);
2005
- for (let n in r) {
2006
- let a = `fontSize-${B(n)}`, i = Br(n);
2007
- i === null ? e[a] = {
2008
- $value: n,
2009
- $extensions: {
2010
- [$]: n
2011
- }
2012
- } : e[a] = {
286
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.fontSizes);
287
+ for (let e in r) {
288
+ let s = `fontSize-${c(e)}`, l = Se(e), i = {
289
+ [u]: e,
290
+ [a]: p(r[e])
291
+ };
292
+ l === null ? t[s] = {
293
+ $value: e,
294
+ $extensions: i
295
+ } : t[s] = {
2013
296
  $type: "dimension",
2014
- $value: i,
2015
- $extensions: {
2016
- [$]: n
2017
- }
297
+ $value: l,
298
+ $extensions: i
2018
299
  };
2019
300
  }
2020
- return e;
301
+ return t;
2021
302
  })(),
2022
303
  font_family: (() => {
2023
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.fontFamilies);
2024
- for (let n in r) {
2025
- let a = _r(n), i = `fontFamily-${B(n)}`;
2026
- e[i] = {
304
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.fontFamilies);
305
+ for (let e in r) {
306
+ let s = ye(e), l = `fontFamily-${c(e)}`;
307
+ t[l] = {
2027
308
  $type: "fontFamily",
2028
- $value: a,
309
+ $value: s,
2029
310
  $extensions: {
2030
- [$]: n
311
+ [u]: e,
312
+ [a]: p(r[e])
2031
313
  }
2032
314
  };
2033
315
  }
2034
- return e;
316
+ return t;
2035
317
  })(),
2036
318
  line_height: (() => {
2037
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.lineHeights);
2038
- for (let n in r) {
2039
- let a = `lineHeight-${B(n)}`, i = xr(n);
2040
- i === null ? e[a] = {
2041
- $value: n,
2042
- $extensions: {
2043
- [$]: n
2044
- }
2045
- } : typeof i == "number" ? e[a] = {
319
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.lineHeights);
320
+ for (let e in r) {
321
+ let s = `lineHeight-${c(e)}`, l = we(e), i = {
322
+ [u]: e,
323
+ [a]: p(r[e])
324
+ };
325
+ l === null ? t[s] = {
326
+ $value: e,
327
+ $extensions: i
328
+ } : typeof l == "number" ? t[s] = {
2046
329
  $type: "number",
2047
- $value: i,
2048
- $extensions: {
2049
- [$]: n
2050
- }
2051
- } : typeof i == "object" && (i.unit === "px" || i.unit === "rem" ? e[a] = {
330
+ $value: l,
331
+ $extensions: i
332
+ } : typeof l == "object" && (l.unit === "px" || l.unit === "rem" ? t[s] = {
2052
333
  $type: "dimension",
2053
- $value: i,
2054
- $extensions: {
2055
- [$]: n
2056
- }
2057
- } : e[a] = {
2058
- $value: n,
2059
- $extensions: {
2060
- [$]: n
2061
- }
334
+ $value: l,
335
+ $extensions: i
336
+ } : t[s] = {
337
+ $value: e,
338
+ $extensions: i
2062
339
  });
2063
340
  }
2064
- return e;
341
+ return t;
2065
342
  })(),
2066
343
  gradient: (() => {
2067
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.gradients);
2068
- for (let n in r)
2069
- e[`gradient-${B(n)}`] = {
2070
- $value: n
344
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.gradients);
345
+ for (let e in r)
346
+ t[`gradient-${c(e)}`] = {
347
+ $value: e,
348
+ $extensions: {
349
+ [u]: e,
350
+ [a]: p(r[e])
351
+ }
2071
352
  };
2072
- return e;
353
+ return t;
2073
354
  })(),
2074
355
  box_shadow: (() => {
2075
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.boxShadows);
2076
- for (let n in r) {
2077
- let a = `boxShadow-${B(n)}`, i = kr(n);
2078
- i === null ? e[a] = {
2079
- $value: n,
2080
- $extensions: {
2081
- [$]: n
2082
- }
2083
- } : e[a] = {
356
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.boxShadows);
357
+ for (let e in r) {
358
+ let s = `boxShadow-${c(e)}`, l = $e(e), i = {
359
+ [u]: e,
360
+ [a]: p(r[e])
361
+ };
362
+ l === null ? t[s] = {
363
+ $value: e,
364
+ $extensions: i
365
+ } : t[s] = {
2084
366
  $type: "shadow",
2085
- $value: i.length === 1 ? i[0] : i,
2086
- $extensions: {
2087
- [$]: n
2088
- }
367
+ $value: l.length === 1 ? l[0] : l,
368
+ $extensions: i
2089
369
  };
2090
370
  }
2091
- return e;
371
+ return t;
2092
372
  })(),
2093
373
  radius: (() => {
2094
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.borderRadiuses);
2095
- for (let n in r) {
2096
- let a = `radius-${B(n)}`;
2097
- e[a] = {
2098
- $value: n
374
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.borderRadiuses);
375
+ for (let e in r) {
376
+ let s = `radius-${c(e)}`;
377
+ t[s] = {
378
+ $value: e,
379
+ $extensions: {
380
+ [u]: e,
381
+ [a]: p(r[e])
382
+ }
2099
383
  };
2100
384
  }
2101
- return e;
385
+ return t;
2102
386
  })(),
2103
387
  duration: (() => {
2104
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.animations.durations);
2105
- for (let n in r) {
2106
- let a = $t(n), i = a < Number.MAX_SAFE_INTEGER - 1, s = B(a.toString());
2107
- i ? e[`duration-${s}`] = {
388
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.animations.durations);
389
+ for (let e in r) {
390
+ let s = k(e), l = s < Number.MAX_SAFE_INTEGER - 1, i = c(s.toString()), m = {
391
+ [u]: e,
392
+ [a]: p(r[e])
393
+ };
394
+ l ? t[`duration-${i}`] = {
2108
395
  $type: "duration",
2109
396
  $value: {
2110
- value: a,
397
+ value: s,
2111
398
  unit: "ms"
2112
399
  },
2113
- $extensions: {
2114
- [$]: n
2115
- }
2116
- } : e[`duration-${s}`] = {
2117
- $value: n,
2118
- $extensions: {
2119
- [$]: n
2120
- }
400
+ $extensions: m
401
+ } : t[`duration-${i}`] = {
402
+ $value: e,
403
+ $extensions: m
2121
404
  };
2122
405
  }
2123
- return e;
406
+ return t;
2124
407
  })(),
2125
408
  easing: (() => {
2126
- let e = /* @__PURE__ */ Object.create(null), r = R(t.values.animations.timingFunctions);
2127
- for (let n in r) {
2128
- let a = `easing-${B(n)}`, i = vr(n);
2129
- i ? e[a] = {
2130
- $value: i,
409
+ let t = /* @__PURE__ */ Object.create(null), r = f(n.values.animations.timingFunctions);
410
+ for (let e in r) {
411
+ let s = `easing-${c(e)}`, l = xe(e), i = {
412
+ [u]: e,
413
+ [a]: p(r[e])
414
+ };
415
+ l !== null ? t[s] = {
416
+ $value: l,
2131
417
  $type: "cubicBezier",
2132
- $extensions: {
2133
- [$]: n
2134
- }
2135
- } : e[a] = {
2136
- $value: n,
2137
- $extensions: {
2138
- [$]: n
2139
- }
418
+ $extensions: i
419
+ } : t[s] = {
420
+ $value: e,
421
+ $extensions: i
2140
422
  };
2141
423
  }
2142
- return e;
424
+ return t;
2143
425
  })()
2144
426
  };
2145
427
  }
2146
428
  export {
2147
- Rr as analysis_to_tokens,
2148
- Ir as css_to_tokens
429
+ Oe as analysis_to_tokens,
430
+ je as css_to_tokens
2149
431
  };