(function(){let e,t,n=`rgba(0, 0, 255, 0.3)`,r=()=>{let n=t.getImageData(0,0,e.width,e.height);self.postMessage({type:`done`,imageData:n})},i=(e,t,n)=>{let{color:r}=n;t?.forEach(({x:t,y:i})=>{let a=n.lineWidth||10;e.save(),e.fillStyle=`rgba(0,0,0,1)`,e.globalCompositeOperation=`destination-out`,e.fillRect(t-a/2,i-a/2,a,a),e.globalCompositeOperation=`source-over`,e.fillStyle=r,e.fillRect(t-a/2,i-a/2,a,a),e.restore()})},a=e=>{e?.forEach(e=>{i(t,e,{color:n})})},o=(e,n)=>{let{color:r,compositeOperation:i}=n;t.lineCap=`round`,t.lineJoin=`round`,t.globalCompositeOperation=i,t.save(),t.beginPath(),e?.forEach((e,n)=>{let{x:r,y:i}=e;t.lineWidth=e.lineWidth||10,n===0?t.moveTo(r,i):t.lineTo(r,i)}),i===`source-over`&&(t.strokeStyle=r),t.stroke(),t.restore()},s=e=>{e?.forEach((e,t)=>{o(e,{color:n,compositeOperation:`destination-out`}),o(e,{color:n,compositeOperation:`source-over`})})};self.onmessage=n=>{if(n.data.type===`init`){e=n.data.canvas,t=e.getContext(`2d`);return}if(n.data.type===`draw`){t?.clearRect(0,0,e.width,e.height);let{maskStrokes:i,strokes:o}=n.data;a(i),s(o),r()}}})();