wj-elements 0.7.7 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/animations.js +28 -51
  2. package/dist/animations.js.map +1 -1
  3. package/dist/base-path.js +19 -31
  4. package/dist/base-path.js.map +1 -1
  5. package/dist/custom-elements.json +11504 -11499
  6. package/dist/dark.css +1 -302
  7. package/dist/date.js +16 -36
  8. package/dist/date.js.map +1 -1
  9. package/dist/element-utils.js +20 -81
  10. package/dist/element-utils.js.map +1 -1
  11. package/dist/event.js +49 -165
  12. package/dist/event.js.map +1 -1
  13. package/dist/form-associated-element-BjeJn7j8.js +101 -0
  14. package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
  15. package/dist/icon-DmsqtDpL.js +102 -0
  16. package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
  17. package/dist/light.css +1 -731
  18. package/dist/localize.js +36 -111
  19. package/dist/localize.js.map +1 -1
  20. package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
  21. package/dist/permissions.js +14 -41
  22. package/dist/permissions.js.map +1 -1
  23. package/dist/popup.element-CbkhthPP.js +806 -0
  24. package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
  25. package/dist/router-links-CNsJ-elb.js +105 -0
  26. package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
  27. package/dist/skeleton.css +1 -197
  28. package/dist/styles.css +1 -866
  29. package/dist/universal-service.js +48 -109
  30. package/dist/universal-service.js.map +1 -1
  31. package/dist/utils.js +11 -18
  32. package/dist/utils.js.map +1 -1
  33. package/dist/web-types.json +760 -760
  34. package/dist/wje-accordion-item.js +33 -106
  35. package/dist/wje-accordion-item.js.map +1 -1
  36. package/dist/wje-accordion.js +19 -84
  37. package/dist/wje-accordion.js.map +1 -1
  38. package/dist/wje-animation.js +37 -4258
  39. package/dist/wje-animation.js.map +1 -1
  40. package/dist/wje-aside.js +9 -34
  41. package/dist/wje-aside.js.map +1 -1
  42. package/dist/wje-avatar.js +36 -126
  43. package/dist/wje-avatar.js.map +1 -1
  44. package/dist/wje-badge.js +10 -52
  45. package/dist/wje-badge.js.map +1 -1
  46. package/dist/wje-breadcrumb.js +205 -672
  47. package/dist/wje-breadcrumb.js.map +1 -1
  48. package/dist/wje-breadcrumbs.js +177 -633
  49. package/dist/wje-breadcrumbs.js.map +1 -1
  50. package/dist/wje-button-group.js +48 -153
  51. package/dist/wje-button-group.js.map +1 -1
  52. package/dist/wje-button.js +92 -413
  53. package/dist/wje-button.js.map +1 -1
  54. package/dist/wje-card-content.js +7 -30
  55. package/dist/wje-card-content.js.map +1 -1
  56. package/dist/wje-card-controls.js +7 -30
  57. package/dist/wje-card-controls.js.map +1 -1
  58. package/dist/wje-card-header.js +7 -30
  59. package/dist/wje-card-header.js.map +1 -1
  60. package/dist/wje-card-subtitle.js +7 -34
  61. package/dist/wje-card-subtitle.js.map +1 -1
  62. package/dist/wje-card-title.js +7 -34
  63. package/dist/wje-card-title.js.map +1 -1
  64. package/dist/wje-card.js +15 -71
  65. package/dist/wje-card.js.map +1 -1
  66. package/dist/wje-carousel-item.js +12 -56
  67. package/dist/wje-carousel-item.js.map +1 -1
  68. package/dist/wje-carousel.js +154 -509
  69. package/dist/wje-carousel.js.map +1 -1
  70. package/dist/wje-checkbox.js +50 -227
  71. package/dist/wje-checkbox.js.map +1 -1
  72. package/dist/wje-chip.js +43 -160
  73. package/dist/wje-chip.js.map +1 -1
  74. package/dist/wje-col.js +7 -20
  75. package/dist/wje-col.js.map +1 -1
  76. package/dist/wje-color-picker.js +445 -1464
  77. package/dist/wje-color-picker.js.map +1 -1
  78. package/dist/wje-container.js +9 -35
  79. package/dist/wje-container.js.map +1 -1
  80. package/dist/wje-copy-button.js +64 -204
  81. package/dist/wje-copy-button.js.map +1 -1
  82. package/dist/wje-dialog.js +85 -553
  83. package/dist/wje-dialog.js.map +1 -1
  84. package/dist/wje-divider.js +7 -34
  85. package/dist/wje-divider.js.map +1 -1
  86. package/dist/wje-dropdown.js +78 -305
  87. package/dist/wje-dropdown.js.map +1 -1
  88. package/dist/wje-element.js +191 -700
  89. package/dist/wje-element.js.map +1 -1
  90. package/dist/wje-file-upload-item.js +51 -156
  91. package/dist/wje-file-upload-item.js.map +1 -1
  92. package/dist/wje-file-upload.js +181 -619
  93. package/dist/wje-file-upload.js.map +1 -1
  94. package/dist/wje-footer.js +7 -31
  95. package/dist/wje-footer.js.map +1 -1
  96. package/dist/wje-form.js +7 -32
  97. package/dist/wje-form.js.map +1 -1
  98. package/dist/wje-format-digital.js +26 -118
  99. package/dist/wje-format-digital.js.map +1 -1
  100. package/dist/wje-grid.js +7 -33
  101. package/dist/wje-grid.js.map +1 -1
  102. package/dist/wje-header.js +9 -35
  103. package/dist/wje-header.js.map +1 -1
  104. package/dist/wje-icon-library.js +12 -18
  105. package/dist/wje-icon-library.js.map +1 -1
  106. package/dist/wje-icon-picker.js +65 -320
  107. package/dist/wje-icon-picker.js.map +1 -1
  108. package/dist/wje-icon.js +1 -1
  109. package/dist/wje-img-comparer.js +37 -114
  110. package/dist/wje-img-comparer.js.map +1 -1
  111. package/dist/wje-img.js +50 -198
  112. package/dist/wje-img.js.map +1 -1
  113. package/dist/wje-infinite-scroll.js +94 -346
  114. package/dist/wje-infinite-scroll.js.map +1 -1
  115. package/dist/wje-input-file.js +23 -84
  116. package/dist/wje-input-file.js.map +1 -1
  117. package/dist/wje-input.js +78 -392
  118. package/dist/wje-input.js.map +1 -1
  119. package/dist/wje-item.js +11 -64
  120. package/dist/wje-item.js.map +1 -1
  121. package/dist/wje-kanban.js +124 -401
  122. package/dist/wje-kanban.js.map +1 -1
  123. package/dist/wje-label.js +9 -32
  124. package/dist/wje-label.js.map +1 -1
  125. package/dist/wje-level-indicator.js +38 -157
  126. package/dist/wje-level-indicator.js.map +1 -1
  127. package/dist/wje-list.js +10 -40
  128. package/dist/wje-list.js.map +1 -1
  129. package/dist/wje-main.js +7 -31
  130. package/dist/wje-main.js.map +1 -1
  131. package/dist/wje-masonry.js +66 -211
  132. package/dist/wje-masonry.js.map +1 -1
  133. package/dist/wje-master.js +45 -161
  134. package/dist/wje-master.js.map +1 -1
  135. package/dist/wje-menu-button.js +10 -38
  136. package/dist/wje-menu-button.js.map +1 -1
  137. package/dist/wje-menu-item.js +127 -577
  138. package/dist/wje-menu-item.js.map +1 -1
  139. package/dist/wje-menu-label.js +9 -35
  140. package/dist/wje-menu-label.js.map +1 -1
  141. package/dist/wje-menu.js +14 -49
  142. package/dist/wje-menu.js.map +1 -1
  143. package/dist/wje-option.js +48 -279
  144. package/dist/wje-option.js.map +1 -1
  145. package/dist/wje-options.js +130 -384
  146. package/dist/wje-options.js.map +1 -1
  147. package/dist/wje-orgchart-group.js +16 -52
  148. package/dist/wje-orgchart-group.js.map +1 -1
  149. package/dist/wje-orgchart-item.js +24 -93
  150. package/dist/wje-orgchart-item.js.map +1 -1
  151. package/dist/wje-orgchart.js +18 -68
  152. package/dist/wje-orgchart.js.map +1 -1
  153. package/dist/wje-pagination.js +113 -397
  154. package/dist/wje-pagination.js.map +1 -1
  155. package/dist/wje-popup.js +3 -3
  156. package/dist/wje-popup.js.map +1 -1
  157. package/dist/wje-progress-bar.js +53 -205
  158. package/dist/wje-progress-bar.js.map +1 -1
  159. package/dist/wje-qr-code.js +398 -2980
  160. package/dist/wje-qr-code.js.map +1 -1
  161. package/dist/wje-radio-group.js +52 -190
  162. package/dist/wje-radio-group.js.map +1 -1
  163. package/dist/wje-radio.js +24 -118
  164. package/dist/wje-radio.js.map +1 -1
  165. package/dist/wje-rate.js +62 -266
  166. package/dist/wje-rate.js.map +1 -1
  167. package/dist/wje-relative-time.js +24 -99
  168. package/dist/wje-relative-time.js.map +1 -1
  169. package/dist/wje-reorder-dropzone.js +9 -31
  170. package/dist/wje-reorder-dropzone.js.map +1 -1
  171. package/dist/wje-reorder-handle.js +67 -204
  172. package/dist/wje-reorder-handle.js.map +1 -1
  173. package/dist/wje-reorder-item.js +14 -44
  174. package/dist/wje-reorder-item.js.map +1 -1
  175. package/dist/wje-reorder.js +61 -246
  176. package/dist/wje-reorder.js.map +1 -1
  177. package/dist/wje-route.js +6 -24
  178. package/dist/wje-route.js.map +1 -1
  179. package/dist/wje-router-link.js +11 -39
  180. package/dist/wje-router-link.js.map +1 -1
  181. package/dist/wje-router-outlet.js +76 -172
  182. package/dist/wje-router-outlet.js.map +1 -1
  183. package/dist/wje-routerx.js +537 -1331
  184. package/dist/wje-routerx.js.map +1 -1
  185. package/dist/wje-row.js +9 -31
  186. package/dist/wje-row.js.map +1 -1
  187. package/dist/wje-select.js +326 -1152
  188. package/dist/wje-select.js.map +1 -1
  189. package/dist/wje-slider.js +44 -225
  190. package/dist/wje-slider.js.map +1 -1
  191. package/dist/wje-sliding-container.js +295 -1319
  192. package/dist/wje-sliding-container.js.map +1 -1
  193. package/dist/wje-split-view.js +35 -121
  194. package/dist/wje-split-view.js.map +1 -1
  195. package/dist/wje-status.js +14 -45
  196. package/dist/wje-status.js.map +1 -1
  197. package/dist/wje-step.js +9 -32
  198. package/dist/wje-step.js.map +1 -1
  199. package/dist/wje-stepper.js +109 -357
  200. package/dist/wje-stepper.js.map +1 -1
  201. package/dist/wje-store.js +67 -360
  202. package/dist/wje-store.js.map +1 -1
  203. package/dist/wje-tab-group.js +85 -314
  204. package/dist/wje-tab-group.js.map +1 -1
  205. package/dist/wje-tab-panel.js +7 -28
  206. package/dist/wje-tab-panel.js.map +1 -1
  207. package/dist/wje-tab.js +21 -198
  208. package/dist/wje-tab.js.map +1 -1
  209. package/dist/wje-textarea.js +64 -264
  210. package/dist/wje-textarea.js.map +1 -1
  211. package/dist/wje-thumbnail.js +10 -51
  212. package/dist/wje-thumbnail.js.map +1 -1
  213. package/dist/wje-toast.js +127 -632
  214. package/dist/wje-toast.js.map +1 -1
  215. package/dist/wje-toggle.js +52 -177
  216. package/dist/wje-toggle.js.map +1 -1
  217. package/dist/wje-toolbar-action.js +128 -456
  218. package/dist/wje-toolbar-action.js.map +1 -1
  219. package/dist/wje-toolbar.js +75 -270
  220. package/dist/wje-toolbar.js.map +1 -1
  221. package/dist/wje-tooltip.js +50 -161
  222. package/dist/wje-tooltip.js.map +1 -1
  223. package/dist/wje-tree-item.js +70 -301
  224. package/dist/wje-tree-item.js.map +1 -1
  225. package/dist/wje-tree.js +145 -489
  226. package/dist/wje-tree.js.map +1 -1
  227. package/dist/wje-visually-hidden.js +7 -34
  228. package/dist/wje-visually-hidden.js.map +1 -1
  229. package/package.json +3 -2
  230. package/dist/form-associated-element-DEQ4y-jn.js +0 -245
  231. package/dist/icon-CReYMzAK.js +0 -245
  232. package/dist/popup.element-CwXvVFK7.js +0 -2133
  233. package/dist/router-links-wjqCnncc.js +0 -156
