import{a0 as f,a1 as g}from"./index-B1H8BCL7.js";function p(e,a=0,s=1){return g(e,a,s)}function h(e){e=e.slice(1);const a=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let s=e.match(a);return s&&s[0].length===1&&(s=s.map(t=>t+t)),s?`rgb${s.length===4?"a":""}(${s.map((t,n)=>n<3?parseInt(t,16):Math.round(parseInt(t,16)/255*1e3)/1e3).join(", ")})`:""}function r(e){if(e.type)return e;if(e.charAt(0)==="#")return r(h(e));const a=e.indexOf("("),s=e.substring(0,a);if(["rgb","rgba","hsl","hsla","color"].indexOf(s)===-1)throw new Error(f(9,e));let t=e.substring(a+1,e.length-1),n;if(s==="color"){if(t=t.split(" "),n=t.shift(),t.length===4&&t[3].charAt(0)==="/"&&(t[3]=t[3].slice(1)),["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(n)===-1)throw new Error(f(10,n))}else t=t.split(",");return t=t.map(i=>parseFloat(i)),{type:s,values:t,colorSpace:n}}function u(e){const{type:a,colorSpace:s}=e;let{values:t}=e;return a.indexOf("rgb")!==-1?t=t.map((n,i)=>i<3?parseInt(n,10):n):a.indexOf("hsl")!==-1&&(t[1]=`${t[1]}%`,t[2]=`${t[2]}%`),a.indexOf("color")!==-1?t=`${s} ${t.join(" ")}`:t=`${t.join(", ")}`,`${a}(${t})`}function d(e,a){return e=r(e),a=p(a),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${a}`:e.values[3]=a,u(e)}function x(e,a){if(e=r(e),a=p(a),e.type.indexOf("hsl")!==-1)e.values[2]*=1-a;else if(e.type.indexOf("rgb")!==-1||e.type.indexOf("color")!==-1)for(let s=0;s<3;s+=1)e.values[s]*=1-a;return u(e)}function b(e,a){if(e=r(e),a=p(a),e.type.indexOf("hsl")!==-1)e.values[2]+=(100-e.values[2])*a;else if(e.type.indexOf("rgb")!==-1)for(let s=0;s<3;s+=1)e.values[s]+=(255-e.values[s])*a;else if(e.type.indexOf("color")!==-1)for(let s=0;s<3;s+=1)e.values[s]+=(1-e.values[s])*a;return u(e)}export{d as a,r as b,x as d,b as l,u as r};
