1import{S as le,i as ie,s as $,B as V,C as d,g as C,E as Y,F as H,q as v,aj as zt,G as F,L as P,r as ke,b as j,H as U,R as Ge,am as At,p,l as x,t as A,o as ee,N as Tt,u as It,a1 as be,ad as Bt,ah as xe,D as Rt,M as D,J as q,Q as St,V as Ct,y as fe,e as T,m as B,n as R,ai as He,ap as Et,f as he,a as G,k as Z,a4 as Dt,a6 as Lt,a7 as jt,a8 as Ut,x as qt,a9 as Ht,h as Ft,j as Nt}from"./index-188ef5e8.js";import{f as et,B as Wt}from"./Button-04f93a38.js";import{B as vt}from"./BlockLabel-9f064630.js";/* empty css */import{I as Fe}from"./Image-f4230afc.js";import{C as Ot,i as Xt,U as Yt,W as Jt}from"./StaticImage.svelte_svelte_type_style_lang-84958894.js";import{I as pe,C as Pt,M as Ne}from"./ModifyUpload-23f36109.js";import{U as Qt}from"./Upload-f2cb7efa.js";import{E as Vt}from"./Empty-ba04ef0b.js";import{D as Gt}from"./Download-9303b529.js";import"./Blocks-658f67b5.js";import{U as Zt}from"./UploadText-2a4d151d.js";import{E as _l}from"./Image-c46cdc96.js";import"./ModifyUpload.svelte_svelte_type_style_lang-d2acacf0.js";function Kt(t){let e,n,l;return{c(){e=V("svg"),n=V("path"),l=V("path"),d(n,"d","M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"),d(n,"fill","currentColor"),d(l,"d","M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"),d(l,"fill","currentColor"),d(e,"width","100%"),d(e,"height","100%"),d(e,"viewBox","0 0 32 32")},m(a,r){C(a,e,r),Y(e,n),Y(e,l)},p:H,i:H,o:H,d(a){a&&v(e)}}}class $t extends le{constructor(e){super(),ie(this,e,null,Kt,$,{})}}function xt(t){let e,n,l,a,r,s,u;return{c(){e=V("svg"),n=V("circle"),l=V("circle"),a=V("circle"),r=V("circle"),s=V("circle"),u=V("path"),d(n,"cx","10"),d(n,"cy","12"),d(n,"r","2"),d(n,"fill","currentColor"),d(l,"cx","16"),d(l,"cy","9"),d(l,"r","2"),d(l,"fill","currentColor"),d(a,"cx","22"),d(a,"cy","12"),d(a,"r","2"),d(a,"fill","currentColor"),d(r,"cx","23"),d(r,"cy","18"),d(r,"r","2"),d(r,"fill","currentColor"),d(s,"cx","19"),d(s,"cy","23"),d(s,"r","2"),d(s,"fill","currentColor"),d(u,"fill","currentColor"),d(u,"d","M16.54 2A14 14 0 0 0 2 16a4.82 4.82 0 0 0 6.09 4.65l1.12-.31a3 3 0 0 1 3.79 2.9V27a3 3 0 0 0 3 3a14 14 0 0 0 14-14.54A14.05 14.05 0 0 0 16.54 2Zm8.11 22.31A11.93 11.93 0 0 1 16 28a1 1 0 0 1-1-1v-3.76a5 5 0 0 0-5-5a5.07 5.07 0 0 0-1.33.18l-1.12.31A2.82 2.82 0 0 1 4 16A12 12 0 0 1 16.47 4A12.18 12.18 0 0 1 28 15.53a11.89 11.89 0 0 1-3.35 8.79Z"),d(e,"width","100%"),d(e,"height","100%"),d(e,"viewBox","0 0 32 32")},m(i,f){C(i,e,f),Y(e,n),Y(e,l),Y(e,a),Y(e,r),Y(e,s),Y(e,u)},p:H,i:H,o:H,d(i){i&&v(e)}}}class en extends le{constructor(e){super(),ie(this,e,null,xt,$,{})}}function tn(t){let e,n;return{c(){e=V("svg"),n=V("path"),d(n,"fill","currentColor"),d(n,"d","M7 27h23v2H7zm20.38-16.49l-7.93-7.92a2 2 0 0 0-2.83 0l-14 14a2 2 0 0 0 0 2.83L7.13 24h9.59l10.66-10.66a2 2 0 0 0 0-2.83zM15.89 22H8l-4-4l6.31-6.31l7.93 7.92zm3.76-3.76l-7.92-7.93L18 4l8 7.93z"),d(e,"xmlns","http://www.w3.org/2000/svg"),d(e,"width","100%"),d(e,"height","100%"),d(e,"viewBox","0 0 32 32")},m(l,a){C(l,e,a),Y(e,n)},p:H,i:H,o:H,d(l){l&&v(e)}}}class nn extends le{constructor(e){super(),ie(this,e,null,tn,$,{})}}function ln(t){let e,n;return{c(){e=V("svg"),n=V("path"),d(n,"d","M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"),d(e,"xmlns","http://www.w3.org/2000/svg"),d(e,"width","100%"),d(e,"height","100%"),d(e,"viewBox","0 0 24 24"),d(e,"fill","none"),d(e,"stroke","currentColor"),d(e,"stroke-width","1.5"),d(e,"stroke-linecap","round"),d(e,"stroke-linejoin","round"),d(e,"class","feather feather-edit-2")},m(l,a){C(l,e,a),Y(e,n)},p:H,i:H,o:H,d(l){l&&v(e)}}}let tt=class extends le{constructor(e){super(),ie(this,e,null,ln,$,{})}};const Mt=t=>{let e=t.currentTarget;
1const n=e.getBoundingClientRect(),l=e.naturalWidth/n.width,a=e.naturalHeight/n.height;if(l>a){n.width;const u=e.naturalHeight/l,i=(n.height-u)/2;var r=Math.round((t.clientX-n.left)*l),s=Math.round((t.clientY-n.top-i)*l)}else{const u=e.naturalWidth/a;n.height;const i=(n.width-u)/2;var r=Math.round((t.clientX-n.left-i)*a),s=Math.round((t.clientY-n.top)*a)}return r<0||r>=e.naturalWidth||s<0||s>=e.naturalHeight?null:[r,s]};function sn(t){let e,n;return{c(){e=F("img"),P(e.src,n=t[0])||d(e,"src",n),d(e,"alt","")},m(l,a){C(l,e,a),t[4](e)},p(l,[a]){a&1&&!P(e.src,n=l[0])&&d(e,"src",n)},i:H,o:H,d(l){l&&v(e),t[4](null)}}}function rn(t,e,n){let{image:l}=e,a;const r=ke();let s;function u(){s.destroy()}function i(){s&&u(),s=new Ot(a,{autoCropArea:1,cropend(){const o=s.getCroppedCanvas().toDataURL();r("crop",o)}}),r("crop",l)}function f(o){j[o?"unshift":"push"](()=>{a=o,n(1,a)})}return t.$$set=o=>{"image"in o&&n(0,l=o.image)},[l,a,u,i,f]}class yt extends le{constructor(e){super(),ie(this,e,rn,sn,$,{image:0,destroy:2,create:3})}get image(){return this.$$.ctx[0]}set image(e){this.$$set({image:e}),zt()}get destroy(){return this.$$.ctx[2]}get create(){return this.$$.ctx[3]}}class nt{constructor(e,n){this.x=e,this.y=n}}class lt extends nt{update(e){this.x=e.x,this.y=e.y}moveByAngle(e,n){const l=e+Math.PI/2;this.x=this.x+Math.sin(l)*n,this.y=this.y-Math.cos(l)*n}equalsTo(e){return this.x===e.x&&this.y===e.y}getDifferenceTo(e){return new nt(this.x-e.x,this.y-e.y)}getDistanceTo(e){const n=this.getDifferenceTo(e);return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}getAngleTo(e){const n=this.getDifferenceTo(e);return Math.atan2(n.y,n.x)}toObject(){return{x:this.x,y:this.y}}}const an=30;class un{constructor({radius:e=an,enabled:n=!0,initialPoint:l={x:0,y:0}}={}){this.radius=e,this._isEnabled=n,this.pointer=new lt(l.x,l.y),this.brush=new lt(l.x,l.y),this.angle=0,this.distance=0,this._hasMoved=!1}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}isEnabled(){return this._isEnabled}setRadius(e){this.radius=e}getRadius(){return this.radius}getBrushCoordinates(){return this.brush.toObject()}getPointerCoordinates(){return this.pointer.toObject()}getBrush(){return this.brush}getPointer(){return this.pointer}getAngle(){return this.angle}getDistance(){return this.distance}brushHasMoved(){return this._hasMoved}update(e,{both:n=!1}={}){return this._hasMoved=!1,this.pointer.equalsTo(e)&&!n?!1:(this.pointer.update(e),n?(this._hasMoved=!0,this.brush.update(e),!0):(this._isEnabled?(this.distance=this.pointer.getDistanceTo(this.brush),this.angle=this.pointer.getAngleTo(this.brush),this.distance>this.radius&&(this.brush.moveByAngle(this.angle,this.distance-this.radius),this._hasMoved=!0)):(this.distance=0,this.angle=0,this.brush.update(e),this._hasMoved=!0),!0))}}function it(t,e,n){const l=t.slice();return l[61]=e[n].name,l[62]=e[n].zIndex,l[63]=e,l[64]=n,l}function st(t){let e,n,l;return{c(){e=F("div"),e.textContent="Start drawing",d(e,"class","start-prompt svelte-yigbas")},m(a,r){C(a,e,r),l=!0},i(a){l||(Ge(()=>{l&&(n||(n=xe(e,et,{duration:50},!0)),n.run(1))}),l=!0)},o(a){n||(n=xe(e,et,{duration:50},!1)),n.run(0),l=!1},d(a){a&&v(e),a&&n&&n.end()}}}function rt(t){let e,n=t[61],l,a;const r=()=>t[30](e,n),s=()=>t[30](null,n);return{c(){e=F("canvas"),d(e,"key",t[61]),Rt(e,"z-index",t[62]),d(e,"class","svelte-yigbas"),D(e,"lr",t[5]),D(e,"tb",!t[5])},m(u,i){C(u,e,i),r(),l||(a=[q(e,"mousedown",t[61]==="interface"?t[7]:void 0),q(e,"mousemove",t[61]==="interface"?t[8]:void 0),q(e,"mouseup",t[61]==="interface"?t[9]:void 0),q(e,"mouseout",t[61]==="interface"?t[9]:void 0),q(e,"blur",t[61]==="interface"?t[9]:void 0),q(e,"touchstart",t[61]==="interface"?t[7]:void 0),q(e,"touchmove",t[61]==="interface"?t[8]:void 0),q(e,"touchend",t[61]==="interface"?t[9]:void 0),q(e,"touchcancel",t[61]==="interface"?t[9]:void 0),q(e,"click",St(t[29]))],l=!0)},p(u,i){t=u,n!==t[61]&&(s(),n=t[61],r()),i[0]&32&&D(e,"lr",t[5]),i[0]&32&&D(e,"tb",!t[5])},d(u){u&&v(e),s(),l=!1,Ct(a)}}}function on(t){let e,n,l,a,r=t[4]===0&&st(),s=t[6],u=[];for(let i=0;i<s.length;i+=1)u[i]=rt(it(t,s,i));return{c(){e=F("div"),r&&r.c(),n=U();for(let i=0;i<u.length;i+=1)u[i].c();d(e,"class","wrap svelte-yigbas"),Ge(()=>t[32].call(e))},m(i,f){C(i,e,f),r&&r.m(e,null),Y(e,n);for(let o=0;o<u.length;
1o+=1)u[o]&&u[o].m(e,null);t[31](e),l=At(e,t[32].bind(e)),a=!0},p(i,f){if(i[4]===0?r?f[0]&16&&p(r,1):(r=st(),r.c(),p(r,1),r.m(e,n)):r&&(x(),A(r,1,1,()=>{r=null}),ee()),f[0]&993){s=i[6];let o;for(o=0;o<s.length;o+=1){const g=it(i,s,o);u[o]?u[o].p(g,f):(u[o]=rt(g),u[o].c(),u[o].m(e,null))}for(;o<u.length;o+=1)u[o].d(1);u.length=s.length}},i(i){a||(p(r),a=!0)},o(i){A(r),a=!1},d(i){i&&v(e),r&&r.d(),Tt(u,i),t[31](null),l()}}}let fn="#aaa";function at(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}function _n(t,e,n){let l;const a=ke();let{value:r}=e,{value_img:s}=e,{mode:u="sketch"}=e,{brush_color:i="#0b0f19"}=e,{brush_radius:f}=e,{source:o}=e,{width:g=400}=e,{height:_=200}=e,{container_height:c=200}=e,{shape:b}=e,I,L=g,N=_,J;const me=[{name:"interface",zIndex:15},{name:"drawing",zIndex:11},{name:"temp",zIndex:12},{name:"mask",zIndex:-1},{name:"temp_fake",zIndex:-2}];let S={},k={},E=[],W=[],re=!0,ae=!0,_e=!1,ue=!1,X=null,te=null,O=null,K=0;function se(){if(!b){k.temp.drawImage(s,0,0,g,_);return}let m=s.naturalWidth,M=s.naturalHeight;const y=b[0]/b[1],h=m/M;let z=0,Q=0;y<h?(m=b[1]*h,M=b[1],z=(b[0]-m)/2):y>h?(m=b[0],M=b[0]/h,Q=(b[1]-M)/2):(z=0,Q=0,m=b[0],M=b[1]),k.temp.drawImage(s,z,Q,m,M)}It(async()=>{Object.keys(S).forEach(m=>{n(26,k[m]=S[m].getContext("2d"),k)}),await be(),s&&(s.addEventListener("load",m=>{o==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(s,0,0),k.temp.restore()):se(),k.drawing.drawImage(S.temp,0,0,g,_),oe()}),setTimeout(()=>{o==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(s,0,0),k.temp.restore()):se(),k.drawing.drawImage(S.temp,0,0,g,_),Ae({lines:W.slice()}),oe()},100)),n(28,X=new un({radius:f*.05,enabled:!0,initialPoint:{x:g/2,y:_/2}})),O=new Xt((m,M,...y)=>{Be()}),O.observe(te),Ie(),n(24,I=!0),requestAnimationFrame(()=>{ce(),requestAnimationFrame(()=>{de()})})});function ce(){const m=g/2,M=_/2;X.update({x:m,y:M},{both:!0}),X.update({x:m,y:M},{both:!1}),re=!0,ae=!0}Bt(()=>{n(24,I=!1),O.unobserve(te)});function ne(m){Ue(),s&&(o==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(s,0,0),k.temp.restore()):se(),(!W||!W.length)&&k.drawing.drawImage(S.temp,0,0,g,_)),Ae({lines:m}),n(4,K=m.length),W.length&&n(27,W=m),W.length==0&&a("clear")}function we(){ne([]),oe()}function w(){const m=W.slice(0,-1);ne(m),oe()}let Ae=({lines:m})=>{m.forEach(M=>{const{points:y,brush_color:h,brush_radius:z}=M;Ee({points:y,brush_color:h,brush_radius:z}),u==="mask"&&De({points:y,brush_color:h,brush_radius:z}),E=y}),je(),u==="mask"&&Le()},We=m=>{m.preventDefault(),ue=!0;const{x:M,y}=Re(m);m.touches&&m.touches.length>0&&X.update({x:M,y},{both:!0}),Se(M,y),n(4,K+=1)},ve=m=>{m.preventDefault();const{x:M,y}=Re(m);Se(M,y)},Oe=m=>{m.preventDefault(),ve(m),_e=!1,ue=!1,je(),u==="mask"&&Le()},Me=0,ye=0,ze=0,Te=!1,Be=async()=>{if(b&&te){const y=te?.getBoundingClientRect(),h=b[0]/b[1],z=y.width/y.height;n(5,Te=h<z)}if(g===Me&&_===ye&&ze===c)return;const m={width:g,height:_},M={height:c,width:c*(m.width/m.height)};await Promise.all([ge(S.interface,m,M),ge(S.drawing,m,M),ge(S.temp,m,M),ge(S.temp_fake,m,M),ge(S.mask,m,M,!1)]),f||n(10,f=20*(m.width/M.width)),Ie({once:!0}),setTimeout(()=>{ye=_,Me=g,ze=c},10),await be(),de()},ge=async(m,M,y,h=!0)=>{if(!I)return;await be();const z=window.devicePixelRatio||1;m.width=M.width*(h?z:1),m.height=M.height*(h?z:1);const Q=m.getContext("2d");h&&Q.scale(z,z),m.style.width=`${y.width}px`,m.style.height=`${y.height}px`},Re=m=>{const M=S.interface.getBoundingClientRect();let y=m.clientX,h=m.clientY;return m.changedTouches&&m.changedTouches.length>0&&(y=m.changedTouches[0].clientX,h=m.changedTouches[0].clientY),{x:(y-M.left)/M.width*g,y:(h-M.top)/M.height*_}},Se=(m,M)=>{X.update({x:m,y:M});const y=!X.isEnabled();(ue&&!_e||y&&ue)&&(_e=!0,E.push(X.brush.toObject())),_e&&(E.push(X.brush.toObject()),Ee({points:E,brush_color:i,brush_radius:f}),u==="mask"&&De({points:E,brush_color:i,brush_radius:f})),re=!0},Ee=({points:m,brush_color:M,brush_radius:y})=>{if(!m||m.length<2||(n(26,k.temp.lineJoin="round",k),n(26,k.temp.lineCap="round",k),n(26,k.temp.strokeStyle=M,k),n(26,k.temp.lineWidth=y,k),!m||m.length<2))return;let h=m[0],z=m[1];k.temp.moveTo(z.x,z.y),k.temp.beginPath();for(var Q=1,Ve=m.length;Q<Ve;Q++){var Ce=at(h,z);k.temp.quadraticCurveTo(h.x,h.y,Ce.x,Ce.y),h=m[Q],z=m[Q+1]}k.temp.lineTo(h.x,h.y),k.temp.stroke()},De=({points:m,brush_color:M,brush_radius:y})=>{if(!m||m.length<2)return;n(26,k.temp_fake.lineJoin="round",k),n(26,k.temp_fake.lineCap="round",k),n(26,k.temp_fake.strokeStyle="#fff",k),n(26,k.temp_fake.lineWidth=y,k);let h=m[0],z=m[1];k.temp_fake.moveTo(z.x,z.y),k.temp_fake.beginPath();for(var Q=1,Ve=m.length;Q<Ve;Q++){var Ce=at(h,z);k.temp_fake.quadraticCurveTo(h.x,h.y,Ce.x,Ce.y),h=m[Q],z=m[Q+1]}k.temp_fake.lineTo(h.x,h.y),k.temp_fake.stroke()},Le=()=>{E.length<1||(E.length=0,k.mask.drawImage(S.temp_fake,0,0,g,_),oe())},je=()=>{E.length<1||(W.push({points:E.slice(),brush_color:i,brush_radius:f}),u!=="mask"&&(E.length=0),k.drawing.drawImage(S.temp,0,0,g,_),oe())},oe=()=>{const m=qe();a("change",m)};function de(){return n(27,W=[]),Ue(),n(4,K=0),!0}function Ue(){ae=!0,k.temp.clearRect(0,0,g,_),n(26,k.temp.fillStyle=u==="mask"?"transparent":"#FFFFFF",k),k.temp.fillRect(0,0,g,_),u==="mask"&&(k.temp_fake.clearRect(0,0,S.temp_fake.width,S.temp_fake.height),k.mask.clearRect(0,0,g,_),n(26,k.mask.fillStyle="#000",k),k.mask.fillRect(0,0,g,_))}let Ie=({once:m=!1}={})=>
1{if(re||ae){const M=X.getPointerCoordinates(),y=X.getBrushCoordinates();Xe(k.interface,M,y),re=!1,ae=!1}m||window.requestAnimationFrame(()=>{Ie()})},Xe=(m,M,y)=>{m.clearRect(0,0,g,_),m.beginPath(),m.fillStyle=i,m.arc(y.x,y.y,f/2,0,Math.PI*2,!0),m.fill(),m.beginPath(),m.fillStyle=fn,m.arc(y.x,y.y,l,0,Math.PI*2,!0),m.fill()};function qe(){return u==="mask"?S.mask.toDataURL("image/jpg"):S.drawing.toDataURL("image/jpg")}function Ye(m){fe.call(this,t,m)}function Je(m,M){j[m?"unshift":"push"](()=>{S[M]=m,n(0,S)})}function Pe(m){j[m?"unshift":"push"](()=>{te=m,n(3,te)})}function Qe(){L=this.offsetWidth,N=this.offsetHeight,n(1,L),n(2,N)}return t.$$set=m=>{"value"in m&&n(13,r=m.value),"value_img"in m&&n(14,s=m.value_img),"mode"in m&&n(15,u=m.mode),"brush_color"in m&&n(16,i=m.brush_color),"brush_radius"in m&&n(10,f=m.brush_radius),"source"in m&&n(17,o=m.source),"width"in m&&n(11,g=m.width),"height"in m&&n(12,_=m.height),"container_height"in m&&n(18,c=m.container_height),"shape"in m&&n(19,b=m.shape)},t.$$.update=()=>{t.$$.dirty[0]&530432&&b&&(g||_)&&(n(11,g=b[0]),n(12,_=b[1])),t.$$.dirty[0]&16785408&&I&&!r&&de(),t.$$.dirty[0]&251811841&&I&&s!==J&&(n(25,J=s),de(),setTimeout(()=>{o==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(s,0,0),k.temp.restore()):se(),k.drawing.drawImage(S.temp,0,0,g,_),Ae({lines:W.slice()}),oe()},50)),t.$$.dirty[0]&268436480&&X&&(ce(),X.setRadius(f*.05)),t.$$.dirty[0]&6144&&(g||_)&&Be(),t.$$.dirty[0]&1024&&(l=f*.075)},[S,L,N,te,K,Te,me,We,ve,Oe,f,g,_,r,s,u,i,o,c,b,we,w,de,qe,I,J,k,W,X,Ye,Je,Pe,Qe]}class Ze extends le{constructor(e){super(),ie(this,e,_n,on,$,{value:13,value_img:14,mode:15,brush_color:16,brush_radius:10,source:17,width:11,height:12,container_height:18,shape:19,clear_mask:20,undo:21,clear:22,get_image_data:23},null,[-1,-1,-1])}get clear_mask(){return this.$$.ctx[20]}get undo(){return this.$$.ctx[21]}get clear(){return this.$$.ctx[22]}get get_image_data(){return this.$$.ctx[23]}}function ut(t){let e,n;return e=new pe({props:{Icon:nn,label:"Clear"}}),e.$on("click",t[3]),{c(){T(e.$$.fragment)},m(l,a){B(e,l,a),n=!0},p:H,i(l){n||(p(e.$$.fragment,l),n=!0)},o(l){A(e.$$.fragment,l),n=!1},d(l){R(e,l)}}}function cn(t){let e,n,l,a,r,s;n=new pe({props:{Icon:Yt,label:"Undo"}}),n.$on("click",t[2]);let u=t[0]&&ut(t);return r=new pe({props:{Icon:Pt,label:"Remove Image"}}),r.$on("click",t[4]),{c(){e=F("div"),T(n.$$.fragment),l=U(),u&&u.c(),a=U(),T(r.$$.fragment),d(e,"class","svelte-s6ybro")},m(i,f){C(i,e,f),B(n,e,null),Y(e,l),u&&u.m(e,null),Y(e,a),B(r,e,null),s=!0},p(i,[f]){i[0]?u?(u.p(i,f),f&1&&p(u,1)):(u=ut(i),u.c(),p(u,1),u.m(e,a)):u&&(x(),A(u,1,1,()=>{u=null}),ee())},i(i){s||(p(n.$$.fragment,i),p(u),p(r.$$.fragment,i),s=!0)},o(i){A(n.$$.fragment,i),A(u),A(r.$$.fragment,i),s=!1},d(i){i&&v(e),R(n),u&&u.d(),R(r)}}}function hn(t,e,n){const l=ke();let{show_eraser:a=!1}=e;const r=()=>l("undo"),s=i=>{l("clear_mask"),i.stopPropagation()},u=i=>{l("remove_image"),i.stopPropagation()};return t.$$set=i=>{"show_eraser"in i&&n(0,a=i.show_eraser)},[a,l,r,s,u]}class Ke extends le{constructor(e){super(),ie(this,e,hn,cn,$,{show_eraser:0})}}function ot(t){let e,n,l,a,r;return{c(){e=F("input"),d(e,"aria-label","Brush radius"),d(e,"type","range"),d(e,"min",n=.5*(t[2]/t[6])),d(e,"max",l=75*(t[2]/t[6])),d(e,"class","svelte-p4aq0j")},m(s,u){C(s,e,u),He(e,t[0]),a||(r=[q(e,"change",t[10]),q(e,"input",t[10])],a=!0)},p(s,u){u&68&&n!==(n=.5*(s[2]/s[6]))&&d(e,"min",n),u&68&&l!==(l=75*(s[2]/s[6]))&&d(e,"max",l),u&1&&He(e,s[0])},d(s){s&&v(e),a=!1,Ct(r)}}}function ft(t){let e,n,l,a;n=new pe({props:{Icon:en,label:"Select brush color"}}),n.$on("click",t[11]);let r=t[5]&&_t(t);return{c(){e=F("span"),T(n.$$.fragment),l=U(),r&&r.c(),d(e,"class","col svelte-p4aq0j")},m(s,u){C(s,e,u),B(n,e,null),Y(e,l),r&&r.m(e,null),a=!0},p(s,u){s[5]?r?r.p(s,u):(r=_t(s),r.c(),r.m(e,null)):r&&(r.d(1),r=null)},i(s){a||(p(n.$$.fragment,s),a=!0)},o(s){A(n.$$.fragment,s),a=!1},d(s){s&&v(e),R(n),r&&r.d()}}}function _t(t){let e,n,l;return{c(){e=F("input"),d(e,"aria-label","Brush color"),d(e,"type","color"),d(e,"class","svelte-p4aq0j")},m(a,r){C(a,e,r),He(e,t[1]),n||(l=q(e,"input",t[12]),n=!0)},p(a,r){r&2&&He(e,a[1])},d(a){a&&v(e),n=!1,l()}}}function mn(t){let e,n,l,a,r,s;l=new pe({props:{Icon:$t,label:"Use brush"}}),l.$on("click",t[9]);let u=t[4]&&ot(t),i=t[3]!=="mask"&&ft(t);return{c(){e=F("div"),n=F("span"),T(l.$$.fragment),a=U(),u&&u.c(),r=U(),i&&i.c(),d(n,"class","brush svelte-p4aq0j"),d(e,"class","wrap svelte-p4aq0j")},m(f,o){C(f,e,o),Y(e,n),B(l,n,null),Y(n,a),u&&u.m(n,null),Y(e,r),i&&i.m(e,null),s=!0},p(f,[o]){f[4]?u?u.p(f,o):(u=ot(f),u.c(),u.m(n,null)):u&&(u.d(1),u=null),f[3]!=="mask"?i?(i.p(f,o),o&8&&p(i,1)):(i=ft(f),i.c(),p(i,1),i.m(e,null)):i&&(x(),A(i,1,1,()=>{i=null}),ee())},i(f){s||(p(l.$$.fragment,f),p(i),s=!0)},o(f){A(l.$$.fragment,f),A(i),s=!1},d(f){f&&v(e),R(l),u&&u.d(),i&&i.d()}}}function gn(t,e,n){let l;ke();let a=!1,r=!1,{brush_radius:s=20}=e,{brush_color:u="#000"}=e,{container_height:i}=e,{img_width:f}=e,{img_height:o}=e,{mode:g="other"}=e;const _=()=>n(4,a=!a);function c(){s=Et(this.value),n(0,s)}const b=()=>n(5,r=!r);
1function I(){u=this.value,n(1,u)}return t.$$set=L=>{"brush_radius"in L&&n(0,s=L.brush_radius),"brush_color"in L&&n(1,u=L.brush_color),"container_height"in L&&n(7,i=L.container_height),"img_width"in L&&n(2,f=L.img_width),"img_height"in L&&n(8,o=L.img_height),"mode"in L&&n(3,g=L.mode)},t.$$.update=()=>{t.$$.dirty&388&&n(6,l=i*(f/o))},[s,u,f,g,a,r,l,i,o,_,c,b,I]}class $e extends le{constructor(e){super(),ie(this,e,gn,mn,$,{brush_radius:0,brush_color:1,container_height:7,img_width:2,img_height:8,mode:3})}}function dn(t){let e,n,l,a;return{c(){e=F("img"),P(e.src,n=t[0].image||t[0])||d(e,"src",n),d(e,"alt",""),d(e,"class","svelte-p3y7hu"),D(e,"webcam",t[5]==="webcam"&&t[9]),D(e,"selectable",t[10])},m(r,s){C(r,e,s),l||(a=q(e,"click",t[29]),l=!0)},p(r,s){s[0]&1&&!P(e.src,n=r[0].image||r[0])&&d(e,"src",n),s[0]&544&&D(e,"webcam",r[5]==="webcam"&&r[9]),s[0]&1024&&D(e,"selectable",r[10])},i:H,o:H,d(r){r&&v(e),l=!1,a()}}}function bn(t){let e=t[21],n,l,a,r=ct(t),s=t[16]>0&&ht(t);return{c(){r.c(),n=U(),s&&s.c(),l=he()},m(u,i){r.m(u,i),C(u,n,i),s&&s.m(u,i),C(u,l,i),a=!0},p(u,i){i[0]&2097152&&$(e,e=u[21])?(r.d(1),r=ct(u),r.c(),r.m(n.parentNode,n)):r.p(u,i),u[16]>0?s?(s.p(u,i),i[0]&65536&&p(s,1)):(s=ht(u),s.c(),p(s,1),s.m(l.parentNode,l)):s&&(x(),A(s,1,1,()=>{s=null}),ee())},i(u){a||(p(s),a=!0)},o(u){A(s),a=!1},d(u){r.d(u),u&&v(n),s&&s.d(u),u&&v(l)}}}function kn(t){let e,n,l,a,r,s,u;return e=new Ne({props:{editable:!0}}),e.$on("edit",t[52]),e.$on("clear",t[24]),{c(){T(e.$$.fragment),n=U(),l=F("img"),P(l.src,a=t[0])||d(l,"src",a),d(l,"alt",""),d(l,"class","svelte-p3y7hu"),D(l,"selectable",t[10]),D(l,"webcam",t[5]==="webcam"&&t[9])},m(i,f){B(e,i,f),C(i,n,f),C(i,l,f),r=!0,s||(u=q(l,"click",t[29]),s=!0)},p(i,f){(!r||f[0]&1&&!P(l.src,a=i[0]))&&d(l,"src",a),(!r||f[0]&1024)&&D(l,"selectable",i[10]),(!r||f[0]&544)&&D(l,"webcam",i[5]==="webcam"&&i[9])},i(i){r||(p(e.$$.fragment,i),r=!0)},o(i){A(e.$$.fragment,i),r=!1},d(i){R(e,i),i&&v(n),i&&v(l),s=!1,u()}}}function pn(t){let e,n,l,a,r={image:t[0]};return e=new yt({props:r}),t[50](e),e.$on("crop",t[25]),l=new Ne({}),l.$on("clear",t[51]),{c(){T(e.$$.fragment),n=U(),T(l.$$.fragment)},m(s,u){B(e,s,u),C(s,n,u),B(l,s,u),a=!0},p(s,u){const i={};u[0]&1&&(i.image=s[0]),e.$set(i)},i(s){a||(p(e.$$.fragment,s),p(l.$$.fragment,s),a=!0)},o(s){A(e.$$.fragment,s),A(l.$$.fragment,s),a=!1},d(s){t[50](null),R(e,s),s&&v(n),R(l,s)}}}function wn(t){let e,n,l=t[5]==="webcam"&&!t[21]&>(t);return{c(){l&&l.c(),e=he()},m(a,r){l&&l.m(a,r),C(a,e,r),n=!0},p(a,r){a[5]==="webcam"&&!a[21]?l?(l.p(a,r),r[0]&2097184&&p(l,1)):(l=gt(a),l.c(),p(l,1),l.m(e.parentNode,e)):l&&(x(),A(l,1,1,()=>{l=null}),ee())},i(a){n||(p(l),n=!0)},o(a){A(l),n=!1},d(a){l&&l.d(a),a&&v(e)}}}function An(t){let e,n,l,a,r,s,u;e=new Ke({}),e.$on("undo",t[42]),e.$on("remove_image",t[27]);let i=t[1]==="color-sketch"&&dt(t);function f(_){t[45](_)}function o(_){t[46](_)}let g={value:t[0],mode:t[13],width:t[16]||t[20],height:t[15]||t[19],container_height:t[17]||t[19],shape:t[6]};return t[2]!==void 0&&(g.brush_radius=t[2]),t[22]!==void 0&&(g.brush_color=t[22]),a=new Ze({props:g}),j.push(()=>G(a,"brush_radius",f)),j.push(()=>G(a,"brush_color",o)),t[47](a),a.$on("change",t[25]),a.$on("clear",t[27]),{c(){T(e.$$.fragment),n=U(),i&&i.c(),l=U(),T(a.$$.fragment)},m(_,c){B(e,_,c),C(_,n,c),i&&i.m(_,c),C(_,l,c),B(a,_,c),u=!0},p(_,c){_[1]==="color-sketch"?i?(i.p(_,c),c[0]&2&&p(i,1)):(i=dt(_),i.c(),p(i,1),i.m(l.parentNode,l)):i&&(x(),A(i,1,1,()=>{i=null}),ee());const b={};c[0]&1&&(b.value=_[0]),c[0]&8192&&(b.mode=_[13]),c[0]&1114112&&(b.width=_[16]||_[20]),c[0]&557056&&(b.height=_[15]||_[19]),c[0]&655360&&(b.container_height=_[17]||_[19]),c[0]&64&&(b.shape=_[6]),!r&&c[0]&4&&(r=!0,b.brush_radius=_[2],Z(()=>r=!1)),!s&&c[0]&4194304&&(s=!0,b.brush_color=_[22],Z(()=>s=!1)),a.$set(b)},i(_){u||(p(e.$$.fragment,_),p(i),p(a.$$.fragment,_),u=!0)},o(_){A(e.$$.fragment,_),A(i),A(a.$$.fragment,_),u=!1},d(_){R(e,_),_&&v(n),i&&i.d(_),_&&v(l),t[47](null),R(a,_)}}}function In(t){let e,n,l;function a(s){t[41](s)}let r={filetype:"image/*",include_file_metadata:!1,disable_click:!!t[0],$$slots:{default:[Tn]},$$scope:{ctx:t}};return t[12]!==void 0&&(r.dragging=t[12]),e=new Qt({props:r}),j.push(()=>G(e,"dragging",a)),e.$on("load",t[23]),{c(){T(e.$$.fragment)},m(s,u){B(e,s,u),l=!0},p(s,u){const i={};u[0]&1&&(i.disable_click=!!s[0]),u[0]&8384231|u[1]&1073741824&&(i.$$scope={dirty:u,ctx:s}),!n&&u[0]&4096&&(n=!0,i.dragging=s[12],Z(()=>n=!1)),e.$set(i)},i(s){l||(p(e.$$.fragment,s),l=!0)},o(s){A(e.$$.fragment,s),l=!1},d(s){R(e,s)}}}function ct(t){let e,n,l,a;
1return{c(){e=F("img"),d(e,"class","absolute-img svelte-p3y7hu"),P(e.src,n=t[21]||t[0]?.image||t[0])||d(e,"src",n),d(e,"alt",""),D(e,"webcam",t[5]==="webcam"&&t[9])},m(r,s){C(r,e,s),t[53](e),l||(a=q(e,"load",t[26]),l=!0)},p(r,s){s[0]&2097153&&!P(e.src,n=r[21]||r[0]?.image||r[0])&&d(e,"src",n),s[0]&544&&D(e,"webcam",r[5]==="webcam"&&r[9])},d(r){r&&v(e),t[53](null),l=!1,a()}}}function ht(t){let e,n,l,a,r,s,u,i;function f(c){t[55](c)}function o(c){t[56](c)}let g={value:t[0],mode:t[13],width:t[16]||t[20],height:t[15]||t[19],container_height:t[17]||t[19],value_img:t[18],source:t[5]};t[2]!==void 0&&(g.brush_radius=t[2]),t[22]!==void 0&&(g.brush_color=t[22]),e=new Ze({props:g}),t[54](e),j.push(()=>G(e,"brush_radius",f)),j.push(()=>G(e,"brush_color",o)),e.$on("change",t[25]),r=new Ke({}),r.$on("undo",t[57]),r.$on("remove_image",t[27]);let _=(t[1]==="color-sketch"||t[1]==="sketch")&&mt(t);return{c(){T(e.$$.fragment),a=U(),T(r.$$.fragment),s=U(),_&&_.c(),u=he()},m(c,b){B(e,c,b),C(c,a,b),B(r,c,b),C(c,s,b),_&&_.m(c,b),C(c,u,b),i=!0},p(c,b){const I={};b[0]&1&&(I.value=c[0]),b[0]&8192&&(I.mode=c[13]),b[0]&1114112&&(I.width=c[16]||c[20]),b[0]&557056&&(I.height=c[15]||c[19]),b[0]&655360&&(I.container_height=c[17]||c[19]),b[0]&262144&&(I.value_img=c[18]),b[0]&32&&(I.source=c[5]),!n&&b[0]&4&&(n=!0,I.brush_radius=c[2],Z(()=>n=!1)),!l&&b[0]&4194304&&(l=!0,I.brush_color=c[22],Z(()=>l=!1)),e.$set(I),c[1]==="color-sketch"||c[1]==="sketch"?_?(_.p(c,b),b[0]&2&&p(_,1)):(_=mt(c),_.c(),p(_,1),_.m(u.parentNode,u)):_&&(x(),A(_,1,1,()=>{_=null}),ee())},i(c){i||(p(e.$$.fragment,c),p(r.$$.fragment,c),p(_),i=!0)},o(c){A(e.$$.fragment,c),A(r.$$.fragment,c),A(_),i=!1},d(c){t[54](null),R(e,c),c&&v(a),R(r,c),c&&v(s),_&&_.d(c),c&&v(u)}}}function mt(t){let e,n,l,a;function r(i){t[58](i)}function s(i){t[59](i)}let u={container_height:t[17]||t[19],img_width:t[16]||t[20],img_height:t[15]||t[19],mode:t[13]};return t[2]!==void 0&&(u.brush_radius=t[2]),t[22]!==void 0&&(u.brush_color=t[22]),e=new $e({props:u}),j.push(()=>G(e,"brush_radius",r)),j.push(()=>G(e,"brush_color",s)),{c(){T(e.$$.fragment)},m(i,f){B(e,i,f),a=!0},p(i,f){const o={};f[0]&655360&&(o.container_height=i[17]||i[19]),f[0]&1114112&&(o.img_width=i[16]||i[20]),f[0]&557056&&(o.img_height=i[15]||i[19]),f[0]&8192&&(o.mode=i[13]),!n&&f[0]&4&&(n=!0,o.brush_radius=i[2],Z(()=>n=!1)),!l&&f[0]&4194304&&(l=!0,o.brush_color=i[22],Z(()=>l=!1)),e.$set(o)},i(i){a||(p(e.$$.fragment,i),a=!0)},o(i){A(e.$$.fragment,i),a=!1},d(i){R(e,i)}}}function gt(t){let e,n;return e=new Jt({props:{streaming:t[7],pending:t[8],mirror_webcam:t[9]}}),e.$on("capture",t[48]),e.$on("stream",t[25]),e.$on("error",t[49]),{c(){T(e.$$.fragment)},m(l,a){B(e,l,a),n=!0},p(l,a){const r={};a[0]&128&&(r.streaming=l[7]),a[0]&256&&(r.pending=l[8]),a[0]&512&&(r.mirror_webcam=l[9]),e.$set(r)},i(l){n||(p(e.$$.fragment,l),n=!0)},o(l){A(e.$$.fragment,l),n=!1},d(l){R(e,l)}}}function dt(t){let e,n,l,a;function r(i){t[43](i)}function s(i){t[44](i)}let u={container_height:t[17]||t[19],img_width:t[16]||t[20],img_height:t[15]||t[19]};return t[2]!==void 0&&(u.brush_radius=t[2]),t[22]!==void 0&&(u.brush_color=t[22]),e=new $e({props:u}),j.push(()=>G(e,"brush_radius",r)),j.push(()=>G(e,"brush_color",s)),{c(){T(e.$$.fragment)},m(i,f){B(e,i,f),a=!0},p(i,f){const o={};f[0]&655360&&(o.container_height=i[17]||i[19]),f[0]&1114112&&(o.img_width=i[16]||i[20]),f[0]&557056&&(o.img_height=i[15]||i[19]),!n&&f[0]&4&&(n=!0,o.brush_radius=i[2],Z(()=>n=!1)),!l&&f[0]&4194304&&(l=!0,o.brush_color=i[22],Z(()=>l=!1)),e.$set(o)},i(i){a||(p(e.$$.fragment,i),a=!0)},o(i){A(e.$$.fragment,i),a=!1},d(i){R(e,i)}}}function Cn(t){let e,n,l,a;return{c(){e=F("img"),P(e.src,n=t[0].image||t[0])||d(e,"src",n),d(e,"alt","hello"),d(e,"class","svelte-p3y7hu"),D(e,"webcam",t[5]==="webcam"&&t[9]),D(e,"selectable",t[10])},m(r,s){C(r,e,s),l||(a=q(e,"click",t[29]),l=!0)},p(r,s){s[0]&1&&!P(e.src,n=r[0].image||r[0])&&d(e,"src",n),s[0]&544&&D(e,"webcam",r[5]==="webcam"&&r[9]),s[0]&1024&&D(e,"selectable",r[10])},i:H,o:H,d(r){r&&v(e),l=!1,a()}}}function vn(t){let e=t[21],n,l,a,r=bt(t),s=t[16]>0&&kt(t);return{c(){r.c(),n=U(),s&&s.c(),l=he()},m(u,i){r.m(u,i),C(u,n,i),s&&s.m(u,i),C(u,l,i),a=!0},p(u,i){i[0]&2097152&&$(e,e=u[21])?(r.d(1),r=bt(u),r.c(),r.m(n.parentNode,n)):r.p(u,i),u[16]>0?s?(s.p(u,i),i[0]&65536&&p(s,1)):(s=kt(u),s.c(),p(s,1),s.m(l.parentNode,l)):s&&(x(),A(s,1,1,()=>{s=null}),ee())},i(u){a||(p(s),a=!0)},o(u){A(s),a=!1},d(u){r.d(u),u&&v(n),s&&s.d(u),u&&v(l)}}}function Mn(t){let e,n,l,a,r,s,u;return e=new Ne({props:{editable:!0}}),e.$on("edit",t[33]),e.$on("clear",t[24]),{c(){T(e.$$.fragment),n=U(),l=F("img"),P(l.src,a=t[0])||d(l,"src",a),d(l,"alt",""),d(l,"class","svelte-p3
1y7hu"),D(l,"scale-x-[-1]",t[5]==="webcam"&&t[9]),D(l,"selectable",t[10])},m(i,f){B(e,i,f),C(i,n,f),C(i,l,f),r=!0,s||(u=q(l,"click",t[29]),s=!0)},p(i,f){(!r||f[0]&1&&!P(l.src,a=i[0]))&&d(l,"src",a),(!r||f[0]&544)&&D(l,"scale-x-[-1]",i[5]==="webcam"&&i[9]),(!r||f[0]&1024)&&D(l,"selectable",i[10])},i(i){r||(p(e.$$.fragment,i),r=!0)},o(i){A(e.$$.fragment,i),r=!1},d(i){R(e,i),i&&v(n),i&&v(l),s=!1,u()}}}function yn(t){let e,n,l,a,r={image:t[0]};return e=new yt({props:r}),t[31](e),e.$on("crop",t[25]),l=new Ne({}),l.$on("clear",t[32]),{c(){T(e.$$.fragment),n=U(),T(l.$$.fragment)},m(s,u){B(e,s,u),C(s,n,u),B(l,s,u),a=!0},p(s,u){const i={};u[0]&1&&(i.image=s[0]),e.$set(i)},i(s){a||(p(e.$$.fragment,s),p(l.$$.fragment,s),a=!0)},o(s){A(e.$$.fragment,s),A(l.$$.fragment,s),a=!1},d(s){t[31](null),R(e,s),s&&v(n),R(l,s)}}}function zn(t){let e;const n=t[30].default,l=Dt(n,t,t[61],null);return{c(){l&&l.c()},m(a,r){l&&l.m(a,r),e=!0},p(a,r){l&&l.p&&(!e||r[1]&1073741824)&&Lt(l,n,a,a[61],e?Ut(n,a[61],r,null):jt(a[61]),null)},i(a){e||(p(l,a),e=!0)},o(a){A(l,a),e=!1},d(a){l&&l.d(a)}}}function bt(t){let e,n,l,a;return{c(){e=F("img"),d(e,"class","absolute-img svelte-p3y7hu"),P(e.src,n=t[21]||t[0]?.image||t[0])||d(e,"src",n),d(e,"alt",""),D(e,"webcam",t[5]==="webcam"&&t[9])},m(r,s){C(r,e,s),t[34](e),l||(a=q(e,"load",t[26]),l=!0)},p(r,s){s[0]&2097153&&!P(e.src,n=r[21]||r[0]?.image||r[0])&&d(e,"src",n),s[0]&544&&D(e,"webcam",r[5]==="webcam"&&r[9])},d(r){r&&v(e),t[34](null),l=!1,a()}}}function kt(t){let e,n,l,a,r,s,u,i;function f(c){t[36](c)}function o(c){t[37](c)}let g={value:t[0],mode:t[13],width:t[16]||t[20],height:t[15]||t[19],container_height:t[17]||t[19],value_img:t[18],source:t[5],shape:t[6]};t[2]!==void 0&&(g.brush_radius=t[2]),t[22]!==void 0&&(g.brush_color=t[22]),e=new Ze({props:g}),t[35](e),j.push(()=>G(e,"brush_radius",f)),j.push(()=>G(e,"brush_color",o)),e.$on("change",t[25]),r=new Ke({props:{show_eraser:t[18]}}),r.$on("undo",t[38]),r.$on("clear_mask",t[28]),r.$on("remove_image",t[27]);let _=(t[1]==="color-sketch"||t[1]==="sketch")&&pt(t);return{c(){T(e.$$.fragment),a=U(),T(r.$$.fragment),s=U(),_&&_.c(),u=he()},m(c,b){B(e,c,b),C(c,a,b),B(r,c,b),C(c,s,b),_&&_.m(c,b),C(c,u,b),i=!0},p(c,b){const I={};b[0]&1&&(I.value=c[0]),b[0]&8192&&(I.mode=c[13]),b[0]&1114112&&(I.width=c[16]||c[20]),b[0]&557056&&(I.height=c[15]||c[19]),b[0]&655360&&(I.container_height=c[17]||c[19]),b[0]&262144&&(I.value_img=c[18]),b[0]&32&&(I.source=c[5]),b[0]&64&&(I.shape=c[6]),!n&&b[0]&4&&(n=!0,I.brush_radius=c[2],Z(()=>n=!1)),!l&&b[0]&4194304&&(l=!0,I.brush_color=c[22],Z(()=>l=!1)),e.$set(I);const L={};b[0]&262144&&(L.show_eraser=c[18]),r.$set(L),c[1]==="color-sketch"||c[1]==="sketch"?_?(_.p(c,b),b[0]&2&&p(_,1)):(_=pt(c),_.c(),p(_,1),_.m(u.parentNode,u)):_&&(x(),A(_,1,1,()=>{_=null}),ee())},i(c){i||(p(e.$$.fragment,c),p(r.$$.fragment,c),p(_),i=!0)},o(c){A(e.$$.fragment,c),A(r.$$.fragment,c),A(_),i=!1},d(c){t[35](null),R(e,c),c&&v(a),R(r,c),c&&v(s),_&&_.d(c),c&&v(u)}}}function pt(t){let e,n,l,a;function r(i){t[39](i)}function s(i){t[40](i)}let u={container_height:t[17]||t[19],img_width:t[16]||t[20],img_height:t[15]||t[19],mode:t[13]};return t[2]!==void 0&&(u.brush_radius=t[2]),t[22]!==void 0&&(u.brush_color=t[22]),e=new $e({props:u}),j.push(()=>G(e,"brush_radius",r)),j.push(()=>G(e,"brush_color",s)),{c(){T(e.$$.fragment)},m(i,f){B(e,i,f),a=!0},p(i,f){const o={};f[0]&655360&&(o.container_height=i[17]||i[19]),f[0]&1114112&&(o.img_width=i[16]||i[20]),f[0]&557056&&(o.img_height=i[15]||i[19]),f[0]&8192&&(o.mode=i[13]),!n&&f[0]&4&&(n=!0,o.brush_radius=i[2],Z(()=>n=!1)),!l&&f[0]&4194304&&(l=!0,o.brush_color=i[22],Z(()=>l=!1)),e.$set(o)},i(i){a||(p(e.$$.fragment,i),a=!0)},o(i){A(e.$$.fragment,i),a=!1},d(i){R(e,i)}}}function Tn(t){let e,n,l,a;const r=[zn,yn,Mn,vn,Cn],s=[];function u(i,f){return i[0]===null&&!i[21]||i[7]?0:i[1]==="select"?1:i[1]==="editor"?2:(i[1]==="sketch"||i[1]==="color-sketch")&&(i[0]!==null||i[21])?3:4}return e=u(t),n=s[e]=r[e](t),{c(){n.c(),l=he()},m(i,f){s[e].m(i,f),C(i,l,f),a=!0},p(i,f){let o=e;e=u(i),e===o?s[e].p(i,f):(x(),A(s[o],1,1,()=>{s[o]=null}),ee(),n=s[e],n?n.p(i,f):(n=s[e]=r[e](i),n.c()),p(n,1),n.m(l.parentNode,l))},i(i){a||(p(n),a=!0)},o(i){A(n),a=!1},d(i){s[e].d(i),i&&v(l)}}}function Bn(t){let e,n,l,a,r,s,u;e=new vt({props:{show_label:t[4],Icon:t[5]==="canvas"?tt:Fe,label:t[3]||(t[5]==="canvas"?"Sketch":"Image")}});const i=[In,An,wn,pn,kn,bn,dn],f=[];function o(g,_){return g[5]==="upload"?0:g[5]==="canvas"?1:g[0]===null&&!g[21]||g[7]?2:g[1]==="select"?3:g[1]==="editor"?4:(g[1]==="sketch"||g[1]==="color-sketch")&&(g[0]!==null||g[21])?5:6}return a=o(t),r=f[a]=i[a](t),{c(){T(e.$$.fragment),n=U(),l=F("div"),r.c(),d(l,"data-testid","image"),d(l,"class","image-container svelte-p3
1y7hu"),Ge(()=>t[60].call(l))},m(g,_){B(e,g,_),C(g,n,_),C(g,l,_),f[a].m(l,null),s=At(l,t[60].bind(l)),u=!0},p(g,_){const c={};_[0]&16&&(c.show_label=g[4]),_[0]&32&&(c.Icon=g[5]==="canvas"?tt:Fe),_[0]&40&&(c.label=g[3]||(g[5]==="canvas"?"Sketch":"Image")),e.$set(c);let b=a;a=o(g),a===b?f[a].p(g,_):(x(),A(f[b],1,1,()=>{f[b]=null}),ee(),r=f[a],r?r.p(g,_):(r=f[a]=i[a](g),r.c()),p(r,1),r.m(l,null))},i(g){u||(p(e.$$.fragment,g),p(r),u=!0)},o(g){A(e.$$.fragment,g),A(r),u=!1},d(g){R(e,g),g&&v(n),g&&v(l),f[a].d(),s()}}}function Rn(t,e,n){let l,{$$slots:a={},$$scope:r}=e,{value:s}=e,{label:u=void 0}=e,{show_label:i}=e,{source:f="upload"}=e,{tool:o="editor"}=e,{shape:g}=e,{streaming:_=!1}=e,{pending:c=!1}=e,{mirror_webcam:b}=e,{brush_radius:I}=e,{selectable:L=!1}=e,N,J;s&&(f==="upload"||f==="webcam")&&o==="sketch"&&(s={image:s,mask:null});function me({detail:h}){o==="color-sketch"?n(21,ne=h):n(0,s=(f==="upload"||f==="webcam")&&o==="sketch"?{image:h,mask:null}:h),E("upload",h)}function S({detail:h}){n(0,s=null),n(21,ne=void 0),E("clear")}async function k({detail:h},z){O==="mask"?f==="webcam"&&z?n(0,s={image:h,mask:null}):n(0,s={image:typeof s=="string"?s:s?.image||null,mask:h}):(f==="upload"||f==="webcam")&&o==="sketch"?n(0,s={image:h,mask:null}):n(0,s=h),await be(),E(_?"stream":"edit")}const E=ke();let W=!1;function re(h){const z=h.currentTarget;n(16,X=z.naturalWidth),n(15,ue=z.naturalHeight),n(17,te=z.getBoundingClientRect().height)}async function ae(){N.clear(),await be(),n(0,s=null),n(21,ne=void 0)}async function _e(){N.clear_mask(),await be()}let ue=0,X=0,te=0,O,K,se,ce,ne;It(async()=>{o==="color-sketch"&&s&&typeof s=="string"&&(n(21,ne=s),await be(),re({currentTarget:K}))});const we=h=>{let z=Mt(h);z&&E("select",{index:z,value:null})};function w(h){j[h?"unshift":"push"](()=>{J=h,n(11,J),n(0,s)})}const Ae=h=>(S(h),n(1,o="editor")),We=()=>n(1,o="select");function ve(h){j[h?"unshift":"push"](()=>{K=h,n(18,K)})}function Oe(h){j[h?"unshift":"push"](()=>{N=h,n(14,N)})}function Me(h){I=h,n(2,I)}function ye(h){l=h,n(22,l),n(13,O),n(5,f),n(1,o)}const ze=()=>N.undo();function Te(h){I=h,n(2,I)}function Be(h){l=h,n(22,l),n(13,O),n(5,f),n(1,o)}function ge(h){W=h,n(12,W)}const Re=()=>N.undo();function Se(h){I=h,n(2,I)}function Ee(h){l=h,n(22,l),n(13,O),n(5,f),n(1,o)}function De(h){I=h,n(2,I)}function Le(h){l=h,n(22,l),n(13,O),n(5,f),n(1,o)}function je(h){j[h?"unshift":"push"](()=>{N=h,n(14,N)})}const oe=h=>o==="color-sketch"?me(h):k(h,!0);function de(h){fe.call(this,t,h)}function Ue(h){j[h?"unshift":"push"](()=>{J=h,n(11,J),n(0,s)})}const Ie=h=>(S(h),n(1,o="editor")),Xe=()=>n(1,o="select");function qe(h){j[h?"unshift":"push"](()=>{K=h,n(18,K)})}function Ye(h){j[h?"unshift":"push"](()=>{N=h,n(14,N)})}function Je(h){I=h,n(2,I)}function Pe(h){l=h,n(22,l),n(13,O),n(5,f),n(1,o)}const Qe=()=>N.undo();function m(h){I=h,n(2,I)}function M(h){l=h,n(22,l),n(13,O),n(5,f),n(1,o)}function y(){se=this.offsetHeight,ce=this.offsetWidth,n(19,se),n(20,ce)}return t.$$set=h=>{"value"in h&&n(0,s=h.value),"label"in h&&n(3,u=h.label),"show_label"in h&&n(4,i=h.show_label),"source"in h&&n(5,f=h.source),"tool"in h&&n(1,o=h.tool),"shape"in h&&n(6,g=h.shape),"streaming"in h&&n(7,_=h.streaming),"pending"in h&&n(8,c=h.pending),"mirror_webcam"in h&&n(9,b=h.mirror_webcam),"brush_radius"in h&&n(2,I=h.brush_radius),"selectable"in h&&n(10,L=h.selectable),"$$scope"in h&&n(61,r=h.$$scope)},t.$$.update=()=>{t.$$.dirty[0]&1&&E("change",s),t.$$.dirty[0]&4096&&E("drag",W),t.$$.dirty[0]&34&&(f==="canvas"&&o==="sketch"?n(13,O="bw-sketch"):o==="color-sketch"?n(13,O="color-sketch"):(f==="upload"||f==="webcam")&&o==="sketch"?n(13,O="mask"):n(13,O="editor")),t.$$.dirty[0]&8192&&n(22,l=O=="mask"?"#000000":"#000"),t.$$.dirty[0]&1&&(s===null||s.image===null&&s.mask===null)&&n(21,ne=void 0),t.$$.dirty[0]&2049&&J&&(s?(n(11,J.image=s,J),J.create()):J.destroy())},[s,o,I,u,i,f,g,_,c,b,L,J,W,O,N,ue,X,te,K,se,ce,ne,l,me,S,k,re,ae,_e,we,a,w,Ae,We,ve,Oe,Me,ye,ze,Te,Be,ge,Re,Se,Ee,De,Le,je,oe,de,Ue,Ie,Xe,qe,Ye,Je,Pe,Qe,m,M,y,r]}let Sn=class extends le{constructor(e){super(),ie(this,e,Rn,Bn,$,{value:0,label:3,show_label:4,source:5,tool:1,shape:6,streaming:7,pending:8,mirror_webcam:9,brush_radius:2,selectable:10},null,[-1,-1,-1])}};function En(t){let e,n,l,a,r,s,u,i,f;return l=new pe({props:{Icon:Gt,label:"Download"}}),{c(){e=F("div"),n=F("a"),T(l.$$.fragment),a=U(),r=F("img"),d(n,"href",t[0]),d(n,"target",window.__is_colab__?"_blank":null),d(n,"download","image"),d(e,"class","download svelte-ms5bsk"),P(r.src,s=t[0])||d(r,"src",s),d(r,"alt",""),d(r,"class","svelte-ms5bsk"),D(r,"selectable",t[3])},m(o,g){C(o,e,g),Y(e,n),B(l,n,null),C(o,a,g),C(o,r,g),u=!0,i||(f=q(r,"click",t[4]),i=!0)},p(o,g){(!u||g&1)&&d(n,"href",o[0]),(!u||g&1&&!P(r.src,s=o[0]))&&d(r,"src",s),(!u||g&8)&&D(r,"selectable",o[3])},i(o){u||(p(l.$$.fragment,o),u=!0)},o(o){A(l.$$.fragment,o),u=!1},d(o){o&&v(e),R(l),o&&v(a),o&&v(r),i=!1,f()}}}function Dn(t){let e,n;return e=new Vt({props:{unpadded_box:!0,size:"large",$$slots:{default:[Ln]},$$scope:{ctx:t}}}),{c(){T(e.$$.fragment)},m(l,a){B(e,l,a),n=!0},p(l,a){const r={};a&64&&(r.$$scope={dirty:a,ctx:l}),e.$set(r)},i(l){n||(p(e.$$.fragment,l),n=!0)},o(l){A(e.$$.fragment,l),n=!1},d(l){R(e,l)}}}function Ln(t){let e,n;return e=new Fe({}),{c(){T(e.$$.fragment)},m(l,a){B(e,l,a),n=!0},i(l){n||(p(e.$$.fragment,l),n=!0)},o(l){A(e.$$.fragment,l),n=!1},d(l){R(e,l)}}}function jn(t){let e,n,l,a,r,s;e=new vt({props:{show_label:t[2],Icon:Fe,label:t[1]||"Image"}});const u=[Dn,En],i=[];function f(o,g){return o[0]===null?0:1}return l=f(t),a=i[l]=u[l](t),{c(){T(e.$$.fragment),n=U(),a.c(),r=he()},m(o,g){B(e,o,g),C(o,n,g),i[l].m(o,g),C(o,r,g),s=!0},p(o,[g]){const _={};g&4&&(_.show_label=o[2]),g&2&&(_.label=o[1]||"Image"),e.$set(_);let c=l;l=f(o),l===c?i[l].p(o,g):(x(),A(i[c],1,1,()=>{i[c]=null}),ee(),a=i[l],a?a.p(o,g):(a=i[l]=u[l](o),a.c()),p(a,1),a.m(r.parentNode,r))},i(o){s||(p(e.$$.fragment,o),p(a),s=!0)},o(o){A(e.$$.fragment,o),A(a),s=!1},d(o){R(e,o),o&&v(n),i[l].d(o),o&&v(r)}}}function Un(t,e,n){let{value:l}=e,{label:a=void 0}=e,{show_label:r}=e,{selectable:s=!1}=e;const u=ke(),i=f=>{let o=Mt(f);o&&u("select",{index:o,value:null})};return t.$$set=f=>{"value"in f&&n(0,l=f.value),"label"in f&&n(1,a=f.label),"show_label"in f&&n(2,r=f.
1show_label),"selectable"in f&&n(3,s=f.selectable)},t.$$.update=()=>{t.$$.dirty&1&&l&&u("change",l)},[l,a,r,s,i]}class qn extends le{constructor(e){super(),ie(this,e,Un,jn,$,{value:0,label:1,show_label:2,selectable:3})}}function Hn(t){let e,n,l;function a(s){t[23](s)}let r={brush_radius:t[15],shape:t[14],source:t[5],tool:t[6],selectable:t[16],label:t[7],show_label:t[8],pending:t[10],streaming:t[9],mirror_webcam:t[13],$$slots:{default:[Nn]},$$scope:{ctx:t}};return t[0]!==void 0&&(r.value=t[0]),e=new Sn({props:r}),j.push(()=>G(e,"value",a)),e.$on("edit",t[24]),e.$on("clear",t[25]),e.$on("change",t[26]),e.$on("stream",t[27]),e.$on("drag",t[28]),e.$on("upload",t[29]),e.$on("select",t[30]),e.$on("error",t[31]),{c(){T(e.$$.fragment)},m(s,u){B(e,s,u),l=!0},p(s,u){const i={};u[0]&32768&&(i.brush_radius=s[15]),u[0]&16384&&(i.shape=s[14]),u[0]&32&&(i.source=s[5]),u[0]&64&&(i.tool=s[6]),u[0]&65536&&(i.selectable=s[16]),u[0]&128&&(i.label=s[7]),u[0]&256&&(i.show_label=s[8]),u[0]&1024&&(i.pending=s[10]),u[0]&512&&(i.streaming=s[9]),u[0]&8192&&(i.mirror_webcam=s[13]),u[1]&4&&(i.$$scope={dirty:u,ctx:s}),!n&&u[0]&1&&(n=!0,i.value=s[0],Z(()=>n=!1)),e.$set(i)},i(s){l||(p(e.$$.fragment,s),l=!0)},o(s){A(e.$$.fragment,s),l=!1},d(s){R(e,s)}}}function Fn(t){let e,n;return e=new qn({props:{value:t[0],label:t[7],show_label:t[8],selectable:t[16]}}),e.$on("select",t[22]),{c(){T(e.$$.fragment)},m(l,a){B(e,l,a),n=!0},p(l,a){const r={};a[0]&1&&(r.value=l[0]),a[0]&128&&(r.label=l[7]),a[0]&256&&(r.show_label=l[8]),a[0]&65536&&(r.selectable=l[16]),e.$set(r)},i(l){n||(p(e.$$.fragment,l),n=!0)},o(l){A(e.$$.fragment,l),n=!1},d(l){R(e,l)}}}function Nn(t){let e,n;return e=new Zt({props:{type:"image"}}),{c(){T(e.$$.fragment)},m(l,a){B(e,l,a),n=!0},p:H,i(l){n||(p(e.$$.fragment,l),n=!0)},o(l){A(e.$$.fragment,l),n=!1},d(l){R(e,l)}}}function Wn(t){let e,n,l,a,r,s;const u=[t[1]];let i={};for(let _=0;_<u.length;_+=1)i=qt(i,u[_]);e=new Ht({props:i});const f=[Fn,Hn],o=[];function g(_,c){return _[20]==="static"?0:1}return l=g(t),a=o[l]=f[l](t),{c(){T(e.$$.fragment),n=U(),a.c(),r=he()},m(_,c){B(e,_,c),C(_,n,c),o[l].m(_,c),C(_,r,c),s=!0},p(_,c){const b=c[0]&2?Ft(u,[Nt(_[1])]):{};e.$set(b);let I=l;l=g(_),l===I?o[l].p(_,c):(x(),A(o[I],1,1,()=>{o[I]=null}),ee(),a=o[l],a?a.p(_,c):(a=o[l]=f[l](_),a.c()),p(a,1),a.m(r.parentNode,r))},i(_){s||(p(e.$$.fragment,_),p(a),s=!0)},o(_){A(e.$$.fragment,_),A(a),s=!1},d(_){R(e,_),_&&v(n),o[l].d(_),_&&v(r)}}}function On(t){let e,n;return e=new Wt({props:{visible:t[4],variant:t[20]==="dynamic"&&t[0]===null&&t[5]==="upload"?"dashed":"solid",border_mode:t[21]?"focus":"base",padding:!1,elem_id:t[2],elem_classes:t[3],height:t[11]||(t[5]==="webcam"||t[20]==="static"?void 0:wt),width:t[12],allow_overflow:!1,container:t[17],scale:t[18],min_width:t[19],$$slots:{default:[Wn]},$$scope:{ctx:t}}}),{c(){T(e.$$.fragment)},m(l,a){B(e,l,a),n=!0},p(l,a){const r={};a[0]&16&&(r.visible=l[4]),a[0]&1048609&&(r.variant=l[20]==="dynamic"&&l[0]===null&&l[5]==="upload"?"dashed":"solid"),a[0]&2097152&&(r.border_mode=l[21]?"focus":"base"),a[0]&4&&(r.elem_id=l[2]),a[0]&8&&(r.elem_classes=l[3]),a[0]&1050656&&(r.height=l[11]||(l[5]==="webcam"||l[20]==="static"?void 0:wt)),a[0]&4096&&(r.width=l[12]),a[0]&131072&&(r.container=l[17]),a[0]&262144&&(r.scale=l[18]),a[0]&524288&&(r.min_width=l[19]),a[0]&3270627|a[1]&4&&(r.$$scope={dirty:a,ctx:l}),e.$set(r)},i(l){n||(p(e.$$.fragment,l),n=!0)},o(l){A(e.$$.fragment,l),n=!1},d(l){R(e,l)}}}const wt=240;function Xn(t,e,n){let{elem_id:l=""}=e,{elem_classes:a=[]}=e,{visible:r=!0}=e,{value:s=null}=e,{source:u="upload"}=e,{tool:i="editor"}=e,{label:f}=e,{show_label:o}=e,{streaming:g}=e,{pending:_}=e,{height:c}=e,{width:b}=e,{mirror_webcam:I}=e,{shape:L}=e,{brush_radius:N}=e,{selectable:J=!1}=e,{container:me=!1}=e,{scale:S=1}=e,{min_width:k=void 0}=e,{loading_status:E}=e,{mode:W}=e;const re=ke();let ae;function _e(w){fe.call(this,t,w)}function ue(w){s=w,n(0,s)}function X(w){fe.call(this,t,w)}function te(w){fe.call(this,t,w)}function O(w){fe.call(this,t,w)}function K(w){fe.call(this,t,w)}const se=({detail:w})=>n(21,ae=w);function ce(w){fe.call(this,t,w)}function ne(w){fe.call(this,t,w)}const we=({detail:w})=>{n(1,E=E||{}
1),n(1,E.status="error",E),n(1,E.message=w,E)};return t.$$set=w=>{"elem_id"in w&&n(2,l=w.elem_id),"elem_classes"in w&&n(3,a=w.elem_classes),"visible"in w&&n(4,r=w.visible),"value"in w&&n(0,s=w.value),"source"in w&&n(5,u=w.source),"tool"in w&&n(6,i=w.tool),"label"in w&&n(7,f=w.label),"show_label"in w&&n(8,o=w.show_label),"streaming"in w&&n(9,g=w.streaming),"pending"in w&&n(10,_=w.pending),"height"in w&&n(11,c=w.height),"width"in w&&n(12,b=w.width),"mirror_webcam"in w&&n(13,I=w.mirror_webcam),"shape"in w&&n(14,L=w.shape),"brush_radius"in w&&n(15,N=w.brush_radius),"selectable"in w&&n(16,J=w.selectable),"container"in w&&n(17,me=w.container),"scale"in w&&n(18,S=w.scale),"min_width"in w&&n(19,k=w.min_width),"loading_status"in w&&n(1,E=w.loading_status),"mode"in w&&n(20,W=w.mode)},t.$$.update=()=>{t.$$.dirty[0]&1&&n(0,s=s||null),t.$$.dirty[0]&1&&re("change")},[s,E,l,a,r,u,i,f,o,g,_,c,b,I,L,N,J,me,S,k,W,ae,_e,ue,X,te,O,K,se,ce,ne,we]}class Yn extends le{constructor(e){super(),ie(this,e,Xn,On,$,{elem_id:2,elem_classes:3,visible:4,value:0,source:5,tool:6,label:7,show_label:8,streaming:9,pending:10,height:11,width:12,mirror_webcam:13,shape:14,brush_radius:15,selectable:16,container:17,scale:18,min_width:19,loading_status:1,mode:20},null,[-1,-1])}}const rl=Yn,al=["static","dynamic"],ul=t=>({type:{payload:"string"},description:{payload:"image data as base64 string"},example_data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="});export{rl as Component,_l as ExampleComponent,ul as document,al as modes}; 2//# sourceMappingURL=index-cd065d08.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.