@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
1 lines • 60.9 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(e,r,t,a){function o(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,n){function i(e){try{s(a.next(e))}catch(r){n(r)}}function l(e){try{s(a["throw"](e))}catch(r){n(r)}}function s(e){e.done?t(e.value):o(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(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},a,o,n,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,o&&(n=i[0]&2?o["return"]:i[0]?o["throw"]||((n=o["return"])&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;if(o=0,n)i=[i[0]&2,n.value];switch(i[0]){case 0:case 1:n=i;break;case 4:t.label++;return{value:i[1],done:false};case 5:t.label++;o=i[1];i=[0];continue;case 7:i=t.ops.pop();t.trys.pop();continue;default:if(!(n=t.trys,n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){t.label=i[1];break}if(i[0]===6&&t.label<n[1]){t.label=n[1];n=i;break}if(n&&t.label<n[2]){t.label=n[2];t.ops.push(i);break}if(n[2])t.ops.pop();t.trys.pop();continue}i=r.call(e,t)}catch(l){i=[6,l];o=0}finally{a=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,r){for(var t=0,a=r.length,o=e.length;t<a;t++,o++)e[o]=r[t];return e};import{r as registerInstance,c as createEvent,h,g as getElement}from"./index-aa8afca4.js";import{f as focusElement,g as getElementDir,C as CSS_UTILITY,a as getThemeName}from"./dom-466af3c7.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-60acc1d6.js";import{g as getKey}from"./key-ec82f942.js";import{d as debounce,i as isObject}from"./debounce-047e09f4.js";import"./guid-09142681.js";var FUNC_ERROR_TEXT="Expected a function";function throttle(e,r,t){var a=true,o=true;if(typeof e!="function"){throw new TypeError(FUNC_ERROR_TEXT)}if(isObject(t)){a="leading"in t?!!t.leading:a;o="trailing"in t?!!t.trailing:o}return debounce(e,r,{leading:a,maxWait:r,trailing:o})}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 o=[];for(var n=0,i=a.length;n<i;n++){var l=a[n];if(isArrayish(l)){o=r.call(o,t.call(l))}else{o.push(l)}}return o};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 o;switch(r){case"hsl":t=a.get.hsl(e);o="hsl";break;case"hwb":t=a.get.hwb(e);o="hwb";break;default:t=a.get.rgb(e);o="rgb";break}if(!t){return null}return{model:o,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 n=/^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(n)){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]=o(l[c],0,255)}l[3]=o(l[3],0,1);return l};a.get.hsl=function(e){if(!e){return null}var r=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\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 n=(parseFloat(t[1])+360)%360;var i=o(parseFloat(t[2]),0,100);var l=o(parseFloat(t[3]),0,100);var s=o(isNaN(a)?1:a,0,1);return[n,i,l,s]}return null};a.get.hwb=function(e){if(!e){return null}var r=/^hwb\(\s*([+-]?\d{0,3}(?:\.\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 n=(parseFloat(t[1])%360+360)%360;var i=o(parseFloat(t[2]),0,100);var l=o(parseFloat(t[3]),0,100);var s=o(isNaN(a)?1:a,0,1);return[n,i,l,s]}return null};a.to.hex=function(){var e=simpleSwizzle(arguments);return"#"+n(e[0])+n(e[1])+n(e[2])+(e[3]<1?n(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 o(e,r,t){return Math.min(Math.max(r,e),t)}function n(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 o in a){if(a.hasOwnProperty(o)){if(!("channels"in a[o])){throw new Error("missing channels property: "+o)}if(!("labels"in a[o])){throw new Error("missing channel labels property: "+o)}if(a[o].labels.length!==a[o].channels){throw new Error("channel and label counts mismatch: "+o)}var n=a[o].channels;var i=a[o].labels;delete a[o].channels;delete a[o].labels;Object.defineProperty(a[o],"channels",{value:n});Object.defineProperty(a[o],"labels",{value:i})}}a.rgb.hsl=function(e){var r=e[0]/255;var t=e[1]/255;var a=e[2]/255;var o=Math.min(r,t,a);var n=Math.max(r,t,a);var i=n-o;var l;var s;var c;if(n===o){l=0}else if(r===n){l=(t-a)/i}else if(t===n){l=2+(a-r)/i}else if(a===n){l=4+(r-t)/i}l=Math.min(l*60,360);if(l<0){l+=360}c=(o+n)/2;if(n===o){s=0}else if(c<=.5){s=i/(n+o)}else{s=i/(2-n-o)}return[l,s*100,c*100]};a.rgb.hsv=function(e){var r;var t;var a;var o;var n;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){o=n=0}else{n=h/c;r=u(i);t=u(l);a=u(s);if(i===c){o=a-t}else if(l===c){o=1/3+r-a}else if(s===c){o=2/3+t-r}if(o<0){o+=1}else if(o>1){o-=1}}return[o*360,n*100,c*100]};a.rgb.hwb=function(e){var r=e[0];var t=e[1];var o=e[2];var n=a.rgb.hsl(e)[0];var i=1/255*Math.min(r,Math.min(t,o));o=1-1/255*Math.max(r,Math.max(t,o));return[n,i*100,o*100]};a.rgb.cmyk=function(e){var r=e[0]/255;var t=e[1]/255;var a=e[2]/255;var o;var n;var i;var l;l=Math.min(1-r,1-t,1-a);o=(1-r-l)/(1-l)||0;n=(1-t-l)/(1-l)||0;i=(1-a-l)/(1-l)||0;return[o*100,n*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 o;for(var n in colorName){if(colorName.hasOwnProperty(n)){var i=colorName[n];var s=l(e,i);if(s<a){a=s;o=n}}}return o};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 o=r*.4124+t*.3576+a*.1805;var n=r*.2126+t*.7152+a*.0722;var i=r*.0193+t*.1192+a*.9505;return[o*100,n*100,i*100]};a.rgb.lab=function(e){var r=a.rgb.xyz(e);var t=r[0];var o=r[1];var n=r[2];var i;var l;var s;t/=95.047;o/=100;n/=108.883;t=t>.008856?Math.pow(t,1/3):7.787*t+16/116;o=o>.008856?Math.pow(o,1/3):7.787*o+16/116;n=n>.008856?Math.pow(n,1/3):7.787*n+16/116;i=116*o-16;l=500*(t-o);s=200*(o-n);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 o;var n;var i;var l;var s;if(t===0){s=a*255;return[s,s,s]}if(a<.5){n=a*(1+t)}else{n=a+t-a*t}o=2*a-n;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=o+(n-o)*6*i}else if(2*i<1){s=n}else if(3*i<2){s=o+(n-o)*(2/3-i)*6}else{s=o}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 o=t;var n=Math.max(a,.01);var i;var l;a*=2;t*=a<=1?a:2-a;o*=n<=1?n:2-n;l=(a+t)/2;i=a===0?2*o/(n+o):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 o=Math.floor(r)%6;var n=r-Math.floor(r);var i=255*a*(1-t);var l=255*a*(1-t*n);var s=255*a*(1-t*(1-n));a*=255;switch(o){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 o=Math.max(a,.01);var n;var i;var l;l=(2-t)*a;n=(2-t)*o;i=t*o;i/=n<=1?n:2-n;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 o=t+a;var n;var i;var l;var s;if(o>1){t/=o;a/=o}n=Math.floor(6*r);i=1-a;l=6*r-n;if((n&1)!==0){l=1-l}s=t+l*(i-t);var c;var h;var u;switch(n){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 o=e[3]/100;var n;var i;var l;n=1-Math.min(1,r*(1-o)+o);i=1-Math.min(1,t*(1-o)+o);l=1-Math.min(1,a*(1-o)+o);return[n*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 o;var n;var i;o=r*3.2406+t*-1.5372+a*-.4986;n=r*-.9689+t*1.8758+a*.0415;i=r*.0557+t*-.204+a*1.057;o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o*12.92;n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n*12.92;i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*12.92;o=Math.min(Math.max(0,o),1);n=Math.min(Math.max(0,n),1);i=Math.min(Math.max(0,i),1);return[o*255,n*255,i*255]};a.xyz.lab=function(e){var r=e[0];var t=e[1];var a=e[2];var o;var n;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;o=116*t-16;n=500*(r-t);i=200*(t-a);return[o,n,i]};a.lab.xyz=function(e){var r=e[0];var t=e[1];var a=e[2];var o;var n;var i;n=(r+16)/116;o=t/500+n;i=n-a/200;var l=Math.pow(n,3);var s=Math.pow(o,3);var c=Math.pow(i,3);n=l>.008856?l:(n-16/116)/7.787;o=s>.008856?s:(o-16/116)/7.787;i=c>.008856?c:(i-16/116)/7.787;o*=95.047;n*=100;i*=108.883;return[o,n,i]};a.lab.lch=function(e){var r=e[0];var t=e[1];var a=e[2];var o;var n;var i;o=Math.atan2(a,t);n=o*360/2/Math.PI;if(n<0){n+=360}i=Math.sqrt(t*t+a*a);return[r,i,n]};a.lch.lab=function(e){var r=e[0];var t=e[1];var a=e[2];var o;var n;var i;i=a/360*2*Math.PI;o=t*Math.cos(i);n=t*Math.sin(i);return[r,o,n]};a.rgb.ansi16=function(e){var r=e[0];var t=e[1];var o=e[2];var n=1 in arguments?arguments[1]:a.rgb.hsv(e)[2];n=Math.round(n/50);if(n===0){return 30}var i=30+(Math.round(o/255)<<2|Math.round(t/255)<<1|Math.round(r/255));if(n===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 o=16+36*Math.round(r/255*5)+6*Math.round(t/255*5)+Math.round(a/255*5);return o};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 o=(r>>1&1)*t*255;var n=(r>>2&1)*t*255;return[a,o,n]};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 o=Math.floor((t=e%36)/6)/5*255;var n=t%6/5*255;return[a,o,n]};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 o=a>>16&255;var n=a>>8&255;var i=a&255;return[o,n,i]};a.rgb.hcg=function(e){var r=e[0]/255;var t=e[1]/255;var a=e[2]/255;var o=Math.max(Math.max(r,t),a);var n=Math.min(Math.min(r,t),a);var i=o-n;var l;var s;if(i<1){l=n/(1-i)}else{l=0}if(i<=0){s=0}else if(o===r){s=(t-a)/i%6}else if(o===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 o=0;if(t<.5){a=2*r*t}else{a=2*r*(1-t)}if(a<1){o=(t-.5*a)/(1-a)}return[e[0],a*100,o*100]};a.hsv.hcg=function(e){var r=e[1]/100;var t=e[2]/100;var a=r*t;var o=0;if(a<1){o=(t-a)/(1-a)}return[e[0],a*100,o*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 o=[0,0,0];var n=r%1*6;var i=n%1;var l=1-i;var s=0;switch(Math.floor(n)){case 0:o[0]=1;o[1]=i;o[2]=0;break;case 1:o[0]=l;o[1]=1;o[2]=0;break;case 2:o[0]=0;o[1]=1;o[2]=i;break;case 3:o[0]=0;o[1]=l;o[2]=1;break;case 4:o[0]=i;o[1]=0;o[2]=1;break;default:o[0]=1;o[1]=0;o[2]=l}s=(1-t)*a;return[(t*o[0]+s)*255,(t*o[1]+s)*255,(t*o[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 o=0;if(a>0){o=r/a}return[e[0],o*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 o=0;if(a>0&&a<.5){o=r/(2*a)}else if(a>=.5&&a<1){o=r/(2*(1-a))}return[e[0],o*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 o=a-r;var n=0;if(o<1){n=(a-o)/(1-o)}return[e[0],o*100,n*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 o=Object.keys(conversions[a]);for(var n=o.length,i=0;i<n;i++){var l=o[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 o=r[e].parent;while(r[o].parent){t.unshift(r[o].parent);a=link(conversions[r[o].parent][o],a);o=r[o].parent}a.conversion=t;return a}var route=function(e){var r=deriveBFS(e);var t={};var a=Object.keys(r);for(var o=a.length,n=0;n<o;n++){var i=a[n];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,o=0;o<a;o++){t[o]=Math.round(t[o])}}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 o=colorString.get(e);if(o===null){throw new Error("Unable to parse color from string: "+e)}this.model=o.model;a=colorConvert[this.model].channels;this.color=o.value.slice(0,a);this.valpha=typeof o.value[a]==="number"?o.value[a]:1}else if(e.length){this.model=r||"rgb";a=colorConvert[this.model].channels;var n=_slice.call(e,0,a);this.color=zeroArray(n,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 o=r===undefined?.5:r;var n=2*o-1;var i=t.alpha()-a.alpha();var l=((n*i===-1?n:(n+i)/(1+n*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()*o+a.alpha()*(1-o))}};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 o;if(arguments.length){if(t){a=t(a)}o=this[e]();o.color[r]=a;return o}o=this[e]().color[r];if(t){o=t(o)}return o}}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$2={container:"container",controlSection:"control-section",hexOptions:"color-hex-options",section:"section",header:"header",control:"control",splitSection:"section--split",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",colorFieldAndSliderWrap:"color-field-and-slider-wrap",scope:"scope",hueScope:"scope--hue",colorFieldScope:"scope--color-field",savedColor:"saved-color"};var DEFAULT_COLOR$1=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",noColor:"No color",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 clamp=function(e,r,t){return Math.max(r,Math.min(e,t))};var calciteColorPickerCss="@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes 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 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 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 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 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 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:inline-block}: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]) .control-section.section.calcite--rtl>: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;-ms-flex-align:baseline;align-items:baseline}:host([scale=l]) .control-section>:nth-child(2){margin-left:12px}:host([scale=l]) .color-hex-options{-ms-flex-negative:1;flex-shrink:1;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:distribute;justify-content:space-around;min-height:90px}:host([scale=l]) .color-mode-container{-ms-flex-negative:3;flex-shrink:3}:host([appearance=minimal]) .container{border:none}.container{background-color:var(--calcite-ui-foreground-1);display:inline-block;border:1px solid var(--calcite-ui-border-1)}.color-field-and-slider-wrap{position:relative}.scope{font-size:var(--calcite-font-size--1);padding:0;margin-bottom:0;margin-right:0;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;width:0.5rem;height:0.5rem;position:absolute;pointer-events:none;margin-top:-0.25rem;margin-left:-0.25rem;outline-offset:10px}.scope:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px;outline-offset:12px}.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{margin-bottom:1rem}.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--hex{line-height:1.5;font-size:0.875rem;line-height:1.5;padding-top:12px}.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-brand);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 defaultValue=normalizeHex(DEFAULT_COLOR$1.hex());var defaultFormat="auto";var CalciteColorPicker=function(){function e(e){var r=this;registerInstance(this,e);this.calciteColorPickerChange=createEvent(this,"calciteColorPickerChange",7);this.allowEmpty=false;this.appearance="default";this.color=DEFAULT_COLOR$1;this.format=defaultFormat;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.intlNoColor=TEXT.noColor;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.value=defaultValue;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$1);this.dimensions=DIMENSIONS.m;this.savedColors=[];this.handleTabActivate=function(e){r.channelMode=e.currentTarget.getAttribute("data-color-mode");r.updateChannelsFromColor(r.color)};this.handleColorFieldScopeKeyDown=function(e){var t=getKey(e.key);var a={ArrowUp:{x:0,y:-10},ArrowRight:{x:10,y:0},ArrowDown:{x:0,y:10},ArrowLeft:{x:-10,y:0}};if(Object.keys(a).includes(t)){e.preventDefault();r.scopeOrientation=t==="ArrowDown"||t==="ArrowUp"?"vertical":"horizontal";r.captureColorFieldColor(r.colorFieldScopeLeft+a[t].x||0,r.colorFieldScopeTop+a[t].y||0,false);return}};this.handleHueScopeKeyDown=function(e){var t;var a=e.shiftKey?10:1;var o=getKey(e.key);var n={ArrowUp:1,ArrowRight:1,ArrowDown:-1,ArrowLeft:-1};if(Object.keys(n).includes(o)){e.preventDefault();var i=n[o]*a;var l=(t=r.baseColorFieldColor)===null||t===void 0?void 0:t.hue();var s=l?r.baseColorFieldColor.hue(l+i):color({h:0,s:0,v:100});r.internalColorSet(s,false);return}};this.handleHexInputChange=function(e){e.stopPropagation();var t=r,a=t.allowEmpty,o=t.color;var n=e.target;var i=n.value;if(a&&!i){r.internalColorSet(null);return}var l=o&&normalizeHex(o.hex());if(i!==l){r.internalColorSet(color(i))}};this.handleSavedColorSelect=function(e){var t=e.currentTarget;r.internalColorSet(color(t.color))};this.handleChannelInput=function(e){var t=e.currentTarget;var a=e.detail.nativeEvent.target;var o=Number(t.getAttribute("data-channel-index"));var n=r.channelMode==="rgb"?RGB_LIMITS[Object.keys(RGB_LIMITS)[o]]:HSV_LIMITS[Object.keys(HSV_LIMITS)[o]];var i;if(r.allowEmpty&&!t.value){i=""}else{var l=Number(t.value)+r.shiftKeyChannelAdjustment;var s=clamp(l,0,n);i=s.toString()}t.value=i;a.value=i};this.handleChannelChange=function(e){var t=e.currentTarget;var a=Number(t.getAttribute("data-channel-index"));var o=__spreadArray([],r.channels);var n=r.allowEmpty&&!t.value;if(n){r.channels=[null,null,null];r.internalColorSet(null);return}o[a]=Number(t.value);r.updateColorFromChannels(o)};this.handleSavedColorKeyDown=function(e){if(e.key===" "||e.key==="Enter"){e.preventDefault();e.stopPropagation();r.handleSavedColorSelect(e)}};this.handleColorFieldAndSliderMouseLeave=function(){r.colorFieldAndSliderInteractive=false;if(r.sliderThumbState!=="drag"&&r.hueThumbState!=="drag"){r.hueThumbState="idle";r.sliderThumbState="idle";r.drawColorFieldAndSlider()}};this.handleColorFieldAndSliderMouseDown=function(e){var t=e.offsetX,a=e.offsetY;r.activeThumbX=t;r.activeThumbY=a;r.globalThumbX=t;r.globalThumbY=a;var o=r.getCanvasRegion(a);if(o==="color-field"){r.hueThumbState="drag";r.captureColorFieldColor(t,a)}else if(o==="slider"){r.sliderThumbState="drag";r.captureHueSliderColor(t)}e.preventDefault();document.addEventListener("mousemove",r.globalMouseMoveHandler);document.addEventListener("mouseup",r.globalMouseUpHandler,{once:true})};this.globalMouseUpHandler=function(){r.hueThumbState="idle";r.sliderThumbState="idle";r.drawColorFieldAndSlider()};this.globalMouseMoveHandler=function(e){var t=r,a=t.el,o=t.dimensions;var n=r.sliderThumbState==="drag";var i=r.hueThumbState==="drag";if(!a.isConnected||!n&&!i){return}r.globalThumbX=r.globalThumbX+e.movementX;r.globalThumbY=r.globalThumbY+e.movementY;r.activeThumbX=clamp(r.globalThumbX,0,o.colorField.width);r.activeThumbY=clamp(r.globalThumbY,0,o.colorField.height+o.slider.height);var l=i?"color-field":n?"slider":r.getCanvasRegion(r.activeThumbY);if(l==="color-field"){r.captureColorFieldColor(r.activeThumbX,r.activeThumbY,false)}else if(l==="slider"){r.captureHueSliderColor(r.activeThumbX)}};this.handleColorFieldAndSliderMouseEnterOrMove=function(e){var t=e.offsetX,a=e.offsetY;var o=r.dimensions,n=o.colorField,i=o.slider,l=o.thumb;r.colorFieldAndSliderInteractive=a<=n.height+i.height;var s=r.getCanvasRegion(a);if(s==="color-field"){var c=r.hueThumbState;var h=r.baseColorFieldColor.hsv();var u=Math.round(h.saturationv()/(HSV_LIMITS.s/n.width));var d=Math.round(n.height-h.value()/(HSV_LIMITS.v/n.height));var v=r.containsPoint(t,a,u,d,l.radius);var f=false;if(c==="idle"&&v){r.hueThumbState="hover";f=true}else if(c==="hover"&&!v){r.hueThumbState="idle";f=true}if(r.hueThumbState!=="drag"){if(f){r.drawColorFieldAndSlider()}}}else if(s==="slider"){var p=r.baseColorFieldColor.hsv().saturationv(100).value(100);var m=r.sliderThumbState;var g=Math.round(p.hue()/(360/i.width));var b=Math.round((i.height+r.getSliderCapSpacing())/2)+n.height;var y=r.containsPoint(t,a,g,b,l.radius);var C=false;if(m==="idle"&&y){r.sliderThumbState="hover";C=true}else if(m==="hover"&&!y){r.sliderThumbState="idle";C=true}if(r.sliderThumbState!=="drag"){if(C){r.drawColorFieldAndSlider()}}}};this.storeColorFieldScope=function(e){r.colorFieldScopeNode=e};this.renderChannelsTabTitle=function(e){var t=r,a=t.channelMode,o=t.intlRgb,n=t.intlHsv;var i=e===a;var l=e==="rgb"?o:n;return h("calcite-tab-title",{active:i,class:CSS$2.colorMode,"data-color-mode":e,key:e,onCalciteTabsActivate:r.handleTabActivate},l)};this.renderChannelsTab=function(e){var t=r,a=t.channelMode,o=t.channels,n=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 C=y?[d,l,n]:[c,f,m];var w=y?[v,s,i]:[u,p,g];return h("calcite-tab",{active:b,class:CSS$2.control,key:e},h("div",{class:CSS$2.channels},o.map((function(e,t){return r.renderChannel(e,t,C[t],w[t])}))))};this.renderChannel=function(e,t,a,o){return h("calcite-input",{"aria-label":o,class:CSS$2.channel,"data-channel-index":t,numberButtonType:"none",onCalciteInputChange:r.handleChannelChange,onCalciteInputInput:r.handleChannelInput,prefixText:a,scale:"s",type:"number",value:e===null||e===void 0?void 0: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 o=""+DEFAULT_STORAGE_KEY_PREFIX+r.storageId;if(r.storageId){localStorage.setItem(o,JSON.stringify(a))}};this.saveColor=function(){var e=r.color.hex();var t=r.savedColors.indexOf(e)>-1;if(t){return}var a=__spreadArray(__spreadArray([],r.savedColors),[e]);r.savedColors=a;var o=""+DEFAULT_STORAGE_KEY_PREFIX+r.storageId;if(r.storageId){localStorage.setItem(o,JSON.stringify(a))}};this.drawColorFieldAndSlider=throttle((function(){if(!r.fieldAndSliderRenderingContext){return}r.drawColorField();r.drawHueSlider()}),throttleFor60FpsInMs);this.captureColorFieldColor=function(e,t,a){if(a===void 0){a=true}var o=r.dimensions.colorField,n=o.height,i=o.width;var l=Math.round(HSV_LIMITS.s/i*e);var s=Math.round(HSV_LIMITS.v/n*(n-t));r.internalColorSet(r.baseColorFieldColor.hsv().saturationv(l).value(s),a)};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()}}e.prototype.handleColorChange=function(e,r){this.drawColorFieldAndSlider();this.updateChannelsFromColor(e);this.previousColor=r;if(this.colorUpdateLocked){return}this.value=this.toValue(e)};e.prototype.handleFormatChange=function(e){this.mode=e==="auto"?this.mode:e;this.value=this.toValue(this.color)};e.prototype.handleScaleChange=function(e){if(e===void 0){e="m"}this.updateDimensions(e)};e.prototype.handleValueChange=function(e,r){var t=this,a=t.allowEmpty,o=t.format;var n=!a||e;var i=false;if(n){var l=parseMode(e);if(!l||o!=="auto"&&l!==o){console.warn("ignoring invalid color value: "+e);this.value=r;return}i=this.mode!==l;this.mode=l}if(this.colorUpdateLocked){this.calciteColorPickerChange.emit();return}var s=a&&!e?null:color(e);var c=!colorEqual(s,this.color);if(i||c){this.color=s;this.calciteColorPickerChange.emit()}};Object.defineProperty(e.prototype,"baseColorFieldColor",{get:function(){return this.color||this.previousColor||DEFAULT_COLOR$1},enumerable:false,configurable:true});e.prototype.handleChannelKeyUpOrDown=function(e){this.shiftKeyChannelAdjustment=0;var r=getKey(e.key);if(r!=="ArrowUp"&&r!=="ArrowDown"||!e.composedPath().some((function(e){var r;return(r=e.classList)===null||r===void 0?void 0:r.contains(CSS$2.channel)}))){return}var t=e.shiftKey;e.preventDefault();if(!this.color){this.internalColorSet(this.previousColor);e.stopPropagation();return}var a=9;this.shiftKeyChannelAdjustment=r==="ArrowUp"&&t?a:r==="ArrowDown"&&t?-a:0};e.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,focusElement(this.colorFieldScopeNode)]}))}))};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))}};e.prototype.connectedCallback=function(){var e=this,r=e.color,t=e.format,a=e.value;var o=t!=="auto"?this.toValue(r,t):defaultValue;var n=t!=="auto"&&a===defaultValue?o:a;this.handleValueChange(n,o);this.updateDimensions(this.scale)};e.prototype.disconnectedCallback=function(){document.removeEventListener("mousemove",this.globalMouseMoveHandler);document.removeEventListener("mouseup",this.globalMouseUpHandler)};e.prototype.render=function(){var e,r,t,a,o,n,i;var l=this;var s=this,c=s.allowEmpty,u=s.color,d=s.intlDeleteColor,v=s.el,f=s.hideHex,p=s.hideChannels,m=s.hideSaved,g=s.intlHex,b=s.intlSaved,y=s.intlSaveColor,C=s.savedColors,w=s.scale;var S=u?u.hex():null;var x=w!=="s"?"m":w;var k=this,M=k.colorFieldAndSliderInteractive,T=k.colorFieldScopeTop,D=k.colorFieldScopeLeft,F=k.hueScopeLeft,A=k.hueScopeTop,E=k.scopeOrientation,I=k.dimensions,O=I.colorField,_=O.height,H=O.width,L=I.slider.height;var R=A!==null&&A!==void 0?A:L/2+_;var j=F!==null&&F!==void 0?F:H*DEFAULT_COLOR$1.hue()/HSV_LIMITS.h;var P=getElementDir(v);var N=u===null;var z=E==="vertical";return h("div",{class:CSS$2.container},h("div",{class:CSS$2.colorFieldAndSliderWrap},h("canvas",{class:(e={},e[CSS$2.colorFieldAndSlider]=true,e[CSS$2.colorFieldAndSliderInteractive]=M,e),onMouseDown:this.handleColorFieldAndSliderMouseDown,onMouseEnter:this.handleColorFieldAndSliderMouseEnterOrMove,onMouseLeave:this.handleColorFieldAndSliderMouseLeave,onMouseMove:this.handleColorFieldAndSliderMouseEnterOrMove,ref:this.initColorFieldAndSlider}),h("div",{"aria-label":z?this.intlValue:this.intlSaturation,"aria-valuemax":z?HSV_LIMITS.v:HSV_LIMITS.s,"aria-valuemin":"0","aria-valuenow":(z?u===null||u===void 0?void 0:u.saturationv():u===null||u===void 0?void 0:u.value())||"0",class:(r={},r[CSS$2.scope]=true,r[CSS$2.colorFieldScope]=true,r),onKeyDown:this.handleColorFieldScopeKeyDown,ref:this.storeColorFieldScope,role:"slider",style:{top:(T||0)+"px",left:(D||0)+"px"},tabindex:"0"}),h("div",{"aria-label":this.intlHue,"aria-valuemax":HSV_LIMITS.h,"aria-valuemin":"0","aria-valuenow":(u===null||u===void 0?void 0:u.round().hue())||DEFAULT_COLOR$1.round().hue(),class:(t={},t[CSS$2.scope]=true,t[CSS$2.hueScope]=true,t),onKeyDown:this.handleHueScopeKeyDown,role:"slider",style:{top:R+"px",left:j+"px"},tabindex:"0"})),f&&p?null:h("div",{class:(a={},a[CSS$2.controlSection]=true,a[CSS$2.section]=true,a[CSS_UTILITY.rtl]=P==="rtl",a)},f?null:h("div",{class:CSS$2.hexOptions},h("span",{class:(o={},o[CSS$2.header]=true,o[CSS$2.headerHex]=true,o)},g),h("calcite-color-picker-hex-input",{allowEmpty:c,class:CSS$2.control,dir:P,onCalciteColorPickerHexInputChange:this.handleHexInputChange,scale:x,value:S})),p?null:h("calcite-tabs",{class:(n={},n[CSS$2.colorModeContainer]=true,n[CSS$2.splitSection]=true,n),dir:P,scale:"s"},h("calcite-tab-nav",{slot:"tab-nav"},this.renderChannelsTabTitle("rgb"),this.renderChannelsTabTitle("hsv")),this.renderChannelsTab("rgb"),this.renderChannelsTab("hsv"))),m?null:h("div",{class:(i={},i[CSS$2.savedColorsSection]=true,i[CSS$2.section]=true,i)},h("div",{class:CSS$2.header},h("label",null,b),h("div",{class:CSS$2.savedColorsButtons},h("calcite-button",{appearance:"transparent",class:CSS$2.deleteColor,color:"neutral",disabled:N,iconStart:"minus",label:d,onClick:this.deleteColor,scale:w}),h("calcite-button",{appearance:"transparent",class:CSS$2.saveColor,color:"neutral",disabled:N,iconStart:"plus",label:y,onClick:this.saveColor,scale:w}))),C.length>0?h("div",{class:CSS$2.savedColors},__spreadArray([],C.map((function(e){return h("calcite-color-picker-swatch",{active:S===e,class:CSS$2.savedColor,color:e,key:e,onClick:l.handleSavedColorSelect,onKeyDown:l.handleSavedColorKeyDown,scale:w,tabIndex:0})})))):null))};e.prototype.captureHueSliderColor=function(e){var r=this.dimensions.slider.width;var t=360/r*e;this.internalColorSet(this.baseColorFieldColor.hue(t),false)};e.prototype.getCanvasRegion=function(e){var r=this.dimensions,t=r.colorField.height,a=r.slider.height;if(e<=t){return"color-field"}if(e<=t+a){return"slider"}return"none"};e.prototype.internalColorSet=function(e,r){if(r===void 0){r=true}if(r&&colorEqual(e,this.color)){return}this.colorUpdateLocked=true;this.color=e;this.value=this.toValue(e);this.colorUpdateLocked=false};e.prototype.toValue=function(e,r){if(r===void 0){r=this.mode}if(!e){return null}var t="hex";if(r.includes(t)){return normalizeHex(e.round()[t]())}if(r.includes("-css")){return e[r.replace("-css","").replace("a","")]().round().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.baseColorFieldColor.hsv().saturationv(100).value(100).string();e.fillRect(0,0,a,t);var o=e.createLinearGradient(0,0,a,0);o.addColorStop(0,"rgba(255,255,255,1)");o.addColorStop(1,"rgba(255,255,255,0)");e.fillStyle=o;e.fillRect(0,0,a,t);var n=e.createLinearGradient(0,0,0,t);n.addColorStop(0,"rgba(0,0,0,0)");n.addColorStop(1,"rgba(0,0,0,1)");e.fillStyle=n;e.fillRect(0,0,a,t);this.drawActiveColorFieldColor()};e.prototype.setCanvasContextSize=function(e,r){var t=r.height,a=r.width;var o=window.devicePixelRatio||1;e.width=a*o;e.height=t*o;e.style.height=t+"px";e.style.width=a+"px";var n=e.getContext("2d");n.scale(o,o)};e.prototype.containsPoint=function(e,r,t,a,o){return Math.pow(e-t,2)+Math.pow(r-a,2)<=Math.pow(o,2)};e.prototype.drawActiveColorFieldColor=function(){var e=this;var r=this.color;if(!r){return}var t=r.hsv();var a=this.dimensions,o=a.colorField,n=o.height,i=o.width,l=a.thumb.radius;var s=t.saturationv()/(HSV_LIMITS.s/i);var c=n-t.value()/(HSV_LIMITS.v/n);requestAnimationFrame((function(){e.colorFieldScopeLeft=s;e.colorFieldScopeTop=c}));this.drawThumb(this.fieldAndSliderRenderingContext,l,s,c,t,this.hueThumbState)};e.prototype.drawThumb=function(e,r,t,a,o,n){var i=0;var l=2*Math.PI;e.beginPath();e.arc(t,a,r,i,l);e.shadowBlur=n==="hover"?32:16;e.shadowColor="rgba(0, 0, 0, "+(n==="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=o.rgb().string();e.fill()};e.prototype.drawActiveHueSliderColor=function(){var e=this;var r=this.color;if(!r){return}var t=r.hsv().saturationv(100).value(100);var a=this.dimensions,o=a.colorField.height,n=a.slider,i=n.height,l=n.width,s=a.thumb.radius;var c=t.hue()/(360/l);var h=i/2+o;requestAnimationFrame((function(){e.hueScopeLeft=c;e.hueScopeTop=h}));this.drawThumb(this.fieldAndSliderRenderingContext,s,c,h,t,this.sliderThumbState)};e.prototype.drawHueSlider=function(){var e=this.fieldAndSliderRenderingContext;var r=this.dimensions,t=r.colorField.height,a=r.slider,o=a.height,n=a.width;var i=e.createLinearGradient(0,0,n,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,n,o+this.getSliderCapSpacing()*2);e.fillRect(0,t,n,o);this.drawActiveHueSliderColor()};e.prototype.updateColorFromChannels=function(e){this.internalColorSet(color(e,this.channelMode))};e.prototype.updateChannelsFromColor=function(e){this.channels=e?this.toChannels(e):[null,null,null]};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"],format:["handleFormatChange"],scale:["handleScaleChange"],value:["handleValueChange"]}},enumerable:false,configurable:true});return e}();CalciteColorPicker.style=calciteColorPickerCss;var CSS$1={container:"container",preview:"preview",input:"input"};var calciteColorPickerHexInputCss="@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes 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 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 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 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 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 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:inline-grid;-ms-flex-align:center;align-items:center;grid-template-columns:1fr auto}.preview{grid-column:2/3;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;pointer-events:none;margin-top:0;margin-bottom:0;margin-left:0.25rem;margin-right:0.25rem;z-index:1}.preview,.input{grid-row:1}.input{grid-column:1/3;text-transform:uppercase;width:100%}";var DEFAULT_COLOR=color();var CalciteColorPickerHexInput=function(){function e(e){var r=this;registerInstance(this,e);this.calciteColorPickerHexInputChange=createEvent(this,"calciteColorPickerHexInputChange",7);this.allowEmpty=false;this.intlHex=TEXT.hex;this.intlNoColor=TEXT.noColor;this.scale="m";this.value=normalizeHex(DEFAULT_COLOR.hex());this.onCalciteInputBlur=function(e){var t=e.currentTarget;var a=t.value;var o="#"+a;var n=r.allowEmpty&&!a;if(n||isValidHex(o)&&isLonghandHex(o)){return}t.value=r.allowEmpty&&!r.internalColor?"":r.formatForInternalInput(rgbToHex(r.internalColor.object()))};this.onInputChange=function(e){var t=e.currentTarget;var a=t.value;var o;if(a){var n=a;var i=hexToRGB("#"+n);if(!i){return}o=normalizeHex(n)}else if(r.allowEmpty){o=null}r.value=o;r.calciteColorPickerHexInputChange.emit()};this.internalColor=DEFAULT_COLOR;this.previousNonNullValue=this.value;this.storeInputRef=function(e){r.inputNode=e}}e.prototype.connectedCallback=function(){var e=this,r=e.allowEmpty,t=e.value;if(t){var a=normalizeHex(t);if(isValidHex(a)){this.internalColor=color(a);this.value=a}return}if(r){this.internalColor=null;this.value=null}};e.prototype.handleValueChange=function(e,r){if(e){var t=normalizeHex(e);if(isValidHex(t)){var a=this.internalColor;var o=!a||t!==normalizeHex(a.hex());this.internalColor=color(t);this.previousNonNullValue=t;this.value=t;if(o){this.calciteColorPickerHexInputChange.emit()}return}}else if(this.allowEmpty){this.internalColor=null;this.value=null;this.calciteColorPickerHexInputChange.emit();return}this.value=r};e.prototype.onInputKeyDown=function(e){var r=e.altKey,t=e.ctrlKey,a=e.metaKey,o=e.shiftKey;var n=this,i=n.el,l=n.inputNode,s=n.internalColor,c=n.value;var h=getKey(e.key);var u=h==="ArrowDown"||h==="ArrowUp";if(u){if(!c){this.value=this.previousNonNullValue;e.preventDefault();return}var d=h==="ArrowUp"?1:-1;var v=o?10:1;this.value=normalizeHex(this.nudgeRGBChannels(s,v*d).hex());e.preventDefault();return}var f=r||t||a;var p=l.value.length>=6;var m=i.shadowRoot.activeElement;var g=m.selectionStart!=m.selectionEnd;var b=h.length===1;var y=hexChar.test(h);if(b&&!f&&(!y||!g&&p)){e.preventDefault()}};e.prototype.render=function(){var e=this,r=e.el,t=e.intlHex,a=e.value;var o=this.formatForInternalInput(a);var n=getElementDir(r);return h("div",{class:CSS$1.container},h("calcite-input",{"aria-label":t,class:CSS$1.input,dir:n,onCalciteInputBlur:this.onCalciteInputBlur,onChange:this.onInputChange,prefixText:"#",ref:this.storeInputRef,scale:"s",value:o}),o?h("calcite-color-picker-swatch",{active:true,class:CSS$1.preview,color:"#"+o,scale:"s"}):null)};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?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}();CalciteColorPickerHexInput.style=calciteColorPickerHexInputCss;var CSS={swatch:"swatch",noColorIcon:"no-color-icon"};var COLORS={borderLight:"rgba(0, 0, 0, 0.15)",borderDark:"rgba(255, 255, 255, 0.15)"};var calciteColorPickerSwatchCss="@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes 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 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 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 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 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 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;position:relative}:host([scale=s]){height:1.25rem;width:1.25rem}:host([scale=m]){height:1.5rem;width:1.5rem}:host([scale=l]){height:2rem;width:2rem}.swatch{overflow:visible;height:inherit;width:inherit}.swatch rect{-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.no-color-icon{height:100%;width:100%;top:0;right:0;bottom:0;left:0;position:absolute}";var CalciteColorPickerSwatch=function(){function e(e){registerInstance(this,e);this.active=false;this.scale="m"}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.active,t=e.el,a=e.internalColor;var o=r?"100%":"0";var n=a.hex();var i=getThemeName(t);var l=i==="light"?COLORS.borderLight:COLORS.borderDark;return h("svg",{class:CSS.swatch,xmlns:"http://www.w3.org/2000/svg"},h("title",null,n),h("rect",{fill:n,height:"100%",id:"swatch",rx:o,stroke:l,"stroke-width":"2",style:{"clip-path":"inset(0 round "+o+")"},width:"100%"}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{color:["handleColorChange"]}},enumerable:false,configurable:true});return e}();CalciteColorPickerSwatch.style=calciteColorPickerSwatchCss;export{CalciteColorPicker as calcite_color_picker,CalciteColorPickerHexInput as calcite_color_picker_hex_input,CalciteColorPickerSwatch as calcite_color_picker_swatch};