@@ -8,1557 +8,538 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
8
8
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
- var _init;
12
- import WJElement from "./wje-element.js";
13
- import { event } from "./event.js";
14
- function _typeof(obj) {
15
- "@babel/helpers - typeof";
16
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
17
- return typeof obj2;
18
- } : function(obj2) {
19
- return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
20
- }, _typeof(obj);
21
- }
22
- var trimLeft = /^\s+/;
23
- var trimRight = /\s+$/;
24
- function tinycolor(color, opts) {
25
- color = color ? color : "";
26
- opts = opts || {};
27
- if (color instanceof tinycolor) {
28
- return color;
29
- }
30
- if (!(this instanceof tinycolor)) {
31
- return new tinycolor(color, opts);
32
- }
33
- var rgb = inputToRGB(color);
34
- this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
35
- this._gradientType = opts.gradientType;
36
- if (this._r < 1) this._r = Math.round(this._r);
37
- if (this._g < 1) this._g = Math.round(this._g);
38
- if (this._b < 1) this._b = Math.round(this._b);
39
- this._ok = rgb.ok;
40
- }
41
- tinycolor.prototype = {
42
- isDark: function isDark() {
43
- return this.getBrightness() < 128;
44
- },
45
- isLight: function isLight() {
46
- return !this.isDark();
47
- },
48
- isValid: function isValid() {
49
- return this._ok;
50
- },
51
- getOriginalInput: function getOriginalInput() {
52
- return this._originalInput;
53
- },
54
- getFormat: function getFormat() {
55
- return this._format;
56
- },
57
- getAlpha: function getAlpha() {
58
- return this._a;
59
- },
60
- getBrightness: function getBrightness() {
61
- var rgb = this.toRgb();
62
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
63
- },
64
- getLuminance: function getLuminance() {
65
- var rgb = this.toRgb();
66
- var RsRGB, GsRGB, BsRGB, R, G, B;
67
- RsRGB = rgb.r / 255;
68
- GsRGB = rgb.g / 255;
69
- BsRGB = rgb.b / 255;
70
- if (RsRGB <= 0.03928) R = RsRGB / 12.92;
71
- else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
72
- if (GsRGB <= 0.03928) G = GsRGB / 12.92;
73
- else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
74
- if (BsRGB <= 0.03928) B = BsRGB / 12.92;
75
- else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
76
- return 0.2126 * R + 0.7152 * G + 0.0722 * B;
77
- },
78
- setAlpha: function setAlpha(value) {
79
- this._a = boundAlpha(value);
80
- this._roundA = Math.round(100 * this._a) / 100;
81
- return this;
82
- },
83
- toHsv: function toHsv() {
84
- var hsv = rgbToHsv(this._r, this._g, this._b);
85
- return {
86
- h: hsv.h * 360,
87
- s: hsv.s,
88
- v: hsv.v,
89
- a: this._a
90
- };
91
- },
92
- toHsvString: function toHsvString() {
93
- var hsv = rgbToHsv(this._r, this._g, this._b);
94
- var h = Math.round(hsv.h * 360), s = Math.round(hsv.s * 100), v = Math.round(hsv.v * 100);
95
- return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
96
- },
97
- toHsl: function toHsl() {
98
- var hsl = rgbToHsl(this._r, this._g, this._b);
99
- return {
100
- h: hsl.h * 360,
101
- s: hsl.s,
102
- l: hsl.l,
103
- a: this._a
104
- };
105
- },
106
- toHslString: function toHslString() {
107
- var hsl = rgbToHsl(this._r, this._g, this._b);
108
- var h = Math.round(hsl.h * 360), s = Math.round(hsl.s * 100), l = Math.round(hsl.l * 100);
109
- return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
110
- },
111
- toHex: function toHex(allow3Char) {
112
- return rgbToHex(this._r, this._g, this._b, allow3Char);
113
- },
114
- toHexString: function toHexString(allow3Char) {
115
- return "#" + this.toHex(allow3Char);
116
- },
117
- toHex8: function toHex8(allow4Char) {
118
- return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
119
- },
120
- toHex8String: function toHex8String(allow4Char) {
121
- return "#" + this.toHex8(allow4Char);
122
- },
123
- toRgb: function toRgb() {
124
- return {
125
- r: Math.round(this._r),
126
- g: Math.round(this._g),
127
- b: Math.round(this._b),
128
- a: this._a
129
- };
130
- },
131
- toRgbString: function toRgbString() {
132
- return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
133
- },
134
- toPercentageRgb: function toPercentageRgb() {
135
- return {
136
- r: Math.round(bound01(this._r, 255) * 100) + "%",
137
- g: Math.round(bound01(this._g, 255) * 100) + "%",
138
- b: Math.round(bound01(this._b, 255) * 100) + "%",
139
- a: this._a
140
- };
141
- },
142
- toPercentageRgbString: function toPercentageRgbString() {
143
- return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
144
- },
145
- toName: function toName() {
146
- if (this._a === 0) {
147
- return "transparent";
148
- }
149
- if (this._a < 1) {
11
+ var _t;
12
+ import t from "./wje-element.js";
13
+ import { event as e } from "./event.js";
14
+ function r(t2) {
15
+ return r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t3) {
16
+ return typeof t3;
17
+ } : function(t3) {
18
+ return t3 && "function" == typeof Symbol && t3.constructor === Symbol && t3 !== Symbol.prototype ? "symbol" : typeof t3;
19
+ }, r(t2);
20
+ }
21
+ var i = /^\s+/, a = /\s+$/;
22
+ function n(t2, e2) {
23
+ if (e2 = e2 || {}, (t2 = t2 || "") instanceof n) return t2;
24
+ if (!(this instanceof n)) return new n(t2, e2);
25
+ var o2 = (function(t3) {
26
+ var e3 = { r: 0, g: 0, b: 0 }, n2 = 1, o3 = null, s2 = null, h2 = null, l2 = false, u2 = false;
27
+ "string" == typeof t3 && (t3 = (function(t4) {
28
+ t4 = t4.replace(i, "").replace(a, "").toLowerCase();
29
+ var e4, r2 = false;
30
+ if (y[t4]) t4 = y[t4], r2 = true;
31
+ else if ("transparent" == t4) return { r: 0, g: 0, b: 0, a: 0, format: "name" };
32
+ if (e4 = N.rgb.exec(t4)) return { r: e4[1], g: e4[2], b: e4[3] };
33
+ if (e4 = N.rgba.exec(t4)) return { r: e4[1], g: e4[2], b: e4[3], a: e4[4] };
34
+ if (e4 = N.hsl.exec(t4)) return { h: e4[1], s: e4[2], l: e4[3] };
35
+ if (e4 = N.hsla.exec(t4)) return { h: e4[1], s: e4[2], l: e4[3], a: e4[4] };
36
+ if (e4 = N.hsv.exec(t4)) return { h: e4[1], s: e4[2], v: e4[3] };
37
+ if (e4 = N.hsva.exec(t4)) return { h: e4[1], s: e4[2], v: e4[3], a: e4[4] };
38
+ if (e4 = N.hex8.exec(t4)) return { r: j(e4[1]), g: j(e4[2]), b: j(e4[3]), a: E(e4[4]), format: r2 ? "name" : "hex8" };
39
+ if (e4 = N.hex6.exec(t4)) return { r: j(e4[1]), g: j(e4[2]), b: j(e4[3]), format: r2 ? "name" : "hex" };
40
+ if (e4 = N.hex4.exec(t4)) return { r: j(e4[1] + "" + e4[1]), g: j(e4[2] + "" + e4[2]), b: j(e4[3] + "" + e4[3]), a: E(e4[4] + "" + e4[4]), format: r2 ? "name" : "hex8" };
41
+ if (e4 = N.hex3.exec(t4)) return { r: j(e4[1] + "" + e4[1]), g: j(e4[2] + "" + e4[2]), b: j(e4[3] + "" + e4[3]), format: r2 ? "name" : "hex" };
150
42
  return false;
151
- }
152
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
153
- },
154
- toFilter: function toFilter(secondColor) {
155
- var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
156
- var secondHex8String = hex8String;
157
- var gradientType = this._gradientType ? "GradientType = 1, " : "";
158
- if (secondColor) {
159
- var s = tinycolor(secondColor);
160
- secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
161
- }
162
- return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
163
- },
164
- toString: function toString(format) {
165
- var formatSet = !!format;
166
- format = format || this._format;
167
- var formattedString = false;
168
- var hasAlpha = this._a < 1 && this._a >= 0;
169
- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
170
- if (needsAlphaFormat) {
171
- if (format === "name" && this._a === 0) {
172
- return this.toName();
43
+ })(t3));
44
+ "object" == r(t3) && (D(t3.r) && D(t3.g) && D(t3.b) ? (c2 = t3.r, d2 = t3.g, f2 = t3.b, e3 = { r: 255 * M(c2, 255), g: 255 * M(d2, 255), b: 255 * M(f2, 255) }, l2 = true, u2 = "%" === String(t3.r).substr(-1) ? "prgb" : "rgb") : D(t3.h) && D(t3.s) && D(t3.v) ? (o3 = P(t3.s), s2 = P(t3.v), e3 = (function(t4, e4, r2) {
45
+ t4 = 6 * M(t4, 360), e4 = M(e4, 100), r2 = M(r2, 100);
46
+ var i2 = Math.floor(t4), a2 = t4 - i2, n3 = r2 * (1 - e4), o4 = r2 * (1 - a2 * e4), s3 = r2 * (1 - (1 - a2) * e4), h3 = i2 % 6, l3 = [r2, o4, n3, n3, s3, r2][h3], u3 = [s3, r2, r2, o4, n3, n3][h3], c3 = [n3, n3, s3, r2, r2, o4][h3];
47
+ return { r: 255 * l3, g: 255 * u3, b: 255 * c3 };
48
+ })(t3.h, o3, s2), l2 = true, u2 = "hsv") : D(t3.h) && D(t3.s) && D(t3.l) && (o3 = P(t3.s), h2 = P(t3.l), e3 = (function(t4, e4, r2) {
49
+ var i2, a2, n3;
50
+ function o4(t5, e5, r3) {
51
+ return r3 < 0 && (r3 += 1), r3 > 1 && (r3 -= 1), r3 < 1 / 6 ? t5 + 6 * (e5 - t5) * r3 : r3 < 0.5 ? e5 : r3 < 2 / 3 ? t5 + (e5 - t5) * (2 / 3 - r3) * 6 : t5;
173
52
  }
174
- return this.toRgbString();
175
- }
176
- if (format === "rgb") {
177
- formattedString = this.toRgbString();
178
- }
179
- if (format === "prgb") {
180
- formattedString = this.toPercentageRgbString();
181
- }
182
- if (format === "hex" || format === "hex6") {
183
- formattedString = this.toHexString();
184
- }
185
- if (format === "hex3") {
186
- formattedString = this.toHexString(true);
187
- }
188
- if (format === "hex4") {
189
- formattedString = this.toHex8String(true);
190
- }
191
- if (format === "hex8") {
192
- formattedString = this.toHex8String();
193
- }
194
- if (format === "name") {
195
- formattedString = this.toName();
196
- }
197
- if (format === "hsl") {
198
- formattedString = this.toHslString();
199
- }
200
- if (format === "hsv") {
201
- formattedString = this.toHsvString();
202
- }
203
- return formattedString || this.toHexString();
204
- },
205
- clone: function clone() {
206
- return tinycolor(this.toString());
207
- },
208
- _applyModification: function _applyModification(fn, args) {
209
- var color = fn.apply(null, [this].concat([].slice.call(args)));
210
- this._r = color._r;
211
- this._g = color._g;
212
- this._b = color._b;
213
- this.setAlpha(color._a);
214
- return this;
215
- },
216
- lighten: function lighten() {
217
- return this._applyModification(_lighten, arguments);
218
- },
219
- brighten: function brighten() {
220
- return this._applyModification(_brighten, arguments);
221
- },
222
- darken: function darken() {
223
- return this._applyModification(_darken, arguments);
224
- },
225
- desaturate: function desaturate() {
226
- return this._applyModification(_desaturate, arguments);
227
- },
228
- saturate: function saturate() {
229
- return this._applyModification(_saturate, arguments);
230
- },
231
- greyscale: function greyscale() {
232
- return this._applyModification(_greyscale, arguments);
233
- },
234
- spin: function spin() {
235
- return this._applyModification(_spin, arguments);
236
- },
237
- _applyCombination: function _applyCombination(fn, args) {
238
- return fn.apply(null, [this].concat([].slice.call(args)));
239
- },
240
- analogous: function analogous() {
241
- return this._applyCombination(_analogous, arguments);
242
- },
243
- complement: function complement() {
244
- return this._applyCombination(_complement, arguments);
245
- },
246
- monochromatic: function monochromatic() {
247
- return this._applyCombination(_monochromatic, arguments);
248
- },
249
- splitcomplement: function splitcomplement() {
250
- return this._applyCombination(_splitcomplement, arguments);
251
- },
252
- // Disabled until https://github.com/bgrins/TinyColor/issues/254
253
- // polyad: function (number) {
254
- // return this._applyCombination(polyad, [number]);
255
- // },
256
- triad: function triad() {
257
- return this._applyCombination(polyad, [3]);
258
- },
259
- tetrad: function tetrad() {
260
- return this._applyCombination(polyad, [4]);
261
- }
262
- };
263
- tinycolor.fromRatio = function(color, opts) {
264
- if (_typeof(color) == "object") {
265
- var newColor = {};
266
- for (var i in color) {
267
- if (color.hasOwnProperty(i)) {
268
- if (i === "a") {
269
- newColor[i] = color[i];
270
- } else {
271
- newColor[i] = convertToPercentage(color[i]);
272
- }
53
+ if (t4 = M(t4, 360), e4 = M(e4, 100), r2 = M(r2, 100), 0 === e4) i2 = a2 = n3 = r2;
54
+ else {
55
+ var s3 = r2 < 0.5 ? r2 * (1 + e4) : r2 + e4 - r2 * e4, h3 = 2 * r2 - s3;
56
+ i2 = o4(h3, s3, t4 + 1 / 3), a2 = o4(h3, s3, t4), n3 = o4(h3, s3, t4 - 1 / 3);
273
57
  }
274
- }
275
- color = newColor;
276
- }
277
- return tinycolor(color, opts);
278
- };
279
- function inputToRGB(color) {
280
- var rgb = {
281
- r: 0,
282
- g: 0,
283
- b: 0
284
- };
285
- var a = 1;
286
- var s = null;
287
- var v = null;
288
- var l = null;
289
- var ok = false;
290
- var format = false;
291
- if (typeof color == "string") {
292
- color = stringInputToObject(color);
293
- }
294
- if (_typeof(color) == "object") {
295
- if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
296
- rgb = rgbToRgb(color.r, color.g, color.b);
297
- ok = true;
298
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
299
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
300
- s = convertToPercentage(color.s);
301
- v = convertToPercentage(color.v);
302
- rgb = hsvToRgb(color.h, s, v);
303
- ok = true;
304
- format = "hsv";
305
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
306
- s = convertToPercentage(color.s);
307
- l = convertToPercentage(color.l);
308
- rgb = hslToRgb(color.h, s, l);
309
- ok = true;
310
- format = "hsl";
311
- }
312
- if (color.hasOwnProperty("a")) {
313
- a = color.a;
314
- }
315
- }
316
- a = boundAlpha(a);
317
- return {
318
- ok,
319
- format: color.format || format,
320
- r: Math.min(255, Math.max(rgb.r, 0)),
321
- g: Math.min(255, Math.max(rgb.g, 0)),
322
- b: Math.min(255, Math.max(rgb.b, 0)),
323
- a
324
- };
325
- }
326
- function rgbToRgb(r, g, b) {
327
- return {
328
- r: bound01(r, 255) * 255,
329
- g: bound01(g, 255) * 255,
330
- b: bound01(b, 255) * 255
331
- };
332
- }
333
- function rgbToHsl(r, g, b) {
334
- r = bound01(r, 255);
335
- g = bound01(g, 255);
336
- b = bound01(b, 255);
337
- var max = Math.max(r, g, b), min = Math.min(r, g, b);
338
- var h, s, l = (max + min) / 2;
339
- if (max == min) {
340
- h = s = 0;
341
- } else {
342
- var d = max - min;
343
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
344
- switch (max) {
345
- case r:
346
- h = (g - b) / d + (g < b ? 6 : 0);
58
+ return { r: 255 * i2, g: 255 * a2, b: 255 * n3 };
59
+ })(t3.h, o3, h2), l2 = true, u2 = "hsl"), t3.hasOwnProperty("a") && (n2 = t3.a));
60
+ var c2, d2, f2;
61
+ return n2 = _(n2), { ok: l2, format: t3.format || u2, r: Math.min(255, Math.max(e3.r, 0)), g: Math.min(255, Math.max(e3.g, 0)), b: Math.min(255, Math.max(e3.b, 0)), a: n2 };
62
+ })(t2);
63
+ this._originalInput = t2, this._r = o2.r, this._g = o2.g, this._b = o2.b, this._a = o2.a, this._roundA = Math.round(100 * this._a) / 100, this._format = e2.format || o2.format, this._gradientType = e2.gradientType, this._r < 1 && (this._r = Math.round(this._r)), this._g < 1 && (this._g = Math.round(this._g)), this._b < 1 && (this._b = Math.round(this._b)), this._ok = o2.ok;
64
+ }
65
+ function o(t2, e2, r2) {
66
+ t2 = M(t2, 255), e2 = M(e2, 255), r2 = M(r2, 255);
67
+ var i2, a2, n2 = Math.max(t2, e2, r2), o2 = Math.min(t2, e2, r2), s2 = (n2 + o2) / 2;
68
+ if (n2 == o2) i2 = a2 = 0;
69
+ else {
70
+ var h2 = n2 - o2;
71
+ switch (a2 = s2 > 0.5 ? h2 / (2 - n2 - o2) : h2 / (n2 + o2), n2) {
72
+ case t2:
73
+ i2 = (e2 - r2) / h2 + (e2 < r2 ? 6 : 0);
347
74
  break;
348
- case g:
349
- h = (b - r) / d + 2;
350
- break;
351
- case b:
352
- h = (r - g) / d + 4;
75
+ case e2:
76
+ i2 = (r2 - t2) / h2 + 2;
353
77
  break;
78
+ case r2:
79
+ i2 = (t2 - e2) / h2 + 4;
354
80
  }
355
- h /= 6;
356
- }
357
- return {
358
- h,
359
- s,
360
- l
361
- };
362
- }
363
- function hslToRgb(h, s, l) {
364
- var r, g, b;
365
- h = bound01(h, 360);
366
- s = bound01(s, 100);
367
- l = bound01(l, 100);
368
- function hue2rgb(p2, q2, t) {
369
- if (t < 0) t += 1;
370
- if (t > 1) t -= 1;
371
- if (t < 1 / 6) return p2 + (q2 - p2) * 6 * t;
372
- if (t < 1 / 2) return q2;
373
- if (t < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - t) * 6;
374
- return p2;
375
- }
376
- if (s === 0) {
377
- r = g = b = l;
378
- } else {
379
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
380
- var p = 2 * l - q;
381
- r = hue2rgb(p, q, h + 1 / 3);
382
- g = hue2rgb(p, q, h);
383
- b = hue2rgb(p, q, h - 1 / 3);
384
- }
385
- return {
386
- r: r * 255,
387
- g: g * 255,
388
- b: b * 255
389
- };
390
- }
391
- function rgbToHsv(r, g, b) {
392
- r = bound01(r, 255);
393
- g = bound01(g, 255);
394
- b = bound01(b, 255);
395
- var max = Math.max(r, g, b), min = Math.min(r, g, b);
396
- var h, s, v = max;
397
- var d = max - min;
398
- s = max === 0 ? 0 : d / max;
399
- if (max == min) {
400
- h = 0;
401
- } else {
402
- switch (max) {
403
- case r:
404
- h = (g - b) / d + (g < b ? 6 : 0);
405
- break;
406
- case g:
407
- h = (b - r) / d + 2;
81
+ i2 /= 6;
82
+ }
83
+ return { h: i2, s: a2, l: s2 };
84
+ }
85
+ function s(t2, e2, r2) {
86
+ t2 = M(t2, 255), e2 = M(e2, 255), r2 = M(r2, 255);
87
+ var i2, a2, n2 = Math.max(t2, e2, r2), o2 = Math.min(t2, e2, r2), s2 = n2, h2 = n2 - o2;
88
+ if (a2 = 0 === n2 ? 0 : h2 / n2, n2 == o2) i2 = 0;
89
+ else {
90
+ switch (n2) {
91
+ case t2:
92
+ i2 = (e2 - r2) / h2 + (e2 < r2 ? 6 : 0);
408
93
  break;
409
- case b:
410
- h = (r - g) / d + 4;
94
+ case e2:
95
+ i2 = (r2 - t2) / h2 + 2;
411
96
  break;
97
+ case r2:
98
+ i2 = (t2 - e2) / h2 + 4;
412
99
  }
413
- h /= 6;
414
- }
415
- return {
416
- h,
417
- s,
418
- v
419
- };
420
- }
421
- function hsvToRgb(h, s, v) {
422
- h = bound01(h, 360) * 6;
423
- s = bound01(s, 100);
424
- v = bound01(v, 100);
425
- var i = Math.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), mod = i % 6, r = [v, q, p, p, t, v][mod], g = [t, v, v, q, p, p][mod], b = [p, p, t, v, v, q][mod];
426
- return {
427
- r: r * 255,
428
- g: g * 255,
429
- b: b * 255
430
- };
431
- }
432
- function rgbToHex(r, g, b, allow3Char) {
433
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
434
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
435
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
436
- }
437
- return hex.join("");
438
- }
439
- function rgbaToHex(r, g, b, a, allow4Char) {
440
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
441
- if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
442
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
443
- }
444
- return hex.join("");
445
- }
446
- function rgbaToArgbHex(r, g, b, a) {
447
- var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
448
- return hex.join("");
449
- }
450
- tinycolor.equals = function(color1, color2) {
451
- if (!color1 || !color2) return false;
452
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
453
- };
454
- tinycolor.random = function() {
455
- return tinycolor.fromRatio({
456
- r: Math.random(),
457
- g: Math.random(),
458
- b: Math.random()
459
- });
460
- };
461
- function _desaturate(color, amount) {
462
- amount = amount === 0 ? 0 : amount || 10;
463
- var hsl = tinycolor(color).toHsl();
464
- hsl.s -= amount / 100;
465
- hsl.s = clamp01(hsl.s);
466
- return tinycolor(hsl);
467
- }
468
- function _saturate(color, amount) {
469
- amount = amount === 0 ? 0 : amount || 10;
470
- var hsl = tinycolor(color).toHsl();
471
- hsl.s += amount / 100;
472
- hsl.s = clamp01(hsl.s);
473
- return tinycolor(hsl);
474
- }
475
- function _greyscale(color) {
476
- return tinycolor(color).desaturate(100);
477
- }
478
- function _lighten(color, amount) {
479
- amount = amount === 0 ? 0 : amount || 10;
480
- var hsl = tinycolor(color).toHsl();
481
- hsl.l += amount / 100;
482
- hsl.l = clamp01(hsl.l);
483
- return tinycolor(hsl);
484
- }
485
- function _brighten(color, amount) {
486
- amount = amount === 0 ? 0 : amount || 10;
487
- var rgb = tinycolor(color).toRgb();
488
- rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
489
- rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
490
- rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
491
- return tinycolor(rgb);
492
- }
493
- function _darken(color, amount) {
494
- amount = amount === 0 ? 0 : amount || 10;
495
- var hsl = tinycolor(color).toHsl();
496
- hsl.l -= amount / 100;
497
- hsl.l = clamp01(hsl.l);
498
- return tinycolor(hsl);
499
- }
500
- function _spin(color, amount) {
501
- var hsl = tinycolor(color).toHsl();
502
- var hue = (hsl.h + amount) % 360;
503
- hsl.h = hue < 0 ? 360 + hue : hue;
504
- return tinycolor(hsl);
505
- }
506
- function _complement(color) {
507
- var hsl = tinycolor(color).toHsl();
508
- hsl.h = (hsl.h + 180) % 360;
509
- return tinycolor(hsl);
510
- }
511
- function polyad(color, number) {
512
- if (isNaN(number) || number <= 0) {
513
- throw new Error("Argument to polyad must be a positive number");
514
- }
515
- var hsl = tinycolor(color).toHsl();
516
- var result = [tinycolor(color)];
517
- var step = 360 / number;
518
- for (var i = 1; i < number; i++) {
519
- result.push(tinycolor({
520
- h: (hsl.h + i * step) % 360,
521
- s: hsl.s,
522
- l: hsl.l
523
- }));
524
- }
525
- return result;
526
- }
527
- function _splitcomplement(color) {
528
- var hsl = tinycolor(color).toHsl();
529
- var h = hsl.h;
530
- return [tinycolor(color), tinycolor({
531
- h: (h + 72) % 360,
532
- s: hsl.s,
533
- l: hsl.l
534
- }), tinycolor({
535
- h: (h + 216) % 360,
536
- s: hsl.s,
537
- l: hsl.l
538
- })];
539
- }
540
- function _analogous(color, results, slices) {
541
- results = results || 6;
542
- slices = slices || 30;
543
- var hsl = tinycolor(color).toHsl();
544
- var part = 360 / slices;
545
- var ret = [tinycolor(color)];
546
- for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
547
- hsl.h = (hsl.h + part) % 360;
548
- ret.push(tinycolor(hsl));
549
- }
550
- return ret;
551
- }
552
- function _monochromatic(color, results) {
553
- results = results || 6;
554
- var hsv = tinycolor(color).toHsv();
555
- var h = hsv.h, s = hsv.s, v = hsv.v;
556
- var ret = [];
557
- var modification = 1 / results;
558
- while (results--) {
559
- ret.push(tinycolor({
560
- h,
561
- s,
562
- v
563
- }));
564
- v = (v + modification) % 1;
565
- }
566
- return ret;
567
- }
568
- tinycolor.mix = function(color1, color2, amount) {
569
- amount = amount === 0 ? 0 : amount || 50;
570
- var rgb1 = tinycolor(color1).toRgb();
571
- var rgb2 = tinycolor(color2).toRgb();
572
- var p = amount / 100;
573
- var rgba = {
574
- r: (rgb2.r - rgb1.r) * p + rgb1.r,
575
- g: (rgb2.g - rgb1.g) * p + rgb1.g,
576
- b: (rgb2.b - rgb1.b) * p + rgb1.b,
577
- a: (rgb2.a - rgb1.a) * p + rgb1.a
578
- };
579
- return tinycolor(rgba);
580
- };
581
- tinycolor.readability = function(color1, color2) {
582
- var c1 = tinycolor(color1);
583
- var c2 = tinycolor(color2);
584
- return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
585
- };
586
- tinycolor.isReadable = function(color1, color2, wcag2) {
587
- var readability = tinycolor.readability(color1, color2);
588
- var wcag2Parms, out;
589
- out = false;
590
- wcag2Parms = validateWCAG2Parms(wcag2);
591
- switch (wcag2Parms.level + wcag2Parms.size) {
100
+ i2 /= 6;
101
+ }
102
+ return { h: i2, s: a2, v: s2 };
103
+ }
104
+ function h(t2, e2, r2, i2) {
105
+ var a2 = [H(Math.round(t2).toString(16)), H(Math.round(e2).toString(16)), H(Math.round(r2).toString(16))];
106
+ return i2 && a2[0].charAt(0) == a2[0].charAt(1) && a2[1].charAt(0) == a2[1].charAt(1) && a2[2].charAt(0) == a2[2].charAt(1) ? a2[0].charAt(0) + a2[1].charAt(0) + a2[2].charAt(0) : a2.join("");
107
+ }
108
+ function l(t2, e2, r2, i2) {
109
+ return [H(C(i2)), H(Math.round(t2).toString(16)), H(Math.round(e2).toString(16)), H(Math.round(r2).toString(16))].join("");
110
+ }
111
+ function u(t2, e2) {
112
+ e2 = 0 === e2 ? 0 : e2 || 10;
113
+ var r2 = n(t2).toHsl();
114
+ return r2.s -= e2 / 100, r2.s = S(r2.s), n(r2);
115
+ }
116
+ function c(t2, e2) {
117
+ e2 = 0 === e2 ? 0 : e2 || 10;
118
+ var r2 = n(t2).toHsl();
119
+ return r2.s += e2 / 100, r2.s = S(r2.s), n(r2);
120
+ }
121
+ function d(t2) {
122
+ return n(t2).desaturate(100);
123
+ }
124
+ function f(t2, e2) {
125
+ e2 = 0 === e2 ? 0 : e2 || 10;
126
+ var r2 = n(t2).toHsl();
127
+ return r2.l += e2 / 100, r2.l = S(r2.l), n(r2);
128
+ }
129
+ function p(t2, e2) {
130
+ e2 = 0 === e2 ? 0 : e2 || 10;
131
+ var r2 = n(t2).toRgb();
132
+ return r2.r = Math.max(0, Math.min(255, r2.r - Math.round(-e2 / 100 * 255))), r2.g = Math.max(0, Math.min(255, r2.g - Math.round(-e2 / 100 * 255))), r2.b = Math.max(0, Math.min(255, r2.b - Math.round(-e2 / 100 * 255))), n(r2);
133
+ }
134
+ function g(t2, e2) {
135
+ e2 = 0 === e2 ? 0 : e2 || 10;
136
+ var r2 = n(t2).toHsl();
137
+ return r2.l -= e2 / 100, r2.l = S(r2.l), n(r2);
138
+ }
139
+ function m(t2, e2) {
140
+ var r2 = n(t2).toHsl(), i2 = (r2.h + e2) % 360;
141
+ return r2.h = i2 < 0 ? 360 + i2 : i2, n(r2);
142
+ }
143
+ function b(t2) {
144
+ var e2 = n(t2).toHsl();
145
+ return e2.h = (e2.h + 180) % 360, n(e2);
146
+ }
147
+ function v(t2, e2) {
148
+ if (isNaN(e2) || e2 <= 0) throw new Error("Argument to polyad must be a positive number");
149
+ for (var r2 = n(t2).toHsl(), i2 = [n(t2)], a2 = 360 / e2, o2 = 1; o2 < e2; o2++) i2.push(n({ h: (r2.h + o2 * a2) % 360, s: r2.s, l: r2.l }));
150
+ return i2;
151
+ }
152
+ function w(t2) {
153
+ var e2 = n(t2).toHsl(), r2 = e2.h;
154
+ return [n(t2), n({ h: (r2 + 72) % 360, s: e2.s, l: e2.l }), n({ h: (r2 + 216) % 360, s: e2.s, l: e2.l })];
155
+ }
156
+ function x(t2, e2, r2) {
157
+ e2 = e2 || 6, r2 = r2 || 30;
158
+ var i2 = n(t2).toHsl(), a2 = 360 / r2, o2 = [n(t2)];
159
+ for (i2.h = (i2.h - (a2 * e2 >> 1) + 720) % 360; --e2; ) i2.h = (i2.h + a2) % 360, o2.push(n(i2));
160
+ return o2;
161
+ }
162
+ function k(t2, e2) {
163
+ e2 = e2 || 6;
164
+ for (var r2 = n(t2).toHsv(), i2 = r2.h, a2 = r2.s, o2 = r2.v, s2 = [], h2 = 1 / e2; e2--; ) s2.push(n({ h: i2, s: a2, v: o2 })), o2 = (o2 + h2) % 1;
165
+ return s2;
166
+ }
167
+ n.prototype = { isDark: function() {
168
+ return this.getBrightness() < 128;
169
+ }, isLight: function() {
170
+ return !this.isDark();
171
+ }, isValid: function() {
172
+ return this._ok;
173
+ }, getOriginalInput: function() {
174
+ return this._originalInput;
175
+ }, getFormat: function() {
176
+ return this._format;
177
+ }, getAlpha: function() {
178
+ return this._a;
179
+ }, getBrightness: function() {
180
+ var t2 = this.toRgb();
181
+ return (299 * t2.r + 587 * t2.g + 114 * t2.b) / 1e3;
182
+ }, getLuminance: function() {
183
+ var t2, e2, r2, i2 = this.toRgb();
184
+ return t2 = i2.r / 255, e2 = i2.g / 255, r2 = i2.b / 255, 0.2126 * (t2 <= 0.03928 ? t2 / 12.92 : Math.pow((t2 + 0.055) / 1.055, 2.4)) + 0.7152 * (e2 <= 0.03928 ? e2 / 12.92 : Math.pow((e2 + 0.055) / 1.055, 2.4)) + 0.0722 * (r2 <= 0.03928 ? r2 / 12.92 : Math.pow((r2 + 0.055) / 1.055, 2.4));
185
+ }, setAlpha: function(t2) {
186
+ return this._a = _(t2), this._roundA = Math.round(100 * this._a) / 100, this;
187
+ }, toHsv: function() {
188
+ var t2 = s(this._r, this._g, this._b);
189
+ return { h: 360 * t2.h, s: t2.s, v: t2.v, a: this._a };
190
+ }, toHsvString: function() {
191
+ var t2 = s(this._r, this._g, this._b), e2 = Math.round(360 * t2.h), r2 = Math.round(100 * t2.s), i2 = Math.round(100 * t2.v);
192
+ return 1 == this._a ? "hsv(" + e2 + ", " + r2 + "%, " + i2 + "%)" : "hsva(" + e2 + ", " + r2 + "%, " + i2 + "%, " + this._roundA + ")";
193
+ }, toHsl: function() {
194
+ var t2 = o(this._r, this._g, this._b);
195
+ return { h: 360 * t2.h, s: t2.s, l: t2.l, a: this._a };
196
+ }, toHslString: function() {
197
+ var t2 = o(this._r, this._g, this._b), e2 = Math.round(360 * t2.h), r2 = Math.round(100 * t2.s), i2 = Math.round(100 * t2.l);
198
+ return 1 == this._a ? "hsl(" + e2 + ", " + r2 + "%, " + i2 + "%)" : "hsla(" + e2 + ", " + r2 + "%, " + i2 + "%, " + this._roundA + ")";
199
+ }, toHex: function(t2) {
200
+ return h(this._r, this._g, this._b, t2);
201
+ }, toHexString: function(t2) {
202
+ return "#" + this.toHex(t2);
203
+ }, toHex8: function(t2) {
204
+ return (function(t3, e2, r2, i2, a2) {
205
+ var n2 = [H(Math.round(t3).toString(16)), H(Math.round(e2).toString(16)), H(Math.round(r2).toString(16)), H(C(i2))];
206
+ if (a2 && n2[0].charAt(0) == n2[0].charAt(1) && n2[1].charAt(0) == n2[1].charAt(1) && n2[2].charAt(0) == n2[2].charAt(1) && n2[3].charAt(0) == n2[3].charAt(1)) return n2[0].charAt(0) + n2[1].charAt(0) + n2[2].charAt(0) + n2[3].charAt(0);
207
+ return n2.join("");
208
+ })(this._r, this._g, this._b, this._a, t2);
209
+ }, toHex8String: function(t2) {
210
+ return "#" + this.toHex8(t2);
211
+ }, toRgb: function() {
212
+ return { r: Math.round(this._r), g: Math.round(this._g), b: Math.round(this._b), a: this._a };
213
+ }, toRgbString: function() {
214
+ return 1 == this._a ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
215
+ }, toPercentageRgb: function() {
216
+ return { r: Math.round(100 * M(this._r, 255)) + "%", g: Math.round(100 * M(this._g, 255)) + "%", b: Math.round(100 * M(this._b, 255)) + "%", a: this._a };
217
+ }, toPercentageRgbString: function() {
218
+ return 1 == this._a ? "rgb(" + Math.round(100 * M(this._r, 255)) + "%, " + Math.round(100 * M(this._g, 255)) + "%, " + Math.round(100 * M(this._b, 255)) + "%)" : "rgba(" + Math.round(100 * M(this._r, 255)) + "%, " + Math.round(100 * M(this._g, 255)) + "%, " + Math.round(100 * M(this._b, 255)) + "%, " + this._roundA + ")";
219
+ }, toName: function() {
220
+ return 0 === this._a ? "transparent" : !(this._a < 1) && (A[h(this._r, this._g, this._b, true)] || false);
221
+ }, toFilter: function(t2) {
222
+ var e2 = "#" + l(this._r, this._g, this._b, this._a), r2 = e2, i2 = this._gradientType ? "GradientType = 1, " : "";
223
+ if (t2) {
224
+ var a2 = n(t2);
225
+ r2 = "#" + l(a2._r, a2._g, a2._b, a2._a);
226
+ }
227
+ return "progid:DXImageTransform.Microsoft.gradient(" + i2 + "startColorstr=" + e2 + ",endColorstr=" + r2 + ")";
228
+ }, toString: function(t2) {
229
+ var e2 = !!t2;
230
+ t2 = t2 || this._format;
231
+ var r2 = false, i2 = this._a < 1 && this._a >= 0;
232
+ return e2 || !i2 || "hex" !== t2 && "hex6" !== t2 && "hex3" !== t2 && "hex4" !== t2 && "hex8" !== t2 && "name" !== t2 ? ("rgb" === t2 && (r2 = this.toRgbString()), "prgb" === t2 && (r2 = this.toPercentageRgbString()), "hex" !== t2 && "hex6" !== t2 || (r2 = this.toHexString()), "hex3" === t2 && (r2 = this.toHexString(true)), "hex4" === t2 && (r2 = this.toHex8String(true)), "hex8" === t2 && (r2 = this.toHex8String()), "name" === t2 && (r2 = this.toName()), "hsl" === t2 && (r2 = this.toHslString()), "hsv" === t2 && (r2 = this.toHsvString()), r2 || this.toHexString()) : "name" === t2 && 0 === this._a ? this.toName() : this.toRgbString();
233
+ }, clone: function() {
234
+ return n(this.toString());
235
+ }, _applyModification: function(t2, e2) {
236
+ var r2 = t2.apply(null, [this].concat([].slice.call(e2)));
237
+ return this._r = r2._r, this._g = r2._g, this._b = r2._b, this.setAlpha(r2._a), this;
238
+ }, lighten: function() {
239
+ return this._applyModification(f, arguments);
240
+ }, brighten: function() {
241
+ return this._applyModification(p, arguments);
242
+ }, darken: function() {
243
+ return this._applyModification(g, arguments);
244
+ }, desaturate: function() {
245
+ return this._applyModification(u, arguments);
246
+ }, saturate: function() {
247
+ return this._applyModification(c, arguments);
248
+ }, greyscale: function() {
249
+ return this._applyModification(d, arguments);
250
+ }, spin: function() {
251
+ return this._applyModification(m, arguments);
252
+ }, _applyCombination: function(t2, e2) {
253
+ return t2.apply(null, [this].concat([].slice.call(e2)));
254
+ }, analogous: function() {
255
+ return this._applyCombination(x, arguments);
256
+ }, complement: function() {
257
+ return this._applyCombination(b, arguments);
258
+ }, monochromatic: function() {
259
+ return this._applyCombination(k, arguments);
260
+ }, splitcomplement: function() {
261
+ return this._applyCombination(w, arguments);
262
+ }, triad: function() {
263
+ return this._applyCombination(v, [3]);
264
+ }, tetrad: function() {
265
+ return this._applyCombination(v, [4]);
266
+ } }, n.fromRatio = function(t2, e2) {
267
+ if ("object" == r(t2)) {
268
+ var i2 = {};
269
+ for (var a2 in t2) t2.hasOwnProperty(a2) && (i2[a2] = "a" === a2 ? t2[a2] : P(t2[a2]));
270
+ t2 = i2;
271
+ }
272
+ return n(t2, e2);
273
+ }, n.equals = function(t2, e2) {
274
+ return !(!t2 || !e2) && n(t2).toRgbString() == n(e2).toRgbString();
275
+ }, n.random = function() {
276
+ return n.fromRatio({ r: Math.random(), g: Math.random(), b: Math.random() });
277
+ }, n.mix = function(t2, e2, r2) {
278
+ r2 = 0 === r2 ? 0 : r2 || 50;
279
+ var i2 = n(t2).toRgb(), a2 = n(e2).toRgb(), o2 = r2 / 100;
280
+ return n({ r: (a2.r - i2.r) * o2 + i2.r, g: (a2.g - i2.g) * o2 + i2.g, b: (a2.b - i2.b) * o2 + i2.b, a: (a2.a - i2.a) * o2 + i2.a });
281
+ }, n.readability = function(t2, e2) {
282
+ var r2 = n(t2), i2 = n(e2);
283
+ return (Math.max(r2.getLuminance(), i2.getLuminance()) + 0.05) / (Math.min(r2.getLuminance(), i2.getLuminance()) + 0.05);
284
+ }, n.isReadable = function(t2, e2, r2) {
285
+ var i2, a2, o2 = n.readability(t2, e2);
286
+ switch (a2 = false, (i2 = (function(t3) {
287
+ var e3, r3;
288
+ e3 = ((t3 = t3 || { level: "AA", size: "small" }).level || "AA").toUpperCase(), r3 = (t3.size || "small").toLowerCase(), "AA" !== e3 && "AAA" !== e3 && (e3 = "AA");
289
+ "small" !== r3 && "large" !== r3 && (r3 = "small");
290
+ return { level: e3, size: r3 };
291
+ })(r2)).level + i2.size) {
592
292
  case "AAsmall":
593
293
  case "AAAlarge":
594
- out = readability >= 4.5;
294
+ a2 = o2 >= 4.5;
595
295
  break;
596
296
  case "AAlarge":
597
- out = readability >= 3;
297
+ a2 = o2 >= 3;
598
298
  break;
599
299
  case "AAAsmall":
600
- out = readability >= 7;
601
- break;
602
- }
603
- return out;
604
- };
605
- tinycolor.mostReadable = function(baseColor, colorList, args) {
606
- var bestColor = null;
607
- var bestScore = 0;
608
- var readability;
609
- var includeFallbackColors, level, size;
610
- args = args || {};
611
- includeFallbackColors = args.includeFallbackColors;
612
- level = args.level;
613
- size = args.size;
614
- for (var i = 0; i < colorList.length; i++) {
615
- readability = tinycolor.readability(baseColor, colorList[i]);
616
- if (readability > bestScore) {
617
- bestScore = readability;
618
- bestColor = tinycolor(colorList[i]);
619
- }
620
- }
621
- if (tinycolor.isReadable(baseColor, bestColor, {
622
- level,
623
- size
624
- }) || !includeFallbackColors) {
625
- return bestColor;
626
- } else {
627
- args.includeFallbackColors = false;
628
- return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
629
- }
300
+ a2 = o2 >= 7;
301
+ }
302
+ return a2;
303
+ }, n.mostReadable = function(t2, e2, r2) {
304
+ var i2, a2, o2, s2, h2 = null, l2 = 0;
305
+ a2 = (r2 = r2 || {}).includeFallbackColors, o2 = r2.level, s2 = r2.size;
306
+ for (var u2 = 0; u2 < e2.length; u2++) (i2 = n.readability(t2, e2[u2])) > l2 && (l2 = i2, h2 = n(e2[u2]));
307
+ return n.isReadable(t2, h2, { level: o2, size: s2 }) || !a2 ? h2 : (r2.includeFallbackColors = false, n.mostReadable(t2, ["#fff", "#000"], r2));
630
308
  };
