import{b as g}from"./chunk-5VDVFGVW.js";var p=(()=>{class i{static invertHexColor(t,r=!0){t.indexOf("#")===0&&(t=t.slice(1)),t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),t=i.sanitizeHexColor(t);let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);if(r)return e*.299+o*.587+n*.114>186?"#000000":"#FFFFFF";let s=(255-e).toString(16),a=(255-o).toString(16),u=(255-n).toString(16);return"#"+this.padZero(s)+this.padZero(a)+this.padZero(u)}static padZero(t,r=2){var e=new Array(r).join("0");return(e+t).slice(-r)}static rgbComponentToHex(t){var r=Number(t).toString(16);return r.length<2&&(r="0"+r),r}static rgbComponentsToHex(t){return i.rgbToHex(`rgb(${t.r},${t.g},${t.b})`)}static rgbToComponents(t){let r="";return t.indexOf("rgb(")>-1?r=t.substring(t.indexOf("rgb(")+4,t.length-1):r=t,r.split(",")}static rgbToHex(t){let r=i.rgbToComponents(t);var e=i.rgbComponentToHex(r[0]),o=i.rgbComponentToHex(r[1]),n=i.rgbComponentToHex(r[2]);return e+o+n}static rgbToNum(t){let r=i.rgbToComponents(t);return Number(r[0])<<16+Number(r[1])<<16+Number(r[2])}static hexToRgbComponent(t){let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(r,function(o,n,s,a){return n+n+s+s+a+a}),t="#"+i.sanitizeHexColor(t.substring(1));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}static hexToRgb(t){let r=i.hexToRgbComponent(t);return`rgb(${r.r}, ${r.g}, ${r.b})`}static hexToRgba(t,r=1){let e=i.hexToRgbComponent(t);return`rgb(${e.r}, ${e.g}, ${e.b}, ${r})`}static shadeHexColor(t,r){let e=parseInt(t.substring(1,3),16),o=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);e=parseInt(g.numToStr(e*(100+r)/100)),o=parseInt(g.numToStr(o*(100+r)/100)),n=parseInt(g.numToStr(n*(100+r)/100)),e=e<255?e:255,o=o<255?o:255,n=n<255?n:255;let s=e.toString(16).length==1?"0"+e.toString(16):e.toString(16),a=o.toString(16).length==1?"0"+o.toString(16):o.toString(16),u=n.toString(16).length==1?"0"+n.toString(16):n.toString(16);return"#"+s+a+u}static sanitizeHexColor(t){if(t.length===6)return t;if(t.length>3&&t.length<6){let r="";for(let e=0;e<6-t.length;e++)r+="0";return r+=t,console.error("Invalid HEX color "+t+". "+r+" will be used"),r}else if(t.length>6){let r=t.substring(0,6);return console.error("HEX color length issue "+t+"). "+r+" will be used."),r}return t}static hexToNum(t){return t.indexOf("#")>-1&&(t=t.substring(1)),g.strToNum("0x"+i.sanitizeHexColor(t))}static numToHex(t){return`#${g.numToStr(t)}`}static{this.colors={red:"#FF0000",green:"#00FF00",blue:"#0000FF",black:"#000000",white:"#FFFFFF"}}static PAColorToHex(t){if(!t)return"transparent";if(t.startsWith("#"))return t;let r=parseInt(t);return isNaN(r)?"transparent":`#${(r<0?r>>>0:r).toString(16).padStart(6,"0")}`}}return i})();export{p as a};
