@thednp/color-picker 1.0.0 → 2.0.0-alpha1

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 (88) hide show
  1. package/.eslintrc.cjs +199 -0
  2. package/.lgtm.yml +9 -0
  3. package/.prettierrc.json +15 -0
  4. package/.stylelintrc.json +236 -0
  5. package/LICENSE +0 -0
  6. package/README.md +63 -80
  7. package/compile.js +48 -0
  8. package/cypress/downloads/downloads.htm +0 -0
  9. package/cypress/e2e/color-palette.cy.ts +128 -0
  10. package/cypress/e2e/color-picker.cy.ts +920 -0
  11. package/cypress/fixtures/colorNamesFrench.js +3 -0
  12. package/cypress/fixtures/componentLabelsFrench.js +21 -0
  13. package/cypress/fixtures/format.js +3 -0
  14. package/cypress/fixtures/getCEMarkup.js +29 -0
  15. package/cypress/fixtures/getMarkup.js +28 -0
  16. package/cypress/fixtures/getRandomInt.js +6 -0
  17. package/cypress/fixtures/sampleWebcolors.js +18 -0
  18. package/cypress/fixtures/testSample.js +8 -0
  19. package/cypress/plugins/esbuild-istanbul.ts +50 -0
  20. package/cypress/plugins/tsCompile.ts +34 -0
  21. package/cypress/support/commands.ts +0 -0
  22. package/cypress/support/e2e.ts +21 -0
  23. package/cypress/test.html +23 -0
  24. package/cypress.config.ts +29 -0
  25. package/dist/css/color-picker.css +15 -39
  26. package/dist/css/color-picker.min.css +2 -2
  27. package/dist/css/color-picker.rtl.css +15 -39
  28. package/dist/css/color-picker.rtl.min.css +2 -2
  29. package/dist/js/color-picker.cjs +8 -0
  30. package/dist/js/color-picker.cjs.map +1 -0
  31. package/dist/js/color-picker.d.ts +278 -0
  32. package/dist/js/color-picker.js +5 -3583
  33. package/dist/js/color-picker.js.map +1 -0
  34. package/dist/js/color-picker.mjs +2631 -0
  35. package/dist/js/color-picker.mjs.map +1 -0
  36. package/dts.config.ts +15 -0
  37. package/package.json +64 -74
  38. package/src/scss/_variables.scss +0 -1
  39. package/src/scss/color-picker.rtl.scss +4 -0
  40. package/src/scss/color-picker.scss +75 -39
  41. package/src/ts/colorPalette.ts +89 -0
  42. package/src/{js/color-picker.js → ts/index.ts} +492 -502
  43. package/src/ts/interface/colorPickerLabels.ts +20 -0
  44. package/src/ts/interface/colorPickerOptions.ts +11 -0
  45. package/src/ts/interface/paletteOptions.ts +6 -0
  46. package/src/ts/util/colorNames.ts +21 -0
  47. package/src/{js/util/colorPickerLabels.js → ts/util/colorPickerLabels.ts} +4 -2
  48. package/src/ts/util/getColorControls.ts +90 -0
  49. package/src/{js/util/getColorForm.js → ts/util/getColorForm.ts} +28 -18
  50. package/src/{js/util/getColorMenu.js → ts/util/getColorMenu.ts} +21 -30
  51. package/src/ts/util/isValidJSON.ts +19 -0
  52. package/src/{js/util/setMarkup.js → ts/util/setMarkup.ts} +57 -48
  53. package/src/{js/util/vHidden.js → ts/util/vHidden.ts} +0 -0
  54. package/tsconfig.json +29 -0
  55. package/vite.config.ts +34 -0
  56. package/dist/js/color-esm.js +0 -1167
  57. package/dist/js/color-esm.min.js +0 -2
  58. package/dist/js/color-palette-esm.js +0 -1238
  59. package/dist/js/color-palette-esm.min.js +0 -2
  60. package/dist/js/color-palette.js +0 -1246
  61. package/dist/js/color-palette.min.js +0 -2
  62. package/dist/js/color-picker-element-esm.js +0 -3739
  63. package/dist/js/color-picker-element-esm.min.js +0 -2
  64. package/dist/js/color-picker-element.js +0 -3747
  65. package/dist/js/color-picker-element.min.js +0 -2
  66. package/dist/js/color-picker-esm.js +0 -3578
  67. package/dist/js/color-picker-esm.min.js +0 -2
  68. package/dist/js/color-picker.min.js +0 -2
  69. package/dist/js/color.js +0 -1175
  70. package/dist/js/color.min.js +0 -2
  71. package/src/js/color-palette.js +0 -75
  72. package/src/js/color-picker-element.js +0 -110
  73. package/src/js/color.js +0 -1107
  74. package/src/js/index.js +0 -3
  75. package/src/js/util/colorNames.js +0 -6
  76. package/src/js/util/getColorControls.js +0 -103
  77. package/src/js/util/isValidJSON.js +0 -13
  78. package/src/js/util/nonColors.js +0 -5
  79. package/src/js/util/roundPart.js +0 -9
  80. package/src/js/util/setCSSProperties.js +0 -12
  81. package/src/js/util/tabindex.js +0 -3
  82. package/src/js/util/toggleCEAttr.js +0 -70
  83. package/src/js/util/version.js +0 -6
  84. package/src/js/version.js +0 -6
  85. package/types/cp.d.ts +0 -544
  86. package/types/index.d.ts +0 -48
  87. package/types/source/source.ts +0 -5
  88. package/types/source/types.d.ts +0 -92
