var __awaiter=this&&this.__awaiter||function(e,r,t,a){function n(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,o){function i(e){try{s(a.next(e))}catch(r){o(r)}}function l(e){try{s(a["throw"](e))}catch(r){o(r)}}function s(e){e.done?t(e.value):n(e.value).then(i,l)}s((a=a.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a,n,o,i;return i={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(e){return function(r){return s([e,r])}}function s(i){if(a)throw new TypeError("Generator is already executing.");while(t)try{if(a=1,n&&(o=i[0]&2?n["return"]:i[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;if(n=0,o)i=[i[0]&2,o.value];switch(i[0]){case 0:case 1:o=i;break;case 4:t.label++;return{value:i[1],done:false};case 5:t.label++;n=i[1];i=[0];continue;case 7:i=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){t.label=i[1];break}if(i[0]===6&&t.label<o[1]){t.label=o[1];o=i;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(i);break}if(o[2])t.ops.pop();t.trys.pop();continue}i=r.call(e,t)}catch(l){i=[6,l];n=0}finally{a=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var __spreadArrays=this&&this.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;for(var a=Array(e),n=0,r=0;r<t;r++)for(var o=arguments[r],i=0,l=o.length;i<l;i++,n++)a[n]=o[i];return a};import{r as registerInstance,c as createEvent,h,g as getElement,H as Host}from"./index-8fd57462.js";import{f as focusElement,g as getElementDir}from"./dom-d9ba1da4.js";import{n as normalizeHex,C as CSSColorMode,p as parseMode,c as colorEqual,i as isValidHex,a as isLonghandHex,r as rgbToHex,h as hexToRGB,b as hexChar}from"./utils-f2b09093.js";import{g as getKey}from"./key-477fdfc4.js";import{d as debounce,i as isObject}from"./debounce-4dee3b1c.js";var FUNC_ERROR_TEXT="Expected a function";function throttle(e,r,t){var a=true,n=true;if(typeof e!="function"){throw new TypeError(FUNC_ERROR_TEXT)}if(isObject(t)){a="leading"in t?!!t.leading:a;n="trailing"in t?!!t.trailing:n}return debounce(e,r,{leading:a,maxWait:r,trailing:n})}function createCommonjsModule(e,r,t){return t={path:r,exports:{},require:function(e,r){return commonjsRequire()}},e(t,t.exports),t.exports}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var colorName={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]};var isArrayish=function e(r){if(!r||typeof r==="string"){return false}return r instanceof Array||Array.isArray(r)||r.length>=0&&(r.splice instanceof Function||Object.getOwnPropertyDescriptor(r,r.length-1)&&r.constructor.name!=="String")};var simpleSwizzle=createCommonjsModule((function(e){var r=Array.prototype.concat;var t=Array.prototype.slice;var a=e.exports=function e(a){var n=[];for(var o=0,i=a.length;o<i;o++){var l=a[o];if(isArrayish(l)){n=r.call(n,t.call(l))}else{n.push(l)}}return n};a.wrap=function(e){return function(){return e(a(arguments))}}}));var colorString=createCommonjsModule((function(e){var r={};for(var t in colorName){if(colorName.hasOwnProperty(t)){r[colorName[t]]=t}}var a=e.exports={to:{},get:{}};a.get=function(e){var r=e.substring(0,3).toLowerCase();var t;var n;switch(r){case"hsl":t=a.get.hsl(e);n="hsl";break;case"hwb":t=a.get.hwb(e);n="hwb";break;default:t=a.get.rgb(e);n="rgb";break}if(!t){return null}return{model:n,value:t}};a.get.rgb=function(e){if(!e){return null}var r=/^#([a-f0-9]{3,4})$/i;var t=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i;var a=/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;var o=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;var i=/(\D+)/;var l=[0,0,0,1];var s;var c;var h;if(s=e.match(t)){h=s[2];s=s[1];for(c=0;c<3;c++){var u=c*2;l[c]=parseInt(s.slice(u,u+2),16)}if(h){l[3]=parseInt(h,16)/255}}else if(s=e.match(r)){s=s[1];h=s[3];for(c=0;c<3;c++){l[c]=parseInt(s[c]+s[c],16)}if(h){l[3]=parseInt(h+h,16)/255}}else if(s=e.match(a)){for(c=0;c<3;c++){l[c]=parseInt(s[c+1],0)}if(s[4]){l[3]=parseFloat(s[4])}}else if(s=e.match(o)){for(c=0;c<3;c++){l[c]=Math.round(parseFloat(s[c+1])*2.55)}if(s[4]){l[3]=parseFloat(s[4])}}else if(s=e.match(i)){if(s[1]==="transparent"){return[0,0,0,0]}l=colorName[s[1]];if(!l){return null}l[3]=1;return l}else{return null}for(c=0;c<3;c++){l[c]=n(l[c],0,255)}l[3]=n(l[3],0,1);return l};a.get.hsl=function(e){if(!e){return null}var r=/^hsla?\(\s*([+-]?(?:\d*\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;var t=e.match(r);if(t){var a=parseFloat(t[4]);var o=(parseFloat(t[1])+360)%360;var i=n(parseFloat(t[2]),0,100);var l=n(parseFloat(t[3]),0,100);var s=n(isNaN(a)?1:a,0,1);return[o,i,l,s]}return null};a.get.hwb=function(e){if(!e){return null}var r=/^hwb\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;var t=e.match(r);if(t){var a=parseFloat(t[4]);var o=(parseFloat(t[1])%360+360)%360;var i=n(parseFloat(t[2]),0,100);var l=n(parseFloat(t[3]),0,100);var s=n(isNaN(a)?1:a,0,1);return[o,i,l,s]}return null};a.to.hex=function(){var e=simpleSwizzle(arguments);return"#"+o(e[0])+o(e[1])+o(e[2])+(e[3]<1?o(Math.round(e[3]*255)):"")};a.to.rgb=function(){var e=simpleSwizzle(arguments);return e.length<4||e[3]===1?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"};a.to.rgb.percent=function(){var e=simpleSwizzle(arguments);var r=Math.round(e[0]/255*100);var t=Math.round(e[1]/255*100);var a=Math.round(e[2]/255*100);return e.length<4||e[3]===1?"rgb("+r+"%, "+t+"%, "+a+"%)":"rgba("+r+"%, "+t+"%, "+a+"%, "+e[3]+")"};a.to.hsl=function(){var e=simpleSwizzle(arguments);return e.length<4||e[3]===1?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"};a.to.hwb=function(){var e=simpleSwizzle(arguments);var r="";if(e.length>=4&&e[3]!==1){r=", "+e[3]}return"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+r+")"};a.to.keyword=function(e){return r[e.slice(0,3)]};function n(e,r,t){return Math.min(Math.max(r,e),t)}function o(e){var r=e.toString(16).toUpperCase();return r.length<2?"0"+r:r}}));var conversions=createCommonjsModule((function(e){var r={};for(var t in colorName){if(colorName.hasOwnProperty(t)){r[colorName[t]]=t}}var a=e.exports={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"]}};for(var n in a){if(a.hasOwnProperty(n)){if(!("channels"in a[n])){throw new Error("missing channels property: "+n)}if(!("labels"in a[n])){throw new Error("missing channel labels property: "+n)}if(a[n].labels.length!==a[n].channels){throw new Error("channel and label counts mismatch: "+n)}var o=a[n].channels;var i=a[n].labels;delete a[n].channels;delete a[n].labels;Object.defineProperty(a[n],"channels",{value:o});Object.defineProperty(a[n],"labels",{value:i})}}a.rgb.hsl=function(e){var r=e[0]/255;var t=e[1]/255;var a=e[2]/255;var n=Math.min(r,t,a);var o=Math.max(r,t,a);var i=o-n;var l;var s;var c;if(o===n){l=0}else if(r===o){l=(t-a)/i}else if(t===o){l=2+(a-r)/i}else if(a===o){l=4+(r-t)/i}l=Math.min(l*60,360);if(l<0){l+=360}c=(n+o)/2;if(o===n){s=0}else if(c<=.5){s=i/(o+n)}else{s=i/(2-o-n)}return[l,s*100,c*100]};a.rgb.hsv=function(e){var r;var t;var a;var n;var o;var i=e[0]/255;var l=e[1]/255;var s=e[2]/255;var c=Math.max(i,l,s);var h=c-Math.min(i,l,s);var u=function(e){return(c-e)/6/h+1/2};if(h===0){n=o=0}else{o=h/c;r=u(i);t=u(l);a=u(s);if(i===c){n=a-t}else if(l===c){n=1/3+r-a}else if(s===c){n=2/3+t-r}if(n<0){n+=1}else if(n>1){n-=1}}return[n*360,o*100,c*100]};a.rgb.hwb=function(e){var r=e[0];var t=e[1];var n=e[2];var o=a.rgb.hsl(e)[0];var i=1/255*Math.min(r,Math.min(t,n));n=1-1/255*Math.max(r,Math.max(t,n));return[o,i*100,n*100]};a.rgb.cmyk=function(e){var r=e[0]/255;var t=e[1]/255;var a=e[2]/255;var n;var o;var i;var l;l=Math.min(1-r,1-t,1-a);n=(1-r-l)/(1-l)||0;o=(1-t-l)/(1-l)||0;i=(1-a-l)/(1-l)||0;return[n*100,o*100,i*100,l*100]};function l(e,r){return Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2)+Math.pow(e[2]-r[2],2)}a.rgb.keyword=function(e){var t=r[e];if(t){return t}var a=Infinity;var n;for(var o in colorName){if(colorName.hasOwnProperty(o)){var i=colorName[o];var s=l(e,i);if(s<a){a=s;n=o}}}return n};a.keyword.rgb=function(e){return colorName[e]};a.rgb.xyz=function(e){var r=e[0]/255;var t=e[1]/255;var a=e[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92;t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92;a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var n=r*.4124+t*.3576+a*.1805;var o=r*.2126+t*.7152+a*.0722;var i=r*.0193+t*.1192+a*.9505;return[n*100,o*100,i*100]};a.rgb.lab=function(e){var r=a.rgb.xyz(e);var t=r[0];var n=r[1];var o=r[2];var i;var l;var s;t/=95.047;n/=100;o/=108.883;t=t>.008856?Math.pow(t,1/3):7.787*t+16/116;n=n>.008856?Math.pow(n,1/3):7.787*n+16/116;o=o>.008856?Math.pow(o,1/3):7.787*o+16/116;i=116*n-16;l=500*(t-n);s=200*(n-o);return[i,l,s]};a.hsl.rgb=function(e){var r=e[0]/360;var t=e[1]/100;var a=e[2]/100;var n;var o;var i;var l;var s;if(t===0){s=a*255;return[s,s,s]}if(a<.5){o=a*(1+t)}else{o=a+t-a*t}n=2*a-o;l=[0,0,0];for(var c=0;c<3;c++){i=r+1/3*-(c-1);if(i<0){i++}if(i>1){i--}if(6*i<1){s=n+(o-n)*6*i}else if(2*i<1){s=o}else if(3*i<2){s=n+(o-n)*(2/3-i)*6}else{s=n}l[c]=s*255}return l};a.hsl.hsv=function(e){var r=e[0];var t=e[1]/100;var a=e[2]/100;var n=t;var o=Math.max(a,.01);var i;var l;a*=2;t*=a<=1?a:2-a;n*=o<=1?o:2-o;l=(a+t)/2;i=a===0?2*n/(o+n):2*t/(a+t);return[r,i*100,l*100]};a.hsv.rgb=function(e){var r=e[0]/60;var t=e[1]/100;var a=e[2]/100;var n=Math.floor(r)%6;var o=r-Math.floor(r);var i=255*a*(1-t);var l=255*a*(1-t*o);var s=255*a*(1-t*(1-o));a*=255;switch(n){case 0:return[a,s,i];case 1:return[l,a,i];case 2:return[i,a,s];case 3:return[i,l,a];case 4:return[s,i,a];case 5:return[a,i,l]}};a.hsv.hsl=function(e){var r=e[0];var t=e[1]/100;var a=e[2]/100;var n=Math.max(a,.01);var o;var i;var l;l=(2-t)*a;o=(2-t)*n;i=t*n;i/=o<=1?o:2-o;i=i||0;l/=2;return[r,i*100,l*100]};a.hwb.rgb=function(e){var r=e[0]/360;var t=e[1]/100;var a=e[2]/100;var n=t+a;var o;var i;var l;var s;if(n>1){t/=n;a/=n}o=Math.floor(6*r);i=1-a;l=6*r-o;if((o&1)!==0){l=1-l}s=t+l*(i-t);var c;var h;var u;switch(o){default:case 6:case 0:c=i;h=s;u=t;break;case 1:c=s;h=i;u=t;break;case 2:c=t;h=i;u=s;break;case 3:c=t;h=s;u=i;break;case 4:c=s;h=t;u=i;break;case 5:c=i;h=t;u=s;break}return[c*255,h*255,u*255]};a.cmyk.rgb=function(e){var r=e[0]/100;var t=e[1]/100;var a=e[2]/100;var n=e[3]/100;var o;var i;var l;o=1-Math.min(1,r*(1-n)+n);i=1-Math.min(1,t*(1-n)+n);l=1-Math.min(1,a*(1-n)+n);return[o*255,i*255,l*255]};a.xyz.rgb=function(e){var r=e[0]/100;var t=e[1]/100;var a=e[2]/100;var n;var o;var i;n=r*3.2406+t*-1.5372+a*-.4986;o=r*-.9689+t*1.8758+a*.0415;i=r*.0557+t*-.204+a*1.057;n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n*12.92;o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o*12.92;i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*12.92;n=Math.min(Math.max(0,n),1);o=Math.min(Math.max(0,o),1);i=Math.min(Math.max(0,i),1);return[n*255,o*255,i*255]};a.xyz.lab=function(e){var r=e[0];var t=e[1];var a=e[2];var n;var o;var i;r/=95.047;t/=100;a/=108.883;r=r>.008856?Math.pow(r,1/3):7.787*r+16/116;t=t>.008856?Math.pow(t,1/3):7.787*t+16/116;a=a>.008856?Math.pow(a,1/3):7.787*a+16/116;n=116*t-16;o=500*(r-t);i=200*(t-a);return[n,o,i]};a.lab.xyz=function(e){var r=e[0];var t=e[1];var a=e[2];var n;var o;var i;o=(r+16)/116;n=t/500+o;i=o-a/200;var l=Math.pow(o,3);var s=Math.pow(n,3);var c=Math.pow(i,3);o=l>.008856?l:(o-16/116)/7.787;n=s>.008856?s:(n-16/116)/7.787;i=c>.008856?c:(i-16/116)/7.787;n*=95.047;o*=100;i*=108.883;return[n,o,i]};a.lab.lch=function(e){var r=e[0];var t=e[1];var a=e[2];var n;var o;var i;n=Math.atan2(a,t);o=n*360/2/Math.PI;if(o<0){o+=360}i=Math.sqrt(t*t+a*a);return[r,i,o]};a.lch.lab=function(e){var r=e[0];var t=e[1];var a=e[2];var n;var o;var i;i=a/360*2*Math.PI;n=t*Math.cos(i);o=t*Math.sin(i);return[r,n,o]};a.rgb.ansi16=function(e){var r=e[0];var t=e[1];var n=e[2];var o=1 in arguments?arguments[1]:a.rgb.hsv(e)[2];o=Math.round(o/50);if(o===0){return 30}var i=30+(Math.round(n/255)<<2|Math.round(t/255)<<1|Math.round(r/255));if(o===2){i+=60}return i};a.hsv.ansi16=function(e){return a.rgb.ansi16(a.hsv.rgb(e),e[2])};a.rgb.ansi256=function(e){var r=e[0];var t=e[1];var a=e[2];if(r===t&&t===a){if(r<8){return 16}if(r>248){return 231}return Math.round((r-8)/247*24)+232}var n=16+36*Math.round(r/255*5)+6*Math.round(t/255*5)+Math.round(a/255*5);return n};a.ansi16.rgb=function(e){var r=e%10;if(r===0||r===7){if(e>50){r+=3.5}r=r/10.5*255;return[r,r,r]}var t=(~~(e>50)+1)*.5;var a=(r&1)*t*255;var n=(r>>1&1)*t*255;var o=(r>>2&1)*t*255;return[a,n,o]};a.ansi256.rgb=function(e){if(e>=232){var r=(e-232)*10+8;return[r,r,r]}e-=16;var t;var a=Math.floor(e/36)/5*255;var n=Math.floor((t=e%36)/6)/5*255;var o=t%6/5*255;return[a,n,o]};a.rgb.hex=function(e){var r=((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255);var t=r.toString(16).toUpperCase();return"000000".substring(t.length)+t};a.hex.rgb=function(e){var r=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!r){return[0,0,0]}var t=r[0];if(r[0].length===3){t=t.split("").map((function(e){return e+e})).join("")}var a=parseInt(t,16);var n=a>>16&255;var o=a>>8&255;var i=a&255;return[n,o,i]};a.rgb.hcg=function(e){var r=e[0]/255;var t=e[1]/255;var a=e[2]/255;var n=Math.max(Math.max(r,t),a);var o=Math.min(Math.min(r,t),a);var i=n-o;var l;var s;if(i<1){l=o/(1-i)}else{l=0}if(i<=0){s=0}else if(n===r){s=(t-a)/i%6}else if(n===t){s=2+(a-r)/i}else{s=4+(r-t)/i+4}s/=6;s%=1;return[s*360,i*100,l*100]};a.hsl.hcg=function(e){var r=e[1]/100;var t=e[2]/100;var a=1;var n=0;if(t<.5){a=2*r*t}else{a=2*r*(1-t)}if(a<1){n=(t-.5*a)/(1-a)}return[e[0],a*100,n*100]};a.hsv.hcg=function(e){var r=e[1]/100;var t=e[2]/100;var a=r*t;var n=0;if(a<1){n=(t-a)/(1-a)}return[e[0],a*100,n*100]};a.hcg.rgb=function(e){var r=e[0]/360;var t=e[1]/100;var a=e[2]/100;if(t===0){return[a*255,a*255,a*255]}var n=[0,0,0];var o=r%1*6;var i=o%1;var l=1-i;var s=0;switch(Math.floor(o)){case 0:n[0]=1;n[1]=i;n[2]=0;break;case 1:n[0]=l;n[1]=1;n[2]=0;break;case 2:n[0]=0;n[1]=1;n[2]=i;break;case 3:n[0]=0;n[1]=l;n[2]=1;break;case 4:n[0]=i;n[1]=0;n[2]=1;break;default:n[0]=1;n[1]=0;n[2]=l}s=(1-t)*a;return[(t*n[0]+s)*255,(t*n[1]+s)*255,(t*n[2]+s)*255]};a.hcg.hsv=function(e){var r=e[1]/100;var t=e[2]/100;var a=r+t*(1-r);var n=0;if(a>0){n=r/a}return[e[0],n*100,a*100]};a.hcg.hsl=function(e){var r=e[1]/100;var t=e[2]/100;var a=t*(1-r)+.5*r;var n=0;if(a>0&&a<.5){n=r/(2*a)}else if(a>=.5&&a<1){n=r/(2*(1-a))}return[e[0],n*100,a*100]};a.hcg.hwb=function(e){var r=e[1]/100;var t=e[2]/100;var a=r+t*(1-r);return[e[0],(a-r)*100,(1-a)*100]};a.hwb.hcg=function(e){var r=e[1]/100;var t=e[2]/100;var a=1-t;var n=a-r;var o=0;if(n<1){o=(a-n)/(1-n)}return[e[0],n*100,o*100]};a.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};a.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};a.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};a.gray.hsl=a.gray.hsv=function(e){return[0,0,e[0]]};a.gray.hwb=function(e){return[0,100,e[0]]};a.gray.cmyk=function(e){return[0,0,0,e[0]]};a.gray.lab=function(e){return[e[0],0,0]};a.gray.hex=function(e){var r=Math.round(e[0]/100*255)&255;var t=(r<<16)+(r<<8)+r;var a=t.toString(16).toUpperCase();return"000000".substring(a.length)+a};a.rgb.gray=function(e){var r=(e[0]+e[1]+e[2])/3;return[r/255*100]}}));function buildGraph(){var e={};var r=Object.keys(conversions);for(var t=r.length,a=0;a<t;a++){e[r[a]]={distance:-1,parent:null}}return e}function deriveBFS(e){var r=buildGraph();var t=[e];r[e].distance=0;while(t.length){var a=t.pop();var n=Object.keys(conversions[a]);for(var o=n.length,i=0;i<o;i++){var l=n[i];var s=r[l];if(s.distance===-1){s.distance=r[a].distance+1;s.parent=a;t.unshift(l)}}}return r}function link(e,r){return function(t){return r(e(t))}}function wrapConversion(e,r){var t=[r[e].parent,e];var a=conversions[r[e].parent][e];var n=r[e].parent;while(r[n].parent){t.unshift(r[n].parent);a=link(conversions[r[n].parent][n],a);n=r[n].parent}a.conversion=t;return a}var route=function(e){var r=deriveBFS(e);var t={};var a=Object.keys(r);for(var n=a.length,o=0;o<n;o++){var i=a[o];var l=r[i];if(l.parent===null){continue}t[i]=wrapConversion(i,r)}return t};var convert={};var models=Object.keys(conversions);function wrapRaw(e){var r=function(r){if(r===undefined||r===null){return r}if(arguments.length>1){r=Array.prototype.slice.call(arguments)}return e(r)};if("conversion"in e){r.conversion=e.conversion}return r}function wrapRounded(e){var r=function(r){if(r===undefined||r===null){return r}if(arguments.length>1){r=Array.prototype.slice.call(arguments)}var t=e(r);if(typeof t==="object"){for(var a=t.length,n=0;n<a;n++){t[n]=Math.round(t[n])}}return t};if("conversion"in e){r.conversion=e.conversion}return r}models.forEach((function(e){convert[e]={};Object.defineProperty(convert[e],"channels",{value:conversions[e].channels});Object.defineProperty(convert[e],"labels",{value:conversions[e].labels});var r=route(e);var t=Object.keys(r);t.forEach((function(t){var a=r[t];convert[e][t]=wrapRounded(a);convert[e][t].raw=wrapRaw(a)}))}));var colorConvert=convert;var _slice=[].slice;var skippedModels=["keyword","gray","hex"];var hashedModelKeys={};Object.keys(colorConvert).forEach((function(e){hashedModelKeys[_slice.call(colorConvert[e].labels).sort().join("")]=e}));var limiters={};function Color(e,r){if(!(this instanceof Color)){return new Color(e,r)}if(r&&r in skippedModels){r=null}if(r&&!(r in colorConvert)){throw new Error("Unknown model: "+r)}var t;var a;if(e==null){this.model="rgb";this.color=[0,0,0];this.valpha=1}else if(e instanceof Color){this.model=e.model;this.color=e.color.slice();this.valpha=e.valpha}else if(typeof e==="string"){var n=colorString.get(e);if(n===null){throw new Error("Unable to parse color from string: "+e)}this.model=n.model;a=colorConvert[this.model].channels;this.color=n.value.slice(0,a);this.valpha=typeof n.value[a]==="number"?n.value[a]:1}else if(e.length){this.model=r||"rgb";a=colorConvert[this.model].channels;var o=_slice.call(e,0,a);this.color=zeroArray(o,a);this.valpha=typeof e[a]==="number"?e[a]:1}else if(typeof e==="number"){e&=16777215;this.model="rgb";this.color=[e>>16&255,e>>8&255,e&255];this.valpha=1}else{this.valpha=1;var i=Object.keys(e);if("alpha"in e){i.splice(i.indexOf("alpha"),1);this.valpha=typeof e.alpha==="number"?e.alpha:0}var l=i.sort().join("");if(!(l in hashedModelKeys)){throw new Error("Unable to parse color from object: "+JSON.stringify(e))}this.model=hashedModelKeys[l];var s=colorConvert[this.model].labels;var c=[];for(t=0;t<s.length;t++){c.push(e[s[t]])}this.color=zeroArray(c)}if(limiters[this.model]){a=colorConvert[this.model].channels;for(t=0;t<a;t++){var h=limiters[this.model][t];if(h){this.color[t]=h(this.color[t])}}}this.valpha=Math.max(0,Math.min(1,this.valpha));if(Object.freeze){Object.freeze(this)}}Color.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(e){var r=this.model in colorString.to?this:this.rgb();r=r.round(typeof e==="number"?e:1);var t=r.valpha===1?r.color:r.color.concat(this.valpha);return colorString.to[r.model](t)},percentString:function(e){var r=this.rgb().round(typeof e==="number"?e:1);var t=r.valpha===1?r.color:r.color.concat(this.valpha);return colorString.to.rgb.percent(t)},array:function(){return this.valpha===1?this.color.slice():this.color.concat(this.valpha)},object:function(){var e={};var r=colorConvert[this.model].channels;var t=colorConvert[this.model].labels;for(var a=0;a<r;a++){e[t[a]]=this.color[a]}if(this.valpha!==1){e.alpha=this.valpha}return e},unitArray:function(){var e=this.rgb().color;e[0]/=255;e[1]/=255;e[2]/=255;if(this.valpha!==1){e.push(this.valpha)}return e},unitObject:function(){var e=this.rgb().object();e.r/=255;e.g/=255;e.b/=255;if(this.valpha!==1){e.alpha=this.valpha}return e},round:function(e){e=Math.max(e||0,0);return new Color(this.color.map(roundToPlace(e)).concat(this.valpha),this.model)},alpha:function(e){if(arguments.length){return new Color(this.color.concat(Math.max(0,Math.min(1,e))),this.model)}return this.valpha},red:getset("rgb",0,maxfn(255)),green:getset("rgb",1,maxfn(255)),blue:getset("rgb",2,maxfn(255)),hue:getset(["hsl","hsv","hsl","hwb","hcg"],0,(function(e){return(e%360+360)%360})),saturationl:getset("hsl",1,maxfn(100)),lightness:getset("hsl",2,maxfn(100)),saturationv:getset("hsv",1,maxfn(100)),value:getset("hsv",2,maxfn(100)),chroma:getset("hcg",1,maxfn(100)),gray:getset("hcg",2,maxfn(100)),white:getset("hwb",1,maxfn(100)),wblack:getset("hwb",2,maxfn(100)),cyan:getset("cmyk",0,maxfn(100)),magenta:getset("cmyk",1,maxfn(100)),yellow:getset("cmyk",2,maxfn(100)),black:getset("cmyk",3,maxfn(100)),x:getset("xyz",0,maxfn(100)),y:getset("xyz",1,maxfn(100)),z:getset("xyz",2,maxfn(100)),l:getset("lab",0,maxfn(100)),a:getset("lab",1),b:getset("lab",2),keyword:function(e){if(arguments.length){return new Color(e)}return colorConvert[this.model].keyword(this.color)},hex:function(e){if(arguments.length){return new Color(e)}return colorString.to.hex(this.rgb().round().color)},rgbNumber:function(){var e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity:function(){var e=this.rgb().color;var r=[];for(var t=0;t<e.length;t++){var a=e[t]/255;r[t]=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*r[0]+.7152*r[1]+.0722*r[2]},contrast:function(e){var r=this.luminosity();var t=e.luminosity();if(r>t){return(r+.05)/(t+.05)}return(t+.05)/(r+.05)},level:function(e){var r=this.contrast(e);if(r>=7.1){return"AAA"}return r>=4.5?"AA":""},isDark:function(){var e=this.rgb().color;var r=(e[0]*299+e[1]*587+e[2]*114)/1e3;return r<128},isLight:function(){return!this.isDark()},negate:function(){var e=this.rgb();for(var r=0;r<3;r++){e.color[r]=255-e.color[r]}return e},lighten:function(e){var r=this.hsl();r.color[2]+=r.color[2]*e;return r},darken:function(e){var r=this.hsl();r.color[2]-=r.color[2]*e;return r},saturate:function(e){var r=this.hsl();r.color[1]+=r.color[1]*e;return r},desaturate:function(e){var r=this.hsl();r.color[1]-=r.color[1]*e;return r},whiten:function(e){var r=this.hwb();r.color[1]+=r.color[1]*e;return r},blacken:function(e){var r=this.hwb();r.color[2]+=r.color[2]*e;return r},grayscale:function(){var e=this.rgb().color;var r=e[0]*.3+e[1]*.59+e[2]*.11;return Color.rgb(r,r,r)},fade:function(e){return this.alpha(this.valpha-this.valpha*e)},opaquer:function(e){return this.alpha(this.valpha+this.valpha*e)},rotate:function(e){var r=this.hsl();var t=r.color[0];t=(t+e)%360;t=t<0?360+t:t;r.color[0]=t;return r},mix:function(e,r){if(!e||!e.rgb){throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e)}var t=e.rgb();var a=this.rgb();var n=r===undefined?.5:r;var o=2*n-1;var i=t.alpha()-a.alpha();var l=((o*i===-1?o:(o+i)/(1+o*i))+1)/2;var s=1-l;return Color.rgb(l*t.red()+s*a.red(),l*t.green()+s*a.green(),l*t.blue()+s*a.blue(),t.alpha()*n+a.alpha()*(1-n))}};Object.keys(colorConvert).forEach((function(e){if(skippedModels.indexOf(e)!==-1){return}var r=colorConvert[e].channels;Color.prototype[e]=function(){if(this.model===e){return new Color(this)}if(arguments.length){return new Color(arguments,e)}var t=typeof arguments[r]==="number"?r:this.valpha;return new Color(assertArray(colorConvert[this.model][e].raw(this.color)).concat(t),e)};Color[e]=function(t){if(typeof t==="number"){t=zeroArray(_slice.call(arguments),r)}return new Color(t,e)}}));function roundTo(e,r){return Number(e.toFixed(r))}function roundToPlace(e){return function(r){return roundTo(r,e)}}function getset(e,r,t){e=Array.isArray(e)?e:[e];e.forEach((function(e){(limiters[e]||(limiters[e]=[]))[r]=t}));e=e[0];return function(a){var n;if(arguments.length){if(t){a=t(a)}n=this[e]();n.color[r]=a;return n}n=this[e]().color[r];if(t){n=t(n)}return n}}function maxfn(e){return function(r){return Math.max(0,Math.min(e,r))}}function assertArray(e){return Array.isArray(e)?e:[e]}function zeroArray(e,r){for(var t=0;t<r;t++){if(typeof e[t]!=="number"){e[t]=0}}return e}var color=Color;var CSS={container:"container",controlSection:"control-section",hexOptions:"color-hex-options",section:"section",header:"header",control:"control",splitSection:"section--split",underlinedHeader:"header--underlined",colorModeContainer:"color-mode-container",colorMode:"color-mode",channels:"channels",channel:"channel",savedColors:"saved-colors",savedColorsSection:"saved-colors-section",saveColor:"save-color",deleteColor:"delete-color",savedColorsButtons:"saved-colors-buttons",headerHex:"header--hex",colorFieldAndSlider:"color-field-and-slider",colorFieldAndSliderInteractive:"color-field-and-slider--interactive",savedColor:"saved-color"};var DEFAULT_COLOR=color("#007AC2");var DEFAULT_STORAGE_KEY_PREFIX="calcite-color-";var RGB_LIMITS={r:255,g:255,b:255};var HSV_LIMITS={h:360,s:100,v:100};var TEXT={b:"B",blue:"Blue",deleteColor:"Delete color",g:"G",green:"Green",h:"H",hsv:"HSV",hex:"Hex",hue:"Hue",r:"R",red:"Red",rgb:"RGB",s:"S",saturation:"Saturation",saveColor:"Save color",saved:"Saved",v:"V",value:"Value"};var DIMENSIONS={s:{slider:{height:10,width:156},colorField:{height:80,width:156},thumb:{radius:8}},m:{slider:{height:14,width:272},colorField:{height:150,width:272},thumb:{radius:10}},l:{slider:{height:16,width:420},colorField:{height:200,width:420},thumb:{radius:12}}};var calciteColorCss="@-webkit-keyframes calcite-fade-in{0%{opacity:0}100%{opacity:1}}@keyframes calcite-fade-in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes calcite-fade-in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes calcite-fade-in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes calcite-fade-in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes calcite-fade-in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes calcite-fade-in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes calcite-fade-in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-popper-transition:150ms ease-in-out}:host([hidden]){display:none}:host([scale=s]) .container{width:156px}:host([scale=s]) .saved-colors{grid-template-columns:repeat(auto-fill, minmax(20px, 1fr))}:host([scale=s]) .channels{-ms-flex-direction:column;flex-direction:column}:host([scale=s]) .channel{width:100%;margin-bottom:4px}:host([scale=s]) .channel:last-child{margin-bottom:0}:host([scale=m]) .container{width:272px}:host([scale=l][dir=rtl]) .control-section>:nth-child(2){margin-left:0;margin-right:12px}:host([scale=l]) .container{width:420px}:host([scale=l]) .color-field-and-slider{margin-bottom:-20px}:host([scale=l]) .section{padding:0 16px 16px}:host([scale=l]) .section:first-of-type{padding-top:16px}:host([scale=l]) .saved-colors{grid-template-columns:repeat(auto-fill, minmax(28px, 1fr));grid-gap:12px;padding-top:16px}:host([scale=l]) .control-section{-ms-flex-wrap:nowrap;flex-wrap:nowrap}:host([scale=l]) .control-section>:nth-child(2){margin-left:12px}:host([scale=l]) .color-hex-options{-ms-flex-negative:1;flex-shrink:1}:host([scale=l]) .color-mode-container{-ms-flex-negative:3;flex-shrink:3}:host([appearance=minimal]) .container{border:none}.container{display:inline-block;border:1px solid var(--calcite-ui-border-1);background-color:var(--calcite-ui-foreground-1)}.color-field-and-slider{margin-bottom:-16px}.color-field-and-slider--interactive{cursor:pointer}.control-section{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}.section{padding:0 12px 12px}.section:first-of-type{padding-top:12px}.color-hex-options,.section--split{-ms-flex-positive:1;flex-grow:1}.header{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;color:var(--calcite-ui-text-3);font-weight:500;font-size:0.875rem;line-height:1.5}.header.header--underlined{border-bottom:1px solid var(--calcite-ui-border-1)}.header--hex{line-height:1.5;font-size:0.875rem;line-height:1.5;padding:12px 0 15px}.control{margin-top:8px}.channels{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}.channel{width:31%}.saved-colors{padding-top:12px;display:-ms-grid;display:grid;grid-template-columns:repeat(auto-fill, minmax(24px, 1fr));grid-gap:8px;width:100%}.saved-colors-buttons{display:-ms-flexbox;display:flex}.saved-color{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;cursor:pointer}.saved-color:focus{outline:2px solid var(--calcite-ui-blue-1);outline-offset:2px}.saved-color:hover{-webkit-transition:outline-color 100ms ease-in-out;transition:outline-color 100ms ease-in-out;outline:2px solid var(--calcite-ui-border-2);outline-offset:2px}";var throttleFor60FpsInMs=16;var defaultColor=normalizeHex(DEFAULT_COLOR.hex());var CalciteColor=function(){function e(e){var r=this;registerInstance(this,e);this.calciteColorChange=createEvent(this,"calciteColorChange",7);this.appearance="default";this.color=DEFAULT_COLOR;this.hideHex=false;this.hideChannels=false;this.hideSaved=false;this.intlB=TEXT.b;this.intlBlue=TEXT.blue;this.intlDeleteColor=TEXT.deleteColor;this.intlG=TEXT.g;this.intlGreen=TEXT.green;this.intlH=TEXT.h;this.intlHsv=TEXT.hsv;this.intlHex=TEXT.hex;this.intlHue=TEXT.hue;this.intlR=TEXT.r;this.intlRed=TEXT.red;this.intlRgb=TEXT.rgb;this.intlS=TEXT.s;this.intlSaturation=TEXT.saturation;this.intlSaveColor=TEXT.saveColor;this.intlSaved=TEXT.saved;this.intlV=TEXT.v;this.intlValue=TEXT.value;this.scale="m";this.theme="light";this.value=defaultColor;this.colorUpdateLocked=false;this.hueThumbState="idle";this.mode=CSSColorMode.HEX;this.shiftKeyChannelAdjustment=0;this.sliderThumbState="idle";this.colorFieldAndSliderInteractive=false;this.channelMode="rgb";this.channels=this.toChannels(DEFAULT_COLOR);this.dimensions=DIMENSIONS.m;this.savedColors=[];this.handleTabActivate=function(e){r.channelMode=e.currentTarget.getAttribute("data-color-mode");r.updateChannelsFromColor(r.color)};this.handleHexInputChange=function(e){e.stopPropagation();var t=r.color;var a=e.target;var n=a.value;if(n!==normalizeHex(t.hex())){r.internalColorSet(color(n))}};this.handleSavedColorSelect=function(e){var t=e.currentTarget;r.internalColorSet(color(t.color))};this.handleChannelInput=function(e){var t=e.currentTarget;var a=e.target;var n=Number(a.getAttribute("data-channel-index"));var o=r.channelMode==="rgb"?RGB_LIMITS[Object.keys(RGB_LIMITS)[n]]:HSV_LIMITS[Object.keys(HSV_LIMITS)[n]];var i=Number(a.value)+r.shiftKeyChannelAdjustment;var l=Math.max(0,Math.min(i,o));t.value=""+l;a.value=""+l};this.handleChannelKeyUpOrDown=function(e){var t=e.key,a=e.shiftKey;t=getKey(t);var n=9;r.shiftKeyChannelAdjustment=t==="ArrowUp"&&a?n:t==="ArrowDown"&&a?-n:0};this.handleChannelChange=function(e){var t=e.target;var a=Number(t.getAttribute("data-channel-index"));var n=__spreadArrays(r.channels);n[a]=Number(t.value);r.updateColorFromChannels(n)};this.handleSavedColorKeyDown=function(e){if(e.key===" "||e.key==="Enter"){e.preventDefault();e.stopPropagation();r.handleSavedColorSelect(e)}};this.handleColorFieldAndSliderMouseLeave=function(){r.colorFieldAndSliderInteractive=false};this.handleColorFieldAndSliderMouseEnterOrMove=function(e){var t=e.offsetY;var a=r.dimensions,n=a.colorField.height,o=a.slider.height;r.colorFieldAndSliderInteractive=t<=n+o};this.renderChannelsTabTitle=function(e){var t=r,a=t.channelMode,n=t.intlRgb,o=t.intlHsv;var i=e===a;var l=e==="rgb"?n:o;return h("calcite-tab-title",{active:i,class:CSS.colorMode,"data-color-mode":e,onCalciteTabsActivate:r.handleTabActivate},l)};this.renderChannelsTab=function(e){var t=r,a=t.channelMode,n=t.channels,o=t.intlB,i=t.intlBlue,l=t.intlG,s=t.intlGreen,c=t.intlH,u=t.intlHue,d=t.intlR,v=t.intlRed,f=t.intlS,p=t.intlSaturation,m=t.intlV,g=t.intlValue;var b=e===a;var y=e==="rgb";var w=y?[d,l,o]:[c,f,m];var C=y?[v,s,i]:[u,p,g];return h("calcite-tab",{active:b,class:CSS.control},h("div",{class:CSS.channels},n.map((function(e,t){return r.renderChannel(e,t,w[t],C[t])}))))};this.renderChannel=function(e,t,a,n){return h("calcite-input",{"aria-label":n,class:CSS.channel,"data-channel-index":t,numberButtonType:"none",onChange:r.handleChannelChange,onInput:r.handleChannelInput,onKeyDown:r.handleChannelKeyUpOrDown,onKeyUp:r.handleChannelKeyUpOrDown,prefixText:a,scale:"s",type:"number",value:e.toString()})};this.deleteColor=function(){var e=r.color.hex();var t=r.savedColors.indexOf(e)>-1;if(!t){return}var a=r.savedColors.filter((function(r){return r!==e}));r.savedColors=a;var n=""+DEFAULT_STORAGE_KEY_PREFIX+r.storageId;if(r.storageId){localStorage.setItem(n,JSON.stringify(a))}};this.saveColor=function(){var e=r.color.hex();var t=r.savedColors.indexOf(e)>-1;if(t){return}var a=__spreadArrays(r.savedColors,[e]);r.savedColors=a;var n=""+DEFAULT_STORAGE_KEY_PREFIX+r.storageId;if(r.storageId){localStorage.setItem(n,JSON.stringify(a))}};this.drawColorFieldAndSlider=throttle((function(){if(!r.fieldAndSliderRenderingContext){return}r.drawColorField();r.drawHueSlider()}),throttleFor60FpsInMs);this.initColorFieldAndSlider=function(e){r.fieldAndSliderRenderingContext=e.getContext("2d");r.setCanvasContextSize(e,{width:r.dimensions.colorField.width,height:r.dimensions.colorField.height+r.dimensions.slider.height+r.getSliderCapSpacing()*2});r.drawColorFieldAndSlider();var t=function(e){var t=r.dimensions,a=t.colorField.height,n=t.slider.height;if(e<=a){return"color-field"}if(e<=a+n){return"slider"}return"none"};var a=function(e,t){var a=r.dimensions.colorField,n=a.height,o=a.width;var i=Math.round(HSV_LIMITS.s/o*e);var l=Math.round(HSV_LIMITS.v/n*(n-t));r.internalColorSet(r.color.hsv().saturationv(i).value(l))};e.addEventListener("mousedown",(function(e){var o=e.offsetX,i=e.offsetY;var l=t(i);if(l==="color-field"){r.hueThumbState="drag";a(o,i)}else if(l==="slider"){r.sliderThumbState="drag";n(o)}}));e.addEventListener("mouseout",(function(){r.hueThumbState="idle";r.sliderThumbState="idle";r.drawColorFieldAndSlider()}));e.addEventListener("mouseup",(function(){r.hueThumbState="hover";r.sliderThumbState="hover";r.drawColorFieldAndSlider()}));e.addEventListener("mousemove",(function(e){var o=e.offsetX,i=e.offsetY;var l=t(i);if(l==="color-field"){var s=r.hueThumbState;var c=r.color.hsv();var h=r.dimensions,u=h.colorField,d=u.height,v=u.width,f=h.thumb.radius;var p=Math.round(c.saturationv()/(HSV_LIMITS.s/v));var m=Math.round(d-c.value()/(HSV_LIMITS.v/d));var g=r.containsPoint(o,i,p,m,f);var b=false;if(s==="idle"&&g){r.hueThumbState="hover";b=true}else if(s==="hover"&&!g){r.hueThumbState="idle";b=true}if(r.hueThumbState!=="drag"){if(b){r.drawColorFieldAndSlider()}return}a(o,i)}else if(l==="slider"){var y=r.dimensions,w=y.slider,C=w.height,x=w.width,S=y.thumb.radius;var k=r.sliderThumbState;var M=r.color.hsv().saturationv(100).value(100);var T=Math.round(M.hue()/(360/x));var D=Math.round((C+r.getSliderCapSpacing())/2);var I=r.containsPoint(o,i,T,D,S);var A=false;if(k==="idle"&&I){r.sliderThumbState="hover";A=true}else if(k==="hover"&&!I){r.sliderThumbState="idle";A=true}if(r.sliderThumbState!=="drag"){if(A){r.drawColorFieldAndSlider()}return}n(o)}}));var n=function(e){var t=r.dimensions.slider.width;var a=360/t*e;r.internalColorSet(r.color.hue(a))}}}e.prototype.handleColorChange=function(e){this.drawColorFieldAndSlider();this.updateChannelsFromColor(e);if(this.colorUpdateLocked){return}var r=this.toValue(e);this.value=r};e.prototype.handleScaleChange=function(e){if(e===void 0){e="m"}this.updateDimensions(e)};e.prototype.handleValueChange=function(e,r){var t=parseMode(e);if(!t){console.warn("ignoring invalid color value: "+e);this.value=r;return}var a=this.mode!==t;this.mode=t;if(this.colorUpdateLocked){this.calciteColorChange.emit();return}var n=color(e);var o=!colorEqual(n,this.color);if(a||o){this.color=n;this.calciteColorChange.emit()}};e.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){focusElement(this.hexInputNode);return[2]}))}))};e.prototype.componentWillLoad=function(){var e=""+DEFAULT_STORAGE_KEY_PREFIX+this.storageId;if(this.storageId&&localStorage.getItem(e)){this.savedColors=JSON.parse(localStorage.getItem(e))}this.handleValueChange(this.value,defaultColor);this.updateDimensions(this.scale)};e.prototype.render=function(){var e,r,t,a,n;var o=this;var i=this,l=i.color,s=i.intlDeleteColor,c=i.el,u=i.hideHex,d=i.hideChannels,v=i.hideSaved,f=i.intlHex,p=i.intlSaved,m=i.intlSaveColor,g=i.savedColors,b=i.scale,y=i.theme;var w=l.hex();var C=b!=="s"?"m":b;var x=this.colorFieldAndSliderInteractive;var S=getElementDir(c);return h("div",{class:CSS.container},h("canvas",{class:(e={},e[CSS.colorFieldAndSlider]=true,e[CSS.colorFieldAndSliderInteractive]=x,e),onMouseEnter:this.handleColorFieldAndSliderMouseEnterOrMove,onMouseLeave:this.handleColorFieldAndSliderMouseLeave,onMouseMove:this.handleColorFieldAndSliderMouseEnterOrMove,ref:this.initColorFieldAndSlider}),u&&d?null:h("div",{class:(r={},r[CSS.controlSection]=true,r[CSS.section]=true,r)},u?null:h("div",{class:CSS.hexOptions},h("span",{class:(t={},t[CSS.header]=true,t[CSS.headerHex]=true,t[CSS.underlinedHeader]=true,t)},f),h("calcite-color-hex-input",{class:CSS.control,dir:S,onCalciteColorHexInputChange:this.handleHexInputChange,ref:function(e){return o.hexInputNode=e},scale:C,theme:y,value:w})),d?null:h("calcite-tabs",{class:(a={},a[CSS.colorModeContainer]=true,a[CSS.splitSection]=true,a),dir:S},h("calcite-tab-nav",{slot:"tab-nav"},this.renderChannelsTabTitle("rgb"),this.renderChannelsTabTitle("hsv")),this.renderChannelsTab("rgb"),this.renderChannelsTab("hsv"))),v?null:h("div",{class:(n={},n[CSS.savedColorsSection]=true,n[CSS.section]=true,n)},h("div",{class:CSS.header},h("label",null,p),h("div",{class:CSS.savedColorsButtons},h("calcite-button",{appearance:"transparent","aria-label":s,class:CSS.deleteColor,color:"dark",iconStart:"minus",onClick:this.deleteColor,scale:b,theme:y}),h("calcite-button",{appearance:"transparent","aria-label":m,class:CSS.saveColor,color:"dark",iconStart:"plus",onClick:this.saveColor,scale:b,theme:y}))),g.length>0?h("div",{class:CSS.savedColors},__spreadArrays(g.map((function(e){return h("calcite-color-swatch",{active:w===e,class:CSS.savedColor,color:e,key:e,onClick:o.handleSavedColorSelect,onKeyDown:o.handleSavedColorKeyDown,scale:b,tabIndex:0,theme:y})})))):null))};e.prototype.internalColorSet=function(e){if(colorEqual(e,this.color)){return}this.colorUpdateLocked=true;this.color=e;this.value=this.toValue(e);this.colorUpdateLocked=false};e.prototype.toValue=function(e){var r=this.mode;var t="hex";if(r.includes(t)){return normalizeHex(e[t]())}if(r.includes("-css")){return e[r.replace("-css","").replace("a","")]().string()}var a=e[r]().round().object();if(r.endsWith("a")){a.a=a.alpha;delete a.alpha}return a};e.prototype.getSliderCapSpacing=function(){var e=this.dimensions,r=e.slider.height,t=e.thumb.radius;return t*2-r};e.prototype.updateDimensions=function(e){if(e===void 0){e="m"}this.dimensions=DIMENSIONS[e]};e.prototype.drawColorField=function(){var e=this.fieldAndSliderRenderingContext;var r=this.dimensions.colorField,t=r.height,a=r.width;e.fillStyle=this.color.hsv().saturationv(100).value(100).string();e.fillRect(0,0,a,t);var n=e.createLinearGradient(0,0,a,0);n.addColorStop(0,"rgba(255,255,255,1)");n.addColorStop(1,"rgba(255,255,255,0)");e.fillStyle=n;e.fillRect(0,0,a,t);var o=e.createLinearGradient(0,0,0,t);o.addColorStop(0,"rgba(0,0,0,0)");o.addColorStop(1,"rgba(0,0,0,1)");e.fillStyle=o;e.fillRect(0,0,a,t);this.drawActiveColorFieldColor()};e.prototype.setCanvasContextSize=function(e,r){var t=r.height,a=r.width;var n=window.devicePixelRatio||1;e.width=a*n;e.height=t*n;e.style.height=t+"px";e.style.width=a+"px";var o=e.getContext("2d");o.scale(n,n)};e.prototype.containsPoint=function(e,r,t,a,n){return Math.pow(e-t,2)+Math.pow(r-a,2)<=Math.pow(n,2)};e.prototype.drawActiveColorFieldColor=function(){var e=this.color.hsv();var r=this.dimensions,t=r.colorField,a=t.height,n=t.width,o=r.thumb.radius;var i=e.saturationv()/(HSV_LIMITS.s/n);var l=a-e.value()/(HSV_LIMITS.v/a);this.drawThumb(this.fieldAndSliderRenderingContext,o,i,l,e,this.hueThumbState)};e.prototype.drawThumb=function(e,r,t,a,n,o){var i=0;var l=2*Math.PI;e.beginPath();e.arc(t,a,r,i,l);e.shadowBlur=o==="hover"?32:16;e.shadowColor="rgba(0, 0, 0, "+(o==="drag"?.32:.16)+")";e.fillStyle="#fff";e.fill();e.beginPath();e.arc(t,a,r-3,i,l);e.shadowBlur=0;e.shadowColor="transparent";e.fillStyle=n.rgb().string();e.fill()};e.prototype.drawActiveHueSliderColor=function(){var e=this.color.hsv().saturationv(100).value(100);var r=this.dimensions,t=r.colorField.height,a=r.slider,n=a.height,o=a.width,i=r.thumb.radius;var l=e.hue()/(360/o);var s=n/2+t;this.drawThumb(this.fieldAndSliderRenderingContext,i,l,s,e,this.sliderThumbState)};e.prototype.drawHueSlider=function(){var e=this.fieldAndSliderRenderingContext;var r=this.dimensions,t=r.colorField.height,a=r.slider,n=a.height,o=a.width;var i=e.createLinearGradient(0,0,o,0);var l=["red","yellow","lime","cyan","blue","magenta","red"];var s=1/(l.length-1);var c=0;l.forEach((function(e){i.addColorStop(c,color(e).string());c+=s}));e.fillStyle=i;e.clearRect(0,t,o,n+this.getSliderCapSpacing()*2);e.fillRect(0,t,o,n);this.drawActiveHueSliderColor()};e.prototype.updateColorFromChannels=function(e){this.internalColorSet(color(e,this.channelMode))};e.prototype.updateChannelsFromColor=function(e){this.channels=this.toChannels(e)};e.prototype.toChannels=function(e){var r=this.channelMode;return e[r]().array().map((function(e){return Math.floor(e)}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{color:["handleColorChange"],scale:["handleScaleChange"],value:["handleValueChange"]}},enumerable:false,configurable:true});return e}();CalciteColor.style=calciteColorCss;var CSS$1={container:"container",preview:"preview",input:"input"};var calciteColorHexInputCss="@-webkit-keyframes calcite-fade-in{0%{opacity:0}100%{opacity:1}}@keyframes calcite-fade-in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes calcite-fade-in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes calcite-fade-in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes calcite-fade-in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes calcite-fade-in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes calcite-fade-in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes calcite-fade-in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-popper-transition:150ms ease-in-out}:host([hidden]){display:none}:host{display:block}.container{width:100%;display:-ms-inline-grid;display:inline-grid;-ms-grid-columns:1fr auto;grid-template-columns:1fr auto;-ms-flex-align:center;align-items:center}.preview{-ms-grid-column:2;-ms-grid-column-span:1;grid-column:2/3;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;pointer-events:none;margin:0 6px;z-index:1}.preview,.input{-ms-grid-row:1;grid-row:1}.input{-ms-grid-column:1;-ms-grid-column-span:2;grid-column:1/3;text-transform:uppercase;width:100%}";var DEFAULT_COLOR$1=color();var CalciteColorHexInput=function(){function e(e){var r=this;registerInstance(this,e);this.calciteColorHexInputChange=createEvent(this,"calciteColorHexInputChange",7);this.intlHex=TEXT.hex;this.scale="m";this.theme="light";this.value=normalizeHex(DEFAULT_COLOR$1.hex());this.onCalciteInputBlur=function(e){var t=e.currentTarget;var a="#"+t.value;if(isValidHex(a)&&isLonghandHex(a)){return}t.value=r.formatForInternalInput(rgbToHex(r.internalColor.object()))};this.onInputChange=function(e){var t=e.currentTarget;var a=t.value;var n=hexToRGB("#"+a);if(!n){return}r.value=normalizeHex(a);r.calciteColorHexInputChange.emit()};this.onInputKeyDown=function(e){var t=e.altKey,a=e.ctrlKey,n=e.metaKey,o=e.shiftKey;var i=getKey(e.key);if(i==="ArrowDown"||i==="ArrowUp"){var l=i==="ArrowUp"?1:-1;var s=o?10:1;r.value=normalizeHex(r.nudgeRGBChannels(r.internalColor,s*l).hex());e.preventDefault();return}var c=r.inputNode;var h=t||a||n;var u=c.value.length>=6;var d=getSelection().type==="Range";if(i.length===1&&!h&&!d&&(!hexChar.test(i)||u)){e.preventDefault()}};this.internalColor=DEFAULT_COLOR$1}e.prototype.componentWillLoad=function(){var e=normalizeHex(this.value);if(isValidHex(e)){this.internalColor=color(e);this.value=e}};e.prototype.handleValueChange=function(e,r){var t=normalizeHex(e);if(isValidHex(t)){var a=t!==normalizeHex(this.internalColor.hex());this.internalColor=color(t);this.value=t;if(a){this.calciteColorHexInputChange.emit()}return}this.value=r};e.prototype.render=function(){var e=this;var r=this,t=r.el,a=r.intlHex,n=r.value;var o=this.formatForInternalInput(n);var i=getElementDir(t);return h("div",{class:CSS$1.container},h("calcite-input",{"aria-label":a,class:CSS$1.input,dir:i,onCalciteInputBlur:this.onCalciteInputBlur,onChange:this.onInputChange,onKeyDown:this.onInputKeyDown,prefixText:"#",ref:function(r){return e.inputNode=r},scale:"s",value:o}),h("calcite-color-swatch",{active:true,class:CSS$1.preview,color:"#"+o,scale:"s"}))};e.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){focusElement(this.inputNode);return[2]}))}))};e.prototype.formatForInternalInput=function(e){return e.replace("#","")};e.prototype.nudgeRGBChannels=function(e,r){return color.rgb(e.array().map((function(e){return e+r})))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{value:["handleValueChange"]}},enumerable:false,configurable:true});return e}();CalciteColorHexInput.style=calciteColorHexInputCss;var CSS$2={swatch:"swatch"};var calciteColorSwatchCss="@-webkit-keyframes calcite-fade-in{0%{opacity:0}100%{opacity:1}}@keyframes calcite-fade-in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes calcite-fade-in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes calcite-fade-in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes calcite-fade-in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes calcite-fade-in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes calcite-fade-in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes calcite-fade-in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-popper-transition:150ms ease-in-out}:host([hidden]){display:none}:host{display:-ms-inline-flexbox;display:inline-flex}:host([scale=s]){height:20px;width:20px}:host([scale=m]){height:24px;width:24px}:host([scale=l]){height:28px;width:28px}.swatch{height:inherit;width:inherit;overflow:visible}.swatch rect{-webkit-transition:all 150ms ease-in-out;transition:all 150ms ease-in-out}";var ACTIVE_BORDER_COLOR="rgba(0, 0, 0, 0.15)";var CalciteColorSwatch=function(){function e(e){registerInstance(this,e);this.active=false;this.scale="m";this.theme="light"}e.prototype.handleColorChange=function(e){this.internalColor=color(e)};e.prototype.componentWillLoad=function(){this.handleColorChange(this.color)};e.prototype.render=function(){var e=this,r=e.internalColor,t=e.active,a=e.theme;var n=r.hex();var o=t?ACTIVE_BORDER_COLOR:r[a==="light"?"darken":"whiten"](.25).hex();var i=t?"100%":"0";return h(Host,{"aria-label":n,title:n},h("svg",{class:CSS$2.swatch,xmlns:"http://www.w3.org/2000/svg"},h("rect",{fill:n,height:"100%",rx:i,stroke:o,width:"100%"})))};Object.defineProperty(e,"watchers",{get:function(){return{color:["handleColorChange"]}},enumerable:false,configurable:true});return e}();CalciteColorSwatch.style=calciteColorSwatchCss;export{CalciteColor as calcite_color,CalciteColorHexInput as calcite_color_hex_input,CalciteColorSwatch as calcite_color_swatch};