import {a,c as c$2}from'../chunk-OYLVEKC4.mjs';import'../chunk-OD65R6MQ.mjs';import {b,d,h as h$1,i as i$1,f,g,a as a$1,c as c$1}from'../chunk-JFPP44S3.mjs';var i=o=>{let r=a$1(o.w,0,1/0),t=a$1(o.b,0,1/0),n=r+t;return {h:c$1(o.h),w:n>100?r/n*100:r,b:n>100?t/n*100:t,alpha:a$1(b(o.alpha,3),0,1)}};var x=o=>{let{h:r}=a(o);return i({h:r,w:Math.min(o.r,o.g,o.b)/255*100,b:100-Math.max(o.r,o.g,o.b)/255*100,alpha:o.alpha})},y=({h:o,w:r,b:t,alpha:n})=>{let e=t===100?0:100-r/(100-t)*100;return c$2({h:o,s:e,v:100-t,alpha:n})},h=o=>{if(!h$1(o)||!i$1(o,["h","w","b"]))return null;let{h:r,w:t,b:n,alpha:e=1}=o;return !f(r)||!f(t)||!f(n)||!f(e)?null:y(i({h:g(r),w:g(t),b:g(n),alpha:g(e)}))},R=/^hwb\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,c=o=>{if(typeof o!="string")return null;let r=R.exec(o.trim());if(!r)return null;let t=r[2]?.toLowerCase()??"deg",n=Number(r[1])*(d[t]??1),e=r[5]===void 0?1:Number(r[5])/(r[6]?100:1);return y(i({h:n,w:Number(r[3]),b:Number(r[4]),alpha:e}))};var $=(o,r,t)=>{o.prototype.toHwb=function(n=0){let{h:e,w,b:a,alpha:u}=x(this._rawRgb());return {h:b(e,n),w:b(w,n),b:b(a,n),alpha:b(u,3)}},o.prototype.toHwbString=function(n=0){let{h:e,w,b:a,alpha:u}=this.toHwb(n);return u<1?`hwb(${e} ${w}% ${a}% / ${u})`:`hwb(${e} ${w}% ${a}%)`},r.push(c,h),t.push([c,"hwb"],[h,"hwb"]);},v=$;export{v as default};//# sourceMappingURL=hwb.mjs.map
//# sourceMappingURL=hwb.mjs.map