@pixerate/editor 0.161.0 → 0.162.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/agent/index.cjs +36 -35
  2. package/dist/agent/index.js +7 -6
  3. package/dist/animation/index.cjs +5 -4
  4. package/dist/animation/index.js +4 -3
  5. package/dist/animation-editor/index.cjs +62 -61
  6. package/dist/animation-editor/index.js +6 -5
  7. package/dist/canvas/index.cjs +33 -32
  8. package/dist/canvas/index.js +6 -5
  9. package/dist/chart/index.cjs +88 -87
  10. package/dist/chart/index.js +7 -6
  11. package/dist/{chunk-QMI5HZWA.cjs → chunk-236TKNUR.cjs} +3 -3
  12. package/dist/{chunk-6UPGM3JB.js → chunk-2TKHLX6H.js} +1 -1
  13. package/dist/{chunk-3YDQLQH2.cjs → chunk-32MMQYCQ.cjs} +81 -81
  14. package/dist/{chunk-MHEXLG3M.cjs → chunk-3GJH2MGH.cjs} +37 -37
  15. package/dist/{chunk-AKDWAWSY.cjs → chunk-3IHNXRUV.cjs} +45 -45
  16. package/dist/{chunk-TVO6W2Q6.cjs → chunk-4NGVHHJB.cjs} +17 -17
  17. package/dist/chunk-4VU4CP7R.js +769 -0
  18. package/dist/{chunk-DBIVICAO.js → chunk-7CKPUUN4.js} +1 -1
  19. package/dist/{chunk-57JLBGJ5.cjs → chunk-7YBDRJXT.cjs} +8 -8
  20. package/dist/{chunk-KY3FYKP3.js → chunk-BQWGN5WH.js} +1 -1
  21. package/dist/{chunk-LEUZ4FRC.cjs → chunk-CIPIESX4.cjs} +3 -3
  22. package/dist/chunk-CJE5MOIS.js +347 -0
  23. package/dist/{chunk-5QBRAIVK.js → chunk-CX6JLDFC.js} +3 -3
  24. package/dist/{chunk-R3QY7PPL.js → chunk-DTSTNRPH.js} +1 -1
  25. package/dist/{chunk-6LUYFHHN.cjs → chunk-EQ46F75O.cjs} +51 -51
  26. package/dist/{chunk-UKCJ43YL.cjs → chunk-ES3UEVUT.cjs} +130 -898
  27. package/dist/{chunk-UM3RPYC5.js → chunk-EVPZ5IKN.js} +1 -1
  28. package/dist/{chunk-XNQ5EFB4.cjs → chunk-EY22AY6R.cjs} +16 -16
  29. package/dist/chunk-FKUKJ3XA.cjs +347 -0
  30. package/dist/{chunk-YABNLNY7.js → chunk-GLMP22FT.js} +3 -3
  31. package/dist/{chunk-SUF6WRXR.cjs → chunk-GTELFJRE.cjs} +2 -2
  32. package/dist/{chunk-72BGL3I2.js → chunk-GWV4T5NZ.js} +1 -1
  33. package/dist/{chunk-AY65VQSU.js → chunk-H3OEM3Q2.js} +1 -1
  34. package/dist/{chunk-4YWAEV4W.cjs → chunk-HDGBM7EA.cjs} +26 -26
  35. package/dist/{chunk-H5XX4KHB.js → chunk-HLOKB7WW.js} +5 -3
  36. package/dist/{chunk-WNAAWLZ5.js → chunk-KGTF55R3.js} +2 -2
  37. package/dist/{chunk-WPPJH6X4.cjs → chunk-LL3H5XUH.cjs} +6 -4
  38. package/dist/{chunk-4T44CJ5K.cjs → chunk-NA4UVVJ4.cjs} +15 -15
  39. package/dist/{chunk-Q6PA362P.js → chunk-NO5QQDHZ.js} +2 -2
  40. package/dist/{chunk-AA34BA7G.js → chunk-QYZGBVNC.js} +30 -798
  41. package/dist/chunk-S6X2QRVU.cjs +769 -0
  42. package/dist/{chunk-SSCL7QQ4.js → chunk-XDCFJEU7.js} +2 -2
  43. package/dist/color/index.cjs +6 -2
  44. package/dist/color/index.d.cts +1 -0
  45. package/dist/color/index.d.ts +1 -0
  46. package/dist/color/index.js +28 -24
  47. package/dist/color/suggest.d.cts +12 -0
  48. package/dist/color/suggest.d.ts +12 -0
  49. package/dist/effects/index.cjs +37 -13
  50. package/dist/effects/index.js +29 -5
  51. package/dist/effects/ui.d.cts +20 -3
  52. package/dist/effects/ui.d.ts +20 -3
  53. package/dist/export/index.cjs +6 -5
  54. package/dist/export/index.js +5 -4
  55. package/dist/extensions/index.cjs +9 -8
  56. package/dist/extensions/index.js +8 -7
  57. package/dist/gradient/index.cjs +28 -26
  58. package/dist/gradient/index.js +7 -5
  59. package/dist/image-editor/index.cjs +638 -637
  60. package/dist/image-editor/index.js +5 -4
  61. package/dist/index.cjs +15 -14
  62. package/dist/index.js +9 -8
  63. package/dist/paint-editor/index.cjs +15 -14
  64. package/dist/paint-editor/index.js +5 -4
  65. package/dist/typography/accessibility.d.cts +44 -0
  66. package/dist/typography/accessibility.d.ts +44 -0
  67. package/dist/typography/catalog.d.cts +98 -0
  68. package/dist/typography/catalog.d.ts +98 -0
  69. package/dist/typography/index.cjs +1099 -0
  70. package/dist/typography/index.d.cts +16 -0
  71. package/dist/typography/index.d.ts +16 -0
  72. package/dist/typography/index.js +1099 -0
  73. package/dist/typography/metrics.d.cts +31 -0
  74. package/dist/typography/metrics.d.ts +31 -0
  75. package/dist/typography/picker.d.cts +132 -0
  76. package/dist/typography/picker.d.ts +132 -0
  77. package/dist/typography/registry.d.cts +66 -0
  78. package/dist/typography/registry.d.ts +66 -0
  79. package/dist/typography/scale.d.cts +62 -0
  80. package/dist/typography/scale.d.ts +62 -0
  81. package/dist/typography/segment.d.cts +26 -0
  82. package/dist/typography/segment.d.ts +26 -0
  83. package/dist/typography/stack.d.cts +26 -0
  84. package/dist/typography/stack.d.ts +26 -0
  85. package/dist/typography/tools.d.cts +34 -0
  86. package/dist/typography/tools.d.ts +34 -0
  87. package/dist/typography/types.d.cts +96 -0
  88. package/dist/typography/types.d.ts +96 -0
  89. package/dist/typography/weight.d.cts +13 -0
  90. package/dist/typography/weight.d.ts +13 -0
  91. package/dist/vector/index.cjs +950 -949
  92. package/dist/vector/index.js +5 -4
  93. package/dist/video-editor/index.cjs +5 -4
  94. package/dist/video-editor/index.js +4 -3
  95. package/package.json +11 -1
  96. package/skills/README.md +1 -0
  97. package/skills/pixerate-typography/SKILL.md +91 -0
@@ -5,720 +5,22 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkIPJ3TEYRcjs = require('./chunk-IPJ3TEYR.cjs');
9
8
 
