@thednp/color-picker 2.0.0-alpha1 → 2.0.0-alpha10

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 (56) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/.lgtm.yml +0 -0
  3. package/.prettierrc.json +0 -0
  4. package/.stylelintrc.json +0 -0
  5. package/LICENSE +0 -0
  6. package/README.md +8 -7
  7. package/compile.js +6 -3
  8. package/cypress/e2e/color-palette.cy.ts +0 -0
  9. package/cypress/e2e/color-picker.cy.ts +58 -69
  10. package/cypress/fixtures/colorNamesFrench.js +0 -0
  11. package/cypress/fixtures/componentLabelsFrench.js +0 -0
  12. package/cypress/fixtures/format.js +0 -0
  13. package/cypress/fixtures/getMarkup.js +8 -1
  14. package/cypress/fixtures/getRandomInt.js +0 -0
  15. package/cypress/fixtures/sampleWebcolors.js +0 -0
  16. package/cypress/fixtures/testSample.js +0 -0
  17. package/cypress/plugins/esbuild-istanbul.ts +0 -0
  18. package/cypress/plugins/tsCompile.ts +0 -0
  19. package/cypress/support/commands.ts +0 -0
  20. package/cypress/support/e2e.ts +0 -0
  21. package/cypress/test.html +0 -0
  22. package/cypress.config.ts +0 -0
  23. package/dist/css/color-picker.css +13 -18
  24. package/dist/css/color-picker.min.css +2 -2
  25. package/dist/css/color-picker.rtl.css +13 -18
  26. package/dist/css/color-picker.rtl.min.css +2 -2
  27. package/dist/js/color-picker.cjs +3 -3
  28. package/dist/js/color-picker.cjs.map +1 -1
  29. package/dist/js/color-picker.d.ts +42 -24
  30. package/dist/js/color-picker.js +3 -3
  31. package/dist/js/color-picker.js.map +1 -1
  32. package/dist/js/color-picker.mjs +408 -421
  33. package/dist/js/color-picker.mjs.map +1 -1
  34. package/dts.config.ts +0 -0
  35. package/package.json +116 -98
  36. package/src/scss/_variables.scss +0 -0
  37. package/src/scss/color-picker.rtl.scss +0 -0
  38. package/src/scss/color-picker.scss +20 -14
  39. package/src/ts/colorPalette.ts +0 -0
  40. package/src/ts/index.ts +40 -54
  41. package/src/ts/interface/ColorNames.ts +20 -0
  42. package/src/ts/interface/colorPickerLabels.ts +0 -0
  43. package/src/ts/interface/colorPickerOptions.ts +0 -0
  44. package/src/ts/interface/paletteOptions.ts +0 -0
  45. package/src/ts/util/colorNames.ts +0 -0
  46. package/src/ts/util/colorPickerLabels.ts +0 -0
  47. package/src/ts/util/getColorControls.ts +0 -0
  48. package/src/ts/util/getColorForm.ts +0 -0
  49. package/src/ts/util/getColorMenu.ts +0 -0
  50. package/src/ts/util/isValidJSON.ts +0 -0
  51. package/src/ts/util/setMarkup.ts +6 -4
  52. package/src/ts/util/vHidden.ts +0 -0
  53. package/tsconfig.json +1 -1
  54. package/vite.config.ts +0 -0
  55. package/cypress/downloads/downloads.htm +0 -0
  56. package/cypress/fixtures/getCEMarkup.js +0 -29
@@ -1,21 +1,5 @@
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);
1
+ const _t = "aria-description", Nt = "aria-expanded", Ee = "aria-hidden", St = "aria-selected", tt = "aria-valuenow", et = "aria-valuetext", Me = "change", Te = "DOMContentLoaded", Re = "focusin", Oe = "focusout", zt = "keydown", De = "keyup", Et = "click", Fe = "pointerdown", ue = "pointermove", Ie = "pointerup", Ke = "resize", Ve = "scroll", Be = "touchmove", j = "ArrowDown", ot = "ArrowUp", ht = "ArrowLeft", U = "ArrowRight", je = "Enter", qe = "Escape", Wt = "Space", Ge = "transitionDuration", Ue = "transitionProperty", X = "tabindex", _e = navigator.userAgentData, mt = _e, { userAgent: ze } = navigator, vt = ze, Jt = /iPhone|iPad|iPod|Android/i;
2
+ mt ? mt.brands.some((o) => Jt.test(o.brand)) : Jt.test(vt);
19
3
  const Xt = /(iPhone|iPod|iPad)/;
