proto-tinker-wc 0.0.1

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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/cjs/index-cea62b03.js +1176 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/proto-tinker-wc.cjs.js +19 -0
  7. package/dist/cjs/proto-tinker.cjs.entry.js +2524 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/proto-tinker/chevron-double-left.js +14 -0
  10. package/dist/collection/components/proto-tinker/close.js +14 -0
  11. package/dist/collection/components/proto-tinker/color-picker.js +16 -0
  12. package/dist/collection/components/proto-tinker/data-source.js +25 -0
  13. package/dist/collection/components/proto-tinker/data-values.js +17 -0
  14. package/dist/collection/components/proto-tinker/eswat2-io.js +10 -0
  15. package/dist/collection/components/proto-tinker/fingerprint.js +14 -0
  16. package/dist/collection/components/proto-tinker/proto-tinker.css +152 -0
  17. package/dist/collection/components/proto-tinker/proto-tinker.js +46 -0
  18. package/dist/collection/components/proto-tinker/radio.js +15 -0
  19. package/dist/collection/components/proto-tinker/refresh.js +14 -0
  20. package/dist/collection/components/proto-tinker/tw-label.js +9 -0
  21. package/dist/collection/index.js +1 -0
  22. package/dist/collection/utils/color-plugin.js +36 -0
  23. package/dist/collection/utils/funnel-defs.js +10 -0
  24. package/dist/collection/utils/index.js +5 -0
  25. package/dist/collection/utils/named-colors.js +51 -0
  26. package/dist/collection/utils/store.js +25 -0
  27. package/dist/collection/utils/types.js +1 -0
  28. package/dist/components/index.d.ts +26 -0
  29. package/dist/components/index.js +1 -0
  30. package/dist/components/proto-tinker.d.ts +11 -0
  31. package/dist/components/proto-tinker.js +2541 -0
  32. package/dist/esm/index-b22d500f.js +1149 -0
  33. package/dist/esm/index.js +1 -0
  34. package/dist/esm/loader.js +17 -0
  35. package/dist/esm/polyfills/core-js.js +11 -0
  36. package/dist/esm/polyfills/css-shim.js +1 -0
  37. package/dist/esm/polyfills/dom.js +79 -0
  38. package/dist/esm/polyfills/es5-html-element.js +1 -0
  39. package/dist/esm/polyfills/index.js +34 -0
  40. package/dist/esm/polyfills/system.js +6 -0
  41. package/dist/esm/proto-tinker-wc.js +17 -0
  42. package/dist/esm/proto-tinker.entry.js +2520 -0
  43. package/dist/index.cjs.js +1 -0
  44. package/dist/index.js +1 -0
  45. package/dist/proto-tinker-wc/index.esm.js +0 -0
  46. package/dist/proto-tinker-wc/p-18633a0f.entry.js +1 -0
  47. package/dist/proto-tinker-wc/p-b3c235a0.js +1 -0
  48. package/dist/proto-tinker-wc/proto-tinker-wc.esm.js +1 -0
  49. package/dist/types/components/proto-tinker/chevron-double-left.d.ts +5 -0
  50. package/dist/types/components/proto-tinker/close.d.ts +5 -0
  51. package/dist/types/components/proto-tinker/color-picker.d.ts +4 -0
  52. package/dist/types/components/proto-tinker/data-source.d.ts +4 -0
  53. package/dist/types/components/proto-tinker/data-values.d.ts +4 -0
  54. package/dist/types/components/proto-tinker/eswat2-io.d.ts +4 -0
  55. package/dist/types/components/proto-tinker/fingerprint.d.ts +5 -0
  56. package/dist/types/components/proto-tinker/proto-tinker.d.ts +4 -0
  57. package/dist/types/components/proto-tinker/radio.d.ts +5 -0
  58. package/dist/types/components/proto-tinker/refresh.d.ts +5 -0
  59. package/dist/types/components/proto-tinker/tw-label.d.ts +4 -0
  60. package/dist/types/components.d.ts +39 -0
  61. package/dist/types/index.d.ts +1 -0
  62. package/dist/types/stencil-public-runtime.d.ts +1563 -0
  63. package/dist/types/utils/color-plugin.d.ts +14 -0
  64. package/dist/types/utils/funnel-defs.d.ts +5 -0
  65. package/dist/types/utils/index.d.ts +5 -0
  66. package/dist/types/utils/named-colors.d.ts +24 -0
  67. package/dist/types/utils/store.d.ts +5 -0
  68. package/dist/types/utils/types.d.ts +42 -0
  69. package/loader/cdn.js +3 -0
  70. package/loader/index.cjs.js +3 -0
  71. package/loader/index.d.ts +12 -0
  72. package/loader/index.es2017.js +3 -0
  73. package/loader/index.js +4 -0
  74. package/loader/package.json +10 -0
  75. package/package.json +46 -0