10
- // src/color/convert.ts
11
- function srgbToLinear(v) {
12
- const sign = Math.sign(v);
13
- const abs = Math.abs(v);
14
- return sign * (abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4);
15
- }
16
- function linearToSrgb(v) {
17
- const sign = Math.sign(v);
18
- const abs = Math.abs(v);
19
- return sign * (abs <= 31308e-7 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055);
20
- }
21
- function rgbToHsl(rgba) {
22
- const { r, g, b, a } = rgba;
23
- const max = Math.max(r, g, b);
24
- const min = Math.min(r, g, b);
25
- const d = max - min;
26
- const l = (max + min) / 2;
27
- let h = 0;
28
- if (d > 0) {
29
- if (max === r) h = 60 * ((g - b) / d % 6);
30
- else if (max === g) h = 60 * ((b - r) / d + 2);
31
- else h = 60 * ((r - g) / d + 4);
32
- }
33
- if (h < 0) h += 360;
34
- const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
35
- return { h, s, l, alpha: a };
36
- }
37
- function hslToRgb(hsla) {
38
- const { h, s, l, alpha } = hsla;
39
- const hh = (h % 360 + 360) % 360 / 60;
40
- const c = (1 - Math.abs(2 * l - 1)) * s;
41
- const x = c * (1 - Math.abs(hh % 2 - 1));
42
- const m = l - c / 2;
43
- let r = 0;
44
- let g = 0;
45
- let b = 0;
46
- if (hh < 1) {
47
- r = c;
48
- g = x;
49
- b = 0;
50
- } else if (hh < 2) {
51
- r = x;
52
- g = c;
53
- b = 0;
54
- } else if (hh < 3) {
55
- r = 0;
56
- g = c;
57
- b = x;
58
- } else if (hh < 4) {
59
- r = 0;
60
- g = x;
61
- b = c;
62
- } else if (hh < 5) {
63
- r = x;
64
- g = 0;
65
- b = c;
66
- } else {
67
- r = c;
68
- g = 0;
69
- b = x;
70
- }
71
- return { r: r + m, g: g + m, b: b + m, a: alpha };
72
- }
73
- function rgbToHsv(rgba) {
74
- const { r, g, b, a } = rgba;
75
- const max = Math.max(r, g, b);
76
- const min = Math.min(r, g, b);
77
- const d = max - min;
78
- let h = 0;
79
- if (d > 0) {
80
- if (max === r) h = 60 * ((g - b) / d % 6);
81
- else if (max === g) h = 60 * ((b - r) / d + 2);
82
- else h = 60 * ((r - g) / d + 4);
83
- }
84
- if (h < 0) h += 360;
85
- const s = max === 0 ? 0 : d / max;
86
- return { h, s, v: max, alpha: a };
87
- }
88
- function hsvToRgb(hsva) {
89
- const { h, s, v, alpha } = hsva;
90
- const hh = (h % 360 + 360) % 360 / 60;
91
- const c = v * s;
92
- const x = c * (1 - Math.abs(hh % 2 - 1));
93
- const m = v - c;
94
- let r = 0;
95
- let g = 0;
96
- let b = 0;
97
- if (hh < 1) {
98
- r = c;
99
- g = x;
100
- b = 0;
101
- } else if (hh < 2) {
102
- r = x;
103
- g = c;
104
- b = 0;
105
- } else if (hh < 3) {
106
- r = 0;
107
- g = c;
108
- b = x;
109
- } else if (hh < 4) {
110
- r = 0;
111
- g = x;
112
- b = c;
113
- } else if (hh < 5) {
114
- r = x;
115
- g = 0;
116
- b = c;
117
- } else {
118
- r = c;
119
- g = 0;
120
- b = x;
121
- }
122
- return { r: r + m, g: g + m, b: b + m, a: alpha };
123
- }
124
- function rgbToOklab(rgba) {
125
- const lr = srgbToLinear(rgba.r);
126
- const lg = srgbToLinear(rgba.g);
127
- const lb = srgbToLinear(rgba.b);
128
- const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
129
- const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
130
- const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
131
- return {
132
- l: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
133
- a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
134
- b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
135
- alpha: rgba.a
136
- };
137
- }
138
- function oklabToRgb(lab) {
139
- const l_ = lab.l + 0.3963377774 * lab.a + 0.2158037573 * lab.b;
140
- const m_ = lab.l - 0.1055613458 * lab.a - 0.0638541728 * lab.b;
141
- const s_ = lab.l - 0.0894841775 * lab.a - 1.291485548 * lab.b;
142
- const l = l_ ** 3;
143
- const m = m_ ** 3;
144
- const s = s_ ** 3;
145
- return {
146
- r: linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
147
- g: linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
148
- b: linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
149
- a: lab.alpha
150
- };
151
- }
152
- function oklabToOklch(lab) {
153
- const c = Math.hypot(lab.a, lab.b);
154
- let h = 0;
155
- if (c >= 1e-6) {
156
- h = Math.atan2(lab.b, lab.a) * 180 / Math.PI;
157
- if (h < 0) h += 360;
158
- if (h >= 360) h -= 360;
159
- }
160
- return { l: lab.l, c, h, alpha: lab.alpha };
161
- }
162
- function oklchToOklab(lch) {
163
- const rad = lch.h * Math.PI / 180;
164
- return {
165
- l: lch.l,
166
- a: lch.c * Math.cos(rad),
167
- b: lch.c * Math.sin(rad),
168
- alpha: lch.alpha
169
- };
170
- }
171
- var D65_XYZ = _chunkIPJ3TEYRcjs.xyToXyz.call(void 0, _chunkIPJ3TEYRcjs.D65_XY);
172
- var SRGB_TO_XYZ = _chunkIPJ3TEYRcjs.rgbToXyzMatrix.call(void 0, [0.64, 0.33], [0.3, 0.6], [0.15, 0.06], D65_XYZ);
173
- var P3_TO_XYZ = _chunkIPJ3TEYRcjs.rgbToXyzMatrix.call(void 0, [0.68, 0.32], [0.265, 0.69], [0.15, 0.06], D65_XYZ);
174
- var XYZ_TO_SRGB = _chunkIPJ3TEYRcjs.invert.call(void 0, SRGB_TO_XYZ);
175
- var XYZ_TO_P3 = _chunkIPJ3TEYRcjs.invert.call(void 0, P3_TO_XYZ);
176
- var P3_TO_SRGB_MAT = _chunkIPJ3TEYRcjs.mul.call(void 0, XYZ_TO_SRGB, P3_TO_XYZ);
177
- var SRGB_TO_P3_MAT = _chunkIPJ3TEYRcjs.mul.call(void 0, XYZ_TO_P3, SRGB_TO_XYZ);
178
- function linearSrgbToDisplayP3(rgb) {
179
- const out = _chunkIPJ3TEYRcjs.apply.call(void 0, SRGB_TO_P3_MAT, [rgb.r, rgb.g, rgb.b]);
180
- return { r: out[0], g: out[1], b: out[2], a: rgb.a };
181
- }
182
- function displayP3ToLinearSrgb(rgb) {
183
- const out = _chunkIPJ3TEYRcjs.apply.call(void 0, P3_TO_SRGB_MAT, [rgb.r, rgb.g, rgb.b]);
184
- return { r: out[0], g: out[1], b: out[2], a: rgb.a };
185
- }
186
9
 
187
- // src/color/named.ts
188
- var NAMED_COLORS = {
189
- aliceblue: "#f0f8ff",
190
- antiquewhite: "#faebd7",
191
- aqua: "#00ffff",
192
- aquamarine: "#7fffd4",
193
- azure: "#f0ffff",
194
- beige: "#f5f5dc",
195
- bisque: "#ffe4c4",
196
- black: "#000000",
197
- blanchedalmond: "#ffebcd",
198
- blue: "#0000ff",
199
- blueviolet: "#8a2be2",
200
- brown: "#a52a2a",
201
- burlywood: "#deb887",
202
- cadetblue: "#5f9ea0",
203
- chartreuse: "#7fff00",
204
- chocolate: "#d2691e",
205
- coral: "#ff7f50",
206
- cornflowerblue: "#6495ed",
207
- cornsilk: "#fff8dc",
208
- crimson: "#dc143c",
209
- cyan: "#00ffff",
210
- darkblue: "#00008b",
211
- darkcyan: "#008b8b",
212
- darkgoldenrod: "#b8860b",
213
- darkgray: "#a9a9a9",
214
- darkgreen: "#006400",
215
- darkgrey: "#a9a9a9",
216
- darkkhaki: "#bdb76b",
217
- darkmagenta: "#8b008b",
218
- darkolivegreen: "#556b2f",
219
- darkorange: "#ff8c00",
220
- darkorchid: "#9932cc",
221
- darkred: "#8b0000",
222
- darksalmon: "#e9967a",
223
- darkseagreen: "#8fbc8f",
224
- darkslateblue: "#483d8b",
225
- darkslategray: "#2f4f4f",
226
- darkslategrey: "#2f4f4f",
227
- darkturquoise: "#00ced1",
228
- darkviolet: "#9400d3",
229
- deeppink: "#ff1493",
230
- deepskyblue: "#00bfff",
231
- dimgray: "#696969",
232
- dimgrey: "#696969",
233
- dodgerblue: "#1e90ff",
234
- firebrick: "#b22222",
235
- floralwhite: "#fffaf0",
236
- forestgreen: "#228b22",
237
- fuchsia: "#ff00ff",
238
- gainsboro: "#dcdcdc",
239
- ghostwhite: "#f8f8ff",
240
- gold: "#ffd700",
241
- goldenrod: "#daa520",
242
- gray: "#808080",
243
- green: "#008000",
244
- greenyellow: "#adff2f",
245
- grey: "#808080",
246
- honeydew: "#f0fff0",
247
- hotpink: "#ff69b4",
248
- indianred: "#cd5c5c",
249
- indigo: "#4b0082",
250
- ivory: "#fffff0",
251
- khaki: "#f0e68c",
252
- lavender: "#e6e6fa",
253
- lavenderblush: "#fff0f5",
254
- lawngreen: "#7cfc00",
255
- lemonchiffon: "#fffacd",
256
- lightblue: "#add8e6",
257
- lightcoral: "#f08080",
258
- lightcyan: "#e0ffff",
259
- lightgoldenrodyellow: "#fafad2",
260
- lightgray: "#d3d3d3",
261
- lightgreen: "#90ee90",
262
- lightgrey: "#d3d3d3",
263
- lightpink: "#ffb6c1",
264
- lightsalmon: "#ffa07a",
265
- lightseagreen: "#20b2aa",
266
- lightskyblue: "#87cefa",
267
- lightslategray: "#778899",
268
- lightslategrey: "#778899",
269
- lightsteelblue: "#b0c4de",
270
- lightyellow: "#ffffe0",
271
- lime: "#00ff00",
272
- limegreen: "#32cd32",
273
- linen: "#faf0e6",
274
- magenta: "#ff00ff",
275
- maroon: "#800000",
276
- mediumaquamarine: "#66cdaa",
277
- mediumblue: "#0000cd",
278
- mediumorchid: "#ba55d3",
279
- mediumpurple: "#9370db",
280
- mediumseagreen: "#3cb371",
281
- mediumslateblue: "#7b68ee",
282
- mediumspringgreen: "#00fa9a",
283
- mediumturquoise: "#48d1cc",
284
- mediumvioletred: "#c71585",
285
- midnightblue: "#191970",
286
- mintcream: "#f5fffa",
287
- mistyrose: "#ffe4e1",
288
- moccasin: "#ffe4b5",
289
- navajowhite: "#ffdead",
290
- navy: "#000080",
291
- oldlace: "#fdf5e6",
292
- olive: "#808000",
293
- olivedrab: "#6b8e23",
294
- orange: "#ffa500",
295
- orangered: "#ff4500",
296
- orchid: "#da70d6",
297
- palegoldenrod: "#eee8aa",
298
- palegreen: "#98fb98",
299
- paleturquoise: "#afeeee",
300
- palevioletred: "#db7093",
301
- papayawhip: "#ffefd5",
302
- peachpuff: "#ffdab9",
303
- peru: "#cd853f",
304
- pink: "#ffc0cb",
305
- plum: "#dda0dd",
306
- powderblue: "#b0e0e6",
307
- purple: "#800080",
308
- rebeccapurple: "#663399",
309
- red: "#ff0000",
310
- rosybrown: "#bc8f8f",
311
- royalblue: "#4169e1",
312
- saddlebrown: "#8b4513",
313
- salmon: "#fa8072",
314
- sandybrown: "#f4a460",
315
- seagreen: "#2e8b57",
316
- seashell: "#fff5ee",
317
- sienna: "#a0522d",
318
- silver: "#c0c0c0",
319
- skyblue: "#87ceeb",
320
- slateblue: "#6a5acd",
321
- slategray: "#708090",
322
- slategrey: "#708090",
323
- snow: "#fffafa",
324
- springgreen: "#00ff7f",
325
- steelblue: "#4682b4",
326
- tan: "#d2b48c",
327
- teal: "#008080",
328
- thistle: "#d8bfd8",
329
- tomato: "#ff6347",
330
- transparent: "#00000000",
331
- turquoise: "#40e0d0",
332
- violet: "#ee82ee",
333
- wheat: "#f5deb3",
334
- white: "#ffffff",
335
- whitesmoke: "#f5f5f5",
336
- yellow: "#ffff00",
337
- yellowgreen: "#9acd32"
338
- };
339
10
 