20
4
  mt ? mt.brands.some((o) => Xt.test(o.brand)) : (
21
5
  /* istanbul ignore next */
@@ -24,18 +8,18 @@ mt ? mt.brands.some((o) => Xt.test(o.brand)) : (
24
8
  vt && vt.includes("Firefox");
25
9
  const { head: kt } = document;
26
10
  ["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));
11
+ const Bt = (o, t, e, s) => {
12
+ const r = s || !1;
13
+ o.addEventListener(t, e, r);
14
+ }, jt = (o, t, e, s) => {
15
+ const r = s || !1;
16
+ o.removeEventListener(t, e, r);
17
+ }, We = (o, t, e, s) => {
18
+ const r = (n) => {
19
+ (n.target === o || n.currentTarget === o) && (e.apply(o, [n]), jt(o, t, r, s));
36
20
  };
37
- Xe(o, t, n, s);
38
- }, Ze = () => {
21
+ Bt(o, t, r, s);
22
+ }, Je = () => {
39
23
  };
40
24
  (() => {
41
25
  let o = !1;
@@ -43,7 +27,7 @@ const Xe = (o, t, e, s) => {
43
27
  const t = Object.defineProperty({}, "passive", {
44
28
  get: () => (o = !0, o)
45
29
  });
46
- Ye(document, Re, Ze, t);
30
+ We(document, Te, Je, t);
47
31
  } catch {
48
32
  }
49
33
  return o;
@@ -51,11 +35,11 @@ const Xe = (o, t, e, s) => {
51
35
  ["webkitTransform", "transform"].some((o) => o in kt.style);
52
36
  ["webkitAnimation", "animation"].some((o) => o in kt.style);
53
37
  ["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) => {
38
+ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), Pt = (o, t) => o.removeAttribute(t), q = (o, ...t) => {
55
39
  o.classList.add(...t);
56
- }, D = (o, ...t) => {
40
+ }, O = (o, ...t) => {
57
41
  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 = {
42
+ }, T = (o, t) => o.classList.contains(t), qt = (o) => o != null && typeof o == "object" || !1, Y = (o) => qt(o) && typeof o.nodeType == "number" && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].some((t) => o.nodeType === t) || !1, at = (o) => Y(o) && o.nodeType === 1 || !1, W = /* @__PURE__ */ new Map(), ct = {
59
43
  data: W,
60
44
  /**
61
45
  * Sets web components data.
@@ -97,62 +81,62 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), S
97
81
  const e = ct.getAllFor(t);
98
82
  !e || !at(o) || (e.delete(o), e.size === 0 && W.delete(t));
99
83
  }
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) => {
84
+ }, Xe = (o, t) => ct.get(o, t), B = (o) => typeof o == "string" || !1, Ze = (o) => qt(o) && o.constructor.name === "Window" || !1, be = (o) => Y(o) && o.nodeType === 9 || !1, V = (o) => Ze(o) ? o.document : be(o) ? o : Y(o) ? o.ownerDocument : window.document, K = (o, ...t) => Object.assign(o, ...t), x = (o) => {
101
85
  if (!o)
102
86
  return;
103
- if (V(o))
104
- return K().createElement(o);
87
+ if (B(o))
88
+ return V().createElement(o);
105
89
  const { tagName: t } = o, e = x(t);
106
90
  if (!e)
107
91
  return;
108
92
  const s = { ...o };
109
- return delete s.tagName, B(e, s);
93
+ return delete s.tagName, K(e, s);
110
94
  }, Mt = (o, t) => {
111
95
  if (!o || !t)
112
96
  return;
113
- if (V(t))
114
- return K().createElementNS(o, t);
97
+ if (B(t))
98
+ return V().createElementNS(o, t);
115
99
  const { tagName: e } = t, s = Mt(o, e);
116
100
  if (!s)
117
101
  return;
118
- const n = { ...t };
119
- return delete n.tagName, B(s, n);
120
- }, eo = (o, t) => o.dispatchEvent(t), Tt = (o, t) => {
102
+ const r = { ...t };
103
+ return delete r.tagName, K(s, r);
104
+ }, Ye = (o, t) => o.dispatchEvent(t), Tt = (o, t) => {
121
105
  const e = getComputedStyle(o), s = t.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
122
106
  return e.getPropertyValue(s);
123
- }, oo = (o) => {
107
+ }, Qe = (o) => {
124
108
  const t = Tt(o, Ue), e = Tt(o, Ge), s = e.includes("ms") ? (
125
109
  /* istanbul ignore next */
126
110
  1
127
- ) : 1e3, n = t && t !== "none" ? parseFloat(e) * s : (
111
+ ) : 1e3, r = t && t !== "none" ? parseFloat(e) * s : (
128
112
  /* istanbul ignore next */
129
113
  0
130
114
  );
131
- return Number.isNaN(n) ? (
115
+ return Number.isNaN(r) ? (
132
116
  /* istanbul ignore next */
133
117
  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);
118
+ ) : r;
119
+ }, _ = (o, t) => o.focus(t), Zt = (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), to = (o) => o.toLowerCase(), eo = (o, t, e, s) => {
120
+ const r = { ...e }, n = { ...o.dataset }, i = { ...t }, a = {}, l = "title";
121
+ return pt(n).forEach(([c, h]) => {
122
+ const b = s && typeof c == "string" && c.includes(s) ? c.replace(s, "").replace(/[A-Z]/g, (u) => to(u)) : c;
123
+ a[b] = Zt(h);
124
+ }), pt(r).forEach(([c, h]) => {
125
+ r[c] = Zt(h);
142
126
  }), 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;
127
+ c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ? yt(o, l) : h;
144
128
  }), i;
145
- }, ro = (o) => o.offsetHeight, O = (o, t) => {
129
+ }, Yt = (o) => Object.fromEntries(o), oo = (o) => o.offsetHeight, D = (o, t) => {
146
130
  pt(t).forEach(([e, s]) => {
147
- if (s && V(e) && e.includes("--"))
131
+ if (s && B(e) && e.includes("--"))
148
132
  o.style.setProperty(e, s);
149
133
  else {
150
- const n = {};
151
- n[e] = s, B(o.style, n);
134
+ const r = {};
135
+ r[e] = s, K(o.style, r);
152
136
  }
153
137
  });
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();
138
+ }, so = (o) => qt(o) && o.constructor.name === "Map" || !1, pe = (o) => o.toUpperCase(), gt = (o, t) => {
139
+ const { width: e, height: s, top: r, right: n, bottom: i, left: a } = o.getBoundingClientRect();
156
140
  let l = 1, c = 1;
157
141
  if (t && at(o)) {
158
142
  const { offsetWidth: h, offsetHeight: b } = o;
@@ -167,32 +151,32 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), S
167
151
  return {
168
152
  width: e / l,
169
153
  height: s / c,
170
- top: n / c,
171
- right: r / l,
154
+ top: r / c,
155
+ right: n / l,
172
156
  bottom: i / c,
173
157
  left: a / l,
174
158
  x: a / l,
175
- y: n / c
159
+ y: r / c
176
160
  };
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;
161
+ }, Ct = (o) => V(o).documentElement;
162
+ let Qt = 0, te = 0;
163
+ const J = /* @__PURE__ */ new Map(), de = (o, t) => {
164
+ let e = t ? Qt : te;
181
165
  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);
166
+ const s = de(o), r = J.get(s) || /* @__PURE__ */ new Map();
167
+ J.has(s) || J.set(s, r), so(r) && !r.has(t) ? (r.set(t, e), Qt += 1) : e = r.get(t);
184
168
  } else {
185
169
  const s = o.id || o;
186
- X.has(s) ? e = X.get(s) : (X.set(s, e), Zt += 1);
170
+ J.has(s) ? e = J.get(s) : (J.set(s, e), te += 1);
187
171
  }
188
172
  return e;
189
- }, ao = (o) => {
173
+ }, ro = (o) => {
190
174
  var t;
191
- return o ? be(o) ? o.defaultView : Q(o) ? (t = o?.ownerDocument) == null ? void 0 : t.defaultView : o : window;
175
+ return o ? be(o) ? o.defaultView : Y(o) ? (t = o?.ownerDocument) == null ? void 0 : t.defaultView : o : window;
192
176
  }, 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(
177
+ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Y(t) ? t : V()).querySelector(o), st = (o, t) => (t && Y(t) ? t : V()).getElementsByClassName(
194
178
  o
195
- ), qt = ["transparent", "currentColor", "inherit", "revert", "initial"], v = (o) => {
179
+ ), Gt = ["transparent", "currentColor", "inherit", "revert", "initial"], v = (o) => {
196
180
  const t = Math.floor(o);
197
181
  return o - t < 0.5 ? t : Math.round(o);
198
182
  }, wt = [
@@ -1380,7 +1364,7 @@ fe(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
1380
1364
  b: 50
1381
1365
  }
1382
1366
  ]
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 = {
1367
+ ], me = "deg|rad|grad|turn", ve = "[-\\+]?\\d+%?", we = "[-\\+]?\\d*\\.\\d+%?", $e = `[-\\+]?\\d*\\.?\\d+(?:${me})?`, dt = `(?:${we})|(?:${ve})`, Rt = `(?:${dt})|(?:${$e}?)`, no = "(?:[\\s|\\(\\s|\\s\\(\\s]+)?", io = "(?:[\\s|\\)\\s]+)?", ee = "(?:[,|\\s]+)", ao = "(?:[,|\\/\\s]*)?", rt = `${no}(${Rt})${ee}(${dt})${ee}(${dt})${ao}(${dt})?${io}`, I = {
1384
1368
  CSS_UNIT: new RegExp(Rt),
1385
1369
  ANGLES: me,
1386
1370
  CSS_ANGLE: $e,
@@ -1396,7 +1380,7 @@ fe(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
1396
1380
  hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1397
1381
  hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1398
1382
  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) => {
1383
+ }, ke = (o) => Gt.includes(o), nt = (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"], Se = (o) => Gt.includes(o) || ["#", ...xe].some((t) => o.includes(t)) ? !1 : wt.some(([t]) => o === t), R = (o, t) => {
1400
1384
  let e = o;
1401
1385
  if (typeof o == "number" && Math.min(o, 0) === 0 && // round values to 6 decimals Math.round(N * (10 ** 6)) / 10 ** 6
1402
1386
  Math.max(o, 1) === 1)
@@ -1404,45 +1388,45 @@ fe(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
1404
1388
  ye(o) && (e = "100%");
1405
1389
  const s = $t(e);
1406
1390
  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) => {
1391
+ }, Ot = (o) => {
1408
1392
  let t = parseFloat(o);
1409
1393
  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) => {
1394
+ }, ut = (o) => Math.min(1, Math.max(0, o)), G = (o) => o.length === 1 ? `0${o}` : String(o), Pe = (o) => {
1411
1395
  const [[, t]] = wt.filter(([e]) => e === o.toLowerCase());
1412
1396
  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;
1397
+ }, N = (o) => parseInt(o, 16), Dt = (o) => N(o) / 255, Ce = (o) => v(o * 255).toString(16), oe = (o, t, e) => {
1398
+ const s = Math.max(o, t, e), r = Math.min(o, t, e);
1399
+ let n = 0, i = 0;
1400
+ const a = (s + r) / 2;
1401
+ if (s === r)
1402
+ i = 0, n = 0;
1419
1403
  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;
1404
+ const l = s - r;
1405
+ i = a > 0.5 ? l / (2 - s - r) : l / (s + r), s === o && (n = (t - e) / l + (t < e ? 6 : 0)), s === t && (n = (e - o) / l + 2), s === e && (n = (o - t) / l + 4), n /= 6;
1422
1406
  }
1423
- return { h: r, s: i, l: a };
1407
+ return { h: n, s: i, l: a };
1424
1408
  }, ft = (o, t, e) => {
1425
1409
  let s = e;
1426
1410
  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
1411
  }, lt = (o, t, e) => {
1428
- let s = 0, n = 0, r = 0;
1412
+ let s = 0, r = 0, n = 0;
1429
1413
  if (t === 0)
1430
- n = e, r = e, s = e;
1414
+ r = e, n = e, s = e;
1431
1415
  else if (e) {
1432
1416
  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;
1417
+ s = ft(a, i, o + 1 / 3), r = ft(a, i, o), n = ft(a, i, o - 1 / 3);
1418
+ }
1419
+ return { r: s, g: r, b: n };
1420
+ }, se = (o, t, e) => {
1421
+ let s = 0, r = 0;
1422
+ const n = Math.min(o, t, e), i = Math.max(o, t, e), a = 1 - i;
1423
+ if (i === n)
1424
+ return { h: 0, w: n, b: a };
1425
+ o === n ? (s = t - e, r = 3) : (s = t === n ? e - o : o - t, r = t === n ? 5 : 1);
1426
+ const l = (r - s / (i - n)) / 6;
1443
1427
  return {
1444
1428
  h: l === 1 ? 0 : l,
1445
- w: r,
1429
+ w: n,
1446
1430
  b: a
1447
1431
  };
1448
1432
  }, Le = (o, t, e) => {
@@ -1450,35 +1434,35 @@ fe(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
1450
1434
  const i = t / (t + e);
1451
1435
  return { r: i, g: i, b: i };
1452
1436
  }
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 };
1437
+ let { r: s, g: r, b: n } = lt(o, 1, 0.5);
1438
+ return [s, r, n] = [s, r, n].map((i) => i * (1 - t - e) + t), { r: s, g: r, b: n };
1439
+ }, re = (o, t, e) => {
1440
+ const s = Math.max(o, t, e), r = Math.min(o, t, e);
1441
+ let n = 0;
1442
+ const i = s, a = s - r, l = s === 0 ? 0 : a / s;
1443
+ return s === r ? n = 0 : (o === s && (n = (t - e) / a + (t < e ? 6 : 0)), t === s && (n = (e - o) / a + 2), e === s && (n = (o - t) / a + 4), n /= 6), { h: n, s: l, v: i };
1460
1444
  }, 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];
