import{n as e}from"./jsx-runtime-Bzw2jH9X.js";import{L as t,M as n,R as r}from"./useSize--KU1gilk.js";e();var i=e=>Math.round(Number(e||0)),a=e=>{if(e instanceof n)return e;if(e&&typeof e==`object`&&`h`in e&&`b`in e){let{b:t,...n}=e;return{...n,v:t}}return typeof e==`string`&&/hsb/.test(e)?e.replace(/hsb/,`hsv`):e},o=class extends n{constructor(e){super(a(e))}toHsbString(){let e=this.toHsb(),t=i(e.s*100),n=i(e.b*100),r=i(e.h),a=e.a,o=`hsb(${r}, ${t}%, ${n}%)`,s=`hsba(${r}, ${t}%, ${n}%, ${a.toFixed(a===0?0:2)})`;return a===1?o:s}toHsb(){let{v:e,...t}=this.toHsv();return{...t,b:e,a:this.a}}};(e=>e instanceof o?e:new o(e))(`#1677ff`);var s=(e,t)=>e?.replace(/[^0-9a-f]/gi,``).slice(0,t?8:6)||``,c=(e,t)=>e?s(e,t):``,l=function(){function e(t){if(r(this,e),this.cleared=!1,t instanceof e){this.metaColor=t.metaColor.clone(),this.colors=t.colors?.map(t=>({color:new e(t.color),percent:t.percent})),this.cleared=t.cleared;return}let n=Array.isArray(t);n&&t.length?(this.colors=t.map(({color:t,percent:n})=>({color:new e(t),percent:n})),this.metaColor=new o(this.colors[0].color.metaColor)):this.metaColor=new o(n?``:t),(!t||n&&!this.colors)&&(this.metaColor=this.metaColor.setA(0),this.cleared=!0)}return t(e,[{key:`toHsb`,value:function(){return this.metaColor.toHsb()}},{key:`toHsbString`,value:function(){return this.metaColor.toHsbString()}},{key:`toHex`,value:function(){return c(this.toHexString(),this.metaColor.a<1)}},{key:`toHexString`,value:function(){return this.metaColor.toHexString()}},{key:`toRgb`,value:function(){return this.metaColor.toRgb()}},{key:`toRgbString`,value:function(){return this.metaColor.toRgbString()}},{key:`isGradient`,value:function(){return!!this.colors&&!this.cleared}},{key:`getColors`,value:function(){return this.colors||[{color:this,percent:0}]}},{key:`toCssString`,value:function(){let{colors:e}=this;return e?`linear-gradient(90deg, ${e.map(e=>`${e.color.toRgbString()} ${e.percent}%`).join(`, `)})`:this.metaColor.toRgbString()}},{key:`equals`,value:function(e){return!e||this.isGradient()!==e.isGradient()?!1:this.isGradient()?this.colors.length===e.colors.length&&this.colors.every((t,n)=>{let r=e.colors[n];return t.percent===r.percent&&t.color.equals(r.color)}):this.toHexString()===e.toHexString()}}])}();export{o as n,l as t};