340
- // src/color/parse.ts
341
- var HEX_RE = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
342
- var RGB_RE = /^rgba?\(([^()]*)\)$/i;
343
- var HSL_RE = /^hsla?\(([^()]*)\)$/i;
344
- var OKLAB_RE = /^oklab\(([^()]*)\)$/i;
345
- var OKLCH_RE = /^oklch\(([^()]*)\)$/i;
346
- var COLOR_FN_RE = /^color\(([^()]*)\)$/i;
347
- function parsePercentOrNumber(v, scale) {
348
- const text = v.trim();
349
- const isPct = text.endsWith("%");
350
- const num = Number(isPct ? text.slice(0, -1) : text);
351
- if (!Number.isFinite(num)) return null;
352
- return isPct ? num / 100 : num / scale;
353
- }
354
- function parseAlpha(v) {
355
- if (v === void 0 || v.trim() === "") return 1;
356
- const text = v.trim();
357
- const isPct = text.endsWith("%");
358
- const num = Number(isPct ? text.slice(0, -1) : text);
359
- if (!Number.isFinite(num)) return null;
360
- return isPct ? num / 100 : num;
361
- }
362
- function parseAngle(v) {
363
- const text = v.trim().toLowerCase();
364
- if (text.endsWith("deg")) {
365
- const num2 = Number(text.slice(0, -3));
366
- return Number.isFinite(num2) ? num2 : null;
367
- }
368
- if (text.endsWith("turn")) {
369
- const num2 = Number(text.slice(0, -4));
370
- return Number.isFinite(num2) ? num2 * 360 : null;
371
- }
372
- if (text.endsWith("rad")) {
373
- const num2 = Number(text.slice(0, -3));
374
- return Number.isFinite(num2) ? num2 * 180 / Math.PI : null;
375
- }
376
- const num = Number(text);
377
- return Number.isFinite(num) ? num : null;
378
- }
379
- function splitParts(inner) {
380
- const slashIndex = inner.indexOf("/");
381
- let mainStr = inner;
382
- let alphaPart;
383
- if (slashIndex !== -1) {
384
- mainStr = inner.slice(0, slashIndex);
385
- alphaPart = inner.slice(slashIndex + 1);
386
- }
387
- const parts = mainStr.trim().split(/[\s,]+/).filter(Boolean);
388
- return { parts, alphaPart };
389
- }
390
- function parseColor(input) {
391
- if (typeof input === "string") {
392
- const text = input.trim();
393
- if (text.length === 0 || text.length > 200) return null;
394
- const lower = text.toLowerCase();
395
- const namedHex = NAMED_COLORS[lower];
396
- if (namedHex) {
397
- return parseHex(namedHex);
398
- }
399
- const hexMatch = HEX_RE.exec(text);
400
- if (hexMatch) {
401
- return parseHex(hexMatch[0]);
402
- }
403
- const rgbMatch = RGB_RE.exec(text);
404
- if (rgbMatch) {
405
- const { parts, alphaPart } = splitParts(rgbMatch[1]);
406
- let alphaVal = 1;
407
- if (alphaPart !== void 0) {
408
- alphaVal = parseAlpha(alphaPart);
409
- } else if (parts.length === 4) {
410
- alphaVal = parseAlpha(parts.pop());
411
- }
412
- if (parts.length !== 3 || alphaVal === null) return null;
413
- const r = parsePercentOrNumber(parts[0], 255);
414
- const g = parsePercentOrNumber(parts[1], 255);
415
- const b = parsePercentOrNumber(parts[2], 255);
416
- if (r === null || g === null || b === null) return null;
417
- return { r, g, b, a: alphaVal };
418
- }
419
- const hslMatch = HSL_RE.exec(text);
420
- if (hslMatch) {
421
- const { parts, alphaPart } = splitParts(hslMatch[1]);
422
- let alphaVal = 1;
423
- if (alphaPart !== void 0) {
424
- alphaVal = parseAlpha(alphaPart);
425
- } else if (parts.length === 4) {
426
- alphaVal = parseAlpha(parts.pop());
427
- }
428
- if (parts.length !== 3 || alphaVal === null) return null;
429
- const h = parseAngle(parts[0]);
430
- const s = parsePercentOrNumber(parts[1], 100);
431
- const l = parsePercentOrNumber(parts[2], 100);
432
- if (h === null || s === null || l === null) return null;
433
- return hslToRgb({ h, s, l, alpha: alphaVal });
434
- }
435
- const oklabMatch = OKLAB_RE.exec(text);
436
- if (oklabMatch) {
437
- const { parts, alphaPart } = splitParts(oklabMatch[1]);
438
- let alphaVal = 1;
439
- if (alphaPart !== void 0) {
440
- alphaVal = parseAlpha(alphaPart);
441
- } else if (parts.length === 4) {
442
- alphaVal = parseAlpha(parts.pop());
443
- }
444
- if (parts.length !== 3 || alphaVal === null) return null;
445
- const l = parsePercentOrNumber(parts[0], 1);
446
- const a = parsePercentOrNumber(parts[1], 1);
447
- const b = parsePercentOrNumber(parts[2], 1);
448
- if (l === null || a === null || b === null) return null;
449
- return oklabToRgb({ l, a, b, alpha: alphaVal });
450
- }
451
- const oklchMatch = OKLCH_RE.exec(text);
452
- if (oklchMatch) {
453
- const { parts, alphaPart } = splitParts(oklchMatch[1]);
454
- let alphaVal = 1;
455
- if (alphaPart !== void 0) {
456
- alphaVal = parseAlpha(alphaPart);
457
- } else if (parts.length === 4) {
458
- alphaVal = parseAlpha(parts.pop());
459
- }
460
- if (parts.length !== 3 || alphaVal === null) return null;
461
- const l = parsePercentOrNumber(parts[0], 1);
462
- const c = parsePercentOrNumber(parts[1], 1);
463
- const h = parseAngle(parts[2]);
464
- if (l === null || c === null || h === null) return null;
465
- return oklabToRgb(oklchToOklab({ l, c, h, alpha: alphaVal }));
466
- }
467
- const colorMatch = COLOR_FN_RE.exec(text);
468
- if (colorMatch) {
469
- const { parts, alphaPart } = splitParts(colorMatch[1]);
470
- if (parts.length < 4) return null;
471
- const space = parts[0].toLowerCase();
472
- let alphaVal = 1;
473
- if (alphaPart !== void 0) {
474
- alphaVal = parseAlpha(alphaPart);
475
- } else if (parts.length === 5) {
476
- alphaVal = parseAlpha(parts.pop());
477
- }
478
- if (parts.length !== 4 || alphaVal === null) return null;
479
- const c1 = parsePercentOrNumber(parts[1], 1);
480
- const c2 = parsePercentOrNumber(parts[2], 1);
481
- const c3 = parsePercentOrNumber(parts[3], 1);
482
- if (c1 === null || c2 === null || c3 === null) return null;
483
- if (space === "srgb") {
484
- return { r: c1, g: c2, b: c3, a: alphaVal };
485
- }
486
- if (space === "srgb-linear") {
487
- return {
488
- r: linearToSrgb(c1),
489
- g: linearToSrgb(c2),
490
- b: linearToSrgb(c3),
491
- a: alphaVal
492
- };
493
- }
494
- if (space === "display-p3") {
495
- const linP3R = srgbToLinear(c1);
496
- const linP3G = srgbToLinear(c2);
497
- const linP3B = srgbToLinear(c3);
498
- const linSrgb = displayP3ToLinearSrgb({ r: linP3R, g: linP3G, b: linP3B, a: alphaVal });
499
- return {
500
- r: linearToSrgb(linSrgb.r),
501
- g: linearToSrgb(linSrgb.g),
502
- b: linearToSrgb(linSrgb.b),
503
- a: alphaVal
504
- };
505
- }
506
- return null;
507
- }
508
- return null;
509
- }
510
- if (typeof input === "object" && input !== null) {
511
- const obj = input;
512
- if (Array.isArray(obj.components)) {
513
- const space = obj.colorSpace;
514
- if (space === void 0 || space === "srgb") {
515
- const [r2, g2, b2] = obj.components;
516
- const a2 = typeof obj.alpha === "number" && Number.isFinite(obj.alpha) ? obj.alpha : 1;
517
- if ([r2, g2, b2].every((v) => typeof v === "number" && Number.isFinite(v))) {
518
- return { r: r2, g: g2, b: b2, a: a2 };
519
- }
520
- }
521
- if (typeof obj.hex === "string") {
522
- const base = parseColor(obj.hex);
523
- if (!base) return null;
524
- const a2 = typeof obj.alpha === "number" && Number.isFinite(obj.alpha) ? obj.alpha : 1;
525
- return { r: base.r, g: base.g, b: base.b, a: a2 };
526
- }
527
- return null;
528
- }
529
- const { r, g, b } = obj;
530
- const a = obj.a === void 0 ? 1 : obj.a;
531
- if ([r, g, b, a].every((v) => typeof v === "number" && Number.isFinite(v))) {
532
- return { r, g, b, a };
533
- }
534
- }
535
- return null;
536
- }
537
- function parseHex(hex) {
538
- let raw = hex.trim();
539
- if (raw.startsWith("#")) raw = raw.slice(1);
540
- if (raw.length === 3 || raw.length === 4) {
541
- raw = [...raw].map((c) => c + c).join("");
542
- }
543
- if (raw.length !== 6 && raw.length !== 8) return null;
544
- const r = parseInt(raw.slice(0, 2), 16) / 255;
545
- const g = parseInt(raw.slice(2, 4), 16) / 255;
546
- const b = parseInt(raw.slice(4, 6), 16) / 255;
547
- const a = raw.length === 8 ? parseInt(raw.slice(6, 8), 16) / 255 : 1;
548
- return { r, g, b, a };
549
- }
550
- function isColor(input) {
551
- return parseColor(input) !== null;
552
- }
553
11
 
