@esri/solutions-components 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/buffer-tools_6.cjs.entry.js +8 -5
- package/dist/cjs/calcite-combobox_3.cjs.entry.js +2 -2
- package/dist/cjs/calcite-input-message_5.cjs.entry.js +6 -4
- package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
- package/dist/cjs/{csvUtils-83af7ae1.js → csvUtils-34666909.js} +1 -1
- package/dist/cjs/{interfaces-772edf61.js → interfaces-17c631bf.js} +1 -1
- package/dist/cjs/layer-table.cjs.entry.js +3 -3
- package/dist/cjs/map-card.cjs.entry.js +1 -1
- package/dist/cjs/{mapViewUtils-55ac76cb.js → mapViewUtils-24d1d859.js} +1 -1
- package/dist/cjs/public-notification.cjs.entry.js +16 -10
- package/dist/cjs/solution-configuration.cjs.entry.js +2 -2
- package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
- package/dist/cjs/{solution-store-39726b81.js → solution-store-2dbab624.js} +1 -1
- package/dist/collection/components/buffer-tools/buffer-tools.js +2 -2
- package/dist/collection/components/map-draw-tools/map-draw-tools.js +2 -1
- package/dist/collection/components/public-notification/public-notification.js +14 -8
- package/dist/collection/components/refine-selection/refine-selection.js +4 -2
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.css +1 -0
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +3 -1
- package/dist/collection/demos/new-public-notification.html +2 -1
- package/dist/collection/utils/interfaces.js +1 -1
- package/dist/collection/utils/interfaces.ts +2 -2
- package/dist/components/interfaces3.js +1 -1
- package/dist/components/map-draw-tools2.js +2 -1
- package/dist/components/public-notification.js +14 -8
- package/dist/components/refine-selection-tools2.js +4 -2
- package/dist/components/refine-selection2.js +4 -2
- package/dist/esm/buffer-tools_6.entry.js +8 -5
- package/dist/esm/calcite-combobox_3.entry.js +2 -2
- package/dist/esm/calcite-input-message_5.entry.js +6 -4
- package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
- package/dist/esm/{csvUtils-eb231cfb.js → csvUtils-ae3004b9.js} +1 -1
- package/dist/esm/{interfaces-3b23a5f9.js → interfaces-d0d83efa.js} +1 -1
- package/dist/esm/layer-table.entry.js +3 -3
- package/dist/esm/map-card.entry.js +1 -1
- package/dist/esm/{mapViewUtils-e5d8a1e1.js → mapViewUtils-541e7a3c.js} +1 -1
- package/dist/esm/public-notification.entry.js +16 -10
- package/dist/esm/solution-configuration.entry.js +2 -2
- package/dist/esm/solution-contents_3.entry.js +2 -2
- package/dist/esm/{solution-store-c0bf9200.js → solution-store-41e15f1c.js} +1 -1
- package/dist/solutions-components/demos/new-public-notification.html +2 -1
- package/dist/solutions-components/p-05e64bd1.js +498 -2
- package/dist/solutions-components/p-08a95b33.entry.js +138 -0
- package/dist/solutions-components/p-0da5bbdf.entry.js +91 -0
- package/dist/solutions-components/p-0ef91144.entry.js +913 -0
- package/dist/solutions-components/p-0f523243.entry.js +1916 -0
- package/dist/solutions-components/p-11b9510e.entry.js +173 -0
- package/dist/solutions-components/p-1b875d94.entry.js +58 -0
- package/dist/solutions-components/p-1c567f3a.js +23 -16
- package/dist/solutions-components/p-1c883db9.entry.js +43 -0
- package/dist/solutions-components/p-1f225056.js +322 -0
- package/dist/solutions-components/p-1f499e67.entry.js +72 -0
- package/dist/solutions-components/p-20d3d758.entry.js +881 -0
- package/dist/solutions-components/p-2274ac9e.entry.js +160 -0
- package/dist/solutions-components/p-23ec5ac5.entry.js +93 -0
- package/dist/solutions-components/p-2447798c.entry.js +155 -0
- package/dist/solutions-components/p-2525e691.entry.js +432 -0
- package/dist/solutions-components/p-2561f5b5.js +4092 -0
- package/dist/solutions-components/p-29f887c0.entry.js +234 -0
- package/dist/solutions-components/p-2a0d8047.entry.js +345 -0
- package/dist/solutions-components/p-2c177e6a.entry.js +101 -0
- package/dist/solutions-components/p-2e9ed892.js +46 -1
- package/dist/solutions-components/p-316f56db.js +219 -2
- package/dist/solutions-components/p-327f3ebf.entry.js +98 -0
- package/dist/solutions-components/p-356f8b54.entry.js +138 -0
- package/dist/solutions-components/p-359c58de.entry.js +172 -0
- package/dist/solutions-components/p-37336c0d.entry.js +116 -0
- package/dist/solutions-components/p-374a5031.js +105 -2
- package/dist/solutions-components/p-39ea6ef4.entry.js +71 -0
- package/dist/solutions-components/p-3b010ce1.js +17 -1
- package/dist/solutions-components/p-4307dacd.js +194 -1
- package/dist/solutions-components/p-44da2507.js +405 -14
- package/dist/solutions-components/p-46bdffe8.entry.js +54 -0
- package/dist/solutions-components/p-4894bbeb.js +53 -2
- package/dist/solutions-components/p-4cd569f1.entry.js +1298 -0
- package/dist/solutions-components/p-4d4160f9.entry.js +121 -0
- package/dist/solutions-components/p-4e32bf8c.js +482 -1
- package/dist/solutions-components/p-4e9cbd32.entry.js +184 -0
- package/dist/solutions-components/p-508317b3.js +13 -2
- package/dist/solutions-components/p-54697d58.entry.js +198 -0
- package/dist/solutions-components/p-55c79103.entry.js +311 -0
- package/dist/solutions-components/p-57fd19c0.entry.js +706 -0
- package/dist/solutions-components/p-59b48fde.entry.js +443 -0
- package/dist/solutions-components/p-60e0e6a0.entry.js +214 -0
- package/dist/solutions-components/p-621d0534.entry.js +123 -0
- package/dist/solutions-components/p-63f6e8f1.js +14 -1
- package/dist/solutions-components/p-66aeec57.entry.js +61 -0
- package/dist/solutions-components/p-69834f46.entry.js +618 -0
- package/dist/solutions-components/p-6d9da8e5.entry.js +21530 -0
- package/dist/solutions-components/p-6e0da576.js +13 -1
- package/dist/solutions-components/p-6ec3f294.entry.js +106 -0
- package/dist/solutions-components/p-6fe17794.js +9 -1
- package/dist/solutions-components/p-7024cb16.entry.js +72 -0
- package/dist/solutions-components/p-70535506.entry.js +226 -0
- package/dist/solutions-components/p-708a63a8.js +12 -1
- package/dist/solutions-components/p-729708a3.js +14 -1
- package/dist/solutions-components/p-73e23995.js +6 -1
- package/dist/solutions-components/p-74b29d75.entry.js +231 -0
- package/dist/solutions-components/p-74b7ee25.entry.js +711 -0
- package/dist/solutions-components/p-77182c3a.js +3015 -1
- package/dist/solutions-components/p-78b3ef80.entry.js +456 -0
- package/dist/solutions-components/p-79709c19.js +60 -3
- package/dist/solutions-components/p-7a46ef97.js +181 -2
- package/dist/solutions-components/p-7be159e6.entry.js +175 -0
- package/dist/solutions-components/p-7d4451c2.entry.js +71 -0
- package/dist/solutions-components/p-7daea1df.js +41 -1
- package/dist/solutions-components/p-7e39e5ad.entry.js +102 -0
- package/dist/solutions-components/p-7fb45059.entry.js +43 -0
- package/dist/solutions-components/p-815533de.js +306 -3
- package/dist/solutions-components/p-816622ca.entry.js +248 -0
- package/dist/solutions-components/p-83166522.js +205 -2
- package/dist/solutions-components/p-83bd1991.entry.js +36 -0
- package/dist/solutions-components/p-856464d7.entry.js +572 -0
- package/dist/solutions-components/p-8c349bad.entry.js +347 -0
- package/dist/solutions-components/p-8dccb390.entry.js +1986 -0
- package/dist/solutions-components/p-904c185a.entry.js +228 -0
- package/dist/solutions-components/p-9092f8b3.entry.js +156 -0
- package/dist/solutions-components/p-9371145a.entry.js +477 -0
- package/dist/solutions-components/p-93d3119d.js +1948 -1
- package/dist/solutions-components/p-95ec8062.entry.js +173 -0
- package/dist/solutions-components/p-991ee695.js +109 -1
- package/dist/solutions-components/p-9a57dab7.entry.js +213 -0
- package/dist/solutions-components/p-9a9955db.js +41 -1
- package/dist/solutions-components/p-9c1ebc90.js +35 -16
- package/dist/solutions-components/p-9eba5c66.js +399 -3
- package/dist/solutions-components/p-a033a507.entry.js +252 -0
- package/dist/solutions-components/p-a3773415.entry.js +1132 -0
- package/dist/solutions-components/p-a44fe40f.entry.js +94 -0
- package/dist/solutions-components/p-a5b1ab03.js +33 -3
- package/dist/solutions-components/p-a5b2c13d.entry.js +723 -0
- package/dist/solutions-components/p-a6d729b7.entry.js +85 -0
- package/dist/solutions-components/p-a8005026.entry.js +565 -0
- package/dist/solutions-components/p-a80b3880.js +14 -1
- package/dist/solutions-components/p-a89198a3.entry.js +2620 -0
- package/dist/solutions-components/p-aa04bd1f.entry.js +95 -0
- package/dist/solutions-components/p-aa0a0922.entry.js +80 -0
- package/dist/solutions-components/p-ae1fd76b.js +11 -1
- package/dist/solutions-components/p-b2cf435e.entry.js +87 -0
- package/dist/solutions-components/p-b359dc78.js +41 -1
- package/dist/solutions-components/p-b57bc4eb.entry.js +71 -0
- package/dist/solutions-components/p-b75cc407.entry.js +145 -0
- package/dist/solutions-components/p-b911cb75.entry.js +71 -0
- package/dist/solutions-components/p-b965e177.entry.js +335 -0
- package/dist/solutions-components/p-b978636e.js +14 -1
- package/dist/solutions-components/p-ba10a5c8.entry.js +42 -0
- package/dist/solutions-components/p-bd67334c.js +122 -2
- package/dist/solutions-components/p-bde20dba.entry.js +212 -0
- package/dist/solutions-components/p-be0b5a94.entry.js +248 -0
- package/dist/solutions-components/p-c023e6a1.js +2028 -2
- package/dist/solutions-components/p-c27b0c2d.entry.js +150 -0
- package/dist/solutions-components/p-c579ed60.entry.js +447 -0
- package/dist/solutions-components/p-c92bc231.js +101 -2
- package/dist/solutions-components/p-cc815aca.js +839 -16
- package/dist/solutions-components/p-cc8beabb.entry.js +695 -0
- package/dist/solutions-components/p-cdc46c0c.js +1751 -2
- package/dist/solutions-components/p-d12e6992.entry.js +118 -0
- package/dist/solutions-components/p-d1dfed6b.entry.js +179 -0
- package/dist/solutions-components/p-d48a24e6.js +754 -2
- package/dist/solutions-components/p-d96ee3ef.entry.js +579 -0
- package/dist/solutions-components/p-dbc9a5a8.js +80 -0
- package/dist/solutions-components/p-dcdbe712.entry.js +278 -0
- package/dist/solutions-components/p-de39206f.entry.js +113 -0
- package/dist/solutions-components/p-de5416e8.js +28 -1
- package/dist/solutions-components/p-df420d54.entry.js +213 -0
- package/dist/solutions-components/p-e3138cf0.entry.js +20 -0
- package/dist/solutions-components/p-e4845fec.entry.js +152 -0
- package/dist/solutions-components/p-e611d8c8.js +28 -1
- package/dist/solutions-components/p-e947d3b0.js +5 -1
- package/dist/solutions-components/p-ea534300.js +41 -2
- package/dist/solutions-components/p-ec84ee85.entry.js +55 -0
- package/dist/solutions-components/p-ed36c637.entry.js +85 -0
- package/dist/solutions-components/p-f0add71c.js +74 -0
- package/dist/solutions-components/p-f42e014b.js +171 -2
- package/dist/solutions-components/p-fc02e7de.entry.js +308 -0
- package/dist/solutions-components/p-fc884dd6.js +28 -16
- package/dist/solutions-components/p-fcbfa59c.entry.js +181 -0
- package/dist/solutions-components/p-fdc5cf5f.entry.js +138 -0
- package/dist/solutions-components/solutions-components.esm.js +20 -1
- package/dist/solutions-components/utils/interfaces.ts +2 -2
- package/dist/types/components/buffer-tools/buffer-tools.d.ts +2 -2
- package/dist/types/components/public-notification/public-notification.d.ts +9 -1
- package/dist/types/components.d.ts +2 -2
- package/package.json +1 -1
- package/dist/solutions-components/p-021432b8.entry.js +0 -12
- package/dist/solutions-components/p-03440b1e.entry.js +0 -11
- package/dist/solutions-components/p-0512635b.entry.js +0 -6
- package/dist/solutions-components/p-086ef115.entry.js +0 -29
- package/dist/solutions-components/p-0b4bf57f.entry.js +0 -6
- package/dist/solutions-components/p-0c088725.entry.js +0 -6
- package/dist/solutions-components/p-0f820c08.entry.js +0 -6
- package/dist/solutions-components/p-164780a0.entry.js +0 -6
- package/dist/solutions-components/p-179a68a0.entry.js +0 -6
- package/dist/solutions-components/p-184b5005.entry.js +0 -11
- package/dist/solutions-components/p-1d082fee.entry.js +0 -11
- package/dist/solutions-components/p-1e6c02a2.entry.js +0 -11
- package/dist/solutions-components/p-20a58e62.entry.js +0 -17
- package/dist/solutions-components/p-20b2458c.entry.js +0 -11
- package/dist/solutions-components/p-245d47c1.entry.js +0 -6
- package/dist/solutions-components/p-2cb057a9.entry.js +0 -11
- package/dist/solutions-components/p-2cc72806.entry.js +0 -23
- package/dist/solutions-components/p-2de1db9c.entry.js +0 -11
- package/dist/solutions-components/p-2e9c7055.entry.js +0 -11
- package/dist/solutions-components/p-2ed5e6c8.entry.js +0 -11
- package/dist/solutions-components/p-3109d940.entry.js +0 -6
- package/dist/solutions-components/p-31a8bcfa.entry.js +0 -6
- package/dist/solutions-components/p-3649acb3.entry.js +0 -18
- package/dist/solutions-components/p-3f88ba73.entry.js +0 -6
- package/dist/solutions-components/p-3fa9b3c8.js +0 -36
- package/dist/solutions-components/p-40c41709.entry.js +0 -6
- package/dist/solutions-components/p-40e963c7.entry.js +0 -11
- package/dist/solutions-components/p-40f480da.entry.js +0 -11
- package/dist/solutions-components/p-49d5d2d3.entry.js +0 -11
- package/dist/solutions-components/p-4f7049a4.entry.js +0 -11
- package/dist/solutions-components/p-506e4d78.entry.js +0 -6
- package/dist/solutions-components/p-576fdcab.entry.js +0 -6
- package/dist/solutions-components/p-5bd0cf34.entry.js +0 -23
- package/dist/solutions-components/p-65e177f1.entry.js +0 -6
- package/dist/solutions-components/p-67d710c2.entry.js +0 -6
- package/dist/solutions-components/p-7268b445.entry.js +0 -11
- package/dist/solutions-components/p-75ea4667.entry.js +0 -6
- package/dist/solutions-components/p-778c0a36.entry.js +0 -17
- package/dist/solutions-components/p-7a22509b.entry.js +0 -12
- package/dist/solutions-components/p-7bff51db.entry.js +0 -6
- package/dist/solutions-components/p-7d2d0d5d.entry.js +0 -6
- package/dist/solutions-components/p-7f0036f1.entry.js +0 -11
- package/dist/solutions-components/p-8060fb94.entry.js +0 -6
- package/dist/solutions-components/p-80a1b305.entry.js +0 -6
- package/dist/solutions-components/p-81eae877.entry.js +0 -12
- package/dist/solutions-components/p-84e86b8b.entry.js +0 -6
- package/dist/solutions-components/p-851e04ae.entry.js +0 -6
- package/dist/solutions-components/p-9106950a.entry.js +0 -11
- package/dist/solutions-components/p-979804a4.entry.js +0 -11
- package/dist/solutions-components/p-9862baa8.entry.js +0 -11
- package/dist/solutions-components/p-9b5a9117.entry.js +0 -12
- package/dist/solutions-components/p-9deff0c2.entry.js +0 -6
- package/dist/solutions-components/p-9f400eeb.entry.js +0 -6
- package/dist/solutions-components/p-a0639ad1.entry.js +0 -11
- package/dist/solutions-components/p-a33c044e.entry.js +0 -6
- package/dist/solutions-components/p-a516c658.entry.js +0 -6
- package/dist/solutions-components/p-aa0ef36d.entry.js +0 -11
- package/dist/solutions-components/p-aaccbdf3.entry.js +0 -18
- package/dist/solutions-components/p-ab03a5c9.entry.js +0 -11
- package/dist/solutions-components/p-ad469b92.entry.js +0 -11
- package/dist/solutions-components/p-adc86ac3.entry.js +0 -6
- package/dist/solutions-components/p-addc1156.entry.js +0 -11
- package/dist/solutions-components/p-ae846934.entry.js +0 -11
- package/dist/solutions-components/p-b0572fc4.entry.js +0 -37
- package/dist/solutions-components/p-b4e476b7.js +0 -257
- package/dist/solutions-components/p-b668daf8.js +0 -21
- package/dist/solutions-components/p-b6e6eae1.entry.js +0 -6
- package/dist/solutions-components/p-bc317a7f.entry.js +0 -6
- package/dist/solutions-components/p-be41429f.js +0 -21
- package/dist/solutions-components/p-bf6b6353.entry.js +0 -11
- package/dist/solutions-components/p-c2e3dfbb.entry.js +0 -11
- package/dist/solutions-components/p-c4afae53.entry.js +0 -12
- package/dist/solutions-components/p-c9da1c26.entry.js +0 -6
- package/dist/solutions-components/p-cbf8cd49.entry.js +0 -6
- package/dist/solutions-components/p-cc1a064a.entry.js +0 -11
- package/dist/solutions-components/p-d09a168c.entry.js +0 -6
- package/dist/solutions-components/p-d377f913.entry.js +0 -11
- package/dist/solutions-components/p-d4cefead.entry.js +0 -37
- package/dist/solutions-components/p-d7bc0baf.entry.js +0 -16
- package/dist/solutions-components/p-d8968487.entry.js +0 -11
- package/dist/solutions-components/p-e00a0b86.entry.js +0 -11
- package/dist/solutions-components/p-e9a7ed49.entry.js +0 -11
- package/dist/solutions-components/p-ec27e493.entry.js +0 -11
- package/dist/solutions-components/p-ed6404eb.entry.js +0 -6
- package/dist/solutions-components/p-ef21e195.entry.js +0 -23
- package/dist/solutions-components/p-f6068a2d.entry.js +0 -11
- package/dist/solutions-components/p-f6c4cff3.entry.js +0 -11
- package/dist/solutions-components/p-f847291f.entry.js +0 -6
- package/dist/solutions-components/p-f90fd262.entry.js +0 -11
- package/dist/solutions-components/p-fc973005.entry.js +0 -6
- package/dist/solutions-components/p-ff9fb6bc.entry.js +0 -11
@@ -3,4 +3,1951 @@
|
|
3
3
|
* Licensed under the Apache License, Version 2.0
|
4
4
|
* http://www.apache.org/licenses/LICENSE-2.0
|
5
5
|
*/
|
6
|
-
import{c as t}from"./p-3b010ce1.js";var n={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},e=t((function(t){var n=Array.prototype.concat,e=Array.prototype.slice,r=t.exports=function(t){for(var r,s=[],a=0,o=t.length;a<o;a++){var i=t[a];(r=i)&&"string"!=typeof r&&(r instanceof Array||Array.isArray(r)||r.length>=0&&(r.splice instanceof Function||Object.getOwnPropertyDescriptor(r,r.length-1)&&"String"!==r.constructor.name))?s=n.call(s,e.call(i)):s.push(i)}return s};r.wrap=function(t){return function(){return t(r(arguments))}}})),r=t((function(t){var r=Object.hasOwnProperty,s=Object.create(null);for(var a in n)r.call(n,a)&&(s[n[a]]=a);var o=t.exports={to:{},get:{}};function i(t,n,e){return Math.min(Math.max(n,t),e)}function l(t){var n=Math.round(t).toString(16).toUpperCase();return n.length<2?"0"+n:n}o.get=function(t){var n,e;switch(t.substring(0,3).toLowerCase()){case"hsl":n=o.get.hsl(t),e="hsl";break;case"hwb":n=o.get.hwb(t),e="hwb";break;default:n=o.get.rgb(t),e="rgb"}return n?{model:e,value:n}:null},o.get.rgb=function(t){if(!t)return null;var e,s,a,o=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(a=e[2],e=e[1],s=0;s<3;s++){var l=2*s;o[s]=parseInt(e.slice(l,l+2),16)}a&&(o[3]=parseInt(a,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(a=(e=e[1])[3],s=0;s<3;s++)o[s]=parseInt(e[s]+e[s],16);a&&(o[3]=parseInt(a+a,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(s=0;s<3;s++)o[s]=parseInt(e[s+1],0);e[4]&&(o[3]=e[5]?.01*parseFloat(e[4]):parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:r.call(n,e[1])?((o=n[e[1]])[3]=1,o):null:null;for(s=0;s<3;s++)o[s]=Math.round(2.55*parseFloat(e[s+1]));e[4]&&(o[3]=e[5]?.01*parseFloat(e[4]):parseFloat(e[4]))}for(s=0;s<3;s++)o[s]=i(o[s],0,255);return o[3]=i(o[3],0,1),o},o.get.hsl=function(t){if(!t)return null;var n=t.match(/^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*)?\)$/);if(n){var e=parseFloat(n[4]);return[(parseFloat(n[1])%360+360)%360,i(parseFloat(n[2]),0,100),i(parseFloat(n[3]),0,100),i(isNaN(e)?1:e,0,1)]}return null},o.get.hwb=function(t){if(!t)return null;var n=t.match(/^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*)?\)$/);if(n){var e=parseFloat(n[4]);return[(parseFloat(n[1])%360+360)%360,i(parseFloat(n[2]),0,100),i(parseFloat(n[3]),0,100),i(isNaN(e)?1:e,0,1)]}return null},o.to.hex=function(){var t=e(arguments);return"#"+l(t[0])+l(t[1])+l(t[2])+(t[3]<1?l(Math.round(255*t[3])):"")},o.to.rgb=function(){var t=e(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},o.to.rgb.percent=function(){var t=e(arguments),n=Math.round(t[0]/255*100),r=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+n+"%, "+r+"%, "+s+"%)":"rgba("+n+"%, "+r+"%, "+s+"%, "+t[3]+")"},o.to.hsl=function(){var t=e(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},o.to.hwb=function(){var t=e(arguments),n="";return t.length>=4&&1!==t[3]&&(n=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+n+")"},o.to.keyword=function(t){return s[t.slice(0,3)]}}));const s={};for(const t of Object.keys(n))s[n[t]]=t;const a={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var o=a;for(const t of Object.keys(a)){if(!("channels"in a[t]))throw new Error("missing channels property: "+t);if(!("labels"in a[t]))throw new Error("missing channel labels property: "+t);if(a[t].labels.length!==a[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:n,labels:e}=a[t];delete a[t].channels,delete a[t].labels,Object.defineProperty(a[t],"channels",{value:n}),Object.defineProperty(a[t],"labels",{value:e})}function i(t,n){return function(e){return n(t(e))}}function l(t,n){const e=[n[t].parent,t];let r=o[n[t].parent][t],s=n[t].parent;for(;n[s].parent;)e.unshift(n[s].parent),r=i(o[n[s].parent][s],r),s=n[s].parent;return r.conversion=e,r}a.rgb.hsl=function(t){const n=t[0]/255,e=t[1]/255,r=t[2]/255,s=Math.min(n,e,r),a=Math.max(n,e,r),o=a-s;let i,l;a===s?i=0:n===a?i=(e-r)/o:e===a?i=2+(r-n)/o:r===a&&(i=4+(n-e)/o),i=Math.min(60*i,360),i<0&&(i+=360);const c=(s+a)/2;return l=a===s?0:c<=.5?o/(a+s):o/(2-a-s),[i,100*l,100*c]},a.rgb.hsv=function(t){let n,e,r,s,a;const o=t[0]/255,i=t[1]/255,l=t[2]/255,c=Math.max(o,i,l),u=c-Math.min(o,i,l),h=function(t){return(c-t)/6/u+.5};return 0===u?(s=0,a=0):(a=u/c,n=h(o),e=h(i),r=h(l),o===c?s=r-e:i===c?s=1/3+n-r:l===c&&(s=2/3+e-n),s<0?s+=1:s>1&&(s-=1)),[360*s,100*a,100*c]},a.rgb.hwb=function(t){const n=t[0],e=t[1];let r=t[2];const s=a.rgb.hsl(t)[0],o=1/255*Math.min(n,Math.min(e,r));return r=1-1/255*Math.max(n,Math.max(e,r)),[s,100*o,100*r]},a.rgb.cmyk=function(t){const n=t[0]/255,e=t[1]/255,r=t[2]/255,s=Math.min(1-n,1-e,1-r);return[100*((1-n-s)/(1-s)||0),100*((1-e-s)/(1-s)||0),100*((1-r-s)/(1-s)||0),100*s]},a.rgb.keyword=function(t){const e=s[t];if(e)return e;let r,a=1/0;for(const e of Object.keys(n)){const s=((o=t)[0]-(i=n[e])[0])**2+(o[1]-i[1])**2+(o[2]-i[2])**2;s<a&&(a=s,r=e)}var o,i;return r},a.keyword.rgb=function(t){return n[t]},a.rgb.xyz=function(t){let n=t[0]/255,e=t[1]/255,r=t[2]/255;return n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,[100*(.4124*n+.3576*e+.1805*r),100*(.2126*n+.7152*e+.0722*r),100*(.0193*n+.1192*e+.9505*r)]},a.rgb.lab=function(t){const n=a.rgb.xyz(t);let e=n[0],r=n[1],s=n[2];return e/=95.047,r/=100,s/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,[116*r-16,500*(e-r),200*(r-s)]},a.hsl.rgb=function(t){const n=t[0]/360,e=t[1]/100,r=t[2]/100;let s,a,o;if(0===e)return o=255*r,[o,o,o];s=r<.5?r*(1+e):r+e-r*e;const i=2*r-s,l=[0,0,0];for(let t=0;t<3;t++)a=n+1/3*-(t-1),a<0&&a++,a>1&&a--,o=6*a<1?i+6*(s-i)*a:2*a<1?s:3*a<2?i+(s-i)*(2/3-a)*6:i,l[t]=255*o;return l},a.hsl.hsv=function(t){const n=t[0];let e=t[1]/100,r=t[2]/100,s=e;const a=Math.max(r,.01);return r*=2,e*=r<=1?r:2-r,s*=a<=1?a:2-a,[n,100*(0===r?2*s/(a+s):2*e/(r+e)),(r+e)/2*100]},a.hsv.rgb=function(t){const n=t[0]/60,e=t[1]/100;let r=t[2]/100;const s=Math.floor(n)%6,a=n-Math.floor(n),o=255*r*(1-e),i=255*r*(1-e*a),l=255*r*(1-e*(1-a));switch(r*=255,s){case 0:return[r,l,o];case 1:return[i,r,o];case 2:return[o,r,l];case 3:return[o,i,r];case 4:return[l,o,r];case 5:return[r,o,i]}},a.hsv.hsl=function(t){const n=t[0],e=t[1]/100,r=t[2]/100,s=Math.max(r,.01);let a,o;o=(2-e)*r;const i=(2-e)*s;return a=e*s,a/=i<=1?i:2-i,a=a||0,o/=2,[n,100*a,100*o]},a.hwb.rgb=function(t){const n=t[0]/360;let e=t[1]/100,r=t[2]/100;const s=e+r;let a;s>1&&(e/=s,r/=s);const o=Math.floor(6*n),i=1-r;a=6*n-o,0!=(1&o)&&(a=1-a);const l=e+a*(i-e);let c,u,h;switch(o){default:case 6:case 0:c=i,u=l,h=e;break;case 1:c=l,u=i,h=e;break;case 2:c=e,u=i,h=l;break;case 3:c=e,u=l,h=i;break;case 4:c=l,u=e,h=i;break;case 5:c=i,u=e,h=l}return[255*c,255*u,255*h]},a.cmyk.rgb=function(t){const n=t[1]/100,e=t[2]/100,r=t[3]/100;return[255*(1-Math.min(1,t[0]/100*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r)),255*(1-Math.min(1,e*(1-r)+r))]},a.xyz.rgb=function(t){const n=t[0]/100,e=t[1]/100,r=t[2]/100;let s,a,o;return s=3.2406*n+-1.5372*e+-.4986*r,a=-.9689*n+1.8758*e+.0415*r,o=.0557*n+-.204*e+1.057*r,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,s=Math.min(Math.max(0,s),1),a=Math.min(Math.max(0,a),1),o=Math.min(Math.max(0,o),1),[255*s,255*a,255*o]},a.xyz.lab=function(t){let n=t[0],e=t[1],r=t[2];return n/=95.047,e/=100,r/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,e=e>.008856?e**(1/3):7.787*e+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,[116*e-16,500*(n-e),200*(e-r)]},a.lab.xyz=function(t){let n,e,r;e=(t[0]+16)/116,n=t[1]/500+e,r=e-t[2]/200;const s=e**3,a=n**3,o=r**3;return e=s>.008856?s:(e-16/116)/7.787,n=a>.008856?a:(n-16/116)/7.787,r=o>.008856?o:(r-16/116)/7.787,n*=95.047,e*=100,r*=108.883,[n,e,r]},a.lab.lch=function(t){const n=t[0],e=t[1],r=t[2];let s;return s=360*Math.atan2(r,e)/2/Math.PI,s<0&&(s+=360),[n,Math.sqrt(e*e+r*r),s]},a.lch.lab=function(t){const n=t[1],e=t[2]/360*2*Math.PI;return[t[0],n*Math.cos(e),n*Math.sin(e)]},a.rgb.ansi16=function(t,n=null){const[e,r,s]=t;let o=null===n?a.rgb.hsv(t)[2]:n;if(o=Math.round(o/50),0===o)return 30;let i=30+(Math.round(s/255)<<2|Math.round(r/255)<<1|Math.round(e/255));return 2===o&&(i+=60),i},a.hsv.ansi16=function(t){return a.rgb.ansi16(a.hsv.rgb(t),t[2])},a.rgb.ansi256=function(t){const n=t[0],e=t[1],r=t[2];return n===e&&e===r?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5)},a.ansi16.rgb=function(t){let n=t%10;if(0===n||7===n)return t>50&&(n+=3.5),n=n/10.5*255,[n,n,n];const e=.5*(1+~~(t>50));return[(1&n)*e*255,(n>>1&1)*e*255,(n>>2&1)*e*255]},a.ansi256.rgb=function(t){if(t>=232){const n=10*(t-232)+8;return[n,n,n]}let n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},a.rgb.hex=function(t){const n=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(n.length)+n},a.hex.rgb=function(t){const n=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!n)return[0,0,0];let e=n[0];3===n[0].length&&(e=e.split("").map((t=>t+t)).join(""));const r=parseInt(e,16);return[r>>16&255,r>>8&255,255&r]},a.rgb.hcg=function(t){const n=t[0]/255,e=t[1]/255,r=t[2]/255,s=Math.max(Math.max(n,e),r),a=Math.min(Math.min(n,e),r),o=s-a;let i,l;return i=o<1?a/(1-o):0,l=o<=0?0:s===n?(e-r)/o%6:s===e?2+(r-n)/o:4+(n-e)/o,l/=6,l%=1,[360*l,100*o,100*i]},a.hsl.hcg=function(t){const n=t[1]/100,e=t[2]/100,r=e<.5?2*n*e:2*n*(1-e);let s=0;return r<1&&(s=(e-.5*r)/(1-r)),[t[0],100*r,100*s]},a.hsv.hcg=function(t){const n=t[2]/100,e=t[1]/100*n;let r=0;return e<1&&(r=(n-e)/(1-e)),[t[0],100*e,100*r]},a.hcg.rgb=function(t){const n=t[1]/100,e=t[2]/100;if(0===n)return[255*e,255*e,255*e];const r=[0,0,0],s=t[0]/360%1*6,a=s%1,o=1-a;let i=0;switch(Math.floor(s)){case 0:r[0]=1,r[1]=a,r[2]=0;break;case 1:r[0]=o,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=a;break;case 3:r[0]=0,r[1]=o,r[2]=1;break;case 4:r[0]=a,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=o}return i=(1-n)*e,[255*(n*r[0]+i),255*(n*r[1]+i),255*(n*r[2]+i)]},a.hcg.hsv=function(t){const n=t[1]/100,e=n+t[2]/100*(1-n);let r=0;return e>0&&(r=n/e),[t[0],100*r,100*e]},a.hcg.hsl=function(t){const n=t[1]/100,e=t[2]/100*(1-n)+.5*n;let r=0;return e>0&&e<.5?r=n/(2*e):e>=.5&&e<1&&(r=n/(2*(1-e))),[t[0],100*r,100*e]},a.hcg.hwb=function(t){const n=t[1]/100,e=n+t[2]/100*(1-n);return[t[0],100*(e-n),100*(1-e)]},a.hwb.hcg=function(t){const n=1-t[2]/100,e=n-t[1]/100;let r=0;return e<1&&(r=(n-e)/(1-e)),[t[0],100*e,100*r]},a.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},a.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},a.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},a.gray.hsl=function(t){return[0,0,t[0]]},a.gray.hsv=a.gray.hsl,a.gray.hwb=function(t){return[0,100,t[0]]},a.gray.cmyk=function(t){return[0,0,0,t[0]]},a.gray.lab=function(t){return[t[0],0,0]},a.gray.hex=function(t){const n=255&Math.round(t[0]/100*255),e=((n<<16)+(n<<8)+n).toString(16).toUpperCase();return"000000".substring(e.length)+e},a.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};const c={};Object.keys(o).forEach((t=>{c[t]={},Object.defineProperty(c[t],"channels",{value:o[t].channels}),Object.defineProperty(c[t],"labels",{value:o[t].labels});const n=function(t){const n=function(t){const n=function(){const t={},n=Object.keys(o);for(let e=n.length,r=0;r<e;r++)t[n[r]]={distance:-1,parent:null};return t}(),e=[t];for(n[t].distance=0;e.length;){const t=e.pop(),r=Object.keys(o[t]);for(let s=r.length,a=0;a<s;a++){const s=r[a],o=n[s];-1===o.distance&&(o.distance=n[t].distance+1,o.parent=t,e.unshift(s))}}return n}(t),e={},r=Object.keys(n);for(let t=r.length,s=0;s<t;s++){const t=r[s];null!==n[t].parent&&(e[t]=l(t,n))}return e}(t);Object.keys(n).forEach((e=>{const r=n[e];c[t][e]=function(t){const n=function(...n){const e=n[0];if(null==e)return e;e.length>1&&(n=e);const r=t(n);if("object"==typeof r)for(let t=r.length,n=0;n<t;n++)r[n]=Math.round(r[n]);return r};return"conversion"in t&&(n.conversion=t.conversion),n}(r),c[t][e].raw=function(t){const n=function(...n){const e=n[0];return null==e?e:(e.length>1&&(n=e),t(n))};return"conversion"in t&&(n.conversion=t.conversion),n}(r)}))}));var u=c;const h=["keyword","gray","hex"],f={};for(const t of Object.keys(u))f[[...u[t].labels].sort().join("")]=t;const b={};function d(t,n){if(!(this instanceof d))return new d(t,n);if(n&&n in h&&(n=null),n&&!(n in u))throw new Error("Unknown model: "+n);let e,s;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof d)this.model=t.model,this.color=[...t.color],this.valpha=t.valpha;else if("string"==typeof t){const n=r.get(t);if(null===n)throw new Error("Unable to parse color from string: "+t);this.model=n.model,s=u[this.model].channels,this.color=n.value.slice(0,s),this.valpha="number"==typeof n.value[s]?n.value[s]:1}else if(t.length>0){this.model=n||"rgb",s=u[this.model].channels;const e=Array.prototype.slice.call(t,0,s);this.color=m(e,s),this.valpha="number"==typeof t[s]?t[s]:1}else if("number"==typeof t)this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;const n=Object.keys(t);"alpha"in t&&(n.splice(n.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);const r=n.sort().join("");if(!(r in f))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=f[r];const{labels:s}=u[this.model],a=[];for(e=0;e<s.length;e++)a.push(t[s[e]]);this.color=m(a)}if(b[this.model])for(s=u[this.model].channels,e=0;e<s;e++){const t=b[this.model][e];t&&(this.color[e]=t(this.color[e]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}d.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(t){let n=this.model in r.to?this:this.rgb();n=n.round("number"==typeof t?t:1);const e=1===n.valpha?n.color:[...n.color,this.valpha];return r.to[n.model](e)},percentString(t){const n=this.rgb().round("number"==typeof t?t:1),e=1===n.valpha?n.color:[...n.color,this.valpha];return r.to.rgb.percent(e)},array(){return 1===this.valpha?[...this.color]:[...this.color,this.valpha]},object(){const t={},{channels:n}=u[this.model],{labels:e}=u[this.model];for(let r=0;r<n;r++)t[e[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray(){const t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject(){const t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round(t){return t=Math.max(t||0,0),new d([...this.color.map(g(t)),this.valpha],this.model)},alpha(t){return void 0!==t?new d([...this.color,Math.max(0,Math.min(1,t))],this.model):this.valpha},red:y("rgb",0,p(255)),green:y("rgb",1,p(255)),blue:y("rgb",2,p(255)),hue:y(["hsl","hsv","hsl","hwb","hcg"],0,(t=>(t%360+360)%360)),saturationl:y("hsl",1,p(100)),lightness:y("hsl",2,p(100)),saturationv:y("hsv",1,p(100)),value:y("hsv",2,p(100)),chroma:y("hcg",1,p(100)),gray:y("hcg",2,p(100)),white:y("hwb",1,p(100)),wblack:y("hwb",2,p(100)),cyan:y("cmyk",0,p(100)),magenta:y("cmyk",1,p(100)),yellow:y("cmyk",2,p(100)),black:y("cmyk",3,p(100)),x:y("xyz",0,p(95.047)),y:y("xyz",1,p(100)),z:y("xyz",2,p(108.833)),l:y("lab",0,p(100)),a:y("lab",1),b:y("lab",2),keyword(t){return void 0!==t?new d(t):u[this.model].keyword(this.color)},hex(t){return void 0!==t?new d(t):r.to.hex(this.rgb().round().color)},hexa(t){if(void 0!==t)return new d(t);const n=this.rgb().round().color;let e=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===e.length&&(e="0"+e),r.to.hex(n)+e},rgbNumber(){const t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity(){const t=this.rgb().color,n=[];for(const[e,r]of t.entries()){const t=r/255;n[e]=t<=.04045?t/12.92:((t+.055)/1.055)**2.4}return.2126*n[0]+.7152*n[1]+.0722*n[2]},contrast(t){const n=this.luminosity(),e=t.luminosity();return n>e?(n+.05)/(e+.05):(e+.05)/(n+.05)},level(t){const n=this.contrast(t);return n>=7?"AAA":n>=4.5?"AA":""},isDark(){const t=this.rgb().color;return(2126*t[0]+7152*t[1]+722*t[2])/1e4<128},isLight(){return!this.isDark()},negate(){const t=this.rgb();for(let n=0;n<3;n++)t.color[n]=255-t.color[n];return t},lighten(t){const n=this.hsl();return n.color[2]+=n.color[2]*t,n},darken(t){const n=this.hsl();return n.color[2]-=n.color[2]*t,n},saturate(t){const n=this.hsl();return n.color[1]+=n.color[1]*t,n},desaturate(t){const n=this.hsl();return n.color[1]-=n.color[1]*t,n},whiten(t){const n=this.hwb();return n.color[1]+=n.color[1]*t,n},blacken(t){const n=this.hwb();return n.color[2]+=n.color[2]*t,n},grayscale(){const t=this.rgb().color,n=.3*t[0]+.59*t[1]+.11*t[2];return d.rgb(n,n,n)},fade(t){return this.alpha(this.valpha-this.valpha*t)},opaquer(t){return this.alpha(this.valpha+this.valpha*t)},rotate(t){const n=this.hsl();let e=n.color[0];return e=(e+t)%360,e=e<0?360+e:e,n.color[0]=e,n},mix(t,n){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);const e=t.rgb(),r=this.rgb(),s=void 0===n?.5:n,a=2*s-1,o=e.alpha()-r.alpha(),i=((a*o==-1?a:(a+o)/(1+a*o))+1)/2,l=1-i;return d.rgb(i*e.red()+l*r.red(),i*e.green()+l*r.green(),i*e.blue()+l*r.blue(),e.alpha()*s+r.alpha()*(1-s))}};for(const t of Object.keys(u)){if(h.includes(t))continue;const{channels:n}=u[t];d.prototype[t]=function(...n){return this.model===t?new d(this):new d(n.length>0?n:[...(e=u[this.model][t].raw(this.color),Array.isArray(e)?e:[e]),this.valpha],t);var e},d[t]=function(...e){let r=e[0];return"number"==typeof r&&(r=m(e,n)),new d(r,t)}}function g(t){return function(n){return function(t,n){return Number(t.toFixed(n))}(n,t)}}function y(t,n,e){t=Array.isArray(t)?t:[t];for(const r of t)(b[r]||(b[r]=[]))[n]=e;return t=t[0],function(r){let s;return void 0!==r?(e&&(r=e(r)),s=this[t](),s.color[n]=r,s):(s=this[t]().color[n],e&&(s=e(s)),s)}}function p(t){return function(n){return Math.max(0,Math.min(t,n))}}function m(t,n){for(let e=0;e<n;e++)"number"!=typeof t[e]&&(t[e]=0);return t}var M=d;export{M as c}
|
6
|
+
import { c as createCommonjsModule } from './p-3b010ce1.js';
|
7
|
+
|
8
|
+
var colorName = {
|
9
|
+
"aliceblue": [240, 248, 255],
|
10
|
+
"antiquewhite": [250, 235, 215],
|
11
|
+
"aqua": [0, 255, 255],
|
12
|
+
"aquamarine": [127, 255, 212],
|
13
|
+
"azure": [240, 255, 255],
|
14
|
+
"beige": [245, 245, 220],
|
15
|
+
"bisque": [255, 228, 196],
|
16
|
+
"black": [0, 0, 0],
|
17
|
+
"blanchedalmond": [255, 235, 205],
|
18
|
+
"blue": [0, 0, 255],
|
19
|
+
"blueviolet": [138, 43, 226],
|
20
|
+
"brown": [165, 42, 42],
|
21
|
+
"burlywood": [222, 184, 135],
|
22
|
+
"cadetblue": [95, 158, 160],
|
23
|
+
"chartreuse": [127, 255, 0],
|
24
|
+
"chocolate": [210, 105, 30],
|
25
|
+
"coral": [255, 127, 80],
|
26
|
+
"cornflowerblue": [100, 149, 237],
|
27
|
+
"cornsilk": [255, 248, 220],
|
28
|
+
"crimson": [220, 20, 60],
|
29
|
+
"cyan": [0, 255, 255],
|
30
|
+
"darkblue": [0, 0, 139],
|
31
|
+
"darkcyan": [0, 139, 139],
|
32
|
+
"darkgoldenrod": [184, 134, 11],
|
33
|
+
"darkgray": [169, 169, 169],
|
34
|
+
"darkgreen": [0, 100, 0],
|
35
|
+
"darkgrey": [169, 169, 169],
|
36
|
+
"darkkhaki": [189, 183, 107],
|
37
|
+
"darkmagenta": [139, 0, 139],
|
38
|
+
"darkolivegreen": [85, 107, 47],
|
39
|
+
"darkorange": [255, 140, 0],
|
40
|
+
"darkorchid": [153, 50, 204],
|
41
|
+
"darkred": [139, 0, 0],
|
42
|
+
"darksalmon": [233, 150, 122],
|
43
|
+
"darkseagreen": [143, 188, 143],
|
44
|
+
"darkslateblue": [72, 61, 139],
|
45
|
+
"darkslategray": [47, 79, 79],
|
46
|
+
"darkslategrey": [47, 79, 79],
|
47
|
+
"darkturquoise": [0, 206, 209],
|
48
|
+
"darkviolet": [148, 0, 211],
|
49
|
+
"deeppink": [255, 20, 147],
|
50
|
+
"deepskyblue": [0, 191, 255],
|
51
|
+
"dimgray": [105, 105, 105],
|
52
|
+
"dimgrey": [105, 105, 105],
|
53
|
+
"dodgerblue": [30, 144, 255],
|
54
|
+
"firebrick": [178, 34, 34],
|
55
|
+
"floralwhite": [255, 250, 240],
|
56
|
+
"forestgreen": [34, 139, 34],
|
57
|
+
"fuchsia": [255, 0, 255],
|
58
|
+
"gainsboro": [220, 220, 220],
|
59
|
+
"ghostwhite": [248, 248, 255],
|
60
|
+
"gold": [255, 215, 0],
|
61
|
+
"goldenrod": [218, 165, 32],
|
62
|
+
"gray": [128, 128, 128],
|
63
|
+
"green": [0, 128, 0],
|
64
|
+
"greenyellow": [173, 255, 47],
|
65
|
+
"grey": [128, 128, 128],
|
66
|
+
"honeydew": [240, 255, 240],
|
67
|
+
"hotpink": [255, 105, 180],
|
68
|
+
"indianred": [205, 92, 92],
|
69
|
+
"indigo": [75, 0, 130],
|
70
|
+
"ivory": [255, 255, 240],
|
71
|
+
"khaki": [240, 230, 140],
|
72
|
+
"lavender": [230, 230, 250],
|
73
|
+
"lavenderblush": [255, 240, 245],
|
74
|
+
"lawngreen": [124, 252, 0],
|
75
|
+
"lemonchiffon": [255, 250, 205],
|
76
|
+
"lightblue": [173, 216, 230],
|
77
|
+
"lightcoral": [240, 128, 128],
|
78
|
+
"lightcyan": [224, 255, 255],
|
79
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
80
|
+
"lightgray": [211, 211, 211],
|
81
|
+
"lightgreen": [144, 238, 144],
|
82
|
+
"lightgrey": [211, 211, 211],
|
83
|
+
"lightpink": [255, 182, 193],
|
84
|
+
"lightsalmon": [255, 160, 122],
|
85
|
+
"lightseagreen": [32, 178, 170],
|
86
|
+
"lightskyblue": [135, 206, 250],
|
87
|
+
"lightslategray": [119, 136, 153],
|
88
|
+
"lightslategrey": [119, 136, 153],
|
89
|
+
"lightsteelblue": [176, 196, 222],
|
90
|
+
"lightyellow": [255, 255, 224],
|
91
|
+
"lime": [0, 255, 0],
|
92
|
+
"limegreen": [50, 205, 50],
|
93
|
+
"linen": [250, 240, 230],
|
94
|
+
"magenta": [255, 0, 255],
|
95
|
+
"maroon": [128, 0, 0],
|
96
|
+
"mediumaquamarine": [102, 205, 170],
|
97
|
+
"mediumblue": [0, 0, 205],
|
98
|
+
"mediumorchid": [186, 85, 211],
|
99
|
+
"mediumpurple": [147, 112, 219],
|
100
|
+
"mediumseagreen": [60, 179, 113],
|
101
|
+
"mediumslateblue": [123, 104, 238],
|
102
|
+
"mediumspringgreen": [0, 250, 154],
|
103
|
+
"mediumturquoise": [72, 209, 204],
|
104
|
+
"mediumvioletred": [199, 21, 133],
|
105
|
+
"midnightblue": [25, 25, 112],
|
106
|
+
"mintcream": [245, 255, 250],
|
107
|
+
"mistyrose": [255, 228, 225],
|
108
|
+
"moccasin": [255, 228, 181],
|
109
|
+
"navajowhite": [255, 222, 173],
|
110
|
+
"navy": [0, 0, 128],
|
111
|
+
"oldlace": [253, 245, 230],
|
112
|
+
"olive": [128, 128, 0],
|
113
|
+
"olivedrab": [107, 142, 35],
|
114
|
+
"orange": [255, 165, 0],
|
115
|
+
"orangered": [255, 69, 0],
|
116
|
+
"orchid": [218, 112, 214],
|
117
|
+
"palegoldenrod": [238, 232, 170],
|
118
|
+
"palegreen": [152, 251, 152],
|
119
|
+
"paleturquoise": [175, 238, 238],
|
120
|
+
"palevioletred": [219, 112, 147],
|
121
|
+
"papayawhip": [255, 239, 213],
|
122
|
+
"peachpuff": [255, 218, 185],
|
123
|
+
"peru": [205, 133, 63],
|
124
|
+
"pink": [255, 192, 203],
|
125
|
+
"plum": [221, 160, 221],
|
126
|
+
"powderblue": [176, 224, 230],
|
127
|
+
"purple": [128, 0, 128],
|
128
|
+
"rebeccapurple": [102, 51, 153],
|
129
|
+
"red": [255, 0, 0],
|
130
|
+
"rosybrown": [188, 143, 143],
|
131
|
+
"royalblue": [65, 105, 225],
|
132
|
+
"saddlebrown": [139, 69, 19],
|
133
|
+
"salmon": [250, 128, 114],
|
134
|
+
"sandybrown": [244, 164, 96],
|
135
|
+
"seagreen": [46, 139, 87],
|
136
|
+
"seashell": [255, 245, 238],
|
137
|
+
"sienna": [160, 82, 45],
|
138
|
+
"silver": [192, 192, 192],
|
139
|
+
"skyblue": [135, 206, 235],
|
140
|
+
"slateblue": [106, 90, 205],
|
141
|
+
"slategray": [112, 128, 144],
|
142
|
+
"slategrey": [112, 128, 144],
|
143
|
+
"snow": [255, 250, 250],
|
144
|
+
"springgreen": [0, 255, 127],
|
145
|
+
"steelblue": [70, 130, 180],
|
146
|
+
"tan": [210, 180, 140],
|
147
|
+
"teal": [0, 128, 128],
|
148
|
+
"thistle": [216, 191, 216],
|
149
|
+
"tomato": [255, 99, 71],
|
150
|
+
"turquoise": [64, 224, 208],
|
151
|
+
"violet": [238, 130, 238],
|
152
|
+
"wheat": [245, 222, 179],
|
153
|
+
"white": [255, 255, 255],
|
154
|
+
"whitesmoke": [245, 245, 245],
|
155
|
+
"yellow": [255, 255, 0],
|
156
|
+
"yellowgreen": [154, 205, 50]
|
157
|
+
};
|
158
|
+
|
159
|
+
var isArrayish = function isArrayish(obj) {
|
160
|
+
if (!obj || typeof obj === 'string') {
|
161
|
+
return false;
|
162
|
+
}
|
163
|
+
|
164
|
+
return obj instanceof Array || Array.isArray(obj) ||
|
165
|
+
(obj.length >= 0 && (obj.splice instanceof Function ||
|
166
|
+
(Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
|
167
|
+
};
|
168
|
+
|
169
|
+
var simpleSwizzle = createCommonjsModule(function (module) {
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
var concat = Array.prototype.concat;
|
174
|
+
var slice = Array.prototype.slice;
|
175
|
+
|
176
|
+
var swizzle = module.exports = function swizzle(args) {
|
177
|
+
var results = [];
|
178
|
+
|
179
|
+
for (var i = 0, len = args.length; i < len; i++) {
|
180
|
+
var arg = args[i];
|
181
|
+
|
182
|
+
if (isArrayish(arg)) {
|
183
|
+
// http://jsperf.com/javascript-array-concat-vs-push/98
|
184
|
+
results = concat.call(results, slice.call(arg));
|
185
|
+
} else {
|
186
|
+
results.push(arg);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
return results;
|
191
|
+
};
|
192
|
+
|
193
|
+
swizzle.wrap = function (fn) {
|
194
|
+
return function () {
|
195
|
+
return fn(swizzle(arguments));
|
196
|
+
};
|
197
|
+
};
|
198
|
+
});
|
199
|
+
|
200
|
+
var colorString = createCommonjsModule(function (module) {
|
201
|
+
/* MIT license */
|
202
|
+
|
203
|
+
|
204
|
+
var hasOwnProperty = Object.hasOwnProperty;
|
205
|
+
|
206
|
+
var reverseNames = Object.create(null);
|
207
|
+
|
208
|
+
// create a list of reverse color names
|
209
|
+
for (var name in colorName) {
|
210
|
+
if (hasOwnProperty.call(colorName, name)) {
|
211
|
+
reverseNames[colorName[name]] = name;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
var cs = module.exports = {
|
216
|
+
to: {},
|
217
|
+
get: {}
|
218
|
+
};
|
219
|
+
|
220
|
+
cs.get = function (string) {
|
221
|
+
var prefix = string.substring(0, 3).toLowerCase();
|
222
|
+
var val;
|
223
|
+
var model;
|
224
|
+
switch (prefix) {
|
225
|
+
case 'hsl':
|
226
|
+
val = cs.get.hsl(string);
|
227
|
+
model = 'hsl';
|
228
|
+
break;
|
229
|
+
case 'hwb':
|
230
|
+
val = cs.get.hwb(string);
|
231
|
+
model = 'hwb';
|
232
|
+
break;
|
233
|
+
default:
|
234
|
+
val = cs.get.rgb(string);
|
235
|
+
model = 'rgb';
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
|
239
|
+
if (!val) {
|
240
|
+
return null;
|
241
|
+
}
|
242
|
+
|
243
|
+
return {model: model, value: val};
|
244
|
+
};
|
245
|
+
|
246
|
+
cs.get.rgb = function (string) {
|
247
|
+
if (!string) {
|
248
|
+
return null;
|
249
|
+
}
|
250
|
+
|
251
|
+
var abbr = /^#([a-f0-9]{3,4})$/i;
|
252
|
+
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
253
|
+
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
254
|
+
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
255
|
+
var keyword = /^(\w+)$/;
|
256
|
+
|
257
|
+
var rgb = [0, 0, 0, 1];
|
258
|
+
var match;
|
259
|
+
var i;
|
260
|
+
var hexAlpha;
|
261
|
+
|
262
|
+
if (match = string.match(hex)) {
|
263
|
+
hexAlpha = match[2];
|
264
|
+
match = match[1];
|
265
|
+
|
266
|
+
for (i = 0; i < 3; i++) {
|
267
|
+
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
268
|
+
var i2 = i * 2;
|
269
|
+
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
270
|
+
}
|
271
|
+
|
272
|
+
if (hexAlpha) {
|
273
|
+
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
274
|
+
}
|
275
|
+
} else if (match = string.match(abbr)) {
|
276
|
+
match = match[1];
|
277
|
+
hexAlpha = match[3];
|
278
|
+
|
279
|
+
for (i = 0; i < 3; i++) {
|
280
|
+
rgb[i] = parseInt(match[i] + match[i], 16);
|
281
|
+
}
|
282
|
+
|
283
|
+
if (hexAlpha) {
|
284
|
+
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
285
|
+
}
|
286
|
+
} else if (match = string.match(rgba)) {
|
287
|
+
for (i = 0; i < 3; i++) {
|
288
|
+
rgb[i] = parseInt(match[i + 1], 0);
|
289
|
+
}
|
290
|
+
|
291
|
+
if (match[4]) {
|
292
|
+
if (match[5]) {
|
293
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
294
|
+
} else {
|
295
|
+
rgb[3] = parseFloat(match[4]);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
} else if (match = string.match(per)) {
|
299
|
+
for (i = 0; i < 3; i++) {
|
300
|
+
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
301
|
+
}
|
302
|
+
|
303
|
+
if (match[4]) {
|
304
|
+
if (match[5]) {
|
305
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
306
|
+
} else {
|
307
|
+
rgb[3] = parseFloat(match[4]);
|
308
|
+
}
|
309
|
+
}
|
310
|
+
} else if (match = string.match(keyword)) {
|
311
|
+
if (match[1] === 'transparent') {
|
312
|
+
return [0, 0, 0, 0];
|
313
|
+
}
|
314
|
+
|
315
|
+
if (!hasOwnProperty.call(colorName, match[1])) {
|
316
|
+
return null;
|
317
|
+
}
|
318
|
+
|
319
|
+
rgb = colorName[match[1]];
|
320
|
+
rgb[3] = 1;
|
321
|
+
|
322
|
+
return rgb;
|
323
|
+
} else {
|
324
|
+
return null;
|
325
|
+
}
|
326
|
+
|
327
|
+
for (i = 0; i < 3; i++) {
|
328
|
+
rgb[i] = clamp(rgb[i], 0, 255);
|
329
|
+
}
|
330
|
+
rgb[3] = clamp(rgb[3], 0, 1);
|
331
|
+
|
332
|
+
return rgb;
|
333
|
+
};
|
334
|
+
|
335
|
+
cs.get.hsl = function (string) {
|
336
|
+
if (!string) {
|
337
|
+
return null;
|
338
|
+
}
|
339
|
+
|
340
|
+
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*)?\)$/;
|
341
|
+
var match = string.match(hsl);
|
342
|
+
|
343
|
+
if (match) {
|
344
|
+
var alpha = parseFloat(match[4]);
|
345
|
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
346
|
+
var s = clamp(parseFloat(match[2]), 0, 100);
|
347
|
+
var l = clamp(parseFloat(match[3]), 0, 100);
|
348
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
349
|
+
|
350
|
+
return [h, s, l, a];
|
351
|
+
}
|
352
|
+
|
353
|
+
return null;
|
354
|
+
};
|
355
|
+
|
356
|
+
cs.get.hwb = function (string) {
|
357
|
+
if (!string) {
|
358
|
+
return null;
|
359
|
+
}
|
360
|
+
|
361
|
+
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*)?\)$/;
|
362
|
+
var match = string.match(hwb);
|
363
|
+
|
364
|
+
if (match) {
|
365
|
+
var alpha = parseFloat(match[4]);
|
366
|
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
367
|
+
var w = clamp(parseFloat(match[2]), 0, 100);
|
368
|
+
var b = clamp(parseFloat(match[3]), 0, 100);
|
369
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
370
|
+
return [h, w, b, a];
|
371
|
+
}
|
372
|
+
|
373
|
+
return null;
|
374
|
+
};
|
375
|
+
|
376
|
+
cs.to.hex = function () {
|
377
|
+
var rgba = simpleSwizzle(arguments);
|
378
|
+
|
379
|
+
return (
|
380
|
+
'#' +
|
381
|
+
hexDouble(rgba[0]) +
|
382
|
+
hexDouble(rgba[1]) +
|
383
|
+
hexDouble(rgba[2]) +
|
384
|
+
(rgba[3] < 1
|
385
|
+
? (hexDouble(Math.round(rgba[3] * 255)))
|
386
|
+
: '')
|
387
|
+
);
|
388
|
+
};
|
389
|
+
|
390
|
+
cs.to.rgb = function () {
|
391
|
+
var rgba = simpleSwizzle(arguments);
|
392
|
+
|
393
|
+
return rgba.length < 4 || rgba[3] === 1
|
394
|
+
? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
|
395
|
+
: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
396
|
+
};
|
397
|
+
|
398
|
+
cs.to.rgb.percent = function () {
|
399
|
+
var rgba = simpleSwizzle(arguments);
|
400
|
+
|
401
|
+
var r = Math.round(rgba[0] / 255 * 100);
|
402
|
+
var g = Math.round(rgba[1] / 255 * 100);
|
403
|
+
var b = Math.round(rgba[2] / 255 * 100);
|
404
|
+
|
405
|
+
return rgba.length < 4 || rgba[3] === 1
|
406
|
+
? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
|
407
|
+
: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
408
|
+
};
|
409
|
+
|
410
|
+
cs.to.hsl = function () {
|
411
|
+
var hsla = simpleSwizzle(arguments);
|
412
|
+
return hsla.length < 4 || hsla[3] === 1
|
413
|
+
? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
|
414
|
+
: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
415
|
+
};
|
416
|
+
|
417
|
+
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
418
|
+
// (hwb have alpha optional & 1 is default value)
|
419
|
+
cs.to.hwb = function () {
|
420
|
+
var hwba = simpleSwizzle(arguments);
|
421
|
+
|
422
|
+
var a = '';
|
423
|
+
if (hwba.length >= 4 && hwba[3] !== 1) {
|
424
|
+
a = ', ' + hwba[3];
|
425
|
+
}
|
426
|
+
|
427
|
+
return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
|
428
|
+
};
|
429
|
+
|
430
|
+
cs.to.keyword = function (rgb) {
|
431
|
+
return reverseNames[rgb.slice(0, 3)];
|
432
|
+
};
|
433
|
+
|
434
|
+
// helpers
|
435
|
+
function clamp(num, min, max) {
|
436
|
+
return Math.min(Math.max(min, num), max);
|
437
|
+
}
|
438
|
+
|
439
|
+
function hexDouble(num) {
|
440
|
+
var str = Math.round(num).toString(16).toUpperCase();
|
441
|
+
return (str.length < 2) ? '0' + str : str;
|
442
|
+
}
|
443
|
+
});
|
444
|
+
|
445
|
+
/* MIT license */
|
446
|
+
/* eslint-disable no-mixed-operators */
|
447
|
+
|
448
|
+
|
449
|
+
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
450
|
+
// values that give correct `typeof` results).
|
451
|
+
// do not use box values types (i.e. Number(), String(), etc.)
|
452
|
+
|
453
|
+
const reverseKeywords = {};
|
454
|
+
for (const key of Object.keys(colorName)) {
|
455
|
+
reverseKeywords[colorName[key]] = key;
|
456
|
+
}
|
457
|
+
|
458
|
+
const convert$1 = {
|
459
|
+
rgb: {channels: 3, labels: 'rgb'},
|
460
|
+
hsl: {channels: 3, labels: 'hsl'},
|
461
|
+
hsv: {channels: 3, labels: 'hsv'},
|
462
|
+
hwb: {channels: 3, labels: 'hwb'},
|
463
|
+
cmyk: {channels: 4, labels: 'cmyk'},
|
464
|
+
xyz: {channels: 3, labels: 'xyz'},
|
465
|
+
lab: {channels: 3, labels: 'lab'},
|
466
|
+
lch: {channels: 3, labels: 'lch'},
|
467
|
+
hex: {channels: 1, labels: ['hex']},
|
468
|
+
keyword: {channels: 1, labels: ['keyword']},
|
469
|
+
ansi16: {channels: 1, labels: ['ansi16']},
|
470
|
+
ansi256: {channels: 1, labels: ['ansi256']},
|
471
|
+
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
472
|
+
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
473
|
+
gray: {channels: 1, labels: ['gray']}
|
474
|
+
};
|
475
|
+
|
476
|
+
var conversions = convert$1;
|
477
|
+
|
478
|
+
// Hide .channels and .labels properties
|
479
|
+
for (const model of Object.keys(convert$1)) {
|
480
|
+
if (!('channels' in convert$1[model])) {
|
481
|
+
throw new Error('missing channels property: ' + model);
|
482
|
+
}
|
483
|
+
|
484
|
+
if (!('labels' in convert$1[model])) {
|
485
|
+
throw new Error('missing channel labels property: ' + model);
|
486
|
+
}
|
487
|
+
|
488
|
+
if (convert$1[model].labels.length !== convert$1[model].channels) {
|
489
|
+
throw new Error('channel and label counts mismatch: ' + model);
|
490
|
+
}
|
491
|
+
|
492
|
+
const {channels, labels} = convert$1[model];
|
493
|
+
delete convert$1[model].channels;
|
494
|
+
delete convert$1[model].labels;
|
495
|
+
Object.defineProperty(convert$1[model], 'channels', {value: channels});
|
496
|
+
Object.defineProperty(convert$1[model], 'labels', {value: labels});
|
497
|
+
}
|
498
|
+
|
499
|
+
convert$1.rgb.hsl = function (rgb) {
|
500
|
+
const r = rgb[0] / 255;
|
501
|
+
const g = rgb[1] / 255;
|
502
|
+
const b = rgb[2] / 255;
|
503
|
+
const min = Math.min(r, g, b);
|
504
|
+
const max = Math.max(r, g, b);
|
505
|
+
const delta = max - min;
|
506
|
+
let h;
|
507
|
+
let s;
|
508
|
+
|
509
|
+
if (max === min) {
|
510
|
+
h = 0;
|
511
|
+
} else if (r === max) {
|
512
|
+
h = (g - b) / delta;
|
513
|
+
} else if (g === max) {
|
514
|
+
h = 2 + (b - r) / delta;
|
515
|
+
} else if (b === max) {
|
516
|
+
h = 4 + (r - g) / delta;
|
517
|
+
}
|
518
|
+
|
519
|
+
h = Math.min(h * 60, 360);
|
520
|
+
|
521
|
+
if (h < 0) {
|
522
|
+
h += 360;
|
523
|
+
}
|
524
|
+
|
525
|
+
const l = (min + max) / 2;
|
526
|
+
|
527
|
+
if (max === min) {
|
528
|
+
s = 0;
|
529
|
+
} else if (l <= 0.5) {
|
530
|
+
s = delta / (max + min);
|
531
|
+
} else {
|
532
|
+
s = delta / (2 - max - min);
|
533
|
+
}
|
534
|
+
|
535
|
+
return [h, s * 100, l * 100];
|
536
|
+
};
|
537
|
+
|
538
|
+
convert$1.rgb.hsv = function (rgb) {
|
539
|
+
let rdif;
|
540
|
+
let gdif;
|
541
|
+
let bdif;
|
542
|
+
let h;
|
543
|
+
let s;
|
544
|
+
|
545
|
+
const r = rgb[0] / 255;
|
546
|
+
const g = rgb[1] / 255;
|
547
|
+
const b = rgb[2] / 255;
|
548
|
+
const v = Math.max(r, g, b);
|
549
|
+
const diff = v - Math.min(r, g, b);
|
550
|
+
const diffc = function (c) {
|
551
|
+
return (v - c) / 6 / diff + 1 / 2;
|
552
|
+
};
|
553
|
+
|
554
|
+
if (diff === 0) {
|
555
|
+
h = 0;
|
556
|
+
s = 0;
|
557
|
+
} else {
|
558
|
+
s = diff / v;
|
559
|
+
rdif = diffc(r);
|
560
|
+
gdif = diffc(g);
|
561
|
+
bdif = diffc(b);
|
562
|
+
|
563
|
+
if (r === v) {
|
564
|
+
h = bdif - gdif;
|
565
|
+
} else if (g === v) {
|
566
|
+
h = (1 / 3) + rdif - bdif;
|
567
|
+
} else if (b === v) {
|
568
|
+
h = (2 / 3) + gdif - rdif;
|
569
|
+
}
|
570
|
+
|
571
|
+
if (h < 0) {
|
572
|
+
h += 1;
|
573
|
+
} else if (h > 1) {
|
574
|
+
h -= 1;
|
575
|
+
}
|
576
|
+
}
|
577
|
+
|
578
|
+
return [
|
579
|
+
h * 360,
|
580
|
+
s * 100,
|
581
|
+
v * 100
|
582
|
+
];
|
583
|
+
};
|
584
|
+
|
585
|
+
convert$1.rgb.hwb = function (rgb) {
|
586
|
+
const r = rgb[0];
|
587
|
+
const g = rgb[1];
|
588
|
+
let b = rgb[2];
|
589
|
+
const h = convert$1.rgb.hsl(rgb)[0];
|
590
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
591
|
+
|
592
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
593
|
+
|
594
|
+
return [h, w * 100, b * 100];
|
595
|
+
};
|
596
|
+
|
597
|
+
convert$1.rgb.cmyk = function (rgb) {
|
598
|
+
const r = rgb[0] / 255;
|
599
|
+
const g = rgb[1] / 255;
|
600
|
+
const b = rgb[2] / 255;
|
601
|
+
|
602
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
603
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
604
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
605
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
606
|
+
|
607
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
608
|
+
};
|
609
|
+
|
610
|
+
function comparativeDistance(x, y) {
|
611
|
+
/*
|
612
|
+
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
613
|
+
*/
|
614
|
+
return (
|
615
|
+
((x[0] - y[0]) ** 2) +
|
616
|
+
((x[1] - y[1]) ** 2) +
|
617
|
+
((x[2] - y[2]) ** 2)
|
618
|
+
);
|
619
|
+
}
|
620
|
+
|
621
|
+
convert$1.rgb.keyword = function (rgb) {
|
622
|
+
const reversed = reverseKeywords[rgb];
|
623
|
+
if (reversed) {
|
624
|
+
return reversed;
|
625
|
+
}
|
626
|
+
|
627
|
+
let currentClosestDistance = Infinity;
|
628
|
+
let currentClosestKeyword;
|
629
|
+
|
630
|
+
for (const keyword of Object.keys(colorName)) {
|
631
|
+
const value = colorName[keyword];
|
632
|
+
|
633
|
+
// Compute comparative distance
|
634
|
+
const distance = comparativeDistance(rgb, value);
|
635
|
+
|
636
|
+
// Check if its less, if so set as closest
|
637
|
+
if (distance < currentClosestDistance) {
|
638
|
+
currentClosestDistance = distance;
|
639
|
+
currentClosestKeyword = keyword;
|
640
|
+
}
|
641
|
+
}
|
642
|
+
|
643
|
+
return currentClosestKeyword;
|
644
|
+
};
|
645
|
+
|
646
|
+
convert$1.keyword.rgb = function (keyword) {
|
647
|
+
return colorName[keyword];
|
648
|
+
};
|
649
|
+
|
650
|
+
convert$1.rgb.xyz = function (rgb) {
|
651
|
+
let r = rgb[0] / 255;
|
652
|
+
let g = rgb[1] / 255;
|
653
|
+
let b = rgb[2] / 255;
|
654
|
+
|
655
|
+
// Assume sRGB
|
656
|
+
r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
|
657
|
+
g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
|
658
|
+
b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
|
659
|
+
|
660
|
+
const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
661
|
+
const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
662
|
+
const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
663
|
+
|
664
|
+
return [x * 100, y * 100, z * 100];
|
665
|
+
};
|
666
|
+
|
667
|
+
convert$1.rgb.lab = function (rgb) {
|
668
|
+
const xyz = convert$1.rgb.xyz(rgb);
|
669
|
+
let x = xyz[0];
|
670
|
+
let y = xyz[1];
|
671
|
+
let z = xyz[2];
|
672
|
+
|
673
|
+
x /= 95.047;
|
674
|
+
y /= 100;
|
675
|
+
z /= 108.883;
|
676
|
+
|
677
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
678
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
679
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
680
|
+
|
681
|
+
const l = (116 * y) - 16;
|
682
|
+
const a = 500 * (x - y);
|
683
|
+
const b = 200 * (y - z);
|
684
|
+
|
685
|
+
return [l, a, b];
|
686
|
+
};
|
687
|
+
|
688
|
+
convert$1.hsl.rgb = function (hsl) {
|
689
|
+
const h = hsl[0] / 360;
|
690
|
+
const s = hsl[1] / 100;
|
691
|
+
const l = hsl[2] / 100;
|
692
|
+
let t2;
|
693
|
+
let t3;
|
694
|
+
let val;
|
695
|
+
|
696
|
+
if (s === 0) {
|
697
|
+
val = l * 255;
|
698
|
+
return [val, val, val];
|
699
|
+
}
|
700
|
+
|
701
|
+
if (l < 0.5) {
|
702
|
+
t2 = l * (1 + s);
|
703
|
+
} else {
|
704
|
+
t2 = l + s - l * s;
|
705
|
+
}
|
706
|
+
|
707
|
+
const t1 = 2 * l - t2;
|
708
|
+
|
709
|
+
const rgb = [0, 0, 0];
|
710
|
+
for (let i = 0; i < 3; i++) {
|
711
|
+
t3 = h + 1 / 3 * -(i - 1);
|
712
|
+
if (t3 < 0) {
|
713
|
+
t3++;
|
714
|
+
}
|
715
|
+
|
716
|
+
if (t3 > 1) {
|
717
|
+
t3--;
|
718
|
+
}
|
719
|
+
|
720
|
+
if (6 * t3 < 1) {
|
721
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
722
|
+
} else if (2 * t3 < 1) {
|
723
|
+
val = t2;
|
724
|
+
} else if (3 * t3 < 2) {
|
725
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
726
|
+
} else {
|
727
|
+
val = t1;
|
728
|
+
}
|
729
|
+
|
730
|
+
rgb[i] = val * 255;
|
731
|
+
}
|
732
|
+
|
733
|
+
return rgb;
|
734
|
+
};
|
735
|
+
|
736
|
+
convert$1.hsl.hsv = function (hsl) {
|
737
|
+
const h = hsl[0];
|
738
|
+
let s = hsl[1] / 100;
|
739
|
+
let l = hsl[2] / 100;
|
740
|
+
let smin = s;
|
741
|
+
const lmin = Math.max(l, 0.01);
|
742
|
+
|
743
|
+
l *= 2;
|
744
|
+
s *= (l <= 1) ? l : 2 - l;
|
745
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
746
|
+
const v = (l + s) / 2;
|
747
|
+
const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
748
|
+
|
749
|
+
return [h, sv * 100, v * 100];
|
750
|
+
};
|
751
|
+
|
752
|
+
convert$1.hsv.rgb = function (hsv) {
|
753
|
+
const h = hsv[0] / 60;
|
754
|
+
const s = hsv[1] / 100;
|
755
|
+
let v = hsv[2] / 100;
|
756
|
+
const hi = Math.floor(h) % 6;
|
757
|
+
|
758
|
+
const f = h - Math.floor(h);
|
759
|
+
const p = 255 * v * (1 - s);
|
760
|
+
const q = 255 * v * (1 - (s * f));
|
761
|
+
const t = 255 * v * (1 - (s * (1 - f)));
|
762
|
+
v *= 255;
|
763
|
+
|
764
|
+
switch (hi) {
|
765
|
+
case 0:
|
766
|
+
return [v, t, p];
|
767
|
+
case 1:
|
768
|
+
return [q, v, p];
|
769
|
+
case 2:
|
770
|
+
return [p, v, t];
|
771
|
+
case 3:
|
772
|
+
return [p, q, v];
|
773
|
+
case 4:
|
774
|
+
return [t, p, v];
|
775
|
+
case 5:
|
776
|
+
return [v, p, q];
|
777
|
+
}
|
778
|
+
};
|
779
|
+
|
780
|
+
convert$1.hsv.hsl = function (hsv) {
|
781
|
+
const h = hsv[0];
|
782
|
+
const s = hsv[1] / 100;
|
783
|
+
const v = hsv[2] / 100;
|
784
|
+
const vmin = Math.max(v, 0.01);
|
785
|
+
let sl;
|
786
|
+
let l;
|
787
|
+
|
788
|
+
l = (2 - s) * v;
|
789
|
+
const lmin = (2 - s) * vmin;
|
790
|
+
sl = s * vmin;
|
791
|
+
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
792
|
+
sl = sl || 0;
|
793
|
+
l /= 2;
|
794
|
+
|
795
|
+
return [h, sl * 100, l * 100];
|
796
|
+
};
|
797
|
+
|
798
|
+
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
799
|
+
convert$1.hwb.rgb = function (hwb) {
|
800
|
+
const h = hwb[0] / 360;
|
801
|
+
let wh = hwb[1] / 100;
|
802
|
+
let bl = hwb[2] / 100;
|
803
|
+
const ratio = wh + bl;
|
804
|
+
let f;
|
805
|
+
|
806
|
+
// Wh + bl cant be > 1
|
807
|
+
if (ratio > 1) {
|
808
|
+
wh /= ratio;
|
809
|
+
bl /= ratio;
|
810
|
+
}
|
811
|
+
|
812
|
+
const i = Math.floor(6 * h);
|
813
|
+
const v = 1 - bl;
|
814
|
+
f = 6 * h - i;
|
815
|
+
|
816
|
+
if ((i & 0x01) !== 0) {
|
817
|
+
f = 1 - f;
|
818
|
+
}
|
819
|
+
|
820
|
+
const n = wh + f * (v - wh); // Linear interpolation
|
821
|
+
|
822
|
+
let r;
|
823
|
+
let g;
|
824
|
+
let b;
|
825
|
+
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
826
|
+
switch (i) {
|
827
|
+
default:
|
828
|
+
case 6:
|
829
|
+
case 0: r = v; g = n; b = wh; break;
|
830
|
+
case 1: r = n; g = v; b = wh; break;
|
831
|
+
case 2: r = wh; g = v; b = n; break;
|
832
|
+
case 3: r = wh; g = n; b = v; break;
|
833
|
+
case 4: r = n; g = wh; b = v; break;
|
834
|
+
case 5: r = v; g = wh; b = n; break;
|
835
|
+
}
|
836
|
+
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
837
|
+
|
838
|
+
return [r * 255, g * 255, b * 255];
|
839
|
+
};
|
840
|
+
|
841
|
+
convert$1.cmyk.rgb = function (cmyk) {
|
842
|
+
const c = cmyk[0] / 100;
|
843
|
+
const m = cmyk[1] / 100;
|
844
|
+
const y = cmyk[2] / 100;
|
845
|
+
const k = cmyk[3] / 100;
|
846
|
+
|
847
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
848
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
849
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
850
|
+
|
851
|
+
return [r * 255, g * 255, b * 255];
|
852
|
+
};
|
853
|
+
|
854
|
+
convert$1.xyz.rgb = function (xyz) {
|
855
|
+
const x = xyz[0] / 100;
|
856
|
+
const y = xyz[1] / 100;
|
857
|
+
const z = xyz[2] / 100;
|
858
|
+
let r;
|
859
|
+
let g;
|
860
|
+
let b;
|
861
|
+
|
862
|
+
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
863
|
+
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
864
|
+
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
865
|
+
|
866
|
+
// Assume sRGB
|
867
|
+
r = r > 0.0031308
|
868
|
+
? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
|
869
|
+
: r * 12.92;
|
870
|
+
|
871
|
+
g = g > 0.0031308
|
872
|
+
? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
|
873
|
+
: g * 12.92;
|
874
|
+
|
875
|
+
b = b > 0.0031308
|
876
|
+
? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
|
877
|
+
: b * 12.92;
|
878
|
+
|
879
|
+
r = Math.min(Math.max(0, r), 1);
|
880
|
+
g = Math.min(Math.max(0, g), 1);
|
881
|
+
b = Math.min(Math.max(0, b), 1);
|
882
|
+
|
883
|
+
return [r * 255, g * 255, b * 255];
|
884
|
+
};
|
885
|
+
|
886
|
+
convert$1.xyz.lab = function (xyz) {
|
887
|
+
let x = xyz[0];
|
888
|
+
let y = xyz[1];
|
889
|
+
let z = xyz[2];
|
890
|
+
|
891
|
+
x /= 95.047;
|
892
|
+
y /= 100;
|
893
|
+
z /= 108.883;
|
894
|
+
|
895
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
896
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
897
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
898
|
+
|
899
|
+
const l = (116 * y) - 16;
|
900
|
+
const a = 500 * (x - y);
|
901
|
+
const b = 200 * (y - z);
|
902
|
+
|
903
|
+
return [l, a, b];
|
904
|
+
};
|
905
|
+
|
906
|
+
convert$1.lab.xyz = function (lab) {
|
907
|
+
const l = lab[0];
|
908
|
+
const a = lab[1];
|
909
|
+
const b = lab[2];
|
910
|
+
let x;
|
911
|
+
let y;
|
912
|
+
let z;
|
913
|
+
|
914
|
+
y = (l + 16) / 116;
|
915
|
+
x = a / 500 + y;
|
916
|
+
z = y - b / 200;
|
917
|
+
|
918
|
+
const y2 = y ** 3;
|
919
|
+
const x2 = x ** 3;
|
920
|
+
const z2 = z ** 3;
|
921
|
+
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
922
|
+
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
923
|
+
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
924
|
+
|
925
|
+
x *= 95.047;
|
926
|
+
y *= 100;
|
927
|
+
z *= 108.883;
|
928
|
+
|
929
|
+
return [x, y, z];
|
930
|
+
};
|
931
|
+
|
932
|
+
convert$1.lab.lch = function (lab) {
|
933
|
+
const l = lab[0];
|
934
|
+
const a = lab[1];
|
935
|
+
const b = lab[2];
|
936
|
+
let h;
|
937
|
+
|
938
|
+
const hr = Math.atan2(b, a);
|
939
|
+
h = hr * 360 / 2 / Math.PI;
|
940
|
+
|
941
|
+
if (h < 0) {
|
942
|
+
h += 360;
|
943
|
+
}
|
944
|
+
|
945
|
+
const c = Math.sqrt(a * a + b * b);
|
946
|
+
|
947
|
+
return [l, c, h];
|
948
|
+
};
|
949
|
+
|
950
|
+
convert$1.lch.lab = function (lch) {
|
951
|
+
const l = lch[0];
|
952
|
+
const c = lch[1];
|
953
|
+
const h = lch[2];
|
954
|
+
|
955
|
+
const hr = h / 360 * 2 * Math.PI;
|
956
|
+
const a = c * Math.cos(hr);
|
957
|
+
const b = c * Math.sin(hr);
|
958
|
+
|
959
|
+
return [l, a, b];
|
960
|
+
};
|
961
|
+
|
962
|
+
convert$1.rgb.ansi16 = function (args, saturation = null) {
|
963
|
+
const [r, g, b] = args;
|
964
|
+
let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
|
965
|
+
|
966
|
+
value = Math.round(value / 50);
|
967
|
+
|
968
|
+
if (value === 0) {
|
969
|
+
return 30;
|
970
|
+
}
|
971
|
+
|
972
|
+
let ansi = 30
|
973
|
+
+ ((Math.round(b / 255) << 2)
|
974
|
+
| (Math.round(g / 255) << 1)
|
975
|
+
| Math.round(r / 255));
|
976
|
+
|
977
|
+
if (value === 2) {
|
978
|
+
ansi += 60;
|
979
|
+
}
|
980
|
+
|
981
|
+
return ansi;
|
982
|
+
};
|
983
|
+
|
984
|
+
convert$1.hsv.ansi16 = function (args) {
|
985
|
+
// Optimization here; we already know the value and don't need to get
|
986
|
+
// it converted for us.
|
987
|
+
return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
|
988
|
+
};
|
989
|
+
|
990
|
+
convert$1.rgb.ansi256 = function (args) {
|
991
|
+
const r = args[0];
|
992
|
+
const g = args[1];
|
993
|
+
const b = args[2];
|
994
|
+
|
995
|
+
// We use the extended greyscale palette here, with the exception of
|
996
|
+
// black and white. normal palette only has 4 greyscale shades.
|
997
|
+
if (r === g && g === b) {
|
998
|
+
if (r < 8) {
|
999
|
+
return 16;
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
if (r > 248) {
|
1003
|
+
return 231;
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
return Math.round(((r - 8) / 247) * 24) + 232;
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
const ansi = 16
|
1010
|
+
+ (36 * Math.round(r / 255 * 5))
|
1011
|
+
+ (6 * Math.round(g / 255 * 5))
|
1012
|
+
+ Math.round(b / 255 * 5);
|
1013
|
+
|
1014
|
+
return ansi;
|
1015
|
+
};
|
1016
|
+
|
1017
|
+
convert$1.ansi16.rgb = function (args) {
|
1018
|
+
let color = args % 10;
|
1019
|
+
|
1020
|
+
// Handle greyscale
|
1021
|
+
if (color === 0 || color === 7) {
|
1022
|
+
if (args > 50) {
|
1023
|
+
color += 3.5;
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
color = color / 10.5 * 255;
|
1027
|
+
|
1028
|
+
return [color, color, color];
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
1032
|
+
const r = ((color & 1) * mult) * 255;
|
1033
|
+
const g = (((color >> 1) & 1) * mult) * 255;
|
1034
|
+
const b = (((color >> 2) & 1) * mult) * 255;
|
1035
|
+
|
1036
|
+
return [r, g, b];
|
1037
|
+
};
|
1038
|
+
|
1039
|
+
convert$1.ansi256.rgb = function (args) {
|
1040
|
+
// Handle greyscale
|
1041
|
+
if (args >= 232) {
|
1042
|
+
const c = (args - 232) * 10 + 8;
|
1043
|
+
return [c, c, c];
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
args -= 16;
|
1047
|
+
|
1048
|
+
let rem;
|
1049
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
1050
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
1051
|
+
const b = (rem % 6) / 5 * 255;
|
1052
|
+
|
1053
|
+
return [r, g, b];
|
1054
|
+
};
|
1055
|
+
|
1056
|
+
convert$1.rgb.hex = function (args) {
|
1057
|
+
const integer = ((Math.round(args[0]) & 0xFF) << 16)
|
1058
|
+
+ ((Math.round(args[1]) & 0xFF) << 8)
|
1059
|
+
+ (Math.round(args[2]) & 0xFF);
|
1060
|
+
|
1061
|
+
const string = integer.toString(16).toUpperCase();
|
1062
|
+
return '000000'.substring(string.length) + string;
|
1063
|
+
};
|
1064
|
+
|
1065
|
+
convert$1.hex.rgb = function (args) {
|
1066
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
1067
|
+
if (!match) {
|
1068
|
+
return [0, 0, 0];
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
let colorString = match[0];
|
1072
|
+
|
1073
|
+
if (match[0].length === 3) {
|
1074
|
+
colorString = colorString.split('').map(char => {
|
1075
|
+
return char + char;
|
1076
|
+
}).join('');
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
const integer = parseInt(colorString, 16);
|
1080
|
+
const r = (integer >> 16) & 0xFF;
|
1081
|
+
const g = (integer >> 8) & 0xFF;
|
1082
|
+
const b = integer & 0xFF;
|
1083
|
+
|
1084
|
+
return [r, g, b];
|
1085
|
+
};
|
1086
|
+
|
1087
|
+
convert$1.rgb.hcg = function (rgb) {
|
1088
|
+
const r = rgb[0] / 255;
|
1089
|
+
const g = rgb[1] / 255;
|
1090
|
+
const b = rgb[2] / 255;
|
1091
|
+
const max = Math.max(Math.max(r, g), b);
|
1092
|
+
const min = Math.min(Math.min(r, g), b);
|
1093
|
+
const chroma = (max - min);
|
1094
|
+
let grayscale;
|
1095
|
+
let hue;
|
1096
|
+
|
1097
|
+
if (chroma < 1) {
|
1098
|
+
grayscale = min / (1 - chroma);
|
1099
|
+
} else {
|
1100
|
+
grayscale = 0;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
if (chroma <= 0) {
|
1104
|
+
hue = 0;
|
1105
|
+
} else
|
1106
|
+
if (max === r) {
|
1107
|
+
hue = ((g - b) / chroma) % 6;
|
1108
|
+
} else
|
1109
|
+
if (max === g) {
|
1110
|
+
hue = 2 + (b - r) / chroma;
|
1111
|
+
} else {
|
1112
|
+
hue = 4 + (r - g) / chroma;
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
hue /= 6;
|
1116
|
+
hue %= 1;
|
1117
|
+
|
1118
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
1119
|
+
};
|
1120
|
+
|
1121
|
+
convert$1.hsl.hcg = function (hsl) {
|
1122
|
+
const s = hsl[1] / 100;
|
1123
|
+
const l = hsl[2] / 100;
|
1124
|
+
|
1125
|
+
const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
|
1126
|
+
|
1127
|
+
let f = 0;
|
1128
|
+
if (c < 1.0) {
|
1129
|
+
f = (l - 0.5 * c) / (1.0 - c);
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
return [hsl[0], c * 100, f * 100];
|
1133
|
+
};
|
1134
|
+
|
1135
|
+
convert$1.hsv.hcg = function (hsv) {
|
1136
|
+
const s = hsv[1] / 100;
|
1137
|
+
const v = hsv[2] / 100;
|
1138
|
+
|
1139
|
+
const c = s * v;
|
1140
|
+
let f = 0;
|
1141
|
+
|
1142
|
+
if (c < 1.0) {
|
1143
|
+
f = (v - c) / (1 - c);
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
return [hsv[0], c * 100, f * 100];
|
1147
|
+
};
|
1148
|
+
|
1149
|
+
convert$1.hcg.rgb = function (hcg) {
|
1150
|
+
const h = hcg[0] / 360;
|
1151
|
+
const c = hcg[1] / 100;
|
1152
|
+
const g = hcg[2] / 100;
|
1153
|
+
|
1154
|
+
if (c === 0.0) {
|
1155
|
+
return [g * 255, g * 255, g * 255];
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
const pure = [0, 0, 0];
|
1159
|
+
const hi = (h % 1) * 6;
|
1160
|
+
const v = hi % 1;
|
1161
|
+
const w = 1 - v;
|
1162
|
+
let mg = 0;
|
1163
|
+
|
1164
|
+
/* eslint-disable max-statements-per-line */
|
1165
|
+
switch (Math.floor(hi)) {
|
1166
|
+
case 0:
|
1167
|
+
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
1168
|
+
case 1:
|
1169
|
+
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
1170
|
+
case 2:
|
1171
|
+
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
1172
|
+
case 3:
|
1173
|
+
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
1174
|
+
case 4:
|
1175
|
+
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
1176
|
+
default:
|
1177
|
+
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
1178
|
+
}
|
1179
|
+
/* eslint-enable max-statements-per-line */
|
1180
|
+
|
1181
|
+
mg = (1.0 - c) * g;
|
1182
|
+
|
1183
|
+
return [
|
1184
|
+
(c * pure[0] + mg) * 255,
|
1185
|
+
(c * pure[1] + mg) * 255,
|
1186
|
+
(c * pure[2] + mg) * 255
|
1187
|
+
];
|
1188
|
+
};
|
1189
|
+
|
1190
|
+
convert$1.hcg.hsv = function (hcg) {
|
1191
|
+
const c = hcg[1] / 100;
|
1192
|
+
const g = hcg[2] / 100;
|
1193
|
+
|
1194
|
+
const v = c + g * (1.0 - c);
|
1195
|
+
let f = 0;
|
1196
|
+
|
1197
|
+
if (v > 0.0) {
|
1198
|
+
f = c / v;
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
return [hcg[0], f * 100, v * 100];
|
1202
|
+
};
|
1203
|
+
|
1204
|
+
convert$1.hcg.hsl = function (hcg) {
|
1205
|
+
const c = hcg[1] / 100;
|
1206
|
+
const g = hcg[2] / 100;
|
1207
|
+
|
1208
|
+
const l = g * (1.0 - c) + 0.5 * c;
|
1209
|
+
let s = 0;
|
1210
|
+
|
1211
|
+
if (l > 0.0 && l < 0.5) {
|
1212
|
+
s = c / (2 * l);
|
1213
|
+
} else
|
1214
|
+
if (l >= 0.5 && l < 1.0) {
|
1215
|
+
s = c / (2 * (1 - l));
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
return [hcg[0], s * 100, l * 100];
|
1219
|
+
};
|
1220
|
+
|
1221
|
+
convert$1.hcg.hwb = function (hcg) {
|
1222
|
+
const c = hcg[1] / 100;
|
1223
|
+
const g = hcg[2] / 100;
|
1224
|
+
const v = c + g * (1.0 - c);
|
1225
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
1226
|
+
};
|
1227
|
+
|
1228
|
+
convert$1.hwb.hcg = function (hwb) {
|
1229
|
+
const w = hwb[1] / 100;
|
1230
|
+
const b = hwb[2] / 100;
|
1231
|
+
const v = 1 - b;
|
1232
|
+
const c = v - w;
|
1233
|
+
let g = 0;
|
1234
|
+
|
1235
|
+
if (c < 1) {
|
1236
|
+
g = (v - c) / (1 - c);
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
return [hwb[0], c * 100, g * 100];
|
1240
|
+
};
|
1241
|
+
|
1242
|
+
convert$1.apple.rgb = function (apple) {
|
1243
|
+
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
1244
|
+
};
|
1245
|
+
|
1246
|
+
convert$1.rgb.apple = function (rgb) {
|
1247
|
+
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
1248
|
+
};
|
1249
|
+
|
1250
|
+
convert$1.gray.rgb = function (args) {
|
1251
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
1252
|
+
};
|
1253
|
+
|
1254
|
+
convert$1.gray.hsl = function (args) {
|
1255
|
+
return [0, 0, args[0]];
|
1256
|
+
};
|
1257
|
+
|
1258
|
+
convert$1.gray.hsv = convert$1.gray.hsl;
|
1259
|
+
|
1260
|
+
convert$1.gray.hwb = function (gray) {
|
1261
|
+
return [0, 100, gray[0]];
|
1262
|
+
};
|
1263
|
+
|
1264
|
+
convert$1.gray.cmyk = function (gray) {
|
1265
|
+
return [0, 0, 0, gray[0]];
|
1266
|
+
};
|
1267
|
+
|
1268
|
+
convert$1.gray.lab = function (gray) {
|
1269
|
+
return [gray[0], 0, 0];
|
1270
|
+
};
|
1271
|
+
|
1272
|
+
convert$1.gray.hex = function (gray) {
|
1273
|
+
const val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
1274
|
+
const integer = (val << 16) + (val << 8) + val;
|
1275
|
+
|
1276
|
+
const string = integer.toString(16).toUpperCase();
|
1277
|
+
return '000000'.substring(string.length) + string;
|
1278
|
+
};
|
1279
|
+
|
1280
|
+
convert$1.rgb.gray = function (rgb) {
|
1281
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
1282
|
+
return [val / 255 * 100];
|
1283
|
+
};
|
1284
|
+
|
1285
|
+
/*
|
1286
|
+
This function routes a model to all other models.
|
1287
|
+
|
1288
|
+
all functions that are routed have a property `.conversion` attached
|
1289
|
+
to the returned synthetic function. This property is an array
|
1290
|
+
of strings, each with the steps in between the 'from' and 'to'
|
1291
|
+
color models (inclusive).
|
1292
|
+
|
1293
|
+
conversions that are not possible simply are not included.
|
1294
|
+
*/
|
1295
|
+
|
1296
|
+
function buildGraph() {
|
1297
|
+
const graph = {};
|
1298
|
+
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
1299
|
+
const models = Object.keys(conversions);
|
1300
|
+
|
1301
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
1302
|
+
graph[models[i]] = {
|
1303
|
+
// http://jsperf.com/1-vs-infinity
|
1304
|
+
// micro-opt, but this is simple.
|
1305
|
+
distance: -1,
|
1306
|
+
parent: null
|
1307
|
+
};
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
return graph;
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
// https://en.wikipedia.org/wiki/Breadth-first_search
|
1314
|
+
function deriveBFS(fromModel) {
|
1315
|
+
const graph = buildGraph();
|
1316
|
+
const queue = [fromModel]; // Unshift -> queue -> pop
|
1317
|
+
|
1318
|
+
graph[fromModel].distance = 0;
|
1319
|
+
|
1320
|
+
while (queue.length) {
|
1321
|
+
const current = queue.pop();
|
1322
|
+
const adjacents = Object.keys(conversions[current]);
|
1323
|
+
|
1324
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
1325
|
+
const adjacent = adjacents[i];
|
1326
|
+
const node = graph[adjacent];
|
1327
|
+
|
1328
|
+
if (node.distance === -1) {
|
1329
|
+
node.distance = graph[current].distance + 1;
|
1330
|
+
node.parent = current;
|
1331
|
+
queue.unshift(adjacent);
|
1332
|
+
}
|
1333
|
+
}
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
return graph;
|
1337
|
+
}
|
1338
|
+
|
1339
|
+
function link(from, to) {
|
1340
|
+
return function (args) {
|
1341
|
+
return to(from(args));
|
1342
|
+
};
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
function wrapConversion(toModel, graph) {
|
1346
|
+
const path = [graph[toModel].parent, toModel];
|
1347
|
+
let fn = conversions[graph[toModel].parent][toModel];
|
1348
|
+
|
1349
|
+
let cur = graph[toModel].parent;
|
1350
|
+
while (graph[cur].parent) {
|
1351
|
+
path.unshift(graph[cur].parent);
|
1352
|
+
fn = link(conversions[graph[cur].parent][cur], fn);
|
1353
|
+
cur = graph[cur].parent;
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
fn.conversion = path;
|
1357
|
+
return fn;
|
1358
|
+
}
|
1359
|
+
|
1360
|
+
var route = function (fromModel) {
|
1361
|
+
const graph = deriveBFS(fromModel);
|
1362
|
+
const conversion = {};
|
1363
|
+
|
1364
|
+
const models = Object.keys(graph);
|
1365
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
1366
|
+
const toModel = models[i];
|
1367
|
+
const node = graph[toModel];
|
1368
|
+
|
1369
|
+
if (node.parent === null) {
|
1370
|
+
// No possible conversion, or this node is the source model.
|
1371
|
+
continue;
|
1372
|
+
}
|
1373
|
+
|
1374
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
return conversion;
|
1378
|
+
};
|
1379
|
+
|
1380
|
+
const convert = {};
|
1381
|
+
|
1382
|
+
const models = Object.keys(conversions);
|
1383
|
+
|
1384
|
+
function wrapRaw(fn) {
|
1385
|
+
const wrappedFn = function (...args) {
|
1386
|
+
const arg0 = args[0];
|
1387
|
+
if (arg0 === undefined || arg0 === null) {
|
1388
|
+
return arg0;
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
if (arg0.length > 1) {
|
1392
|
+
args = arg0;
|
1393
|
+
}
|
1394
|
+
|
1395
|
+
return fn(args);
|
1396
|
+
};
|
1397
|
+
|
1398
|
+
// Preserve .conversion property if there is one
|
1399
|
+
if ('conversion' in fn) {
|
1400
|
+
wrappedFn.conversion = fn.conversion;
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
return wrappedFn;
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
function wrapRounded(fn) {
|
1407
|
+
const wrappedFn = function (...args) {
|
1408
|
+
const arg0 = args[0];
|
1409
|
+
|
1410
|
+
if (arg0 === undefined || arg0 === null) {
|
1411
|
+
return arg0;
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
if (arg0.length > 1) {
|
1415
|
+
args = arg0;
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
const result = fn(args);
|
1419
|
+
|
1420
|
+
// We're assuming the result is an array here.
|
1421
|
+
// see notice in conversions.js; don't use box types
|
1422
|
+
// in conversion functions.
|
1423
|
+
if (typeof result === 'object') {
|
1424
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
1425
|
+
result[i] = Math.round(result[i]);
|
1426
|
+
}
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
return result;
|
1430
|
+
};
|
1431
|
+
|
1432
|
+
// Preserve .conversion property if there is one
|
1433
|
+
if ('conversion' in fn) {
|
1434
|
+
wrappedFn.conversion = fn.conversion;
|
1435
|
+
}
|
1436
|
+
|
1437
|
+
return wrappedFn;
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
models.forEach(fromModel => {
|
1441
|
+
convert[fromModel] = {};
|
1442
|
+
|
1443
|
+
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
1444
|
+
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
1445
|
+
|
1446
|
+
const routes = route(fromModel);
|
1447
|
+
const routeModels = Object.keys(routes);
|
1448
|
+
|
1449
|
+
routeModels.forEach(toModel => {
|
1450
|
+
const fn = routes[toModel];
|
1451
|
+
|
1452
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
1453
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
1454
|
+
});
|
1455
|
+
});
|
1456
|
+
|
1457
|
+
var colorConvert = convert;
|
1458
|
+
|
1459
|
+
const skippedModels = [
|
1460
|
+
// To be honest, I don't really feel like keyword belongs in color convert, but eh.
|
1461
|
+
'keyword',
|
1462
|
+
|
1463
|
+
// Gray conflicts with some method names, and has its own method defined.
|
1464
|
+
'gray',
|
1465
|
+
|
1466
|
+
// Shouldn't really be in color-convert either...
|
1467
|
+
'hex',
|
1468
|
+
];
|
1469
|
+
|
1470
|
+
const hashedModelKeys = {};
|
1471
|
+
for (const model of Object.keys(colorConvert)) {
|
1472
|
+
hashedModelKeys[[...colorConvert[model].labels].sort().join('')] = model;
|
1473
|
+
}
|
1474
|
+
|
1475
|
+
const limiters = {};
|
1476
|
+
|
1477
|
+
function Color(object, model) {
|
1478
|
+
if (!(this instanceof Color)) {
|
1479
|
+
return new Color(object, model);
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
if (model && model in skippedModels) {
|
1483
|
+
model = null;
|
1484
|
+
}
|
1485
|
+
|
1486
|
+
if (model && !(model in colorConvert)) {
|
1487
|
+
throw new Error('Unknown model: ' + model);
|
1488
|
+
}
|
1489
|
+
|
1490
|
+
let i;
|
1491
|
+
let channels;
|
1492
|
+
|
1493
|
+
if (object == null) { // eslint-disable-line no-eq-null,eqeqeq
|
1494
|
+
this.model = 'rgb';
|
1495
|
+
this.color = [0, 0, 0];
|
1496
|
+
this.valpha = 1;
|
1497
|
+
} else if (object instanceof Color) {
|
1498
|
+
this.model = object.model;
|
1499
|
+
this.color = [...object.color];
|
1500
|
+
this.valpha = object.valpha;
|
1501
|
+
} else if (typeof object === 'string') {
|
1502
|
+
const result = colorString.get(object);
|
1503
|
+
if (result === null) {
|
1504
|
+
throw new Error('Unable to parse color from string: ' + object);
|
1505
|
+
}
|
1506
|
+
|
1507
|
+
this.model = result.model;
|
1508
|
+
channels = colorConvert[this.model].channels;
|
1509
|
+
this.color = result.value.slice(0, channels);
|
1510
|
+
this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
|
1511
|
+
} else if (object.length > 0) {
|
1512
|
+
this.model = model || 'rgb';
|
1513
|
+
channels = colorConvert[this.model].channels;
|
1514
|
+
const newArray = Array.prototype.slice.call(object, 0, channels);
|
1515
|
+
this.color = zeroArray(newArray, channels);
|
1516
|
+
this.valpha = typeof object[channels] === 'number' ? object[channels] : 1;
|
1517
|
+
} else if (typeof object === 'number') {
|
1518
|
+
// This is always RGB - can be converted later on.
|
1519
|
+
this.model = 'rgb';
|
1520
|
+
this.color = [
|
1521
|
+
(object >> 16) & 0xFF,
|
1522
|
+
(object >> 8) & 0xFF,
|
1523
|
+
object & 0xFF,
|
1524
|
+
];
|
1525
|
+
this.valpha = 1;
|
1526
|
+
} else {
|
1527
|
+
this.valpha = 1;
|
1528
|
+
|
1529
|
+
const keys = Object.keys(object);
|
1530
|
+
if ('alpha' in object) {
|
1531
|
+
keys.splice(keys.indexOf('alpha'), 1);
|
1532
|
+
this.valpha = typeof object.alpha === 'number' ? object.alpha : 0;
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
const hashedKeys = keys.sort().join('');
|
1536
|
+
if (!(hashedKeys in hashedModelKeys)) {
|
1537
|
+
throw new Error('Unable to parse color from object: ' + JSON.stringify(object));
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
this.model = hashedModelKeys[hashedKeys];
|
1541
|
+
|
1542
|
+
const {labels} = colorConvert[this.model];
|
1543
|
+
const color = [];
|
1544
|
+
for (i = 0; i < labels.length; i++) {
|
1545
|
+
color.push(object[labels[i]]);
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
this.color = zeroArray(color);
|
1549
|
+
}
|
1550
|
+
|
1551
|
+
// Perform limitations (clamping, etc.)
|
1552
|
+
if (limiters[this.model]) {
|
1553
|
+
channels = colorConvert[this.model].channels;
|
1554
|
+
for (i = 0; i < channels; i++) {
|
1555
|
+
const limit = limiters[this.model][i];
|
1556
|
+
if (limit) {
|
1557
|
+
this.color[i] = limit(this.color[i]);
|
1558
|
+
}
|
1559
|
+
}
|
1560
|
+
}
|
1561
|
+
|
1562
|
+
this.valpha = Math.max(0, Math.min(1, this.valpha));
|
1563
|
+
|
1564
|
+
if (Object.freeze) {
|
1565
|
+
Object.freeze(this);
|
1566
|
+
}
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
Color.prototype = {
|
1570
|
+
toString() {
|
1571
|
+
return this.string();
|
1572
|
+
},
|
1573
|
+
|
1574
|
+
toJSON() {
|
1575
|
+
return this[this.model]();
|
1576
|
+
},
|
1577
|
+
|
1578
|
+
string(places) {
|
1579
|
+
let self = this.model in colorString.to ? this : this.rgb();
|
1580
|
+
self = self.round(typeof places === 'number' ? places : 1);
|
1581
|
+
const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
|
1582
|
+
return colorString.to[self.model](args);
|
1583
|
+
},
|
1584
|
+
|
1585
|
+
percentString(places) {
|
1586
|
+
const self = this.rgb().round(typeof places === 'number' ? places : 1);
|
1587
|
+
const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
|
1588
|
+
return colorString.to.rgb.percent(args);
|
1589
|
+
},
|
1590
|
+
|
1591
|
+
array() {
|
1592
|
+
return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
|
1593
|
+
},
|
1594
|
+
|
1595
|
+
object() {
|
1596
|
+
const result = {};
|
1597
|
+
const {channels} = colorConvert[this.model];
|
1598
|
+
const {labels} = colorConvert[this.model];
|
1599
|
+
|
1600
|
+
for (let i = 0; i < channels; i++) {
|
1601
|
+
result[labels[i]] = this.color[i];
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
if (this.valpha !== 1) {
|
1605
|
+
result.alpha = this.valpha;
|
1606
|
+
}
|
1607
|
+
|
1608
|
+
return result;
|
1609
|
+
},
|
1610
|
+
|
1611
|
+
unitArray() {
|
1612
|
+
const rgb = this.rgb().color;
|
1613
|
+
rgb[0] /= 255;
|
1614
|
+
rgb[1] /= 255;
|
1615
|
+
rgb[2] /= 255;
|
1616
|
+
|
1617
|
+
if (this.valpha !== 1) {
|
1618
|
+
rgb.push(this.valpha);
|
1619
|
+
}
|
1620
|
+
|
1621
|
+
return rgb;
|
1622
|
+
},
|
1623
|
+
|
1624
|
+
unitObject() {
|
1625
|
+
const rgb = this.rgb().object();
|
1626
|
+
rgb.r /= 255;
|
1627
|
+
rgb.g /= 255;
|
1628
|
+
rgb.b /= 255;
|
1629
|
+
|
1630
|
+
if (this.valpha !== 1) {
|
1631
|
+
rgb.alpha = this.valpha;
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
return rgb;
|
1635
|
+
},
|
1636
|
+
|
1637
|
+
round(places) {
|
1638
|
+
places = Math.max(places || 0, 0);
|
1639
|
+
return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
|
1640
|
+
},
|
1641
|
+
|
1642
|
+
alpha(value) {
|
1643
|
+
if (value !== undefined) {
|
1644
|
+
return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);
|
1645
|
+
}
|
1646
|
+
|
1647
|
+
return this.valpha;
|
1648
|
+
},
|
1649
|
+
|
1650
|
+
// Rgb
|
1651
|
+
red: getset('rgb', 0, maxfn(255)),
|
1652
|
+
green: getset('rgb', 1, maxfn(255)),
|
1653
|
+
blue: getset('rgb', 2, maxfn(255)),
|
1654
|
+
|
1655
|
+
hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, value => ((value % 360) + 360) % 360),
|
1656
|
+
|
1657
|
+
saturationl: getset('hsl', 1, maxfn(100)),
|
1658
|
+
lightness: getset('hsl', 2, maxfn(100)),
|
1659
|
+
|
1660
|
+
saturationv: getset('hsv', 1, maxfn(100)),
|
1661
|
+
value: getset('hsv', 2, maxfn(100)),
|
1662
|
+
|
1663
|
+
chroma: getset('hcg', 1, maxfn(100)),
|
1664
|
+
gray: getset('hcg', 2, maxfn(100)),
|
1665
|
+
|
1666
|
+
white: getset('hwb', 1, maxfn(100)),
|
1667
|
+
wblack: getset('hwb', 2, maxfn(100)),
|
1668
|
+
|
1669
|
+
cyan: getset('cmyk', 0, maxfn(100)),
|
1670
|
+
magenta: getset('cmyk', 1, maxfn(100)),
|
1671
|
+
yellow: getset('cmyk', 2, maxfn(100)),
|
1672
|
+
black: getset('cmyk', 3, maxfn(100)),
|
1673
|
+
|
1674
|
+
x: getset('xyz', 0, maxfn(95.047)),
|
1675
|
+
y: getset('xyz', 1, maxfn(100)),
|
1676
|
+
z: getset('xyz', 2, maxfn(108.833)),
|
1677
|
+
|
1678
|
+
l: getset('lab', 0, maxfn(100)),
|
1679
|
+
a: getset('lab', 1),
|
1680
|
+
b: getset('lab', 2),
|
1681
|
+
|
1682
|
+
keyword(value) {
|
1683
|
+
if (value !== undefined) {
|
1684
|
+
return new Color(value);
|
1685
|
+
}
|
1686
|
+
|
1687
|
+
return colorConvert[this.model].keyword(this.color);
|
1688
|
+
},
|
1689
|
+
|
1690
|
+
hex(value) {
|
1691
|
+
if (value !== undefined) {
|
1692
|
+
return new Color(value);
|
1693
|
+
}
|
1694
|
+
|
1695
|
+
return colorString.to.hex(this.rgb().round().color);
|
1696
|
+
},
|
1697
|
+
|
1698
|
+
hexa(value) {
|
1699
|
+
if (value !== undefined) {
|
1700
|
+
return new Color(value);
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
const rgbArray = this.rgb().round().color;
|
1704
|
+
|
1705
|
+
let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
|
1706
|
+
if (alphaHex.length === 1) {
|
1707
|
+
alphaHex = '0' + alphaHex;
|
1708
|
+
}
|
1709
|
+
|
1710
|
+
return colorString.to.hex(rgbArray) + alphaHex;
|
1711
|
+
},
|
1712
|
+
|
1713
|
+
rgbNumber() {
|
1714
|
+
const rgb = this.rgb().color;
|
1715
|
+
return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
|
1716
|
+
},
|
1717
|
+
|
1718
|
+
luminosity() {
|
1719
|
+
// http://www.w3.org/TR/WCAG20/#relativeluminancedef
|
1720
|
+
const rgb = this.rgb().color;
|
1721
|
+
|
1722
|
+
const lum = [];
|
1723
|
+
for (const [i, element] of rgb.entries()) {
|
1724
|
+
const chan = element / 255;
|
1725
|
+
lum[i] = (chan <= 0.04045) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
|
1726
|
+
}
|
1727
|
+
|
1728
|
+
return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
|
1729
|
+
},
|
1730
|
+
|
1731
|
+
contrast(color2) {
|
1732
|
+
// http://www.w3.org/TR/WCAG20/#contrast-ratiodef
|
1733
|
+
const lum1 = this.luminosity();
|
1734
|
+
const lum2 = color2.luminosity();
|
1735
|
+
|
1736
|
+
if (lum1 > lum2) {
|
1737
|
+
return (lum1 + 0.05) / (lum2 + 0.05);
|
1738
|
+
}
|
1739
|
+
|
1740
|
+
return (lum2 + 0.05) / (lum1 + 0.05);
|
1741
|
+
},
|
1742
|
+
|
1743
|
+
level(color2) {
|
1744
|
+
// https://www.w3.org/TR/WCAG/#contrast-enhanced
|
1745
|
+
const contrastRatio = this.contrast(color2);
|
1746
|
+
if (contrastRatio >= 7) {
|
1747
|
+
return 'AAA';
|
1748
|
+
}
|
1749
|
+
|
1750
|
+
return (contrastRatio >= 4.5) ? 'AA' : '';
|
1751
|
+
},
|
1752
|
+
|
1753
|
+
isDark() {
|
1754
|
+
// YIQ equation from http://24ways.org/2010/calculating-color-contrast
|
1755
|
+
const rgb = this.rgb().color;
|
1756
|
+
const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 10000;
|
1757
|
+
return yiq < 128;
|
1758
|
+
},
|
1759
|
+
|
1760
|
+
isLight() {
|
1761
|
+
return !this.isDark();
|
1762
|
+
},
|
1763
|
+
|
1764
|
+
negate() {
|
1765
|
+
const rgb = this.rgb();
|
1766
|
+
for (let i = 0; i < 3; i++) {
|
1767
|
+
rgb.color[i] = 255 - rgb.color[i];
|
1768
|
+
}
|
1769
|
+
|
1770
|
+
return rgb;
|
1771
|
+
},
|
1772
|
+
|
1773
|
+
lighten(ratio) {
|
1774
|
+
const hsl = this.hsl();
|
1775
|
+
hsl.color[2] += hsl.color[2] * ratio;
|
1776
|
+
return hsl;
|
1777
|
+
},
|
1778
|
+
|
1779
|
+
darken(ratio) {
|
1780
|
+
const hsl = this.hsl();
|
1781
|
+
hsl.color[2] -= hsl.color[2] * ratio;
|
1782
|
+
return hsl;
|
1783
|
+
},
|
1784
|
+
|
1785
|
+
saturate(ratio) {
|
1786
|
+
const hsl = this.hsl();
|
1787
|
+
hsl.color[1] += hsl.color[1] * ratio;
|
1788
|
+
return hsl;
|
1789
|
+
},
|
1790
|
+
|
1791
|
+
desaturate(ratio) {
|
1792
|
+
const hsl = this.hsl();
|
1793
|
+
hsl.color[1] -= hsl.color[1] * ratio;
|
1794
|
+
return hsl;
|
1795
|
+
},
|
1796
|
+
|
1797
|
+
whiten(ratio) {
|
1798
|
+
const hwb = this.hwb();
|
1799
|
+
hwb.color[1] += hwb.color[1] * ratio;
|
1800
|
+
return hwb;
|
1801
|
+
},
|
1802
|
+
|
1803
|
+
blacken(ratio) {
|
1804
|
+
const hwb = this.hwb();
|
1805
|
+
hwb.color[2] += hwb.color[2] * ratio;
|
1806
|
+
return hwb;
|
1807
|
+
},
|
1808
|
+
|
1809
|
+
grayscale() {
|
1810
|
+
// http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
|
1811
|
+
const rgb = this.rgb().color;
|
1812
|
+
const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
|
1813
|
+
return Color.rgb(value, value, value);
|
1814
|
+
},
|
1815
|
+
|
1816
|
+
fade(ratio) {
|
1817
|
+
return this.alpha(this.valpha - (this.valpha * ratio));
|
1818
|
+
},
|
1819
|
+
|
1820
|
+
opaquer(ratio) {
|
1821
|
+
return this.alpha(this.valpha + (this.valpha * ratio));
|
1822
|
+
},
|
1823
|
+
|
1824
|
+
rotate(degrees) {
|
1825
|
+
const hsl = this.hsl();
|
1826
|
+
let hue = hsl.color[0];
|
1827
|
+
hue = (hue + degrees) % 360;
|
1828
|
+
hue = hue < 0 ? 360 + hue : hue;
|
1829
|
+
hsl.color[0] = hue;
|
1830
|
+
return hsl;
|
1831
|
+
},
|
1832
|
+
|
1833
|
+
mix(mixinColor, weight) {
|
1834
|
+
// Ported from sass implementation in C
|
1835
|
+
// https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
|
1836
|
+
if (!mixinColor || !mixinColor.rgb) {
|
1837
|
+
throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
const color1 = mixinColor.rgb();
|
1841
|
+
const color2 = this.rgb();
|
1842
|
+
const p = weight === undefined ? 0.5 : weight;
|
1843
|
+
|
1844
|
+
const w = 2 * p - 1;
|
1845
|
+
const a = color1.alpha() - color2.alpha();
|
1846
|
+
|
1847
|
+
const w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2;
|
1848
|
+
const w2 = 1 - w1;
|
1849
|
+
|
1850
|
+
return Color.rgb(
|
1851
|
+
w1 * color1.red() + w2 * color2.red(),
|
1852
|
+
w1 * color1.green() + w2 * color2.green(),
|
1853
|
+
w1 * color1.blue() + w2 * color2.blue(),
|
1854
|
+
color1.alpha() * p + color2.alpha() * (1 - p));
|
1855
|
+
},
|
1856
|
+
};
|
1857
|
+
|
1858
|
+
// Model conversion methods and static constructors
|
1859
|
+
for (const model of Object.keys(colorConvert)) {
|
1860
|
+
if (skippedModels.includes(model)) {
|
1861
|
+
continue;
|
1862
|
+
}
|
1863
|
+
|
1864
|
+
const {channels} = colorConvert[model];
|
1865
|
+
|
1866
|
+
// Conversion methods
|
1867
|
+
Color.prototype[model] = function (...args) {
|
1868
|
+
if (this.model === model) {
|
1869
|
+
return new Color(this);
|
1870
|
+
}
|
1871
|
+
|
1872
|
+
if (args.length > 0) {
|
1873
|
+
return new Color(args, model);
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
return new Color([...assertArray(colorConvert[this.model][model].raw(this.color)), this.valpha], model);
|
1877
|
+
};
|
1878
|
+
|
1879
|
+
// 'static' construction methods
|
1880
|
+
Color[model] = function (...args) {
|
1881
|
+
let color = args[0];
|
1882
|
+
if (typeof color === 'number') {
|
1883
|
+
color = zeroArray(args, channels);
|
1884
|
+
}
|
1885
|
+
|
1886
|
+
return new Color(color, model);
|
1887
|
+
};
|
1888
|
+
}
|
1889
|
+
|
1890
|
+
function roundTo(number, places) {
|
1891
|
+
return Number(number.toFixed(places));
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
function roundToPlace(places) {
|
1895
|
+
return function (number) {
|
1896
|
+
return roundTo(number, places);
|
1897
|
+
};
|
1898
|
+
}
|
1899
|
+
|
1900
|
+
function getset(model, channel, modifier) {
|
1901
|
+
model = Array.isArray(model) ? model : [model];
|
1902
|
+
|
1903
|
+
for (const m of model) {
|
1904
|
+
(limiters[m] || (limiters[m] = []))[channel] = modifier;
|
1905
|
+
}
|
1906
|
+
|
1907
|
+
model = model[0];
|
1908
|
+
|
1909
|
+
return function (value) {
|
1910
|
+
let result;
|
1911
|
+
|
1912
|
+
if (value !== undefined) {
|
1913
|
+
if (modifier) {
|
1914
|
+
value = modifier(value);
|
1915
|
+
}
|
1916
|
+
|
1917
|
+
result = this[model]();
|
1918
|
+
result.color[channel] = value;
|
1919
|
+
return result;
|
1920
|
+
}
|
1921
|
+
|
1922
|
+
result = this[model]().color[channel];
|
1923
|
+
if (modifier) {
|
1924
|
+
result = modifier(result);
|
1925
|
+
}
|
1926
|
+
|
1927
|
+
return result;
|
1928
|
+
};
|
1929
|
+
}
|
1930
|
+
|
1931
|
+
function maxfn(max) {
|
1932
|
+
return function (v) {
|
1933
|
+
return Math.max(0, Math.min(max, v));
|
1934
|
+
};
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
function assertArray(value) {
|
1938
|
+
return Array.isArray(value) ? value : [value];
|
1939
|
+
}
|
1940
|
+
|
1941
|
+
function zeroArray(array, length) {
|
1942
|
+
for (let i = 0; i < length; i++) {
|
1943
|
+
if (typeof array[i] !== 'number') {
|
1944
|
+
array[i] = 0;
|
1945
|
+
}
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
return array;
|
1949
|
+
}
|
1950
|
+
|
1951
|
+
var color = Color;
|
1952
|
+
|
1953
|
+
export { color as c };
|