import {e,h as h$1}from'../chunk-HFDTK2ZP.mjs';import'../chunk-FXCFKFXK.mjs';import'../chunk-OD65R6MQ.mjs';import {b,h,i as i$1,f,g,d,a,c}from'../chunk-JFPP44S3.mjs';var S=r=>({l:a(r.l,0,100),c:Math.max(0,r.c),h:c(r.h),alpha:a(r.alpha,0,1),colorSpace:"lch"}),w=r=>{let o=e(r),t=b(Math.sqrt(o.a**2+o.b**2),2),n=Math.atan2(o.b,o.a)/Math.PI*180;return {l:o.l,c:t,h:t<.0015?0:b(n<0?n+360:n,2),alpha:o.alpha,colorSpace:"lch"}},y=({l:r,c:o,h:t,alpha:n})=>h$1({l:r,a:o*Math.cos(t*Math.PI/180),b:o*Math.sin(t*Math.PI/180),alpha:n,colorSpace:"lab"}),u=r=>{if(!h(r)||r.colorSpace!=="lch"||!i$1(r,["l","c","h"]))return null;let{l:o,c:t,h:n,alpha:c=1}=r;return !f(o)||!f(t)||!f(n)||!f(c)?null:y(S({l:g(o),c:g(t),h:g(n),alpha:g(c)}))},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+(none|[+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,i=r=>{if(typeof r!="string")return null;let o=x.exec(r.trim());if(!o)return null;let t=o[4]?.toLowerCase()??"deg",n=o[3].toLowerCase()==="none"?0:Number(o[3])*(d[t]??1),c=o[5]===void 0?1:Number(o[5])/(o[6]?100:1);return y(S({l:Number(o[1]),c:Number(o[2]),h:n,alpha:c}))};var R=(r,o,t)=>{r.prototype.toLch=function(){let{l:n,c,h:s,alpha:h}=w(this._rawRgb());return {l:b(n,2),c:b(c,2),h:b(s,2),alpha:h,colorSpace:"lch"}},r.prototype.toLchString=function(){let{l:n,c,h:s,alpha:h}=this.toLch(),m=c===0?"none":s;return h<1?`lch(${n}% ${c} ${m} / ${h})`:`lch(${n}% ${c} ${m})`},o.push(u,i),t.push([u,"lch"],[i,"lch"]);},T=R;export{T as default};//# sourceMappingURL=lch.mjs.map
//# sourceMappingURL=lch.mjs.map