554
- // src/color/gamut.ts
555
- var clamp01 = (v) => Math.min(1, Math.max(0, v));
556
- function inSrgbGamut(c, epsilon = 1e-5) {
557
- return c.r >= -epsilon && c.r <= 1 + epsilon && c.g >= -epsilon && c.g <= 1 + epsilon && c.b >= -epsilon && c.b <= 1 + epsilon;
558
- }
559
- function deltaEOK(a, b) {
560
- const la = rgbToOklab(a);
561
- const lb = rgbToOklab(b);
562
- return Math.hypot(la.l - lb.l, la.a - lb.a, la.b - lb.b);
563
- }
564
- function toSrgbGamut(c) {
565
- const lch = oklabToOklch(rgbToOklab(c));
566
- if (lch.l >= 1) return { r: 1, g: 1, b: 1, a: c.a };
567
- if (lch.l <= 0) return { r: 0, g: 0, b: 0, a: c.a };
568
- if (inSrgbGamut(c)) {
569
- return { r: clamp01(c.r), g: clamp01(c.g), b: clamp01(c.b), a: c.a };
570
- }
571
- let low = 0;
572
- let high = lch.c;
573
- let clippedCandidate = { r: clamp01(c.r), g: clamp01(c.g), b: clamp01(c.b), a: c.a };
574
- const JND = 0.02;
575
- const EPS = 1e-4;
576
- for (let i = 0; i < 30; i++) {
577
- const mid = (low + high) / 2;
578
- const candidate = oklabToRgb(oklchToOklab({ l: lch.l, c: mid, h: lch.h, alpha: c.a }));
579
- const clipped = {
580
- r: clamp01(candidate.r),
581
- g: clamp01(candidate.g),
582
- b: clamp01(candidate.b),
583
- a: c.a
584
- };
585
- clippedCandidate = clipped;
586
- const dE = deltaEOK(candidate, clipped);
587
- if (dE < JND) {
588
- if (JND - dE < EPS) {
589
- return clipped;
590
- }
591
- low = mid;
592
- } else {
593
- high = mid;
594
- }
595
- if (high - low < 1e-4) {
596
- break;
597
- }
598
- }
599
- return clippedCandidate;
600
- }
601
12
 
602
- // src/color/format.ts
603
- var clamp012 = (v) => Math.min(1, Math.max(0, v));
604
- var byte = (v) => Math.round(clamp012(v) * 255);
605
- var hex2 = (n) => n.toString(16).padStart(2, "0");
606
- var round2 = (n) => (Math.round(n * 100) / 100).toString();
607
- function formatHex(c) {
608
- const mapped = toSrgbGamut(c);
609
- const head = `#${hex2(byte(mapped.r))}${hex2(byte(mapped.g))}${hex2(byte(mapped.b))}`;
610
- const alpha = byte(mapped.a);
611
- return alpha === 255 ? head : head + hex2(alpha);
612
- }
613
- function formatColor(c, format) {
614
- switch (format) {
615
- case "hex":
616
- return formatHex(c);
617
- case "rgb": {
618
- const inGamut = toSrgbGamut(c);
619
- const r = byte(inGamut.r);
620
- const g = byte(inGamut.g);
621
- const b = byte(inGamut.b);
622
- return c.a < 1 ? `rgb(${r} ${g} ${b} / ${round2(c.a)})` : `rgb(${r} ${g} ${b})`;
623
- }
624
- case "hsl": {
625
- const hsl = rgbToHsl(toSrgbGamut(c));
626
- const h = (Math.round(hsl.h * 100) / 100).toString();
627
- const s = (Math.round(hsl.s * 1e4) / 100).toString();
628
- const l = (Math.round(hsl.l * 1e4) / 100).toString();
629
- return c.a < 1 ? `hsl(${h} ${s}% ${l}% / ${round2(c.a)})` : `hsl(${h} ${s}% ${l}%)`;
630
- }
631
- case "oklch": {
632
- const lch = oklabToOklch(rgbToOklab(c));
633
- const l = (lch.l * 100).toFixed(2);
634
- const ch = lch.c.toFixed(4);
635
- const h = lch.h.toFixed(2);
636
- return c.a < 1 ? `oklch(${l}% ${ch} ${h} / ${round2(c.a)})` : `oklch(${l}% ${ch} ${h})`;
637
- }
638
- case "oklab": {
639
- const lab = rgbToOklab(c);
640
- const l = (lab.l * 100).toFixed(2);
641
- const a = lab.a.toFixed(4);
642
- const b = lab.b.toFixed(4);
643
- return c.a < 1 ? `oklab(${l}% ${a} ${b} / ${round2(c.a)})` : `oklab(${l}% ${a} ${b})`;
644
- }
645
- case "p3": {
646
- const linSrgb = {
647
- r: srgbToLinear(c.r),
648
- g: srgbToLinear(c.g),
649
- b: srgbToLinear(c.b),
650
- a: c.a
651
- };
652
- const linP3 = linearSrgbToDisplayP3(linSrgb);
653
- const r = linearToSrgb(linP3.r).toFixed(4);
654
- const g = linearToSrgb(linP3.g).toFixed(4);
655
- const b = linearToSrgb(linP3.b).toFixed(4);
656
- return c.a < 1 ? `color(display-p3 ${r} ${g} ${b} / ${round2(c.a)})` : `color(display-p3 ${r} ${g} ${b})`;
657
- }
658
- }
659
- }
660
- function normalizeColor(input) {
661
- const parsed = parseColor(input);
662
- return parsed ? formatHex(parsed) : null;
663
- }
664
13
 
665
- // src/color/contrast.ts
666
- var BLACK = { r: 0, g: 0, b: 0, a: 1 };
667
- var WHITE = { r: 1, g: 1, b: 1, a: 1 };
668
- function composite(fg, bg) {
669
- const a = fg.a + bg.a * (1 - fg.a);
670
- if (a === 0) return { r: 0, g: 0, b: 0, a: 0 };
671
- return {
672
- r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / a,
673
- g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / a,
674
- b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / a,
675
- a
676
- };
677
- }
678
- function relativeLuminance(c) {
679
- const r = srgbToLinear(c.r);
680
- const g = srgbToLinear(c.g);
681
- const b = srgbToLinear(c.b);
682
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
683
- }
684
- function contrastRatio(foreground, background) {
685
- let bg = background;
686
- if (bg.a < 1) {
687
- bg = composite(bg, WHITE);
688
- }
689
- let fg = foreground;
690
- if (fg.a < 1) {
691
- fg = composite(fg, bg);
692
- }
693
- const lum1 = relativeLuminance(fg);
694
- const lum2 = relativeLuminance(bg);
695
- const brighter = Math.max(lum1, lum2);
696
- const darker = Math.min(lum1, lum2);
697
- return (brighter + 0.05) / (darker + 0.05);
698
- }
699
- function contrastLevel(ratio, options) {
700
- const large = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.large]), () => ( false));
701
- if (large) {
702
- if (ratio >= 4.5) return "AAA";
703
- if (ratio >= 3) return "AA";
704
- return "fail";
705
- }
706
- if (ratio >= 7) return "AAA";
707
- if (ratio >= 4.5) return "AA";
708
- return "fail";
709
- }
710
- function readableTextColor(background, candidates = [BLACK, WHITE]) {
711
- let bestCandidate = _nullishCoalesce(candidates[0], () => ( BLACK));
712
- let bestRatio = -1;
713
- for (const candidate of candidates) {
714
- const ratio = contrastRatio(candidate, background);
715
- if (ratio > bestRatio) {
716
- bestRatio = ratio;
717
- bestCandidate = candidate;
718
- }
719
- }
720
- return bestCandidate;
721
- }
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+ var _chunkS6X2QRVUcjs = require('./chunk-S6X2QRVU.cjs');
722
24
 
723
25
  // src/color/vision.ts
724
26
  var CVD = {
@@ -738,16 +40,16 @@ var CVD = {
738
40
  [4733e-6, 0.691367, 0.3039]
739
41
  ]
740
42
  };
741
- var clamp013 = (v) => Math.max(0, Math.min(1, v));
43
+ var clamp01 = (v) => Math.max(0, Math.min(1, v));
742
44
  function simulateColorVision(c, vision) {
743
45
  if (vision === "normal") return c;
744
- const lr = srgbToLinear(c.r);
745
- const lg = srgbToLinear(c.g);
746
- const lb = srgbToLinear(c.b);
46
+ const lr = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c.r);
47
+ const lg = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c.g);
48
+ const lb = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c.b);
747
49
  const m = CVD[vision];
748
- const r = linearToSrgb(clamp013(m[0][0] * lr + m[0][1] * lg + m[0][2] * lb));
749
- const g = linearToSrgb(clamp013(m[1][0] * lr + m[1][1] * lg + m[1][2] * lb));
750
- const b = linearToSrgb(clamp013(m[2][0] * lr + m[2][1] * lg + m[2][2] * lb));
50
+ const r = _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, clamp01(m[0][0] * lr + m[0][1] * lg + m[0][2] * lb));
51
+ const g = _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, clamp01(m[1][0] * lr + m[1][1] * lg + m[1][2] * lb));
52
+ const b = _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, clamp01(m[2][0] * lr + m[2][1] * lg + m[2][2] * lb));
751
53
  return { r, g, b, a: c.a };
752
54
  }