631
- var names = tinycolor.names = {
632
- aliceblue: "f0f8ff",
633
- antiquewhite: "faebd7",
634
- aqua: "0ff",
635
- aquamarine: "7fffd4",
636
- azure: "f0ffff",
637
- beige: "f5f5dc",
638
- bisque: "ffe4c4",
639
- black: "000",
640
- blanchedalmond: "ffebcd",
641
- blue: "00f",
642
- blueviolet: "8a2be2",
643
- brown: "a52a2a",
644
- burlywood: "deb887",
645
- burntsienna: "ea7e5d",
646
- cadetblue: "5f9ea0",
647
- chartreuse: "7fff00",
648
- chocolate: "d2691e",
649
- coral: "ff7f50",
650
- cornflowerblue: "6495ed",
651
- cornsilk: "fff8dc",
652
- crimson: "dc143c",
653
- cyan: "0ff",
654
- darkblue: "00008b",
655
- darkcyan: "008b8b",
656
- darkgoldenrod: "b8860b",
657
- darkgray: "a9a9a9",
658
- darkgreen: "006400",
659
- darkgrey: "a9a9a9",
660
- darkkhaki: "bdb76b",
661
- darkmagenta: "8b008b",
662
- darkolivegreen: "556b2f",
663
- darkorange: "ff8c00",
664
- darkorchid: "9932cc",
665
- darkred: "8b0000",
666
- darksalmon: "e9967a",
667
- darkseagreen: "8fbc8f",
668
- darkslateblue: "483d8b",
669
- darkslategray: "2f4f4f",
670
- darkslategrey: "2f4f4f",
671
- darkturquoise: "00ced1",
672
- darkviolet: "9400d3",
673
- deeppink: "ff1493",
674
- deepskyblue: "00bfff",
675
- dimgray: "696969",
676
- dimgrey: "696969",
677
- dodgerblue: "1e90ff",
678
- firebrick: "b22222",
679
- floralwhite: "fffaf0",
680
- forestgreen: "228b22",
681
- fuchsia: "f0f",
682
- gainsboro: "dcdcdc",
683
- ghostwhite: "f8f8ff",
684
- gold: "ffd700",
685
- goldenrod: "daa520",
686
- gray: "808080",
687
- green: "008000",
688
- greenyellow: "adff2f",
689
- grey: "808080",
690
- honeydew: "f0fff0",
691
- hotpink: "ff69b4",
692
- indianred: "cd5c5c",
693
- indigo: "4b0082",
694
- ivory: "fffff0",
695
- khaki: "f0e68c",
696
- lavender: "e6e6fa",
697
- lavenderblush: "fff0f5",
698
- lawngreen: "7cfc00",
699
- lemonchiffon: "fffacd",
700
- lightblue: "add8e6",
701
- lightcoral: "f08080",
702
- lightcyan: "e0ffff",
703
- lightgoldenrodyellow: "fafad2",
704
- lightgray: "d3d3d3",
705
- lightgreen: "90ee90",
706
- lightgrey: "d3d3d3",
707
- lightpink: "ffb6c1",
708
- lightsalmon: "ffa07a",
709
- lightseagreen: "20b2aa",
710
- lightskyblue: "87cefa",
711
- lightslategray: "789",
712
- lightslategrey: "789",
713
- lightsteelblue: "b0c4de",
714
- lightyellow: "ffffe0",
715
- lime: "0f0",
716
- limegreen: "32cd32",
717
- linen: "faf0e6",
718
- magenta: "f0f",
719
- maroon: "800000",
720
- mediumaquamarine: "66cdaa",
721
- mediumblue: "0000cd",
722
- mediumorchid: "ba55d3",
723
- mediumpurple: "9370db",
724
- mediumseagreen: "3cb371",
725
- mediumslateblue: "7b68ee",
726
- mediumspringgreen: "00fa9a",
727
- mediumturquoise: "48d1cc",
728
- mediumvioletred: "c71585",
729
- midnightblue: "191970",
730
- mintcream: "f5fffa",
731
- mistyrose: "ffe4e1",
732
- moccasin: "ffe4b5",
733
- navajowhite: "ffdead",
734
- navy: "000080",
735
- oldlace: "fdf5e6",
736
- olive: "808000",
737
- olivedrab: "6b8e23",
738
- orange: "ffa500",
739
- orangered: "ff4500",
740
- orchid: "da70d6",
741
- palegoldenrod: "eee8aa",
742
- palegreen: "98fb98",
743
- paleturquoise: "afeeee",
744
- palevioletred: "db7093",
745
- papayawhip: "ffefd5",
746
- peachpuff: "ffdab9",
747
- peru: "cd853f",
748
- pink: "ffc0cb",
749
- plum: "dda0dd",
750
- powderblue: "b0e0e6",
751
- purple: "800080",
752
- rebeccapurple: "663399",
753
- red: "f00",
754
- rosybrown: "bc8f8f",
755
- royalblue: "4169e1",
756
- saddlebrown: "8b4513",
757
- salmon: "fa8072",
758
- sandybrown: "f4a460",
759
- seagreen: "2e8b57",
760
- seashell: "fff5ee",
761
- sienna: "a0522d",
762
- silver: "c0c0c0",
763
- skyblue: "87ceeb",
764
- slateblue: "6a5acd",
765
- slategray: "708090",
766
- slategrey: "708090",
767
- snow: "fffafa",
768
- springgreen: "00ff7f",
769
- steelblue: "4682b4",
770
- tan: "d2b48c",
771
- teal: "008080",
772
- thistle: "d8bfd8",
773
- tomato: "ff6347",
774
- turquoise: "40e0d0",
775
- violet: "ee82ee",
776
- wheat: "f5deb3",
777
- white: "fff",
778
- whitesmoke: "f5f5f5",
779
- yellow: "ff0",
780
- yellowgreen: "9acd32"
781
- };
782
- var hexNames = tinycolor.hexNames = flip(names);
783
- function flip(o) {
784
- var flipped = {};
785
- for (var i in o) {
786
- if (o.hasOwnProperty(i)) {
787
- flipped[o[i]] = i;
788
- }
789
- }
790
- return flipped;
791
- }
792
- function boundAlpha(a) {
793
- a = parseFloat(a);
794
- if (isNaN(a) || a < 0 || a > 1) {
795
- a = 1;
796
- }
797
- return a;
798
- }
799
- function bound01(n, max) {
800
- if (isOnePointZero(n)) n = "100%";
801
- var processPercent = isPercentage(n);
802
- n = Math.min(max, Math.max(0, parseFloat(n)));
803
- if (processPercent) {
804
- n = parseInt(n * max, 10) / 100;
805
- }
806
- if (Math.abs(n - max) < 1e-6) {
807
- return 1;
808
- }
809
- return n % max / parseFloat(max);
810
- }
811
- function clamp01(val) {
812
- return Math.min(1, Math.max(0, val));
813
- }
814
- function parseIntFromHex(val) {
815
- return parseInt(val, 16);
816
- }
817
- function isOnePointZero(n) {
818
- return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
819
- }
820
- function isPercentage(n) {
821
- return typeof n === "string" && n.indexOf("%") != -1;
822
- }
823
- function pad2(c) {
824
- return c.length == 1 ? "0" + c : "" + c;
825
- }
826
- function convertToPercentage(n) {
827
- if (n <= 1) {
828
- n = n * 100 + "%";
829
- }
830
- return n;
831
- }
832
- function convertDecimalToHex(d) {
833
- return Math.round(parseFloat(d) * 255).toString(16);
834
- }
835
- function convertHexToDecimal(h) {
836
- return parseIntFromHex(h) / 255;
837
- }
838
- var matchers = (function() {
839
- var CSS_INTEGER = "[-\\+]?\\d+%?";
840
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
841
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
842
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
843
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
844
- return {
845
- CSS_UNIT: new RegExp(CSS_UNIT),
846
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
847
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
848
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
849
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
850
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
851
- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
852
- hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
853
- hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
854
- hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
855
- hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
856
- };
857
- })();
858
- function isValidCSSUnit(color) {
859
- return !!matchers.CSS_UNIT.exec(color);
860
- }
861
- function stringInputToObject(color) {
862
- color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
863
- var named = false;
864
- if (names[color]) {
865
- color = names[color];
866
- named = true;
867
- } else if (color == "transparent") {
868
- return {
869
- r: 0,
870
- g: 0,
871
- b: 0,
872
- a: 0,
873
- format: "name"
874
- };
875
- }
876
- var match;
877
- if (match = matchers.rgb.exec(color)) {
878
- return {
879
- r: match[1],
880
- g: match[2],
881
- b: match[3]
882
- };
883
- }
884
- if (match = matchers.rgba.exec(color)) {
885
- return {
886
- r: match[1],
887
- g: match[2],
888
- b: match[3],
889
- a: match[4]
890
- };
891
- }
892
- if (match = matchers.hsl.exec(color)) {
893
- return {
894
- h: match[1],
895
- s: match[2],
896
- l: match[3]
897
- };
898
- }
899
- if (match = matchers.hsla.exec(color)) {
900
- return {
901
- h: match[1],
902
- s: match[2],
903
- l: match[3],
904
- a: match[4]
905
- };
906
- }
907
- if (match = matchers.hsv.exec(color)) {
908
- return {
909
- h: match[1],
910
- s: match[2],
911
- v: match[3]
912
- };
913
- }
914
- if (match = matchers.hsva.exec(color)) {
915
- return {
916
- h: match[1],
917
- s: match[2],
918
- v: match[3],
919
- a: match[4]
920
- };
921
- }
922
- if (match = matchers.hex8.exec(color)) {
923
- return {
924
- r: parseIntFromHex(match[1]),
925
- g: parseIntFromHex(match[2]),
926
- b: parseIntFromHex(match[3]),
927
- a: convertHexToDecimal(match[4]),
928
- format: named ? "name" : "hex8"
929
- };
930
- }
931
- if (match = matchers.hex6.exec(color)) {
932
- return {
933
- r: parseIntFromHex(match[1]),
934
- g: parseIntFromHex(match[2]),
935
- b: parseIntFromHex(match[3]),
936
- format: named ? "name" : "hex"
937
- };
938
- }
939
- if (match = matchers.hex4.exec(color)) {
940
- return {
941
- r: parseIntFromHex(match[1] + "" + match[1]),
942
- g: parseIntFromHex(match[2] + "" + match[2]),
943
- b: parseIntFromHex(match[3] + "" + match[3]),
944
- a: convertHexToDecimal(match[4] + "" + match[4]),
945
- format: named ? "name" : "hex8"
946
- };
947
- }
948
- if (match = matchers.hex3.exec(color)) {
949
- return {
950
- r: parseIntFromHex(match[1] + "" + match[1]),
951
- g: parseIntFromHex(match[2] + "" + match[2]),
952
- b: parseIntFromHex(match[3] + "" + match[3]),
953
- format: named ? "name" : "hex"
954
- };
955
- }
956
- return false;
957
- }
958
- function validateWCAG2Parms(parms) {
959
- var level, size;
960
- parms = parms || {
961
- level: "AA",
962
- size: "small"
963
- };
964
- level = (parms.level || "AA").toUpperCase();
965
- size = (parms.size || "small").toLowerCase();
966
- if (level !== "AA" && level !== "AAA") {
967
- level = "AA";
968
- }
969
- if (size !== "small" && size !== "large") {
970
- size = "small";
971
- }
972
- return {
973
- level,
974
- size
975
- };
976
- }
977
- const styles = "/*\n[ Wj Color Picker ]\n*/\n\n.anchor {\n width: var(--wje-color-picker-size);\n height: var(--wje-color-picker-size);\n background: var(--wje-color-picker-value);\n}\n\n.picker {\n width: 200px;\n /*min-height: 90px;*/\n box-shadow:\n 0 0 5px rgba(0, 0, 0, 0.05),\n 0 5px 20px rgba(0, 0, 0, 0.1);\n border-radius: var(--wje-color-picker-radius);\n border-width: 1px;\n border-style: var(--wje-border-style);\n border-color: var(--wje-border-color);\n background: var(--wje-background);\n}\n\n.color-area {\n display: block;\n position: relative;\n height: 100px;\n color: var(--wje-color-picker-area);\n background-image: linear-gradient(rgba(0, 0, 0, 0), #000), linear-gradient(90deg, #fff, currentColor);\n cursor: crosshair;\n border-radius: var(--wje-color-picker-radius) var(--wje-color-picker-radius) 0 0;\n border-bottom: 1px solid var(--wje-border-color);\n}\n\n.wrapper {\n display: inline-table;\n width: calc(100% - 2rem);\n margin: 1rem;\n}\n\n.hue {\n border-radius: 0.25rem;\n background-image: linear-gradient(\n to right,\n rgb(255, 0, 0) 0%,\n rgb(255, 255, 0) 17%,\n rgb(0, 255, 0) 33%,\n rgb(0, 255, 255) 50%,\n rgb(0, 0, 255) 67%,\n rgb(255, 0, 255) 83%,\n rgb(255, 0, 0) 100%\n );\n width: 100%;\n height: 8px;\n margin: 0.75rem 0 1rem;\n}\n\n.hue::part(slider) {\n --wje-slider-color: transparent;\n --wje-slider-thumb-color: white;\n --wje-slider-thumb-shadow: 0 0 0 1px var(--wje-border-color);\n --wje-slider-thumb-shadow-active: var(--wje-slider-thumb-shadow);\n --wje-slider-track-color: transparent;\n}\n\n.alpha-wrapper {\n border-radius: 0.25rem;\n width: 100%;\n height: 8px;\n margin: 0.75rem 0 1rem;\n background-image:\n repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa),\n repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position:\n 0 0,\n 4px 4px;\n background-size: 8px 8px;\n}\n\n.alpha {\n color: var(--wje-color-picker-value);\n display: block;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n background-image: linear-gradient(90deg, rgba(0, 0, 0, 0), currentColor);\n}\n\n.alpha::part(slider) {\n --wje-slider-color: transparent;\n --wje-slider-thumb-color: white;\n --wje-slider-thumb-shadow: 0 0 0 1px var(--wje-border-color);\n --wje-slider-thumb-shadow-active: var(--wje-slider-thumb-shadow);\n --wje-slider-track-color: transparent;\n --wje-slider-track-height: 8px;\n}\n\n.input-wrapper {\n display: grid;\n align-items: center;\n grid-template-columns: 1fr auto;\n}\n\n.color-preview {\n width: 30px !important;\n height: 30px !important;\n border-radius: 50%;\n position: relative;\n margin-right: 1rem;\n &:before,\n &:after {\n content: '';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border: 1px solid #fff;\n border-radius: 50%;\n }\n &:before {\n background-image:\n repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa),\n repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position:\n 0 0,\n 4px 4px;\n background-size: 8px 8px;\n }\n &:after {\n background: var(--wje-color-picker-value, transparent);\n }\n}\n\nwje-input {\n --wje-input-border-radius: 1rem;\n --wje-input-margin-bottom: 0;\n}\n\nwje-input::part(input) {\n text-align: center;\n}\n\n.swatches {\n margin-top: 1rem;\n display: flex;\n justify-content: center;\n flex-wrap: wrap;\n}\n\n.swatch {\n background: var(--wje-color-picker-swatch, transparent);\n position: relative;\n width: 20px;\n height: 20px;\n margin: 0 4px 6px 4px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n color: inherit;\n white-space: nowrap;\n overflow: hidden;\n cursor: pointer;\n}\n\n.marker {\n position: absolute;\n width: 12px;\n height: 12px;\n margin: -6px 0 0 -6px;\n border: 1px solid #fff;\n border-radius: 50%;\n background-color: var(--wje-color-picker-value, transparent);\n cursor: pointer;\n}\n";
978
- class ColorPicker extends WJElement {
979
- /**
980
- * ColorPicker constructor method.
981
- */
309
+ var y = n.names = { aliceblue: "f0f8ff", antiquewhite: "faebd7", aqua: "0ff", aquamarine: "7fffd4", azure: "f0ffff", beige: "f5f5dc", bisque: "ffe4c4", black: "000", blanchedalmond: "ffebcd", blue: "00f", blueviolet: "8a2be2", brown: "a52a2a", burlywood: "deb887", burntsienna: "ea7e5d", cadetblue: "5f9ea0", chartreuse: "7fff00", chocolate: "d2691e", coral: "ff7f50", cornflowerblue: "6495ed", cornsilk: "fff8dc", crimson: "dc143c", cyan: "0ff", darkblue: "00008b", darkcyan: "008b8b", darkgoldenrod: "b8860b", darkgray: "a9a9a9", darkgreen: "006400", darkgrey: "a9a9a9", darkkhaki: "bdb76b", darkmagenta: "8b008b", darkolivegreen: "556b2f", darkorange: "ff8c00", darkorchid: "9932cc", darkred: "8b0000", darksalmon: "e9967a", darkseagreen: "8fbc8f", darkslateblue: "483d8b", darkslategray: "2f4f4f", darkslategrey: "2f4f4f", darkturquoise: "00ced1", darkviolet: "9400d3", deeppink: "ff1493", deepskyblue: "00bfff", dimgray: "696969", dimgrey: "696969", dodgerblue: "1e90ff", firebrick: "b22222", floralwhite: "fffaf0", forestgreen: "228b22", fuchsia: "f0f", gainsboro: "dcdcdc", ghostwhite: "f8f8ff", gold: "ffd700", goldenrod: "daa520", gray: "808080", green: "008000", greenyellow: "adff2f", grey: "808080", honeydew: "f0fff0", hotpink: "ff69b4", indianred: "cd5c5c", indigo: "4b0082", ivory: "fffff0", khaki: "f0e68c", lavender: "e6e6fa", lavenderblush: "fff0f5", lawngreen: "7cfc00", lemonchiffon: "fffacd", lightblue: "add8e6", lightcoral: "f08080", lightcyan: "e0ffff", lightgoldenrodyellow: "fafad2", lightgray: "d3d3d3", lightgreen: "90ee90", lightgrey: "d3d3d3", lightpink: "ffb6c1", lightsalmon: "ffa07a", lightseagreen: "20b2aa", lightskyblue: "87cefa", lightslategray: "789", lightslategrey: "789", lightsteelblue: "b0c4de", lightyellow: "ffffe0", lime: "0f0", limegreen: "32cd32", linen: "faf0e6", magenta: "f0f", maroon: "800000", mediumaquamarine: "66cdaa", mediumblue: "0000cd", mediumorchid: "ba55d3", mediumpurple: "9370db", mediumseagreen: "3cb371", mediumslateblue: "7b68ee", mediumspringgreen: "00fa9a", mediumturquoise: "48d1cc", mediumvioletred: "c71585", midnightblue: "191970", mintcream: "f5fffa", mistyrose: "ffe4e1", moccasin: "ffe4b5", navajowhite: "ffdead", navy: "000080", oldlace: "fdf5e6", olive: "808000", olivedrab: "6b8e23", orange: "ffa500", orangered: "ff4500", orchid: "da70d6", palegoldenrod: "eee8aa", palegreen: "98fb98", paleturquoise: "afeeee", palevioletred: "db7093", papayawhip: "ffefd5", peachpuff: "ffdab9", peru: "cd853f", pink: "ffc0cb", plum: "dda0dd", powderblue: "b0e0e6", purple: "800080", rebeccapurple: "663399", red: "f00", rosybrown: "bc8f8f", royalblue: "4169e1", saddlebrown: "8b4513", salmon: "fa8072", sandybrown: "f4a460", seagreen: "2e8b57", seashell: "fff5ee", sienna: "a0522d", silver: "c0c0c0", skyblue: "87ceeb", slateblue: "6a5acd", slategray: "708090", slategrey: "708090", snow: "fffafa", springgreen: "00ff7f", steelblue: "4682b4", tan: "d2b48c", teal: "008080", thistle: "d8bfd8", tomato: "ff6347", turquoise: "40e0d0", violet: "ee82ee", wheat: "f5deb3", white: "fff", whitesmoke: "f5f5f5", yellow: "ff0", yellowgreen: "9acd32" }, A = n.hexNames = (function(t2) {
310
+ var e2 = {};
311
+ for (var r2 in t2) t2.hasOwnProperty(r2) && (e2[t2[r2]] = r2);
312
+ return e2;
313
+ })(y);
314
+ function _(t2) {
315
+ return t2 = parseFloat(t2), (isNaN(t2) || t2 < 0 || t2 > 1) && (t2 = 1), t2;
316
+ }
317
+ function M(t2, e2) {
318
+ (function(t3) {
319
+ return "string" == typeof t3 && -1 != t3.indexOf(".") && 1 === parseFloat(t3);
320
+ })(t2) && (t2 = "100%");
321
+ var r2 = (function(t3) {
322
+ return "string" == typeof t3 && -1 != t3.indexOf("%");
323
+ })(t2);
324
+ return t2 = Math.min(e2, Math.max(0, parseFloat(t2))), r2 && (t2 = parseInt(t2 * e2, 10) / 100), Math.abs(t2 - e2) < 1e-6 ? 1 : t2 % e2 / parseFloat(e2);
325
+ }
326
+ function S(t2) {
327
+ return Math.min(1, Math.max(0, t2));
328
+ }
329
+ function j(t2) {
330
+ return parseInt(t2, 16);
331
+ }
332
+ function H(t2) {
333
+ return 1 == t2.length ? "0" + t2 : "" + t2;
334
+ }
335
+ function P(t2) {
336
+ return t2 <= 1 && (t2 = 100 * t2 + "%"), t2;
337
+ }
338
+ function C(t2) {
339
+ return Math.round(255 * parseFloat(t2)).toString(16);
340
+ }
341
+ function E(t2) {
342
+ return j(t2) / 255;
343
+ }
344
+ var F, L, R, N = (L = "[\\s|\\(]+(" + (F = "(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)") + ")[,|\\s]+(" + F + ")[,|\\s]+(" + F + ")\\s*\\)?", R = "[\\s|\\(]+(" + F + ")[,|\\s]+(" + F + ")[,|\\s]+(" + F + ")[,|\\s]+(" + F + ")\\s*\\)?", { CSS_UNIT: new RegExp(F), rgb: new RegExp("rgb" + L), rgba: new RegExp("rgba" + R), hsl: new RegExp("hsl" + L), hsla: new RegExp("hsla" + R), hsv: new RegExp("hsv" + L), hsva: new RegExp("hsva" + R), hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ });
345
+ function D(t2) {
346
+ return !!N.CSS_UNIT.exec(t2);
347
+ }
348
+ class I extends t {
982
349
  constructor() {
983
350
  super();
984
- __privateAdd(this, _init, false);
351
+ __privateAdd(this, _t, false);
985
352
  __publicField(this, "className", "ColorPicker");
986
- /**
987
- * Updates the position of the marker based on the pointer event.
988
- * This function calculates the position of the marker relative to the color area
989
- * dimensions based on the given event. It adjusts the marker position and updates
990
- * the color associated with the new position. It is intended to handle pointer movement
991
- * events such as mouse or touch interactions.
992
- * @param {Event} e The event triggering the marker movement, typically a mouse or touch event.
993
- */
994
- __publicField(this, "moveMarker", (e) => {
353
+ __publicField(this, "moveMarker", (t2) => {
995
354
  var _a;
996
355
  this.colorAreaDimension = this.dimension();
997
- const pointer = this.getPointerPosition(e);
998
- const x = pointer.x - this.colorAreaDimension.x;
999
- const y = pointer.y - this.colorAreaDimension.y;
1000
- const markerPosition = this.clampMarkerPosition(x, y);
1001
- const alpha = Number(((_a = this.alphaSlider) == null ? void 0 : _a.value) || 100);
1002
- this.setColor(this.setColorAtPosition(markerPosition.x, markerPosition.y, alpha), "marker");
1003
- this.setMarkerPosition(markerPosition.x, markerPosition.y);
356
+ const e2 = this.getPointerPosition(t2), r2 = e2.x - this.colorAreaDimension.x, i2 = e2.y - this.colorAreaDimension.y, a2 = this.clampMarkerPosition(r2, i2), n2 = Number(((_a = this.alphaSlider) == null ? void 0 : _a.value) || 100);
357
+ this.setColor(this.setColorAtPosition(a2.x, a2.y, n2), "marker"), this.setMarkerPosition(a2.x, a2.y);
1004
358
  });
1005
- /**
1006
- * Sets the marker position by color.
1007
- * @param color
1008
- * @returns {{x: number, y: number}}
1009
- */
1010
- __publicField(this, "setMarkerPositionByColor", (color = "red") => {
359
+ __publicField(this, "setMarkerPositionByColor", (t2 = "red") => {
1011
360
  var _a, _b;
1012
- let hsva = tinycolor(color).toHsv();
1013
- const width = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0;
1014
- const height = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0;
1015
- const safeS = Number.isFinite(hsva.s) ? hsva.s : 0;
1016
- const safeV = Number.isFinite(hsva.v) ? hsva.v : 0;
1017
- return {
1018
- x: width * safeS,
1019
- y: height - height * safeV
1020
- };
361
+ let e2 = n(t2).toHsv();
362
+ const r2 = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0, i2 = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0;
363
+ return { x: r2 * (Number.isFinite(e2.s) ? e2.s : 0), y: i2 - i2 * (Number.isFinite(e2.v) ? e2.v : 0) };
1021
364
  });
1022
- /**
1023
- * Updates the color picker's current color and its associated UI elements.
1024
- * @param {tinycolor.Instance|null} [color] The color value to set. If null, the current value from the input field is used.
1025
- * @param {string} [type] The type of action determining which UI element to update. Possible values: "marker", "hue", "alpha", "swatch", "input".
1026
- */
1027
- __publicField(this, "setColor", (color = null, type = "") => {
1028
- let currentColor = color;
1029
- if (currentColor === null && type === "") {
1030
- currentColor = tinycolor(this.input.value);
1031
- this.colorArea.style.setProperty("--wje-color-picker-area", currentColor.toHexString());
1032
- }
1033
- if (type === "marker") {
1034
- this.alphaSlider.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1035
- this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
1036
- this.picker.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1037
- this.marker.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
1038
- }
1039
- if (type === "hue") {
1040
- let markerColorByPosition = this.setColorAtPosition(
1041
- this.markerPosition.x,
1042
- this.markerPosition.y,
1043
- this.alphaSlider.value
1044
- );
1045
- const hueColor = this.getHueAreaColor(this.getHSVA(this.hueSlider.value, 100));
1046
- this.colorPreview.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHex8String());
1047
- this.marker.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHexString());
1048
- this.alphaSlider.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHexString());
1049
- this.colorArea.style.setProperty("--wje-color-picker-area", hueColor);
1050
- this.input.value = markerColorByPosition.toHex8String();
1051
- currentColor = markerColorByPosition;
365
+ __publicField(this, "setColor", (t2 = null, r2 = "") => {
366
+ let i2 = t2;
367
+ if (null === i2 && "" === r2 && (i2 = n(this.input.value), this.colorArea.style.setProperty("--wje-color-picker-area", i2.toHexString())), "marker" === r2 && (this.alphaSlider.style.setProperty("--wje-color-picker-value", i2.toHexString()), this.colorPreview.style.setProperty("--wje-color-picker-value", i2.toHex8String()), this.picker.style.setProperty("--wje-color-picker-value", i2.toHexString()), this.marker.style.setProperty("--wje-color-picker-value", i2.toHex8String())), "hue" === r2) {
368
+ let t3 = this.setColorAtPosition(this.markerPosition.x, this.markerPosition.y, this.alphaSlider.value);
369
+ const e2 = this.getHueAreaColor(this.getHSVA(this.hueSlider.value, 100));
370
+ this.colorPreview.style.setProperty("--wje-color-picker-value", t3.toHex8String()), this.marker.style.setProperty("--wje-color-picker-value", t3.toHexString()), this.alphaSlider.style.setProperty("--wje-color-picker-value", t3.toHexString()), this.colorArea.style.setProperty("--wje-color-picker-area", e2), this.input.value = t3.toHex8String(), i2 = t3;
1052
371
  }
1053
- if (type === "alpha") {
1054
- currentColor = tinycolor(this.input.value);
1055
- let hsv = currentColor.toHsv();
1056
- hsv.a = this.alphaSlider.value / 100;
1057
- currentColor = tinycolor(hsv);
1058
- this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
372
+ if ("alpha" === r2) {
373
+ i2 = n(this.input.value);
374
+ let t3 = i2.toHsv();
375
+ t3.a = this.alphaSlider.value / 100, i2 = n(t3), this.colorPreview.style.setProperty("--wje-color-picker-value", i2.toHex8String());
1059
376
  }
1060
- if (type === "swatch" || type === "init" || type === "input") {
1061
- this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
1062
- this.marker.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1063
- this.alphaSlider.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1064
- this.colorArea.style.setProperty("--wje-color-picker-area", this.getHueAreaColor(currentColor.toHex8String()));
1065
- this.markerPosition = this.setMarkerPositionByColor(currentColor.toHex8String());
1066
- this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y);
1067
- }
1068
- if (!(currentColor == null ? void 0 : currentColor.isValid())) return;
1069
- if (!this.noColorArea || !this.noControls || !this.noSwatches) {
1070
- if (type === "input" && this.inputEditable && typeof this._manualInputValue === "string") {
1071
- this.input.value = this._manualInputValue;
1072
- } else {
1073
- this.input.value = currentColor.toHex8String();
1074
- }
1075
- }
1076
- this.anchor.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1077
- this.value = {
1078
- hex8: currentColor.toHex8String(),
1079
- hex: currentColor.toHexString(),
1080
- rgb: currentColor.toRgbString(),
1081
- rgba: currentColor.toRgbString(),
1082
- hsl: currentColor.toHslString(),
1083
- hsla: currentColor.toHslString(),
1084
- hsv: currentColor.toHsvString(),
1085
- hsva: currentColor.toHsvString(),
1086
- name: currentColor.toName(),
1087
- format: currentColor.getFormat()
1088
- };
1089
- this.color = currentColor.toHex8String();
1090
- event.dispatchCustomEvent(this, "wje-color-picker:select", {
1091
- value: this.value
1092
- });
1093
- });
1094
- /**
1095
- * Sets the hue.
1096
- * @param {object} e The event object.
1097
- */
1098
- __publicField(this, "setHue", (e) => {
1099
- this.hueSlider.value = e.detail.value;
1100
- this.setColor(null, "hue");
377
+ "swatch" !== r2 && "init" !== r2 && "input" !== r2 || (this.colorPreview.style.setProperty("--wje-color-picker-value", i2.toHex8String()), this.marker.style.setProperty("--wje-color-picker-value", i2.toHexString()), this.alphaSlider.style.setProperty("--wje-color-picker-value", i2.toHexString()), this.colorArea.style.setProperty("--wje-color-picker-area", this.getHueAreaColor(i2.toHex8String())), this.markerPosition = this.setMarkerPositionByColor(i2.toHex8String()), this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y)), (i2 == null ? void 0 : i2.isValid()) && (this.noColorArea && this.noControls && this.noSwatches || ("input" === r2 && this.inputEditable && "string" == typeof this._manualInputValue ? this.input.value = this._manualInputValue : this.input.value = i2.toHex8String()), this.anchor.style.setProperty("--wje-color-picker-value", i2.toHexString()), this.value = { hex8: i2.toHex8String(), hex: i2.toHexString(), rgb: i2.toRgbString(), rgba: i2.toRgbString(), hsl: i2.toHslString(), hsla: i2.toHslString(), hsv: i2.toHsvString(), hsva: i2.toHsvString(), name: i2.toName(), format: i2.getFormat() }, this.color = i2.toHex8String(), e.dispatchCustomEvent(this, "wje-color-picker:select", { value: this.value }));
1101
378
  });
1102
- /**
1103
- * Sets the alpha.
1104
- * @param {object} e The event object.
1105
- */
1106
- __publicField(this, "setAlpha", (e) => {
1107
- this.alphaSlider.value = e.detail.value;
1108
- this.setColor(null, "alpha");
379
+ __publicField(this, "setHue", (t2) => {
380
+ this.hueSlider.value = t2.detail.value, this.setColor(null, "hue");
1109
381
  });
1110
- /**
1111
- * Converts hue and alpha values into an HSVA color string.
1112
- * @param {number} hue The hue value, typically between 0 and 360.
1113
- * @param {number} alpha The alpha value, typically between 0 and 100, representing the opacity percentage.
1114
- * @returns {string} - The HSVA color string in the format `hsva(h, 100%, 100%, a)`.
1115
- */
1116
- __publicField(this, "getHSVA", (hue, alpha) => {
1117
- return `hsva(${hue}, 100%, 100%, ${alpha / 100})`;
382
+ __publicField(this, "setAlpha", (t2) => {
383
+ this.alphaSlider.value = t2.detail.value, this.setColor(null, "alpha");
1118
384
  });
1119
- this._markerPosition = {
1120
- markerX: "0",
1121
- markerY: "0"
1122
- };
1123
- this._swatches = [
1124
- "#264653",
1125
- "#2a9d8f",
1126
- "#e9c46a",
1127
- "rgb(244,162,97)",
1128
- "#e76f51",
1129
- "#d62828",
1130
- "navy",
1131
- "#07b",
1132
- "#0096c7",
1133
- "#00b4d880",
1134
- "rgba(0,119,182,0.8)"
1135
- ];
1136
- this._manualInputValue = null;
385
+ __publicField(this, "getHSVA", (t2, e2) => `hsva(${t2}, 100%, 100%, ${e2 / 100})`);
386
+ this._markerPosition = { markerX: "0", markerY: "0" }, this._swatches = ["#264653", "#2a9d8f", "#e9c46a", "rgb(244,162,97)", "#e76f51", "#d62828", "navy", "#07b", "#0096c7", "#00b4d880", "rgba(0,119,182,0.8)"], this._manualInputValue = null;
1137
387
  }
1138
- /**
1139
- * Sets the color attribute of the element.
1140
- * @param {string} value The color value to be set. It should be a valid color string such as a named color, HEX, RGB, or HSL format.
1141
- */
1142
- set color(value) {
1143
- this.setAttribute("color", value);
388
+ set color(t2) {
389
+ this.setAttribute("color", t2);
1144
390
  }
1145
- /**
1146
- * Retrieves the color attribute of the element.
1147
- * @returns {string | null} The current value of the 'color' attribute, or null if the attribute is not set.
1148
- */
1149
391
  get color() {
1150
392
  return this.getAttribute("color") || "#000000";
1151
393
  }
1152
- /**
1153
- * Setter for the marker position.
1154
- * @param {object} value The new marker position.
1155
- */
1156
- set markerPosition(value) {
1157
- this._markerPosition = value;
394
+ set markerPosition(t2) {
395
+ this._markerPosition = t2;
1158
396
  }
1159
- /**
1160
- * Getter for the marker position.
1161
- * @returns {object} The current marker position.
1162
- */
1163
397
  get markerPosition() {
1164
398
  return this._markerPosition;
1165
399
  }
1166
- /**
1167
- * Setter for the color swatches.
1168
- * @param {string} value The new color swatches.
1169
- */
1170
- set swatches(value) {
1171
- if (Array.isArray(value)) {
1172
- this.setAttribute("swatches", value.join(","));
1173
- return;
1174
- }
1175
- this.setAttribute("swatches", this.parseSwatches(value).join(","));
400
+ set swatches(t2) {
401
+ Array.isArray(t2) ? this.setAttribute("swatches", t2.join(",")) : this.setAttribute("swatches", this.parseSwatches(t2).join(","));
1176
402
  }
1177
- /**
1178
- * Getter for the color swatches.
1179
- * @returns {Array} The current color swatches.
1180
- */
1181
403
  get swatches() {
1182
- this._swatches = this.getAttribute("swatches") ? this.parseSwatches(this.getAttribute("swatches")) : this._swatches;
1183
- return this._swatches;
404
+ return this._swatches = this.getAttribute("swatches") ? this.parseSwatches(this.getAttribute("swatches")) : this._swatches, this._swatches;
1184
405
  }
1185
- /**
1186
- * Normalizes swatch colors from a string to an array.
1187
- * Supports comma and semicolon separators.
1188
- * @param {string} value
1189
- * @returns {string[]}
1190
- */
1191
- parseSwatches(value = "") {
1192
- if (typeof value !== "string") return [];
1193
- return value.split(/[;,]/).map((item) => item.trim()).filter(Boolean);
406
+ parseSwatches(t2 = "") {
407
+ return "string" != typeof t2 ? [] : t2.split(/[;,]/).map((t3) => t3.trim()).filter(Boolean);
1194
408
  }
1195
- /**
1196
- * Sets or removes the 'no-color-area' attribute based on the provided value.
1197
- * @param {boolean} value A boolean value indicating whether to set or remove the 'no-color-area' attribute. If true, the attribute is added; if false, the attribute is removed.
1198
- */
1199
- set noColorArea(value) {
1200
- if (value) {
1201
- this.setAttribute("no-color-area", "");
1202
- } else {
1203
- this.removeAttribute("no-color-area");
1204
- }
409
+ set noColorArea(t2) {
410
+ t2 ? this.setAttribute("no-color-area", "") : this.removeAttribute("no-color-area");
1205
411
  }
1206
- /**
1207
- * Getter method to check if the 'no-color-area' attribute is applied.
1208
- * @returns {boolean} Returns true if the 'no-color-area' attribute is present; otherwise, false.
1209
- */
1210
412
  get noColorArea() {
1211
413
  return this.hasAttribute("no-color-area");
1212
414
  }
1213
- /**
1214
- * Sets or removes the "no-controls" attribute.
1215
- * @param {boolean} value If true, sets the "no-controls" attribute. If false, removes the "no-controls" attribute.
1216
- */
1217
- set noControls(value) {
1218
- if (value) {
1219
- this.setAttribute("no-controls", "");
1220
- } else {
1221
- this.removeAttribute("no-controls");
1222
- }
415
+ set noControls(t2) {
416
+ t2 ? this.setAttribute("no-controls", "") : this.removeAttribute("no-controls");
1223
417
  }
1224
- /**
1225
- * Checks if the 'no-controls' attribute is present on the element.
1226
- * @returns {boolean} Returns true if the 'no-controls' attribute is present; otherwise, false.
1227
- */
1228
418
  get noControls() {
1229
419
  return this.hasAttribute("no-controls");
1230
420
  }
1231
- /**
1232
- * Sets or removes the 'no-swatches' attribute on the element.
1233
- * If the value is truthy, the 'no-swatches' attribute is added.
1234
- * If the value is falsy, the 'no-swatches' attribute is removed.
1235
- * @param {boolean} value Determines whether the 'no-swatches' attribute is set (true) or removed (false).
1236
- */
1237
- set noSwatches(value) {
1238
- if (value) {
1239
- this.setAttribute("no-swatches", "");
1240
- } else {
1241
- this.removeAttribute("no-swatches");
1242
- }
421
+ set noSwatches(t2) {
422
+ t2 ? this.setAttribute("no-swatches", "") : this.removeAttribute("no-swatches");
1243
423
  }
1244
- /**
1245
- * Checks if the 'no-swatches' attribute is present on the element.
1246
- * @returns {boolean} Returns true if the 'no-swatches' attribute is present; otherwise, false.
1247
- */
1248
424
  get noSwatches() {
1249
425
  return this.hasAttribute("no-swatches");
1250
426
  }
1251
- /**
1252
- * Enables/disables manual typing in the input.
1253
- * @param {boolean} value
1254
- */
1255
- set inputEditable(value) {
1256
- if (value) {
1257
- this.setAttribute("input-editable", "");
1258
- } else {
1259
- this.removeAttribute("input-editable");
1260
- }
427
+ set inputEditable(t2) {
428
+ t2 ? this.setAttribute("input-editable", "") : this.removeAttribute("input-editable");
1261
429
  }
1262
- /**
1263
- * Returns true when manual input typing is enabled.
1264
- * @returns {boolean}
1265
- */
1266
430
  get inputEditable() {
1267
431
  return this.hasAttribute("input-editable");
1268
432
  }
1269
- /**
1270
- * Getter for the CSS stylesheet.
1271
- * @returns {object} The styles object.
1272
- * @static
1273
- */
1274
433
  static get cssStyleSheet() {
1275
- return styles;
434
+ return '.anchor{width:var(--wje-color-picker-size);height:var(--wje-color-picker-size);background:var(--wje-color-picker-value)}.picker{width:200px;box-shadow:0 0 5px #0000000d,0 5px 20px #0000001a;border-radius:var(--wje-color-picker-radius);border-width:1px;border-style:var(--wje-border-style);border-color:var(--wje-border-color);background:var(--wje-background)}.color-area{display:block;position:relative;height:100px;color:var(--wje-color-picker-area);background-image:linear-gradient(#0000,#000),linear-gradient(90deg,#fff,currentColor);cursor:crosshair;border-radius:var(--wje-color-picker-radius) var(--wje-color-picker-radius) 0 0;border-bottom:1px solid var(--wje-border-color)}.wrapper{display:inline-table;width:calc(100% - 2rem);margin:1rem}.hue{border-radius:.25rem;background-image:linear-gradient(to right,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red);width:100%;height:8px;margin:.75rem 0 1rem}.hue::part(slider){--wje-slider-color: transparent;--wje-slider-thumb-color: white;--wje-slider-thumb-shadow: 0 0 0 1px var(--wje-border-color);--wje-slider-thumb-shadow-active: var(--wje-slider-thumb-shadow);--wje-slider-track-color: transparent}.alpha-wrapper{border-radius:.25rem;width:100%;height:8px;margin:.75rem 0 1rem;background-image:repeating-linear-gradient(45deg,#aaa 25%,transparent 25%,transparent 75%,#aaa 75%,#aaa),repeating-linear-gradient(45deg,#aaa 25%,#fff 25%,#fff 75%,#aaa 75%,#aaa);background-position:0 0,4px 4px;background-size:8px 8px}.alpha{color:var(--wje-color-picker-value);display:block;height:100%;width:100%;border-radius:inherit;background-image:linear-gradient(90deg,rgba(0,0,0,0),currentColor)}.alpha::part(slider){--wje-slider-color: transparent;--wje-slider-thumb-color: white;--wje-slider-thumb-shadow: 0 0 0 1px var(--wje-border-color);--wje-slider-thumb-shadow-active: var(--wje-slider-thumb-shadow);--wje-slider-track-color: transparent;--wje-slider-track-height: 8px}.input-wrapper{display:grid;align-items:center;grid-template-columns:1fr auto}.color-preview{width:30px!important;height:30px!important;border-radius:50%;position:relative;margin-right:1rem}.color-preview:before,.color-preview:after{content:"";position:absolute;height:100%;width:100%;left:0;top:0;border:1px solid #fff;border-radius:50%}.color-preview:before{background-image:repeating-linear-gradient(45deg,#aaa 25%,transparent 25%,transparent 75%,#aaa 75%,#aaa),repeating-linear-gradient(45deg,#aaa 25%,#fff 25%,#fff 75%,#aaa 75%,#aaa);background-position:0 0,4px 4px;background-size:8px 8px}.color-preview:after{background:var(--wje-color-picker-value, transparent)}wje-input{--wje-input-border-radius: 1rem;--wje-input-margin-bottom: 0}wje-input::part(input){text-align:center}.swatches{margin-top:1rem;display:flex;justify-content:center;flex-wrap:wrap}.swatch{background:var(--wje-color-picker-swatch, transparent);position:relative;width:20px;height:20px;margin:0 4px 6px;padding:0;border:0;border-radius:50%;color:inherit;white-space:nowrap;overflow:hidden;cursor:pointer}.marker{position:absolute;width:12px;height:12px;margin:-6px 0 0 -6px;border:1px solid #fff;border-radius:50%;background-color:var(--wje-color-picker-value, transparent);cursor:pointer}';
1276
435
  }
1277
- /**
1278
- * Getter for the observed attributes.
1279
- * @returns {Array} An empty array.
1280
- * @static
1281
- */
1282
436
  static get observedAttributes() {
1283
437
  return [];
1284
438
  }
1285
- /**
1286
- * Sets up the attributes for the ColorPicker.
1287
- */
1288
439
  setupAttributes() {
1289
440
  this.isShadowRoot = "open";
1290
441
  }
1291
- /**
1292
- * Creates and returns a document fragment containing the structure and components of a custom color picker.
1293
- * The method initializes DOM elements such as divs, sliders, and inputs, with specific classes and attributes,
1294
- * and attaches various event listeners to handle user interactions.
1295
- * @returns {DocumentFragment} A DocumentFragment containing the constructed and fully initialized DOM elements for the color picker.
1296
- */
1297
442
  draw() {
1298
- let fragment = document.createDocumentFragment();
1299
- let native = document.createElement("div");
1300
- native.classList.add("native-color-picker");
1301
- let anchor = document.createElement("div");
1302
- anchor.setAttribute("slot", "anchor");
1303
- anchor.setAttribute("part", "anchor");
1304
- anchor.classList.add("anchor");
1305
- let picker = document.createElement("div");
1306
- picker.classList.add("picker");
1307
- let marker = document.createElement("div");
1308
- marker.classList.add("marker");
1309
- let colorArea = document.createElement("div");
1310
- colorArea.classList.add("color-area");
1311
- colorArea.addEventListener("click", this.moveMarker);
1312
- colorArea.addEventListener("mousedown", (e) => {
1313
- e.preventDefault();
1314
- const stopMoving = () => {
1315
- window.removeEventListener("mousemove", this.moveMarker);
1316
- window.removeEventListener("mouseup", stopMoving);
443
+ let t2 = document.createDocumentFragment(), e2 = document.createElement("div");
444
+ e2.classList.add("native-color-picker");
445
+ let r2 = document.createElement("div");
446
+ r2.setAttribute("slot", "anchor"), r2.setAttribute("part", "anchor"), r2.classList.add("anchor");
447
+ let i2 = document.createElement("div");
448
+ i2.classList.add("picker");
449
+ let a2 = document.createElement("div");
450
+ a2.classList.add("marker");
451
+ let o2 = document.createElement("div");
452
+ o2.classList.add("color-area"), o2.addEventListener("click", this.moveMarker), o2.addEventListener("mousedown", (t3) => {
453
+ t3.preventDefault();
454
+ const e3 = () => {
455
+ window.removeEventListener("mousemove", this.moveMarker), window.removeEventListener("mouseup", e3);
1317
456
  };
1318
- window.addEventListener("mousemove", this.moveMarker);
1319
- window.addEventListener("mouseup", stopMoving);
1320
- this.moveMarker(e);
457
+ window.addEventListener("mousemove", this.moveMarker), window.addEventListener("mouseup", e3), this.moveMarker(t3);
1321
458
  });
1322
- let wrapper = document.createElement("div");
1323
- wrapper.classList.add("wrapper");
1324
- let hueSlider = document.createElement("wje-slider");
1325
- hueSlider.setAttribute("min", "0");
1326
- hueSlider.setAttribute("max", "360");
1327
- hueSlider.classList.add("hue");
1328
- hueSlider.addEventListener("wje-slider:move", this.setHue);
1329
- let alphaWrapper = document.createElement("div");
1330
- alphaWrapper.classList.add("alpha-wrapper");
1331
- let alphaSlider = document.createElement("wje-slider");
1332
- alphaSlider.setAttribute("min", "0");
1333
- alphaSlider.setAttribute("max", "100");
1334
- alphaSlider.setAttribute("value", "50");
1335
- alphaSlider.classList.add("alpha");
1336
- alphaSlider.addEventListener("wje-slider:move", this.setAlpha);
1337
- let inputWrapper = document.createElement("div");
1338
- inputWrapper.classList.add("input-wrapper");
1339
- let colorPreview = document.createElement("div");
1340
- colorPreview.classList.add("color-preview");
1341
- let input = document.createElement("wje-input");
1342
- input.setAttribute("variant", "standard");
1343
- input.setAttribute("maxlength", "9");
1344
- if ((!this.noColorArea || !this.noControls || !this.noSwatches) && !this.inputEditable)
1345
- input.setAttribute("readonly", "");
1346
- input.classList.add("input");
1347
- input.addEventListener("wje-input:input", () => {
1348
- let rawValue = (input.value || "").trim();
1349
- const hasHashPrefix = rawValue.startsWith("#");
1350
- const maxLength = hasHashPrefix ? 9 : 8;
1351
- if (rawValue.length > maxLength) {
1352
- rawValue = rawValue.slice(0, maxLength);
1353
- input.value = rawValue;
1354
- }
1355
- const hexCandidate = hasHashPrefix ? rawValue.slice(1) : rawValue;
1356
- const isHex = /^[0-9a-fA-F]+$/.test(hexCandidate);
1357
- if (isHex) {
1358
- if (hexCandidate.length < 6) return;
1359
- if (![6, 8].includes(hexCandidate.length)) return;
459
+ let s2 = document.createElement("div");
460
+ s2.classList.add("wrapper");
461
+ let h2 = document.createElement("wje-slider");
462
+ h2.setAttribute("min", "0"), h2.setAttribute("max", "360"), h2.classList.add("hue"), h2.addEventListener("wje-slider:move", this.setHue);
463
+ let l2 = document.createElement("div");
464
+ l2.classList.add("alpha-wrapper");
465
+ let u2 = document.createElement("wje-slider");
466
+ u2.setAttribute("min", "0"), u2.setAttribute("max", "100"), u2.setAttribute("value", "50"), u2.classList.add("alpha"), u2.addEventListener("wje-slider:move", this.setAlpha);
467
+ let c2 = document.createElement("div");
468
+ c2.classList.add("input-wrapper");
469
+ let d2 = document.createElement("div");
470
+ d2.classList.add("color-preview");
471
+ let f2 = document.createElement("wje-input");
472
+ return f2.setAttribute("variant", "standard"), f2.setAttribute("maxlength", "9"), this.noColorArea && this.noControls && this.noSwatches || this.inputEditable || f2.setAttribute("readonly", ""), f2.classList.add("input"), f2.addEventListener("wje-input:input", () => {
473
+ let t3 = (f2.value || "").trim();
474
+ const e3 = t3.startsWith("#"), r3 = e3 ? 9 : 8;
475
+ t3.length > r3 && (t3 = t3.slice(0, r3), f2.value = t3);
476
+ const i3 = e3 ? t3.slice(1) : t3, a3 = /^[0-9a-fA-F]+$/.test(i3);
477
+ if (a3) {
478
+ if (i3.length < 6) return;
479
+ if (![6, 8].includes(i3.length)) return;
1360
480
  }
1361
- const parsedColor = tinycolor(isHex ? `#${hexCandidate}` : rawValue);
1362
- if (!parsedColor.isValid()) return;
1363
- this._manualInputValue = rawValue;
1364
- this.setSliders(parsedColor.toHex8String());
1365
- this.setColor(parsedColor, "input");
1366
- this._manualInputValue = null;
1367
- });
1368
- colorArea.append(marker);
1369
- alphaWrapper.append(alphaSlider);
1370
- inputWrapper.append(colorPreview, input);
1371
- if (!this.noControls)
1372
- wrapper.append(hueSlider, alphaWrapper);
1373
- wrapper.append(inputWrapper);
1374
- if (!this.noColorArea)
1375
- picker.append(colorArea);
1376
- picker.append(wrapper);
1377
- if (!this.noSwatches)
1378
- this.createSwatches(wrapper);
1379
- native.append(picker);
1380
- fragment.append(native);
1381
- this.anchor = anchor;
1382
- this.picker = picker;
1383
- this.marker = marker;
1384
- this.colorArea = colorArea;
1385
- this.hueSlider = hueSlider;
1386
- this.alphaSlider = alphaSlider;
1387
- this.colorPreview = colorPreview;
1388
- this.input = input;
1389
- return fragment;
481
+ const o3 = n(a3 ? `#${i3}` : t3);
482
+ o3.isValid() && (this._manualInputValue = t3, this.setSliders(o3.toHex8String()), this.setColor(o3, "input"), this._manualInputValue = null);
483
+ }), o2.append(a2), l2.append(u2), c2.append(d2, f2), this.noControls || s2.append(h2, l2), s2.append(c2), this.noColorArea || i2.append(o2), i2.append(s2), this.noSwatches || this.createSwatches(s2), e2.append(i2), t2.append(e2), this.anchor = r2, this.picker = i2, this.marker = a2, this.colorArea = o2, this.hueSlider = h2, this.alphaSlider = u2, this.colorPreview = d2, this.input = f2, t2;
1390
484
  }
1391
- /**
1392
- * Executes after the component is drawn. Initializes some configurations if not already initialized,
1393
- * including updating slider values, setting marker positions, and applying initial color settings.
1394
- * This method ensures that all necessary visual elements and configurations are properly set up.
1395
- * @returns {void} Does not return a value.
1396
- */
1397
485
  afterDraw() {
1398
- __privateSet(this, _init, false);
1399
- if (!__privateGet(this, _init)) {
1400
- window.setTimeout(() => {
1401
- if (this.color !== "") this.alphaSlider.value = 100;
1402
- this.colorAreaDimension = this.dimension();
1403
- this.markerPosition = this.setMarkerPositionByColor(this.color);
1404
- this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y);
1405
- this.setSliders(this.color);
1406
- this.setColor(tinycolor(this.color), "init");
1407
- }, 0);
1408
- __privateSet(this, _init, true);
1409
- }
1410
- }
1411
- /**
1412
- * Sets the hue.
1413
- * @param node
1414
- */
1415
- createSwatches(node) {
1416
- if (this.swatches.length === 0) return;
1417
- let swatches = document.createElement("div");
1418
- swatches.classList.add("swatches");
1419
- this.swatches.forEach((swatch) => {
1420
- if (!tinycolor(swatch).isValid()) return;
1421
- let button = document.createElement("button");
1422
- button.setAttribute("type", "button");
1423
- button.classList.add("swatch");
1424
- button.style.setProperty("--wje-color-picker-swatch", swatch);
1425
- button.addEventListener("click", () => {
1426
- this.setSliders(swatch);
1427
- this.setColor(tinycolor(swatch), "swatch");
1428
- });
1429
- swatches.appendChild(button);
1430
- });
1431
- node.appendChild(swatches);
1432
- }
1433
- /**
1434
- * Sets the sliders to the given color.
1435
- * @param color
1436
- */
1437
- setSliders(color) {
1438
- let hsva = tinycolor(color).toHsv();
1439
- this.hueSlider.value = hsva.h;
1440
- this.alphaSlider.value = hsva.a * 100;
486
+ __privateSet(this, _t, false), __privateGet(this, _t) || (window.setTimeout(() => {
487
+ "" !== this.color && (this.alphaSlider.value = 100), this.colorAreaDimension = this.dimension(), this.markerPosition = this.setMarkerPositionByColor(this.color), this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y), this.setSliders(this.color), this.setColor(n(this.color), "init");
488
+ }, 0), __privateSet(this, _t, true));
489
+ }
490
+ createSwatches(t2) {
491
+ if (0 === this.swatches.length) return;
492
+ let e2 = document.createElement("div");
493
+ e2.classList.add("swatches"), this.swatches.forEach((t3) => {
494
+ if (!n(t3).isValid()) return;
495
+ let r2 = document.createElement("button");
496
+ r2.setAttribute("type", "button"), r2.classList.add("swatch"), r2.style.setProperty("--wje-color-picker-swatch", t3), r2.addEventListener("click", () => {
497
+ this.setSliders(t3), this.setColor(n(t3), "swatch");
498
+ }), e2.appendChild(r2);
499
+ }), t2.appendChild(e2);
500
+ }
501
+ setSliders(t2) {
502
+ let e2 = n(t2).toHsv();
503
+ this.hueSlider.value = e2.h, this.alphaSlider.value = 100 * e2.a;
1441
504
  }
1442
- /**
1443
- * Retrieves the dimensions and position of the color area element relative to the viewport.
1444
- * @returns {object} An object containing the following properties:
1445
- * width: The width of the element in pixels.
1446
- * height: The height of the element in pixels.
1447
- * x: The x-coordinate of the element's left edge relative to the viewport.
1448
- * y: The y-coordinate of the element's top edge relative to the viewport.
1449
- */
1450
505
  dimension() {
1451
- const rect = this.colorArea.getBoundingClientRect();
1452
- return {
1453
- width: rect.width,
1454
- height: rect.height,
1455
- x: rect.left,
1456
- // viewport-relative
1457
- y: rect.top
1458
- // viewport-relative
1459
- };
506
+ const t2 = this.colorArea.getBoundingClientRect();
507
+ return { width: t2.width, height: t2.height, x: t2.left, y: t2.top };
1460
508
  }
1461
- /**
1462
- * Method executed before disconnecting. Resets the initialization state to false.
1463
- * @returns {void} Does not return a value.
1464
- */
1465
509
  beforeDisconnect() {
1466
- __privateSet(this, _init, true);
510
+ __privateSet(this, _t, true);
1467
511
  }
1468
- /**
1469
- * Gets the pointer position in client coordinates (viewport-relative).
1470
- * @param e
1471
- * @returns {{x: number, y: number}}
1472
- */
1473
- getPointerPosition(e) {
1474
- const p = e.touches && e.touches[0] || e.changedTouches && e.changedTouches[0] || e;
1475
- return {
1476
- x: p.clientX,
1477
- y: p.clientY
1478
- };
512
+ getPointerPosition(t2) {
513
+ const e2 = t2.touches && t2.touches[0] || t2.changedTouches && t2.changedTouches[0] || t2;
514
+ return { x: e2.clientX, y: e2.clientY };
1479
515
  }
1480
- /**
1481
- * Sets the position of the marker.
1482
- * @param x
1483
- * @param y
1484
- */
1485
- setMarkerPosition(x, y) {
1486
- const markerPosition = this.clampMarkerPosition(x, y);
1487
- this.markerPosition = {
1488
- x: markerPosition.x,
1489
- y: markerPosition.y
1490
- };
1491
- this.marker.style.left = `${markerPosition.x}px`;
1492
- this.marker.style.top = `${markerPosition.y}px`;
516
+ setMarkerPosition(t2, e2) {
517
+ const r2 = this.clampMarkerPosition(t2, e2);
518
+ this.markerPosition = { x: r2.x, y: r2.y }, this.marker.style.left = `${r2.x}px`, this.marker.style.top = `${r2.y}px`;
1493
519
  }
1494
- /**
1495
- * Clamps marker coordinates to the color area boundaries.
1496
- * @param {number} x
1497
- * @param {number} y
1498
- * @returns {{x: number, y: number}}
1499
- */
1500
- clampMarkerPosition(x, y) {
520
+ clampMarkerPosition(t2, e2) {
1501
521
  var _a, _b;
1502
- const width = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0;
1503
- const height = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0;
1504
- const safeX = Number.isFinite(x) ? x : 0;
1505
- const safeY = Number.isFinite(y) ? y : 0;
1506
- return {
1507
- x: Math.min(Math.max(safeX, 0), width),
1508
- y: Math.min(Math.max(safeY, 0), height)
1509
- };
522
+ const r2 = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0, i2 = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0, a2 = Number.isFinite(t2) ? t2 : 0, n2 = Number.isFinite(e2) ? e2 : 0;
523
+ return { x: Math.min(Math.max(a2, 0), r2), y: Math.min(Math.max(n2, 0), i2) };
1510
524
  }
1511
- /**
1512
- * Sets the color at the given position.
1513
- * @param x
1514
- * @param y
1515
- * @param alpha
1516
- * @returns {*|tinycolor}
1517
- */
1518
- setColorAtPosition(x, y, alpha = 100) {
525
+ setColorAtPosition(t2, e2, r2 = 100) {
1519
526
  var _a, _b, _c;
1520
- const markerPosition = this.clampMarkerPosition(x, y);
1521
- const width = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0;
1522
- const height = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0;
1523
- const safeAlpha = Number.isFinite(Number(alpha)) ? Number(alpha) : 100;
1524
- if (width <= 0 || height <= 0) {
1525
- const fallbackHsv = tinycolor(((_c = this.input) == null ? void 0 : _c.value) || this.color).toHsv();
1526
- return tinycolor({
1527
- h: this.hueSlider.value * 1,
1528
- s: fallbackHsv.s,
1529
- v: fallbackHsv.v,
1530
- a: Math.max(0, Math.min(100, safeAlpha)) / 100
1531
- });
527
+ const i2 = this.clampMarkerPosition(t2, e2), a2 = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0, o2 = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0, s2 = Number.isFinite(Number(r2)) ? Number(r2) : 100;
528
+ if (a2 <= 0 || o2 <= 0) {
529
+ const t3 = n(((_c = this.input) == null ? void 0 : _c.value) || this.color).toHsv();
530
+ return n({ h: 1 * this.hueSlider.value, s: t3.s, v: t3.v, a: Math.max(0, Math.min(100, s2)) / 100 });
1532
531
  }
1533
- const hsva = {
1534
- h: this.hueSlider.value * 1,
1535
- s: markerPosition.x / width * 100,
1536
- v: 100 - markerPosition.y / height * 100,
1537
- a: Math.max(0, Math.min(100, safeAlpha)) / 100
1538
- };
1539
- return tinycolor(hsva);
532
+ return n({ h: 1 * this.hueSlider.value, s: i2.x / a2 * 100, v: 100 - i2.y / o2 * 100, a: Math.max(0, Math.min(100, s2)) / 100 });
1540
533
  }
1541
- /**
1542
- * Returns fully saturated and bright color for the current hue.
1543
- * Used as base color for the SV area so neutral grays do not black out the palette.
1544
- * @param {string} color
1545
- * @returns {string}
1546
- */
1547
- getHueAreaColor(color = "#ff0000") {
534
+ getHueAreaColor(t2 = "#ff0000") {
1548
535
  var _a;
1549
- const hsv = tinycolor(color).toHsv();
1550
- const hue = Number.isFinite(hsv.h) ? hsv.h : Number(((_a = this.hueSlider) == null ? void 0 : _a.value) || 0);
1551
- return tinycolor({
1552
- h: hue,
1553
- s: 100,
1554
- v: 100,
1555
- a: 1
1556
- }).toHexString();
536
+ const e2 = n(t2).toHsv();
537
+ return n({ h: Number.isFinite(e2.h) ? e2.h : Number(((_a = this.hueSlider) == null ? void 0 : _a.value) || 0), s: 100, v: 100, a: 1 }).toHexString();
1557
538
  }
1558
539
  }
1559
- _init = new WeakMap();
1560
- WJElement.define("wje-color-picker", ColorPicker);
540
+ _t = new WeakMap();
541
+ t.define("wje-color-picker", I);
1561
542
  export {
1562
- ColorPicker as default
543
+ I as default
1563
544
  };
1564
545
  //# sourceMappingURL=wje-color-picker.js.map