import{n as x,a as w}from"./C1951IdI.js";import{p as b,t as y,j as m,l as S,a as E}from"./CdjFANdp.js";import{c as g,C as k}from"./8eNpkxEe.js";import{p}from"./OpdB38Ru.js";function v(i,e,l){const d=i.reduce((s,f)=>s+f,0),r=Math.ceil(d/e),o=document.createElement("canvas");o.width=e,o.height=r;const n=o.getContext("2d");if(!n)throw new Error("Failed to get canvas context");n.imageSmoothingEnabled=!1,n.fillStyle=l;let t=0,c=0;return i.forEach((s,f)=>{if(f%2===0){let a=s;for(;a>0;){const h=e-t;a<h?(t+=a,a=0):(a-=h,t=0,c++)}}else{let a=s;for(;a>0;){const h=e-t,u=Math.min(a,h);n.fillRect(t,c,u,1),a-=u,a>0?(t=0,c++):t+=u}}}),{dataUrl:o.toDataURL(),height:r}}var C=x('<image x="0" y="0"></image>');function M(i,e){b(e,!0);const l=p(e,"colorFill",3,"rgba(255, 0, 0, 0.2)"),d=p(e,"opacity",3,.4);if(!e.segmentation)throw new Error("Segmentation data is required");const r=S(()=>{const c=l().replace(/rgba?\((\d+,\s*\d+,\s*\d+)(?:,\s*[\d.]+)?\)/,"rgb($1)");return v(e.segmentation,e.width,c)}),o=S(()=>m(r).dataUrl),n=S(()=>m(r).height);var t=C();y(()=>{g(t,"href",m(o)),g(t,"width",e.width),g(t,"height",m(n)),g(t,"opacity",d())}),w(i,t),E()}function _(i,e){const l=p(e,"isSelected",3,!1);k(i,{get checked(){return l()},get onCheckedChange(){return e.onSelect}})}export{M as S,_ as a};