753
55
  function checkPaletteColors(colors, options = {}) {
@@ -755,8 +57,8 @@ function checkPaletteColors(colors, options = {}) {
755
57
  const minDistance = _nullishCoalesce(options.minDistance, () => ( 0.08));
756
58
  const minContrast = _nullishCoalesce(options.minContrast, () => ( 1.5));
757
59
  const visions = _nullishCoalesce(options.visions, () => ( ["normal", "protanopia", "deuteranopia", "tritanopia"]));
758
- const parsed = colors.map((c) => parseColor(c));
759
- const surfaceParsed = parseColor(surfaceStr);
60
+ const parsed = colors.map((c) => _chunkS6X2QRVUcjs.parseColor.call(void 0, c));
61
+ const surfaceParsed = _chunkS6X2QRVUcjs.parseColor.call(void 0, surfaceStr);
760
62
  const skipped = colors.filter((_, i) => !parsed[i]);
761
63
  const issues = [];
762
64
  const closest = {};
@@ -766,7 +68,7 @@ function checkPaletteColors(colors, options = {}) {
766
68
  for (let a = 0; a < seen.length; a++) {
767
69
  for (let b = a + 1; b < seen.length; b++) {
768
70
  if (!seen[a] || !seen[b]) continue;
769
- const distance = deltaEOK(seen[a], seen[b]);
71
+ const distance = _chunkS6X2QRVUcjs.deltaEOK.call(void 0, seen[a], seen[b]);
770
72
  if (!best || distance < best.distance) {
771
73
  best = {
772
74
  a,
@@ -790,7 +92,7 @@ function checkPaletteColors(colors, options = {}) {
790
92
  const contrast = colors.map((_, i) => {
791
93
  const c = parsed[i];
792
94
  if (!c || !surfaceParsed) return null;
793
- const ratio = contrastRatio(c, surfaceParsed);
95
+ const ratio = _chunkS6X2QRVUcjs.contrastRatio.call(void 0, c, surfaceParsed);
794
96
  return Math.round(ratio * 100) / 100;
795
97
  });
796
98
  contrast.forEach((ratio, i) => {
@@ -814,7 +116,7 @@ var HARMONY_KINDS = [
814
116
  "monochromatic"
815
117
  ];
816
118
  var HEX_6 = /^#?([0-9a-f]{6})$/i;
817
- function parseHex2(value, what = "color") {
119
+ function parseHex(value, what = "color") {
818
120
  const m = typeof value === "string" ? HEX_6.exec(value.trim()) : null;
819
121
  if (!m) throw new Error(`${what} is ${JSON.stringify(value)}; use #rrggbb, e.g. "#2a4b8d".`);
820
122
  const n = parseInt(m[1], 16);
@@ -850,12 +152,12 @@ function hueToWheel(hue, wheel) {
850
152
  }
851
153
  function colorHarmony(base, kind, options = {}) {
852
154
  const wheel = _nullishCoalesce(options.wheel, () => ( "ryb"));
853
- const rgb = parseHex2(base, "base");
854
- const hsv = rgbToHsv(rgb);
155
+ const rgb = parseHex(base, "base");
156
+ const hsv = _chunkS6X2QRVUcjs.rgbToHsv.call(void 0, rgb);
855
157
  const start = hueToWheel(hsv.h, wheel);
856
158
  const at = (angle) => {
857
159
  const a = (angle % 360 + 360) % 360;
858
- return { color: toHex(hsvToRgb({ ...hsv, h: wheelToHue(a, wheel) })), angle: Math.round(a * 10) / 10 };
160
+ return { color: toHex(_chunkS6X2QRVUcjs.hsvToRgb.call(void 0, { ...hsv, h: wheelToHue(a, wheel) })), angle: Math.round(a * 10) / 10 };
859
161
  };
860
162
  const spread = _nullishCoalesce(options.spread, () => ( 30));
861
163
  const offsets = {
@@ -867,10 +169,10 @@ function colorHarmony(base, kind, options = {}) {
867
169
  square: [0, 90, 180, 270]
868
170
  };
869
171
  if (kind === "monochromatic") {
870
- const hsl = rgbToHsl(rgb);
172
+ const hsl = _chunkS6X2QRVUcjs.rgbToHsl.call(void 0, rgb);
871
173
  const steps = [0, -0.3, -0.15, 0.15, 0.3];
872
174
  return steps.map((d) => {
873
- const c = d === 0 ? rgb : hslToRgb({ ...hsl, l: Math.min(0.97, Math.max(0.03, hsl.l + d)) });
175
+ const c = d === 0 ? rgb : _chunkS6X2QRVUcjs.hslToRgb.call(void 0, { ...hsl, l: Math.min(0.97, Math.max(0.03, hsl.l + d)) });
874
176
  return { color: toHex(c), angle: Math.round(start * 10) / 10 };
875
177
  });
876
178
  }
@@ -881,17 +183,17 @@ function colorHarmony(base, kind, options = {}) {
881
183
 
882
184
  // src/color/mix.ts
883
185
  function mixColors(from, to, t, options = {}) {
884
- const c1 = parseColor(from);
885
- const c2 = parseColor(to);
186
+ const c1 = _chunkS6X2QRVUcjs.parseColor.call(void 0, from);
187
+ const c2 = _chunkS6X2QRVUcjs.parseColor.call(void 0, to);
886
188
  if (!c1 || !c2) return null;
887
189
  const space = _nullishCoalesce(options.space, () => ( "oklab"));
888
190
  const alpha = c1.a + (c2.a - c1.a) * t;
889
191
  if (space === "oklab") {
890
- const lab1 = rgbToOklab(c1);
891
- const lab2 = rgbToOklab(c2);
192
+ const lab1 = _chunkS6X2QRVUcjs.rgbToOklab.call(void 0, c1);
193
+ const lab2 = _chunkS6X2QRVUcjs.rgbToOklab.call(void 0, c2);
892
194
  if (alpha <= 1e-9) {
893
195
  const lab3 = { l: lab1.l + (lab2.l - lab1.l) * t, a: 0, b: 0, alpha: 0 };
894
- return formatHex(oklabToRgb(lab3));
196
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, _chunkS6X2QRVUcjs.oklabToRgb.call(void 0, lab3));
895
197
  }
896
198
  const premul = (k) => lab1[k] * lab1.alpha + (lab2[k] * lab2.alpha - lab1[k] * lab1.alpha) * t;
897
199
  const lab = {
@@ -900,11 +202,11 @@ function mixColors(from, to, t, options = {}) {
900
202
  b: premul("b") / alpha,
901
203
  alpha
902
204
  };
903
- return formatHex(oklabToRgb(lab));
205
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, _chunkS6X2QRVUcjs.oklabToRgb.call(void 0, lab));
904
206
  }
905
207
  if (space === "oklch") {
906
- const lch1 = oklabToOklch(rgbToOklab(c1));
907
- const lch2 = oklabToOklch(rgbToOklab(c2));
208
+ const lch1 = _chunkS6X2QRVUcjs.oklabToOklch.call(void 0, _chunkS6X2QRVUcjs.rgbToOklab.call(void 0, c1));
209
+ const lch2 = _chunkS6X2QRVUcjs.oklabToOklch.call(void 0, _chunkS6X2QRVUcjs.rgbToOklab.call(void 0, c2));
908
210
  let h1 = lch1.h;
909
211
  let h2 = lch2.h;
910
212
  const diff = h2 - h1;
@@ -913,41 +215,41 @@ function mixColors(from, to, t, options = {}) {
913
215
  const h = ((h1 + (h2 - h1) * t) % 360 + 360) % 360;
914
216
  if (alpha <= 1e-9) {
915
217
  const l2 = lch1.l + (lch2.l - lch1.l) * t;
916
- return formatHex(oklabToRgb(oklchToOklab({ l: l2, c: 0, h: 0, alpha: 0 })));
218
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, _chunkS6X2QRVUcjs.oklabToRgb.call(void 0, _chunkS6X2QRVUcjs.oklchToOklab.call(void 0, { l: l2, c: 0, h: 0, alpha: 0 })));
917
219
  }
918
220
  const lPremul = lch1.l * lch1.alpha + (lch2.l * lch2.alpha - lch1.l * lch1.alpha) * t;
919
221
  const cPremul = lch1.c * lch1.alpha + (lch2.c * lch2.alpha - lch1.c * lch1.alpha) * t;
920
222
  const l = lPremul / alpha;
921
223
  const c = cPremul / alpha;
922
- return formatHex(oklabToRgb(oklchToOklab({ l, c, h, alpha })));
224
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, _chunkS6X2QRVUcjs.oklabToRgb.call(void 0, _chunkS6X2QRVUcjs.oklchToOklab.call(void 0, { l, c, h, alpha })));
923
225
  }
924
226
  if (space === "srgb-linear") {
925
- const lr1 = srgbToLinear(c1.r);
926
- const lg1 = srgbToLinear(c1.g);
927
- const lb1 = srgbToLinear(c1.b);
928
- const lr2 = srgbToLinear(c2.r);
929
- const lg2 = srgbToLinear(c2.g);
930
- const lb2 = srgbToLinear(c2.b);
227
+ const lr1 = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c1.r);
228
+ const lg1 = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c1.g);
229
+ const lb1 = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c1.b);
230
+ const lr2 = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c2.r);
231
+ const lg2 = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c2.g);
232
+ const lb2 = _chunkS6X2QRVUcjs.srgbToLinear.call(void 0, c2.b);
931
233
  if (alpha <= 1e-9) {
932
- return formatHex({
933
- r: linearToSrgb(lr1 + (lr2 - lr1) * t),
934
- g: linearToSrgb(lg1 + (lg2 - lg1) * t),
935
- b: linearToSrgb(lb1 + (lb2 - lb1) * t),
234
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, {
235
+ r: _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, lr1 + (lr2 - lr1) * t),
236
+ g: _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, lg1 + (lg2 - lg1) * t),
237
+ b: _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, lb1 + (lb2 - lb1) * t),
936
238
  a: 0
937
239
  });
938
240
  }
939
241
  const premulR2 = lr1 * c1.a + (lr2 * c2.a - lr1 * c1.a) * t;
940
242
  const premulG2 = lg1 * c1.a + (lg2 * c2.a - lg1 * c1.a) * t;
941
243
  const premulB2 = lb1 * c1.a + (lb2 * c2.a - lb1 * c1.a) * t;
942
- return formatHex({
943
- r: linearToSrgb(premulR2 / alpha),
944
- g: linearToSrgb(premulG2 / alpha),
945
- b: linearToSrgb(premulB2 / alpha),
244
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, {
245
+ r: _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, premulR2 / alpha),
246
+ g: _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, premulG2 / alpha),
247
+ b: _chunkS6X2QRVUcjs.linearToSrgb.call(void 0, premulB2 / alpha),
946
248
  a: alpha
947
249
  });
948
250
  }
949
251
  if (alpha <= 1e-9) {
950
- return formatHex({
252
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, {
951
253
  r: c1.r + (c2.r - c1.r) * t,
952
254
  g: c1.g + (c2.g - c1.g) * t,
953
255
  b: c1.b + (c2.b - c1.b) * t,
@@ -957,7 +259,7 @@ function mixColors(from, to, t, options = {}) {
957
259
  const premulR = c1.r * c1.a + (c2.r * c2.a - c1.r * c1.a) * t;
958
260
  const premulG = c1.g * c1.a + (c2.g * c2.a - c1.g * c1.a) * t;
959
261
  const premulB = c1.b * c1.a + (c2.b * c2.a - c1.b * c1.a) * t;
960
- return formatHex({
262
+ return _chunkS6X2QRVUcjs.formatHex.call(void 0, {
961
263
  r: premulR / alpha,
962
264
  g: premulG / alpha,
963
265
  b: premulB / alpha,
@@ -967,9 +269,9 @@ function mixColors(from, to, t, options = {}) {
967
269
 
968
270
  // src/color/recent.ts
969
271
  function pushRecentColor(list, color, max = 12) {
970
- const normal = normalizeColor(color);
272
+ const normal = _chunkS6X2QRVUcjs.normalizeColor.call(void 0, color);
971
273
  if (!normal) return list.slice();
972
- const next = [normal, ...list.filter((c) => normalizeColor(c) !== normal)];
274
+ const next = [normal, ...list.filter((c) => _chunkS6X2QRVUcjs.normalizeColor.call(void 0, c) !== normal)];
973
275
  return next.slice(0, max);
974
276
  }
975
277
 
@@ -985,7 +287,7 @@ function isDualColor(value) {
985
287
  function parseDualColor(input) {
986
288
  if (input === null || input === void 0) return null;
987
289
  if (isDualColor(input)) {
988
- if (parseColor(input.light) === null || parseColor(input.dark) === null) {
290
+ if (_chunkS6X2QRVUcjs.parseColor.call(void 0, input.light) === null || _chunkS6X2QRVUcjs.parseColor.call(void 0, input.dark) === null) {
989
291
  return null;
990
292
  }
991
293
  return { light: input.light, dark: input.dark };
@@ -1019,12 +321,12 @@ function parseDualColor(input) {
1019
321
  const lightPart = inner.slice(0, commaIndex).trim();
1020
322
  const darkPart = inner.slice(commaIndex + 1).trim();
1021
323
  if (!lightPart || !darkPart) return null;
1022
- if (parseColor(lightPart) === null || parseColor(darkPart) === null) {
324
+ if (_chunkS6X2QRVUcjs.parseColor.call(void 0, lightPart) === null || _chunkS6X2QRVUcjs.parseColor.call(void 0, darkPart) === null) {
1023
325
  return null;
1024
326
  }
1025
327
  return { light: lightPart, dark: darkPart };
1026
328
  }
1027
- if (parseColor(trimmed) !== null) {
329
+ if (_chunkS6X2QRVUcjs.parseColor.call(void 0, trimmed) !== null) {
1028
330
  return { light: trimmed, dark: trimmed };
1029
331
  }
1030
332
  }
@@ -1033,8 +335,8 @@ function parseDualColor(input) {
1033
335
  function normalizeDualColor(input) {
1034
336
  const parsed = parseDualColor(input);
1035
337
  if (!parsed) return null;
1036
- const light = normalizeColor(parsed.light);
1037
- const dark = normalizeColor(parsed.dark);
338
+ const light = _chunkS6X2QRVUcjs.normalizeColor.call(void 0, parsed.light);
339
+ const dark = _chunkS6X2QRVUcjs.normalizeColor.call(void 0, parsed.dark);
1038
340
  if (!light || !dark) return null;
1039
341
  return { light, dark };
1040
342
  }
@@ -1044,58 +346,58 @@ function resolveColor(value, scheme) {
1044
346
  return scheme === "dark" ? normalized.dark : normalized.light;
1045
347
  }
1046
348
  function formatDualColor(value) {
1047
- const light = _nullishCoalesce(normalizeColor(value.light), () => ( value.light));
1048
- const dark = _nullishCoalesce(normalizeColor(value.dark), () => ( value.dark));
349
+ const light = _nullishCoalesce(_chunkS6X2QRVUcjs.normalizeColor.call(void 0, value.light), () => ( value.light));
350
+ const dark = _nullishCoalesce(_chunkS6X2QRVUcjs.normalizeColor.call(void 0, value.dark), () => ( value.dark));
1049
351
  if (light === dark) {
1050
352
  return light;
1051
353
  }
1052
354
  return `light-dark(${light}, ${dark})`;
1053
355
  }
1054
356
  function isSameInBothSchemes(value) {
1055
- const light = normalizeColor(value.light);
1056
- const dark = normalizeColor(value.dark);
357
+ const light = _chunkS6X2QRVUcjs.normalizeColor.call(void 0, value.light);
358
+ const dark = _chunkS6X2QRVUcjs.normalizeColor.call(void 0, value.dark);
1057
359
  if (!light || !dark) return value.light === value.dark;
1058
360
  return light === dark;
1059
361
  }
1060
362
  function setDualColorSide(value, scheme, color) {
1061
363
  const base = _nullishCoalesce(normalizeDualColor(value), () => ( { light: "#000000", dark: "#000000" }));
1062
- const normColor = _nullishCoalesce(normalizeColor(color), () => ( color));
364
+ const normColor = _nullishCoalesce(_chunkS6X2QRVUcjs.normalizeColor.call(void 0, color), () => ( color));
1063
365
  return {
1064
366
  light: scheme === "light" ? normColor : base.light,
1065
367
  dark: scheme === "dark" ? normColor : base.dark
1066
368
  };
1067
369
  }
1068
370
  function deriveDualColor(color, options) {
1069
- const fromScheme = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _3 => _3.from]), () => ( "light"));
1070
- const baseRgba = parseColor(color);
371
+ const fromScheme = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.from]), () => ( "light"));
372
+ const baseRgba = _chunkS6X2QRVUcjs.parseColor.call(void 0, color);
1071
373
  if (!baseRgba) {
1072
374
  throw new Error(`"${String(color)}" is not a colour; pass hex, rgb(), hsl(), oklch() or a CSS colour name.`);
1073
375
  }
1074
- if (_optionalChain([options, 'optionalAccess', _4 => _4.surfaces]) && !normalizeDualColor(options.surfaces)) {
376
+ if (_optionalChain([options, 'optionalAccess', _3 => _3.surfaces]) && !normalizeDualColor(options.surfaces)) {
1075
377
  throw new Error('The surfaces need a readable light and dark colour, e.g. { light: "#ffffff", dark: "#0b0b0f" }.');
1076
378
  }
1077
- const baseHex = formatHex(baseRgba);
1078
- const lab = rgbToOklab(baseRgba);
1079
- const lch = oklabToOklch(lab);
379
+ const baseHex = _chunkS6X2QRVUcjs.formatHex.call(void 0, baseRgba);
380
+ const lab = _chunkS6X2QRVUcjs.rgbToOklab.call(void 0, baseRgba);
381
+ const lch = _chunkS6X2QRVUcjs.oklabToOklch.call(void 0, lab);
1080
382
  const startL = clamp(1.05 - lch.l, 0.12, 0.95);
1081
383
  const targetC = lch.c * 0.9;
1082
384
  const targetH = lch.h;
1083
385
  let derivedHex;
1084
- if (_optionalChain([options, 'optionalAccess', _5 => _5.surfaces])) {
386
+ if (_optionalChain([options, 'optionalAccess', _4 => _4.surfaces])) {
1085
387
  const surfaces = options.surfaces;
1086
- const fromSurfaceRgba = parseColor(surfaces[fromScheme]);
388
+ const fromSurfaceRgba = _chunkS6X2QRVUcjs.parseColor.call(void 0, surfaces[fromScheme]);
1087
389
  const targetScheme = fromScheme === "light" ? "dark" : "light";
1088
- const targetSurfaceRgba = parseColor(surfaces[targetScheme]);
1089
- const targetRatio = contrastRatio(baseRgba, fromSurfaceRgba);
1090
- const targetSurfaceL = oklabToOklch(rgbToOklab(targetSurfaceRgba)).l;
390
+ const targetSurfaceRgba = _chunkS6X2QRVUcjs.parseColor.call(void 0, surfaces[targetScheme]);
391
+ const targetRatio = _chunkS6X2QRVUcjs.contrastRatio.call(void 0, baseRgba, fromSurfaceRgba);
392
+ const targetSurfaceL = _chunkS6X2QRVUcjs.oklabToOklch.call(void 0, _chunkS6X2QRVUcjs.rgbToOklab.call(void 0, targetSurfaceRgba)).l;
1091
393
  const preferHigherL = targetSurfaceL < 0.5;
1092
394
  let bestDiff = Infinity;
1093
395
  let bestL = startL;
1094
396
  for (let candL = 0.05; candL <= 0.98; candL += 5e-3) {
1095
- const candRgb = toSrgbGamut(
1096
- oklabToRgb(oklchToOklab({ l: candL, c: targetC, h: targetH, alpha: baseRgba.a }))
397
+ const candRgb = _chunkS6X2QRVUcjs.toSrgbGamut.call(void 0,
398
+ _chunkS6X2QRVUcjs.oklabToRgb.call(void 0, _chunkS6X2QRVUcjs.oklchToOklab.call(void 0, { l: candL, c: targetC, h: targetH, alpha: baseRgba.a }))
1097
399
  );
1098
- const ratio = contrastRatio(candRgb, targetSurfaceRgba);
400
+ const ratio = _chunkS6X2QRVUcjs.contrastRatio.call(void 0, candRgb, targetSurfaceRgba);
1099
401
  const diff = Math.abs(ratio - targetRatio);
1100
402
  const isBetter = diff < bestDiff - 1e-4 || Math.abs(diff - bestDiff) <= 1e-4 && (preferHigherL ? candL > bestL : candL < bestL);
1101
403
  if (isBetter) {
@@ -1103,20 +405,20 @@ function deriveDualColor(color, options) {
1103
405
  bestL = candL;
1104
406
  }
1105
407
  }
1106
- const finalRgba = toSrgbGamut(
1107
- oklabToRgb(oklchToOklab({ l: bestL, c: targetC, h: targetH, alpha: baseRgba.a }))
408
+ const finalRgba = _chunkS6X2QRVUcjs.toSrgbGamut.call(void 0,
409
+ _chunkS6X2QRVUcjs.oklabToRgb.call(void 0, _chunkS6X2QRVUcjs.oklchToOklab.call(void 0, { l: bestL, c: targetC, h: targetH, alpha: baseRgba.a }))
1108
410
  );
1109
- derivedHex = formatHex(finalRgba);
411
+ derivedHex = _chunkS6X2QRVUcjs.formatHex.call(void 0, finalRgba);
1110
412
  } else {
1111
- const finalRgba = toSrgbGamut(
1112
- oklabToRgb(oklchToOklab({ l: startL, c: targetC, h: targetH, alpha: baseRgba.a }))
413
+ const finalRgba = _chunkS6X2QRVUcjs.toSrgbGamut.call(void 0,
414
+ _chunkS6X2QRVUcjs.oklabToRgb.call(void 0, _chunkS6X2QRVUcjs.oklchToOklab.call(void 0, { l: startL, c: targetC, h: targetH, alpha: baseRgba.a }))
1113
415
  );
1114
- derivedHex = formatHex(finalRgba);
416
+ derivedHex = _chunkS6X2QRVUcjs.formatHex.call(void 0, finalRgba);
1115
417
  }
1116
418
  return fromScheme === "light" ? { light: baseHex, dark: derivedHex } : { light: derivedHex, dark: baseHex };
1117
419
  }
1118
420
  function checkDualColorContrast(foreground, background, options) {
1119
- const large = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.large]), () => ( false));
421
+ const large = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _5 => _5.large]), () => ( false));
1120
422
  const requiredRatio = large ? 3 : 4.5;
1121
423
  const fg = normalizeDualColor(foreground);
1122
424
  const bg = normalizeDualColor(background);
@@ -1126,14 +428,14 @@ function checkDualColorContrast(foreground, background, options) {
1126
428
  const lightBgHex = bg.light;
1127
429
  const darkFgHex = fg.dark;
1128
430
  const darkBgHex = bg.dark;
1129
- const lightFg = parseColor(lightFgHex);
1130
- const lightBg = parseColor(lightBgHex);
1131
- const darkFg = parseColor(darkFgHex);
1132
- const darkBg = parseColor(darkBgHex);
1133
- const lightRatio = Math.round(contrastRatio(lightFg, lightBg) * 100) / 100;
1134
- const darkRatio = Math.round(contrastRatio(darkFg, darkBg) * 100) / 100;
1135
- const lightLevel = contrastLevel(lightRatio, { large });
1136
- const darkLevel = contrastLevel(darkRatio, { large });
431
+ const lightFg = _chunkS6X2QRVUcjs.parseColor.call(void 0, lightFgHex);
432
+ const lightBg = _chunkS6X2QRVUcjs.parseColor.call(void 0, lightBgHex);
433
+ const darkFg = _chunkS6X2QRVUcjs.parseColor.call(void 0, darkFgHex);
434
+ const darkBg = _chunkS6X2QRVUcjs.parseColor.call(void 0, darkBgHex);
435
+ const lightRatio = Math.round(_chunkS6X2QRVUcjs.contrastRatio.call(void 0, lightFg, lightBg) * 100) / 100;
436
+ const darkRatio = Math.round(_chunkS6X2QRVUcjs.contrastRatio.call(void 0, darkFg, darkBg) * 100) / 100;
437
+ const lightLevel = _chunkS6X2QRVUcjs.contrastLevel.call(void 0, lightRatio, { large });
438
+ const darkLevel = _chunkS6X2QRVUcjs.contrastLevel.call(void 0, darkRatio, { large });
1137
439
  const issues = [];
1138
440
  if (lightLevel === "fail") {
1139
441
  issues.push(
@@ -1156,9 +458,9 @@ function describeValue(value) {
1156
458
  return typeof value === "string" ? value : _nullishCoalesce(JSON.stringify(value), () => ( String(value)));
1157
459
  }
1158
460
  function dualColorsToCss(colors, options) {
1159
- const selector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.selector]), () => ( ":root"));
1160
- const strategy = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _8 => _8.strategy]), () => ( "light-dark"));
1161
- const darkSelector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.darkSelector]), () => ( ".dark"));
461
+ const selector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.selector]), () => ( ":root"));
462
+ const strategy = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.strategy]), () => ( "light-dark"));
463
+ const darkSelector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _8 => _8.darkSelector]), () => ( ".dark"));
1162
464
  for (const [label, sel] of [["selector", selector], ["darkSelector", darkSelector]]) {
1163
465
  if (!sel.trim() || /[{};]/.test(sel)) {
1164
466
  throw new Error(`The ${label} "${sel}" is not a CSS selector (it can't be empty or contain "{", "}" or ";").`);
@@ -1250,7 +552,7 @@ function requireColor(input, name) {
1250
552
  if (typeof input !== "string" || !input.trim()) {
1251
553
  fail(`"${String(input)}" is not a colour I can read; use hex (#2a4b8d), rgb(), hsl(), oklch() or a CSS colour name.`);
1252
554
  }
1253
- const parsed = parseColor(input);
555
+ const parsed = _chunkS6X2QRVUcjs.parseColor.call(void 0, input);
1254
556
  if (!parsed) {
1255
557
  fail(`"${input}" is not a colour I can read; use hex (#2a4b8d), rgb(), hsl(), oklch() or a CSS colour name.`);
1256
558
  }
@@ -1263,28 +565,7 @@ function requireDualColor(input, name) {
1263
565
  }
1264
566
  return parsed;
1265
567
  }
1266
- function findAccessibleLightness(fg, bg, large) {
1267
- const lab = rgbToOklab(fg);
1268
- const lch = oklabToOklch(lab);
1269
- for (let d = 0.01; d <= 1; d += 0.01) {
1270
- const downL = Math.max(0, lch.l - d);
1271
- const upL = Math.min(1, lch.l + d);
1272
- const downCand = toSrgbGamut(oklabToRgb(oklchToOklab({ ...lch, l: downL })));
1273
- const upCand = toSrgbGamut(oklabToRgb(oklchToOklab({ ...lch, l: upL })));
1274
- const downRatio = contrastRatio(downCand, bg);
1275
- const upRatio = contrastRatio(upCand, bg);
1276
- const downPass = contrastLevel(downRatio, { large }) !== "fail";
1277
- const upPass = contrastLevel(upRatio, { large }) !== "fail";
1278
- if (downPass && upPass) {
1279
- return formatHex(downRatio >= upRatio ? downCand : upCand);
1280
- } else if (downPass) {
1281
- return formatHex(downCand);
1282
- } else if (upPass) {
1283
- return formatHex(upCand);
1284
- }
1285
- }
1286
- return void 0;
1287
- }
568
+ var findAccessibleLightness = (fg, bg, large) => _chunkS6X2QRVUcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
1288
569
  function createColorToolProvider(options = {}) {
1289
570
  const id = _nullishCoalesce(options.id, () => ( "color"));
1290
571
  const namespace = _nullishCoalesce(options.namespace, () => ( "color"));
@@ -1304,18 +585,18 @@ function createColorToolProvider(options = {}) {
1304
585
  handler: (args) => {
1305
586
  const { color } = args;
1306
587
  const rgba = requireColor(color, "color");
1307
- const inGamut = inSrgbGamut(rgba);
1308
- const mappedRgba = inGamut ? rgba : toSrgbGamut(rgba);
1309
- const hsl = rgbToHsl(mappedRgba);
1310
- const oklab = rgbToOklab(rgba);
1311
- const oklch = oklabToOklch(oklab);
588
+ const inGamut = _chunkS6X2QRVUcjs.inSrgbGamut.call(void 0, rgba);
589
+ const mappedRgba = inGamut ? rgba : _chunkS6X2QRVUcjs.toSrgbGamut.call(void 0, rgba);
590
+ const hsl = _chunkS6X2QRVUcjs.rgbToHsl.call(void 0, mappedRgba);
591
+ const oklab = _chunkS6X2QRVUcjs.rgbToOklab.call(void 0, rgba);
592
+ const oklch = _chunkS6X2QRVUcjs.oklabToOklch.call(void 0, oklab);
1312
593
  const formats = ["hex", "rgb", "hsl", "oklab", "oklch"];
1313
594
  const css = {};
1314
595
  for (const f of formats) {
1315
- css[f] = formatColor(rgba, f);
596
+ css[f] = _chunkS6X2QRVUcjs.formatColor.call(void 0, rgba, f);
1316
597
  }
1317
598
  return {
1318
- hex: formatHex(mappedRgba),
599
+ hex: _chunkS6X2QRVUcjs.formatHex.call(void 0, mappedRgba),
1319
600
  alpha: Math.round(rgba.a * 1e3) / 1e3,
1320
601
  rgb: {
1321
602
  r: Math.round(Math.min(1, Math.max(0, mappedRgba.r)) * 255),
@@ -1334,8 +615,8 @@ function createColorToolProvider(options = {}) {
1334
615
  },
1335
616
  css,
1336
617
  inSrgbGamut: inGamut,
1337
- ...inGamut ? {} : { gamutMappedHex: formatHex(mappedRgba) },
1338
- relativeLuminance: Math.round(relativeLuminance(mappedRgba) * 1e4) / 1e4
618
+ ...inGamut ? {} : { gamutMappedHex: _chunkS6X2QRVUcjs.formatHex.call(void 0, mappedRgba) },
619
+ relativeLuminance: Math.round(_chunkS6X2QRVUcjs.relativeLuminance.call(void 0, mappedRgba) * 1e4) / 1e4
1339
620
  };
1340
621
  }
1341
622
  };
@@ -1358,35 +639,11 @@ function createColorToolProvider(options = {}) {
1358
639
  const { foreground, background, large = false } = args;
1359
640
  const fg = requireColor(foreground, "foreground");
1360
641
  const bg = requireColor(background, "background");
1361
- const ratio = Math.round(contrastRatio(fg, bg) * 100) / 100;
1362
- const level = contrastLevel(ratio, { large });
642
+ const ratio = Math.round(_chunkS6X2QRVUcjs.contrastRatio.call(void 0, fg, bg) * 100) / 100;
643
+ const level = _chunkS6X2QRVUcjs.contrastLevel.call(void 0, ratio, { large });
1363
644
  const passesAA = level === "AA" || level === "AAA";
1364
645
  const passesAAA = level === "AAA";
1365
- let suggestion;
1366
- if (!passesAA) {
1367
- const lab = rgbToOklab(fg);
1368
- const lch = oklabToOklch(lab);
1369
- for (let d = 0.01; d <= 1; d += 0.01) {
1370
- const downL = Math.max(0, lch.l - d);
1371
- const upL = Math.min(1, lch.l + d);
1372
- const downCand = toSrgbGamut(oklabToRgb(oklchToOklab({ ...lch, l: downL })));
1373
- const upCand = toSrgbGamut(oklabToRgb(oklchToOklab({ ...lch, l: upL })));
1374
- const downRatio = contrastRatio(downCand, bg);
1375
- const upRatio = contrastRatio(upCand, bg);
1376
- const downPass = contrastLevel(downRatio, { large }) !== "fail";
1377
- const upPass = contrastLevel(upRatio, { large }) !== "fail";
1378
- if (downPass && upPass) {
1379
- suggestion = formatHex(downRatio >= upRatio ? downCand : upCand);
1380
- break;
1381
- } else if (downPass) {
1382
- suggestion = formatHex(downCand);
1383
- break;
1384
- } else if (upPass) {
1385
- suggestion = formatHex(upCand);
1386
- break;
1387
- }
1388
- }
1389
- }
646
+ const suggestion = passesAA ? void 0 : _chunkS6X2QRVUcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
1390
647
  return {
1391
648
  ratio,
1392
649
  level,
@@ -1468,7 +725,7 @@ function createColorToolProvider(options = {}) {
1468
725
  handler: (args) => {
1469
726
  const { base, kind, wheel = "rgb", spread } = args;
1470
727
  const rgba = requireColor(base, "base");
1471
- const hex = formatHex(toSrgbGamut(rgba));
728
+ const hex = _chunkS6X2QRVUcjs.formatHex.call(void 0, _chunkS6X2QRVUcjs.toSrgbGamut.call(void 0, rgba));
1472
729
  if (!HARMONY_KINDS.includes(kind)) {
1473
730
  fail(`Unknown harmony kind "${kind}"; expected one of ${HARMONY_KINDS.join(", ")}.`);
1474
731
  }
@@ -1573,10 +830,10 @@ function createColorToolProvider(options = {}) {
1573
830
  from,
1574
831
  surfaces: keepContrast ? resolvedSurfaces : void 0
1575
832
  });
1576
- const lightSurfaceRgba = parseColor(resolvedSurfaces.light);
1577
- const darkSurfaceRgba = parseColor(resolvedSurfaces.dark);
1578
- const lightRatio = Math.round(contrastRatio(parseColor(derived.light), lightSurfaceRgba) * 100) / 100;
1579
- const darkRatio = Math.round(contrastRatio(parseColor(derived.dark), darkSurfaceRgba) * 100) / 100;
833
+ const lightSurfaceRgba = _chunkS6X2QRVUcjs.parseColor.call(void 0, resolvedSurfaces.light);
834
+ const darkSurfaceRgba = _chunkS6X2QRVUcjs.parseColor.call(void 0, resolvedSurfaces.dark);
835
+ const lightRatio = Math.round(_chunkS6X2QRVUcjs.contrastRatio.call(void 0, _chunkS6X2QRVUcjs.parseColor.call(void 0, derived.light), lightSurfaceRgba) * 100) / 100;
836
+ const darkRatio = Math.round(_chunkS6X2QRVUcjs.contrastRatio.call(void 0, _chunkS6X2QRVUcjs.parseColor.call(void 0, derived.dark), darkSurfaceRgba) * 100) / 100;
1580
837
  return {
1581
838
  light: derived.light,
1582
839
  dark: derived.dark,
@@ -1619,16 +876,16 @@ function createColorToolProvider(options = {}) {
1619
876
  const res = checkDualColorContrast(fg, bg, { large });
1620
877
  let suggestion;
1621
878
  if (res.light.level === "fail") {
1622
- const lightFg = parseColor(fg.light);
1623
- const lightBg = parseColor(bg.light);
879
+ const lightFg = _chunkS6X2QRVUcjs.parseColor.call(void 0, fg.light);
880
+ const lightBg = _chunkS6X2QRVUcjs.parseColor.call(void 0, bg.light);
1624
881
  const fixed = findAccessibleLightness(lightFg, lightBg, large);
1625
882
  if (fixed) {
1626
883
  suggestion = { ..._nullishCoalesce(suggestion, () => ( {})), light: fixed };
1627
884
  }
1628
885
  }
1629
886
  if (res.dark.level === "fail") {
1630
- const darkFg = parseColor(fg.dark);
1631
- const darkBg = parseColor(bg.dark);
887
+ const darkFg = _chunkS6X2QRVUcjs.parseColor.call(void 0, fg.dark);
888
+ const darkBg = _chunkS6X2QRVUcjs.parseColor.call(void 0, bg.dark);
1632
889
  const fixed = findAccessibleLightness(darkFg, darkBg, large);
1633
890
  if (fixed) {
1634
891
  suggestion = { ..._nullishCoalesce(suggestion, () => ( {})), dark: fixed };
@@ -1712,13 +969,13 @@ function pickerStateFromColor(input, previous) {
1712
969
  if (typeof input === "object" && "r" in input && "g" in input && "b" in input) {
1713
970
  rgba = input;
1714
971
  } else if (typeof input === "string") {
1715
- rgba = parseColor(input);
972
+ rgba = _chunkS6X2QRVUcjs.parseColor.call(void 0, input);
1716
973
  } else {
1717
974
  return null;
1718
975
  }
1719
976
  if (!rgba) return null;
1720
- const clampedRgba = toSrgbGamut(rgba);
1721
- const hsva = rgbToHsv(clampedRgba);
977
+ const clampedRgba = _chunkS6X2QRVUcjs.toSrgbGamut.call(void 0, rgba);
978
+ const hsva = _chunkS6X2QRVUcjs.rgbToHsv.call(void 0, clampedRgba);
1722
979
  let h = hsva.h;
1723
980
  let s = hsva.s;
1724
981
  const v = hsva.v;
@@ -1739,13 +996,13 @@ function pickerStateFromColor(input, previous) {
1739
996
  };
1740
997
  }
1741
998
  function pickerStateToHex(state, forceAlpha = false) {
1742
- const rgba = hsvToRgb({
999
+ const rgba = _chunkS6X2QRVUcjs.hsvToRgb.call(void 0, {
1743
1000
  h: state.h,
1744
1001
  s: state.s,
1745
1002
  v: state.v,
1746
1003
  alpha: state.alpha
1747
1004
  });
1748
- const hex = formatHex(rgba);
1005
+ const hex = _chunkS6X2QRVUcjs.formatHex.call(void 0, rgba);
1749
1006
  if (forceAlpha && hex.length === 7) {
1750
1007
  return hex + "ff";
1751
1008
  }
@@ -1834,13 +1091,13 @@ function pickerKeyStep(state, target, key, shift) {
1834
1091
  }
1835
1092
  }
1836
1093
  function pickerAreaBackground(state) {
1837
- const pureHueRgb = hsvToRgb({ h: state.h, s: 1, v: 1, alpha: 1 });
1838
- const hueHex = formatHex(pureHueRgb);
1094
+ const pureHueRgb = _chunkS6X2QRVUcjs.hsvToRgb.call(void 0, { h: state.h, s: 1, v: 1, alpha: 1 });
1095
+ const hueHex = _chunkS6X2QRVUcjs.formatHex.call(void 0, pureHueRgb);
1839
1096
  return `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${hueHex})`;
1840
1097
  }
1841
1098
  function pickerAlphaBackground(state) {
1842
- const opaqueRgb = hsvToRgb({ h: state.h, s: state.s, v: state.v, alpha: 1 });
1843
- const hex = formatHex(opaqueRgb);
1099
+ const opaqueRgb = _chunkS6X2QRVUcjs.hsvToRgb.call(void 0, { h: state.h, s: state.s, v: state.v, alpha: 1 });
1100
+ const hex = _chunkS6X2QRVUcjs.formatHex.call(void 0, opaqueRgb);
1844
1101
  return `linear-gradient(to right, transparent, ${hex})`;
1845
1102
  }
1846
1103
  var PICKER_HUE_BACKGROUND = "linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%)";
@@ -1885,29 +1142,4 @@ function dualPickerView(value, scheme) {
1885
1142
 
1886
1143
 
1887
1144
 
1888
-
1889
-
1890
-
1891
-
1892
-
1893
-
1894
-
1895
-
1896
-
1897
-
1898
-
1899
-
1900
-
1901
-
1902
-
1903
-
1904
-
1905
-
1906
-
1907
-
1908
-
1909
-
1910
-
1911
-
1912
-
1913
- exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.rgbToHsv = rgbToHsv; exports.hsvToRgb = hsvToRgb; exports.rgbToOklab = rgbToOklab; exports.oklabToRgb = oklabToRgb; exports.oklabToOklch = oklabToOklch; exports.oklchToOklab = oklchToOklab; exports.linearSrgbToDisplayP3 = linearSrgbToDisplayP3; exports.displayP3ToLinearSrgb = displayP3ToLinearSrgb; exports.NAMED_COLORS = NAMED_COLORS; exports.parseColor = parseColor; exports.isColor = isColor; exports.inSrgbGamut = inSrgbGamut; exports.deltaEOK = deltaEOK; exports.toSrgbGamut = toSrgbGamut; exports.formatHex = formatHex; exports.formatColor = formatColor; exports.normalizeColor = normalizeColor; exports.relativeLuminance = relativeLuminance; exports.contrastRatio = contrastRatio; exports.contrastLevel = contrastLevel; exports.readableTextColor = readableTextColor; exports.simulateColorVision = simulateColorVision; exports.checkPaletteColors = checkPaletteColors; exports.HARMONY_KINDS = HARMONY_KINDS; exports.wheelToHue = wheelToHue; exports.hueToWheel = hueToWheel; exports.colorHarmony = colorHarmony; exports.mixColors = mixColors; exports.pushRecentColor = pushRecentColor; exports.DEFAULT_SCHEME_SURFACES = DEFAULT_SCHEME_SURFACES; exports.isDualColor = isDualColor; exports.parseDualColor = parseDualColor; exports.normalizeDualColor = normalizeDualColor; exports.resolveColor = resolveColor; exports.formatDualColor = formatDualColor; exports.isSameInBothSchemes = isSameInBothSchemes; exports.setDualColorSide = setDualColorSide; exports.deriveDualColor = deriveDualColor; exports.checkDualColorContrast = checkDualColorContrast; exports.dualColorsToCss = dualColorsToCss; exports.createColorToolProvider = createColorToolProvider; exports.pickerStateFromColor = pickerStateFromColor; exports.pickerStateToHex = pickerStateToHex; exports.pickerStateFromArea = pickerStateFromArea; exports.pickerStateFromHue = pickerStateFromHue; exports.pickerStateFromAlpha = pickerStateFromAlpha; exports.pickerKeyStep = pickerKeyStep; exports.pickerAreaBackground = pickerAreaBackground; exports.pickerAlphaBackground = pickerAlphaBackground; exports.PICKER_HUE_BACKGROUND = PICKER_HUE_BACKGROUND; exports.dualPickerView = dualPickerView;
1145
+ exports.simulateColorVision = simulateColorVision; exports.checkPaletteColors = checkPaletteColors; exports.HARMONY_KINDS = HARMONY_KINDS; exports.wheelToHue = wheelToHue; exports.hueToWheel = hueToWheel; exports.colorHarmony = colorHarmony; exports.mixColors = mixColors; exports.pushRecentColor = pushRecentColor; exports.DEFAULT_SCHEME_SURFACES = DEFAULT_SCHEME_SURFACES; exports.isDualColor = isDualColor; exports.parseDualColor = parseDualColor; exports.normalizeDualColor = normalizeDualColor; exports.resolveColor = resolveColor; exports.formatDualColor = formatDualColor; exports.isSameInBothSchemes = isSameInBothSchemes; exports.setDualColorSide = setDualColorSide; exports.deriveDualColor = deriveDualColor; exports.checkDualColorContrast = checkDualColorContrast; exports.dualColorsToCss = dualColorsToCss; exports.createColorToolProvider = createColorToolProvider; exports.pickerStateFromColor = pickerStateFromColor; exports.pickerStateToHex = pickerStateToHex; exports.pickerStateFromArea = pickerStateFromArea; exports.pickerStateFromHue = pickerStateFromHue; exports.pickerStateFromAlpha = pickerStateFromAlpha; exports.pickerKeyStep = pickerKeyStep; exports.pickerAreaBackground = pickerAreaBackground; exports.pickerAlphaBackground = pickerAlphaBackground; exports.PICKER_HUE_BACKGROUND = PICKER_HUE_BACKGROUND; exports.dualPickerView = dualPickerView;