@@ -0,0 +1,2631 @@
1
+ const J = {}, he = (o) => {
2
+ const { type: t, currentTarget: e } = o;
3
+ [...J[t]].forEach(([s, n]) => {
4
+ e === s && [...n].forEach(([r, i]) => {
5
+ r.apply(s, [o]), typeof i == "object" && i.once && Bt(s, t, r, i);
6
+ });
7
+ });
8
+ }, ge = (o, t, e, s) => {
9
+ J[t] || (J[t] = /* @__PURE__ */ new Map());
10
+ const n = J[t];
11
+ n.has(o) || n.set(o, /* @__PURE__ */ new Map());
12
+ const r = n.get(o), { size: i } = r;
13
+ r.set(e, s), i || o.addEventListener(t, he, s);
14
+ }, Bt = (o, t, e, s) => {
15
+ const n = J[t], r = n && n.get(o), i = r && r.get(e), a = i !== void 0 ? i : s;
16
+ r && r.has(e) && r.delete(e), n && (!r || !r.size) && n.delete(o), (!n || !n.size) && delete J[t], (!r || !r.size) && o.removeEventListener(t, he, a);
17
+ }, Gt = "aria-description", Nt = "aria-expanded", Me = "aria-hidden", Pt = "aria-selected", et = "aria-valuenow", ot = "aria-valuetext", Te = "change", Re = "DOMContentLoaded", De = "focusin", Oe = "focusout", Ut = "keydown", Fe = "keyup", Et = "click", Ie = "pointerdown", ue = "pointermove", Ke = "pointerup", Ve = "resize", Be = "scroll", je = "touchmove", j = "ArrowDown", st = "ArrowUp", ht = "ArrowLeft", G = "ArrowRight", qe = "Enter", ze = "Escape", _t = "Space", Ge = "transitionDuration", Ue = "transitionProperty", Y = "tabindex", _e = navigator.userAgentData, mt = _e, { userAgent: We } = navigator, vt = We, Wt = /iPhone|iPad|iPod|Android/i;
18
+ mt ? mt.brands.some((o) => Wt.test(o.brand)) : Wt.test(vt);
19
+ const Xt = /(iPhone|iPod|iPad)/;
20
+ mt ? mt.brands.some((o) => Xt.test(o.brand)) : (
21
+ /* istanbul ignore next */
22
+ Xt.test(vt)
23
+ );
24
+ vt && vt.includes("Firefox");
25
+ const { head: kt } = document;
26
+ ["webkitPerspective", "perspective"].some((o) => o in kt.style);
27
+ const Xe = (o, t, e, s) => {
28
+ const n = s || !1;
29
+ o.addEventListener(t, e, n);
30
+ }, Je = (o, t, e, s) => {
31
+ const n = s || !1;
32
+ o.removeEventListener(t, e, n);
33
+ }, Ye = (o, t, e, s) => {
34
+ const n = (r) => {
35
+ (r.target === o || r.currentTarget === o) && (e.apply(o, [r]), Je(o, t, n, s));
36
+ };
37
+ Xe(o, t, n, s);
38
+ }, Ze = () => {
39
+ };
40
+ (() => {
41
+ let o = !1;
42
+ try {
43
+ const t = Object.defineProperty({}, "passive", {
44
+ get: () => (o = !0, o)
45
+ });
46
+ Ye(document, Re, Ze, t);
47
+ } catch {
48
+ }
49
+ return o;
50
+ })();
51
+ ["webkitTransform", "transform"].some((o) => o in kt.style);
52
+ ["webkitAnimation", "animation"].some((o) => o in kt.style);
53
+ ["webkitTransition", "transition"].some((o) => o in kt.style);
54
+ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), St = (o, t) => o.removeAttribute(t), q = (o, ...t) => {
55
+ o.classList.add(...t);
56
+ }, D = (o, ...t) => {
57
+ o.classList.remove(...t);
58
+ }, T = (o, t) => o.classList.contains(t), jt = (o) => o != null && typeof o == "object" || !1, Q = (o) => jt(o) && typeof o.nodeType == "number" && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].some((t) => o.nodeType === t) || !1, at = (o) => Q(o) && o.nodeType === 1 || !1, W = /* @__PURE__ */ new Map(), ct = {
59
+ data: W,
60
+ /**
61
+ * Sets web components data.
62
+ *
63
+ * @param element target element
64
+ * @param component the component's name or a unique key
65
+ * @param instance the component instance
66
+ */
67
+ set: (o, t, e) => {
68
+ at(o) && (W.has(t) || W.set(t, /* @__PURE__ */ new Map()), W.get(t).set(o, e));
69
+ },
70
+ /**
71
+ * Returns all instances for specified component.
72
+ *
73
+ * @param component the component's name or a unique key
74
+ * @returns all the component instances
75
+ */
76
+ getAllFor: (o) => W.get(o) || null,
77
+ /**
78
+ * Returns the instance associated with the target.
79
+ *
80
+ * @param element target element
81
+ * @param component the component's name or a unique key
82
+ * @returns the instance
83
+ */
84
+ get: (o, t) => {
85
+ if (!at(o) || !t)
86
+ return null;
87
+ const e = ct.getAllFor(t);
88
+ return o && e && e.get(o) || null;
89
+ },
90
+ /**
91
+ * Removes web components data.
92
+ *
93
+ * @param element target element
94
+ * @param component the component's name or a unique key
95
+ */
96
+ remove: (o, t) => {
97
+ const e = ct.getAllFor(t);
98
+ !e || !at(o) || (e.delete(o), e.size === 0 && W.delete(t));
99
+ }
100
+ }, Qe = (o, t) => ct.get(o, t), V = (o) => typeof o == "string" || !1, to = (o) => jt(o) && o.constructor.name === "Window" || !1, be = (o) => Q(o) && o.nodeType === 9 || !1, K = (o) => to(o) ? o.document : be(o) ? o : Q(o) ? o.ownerDocument : window.document, B = (o, ...t) => Object.assign(o, ...t), x = (o) => {
101
+ if (!o)
102
+ return;
103
+ if (V(o))
104
+ return K().createElement(o);
105
+ const { tagName: t } = o, e = x(t);
106
+ if (!e)
107
+ return;
108
+ const s = { ...o };
109
+ return delete s.tagName, B(e, s);
110
+ }, Mt = (o, t) => {
111
+ if (!o || !t)
112
+ return;
113
+ if (V(t))
114
+ return K().createElementNS(o, t);
115
+ const { tagName: e } = t, s = Mt(o, e);
116
+ if (!s)
117
+ return;
118
+ const n = { ...t };
119
+ return delete n.tagName, B(s, n);
120
+ }, eo = (o, t) => o.dispatchEvent(t), Tt = (o, t) => {
121
+ const e = getComputedStyle(o), s = t.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
122
+ return e.getPropertyValue(s);
123
+ }, oo = (o) => {
124
+ const t = Tt(o, Ue), e = Tt(o, Ge), s = e.includes("ms") ? (
125
+ /* istanbul ignore next */
126
+ 1
127
+ ) : 1e3, n = t && t !== "none" ? parseFloat(e) * s : (
128
+ /* istanbul ignore next */
129
+ 0
130
+ );
131
+ return Number.isNaN(n) ? (
132
+ /* istanbul ignore next */
133
+ 0
134
+ ) : n;
135
+ }, U = (o, t) => o.focus(t), Jt = (o) => ["true", !0].includes(o) ? !0 : ["false", !1].includes(o) ? !1 : ["null", "", null, void 0].includes(o) ? null : o !== "" && !Number.isNaN(+o) ? +o : o, pt = (o) => Object.entries(o), so = (o) => o.toLowerCase(), no = (o, t, e, s) => {
136
+ const n = { ...e }, r = { ...o.dataset }, i = { ...t }, a = {}, l = "title";
137
+ return pt(r).forEach(([c, h]) => {
138
+ const b = s && typeof c == "string" && c.includes(s) ? c.replace(s, "").replace(/[A-Z]/g, (u) => so(u)) : c;
139
+ a[b] = Jt(h);
140
+ }), pt(n).forEach(([c, h]) => {
141
+ n[c] = Jt(h);
142
+ }), pt(t).forEach(([c, h]) => {
143
+ c in n ? i[c] = n[c] : c in a ? i[c] = a[c] : i[c] = c === l ? yt(o, l) : h;
144
+ }), i;
145
+ }, ro = (o) => o.offsetHeight, O = (o, t) => {
146
+ pt(t).forEach(([e, s]) => {
147
+ if (s && V(e) && e.includes("--"))
148
+ o.style.setProperty(e, s);
149
+ else {
150
+ const n = {};
151
+ n[e] = s, B(o.style, n);
152
+ }
153
+ });
154
+ }, io = (o) => jt(o) && o.constructor.name === "Map" || !1, pe = (o) => o.toUpperCase(), gt = (o, t) => {
155
+ const { width: e, height: s, top: n, right: r, bottom: i, left: a } = o.getBoundingClientRect();
156
+ let l = 1, c = 1;
157
+ if (t && at(o)) {
158
+ const { offsetWidth: h, offsetHeight: b } = o;
159
+ l = h > 0 ? Math.round(e) / h : (
160
+ /* istanbul ignore next */
161
+ 1
162
+ ), c = b > 0 ? Math.round(s) / b : (
163
+ /* istanbul ignore next */
164
+ 1
165
+ );
166
+ }
167
+ return {
168
+ width: e / l,
169
+ height: s / c,
170
+ top: n / c,
171
+ right: r / l,
172
+ bottom: i / c,
173
+ left: a / l,
174
+ x: a / l,
175
+ y: n / c
176
+ };
177
+ }, Ct = (o) => K(o).documentElement;
178
+ let Yt = 0, Zt = 0;
179
+ const X = /* @__PURE__ */ new Map(), de = (o, t) => {
180
+ let e = t ? Yt : Zt;
181
+ if (t) {
182
+ const s = de(o), n = X.get(s) || /* @__PURE__ */ new Map();
183
+ X.has(s) || X.set(s, n), io(n) && !n.has(t) ? (n.set(t, e), Yt += 1) : e = n.get(t);
184
+ } else {
185
+ const s = o.id || o;
186
+ X.has(s) ? e = X.get(s) : (X.set(s, e), Zt += 1);
187
+ }
188
+ return e;
189
+ }, ao = (o) => {
190
+ var t;
191
+ return o ? be(o) ? o.defaultView : Q(o) ? (t = o?.ownerDocument) == null ? void 0 : t.defaultView : o : window;
192
+ }, Lt = (o) => Array.isArray(o) || !1, fe = (o, t) => o ? o.closest(t) || // break out of `ShadowRoot`
193
+ fe(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).querySelector(o), nt = (o, t) => (t && Q(t) ? t : K()).getElementsByClassName(
194
+ o
195
+ ), qt = ["transparent", "currentColor", "inherit", "revert", "initial"], v = (o) => {
196
+ const t = Math.floor(o);
197
+ return o - t < 0.5 ? t : Math.round(o);
198
+ }, wt = [
199
+ [
200
+ "aliceblue",
201
+ {
202
+ r: 240,
203
+ g: 248,
204
+ b: 255
205
+ }
206
+ ],
207
+ [
208
+ "antiquewhite",
209
+ {
210
+ r: 250,
211
+ g: 235,
212
+ b: 215
213
+ }
214
+ ],
215
+ [
216
+ "aqua",
217
+ {
218
+ r: 0,
219
+ g: 255,
220
+ b: 255
221
+ }
222
+ ],
223
+ [
224
+ "aquamarine",
225
+ {
226
+ r: 127,
227
+ g: 255,
228
+ b: 212
229
+ }
230
+ ],
231
+ [
232
+ "azure",
233
+ {
234
+ r: 240,
235
+ g: 255,
236
+ b: 255
237
+ }
238
+ ],
239
+ [
240
+ "beige",
241
+ {
242
+ r: 245,
243
+ g: 245,
244
+ b: 220
245
+ }
246
+ ],
247
+ [
248
+ "bisque",
249
+ {
250
+ r: 255,
251
+ g: 228,
252
+ b: 196
253
+ }
254
+ ],
255
+ [
256
+ "black",
257
+ {
258
+ r: 0,
259
+ g: 0,
260
+ b: 0
261
+ }
262
+ ],
263
+ [
264
+ "blanchedalmond",
265
+ {
266
+ r: 255,
267
+ g: 235,
268
+ b: 205
269
+ }
270
+ ],
271
+ [
272
+ "blue",
273
+ {
274
+ r: 0,
275
+ g: 0,
276
+ b: 255
277
+ }
278
+ ],
279
+ [
280
+ "blueviolet",
281
+ {
282
+ r: 138,
283
+ g: 43,
284
+ b: 226
285
+ }
286
+ ],
287
+ [
288
+ "brown",
289
+ {
290
+ r: 165,
291
+ g: 42,
292
+ b: 42
293
+ }
294
+ ],
295
+ [
296
+ "burlywood",
297
+ {
298
+ r: 222,
299
+ g: 184,
300
+ b: 135
301
+ }
302
+ ],
303
+ [
304
+ "cadetblue",
305
+ {
306
+ r: 95,
307
+ g: 158,
308
+ b: 160
309
+ }
310
+ ],
311
+ [
312
+ "chartreuse",
313
+ {
314
+ r: 127,
315
+ g: 255,
316
+ b: 0
317
+ }
318
+ ],
319
+ [
320
+ "chocolate",
321
+ {
322
+ r: 210,
323
+ g: 105,
324
+ b: 30
325
+ }
326
+ ],
327
+ [
328
+ "coral",
329
+ {
330
+ r: 255,
331
+ g: 127,
332
+ b: 80
333
+ }
334
+ ],
335
+ [
336
+ "cornflowerblue",
337
+ {
338
+ r: 100,
339
+ g: 149,
340
+ b: 237
341
+ }
342
+ ],
343
+ [
344
+ "cornsilk",
345
+ {
346
+ r: 255,
347
+ g: 248,
348
+ b: 220
349
+ }
350
+ ],
351
+ [
352
+ "crimson",
353
+ {
354
+ r: 220,
355
+ g: 20,
356
+ b: 60
357
+ }
358
+ ],
359
+ [
360
+ "cyan",
361
+ {
362
+ r: 0,
363
+ g: 255,
364
+ b: 255
365
+ }
366
+ ],
367
+ [
368
+ "darkblue",
369
+ {
370
+ r: 0,
371
+ g: 0,
372
+ b: 139
373
+ }
374
+ ],
375
+ [
376
+ "darkcyan",
377
+ {
378
+ r: 0,
379
+ g: 139,
380
+ b: 139
381
+ }
382
+ ],
383
+ [
384
+ "darkgoldenrod",
385
+ {
386
+ r: 184,
387
+ g: 134,
388
+ b: 11
389
+ }
390
+ ],
391
+ [
392
+ "darkgray",
393
+ {
394
+ r: 169,
395
+ g: 169,
396
+ b: 169
397
+ }
398
+ ],
399
+ [
400
+ "darkgreen",
401
+ {
402
+ r: 0,
403
+ g: 100,
404
+ b: 0
405
+ }
406
+ ],
407
+ [
408
+ "darkgrey",
409
+ {
410
+ r: 169,
411
+ g: 169,
412
+ b: 169
413
+ }
414
+ ],
415
+ [
416
+ "darkkhaki",
417
+ {
418
+ r: 189,
419
+ g: 183,
420
+ b: 107
421
+ }
422
+ ],
423
+ [
424
+ "darkmagenta",
425
+ {
426
+ r: 139,
427
+ g: 0,
428
+ b: 139
429
+ }
430
+ ],
431
+ [
432
+ "darkolivegreen",
433
+ {
434
+ r: 85,
435
+ g: 107,
436
+ b: 47
437
+ }
438
+ ],
439
+ [
440
+ "darkorange",
441
+ {
442
+ r: 255,
443
+ g: 140,
444
+ b: 0
445
+ }
446
+ ],
447
+ [
448
+ "darkorchid",
449
+ {
450
+ r: 153,
451
+ g: 50,
452
+ b: 204
453
+ }
454
+ ],
455
+ [
456
+ "darkred",
457
+ {
458
+ r: 139,
459
+ g: 0,
460
+ b: 0
461
+ }
462
+ ],
463
+ [
464
+ "darksalmon",
465
+ {
466
+ r: 233,
467
+ g: 150,
468
+ b: 122
469
+ }
470
+ ],
471
+ [
472
+ "darkseagreen",
473
+ {
474
+ r: 143,
475
+ g: 188,
476
+ b: 143
477
+ }
478
+ ],
479
+ [
480
+ "darkslateblue",
481
+ {
482
+ r: 72,
483
+ g: 61,
484
+ b: 139
485
+ }
486
+ ],
487
+ [
488
+ "darkslategray",
489
+ {
490
+ r: 47,
491
+ g: 79,
492
+ b: 79
493
+ }
494
+ ],
495
+ [
496
+ "darkslategrey",
497
+ {
498
+ r: 47,
499
+ g: 79,
500
+ b: 79
501
+ }
502
+ ],
503
+ [
504
+ "darkturquoise",
505
+ {
506
+ r: 0,
507
+ g: 206,
508
+ b: 209
509
+ }
510
+ ],
511
+ [
512
+ "darkviolet",
513
+ {
514
+ r: 148,
515
+ g: 0,
516
+ b: 211
517
+ }
518
+ ],
519
+ [
520
+ "deeppink",
521
+ {
522
+ r: 255,
523
+ g: 20,
524
+ b: 147
525
+ }
526
+ ],
527
+ [
528
+ "deepskyblue",
529
+ {
530
+ r: 0,
531
+ g: 191,
532
+ b: 255
533
+ }
534
+ ],
535
+ [
536
+ "dimgray",
537
+ {
538
+ r: 105,
539
+ g: 105,
540
+ b: 105
541
+ }
542
+ ],
543
+ [
544
+ "dimgrey",
545
+ {
546
+ r: 105,
547
+ g: 105,
548
+ b: 105
549
+ }
550
+ ],
551
+ [
552
+ "dodgerblue",
553
+ {
554
+ r: 30,
555
+ g: 144,
556
+ b: 255
557
+ }
558
+ ],
559
+ [
560
+ "firebrick",
561
+ {
562
+ r: 178,
563
+ g: 34,
564
+ b: 34
565
+ }
566
+ ],
567
+ [
568
+ "floralwhite",
569
+ {
570
+ r: 255,
571
+ g: 250,
572
+ b: 240
573
+ }
574
+ ],
575
+ [
576
+ "forestgreen",
577
+ {
578
+ r: 34,
579
+ g: 139,
580
+ b: 34
581
+ }
582
+ ],
583
+ [
584
+ "fuchsia",
585
+ {
586
+ r: 255,
587
+ g: 0,
588
+ b: 255
589
+ }
590
+ ],
591
+ [
592
+ "gainsboro",
593
+ {
594
+ r: 220,
595
+ g: 220,
596
+ b: 220
597
+ }
598
+ ],
599
+ [
600
+ "ghostwhite",
601
+ {
602
+ r: 248,
603
+ g: 248,
604
+ b: 255
605
+ }
606
+ ],
607
+ [
608
+ "goldenrod",
609
+ {
610
+ r: 218,
611
+ g: 165,
612
+ b: 32
613
+ }
614
+ ],
615
+ [
616
+ "gold",
617
+ {
618
+ r: 255,
619
+ g: 215,
620
+ b: 0
621
+ }
622
+ ],
623
+ [
624
+ "gray",
625
+ {
626
+ r: 128,
627
+ g: 128,
628
+ b: 128
629
+ }
630
+ ],
631
+ [
632
+ "green",
633
+ {
634
+ r: 0,
635
+ g: 128,
636
+ b: 0
637
+ }
638
+ ],
639
+ [
640
+ "greenyellow",
641
+ {
642
+ r: 173,
643
+ g: 255,
644
+ b: 47
645
+ }
646
+ ],
647
+ [
648
+ "grey",
649
+ {
650
+ r: 128,
651
+ g: 128,
652
+ b: 128
653
+ }
654
+ ],
655
+ [
656
+ "honeydew",
657
+ {
658
+ r: 240,
659
+ g: 255,
660
+ b: 240
661
+ }
662
+ ],
663
+ [
664
+ "hotpink",
665
+ {
666
+ r: 255,
667
+ g: 105,
668
+ b: 180
669
+ }
670
+ ],
671
+ [
672
+ "indianred",
673
+ {
674
+ r: 205,
675
+ g: 92,
676
+ b: 92
677
+ }
678
+ ],
679
+ [
680
+ "indigo",
681
+ {
682
+ r: 75,
683
+ g: 0,
684
+ b: 130
685
+ }
686
+ ],
687
+ [
688
+ "ivory",
689
+ {
690
+ r: 255,
691
+ g: 255,
692
+ b: 240
693
+ }
694
+ ],
695
+ [
696
+ "khaki",
697
+ {
698
+ r: 240,
699
+ g: 230,
700
+ b: 140
701
+ }
702
+ ],
703
+ [
704
+ "lavenderblush",
705
+ {
706
+ r: 255,
707
+ g: 240,
708
+ b: 245
709
+ }
710
+ ],
711
+ [
712
+ "lavender",
713
+ {
714
+ r: 230,
715
+ g: 230,
716
+ b: 250
717
+ }
718
+ ],
719
+ [
720
+ "lawngreen",
721
+ {
722
+ r: 124,
723
+ g: 252,
724
+ b: 0
725
+ }
726
+ ],
727
+ [
728
+ "lemonchiffon",
729
+ {
730
+ r: 255,
731
+ g: 250,
732
+ b: 205
733
+ }
734
+ ],
735
+ [
736
+ "lightblue",
737
+ {
738
+ r: 173,
739
+ g: 216,
740
+ b: 230
741
+ }
742
+ ],
743
+ [
744
+ "lightcoral",
745
+ {
746
+ r: 240,
747
+ g: 128,
748
+ b: 128
749
+ }
750
+ ],
751
+ [
752
+ "lightcyan",
753
+ {
754
+ r: 224,
755
+ g: 255,
756
+ b: 255
757
+ }
758
+ ],
759
+ [
760
+ "lightgoldenrodyellow",
761
+ {
762
+ r: 250,
763
+ g: 250,
764
+ b: 210
765
+ }
766
+ ],
767
+ [
768
+ "lightgray",
769
+ {
770
+ r: 211,
771
+ g: 211,
772
+ b: 211
773
+ }
774
+ ],
775
+ [
776
+ "lightgreen",
777
+ {
778
+ r: 144,
779
+ g: 238,
780
+ b: 144
781
+ }
782
+ ],
783
+ [
784
+ "lightgrey",
785
+ {
786
+ r: 211,
787
+ g: 211,
788
+ b: 211
789
+ }
790
+ ],
791
+ [
792
+ "lightpink",
793
+ {
794
+ r: 255,
795
+ g: 182,
796
+ b: 193
797
+ }
798
+ ],
799
+ [
800
+ "lightsalmon",
801
+ {
802
+ r: 255,
803
+ g: 160,
804
+ b: 122
805
+ }
806
+ ],
807
+ [
808
+ "lightseagreen",
809
+ {
810
+ r: 32,
811
+ g: 178,
812
+ b: 170
813
+ }
814
+ ],
815
+ [
816
+ "lightskyblue",
817
+ {
818
+ r: 135,
819
+ g: 206,
820
+ b: 250
821
+ }
822
+ ],
823
+ [
824
+ "lightslategray",
825
+ {
826
+ r: 119,
827
+ g: 136,
828
+ b: 153
829
+ }
830
+ ],
831
+ [
832
+ "lightslategrey",
833
+ {
834
+ r: 119,
835
+ g: 136,
836
+ b: 153
837
+ }
838
+ ],
839
+ [
840
+ "lightsteelblue",
841
+ {
842
+ r: 176,
843
+ g: 196,
844
+ b: 222
845
+ }
846
+ ],
847
+ [
848
+ "lightyellow",
849
+ {
850
+ r: 255,
851
+ g: 255,
852
+ b: 224
853
+ }
854
+ ],
855
+ [
856
+ "lime",
857
+ {
858
+ r: 0,
859
+ g: 255,
860
+ b: 0
861
+ }
862
+ ],
863
+ [
864
+ "limegreen",
865
+ {
866
+ r: 50,
867
+ g: 205,
868
+ b: 50
869
+ }
870
+ ],
871
+ [
872
+ "linen",
873
+ {
874
+ r: 250,
875
+ g: 240,
876
+ b: 230
877
+ }
878
+ ],
879
+ [
880
+ "magenta",
881
+ {
882
+ r: 255,
883
+ g: 0,
884
+ b: 255
885
+ }
886
+ ],
887
+ [
888
+ "maroon",
889
+ {
890
+ r: 128,
891
+ g: 0,
892
+ b: 0
893
+ }
894
+ ],
895
+ [
896
+ "mediumaquamarine",
897
+ {
898
+ r: 102,
899
+ g: 205,
900
+ b: 170
901
+ }
902
+ ],
903
+ [
904
+ "mediumblue",
905
+ {
906
+ r: 0,
907
+ g: 0,
908
+ b: 205
909
+ }
910
+ ],
911
+ [
912
+ "mediumorchid",
913
+ {
914
+ r: 186,
915
+ g: 85,
916
+ b: 211
917
+ }
918
+ ],
919
+ [
920
+ "mediumpurple",
921
+ {
922
+ r: 147,
923
+ g: 112,
924
+ b: 219
925
+ }
926
+ ],
927
+ [
928
+ "mediumseagreen",
929
+ {
930
+ r: 60,
931
+ g: 179,
932
+ b: 113
933
+ }
934
+ ],
935
+ [
936
+ "mediumslateblue",
937
+ {
938
+ r: 123,
939
+ g: 104,
940
+ b: 238
941
+ }
942
+ ],
943
+ [
944
+ "mediumspringgreen",
945
+ {
946
+ r: 0,
947
+ g: 250,
948
+ b: 154
949
+ }
950
+ ],
951
+ [
952
+ "mediumturquoise",
953
+ {
954
+ r: 72,
955
+ g: 209,
956
+ b: 204
957
+ }
958
+ ],
959
+ [
960
+ "mediumvioletred",
961
+ {
962
+ r: 199,
963
+ g: 21,
964
+ b: 133
965
+ }
966
+ ],
967
+ [
968
+ "midnightblue",
969
+ {
970
+ r: 25,
971
+ g: 25,
972
+ b: 112
973
+ }
974
+ ],
975
+ [
976
+ "mintcream",
977
+ {
978
+ r: 245,
979
+ g: 255,
980
+ b: 250
981
+ }
982
+ ],
983
+ [
984
+ "mistyrose",
985
+ {
986
+ r: 255,
987
+ g: 228,
988
+ b: 225
989
+ }
990
+ ],
991
+ [
992
+ "moccasin",
993
+ {
994
+ r: 255,
995
+ g: 228,
996
+ b: 181
997
+ }
998
+ ],
999
+ [
1000
+ "navajowhite",
1001
+ {
1002
+ r: 255,
1003
+ g: 222,
1004
+ b: 173
1005
+ }
1006
+ ],
1007
+ [
1008
+ "navy",
1009
+ {
1010
+ r: 0,
1011
+ g: 0,
1012
+ b: 128
1013
+ }
1014
+ ],
1015
+ [
1016
+ "oldlace",
1017
+ {
1018
+ r: 253,
1019
+ g: 245,
1020
+ b: 230
1021
+ }
1022
+ ],
1023
+ [
1024
+ "olive",
1025
+ {
1026
+ r: 128,
1027
+ g: 128,
1028
+ b: 0
1029
+ }
1030
+ ],
1031
+ [
1032
+ "olivedrab",
1033
+ {
1034
+ r: 107,
1035
+ g: 142,
1036
+ b: 35
1037
+ }
1038
+ ],
1039
+ [
1040
+ "orange",
1041
+ {
1042
+ r: 255,
1043
+ g: 165,
1044
+ b: 0
1045
+ }
1046
+ ],
1047
+ [
1048
+ "orangered",
1049
+ {
1050
+ r: 255,
1051
+ g: 69,
1052
+ b: 0
1053
+ }
1054
+ ],
1055
+ [
1056
+ "orchid",
1057
+ {
1058
+ r: 218,
1059
+ g: 112,
1060
+ b: 214
1061
+ }
1062
+ ],
1063
+ [
1064
+ "palegoldenrod",
1065
+ {
1066
+ r: 238,
1067
+ g: 232,
1068
+ b: 170
1069
+ }
1070
+ ],
1071
+ [
1072
+ "palegreen",
1073
+ {
1074
+ r: 152,
1075
+ g: 251,
1076
+ b: 152
1077
+ }
1078
+ ],
1079
+ [
1080
+ "paleturquoise",
1081
+ {
1082
+ r: 175,
1083
+ g: 238,
1084
+ b: 238
1085
+ }
1086
+ ],
1087
+ [
1088
+ "palevioletred",
1089
+ {
1090
+ r: 219,
1091
+ g: 112,
1092
+ b: 147
1093
+ }
1094
+ ],
1095
+ [
1096
+ "papayawhip",
1097
+ {
1098
+ r: 255,
1099
+ g: 239,
1100
+ b: 213
1101
+ }
1102
+ ],
1103
+ [
1104
+ "peachpuff",
1105
+ {
1106
+ r: 255,
1107
+ g: 218,
1108
+ b: 185
1109
+ }
1110
+ ],
1111
+ [
1112
+ "peru",
1113
+ {
1114
+ r: 205,
1115
+ g: 133,
1116
+ b: 63
1117
+ }
1118
+ ],
1119
+ [
1120
+ "pink",
1121
+ {
1122
+ r: 255,
1123
+ g: 192,
1124
+ b: 203
1125
+ }
1126
+ ],
1127
+ [
1128
+ "plum",
1129
+ {
1130
+ r: 221,
1131
+ g: 160,
1132
+ b: 221
1133
+ }
1134
+ ],
1135
+ [
1136
+ "powderblue",
1137
+ {
1138
+ r: 176,
1139
+ g: 224,
1140
+ b: 230
1141
+ }
1142
+ ],
1143
+ [
1144
+ "purple",
1145
+ {
1146
+ r: 128,
1147
+ g: 0,
1148
+ b: 128
1149
+ }
1150
+ ],
1151
+ [
1152
+ "rebeccapurple",
1153
+ {
1154
+ r: 102,
1155
+ g: 51,
1156
+ b: 153
1157
+ }
1158
+ ],
1159
+ [
1160
+ "red",
1161
+ {
1162
+ r: 255,
1163
+ g: 0,
1164
+ b: 0
1165
+ }
1166
+ ],
1167
+ [
1168
+ "rosybrown",
1169
+ {
1170
+ r: 188,
1171
+ g: 143,
1172
+ b: 143
1173
+ }
1174
+ ],
1175
+ [
1176
+ "royalblue",
1177
+ {
1178
+ r: 65,
1179
+ g: 105,
1180
+ b: 225
1181
+ }
1182
+ ],
1183
+ [
1184
+ "saddlebrown",
1185
+ {
1186
+ r: 139,
1187
+ g: 69,
1188
+ b: 19
1189
+ }
1190
+ ],
1191
+ [
1192
+ "salmon",
1193
+ {
1194
+ r: 250,
1195
+ g: 128,
1196
+ b: 114
1197
+ }
1198
+ ],
1199
+ [
1200
+ "sandybrown",
1201
+ {
1202
+ r: 244,
1203
+ g: 164,
1204
+ b: 96
1205
+ }
1206
+ ],
1207
+ [
1208
+ "seagreen",
1209
+ {
1210
+ r: 46,
1211
+ g: 139,
1212
+ b: 87
1213
+ }
1214
+ ],
1215
+ [
1216
+ "seashell",
1217
+ {
1218
+ r: 255,
1219
+ g: 245,
1220
+ b: 238
1221
+ }
1222
+ ],
1223
+ [
1224
+ "sienna",
1225
+ {
1226
+ r: 160,
1227
+ g: 82,
1228
+ b: 45
1229
+ }
1230
+ ],
1231
+ [
1232
+ "silver",
1233
+ {
1234
+ r: 192,
1235
+ g: 192,
1236
+ b: 192
1237
+ }
1238
+ ],
1239
+ [
1240
+ "skyblue",
1241
+ {
1242
+ r: 135,
1243
+ g: 206,
1244
+ b: 235
1245
+ }
1246
+ ],
1247
+ [
1248
+ "slateblue",
1249
+ {
1250
+ r: 106,
1251
+ g: 90,
1252
+ b: 205
1253
+ }
1254
+ ],
1255
+ [
1256
+ "slategray",
1257
+ {
1258
+ r: 112,
1259
+ g: 128,
1260
+ b: 144
1261
+ }
1262
+ ],
1263
+ [
1264
+ "slategrey",
1265
+ {
1266
+ r: 112,
1267
+ g: 128,
1268
+ b: 144
1269
+ }
1270
+ ],
1271
+ [
1272
+ "snow",
1273
+ {
1274
+ r: 255,
1275
+ g: 250,
1276
+ b: 250
1277
+ }
1278
+ ],
1279
+ [
1280
+ "springgreen",
1281
+ {
1282
+ r: 0,
1283
+ g: 255,
1284
+ b: 127
1285
+ }
1286
+ ],
1287
+ [
1288
+ "steelblue",
1289
+ {
1290
+ r: 70,
1291
+ g: 130,
1292
+ b: 180
1293
+ }
1294
+ ],
1295
+ [
1296
+ "tan",
1297
+ {
1298
+ r: 210,
1299
+ g: 180,
1300
+ b: 140
1301
+ }
1302
+ ],
1303
+ [
1304
+ "teal",
1305
+ {
1306
+ r: 0,
1307
+ g: 128,
1308
+ b: 128
1309
+ }
1310
+ ],
1311
+ [
1312
+ "thistle",
1313
+ {
1314
+ r: 216,
1315
+ g: 191,
1316
+ b: 216
1317
+ }
1318
+ ],
1319
+ [
1320
+ "tomato",
1321
+ {
1322
+ r: 255,
1323
+ g: 99,
1324
+ b: 71
1325
+ }
1326
+ ],
1327
+ [
1328
+ "turquoise",
1329
+ {
1330
+ r: 64,
1331
+ g: 224,
1332
+ b: 208
1333
+ }
1334
+ ],
1335
+ [
1336
+ "violet",
1337
+ {
1338
+ r: 238,
1339
+ g: 130,
1340
+ b: 238
1341
+ }
1342
+ ],
1343
+ [
1344
+ "wheat",
1345
+ {
1346
+ r: 245,
1347
+ g: 222,
1348
+ b: 179
1349
+ }
1350
+ ],
1351
+ [
1352
+ "white",
1353
+ {
1354
+ r: 255,
1355
+ g: 255,
1356
+ b: 255
1357
+ }
1358
+ ],
1359
+ [
1360
+ "whitesmoke",
1361
+ {
1362
+ r: 245,
1363
+ g: 245,
1364
+ b: 245
1365
+ }
1366
+ ],
1367
+ [
1368
+ "yellow",
1369
+ {
1370
+ r: 255,
1371
+ g: 255,
1372
+ b: 0
1373
+ }
1374
+ ],
1375
+ [
1376
+ "yellowgreen",
1377
+ {
1378
+ r: 154,
1379
+ g: 205,
1380
+ b: 50
1381
+ }
1382
+ ]
1383
+ ], me = "deg|rad|grad|turn", ve = "[-\\+]?\\d+%?", we = "[-\\+]?\\d*\\.\\d+%?", $e = `[-\\+]?\\d*\\.?\\d+(?:${me})?`, dt = `(?:${we})|(?:${ve})`, Rt = `(?:${dt})|(?:${$e}?)`, lo = "(?:[\\s|\\(\\s|\\s\\(\\s]+)?", co = "(?:[\\s|\\)\\s]+)?", Qt = "(?:[,|\\s]+)", ho = "(?:[,|\\/\\s]*)?", rt = `${lo}(${Rt})${Qt}(${dt})${Qt}(${dt})${ho}(${dt})?${co}`, I = {
1384
+ CSS_UNIT: new RegExp(Rt),
1385
+ ANGLES: me,
1386
+ CSS_ANGLE: $e,
1387
+ CSS_INTEGER: ve,
1388
+ CSS_NUMBER: we,
1389
+ CSS_UNIT2: Rt,
1390
+ PERMISSIVE_MATCH: rt,
1391
+ hwb: new RegExp(`hwb${rt}`),
1392
+ rgb: new RegExp(`rgb(?:a)?${rt}`),
1393
+ hsl: new RegExp(`hsl(?:a)?${rt}`),
1394
+ hsv: new RegExp(`hsv(?:a)?${rt}`),
1395
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1396
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1397
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1398
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1399
+ }, ke = (o) => qt.includes(o), it = (o, t) => o !== null && typeof o == "object" && Object.keys(t).every((e) => e in o), ye = (o) => `${o}`.includes(".") && parseFloat(o) === 1, $t = (o) => typeof o == "string" && o.includes("%"), H = (o) => !!I.CSS_UNIT.exec(`${o}`), xe = ["rgb", "hex", "hsl", "hsv", "hwb"], Pe = (o) => qt.includes(o) || ["#", ...xe].some((t) => o.includes(t)) ? !1 : wt.some(([t]) => o === t), R = (o, t) => {
1400
+ let e = o;
1401
+ if (typeof o == "number" && Math.min(o, 0) === 0 && // round values to 6 decimals Math.round(N * (10 ** 6)) / 10 ** 6
1402
+ Math.max(o, 1) === 1)
1403
+ return o;
1404
+ ye(o) && (e = "100%");
1405
+ const s = $t(e);
1406
+ return e = t === 360 ? parseFloat(e) : Math.min(t, Math.max(0, parseFloat(e))), s && (e = e * t / 100), Math.abs(e - t) < 1e-6 ? 1 : (t === 360 ? e = (e < 0 ? e % t + t : e % t) / t : e = e % t / t, e);
1407
+ }, Dt = (o) => {
1408
+ let t = parseFloat(o);
1409
+ return (Number.isNaN(t) || t < 0 || t > 1) && (t = 1), t;
1410
+ }, ut = (o) => Math.min(1, Math.max(0, o)), z = (o) => o.length === 1 ? `0${o}` : String(o), Se = (o) => {
1411
+ const [[, t]] = wt.filter(([e]) => e === o.toLowerCase());
1412
+ return t;
1413
+ }, N = (o) => parseInt(o, 16), Ot = (o) => N(o) / 255, Ce = (o) => v(o * 255).toString(16), te = (o, t, e) => {
1414
+ const s = Math.max(o, t, e), n = Math.min(o, t, e);
1415
+ let r = 0, i = 0;
1416
+ const a = (s + n) / 2;
1417
+ if (s === n)
1418
+ i = 0, r = 0;
1419
+ else {
1420
+ const l = s - n;
1421
+ i = a > 0.5 ? l / (2 - s - n) : l / (s + n), s === o && (r = (t - e) / l + (t < e ? 6 : 0)), s === t && (r = (e - o) / l + 2), s === e && (r = (o - t) / l + 4), r /= 6;
1422
+ }
1423
+ return { h: r, s: i, l: a };
1424
+ }, ft = (o, t, e) => {
1425
+ let s = e;
1426
+ return s < 0 && (s += 1), s > 1 && (s -= 1), s < 1 / 6 ? o + (t - o) * (6 * s) : s < 1 / 2 ? t : s < 2 / 3 ? o + (t - o) * (2 / 3 - s) * 6 : o;
1427
+ }, lt = (o, t, e) => {
1428
+ let s = 0, n = 0, r = 0;
1429
+ if (t === 0)
1430
+ n = e, r = e, s = e;
1431
+ else if (e) {
1432
+ const i = e < 0.5 ? e * (1 + t) : e + t - e * t, a = 2 * e - i;
1433
+ s = ft(a, i, o + 1 / 3), n = ft(a, i, o), r = ft(a, i, o - 1 / 3);
1434
+ }
1435
+ return { r: s, g: n, b: r };
1436
+ }, ee = (o, t, e) => {
1437
+ let s = 0, n = 0;
1438
+ const r = Math.min(o, t, e), i = Math.max(o, t, e), a = 1 - i;
1439
+ if (i === r)
1440
+ return { h: 0, w: r, b: a };
1441
+ o === r ? (s = t - e, n = 3) : (s = t === r ? e - o : o - t, n = t === r ? 5 : 1);
1442
+ const l = (n - s / (i - r)) / 6;
1443
+ return {
1444
+ h: l === 1 ? 0 : l,
1445
+ w: r,
1446
+ b: a
1447
+ };
1448
+ }, Le = (o, t, e) => {
1449
+ if (t + e >= 1) {
1450
+ const i = t / (t + e);
1451
+ return { r: i, g: i, b: i };
1452
+ }
1453
+ let { r: s, g: n, b: r } = lt(o, 1, 0.5);
1454
+ return [s, n, r] = [s, n, r].map((i) => i * (1 - t - e) + t), { r: s, g: n, b: r };
1455
+ }, oe = (o, t, e) => {
1456
+ const s = Math.max(o, t, e), n = Math.min(o, t, e);
1457
+ let r = 0;
1458
+ const i = s, a = s - n, l = s === 0 ? 0 : a / s;
1459
+ return s === n ? r = 0 : (o === s && (r = (t - e) / a + (t < e ? 6 : 0)), t === s && (r = (e - o) / a + 2), e === s && (r = (o - t) / a + 4), r /= 6), { h: r, s: l, v: i };
1460
+ }, Ft = (o, t, e) => {
1461
+ const s = o * 6, n = t, r = e, i = Math.floor(s), a = s - i, l = r * (1 - n), c = r * (1 - a * n), h = r * (1 - (1 - a) * n), b = i % 6, u = [r, c, l, l, h, r][b], d = [h, r, r, c, l, l][b], g = [l, l, h, r, r, c][b];
1462
+ return { r: u, g: d, b: g };
1463
+ }, se = (o, t, e, s) => {
1464
+ const n = [
1465
+ z(v(o).toString(16)),
1466
+ z(v(t).toString(16)),
1467
+ z(v(e).toString(16))
1468
+ ];
1469
+ return s && n[0].charAt(0) === n[0].charAt(1) && n[1].charAt(0) === n[1].charAt(1) && n[2].charAt(0) === n[2].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) : n.join("");
1470
+ }, At = (o, t, e, s, n) => {
1471
+ const r = [
1472
+ z(v(o).toString(16)),
1473
+ z(v(t).toString(16)),
1474
+ z(v(e).toString(16)),
1475
+ z(Ce(s))
1476
+ ];
1477
+ return n && r[0].charAt(0) === r[0].charAt(1) && r[1].charAt(0) === r[1].charAt(1) && r[2].charAt(0) === r[2].charAt(1) && r[3].charAt(0) === r[3].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) + r[3].charAt(0) : r.join("");
1478
+ }, Ae = (o) => {
1479
+ const t = String(o).trim().toLowerCase();
1480
+ if (Pe(t))
1481
+ return Object.assign(Se(t), {
1482
+ a: 1,
1483
+ format: "rgb",
1484
+ ok: !0
1485
+ });
1486
+ if (ke(t))
1487
+ return {
1488
+ r: 0,
1489
+ g: 0,
1490
+ b: 0,
1491
+ a: t === "transparent" ? 0 : 1,
1492
+ format: "rgb",
1493
+ ok: !0
1494
+ };
1495
+ let [, e, s, n, r] = I.rgb.exec(t) || [];
1496
+ return e && s && n ? {
1497
+ r: e,
1498
+ g: s,
1499
+ b: n,
1500
+ a: r !== void 0 ? r : 1,
1501
+ format: "rgb",
1502
+ ok: !0
1503
+ } : ([, e, s, n, r] = I.hsl.exec(t) || [], e && s && n ? {
1504
+ h: e,
1505
+ s,
1506
+ l: n,
1507
+ a: r !== void 0 ? r : 1,
1508
+ format: "hsl",
1509
+ ok: !0
1510
+ } : ([, e, s, n, r] = I.hsv.exec(t) || [], e && s && n ? {
1511
+ h: e,
1512
+ s,
1513
+ v: n,
1514
+ a: r !== void 0 ? r : 1,
1515
+ format: "hsv",
1516
+ ok: !0
1517
+ } : ([, e, s, n, r] = I.hwb.exec(t) || [], e && s && n ? {
1518
+ h: e,
1519
+ w: s,
1520
+ b: n,
1521
+ a: r !== void 0 ? r : 1,
1522
+ format: "hwb",
1523
+ ok: !0
1524
+ } : ([, e, s, n, r] = I.hex8.exec(t) || [], e && s && n && r ? {
1525
+ r: N(e),
1526
+ g: N(s),
1527
+ b: N(n),
1528
+ a: Ot(r),
1529
+ format: "hex",
1530
+ ok: !0
1531
+ } : ([, e, s, n] = I.hex6.exec(t) || [], e && s && n ? {
1532
+ r: N(e),
1533
+ g: N(s),
1534
+ b: N(n),
1535
+ a: 1,
1536
+ format: "hex",
1537
+ ok: !0
1538
+ } : ([, e, s, n, r] = I.hex4.exec(t) || [], e && s && n && r ? {
1539
+ r: N(e + e),
1540
+ g: N(s + s),
1541
+ b: N(n + n),
1542
+ a: Ot(r + r),
1543
+ format: "hex",
1544
+ ok: !0
1545
+ } : ([, e, s, n] = I.hex3.exec(t) || [], e && s && n ? {
1546
+ r: N(e + e),
1547
+ g: N(s + s),
1548
+ b: N(n + n),
1549
+ a: 1,
1550
+ format: "hex",
1551
+ ok: !0
1552
+ } : {
1553
+ r: 0,
1554
+ g: 0,
1555
+ b: 0,
1556
+ a: 1,
1557
+ format: "rgb",
1558
+ ok: !o
1559
+ })))))));
1560
+ }, ne = (o) => {
1561
+ let t = { r: 0, g: 0, b: 0 }, e = o, s = 1, n, r, i, a, l, c, h, b, u = "rgb", d = !1;
1562
+ return (!e || typeof e == "string") && (e = Ae(e), d = e.ok), it(e, t) && H(e.r) && H(e.g) && H(e.b) && ({ r: h, g: b, b: l } = e, [h, b, l] = [h, b, l].map((g) => R(g, $t(g) ? 100 : 255)), t = { r: h, g: b, b: l }, u = "format" in e ? e.format : "rgb"), it(e, { h: 0, s: 0, v: 0 }) && H(e.h) && H(e.s) && H(e.v) && ({ h: c, s: n, v: r } = e, c = R(c, 360), n = R(n, 100), r = R(r, 100), t = Ft(c, n, r), u = "hsv"), it(e, { h: 0, s: 0, l: 0 }) && H(e.h) && H(e.s) && H(e.l) && ({ h: c, s: n, l: i } = e, c = R(c, 360), n = R(n, 100), i = R(i, 100), t = lt(c, n, i), u = "hsl"), it(e, { h: 0, w: 0, b: 0 }) && H(e.h) && H(e.w) && H(e.b) && ({ h: c, w: a, b: l } = e, c = R(c, 360), a = R(a, 100), l = R(l, 100), t = Le(c, a, l), u = "hwb"), H(e.a) && (s = e.a, s = $t(s) || parseFloat(`${s}`) > 1 ? R(s, 100) : s), {
1563
+ r: t.r,
1564
+ g: t.g,
1565
+ b: t.b,
1566
+ a: Dt(s),
1567
+ format: u,
1568
+ ok: d
1569
+ };
1570
+ }, go = "1.0.6";
1571
+ class y {
1572
+ // bring main utilities to front
1573
+ static matchers = I;
1574
+ static isOnePointZero = ye;
1575
+ static isPercentage = $t;
1576
+ static isValidCSSUnit = H;
1577
+ static isNonColor = ke;
1578
+ static isColorName = Pe;
1579
+ static isColorType = it;
1580
+ static pad2 = z;
1581
+ static clamp01 = ut;
1582
+ static bound01 = R;
1583
+ static boundAlpha = Dt;
1584
+ static getRGBFromName = Se;
1585
+ static convertHexToDecimal = Ot;
1586
+ static convertDecimalToHex = Ce;
1587
+ static rgbToHsl = te;
1588
+ static rgbToHex = se;
1589
+ static rgbToHsv = oe;
1590
+ static rgbToHwb = ee;
1591
+ static rgbaToHex = At;
1592
+ static hslToRgb = Ft;
1593
+ static hsvToRgb = Ft;
1594
+ static hueToRgb = ft;
1595
+ static hwbToRgb = Le;
1596
+ static parseIntFromHex = N;
1597
+ static stringInputToObject = Ae;
1598
+ static inputToRGB = ne;
1599
+ static roundPart = v;
1600
+ static webColors = wt;
1601
+ static nonColors = qt;
1602
+ static version = go;
1603
+ // main public properties
1604
+ r;
1605
+ g;
1606
+ b;
1607
+ a;
1608
+ format;
1609
+ ok;
1610
+ originalInput;
1611
+ // main public methods
1612
+ constructor(t, e) {
1613
+ const s = e && xe.includes(e) ? e : "", { r: n, g: r, b: i, a, ok: l, format: c } = ne(t);
1614
+ this.originalInput = t, this.r = n, this.g = r, this.b = i, this.a = a, this.ok = l, this.format = s || c;
1615
+ }
1616
+ /**
1617
+ * Checks if the current input value is a valid colour.
1618
+ */
1619
+ get isValid() {
1620
+ return this.ok;
1621
+ }
1622
+ /**
1623
+ * Checks if the current colour requires a light text colour.
1624
+ */
1625
+ get isDark() {
1626
+ return this.brightness < 120;
1627
+ }
1628
+ /**
1629
+ * Returns the perceived luminance of a colour.
1630
+ *
1631
+ * @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
1632
+ */
1633
+ get luminance() {
1634
+ const { r: t, g: e, b: s } = this;
1635
+ let n = 0, r = 0, i = 0;
1636
+ return t <= 0.03928 ? n = t / 12.92 : n = ((t + 0.055) / 1.055) ** 2.4, e <= 0.03928 ? r = e / 12.92 : r = ((e + 0.055) / 1.055) ** 2.4, s <= 0.03928 ? i = s / 12.92 : i = ((s + 0.055) / 1.055) ** 2.4, 0.2126 * n + 0.7152 * r + 0.0722 * i;
1637
+ }
1638
+ /**
1639
+ * Returns the perceived brightness of the colour.
1640
+ */
1641
+ get brightness() {
1642
+ const { r: t, g: e, b: s } = this.toRgb();
1643
+ return (t * 299 + e * 587 + s * 114) / 1e3;
1644
+ }
1645
+ /**
1646
+ * Returns the web colour name closest to the current colour.
1647
+ */
1648
+ get name() {
1649
+ const { r: t, g: e, b: s } = this.toRgb(), [n] = wt.map(([r, i]) => {
1650
+ const a = (
1651
+ // ((rgb.r - r) ** 2 + (rgb.g - g) ** 2 + (rgb.b - b) ** 2) ** 0.5; // standard
1652
+ (((i.r - t) * 0.3) ** 2 + ((i.g - e) * 0.6) ** 2 + ((i.b - s) * 0.1) ** 2) ** 0.5
1653
+ );
1654
+ return [r, a];
1655
+ }).find(([, r], i, a) => r === Math.min(...a.map(([, l]) => l)));
1656
+ return n;
1657
+ }
1658
+ /**
1659
+ * Returns the colour as an RGBA object.
1660
+ */
1661
+ toRgb() {
1662
+ let { r: t, g: e, b: s, a: n } = this;
1663
+ return [t, e, s] = [t, e, s].map((r) => v(r * 255 * 100) / 100), n = v(n * 100) / 100, {
1664
+ r: t,
1665
+ g: e,
1666
+ b: s,
1667
+ a: n
1668
+ };
1669
+ }
1670
+ /**
1671
+ * Returns the RGBA values concatenated into a CSS3 Module string format.
1672
+ * * rgb(255,255,255)
1673
+ * * rgba(255,255,255,0.5)
1674
+ */
1675
+ toRgbString() {
1676
+ const { r: t, g: e, b: s, a: n } = this.toRgb(), [r, i, a] = [t, e, s].map(v);
1677
+ return n === 1 ? `rgb(${r}, ${i}, ${a})` : `rgba(${r}, ${i}, ${a}, ${n})`;
1678
+ }
1679
+ /**
1680
+ * Returns the RGBA values concatenated into a CSS4 Module string format.
1681
+ * * rgb(255 255 255)
1682
+ * * rgb(255 255 255 / 50%)
1683
+ */
1684
+ toRgbCSS4String() {
1685
+ const { r: t, g: e, b: s, a: n } = this.toRgb(), [r, i, a] = [t, e, s].map(v), l = n === 1 ? "" : ` / ${v(n * 100)}%`;
1686
+ return `rgb(${r} ${i} ${a}${l})`;
1687
+ }
1688
+ /**
1689
+ * Returns the hexadecimal value of the colour. When the parameter is *true*
1690
+ * it will find a 3 characters shorthand of the decimal value.
1691
+ */
1692
+ toHex(t) {
1693
+ const { r: e, g: s, b: n, a: r } = this.toRgb();
1694
+ return r === 1 ? se(e, s, n, t) : At(e, s, n, r, t);
1695
+ }
1696
+ /**
1697
+ * Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
1698
+ * it will find a 3 characters shorthand of the value.
1699
+ */
1700
+ toHexString(t) {
1701
+ return `#${this.toHex(t)}`;
1702
+ }
1703
+ /**
1704
+ * Returns the HEX8 value of the colour.
1705
+ */
1706
+ toHex8(t) {
1707
+ const { r: e, g: s, b: n, a: r } = this.toRgb();
1708
+ return At(e, s, n, r, t);
1709
+ }
1710
+ /**
1711
+ * Returns the HEX8 value of the colour.
1712
+ */
1713
+ toHex8String(t) {
1714
+ return `#${this.toHex8(t)}`;
1715
+ }
1716
+ /**
1717
+ * Returns the colour as a HSVA object.
1718
+ */
1719
+ toHsv() {
1720
+ const { r: t, g: e, b: s, a: n } = this, { h: r, s: i, v: a } = oe(t, e, s);
1721
+ return {
1722
+ h: r,
1723
+ s: i,
1724
+ v: a,
1725
+ a: n
1726
+ };
1727
+ }
1728
+ /**
1729
+ * Returns the colour as an HSLA object.
1730
+ */
1731
+ toHsl() {
1732
+ const { r: t, g: e, b: s, a: n } = this, { h: r, s: i, l: a } = te(t, e, s);
1733
+ return {
1734
+ h: r,
1735
+ s: i,
1736
+ l: a,
1737
+ a: n
1738
+ };
1739
+ }
1740
+ /**
1741
+ * Returns the HSLA values concatenated into a CSS3 Module format string.
1742
+ * * `hsl(150, 100%, 50%)`
1743
+ * * `hsla(150, 100%, 50%, 0.5)`
1744
+ */
1745
+ toHslString() {
1746
+ let { h: t, s: e, l: s, a: n } = this.toHsl();
1747
+ return t = v(t * 360), e = v(e * 100), s = v(s * 100), n = v(n * 100) / 100, n === 1 ? `hsl(${t}, ${e}%, ${s}%)` : `hsla(${t}, ${e}%, ${s}%, ${n})`;
1748
+ }
1749
+ /**
1750
+ * Returns the HSLA values concatenated into a CSS4 Module format string.
1751
+ * * `hsl(150deg 100% 50%)`
1752
+ * * `hsl(150deg 100% 50% / 50%)`
1753
+ */
1754
+ toHslCSS4String() {
1755
+ let { h: t, s: e, l: s, a: n } = this.toHsl();
1756
+ t = v(t * 360), e = v(e * 100), s = v(s * 100), n = v(n * 100);
1757
+ const r = n < 100 ? ` / ${v(n)}%` : "";
1758
+ return `hsl(${t}deg ${e}% ${s}%${r})`;
1759
+ }
1760
+ /**
1761
+ * Returns the colour as an HWBA object.
1762
+ */
1763
+ toHwb() {
1764
+ const { r: t, g: e, b: s, a: n } = this, { h: r, w: i, b: a } = ee(t, e, s);
1765
+ return {
1766
+ h: r,
1767
+ w: i,
1768
+ b: a,
1769
+ a: n
1770
+ };
1771
+ }
1772
+ /**
1773
+ * Returns the HWBA values concatenated into a string.
1774
+ */
1775
+ toHwbString() {
1776
+ let { h: t, w: e, b: s, a: n } = this.toHwb();
1777
+ t = v(t * 360), e = v(e * 100), s = v(s * 100), n = v(n * 100);
1778
+ const r = n < 100 ? ` / ${v(n)}%` : "";
1779
+ return `hwb(${t}deg ${e}% ${s}%${r})`;
1780
+ }
1781
+ /**
1782
+ * Sets the alpha value of the current colour.
1783
+ */
1784
+ setAlpha(t) {
1785
+ return typeof t != "number" ? this : (this.a = Dt(t), this);
1786
+ }
1787
+ /**
1788
+ * Saturate the colour with a given amount.
1789
+ */
1790
+ saturate(t) {
1791
+ if (typeof t != "number")
1792
+ return this;
1793
+ const { h: e, s, l: n } = this.toHsl(), { r, g: i, b: a } = lt(e, ut(s + t / 100), n);
1794
+ return Object.assign(this, { r, g: i, b: a }), this;
1795
+ }
1796
+ /**
1797
+ * Desaturate the colour with a given amount.
1798
+ */
1799
+ desaturate(t) {
1800
+ return typeof t == "number" ? this.saturate(-t) : this;
1801
+ }
1802
+ /**
1803
+ * Completely desaturates a colour into greyscale.
1804
+ * Same as calling `desaturate(100)`
1805
+ */
1806
+ greyscale() {
1807
+ return this.saturate(-100);
1808
+ }
1809
+ /**
1810
+ * Increase the colour lightness with a given amount.
1811
+ */
1812
+ lighten(t) {
1813
+ if (typeof t != "number")
1814
+ return this;
1815
+ const { h: e, s, l: n } = this.toHsl(), { r, g: i, b: a } = lt(e, s, ut(n + t / 100));
1816
+ return Object.assign(this, { r, g: i, b: a }), this;
1817
+ }
1818
+ /**
1819
+ * Decrease the colour lightness with a given amount.
1820
+ */
1821
+ darken(t) {
1822
+ return typeof t == "number" ? this.lighten(-t) : this;
1823
+ }
1824
+ /**
1825
+ * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
1826
+ * Values outside of this range will be wrapped into this range.
1827
+ */
1828
+ spin(t) {
1829
+ if (typeof t != "number")
1830
+ return this;
1831
+ const { h: e, s, l: n } = this.toHsl(), { r, g: i, b: a } = lt(ut((e * 360 + t) % 360 / 360), s, n);
1832
+ return Object.assign(this, { r, g: i, b: a }), this;
1833
+ }
1834
+ /** Returns a clone of the current `Color` instance. */
1835
+ clone() {
1836
+ return new y(this);
1837
+ }
1838
+ /**
1839
+ * Returns the colour value in CSS valid string format.
1840
+ */
1841
+ toString(t) {
1842
+ const { format: e } = this;
1843
+ return e === "hex" ? this.toHexString(t) : e === "hsl" ? this.toHslString() : e === "hwb" ? this.toHwbString() : this.toRgbString();
1844
+ }
1845
+ }
1846
+ class It {
1847
+ static Color = y;
1848
+ hue;
1849
+ hueSteps;
1850
+ lightSteps;
1851
+ saturation;
1852
+ colors;
1853
+ /**
1854
+ * The `hue` parameter is optional, which would be set to 0.
1855
+ * * `args.hue` the starting Hue [0, 360]
1856
+ * * `args.hueSteps` Hue Steps Count [5, 24]
1857
+ * * `args.lightSteps` Lightness Steps Count [5, 12]
1858
+ * * `args.saturation` Saturation [0, 100]
1859
+ */
1860
+ constructor(...t) {
1861
+ let e = 0, s = 12, n = 10, r = [0.5], i = 100;
1862
+ if (t.length === 4)
1863
+ [e, s, n, i] = t;
1864
+ else if (t.length === 3)
1865
+ [e, s, n] = t;
1866
+ else if (t.length === 2 && ([s, n] = t, [s, n].some((g) => g < 1)))
1867
+ throw TypeError("ColorPalette: the two minimum arguments must be numbers higher than 0.");
1868
+ const a = [], l = 360 / s, c = y.roundPart((n - (n % 2 ? 1 : 0)) / 2), h = [0.25, 0.2, 0.15, 0.11, 0.09, 0.075], b = [
1869
+ [1, 2, 3],
1870
+ [4, 5],
1871
+ [6, 7],
1872
+ [8, 9],
1873
+ [10, 11],
1874
+ [12, 13]
1875
+ ], u = b.find((g) => g.includes(n)), d = u ? h[b.indexOf(u)] : 100 / (n + (n % 2 ? 0 : 1)) / 100;
1876
+ for (let g = 1; g < c + 1; g += 1)
1877
+ r = [...r, 0.5 + d * g];
1878
+ for (let g = 1; g < n - c; g += 1)
1879
+ r = [0.5 - d * g, ...r];
1880
+ for (let g = 0; g < s; g += 1) {
1881
+ const p = (e + g * l) % 360 / 360;
1882
+ r.forEach((f) => {
1883
+ const w = new y({ h: p, s: 1, l: f });
1884
+ a.push(i < 100 ? w.saturate(i - 100) : w);
1885
+ });
1886
+ }
1887
+ this.hue = e, this.hueSteps = s, this.lightSteps = n, this.saturation = i, this.colors = a;
1888
+ }
1889
+ }
1890
+ const He = {
1891
+ pickerLabel: "Colour Picker",
1892
+ appearanceLabel: "Colour Appearance",
1893
+ valueLabel: "Colour Value",
1894
+ toggleLabel: "Select Colour",
1895
+ presetsLabel: "Colour Presets",
1896
+ defaultsLabel: "Colour Defaults",
1897
+ formatLabel: "Format",
1898
+ alphaLabel: "Alpha",
1899
+ hexLabel: "Hexadecimal",
1900
+ hueLabel: "Hue",
1901
+ whitenessLabel: "Whiteness",
1902
+ blacknessLabel: "Blackness",
1903
+ saturationLabel: "Saturation",
1904
+ lightnessLabel: "Lightness",
1905
+ redLabel: "Red",
1906
+ greenLabel: "Green",
1907
+ blueLabel: "Blue"
1908
+ }, Kt = [
1909
+ "white",
1910
+ "black",
1911
+ "grey",
1912
+ "red",
1913
+ "orange",
1914
+ "brown",
1915
+ "gold",
1916
+ "olive",
1917
+ "yellow",
1918
+ "lime",
1919
+ "green",
1920
+ "teal",
1921
+ "cyan",
1922
+ "blue",
1923
+ "violet",
1924
+ "magenta",
1925
+ "pink"
1926
+ ], re = (o) => {
1927
+ if (!V(o))
1928
+ return !1;
1929
+ try {
1930
+ JSON.parse(o);
1931
+ } catch {
1932
+ return !1;
1933
+ }
1934
+ return !0;
1935
+ }, Vt = "v-hidden", uo = (o) => {
1936
+ const { format: t, id: e, componentLabels: s } = o, n = x({
1937
+ tagName: "div",
1938
+ className: `color-form ${t}`
1939
+ });
1940
+ let r = ["hex"];
1941
+ return t === "rgb" ? r = ["red", "green", "blue", "alpha"] : t === "hsl" ? r = ["hue", "saturation", "lightness", "alpha"] : t === "hwb" && (r = ["hue", "whiteness", "blackness", "alpha"]), r.forEach((i) => {
1942
+ const [a] = t === "hex" ? ["#"] : pe(i).split(""), l = `color_${t}_${i}_${e}`, c = s[`${i}Label`], h = x({ tagName: "label" });
1943
+ m(h, "for", l), h.append(
1944
+ x({
1945
+ tagName: "span",
1946
+ ariaHidden: "true",
1947
+ innerText: `${a}:`
1948
+ }),
1949
+ x({
1950
+ tagName: "span",
1951
+ className: Vt,
1952
+ innerText: c
1953
+ })
1954
+ );
1955
+ const b = x({
1956
+ tagName: "input",
1957
+ id: l,
1958
+ // name: cID, - prevent saving the value to a form
1959
+ type: t === "hex" ? "text" : "number",
1960
+ value: i === "alpha" ? "100" : "0",
1961
+ className: `color-input ${i}`,
1962
+ autocomplete: "off",
1963
+ spellcheck: !1
1964
+ });
1965
+ let u = "100", d = "1";
1966
+ i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")), B(b, {
1967
+ min: "0",
1968
+ max: u,
1969
+ step: d
1970
+ }), n.append(h, b);
1971
+ }), n;
1972
+ }, bo = (o) => {
1973
+ const { format: t, componentLabels: e } = o, { hueLabel: s, alphaLabel: n, lightnessLabel: r, saturationLabel: i, whitenessLabel: a, blacknessLabel: l } = e, c = t === "hsl" ? 360 : 100, h = t === "hsl" ? 100 : 360, b = 100;
1974
+ let u = t === "hsl" ? `${s} & ${r}` : `${r} & ${i}`;
1975
+ u = t === "hwb" ? `${a} & ${l}` : u;
1976
+ const d = t === "hsl" ? `${i}` : `${s}`, g = x({
1977
+ tagName: "div",
1978
+ className: `color-controls ${t}`
1979
+ }), p = "color-pointer", f = "color-slider";
1980
+ return [
1981
+ {
1982
+ i: 1,
1983
+ c: p,
1984
+ l: u,
1985
+ min: 0,
1986
+ max: c
1987
+ },
1988
+ {
1989
+ i: 2,
1990
+ c: f,
1991
+ l: d,
1992
+ min: 0,
1993
+ max: h
1994
+ },
1995
+ {
1996
+ i: 3,
1997
+ c: f,
1998
+ l: n,
1999
+ min: 0,
2000
+ max: b
2001
+ }
2002
+ ].forEach(($) => {
2003
+ const { i: P, c: L, l: S, min: C, max: M } = $, E = x({
2004
+ tagName: "div",
2005
+ className: "color-control",
2006
+ role: "presentation"
2007
+ });
2008
+ E.append(
2009
+ x({
2010
+ tagName: "div",
2011
+ className: `visual-control visual-control${P}`
2012
+ })
2013
+ );
2014
+ const A = x({
2015
+ tagName: "div",
2016
+ className: `${L} knob`,
2017
+ ariaLive: "polite",
2018
+ ariaLabel: S,
2019
+ role: "slider",
2020
+ tabIndex: 0,
2021
+ ariaValueMin: `${C}`,
2022
+ ariaValueMax: `${M}`
2023
+ });
2024
+ E.append(A), g.append(E);
2025
+ }), g;
2026
+ }, ie = (o, t, e) => {
2027
+ const { input: s, format: n, componentLabels: r } = o, { defaultsLabel: i, presetsLabel: a } = r, l = e === "color-options", c = t instanceof It, h = l ? a : i, b = c ? t.colors : t, u = b.length, { lightSteps: d } = c ? t : { lightSteps: null }, g = d || [9, 10].find((A) => u >= A * 2 && !(u % A)) || 5, p = l && u > g;
2028
+ let f = 2;
2029
+ f = p && u > g * 2 ? 3 : f, f = p && u > g * 3 ? 4 : f, f = p && u > g * 4 ? 5 : f;
2030
+ const w = f - (u <= g * 3 ? 1 : 2), $ = p && u > w * g;
2031
+ let P = e;
2032
+ P += $ ? " scrollable" : "", P += p ? " multiline" : "";
2033
+ const L = p ? "1px" : "0.25rem";
2034
+ let S = p ? 1.75 : 2;
2035
+ S = g > 5 && p ? 1.5 : S;
2036
+ const C = `${w * S}rem`, M = `calc(${f} * ${S}rem + ${f - 1} * ${L})`, E = x({
2037
+ tagName: "ul",
2038
+ className: P,
2039
+ role: "listbox",
2040
+ ariaLabel: h
2041
+ });
2042
+ return $ && O(E, {
2043
+ "--grid-item-size": `${S}rem`,
2044
+ "--grid-fit": `${g}`,
2045
+ "--grid-gap": L,
2046
+ "--grid-height": C,
2047
+ "--grid-hover-height": M
2048
+ }), b.forEach((A) => {
2049
+ let [F, tt] = typeof A == "string" ? A.trim().split(":") : [];
2050
+ A instanceof y && (F = A.toHexString(), tt = F);
2051
+ const zt = new y(A instanceof y ? A : F, n).toString() === yt(s, "value"), xt = x({
2052
+ tagName: "li",
2053
+ className: `color-option${zt ? " active" : ""}`,
2054
+ innerText: `${tt || F}`,
2055
+ tabIndex: 0,
2056
+ role: "option",
2057
+ ariaSelected: zt ? "true" : "false"
2058
+ });
2059
+ m(xt, "data-value", `${F}`), l && O(xt, { backgroundColor: F }), E.append(xt);
2060
+ }), E;
2061
+ }, po = (o) => {
2062
+ const { input: t, parent: e, format: s, id: n, componentLabels: r, colorKeywords: i, colorPresets: a } = o, l = yt(t, "value") || "#fff", { nonColors: c } = y, { toggleLabel: h, pickerLabel: b, formatLabel: u, hexLabel: d } = r, g = c.includes(l) ? "#fff" : l;
2063
+ o.color = new y(g, s);
2064
+ const p = s === "hex" ? d : pe(s), f = x({
2065
+ id: `picker-btn-${n}`,
2066
+ tagName: "button",
2067
+ className: "picker-toggle btn-appearance",
2068
+ ariaExpanded: "false",
2069
+ ariaHasPopup: "true"
2070
+ });
2071
+ f.append(
2072
+ x({
2073
+ tagName: "span",
2074
+ className: Vt,
2075
+ innerText: `${b}. ${u}: ${p}`
2076
+ })
2077
+ );
2078
+ const w = x({
2079
+ tagName: "div",
2080
+ className: "color-dropdown picker",
2081
+ role: "group",
2082
+ ariaLabelledBy: `picker-btn-${n}`
2083
+ }), $ = bo(o), P = uo(o);
2084
+ if (w.append($, P), t.before(f), e.append(w), i || a) {
2085
+ const L = x({
2086
+ tagName: "div",
2087
+ className: "color-dropdown scrollable menu"
2088
+ });
2089
+ a && L.append(ie(o, a, "color-options")), i && i.length && L.append(ie(o, i, "color-defaults"));
2090
+ const S = x({
2091
+ tagName: "button",
2092
+ className: "menu-toggle btn-appearance",
2093
+ tabIndex: -1,
2094
+ ariaExpanded: "false",
2095
+ ariaHasPopup: "true"
2096
+ }), C = encodeURI("http://www.w3.org/2000/svg"), M = Mt(C, {
2097
+ tagName: "svg"
2098
+ });
2099
+ m(M, "xmlns", C), m(M, "viewBox", "0 0 512 512"), m(M, Me, "true");
2100
+ const E = Mt(C, {
2101
+ tagName: "path"
2102
+ });
2103
+ m(E, "d", "M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"), m(E, "fill", "#fff"), M.append(E), S.append(
2104
+ x({
2105
+ tagName: "span",
2106
+ className: Vt,
2107
+ innerText: `${h}`
2108
+ }),
2109
+ M
2110
+ ), e.append(S, L);
2111
+ }
2112
+ i && c.includes(l) && (o.value = l), m(t, Y, "-1");
2113
+ }, fo = "2.0.0-alpha1", Z = "color-picker", mo = `[data-function="${Z}"]`, ae = `.${Z}`, vo = {
2114
+ componentLabels: He,
2115
+ colorLabels: Kt,
2116
+ format: "rgb",
2117
+ colorPresets: !1,
2118
+ colorKeywords: !1
2119
+ }, { roundPart: k, nonColors: bt } = y, wo = (o) => Qe(o, Z), $o = (o) => new ko(o), le = (o, t) => {
2120
+ const e = t ? ge : Bt, { input: s, pickerToggle: n, menuToggle: r } = o;
2121
+ e(s, De, o.showPicker), e(n, Et, o.togglePicker), r && e(r, Et, o.toggleMenu);
2122
+ }, Ne = (o, t) => {
2123
+ const e = t ? ge : Bt, { input: s, colorMenu: n, parent: r } = o, i = K(s), a = ao(i);
2124
+ e(o.controls, Ie, o.pointerDown), o.controlKnobs.forEach((l) => e(l, Ut, o.handleKnobs)), e(a, Be, o.handleScroll), e(a, Ve, o.update), [s, ...o.inputs].forEach((l) => e(l, Te, o.changeHandler)), n && (e(n, Et, o.menuClickHandler), e(n, Ut, o.menuKeyHandler)), e(i, ue, o.pointerMove), e(i, Ke, o.pointerUp), e(r, Oe, o.handleFocusOut), e(i, Fe, o.handleDismiss);
2125
+ }, ce = (o) => {
2126
+ eo(o.input, new CustomEvent("colorpicker.change"));
2127
+ }, Ee = (o) => {
2128
+ o && ["bottom", "top"].forEach((t) => D(o, t));
2129
+ }, Ht = (o, t) => {
2130
+ const { colorPicker: e, colorMenu: s, menuToggle: n, pickerToggle: r, parent: i } = o, a = t === e, l = a ? s : e, c = a ? n : r, h = a ? r : n;
2131
+ T(i, "open") || q(i, "open"), l && (D(l, "show"), Ee(l)), q(t, "bottom"), ro(t), q(t, "show"), a && o.update(), o.isOpen || (Ne(o, !0), o.updateDropdownPosition(), o.isOpen = !0, m(o.input, Y, "0"), n && m(n, Y, "0")), m(h, Nt, "true"), c && m(c, Nt, "false");
2132
+ };
2133
+ class ko {
2134
+ // bring utils to staic
2135
+ static Color = y;
2136
+ static ColorPalette = It;
2137
+ static getInstance = wo;
2138
+ static init = $o;
2139
+ static selector = mo;
2140
+ // utils important for render
2141
+ static roundPart = k;
2142
+ static setElementStyle = O;
2143
+ static setAttribute = m;
2144
+ static getBoundingClientRect = gt;
2145
+ static version = fo;
2146
+ id;
2147
+ input;
2148
+ color;
2149
+ format = "rgb";
2150
+ parent;
2151
+ dragElement;
2152
+ isOpen = !1;
2153
+ controlPositions;
2154
+ colorLabels = {};
2155
+ colorKeywords;
2156
+ colorPresets;
2157
+ componentLabels;
2158
+ pickerToggle;
2159
+ menuToggle;
2160
+ colorPicker;
2161
+ colorMenu;
2162
+ controls;
2163
+ inputs;
2164
+ controlKnobs;
2165
+ visuals;
2166
+ /**
2167
+ * Returns a new `ColorPicker` instance. The target of this constructor
2168
+ * must be an `HTMLInputElement`.
2169
+ *
2170
+ * @param target the target `<input>` element
2171
+ * @param config instance options
2172
+ */
2173
+ constructor(t, e) {
2174
+ const s = _(t);
2175
+ if (typeof t > "u")
2176
+ throw new TypeError("ColorPicker target not specified.");
2177
+ if (V(t) && !s)
2178
+ throw new TypeError(`ColorPicker target "${t}" cannot be found.`);
2179
+ this.input = s;
2180
+ const n = fe(s, ae);
2181
+ if (!n)
2182
+ throw new TypeError("ColorPicker requires a specific markup to work.");
2183
+ this.parent = n, this.id = de(s, Z), this.dragElement = void 0, this.isOpen = !1, this.controlPositions = {
2184
+ c1x: 0,
2185
+ c1y: 0,
2186
+ c2y: 0,
2187
+ c3y: 0
2188
+ }, this.colorLabels = {}, this.colorKeywords = !1, this.colorPresets = !1;
2189
+ const { format: r, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } = no(
2190
+ s,
2191
+ vo,
2192
+ e || {}
2193
+ );
2194
+ let h = Kt;
2195
+ Lt(a) && a.length === 17 ? h = a : V(a) && a.split(",").length === 17 && (h = a.split(",")), Kt.forEach((p, f) => {
2196
+ this.colorLabels[p] = h[f].trim();
2197
+ });
2198
+ const b = V(i) && re(i) ? JSON.parse(i) : i;
2199
+ if (this.componentLabels = B({ ...He }, b), this.color = new y(s.value || "#fff", r), this.format = r, Lt(l) && l.length ? this.colorKeywords = l : V(l) && l.length && (this.colorKeywords = l.split(",").map((p) => p.trim())), Lt(c) && c.length)
2200
+ this.colorPresets = c;
2201
+ else if (c && re(c)) {
2202
+ const { hue: p, hueSteps: f, lightSteps: w, saturation: $ } = JSON.parse(c);
2203
+ this.colorPresets = new It(p, f, w, $);
2204
+ } else
2205
+ V(c) && (this.colorPresets = c.split(",").map((p) => p.trim()));
2206
+ this.showPicker = this.showPicker.bind(this), this.togglePicker = this.togglePicker.bind(this), this.toggleMenu = this.toggleMenu.bind(this), this.menuClickHandler = this.menuClickHandler.bind(this), this.menuKeyHandler = this.menuKeyHandler.bind(this), this.pointerDown = this.pointerDown.bind(this), this.pointerMove = this.pointerMove.bind(this), this.pointerUp = this.pointerUp.bind(this), this.update = this.update.bind(this), this.handleScroll = this.handleScroll.bind(this), this.handleFocusOut = this.handleFocusOut.bind(this), this.changeHandler = this.changeHandler.bind(this), this.handleDismiss = this.handleDismiss.bind(this), this.handleKnobs = this.handleKnobs.bind(this), po(this);
2207
+ const [u, d] = nt("color-dropdown", n);
2208
+ this.pickerToggle = _(".picker-toggle", n), this.menuToggle = _(".menu-toggle", n), this.colorPicker = u, this.colorMenu = d, this.inputs = [...nt("color-input", n)];
2209
+ const [g] = nt("color-controls", n);
2210
+ this.controls = g, this.controlKnobs = [...nt("knob", g)], this.visuals = [...nt("visual-control", g)], this.update(), le(this, !0), ct.set(s, Z, this);
2211
+ }
2212
+ /** Returns the current colour value */
2213
+ get value() {
2214
+ return this.input.value;
2215
+ }
2216
+ /**
2217
+ * Sets a new colour value.
2218
+ *
2219
+ * @param {string} v new colour value
2220
+ */
2221
+ set value(t) {
2222
+ this.input.value = t;
2223
+ }
2224
+ /** Check if the colour presets include any non-colour. */
2225
+ get hasNonColor() {
2226
+ return this.colorKeywords instanceof Array && this.colorKeywords.some((t) => bt.includes(t));
2227
+ }
2228
+ /** Returns hexadecimal value of the current colour. */
2229
+ get hex() {
2230
+ return this.color.toHex(!0);
2231
+ }
2232
+ /** Returns the current colour value in {h,s,v,a} object format. */
2233
+ get hsv() {
2234
+ return this.color.toHsv();
2235
+ }
2236
+ /** Returns the current colour value in {h,s,l,a} object format. */
2237
+ get hsl() {
2238
+ return this.color.toHsl();
2239
+ }
2240
+ /** Returns the current colour value in {h,w,b,a} object format. */
2241
+ get hwb() {
2242
+ return this.color.toHwb();
2243
+ }
2244
+ /** Returns the current colour value in {r,g,b,a} object format. */
2245
+ get rgb() {
2246
+ return this.color.toRgb();
2247
+ }
2248
+ /** Returns the current colour brightness. */
2249
+ get brightness() {
2250
+ return this.color.brightness;
2251
+ }
2252
+ /** Returns the current colour luminance. */
2253
+ get luminance() {
2254
+ return this.color.luminance;
2255
+ }
2256
+ /** Checks if the current colour requires a light text colour. */
2257
+ get isDark() {
2258
+ const { color: t, brightness: e } = this;
2259
+ return e < 120 && t.a > 0.33;
2260
+ }
2261
+ /** Checks if the current input value is a valid colour. */
2262
+ get isValid() {
2263
+ const t = this.input.value;
2264
+ return t !== "" && new y(t).isValid;
2265
+ }
2266
+ /** Returns the colour appearance, usually the closest colour name for the current value. */
2267
+ get appearance() {
2268
+ const { colorLabels: t, hsl: e, hsv: s, format: n } = this, r = k(e.h * 360), i = n === "hsl" ? e.s : s.s, a = k(i * 100), l = k(e.l * 100), c = s.v * 100;
2269
+ let h = "black";
2270
+ if (l === 100 && a === 0)
2271
+ h = t.white;
2272
+ else if (l === 0)
2273
+ h = t.black;
2274
+ else if (a === 0)
2275
+ h = t.grey;
2276
+ else if (r < 15 || r >= 345)
2277
+ h = t.red;
2278
+ else if (r >= 15 && r < 45)
2279
+ h = c > 80 && a > 80 ? t.orange : t.brown;
2280
+ else if (r >= 45 && r < 75) {
2281
+ const b = r > 46 && r < 54 && c < 80 && a > 90, u = r >= 54 && r < 75 && c < 80;
2282
+ h = b ? t.gold : t.yellow, h = u ? t.olive : h;
2283
+ } else
2284
+ r >= 75 && r < 155 ? h = c < 68 ? t.green : t.lime : r >= 155 && r < 175 ? h = t.teal : r >= 175 && r < 195 ? h = t.cyan : r >= 195 && r < 255 ? h = t.blue : r >= 255 && r < 270 ? h = t.violet : r >= 270 && r < 295 ? h = t.magenta : r >= 295 && r < 345 && (h = t.pink);
2285
+ return h;
2286
+ }
2287
+ /** Updates `ColorPicker` visuals. */
2288
+ updateVisuals() {
2289
+ const { controlPositions: t, visuals: e } = this, [s, n, r] = e, { offsetHeight: i } = s, a = t.c2y / i, { r: l, g: c, b: h } = new y({ h: a, s: 1, l: 0.5 }).toRgb(), b = "linear-gradient(rgb(255,255,255) 0%, rgb(255,255,255) 100%)", u = 1 - t.c3y / i, d = k(u * 100) / 100, g = new y({
2290
+ h: a,
2291
+ s: 1,
2292
+ l: 0.5,
2293
+ a: u
2294
+ }).toRgbString(), p = `linear-gradient(
2295
+ rgb(255,0,0) 0%, rgb(255,255,0) 16.67%,
2296
+ rgb(0,255,0) 33.33%, rgb(0,255,255) 50%,
2297
+ rgb(0,0,255) 66.67%, rgb(255,0,255) 83.33%,
2298
+ rgb(255,0,0) 100%)`;
2299
+ O(s, {
2300
+ background: `linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,${d}) 100%),
2301
+ linear-gradient(to right, rgba(255,255,255,${d}) 0%, ${g} 100%),
2302
+ ${b}`
2303
+ }), O(n, { background: p }), O(r, {
2304
+ background: `linear-gradient(rgba(${l},${c},${h},1) 0%,rgba(${l},${c},${h},0) 100%)`
2305
+ });
2306
+ }
2307
+ /**
2308
+ * The `ColorPicker` *focusout* event listener when open.
2309
+ *
2310
+ * @param e
2311
+ * @this {ColorPicker}
2312
+ */
2313
+ handleFocusOut({ relatedTarget: t }) {
2314
+ t && !this.parent.contains(t) && this.hide(!0);
2315
+ }
2316
+ /**
2317
+ * The `ColorPicker` *keyup* event listener when open.
2318
+ *
2319
+ * @param e
2320
+ * @this {ColorPicker}
2321
+ */
2322
+ handleDismiss({ code: t }) {
2323
+ this.isOpen && t === ze && this.hide();
2324
+ }
2325
+ /**
2326
+ * The `ColorPicker` *scroll* event listener when open.
2327
+ *
2328
+ * @param e
2329
+ * @this {ColorPicker}
2330
+ */
2331
+ handleScroll(t) {
2332
+ const { activeElement: e } = K(this.input);
2333
+ this.updateDropdownPosition(), ([ue, je].includes(t.type) && this.dragElement || e && this.controlKnobs.includes(e)) && (t.stopPropagation(), t.preventDefault());
2334
+ }
2335
+ /**
2336
+ * The `ColorPicker` keyboard event listener for menu navigation.
2337
+ *
2338
+ * @param e
2339
+ */
2340
+ menuKeyHandler(t) {
2341
+ const { target: e, code: s } = t, { previousElementSibling: n, nextElementSibling: r, parentElement: i } = e, a = i && T(i, "color-options"), l = i ? [...i.children] : [], c = a && Tt(i, "grid-template-columns").split(" ").length, h = l.indexOf(e), b = h > -1 && c && l[h - c], u = h > -1 && c && l[h + c];
2342
+ [j, st, _t].includes(s) && t.preventDefault(), a ? b && s === st ? U(b) : u && s === j ? U(u) : n && s === ht ? U(n) : r && s === G && U(r) : n && [ht, st].includes(s) ? U(n) : r && [G, j].includes(s) && U(r), [qe, _t].includes(s) && this.menuClickHandler(t);
2343
+ }
2344
+ /**
2345
+ * The `ColorPicker` click event listener for the colour menu presets / defaults.
2346
+ *
2347
+ * @param e
2348
+ * @this {ColorPicker}
2349
+ */
2350
+ menuClickHandler(t) {
2351
+ const { target: e } = t, { colorMenu: s } = this, n = (yt(e, "data-value") || "").trim();
2352
+ if (!n.length)
2353
+ return;
2354
+ const r = _("li.active", s);
2355
+ let i = n;
2356
+ i = bt.includes(i) ? "white" : i, i = i === "transparent" ? "rgba(0,0,0,0)" : i;
2357
+ const { r: a, g: l, b: c, a: h } = new y(i);
2358
+ B(this.color, {
2359
+ r: a,
2360
+ g: l,
2361
+ b: c,
2362
+ a: h
2363
+ }), this.update(), r !== e && (r && (D(r, "active"), St(r, Pt)), q(e, "active"), m(e, Pt, "true"), bt.includes(n) && (this.value = n), ce(this));
2364
+ }
2365
+ /**
2366
+ * The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
2367
+ *
2368
+ * @param e
2369
+ */
2370
+ pointerDown(t) {
2371
+ const { target: e, pageX: s, pageY: n } = t, { colorMenu: r, visuals: i, controlKnobs: a } = this, [l, c, h] = i, [b, u, d] = a, g = a.includes(e) ? e.previousElementSibling : e, p = gt(g), f = Ct(l), w = s - f.scrollLeft - p.left, $ = n - f.scrollTop - p.top;
2372
+ if (e === l || e === b ? (this.dragElement = g, this.changeControl1(w, $)) : e === c || e === u ? (this.dragElement = g, this.changeControl2($)) : (e === h || e === d) && (this.dragElement = g, this.changeAlpha($)), r) {
2373
+ const P = _("li.active", r);
2374
+ P && (D(P, "active"), St(P, Pt));
2375
+ }
2376
+ t.preventDefault();
2377
+ }
2378
+ /**
2379
+ * The `ColorPicker` *touchend* / *mouseup* events listener for control knobs.
2380
+ *
2381
+ * @param e
2382
+ * @this
2383
+ */
2384
+ pointerUp({ target: t }) {
2385
+ const { parent: e } = this, s = K(e), n = _(`${ae}.open`, s) !== null, r = s.getSelection();
2386
+ !this.dragElement && (!r || !r.toString().length) && !e.contains(t) && this.hide(n), this.dragElement = void 0;
2387
+ }
2388
+ /**
2389
+ * The `ColorPicker` *touchmove* / *mousemove* events listener for control knobs.
2390
+ *
2391
+ * @param {PointerEvent} e
2392
+ */
2393
+ pointerMove(t) {
2394
+ const { dragElement: e, visuals: s } = this, [n, r, i] = s, { pageX: a, pageY: l } = t;
2395
+ if (!e)
2396
+ return;
2397
+ const c = gt(e), h = Ct(n), b = a - h.scrollLeft - c.left, u = l - h.scrollTop - c.top;
2398
+ e === n && this.changeControl1(b, u), e === r && this.changeControl2(u), e === i && this.changeAlpha(u);
2399
+ }
2400
+ /**
2401
+ * The `ColorPicker` *keydown* event listener for control knobs.
2402
+ *
2403
+ * @param e
2404
+ */
2405
+ handleKnobs(t) {
2406
+ const { target: e, code: s } = t;
2407
+ if (![st, j, ht, G].includes(s))
2408
+ return;
2409
+ t.preventDefault();
2410
+ const { controlKnobs: n, visuals: r } = this, { offsetWidth: i, offsetHeight: a } = r[0], [l, c, h] = n, { activeElement: b } = K(l), u = n.find((g) => g === b), d = a / 360;
2411
+ if (u) {
2412
+ let g = 0, p = 0;
2413
+ if (e === l) {
2414
+ const f = i / 100;
2415
+ [ht, G].includes(s) ? this.controlPositions.c1x += s === G ? f : -f : [st, j].includes(s) && (this.controlPositions.c1y += s === j ? d : -d), g = this.controlPositions.c1x, p = this.controlPositions.c1y, this.changeControl1(g, p);
2416
+ } else
2417
+ e === c ? (this.controlPositions.c2y += [j, G].includes(s) ? d : -d, p = this.controlPositions.c2y, this.changeControl2(p)) : e === h && (this.controlPositions.c3y += [j, G].includes(s) ? d : -d, p = this.controlPositions.c3y, this.changeAlpha(p));
2418
+ this.handleScroll(t);
2419
+ }
2420
+ }
2421
+ /** The event listener of the colour form inputs. */
2422
+ changeHandler() {
2423
+ let t;
2424
+ const { inputs: e, format: s, value: n, input: r, controlPositions: i, visuals: a } = this, { activeElement: l } = K(r), { offsetHeight: c } = a[0], [h, , , b] = e, [u, d, g, p] = s === "rgb" ? e.map(($) => parseFloat($.value) / ($ === b ? 100 : 1)) : e.map(($) => parseFloat($.value) / ($ !== h ? 100 : 360)), f = this.hasNonColor && bt.includes(n), w = b ? p : 1 - i.c3y / c;
2425
+ if (l === r || l && e.includes(l)) {
2426
+ l === r ? f ? t = n === "transparent" ? "rgba(0,0,0,0)" : "rgb(0,0,0)" : t = n : s === "hex" ? t = h.value : s === "hsl" ? t = {
2427
+ h: u,
2428
+ s: d,
2429
+ l: g,
2430
+ a: w
2431
+ } : s === "hwb" ? t = {
2432
+ h: u,
2433
+ w: d,
2434
+ b: g,
2435
+ a: w
2436
+ } : t = {
2437
+ r: u,
2438
+ g: d,
2439
+ b: g,
2440
+ a: w
2441
+ };
2442
+ const { r: $, g: P, b: L, a: S } = new y(t);
2443
+ B(this.color, {
2444
+ r: $,
2445
+ g: P,
2446
+ b: L,
2447
+ a: S
2448
+ }), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === r && f && (this.value = n);
2449
+ }
2450
+ }
2451
+ /**
2452
+ * Updates `ColorPicker` first control:
2453
+ * * `lightness` and `saturation` for HEX/RGB;
2454
+ * * `lightness` and `hue` for HSL.
2455
+ *
2456
+ * @param X the X component of the offset
2457
+ * @param Y the Y component of the offset
2458
+ */
2459
+ changeControl1(t, e) {
2460
+ let [s, n] = [0, 0];
2461
+ const { controlPositions: r, visuals: i } = this, { offsetHeight: a, offsetWidth: l } = i[0];
2462
+ t > l ? s = l : t >= 0 && (s = t), e > a ? n = a : e >= 0 && (n = e);
2463
+ const c = r.c2y / a, h = s / l, b = 1 - n / a, u = 1 - r.c3y / a, { r: d, g, b: p, a: f } = new y({
2464
+ h: c,
2465
+ s: h,
2466
+ v: b,
2467
+ a: u
2468
+ });
2469
+ B(this.color, {
2470
+ r: d,
2471
+ g,
2472
+ b: p,
2473
+ a: f
2474
+ }), this.controlPositions.c1x = s, this.controlPositions.c1y = n, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2475
+ }
2476
+ /**
2477
+ * Updates `ColorPicker` second control:
2478
+ * * `hue` for HEX/RGB/HWB;
2479
+ * * `saturation` for HSL.
2480
+ *
2481
+ * @param Y the Y offset
2482
+ */
2483
+ changeControl2(t) {
2484
+ const { controlPositions: e, visuals: s } = this, { offsetHeight: n, offsetWidth: r } = s[0];
2485
+ let i = 0;
2486
+ t > n ? i = n : t >= 0 && (i = t);
2487
+ const a = i / n, l = e.c1x / r, c = 1 - e.c1y / n, h = 1 - e.c3y / n, { r: b, g: u, b: d, a: g } = new y({
2488
+ h: a,
2489
+ s: l,
2490
+ v: c,
2491
+ a: h
2492
+ });
2493
+ B(this.color, {
2494
+ r: b,
2495
+ g: u,
2496
+ b: d,
2497
+ a: g
2498
+ }), this.controlPositions.c2y = i, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2499
+ }
2500
+ /**
2501
+ * Updates `ColorPicker` last control,
2502
+ * the `alpha` channel.
2503
+ *
2504
+ * @param Y
2505
+ */
2506
+ changeAlpha(t) {
2507
+ const { visuals: e } = this, { offsetHeight: s } = e[0];
2508
+ let n = 0;
2509
+ t > s ? n = s : t >= 0 && (n = t);
2510
+ const r = 1 - n / s;
2511
+ this.color.setAlpha(r), this.controlPositions.c3y = n, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2512
+ }
2513
+ /**
2514
+ * Updates `ColorPicker` control positions on:
2515
+ * * initialization
2516
+ * * window resize
2517
+ */
2518
+ update() {
2519
+ this.updateDropdownPosition(), this.updateAppearance(), this.setControlPositions(), this.updateInputs(!0), this.updateControls(), this.updateVisuals();
2520
+ }
2521
+ /** Updates the open dropdown position on *scroll* event. */
2522
+ updateDropdownPosition() {
2523
+ const { input: t, colorPicker: e, colorMenu: s } = this, n = gt(t), { top: r, bottom: i } = n, { offsetHeight: a } = t, l = Ct(t).clientHeight, h = T(e, "show") ? e : s;
2524
+ if (!h)
2525
+ return;
2526
+ const { offsetHeight: b } = h, u = l - i, d = r, g = r + b + a > l, p = r - b < 0;
2527
+ (T(h, "bottom") || !p) && u < d && g ? (D(h, "bottom"), q(h, "top")) : (D(h, "top"), q(h, "bottom"));
2528
+ }
2529
+ /** Updates control knobs' positions. */
2530
+ setControlPositions() {
2531
+ const { visuals: t, color: e, hsv: s } = this, { offsetHeight: n, offsetWidth: r } = t[0], i = e.a, a = s.h, l = s.s, c = s.v;
2532
+ this.controlPositions.c1x = l * r, this.controlPositions.c1y = (1 - c) * n, this.controlPositions.c2y = a * n, this.controlPositions.c3y = (1 - i) * n;
2533
+ }
2534
+ /** Update the visual appearance label and control knob labels. */
2535
+ updateAppearance() {
2536
+ const { componentLabels: t, color: e, parent: s, hsv: n, hex: r, format: i, controlKnobs: a } = this, { appearanceLabel: l, hexLabel: c, valueLabel: h } = t;
2537
+ let { r: b, g: u, b: d } = e.toRgb();
2538
+ const [g, p, f] = a, w = k(n.h * 360), $ = e.a, P = k(n.s * 100), L = k(n.v * 100), S = this.appearance;
2539
+ let C = `${c} ${r.split("").join(" ")}`;
2540
+ if (i === "hwb") {
2541
+ const { hwb: A } = this, F = k(A.w * 100), tt = k(A.b * 100);
2542
+ C = `HWB: ${w}°, ${F}%, ${tt}%`, m(g, ot, `${F}% & ${tt}%`), m(g, et, `${F}`), m(p, Gt, `${h}: ${C}. ${l}: ${S}.`), m(p, ot, `${w}%`), m(p, et, `${w}`);
2543
+ } else
2544
+ [b, u, d] = [b, u, d].map(k), C = i === "hsl" ? `HSL: ${w}°, ${P}%, ${L}%` : C, C = i === "rgb" ? `RGB: ${b}, ${u}, ${d}` : C, m(g, ot, `${L}% & ${P}%`), m(g, et, `${L}`), m(p, Gt, `${h}: ${C}. ${l}: ${S}.`), m(p, ot, `${w}°`), m(p, et, `${w}`);
2545
+ const M = k($ * 100);
2546
+ m(f, ot, `${M}%`), m(f, et, `${M}`);
2547
+ const E = e.toString();
2548
+ O(this.input, { backgroundColor: E }), this.isDark ? (T(s, "txt-light") && D(s, "txt-light"), T(s, "txt-dark") || q(s, "txt-dark")) : (T(s, "txt-dark") && D(s, "txt-dark"), T(s, "txt-light") || q(s, "txt-light"));
2549
+ }
2550
+ /** Updates the control knobs actual positions. */
2551
+ updateControls() {
2552
+ const { controlKnobs: t, controlPositions: e } = this;
2553
+ let { c1x: s, c1y: n, c2y: r, c3y: i } = e;
2554
+ const [a, l, c] = t;
2555
+ [s, n, r, i] = [s, n, r, i].map(k), O(a, {
2556
+ transform: `translate3d(${s - 4}px,${n - 4}px,0)`
2557
+ }), O(l, { transform: `translate3d(0,${r - 4}px,0)` }), O(c, { transform: `translate3d(0,${i - 4}px,0)` });
2558
+ }
2559
+ /**
2560
+ * Updates all color form inputs.
2561
+ *
2562
+ * @param isPrevented when `true`, the component original event is prevented
2563
+ */
2564
+ updateInputs(t) {
2565
+ const { value: e, format: s, inputs: n, color: r, hsl: i } = this, [a, l, c, h] = n, b = k(r.a * 100), u = k(i.h * 360);
2566
+ let d = r.toString();
2567
+ if (s === "hex")
2568
+ d = this.color.toHexString(!0), a.value = this.hex;
2569
+ else if (s === "hsl") {
2570
+ const g = k(i.l * 100), p = k(i.s * 100);
2571
+ d = this.color.toHslString(), a.value = `${u}`, l.value = `${p}`, c.value = `${g}`, h.value = `${b}`;
2572
+ } else if (s === "hwb") {
2573
+ const { w: g, b: p } = this.hwb, f = k(g * 100), w = k(p * 100);
2574
+ d = this.color.toHwbString(), a.value = `${u}`, l.value = `${f}`, c.value = `${w}`, h.value = `${b}`;
2575
+ } else if (s === "rgb") {
2576
+ let { r: g, g: p, b: f } = this.rgb;
2577
+ [g, p, f] = [g, p, f].map(k), d = this.color.toRgbString(), a.value = `${g}`, l.value = `${p}`, c.value = `${f}`, h.value = `${b}`;
2578
+ }
2579
+ this.value = d, !t && d !== e && ce(this);
2580
+ }
2581
+ /**
2582
+ * Toggle the `ColorPicker` dropdown visibility.
2583
+ *
2584
+ * @param e
2585
+ */
2586
+ togglePicker(t) {
2587
+ t && t.preventDefault();
2588
+ const { colorPicker: e } = this;
2589
+ this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
2590
+ }
2591
+ /** Shows the `ColorPicker` dropdown. */
2592
+ showPicker() {
2593
+ const { colorPicker: t } = this;
2594
+ ["top", "bottom"].some((e) => T(t, e)) || Ht(this, t);
2595
+ }
2596
+ /**
2597
+ * Toggles the visibility of the `ColorPicker` presets menu.
2598
+ *
2599
+ * @param e
2600
+ * @this {ColorPicker}
2601
+ */
2602
+ toggleMenu(t) {
2603
+ t && t.preventDefault();
2604
+ const { colorMenu: e } = this;
2605
+ this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
2606
+ }
2607
+ /**
2608
+ * Hides the currently open `ColorPicker` dropdown.
2609
+ *
2610
+ * @param {boolean=} focusPrevented
2611
+ */
2612
+ hide(t) {
2613
+ if (this.isOpen) {
2614
+ const { pickerToggle: e, menuToggle: s, colorPicker: n, colorMenu: r, parent: i, input: a } = this, l = T(n, "show"), c = l ? n : r, h = l ? e : s, b = c && oo(c);
2615
+ this.value = this.color.toString(!0), c && (D(c, "show"), m(h, Nt, "false"), setTimeout(() => {
2616
+ Ee(c), _(".show", i) || (D(i, "open"), Ne(this), this.isOpen = !1);
2617
+ }, b)), t || U(e), m(a, Y, "-1"), h === s && m(s, Y, "-1");
2618
+ }
2619
+ }
2620
+ /** Removes `ColorPicker` from target `<input>`. */
2621
+ dispose() {
2622
+ const { input: t, parent: e } = this;
2623
+ this.hide(!0), le(this), [...e.children].forEach((s) => {
2624
+ s !== t && s.remove();
2625
+ }), St(t, Y), O(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => D(e, s)), ct.remove(t, Z);
2626
+ }
2627
+ }
2628
+ export {
2629
+ ko as default
2630
+ };
2631
+ //# sourceMappingURL=color-picker.mjs.map