import{x as f,y as i,z as o,A as h,B as M}from"./index-B6uGkrgD.js";function u(t){Array.isArray(t)&&t.raw&&(t=String.raw(...arguments));var n,a=f(t);if(!a.space)return[];const r=a.space[0]==="h"?i.min:o.min,e=a.space[0]==="h"?i.max:o.max;return n=Array(3),n[0]=Math.min(Math.max(a.values[0],r[0]),e[0]),n[1]=Math.min(Math.max(a.values[1],r[1]),e[1]),n[2]=Math.min(Math.max(a.values[2],r[2]),e[2]),a.space[0]==="h"&&(n=i.rgb(n)),n.push(Math.min(Math.max(a.alpha,0),1)),n}const x=(t,n,a)=>(t*299+n*587+a*114)/1e3>=128?-1:1,c=(t,n,a,r=1)=>{const e=[Math.max(Math.min(Math.round(n[0]+r*Math.max(1,n[0]/100)),255),0),Math.max(Math.min(Math.round(n[1]+r*Math.max(1,n[1]/100)),255),0),Math.max(Math.min(Math.round(n[2]+r*Math.max(1,n[2]/100)),255),0)],s=M(h.hex(`rgba(${t.join(",")},1)`),h.hex(`rgba(${e.join(",")},1)`)),g=e[0]+e[1]+e[2];return g===0||g===765||s>a?{background:t,foreground:e,contrast:s}:c(t,e,a,r)},m=new Map,p=(t,n,a,r=1)=>{if(m.has(t))return m.get(t);const e=c(t,n,a,r);return m.set(t,e),e},d=(t,n=7)=>{let a=[0,0,0,1],r=[255,255,255,1];typeof t=="string"?(a=u(t),r=a):typeof t=="object"&&t!==null&&typeof t.background=="string"&&typeof t.foreground=="string"&&(a=u(t.background),typeof t.foreground=="string"?r=u(t.foreground):r=a);const e=x(a[0],a[1],a[2]),s=p([a[0],a[1],a[2]],[r[0],r[1],r[2]],n,e);return r=[...s.foreground,1],{background:h.hex(`rgba(${a.join(",")})`),foreground:h.hex(`rgba(${r.join(",")})`),contrast:s.contrast}};export{d as c,u as r};
//# sourceMappingURL=contrast-qfZiX0wi-BxADjsFV.js.map