1445
+ const s = o * 6, r = t, n = e, i = Math.floor(s), a = s - i, l = n * (1 - r), c = n * (1 - a * r), h = n * (1 - (1 - a) * r), b = i % 6, u = [n, c, l, l, h, n][b], d = [h, n, n, c, l, l][b], g = [l, l, h, n, n, c][b];
1462
1446
  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) => {
1447
+ }, ne = (o, t, e, s) => {
1471
1448
  const r = [
1472
- z(v(o).toString(16)),
1473
- z(v(t).toString(16)),
1474
- z(v(e).toString(16)),
1475
- z(Ce(s))
1449
+ G(v(o).toString(16)),
1450
+ G(v(t).toString(16)),
1451
+ G(v(e).toString(16))
1476
1452
  ];
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("");
1453
+ return s && 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[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) : r.join("");
1454
+ }, At = (o, t, e, s, r) => {
1455
+ const n = [
1456
+ G(v(o).toString(16)),
1457
+ G(v(t).toString(16)),
1458
+ G(v(e).toString(16)),
1459
+ G(Ce(s))
1460
+ ];
1461
+ return r && 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[3].charAt(0) === n[3].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) + n[3].charAt(0) : n.join("");
1478
1462
  }, Ae = (o) => {
1479
1463
  const t = String(o).trim().toLowerCase();
1480
- if (Pe(t))
1481
- return Object.assign(Se(t), {
1464
+ if (Se(t))
1465
+ return Object.assign(Pe(t), {
1482
1466
  a: 1,
1483
1467
  format: "rgb",
1484
1468
  ok: !0
@@ -1492,60 +1476,60 @@ fe(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
1492
1476
  format: "rgb",
1493
1477
  ok: !0
1494
1478
  };
1495
- let [, e, s, n, r] = I.rgb.exec(t) || [];
1496
- return e && s && n ? {
1479
+ let [, e, s, r, n] = I.rgb.exec(t) || [];
1480
+ return e && s && r ? {
1497
1481
  r: e,
1498
1482
  g: s,
1499
- b: n,
1500
- a: r !== void 0 ? r : 1,
1483
+ b: r,
1484
+ a: n !== void 0 ? n : 1,
1501
1485
  format: "rgb",
1502
1486
  ok: !0
1503
- } : ([, e, s, n, r] = I.hsl.exec(t) || [], e && s && n ? {
1487
+ } : ([, e, s, r, n] = I.hsl.exec(t) || [], e && s && r ? {
1504
1488
  h: e,
1505
1489
  s,
1506
- l: n,
1507
- a: r !== void 0 ? r : 1,
1490
+ l: r,
1491
+ a: n !== void 0 ? n : 1,
1508
1492
  format: "hsl",
1509
1493
  ok: !0
1510
- } : ([, e, s, n, r] = I.hsv.exec(t) || [], e && s && n ? {
1494
+ } : ([, e, s, r, n] = I.hsv.exec(t) || [], e && s && r ? {
1511
1495
  h: e,
1512
1496
  s,
1513
- v: n,
1514
- a: r !== void 0 ? r : 1,
1497
+ v: r,
1498
+ a: n !== void 0 ? n : 1,
1515
1499
  format: "hsv",
1516
1500
  ok: !0
1517
- } : ([, e, s, n, r] = I.hwb.exec(t) || [], e && s && n ? {
1501
+ } : ([, e, s, r, n] = I.hwb.exec(t) || [], e && s && r ? {
1518
1502
  h: e,
1519
1503
  w: s,
1520
- b: n,
1521
- a: r !== void 0 ? r : 1,
1504
+ b: r,
1505
+ a: n !== void 0 ? n : 1,
1522
1506
  format: "hwb",
1523
1507
  ok: !0
1524
- } : ([, e, s, n, r] = I.hex8.exec(t) || [], e && s && n && r ? {
1508
+ } : ([, e, s, r, n] = I.hex8.exec(t) || [], e && s && r && n ? {
1525
1509
  r: N(e),
1526
1510
  g: N(s),
1527
- b: N(n),
1528
- a: Ot(r),
1511
+ b: N(r),
1512
+ a: Dt(n),
1529
1513
  format: "hex",
1530
1514
  ok: !0
1531
- } : ([, e, s, n] = I.hex6.exec(t) || [], e && s && n ? {
1515
+ } : ([, e, s, r] = I.hex6.exec(t) || [], e && s && r ? {
1532
1516
  r: N(e),
1533
1517
  g: N(s),
1534
- b: N(n),
1518
+ b: N(r),
1535
1519
  a: 1,
1536
1520
  format: "hex",
1537
1521
  ok: !0
1538
- } : ([, e, s, n, r] = I.hex4.exec(t) || [], e && s && n && r ? {
1522
+ } : ([, e, s, r, n] = I.hex4.exec(t) || [], e && s && r && n ? {
1539
1523
  r: N(e + e),
1540
1524
  g: N(s + s),
1541
- b: N(n + n),
1542
- a: Ot(r + r),
1525
+ b: N(r + r),
1526
+ a: Dt(n + n),
1543
1527
  format: "hex",
1544
1528
  ok: !0
1545
- } : ([, e, s, n] = I.hex3.exec(t) || [], e && s && n ? {
1529
+ } : ([, e, s, r] = I.hex3.exec(t) || [], e && s && r ? {
1546
1530
  r: N(e + e),
1547
1531
  g: N(s + s),
1548
- b: N(n + n),
1532
+ b: N(r + r),
1549
1533
  a: 1,
1550
1534
  format: "hex",
1551
1535
  ok: !0
@@ -1557,17 +1541,17 @@ fe(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
1557
1541
  format: "rgb",
1558
1542
  ok: !o
1559
1543
  })))))));
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), {
1544
+ }, ie = (o) => {
1545
+ let t = { r: 0, g: 0, b: 0 }, e = o, s = 1, r, n, i, a, l, c, h, b, u = "rgb", d = !1;
1546
+ return (!e || typeof e == "string") && (e = Ae(e), d = e.ok), nt(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"), nt(e, { h: 0, s: 0, v: 0 }) && H(e.h) && H(e.s) && H(e.v) && ({ h: c, s: r, v: n } = e, c = R(c, 360), r = R(r, 100), n = R(n, 100), t = Ft(c, r, n), u = "hsv"), nt(e, { h: 0, s: 0, l: 0 }) && H(e.h) && H(e.s) && H(e.l) && ({ h: c, s: r, l: i } = e, c = R(c, 360), r = R(r, 100), i = R(i, 100), t = lt(c, r, i), u = "hsl"), nt(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
1547
  r: t.r,
1564
1548
  g: t.g,
1565
1549
  b: t.b,
1566
- a: Dt(s),
1550
+ a: Ot(s),
1567
1551
  format: u,
1568
1552
  ok: d
1569
1553
  };
1570
- }, go = "1.0.6";
1554
+ }, lo = "1.0.8";
1571
1555
  class y {
1572
1556
  // bring main utilities to front
1573
1557
  static matchers = I;
@@ -1575,19 +1559,19 @@ class y {
1575
1559
  static isPercentage = $t;
1576
1560
  static isValidCSSUnit = H;
1577
1561
  static isNonColor = ke;
1578
- static isColorName = Pe;
1579
- static isColorType = it;
1580
- static pad2 = z;
1562
+ static isColorName = Se;
1563
+ static isColorType = nt;
1564
+ static pad2 = G;
1581
1565
  static clamp01 = ut;
1582
1566
  static bound01 = R;
1583
- static boundAlpha = Dt;
1584
- static getRGBFromName = Se;
1585
- static convertHexToDecimal = Ot;
1567
+ static boundAlpha = Ot;
1568
+ static getRGBFromName = Pe;
1569
+ static convertHexToDecimal = Dt;
1586
1570
  static convertDecimalToHex = Ce;
1587
- static rgbToHsl = te;
1588
- static rgbToHex = se;
1589
- static rgbToHsv = oe;
1590
- static rgbToHwb = ee;
1571
+ static rgbToHsl = oe;
1572
+ static rgbToHex = ne;
1573
+ static rgbToHsv = re;
1574
+ static rgbToHwb = se;
1591
1575
  static rgbaToHex = At;
1592
1576
  static hslToRgb = Ft;
1593
1577
  static hsvToRgb = Ft;
@@ -1595,11 +1579,11 @@ class y {
1595
1579
  static hwbToRgb = Le;
1596
1580
  static parseIntFromHex = N;
1597
1581
  static stringInputToObject = Ae;
1598
- static inputToRGB = ne;
1582
+ static inputToRGB = ie;
1599
1583
  static roundPart = v;
1600
1584
  static webColors = wt;
1601
- static nonColors = qt;
1602
- static version = go;
1585
+ static nonColors = Gt;
1586
+ static version = lo;
1603
1587
  // main public properties
1604
1588
  r;
1605
1589
  g;
@@ -1610,8 +1594,8 @@ class y {
1610
1594
  originalInput;
1611
1595
  // main public methods
1612
1596
  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;
1597
+ const s = e && xe.includes(e) ? e : "", { r, g: n, b: i, a, ok: l, format: c } = ie(t);
1598
+ this.originalInput = t, this.r = r, this.g = n, this.b = i, this.a = a, this.ok = l, this.format = s || c;
1615
1599
  }
1616
1600
  /**
1617
1601
  * Checks if the current input value is a valid colour.
@@ -1632,8 +1616,8 @@ class y {
1632
1616
  */
1633
1617
  get luminance() {
1634
1618
  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;
1619
+ let r = 0, n = 0, i = 0;
1620
+ return t <= 0.03928 ? r = t / 12.92 : r = ((t + 0.055) / 1.055) ** 2.4, e <= 0.03928 ? n = e / 12.92 : n = ((e + 0.055) / 1.055) ** 2.4, s <= 0.03928 ? i = s / 12.92 : i = ((s + 0.055) / 1.055) ** 2.4, 0.2126 * r + 0.7152 * n + 0.0722 * i;
1637
1621
  }
1638
1622
  /**
1639
1623
  * Returns the perceived brightness of the colour.
@@ -1646,25 +1630,25 @@ class y {
1646
1630
  * Returns the web colour name closest to the current colour.
1647
1631
  */
1648
1632
  get name() {
1649
- const { r: t, g: e, b: s } = this.toRgb(), [n] = wt.map(([r, i]) => {
1633
+ const { r: t, g: e, b: s } = this.toRgb(), [r] = wt.map(([n, i]) => {
1650
1634
  const a = (
1651
1635
  // ((rgb.r - r) ** 2 + (rgb.g - g) ** 2 + (rgb.b - b) ** 2) ** 0.5; // standard
1652
1636
  (((i.r - t) * 0.3) ** 2 + ((i.g - e) * 0.6) ** 2 + ((i.b - s) * 0.1) ** 2) ** 0.5
1653
1637
  );
1654
- return [r, a];
1655
- }).find(([, r], i, a) => r === Math.min(...a.map(([, l]) => l)));
1656
- return n;
1638
+ return [n, a];
1639
+ }).find(([, n], i, a) => n === Math.min(...a.map(([, l]) => l)));
1640
+ return r;
1657
1641
  }
1658
1642
  /**
1659
1643
  * Returns the colour as an RGBA object.
1660
1644
  */
1661
1645
  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, {
1646
+ let { r: t, g: e, b: s, a: r } = this;
1647
+ return [t, e, s] = [t, e, s].map((n) => v(n * 255 * 100) / 100), r = v(r * 100) / 100, {
1664
1648
  r: t,
1665
1649
  g: e,
1666
1650
  b: s,
1667
- a: n
1651
+ a: r
1668
1652
  };
1669
1653
  }
1670
1654
  /**
@@ -1673,8 +1657,8 @@ class y {
1673
1657
  * * rgba(255,255,255,0.5)
1674
1658
  */
1675
1659
  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})`;
1660
+ const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(v);
1661
+ return r === 1 ? `rgb(${n}, ${i}, ${a})` : `rgba(${n}, ${i}, ${a}, ${r})`;
1678
1662
  }
1679
1663
  /**
1680
1664
  * Returns the RGBA values concatenated into a CSS4 Module string format.
@@ -1682,16 +1666,16 @@ class y {
1682
1666
  * * rgb(255 255 255 / 50%)
1683
1667
  */
1684
1668
  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})`;
1669
+ const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(v), l = r === 1 ? "" : ` / ${v(r * 100)}%`;
1670
+ return `rgb(${n} ${i} ${a}${l})`;
1687
1671
  }
1688
1672
  /**
1689
1673
  * Returns the hexadecimal value of the colour. When the parameter is *true*
1690
1674
  * it will find a 3 characters shorthand of the decimal value.
1691
1675
  */
1692
1676
  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);
1677
+ const { r: e, g: s, b: r, a: n } = this.toRgb();
1678
+ return n === 1 ? ne(e, s, r, t) : At(e, s, r, n, t);
1695
1679
  }
1696
1680
  /**
1697
1681
  * Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
@@ -1704,8 +1688,8 @@ class y {
1704
1688
  * Returns the HEX8 value of the colour.
1705
1689
  */
1706
1690
  toHex8(t) {
1707
- const { r: e, g: s, b: n, a: r } = this.toRgb();
1708
- return At(e, s, n, r, t);
1691
+ const { r: e, g: s, b: r, a: n } = this.toRgb();
1692
+ return At(e, s, r, n, t);
1709
1693
  }
1710
1694
  /**
1711
1695
  * Returns the HEX8 value of the colour.
@@ -1717,24 +1701,24 @@ class y {
1717
1701
  * Returns the colour as a HSVA object.
1718
1702
  */
1719
1703
  toHsv() {
1720
- const { r: t, g: e, b: s, a: n } = this, { h: r, s: i, v: a } = oe(t, e, s);
1704
+ const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } = re(t, e, s);
1721
1705
  return {
1722
- h: r,
1706
+ h: n,
1723
1707
  s: i,
1724
1708
  v: a,
1725
- a: n
1709
+ a: r
1726
1710
  };
1727
1711
  }
1728
1712
  /**
1729
1713
  * Returns the colour as an HSLA object.
1730
1714
  */
1731
1715
  toHsl() {
1732
- const { r: t, g: e, b: s, a: n } = this, { h: r, s: i, l: a } = te(t, e, s);
1716
+ const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } = oe(t, e, s);
1733
1717
  return {
1734
- h: r,
1718
+ h: n,
1735
1719
  s: i,
1736
1720
  l: a,
1737
- a: n
1721
+ a: r
1738
1722
  };
1739
1723
  }
1740
1724
  /**
@@ -1743,8 +1727,8 @@ class y {
1743
1727
  * * `hsla(150, 100%, 50%, 0.5)`
1744
1728
  */
1745
1729
  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})`;
1730
+ let { h: t, s: e, l: s, a: r } = this.toHsl();
1731
+ return t = v(t * 360), e = v(e * 100), s = v(s * 100), r = v(r * 100) / 100, r === 1 ? `hsl(${t}, ${e}%, ${s}%)` : `hsla(${t}, ${e}%, ${s}%, ${r})`;
1748
1732
  }
1749
1733
  /**
1750
1734
  * Returns the HSLA values concatenated into a CSS4 Module format string.
@@ -1752,37 +1736,37 @@ class y {
1752
1736
  * * `hsl(150deg 100% 50% / 50%)`
1753
1737
  */
1754
1738
  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})`;
1739
+ let { h: t, s: e, l: s, a: r } = this.toHsl();
1740
+ t = v(t * 360), e = v(e * 100), s = v(s * 100), r = v(r * 100);
1741
+ const n = r < 100 ? ` / ${v(r)}%` : "";
1742
+ return `hsl(${t}deg ${e}% ${s}%${n})`;
1759
1743
  }
1760
1744
  /**
1761
1745
  * Returns the colour as an HWBA object.
1762
1746
  */
1763
1747
  toHwb() {
1764
- const { r: t, g: e, b: s, a: n } = this, { h: r, w: i, b: a } = ee(t, e, s);
1748
+ const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } = se(t, e, s);
1765
1749
  return {
1766
- h: r,
1750
+ h: n,
1767
1751
  w: i,
1768
1752
  b: a,
1769
- a: n
1753
+ a: r
1770
1754
  };
1771
1755
  }
1772
1756
  /**
1773
1757
  * Returns the HWBA values concatenated into a string.
1774
1758
  */
1775
1759
  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})`;
1760
+ let { h: t, w: e, b: s, a: r } = this.toHwb();
1761
+ t = v(t * 360), e = v(e * 100), s = v(s * 100), r = v(r * 100);
1762
+ const n = r < 100 ? ` / ${v(r)}%` : "";
1763
+ return `hwb(${t}deg ${e}% ${s}%${n})`;
1780
1764
  }
1781
1765
  /**
1782
1766
  * Sets the alpha value of the current colour.
1783
1767
  */
1784
1768
  setAlpha(t) {
1785
- return typeof t != "number" ? this : (this.a = Dt(t), this);
1769
+ return typeof t != "number" ? this : (this.a = Ot(t), this);
1786
1770
  }
1787
1771
  /**
1788
1772
  * Saturate the colour with a given amount.
@@ -1790,8 +1774,8 @@ class y {
1790
1774
  saturate(t) {
1791
1775
  if (typeof t != "number")
1792
1776
  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;
1777
+ const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(e, ut(s + t / 100), r);
1778
+ return Object.assign(this, { r: n, g: i, b: a }), this;
1795
1779
  }
1796
1780
  /**
1797
1781
  * Desaturate the colour with a given amount.
@@ -1812,8 +1796,8 @@ class y {
1812
1796
  lighten(t) {
1813
1797
  if (typeof t != "number")
1814
1798
  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;
1799
+ const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(e, s, ut(r + t / 100));
1800
+ return Object.assign(this, { r: n, g: i, b: a }), this;
1817
1801
  }
1818
1802
  /**
1819
1803
  * Decrease the colour lightness with a given amount.
@@ -1828,8 +1812,8 @@ class y {
1828
1812
  spin(t) {
1829
1813
  if (typeof t != "number")
1830
1814
  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;
1815
+ const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(ut((e * 360 + t) % 360 / 360), s, r);
1816
+ return Object.assign(this, { r: n, g: i, b: a }), this;
1833
1817
  }
1834
1818
  /** Returns a clone of the current `Color` instance. */
1835
1819
  clone() {
@@ -1858,36 +1842,36 @@ class It {
1858
1842
  * * `args.saturation` Saturation [0, 100]
1859
1843
  */
1860
1844
  constructor(...t) {
1861
- let e = 0, s = 12, n = 10, r = [0.5], i = 100;
1845
+ let e = 0, s = 12, r = 10, n = [0.5], i = 100;
1862
1846
  if (t.length === 4)
1863
- [e, s, n, i] = t;
1847
+ [e, s, r, i] = t;
1864
1848
  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)))
1849
+ [e, s, r] = t;
1850
+ else if (t.length === 2 && ([s, r] = t, [s, r].some((g) => g < 1)))
1867
1851
  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 = [
1852
+ const a = [], l = 360 / s, c = y.roundPart((r - (r % 2 ? 1 : 0)) / 2), h = [0.25, 0.2, 0.15, 0.11, 0.09, 0.075], b = [
1869
1853
  [1, 2, 3],
1870
1854
  [4, 5],
1871
1855
  [6, 7],
1872
1856
  [8, 9],
1873
1857
  [10, 11],
1874
1858
  [12, 13]
1875
- ], u = b.find((g) => g.includes(n)), d = u ? h[b.indexOf(u)] : 100 / (n + (n % 2 ? 0 : 1)) / 100;
1859
+ ], u = b.find((g) => g.includes(r)), d = u ? h[b.indexOf(u)] : 100 / (r + (r % 2 ? 0 : 1)) / 100;
1876
1860
  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];
1861
+ n = [...n, 0.5 + d * g];
1862
+ for (let g = 1; g < r - c; g += 1)
1863
+ n = [0.5 - d * g, ...n];
1880
1864
  for (let g = 0; g < s; g += 1) {
1881
1865
  const p = (e + g * l) % 360 / 360;
1882
- r.forEach((f) => {
1866
+ n.forEach((f) => {
1883
1867
  const w = new y({ h: p, s: 1, l: f });
1884
1868
  a.push(i < 100 ? w.saturate(i - 100) : w);
1885
1869
  });
1886
1870
  }
1887
- this.hue = e, this.hueSteps = s, this.lightSteps = n, this.saturation = i, this.colors = a;
1871
+ this.hue = e, this.hueSteps = s, this.lightSteps = r, this.saturation = i, this.colors = a;
1888
1872
  }
1889
1873
  }
1890
- const He = {
1874
+ const Kt = {
1891
1875
  pickerLabel: "Colour Picker",
1892
1876
  appearanceLabel: "Colour Appearance",
1893
1877
  valueLabel: "Colour Value",
@@ -1905,7 +1889,7 @@ const He = {
1905
1889
  redLabel: "Red",
1906
1890
  greenLabel: "Green",
1907
1891
  blueLabel: "Blue"
1908
- }, Kt = [
1892
+ }, it = [
1909
1893
  "white",
1910
1894
  "black",
1911
1895
  "grey",
@@ -1923,8 +1907,8 @@ const He = {
1923
1907
  "violet",
1924
1908
  "magenta",
1925
1909
  "pink"
1926
- ], re = (o) => {
1927
- if (!V(o))
1910
+ ], ae = (o) => {
1911
+ if (!B(o))
1928
1912
  return !1;
1929
1913
  try {
1930
1914
  JSON.parse(o);
@@ -1932,13 +1916,13 @@ const He = {
1932
1916
  return !1;
1933
1917
  }
1934
1918
  return !0;
1935
- }, Vt = "v-hidden", uo = (o) => {
1936
- const { format: t, id: e, componentLabels: s } = o, n = x({
1919
+ }, Vt = "v-hidden", co = (o) => {
1920
+ const { format: t, id: e, componentLabels: s } = o, r = x({
1937
1921
  tagName: "div",
1938
1922
  className: `color-form ${t}`
1939
1923
  });
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) => {
1924
+ let n = ["hex"];
1925
+ return t === "rgb" ? n = ["red", "green", "blue", "alpha"] : t === "hsl" ? n = ["hue", "saturation", "lightness", "alpha"] : t === "hwb" && (n = ["hue", "whiteness", "blackness", "alpha"]), n.forEach((i) => {
1942
1926
  const [a] = t === "hex" ? ["#"] : pe(i).split(""), l = `color_${t}_${i}_${e}`, c = s[`${i}Label`], h = x({ tagName: "label" });
1943
1927
  m(h, "for", l), h.append(
1944
1928
  x({
@@ -1963,15 +1947,15 @@ const He = {
1963
1947
  spellcheck: !1
1964
1948
  });
1965
1949
  let u = "100", d = "1";
1966
- i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")), B(b, {
1950
+ i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")), K(b, {
1967
1951
  min: "0",
1968
1952
  max: u,
1969
1953
  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}`;
1954
+ }), r.append(h, b);
1955
+ }), r;
1956
+ }, ho = (o) => {
1957
+ const { format: t, componentLabels: e } = o, { hueLabel: s, alphaLabel: r, lightnessLabel: n, saturationLabel: i, whitenessLabel: a, blacknessLabel: l } = e, c = t === "hsl" ? 360 : 100, h = t === "hsl" ? 100 : 360, b = 100;
1958
+ let u = t === "hsl" ? `${s} & ${n}` : `${n} & ${i}`;
1975
1959
  u = t === "hwb" ? `${a} & ${l}` : u;
1976
1960
  const d = t === "hsl" ? `${i}` : `${s}`, g = x({
1977
1961
  tagName: "div",
@@ -1995,12 +1979,12 @@ const He = {
1995
1979
  {
1996
1980
  i: 3,
1997
1981
  c: f,
1998
- l: n,
1982
+ l: r,
1999
1983
  min: 0,
2000
1984
  max: b
2001
1985
  }
2002
1986
  ].forEach(($) => {
2003
- const { i: P, c: L, l: S, min: C, max: M } = $, E = x({
1987
+ const { i: S, c: L, l: P, min: C, max: M } = $, E = x({
2004
1988
  tagName: "div",
2005
1989
  className: "color-control",
2006
1990
  role: "presentation"
@@ -2008,14 +1992,14 @@ const He = {
2008
1992
  E.append(
2009
1993
  x({
2010
1994
  tagName: "div",
2011
- className: `visual-control visual-control${P}`
1995
+ className: `visual-control visual-control${S}`
2012
1996
  })
2013
1997
  );
2014
1998
  const A = x({
2015
1999
  tagName: "div",
2016
2000
  className: `${L} knob`,
2017
2001
  ariaLive: "polite",
2018
- ariaLabel: S,
2002
+ ariaLabel: P,
2019
2003
  role: "slider",
2020
2004
  tabIndex: 0,
2021
2005
  ariaValueMin: `${C}`,
@@ -2023,47 +2007,48 @@ const He = {
2023
2007
  });
2024
2008
  E.append(A), g.append(E);
2025
2009
  }), 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;
2010
+ }, le = (o, t, e) => {
2011
+ const { input: s, format: r, componentLabels: n } = o, { defaultsLabel: i, presetsLabel: a } = n, 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
2012
  let f = 2;
2029
2013
  f = p && u > g * 2 ? 3 : f, f = p && u > g * 3 ? 4 : f, f = p && u > g * 4 ? 5 : f;
2030
2014
  const w = f - (u <= g * 3 ? 1 : 2), $ = p && u > w * g;
2031
- let P = e;
2032
- P += $ ? " scrollable" : "", P += p ? " multiline" : "";
2015
+ let S = e;
2016
+ S += $ ? " scrollable" : "", S += p ? " multiline" : "";
2033
2017
  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({
2018
+ let P = p ? 1.75 : 2;
2019
+ P = g > 5 && p ? 1.5 : P;
2020
+ const C = `${w * P}rem`, M = `calc(${f} * ${P}rem + ${f - 1} * ${L})`, E = x({
2037
2021
  tagName: "ul",
2038
- className: P,
2022
+ className: S,
2039
2023
  role: "listbox",
2040
2024
  ariaLabel: h
2041
2025
  });
2042
- return $ && O(E, {
2043
- "--grid-item-size": `${S}rem`,
2026
+ return $ && D(E, {
2027
+ "--grid-item-size": `${P}rem`,
2044
2028
  "--grid-fit": `${g}`,
2045
2029
  "--grid-gap": L,
2046
2030
  "--grid-height": C,
2047
2031
  "--grid-hover-height": M
2048
2032
  }), 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({
2033
+ let [F, Q] = typeof A == "string" ? A.trim().split(":") : [];
2034
+ A instanceof y && (F = A.toHexString(), Q = F);
2035
+ const Ut = new y(A instanceof y ? A : F, r).toString() === yt(s, "value"), xt = x({
2052
2036
  tagName: "li",
2053
- className: `color-option${zt ? " active" : ""}`,
2054
- innerText: `${tt || F}`,
2037
+ className: `color-option${Ut ? " active" : ""}`,
2038
+ innerText: `${Q || F}`,
2055
2039
  tabIndex: 0,
2056
2040
  role: "option",
2057
- ariaSelected: zt ? "true" : "false"
2041
+ ariaSelected: Ut ? "true" : "false"
2058
2042
  });
2059
- m(xt, "data-value", `${F}`), l && O(xt, { backgroundColor: F }), E.append(xt);
2043
+ m(xt, "data-value", `${F}`), l && D(xt, { backgroundColor: F }), E.append(xt);
2060
2044
  }), 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;
2045
+ }, go = (o) => {
2046
+ const { input: t, parent: e, format: s, id: r, componentLabels: n, colorKeywords: i, colorPresets: a } = o, l = yt(t, "value") || "#fff", { nonColors: c } = y, { toggleLabel: h, pickerLabel: b, formatLabel: u, hexLabel: d } = n, g = c.includes(l) ? "#fff" : l;
2063
2047
  o.color = new y(g, s);
2064
2048
  const p = s === "hex" ? d : pe(s), f = x({
2065
- id: `picker-btn-${n}`,
2049
+ id: `picker-btn-${r}`,
2066
2050
  tagName: "button",
2051
+ type: "button",
2067
2052
  className: "picker-toggle btn-appearance",
2068
2053
  ariaExpanded: "false",
2069
2054
  ariaHasPopup: "true"
@@ -2079,16 +2064,17 @@ const He = {
2079
2064
  tagName: "div",
2080
2065
  className: "color-dropdown picker",
2081
2066
  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) {
2067
+ ariaLabelledBy: `picker-btn-${r}`
2068
+ }), $ = ho(o), S = co(o);
2069
+ if (w.append($, S), t.before(f), e.append(w), i || a) {
2085
2070
  const L = x({
2086
2071
  tagName: "div",
2087
2072
  className: "color-dropdown scrollable menu"
2088
2073
  });
2089
- a && L.append(ie(o, a, "color-options")), i && i.length && L.append(ie(o, i, "color-defaults"));
2090
- const S = x({
2074
+ a && L.append(le(o, a, "color-options")), i && i.length && L.append(le(o, i, "color-defaults"));
2075
+ const P = x({
2091
2076
  tagName: "button",
2077
+ type: "button",
2092
2078
  className: "menu-toggle btn-appearance",
2093
2079
  tabIndex: -1,
2094
2080
  ariaExpanded: "false",
@@ -2096,53 +2082,55 @@ const He = {
2096
2082
  }), C = encodeURI("http://www.w3.org/2000/svg"), M = Mt(C, {
2097
2083
  tagName: "svg"
2098
2084
  });
2099
- m(M, "xmlns", C), m(M, "viewBox", "0 0 512 512"), m(M, Me, "true");
2085
+ m(M, "xmlns", C), m(M, "viewBox", "0 0 512 512"), m(M, Ee, "true");
2100
2086
  const E = Mt(C, {
2101
2087
  tagName: "path"
2102
2088
  });
2103
- m(E, "d", "M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"), m(E, "fill", "#fff"), M.append(E), S.append(
2089
+ m(E, "d", "M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"), m(E, "fill", "#fff"), M.append(E), P.append(
2104
2090
  x({
2105
2091
  tagName: "span",
2106
2092
  className: Vt,
2107
2093
  innerText: `${h}`
2108
2094
  }),
2109
2095
  M
2110
- ), e.append(S, L);
2096
+ ), e.append(P, L);
2111
2097
  }
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,
2098
+ i && c.includes(l) && (o.value = l), m(t, X, "-1");
2099
+ }, uo = "2.0.0-alpha10", Z = "color-picker", bo = `[data-function="${Z}"]`, ce = `.${Z}`, po = {
2100
+ componentLabels: Kt,
2101
+ colorLabels: it,
2116
2102
  format: "rgb",
2117
2103
  colorPresets: !1,
2118
2104
  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));
2105
+ }, { roundPart: k, nonColors: bt } = y, fo = (o) => Xe(o, Z), mo = (o) => new vo(o), he = (o, t) => {
2106
+ const e = t ? Bt : jt, { input: s, pickerToggle: r, menuToggle: n } = o;
2107
+ e(s, Re, o.showPicker), e(r, Et, o.togglePicker), n && e(n, Et, o.toggleMenu);
2108
+ }, He = (o, t) => {
2109
+ const e = t ? Bt : jt, { input: s, colorMenu: r, parent: n } = o, i = V(s), a = ro(i);
2110
+ e(o.controls, Fe, o.pointerDown), o.controlKnobs.forEach((l) => e(l, zt, o.handleKnobs)), e(a, Ve, o.handleScroll), e(a, Ke, o.update), [s, ...o.inputs].forEach((l) => e(l, Me, o.changeHandler)), r && (e(r, Et, o.menuClickHandler), e(r, zt, o.menuKeyHandler)), e(i, ue, o.pointerMove), e(i, Ie, o.pointerUp), e(n, Oe, o.handleFocusOut), e(i, De, o.handleDismiss);
2111
+ }, ge = (o) => {
2112
+ Ye(o.input, new CustomEvent("colorpicker.change"));
2113
+ }, Ne = (o) => {
2114
+ o && ["bottom", "top"].forEach((t) => O(o, t));
2129
2115
  }, 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");
2116
+ const { colorPicker: e, colorMenu: s, menuToggle: r, pickerToggle: n, parent: i } = o, a = t === e, l = a ? s : e, c = a ? r : n, h = a ? n : r;
2117
+ T(i, "open") || q(i, "open"), l && (O(l, "show"), Ne(l)), q(t, "bottom"), oo(t), q(t, "show"), a && o.update(), o.isOpen || (He(o, !0), o.updateDropdownPosition(), o.isOpen = !0, m(o.input, X, "0"), r && m(r, X, "0")), m(h, Nt, "true"), c && m(c, Nt, "false");
2132
2118
  };
2133
- class ko {
2119
+ class vo {
2134
2120
  // bring utils to staic
2135
2121
  static Color = y;
2136
2122
  static ColorPalette = It;
2137
- static getInstance = wo;
2138
- static init = $o;
2139
- static selector = mo;
2123
+ static getInstance = fo;
2124
+ static init = mo;
2125
+ static selector = bo;
2140
2126
  // utils important for render
2141
2127
  static roundPart = k;
2142
- static setElementStyle = O;
2128
+ static setElementStyle = D;
2143
2129
  static setAttribute = m;
2144
2130
  static getBoundingClientRect = gt;
2145
- static version = fo;
2131
+ static version = uo;
2132
+ static colorNames = it;
2133
+ static colorPickerLabels = Kt;
2146
2134
  id;
2147
2135
  input;
2148
2136
  color;
@@ -2151,7 +2139,7 @@ class ko {
2151
2139
  dragElement;
2152
2140
  isOpen = !1;
2153
2141
  controlPositions;
2154
- colorLabels = {};
2142
+ colorLabels = Yt(it.map((t) => [t, t]));
2155
2143
  colorKeywords;
2156
2144
  colorPresets;
2157
2145
  componentLabels;
@@ -2171,43 +2159,41 @@ class ko {
2171
2159
  * @param config instance options
2172
2160
  */
2173
2161
  constructor(t, e) {
2174
- const s = _(t);
2162
+ const s = z(t);
2175
2163
  if (typeof t > "u")
2176
2164
  throw new TypeError("ColorPicker target not specified.");
2177
- if (V(t) && !s)
2165
+ if (B(t) && !s)
2178
2166
  throw new TypeError(`ColorPicker target "${t}" cannot be found.`);
2179
2167
  this.input = s;
2180
- const n = fe(s, ae);
2181
- if (!n)
2168
+ const r = fe(s, ce);
2169
+ if (!r)
2182
2170
  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 = {
2171
+ this.parent = r, this.id = de(s, Z), this.dragElement = void 0, this.isOpen = !1, this.controlPositions = {
2184
2172
  c1x: 0,
2185
2173
  c1y: 0,
2186
2174
  c2y: 0,
2187
2175
  c3y: 0
2188
- }, this.colorLabels = {}, this.colorKeywords = !1, this.colorPresets = !1;
2189
- const { format: r, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } = no(
2176
+ }, this.colorKeywords = !1, this.colorPresets = !1;
2177
+ const { format: n, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } = eo(
2190
2178
  s,
2191
- vo,
2179
+ po,
2192
2180
  e || {}
2193
2181
  );
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)
2182
+ let h = it;
2183
+ Lt(a) && a.length === 17 ? h = a : B(a) && a.split(",").length === 17 && (h = a.split(",")), K(this.colorLabels, Yt(h.map((p, f) => [it[f], p])));
2184
+ const b = B(i) && ae(i) ? JSON.parse(i) : i;
2185
+ if (this.componentLabels = K({ ...Kt }, b), this.color = new y(s.value || "#fff", n), this.format = n, Lt(l) && l.length ? this.colorKeywords = l : B(l) && l.length && (this.colorKeywords = l.split(",").map((p) => p.trim())), Lt(c) && c.length)
2200
2186
  this.colorPresets = c;
2201
- else if (c && re(c)) {
2187
+ else if (c && ae(c)) {
2202
2188
  const { hue: p, hueSteps: f, lightSteps: w, saturation: $ } = JSON.parse(c);
2203
2189
  this.colorPresets = new It(p, f, w, $);
2204
2190
  } 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);
2191
+ B(c) && (this.colorPresets = c.split(",").map((p) => p.trim()));
2192
+ go(this);
2193
+ const [u, d] = st("color-dropdown", r);
2194
+ this.pickerToggle = z(".picker-toggle", r), this.menuToggle = z(".menu-toggle", r), this.colorPicker = u, this.colorMenu = d, this.inputs = [...st("color-input", r)];
2195
+ const [g] = st("color-controls", r);
2196
+ this.controls = g, this.controlKnobs = [...st("knob", g)], this.visuals = [...st("visual-control", g)], this.update(), he(this, !0), ct.set(s, Z, this);
2211
2197
  }
2212
2198
  /** Returns the current colour value */
2213
2199
  get value() {
@@ -2265,7 +2251,7 @@ class ko {
2265
2251
  }
2266
2252
  /** Returns the colour appearance, usually the closest colour name for the current value. */
2267
2253
  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;
2254
+ const { colorLabels: t, hsl: e, hsv: s, format: r } = this, n = k(e.h * 360), i = r === "hsl" ? e.s : s.s, a = k(i * 100), l = k(e.l * 100), c = s.v * 100;
2269
2255
  let h = "black";
2270
2256
  if (l === 100 && a === 0)
2271
2257
  h = t.white;
@@ -2273,20 +2259,20 @@ class ko {
2273
2259
  h = t.black;
2274
2260
  else if (a === 0)
2275
2261
  h = t.grey;
2276
- else if (r < 15 || r >= 345)
2262
+ else if (n < 15 || n >= 345)
2277
2263
  h = t.red;
2278
- else if (r >= 15 && r < 45)
2264
+ else if (n >= 15 && n < 45)
2279
2265
  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;
2266
+ else if (n >= 45 && n < 75) {
2267
+ const b = n > 46 && n < 54 && c < 80 && a > 90, u = n >= 54 && n < 75 && c < 80;
2282
2268
  h = b ? t.gold : t.yellow, h = u ? t.olive : h;
2283
2269
  } 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);
2270
+ n >= 75 && n < 155 ? h = c < 68 ? t.green : t.lime : n >= 155 && n < 175 ? h = t.teal : n >= 175 && n < 195 ? h = t.cyan : n >= 195 && n < 255 ? h = t.blue : n >= 255 && n < 270 ? h = t.violet : n >= 270 && n < 295 ? h = t.magenta : n >= 295 && n < 345 && (h = t.pink);
2285
2271
  return h;
2286
2272
  }
2287
2273
  /** Updates `ColorPicker` visuals. */
2288
2274
  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({
2275
+ const { controlPositions: t, visuals: e } = this, [s, r, n] = 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
2276
  h: a,
2291
2277
  s: 1,
2292
2278
  l: 0.5,
@@ -2296,11 +2282,11 @@ class ko {
2296
2282
  rgb(0,255,0) 33.33%, rgb(0,255,255) 50%,
2297
2283
  rgb(0,0,255) 66.67%, rgb(255,0,255) 83.33%,
2298
2284
  rgb(255,0,0) 100%)`;
2299
- O(s, {
2285
+ D(s, {
2300
2286
  background: `linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,${d}) 100%),
2301
2287
  linear-gradient(to right, rgba(255,255,255,${d}) 0%, ${g} 100%),
2302
2288
  ${b}`
2303
- }), O(n, { background: p }), O(r, {
2289
+ }), D(r, { background: p }), D(n, {
2304
2290
  background: `linear-gradient(rgba(${l},${c},${h},1) 0%,rgba(${l},${c},${h},0) 100%)`
2305
2291
  });
2306
2292
  }
@@ -2310,120 +2296,121 @@ class ko {
2310
2296
  * @param e
2311
2297
  * @this {ColorPicker}
2312
2298
  */
2313
- handleFocusOut({ relatedTarget: t }) {
2299
+ handleFocusOut = ({ relatedTarget: t }) => {
2314
2300
  t && !this.parent.contains(t) && this.hide(!0);
2315
- }
2301
+ };
2316
2302
  /**
2317
2303
  * The `ColorPicker` *keyup* event listener when open.
2318
2304
  *
2319
2305
  * @param e
2320
2306
  * @this {ColorPicker}
2321
2307
  */
2322
- handleDismiss({ code: t }) {
2323
- this.isOpen && t === ze && this.hide();
2324
- }
2308
+ handleDismiss = ({ code: t }) => {
2309
+ this.isOpen && t === qe && this.hide();
2310
+ };
2325
2311
  /**
2326
2312
  * The `ColorPicker` *scroll* event listener when open.
2327
2313
  *
2328
2314
  * @param e
2329
- * @this {ColorPicker}
2330
2315
  */
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
- }
2316
+ handleScroll = (t) => {
2317
+ const { activeElement: e } = V(this.input);
2318
+ this.updateDropdownPosition(), ([ue, Be].includes(t.type) && this.dragElement || e && this.controlKnobs.includes(e)) && (t.stopPropagation(), t.preventDefault());
2319
+ };
2335
2320
  /**
2336
2321
  * The `ColorPicker` keyboard event listener for menu navigation.
2337
2322
  *
2338
2323
  * @param e
2339
2324
  */
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
- }
2325
+ menuKeyHandler = (t) => {
2326
+ const { target: e, code: s } = t, { previousElementSibling: r, nextElementSibling: n, 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];
2327
+ [j, ot, Wt].includes(s) && t.preventDefault(), a ? b && s === ot ? _(b) : u && s === j ? _(u) : r && s === ht ? _(r) : n && s === U && _(n) : r && [ht, ot].includes(s) ? _(r) : n && [U, j].includes(s) && _(n), [je, Wt].includes(s) && this.menuClickHandler(t);
2328
+ };
2344
2329
  /**
2345
2330
  * The `ColorPicker` click event listener for the colour menu presets / defaults.
2346
2331
  *
2347
2332
  * @param e
2348
2333
  * @this {ColorPicker}
2349
2334
  */
2350
- menuClickHandler(t) {
2351
- const { target: e } = t, { colorMenu: s } = this, n = (yt(e, "data-value") || "").trim();
2352
- if (!n.length)
2335
+ menuClickHandler = (t) => {
2336
+ const { target: e } = t, { colorMenu: s } = this, r = (yt(e, "data-value") || "").trim();
2337
+ if (!r.length)
2353
2338
  return;
2354
- const r = _("li.active", s);
2355
- let i = n;
2339
+ const n = z("li.active", s);
2340
+ let i = r;
2356
2341
  i = bt.includes(i) ? "white" : i, i = i === "transparent" ? "rgba(0,0,0,0)" : i;
2357
2342
  const { r: a, g: l, b: c, a: h } = new y(i);
2358
- B(this.color, {
2343
+ K(this.color, {
2359
2344
  r: a,
2360
2345
  g: l,
2361
2346
  b: c,
2362
2347
  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
- }
2348
+ }), this.update(), n !== e && (n && (O(n, "active"), Pt(n, St)), q(e, "active"), m(e, St, "true"), bt.includes(r) && (this.value = r), ge(this));
2349
+ };
2365
2350
  /**
2366
2351
  * The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
2367
2352
  *
2368
2353
  * @param e
2369
2354
  */
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));
2355
+ pointerDown = (t) => {
2356
+ if (t.button !== 0)
2357
+ return;
2358
+ const { target: e, pageX: s, pageY: r } = t, { colorMenu: n, 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, $ = r - f.scrollTop - p.top;
2359
+ 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($)), n) {
2360
+ const S = z("li.active", n);
2361
+ S && (O(S, "active"), Pt(S, St));
2375
2362
  }
2376
2363
  t.preventDefault();
2377
- }
2364
+ };
2378
2365
  /**
2379
2366
  * The `ColorPicker` *touchend* / *mouseup* events listener for control knobs.
2380
2367
  *
2381
2368
  * @param e
2382
2369
  * @this
2383
2370
  */
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
- }
2371
+ pointerUp = ({ target: t }) => {
2372
+ const { parent: e } = this, s = V(e), r = z(`${ce}.open`, s) !== null, n = s.getSelection();
2373
+ !this.dragElement && (!n || !n.toString().length) && !e.contains(t) && this.hide(r), this.dragElement = void 0;
2374
+ };
2388
2375
  /**
2389
2376
  * The `ColorPicker` *touchmove* / *mousemove* events listener for control knobs.
2390
2377
  *
2391
2378
  * @param {PointerEvent} e
2392
2379
  */
2393
- pointerMove(t) {
2394
- const { dragElement: e, visuals: s } = this, [n, r, i] = s, { pageX: a, pageY: l } = t;
2380
+ pointerMove = (t) => {
2381
+ const { dragElement: e, visuals: s } = this, [r, n, i] = s, { pageX: a, pageY: l } = t;
2395
2382
  if (!e)
2396
2383
  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
- }
2384
+ const c = gt(e), h = Ct(r), b = a - h.scrollLeft - c.left, u = l - h.scrollTop - c.top;
2385
+ e === r && this.changeControl1(b, u), e === n && this.changeControl2(u), e === i && this.changeAlpha(u);
2386
+ };
2400
2387
  /**
2401
2388
  * The `ColorPicker` *keydown* event listener for control knobs.
2402
2389
  *
2403
2390
  * @param e
2404
2391
  */
2405
- handleKnobs(t) {
2392
+ handleKnobs = (t) => {
2406
2393
  const { target: e, code: s } = t;
2407
- if (![st, j, ht, G].includes(s))
2394
+ if (![ot, j, ht, U].includes(s))
2408
2395
  return;
2409
2396
  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;
2397
+ const { controlKnobs: r, visuals: n } = this, { offsetWidth: i, offsetHeight: a } = n[0], [l, c, h] = r, { activeElement: b } = V(l), u = r.find((g) => g === b), d = a / 360;
2411
2398
  if (u) {
2412
2399
  let g = 0, p = 0;
2413
2400
  if (e === l) {
2414
2401
  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);
2402
+ [ht, U].includes(s) ? this.controlPositions.c1x += s === U ? f : -f : [ot, j].includes(s) && (this.controlPositions.c1y += s === j ? d : -d), g = this.controlPositions.c1x, p = this.controlPositions.c1y, this.changeControl1(g, p);
2416
2403
  } 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));
2404
+ e === c ? (this.controlPositions.c2y += [j, U].includes(s) ? d : -d, p = this.controlPositions.c2y, this.changeControl2(p)) : e === h && (this.controlPositions.c3y += [j, U].includes(s) ? d : -d, p = this.controlPositions.c3y, this.changeAlpha(p));
2418
2405
  this.handleScroll(t);
2419
2406
  }
2420
- }
2407
+ };
2421
2408
  /** The event listener of the colour form inputs. */
2422
- changeHandler() {
2409
+ changeHandler = () => {
2423
2410
  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 = {
2411
+ const { inputs: e, format: s, value: r, input: n, controlPositions: i, visuals: a } = this, { activeElement: l } = V(n), { 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(r), w = b ? p : 1 - i.c3y / c;
2412
+ if (l === n || l && e.includes(l)) {
2413
+ l === n ? f ? t = r === "transparent" ? "rgba(0,0,0,0)" : "rgb(0,0,0)" : t = r : s === "hex" ? t = h.value : s === "hsl" ? t = {
2427
2414
  h: u,
2428
2415
  s: d,
2429
2416
  l: g,
@@ -2439,15 +2426,15 @@ class ko {
2439
2426
  b: g,
2440
2427
  a: w
2441
2428
  };
2442
- const { r: $, g: P, b: L, a: S } = new y(t);
2443
- B(this.color, {
2429
+ const { r: $, g: S, b: L, a: P } = new y(t);
2430
+ K(this.color, {
2444
2431
  r: $,
2445
- g: P,
2432
+ g: S,
2446
2433
  b: L,
2447
- a: S
2448
- }), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === r && f && (this.value = n);
2434
+ a: P
2435
+ }), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === n && f && (this.value = r);
2449
2436
  }
2450
- }
2437
+ };
2451
2438
  /**
2452
2439
  * Updates `ColorPicker` first control:
2453
2440
  * * `lightness` and `saturation` for HEX/RGB;
@@ -2457,21 +2444,21 @@ class ko {
2457
2444
  * @param Y the Y component of the offset
2458
2445
  */
2459
2446
  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({
2447
+ let [s, r] = [0, 0];
2448
+ const { controlPositions: n, visuals: i } = this, { offsetHeight: a, offsetWidth: l } = i[0];
2449
+ t > l ? s = l : t >= 0 && (s = t), e > a ? r = a : e >= 0 && (r = e);
2450
+ const c = n.c2y / a, h = s / l, b = 1 - r / a, u = 1 - n.c3y / a, { r: d, g, b: p, a: f } = new y({
2464
2451
  h: c,
2465
2452
  s: h,
2466
2453
  v: b,
2467
2454
  a: u
2468
2455
  });
2469
- B(this.color, {
2456
+ K(this.color, {
2470
2457
  r: d,
2471
2458
  g,
2472
2459
  b: p,
2473
2460
  a: f
2474
- }), this.controlPositions.c1x = s, this.controlPositions.c1y = n, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2461
+ }), this.controlPositions.c1x = s, this.controlPositions.c1y = r, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2475
2462
  }
2476
2463
  /**
2477
2464
  * Updates `ColorPicker` second control:
@@ -2481,16 +2468,16 @@ class ko {
2481
2468
  * @param Y the Y offset
2482
2469
  */
2483
2470
  changeControl2(t) {
2484
- const { controlPositions: e, visuals: s } = this, { offsetHeight: n, offsetWidth: r } = s[0];
2471
+ const { controlPositions: e, visuals: s } = this, { offsetHeight: r, offsetWidth: n } = s[0];
2485
2472
  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({
2473
+ t > r ? i = r : t >= 0 && (i = t);
2474
+ const a = i / r, l = e.c1x / n, c = 1 - e.c1y / r, h = 1 - e.c3y / r, { r: b, g: u, b: d, a: g } = new y({
2488
2475
  h: a,
2489
2476
  s: l,
2490
2477
  v: c,
2491
2478
  a: h
2492
2479
  });
2493
- B(this.color, {
2480
+ K(this.color, {
2494
2481
  r: b,
2495
2482
  g: u,
2496
2483
  b: d,
@@ -2505,56 +2492,56 @@ class ko {
2505
2492
  */
2506
2493
  changeAlpha(t) {
2507
2494
  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();
2495
+ let r = 0;
2496
+ t > s ? r = s : t >= 0 && (r = t);
2497
+ const n = 1 - r / s;
2498
+ this.color.setAlpha(n), this.controlPositions.c3y = r, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2512
2499
  }
2513
2500
  /**
2514
2501
  * Updates `ColorPicker` control positions on:
2515
2502
  * * initialization
2516
2503
  * * window resize
2517
2504
  */
2518
- update() {
2505
+ update = () => {
2519
2506
  this.updateDropdownPosition(), this.updateAppearance(), this.setControlPositions(), this.updateInputs(!0), this.updateControls(), this.updateVisuals();
2520
- }
2507
+ };
2521
2508
  /** Updates the open dropdown position on *scroll* event. */
2522
2509
  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;
2510
+ const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l = Ct(t).clientHeight, h = T(e, "show") ? e : s;
2524
2511
  if (!h)
2525
2512
  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"));
2513
+ const { offsetHeight: b } = h, u = l - i, d = n, g = n + b + a > l, p = n - b < 0;
2514
+ (T(h, "bottom") || !p) && u < d && g ? (O(h, "bottom"), q(h, "top")) : (O(h, "top"), q(h, "bottom"));
2528
2515
  }
2529
2516
  /** Updates control knobs' positions. */
2530
2517
  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;
2518
+ const { visuals: t, color: e, hsv: s } = this, { offsetHeight: r, offsetWidth: n } = t[0], i = e.a, a = s.h, l = s.s, c = s.v;
2519
+ this.controlPositions.c1x = l * n, this.controlPositions.c1y = (1 - c) * r, this.controlPositions.c2y = a * r, this.controlPositions.c3y = (1 - i) * r;
2533
2520
  }
2534
2521
  /** Update the visual appearance label and control knob labels. */
2535
2522
  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;
2523
+ const { componentLabels: t, color: e, parent: s, hsv: r, hex: n, format: i, controlKnobs: a } = this, { appearanceLabel: l, hexLabel: c, valueLabel: h } = t;
2537
2524
  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(" ")}`;
2525
+ const [g, p, f] = a, w = k(r.h * 360), $ = e.a, S = k(r.s * 100), L = k(r.v * 100), P = this.appearance;
2526
+ let C = `${c} ${n.split("").join(" ")}`;
2540
2527
  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}`);
2528
+ const { hwb: A } = this, F = k(A.w * 100), Q = k(A.b * 100);
2529
+ C = `HWB: ${w}°, ${F}%, ${Q}%`, m(g, et, `${F}% & ${Q}%`), m(g, tt, `${F}`), m(p, _t, `${h}: ${C}. ${l}: ${P}.`), m(p, et, `${w}%`), m(p, tt, `${w}`);
2543
2530
  } 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}`);
2531
+ [b, u, d] = [b, u, d].map(k), C = i === "hsl" ? `HSL: ${w}°, ${S}%, ${L}%` : C, C = i === "rgb" ? `RGB: ${b}, ${u}, ${d}` : C, m(g, et, `${L}% & ${S}%`), m(g, tt, `${L}`), m(p, _t, `${h}: ${C}. ${l}: ${P}.`), m(p, et, `${w}°`), m(p, tt, `${w}`);
2545
2532
  const M = k($ * 100);
2546
- m(f, ot, `${M}%`), m(f, et, `${M}`);
2533
+ m(f, et, `${M}%`), m(f, tt, `${M}`);
2547
2534
  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"));
2535
+ D(this.input, { backgroundColor: E }), this.isDark ? (T(s, "txt-light") && O(s, "txt-light"), T(s, "txt-dark") || q(s, "txt-dark")) : (T(s, "txt-dark") && O(s, "txt-dark"), T(s, "txt-light") || q(s, "txt-light"));
2549
2536
  }
2550
2537
  /** Updates the control knobs actual positions. */
2551
2538
  updateControls() {
2552
2539
  const { controlKnobs: t, controlPositions: e } = this;
2553
- let { c1x: s, c1y: n, c2y: r, c3y: i } = e;
2540
+ let { c1x: s, c1y: r, c2y: n, c3y: i } = e;
2554
2541
  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)` });
2542
+ [s, r, n, i] = [s, r, n, i].map(k), D(a, {
2543
+ transform: `translate3d(${s - 4}px,${r - 4}px,0)`
2544
+ }), D(l, { transform: `translate3d(0,${n - 4}px,0)` }), D(c, { transform: `translate3d(0,${i - 4}px,0)` });
2558
2545
  }
2559
2546
  /**
2560
2547
  * Updates all color form inputs.
@@ -2562,8 +2549,8 @@ class ko {
2562
2549
  * @param isPrevented when `true`, the component original event is prevented
2563
2550
  */
2564
2551
  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();
2552
+ const { value: e, format: s, inputs: r, color: n, hsl: i } = this, [a, l, c, h] = r, b = k(n.a * 100), u = k(i.h * 360);
2553
+ let d = n.toString();
2567
2554
  if (s === "hex")
2568
2555
  d = this.color.toHexString(!0), a.value = this.hex;
2569
2556
  else if (s === "hsl") {
@@ -2576,34 +2563,34 @@ class ko {
2576
2563
  let { r: g, g: p, b: f } = this.rgb;
2577
2564
  [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
2565
  }
2579
- this.value = d, !t && d !== e && ce(this);
2566
+ this.value = d, !t && d !== e && ge(this);
2580
2567
  }
2581
2568
  /**
2582
2569
  * Toggle the `ColorPicker` dropdown visibility.
2583
2570
  *
2584
2571
  * @param e
2585
2572
  */
2586
- togglePicker(t) {
2573
+ togglePicker = (t) => {
2587
2574
  t && t.preventDefault();
2588
2575
  const { colorPicker: e } = this;
2589
2576
  this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
2590
- }
2577
+ };
2591
2578
  /** Shows the `ColorPicker` dropdown. */
2592
- showPicker() {
2579
+ showPicker = () => {
2593
2580
  const { colorPicker: t } = this;
2594
2581
  ["top", "bottom"].some((e) => T(t, e)) || Ht(this, t);
2595
- }
2582
+ };
2596
2583
  /**
2597
2584
  * Toggles the visibility of the `ColorPicker` presets menu.
2598
2585
  *
2599
2586
  * @param e
2600
2587
  * @this {ColorPicker}
2601
2588
  */
2602
- toggleMenu(t) {
2589
+ toggleMenu = (t) => {
2603
2590
  t && t.preventDefault();
2604
2591
  const { colorMenu: e } = this;
2605
2592
  this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
2606
- }
2593
+ };
2607
2594
  /**
2608
2595
  * Hides the currently open `ColorPicker` dropdown.
2609
2596
  *
@@ -2611,21 +2598,21 @@ class ko {
2611
2598
  */
2612
2599
  hide(t) {
2613
2600
  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");
2601
+ const { pickerToggle: e, menuToggle: s, colorPicker: r, colorMenu: n, parent: i, input: a } = this, l = T(r, "show"), c = l ? r : n, h = l ? e : s, b = c && Qe(c);
2602
+ this.value = this.color.toString(!0), c && (O(c, "show"), m(h, Nt, "false"), setTimeout(() => {
2603
+ Ne(c), z(".show", i) || (O(i, "open"), He(this), this.isOpen = !1);
2604
+ }, b)), t || _(e), m(a, X, "-1"), h === s && m(s, X, "-1");
2618
2605
  }
2619
2606
  }
2620
2607
  /** Removes `ColorPicker` from target `<input>`. */
2621
2608
  dispose() {
2622
2609
  const { input: t, parent: e } = this;
2623
- this.hide(!0), le(this), [...e.children].forEach((s) => {
2610
+ this.hide(!0), he(this), [...e.children].forEach((s) => {
2624
2611
  s !== t && s.remove();
2625
- }), St(t, Y), O(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => D(e, s)), ct.remove(t, Z);
2612
+ }), Pt(t, X), D(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => O(e, s)), ct.remove(t, Z);
2626
2613
  }
2627
2614
  }
2628
2615
  export {
2629
- ko as default
2616
+ vo as default
2630
2617
  };
2631
2618
  //# sourceMappingURL=color-picker.mjs.map