@@ -0,0 +1,2524 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-cea62b03.js');
6
+
7
+ const Radio = props => {
8
+ const hex = props.hex || 'currentColor';
9
+ const klass = props.class;
10
+ const label = props.label || 'radio';
11
+ const selected = props.selected || false;
12
+ const size = props.size || 24;
13
+ return (index.h("svg", { class: klass, width: size, height: size, viewBox: "0 0 24 24", role: "img", "aria-label": "title" },
14
+ index.h("title", null, label),
15
+ ' ',
16
+ index.h("g", { fill: hex }, selected ? (index.h("path", { d: "M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" })) : (index.h("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }))),
17
+ index.h("path", { d: "M0 0h24v24H0z", fill: "none" })));
18
+ };
19
+
20
+ function createCommonjsModule(fn, basedir, module) {
21
+ return module = {
22
+ path: basedir,
23
+ exports: {},
24
+ require: function (path, base) {
25
+ return commonjsRequire();
26
+ }
27
+ }, fn(module, module.exports), module.exports;
28
+ }
29
+
30
+ function commonjsRequire () {
31
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
32
+ }
33
+
34
+ var colorName$1 = {
35
+ "aliceblue": [240, 248, 255],
36
+ "antiquewhite": [250, 235, 215],
37
+ "aqua": [0, 255, 255],
38
+ "aquamarine": [127, 255, 212],
39
+ "azure": [240, 255, 255],
40
+ "beige": [245, 245, 220],
41
+ "bisque": [255, 228, 196],
42
+ "black": [0, 0, 0],
43
+ "blanchedalmond": [255, 235, 205],
44
+ "blue": [0, 0, 255],
45
+ "blueviolet": [138, 43, 226],
46
+ "brown": [165, 42, 42],
47
+ "burlywood": [222, 184, 135],
48
+ "cadetblue": [95, 158, 160],
49
+ "chartreuse": [127, 255, 0],
50
+ "chocolate": [210, 105, 30],
51
+ "coral": [255, 127, 80],
52
+ "cornflowerblue": [100, 149, 237],
53
+ "cornsilk": [255, 248, 220],
54
+ "crimson": [220, 20, 60],
55
+ "cyan": [0, 255, 255],
56
+ "darkblue": [0, 0, 139],
57
+ "darkcyan": [0, 139, 139],
58
+ "darkgoldenrod": [184, 134, 11],
59
+ "darkgray": [169, 169, 169],
60
+ "darkgreen": [0, 100, 0],
61
+ "darkgrey": [169, 169, 169],
62
+ "darkkhaki": [189, 183, 107],
63
+ "darkmagenta": [139, 0, 139],
64
+ "darkolivegreen": [85, 107, 47],
65
+ "darkorange": [255, 140, 0],
66
+ "darkorchid": [153, 50, 204],
67
+ "darkred": [139, 0, 0],
68
+ "darksalmon": [233, 150, 122],
69
+ "darkseagreen": [143, 188, 143],
70
+ "darkslateblue": [72, 61, 139],
71
+ "darkslategray": [47, 79, 79],
72
+ "darkslategrey": [47, 79, 79],
73
+ "darkturquoise": [0, 206, 209],
74
+ "darkviolet": [148, 0, 211],
75
+ "deeppink": [255, 20, 147],
76
+ "deepskyblue": [0, 191, 255],
77
+ "dimgray": [105, 105, 105],
78
+ "dimgrey": [105, 105, 105],
79
+ "dodgerblue": [30, 144, 255],
80
+ "firebrick": [178, 34, 34],
81
+ "floralwhite": [255, 250, 240],
82
+ "forestgreen": [34, 139, 34],
83
+ "fuchsia": [255, 0, 255],
84
+ "gainsboro": [220, 220, 220],
85
+ "ghostwhite": [248, 248, 255],
86
+ "gold": [255, 215, 0],
87
+ "goldenrod": [218, 165, 32],
88
+ "gray": [128, 128, 128],
89
+ "green": [0, 128, 0],
90
+ "greenyellow": [173, 255, 47],
91
+ "grey": [128, 128, 128],
92
+ "honeydew": [240, 255, 240],
93
+ "hotpink": [255, 105, 180],
94
+ "indianred": [205, 92, 92],
95
+ "indigo": [75, 0, 130],
96
+ "ivory": [255, 255, 240],
97
+ "khaki": [240, 230, 140],
98
+ "lavender": [230, 230, 250],
99
+ "lavenderblush": [255, 240, 245],
100
+ "lawngreen": [124, 252, 0],
101
+ "lemonchiffon": [255, 250, 205],
102
+ "lightblue": [173, 216, 230],
103
+ "lightcoral": [240, 128, 128],
104
+ "lightcyan": [224, 255, 255],
105
+ "lightgoldenrodyellow": [250, 250, 210],
106
+ "lightgray": [211, 211, 211],
107
+ "lightgreen": [144, 238, 144],
108
+ "lightgrey": [211, 211, 211],
109
+ "lightpink": [255, 182, 193],
110
+ "lightsalmon": [255, 160, 122],
111
+ "lightseagreen": [32, 178, 170],
112
+ "lightskyblue": [135, 206, 250],
113
+ "lightslategray": [119, 136, 153],
114
+ "lightslategrey": [119, 136, 153],
115
+ "lightsteelblue": [176, 196, 222],
116
+ "lightyellow": [255, 255, 224],
117
+ "lime": [0, 255, 0],
118
+ "limegreen": [50, 205, 50],
119
+ "linen": [250, 240, 230],
120
+ "magenta": [255, 0, 255],
121
+ "maroon": [128, 0, 0],
122
+ "mediumaquamarine": [102, 205, 170],
123
+ "mediumblue": [0, 0, 205],
124
+ "mediumorchid": [186, 85, 211],
125
+ "mediumpurple": [147, 112, 219],
126
+ "mediumseagreen": [60, 179, 113],
127
+ "mediumslateblue": [123, 104, 238],
128
+ "mediumspringgreen": [0, 250, 154],
129
+ "mediumturquoise": [72, 209, 204],
130
+ "mediumvioletred": [199, 21, 133],
131
+ "midnightblue": [25, 25, 112],
132
+ "mintcream": [245, 255, 250],
133
+ "mistyrose": [255, 228, 225],
134
+ "moccasin": [255, 228, 181],
135
+ "navajowhite": [255, 222, 173],
136
+ "navy": [0, 0, 128],
137
+ "oldlace": [253, 245, 230],
138
+ "olive": [128, 128, 0],
139
+ "olivedrab": [107, 142, 35],
140
+ "orange": [255, 165, 0],
141
+ "orangered": [255, 69, 0],
142
+ "orchid": [218, 112, 214],
143
+ "palegoldenrod": [238, 232, 170],
144
+ "palegreen": [152, 251, 152],
145
+ "paleturquoise": [175, 238, 238],
146
+ "palevioletred": [219, 112, 147],
147
+ "papayawhip": [255, 239, 213],
148
+ "peachpuff": [255, 218, 185],
149
+ "peru": [205, 133, 63],
150
+ "pink": [255, 192, 203],
151
+ "plum": [221, 160, 221],
152
+ "powderblue": [176, 224, 230],
153
+ "purple": [128, 0, 128],
154
+ "rebeccapurple": [102, 51, 153],
155
+ "red": [255, 0, 0],
156
+ "rosybrown": [188, 143, 143],
157
+ "royalblue": [65, 105, 225],
158
+ "saddlebrown": [139, 69, 19],
159
+ "salmon": [250, 128, 114],
160
+ "sandybrown": [244, 164, 96],
161
+ "seagreen": [46, 139, 87],
162
+ "seashell": [255, 245, 238],
163
+ "sienna": [160, 82, 45],
164
+ "silver": [192, 192, 192],
165
+ "skyblue": [135, 206, 235],
166
+ "slateblue": [106, 90, 205],
167
+ "slategray": [112, 128, 144],
168
+ "slategrey": [112, 128, 144],
169
+ "snow": [255, 250, 250],
170
+ "springgreen": [0, 255, 127],
171
+ "steelblue": [70, 130, 180],
172
+ "tan": [210, 180, 140],
173
+ "teal": [0, 128, 128],
174
+ "thistle": [216, 191, 216],
175
+ "tomato": [255, 99, 71],
176
+ "turquoise": [64, 224, 208],
177
+ "violet": [238, 130, 238],
178
+ "wheat": [245, 222, 179],
179
+ "white": [255, 255, 255],
180
+ "whitesmoke": [245, 245, 245],
181
+ "yellow": [255, 255, 0],
182
+ "yellowgreen": [154, 205, 50]
183
+ };
184
+
185
+ var isArrayish = function isArrayish(obj) {
186
+ if (!obj || typeof obj === 'string') {
187
+ return false;
188
+ }
189
+
190
+ return obj instanceof Array || Array.isArray(obj) ||
191
+ (obj.length >= 0 && (obj.splice instanceof Function ||
192
+ (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
193
+ };
194
+
195
+ var simpleSwizzle = createCommonjsModule(function (module) {
196
+
197
+
198
+
199
+ var concat = Array.prototype.concat;
200
+ var slice = Array.prototype.slice;
201
+
202
+ var swizzle = module.exports = function swizzle(args) {
203
+ var results = [];
204
+
205
+ for (var i = 0, len = args.length; i < len; i++) {
206
+ var arg = args[i];
207
+
208
+ if (isArrayish(arg)) {
209
+ // http://jsperf.com/javascript-array-concat-vs-push/98
210
+ results = concat.call(results, slice.call(arg));
211
+ } else {
212
+ results.push(arg);
213
+ }
214
+ }
215
+
216
+ return results;
217
+ };
218
+
219
+ swizzle.wrap = function (fn) {
220
+ return function () {
221
+ return fn(swizzle(arguments));
222
+ };
223
+ };
224
+ });
225
+
226
+ var colorString = createCommonjsModule(function (module) {
227
+ /* MIT license */
228
+
229
+
230
+ var hasOwnProperty = Object.hasOwnProperty;
231
+
232
+ var reverseNames = {};
233
+
234
+ // create a list of reverse color names
235
+ for (var name in colorName$1) {
236
+ if (hasOwnProperty.call(colorName$1, name)) {
237
+ reverseNames[colorName$1[name]] = name;
238
+ }
239
+ }
240
+
241
+ var cs = module.exports = {
242
+ to: {},
243
+ get: {}
244
+ };
245
+
246
+ cs.get = function (string) {
247
+ var prefix = string.substring(0, 3).toLowerCase();
248
+ var val;
249
+ var model;
250
+ switch (prefix) {
251
+ case 'hsl':
252
+ val = cs.get.hsl(string);
253
+ model = 'hsl';
254
+ break;
255
+ case 'hwb':
256
+ val = cs.get.hwb(string);
257
+ model = 'hwb';
258
+ break;
259
+ default:
260
+ val = cs.get.rgb(string);
261
+ model = 'rgb';
262
+ break;
263
+ }
264
+
265
+ if (!val) {
266
+ return null;
267
+ }
268
+
269
+ return {model: model, value: val};
270
+ };
271
+
272
+ cs.get.rgb = function (string) {
273
+ if (!string) {
274
+ return null;
275
+ }
276
+
277
+ var abbr = /^#([a-f0-9]{3,4})$/i;
278
+ var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
279
+ var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
280
+ var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
281
+ var keyword = /^(\w+)$/;
282
+
283
+ var rgb = [0, 0, 0, 1];
284
+ var match;
285
+ var i;
286
+ var hexAlpha;
287
+
288
+ if (match = string.match(hex)) {
289
+ hexAlpha = match[2];
290
+ match = match[1];
291
+
292
+ for (i = 0; i < 3; i++) {
293
+ // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
294
+ var i2 = i * 2;
295
+ rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
296
+ }
297
+
298
+ if (hexAlpha) {
299
+ rgb[3] = parseInt(hexAlpha, 16) / 255;
300
+ }
301
+ } else if (match = string.match(abbr)) {
302
+ match = match[1];
303
+ hexAlpha = match[3];
304
+
305
+ for (i = 0; i < 3; i++) {
306
+ rgb[i] = parseInt(match[i] + match[i], 16);
307
+ }
308
+
309
+ if (hexAlpha) {
310
+ rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
311
+ }
312
+ } else if (match = string.match(rgba)) {
313
+ for (i = 0; i < 3; i++) {
314
+ rgb[i] = parseInt(match[i + 1], 0);
315
+ }
316
+
317
+ if (match[4]) {
318
+ if (match[5]) {
319
+ rgb[3] = parseFloat(match[4]) * 0.01;
320
+ } else {
321
+ rgb[3] = parseFloat(match[4]);
322
+ }
323
+ }
324
+ } else if (match = string.match(per)) {
325
+ for (i = 0; i < 3; i++) {
326
+ rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
327
+ }
328
+
329
+ if (match[4]) {
330
+ if (match[5]) {
331
+ rgb[3] = parseFloat(match[4]) * 0.01;
332
+ } else {
333
+ rgb[3] = parseFloat(match[4]);
334
+ }
335
+ }
336
+ } else if (match = string.match(keyword)) {
337
+ if (match[1] === 'transparent') {
338
+ return [0, 0, 0, 0];
339
+ }
340
+
341
+ if (!hasOwnProperty.call(colorName$1, match[1])) {
342
+ return null;
343
+ }
344
+
345
+ rgb = colorName$1[match[1]];
346
+ rgb[3] = 1;
347
+
348
+ return rgb;
349
+ } else {
350
+ return null;
351
+ }
352
+
353
+ for (i = 0; i < 3; i++) {
354
+ rgb[i] = clamp(rgb[i], 0, 255);
355
+ }
356
+ rgb[3] = clamp(rgb[3], 0, 1);
357
+
358
+ return rgb;
359
+ };
360
+
361
+ cs.get.hsl = function (string) {
362
+ if (!string) {
363
+ return null;
364
+ }
365
+
366
+ var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
367
+ var match = string.match(hsl);
368
+
369
+ if (match) {
370
+ var alpha = parseFloat(match[4]);
371
+ var h = ((parseFloat(match[1]) % 360) + 360) % 360;
372
+ var s = clamp(parseFloat(match[2]), 0, 100);
373
+ var l = clamp(parseFloat(match[3]), 0, 100);
374
+ var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
375
+
376
+ return [h, s, l, a];
377
+ }
378
+
379
+ return null;
380
+ };
381
+
382
+ cs.get.hwb = function (string) {
383
+ if (!string) {
384
+ return null;
385
+ }
386
+
387
+ var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
388
+ var match = string.match(hwb);
389
+
390
+ if (match) {
391
+ var alpha = parseFloat(match[4]);
392
+ var h = ((parseFloat(match[1]) % 360) + 360) % 360;
393
+ var w = clamp(parseFloat(match[2]), 0, 100);
394
+ var b = clamp(parseFloat(match[3]), 0, 100);
395
+ var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
396
+ return [h, w, b, a];
397
+ }
398
+
399
+ return null;
400
+ };
401
+
402
+ cs.to.hex = function () {
403
+ var rgba = simpleSwizzle(arguments);
404
+
405
+ return (
406
+ '#' +
407
+ hexDouble(rgba[0]) +
408
+ hexDouble(rgba[1]) +
409
+ hexDouble(rgba[2]) +
410
+ (rgba[3] < 1
411
+ ? (hexDouble(Math.round(rgba[3] * 255)))
412
+ : '')
413
+ );
414
+ };
415
+
416
+ cs.to.rgb = function () {
417
+ var rgba = simpleSwizzle(arguments);
418
+
419
+ return rgba.length < 4 || rgba[3] === 1
420
+ ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
421
+ : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
422
+ };
423
+
424
+ cs.to.rgb.percent = function () {
425
+ var rgba = simpleSwizzle(arguments);
426
+
427
+ var r = Math.round(rgba[0] / 255 * 100);
428
+ var g = Math.round(rgba[1] / 255 * 100);
429
+ var b = Math.round(rgba[2] / 255 * 100);
430
+
431
+ return rgba.length < 4 || rgba[3] === 1
432
+ ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
433
+ : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
434
+ };
435
+
436
+ cs.to.hsl = function () {
437
+ var hsla = simpleSwizzle(arguments);
438
+ return hsla.length < 4 || hsla[3] === 1
439
+ ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
440
+ : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
441
+ };
442
+
443
+ // hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
444
+ // (hwb have alpha optional & 1 is default value)
445
+ cs.to.hwb = function () {
446
+ var hwba = simpleSwizzle(arguments);
447
+
448
+ var a = '';
449
+ if (hwba.length >= 4 && hwba[3] !== 1) {
450
+ a = ', ' + hwba[3];
451
+ }
452
+
453
+ return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
454
+ };
455
+
456
+ cs.to.keyword = function (rgb) {
457
+ return reverseNames[rgb.slice(0, 3)];
458
+ };
459
+
460
+ // helpers
461
+ function clamp(num, min, max) {
462
+ return Math.min(Math.max(min, num), max);
463
+ }
464
+
465
+ function hexDouble(num) {
466
+ var str = Math.round(num).toString(16).toUpperCase();
467
+ return (str.length < 2) ? '0' + str : str;
468
+ }
469
+ });
470
+
471
+ var colorName = {
472
+ "aliceblue": [240, 248, 255],
473
+ "antiquewhite": [250, 235, 215],
474
+ "aqua": [0, 255, 255],
475
+ "aquamarine": [127, 255, 212],
476
+ "azure": [240, 255, 255],
477
+ "beige": [245, 245, 220],
478
+ "bisque": [255, 228, 196],
479
+ "black": [0, 0, 0],
480
+ "blanchedalmond": [255, 235, 205],
481
+ "blue": [0, 0, 255],
482
+ "blueviolet": [138, 43, 226],
483
+ "brown": [165, 42, 42],
484
+ "burlywood": [222, 184, 135],
485
+ "cadetblue": [95, 158, 160],
486
+ "chartreuse": [127, 255, 0],
487
+ "chocolate": [210, 105, 30],
488
+ "coral": [255, 127, 80],
489
+ "cornflowerblue": [100, 149, 237],
490
+ "cornsilk": [255, 248, 220],
491
+ "crimson": [220, 20, 60],
492
+ "cyan": [0, 255, 255],
493
+ "darkblue": [0, 0, 139],
494
+ "darkcyan": [0, 139, 139],
495
+ "darkgoldenrod": [184, 134, 11],
496
+ "darkgray": [169, 169, 169],
497
+ "darkgreen": [0, 100, 0],
498
+ "darkgrey": [169, 169, 169],
499
+ "darkkhaki": [189, 183, 107],
500
+ "darkmagenta": [139, 0, 139],
501
+ "darkolivegreen": [85, 107, 47],
502
+ "darkorange": [255, 140, 0],
503
+ "darkorchid": [153, 50, 204],
504
+ "darkred": [139, 0, 0],
505
+ "darksalmon": [233, 150, 122],
506
+ "darkseagreen": [143, 188, 143],
507
+ "darkslateblue": [72, 61, 139],
508
+ "darkslategray": [47, 79, 79],
509
+ "darkslategrey": [47, 79, 79],
510
+ "darkturquoise": [0, 206, 209],
511
+ "darkviolet": [148, 0, 211],
512
+ "deeppink": [255, 20, 147],
513
+ "deepskyblue": [0, 191, 255],
514
+ "dimgray": [105, 105, 105],
515
+ "dimgrey": [105, 105, 105],
516
+ "dodgerblue": [30, 144, 255],
517
+ "firebrick": [178, 34, 34],
518
+ "floralwhite": [255, 250, 240],
519
+ "forestgreen": [34, 139, 34],
520
+ "fuchsia": [255, 0, 255],
521
+ "gainsboro": [220, 220, 220],
522
+ "ghostwhite": [248, 248, 255],
523
+ "gold": [255, 215, 0],
524
+ "goldenrod": [218, 165, 32],
525
+ "gray": [128, 128, 128],
526
+ "green": [0, 128, 0],
527
+ "greenyellow": [173, 255, 47],
528
+ "grey": [128, 128, 128],
529
+ "honeydew": [240, 255, 240],
530
+ "hotpink": [255, 105, 180],
531
+ "indianred": [205, 92, 92],
532
+ "indigo": [75, 0, 130],
533
+ "ivory": [255, 255, 240],
534
+ "khaki": [240, 230, 140],
535
+ "lavender": [230, 230, 250],
536
+ "lavenderblush": [255, 240, 245],
537
+ "lawngreen": [124, 252, 0],
538
+ "lemonchiffon": [255, 250, 205],
539
+ "lightblue": [173, 216, 230],
540
+ "lightcoral": [240, 128, 128],
541
+ "lightcyan": [224, 255, 255],
542
+ "lightgoldenrodyellow": [250, 250, 210],
543
+ "lightgray": [211, 211, 211],
544
+ "lightgreen": [144, 238, 144],
545
+ "lightgrey": [211, 211, 211],
546
+ "lightpink": [255, 182, 193],
547
+ "lightsalmon": [255, 160, 122],
548
+ "lightseagreen": [32, 178, 170],
549
+ "lightskyblue": [135, 206, 250],
550
+ "lightslategray": [119, 136, 153],
551
+ "lightslategrey": [119, 136, 153],
552
+ "lightsteelblue": [176, 196, 222],
553
+ "lightyellow": [255, 255, 224],
554
+ "lime": [0, 255, 0],
555
+ "limegreen": [50, 205, 50],
556
+ "linen": [250, 240, 230],
557
+ "magenta": [255, 0, 255],
558
+ "maroon": [128, 0, 0],
559
+ "mediumaquamarine": [102, 205, 170],
560
+ "mediumblue": [0, 0, 205],
561
+ "mediumorchid": [186, 85, 211],
562
+ "mediumpurple": [147, 112, 219],
563
+ "mediumseagreen": [60, 179, 113],
564
+ "mediumslateblue": [123, 104, 238],
565
+ "mediumspringgreen": [0, 250, 154],
566
+ "mediumturquoise": [72, 209, 204],
567
+ "mediumvioletred": [199, 21, 133],
568
+ "midnightblue": [25, 25, 112],
569
+ "mintcream": [245, 255, 250],
570
+ "mistyrose": [255, 228, 225],
571
+ "moccasin": [255, 228, 181],
572
+ "navajowhite": [255, 222, 173],
573
+ "navy": [0, 0, 128],
574
+ "oldlace": [253, 245, 230],
575
+ "olive": [128, 128, 0],
576
+ "olivedrab": [107, 142, 35],
577
+ "orange": [255, 165, 0],
578
+ "orangered": [255, 69, 0],
579
+ "orchid": [218, 112, 214],
580
+ "palegoldenrod": [238, 232, 170],
581
+ "palegreen": [152, 251, 152],
582
+ "paleturquoise": [175, 238, 238],
583
+ "palevioletred": [219, 112, 147],
584
+ "papayawhip": [255, 239, 213],
585
+ "peachpuff": [255, 218, 185],
586
+ "peru": [205, 133, 63],
587
+ "pink": [255, 192, 203],
588
+ "plum": [221, 160, 221],
589
+ "powderblue": [176, 224, 230],
590
+ "purple": [128, 0, 128],
591
+ "rebeccapurple": [102, 51, 153],
592
+ "red": [255, 0, 0],
593
+ "rosybrown": [188, 143, 143],
594
+ "royalblue": [65, 105, 225],
595
+ "saddlebrown": [139, 69, 19],
596
+ "salmon": [250, 128, 114],
597
+ "sandybrown": [244, 164, 96],
598
+ "seagreen": [46, 139, 87],
599
+ "seashell": [255, 245, 238],
600
+ "sienna": [160, 82, 45],
601
+ "silver": [192, 192, 192],
602
+ "skyblue": [135, 206, 235],
603
+ "slateblue": [106, 90, 205],
604
+ "slategray": [112, 128, 144],
605
+ "slategrey": [112, 128, 144],
606
+ "snow": [255, 250, 250],
607
+ "springgreen": [0, 255, 127],
608
+ "steelblue": [70, 130, 180],
609
+ "tan": [210, 180, 140],
610
+ "teal": [0, 128, 128],
611
+ "thistle": [216, 191, 216],
612
+ "tomato": [255, 99, 71],
613
+ "turquoise": [64, 224, 208],
614
+ "violet": [238, 130, 238],
615
+ "wheat": [245, 222, 179],
616
+ "white": [255, 255, 255],
617
+ "whitesmoke": [245, 245, 245],
618
+ "yellow": [255, 255, 0],
619
+ "yellowgreen": [154, 205, 50]
620
+ };
621
+
622
+ var conversions = createCommonjsModule(function (module) {
623
+ /* MIT license */
624
+
625
+
626
+ // NOTE: conversions should only return primitive values (i.e. arrays, or
627
+ // values that give correct `typeof` results).
628
+ // do not use box values types (i.e. Number(), String(), etc.)
629
+
630
+ var reverseKeywords = {};
631
+ for (var key in colorName) {
632
+ if (colorName.hasOwnProperty(key)) {
633
+ reverseKeywords[colorName[key]] = key;
634
+ }
635
+ }
636
+
637
+ var convert = module.exports = {
638
+ rgb: {channels: 3, labels: 'rgb'},
639
+ hsl: {channels: 3, labels: 'hsl'},
640
+ hsv: {channels: 3, labels: 'hsv'},
641
+ hwb: {channels: 3, labels: 'hwb'},
642
+ cmyk: {channels: 4, labels: 'cmyk'},
643
+ xyz: {channels: 3, labels: 'xyz'},
644
+ lab: {channels: 3, labels: 'lab'},
645
+ lch: {channels: 3, labels: 'lch'},
646
+ hex: {channels: 1, labels: ['hex']},
647
+ keyword: {channels: 1, labels: ['keyword']},
648
+ ansi16: {channels: 1, labels: ['ansi16']},
649
+ ansi256: {channels: 1, labels: ['ansi256']},
650
+ hcg: {channels: 3, labels: ['h', 'c', 'g']},
651
+ apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
652
+ gray: {channels: 1, labels: ['gray']}
653
+ };
654
+
655
+ // hide .channels and .labels properties
656
+ for (var model in convert) {
657
+ if (convert.hasOwnProperty(model)) {
658
+ if (!('channels' in convert[model])) {
659
+ throw new Error('missing channels property: ' + model);
660
+ }
661
+
662
+ if (!('labels' in convert[model])) {
663
+ throw new Error('missing channel labels property: ' + model);
664
+ }
665
+
666
+ if (convert[model].labels.length !== convert[model].channels) {
667
+ throw new Error('channel and label counts mismatch: ' + model);
668
+ }
669
+
670
+ var channels = convert[model].channels;
671
+ var labels = convert[model].labels;
672
+ delete convert[model].channels;
673
+ delete convert[model].labels;
674
+ Object.defineProperty(convert[model], 'channels', {value: channels});
675
+ Object.defineProperty(convert[model], 'labels', {value: labels});
676
+ }
677
+ }
678
+
679
+ convert.rgb.hsl = function (rgb) {
680
+ var r = rgb[0] / 255;
681
+ var g = rgb[1] / 255;
682
+ var b = rgb[2] / 255;
683
+ var min = Math.min(r, g, b);
684
+ var max = Math.max(r, g, b);
685
+ var delta = max - min;
686
+ var h;
687
+ var s;
688
+ var l;
689
+
690
+ if (max === min) {
691
+ h = 0;
692
+ } else if (r === max) {
693
+ h = (g - b) / delta;
694
+ } else if (g === max) {
695
+ h = 2 + (b - r) / delta;
696
+ } else if (b === max) {
697
+ h = 4 + (r - g) / delta;
698
+ }
699
+
700
+ h = Math.min(h * 60, 360);
701
+
702
+ if (h < 0) {
703
+ h += 360;
704
+ }
705
+
706
+ l = (min + max) / 2;
707
+
708
+ if (max === min) {
709
+ s = 0;
710
+ } else if (l <= 0.5) {
711
+ s = delta / (max + min);
712
+ } else {
713
+ s = delta / (2 - max - min);
714
+ }
715
+
716
+ return [h, s * 100, l * 100];
717
+ };
718
+
719
+ convert.rgb.hsv = function (rgb) {
720
+ var rdif;
721
+ var gdif;
722
+ var bdif;
723
+ var h;
724
+ var s;
725
+
726
+ var r = rgb[0] / 255;
727
+ var g = rgb[1] / 255;
728
+ var b = rgb[2] / 255;
729
+ var v = Math.max(r, g, b);
730
+ var diff = v - Math.min(r, g, b);
731
+ var diffc = function (c) {
732
+ return (v - c) / 6 / diff + 1 / 2;
733
+ };
734
+
735
+ if (diff === 0) {
736
+ h = s = 0;
737
+ } else {
738
+ s = diff / v;
739
+ rdif = diffc(r);
740
+ gdif = diffc(g);
741
+ bdif = diffc(b);
742
+
743
+ if (r === v) {
744
+ h = bdif - gdif;
745
+ } else if (g === v) {
746
+ h = (1 / 3) + rdif - bdif;
747
+ } else if (b === v) {
748
+ h = (2 / 3) + gdif - rdif;
749
+ }
750
+ if (h < 0) {
751
+ h += 1;
752
+ } else if (h > 1) {
753
+ h -= 1;
754
+ }
755
+ }
756
+
757
+ return [
758
+ h * 360,
759
+ s * 100,
760
+ v * 100
761
+ ];
762
+ };
763
+
764
+ convert.rgb.hwb = function (rgb) {
765
+ var r = rgb[0];
766
+ var g = rgb[1];
767
+ var b = rgb[2];
768
+ var h = convert.rgb.hsl(rgb)[0];
769
+ var w = 1 / 255 * Math.min(r, Math.min(g, b));
770
+
771
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
772
+
773
+ return [h, w * 100, b * 100];
774
+ };
775
+
776
+ convert.rgb.cmyk = function (rgb) {
777
+ var r = rgb[0] / 255;
778
+ var g = rgb[1] / 255;
779
+ var b = rgb[2] / 255;
780
+ var c;
781
+ var m;
782
+ var y;
783
+ var k;
784
+
785
+ k = Math.min(1 - r, 1 - g, 1 - b);
786
+ c = (1 - r - k) / (1 - k) || 0;
787
+ m = (1 - g - k) / (1 - k) || 0;
788
+ y = (1 - b - k) / (1 - k) || 0;
789
+
790
+ return [c * 100, m * 100, y * 100, k * 100];
791
+ };
792
+
793
+ /**
794
+ * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
795
+ * */
796
+ function comparativeDistance(x, y) {
797
+ return (
798
+ Math.pow(x[0] - y[0], 2) +
799
+ Math.pow(x[1] - y[1], 2) +
800
+ Math.pow(x[2] - y[2], 2)
801
+ );
802
+ }
803
+
804
+ convert.rgb.keyword = function (rgb) {
805
+ var reversed = reverseKeywords[rgb];
806
+ if (reversed) {
807
+ return reversed;
808
+ }
809
+
810
+ var currentClosestDistance = Infinity;
811
+ var currentClosestKeyword;
812
+
813
+ for (var keyword in colorName) {
814
+ if (colorName.hasOwnProperty(keyword)) {
815
+ var value = colorName[keyword];
816
+
817
+ // Compute comparative distance
818
+ var distance = comparativeDistance(rgb, value);
819
+
820
+ // Check if its less, if so set as closest
821
+ if (distance < currentClosestDistance) {
822
+ currentClosestDistance = distance;
823
+ currentClosestKeyword = keyword;
824
+ }
825
+ }
826
+ }
827
+
828
+ return currentClosestKeyword;
829
+ };
830
+
831
+ convert.keyword.rgb = function (keyword) {
832
+ return colorName[keyword];
833
+ };
834
+
835
+ convert.rgb.xyz = function (rgb) {
836
+ var r = rgb[0] / 255;
837
+ var g = rgb[1] / 255;
838
+ var b = rgb[2] / 255;
839
+
840
+ // assume sRGB
841
+ r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
842
+ g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
843
+ b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
844
+
845
+ var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
846
+ var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
847
+ var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
848
+
849
+ return [x * 100, y * 100, z * 100];
850
+ };
851
+
852
+ convert.rgb.lab = function (rgb) {
853
+ var xyz = convert.rgb.xyz(rgb);
854
+ var x = xyz[0];
855
+ var y = xyz[1];
856
+ var z = xyz[2];
857
+ var l;
858
+ var a;
859
+ var b;
860
+
861
+ x /= 95.047;
862
+ y /= 100;
863
+ z /= 108.883;
864
+
865
+ x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
866
+ y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
867
+ z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
868
+
869
+ l = (116 * y) - 16;
870
+ a = 500 * (x - y);
871
+ b = 200 * (y - z);
872
+
873
+ return [l, a, b];
874
+ };
875
+
876
+ convert.hsl.rgb = function (hsl) {
877
+ var h = hsl[0] / 360;
878
+ var s = hsl[1] / 100;
879
+ var l = hsl[2] / 100;
880
+ var t1;
881
+ var t2;
882
+ var t3;
883
+ var rgb;
884
+ var val;
885
+
886
+ if (s === 0) {
887
+ val = l * 255;
888
+ return [val, val, val];
889
+ }
890
+
891
+ if (l < 0.5) {
892
+ t2 = l * (1 + s);
893
+ } else {
894
+ t2 = l + s - l * s;
895
+ }
896
+
897
+ t1 = 2 * l - t2;
898
+
899
+ rgb = [0, 0, 0];
900
+ for (var i = 0; i < 3; i++) {
901
+ t3 = h + 1 / 3 * -(i - 1);
902
+ if (t3 < 0) {
903
+ t3++;
904
+ }
905
+ if (t3 > 1) {
906
+ t3--;
907
+ }
908
+
909
+ if (6 * t3 < 1) {
910
+ val = t1 + (t2 - t1) * 6 * t3;
911
+ } else if (2 * t3 < 1) {
912
+ val = t2;
913
+ } else if (3 * t3 < 2) {
914
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
915
+ } else {
916
+ val = t1;
917
+ }
918
+
919
+ rgb[i] = val * 255;
920
+ }
921
+
922
+ return rgb;
923
+ };
924
+
925
+ convert.hsl.hsv = function (hsl) {
926
+ var h = hsl[0];
927
+ var s = hsl[1] / 100;
928
+ var l = hsl[2] / 100;
929
+ var smin = s;
930
+ var lmin = Math.max(l, 0.01);
931
+ var sv;
932
+ var v;
933
+
934
+ l *= 2;
935
+ s *= (l <= 1) ? l : 2 - l;
936
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
937
+ v = (l + s) / 2;
938
+ sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
939
+
940
+ return [h, sv * 100, v * 100];
941
+ };
942
+
943
+ convert.hsv.rgb = function (hsv) {
944
+ var h = hsv[0] / 60;
945
+ var s = hsv[1] / 100;
946
+ var v = hsv[2] / 100;
947
+ var hi = Math.floor(h) % 6;
948
+
949
+ var f = h - Math.floor(h);
950
+ var p = 255 * v * (1 - s);
951
+ var q = 255 * v * (1 - (s * f));
952
+ var t = 255 * v * (1 - (s * (1 - f)));
953
+ v *= 255;
954
+
955
+ switch (hi) {
956
+ case 0:
957
+ return [v, t, p];
958
+ case 1:
959
+ return [q, v, p];
960
+ case 2:
961
+ return [p, v, t];
962
+ case 3:
963
+ return [p, q, v];
964
+ case 4:
965
+ return [t, p, v];
966
+ case 5:
967
+ return [v, p, q];
968
+ }
969
+ };
970
+
971
+ convert.hsv.hsl = function (hsv) {
972
+ var h = hsv[0];
973
+ var s = hsv[1] / 100;
974
+ var v = hsv[2] / 100;
975
+ var vmin = Math.max(v, 0.01);
976
+ var lmin;
977
+ var sl;
978
+ var l;
979
+
980
+ l = (2 - s) * v;
981
+ lmin = (2 - s) * vmin;
982
+ sl = s * vmin;
983
+ sl /= (lmin <= 1) ? lmin : 2 - lmin;
984
+ sl = sl || 0;
985
+ l /= 2;
986
+
987
+ return [h, sl * 100, l * 100];
988
+ };
989
+
990
+ // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
991
+ convert.hwb.rgb = function (hwb) {
992
+ var h = hwb[0] / 360;
993
+ var wh = hwb[1] / 100;
994
+ var bl = hwb[2] / 100;
995
+ var ratio = wh + bl;
996
+ var i;
997
+ var v;
998
+ var f;
999
+ var n;
1000
+
1001
+ // wh + bl cant be > 1
1002
+ if (ratio > 1) {
1003
+ wh /= ratio;
1004
+ bl /= ratio;
1005
+ }
1006
+
1007
+ i = Math.floor(6 * h);
1008
+ v = 1 - bl;
1009
+ f = 6 * h - i;
1010
+
1011
+ if ((i & 0x01) !== 0) {
1012
+ f = 1 - f;
1013
+ }
1014
+
1015
+ n = wh + f * (v - wh); // linear interpolation
1016
+
1017
+ var r;
1018
+ var g;
1019
+ var b;
1020
+ switch (i) {
1021
+ default:
1022
+ case 6:
1023
+ case 0: r = v; g = n; b = wh; break;
1024
+ case 1: r = n; g = v; b = wh; break;
1025
+ case 2: r = wh; g = v; b = n; break;
1026
+ case 3: r = wh; g = n; b = v; break;
1027
+ case 4: r = n; g = wh; b = v; break;
1028
+ case 5: r = v; g = wh; b = n; break;
1029
+ }
1030
+
1031
+ return [r * 255, g * 255, b * 255];
1032
+ };
1033
+
1034
+ convert.cmyk.rgb = function (cmyk) {
1035
+ var c = cmyk[0] / 100;
1036
+ var m = cmyk[1] / 100;
1037
+ var y = cmyk[2] / 100;
1038
+ var k = cmyk[3] / 100;
1039
+ var r;
1040
+ var g;
1041
+ var b;
1042
+
1043
+ r = 1 - Math.min(1, c * (1 - k) + k);
1044
+ g = 1 - Math.min(1, m * (1 - k) + k);
1045
+ b = 1 - Math.min(1, y * (1 - k) + k);
1046
+
1047
+ return [r * 255, g * 255, b * 255];
1048
+ };
1049
+
1050
+ convert.xyz.rgb = function (xyz) {
1051
+ var x = xyz[0] / 100;
1052
+ var y = xyz[1] / 100;
1053
+ var z = xyz[2] / 100;
1054
+ var r;
1055
+ var g;
1056
+ var b;
1057
+
1058
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
1059
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
1060
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
1061
+
1062
+ // assume sRGB
1063
+ r = r > 0.0031308
1064
+ ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
1065
+ : r * 12.92;
1066
+
1067
+ g = g > 0.0031308
1068
+ ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
1069
+ : g * 12.92;
1070
+
1071
+ b = b > 0.0031308
1072
+ ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
1073
+ : b * 12.92;
1074
+
1075
+ r = Math.min(Math.max(0, r), 1);
1076
+ g = Math.min(Math.max(0, g), 1);
1077
+ b = Math.min(Math.max(0, b), 1);
1078
+
1079
+ return [r * 255, g * 255, b * 255];
1080
+ };
1081
+
1082
+ convert.xyz.lab = function (xyz) {
1083
+ var x = xyz[0];
1084
+ var y = xyz[1];
1085
+ var z = xyz[2];
1086
+ var l;
1087
+ var a;
1088
+ var b;
1089
+
1090
+ x /= 95.047;
1091
+ y /= 100;
1092
+ z /= 108.883;
1093
+
1094
+ x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
1095
+ y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
1096
+ z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
1097
+
1098
+ l = (116 * y) - 16;
1099
+ a = 500 * (x - y);
1100
+ b = 200 * (y - z);
1101
+
1102
+ return [l, a, b];
1103
+ };
1104
+
1105
+ convert.lab.xyz = function (lab) {
1106
+ var l = lab[0];
1107
+ var a = lab[1];
1108
+ var b = lab[2];
1109
+ var x;
1110
+ var y;
1111
+ var z;
1112
+
1113
+ y = (l + 16) / 116;
1114
+ x = a / 500 + y;
1115
+ z = y - b / 200;
1116
+
1117
+ var y2 = Math.pow(y, 3);
1118
+ var x2 = Math.pow(x, 3);
1119
+ var z2 = Math.pow(z, 3);
1120
+ y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
1121
+ x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
1122
+ z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
1123
+
1124
+ x *= 95.047;
1125
+ y *= 100;
1126
+ z *= 108.883;
1127
+
1128
+ return [x, y, z];
1129
+ };
1130
+
1131
+ convert.lab.lch = function (lab) {
1132
+ var l = lab[0];
1133
+ var a = lab[1];
1134
+ var b = lab[2];
1135
+ var hr;
1136
+ var h;
1137
+ var c;
1138
+
1139
+ hr = Math.atan2(b, a);
1140
+ h = hr * 360 / 2 / Math.PI;
1141
+
1142
+ if (h < 0) {
1143
+ h += 360;
1144
+ }
1145
+
1146
+ c = Math.sqrt(a * a + b * b);
1147
+
1148
+ return [l, c, h];
1149
+ };
1150
+
1151
+ convert.lch.lab = function (lch) {
1152
+ var l = lch[0];
1153
+ var c = lch[1];
1154
+ var h = lch[2];
1155
+ var a;
1156
+ var b;
1157
+ var hr;
1158
+
1159
+ hr = h / 360 * 2 * Math.PI;
1160
+ a = c * Math.cos(hr);
1161
+ b = c * Math.sin(hr);
1162
+
1163
+ return [l, a, b];
1164
+ };
1165
+
1166
+ convert.rgb.ansi16 = function (args) {
1167
+ var r = args[0];
1168
+ var g = args[1];
1169
+ var b = args[2];
1170
+ var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
1171
+
1172
+ value = Math.round(value / 50);
1173
+
1174
+ if (value === 0) {
1175
+ return 30;
1176
+ }
1177
+
1178
+ var ansi = 30
1179
+ + ((Math.round(b / 255) << 2)
1180
+ | (Math.round(g / 255) << 1)
1181
+ | Math.round(r / 255));
1182
+
1183
+ if (value === 2) {
1184
+ ansi += 60;
1185
+ }
1186
+
1187
+ return ansi;
1188
+ };
1189
+
1190
+ convert.hsv.ansi16 = function (args) {
1191
+ // optimization here; we already know the value and don't need to get
1192
+ // it converted for us.
1193
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
1194
+ };
1195
+
1196
+ convert.rgb.ansi256 = function (args) {
1197
+ var r = args[0];
1198
+ var g = args[1];
1199
+ var b = args[2];
1200
+
1201
+ // we use the extended greyscale palette here, with the exception of
1202
+ // black and white. normal palette only has 4 greyscale shades.
1203
+ if (r === g && g === b) {
1204
+ if (r < 8) {
1205
+ return 16;
1206
+ }
1207
+
1208
+ if (r > 248) {
1209
+ return 231;
1210
+ }
1211
+
1212
+ return Math.round(((r - 8) / 247) * 24) + 232;
1213
+ }
1214
+
1215
+ var ansi = 16
1216
+ + (36 * Math.round(r / 255 * 5))
1217
+ + (6 * Math.round(g / 255 * 5))
1218
+ + Math.round(b / 255 * 5);
1219
+
1220
+ return ansi;
1221
+ };
1222
+
1223
+ convert.ansi16.rgb = function (args) {
1224
+ var color = args % 10;
1225
+
1226
+ // handle greyscale
1227
+ if (color === 0 || color === 7) {
1228
+ if (args > 50) {
1229
+ color += 3.5;
1230
+ }
1231
+
1232
+ color = color / 10.5 * 255;
1233
+
1234
+ return [color, color, color];
1235
+ }
1236
+
1237
+ var mult = (~~(args > 50) + 1) * 0.5;
1238
+ var r = ((color & 1) * mult) * 255;
1239
+ var g = (((color >> 1) & 1) * mult) * 255;
1240
+ var b = (((color >> 2) & 1) * mult) * 255;
1241
+
1242
+ return [r, g, b];
1243
+ };
1244
+
1245
+ convert.ansi256.rgb = function (args) {
1246
+ // handle greyscale
1247
+ if (args >= 232) {
1248
+ var c = (args - 232) * 10 + 8;
1249
+ return [c, c, c];
1250
+ }
1251
+
1252
+ args -= 16;
1253
+
1254
+ var rem;
1255
+ var r = Math.floor(args / 36) / 5 * 255;
1256
+ var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1257
+ var b = (rem % 6) / 5 * 255;
1258
+
1259
+ return [r, g, b];
1260
+ };
1261
+
1262
+ convert.rgb.hex = function (args) {
1263
+ var integer = ((Math.round(args[0]) & 0xFF) << 16)
1264
+ + ((Math.round(args[1]) & 0xFF) << 8)
1265
+ + (Math.round(args[2]) & 0xFF);
1266
+
1267
+ var string = integer.toString(16).toUpperCase();
1268
+ return '000000'.substring(string.length) + string;
1269
+ };
1270
+
1271
+ convert.hex.rgb = function (args) {
1272
+ var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1273
+ if (!match) {
1274
+ return [0, 0, 0];
1275
+ }
1276
+
1277
+ var colorString = match[0];
1278
+
1279
+ if (match[0].length === 3) {
1280
+ colorString = colorString.split('').map(function (char) {
1281
+ return char + char;
1282
+ }).join('');
1283
+ }
1284
+
1285
+ var integer = parseInt(colorString, 16);
1286
+ var r = (integer >> 16) & 0xFF;
1287
+ var g = (integer >> 8) & 0xFF;
1288
+ var b = integer & 0xFF;
1289
+
1290
+ return [r, g, b];
1291
+ };
1292
+
1293
+ convert.rgb.hcg = function (rgb) {
1294
+ var r = rgb[0] / 255;
1295
+ var g = rgb[1] / 255;
1296
+ var b = rgb[2] / 255;
1297
+ var max = Math.max(Math.max(r, g), b);
1298
+ var min = Math.min(Math.min(r, g), b);
1299
+ var chroma = (max - min);
1300
+ var grayscale;
1301
+ var hue;
1302
+
1303
+ if (chroma < 1) {
1304
+ grayscale = min / (1 - chroma);
1305
+ } else {
1306
+ grayscale = 0;
1307
+ }
1308
+
1309
+ if (chroma <= 0) {
1310
+ hue = 0;
1311
+ } else
1312
+ if (max === r) {
1313
+ hue = ((g - b) / chroma) % 6;
1314
+ } else
1315
+ if (max === g) {
1316
+ hue = 2 + (b - r) / chroma;
1317
+ } else {
1318
+ hue = 4 + (r - g) / chroma + 4;
1319
+ }
1320
+
1321
+ hue /= 6;
1322
+ hue %= 1;
1323
+
1324
+ return [hue * 360, chroma * 100, grayscale * 100];
1325
+ };
1326
+
1327
+ convert.hsl.hcg = function (hsl) {
1328
+ var s = hsl[1] / 100;
1329
+ var l = hsl[2] / 100;
1330
+ var c = 1;
1331
+ var f = 0;
1332
+
1333
+ if (l < 0.5) {
1334
+ c = 2.0 * s * l;
1335
+ } else {
1336
+ c = 2.0 * s * (1.0 - l);
1337
+ }
1338
+
1339
+ if (c < 1.0) {
1340
+ f = (l - 0.5 * c) / (1.0 - c);
1341
+ }
1342
+
1343
+ return [hsl[0], c * 100, f * 100];
1344
+ };
1345
+
1346
+ convert.hsv.hcg = function (hsv) {
1347
+ var s = hsv[1] / 100;
1348
+ var v = hsv[2] / 100;
1349
+
1350
+ var c = s * v;
1351
+ var f = 0;
1352
+
1353
+ if (c < 1.0) {
1354
+ f = (v - c) / (1 - c);
1355
+ }
1356
+
1357
+ return [hsv[0], c * 100, f * 100];
1358
+ };
1359
+
1360
+ convert.hcg.rgb = function (hcg) {
1361
+ var h = hcg[0] / 360;
1362
+ var c = hcg[1] / 100;
1363
+ var g = hcg[2] / 100;
1364
+
1365
+ if (c === 0.0) {
1366
+ return [g * 255, g * 255, g * 255];
1367
+ }
1368
+
1369
+ var pure = [0, 0, 0];
1370
+ var hi = (h % 1) * 6;
1371
+ var v = hi % 1;
1372
+ var w = 1 - v;
1373
+ var mg = 0;
1374
+
1375
+ switch (Math.floor(hi)) {
1376
+ case 0:
1377
+ pure[0] = 1; pure[1] = v; pure[2] = 0; break;
1378
+ case 1:
1379
+ pure[0] = w; pure[1] = 1; pure[2] = 0; break;
1380
+ case 2:
1381
+ pure[0] = 0; pure[1] = 1; pure[2] = v; break;
1382
+ case 3:
1383
+ pure[0] = 0; pure[1] = w; pure[2] = 1; break;
1384
+ case 4:
1385
+ pure[0] = v; pure[1] = 0; pure[2] = 1; break;
1386
+ default:
1387
+ pure[0] = 1; pure[1] = 0; pure[2] = w;
1388
+ }
1389
+
1390
+ mg = (1.0 - c) * g;
1391
+
1392
+ return [
1393
+ (c * pure[0] + mg) * 255,
1394
+ (c * pure[1] + mg) * 255,
1395
+ (c * pure[2] + mg) * 255
1396
+ ];
1397
+ };
1398
+
1399
+ convert.hcg.hsv = function (hcg) {
1400
+ var c = hcg[1] / 100;
1401
+ var g = hcg[2] / 100;
1402
+
1403
+ var v = c + g * (1.0 - c);
1404
+ var f = 0;
1405
+
1406
+ if (v > 0.0) {
1407
+ f = c / v;
1408
+ }
1409
+
1410
+ return [hcg[0], f * 100, v * 100];
1411
+ };
1412
+
1413
+ convert.hcg.hsl = function (hcg) {
1414
+ var c = hcg[1] / 100;
1415
+ var g = hcg[2] / 100;
1416
+
1417
+ var l = g * (1.0 - c) + 0.5 * c;
1418
+ var s = 0;
1419
+
1420
+ if (l > 0.0 && l < 0.5) {
1421
+ s = c / (2 * l);
1422
+ } else
1423
+ if (l >= 0.5 && l < 1.0) {
1424
+ s = c / (2 * (1 - l));
1425
+ }
1426
+
1427
+ return [hcg[0], s * 100, l * 100];
1428
+ };
1429
+
1430
+ convert.hcg.hwb = function (hcg) {
1431
+ var c = hcg[1] / 100;
1432
+ var g = hcg[2] / 100;
1433
+ var v = c + g * (1.0 - c);
1434
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
1435
+ };
1436
+
1437
+ convert.hwb.hcg = function (hwb) {
1438
+ var w = hwb[1] / 100;
1439
+ var b = hwb[2] / 100;
1440
+ var v = 1 - b;
1441
+ var c = v - w;
1442
+ var g = 0;
1443
+
1444
+ if (c < 1) {
1445
+ g = (v - c) / (1 - c);
1446
+ }
1447
+
1448
+ return [hwb[0], c * 100, g * 100];
1449
+ };
1450
+
1451
+ convert.apple.rgb = function (apple) {
1452
+ return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
1453
+ };
1454
+
1455
+ convert.rgb.apple = function (rgb) {
1456
+ return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
1457
+ };
1458
+
1459
+ convert.gray.rgb = function (args) {
1460
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1461
+ };
1462
+
1463
+ convert.gray.hsl = convert.gray.hsv = function (args) {
1464
+ return [0, 0, args[0]];
1465
+ };
1466
+
1467
+ convert.gray.hwb = function (gray) {
1468
+ return [0, 100, gray[0]];
1469
+ };
1470
+
1471
+ convert.gray.cmyk = function (gray) {
1472
+ return [0, 0, 0, gray[0]];
1473
+ };
1474
+
1475
+ convert.gray.lab = function (gray) {
1476
+ return [gray[0], 0, 0];
1477
+ };
1478
+
1479
+ convert.gray.hex = function (gray) {
1480
+ var val = Math.round(gray[0] / 100 * 255) & 0xFF;
1481
+ var integer = (val << 16) + (val << 8) + val;
1482
+
1483
+ var string = integer.toString(16).toUpperCase();
1484
+ return '000000'.substring(string.length) + string;
1485
+ };
1486
+
1487
+ convert.rgb.gray = function (rgb) {
1488
+ var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1489
+ return [val / 255 * 100];
1490
+ };
1491
+ });
1492
+
1493
+ /*
1494
+ this function routes a model to all other models.
1495
+
1496
+ all functions that are routed have a property `.conversion` attached
1497
+ to the returned synthetic function. This property is an array
1498
+ of strings, each with the steps in between the 'from' and 'to'
1499
+ color models (inclusive).
1500
+
1501
+ conversions that are not possible simply are not included.
1502
+ */
1503
+
1504
+ function buildGraph() {
1505
+ var graph = {};
1506
+ // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1507
+ var models = Object.keys(conversions);
1508
+
1509
+ for (var len = models.length, i = 0; i < len; i++) {
1510
+ graph[models[i]] = {
1511
+ // http://jsperf.com/1-vs-infinity
1512
+ // micro-opt, but this is simple.
1513
+ distance: -1,
1514
+ parent: null
1515
+ };
1516
+ }
1517
+
1518
+ return graph;
1519
+ }
1520
+
1521
+ // https://en.wikipedia.org/wiki/Breadth-first_search
1522
+ function deriveBFS(fromModel) {
1523
+ var graph = buildGraph();
1524
+ var queue = [fromModel]; // unshift -> queue -> pop
1525
+
1526
+ graph[fromModel].distance = 0;
1527
+
1528
+ while (queue.length) {
1529
+ var current = queue.pop();
1530
+ var adjacents = Object.keys(conversions[current]);
1531
+
1532
+ for (var len = adjacents.length, i = 0; i < len; i++) {
1533
+ var adjacent = adjacents[i];
1534
+ var node = graph[adjacent];
1535
+
1536
+ if (node.distance === -1) {
1537
+ node.distance = graph[current].distance + 1;
1538
+ node.parent = current;
1539
+ queue.unshift(adjacent);
1540
+ }
1541
+ }
1542
+ }
1543
+
1544
+ return graph;
1545
+ }
1546
+
1547
+ function link(from, to) {
1548
+ return function (args) {
1549
+ return to(from(args));
1550
+ };
1551
+ }
1552
+
1553
+ function wrapConversion(toModel, graph) {
1554
+ var path = [graph[toModel].parent, toModel];
1555
+ var fn = conversions[graph[toModel].parent][toModel];
1556
+
1557
+ var cur = graph[toModel].parent;
1558
+ while (graph[cur].parent) {
1559
+ path.unshift(graph[cur].parent);
1560
+ fn = link(conversions[graph[cur].parent][cur], fn);
1561
+ cur = graph[cur].parent;
1562
+ }
1563
+
1564
+ fn.conversion = path;
1565
+ return fn;
1566
+ }
1567
+
1568
+ var route = function (fromModel) {
1569
+ var graph = deriveBFS(fromModel);
1570
+ var conversion = {};
1571
+
1572
+ var models = Object.keys(graph);
1573
+ for (var len = models.length, i = 0; i < len; i++) {
1574
+ var toModel = models[i];
1575
+ var node = graph[toModel];
1576
+
1577
+ if (node.parent === null) {
1578
+ // no possible conversion, or this node is the source model.
1579
+ continue;
1580
+ }
1581
+
1582
+ conversion[toModel] = wrapConversion(toModel, graph);
1583
+ }
1584
+
1585
+ return conversion;
1586
+ };
1587
+
1588
+ var convert = {};
1589
+
1590
+ var models = Object.keys(conversions);
1591
+
1592
+ function wrapRaw(fn) {
1593
+ var wrappedFn = function (args) {
1594
+ if (args === undefined || args === null) {
1595
+ return args;
1596
+ }
1597
+
1598
+ if (arguments.length > 1) {
1599
+ args = Array.prototype.slice.call(arguments);
1600
+ }
1601
+
1602
+ return fn(args);
1603
+ };
1604
+
1605
+ // preserve .conversion property if there is one
1606
+ if ('conversion' in fn) {
1607
+ wrappedFn.conversion = fn.conversion;
1608
+ }
1609
+
1610
+ return wrappedFn;
1611
+ }
1612
+
1613
+ function wrapRounded(fn) {
1614
+ var wrappedFn = function (args) {
1615
+ if (args === undefined || args === null) {
1616
+ return args;
1617
+ }
1618
+
1619
+ if (arguments.length > 1) {
1620
+ args = Array.prototype.slice.call(arguments);
1621
+ }
1622
+
1623
+ var result = fn(args);
1624
+
1625
+ // we're assuming the result is an array here.
1626
+ // see notice in conversions.js; don't use box types
1627
+ // in conversion functions.
1628
+ if (typeof result === 'object') {
1629
+ for (var len = result.length, i = 0; i < len; i++) {
1630
+ result[i] = Math.round(result[i]);
1631
+ }
1632
+ }
1633
+
1634
+ return result;
1635
+ };
1636
+
1637
+ // preserve .conversion property if there is one
1638
+ if ('conversion' in fn) {
1639
+ wrappedFn.conversion = fn.conversion;
1640
+ }
1641
+
1642
+ return wrappedFn;
1643
+ }
1644
+
1645
+ models.forEach(function (fromModel) {
1646
+ convert[fromModel] = {};
1647
+
1648
+ Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
1649
+ Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
1650
+
1651
+ var routes = route(fromModel);
1652
+ var routeModels = Object.keys(routes);
1653
+
1654
+ routeModels.forEach(function (toModel) {
1655
+ var fn = routes[toModel];
1656
+
1657
+ convert[fromModel][toModel] = wrapRounded(fn);
1658
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1659
+ });
1660
+ });
1661
+
1662
+ var colorConvert = convert;
1663
+
1664
+ var _slice = [].slice;
1665
+
1666
+ var skippedModels = [
1667
+ // to be honest, I don't really feel like keyword belongs in color convert, but eh.
1668
+ 'keyword',
1669
+
1670
+ // gray conflicts with some method names, and has its own method defined.
1671
+ 'gray',
1672
+
1673
+ // shouldn't really be in color-convert either...
1674
+ 'hex'
1675
+ ];
1676
+
1677
+ var hashedModelKeys = {};
1678
+ Object.keys(colorConvert).forEach(function (model) {
1679
+ hashedModelKeys[_slice.call(colorConvert[model].labels).sort().join('')] = model;
1680
+ });
1681
+
1682
+ var limiters = {};
1683
+
1684
+ function Color(obj, model) {
1685
+ if (!(this instanceof Color)) {
1686
+ return new Color(obj, model);
1687
+ }
1688
+
1689
+ if (model && model in skippedModels) {
1690
+ model = null;
1691
+ }
1692
+
1693
+ if (model && !(model in colorConvert)) {
1694
+ throw new Error('Unknown model: ' + model);
1695
+ }
1696
+
1697
+ var i;
1698
+ var channels;
1699
+
1700
+ if (obj == null) { // eslint-disable-line no-eq-null,eqeqeq
1701
+ this.model = 'rgb';
1702
+ this.color = [0, 0, 0];
1703
+ this.valpha = 1;
1704
+ } else if (obj instanceof Color) {
1705
+ this.model = obj.model;
1706
+ this.color = obj.color.slice();
1707
+ this.valpha = obj.valpha;
1708
+ } else if (typeof obj === 'string') {
1709
+ var result = colorString.get(obj);
1710
+ if (result === null) {
1711
+ throw new Error('Unable to parse color from string: ' + obj);
1712
+ }
1713
+
1714
+ this.model = result.model;
1715
+ channels = colorConvert[this.model].channels;
1716
+ this.color = result.value.slice(0, channels);
1717
+ this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
1718
+ } else if (obj.length) {
1719
+ this.model = model || 'rgb';
1720
+ channels = colorConvert[this.model].channels;
1721
+ var newArr = _slice.call(obj, 0, channels);
1722
+ this.color = zeroArray(newArr, channels);
1723
+ this.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1;
1724
+ } else if (typeof obj === 'number') {
1725
+ // this is always RGB - can be converted later on.
1726
+ obj &= 0xFFFFFF;
1727
+ this.model = 'rgb';
1728
+ this.color = [
1729
+ (obj >> 16) & 0xFF,
1730
+ (obj >> 8) & 0xFF,
1731
+ obj & 0xFF
1732
+ ];
1733
+ this.valpha = 1;
1734
+ } else {
1735
+ this.valpha = 1;
1736
+
1737
+ var keys = Object.keys(obj);
1738
+ if ('alpha' in obj) {
1739
+ keys.splice(keys.indexOf('alpha'), 1);
1740
+ this.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0;
1741
+ }
1742
+
1743
+ var hashedKeys = keys.sort().join('');
1744
+ if (!(hashedKeys in hashedModelKeys)) {
1745
+ throw new Error('Unable to parse color from object: ' + JSON.stringify(obj));
1746
+ }
1747
+
1748
+ this.model = hashedModelKeys[hashedKeys];
1749
+
1750
+ var labels = colorConvert[this.model].labels;
1751
+ var color = [];
1752
+ for (i = 0; i < labels.length; i++) {
1753
+ color.push(obj[labels[i]]);
1754
+ }
1755
+
1756
+ this.color = zeroArray(color);
1757
+ }
1758
+
1759
+ // perform limitations (clamping, etc.)
1760
+ if (limiters[this.model]) {
1761
+ channels = colorConvert[this.model].channels;
1762
+ for (i = 0; i < channels; i++) {
1763
+ var limit = limiters[this.model][i];
1764
+ if (limit) {
1765
+ this.color[i] = limit(this.color[i]);
1766
+ }
1767
+ }
1768
+ }
1769
+
1770
+ this.valpha = Math.max(0, Math.min(1, this.valpha));
1771
+
1772
+ if (Object.freeze) {
1773
+ Object.freeze(this);
1774
+ }
1775
+ }
1776
+
1777
+ Color.prototype = {
1778
+ toString: function () {
1779
+ return this.string();
1780
+ },
1781
+
1782
+ toJSON: function () {
1783
+ return this[this.model]();
1784
+ },
1785
+
1786
+ string: function (places) {
1787
+ var self = this.model in colorString.to ? this : this.rgb();
1788
+ self = self.round(typeof places === 'number' ? places : 1);
1789
+ var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
1790
+ return colorString.to[self.model](args);
1791
+ },
1792
+
1793
+ percentString: function (places) {
1794
+ var self = this.rgb().round(typeof places === 'number' ? places : 1);
1795
+ var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
1796
+ return colorString.to.rgb.percent(args);
1797
+ },
1798
+
1799
+ array: function () {
1800
+ return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
1801
+ },
1802
+
1803
+ object: function () {
1804
+ var result = {};
1805
+ var channels = colorConvert[this.model].channels;
1806
+ var labels = colorConvert[this.model].labels;
1807
+
1808
+ for (var i = 0; i < channels; i++) {
1809
+ result[labels[i]] = this.color[i];
1810
+ }
1811
+
1812
+ if (this.valpha !== 1) {
1813
+ result.alpha = this.valpha;
1814
+ }
1815
+
1816
+ return result;
1817
+ },
1818
+
1819
+ unitArray: function () {
1820
+ var rgb = this.rgb().color;
1821
+ rgb[0] /= 255;
1822
+ rgb[1] /= 255;
1823
+ rgb[2] /= 255;
1824
+
1825
+ if (this.valpha !== 1) {
1826
+ rgb.push(this.valpha);
1827
+ }
1828
+
1829
+ return rgb;
1830
+ },
1831
+
1832
+ unitObject: function () {
1833
+ var rgb = this.rgb().object();
1834
+ rgb.r /= 255;
1835
+ rgb.g /= 255;
1836
+ rgb.b /= 255;
1837
+
1838
+ if (this.valpha !== 1) {
1839
+ rgb.alpha = this.valpha;
1840
+ }
1841
+
1842
+ return rgb;
1843
+ },
1844
+
1845
+ round: function (places) {
1846
+ places = Math.max(places || 0, 0);
1847
+ return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
1848
+ },
1849
+
1850
+ alpha: function (val) {
1851
+ if (arguments.length) {
1852
+ return new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);
1853
+ }
1854
+
1855
+ return this.valpha;
1856
+ },
1857
+
1858
+ // rgb
1859
+ red: getset('rgb', 0, maxfn(255)),
1860
+ green: getset('rgb', 1, maxfn(255)),
1861
+ blue: getset('rgb', 2, maxfn(255)),
1862
+
1863
+ hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style
1864
+
1865
+ saturationl: getset('hsl', 1, maxfn(100)),
1866
+ lightness: getset('hsl', 2, maxfn(100)),
1867
+
1868
+ saturationv: getset('hsv', 1, maxfn(100)),
1869
+ value: getset('hsv', 2, maxfn(100)),
1870
+
1871
+ chroma: getset('hcg', 1, maxfn(100)),
1872
+ gray: getset('hcg', 2, maxfn(100)),
1873
+
1874
+ white: getset('hwb', 1, maxfn(100)),
1875
+ wblack: getset('hwb', 2, maxfn(100)),
1876
+
1877
+ cyan: getset('cmyk', 0, maxfn(100)),
1878
+ magenta: getset('cmyk', 1, maxfn(100)),
1879
+ yellow: getset('cmyk', 2, maxfn(100)),
1880
+ black: getset('cmyk', 3, maxfn(100)),
1881
+
1882
+ x: getset('xyz', 0, maxfn(100)),
1883
+ y: getset('xyz', 1, maxfn(100)),
1884
+ z: getset('xyz', 2, maxfn(100)),
1885
+
1886
+ l: getset('lab', 0, maxfn(100)),
1887
+ a: getset('lab', 1),
1888
+ b: getset('lab', 2),
1889
+
1890
+ keyword: function (val) {
1891
+ if (arguments.length) {
1892
+ return new Color(val);
1893
+ }
1894
+
1895
+ return colorConvert[this.model].keyword(this.color);
1896
+ },
1897
+
1898
+ hex: function (val) {
1899
+ if (arguments.length) {
1900
+ return new Color(val);
1901
+ }
1902
+
1903
+ return colorString.to.hex(this.rgb().round().color);
1904
+ },
1905
+
1906
+ rgbNumber: function () {
1907
+ var rgb = this.rgb().color;
1908
+ return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
1909
+ },
1910
+
1911
+ luminosity: function () {
1912
+ // http://www.w3.org/TR/WCAG20/#relativeluminancedef
1913
+ var rgb = this.rgb().color;
1914
+
1915
+ var lum = [];
1916
+ for (var i = 0; i < rgb.length; i++) {
1917
+ var chan = rgb[i] / 255;
1918
+ lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
1919
+ }
1920
+
1921
+ return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
1922
+ },
1923
+
1924
+ contrast: function (color2) {
1925
+ // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
1926
+ var lum1 = this.luminosity();
1927
+ var lum2 = color2.luminosity();
1928
+
1929
+ if (lum1 > lum2) {
1930
+ return (lum1 + 0.05) / (lum2 + 0.05);
1931
+ }
1932
+
1933
+ return (lum2 + 0.05) / (lum1 + 0.05);
1934
+ },
1935
+
1936
+ level: function (color2) {
1937
+ var contrastRatio = this.contrast(color2);
1938
+ if (contrastRatio >= 7.1) {
1939
+ return 'AAA';
1940
+ }
1941
+
1942
+ return (contrastRatio >= 4.5) ? 'AA' : '';
1943
+ },
1944
+
1945
+ isDark: function () {
1946
+ // YIQ equation from http://24ways.org/2010/calculating-color-contrast
1947
+ var rgb = this.rgb().color;
1948
+ var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
1949
+ return yiq < 128;
1950
+ },
1951
+
1952
+ isLight: function () {
1953
+ return !this.isDark();
1954
+ },
1955
+
1956
+ negate: function () {
1957
+ var rgb = this.rgb();
1958
+ for (var i = 0; i < 3; i++) {
1959
+ rgb.color[i] = 255 - rgb.color[i];
1960
+ }
1961
+ return rgb;
1962
+ },
1963
+
1964
+ lighten: function (ratio) {
1965
+ var hsl = this.hsl();
1966
+ hsl.color[2] += hsl.color[2] * ratio;
1967
+ return hsl;
1968
+ },
1969
+
1970
+ darken: function (ratio) {
1971
+ var hsl = this.hsl();
1972
+ hsl.color[2] -= hsl.color[2] * ratio;
1973
+ return hsl;
1974
+ },
1975
+
1976
+ saturate: function (ratio) {
1977
+ var hsl = this.hsl();
1978
+ hsl.color[1] += hsl.color[1] * ratio;
1979
+ return hsl;
1980
+ },
1981
+
1982
+ desaturate: function (ratio) {
1983
+ var hsl = this.hsl();
1984
+ hsl.color[1] -= hsl.color[1] * ratio;
1985
+ return hsl;
1986
+ },
1987
+
1988
+ whiten: function (ratio) {
1989
+ var hwb = this.hwb();
1990
+ hwb.color[1] += hwb.color[1] * ratio;
1991
+ return hwb;
1992
+ },
1993
+
1994
+ blacken: function (ratio) {
1995
+ var hwb = this.hwb();
1996
+ hwb.color[2] += hwb.color[2] * ratio;
1997
+ return hwb;
1998
+ },
1999
+
2000
+ grayscale: function () {
2001
+ // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
2002
+ var rgb = this.rgb().color;
2003
+ var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
2004
+ return Color.rgb(val, val, val);
2005
+ },
2006
+
2007
+ fade: function (ratio) {
2008
+ return this.alpha(this.valpha - (this.valpha * ratio));
2009
+ },
2010
+
2011
+ opaquer: function (ratio) {
2012
+ return this.alpha(this.valpha + (this.valpha * ratio));
2013
+ },
2014
+
2015
+ rotate: function (degrees) {
2016
+ var hsl = this.hsl();
2017
+ var hue = hsl.color[0];
2018
+ hue = (hue + degrees) % 360;
2019
+ hue = hue < 0 ? 360 + hue : hue;
2020
+ hsl.color[0] = hue;
2021
+ return hsl;
2022
+ },
2023
+
2024
+ mix: function (mixinColor, weight) {
2025
+ // ported from sass implementation in C
2026
+ // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
2027
+ if (!mixinColor || !mixinColor.rgb) {
2028
+ throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
2029
+ }
2030
+ var color1 = mixinColor.rgb();
2031
+ var color2 = this.rgb();
2032
+ var p = weight === undefined ? 0.5 : weight;
2033
+
2034
+ var w = 2 * p - 1;
2035
+ var a = color1.alpha() - color2.alpha();
2036
+
2037
+ var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
2038
+ var w2 = 1 - w1;
2039
+
2040
+ return Color.rgb(
2041
+ w1 * color1.red() + w2 * color2.red(),
2042
+ w1 * color1.green() + w2 * color2.green(),
2043
+ w1 * color1.blue() + w2 * color2.blue(),
2044
+ color1.alpha() * p + color2.alpha() * (1 - p));
2045
+ }
2046
+ };
2047
+
2048
+ // model conversion methods and static constructors
2049
+ Object.keys(colorConvert).forEach(function (model) {
2050
+ if (skippedModels.indexOf(model) !== -1) {
2051
+ return;
2052
+ }
2053
+
2054
+ var channels = colorConvert[model].channels;
2055
+
2056
+ // conversion methods
2057
+ Color.prototype[model] = function () {
2058
+ if (this.model === model) {
2059
+ return new Color(this);
2060
+ }
2061
+
2062
+ if (arguments.length) {
2063
+ return new Color(arguments, model);
2064
+ }
2065
+
2066
+ var newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;
2067
+ return new Color(assertArray(colorConvert[this.model][model].raw(this.color)).concat(newAlpha), model);
2068
+ };
2069
+
2070
+ // 'static' construction methods
2071
+ Color[model] = function (color) {
2072
+ if (typeof color === 'number') {
2073
+ color = zeroArray(_slice.call(arguments), channels);
2074
+ }
2075
+ return new Color(color, model);
2076
+ };
2077
+ });
2078
+
2079
+ function roundTo(num, places) {
2080
+ return Number(num.toFixed(places));
2081
+ }
2082
+
2083
+ function roundToPlace(places) {
2084
+ return function (num) {
2085
+ return roundTo(num, places);
2086
+ };
2087
+ }
2088
+
2089
+ function getset(model, channel, modifier) {
2090
+ model = Array.isArray(model) ? model : [model];
2091
+
2092
+ model.forEach(function (m) {
2093
+ (limiters[m] || (limiters[m] = []))[channel] = modifier;
2094
+ });
2095
+
2096
+ model = model[0];
2097
+
2098
+ return function (val) {
2099
+ var result;
2100
+
2101
+ if (arguments.length) {
2102
+ if (modifier) {
2103
+ val = modifier(val);
2104
+ }
2105
+
2106
+ result = this[model]();
2107
+ result.color[channel] = val;
2108
+ return result;
2109
+ }
2110
+
2111
+ result = this[model]().color[channel];
2112
+ if (modifier) {
2113
+ result = modifier(result);
2114
+ }
2115
+
2116
+ return result;
2117
+ };
2118
+ }
2119
+
2120
+ function maxfn(max) {
2121
+ return function (v) {
2122
+ return Math.max(0, Math.min(max, v));
2123
+ };
2124
+ }
2125
+
2126
+ function assertArray(val) {
2127
+ return Array.isArray(val) ? val : [val];
2128
+ }
2129
+
2130
+ function zeroArray(arr, length) {
2131
+ for (var i = 0; i < length; i++) {
2132
+ if (typeof arr[i] !== 'number') {
2133
+ arr[i] = 0;
2134
+ }
2135
+ }
2136
+
2137
+ return arr;
2138
+ }
2139
+
2140
+ const funnelDefs = [
2141
+ { id: 1, height: 400, width: 100, x: 10, y: 10, drop: 20 },
2142
+ { id: 2, height: 356, width: 100, x: 120, y: 32, drop: 20 },
2143
+ { id: 3, height: 312, width: 100, x: 230, y: 54, drop: 20 },
2144
+ { id: 4, height: 268, width: 100, x: 340, y: 76, drop: 20 },
2145
+ { id: 5, height: 224, width: 100, x: 450, y: 98, drop: 20 },
2146
+ ];
2147
+ const sample = funnelDefs.map(() => 0);
2148
+
2149
+ /* NOTE: colors from clrs.cc - A nicer color palette for the web...
2150
+ */
2151
+ const navy = '#001f3f';
2152
+ const blue = '#0074d9';
2153
+ const aqua = '#7fdbff';
2154
+ const teal = '#39cccc';
2155
+ const olive = '#3d9970';
2156
+ const green = '#2ecc40';
2157
+ const lime = '#01ff70';
2158
+ const yellow = '#ffdc00';
2159
+ const orange = '#ff851b';
2160
+ const red = '#ff4136';
2161
+ const maroon = '#85144b';
2162
+ const fuchsia = '#f012be';
2163
+ const purple = '#b10dc9';
2164
+ const black = '#111111';
2165
+ const gray = '#aaaaaa';
2166
+ const silver = '#dddddd';
2167
+ const bada55 = '#bada55';
2168
+ const slate = '#708090';
2169
+ const slate4 = '#4e5964';
2170
+ const white = '#ffffff';
2171
+ // NOTE: this is ONLY used internally...
2172
+ const _namedColors = {
2173
+ bada55,
2174
+ navy,
2175
+ blue,
2176
+ aqua,
2177
+ teal,
2178
+ olive,
2179
+ green,
2180
+ lime,
2181
+ yellow,
2182
+ orange,
2183
+ red,
2184
+ maroon,
2185
+ fuchsia,
2186
+ purple,
2187
+ black,
2188
+ gray,
2189
+ silver,
2190
+ };
2191
+ const _altColors = {
2192
+ slate,
2193
+ slate4,
2194
+ white,
2195
+ };
2196
+ const colorFor = (key) => _namedColors[key] || _altColors[key];
2197
+ const colorKeys = Object.keys(_namedColors);
2198
+
2199
+ const appendToMap = (map, propName, value) => {
2200
+ const items = map.get(propName);
2201
+ if (!items) {
2202
+ map.set(propName, [value]);
2203
+ }
2204
+ else if (!items.includes(value)) {
2205
+ items.push(value);
2206
+ }
2207
+ };
2208
+ const debounce = (fn, ms) => {
2209
+ let timeoutId;
2210
+ return (...args) => {
2211
+ if (timeoutId) {
2212
+ clearTimeout(timeoutId);
2213
+ }
2214
+ timeoutId = setTimeout(() => {
2215
+ timeoutId = 0;
2216
+ fn(...args);
2217
+ }, ms);
2218
+ };
2219
+ };
2220
+
2221
+ /**
2222
+ * Check if a possible element isConnected.
2223
+ * The property might not be there, so we check for it.
2224
+ *
2225
+ * We want it to return true if isConnected is not a property,
2226
+ * otherwise we would remove these elements and would not update.
2227
+ *
2228
+ * Better leak in Edge than to be useless.
2229
+ */
2230
+ const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
2231
+ const cleanupElements = debounce((map) => {
2232
+ for (let key of map.keys()) {
2233
+ map.set(key, map.get(key).filter(isConnected));
2234
+ }
2235
+ }, 2000);
2236
+ const stencilSubscription = () => {
2237
+ if (typeof index.getRenderingRef !== 'function') {
2238
+ // If we are not in a stencil project, we do nothing.
2239
+ // This function is not really exported by @stencil/core.
2240
+ return {};
2241
+ }
2242
+ const elmsToUpdate = new Map();
2243
+ return {
2244
+ dispose: () => elmsToUpdate.clear(),
2245
+ get: (propName) => {
2246
+ const elm = index.getRenderingRef();
2247
+ if (elm) {
2248
+ appendToMap(elmsToUpdate, propName, elm);
2249
+ }
2250
+ },
2251
+ set: (propName) => {
2252
+ const elements = elmsToUpdate.get(propName);
2253
+ if (elements) {
2254
+ elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
2255
+ }
2256
+ cleanupElements(elmsToUpdate);
2257
+ },
2258
+ reset: () => {
2259
+ elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
2260
+ cleanupElements(elmsToUpdate);
2261
+ },
2262
+ };
2263
+ };
2264
+
2265
+ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
2266
+ let states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
2267
+ const handlers = {
2268
+ dispose: [],
2269
+ get: [],
2270
+ set: [],
2271
+ reset: [],
2272
+ };
2273
+ const reset = () => {
2274
+ states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
2275
+ handlers.reset.forEach((cb) => cb());
2276
+ };
2277
+ const dispose = () => {
2278
+ // Call first dispose as resetting the state would
2279
+ // cause less updates ;)
2280
+ handlers.dispose.forEach((cb) => cb());
2281
+ reset();
2282
+ };
2283
+ const get = (propName) => {
2284
+ handlers.get.forEach((cb) => cb(propName));
2285
+ return states.get(propName);
2286
+ };
2287
+ const set = (propName, value) => {
2288
+ const oldValue = states.get(propName);
2289
+ if (shouldUpdate(value, oldValue, propName)) {
2290
+ states.set(propName, value);
2291
+ handlers.set.forEach((cb) => cb(propName, value, oldValue));
2292
+ }
2293
+ };
2294
+ const state = (typeof Proxy === 'undefined'
2295
+ ? {}
2296
+ : new Proxy(defaultState, {
2297
+ get(_, propName) {
2298
+ return get(propName);
2299
+ },
2300
+ ownKeys(_) {
2301
+ return Array.from(states.keys());
2302
+ },
2303
+ getOwnPropertyDescriptor() {
2304
+ return {
2305
+ enumerable: true,
2306
+ configurable: true,
2307
+ };
2308
+ },
2309
+ has(_, propName) {
2310
+ return states.has(propName);
2311
+ },
2312
+ set(_, propName, value) {
2313
+ set(propName, value);
2314
+ return true;
2315
+ },
2316
+ }));
2317
+ const on = (eventName, callback) => {
2318
+ handlers[eventName].push(callback);
2319
+ return () => {
2320
+ removeFromArray(handlers[eventName], callback);
2321
+ };
2322
+ };
2323
+ const onChange = (propName, cb) => {
2324
+ const unSet = on('set', (key, newValue) => {
2325
+ if (key === propName) {
2326
+ cb(newValue);
2327
+ }
2328
+ });
2329
+ const unReset = on('reset', () => cb(defaultState[propName]));
2330
+ return () => {
2331
+ unSet();
2332
+ unReset();
2333
+ };
2334
+ };
2335
+ const use = (...subscriptions) => {
2336
+ const unsubs = subscriptions.reduce((unsubs, subscription) => {
2337
+ if (subscription.set) {
2338
+ unsubs.push(on('set', subscription.set));
2339
+ }
2340
+ if (subscription.get) {
2341
+ unsubs.push(on('get', subscription.get));
2342
+ }
2343
+ if (subscription.reset) {
2344
+ unsubs.push(on('reset', subscription.reset));
2345
+ }
2346
+ if (subscription.dispose) {
2347
+ unsubs.push(on('dispose', subscription.dispose));
2348
+ }
2349
+ return unsubs;
2350
+ }, []);
2351
+ return () => unsubs.forEach((unsub) => unsub());
2352
+ };
2353
+ const forceUpdate = (key) => {
2354
+ const oldValue = states.get(key);
2355
+ handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
2356
+ };
2357
+ return {
2358
+ state,
2359
+ get,
2360
+ set,
2361
+ on,
2362
+ onChange,
2363
+ use,
2364
+ dispose,
2365
+ reset,
2366
+ forceUpdate,
2367
+ };
2368
+ };
2369
+ const removeFromArray = (array, item) => {
2370
+ const index = array.indexOf(item);
2371
+ if (index >= 0) {
2372
+ array[index] = array[array.length - 1];
2373
+ array.length--;
2374
+ }
2375
+ };
2376
+
2377
+ const createStore = (defaultState, shouldUpdate) => {
2378
+ const map = createObservableMap(defaultState, shouldUpdate);
2379
+ map.use(stencilSubscription());
2380
+ return map;
2381
+ };
2382
+
2383
+ const initStore = {
2384
+ count: 0,
2385
+ pick: 'bada55',
2386
+ values: [...sample],
2387
+ };
2388
+ const store = createStore(initStore);
2389
+ const { state } = store;
2390
+ const actions = {
2391
+ refresh: () => {
2392
+ const values = sample.map(() => Math.floor(Math.random() * 100));
2393
+ state.count = state.count + 1;
2394
+ state.values = values;
2395
+ },
2396
+ reset: () => {
2397
+ state.count = 0;
2398
+ state.values = [...sample];
2399
+ },
2400
+ updatePick: pick => {
2401
+ state.pick = pick;
2402
+ },
2403
+ };
2404
+
2405
+ const ColorPicker = _props => {
2406
+ const { pick } = store.state;
2407
+ return (index.h("div", { id: "toolbar", class: "flex flex-wrap", role: "radiogroup" }, colorKeys.map((key) => {
2408
+ const hex = colorFor(key);
2409
+ const selected = pick == key;
2410
+ return (index.h("div", { "aria-label": key, role: "radio", title: key, onClick: () => {
2411
+ actions.updatePick(key);
2412
+ } },
2413
+ index.h(Radio, { hex: hex, selected: selected })));
2414
+ })));
2415
+ };
2416
+
2417
+ const ChevronDoubleLeft = props => {
2418
+ const hex = props.hex || 'currentColor';
2419
+ const klass = props.class;
2420
+ const label = props.label || 'chevron-double-left';
2421
+ const size = props.size || 24;
2422
+ return (index.h("svg", { class: klass, width: size, height: size, viewBox: "0 0 24 24", role: "img", "aria-label": "title" },
2423
+ index.h("title", null, label),
2424
+ index.h("g", { fill: hex },
2425
+ index.h("path", { d: "M18.41,7.41L17,6L11,12L17,18L18.41,16.59L13.83,12L18.41,7.41M12.41,7.41L11,6L5,12L11,18L12.41,16.59L7.83,12L12.41,7.41Z" })),
2426
+ index.h("path", { d: "M0 0h24v24H0z", fill: "none" })));
2427
+ };
2428
+
2429
+ const Close = props => {
2430
+ const hex = props.hex || 'currentColor';
2431
+ const klass = props.class;
2432
+ const label = props.label || 'close';
2433
+ const size = props.size || 24;
2434
+ return (index.h("svg", { class: klass, width: size, height: size, viewBox: "0 0 24 24", role: "img", "aria-label": "title" },
2435
+ index.h("title", null, label),
2436
+ index.h("g", { fill: hex },
2437
+ index.h("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })),
2438
+ index.h("path", { d: "M0 0h24v24H0z", fill: "none" })));
2439
+ };
2440
+
2441
+ const Refresh = props => {
2442
+ const hex = props.hex || 'currentColor';
2443
+ const klass = props.class;
2444
+ const label = props.label || 'refresh';
2445
+ const size = props.size || 24;
2446
+ return (index.h("svg", { class: klass, width: size, height: size, viewBox: "0 0 24 24", role: "img", "aria-label": "title" },
2447
+ index.h("title", null, label),
2448
+ index.h("g", { fill: hex },
2449
+ index.h("path", { d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99\n 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65\n 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35\n 2.35z" })),
2450
+ index.h("path", { d: "M0 0h24v24H0z", fill: "none" })));
2451
+ };
2452
+
2453
+ const help = 'click a button... ';
2454
+ const DataSource = _props => {
2455
+ const { count } = store.state;
2456
+ return (index.h("div", { class: "flex mt-3 mb-10px items-center" },
2457
+ index.h("button", { "aria-label": "Refresh", title: "Refresh", class: "ds1-button data-button bg-clrs-blue", onClick: () => {
2458
+ actions.refresh();
2459
+ } },
2460
+ index.h(Refresh, null)),
2461
+ index.h("button", { "aria-label": "Reset", title: "Reset", class: "ds1-button data-button bg-clrs-red", onClick: () => {
2462
+ actions.reset();
2463
+ } },
2464
+ index.h(Close, null)),
2465
+ index.h("span", { class: "flex items-center" },
2466
+ index.h(ChevronDoubleLeft, { size: 28 }),
2467
+ index.h("span", { class: "italic" },
2468
+ help,
2469
+ index.h("sup", null, count)))));
2470
+ };
2471
+
2472
+ const TW_VERSION = '3.0.2';
2473
+ const TwLabel = _props => {
2474
+ return (index.h("label", { class: "ml-auto align-top text-xs italic text-clrs-slate4" },
2475
+ "Tailwind ",
2476
+ TW_VERSION));
2477
+ };
2478
+
2479
+ const DataValues = _props => {
2480
+ const { values, pick, count } = store.state;
2481
+ return (index.h("div", { class: "flex" },
2482
+ index.h("div", { class: "flex flex-col" },
2483
+ index.h("div", { class: "flex" },
2484
+ index.h("span", { class: "font-bold mr-10px" }, "color:"),
2485
+ index.h("span", { class: "italic text-clrs-slate4" }, pick)),
2486
+ index.h("div", { class: "flex mt-5px" },
2487
+ index.h("span", { class: "font-bold mr-10px" }, "sample:"),
2488
+ index.h("span", { class: "italic text-clrs-slate4" }, `${count > 0 ? values : '...'}`))),
2489
+ index.h(TwLabel, null)));
2490
+ };
2491
+
2492
+ const Fingerprint = props => {
2493
+ const hex = props.hex || 'currentColor';
2494
+ const klass = props.class;
2495
+ const label = props.label || 'fingerprint';
2496
+ const size = props.size || 24;
2497
+ return (index.h("svg", { class: klass, width: size, height: size, viewBox: "0 0 24 24", role: "img", "aria-label": "title" },
2498
+ index.h("title", null, label),
2499
+ index.h("g", { fill: hex },
2500
+ index.h("path", { d: "M17.81,4.47C17.73,4.47 17.65,4.45 17.58,4.41C15.66,3.42 14,3\n 12,3C10.03,3 8.15,3.47 6.44,4.41C6.2,4.54 5.9,4.45 5.76,4.21C5.63,3.97\n 5.72,3.66 5.96,3.53C7.82,2.5 9.86,2 12,2C14.14,2 16,2.47\n 18.04,3.5C18.29,3.65 18.38,3.95 18.25,4.19C18.16,4.37 18,4.47\n 17.81,4.47M3.5,9.72C3.4,9.72 3.3,9.69 3.21,9.63C3,9.47 2.93,9.16\n 3.09,8.93C4.08,7.53 5.34,6.43 6.84,5.66C10,4.04 14,4.03\n 17.15,5.65C18.65,6.42 19.91,7.5 20.9,8.9C21.06,9.12 21,9.44\n 20.78,9.6C20.55,9.76 20.24,9.71 20.08,9.5C19.18,8.22 18.04,7.23\n 16.69,6.54C13.82,5.07 10.15,5.07 7.29,6.55C5.93,7.25 4.79,8.25\n 3.89,9.5C3.81,9.65 3.66,9.72 3.5,9.72M9.75,21.79C9.62,21.79 9.5,21.74\n 9.4,21.64C8.53,20.77 8.06,20.21 7.39,19C6.7,17.77 6.34,16.27\n 6.34,14.66C6.34,11.69 8.88,9.27 12,9.27C15.12,9.27 17.66,11.69\n 17.66,14.66A0.5,0.5 0 0,1 17.16,15.16A0.5,0.5 0 0,1\n 16.66,14.66C16.66,12.24 14.57,10.27 12,10.27C9.43,10.27 7.34,12.24\n 7.34,14.66C7.34,16.1 7.66,17.43 8.27,18.5C8.91,19.66 9.35,20.15\n 10.12,20.93C10.31,21.13 10.31,21.44 10.12,21.64C10,21.74 9.88,21.79\n 9.75,21.79M16.92,19.94C15.73,19.94 14.68,19.64 13.82,19.05C12.33,18.04\n 11.44,16.4 11.44,14.66A0.5,0.5 0 0,1 11.94,14.16A0.5,0.5 0 0,1\n 12.44,14.66C12.44,16.07 13.16,17.4 14.38,18.22C15.09,18.7 15.92,18.93\n 16.92,18.93C17.16,18.93 17.56,18.9 17.96,18.83C18.23,18.78 18.5,18.96\n 18.54,19.24C18.59,19.5 18.41,19.77 18.13,19.82C17.56,19.93 17.06,19.94\n 16.92,19.94M14.91,22C14.87,22 14.82,22 14.78,22C13.19,21.54 12.15,20.95\n 11.06,19.88C9.66,18.5 8.89,16.64 8.89,14.66C8.89,13.04 10.27,11.72\n 11.97,11.72C13.67,11.72 15.05,13.04 15.05,14.66C15.05,15.73 16,16.6\n 17.13,16.6C18.28,16.6 19.21,15.73 19.21,14.66C19.21,10.89 15.96,7.83\n 11.96,7.83C9.12,7.83 6.5,9.41 5.35,11.86C4.96,12.67 4.76,13.62\n 4.76,14.66C4.76,15.44 4.83,16.67 5.43,18.27C5.53,18.53 5.4,18.82\n 5.14,18.91C4.88,19 4.59,18.87 4.5,18.62C4,17.31 3.77,16\n 3.77,14.66C3.77,13.46 4,12.37 4.45,11.42C5.78,8.63 8.73,6.82\n 11.96,6.82C16.5,6.82 20.21,10.33 20.21,14.65C20.21,16.27 18.83,17.59\n 17.13,17.59C15.43,17.59 14.05,16.27 14.05,14.65C14.05,13.58 13.12,12.71\n 11.97,12.71C10.82,12.71 9.89,13.58 9.89,14.65C9.89,16.36 10.55,17.96\n 11.76,19.16C12.71,20.1 13.62,20.62 15.03,21C15.3,21.08 15.45,21.36\n 15.38,21.62C15.33,21.85 15.12,22 14.91,22Z" })),
2501
+ index.h("path", { d: "M0 0h24v24H0z", fill: "none" })));
2502
+ };
2503
+
2504
+ const url = 'https://eswat2.dev';
2505
+ const who = 'eswat2';
2506
+ const Eswat2Io = _props => {
2507
+ return (index.h("a", { class: "absolute top-8 right-8 text-clrs-gray hover:text-clrs-navy", href: url, "aria-label": who, title: who },
2508
+ index.h(Fingerprint, { label: "eswat2" })));
2509
+ };
2510
+
2511
+ const protoTinkerCss = "*,::before,::after{--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.ds1-main{display:flex;flex-direction:column;padding:1rem;font-family:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,\n 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';color:var(--clrs-navy, #001f3f);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ds1-button{display:flex;align-items:center;border-style:solid;border-color:var(--clrs-slate, #708090);color:var(--clrs-white, #ffffff)}.ds1-button:active{background-color:var(--clrs-gray, #aaaaaa);color:var(--clrs-navy, #001f3f)}.absolute{position:absolute}.top-8{top:2rem}.right-8{right:2rem}.mt-3{margin-top:0.75rem}.mb-10px{margin-bottom:10px}.mr-10px{margin-right:10px}.mt-5px{margin-top:5px}.mr-0{margin-right:0px}.ml-0{margin-left:0px}.ml-auto{margin-left:auto}.flex{display:flex}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.bg-clrs-blue{background-color:var(--clrs-blue, #0074d9)}.bg-clrs-red{background-color:var(--clrs-red, #ff4136)}.align-top{vertical-align:top}.text-xs{font-size:0.75rem;line-height:1rem}.font-bold{font-weight:700}.italic{font-style:italic}.text-clrs-slate4{color:var(--clrs-slate4, #4e5964)}.text-clrs-gray{color:var(--clrs-gray, #aaaaaa)}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),\n 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),\n var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.data-button{border-radius:5px;border-width:1px;padding:5px;margin:0px;margin-right:5px;cursor:pointer}.funnel{width:calc(100% - 20px);height:100%;padding:10px;padding-bottom:7px;border-radius:10px;border-width:1px}.hover\\:text-clrs-navy:hover{color:var(--clrs-navy, #001f3f)}";
2512
+
2513
+ let ProtoTinker = class {
2514
+ constructor(hostRef) {
2515
+ index.registerInstance(this, hostRef);
2516
+ this.tag = 'proto-tinker';
2517
+ }
2518
+ render() {
2519
+ return (index.h("div", { id: "app", class: "ds1-main" }, index.h(Eswat2Io, null), index.h(DataSource, null), index.h(ColorPicker, null), index.h("hr", { class: "mr-0 ml-0" }), index.h(DataValues, null)));
2520
+ }
2521
+ };
2522
+ ProtoTinker.style = protoTinkerCss;
2523
+
2524
+ exports.proto_tinker = ProtoTinker;