yk-color-picker 1.0.0-alpha

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.
@@ -0,0 +1,1529 @@
1
+ function w(n) {
2
+ return n.toString(16).padStart(2, "0");
3
+ }
4
+ function c(n, t, e) {
5
+ const o = document.createElement(n);
6
+ if (t != null && o.classList.add(...t), e)
7
+ for (const i in e)
8
+ Object.prototype.hasOwnProperty.call(e, i) && o.setAttribute(i, e[i]);
9
+ return o;
10
+ }
11
+ function l(n, t, e) {
12
+ n.addEventListener(t, e);
13
+ }
14
+ function p(n, t, e) {
15
+ return Math.min(Math.max(Math.round(n), t), e);
16
+ }
17
+ const d = {
18
+ parse: function(n) {
19
+ if (n == null)
20
+ throw new Error("YKColorParser:: color is undefined");
21
+ if (typeof n == "string") {
22
+ if (n = n.trim(), /^(rgba?)/i.test(n))
23
+ return this.compileRGB(n);
24
+ if (/^(#)/i.test(n))
25
+ return this.compileHEX(n);
26
+ let t = this.getNamedColor(n.toLowerCase());
27
+ if (t != null) {
28
+ const e = t.split(" "), { h: o, s: i, v: s } = d.RGBtoHSV(
29
+ parseInt(e[0]),
30
+ parseInt(e[1]),
31
+ parseInt(e[2])
32
+ );
33
+ return { h: o, s: i, v: s, a: 1 };
34
+ }
35
+ } else {
36
+ const { r: t, g: e, b: o, a: i } = n;
37
+ if (t >= 0 && t <= 255 && e >= 0 && e <= 255 && o >= 0 && o <= 255 && i >= 0 && i <= 1) {
38
+ const { h: s, s: r, v: h } = d.RGBtoHSV(t, e, o);
39
+ return { h: s, s: r, v: h, a: i };
40
+ }
41
+ throw new Error(
42
+ "YKColorParser:: The provided RGB object has invalid values, please make sure red, green, blue are between 0 and 255 and alpha value is between 0 and 1"
43
+ );
44
+ }
45
+ throw new Error(
46
+ "YKColorParser:: Color is not in RGB or HEX format or a named color"
47
+ );
48
+ },
49
+ compileRGB: function(n) {
50
+ let t, e, o, i;
51
+ const s = /rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)\s*(\s+(0?(\.\d+)?|1(\.0*)?)\s*)?\)/i;
52
+ if (s.test(n)) {
53
+ const r = n.split(s).filter((g) => !isNaN(parseInt(g)) && g != "" && g != null);
54
+ if (t = parseInt(r[0]), e = parseInt(r[1]), o = parseInt(r[2]), i = parseFloat(r[3]), t > 255)
55
+ throw new RangeError(
56
+ `YKColorParser:: '${n}' --> ${t} has an invalid red color, it must be an interger between 0 and 255`
57
+ );
58
+ if (e > 255)
59
+ throw new RangeError(
60
+ `YKColorParser:: '${n}' --> ${e} has an invalid green color, it must be an interger between 0 and 255`
61
+ );
62
+ if (o > 255)
63
+ throw new RangeError(
64
+ `YKColorParser:: '${n}' --> ${o} has an invalid blue color, it must be an interger between 0 and 255`
65
+ );
66
+ const { h, s: u, v: _ } = d.RGBtoHSV(t, e, o);
67
+ return { h, s: u, v: _, a: isNaN(i) ? 1 : i };
68
+ }
69
+ throw new SyntaxError(
70
+ `YKColorParser:: '${n}' is an invalid RGB format`
71
+ );
72
+ },
73
+ compileHEX: function(n) {
74
+ const t = d.HEXtoRGBA(n);
75
+ if (t) {
76
+ const { r: e, g: o, b: i, a: s } = t, { h: r, s: h, v: u } = d.RGBtoHSV(e, o, i);
77
+ return { h: r, s: h, v: u, a: s };
78
+ }
79
+ throw new Error(`YKColorParser:: '${n}' is an invalid HEX format`);
80
+ },
81
+ RGBtoHSV: function(n, t, e) {
82
+ n /= 255, t /= 255, e /= 255;
83
+ let o = Math.max(n, t, e), i = Math.min(n, t, e), s = 0, r = 0, h = o, u = o - i;
84
+ if (r = o == 0 ? 0 : u / o, o == i)
85
+ s = 0;
86
+ else {
87
+ switch (o) {
88
+ case n:
89
+ s = (t - e) / u + (t < e ? 6 : 0);
90
+ break;
91
+ case t:
92
+ s = (e - n) / u + 2;
93
+ break;
94
+ case e:
95
+ s = (n - t) / u + 4;
96
+ break;
97
+ }
98
+ s /= 6;
99
+ }
100
+ return s = s * 360, r = r * 100, h = h * 100, { h: s, s: r, v: h };
101
+ },
102
+ HSLtoHSV: function(n, t, e) {
103
+ t /= 100, e /= 100;
104
+ let o = e + t * Math.min(e, 1 - e), i = o == 0 ? 0 : 2 * (1 - e / o);
105
+ return {
106
+ h: n,
107
+ s: p(i * 100, 0, 100),
108
+ v: p(o * 100, 0, 100)
109
+ };
110
+ },
111
+ HSVtoHSL: function(n, t, e) {
112
+ t /= 100, e /= 100;
113
+ let o = (2 - t) * e / 2, i = o !== 0 && o !== 1 ? t * e / (o < 0.5 ? o * 2 : 2 - o * 2) : 0;
114
+ return {
115
+ h: p(n, 0, 360),
116
+ s: p(i * 100, 0, 100),
117
+ l: p(o * 100, 0, 100)
118
+ };
119
+ },
120
+ HEXtoRGBA: function(n) {
121
+ let t = 0, e = 0, o = 0, i = 0;
122
+ if (/^#(([a-f0-9]){3,4}|([a-f0-9]){6}|([a-f0-9]){8})$/i.test(n)) {
123
+ if (n.length < 6) {
124
+ const s = n.split("");
125
+ t = +("0x" + s[1] + s[1]), e = +("0x" + s[2] + s[2]), o = +("0x" + s[3] + s[3]), i = s[4] ? parseFloat(
126
+ (+("0x" + s[4] + s[4]) / 255).toFixed(2)
127
+ ) : 1;
128
+ } else if (n.length < 10) {
129
+ const s = n.split(/([a-f0-9]{2})/i);
130
+ t = +("0x" + s[1]), e = +("0x" + s[3]), o = +("0x" + s[5]), i = s[7] ? parseFloat((+("0x" + s[7]) / 255).toFixed(2)) : 1;
131
+ }
132
+ return { r: t, g: e, b: o, a: i };
133
+ }
134
+ },
135
+ RGBAtoHEX: function(n, t, e, o) {
136
+ return `#${w(p(n, 0, 255))}${w(
137
+ p(t, 0, 255)
138
+ )}${w(p(e, 0, 255))}${o < 1 ? w(Math.round(o * 255)) : ""}`;
139
+ },
140
+ HSVtoRGB: function(n, t, e) {
141
+ n /= 360, t /= 100, e /= 100;
142
+ let o = 0, i = 0, s = 0, r, h, u, _, g;
143
+ switch (r = Math.floor(n * 6), h = n * 6 - r, u = e * (1 - t), _ = e * (1 - h * t), g = e * (1 - (1 - h) * t), r % 6) {
144
+ case 0:
145
+ o = e, i = g, s = u;
146
+ break;
147
+ case 1:
148
+ o = _, i = e, s = u;
149
+ break;
150
+ case 2:
151
+ o = u, i = e, s = g;
152
+ break;
153
+ case 3:
154
+ o = u, i = _, s = e;
155
+ break;
156
+ case 4:
157
+ o = g, i = u, s = e;
158
+ break;
159
+ case 5:
160
+ o = e, i = u, s = _;
161
+ break;
162
+ }
163
+ return {
164
+ r: p(o * 255, 0, 255),
165
+ g: p(i * 255, 0, 255),
166
+ b: p(s * 255, 0, 255)
167
+ };
168
+ },
169
+ getNamedColor: function(n) {
170
+ return {
171
+ aliceblue: "240 248 255",
172
+ antiquewhite: "250 235 215",
173
+ aqua: "0 255 255",
174
+ aquamarine: "127 255 212",
175
+ azure: "240 255 255",
176
+ beige: "245 245 220",
177
+ bisque: "255 228 196",
178
+ black: "0 0 0",
179
+ blanchedalmond: "255 235 205",
180
+ blue: "0 0 255",
181
+ blueviolet: "138 43 226",
182
+ brown: "165 42 42",
183
+ burlywood: "222 184 135",
184
+ cadetblue: "95 158 160",
185
+ chartreuse: "127 255 0",
186
+ chocolate: "210 105 30",
187
+ coral: "255 127 80",
188
+ cornflowerblue: "100 149 237",
189
+ cornsilk: "255 248 220",
190
+ crimson: "220 20 60",
191
+ cyan: "0 255 255",
192
+ darkblue: "0 0 139",
193
+ darkcyan: "0 139 139",
194
+ darkgoldenrod: "184 134 11",
195
+ darkgray: "169 169 169",
196
+ darkgrey: "169 169 169",
197
+ darkgreen: "0 100 0",
198
+ darkkhaki: "189 183 107",
199
+ darkmagenta: "139 0 139",
200
+ darkolivegreen: "85 107 47",
201
+ darkorange: "255 140 0",
202
+ darkorchid: "153 50 204",
203
+ darkred: "139 0 0",
204
+ darksalmon: "233 150 122",
205
+ darkseagreen: "143 188 143",
206
+ darkslateblue: "72 61 139",
207
+ darkslategray: "47 79 79",
208
+ darkslategrey: "47 79 79",
209
+ darkturquoise: "0 206 209",
210
+ darkviolet: "148 0 211",
211
+ deeppink: "255 20 147",
212
+ deepskyblue: "0 191 255",
213
+ dimgray: "105 105 105",
214
+ dimgrey: "105 105 105",
215
+ dodgerblue: "30 144 255",
216
+ firebrick: "178 34 34",
217
+ floralwhite: "255 250 240",
218
+ forestgreen: "34 139 34",
219
+ fuchsia: "255 0 255",
220
+ gainsboro: "220 220 220",
221
+ ghostwhite: "248 248 255",
222
+ gold: "255 215 0",
223
+ goldenrod: "218 165 32",
224
+ gray: "128 128 128",
225
+ grey: "128 128 128",
226
+ green: "0 128 0",
227
+ greenyellow: "173 255 47",
228
+ honeydew: "240 255 240",
229
+ hotpink: "255 105 180",
230
+ indianred: "205 92 92",
231
+ indigo: "75 0 130",
232
+ ivory: "255 255 240",
233
+ khaki: "240 230 140",
234
+ lavender: "230 230 250",
235
+ lavenderblush: "255 240 245",
236
+ lawngreen: "124 252 0",
237
+ lemonchiffon: "255 250 205",
238
+ lightblue: "173 216 230",
239
+ lightcoral: "240 128 128",
240
+ lightcyan: "224 255 255",
241
+ lightgoldenrodyellow: "250 250 210",
242
+ lightgray: "211 211 211",
243
+ lightgrey: "211 211 211",
244
+ lightgreen: "144 238 144",
245
+ lightpink: "255 182 193",
246
+ lightsalmon: "255 160 122",
247
+ lightseagreen: "32 178 170",
248
+ lightskyblue: "135 206 250",
249
+ lightslategray: "119 136 153",
250
+ lightslategrey: "119 136 153",
251
+ lightsteelblue: "176 196 222",
252
+ lightyellow: "255 255 224",
253
+ lime: "0 255 0",
254
+ limegreen: "50 205 50",
255
+ linen: "250 240 230",
256
+ magenta: "255 0 255",
257
+ maroon: "128 0 0",
258
+ mediumaquamarine: "102 205 170",
259
+ mediumblue: "0 0 205",
260
+ mediumorchid: "186 85 211",
261
+ mediumpurple: "147 112 216",
262
+ mediumseagreen: "60 179 113",
263
+ mediumslateblue: "123 104 238",
264
+ mediumspringgreen: "0 250 154",
265
+ mediumturquoise: "72 209 204",
266
+ mediumvioletred: "199 21 133",
267
+ midnightblue: "25 25 112",
268
+ mintcream: "245 255 250",
269
+ mistyrose: "255 228 225",
270
+ moccasin: "255 228 181",
271
+ navajowhite: "255 222 173",
272
+ navy: "0 0 128",
273
+ oldlace: "253 245 230",
274
+ olive: "128 128 0",
275
+ olivedrab: "107 142 35",
276
+ orange: "255 165 0",
277
+ orangered: "255 69 0",
278
+ orchid: "218 112 214",
279
+ palegoldenrod: "238 232 170",
280
+ palegreen: "152 251 152",
281
+ paleturquoise: "175 238 238",
282
+ palevioletred: "216 112 147",
283
+ papayawhip: "255 239 213",
284
+ peachpuff: "255 218 185",
285
+ peru: "205 133 63",
286
+ pink: "255 192 203",
287
+ plum: "221 160 221",
288
+ powderblue: "176 224 230",
289
+ purple: "128 0 128",
290
+ red: "255 0 0",
291
+ rosybrown: "188 143 143",
292
+ royalblue: "65 105 225",
293
+ saddlebrown: "139 69 19",
294
+ salmon: "250 128 114",
295
+ sandybrown: "244 164 96",
296
+ seagreen: "46 139 87",
297
+ seashell: "255 245 238",
298
+ sienna: "160 82 45",
299
+ silver: "192 192 192",
300
+ skyblue: "135 206 235",
301
+ slateblue: "106 90 205",
302
+ slategray: "112 128 144",
303
+ slategrey: "112 128 144",
304
+ snow: "255 250 250",
305
+ springgreen: "0 255 127",
306
+ steelblue: "70 130 180",
307
+ tan: "210 180 140",
308
+ teal: "0 128 128",
309
+ thistle: "216 191 216",
310
+ tomato: "255 99 71",
311
+ turquoise: "64 224 208",
312
+ violet: "238 130 238",
313
+ wheat: "245 222 179",
314
+ white: "255 255 255",
315
+ whitesmoke: "245 245 245",
316
+ yellow: "255 255 0",
317
+ yellowgreen: "154 205 50"
318
+ }[n];
319
+ }
320
+ };
321
+ class T {
322
+ constructor(t, e, o, i) {
323
+ this.a = i, this.hsv = { h: t, s: e, v: o }, this.rgb = this.toRGB(), this.hsl = this.toHSL(), this.hex = this.toHEX();
324
+ }
325
+ getRGB() {
326
+ return {
327
+ r: p(this.rgb.r, 0, 255),
328
+ g: p(this.rgb.g, 0, 255),
329
+ b: p(this.rgb.b, 0, 255)
330
+ };
331
+ }
332
+ getHSV() {
333
+ return {
334
+ h: p(this.hsv.h, 0, 360),
335
+ s: p(this.hsv.s, 0, 100),
336
+ v: p(this.hsv.v, 0, 100)
337
+ };
338
+ }
339
+ getHSL() {
340
+ return {
341
+ h: p(this.hsl.h, 0, 360),
342
+ s: p(this.hsl.s, 0, 100),
343
+ l: p(this.hsl.l, 0, 100)
344
+ };
345
+ }
346
+ toRGB() {
347
+ let { h: t, s: e, v: o } = this.hsv;
348
+ return d.HSVtoRGB(t, e, o);
349
+ }
350
+ toHSL() {
351
+ let { h: t, s: e, v: o } = this.hsv;
352
+ return d.HSVtoHSL(t, e, o);
353
+ }
354
+ toHEX() {
355
+ let { r: t, g: e, b: o } = this.toRGB();
356
+ return d.RGBAtoHEX(t, e, o, this.a);
357
+ }
358
+ }
359
+ var M = /* @__PURE__ */ ((n) => (n.TOP = "t", n.BOTTOM = "b", n.LEFT = "l", n.RIGHT = "r", n))(M || {}), A = /* @__PURE__ */ ((n) => (n.RGB = "rgb", n.HSV = "hsv", n.HSL = "hsl", n.HEX = "hex", n))(A || {});
360
+ const a = class a {
361
+ constructor(t) {
362
+ this._isOpen = !1, this._options = a.DEFAULT_OPTIONS, this._color = new T(0, 0, 0, 1), this._dom = {}, this._copyTimeout = null, this._prevColor = null, this._targetKeydownOpen = !1, this._options = a._buildOptions(
363
+ a.DEFAULT_OPTIONS,
364
+ t
365
+ );
366
+ const { target: e, representation: o } = this._options;
367
+ let i = null;
368
+ if (typeof e == "string")
369
+ i = document.querySelector(e);
370
+ else if (e && e.nodeType == Node.ELEMENT_NODE)
371
+ i = e;
372
+ else if (e != null)
373
+ throw new Error(
374
+ "YKColorPicker:: target must be a string or an HTMLElement"
375
+ );
376
+ this._dom.target = i, this._currentRepresentation = o, i && (this._onClickTargetBind = this._onClickTarget.bind(this), l(i, "click", this._onClickTargetBind)), this._initDOM(), this.setColor(this._options.color);
377
+ }
378
+ get options() {
379
+ return this._options;
380
+ }
381
+ get target() {
382
+ return this._dom.target;
383
+ }
384
+ isOpen() {
385
+ return this._isOpen;
386
+ }
387
+ open() {
388
+ this._isOpen = !0, this._prevColor = this.getHEX(), this._options.container ? this._attachToContainer(!0) : this._attachToBody(), this._dom.overlayWrapper.classList.add("yk-overlay-wrapper--open"), this._dom.cursor.focus(), this._options.onOpen && this._options.onOpen(this);
389
+ }
390
+ close() {
391
+ this._dc || (this._prevColor != this.getHEX() && this._options.onChange && this._options.onChange(this), this._detachOverlay(), this._options.onClose && this._options.onClose(this)), this._dc = !1;
392
+ }
393
+ getRGB() {
394
+ return { ...this._color.toRGB(), a: this._color.a };
395
+ }
396
+ getHSV() {
397
+ const { h: t, s: e, v: o } = this._color.getHSV();
398
+ return {
399
+ h: t,
400
+ s: e,
401
+ v: o,
402
+ a: this._color.a
403
+ };
404
+ }
405
+ getHSL() {
406
+ const { h: t, s: e, l: o } = this._color.toHSL();
407
+ return {
408
+ h: t,
409
+ s: e,
410
+ l: o,
411
+ a: this._color.a
412
+ };
413
+ }
414
+ getHEX() {
415
+ return this._color.toHEX();
416
+ }
417
+ updateOptions(t) {
418
+ const e = a._buildOptions(this._options, t);
419
+ this._options = e, t.hasOwnProperty("theme") && this._updateTheme(e.theme), t.hasOwnProperty("representation") && this._updateRepresentation(e.representation), t.hasOwnProperty("position") && t.hasOwnProperty("container") == !1 && this._updatePosition(), t.hasOwnProperty("container") && (t.container ? this._attachToContainer(!0) : this._attachToBody()), t.hasOwnProperty("target") && this._updateTarget(t.target), t.hasOwnProperty("color") && t.color && this.setColor(t.color);
420
+ }
421
+ getColor() {
422
+ switch (this._currentRepresentation) {
423
+ case "rgb": {
424
+ const { r: t, g: e, b: o } = this._color.getRGB();
425
+ return {
426
+ r: t,
427
+ g: e,
428
+ b: o,
429
+ a: this._color.a
430
+ };
431
+ }
432
+ case "hsv": {
433
+ const { h: t, s: e, v: o } = this._color.getHSV();
434
+ return {
435
+ h: t,
436
+ s: e,
437
+ v: o,
438
+ a: this._color.a
439
+ };
440
+ }
441
+ case "hsl": {
442
+ const { h: t, s: e, l: o } = this._color.getHSL();
443
+ return {
444
+ h: t,
445
+ s: e,
446
+ l: o,
447
+ a: this._color.a
448
+ };
449
+ }
450
+ case "hex":
451
+ return this.getHEX();
452
+ }
453
+ }
454
+ setColor(t) {
455
+ const { h: e, s: o, v: i, a: s } = d.parse(t);
456
+ this._color = new T(e, o, i, s), this._updateGUI(), this._options.onInput(this);
457
+ }
458
+ _initDOM() {
459
+ const t = c("div", ["yk-overlay-wrapper"]), e = c("div", ["yk-wrapper"]);
460
+ t.appendChild(e), e.appendChild(this._buildPaletteColor()), e.appendChild(this._buildColorSettings()), l(
461
+ t,
462
+ "click",
463
+ (o) => o.stopPropagation()
464
+ ), this._dom.overlayWrapper = t, this._onKeyUpCloseBind = this._onKeyUpClose.bind(this), this._onResizeScrollWindowBind = this._onResizeScrollWindow.bind(this), this._onClickCloseBind = this.close.bind(this), this._options.container ? this._attachToContainer(!1) : document.body.appendChild(this._dom.overlayWrapper), this._options.onInit && this._options.onInit(this);
465
+ }
466
+ _updateGUI() {
467
+ this._updateCursorThumb(), this._updateInputs(), this._updateColorPreview(!1), this._updateHueThumb(), this._updateOpacityThumb();
468
+ }
469
+ _buildPaletteColor() {
470
+ const t = c("div", ["yk-palette-wrapper"]), e = c("div", ["yk-palette"]), o = c("a", ["yk-cursor"], { tabindex: 0 });
471
+ return t.appendChild(e), t.appendChild(o), this._onMouseDownCursorBind = this._onMouseDownCursor.bind(this), this._onMouseUpCursorBind = this._onMouseUpCursor.bind(this), this._onMouseMoveCursorBind = this._onMouseMoveCursor.bind(this), l(t, "pointerdown", this._onMouseDownCursorBind), l(o, "keydown", this._onKeydownCursor.bind(this)), this._dom.palette = e, this._dom.cursor = o, t;
472
+ }
473
+ _buildColorSettings() {
474
+ const t = c("div", ["yk-color-settings"]);
475
+ return t.appendChild(this._buildCopyColor()), t.appendChild(this._buildColorPreview()), t.appendChild(this._buildColorSliders()), t.appendChild(this._buildColorInputs()), t;
476
+ }
477
+ _buildColorInputs() {
478
+ const t = c("div", ["yk-color-model-wrapper"]), e = c("div", ["yk-color-model"]), o = c("button", ["yk-color-model-switch"], {
479
+ type: "button"
480
+ });
481
+ return o.appendChild(
482
+ this._createSVGIcon(
483
+ '<path d="m3.5045 11.431 1.5786-1.5786 3.0256 3.0256 3.0256-3.0256 1.5786 1.5786-4.6042 4.4726zm4.6042-11.313 4.6042 4.4726-1.5786 1.5786-3.0256-3.0256-3.0256 3.0256-1.5786-1.5786z"/>'
484
+ )
485
+ ), t.appendChild(e), t.appendChild(o), l(o, "click", this._onClickInputsSwitch.bind(this)), this._dom.btnSwitch = o, this._dom.inputsWrapper = e, t;
486
+ }
487
+ _buildInput() {
488
+ const { inputsWrapper: t } = this._dom;
489
+ t.innerHTML = "", this._currentRepresentation == "hex" ? t.appendChild(this._buildHEXInput()) : t.appendChild(this._buildQuadrupedInput());
490
+ }
491
+ _buildHEXInput() {
492
+ const t = c("div", ["yk-hex-input"]), e = c("input", ["yk-color-input"], {
493
+ id: "yk-color-input-hex"
494
+ }), o = c("label", ["yk-color-model-label"], {
495
+ for: "yk-color-input-hex"
496
+ });
497
+ return e.setAttribute("type", "text"), o.textContent = "HEX", t.appendChild(e), t.appendChild(o), l(e, "focus", this._onFocusInput.bind(this)), l(e, "keydown", this._onKeyDownInputHEX.bind(this)), l(e, "input", this._onInputHEX.bind(this)), l(e, "change", this._onChangeInputHEX.bind(this)), this._dom.inputHEX = e, t;
498
+ }
499
+ _buildQuadrupedInput() {
500
+ const t = c("div", ["yk-input-wrapper"]), e = c("input", ["yk-color-input"], {
501
+ type: "text",
502
+ inputmode: "numeric",
503
+ id: "yk-color-input-1"
504
+ }), o = c("input", ["yk-color-input"], {
505
+ type: "text",
506
+ inputmode: "numeric",
507
+ id: "yk-color-input-2"
508
+ }), i = c("input", ["yk-color-input"], {
509
+ type: "text",
510
+ inputmode: "numeric",
511
+ id: "yk-color-input-3"
512
+ }), s = c("input", ["yk-color-input"], {
513
+ type: "text",
514
+ inputmode: "numeric",
515
+ id: "yk-color-input-4"
516
+ }), r = c("label", ["yk-color-model-label"], {
517
+ for: "yk-color-input-1"
518
+ }), h = c("label", ["yk-color-model-label"], {
519
+ for: "yk-color-input-2"
520
+ }), u = c("label", ["yk-color-model-label"], {
521
+ for: "yk-color-input-3"
522
+ }), _ = c("label", ["yk-color-model-label"], {
523
+ for: "yk-color-input-4"
524
+ }), g = this._currentRepresentation.toUpperCase();
525
+ return r.textContent = g[0], h.textContent = g[1], u.textContent = g[2], _.textContent = "A", t.appendChild(e), t.appendChild(o), t.appendChild(i), t.appendChild(s), t.appendChild(r), t.appendChild(h), t.appendChild(u), t.appendChild(_), l(e, "focus", this._onFocusInput.bind(this)), l(e, "keydown", this._onKeyDownInputA.bind(this)), l(e, "input", this._onInputA.bind(this)), l(e, "change", this._onChangeInputA.bind(this)), l(o, "focus", this._onFocusInput.bind(this)), l(o, "keydown", this._onKeyDownInputB.bind(this)), l(o, "input", this._onInputB.bind(this)), l(o, "change", this._onChangeInputB.bind(this)), l(i, "focus", this._onFocusInput.bind(this)), l(i, "keydown", this._onKeyDownInputC.bind(this)), l(i, "input", this._onInputC.bind(this)), l(i, "change", this._onChangeInputC.bind(this)), l(s, "keydown", this._onKeyDownAlphaInput.bind(this)), l(s, "input", this._onKeyUpAlphaInput.bind(this)), l(s, "change", this._onChangeAlphaInput.bind(this)), this._dom.inputA = e, this._dom.inputB = o, this._dom.inputC = i, this._dom.inputAlpha = s, t;
526
+ }
527
+ _updateOpacityThumb() {
528
+ const { opacitySlider: t, opacityThumb: e } = this._dom;
529
+ e.style.translate = `${this._color.a * t.offsetWidth}px`;
530
+ }
531
+ _updateHueThumb() {
532
+ const { hueThumb: t, hueSlider: e } = this._dom;
533
+ t.style.translate = `${this._color.hsv.h / 360 * e.offsetWidth}px`;
534
+ }
535
+ _setQuadrupedValue(t, e, o) {
536
+ this._dom.inputA.value = t, this._dom.inputB.value = e, this._dom.inputC.value = o, this._dom.inputAlpha.value = parseFloat(this._color.a.toFixed(2));
537
+ }
538
+ _updateHEXInput() {
539
+ this._dom.inputHEX.value = this._color.hex;
540
+ }
541
+ _updateSettingsView() {
542
+ this._updateInputsValue(), this._updateColorPreview(!0);
543
+ }
544
+ _updateInputs() {
545
+ this._buildInput(), this._updateInputsValue();
546
+ }
547
+ _updateInputsValue() {
548
+ switch (this._currentRepresentation) {
549
+ case "rgb":
550
+ {
551
+ const { r: t, g: e, b: o } = this._color.rgb = this._color.toRGB();
552
+ this._setQuadrupedValue(t, e, o);
553
+ }
554
+ break;
555
+ case "hsv":
556
+ {
557
+ const { h: t, s: e, v: o } = this._color.getHSV();
558
+ this._setQuadrupedValue(`${t}°`, `${e}%`, `${o}%`);
559
+ }
560
+ break;
561
+ case "hsl":
562
+ {
563
+ const { h: t, s: e, l: o } = this._color.hsl = this._color.toHSL();
564
+ this._setQuadrupedValue(`${t}°`, `${e}%`, `${o}%`);
565
+ }
566
+ break;
567
+ case "hex":
568
+ this._updateHEXColor(), this._updateHEXInput();
569
+ break;
570
+ }
571
+ }
572
+ _updateColorPreview(t) {
573
+ const e = this._color.a, o = this._color.toHSL(), { palette: i, opacitySlider: s, colorPreview: r } = this._dom, h = `hsl(${o.h}deg 100% 50% / 1)`;
574
+ i.style.backgroundImage = `linear-gradient(180deg, transparent 0%, rgba(0,0,0,1) 100%), linear-gradient(90deg, rgba(255,255,255,1) 0%, ${h} 100%)`;
575
+ const u = `hsl(${o.h}, ${o.s}%, ${o.l}%)`;
576
+ s.style.setProperty(
577
+ "background-image",
578
+ `linear-gradient(90deg, transparent, ${u})`
579
+ ), r.setAttribute("fill", u), r.setAttribute("fill-opacity", e), t == !0 && this._options.onInput(this);
580
+ }
581
+ _updateCursorThumb() {
582
+ const { palette: t, cursor: e } = this._dom, { s: o, v: i } = this._color.getHSV();
583
+ e.style.translate = `${o / 100 * t.offsetWidth}px ${t.offsetHeight - i / 100 * t.offsetHeight}px`;
584
+ }
585
+ _buildCopyColor() {
586
+ const t = c("button", ["yk-clipboard-color"], {
587
+ type: "button"
588
+ });
589
+ return l(t, "click", this._onClickCopyColor.bind(this)), this._dom.copyColor = t, this._attachCopyIcon(), t;
590
+ }
591
+ _attachCopyIcon() {
592
+ const t = '<path d="m1.9695 11.037v-6.7c0-2 1.6-3.7 3.7-3.7h4.3c0.8 0 1.5 0.5 1.7 1.2h-5.6c-1.6 0.1-2.9 1.4-2.9 3.1v7.9c-0.7-0.3-1.2-1-1.2-1.8zm4.3 4.3c-1 0-1.8-0.8-1.8-1.8v-8.6c0-1 0.8-1.8 1.8-1.8h6.1c1 0 1.8 0.8 1.8 1.8v8.6c0 1-0.8 1.8-1.8 1.8zm6.7-1.8v-8.6c0-0.3-0.3-0.6-0.6-0.6h-6.1c-0.3 0-0.6 0.3-0.6 0.6v8.6c0 0.3 0.3 0.6 0.6 0.6h6.1c0.3 0 0.6-0.3 0.6-0.6z"/>';
593
+ this._dom.copyColor.innerHTML = "", this._dom.copyColor.appendChild(this._createSVGIcon(t));
594
+ }
595
+ _attachCheckIcon() {
596
+ const t = '<path d="m13.975 5.3001c0.24929-0.24929 0.16619-0.58168-0.0831-0.83097l-0.66477-0.66477c-0.24929-0.24929-0.58168-0.16619-0.83097 0.083097l-5.5675 6.2322-3.407-3.1577c-0.24929-0.24929-0.58168-0.16619-0.83097 0.083097l-0.66477 0.66477c-0.24929 0.24929-0.16619 0.58168 0.083097 0.83097l4.5703 4.1548c0.24929 0.24929 0.58168 0.16619 0.83097-0.0831z"/>';
597
+ this._dom.copyColor.innerHTML = "", this._dom.copyColor.appendChild(this._createSVGIcon(t));
598
+ }
599
+ _createSVGIcon(t) {
600
+ const e = document.createElementNS(
601
+ "http://www.w3.org/2000/svg",
602
+ "svg"
603
+ );
604
+ return e.setAttribute("viewBox", "0 0 16 16"), e.setAttribute("width", "16px"), e.setAttribute("height", "16px"), e.innerHTML = t, e;
605
+ }
606
+ _buildColorSliders() {
607
+ const t = c("div", ["yk-sliders"]);
608
+ return t.appendChild(this._buildHueSlider()), t.appendChild(this._buildOpacitySlider()), t;
609
+ }
610
+ _buildHueSlider() {
611
+ const t = c("div", ["yk-hue-slider-wrapper"]), e = c("div", ["yk-hue-slider"]), o = c("div", ["yk-hue-slider-thumb"]);
612
+ return o.setAttribute("tabindex", "0"), t.appendChild(e), t.appendChild(o), this._onMouseDownHueSliderBind = this._onMouseDownHueSlider.bind(this), this._onMouseUpHueSliderBind = this._onMouseUpHueSlider.bind(this), this._onMouseMoveHueSliderBind = this._onMouseMoveHueSlider.bind(this), l(t, "pointerdown", this._onMouseDownHueSliderBind), l(o, "keydown", this._onKeyDownHueSlider.bind(this)), this._dom.hueSlider = e, this._dom.hueThumb = o, t;
613
+ }
614
+ _buildOpacitySlider() {
615
+ const t = c("div", ["yk-opacity-slider-wrapper"]), e = c("div", ["yk-opacity-color"]), o = c("div", ["yk-opacity-slider-thumb"]);
616
+ return o.setAttribute("tabindex", "0"), t.appendChild(e), t.appendChild(o), this._onMouseDownOpacitySliderBind = this._onMouseDownOpacitySlider.bind(this), this._onMouseUpOpacitySliderBind = this._onMouseUpOpacitySlider.bind(this), this._onMouseMoveOpacitySliderBind = this._onMouseMoveOpacitySlider.bind(this), l(
617
+ t,
618
+ "pointerdown",
619
+ this._onMouseDownOpacitySliderBind
620
+ ), l(
621
+ o,
622
+ "keydown",
623
+ this._onKeyDownOpacitySlider.bind(this)
624
+ ), this._dom.opacitySlider = e, this._dom.opacityThumb = o, t;
625
+ }
626
+ _buildColorPreview() {
627
+ const t = c("span", [
628
+ "yk-color-preview-wrapper"
629
+ ]), e = document.createElementNS(
630
+ "http://www.w3.org/2000/svg",
631
+ "svg"
632
+ );
633
+ e.setAttribute("width", "38"), e.setAttribute("height", "38");
634
+ const o = document.createElementNS(
635
+ "http://www.w3.org/2000/svg",
636
+ "circle"
637
+ );
638
+ return o.setAttribute("cx", "19"), o.setAttribute("cy", "19"), o.setAttribute("r", "18"), o.classList.add("yk-preview-stroke"), e.innerHTML = '<pattern id="transparent-grid" x="0" y="0" width="6" height="6" patternUnits="userSpaceOnUse"><path fill="#DBDBDB" d="M0 0h3v3H0z"/><path fill="#fff" d="M3 0h3v3H3z"/><path fill="#DBDBDB" d="M3 3h3v3H3z"/><path fill="#fff" d="M0 3h3v3H0z"/></pattern></defs><circle cx="19" cy="19" r="18" fill="url(#transparent-grid)"/>', e.appendChild(o), t.appendChild(e), this._dom.colorPreview = o, t;
639
+ }
640
+ _rgbUpdateView() {
641
+ this._updateColorPreview(!0), this._updateHueThumb(), this._updateCursorThumb();
642
+ }
643
+ _updateHEXColorSection(t, e, o, i, s, r, h) {
644
+ const u = e.target, { rgb: _, hex: g } = this._color;
645
+ if (o(_[t], i)) {
646
+ _[t] = s(_[t], 1), this._color.hex = g.substring(0, r) + w(p(_[t], 0, 255)) + g.substring(h);
647
+ const { r: k, g: S, b: H } = _;
648
+ this._color.hsv = d.RGBtoHSV(k, S, H), this._rgbUpdateView();
649
+ }
650
+ u.value = this._color.hex, u.setSelectionRange(r, h), e.preventDefault();
651
+ }
652
+ _updateHEXAlphaSection(t, e, o, i) {
653
+ const s = t.target, { hex: r, a: h } = this._color;
654
+ e(h, o) && (this._color.a = parseFloat(i(h, 0.01).toFixed(2)), s.value = this._color.hex = r.substring(0, 7) + w(p(this._color.a * 255, 0, 255)), this._updateColorPreview(!0), this._updateOpacityThumb()), s.value = this._color.hex, s.setSelectionRange(7, 9), t.preventDefault();
655
+ }
656
+ _updateOpacityValue(t) {
657
+ this._color.a = parseFloat(t.toFixed(2)), this._currentRepresentation == "hex" ? (this._updateHEXColor(), this._updateHEXInput()) : this._dom.inputAlpha.value = this._color.a, this._updateColorPreview(!0);
658
+ }
659
+ _updatePosition() {
660
+ if (this._dom.target != null) {
661
+ if (!a._isTargetInViewport(this._dom.target)) {
662
+ this.close();
663
+ return;
664
+ }
665
+ this._setPositionAxis(this._getPositionAxis());
666
+ }
667
+ }
668
+ _attachToContainer(t) {
669
+ if (!this._options.container)
670
+ throw new Error("YKColorPicker:: container is not defined");
671
+ let e = null;
672
+ if (typeof this._options.container == "string" ? e = document.querySelector(this._options.container) : this._options.container && this._options.container.nodeType == Node.ELEMENT_NODE && (e = this._options.container), !e)
673
+ throw ReferenceError(
674
+ "ColorPicker:: container to set color picker is undefined"
675
+ );
676
+ this._removeWindowEvents();
677
+ const { overlayWrapper: o } = this._dom, i = o.parentElement;
678
+ e.appendChild(o), o.classList.add("yk-overlay-wrapper--static"), this._updateTheme(this._options.theme), this._updateGUI(), t && i != o.parentElement && this._options.onContainerChange && this._options.onContainerChange(this, i);
679
+ }
680
+ _attachToBody() {
681
+ this._removeWindowEvents();
682
+ const { overlayWrapper: t } = this._dom, e = t.parentElement;
683
+ document.body.appendChild(t), t.classList.remove("yk-overlay-wrapper--static"), this._updateTheme(this._options.theme), this._updateGUI(), this._updatePosition(), l(window, "resize", this._onResizeScrollWindowBind), l(window, "scroll", this._onResizeScrollWindowBind), l(document, "click", this._onClickCloseBind), l(document, "keyup", this._onKeyUpCloseBind), e != t.parentElement && this._options.onContainerChange && this._options.onContainerChange(this, e);
684
+ }
685
+ _detachOverlay() {
686
+ var t;
687
+ this._dom.overlayWrapper.classList.remove("yk-overlay-wrapper--open"), this._removeWindowEvents(), this._isOpen = !1, (t = this._dom.target) == null || t.focus();
688
+ }
689
+ _onKeydownCursor(t) {
690
+ if (["ArrowUp", "ArrowDown", "ArrowRight", "ArrowLeft"].includes(t.key)) {
691
+ switch (t.preventDefault(), t.stopPropagation(), t.key) {
692
+ case "ArrowUp":
693
+ {
694
+ let e = Math.round(this._color.hsv.v);
695
+ e < 100 && (this._color.hsv.v = e + 1);
696
+ }
697
+ break;
698
+ case "ArrowDown":
699
+ {
700
+ let e = Math.round(this._color.hsv.v);
701
+ e > 0 && (this._color.hsv.v = e - 1);
702
+ }
703
+ break;
704
+ case "ArrowRight":
705
+ {
706
+ let e = Math.round(this._color.hsv.s);
707
+ e < 100 && (this._color.hsv.s = e + 1);
708
+ }
709
+ break;
710
+ case "ArrowLeft":
711
+ {
712
+ let e = Math.round(this._color.hsv.s);
713
+ e > 0 && (this._color.hsv.s = e - 1);
714
+ }
715
+ break;
716
+ }
717
+ this._updateCursorThumb(), this._updateInputsValue(), this._updateColorPreview(!0);
718
+ }
719
+ }
720
+ _onClickTarget(t) {
721
+ t.stopPropagation(), this._targetKeydownOpen = !0, this._isOpen ? this.close() : this.open();
722
+ }
723
+ _onMouseDownCursor(t) {
724
+ this._dc = !0, l(document, "pointermove", this._onMouseMoveCursorBind), l(document, "pointerup", this._onMouseUpCursorBind), this._onMouseMoveCursorBind(t);
725
+ }
726
+ _onMouseUpCursor(t) {
727
+ document.removeEventListener("pointermove", this._onMouseMoveCursorBind), document.removeEventListener("pointerup", this._onMouseUpCursorBind), this._dom.overlayWrapper.contains(t.target) && (this._dc = !1), this._dom.cursor.focus();
728
+ }
729
+ _onMouseMoveCursor(t) {
730
+ const { x: e, y: o } = this._getCursorPosition(t.clientX, t.clientY);
731
+ this._dom.cursor.style.translate = `${e}px ${o}px`;
732
+ const i = this._dom.palette.offsetHeight, s = this._dom.palette.offsetWidth;
733
+ this._color.hsv.s = e / s * 100, this._color.hsv.v = (i - o) / i * 100, this._updateSettingsView();
734
+ }
735
+ _onClickInputsSwitch() {
736
+ switch (this._currentRepresentation) {
737
+ case "rgb":
738
+ this._updateRepresentation(
739
+ "hsv"
740
+ /* HSV */
741
+ );
742
+ break;
743
+ case "hsv":
744
+ this._updateRepresentation(
745
+ "hsl"
746
+ /* HSL */
747
+ );
748
+ break;
749
+ case "hsl":
750
+ this._updateRepresentation(
751
+ "hex"
752
+ /* HEX */
753
+ );
754
+ break;
755
+ case "hex":
756
+ this._updateRepresentation(
757
+ "rgb"
758
+ /* RGB */
759
+ );
760
+ break;
761
+ }
762
+ }
763
+ _onFocusInput() {
764
+ switch (this._currentRepresentation) {
765
+ case "rgb":
766
+ this._color.rgb = this._color.getRGB();
767
+ break;
768
+ case "hsv":
769
+ this._color.hsv = this._color.getHSV();
770
+ break;
771
+ case "hsl":
772
+ this._color.hsl = this._color.getHSL();
773
+ break;
774
+ case "hex":
775
+ this._updateHEXColor();
776
+ break;
777
+ }
778
+ }
779
+ _onKeyDownAlphaInput(t) {
780
+ const e = t.target, { a: o } = this._color;
781
+ switch (t.key) {
782
+ case "ArrowUp":
783
+ if (o < 1) {
784
+ let i = parseFloat((o + 0.01).toFixed(2));
785
+ i > 1 && (i = 1), e.value = (this._color.a = i).toString(), this._updateColorPreview(!0), this._updateOpacityThumb();
786
+ }
787
+ break;
788
+ case "ArrowDown":
789
+ if (o > 0) {
790
+ let i = parseFloat((o - 0.01).toFixed(2));
791
+ i < 0 && (i = 0), e.value = (this._color.a = i).toString(), this._updateColorPreview(!0), this._updateOpacityThumb();
792
+ }
793
+ break;
794
+ case ".":
795
+ /(\.)/.test(e.value) && t.preventDefault();
796
+ break;
797
+ }
798
+ }
799
+ _onKeyUpAlphaInput(t) {
800
+ const e = t.target;
801
+ if (/^(0(\.\d{1,2})?|(0*)1?)$/.test(e.value) || e.value == "") {
802
+ const o = parseFloat(e.value) || 0;
803
+ !isNaN(o) && o >= 0 && o <= 1 && (this._color.a = o, this._updateColorPreview(!0), this._updateOpacityThumb());
804
+ }
805
+ }
806
+ _onChangeAlphaInput(t) {
807
+ t.target && (t.target.value = this._color.a.toString());
808
+ }
809
+ _onKeyDownInputHEX(t) {
810
+ const e = t.target;
811
+ switch (t.key) {
812
+ case "ArrowUp":
813
+ {
814
+ /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(
815
+ e.value
816
+ ) || (e.value = this._color.hex);
817
+ const o = this._getCaretPosition(e), i = e.value.length;
818
+ i <= 5 ? o < 2 ? this._updateHEXColorSection(
819
+ "r",
820
+ t,
821
+ a._lt,
822
+ 255,
823
+ a._add,
824
+ 1,
825
+ 3
826
+ ) : o < 3 ? this._updateHEXColorSection(
827
+ "g",
828
+ t,
829
+ a._lt,
830
+ 255,
831
+ a._add,
832
+ 3,
833
+ 5
834
+ ) : o <= 4 && i <= 4 || o < 4 ? this._updateHEXColorSection(
835
+ "b",
836
+ t,
837
+ a._lt,
838
+ 255,
839
+ a._add,
840
+ 5,
841
+ 7
842
+ ) : o <= 5 && this._updateHEXAlphaSection(
843
+ t,
844
+ a._lt,
845
+ 1,
846
+ a._add
847
+ ) : o < 3 ? this._updateHEXColorSection(
848
+ "r",
849
+ t,
850
+ a._lt,
851
+ 255,
852
+ a._add,
853
+ 1,
854
+ 3
855
+ ) : o < 5 ? this._updateHEXColorSection(
856
+ "g",
857
+ t,
858
+ a._lt,
859
+ 255,
860
+ a._add,
861
+ 3,
862
+ 5
863
+ ) : o <= 7 && i == 7 || o < 7 ? this._updateHEXColorSection(
864
+ "b",
865
+ t,
866
+ a._lt,
867
+ 255,
868
+ a._add,
869
+ 5,
870
+ 7
871
+ ) : o <= 9 && this._updateHEXAlphaSection(
872
+ t,
873
+ a._lt,
874
+ 1,
875
+ a._add
876
+ );
877
+ }
878
+ break;
879
+ case "ArrowDown":
880
+ {
881
+ /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(
882
+ e.value
883
+ ) || (e.value = this._color.hex);
884
+ const o = this._getCaretPosition(e), i = e.value.length;
885
+ i <= 5 ? o < 2 ? this._updateHEXColorSection(
886
+ "r",
887
+ t,
888
+ a._gt,
889
+ 0,
890
+ a._sub,
891
+ 1,
892
+ 3
893
+ ) : o < 3 ? this._updateHEXColorSection(
894
+ "g",
895
+ t,
896
+ a._gt,
897
+ 0,
898
+ a._sub,
899
+ 3,
900
+ 5
901
+ ) : o <= 4 && i <= 4 || o < 4 ? this._updateHEXColorSection(
902
+ "b",
903
+ t,
904
+ a._gt,
905
+ 0,
906
+ a._sub,
907
+ 5,
908
+ 7
909
+ ) : o <= 5 && this._updateHEXAlphaSection(
910
+ t,
911
+ a._gt,
912
+ 0,
913
+ a._sub
914
+ ) : o < 3 ? this._updateHEXColorSection(
915
+ "r",
916
+ t,
917
+ a._gt,
918
+ 0,
919
+ a._sub,
920
+ 1,
921
+ 3
922
+ ) : o < 5 ? this._updateHEXColorSection(
923
+ "g",
924
+ t,
925
+ a._gt,
926
+ 0,
927
+ a._sub,
928
+ 3,
929
+ 5
930
+ ) : o <= 7 && i == 7 || o < 7 ? this._updateHEXColorSection(
931
+ "b",
932
+ t,
933
+ a._gt,
934
+ 0,
935
+ a._sub,
936
+ 5,
937
+ 7
938
+ ) : o <= 9 && this._updateHEXAlphaSection(
939
+ t,
940
+ a._gt,
941
+ 0,
942
+ a._sub
943
+ );
944
+ }
945
+ break;
946
+ }
947
+ }
948
+ _onInputHEX(t) {
949
+ const e = d.HEXtoRGBA(
950
+ t.target.value.trim()
951
+ );
952
+ if (e != null) {
953
+ const { r: o, g: i, b: s, a: r } = e;
954
+ this._color.a = r, this._color.rgb = { r: o, g: i, b: s }, this._color.hex = d.RGBAtoHEX(o, i, s, r), this._color.hsv = d.RGBtoHSV(o, i, s), this._updateColorPreview(!0), this._updateHueThumb(), this._updateOpacityThumb(), this._updateCursorThumb();
955
+ }
956
+ }
957
+ _onChangeInputHEX(t) {
958
+ t.target.value = this._color.hex;
959
+ }
960
+ _onKeyDownInputA(t) {
961
+ const { target: e, key: o } = t;
962
+ switch (o) {
963
+ case "ArrowUp":
964
+ switch (this._currentRepresentation) {
965
+ case "rgb":
966
+ {
967
+ let { r: i, g: s, b: r } = this._color.getRGB();
968
+ i < 255 && (this._color.rgb.r = parseInt(
969
+ e.value = (++i).toString()
970
+ ), this._color.hsv = d.RGBtoHSV(i, s, r), this._rgbUpdateView());
971
+ }
972
+ break;
973
+ case "hsv":
974
+ case "hsl":
975
+ {
976
+ let { h: i } = this._color.hsv;
977
+ i = p(i, 0, 360), i < 360 && (e.value = ++i + "°", this._color.hsv.h = this._color.hsl.h = i, this._updateColorPreview(!0), this._updateHueThumb());
978
+ }
979
+ break;
980
+ }
981
+ break;
982
+ case "ArrowDown":
983
+ switch (this._currentRepresentation) {
984
+ case "rgb":
985
+ {
986
+ let { r: i, g: s, b: r } = this._color.getRGB();
987
+ i > 0 && (this._color.rgb.r = parseInt(
988
+ e.value = (--i).toString()
989
+ ), this._color.hsv = d.RGBtoHSV(i, s, r), this._rgbUpdateView());
990
+ }
991
+ break;
992
+ case "hsv":
993
+ case "hsl":
994
+ {
995
+ let { h: i } = this._color.hsv;
996
+ i = p(i, 0, 360), i > 0 && (e.value = --i + "°", this._color.hsv.h = this._color.hsl.h = i, this._updateColorPreview(!0), this._updateHueThumb());
997
+ }
998
+ break;
999
+ }
1000
+ break;
1001
+ }
1002
+ }
1003
+ _onInputA(t) {
1004
+ const e = parseInt(t.target.value || "0");
1005
+ if (/^(\d{1,3})(°?)$/.test(e.toString()))
1006
+ switch (this._currentRepresentation) {
1007
+ case "rgb":
1008
+ {
1009
+ const { g: o, b: i } = this._color.getRGB();
1010
+ !isNaN(e) && e >= 0 && e <= 255 && (this._color.rgb.r = e, this._color.hsv = d.RGBtoHSV(e, o, i), this._updateColorPreview(!0), this._updateHueThumb(), this._updateCursorThumb());
1011
+ }
1012
+ break;
1013
+ case "hsv":
1014
+ case "hsl":
1015
+ !isNaN(e) && e >= 0 && e <= 360 && (this._color.hsv.h = this._color.hsl.h = e, this._updateColorPreview(!0), this._updateHueThumb());
1016
+ break;
1017
+ }
1018
+ }
1019
+ _onChangeInputA(t) {
1020
+ let e = t.target.value;
1021
+ switch (this._currentRepresentation) {
1022
+ case "rgb":
1023
+ e = p(this._color.rgb.r, 0, 255).toString();
1024
+ break;
1025
+ case "hsv":
1026
+ case "hsl":
1027
+ e = `${this._color.getHSV().h}°`;
1028
+ break;
1029
+ }
1030
+ t.target.value = e;
1031
+ }
1032
+ _onKeyDownInputB(t) {
1033
+ const { target: e, key: o } = t;
1034
+ switch (o) {
1035
+ case "ArrowUp":
1036
+ switch (this._currentRepresentation) {
1037
+ case "rgb":
1038
+ {
1039
+ let { r: i, g: s, b: r } = this._color.getRGB();
1040
+ s < 255 && (this._color.rgb.g = parseInt(
1041
+ e.value = (++s).toString()
1042
+ ), this._color.hsv = d.RGBtoHSV(i, s, r), this._rgbUpdateView());
1043
+ }
1044
+ break;
1045
+ case "hsv":
1046
+ {
1047
+ let { s: i } = this._color.getHSV();
1048
+ i < 100 && (e.value = ++i + "%", this._color.hsv.s = i, this._updateColorPreview(!0), this._updateCursorThumb());
1049
+ }
1050
+ break;
1051
+ case "hsl":
1052
+ {
1053
+ const { h: i, s, l: r } = this._color.getHSL();
1054
+ let h = s;
1055
+ h < 100 && (++h, this._color.hsl.s = h, this._color.hsv = d.HSLtoHSV(i, h, r), this._color.hsl.l = this.getHSL().l, this._updateColorPreview(!0), this._updateCursorThumb(), e.value = h + "%", this._dom.inputC.value = this._color.hsl.l + "%");
1056
+ }
1057
+ break;
1058
+ }
1059
+ break;
1060
+ case "ArrowDown":
1061
+ switch (this._currentRepresentation) {
1062
+ case "rgb":
1063
+ {
1064
+ let { r: i, g: s, b: r } = this._color.getRGB();
1065
+ s > 0 && (this._color.rgb.g = parseInt(
1066
+ e.value = (--s).toString()
1067
+ ), this._color.hsv = d.RGBtoHSV(i, s, r), this._rgbUpdateView());
1068
+ }
1069
+ break;
1070
+ case "hsv":
1071
+ {
1072
+ let { s: i } = this._color.getHSV();
1073
+ i > 0 && (e.value = --i + "%", this._color.hsv.s = i, this._updateColorPreview(!0), this._updateCursorThumb());
1074
+ }
1075
+ break;
1076
+ case "hsl":
1077
+ {
1078
+ const { h: i, s, l: r } = this._color.getHSL();
1079
+ let h = s;
1080
+ h > 0 && (--h, this._color.hsl.s = h, this._color.hsv = d.HSLtoHSV(i, h, r), this._color.hsl.l = this.getHSL().l, this._updateColorPreview(!0), this._updateCursorThumb(), e.value = h + "%", this._dom.inputC.value = this._color.hsl.l + "%");
1081
+ }
1082
+ break;
1083
+ }
1084
+ break;
1085
+ }
1086
+ }
1087
+ _onInputB(t) {
1088
+ const e = parseInt(t.target.value || "0");
1089
+ if (/^(\d{1,3})(%?)$/.test(e.toString()))
1090
+ switch (this._currentRepresentation) {
1091
+ case "rgb":
1092
+ {
1093
+ const { r: o, b: i } = this._color.getRGB();
1094
+ !isNaN(e) && e >= 0 && e <= 255 && (this._color.rgb.g = e, this._color.hsv = d.RGBtoHSV(o, e, i), this._updateColorPreview(!0), this._updateHueThumb(), this._updateCursorThumb());
1095
+ }
1096
+ break;
1097
+ case "hsv":
1098
+ !isNaN(e) && e >= 0 && e <= 100 && (this._color.hsv.s = e, this._updateColorPreview(!0), this._updateCursorThumb());
1099
+ break;
1100
+ case "hsl":
1101
+ {
1102
+ const { h: o, l: i } = this._color.getHSL();
1103
+ !isNaN(e) && e >= 0 && e <= 100 && (this._color.hsv = d.HSLtoHSV(o, e, i), this._color.hsl = this._color.toHSL(), this._updateColorPreview(!0), this._updateCursorThumb(), this._dom.inputC.value = Math.round(this._color.hsl.l) + "%");
1104
+ }
1105
+ break;
1106
+ }
1107
+ }
1108
+ _onChangeInputB(t) {
1109
+ let e = t.target.value;
1110
+ switch (this._currentRepresentation) {
1111
+ case "rgb":
1112
+ e = this._color.getRGB().g;
1113
+ break;
1114
+ case "hsv":
1115
+ e = `${this._color.getHSV().s}%`;
1116
+ break;
1117
+ case "hsl":
1118
+ e = `${this._color.getHSL().s}%`;
1119
+ break;
1120
+ }
1121
+ t.target.value = e;
1122
+ }
1123
+ _onKeyDownInputC(t) {
1124
+ const { target: e, key: o } = t;
1125
+ switch (o) {
1126
+ case "ArrowUp":
1127
+ switch (this._currentRepresentation) {
1128
+ case "rgb":
1129
+ {
1130
+ let { r: i, g: s, b: r } = this._color.getRGB();
1131
+ r < 255 && (this._color.rgb.b = parseInt(
1132
+ e.value = (++r).toString()
1133
+ ), this._color.hsv = d.RGBtoHSV(i, s, r), this._rgbUpdateView());
1134
+ }
1135
+ break;
1136
+ case "hsv":
1137
+ {
1138
+ let { v: i } = this._color.getHSV();
1139
+ i < 100 && (e.value = ++i + "%", this._color.hsv.v = i, this._updateColorPreview(!0), this._updateCursorThumb());
1140
+ }
1141
+ break;
1142
+ case "hsl":
1143
+ {
1144
+ const { h: i, s, l: r } = this._color.getHSL();
1145
+ let h = r;
1146
+ h < 100 && (++h, this._color.hsl.l = h, this._color.hsv = d.HSLtoHSV(i, s, h), this._color.hsl.s = this.getHSL().s, this._updateColorPreview(!0), this._updateCursorThumb(), e.value = h + "%", this._dom.inputB.value = this._color.hsl.s + "%");
1147
+ }
1148
+ break;
1149
+ }
1150
+ break;
1151
+ case "ArrowDown":
1152
+ switch (this._currentRepresentation) {
1153
+ case "rgb":
1154
+ {
1155
+ let { r: i, g: s, b: r } = this._color.getRGB();
1156
+ r > 0 && (this._color.rgb.b = parseInt(
1157
+ e.value = (--r).toString()
1158
+ ), this._color.hsv = d.RGBtoHSV(i, s, r), this._rgbUpdateView());
1159
+ }
1160
+ break;
1161
+ case "hsv":
1162
+ {
1163
+ let { v: i } = this._color.getHSV();
1164
+ i > 0 && (e.value = --i + "%", this._color.hsv.v = i, this._updateColorPreview(!0), this._updateCursorThumb());
1165
+ }
1166
+ break;
1167
+ case "hsl":
1168
+ {
1169
+ const { h: i, s, l: r } = this._color.getHSL();
1170
+ let h = r;
1171
+ r > 0 && (--h, this._color.hsl.l = h, this._color.hsv = d.HSLtoHSV(i, s, h), this._color.hsl.s = this.getHSL().s, this._updateColorPreview(!0), this._updateCursorThumb(), e.value = h + "%", this._dom.inputB.value = this._color.hsl.s + "%");
1172
+ }
1173
+ break;
1174
+ }
1175
+ break;
1176
+ }
1177
+ }
1178
+ _onInputC(t) {
1179
+ const e = parseInt(t.target.value || "0");
1180
+ if (/^(\d{1,3})(%?)$/.test(e.toString()))
1181
+ switch (this._currentRepresentation) {
1182
+ case "rgb":
1183
+ {
1184
+ const { r: o, g: i } = this._color.getRGB();
1185
+ !isNaN(e) && e >= 0 && e <= 255 && (this._color.rgb.b = e, this._color.hsv = d.RGBtoHSV(o, i, e), this._updateColorPreview(!0), this._updateHueThumb(), this._updateCursorThumb());
1186
+ }
1187
+ break;
1188
+ case "hsv":
1189
+ !isNaN(e) && e >= 0 && e <= 100 && (this._color.hsv.v = e, this._updateColorPreview(!0), this._updateCursorThumb());
1190
+ break;
1191
+ case "hsl":
1192
+ {
1193
+ const { h: o, s: i } = this._color.getHSL();
1194
+ !isNaN(e) && e >= 0 && e <= 100 && (this._color.hsv = d.HSLtoHSV(o, i, e), this._color.hsl = this._color.toHSL(), this._updateColorPreview(!0), this._updateCursorThumb(), this._dom.inputB.value = Math.round(this._color.hsl.s) + "%");
1195
+ }
1196
+ break;
1197
+ }
1198
+ }
1199
+ _onChangeInputC(t) {
1200
+ let e = t.target.value;
1201
+ switch (this._currentRepresentation) {
1202
+ case "rgb":
1203
+ e = this._color.getRGB().b;
1204
+ break;
1205
+ case "hsv":
1206
+ e = `${this._color.getHSV().v}%`;
1207
+ break;
1208
+ case "hsl":
1209
+ e = `${this._color.getHSL().l}%`;
1210
+ break;
1211
+ }
1212
+ t.target.value = e;
1213
+ }
1214
+ _onClickCopyColor() {
1215
+ this._copyTimeout && clearTimeout(this._copyTimeout);
1216
+ const t = document.createElement("input");
1217
+ t.style.position = "absolute", t.style.left = "-99999px", t.style.top = "-99999px", t.value = this._getColorText() || "", document.body.appendChild(t), t.select();
1218
+ try {
1219
+ document.execCommand("copy"), this._attachCheckIcon(), this._dom.copyColor.focus(), this._options.onCopy(this), this._copyTimeout = setTimeout(() => {
1220
+ this._attachCopyIcon(), this._copyTimeout = null;
1221
+ }, 600);
1222
+ } catch (e) {
1223
+ throw document.body.removeChild(t), new Error(`YKColorPicker:: Failed to copy color.
1224
+ ` + e);
1225
+ }
1226
+ }
1227
+ _onMouseDownHueSlider(t) {
1228
+ t.preventDefault(), this._dc = !0, l(document, "pointermove", this._onMouseMoveHueSliderBind), l(document, "pointerup", this._onMouseUpHueSliderBind), this._dom.hueThumb.focus(), this._onMouseMoveHueSliderBind(t);
1229
+ }
1230
+ _onMouseUpHueSlider(t) {
1231
+ document.removeEventListener("pointermove", this._onMouseMoveHueSliderBind), document.removeEventListener("pointerup", this._onMouseUpHueSliderBind), this._dom.overlayWrapper.contains(t.target) && (this._dc = !1);
1232
+ }
1233
+ _onMouseMoveHueSlider(t) {
1234
+ const { hueSlider: e, hueThumb: o } = this._dom, i = e.getBoundingClientRect(), s = i.width;
1235
+ let r = t.clientX - i.left;
1236
+ r < 0 && (r = 0), r > s && (r = s), this._color.hsv.h = r / i.width * 360, o.style.translate = `${r}px`, this._updateSettingsView();
1237
+ }
1238
+ _onMouseDownOpacitySlider(t) {
1239
+ t.preventDefault(), this._dc = !0, l(document, "pointermove", this._onMouseMoveOpacitySliderBind), l(document, "pointerup", this._onMouseUpOpacitySliderBind), this._dom.opacityThumb.focus(), this._onMouseMoveOpacitySliderBind(t);
1240
+ }
1241
+ _onMouseUpOpacitySlider(t) {
1242
+ document.removeEventListener(
1243
+ "pointermove",
1244
+ this._onMouseMoveOpacitySliderBind
1245
+ ), document.removeEventListener("pointerup", this._onMouseUpOpacitySliderBind), this._dom.overlayWrapper.contains(t.target) && (this._dc = !1);
1246
+ }
1247
+ _onMouseMoveOpacitySlider(t) {
1248
+ const { opacitySlider: e, opacityThumb: o } = this._dom, i = e.getBoundingClientRect(), s = i.width;
1249
+ let r = t.clientX - i.left;
1250
+ o.focus(), r < 0 && (r = 0), r > s && (r = s), o.style.translate = `${r}px`, this._updateOpacityValue(r / s);
1251
+ }
1252
+ _onKeyDownHueSlider(t) {
1253
+ const { key: e } = t;
1254
+ switch (e) {
1255
+ case "ArrowUp":
1256
+ case "ArrowRight":
1257
+ {
1258
+ const { hueThumb: o, hueSlider: i } = this._dom;
1259
+ let s = parseInt(o.style.translate);
1260
+ !isNaN(s) && s < i.offsetWidth && (o.style.translate = `${++s}px`, this._color.hsv.h = s / i.offsetWidth * 360, this._updateSettingsView()), t.preventDefault();
1261
+ }
1262
+ break;
1263
+ case "ArrowDown":
1264
+ case "ArrowLeft":
1265
+ {
1266
+ const { hueThumb: o, hueSlider: i } = this._dom;
1267
+ let s = parseInt(o.style.translate);
1268
+ !isNaN(s) && s > 0 && (o.style.translate = `${--s}px`, this._color.hsv.h = s / i.offsetWidth * 360, this._updateSettingsView()), t.preventDefault();
1269
+ }
1270
+ break;
1271
+ }
1272
+ }
1273
+ _onKeyDownOpacitySlider(t) {
1274
+ const { key: e } = t;
1275
+ switch (e) {
1276
+ case "ArrowUp":
1277
+ case "ArrowRight":
1278
+ {
1279
+ const { opacityThumb: o, opacitySlider: i } = this._dom;
1280
+ let s = parseInt(o.style.translate);
1281
+ !isNaN(s) && s < i.offsetWidth && (o.style.translate = `${++s}px`, this._updateOpacityValue(s / i.offsetWidth)), t.preventDefault();
1282
+ }
1283
+ break;
1284
+ case "ArrowDown":
1285
+ case "ArrowLeft":
1286
+ {
1287
+ const { opacityThumb: o, opacitySlider: i } = this._dom;
1288
+ let s = parseInt(o.style.translate);
1289
+ !isNaN(s) && s > 0 && (o.style.translate = `${--s}px`, this._updateOpacityValue(s / i.offsetWidth)), t.preventDefault();
1290
+ }
1291
+ break;
1292
+ }
1293
+ }
1294
+ _onKeyUpClose(t) {
1295
+ const { target: e, key: o } = t;
1296
+ if (this._targetKeydownOpen && o == "Enter") {
1297
+ this._targetKeydownOpen = !1;
1298
+ return;
1299
+ }
1300
+ if (o == "Enter" && this._isOpen && ![this._dom.copyColor, this._dom.btnSwitch].includes(e)) {
1301
+ this.close();
1302
+ return;
1303
+ }
1304
+ o == "Escape" && (this._prevColor != this.getHEX() && this.setColor(this._prevColor), this.close());
1305
+ }
1306
+ _onResizeScrollWindow(t) {
1307
+ const { type: e } = t, { target: o } = this._dom;
1308
+ if (o == null)
1309
+ return;
1310
+ const { closeOnScroll: i, closeOnResize: s } = this._options;
1311
+ if (e == "scroll" && i || e == "resize" && s)
1312
+ this.close();
1313
+ else {
1314
+ if (!a._isTargetInViewport(o)) {
1315
+ this.close();
1316
+ return;
1317
+ }
1318
+ this._setPositionAxis(this._getPositionAxis());
1319
+ }
1320
+ }
1321
+ _removeWindowEvents() {
1322
+ window.removeEventListener("resize", this._onResizeScrollWindowBind), window.removeEventListener("scroll", this._onResizeScrollWindowBind), document.removeEventListener("keyup", this._onKeyUpCloseBind), document.removeEventListener("click", this._onClickCloseBind);
1323
+ }
1324
+ _getCursorPosition(t, e) {
1325
+ const o = this._dom.palette.getBoundingClientRect();
1326
+ let i = t - o.left, s = e - o.top;
1327
+ return i < 0 ? i = 0 : i > o.width && (i = o.width), s < 0 ? s = 0 : s > o.height && (s = o.height), {
1328
+ x: i,
1329
+ y: s
1330
+ };
1331
+ }
1332
+ _updateHEXColor() {
1333
+ const { r: t, g: e, b: o } = this._color.rgb = this._color.toRGB();
1334
+ this._color.hex = d.RGBAtoHEX(t, e, o, this._color.a);
1335
+ }
1336
+ _getColorText() {
1337
+ switch (this._currentRepresentation) {
1338
+ case "rgb":
1339
+ const { r: t, g: e, b: o } = this._color.getRGB();
1340
+ return `rgba(${t}, ${e}, ${o}, ${this._color.a})`;
1341
+ case "hsv": {
1342
+ const { h: i, s, v: r } = this._color.getHSV();
1343
+ return `hsva(${i}, ${s}%, ${r}%, ${this._color.a})`;
1344
+ }
1345
+ case "hsl": {
1346
+ const { h: i, s, l: r } = this._color.getHSL();
1347
+ return `hsla(${i}, ${s}%, ${r}%, ${this._color.a})`;
1348
+ }
1349
+ case "hex":
1350
+ return this.getHEX();
1351
+ }
1352
+ }
1353
+ _getCaretPosition(t) {
1354
+ let e = t.selectionStart || 0;
1355
+ const o = t.value.length;
1356
+ return e > o && (e = o), e;
1357
+ }
1358
+ _getPositionAxis() {
1359
+ const { position: t, positionFallback: e } = this._options, { target: o } = this._dom;
1360
+ if (!o || !t || !e)
1361
+ return { x: 0, y: 0 };
1362
+ const i = o.getBoundingClientRect(), s = this._dom.overlayWrapper.getBoundingClientRect(), r = document.documentElement.scrollTop, h = document.documentElement.scrollLeft, u = 6;
1363
+ let _ = t;
1364
+ const g = a._enoughSpace(
1365
+ () => r + i.top,
1366
+ () => i.top,
1367
+ s.height + u
1368
+ ), k = a._enoughSpace(
1369
+ () => a._getPageHeight() - (r + i.top + i.height),
1370
+ () => window.innerHeight - (i.top + i.height),
1371
+ s.height + u
1372
+ ), S = a._enoughSpace(
1373
+ () => h + i.left,
1374
+ () => i.left,
1375
+ s.width + u
1376
+ ), H = a._enoughSpace(
1377
+ () => a._getPageWidth() - (h + i.left + i.width),
1378
+ () => window.innerWidth - (i.left + i.width),
1379
+ s.width + u
1380
+ ), x = {
1381
+ t: g,
1382
+ b: k,
1383
+ l: S,
1384
+ r: H
1385
+ };
1386
+ let f = "";
1387
+ for (let v = 0; v < e.length; v++)
1388
+ f += e[v] + x[e[v]];
1389
+ let y = "", C = "";
1390
+ for (let v = 1; v < f.length; v += 2) {
1391
+ const R = f[v];
1392
+ R == "2" && (y = y + f[v - 1]), R == "1" && (C = C + f[v - 1]);
1393
+ }
1394
+ y != "" ? y.includes(_) == !1 && (_ = y[0]) : C != "" ? C.includes(_) == !1 && (_ = C[0]) : _ = "b";
1395
+ let b = 0, m = 0;
1396
+ switch (_) {
1397
+ case "t":
1398
+ m = i.top - s.height - u, b = i.left + i.width / 2 - s.width / 2;
1399
+ break;
1400
+ case "b":
1401
+ m = i.top + i.height + u, b = i.left + i.width / 2 - s.width / 2;
1402
+ break;
1403
+ case "l":
1404
+ m = i.top + i.height / 2 - s.height / 2, b = i.left - s.width - u;
1405
+ break;
1406
+ case "r":
1407
+ m = i.top + i.height / 2 - s.height / 2, b = i.left + i.width + u;
1408
+ break;
1409
+ }
1410
+ const E = window.innerWidth - document.documentElement.clientWidth, B = window.innerHeight - document.documentElement.clientHeight;
1411
+ return window.innerWidth - E < b + s.width && (b -= b + s.width - window.innerWidth + E), window.innerHeight - B < m + s.height && (m -= m + s.height - window.innerHeight + B), b = Math.max(b, 0), m = Math.max(m, 0), {
1412
+ x: b,
1413
+ y: m
1414
+ };
1415
+ }
1416
+ _setPositionAxis(t) {
1417
+ const { x: e, y: o } = t;
1418
+ this._dom.overlayWrapper.style.top = `${o}px`, this._dom.overlayWrapper.style.left = `${e}px`;
1419
+ }
1420
+ _updateRepresentation(t) {
1421
+ this._currentRepresentation = t, this._updateInputs(), this._options.onRepresentationChange && this._options.onRepresentationChange(this);
1422
+ }
1423
+ _updateTheme(t) {
1424
+ if (this._dom.overlayWrapper.classList.remove(
1425
+ "yk-overlay-wrapper--light",
1426
+ "yk-overlay-wrapper--dark"
1427
+ ), t !== "light" && t !== "dark")
1428
+ throw new Error("YKColorPicker:: Theme must be light or dark");
1429
+ this._dom.overlayWrapper.classList.add(`yk-overlay-wrapper--${t}`);
1430
+ }
1431
+ _updateTarget(t) {
1432
+ let e = null;
1433
+ if (typeof t == "string")
1434
+ e = document.querySelector(t);
1435
+ else if (t && t.nodeType == Node.ELEMENT_NODE)
1436
+ e = t;
1437
+ else if (t != null)
1438
+ throw new Error(
1439
+ "YKColorPicker:: target must be a string or an HTMLElement"
1440
+ );
1441
+ const o = this._dom.target;
1442
+ o != null && o.removeEventListener("click", this._onClickTargetBind), this._dom.target = e, this._dom.target != null && l(this._dom.target, "click", this._onClickTargetBind), this._updatePosition(), this._options.onTargetChange(this, o);
1443
+ }
1444
+ static _isTargetInViewport(t) {
1445
+ if (!t)
1446
+ return !1;
1447
+ const e = t.getBoundingClientRect();
1448
+ return e.top >= 0 && e.left >= 0 && e.bottom <= (window.innerHeight || document.documentElement.clientHeight) && e.right <= (window.innerWidth || document.documentElement.clientWidth);
1449
+ }
1450
+ static _getPageHeight() {
1451
+ return Math.max(
1452
+ document.body.scrollHeight,
1453
+ document.documentElement.scrollHeight,
1454
+ document.body.offsetHeight,
1455
+ document.documentElement.offsetHeight,
1456
+ document.body.clientHeight,
1457
+ document.documentElement.clientHeight
1458
+ );
1459
+ }
1460
+ static _getPageWidth() {
1461
+ return Math.max(
1462
+ document.body.scrollWidth,
1463
+ document.documentElement.scrollWidth,
1464
+ document.body.offsetWidth,
1465
+ document.documentElement.offsetWidth,
1466
+ document.body.clientWidth,
1467
+ document.documentElement.clientWidth
1468
+ );
1469
+ }
1470
+ static _enoughSpace(t, e, o) {
1471
+ return t() >= o ? e() >= o ? 2 : 1 : 0;
1472
+ }
1473
+ static _buildOptions(t, e) {
1474
+ const o = {}, i = Object.keys(t);
1475
+ for (let s = 0; s < i.length; s++) {
1476
+ const r = i[s];
1477
+ e.hasOwnProperty(r) == !0 ? o[r] = e[r] : o[r] = t[r];
1478
+ }
1479
+ return o;
1480
+ }
1481
+ static _lt(t, e) {
1482
+ return t < e;
1483
+ }
1484
+ static _gt(t, e) {
1485
+ return t > e;
1486
+ }
1487
+ static _add(t, e) {
1488
+ return t + e;
1489
+ }
1490
+ static _sub(t, e) {
1491
+ return t - e;
1492
+ }
1493
+ };
1494
+ a.DEFAULT_OPTIONS = {
1495
+ target: null,
1496
+ container: null,
1497
+ position: "b",
1498
+ positionFallback: "btrl",
1499
+ representation: "rgb",
1500
+ color: "red",
1501
+ closeOnScroll: !0,
1502
+ closeOnResize: !1,
1503
+ theme: "light",
1504
+ onInit: () => {
1505
+ },
1506
+ onOpen: () => {
1507
+ },
1508
+ onClose: () => {
1509
+ },
1510
+ onInput: () => {
1511
+ },
1512
+ onChange: () => {
1513
+ },
1514
+ onCopy: () => {
1515
+ },
1516
+ onRepresentationChange: () => {
1517
+ },
1518
+ onTargetChange: () => {
1519
+ },
1520
+ onContainerChange: () => {
1521
+ }
1522
+ };
1523
+ let I = a;
1524
+ export {
1525
+ I as YKColorPicker,
1526
+ A as YKColorPickerMode,
1527
+ M as YKColorPickerPosition
1528
+ };
1529
+ //# sourceMappingURL=yk-color-picker.js.map