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