dikdimon's picture
Upload extensions using SD-Hub extension
c336648 verified
raw
history blame
97.6 kB
import{S as be,e as ve,s as ce,f as re,g as m,h as S,j as Z,n as U,k as A,m as $,o as te,N as G,w as y,r as ye,u as D,v as Ee,a0 as Dr,a1 as Mr,C as Je,D as ti,p as ee,b as ht,R as F,F as W,G as X,H as Y,Q as He,af as Q,M as ge,ax as Cr,I as di,y as ii,ap as $i,O as Or,a6 as Le,aj as Tr,am as mi,K as gi,q as Rr,B as ri,E as er,an as Dt,ay as Sr,U as pe,X as _e,a8 as Ar,aa as Ir,ab as Nr,ac as zr,Z as Br,ad as Lr,V as Pr,W as Hr}from"./index-7a57bd3a.js";import{f as pi,B as Wr}from"./Button-778c588b.js";import{B as Xr}from"./BlockLabel-22b082f8.js";import{I as _i}from"./Image-d55cd4ba.js";import{g as Yr}from"./utils-90f3612b.js";import{I as Fe}from"./IconButton-85b41b48.js";import{C as Ur,M as Tt}from"./ModifyUpload-d7989679.js";import{C as jr}from"./Copy-8f1b2a9a.js";import{U as qr}from"./Undo-22283651.js";import{U as Vr}from"./Upload-0289bf35.js";import{U as Gr}from"./UploadText-39304b69.js";function Fr(i){let e,t,r;return{c(){e=re("svg"),t=re("path"),r=re("path"),m(t,"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"),m(t,"fill","currentColor"),m(r,"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"),m(r,"fill","currentColor"),m(e,"width","100%"),m(e,"height","100%"),m(e,"viewBox","0 0 32 32")},m(a,n){S(a,e,n),Z(e,t),Z(e,r)},p:U,i:U,o:U,d(a){a&&A(e)}}}class Zr extends be{constructor(e){super(),ve(this,e,null,Fr,ce,{})}}function Kr(i){let e,t,r;return{c(){e=re("svg"),t=re("path"),r=re("circle"),m(t,"d","M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"),m(r,"cx","12"),m(r,"cy","13"),m(r,"r","4"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"width","100%"),m(e,"height","100%"),m(e,"viewBox","0 0 24 24"),m(e,"fill","none"),m(e,"stroke","currentColor"),m(e,"stroke-width","1.5"),m(e,"stroke-linecap","round"),m(e,"stroke-linejoin","round"),m(e,"class","feather feather-camera")},m(a,n){S(a,e,n),Z(e,t),Z(e,r)},p:U,i:U,o:U,d(a){a&&A(e)}}}class Qr extends be{constructor(e){super(),ve(this,e,null,Kr,ce,{})}}function Jr(i){let e,t;return{c(){e=re("svg"),t=re("circle"),m(t,"cx","12"),m(t,"cy","12"),m(t,"r","10"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"width","100%"),m(e,"height","100%"),m(e,"viewBox","0 0 24 24"),m(e,"fill","red"),m(e,"stroke","red"),m(e,"stroke-width","1.5"),m(e,"stroke-linecap","round"),m(e,"stroke-linejoin","round"),m(e,"class","feather feather-circle")},m(r,a){S(r,e,a),Z(e,t)},p:U,i:U,o:U,d(r){r&&A(e)}}}class xr extends be{constructor(e){super(),ve(this,e,null,Jr,ce,{})}}function $r(i){let e,t,r,a,n,s,l;return{c(){e=re("svg"),t=re("circle"),r=re("circle"),a=re("circle"),n=re("circle"),s=re("circle"),l=re("path"),m(t,"cx","10"),m(t,"cy","12"),m(t,"r","2"),m(t,"fill","currentColor"),m(r,"cx","16"),m(r,"cy","9"),m(r,"r","2"),m(r,"fill","currentColor"),m(a,"cx","22"),m(a,"cy","12"),m(a,"r","2"),m(a,"fill","currentColor"),m(n,"cx","23"),m(n,"cy","18"),m(n,"r","2"),m(n,"fill","currentColor"),m(s,"cx","19"),m(s,"cy","23"),m(s,"r","2"),m(s,"fill","currentColor"),m(l,"fill","currentColor"),m(l,"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"),m(e,"width","100%"),m(e,"height","100%"),m(e,"viewBox","0 0 32 32")},m(o,h){S(o,e,h),Z(e,t),Z(e,r),Z(e,a),Z(e,n),Z(e,s),Z(e,l)},p:U,i:U,o:U,d(o){o&&A(e)}}}class en extends be{constructor(e){super(),ve(this,e,null,$r,ce,{})}}function tn(i){let e,t;return{c(){e=re("svg"),t=re("path"),m(t,"fill","currentColor"),m(t,"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"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"width","100%"),m(e,"height","100%"),m(e,"viewBox","0 0 32 32")},m(r,a){S(r,e,a),Z(e,t)},p:U,i:U,o:U,d(r){r&&A(e)}}}class rn extends be{constructor(e){super(),ve(this,e,null,tn,ce,{})}}function nn(i){let e,t;return{c(){e=re("svg"),t=re("path"),m(t,"d","M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"width","100%"),m(e,"height","100%"),m(e,"viewBox","0 0 24 24"),m(e,"fill","none"),m(e,"stroke","currentColor"),m(e,"stroke-width","1.5"),m(e,"stroke-linecap","round"),m(e,"stroke-linejoin","round"),m(e,"class","feather feather-edit-2")},m(r,a){S(r,e,a),Z(e,t)},p:U,i:U,o:U,d(r){r&&A(e)}}}let bi=class extends be{constructor(e){super(),ve(this,e,null,nn,ce,{})}};function an(i){let e,t;return{c(){e=re("svg"),t=re("rect"),m(t,"x","3"),m(t,"y","3"),m(t,"width","18"),m(t,"height","18"),m(t,"rx","2"),m(t,"ry","2"),m(e,"xmlns","http://www.w3.org/2000/svg"),m(e,"width","100%"),m(e,"height","100%"),m(e,"viewBox","0 0 24 24"),m(e,"fill","red"),m(e,"stroke","red"),m(e,"stroke-width","1.5"),m(e,"stroke-linecap","round"),m(e,"stroke-linejoin","round"),m(e,"class","feather feather-square")},m(r,a){S(r,e,a),Z(e,t)},p:U,i:U,o:U,d(r){r&&A(e)}}}class sn extends be{constructor(e){super(),ve(this,e,null,an,ce,{})}}function vi(i){let e,t,r,a,n,s;const l=[ln,on],o=[];function h(u,f){return u[1]==="video"?0:1}return t=h(i),r=o[t]=l[t](i),{c(){e=$("button"),r.c(),m(e,"class","svelte-425ent")},m(u,f){S(u,e,f),o[t].m(e,null),a=!0,n||(s=ee(e,"click",function(){ht(i[1]==="image"?i[5]:i[6])&&(i[1]==="image"?i[5]:i[6]).apply(this,arguments)}),n=!0)},p(u,f){i=u;let c=t;t=h(i),t===c?o[t].p(i,f):(ye(),D(o[c],1,1,()=>{o[c]=null}),Ee(),r=o[t],r?r.p(i,f):(r=o[t]=l[t](i),r.c()),y(r,1),r.m(e,null))},i(u){a||(y(r),a=!0)},o(u){D(r),a=!1},d(u){u&&A(e),o[t].d(),n=!1,s()}}}function on(i){let e,t,r;return t=new Qr({}),{c(){e=$("div"),W(t.$$.fragment),m(e,"class","icon svelte-425ent")},m(a,n){S(a,e,n),X(t,e,null),r=!0},p:U,i(a){r||(y(t.$$.fragment,a),r=!0)},o(a){D(t.$$.fragment,a),r=!1},d(a){a&&A(e),Y(t)}}}function ln(i){let e,t,r,a;const n=[un,hn],s=[];function l(o,h){return o[4]?0:1}return e=l(i),t=s[e]=n[e](i),{c(){t.c(),r=He()},m(o,h){s[e].m(o,h),S(o,r,h),a=!0},p(o,h){let u=e;e=l(o),e!==u&&(ye(),D(s[u],1,1,()=>{s[u]=null}),Ee(),t=s[e],t||(t=s[e]=n[e](o),t.c()),y(t,1),t.m(r.parentNode,r))},i(o){a||(y(t),a=!0)},o(o){D(t),a=!1},d(o){o&&A(r),s[e].d(o)}}}function hn(i){let e,t,r;return t=new xr({}),{c(){e=$("div"),W(t.$$.fragment),m(e,"class","icon svelte-425ent")},m(a,n){S(a,e,n),X(t,e,null),r=!0},i(a){r||(y(t.$$.fragment,a),r=!0)},o(a){D(t.$$.fragment,a),r=!1},d(a){a&&A(e),Y(t)}}}function un(i){let e,t,r;return t=new sn({}),{c(){e=$("div"),W(t.$$.fragment),m(e,"class","icon svelte-425ent")},m(a,n){S(a,e,n),X(t,e,null),r=!0},i(a){r||(y(t.$$.fragment,a),r=!0)},o(a){D(t.$$.fragment,a),r=!1},d(a){a&&A(e),Y(t)}}}function cn(i){let e,t,r,a,n=!i[0]&&vi(i);return{c(){e=$("div"),t=$("video"),r=te(),n&&n.c(),m(t,"class","svelte-425ent"),G(t,"flip",i[2]),m(e,"class","wrap svelte-425ent")},m(s,l){S(s,e,l),Z(e,t),i[9](t),Z(e,r),n&&n.m(e,null),a=!0},p(s,[l]){(!a||l&4)&&G(t,"flip",s[2]),s[0]?n&&(ye(),D(n,1,1,()=>{n=null}),Ee()):n?(n.p(s,l),l&1&&y(n,1)):(n=vi(s),n.c(),y(n,1),n.m(e,null))},i(s){a||(y(n),a=!0)},o(s){D(n),a=!1},d(s){s&&A(e),i[9](null),n&&n.d()}}}function fn(i,e,t){let r;Dr(i,Mr,R=>t(15,r=R));let a,n,{streaming:s=!1}=e,{pending:l=!1}=e,{mode:o="image"}=e,{mirror_webcam:h}=e,{include_audio:u}=e;const f=Je();ti(()=>n=document.createElement("canvas"));async function c(){try{O=await navigator.mediaDevices.getUserMedia({video:!0,audio:u}),t(3,a.srcObject=O,a),t(3,a.muted=!0,a),a.play()}catch(R){if(R instanceof DOMException&&R.name=="NotAllowedError")f("error",r("image.allow_webcam_access"));else throw R}}function d(){var R=n.getContext("2d");if(a.videoWidth&&a.videoHeight){n.width=a.videoWidth,n.height=a.videoHeight,R.drawImage(a,0,0,a.videoWidth,a.videoHeight);var _=n.toDataURL("image/png");f(s?"stream":"capture",_)}}let p=!1,v=[],O,z,T;function E(){if(p){T.stop();let R=new Blob(v,{type:z}),_=new FileReader;_.onload=function(I){I.target&&(f("capture",{data:I.target.result,name:"sample."+z.substring(6),is_example:!1}),f("stop_recording"))},_.readAsDataURL(R)}else{f("start_recording"),v=[];let R=["video/webm","video/mp4"];for(let _ of R)if(MediaRecorder.isTypeSupported(_)){z=_;break}if(z===null){console.error("No supported MediaRecorder mimeType");return}T=new MediaRecorder(O,{mimeType:z}),T.addEventListener("dataavailable",function(_){v.push(_.data)}),T.start(200)}t(4,p=!p)}c(),s&&o==="image"&&window.setInterval(()=>{a&&!l&&d()},500);function V(R){F[R?"unshift":"push"](()=>{a=R,t(3,a)})}return i.$$set=R=>{"streaming"in R&&t(0,s=R.streaming),"pending"in R&&t(7,l=R.pending),"mode"in R&&t(1,o=R.mode),"mirror_webcam"in R&&t(2,h=R.mirror_webcam),"include_audio"in R&&t(8,u=R.include_audio)},[s,o,h,a,p,d,E,l,u,V]}class dn extends be{constructor(e){super(),ve(this,e,fn,cn,ce,{streaming:0,pending:7,mode:1,mirror_webcam:2,include_audio:8})}}const mn=dn;/*!
* Cropper.js v1.5.12
* https://fengyuanchen.github.io/cropperjs
*
* Copyright 2015-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2021-06-12T08:00:17.411Z
*/function wi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(i,a).enumerable})),t.push.apply(t,r)}return t}function tr(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wi(Object(t),!0).forEach(function(r){_n(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):wi(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function Et(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Et=function(e){return typeof e}:Et=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Et(i)}function gn(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function ki(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function pn(i,e,t){return e&&ki(i.prototype,e),t&&ki(i,t),i}function _n(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ir(i){return bn(i)||vn(i)||wn(i)||kn()}function bn(i){if(Array.isArray(i))return Vt(i)}function vn(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function wn(i,e){if(i){if(typeof i=="string")return Vt(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Vt(i,e)}}function Vt(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function kn(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Rt=typeof window<"u"&&typeof window.document<"u",Oe=Rt?window:{},ni=Rt&&Oe.document.documentElement?"ontouchstart"in Oe.document.documentElement:!1,ai=Rt?"PointerEvent"in Oe:!1,J="cropper",si="all",rr="crop",nr="move",ar="zoom",ze="e",Be="w",qe="s",Te="n",it="ne",rt="nw",nt="se",at="sw",Gt="".concat(J,"-crop"),yi="".concat(J,"-disabled"),me="".concat(J,"-hidden"),Ei="".concat(J,"-hide"),yn="".concat(J,"-invisible"),Mt="".concat(J,"-modal"),Ft="".concat(J,"-move"),ot="".concat(J,"Action"),kt="".concat(J,"Preview"),oi="crop",sr="move",or="none",Zt="crop",Kt="cropend",Qt="cropmove",Jt="cropstart",Di="dblclick",En=ni?"touchstart":"mousedown",Dn=ni?"touchmove":"mousemove",Mn=ni?"touchend touchcancel":"mouseup",Mi=ai?"pointerdown":En,Ci=ai?"pointermove":Dn,Oi=ai?"pointerup pointercancel":Mn,Ti="ready",Ri="resize",Si="wheel",xt="zoom",Ai="image/jpeg",Cn=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,On=/^data:/,Tn=/^data:image\/jpeg;base64,/,Rn=/^img|canvas$/i,lr=200,hr=100,Ii={viewMode:0,dragMode:oi,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:lr,minContainerHeight:hr,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},Sn='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>',An=Number.isNaN||Oe.isNaN;function B(i){return typeof i=="number"&&!An(i)}var Ni=function(e){return e>0&&e<1/0};function jt(i){return typeof i>"u"}function Pe(i){return Et(i)==="object"&&i!==null}var In=Object.prototype.hasOwnProperty;function Ve(i){if(!Pe(i))return!1;try{var e=i.constructor,t=e.prototype;return e&&t&&In.call(t,"isPrototypeOf")}catch{return!1}}function de(i){return typeof i=="function"}var Nn=Array.prototype.slice;function ur(i){return Array.from?Array.from(i):Nn.call(i)}function oe(i,e){return i&&de(e)&&(Array.isArray(i)||B(i.length)?ur(i).forEach(function(t,r){e.call(i,t,r,i)}):Pe(i)&&Object.keys(i).forEach(function(t){e.call(i,i[t],t,i)})),i}var x=Object.assign||function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return Pe(e)&&r.length>0&&r.forEach(function(n){Pe(n)&&Object.keys(n).forEach(function(s){e[s]=n[s]})}),e},zn=/\.\d*(?:0|9){12}\d*$/;function Ze(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return zn.test(i)?Math.round(i*e)/e:i}var Bn=/^width|height|left|top|marginLeft|marginTop$/;function Re(i,e){var t=i.style;oe(e,function(r,a){Bn.test(a)&&B(r)&&(r="".concat(r,"px")),t[a]=r})}function Ln(i,e){return i.classList?i.classList.contains(e):i.className.indexOf(e)>-1}function le(i,e){if(e){if(B(i.length)){oe(i,function(r){le(r,e)});return}if(i.classList){i.classList.add(e);return}var t=i.className.trim();t?t.indexOf(e)<0&&(i.className="".concat(t," ").concat(e)):i.className=e}}function Ce(i,e){if(e){if(B(i.length)){oe(i,function(t){Ce(t,e)});return}if(i.classList){i.classList.remove(e);return}i.className.indexOf(e)>=0&&(i.className=i.className.replace(e,""))}}function Ge(i,e,t){if(e){if(B(i.length)){oe(i,function(r){Ge(r,e,t)});return}t?le(i,e):Ce(i,e)}}var Pn=/([a-z\d])([A-Z])/g;function li(i){return i.replace(Pn,"$1-$2").toLowerCase()}function $t(i,e){return Pe(i[e])?i[e]:i.dataset?i.dataset[e]:i.getAttribute("data-".concat(li(e)))}function lt(i,e,t){Pe(t)?i[e]=t:i.dataset?i.dataset[e]=t:i.setAttribute("data-".concat(li(e)),t)}function Hn(i,e){if(Pe(i[e]))try{delete i[e]}catch{i[e]=void 0}else if(i.dataset)try{delete i.dataset[e]}catch{i.dataset[e]=void 0}else i.removeAttribute("data-".concat(li(e)))}var cr=/\s\s*/,fr=function(){var i=!1;if(Rt){var e=!1,t=function(){},r=Object.defineProperty({},"once",{get:function(){return i=!0,e},set:function(n){e=n}});Oe.addEventListener("test",t,r),Oe.removeEventListener("test",t,r)}return i}();function De(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=t;e.trim().split(cr).forEach(function(n){if(!fr){var s=i.listeners;s&&s[n]&&s[n][t]&&(a=s[n][t],delete s[n][t],Object.keys(s[n]).length===0&&delete s[n],Object.keys(s).length===0&&delete i.listeners)}i.removeEventListener(n,a,r)})}function ke(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=t;e.trim().split(cr).forEach(function(n){if(r.once&&!fr){var s=i.listeners,l=s===void 0?{}:s;a=function(){delete l[n][t],i.removeEventListener(n,a,r);for(var h=arguments.length,u=new Array(h),f=0;f<h;f++)u[f]=arguments[f];t.apply(i,u)},l[n]||(l[n]={}),l[n][t]&&i.removeEventListener(n,l[n][t],r),l[n][t]=a,i.listeners=l}i.addEventListener(n,a,r)})}function Ke(i,e,t){var r;return de(Event)&&de(CustomEvent)?r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0}):(r=document.createEvent("CustomEvent"),r.initCustomEvent(e,!0,!0,t)),i.dispatchEvent(r)}function dr(i){var e=i.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}var qt=Oe.location,Wn=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function zi(i){var e=i.match(Wn);return e!==null&&(e[1]!==qt.protocol||e[2]!==qt.hostname||e[3]!==qt.port)}function Bi(i){var e="timestamp=".concat(new Date().getTime());return i+(i.indexOf("?")===-1?"?":"&")+e}function st(i){var e=i.rotate,t=i.scaleX,r=i.scaleY,a=i.translateX,n=i.translateY,s=[];B(a)&&a!==0&&s.push("translateX(".concat(a,"px)")),B(n)&&n!==0&&s.push("translateY(".concat(n,"px)")),B(e)&&e!==0&&s.push("rotate(".concat(e,"deg)")),B(t)&&t!==1&&s.push("scaleX(".concat(t,")")),B(r)&&r!==1&&s.push("scaleY(".concat(r,")"));var l=s.length?s.join(" "):"none";return{WebkitTransform:l,msTransform:l,transform:l}}function Xn(i){var e=tr({},i),t=0;return oe(i,function(r,a){delete e[a],oe(e,function(n){var s=Math.abs(r.startX-n.startX),l=Math.abs(r.startY-n.startY),o=Math.abs(r.endX-n.endX),h=Math.abs(r.endY-n.endY),u=Math.sqrt(s*s+l*l),f=Math.sqrt(o*o+h*h),c=(f-u)/u;Math.abs(c)>Math.abs(t)&&(t=c)})}),t}function yt(i,e){var t=i.pageX,r=i.pageY,a={endX:t,endY:r};return e?a:tr({startX:t,startY:r},a)}function Yn(i){var e=0,t=0,r=0;return oe(i,function(a){var n=a.startX,s=a.startY;e+=n,t+=s,r+=1}),e/=r,t/=r,{pageX:e,pageY:t}}function Se(i){var e=i.aspectRatio,t=i.height,r=i.width,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"contain",n=Ni(r),s=Ni(t);if(n&&s){var l=t*e;a==="contain"&&l>r||a==="cover"&&l<r?t=r/e:r=t*e}else n?t=r/e:s&&(r=t*e);return{width:r,height:t}}function Un(i){var e=i.width,t=i.height,r=i.degree;if(r=Math.abs(r)%180,r===90)return{width:t,height:e};var a=r%90*Math.PI/180,n=Math.sin(a),s=Math.cos(a),l=e*s+t*n,o=e*n+t*s;return r>90?{width:o,height:l}:{width:l,height:o}}function jn(i,e,t,r){var a=e.aspectRatio,n=e.naturalWidth,s=e.naturalHeight,l=e.rotate,o=l===void 0?0:l,h=e.scaleX,u=h===void 0?1:h,f=e.scaleY,c=f===void 0?1:f,d=t.aspectRatio,p=t.naturalWidth,v=t.naturalHeight,O=r.fillColor,z=O===void 0?"transparent":O,T=r.imageSmoothingEnabled,E=T===void 0?!0:T,V=r.imageSmoothingQuality,R=V===void 0?"low":V,_=r.maxWidth,I=_===void 0?1/0:_,H=r.maxHeight,M=H===void 0?1/0:H,w=r.minWidth,ie=w===void 0?0:w,j=r.minHeight,he=j===void 0?0:j,ne=document.createElement("canvas"),K=ne.getContext("2d"),ue=Se({aspectRatio:d,width:I,height:M}),q=Se({aspectRatio:d,width:ie,height:he},"cover"),ae=Math.min(ue.width,Math.max(q.width,p)),we=Math.min(ue.height,Math.max(q.height,v)),k=Se({aspectRatio:a,width:I,height:M}),fe=Se({aspectRatio:a,width:ie,height:he},"cover"),Ae=Math.min(k.width,Math.max(fe.width,n)),We=Math.min(k.height,Math.max(fe.height,s)),Xe=[-Ae/2,-We/2,Ae,We];return ne.width=Ze(ae),ne.height=Ze(we),K.fillStyle=z,K.fillRect(0,0,ae,we),K.save(),K.translate(ae/2,we/2),K.rotate(o*Math.PI/180),K.scale(u,c),K.imageSmoothingEnabled=E,K.imageSmoothingQuality=R,K.drawImage.apply(K,[i].concat(ir(Xe.map(function(xe){return Math.floor(Ze(xe))})))),K.restore(),ne}var mr=String.fromCharCode;function qn(i,e,t){var r="";t+=e;for(var a=e;a<t;a+=1)r+=mr(i.getUint8(a));return r}var Vn=/^data:.*,/;function Gn(i){var e=i.replace(Vn,""),t=atob(e),r=new ArrayBuffer(t.length),a=new Uint8Array(r);return oe(a,function(n,s){a[s]=t.charCodeAt(s)}),r}function Fn(i,e){for(var t=[],r=8192,a=new Uint8Array(i);a.length>0;)t.push(mr.apply(null,ur(a.subarray(0,r)))),a=a.subarray(r);return"data:".concat(e,";base64,").concat(btoa(t.join("")))}function Zn(i){var e=new DataView(i),t;try{var r,a,n;if(e.getUint8(0)===255&&e.getUint8(1)===216)for(var s=e.byteLength,l=2;l+1<s;){if(e.getUint8(l)===255&&e.getUint8(l+1)===225){a=l;break}l+=1}if(a){var o=a+4,h=a+10;if(qn(e,o,4)==="Exif"){var u=e.getUint16(h);if(r=u===18761,(r||u===19789)&&e.getUint16(h+2,r)===42){var f=e.getUint32(h+4,r);f>=8&&(n=h+f)}}}if(n){var c=e.getUint16(n,r),d,p;for(p=0;p<c;p+=1)if(d=n+p*12+2,e.getUint16(d,r)===274){d+=8,t=e.getUint16(d,r),e.setUint16(d,1,r);break}}}catch{t=1}return t}function Kn(i){var e=0,t=1,r=1;switch(i){case 2:t=-1;break;case 3:e=-180;break;case 4:r=-1;break;case 5:e=90,r=-1;break;case 6:e=90;break;case 7:e=90,t=-1;break;case 8:e=-90;break}return{rotate:e,scaleX:t,scaleY:r}}var Qn={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var e=this.element,t=this.options,r=this.container,a=this.cropper,n=Number(t.minContainerWidth),s=Number(t.minContainerHeight);le(a,me),Ce(e,me);var l={width:Math.max(r.offsetWidth,n>=0?n:lr),height:Math.max(r.offsetHeight,s>=0?s:hr)};this.containerData=l,Re(a,{width:l.width,height:l.height}),le(e,me),Ce(a,me)},initCanvas:function(){var e=this.containerData,t=this.imageData,r=this.options.viewMode,a=Math.abs(t.rotate)%180===90,n=a?t.naturalHeight:t.naturalWidth,s=a?t.naturalWidth:t.naturalHeight,l=n/s,o=e.width,h=e.height;e.height*l>e.width?r===3?o=e.height*l:h=e.width/l:r===3?h=e.width/l:o=e.height*l;var u={aspectRatio:l,naturalWidth:n,naturalHeight:s,width:o,height:h};this.canvasData=u,this.limited=r===1||r===2,this.limitCanvas(!0,!0),u.width=Math.min(Math.max(u.width,u.minWidth),u.maxWidth),u.height=Math.min(Math.max(u.height,u.minHeight),u.maxHeight),u.left=(e.width-u.width)/2,u.top=(e.height-u.height)/2,u.oldLeft=u.left,u.oldTop=u.top,this.initialCanvasData=x({},u)},limitCanvas:function(e,t){var r=this.options,a=this.containerData,n=this.canvasData,s=this.cropBoxData,l=r.viewMode,o=n.aspectRatio,h=this.cropped&&s;if(e){var u=Number(r.minCanvasWidth)||0,f=Number(r.minCanvasHeight)||0;l>1?(u=Math.max(u,a.width),f=Math.max(f,a.height),l===3&&(f*o>u?u=f*o:f=u/o)):l>0&&(u?u=Math.max(u,h?s.width:0):f?f=Math.max(f,h?s.height:0):h&&(u=s.width,f=s.height,f*o>u?u=f*o:f=u/o));var c=Se({aspectRatio:o,width:u,height:f});u=c.width,f=c.height,n.minWidth=u,n.minHeight=f,n.maxWidth=1/0,n.maxHeight=1/0}if(t)if(l>(h?0:1)){var d=a.width-n.width,p=a.height-n.height;n.minLeft=Math.min(0,d),n.minTop=Math.min(0,p),n.maxLeft=Math.max(0,d),n.maxTop=Math.max(0,p),h&&this.limited&&(n.minLeft=Math.min(s.left,s.left+(s.width-n.width)),n.minTop=Math.min(s.top,s.top+(s.height-n.height)),n.maxLeft=s.left,n.maxTop=s.top,l===2&&(n.width>=a.width&&(n.minLeft=Math.min(0,d),n.maxLeft=Math.max(0,d)),n.height>=a.height&&(n.minTop=Math.min(0,p),n.maxTop=Math.max(0,p))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(e,t){var r=this.canvasData,a=this.imageData;if(t){var n=Un({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),s=n.width,l=n.height,o=r.width*(s/r.naturalWidth),h=r.height*(l/r.naturalHeight);r.left-=(o-r.width)/2,r.top-=(h-r.height)/2,r.width=o,r.height=h,r.aspectRatio=s/l,r.naturalWidth=s,r.naturalHeight=l,this.limitCanvas(!0,!1)}(r.width>r.maxWidth||r.width<r.minWidth)&&(r.left=r.oldLeft),(r.height>r.maxHeight||r.height<r.minHeight)&&(r.top=r.oldTop),r.width=Math.min(Math.max(r.width,r.minWidth),r.maxWidth),r.height=Math.min(Math.max(r.height,r.minHeight),r.maxHeight),this.limitCanvas(!1,!0),r.left=Math.min(Math.max(r.left,r.minLeft),r.maxLeft),r.top=Math.min(Math.max(r.top,r.minTop),r.maxTop),r.oldLeft=r.left,r.oldTop=r.top,Re(this.canvas,x({width:r.width,height:r.height},st({translateX:r.left,translateY:r.top}))),this.renderImage(e),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(e){var t=this.canvasData,r=this.imageData,a=r.naturalWidth*(t.width/t.naturalWidth),n=r.naturalHeight*(t.height/t.naturalHeight);x(r,{width:a,height:n,left:(t.width-a)/2,top:(t.height-n)/2}),Re(this.image,x({width:r.width,height:r.height},st(x({translateX:r.left,translateY:r.top},r)))),e&&this.output()},initCropBox:function(){var e=this.options,t=this.canvasData,r=e.aspectRatio||e.initialAspectRatio,a=Number(e.autoCropArea)||.8,n={width:t.width,height:t.height};r&&(t.height*r>t.width?n.height=n.width/r:n.width=n.height*r),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=t.left+(t.width-n.width)/2,n.top=t.top+(t.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=x({},n)},limitCropBox:function(e,t){var r=this.options,a=this.containerData,n=this.canvasData,s=this.cropBoxData,l=this.limited,o=r.aspectRatio;if(e){var h=Number(r.minCropBoxWidth)||0,u=Number(r.minCropBoxHeight)||0,f=l?Math.min(a.width,n.width,n.width+n.left,a.width-n.left):a.width,c=l?Math.min(a.height,n.height,n.height+n.top,a.height-n.top):a.height;h=Math.min(h,a.width),u=Math.min(u,a.height),o&&(h&&u?u*o>h?u=h/o:h=u*o:h?u=h/o:u&&(h=u*o),c*o>f?c=f/o:f=c*o),s.minWidth=Math.min(h,f),s.minHeight=Math.min(u,c),s.maxWidth=f,s.maxHeight=c}t&&(l?(s.minLeft=Math.max(0,n.left),s.minTop=Math.max(0,n.top),s.maxLeft=Math.min(a.width,n.left+n.width)-s.width,s.maxTop=Math.min(a.height,n.top+n.height)-s.height):(s.minLeft=0,s.minTop=0,s.maxLeft=a.width-s.width,s.maxTop=a.height-s.height))},renderCropBox:function(){var e=this.options,t=this.containerData,r=this.cropBoxData;(r.width>r.maxWidth||r.width<r.minWidth)&&(r.left=r.oldLeft),(r.height>r.maxHeight||r.height<r.minHeight)&&(r.top=r.oldTop),r.width=Math.min(Math.max(r.width,r.minWidth),r.maxWidth),r.height=Math.min(Math.max(r.height,r.minHeight),r.maxHeight),this.limitCropBox(!1,!0),r.left=Math.min(Math.max(r.left,r.minLeft),r.maxLeft),r.top=Math.min(Math.max(r.top,r.minTop),r.maxTop),r.oldLeft=r.left,r.oldTop=r.top,e.movable&&e.cropBoxMovable&&lt(this.face,ot,r.width>=t.width&&r.height>=t.height?nr:si),Re(this.cropBox,x({width:r.width,height:r.height},st({translateX:r.left,translateY:r.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),Ke(this.element,Zt,this.getData())}},Jn={initPreview:function(){var e=this.element,t=this.crossOrigin,r=this.options.preview,a=t?this.crossOriginUrl:this.url,n=e.alt||"The image to preview",s=document.createElement("img");if(t&&(s.crossOrigin=t),s.src=a,s.alt=n,this.viewBox.appendChild(s),this.viewBoxImage=s,!!r){var l=r;typeof r=="string"?l=e.ownerDocument.querySelectorAll(r):r.querySelector&&(l=[r]),this.previews=l,oe(l,function(o){var h=document.createElement("img");lt(o,kt,{width:o.offsetWidth,height:o.offsetHeight,html:o.innerHTML}),t&&(h.crossOrigin=t),h.src=a,h.alt=n,h.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',o.innerHTML="",o.appendChild(h)})}},resetPreview:function(){oe(this.previews,function(e){var t=$t(e,kt);Re(e,{width:t.width,height:t.height}),e.innerHTML=t.html,Hn(e,kt)})},preview:function(){var e=this.imageData,t=this.canvasData,r=this.cropBoxData,a=r.width,n=r.height,s=e.width,l=e.height,o=r.left-t.left-e.left,h=r.top-t.top-e.top;!this.cropped||this.disabled||(Re(this.viewBoxImage,x({width:s,height:l},st(x({translateX:-o,translateY:-h},e)))),oe(this.previews,function(u){var f=$t(u,kt),c=f.width,d=f.height,p=c,v=d,O=1;a&&(O=c/a,v=n*O),n&&v>d&&(O=d/n,p=a*O,v=d),Re(u,{width:p,height:v}),Re(u.getElementsByTagName("img")[0],x({width:s*O,height:l*O},st(x({translateX:-o*O,translateY:-h*O},e))))}))}},xn={bind:function(){var e=this.element,t=this.options,r=this.cropper;de(t.cropstart)&&ke(e,Jt,t.cropstart),de(t.cropmove)&&ke(e,Qt,t.cropmove),de(t.cropend)&&ke(e,Kt,t.cropend),de(t.crop)&&ke(e,Zt,t.crop),de(t.zoom)&&ke(e,xt,t.zoom),ke(r,Mi,this.onCropStart=this.cropStart.bind(this)),t.zoomable&&t.zoomOnWheel&&ke(r,Si,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),t.toggleDragModeOnDblclick&&ke(r,Di,this.onDblclick=this.dblclick.bind(this)),ke(e.ownerDocument,Ci,this.onCropMove=this.cropMove.bind(this)),ke(e.ownerDocument,Oi,this.onCropEnd=this.cropEnd.bind(this)),t.responsive&&ke(window,Ri,this.onResize=this.resize.bind(this))},unbind:function(){var e=this.element,t=this.options,r=this.cropper;de(t.cropstart)&&De(e,Jt,t.cropstart),de(t.cropmove)&&De(e,Qt,t.cropmove),de(t.cropend)&&De(e,Kt,t.cropend),de(t.crop)&&De(e,Zt,t.crop),de(t.zoom)&&De(e,xt,t.zoom),De(r,Mi,this.onCropStart),t.zoomable&&t.zoomOnWheel&&De(r,Si,this.onWheel,{passive:!1,capture:!0}),t.toggleDragModeOnDblclick&&De(r,Di,this.onDblclick),De(e.ownerDocument,Ci,this.onCropMove),De(e.ownerDocument,Oi,this.onCropEnd),t.responsive&&De(window,Ri,this.onResize)}},$n={resize:function(){if(!this.disabled){var e=this.options,t=this.container,r=this.containerData,a=t.offsetWidth/r.width,n=t.offsetHeight/r.height,s=Math.abs(a-1)>Math.abs(n-1)?a:n;if(s!==1){var l,o;e.restore&&(l=this.getCanvasData(),o=this.getCropBoxData()),this.render(),e.restore&&(this.setCanvasData(oe(l,function(h,u){l[u]=h*s})),this.setCropBoxData(oe(o,function(h,u){o[u]=h*s})))}}},dblclick:function(){this.disabled||this.options.dragMode===or||this.setDragMode(Ln(this.dragBox,Gt)?sr:oi)},wheel:function(e){var t=this,r=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(e.preventDefault(),!this.wheeling&&(this.wheeling=!0,setTimeout(function(){t.wheeling=!1},50),e.deltaY?a=e.deltaY>0?1:-1:e.wheelDelta?a=-e.wheelDelta/120:e.detail&&(a=e.detail>0?1:-1),this.zoom(-a*r,e)))},cropStart:function(e){var t=e.buttons,r=e.button;if(!(this.disabled||(e.type==="mousedown"||e.type==="pointerdown"&&e.pointerType==="mouse")&&(B(t)&&t!==1||B(r)&&r!==0||e.ctrlKey))){var a=this.options,n=this.pointers,s;e.changedTouches?oe(e.changedTouches,function(l){n[l.identifier]=yt(l)}):n[e.pointerId||0]=yt(e),Object.keys(n).length>1&&a.zoomable&&a.zoomOnTouch?s=ar:s=$t(e.target,ot),Cn.test(s)&&Ke(this.element,Jt,{originalEvent:e,action:s})!==!1&&(e.preventDefault(),this.action=s,this.cropping=!1,s===rr&&(this.cropping=!0,le(this.dragBox,Mt)))}},cropMove:function(e){var t=this.action;if(!(this.disabled||!t)){var r=this.pointers;e.preventDefault(),Ke(this.element,Qt,{originalEvent:e,action:t})!==!1&&(e.changedTouches?oe(e.changedTouches,function(a){x(r[a.identifier]||{},yt(a,!0))}):x(r[e.pointerId||0]||{},yt(e,!0)),this.change(e))}},cropEnd:function(e){if(!this.disabled){var t=this.action,r=this.pointers;e.changedTouches?oe(e.changedTouches,function(a){delete r[a.identifier]}):delete r[e.pointerId||0],t&&(e.preventDefault(),Object.keys(r).length||(this.action=""),this.cropping&&(this.cropping=!1,Ge(this.dragBox,Mt,this.cropped&&this.options.modal)),Ke(this.element,Kt,{originalEvent:e,action:t}))}}},ea={change:function(e){var t=this.options,r=this.canvasData,a=this.containerData,n=this.cropBoxData,s=this.pointers,l=this.action,o=t.aspectRatio,h=n.left,u=n.top,f=n.width,c=n.height,d=h+f,p=u+c,v=0,O=0,z=a.width,T=a.height,E=!0,V;!o&&e.shiftKey&&(o=f&&c?f/c:1),this.limited&&(v=n.minLeft,O=n.minTop,z=v+Math.min(a.width,r.width,r.left+r.width),T=O+Math.min(a.height,r.height,r.top+r.height));var R=s[Object.keys(s)[0]],_={x:R.endX-R.startX,y:R.endY-R.startY},I=function(M){switch(M){case ze:d+_.x>z&&(_.x=z-d);break;case Be:h+_.x<v&&(_.x=v-h);break;case Te:u+_.y<O&&(_.y=O-u);break;case qe:p+_.y>T&&(_.y=T-p);break}};switch(l){case si:h+=_.x,u+=_.y;break;case ze:if(_.x>=0&&(d>=z||o&&(u<=O||p>=T))){E=!1;break}I(ze),f+=_.x,f<0&&(l=Be,f=-f,h-=f),o&&(c=f/o,u+=(n.height-c)/2);break;case Te:if(_.y<=0&&(u<=O||o&&(h<=v||d>=z))){E=!1;break}I(Te),c-=_.y,u+=_.y,c<0&&(l=qe,c=-c,u-=c),o&&(f=c*o,h+=(n.width-f)/2);break;case Be:if(_.x<=0&&(h<=v||o&&(u<=O||p>=T))){E=!1;break}I(Be),f-=_.x,h+=_.x,f<0&&(l=ze,f=-f,h-=f),o&&(c=f/o,u+=(n.height-c)/2);break;case qe:if(_.y>=0&&(p>=T||o&&(h<=v||d>=z))){E=!1;break}I(qe),c+=_.y,c<0&&(l=Te,c=-c,u-=c),o&&(f=c*o,h+=(n.width-f)/2);break;case it:if(o){if(_.y<=0&&(u<=O||d>=z)){E=!1;break}I(Te),c-=_.y,u+=_.y,f=c*o}else I(Te),I(ze),_.x>=0?d<z?f+=_.x:_.y<=0&&u<=O&&(E=!1):f+=_.x,_.y<=0?u>O&&(c-=_.y,u+=_.y):(c-=_.y,u+=_.y);f<0&&c<0?(l=at,c=-c,f=-f,u-=c,h-=f):f<0?(l=rt,f=-f,h-=f):c<0&&(l=nt,c=-c,u-=c);break;case rt:if(o){if(_.y<=0&&(u<=O||h<=v)){E=!1;break}I(Te),c-=_.y,u+=_.y,f=c*o,h+=n.width-f}else I(Te),I(Be),_.x<=0?h>v?(f-=_.x,h+=_.x):_.y<=0&&u<=O&&(E=!1):(f-=_.x,h+=_.x),_.y<=0?u>O&&(c-=_.y,u+=_.y):(c-=_.y,u+=_.y);f<0&&c<0?(l=nt,c=-c,f=-f,u-=c,h-=f):f<0?(l=it,f=-f,h-=f):c<0&&(l=at,c=-c,u-=c);break;case at:if(o){if(_.x<=0&&(h<=v||p>=T)){E=!1;break}I(Be),f-=_.x,h+=_.x,c=f/o}else I(qe),I(Be),_.x<=0?h>v?(f-=_.x,h+=_.x):_.y>=0&&p>=T&&(E=!1):(f-=_.x,h+=_.x),_.y>=0?p<T&&(c+=_.y):c+=_.y;f<0&&c<0?(l=it,c=-c,f=-f,u-=c,h-=f):f<0?(l=nt,f=-f,h-=f):c<0&&(l=rt,c=-c,u-=c);break;case nt:if(o){if(_.x>=0&&(d>=z||p>=T)){E=!1;break}I(ze),f+=_.x,c=f/o}else I(qe),I(ze),_.x>=0?d<z?f+=_.x:_.y>=0&&p>=T&&(E=!1):f+=_.x,_.y>=0?p<T&&(c+=_.y):c+=_.y;f<0&&c<0?(l=rt,c=-c,f=-f,u-=c,h-=f):f<0?(l=at,f=-f,h-=f):c<0&&(l=it,c=-c,u-=c);break;case nr:this.move(_.x,_.y),E=!1;break;case ar:this.zoom(Xn(s),e),E=!1;break;case rr:if(!_.x||!_.y){E=!1;break}V=dr(this.cropper),h=R.startX-V.left,u=R.startY-V.top,f=n.minWidth,c=n.minHeight,_.x>0?l=_.y>0?nt:it:_.x<0&&(h-=f,l=_.y>0?at:rt),_.y<0&&(u-=c),this.cropped||(Ce(this.cropBox,me),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0));break}E&&(n.width=f,n.height=c,n.left=h,n.top=u,this.action=l,this.renderCropBox()),oe(s,function(H){H.startX=H.endX,H.startY=H.endY})}},ta={crop:function(){return this.ready&&!this.cropped&&!this.disabled&&(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&le(this.dragBox,Mt),Ce(this.cropBox,me),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=x({},this.initialImageData),this.canvasData=x({},this.initialCanvasData),this.cropBoxData=x({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(x(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),Ce(this.dragBox,Mt),le(this.cropBox,me)),this},replace:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return!this.disabled&&e&&(this.isImg&&(this.element.src=e),t?(this.url=e,this.image.src=e,this.ready&&(this.viewBoxImage.src=e,oe(this.previews,function(r){r.getElementsByTagName("img")[0].src=e}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(e))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,Ce(this.cropper,yi)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,le(this.cropper,yi)),this},destroy:function(){var e=this.element;return e[J]?(e[J]=void 0,this.isImg&&this.replaced&&(e.src=this.originalUrl),this.uncreate(),this):this},move:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e,r=this.canvasData,a=r.left,n=r.top;return this.moveTo(jt(e)?e:a+Number(e),jt(t)?t:n+Number(t))},moveTo:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e,r=this.canvasData,a=!1;return e=Number(e),t=Number(t),this.ready&&!this.disabled&&this.options.movable&&(B(e)&&(r.left=e,a=!0),B(t)&&(r.top=t,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(e,t){var r=this.canvasData;return e=Number(e),e<0?e=1/(1-e):e=1+e,this.zoomTo(r.width*e/r.naturalWidth,null,t)},zoomTo:function(e,t,r){var a=this.options,n=this.canvasData,s=n.width,l=n.height,o=n.naturalWidth,h=n.naturalHeight;if(e=Number(e),e>=0&&this.ready&&!this.disabled&&a.zoomable){var u=o*e,f=h*e;if(Ke(this.element,xt,{ratio:e,oldRatio:s/o,originalEvent:r})===!1)return this;if(r){var c=this.pointers,d=dr(this.cropper),p=c&&Object.keys(c).length?Yn(c):{pageX:r.pageX,pageY:r.pageY};n.left-=(u-s)*((p.pageX-d.left-n.left)/s),n.top-=(f-l)*((p.pageY-d.top-n.top)/l)}else Ve(t)&&B(t.x)&&B(t.y)?(n.left-=(u-s)*((t.x-n.left)/s),n.top-=(f-l)*((t.y-n.top)/l)):(n.left-=(u-s)/2,n.top-=(f-l)/2);n.width=u,n.height=f,this.renderCanvas(!0)}return this},rotate:function(e){return this.rotateTo((this.imageData.rotate||0)+Number(e))},rotateTo:function(e){return e=Number(e),B(e)&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=e%360,this.renderCanvas(!0,!0)),this},scaleX:function(e){var t=this.imageData.scaleY;return this.scale(e,B(t)?t:1)},scaleY:function(e){var t=this.imageData.scaleX;return this.scale(B(t)?t:1,e)},scale:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e,r=this.imageData,a=!1;return e=Number(e),t=Number(t),this.ready&&!this.disabled&&this.options.scalable&&(B(e)&&(r.scaleX=e,a=!0),B(t)&&(r.scaleY=t,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=this.options,r=this.imageData,a=this.canvasData,n=this.cropBoxData,s;if(this.ready&&this.cropped){s={x:n.left-a.left,y:n.top-a.top,width:n.width,height:n.height};var l=r.width/r.naturalWidth;if(oe(s,function(u,f){s[f]=u/l}),e){var o=Math.round(s.y+s.height),h=Math.round(s.x+s.width);s.x=Math.round(s.x),s.y=Math.round(s.y),s.width=h-s.x,s.height=o-s.y}}else s={x:0,y:0,width:0,height:0};return t.rotatable&&(s.rotate=r.rotate||0),t.scalable&&(s.scaleX=r.scaleX||1,s.scaleY=r.scaleY||1),s},setData:function(e){var t=this.options,r=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&Ve(e)){var s=!1;t.rotatable&&B(e.rotate)&&e.rotate!==r.rotate&&(r.rotate=e.rotate,s=!0),t.scalable&&(B(e.scaleX)&&e.scaleX!==r.scaleX&&(r.scaleX=e.scaleX,s=!0),B(e.scaleY)&&e.scaleY!==r.scaleY&&(r.scaleY=e.scaleY,s=!0)),s&&this.renderCanvas(!0,!0);var l=r.width/r.naturalWidth;B(e.x)&&(n.left=e.x*l+a.left),B(e.y)&&(n.top=e.y*l+a.top),B(e.width)&&(n.width=e.width*l),B(e.height)&&(n.height=e.height*l),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?x({},this.containerData):{}},getImageData:function(){return this.sized?x({},this.imageData):{}},getCanvasData:function(){var e=this.canvasData,t={};return this.ready&&oe(["left","top","width","height","naturalWidth","naturalHeight"],function(r){t[r]=e[r]}),t},setCanvasData:function(e){var t=this.canvasData,r=t.aspectRatio;return this.ready&&!this.disabled&&Ve(e)&&(B(e.left)&&(t.left=e.left),B(e.top)&&(t.top=e.top),B(e.width)?(t.width=e.width,t.height=e.width/r):B(e.height)&&(t.height=e.height,t.width=e.height*r),this.renderCanvas(!0)),this},getCropBoxData:function(){var e=this.cropBoxData,t;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function(e){var t=this.cropBoxData,r=this.options.aspectRatio,a,n;return this.ready&&this.cropped&&!this.disabled&&Ve(e)&&(B(e.left)&&(t.left=e.left),B(e.top)&&(t.top=e.top),B(e.width)&&e.width!==t.width&&(a=!0,t.width=e.width),B(e.height)&&e.height!==t.height&&(n=!0,t.height=e.height),r&&(a?t.height=t.width/r:n&&(t.width=t.height*r)),this.renderCropBox()),this},getCroppedCanvas:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var t=this.canvasData,r=jn(this.image,this.imageData,t,e);if(!this.cropped)return r;var a=this.getData(),n=a.x,s=a.y,l=a.width,o=a.height,h=r.width/Math.floor(t.naturalWidth);h!==1&&(n*=h,s*=h,l*=h,o*=h);var u=l/o,f=Se({aspectRatio:u,width:e.maxWidth||1/0,height:e.maxHeight||1/0}),c=Se({aspectRatio:u,width:e.minWidth||0,height:e.minHeight||0},"cover"),d=Se({aspectRatio:u,width:e.width||(h!==1?r.width:l),height:e.height||(h!==1?r.height:o)}),p=d.width,v=d.height;p=Math.min(f.width,Math.max(c.width,p)),v=Math.min(f.height,Math.max(c.height,v));var O=document.createElement("canvas"),z=O.getContext("2d");O.width=Ze(p),O.height=Ze(v),z.fillStyle=e.fillColor||"transparent",z.fillRect(0,0,p,v);var T=e.imageSmoothingEnabled,E=T===void 0?!0:T,V=e.imageSmoothingQuality;z.imageSmoothingEnabled=E,V&&(z.imageSmoothingQuality=V);var R=r.width,_=r.height,I=n,H=s,M,w,ie,j,he,ne;I<=-l||I>R?(I=0,M=0,ie=0,he=0):I<=0?(ie=-I,I=0,M=Math.min(R,l+I),he=M):I<=R&&(ie=0,M=Math.min(l,R-I),he=M),M<=0||H<=-o||H>_?(H=0,w=0,j=0,ne=0):H<=0?(j=-H,H=0,w=Math.min(_,o+H),ne=w):H<=_&&(j=0,w=Math.min(o,_-H),ne=w);var K=[I,H,M,w];if(he>0&&ne>0){var ue=p/l;K.push(ie*ue,j*ue,he*ue,ne*ue)}return z.drawImage.apply(z,[r].concat(ir(K.map(function(q){return Math.floor(Ze(q))})))),O},setAspectRatio:function(e){var t=this.options;return!this.disabled&&!jt(e)&&(t.aspectRatio=Math.max(0,e)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(e){var t=this.options,r=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n=e===oi,s=t.movable&&e===sr;e=n||s?e:or,t.dragMode=e,lt(r,ot,e),Ge(r,Gt,n),Ge(r,Ft,s),t.cropBoxMovable||(lt(a,ot,e),Ge(a,Gt,n),Ge(a,Ft,s))}return this}},ia=Oe.Cropper,gr=function(){function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(gn(this,i),!e||!Rn.test(e.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=e,this.options=x({},Ii,Ve(t)&&t),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return pn(i,[{key:"init",value:function(){var t=this.element,r=t.tagName.toLowerCase(),a;if(!t[J]){if(t[J]=this,r==="img"){if(this.isImg=!0,a=t.getAttribute("src")||"",this.originalUrl=a,!a)return;a=t.src}else r==="canvas"&&window.HTMLCanvasElement&&(a=t.toDataURL());this.load(a)}}},{key:"load",value:function(t){var r=this;if(t){this.url=t,this.imageData={};var a=this.element,n=this.options;if(!n.rotatable&&!n.scalable&&(n.checkOrientation=!1),!n.checkOrientation||!window.ArrayBuffer){this.clone();return}if(On.test(t)){Tn.test(t)?this.read(Gn(t)):this.clone();return}var s=new XMLHttpRequest,l=this.clone.bind(this);this.reloading=!0,this.xhr=s,s.onabort=l,s.onerror=l,s.ontimeout=l,s.onprogress=function(){s.getResponseHeader("content-type")!==Ai&&s.abort()},s.onload=function(){r.read(s.response)},s.onloadend=function(){r.reloading=!1,r.xhr=null},n.checkCrossOrigin&&zi(t)&&a.crossOrigin&&(t=Bi(t)),s.open("GET",t,!0),s.responseType="arraybuffer",s.withCredentials=a.crossOrigin==="use-credentials",s.send()}}},{key:"read",value:function(t){var r=this.options,a=this.imageData,n=Zn(t),s=0,l=1,o=1;if(n>1){this.url=Fn(t,Ai);var h=Kn(n);s=h.rotate,l=h.scaleX,o=h.scaleY}r.rotatable&&(a.rotate=s),r.scalable&&(a.scaleX=l,a.scaleY=o),this.clone()}},{key:"clone",value:function(){var t=this.element,r=this.url,a=t.crossOrigin,n=r;this.options.checkCrossOrigin&&zi(r)&&(a||(a="anonymous"),n=Bi(r)),this.crossOrigin=a,this.crossOriginUrl=n;var s=document.createElement("img");a&&(s.crossOrigin=a),s.src=n||r,s.alt=t.alt||"The image to crop",this.image=s,s.onload=this.start.bind(this),s.onerror=this.stop.bind(this),le(s,Ei),t.parentNode.insertBefore(s,t.nextSibling)}},{key:"start",value:function(){var t=this,r=this.image;r.onload=null,r.onerror=null,this.sizing=!0;var a=Oe.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(Oe.navigator.userAgent),n=function(h,u){x(t.imageData,{naturalWidth:h,naturalHeight:u,aspectRatio:h/u}),t.initialImageData=x({},t.imageData),t.sizing=!1,t.sized=!0,t.build()};if(r.naturalWidth&&!a){n(r.naturalWidth,r.naturalHeight);return}var s=document.createElement("img"),l=document.body||document.documentElement;this.sizingImage=s,s.onload=function(){n(s.width,s.height),a||l.removeChild(s)},s.src=r.src,a||(s.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",l.appendChild(s))}},{key:"stop",value:function(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){if(!(!this.sized||this.ready)){var t=this.element,r=this.options,a=this.image,n=t.parentNode,s=document.createElement("div");s.innerHTML=Sn;var l=s.querySelector(".".concat(J,"-container")),o=l.querySelector(".".concat(J,"-canvas")),h=l.querySelector(".".concat(J,"-drag-box")),u=l.querySelector(".".concat(J,"-crop-box")),f=u.querySelector(".".concat(J,"-face"));this.container=n,this.cropper=l,this.canvas=o,this.dragBox=h,this.cropBox=u,this.viewBox=l.querySelector(".".concat(J,"-view-box")),this.face=f,o.appendChild(a),le(t,me),n.insertBefore(l,t.nextSibling),this.isImg||Ce(a,Ei),this.initPreview(),this.bind(),r.initialAspectRatio=Math.max(0,r.initialAspectRatio)||NaN,r.aspectRatio=Math.max(0,r.aspectRatio)||NaN,r.viewMode=Math.max(0,Math.min(3,Math.round(r.viewMode)))||0,le(u,me),r.guides||le(u.getElementsByClassName("".concat(J,"-dashed")),me),r.center||le(u.getElementsByClassName("".concat(J,"-center")),me),r.background&&le(l,"".concat(J,"-bg")),r.highlight||le(f,yn),r.cropBoxMovable&&(le(f,Ft),lt(f,ot,si)),r.cropBoxResizable||(le(u.getElementsByClassName("".concat(J,"-line")),me),le(u.getElementsByClassName("".concat(J,"-point")),me)),this.render(),this.ready=!0,this.setDragMode(r.dragMode),r.autoCrop&&this.crop(),this.setData(r.data),de(r.ready)&&ke(t,Ti,r.ready,{once:!0}),Ke(t,Ti)}}},{key:"unbuild",value:function(){this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),this.cropper.parentNode.removeChild(this.cropper),Ce(this.element,me))}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function(){return window.Cropper=ia,i}},{key:"setDefaults",value:function(t){x(Ii,Ve(t)&&t)}}]),i}();x(gr.prototype,Qn,Jn,xn,$n,ea,ta);function ra(i){let e,t;return{c(){e=$("img"),ge(e.src,t=i[0])||m(e,"src",t),m(e,"alt","")},m(r,a){S(r,e,a),i[4](e)},p(r,[a]){a&1&&!ge(e.src,t=r[0])&&m(e,"src",t)},i:U,o:U,d(r){r&&A(e),i[4](null)}}}function na(i,e,t){let{image:r}=e,a;const n=Je();let s;function l(){s.destroy()}function o(){s&&l(),s=new gr(a,{autoCropArea:1,cropend(){const u=s.getCroppedCanvas().toDataURL();n("crop",u)}}),n("crop",r)}function h(u){F[u?"unshift":"push"](()=>{a=u,t(1,a)})}return i.$$set=u=>{"image"in u&&t(0,r=u.image)},[r,a,l,o,h]}class pr extends be{constructor(e){super(),ve(this,e,na,ra,ce,{image:0,destroy:2,create:3})}get image(){return this.$$.ctx[0]}set image(e){this.$$set({image:e}),Q()}get destroy(){return this.$$.ctx[2]}get create(){return this.$$.ctx[3]}}class Li{constructor(e,t){this.x=e,this.y=t}}class Pi extends Li{update(e){this.x=e.x,this.y=e.y}moveByAngle(e,t){const r=e+Math.PI/2;this.x=this.x+Math.sin(r)*t,this.y=this.y-Math.cos(r)*t}equalsTo(e){return this.x===e.x&&this.y===e.y}getDifferenceTo(e){return new Li(this.x-e.x,this.y-e.y)}getDistanceTo(e){const t=this.getDifferenceTo(e);return Math.sqrt(Math.pow(t.x,2)+Math.pow(t.y,2))}getAngleTo(e){const t=this.getDifferenceTo(e);return Math.atan2(t.y,t.x)}toObject(){return{x:this.x,y:this.y}}}const aa=30;class sa{constructor({radius:e=aa,enabled:t=!0,initialPoint:r={x:0,y:0}}={}){this.radius=e,this._isEnabled=t,this.pointer=new Pi(r.x,r.y),this.brush=new Pi(r.x,r.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:t=!1}={}){return this._hasMoved=!1,this.pointer.equalsTo(e)&&!t?!1:(this.pointer.update(e),t?(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))}}const _r=Cr("#000000");var br=function(){if(typeof Map<"u")return Map;function i(e,t){var r=-1;return e.some(function(a,n){return a[0]===t?(r=n,!0):!1}),r}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(t){var r=i(this.__entries__,t),a=this.__entries__[r];return a&&a[1]},e.prototype.set=function(t,r){var a=i(this.__entries__,t);~a?this.__entries__[a][1]=r:this.__entries__.push([t,r])},e.prototype.delete=function(t){var r=this.__entries__,a=i(r,t);~a&&r.splice(a,1)},e.prototype.has=function(t){return!!~i(this.__entries__,t)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,r){r===void 0&&(r=null);for(var a=0,n=this.__entries__;a<n.length;a++){var s=n[a];t.call(r,s[1],s[0])}},e}()}(),ei=typeof window<"u"&&typeof document<"u"&&window.document===document,Ct=function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()}(),oa=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(Ct):function(i){return setTimeout(function(){return i(Date.now())},1e3/60)}}(),la=2;function ha(i,e){var t=!1,r=!1,a=0;function n(){t&&(t=!1,i()),r&&l()}function s(){oa(n)}function l(){var o=Date.now();if(t){if(o-a<la)return;r=!0}else t=!0,r=!1,setTimeout(s,e);a=o}return l}var ua=20,ca=["top","right","bottom","left","width","height","size","weight"],fa=typeof MutationObserver<"u",da=function(){function i(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=ha(this.refresh.bind(this),ua)}return i.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},i.prototype.removeObserver=function(e){var t=this.observers_,r=t.indexOf(e);~r&&t.splice(r,1),!t.length&&this.connected_&&this.disconnect_()},i.prototype.refresh=function(){var e=this.updateObservers_();e&&this.refresh()},i.prototype.updateObservers_=function(){var e=this.observers_.filter(function(t){return t.gatherActive(),t.hasActive()});return e.forEach(function(t){return t.broadcastActive()}),e.length>0},i.prototype.connect_=function(){!ei||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),fa?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},i.prototype.disconnect_=function(){!ei||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},i.prototype.onTransitionEnd_=function(e){var t=e.propertyName,r=t===void 0?"":t,a=ca.some(function(n){return!!~r.indexOf(n)});a&&this.refresh()},i.getInstance=function(){return this.instance_||(this.instance_=new i),this.instance_},i.instance_=null,i}(),vr=function(i,e){for(var t=0,r=Object.keys(e);t<r.length;t++){var a=r[t];Object.defineProperty(i,a,{value:e[a],enumerable:!1,writable:!1,configurable:!0})}return i},Qe=function(i){var e=i&&i.ownerDocument&&i.ownerDocument.defaultView;return e||Ct},wr=St(0,0,0,0);function Ot(i){return parseFloat(i)||0}function Hi(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return e.reduce(function(r,a){var n=i["border-"+a+"-width"];return r+Ot(n)},0)}function ma(i){for(var e=["top","right","bottom","left"],t={},r=0,a=e;r<a.length;r++){var n=a[r],s=i["padding-"+n];t[n]=Ot(s)}return t}function ga(i){var e=i.getBBox();return St(0,0,e.width,e.height)}function pa(i){var e=i.clientWidth,t=i.clientHeight;if(!e&&!t)return wr;var r=Qe(i).getComputedStyle(i),a=ma(r),n=a.left+a.right,s=a.top+a.bottom,l=Ot(r.width),o=Ot(r.height);if(r.boxSizing==="border-box"&&(Math.round(l+n)!==e&&(l-=Hi(r,"left","right")+n),Math.round(o+s)!==t&&(o-=Hi(r,"top","bottom")+s)),!ba(i)){var h=Math.round(l+n)-e,u=Math.round(o+s)-t;Math.abs(h)!==1&&(l-=h),Math.abs(u)!==1&&(o-=u)}return St(a.left,a.top,l,o)}var _a=function(){return typeof SVGGraphicsElement<"u"?function(i){return i instanceof Qe(i).SVGGraphicsElement}:function(i){return i instanceof Qe(i).SVGElement&&typeof i.getBBox=="function"}}();function ba(i){return i===Qe(i).document.documentElement}function va(i){return ei?_a(i)?ga(i):pa(i):wr}function wa(i){var e=i.x,t=i.y,r=i.width,a=i.height,n=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,s=Object.create(n.prototype);return vr(s,{x:e,y:t,width:r,height:a,top:t,right:e+r,bottom:a+t,left:e}),s}function St(i,e,t,r){return{x:i,y:e,width:t,height:r}}var ka=function(){function i(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=St(0,0,0,0),this.target=e}return i.prototype.isActive=function(){var e=va(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},i.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},i}(),ya=function(){function i(e,t){var r=wa(t);vr(this,{target:e,contentRect:r})}return i}(),Ea=function(){function i(e,t,r){if(this.activeObservations_=[],this.observations_=new br,typeof e!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=r}return i.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(e instanceof Qe(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)||(t.set(e,new ka(e)),this.controller_.addObserver(this),this.controller_.refresh())}},i.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(e instanceof Qe(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)&&(t.delete(e),t.size||this.controller_.removeObserver(this))}},i.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},i.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach(function(t){t.isActive()&&e.activeObservations_.push(t)})},i.prototype.broadcastActive=function(){if(this.hasActive()){var e=this.callbackCtx_,t=this.activeObservations_.map(function(r){return new ya(r.target,r.broadcastRect())});this.callback_.call(e,t,e),this.clearActive()}},i.prototype.clearActive=function(){this.activeObservations_.splice(0)},i.prototype.hasActive=function(){return this.activeObservations_.length>0},i}(),kr=typeof WeakMap<"u"?new WeakMap:new br,yr=function(){function i(e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var t=da.getInstance(),r=new Ea(e,t,this);kr.set(this,r)}return i}();["observe","unobserve","disconnect"].forEach(function(i){yr.prototype[i]=function(){var e;return(e=kr.get(this))[i].apply(e,arguments)}});var Da=function(){return typeof Ct.ResizeObserver<"u"?Ct.ResizeObserver:yr}();function Wi(i,e,t){const r=i.slice();return r[73]=e[t].name,r[74]=e[t].zIndex,r[75]=e[t].opacity,r[76]=e,r[77]=t,r}function Xi(i){let e,t,r;return{c(){e=$("div"),e.textContent="Start drawing",m(e,"class","start-prompt svelte-xrgqd4")},m(a,n){S(a,e,n),r=!0},i(a){r||(a&&ii(()=>{r&&(t||(t=mi(e,pi,{duration:50},!0)),t.run(1))}),r=!0)},o(a){a&&(t||(t=mi(e,pi,{duration:50},!1)),t.run(0)),r=!1},d(a){a&&A(e),a&&t&&t.end()}}}function Yi(i){let e,t=i[73],r,a;const n=()=>i[34](e,t),s=()=>i[34](null,t);return{c(){e=$("canvas"),m(e,"key",i[73]),gi(e,"z-index",i[74]),m(e,"class","svelte-xrgqd4"),G(e,"lr",i[7]),G(e,"tb",!i[7]),gi(e,"opacity",i[75])},m(l,o){S(l,e,o),n(),r||(a=[ee(e,"mousedown",i[73]==="interface"?i[9]:void 0),ee(e,"mousemove",i[73]==="interface"?i[10]:void 0),ee(e,"mouseup",i[73]==="interface"?i[11]:void 0),ee(e,"mouseout",i[73]==="interface"?i[11]:void 0),ee(e,"mouseout",function(){ht(i[73]==="interface"?i[35]:void 0)&&(i[73]==="interface"?i[35]:void 0).apply(this,arguments)}),ee(e,"blur",i[73]==="interface"?i[11]:void 0),ee(e,"touchstart",i[73]==="interface"?i[9]:void 0),ee(e,"touchmove",i[73]==="interface"?i[10]:void 0),ee(e,"touchend",i[73]==="interface"?i[11]:void 0),ee(e,"touchcancel",i[73]==="interface"?i[11]:void 0),ee(e,"click",Rr(i[33]))],r=!0)},p(l,o){i=l,t!==i[73]&&(s(),t=i[73],n()),o[0]&128&&G(e,"lr",i[7]),o[0]&128&&G(e,"tb",!i[7])},d(l){l&&A(e),s(),r=!1,ri(a)}}}function Ma(i){let e,t,r,a=i[6]===0&&Xi(),n=di(i[8]),s=[];for(let l=0;l<n.length;l+=1)s[l]=Yi(Wi(i,n,l));return{c(){e=$("div"),a&&a.c(),t=te();for(let l=0;l<s.length;l+=1)s[l].c();m(e,"class","wrap svelte-xrgqd4"),ii(()=>i[37].call(e))},m(l,o){S(l,e,o),a&&a.m(e,null),Z(e,t);for(let h=0;h<s.length;h+=1)s[h]&&s[h].m(e,null);i[36](e),r=$i(e,i[37].bind(e))},p(l,o){if(l[6]===0?a?o[0]&64&&y(a,1):(a=Xi(),a.c(),y(a,1),a.m(e,t)):a&&(ye(),D(a,1,1,()=>{a=null}),Ee()),o[0]&3975){n=di(l[8]);let h;for(h=0;h<n.length;h+=1){const u=Wi(l,n,h);s[h]?s[h].p(u,o):(s[h]=Yi(u),s[h].c(),s[h].m(e,null))}for(;h<s.length;h+=1)s[h].d(1);s.length=n.length}},i(l){y(a)},o(l){D(a)},d(l){l&&A(e),a&&a.d(),Or(s,l),i[36](null),r()}}}let Ca="#aaa";function Oa(i,e){return{x:i.x+(e.x-i.x)/2,y:i.y+(e.y-i.y)/2}}function Ta(i){const e=Ra(i);if(e){const{r:t,g:r,b:a}=e;return(t*299+r*587+a*114)/1e3}return 0}function Ra(i){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function Sa(i){const[e,t,r]=i.match(/\d+/g).map(Number);function a(n){const s=n.toString(16);return s.length===1?`0${s}`:s}return`#${a(e)}${a(t)}${a(r)}`}function Aa(i,e,t){let r;const a=Je();let{value:n}=e,{value_img:s}=e,{mode:l="sketch"}=e,{brush_color:o="#0b0f19"}=e,{brush_radius:h}=e,{mask_opacity:u=.7}=e,{source:f}=e,{width:c=400}=e,{height:d=200}=e,{container_height:p=200}=e,{shape:v}=e;window.maskOpacity&&(u=window.maskOpacity);let O=localStorage.setItem("colorPickerEnable",!1);localStorage.setItem("transparentMask",!1);let z=0,T=0,E=null,V,R=c,_=d,I;const H=[{name:"interface",zIndex:15},{name:"mask",zIndex:13,opacity:u},{name:"drawing",zIndex:11},{name:"temp",zIndex:12}];let M={},w={},ie=[],j=[],he=!0,ne=!0,K=!1,ue=!1,q=null,ae=null,we=null,k=0;function fe(){if(!v){w.temp.drawImage(s,0,0,c,d);return}let g=s.naturalWidth,C=s.naturalHeight;const N=v[0]/v[1],L=g/C;let P=0,se=0;N<L?(g=v[1]*L,C=v[1],P=(v[0]-g)/2):N>L?(g=v[0],C=v[0]/L,se=(v[1]-C)/2):(P=0,se=0,g=v[0],C=v[1]),w.temp.drawImage(s,P,se,g,C)}ti(async()=>{Object.keys(M).forEach(g=>{t(30,w[g]=M[g].getContext("2d"),w)}),await Le(),s&&(s.addEventListener("load",g=>{f==="webcam"?(w.temp.save(),w.temp.translate(c,0),w.temp.scale(-1,1),w.temp.drawImage(s,0,0),w.temp.restore()):fe(),w.drawing.drawImage(M.temp,0,0,c,d),Me()}),setTimeout(()=>{f==="webcam"?(w.temp.save(),w.temp.translate(c,0),w.temp.scale(-1,1),w.temp.drawImage(s,0,0),w.temp.restore()):fe(),w.drawing.drawImage(M.temp,0,0,c,d),Ye({lines:j.slice()}),Me()},100)),t(32,q=new sa({radius:h*.05,enabled:!0,initialPoint:{x:c/2,y:d/2}})),we=new Da((g,C,...N)=>{gt()}),we.observe(ae),tt(),t(28,V=!0),requestAnimationFrame(()=>{Ae(),requestAnimationFrame(()=>{Ie()})})});function Ae(){const g=c/2,C=d/2;q.update({x:g,y:C},{both:!0}),q.update({x:g,y:C},{both:!1}),he=!0,ne=!0}Tr(()=>{t(28,V=!1),we.unobserve(ae)});function We(){et(),s&&fe(),j.length==0&&a("clear"),t(6,k=j.length),Ye({lines:j}),Me()}function Xe(g){et(),s&&(f==="webcam"?(w.temp.save(),w.temp.translate(c,0),w.temp.scale(-1,1),w.temp.drawImage(s,0,0),w.temp.restore()):fe(),(!j||!j.length)&&w.drawing.drawImage(M.temp,0,0,c,d)),Ye({lines:g}),t(6,k=g.length),t(31,j=g),w.drawing.drawImage(M.temp,0,0,c,d),j.length==0&&a("clear")}function xe(){Xe([]),Me()}function At(){const g=j.slice(0,-1);Xe(g),Me()}let Ye=({lines:g})=>{const C=o;g.forEach(N=>{const{points:L,brush_color:P,brush_radius:se}=N;$e(l==="mask"?{points:L,brush_color:C,brush_radius:se,mask:l==="mask"}:{points:L,brush_color:P,brush_radius:se,mask:l==="mask"})}),je(),l==="mask"&&bt()},It=({start:g,end:C,brush_color:N,brush_radius:L})=>{w.temp.beginPath(),w.temp.moveTo(g.x,g.y),w.temp.lineTo(C.x,C.y),t(30,w.temp.strokeStyle=N,w),t(30,w.temp.lineWidth=L,w),w.temp.stroke();const P={points:[g,C],brush_color:N,brush_radius:L};j.push(P),t(6,k+=1),je()},Nt=g=>{g.preventDefault();const{x:C,y:N}=pt(g);if(window.isDrawing=!0,!g.touches&&g.button!==0)return;let L=window.drawStraightLine||!1;if((L===!1||j.length===0&&!E)&&(E=null),L){E===null?E={x:C,y:N}:(It({start:E,end:{x:C,y:N},brush_color:o,brush_radius:h}),E={x:C,y:N});return}if(O=localStorage.getItem("colorPickerEnable")==="true",O&&l!=="mask"){t(15,o=Lt(C,N));const P=Sa(o);_r.set(P),localStorage.setItem("colorPickerEnable","false");return}ue=!0,g.touches&&g.touches.length>0&&q.update({x:C,y:N},{both:!0}),_t(C,N),t(6,k+=1)},ut=g=>{g.preventDefault(),localStorage.getItem("fillCanvasBrushColor")==="true"&&(Pt(),localStorage.setItem("fillCanvasBrushColor",!1));const{x:C,y:N}=pt(g);t(1,z=C),t(2,T=N),_t(C,N)},zt=g=>{g.preventDefault(),ut(g),K=!1,ue=!1,je(),l==="mask"&&bt()},ct=0,ft=0,dt=0,mt=!1,gt=async()=>{if(v&&ae){const N=ae?.getBoundingClientRect(),L=v[0]/v[1],P=N.width/N.height;t(7,mt=L<P)}if(c===ct&&d===ft&&dt===p)return;const g={width:c,height:d},C={height:p,width:p*(g.width/g.height)};await Promise.all([Ue(M.interface,g,C),Ue(M.drawing,g,C),Ue(M.temp,g,C),Ue(M.mask,g,C,!1)]),h||t(12,h=20*(g.width/C.width)),tt({once:!0}),setTimeout(()=>{ft=d,ct=c,dt=p},10),await Le(),Ie()},Ue=async(g,C,N,L=!0)=>{if(!V)return;await Le();const P=window.devicePixelRatio||1;g.width=C.width*(L?P:1),g.height=C.height*(L?P:1);const se=g.getContext("2d");L&&se.scale(P,P),g.style.width=`${N.width}px`,g.style.height=`${N.height}px`},pt=g=>{const C=M.interface.getBoundingClientRect();let N=g.clientX,L=g.clientY;return g.changedTouches&&g.changedTouches.length>0&&(N=g.changedTouches[0].clientX,L=g.changedTouches[0].clientY),{x:(N-C.left)/C.width*c,y:(L-C.top)/C.height*d}};function Bt(){if(O=localStorage.getItem("colorPickerEnable")==="true",O&&l!=="mask")for(const g in M)t(0,M[g].style.cursor="crosshair",M);else for(const g in M)t(0,M[g].style.cursor="none",M)}let _t=(g,C)=>{if(O=localStorage.getItem("colorPickerEnable")==="true",Bt(),O&&l!=="mask")return;q.update({x:g,y:C});const N=!q.isEnabled();(ue&&!K||N&&ue)&&(K=!0,ie.push(q.brush.toObject())),K&&(ie.push(q.brush.toObject()),$e({points:ie,brush_color:o,brush_radius:h,mask:l==="mask"})),he=!0},$e=({points:g,brush_color:C,brush_radius:N,mask:L})=>{if(!g||g.length<2)return;let P=L?w.mask:w.temp;P.lineJoin="round",P.lineCap="round",P.strokeStyle=C,P.lineWidth=N;let se=g[0],Ne=g[1];P.moveTo(Ne.x,Ne.y),P.beginPath();for(var wt=1,Er=g.length;wt<Er;wt++){var fi=Oa(se,Ne);P.quadraticCurveTo(se.x,se.y,fi.x,fi.y),se=g[wt],Ne=g[wt+1]}P.lineTo(se.x,se.y),P.stroke()};function Lt(g,C){const N=w.drawing.getImageData(g-1,C,1,1),[L,P,se,Ne]=N.data;return`rgb(${L}, ${P}, ${se})`}function Pt(){if(l!=="mask"){t(30,w.temp.fillStyle=o,w),w.temp.fillRect(0,0,c,d);var g=0,C=d/2,N=c,L=d/2;w.drawing.beginPath(),w.drawing.moveTo(g,C),w.drawing.lineTo(N,L),t(30,w.drawing.strokeStyle=o,w),t(30,w.drawing.lineWidth=d,w),w.drawing.stroke(),t(31,j=[{points:[{x:g,y:C},{x:N,y:L}],brush_color:o,brush_radius:d}]),t(6,k=1),je()}}let bt=()=>{ie.length<1||(ie.length=0,Me())},je=()=>{ie.length<1||(j.push({points:ie.slice(),brush_color:o,brush_radius:h}),l!=="mask"&&(ie.length=0),w.drawing.drawImage(M.temp,0,0,c,d),Me())},Me=()=>{const g=vt();a("change",g)};function Ie(){return t(31,j=[]),et(),t(6,k=0),!0}function et(){ne=!0,w.temp.clearRect(0,0,c,d),t(30,w.temp.fillStyle=l==="mask"?"transparent":"#FFFFFF",w),w.temp.fillRect(0,0,c,d),l==="mask"&&w.mask.clearRect(0,0,M.mask.width,M.mask.height)}let tt=({once:g=!1}={})=>{if(he||ne){const C=q.getPointerCoordinates(),N=q.getBrushCoordinates();Ht(w.interface,C,N),he=!1,ne=!1}g||window.requestAnimationFrame(()=>{tt()})},Ht=(g,C,N)=>{g.clearRect(0,0,c,d);let L=N.x,P=N.y;z&&T&&(L=z,P=T),g.beginPath(),g.fillStyle=o;const se=localStorage.getItem("brushOutline")==="true";if(se){const Ne=Ta(o);g.strokeStyle=Ne>128?"black":"white",h>180?g.lineWidth=4:h>80?g.lineWidth=3:(h>20,g.lineWidth=2)}g.arc(L,P,h/2,0,Math.PI*2,!0),g.fill(),se&&g.stroke(),g.beginPath(),g.fillStyle=Ca,g.arc(L,P,r,0,Math.PI*2,!0),g.fill()};function vt(){return l==="mask"?M.mask.toDataURL("image/png"):M.drawing.toDataURL("image/jpg")}function Wt(g){er.call(this,i,g)}function Xt(g,C){F[g?"unshift":"push"](()=>{M[C]=g,t(0,M)})}const Yt=()=>{t(1,z=t(2,T=0)),localStorage.setItem("overCanvas","false")};function Ut(g){F[g?"unshift":"push"](()=>{ae=g,t(5,ae)})}function b(){R=this.offsetWidth,_=this.offsetHeight,t(3,R),t(4,_)}return i.$$set=g=>{"value"in g&&t(17,n=g.value),"value_img"in g&&t(18,s=g.value_img),"mode"in g&&t(19,l=g.mode),"brush_color"in g&&t(15,o=g.brush_color),"brush_radius"in g&&t(12,h=g.brush_radius),"mask_opacity"in g&&t(16,u=g.mask_opacity),"source"in g&&t(20,f=g.source),"width"in g&&t(13,c=g.width),"height"in g&&t(14,d=g.height),"container_height"in g&&t(21,p=g.container_height),"shape"in g&&t(22,v=g.shape)},i.$$.update=()=>{i.$$.dirty[0]&4218880&&v&&(c||d)&&(t(13,c=v[0]),t(14,d=v[1])),i.$$.dirty[0]&268566528&&V&&!n&&Ie(),i.$$.dirty[0]&1880383489|i.$$.dirty[1]&1&&V&&s!==I&&(t(29,I=s),Ie(),setTimeout(()=>{f==="webcam"?(w.temp.save(),w.temp.translate(c,0),w.temp.scale(-1,1),w.temp.drawImage(s,0,0),w.temp.restore()):fe(),w.drawing.drawImage(M.temp,0,0,c,d),Ye({lines:j.slice()}),Me()},50)),i.$$.dirty[0]&4096|i.$$.dirty[1]&2&&q&&(Ae(),q.setRadius(h*.05)),i.$$.dirty[0]&24576&&(c||d)&&gt(),i.$$.dirty[0]&4096&&(r=h*.075)},[M,z,T,R,_,ae,k,mt,H,Nt,ut,zt,h,c,d,o,u,n,s,l,f,p,v,We,xe,At,Ie,vt,V,I,w,j,q,Wt,Xt,Yt,Ut,b]}class hi extends be{constructor(e){super(),ve(this,e,Aa,Ma,ce,{value:17,value_img:18,mode:19,brush_color:15,brush_radius:12,mask_opacity:16,source:20,width:13,height:14,container_height:21,shape:22,redraw:23,clear_mask:24,undo:25,clear:26,get_image_data:27},null,[-1,-1,-1])}get redraw(){return this.$$.ctx[23]}get clear_mask(){return this.$$.ctx[24]}get undo(){return this.$$.ctx[25]}get clear(){return this.$$.ctx[26]}get get_image_data(){return this.$$.ctx[27]}}function Ia(i){let e,t;return e=new Fe({props:{Icon:rn,label:"Clear"}}),e.$on("click",i[3]),{c(){W(e.$$.fragment)},m(r,a){X(e,r,a),t=!0},p:U,i(r){t||(y(e.$$.fragment,r),t=!0)},o(r){D(e.$$.fragment,r),t=!1},d(r){Y(e,r)}}}function Na(i){let e,t,r,a,n,s,l,o,h;t=new Fe({props:{Icon:qr,label:"Undo"}}),t.$on("click",i[1]),n=new Fe({props:{Icon:jr,label:"Redraw"}}),n.$on("click",i[2]);let u=Ia(i);return o=new Fe({props:{Icon:Ur,label:"Remove Image"}}),o.$on("click",i[4]),{c(){e=$("div"),W(t.$$.fragment),r=te(),a=$("span"),W(n.$$.fragment),s=te(),u&&u.c(),l=te(),W(o.$$.fragment),m(a,"class","hide_redraw svelte-q8xc61"),m(e,"class","svelte-q8xc61")},m(f,c){S(f,e,c),X(t,e,null),Z(e,r),Z(e,a),X(n,a,null),Z(e,s),u&&u.m(e,null),Z(e,l),X(o,e,null),h=!0},p(f,[c]){u.p(f,c)},i(f){h||(y(t.$$.fragment,f),y(n.$$.fragment,f),y(u),y(o.$$.fragment,f),h=!0)},o(f){D(t.$$.fragment,f),D(n.$$.fragment,f),D(u),D(o.$$.fragment,f),h=!1},d(f){f&&A(e),Y(t),Y(n),u&&u.d(),Y(o)}}}function za(i){const e=Je();return[e,()=>e("undo"),()=>e("redraw"),s=>{e("clear_mask"),s.stopPropagation()},s=>{e("remove_image"),s.stopPropagation()}]}class ui extends be{constructor(e){super(),ve(this,e,za,Na,ce,{})}}function Ui(i){let e,t,r,a,n;return{c(){e=$("input"),m(e,"aria-label","Brush radius"),m(e,"type","range"),m(e,"min",t=.5*(i[2]/i[7])),m(e,"max",r=75*(i[2]/i[7])*i[6]),m(e,"class","svelte-p4aq0j")},m(s,l){S(s,e,l),Dt(e,i[0]),a||(n=[ee(e,"change",i[12]),ee(e,"input",i[12])],a=!0)},p(s,l){l&132&&t!==(t=.5*(s[2]/s[7]))&&m(e,"min",t),l&196&&r!==(r=75*(s[2]/s[7])*s[6])&&m(e,"max",r),l&1&&Dt(e,s[0])},d(s){s&&A(e),a=!1,ri(n)}}}function Ba(i){let e,t,r,a;t=new Fe({props:{Icon:en,label:"Select brush color"}}),t.$on("click",i[13]);let n=i[5]&&ji(i);return{c(){e=$("span"),W(t.$$.fragment),r=te(),n&&n.c(),m(e,"class","col svelte-p4aq0j")},m(s,l){S(s,e,l),X(t,e,null),Z(e,r),n&&n.m(e,null),a=!0},p(s,l){s[5]?n?n.p(s,l):(n=ji(s),n.c(),n.m(e,null)):n&&(n.d(1),n=null)},i(s){a||(y(t.$$.fragment,s),a=!0)},o(s){D(t.$$.fragment,s),a=!1},d(s){s&&A(e),Y(t),n&&n.d()}}}function ji(i){let e,t,r;return{c(){e=$("input"),m(e,"aria-label","Brush color"),m(e,"type","color"),m(e,"class","svelte-p4aq0j")},m(a,n){S(a,e,n),Dt(e,i[1]),t||(r=[ee(e,"change",i[14]),ee(e,"input",i[15])],t=!0)},p(a,n){n&2&&Dt(e,a[1])},d(a){a&&A(e),t=!1,ri(r)}}}function La(i){let e,t,r,a,n,s;r=new Fe({props:{Icon:Zr,label:"Use brush"}}),r.$on("click",i[11]);let l=i[4]&&Ui(i),o=Ba(i);return{c(){e=$("div"),t=$("span"),W(r.$$.fragment),a=te(),l&&l.c(),n=te(),o&&o.c(),m(t,"class","brush svelte-p4aq0j"),m(e,"class","wrap svelte-p4aq0j")},m(h,u){S(h,e,u),Z(e,t),X(r,t,null),Z(t,a),l&&l.m(t,null),Z(e,n),o&&o.m(e,null),s=!0},p(h,[u]){h[4]?l?l.p(h,u):(l=Ui(h),l.c(),l.m(t,null)):l&&(l.d(1),l=null),o.p(h,u)},i(h){s||(y(r.$$.fragment,h),y(o),s=!0)},o(h){D(r.$$.fragment,h),D(o),s=!1},d(h){h&&A(e),Y(r),l&&l.d(),o&&o.d()}}}function Pa(i,e,t){let r;const a=Je();let n=!1,s=!1,{brush_radius:l=20}=e,{container_height:o}=e,{img_width:h}=e,{img_height:u}=e,{mode:f="other"}=e,{brush_color:c="#000"}=e,d=window.maxBrushSize;d?d=d/100:d=1,_r.subscribe(E=>{t(1,c=E)});const p=()=>t(4,n=!n);function v(){l=Sr(this.value),t(0,l)}const O=()=>t(5,s=!s),z=()=>{f==="mask"&&a("redraw")};function T(){c=this.value,t(1,c)}return i.$$set=E=>{"brush_radius"in E&&t(0,l=E.brush_radius),"container_height"in E&&t(9,o=E.container_height),"img_width"in E&&t(2,h=E.img_width),"img_height"in E&&t(10,u=E.img_height),"mode"in E&&t(3,f=E.mode),"brush_color"in E&&t(1,c=E.brush_color)},i.$$.update=()=>{i.$$.dirty&1540&&t(7,r=o*(h/u))},[l,c,h,f,n,s,d,r,a,o,u,p,v,O,z,T]}class ci extends be{constructor(e){super(),ve(this,e,Pa,La,ce,{brush_radius:0,container_height:9,img_width:2,img_height:10,mode:3,brush_color:1})}}function Ha(i){let e,t,r,a;return{c(){e=$("img"),ge(e.src,t=i[0].image||i[0])||m(e,"src",t),m(e,"alt",""),m(e,"class","svelte-p3y7hu"),G(e,"webcam",i[6]==="webcam"&&i[10]),G(e,"selectable",i[11])},m(n,s){S(n,e,s),r||(a=ee(e,"click",i[32]),r=!0)},p(n,s){s[0]&1&&!ge(e.src,t=n[0].image||n[0])&&m(e,"src",t),s[0]&1088&&G(e,"webcam",n[6]==="webcam"&&n[10]),s[0]&2048&&G(e,"selectable",n[11])},i:U,o:U,d(n){n&&A(e),r=!1,a()}}}function Wa(i){let e=i[25],t,r,a,n=qi(i),s=i[19]>0&&Vi(i);return{c(){n.c(),t=te(),s&&s.c(),r=He()},m(l,o){n.m(l,o),S(l,t,o),s&&s.m(l,o),S(l,r,o),a=!0},p(l,o){o[0]&33554432&&ce(e,e=l[25])?(n.d(1),n=qi(l),n.c(),n.m(t.parentNode,t)):n.p(l,o),l[19]>0?s?(s.p(l,o),o[0]&524288&&y(s,1)):(s=Vi(l),s.c(),y(s,1),s.m(r.parentNode,r)):s&&(ye(),D(s,1,1,()=>{s=null}),Ee())},i(l){a||(y(s),a=!0)},o(l){D(s),a=!1},d(l){l&&(A(t),A(r)),n.d(l),s&&s.d(l)}}}function Xa(i){let e,t,r,a,n,s,l;return e=new Tt({props:{editable:!0}}),e.$on("edit",i[57]),e.$on("clear",i[27]),{c(){W(e.$$.fragment),t=te(),r=$("img"),ge(r.src,a=i[0])||m(r,"src",a),m(r,"alt",""),m(r,"class","svelte-p3y7hu"),G(r,"selectable",i[11]),G(r,"webcam",i[6]==="webcam"&&i[10])},m(o,h){X(e,o,h),S(o,t,h),S(o,r,h),n=!0,s||(l=ee(r,"click",i[32]),s=!0)},p(o,h){(!n||h[0]&1&&!ge(r.src,a=o[0]))&&m(r,"src",a),(!n||h[0]&2048)&&G(r,"selectable",o[11]),(!n||h[0]&1088)&&G(r,"webcam",o[6]==="webcam"&&o[10])},i(o){n||(y(e.$$.fragment,o),n=!0)},o(o){D(e.$$.fragment,o),n=!1},d(o){o&&(A(t),A(r)),Y(e,o),s=!1,l()}}}function Ya(i){let e,t,r,a,n={image:i[0]};return e=new pr({props:n}),i[55](e),e.$on("crop",i[28]),r=new Tt({}),r.$on("clear",i[56]),{c(){W(e.$$.fragment),t=te(),W(r.$$.fragment)},m(s,l){X(e,s,l),S(s,t,l),X(r,s,l),a=!0},p(s,l){const o={};l[0]&1&&(o.image=s[0]),e.$set(o)},i(s){a||(y(e.$$.fragment,s),y(r.$$.fragment,s),a=!0)},o(s){D(e.$$.fragment,s),D(r.$$.fragment,s),a=!1},d(s){s&&A(t),i[55](null),Y(e,s),Y(r,s)}}}function Ua(i){let e,t,r=i[6]==="webcam"&&!i[25]&&Fi(i);return{c(){r&&r.c(),e=He()},m(a,n){r&&r.m(a,n),S(a,e,n),t=!0},p(a,n){a[6]==="webcam"&&!a[25]?r?(r.p(a,n),n[0]&33554496&&y(r,1)):(r=Fi(a),r.c(),y(r,1),r.m(e.parentNode,e)):r&&(ye(),D(r,1,1,()=>{r=null}),Ee())},i(a){t||(y(r),t=!0)},o(a){D(r),t=!1},d(a){a&&A(e),r&&r.d(a)}}}function ja(i){let e,t,r,a,n,s,l;e=new ui({}),e.$on("undo",i[46]),e.$on("redraw",i[47]),e.$on("clear",i[30]),e.$on("remove_image",i[30]);let o=i[1]==="color-sketch"&&Zi(i);function h(c){i[50](c)}function u(c){i[51](c)}let f={value:i[0],mode:i[21],width:i[19]||i[24],height:i[18]||i[23],container_height:i[20]||i[23],shape:i[7]};return i[2]!==void 0&&(f.brush_radius=i[2]),i[3]!==void 0&&(f.brush_color=i[3]),a=new hi({props:f}),F.push(()=>pe(a,"brush_radius",h)),F.push(()=>pe(a,"brush_color",u)),i[52](a),a.$on("change",i[28]),a.$on("clear",i[30]),{c(){W(e.$$.fragment),t=te(),o&&o.c(),r=te(),W(a.$$.fragment)},m(c,d){X(e,c,d),S(c,t,d),o&&o.m(c,d),S(c,r,d),X(a,c,d),l=!0},p(c,d){c[1]==="color-sketch"?o?(o.p(c,d),d[0]&2&&y(o,1)):(o=Zi(c),o.c(),y(o,1),o.m(r.parentNode,r)):o&&(ye(),D(o,1,1,()=>{o=null}),Ee());const p={};d[0]&1&&(p.value=c[0]),d[0]&2097152&&(p.mode=c[21]),d[0]&17301504&&(p.width=c[19]||c[24]),d[0]&8650752&&(p.height=c[18]||c[23]),d[0]&9437184&&(p.container_height=c[20]||c[23]),d[0]&128&&(p.shape=c[7]),!n&&d[0]&4&&(n=!0,p.brush_radius=c[2],_e(()=>n=!1)),!s&&d[0]&8&&(s=!0,p.brush_color=c[3],_e(()=>s=!1)),a.$set(p)},i(c){l||(y(e.$$.fragment,c),y(o),y(a.$$.fragment,c),l=!0)},o(c){D(e.$$.fragment,c),D(o),D(a.$$.fragment,c),l=!1},d(c){c&&(A(t),A(r)),Y(e,c),o&&o.d(c),i[52](null),Y(a,c)}}}function qa(i){let e,t,r;function a(s){i[45](s)}let n={filetype:"image/*",include_file_metadata:!1,disable_click:!!i[0],$$slots:{default:[Qa]},$$scope:{ctx:i}};return i[14]!==void 0&&(n.dragging=i[14]),e=new Vr({props:n}),F.push(()=>pe(e,"dragging",a)),e.$on("load",i[26]),{c(){W(e.$$.fragment)},m(s,l){X(e,s,l),r=!0},p(s,l){const o={};l[0]&1&&(o.disable_click=!!s[0]),l[0]&67091919|l[2]&32&&(o.$$scope={dirty:l,ctx:s}),!t&&l[0]&16384&&(t=!0,o.dragging=s[14],_e(()=>t=!1)),e.$set(o)},i(s){r||(y(e.$$.fragment,s),r=!0)},o(s){D(e.$$.fragment,s),r=!1},d(s){Y(e,s)}}}function qi(i){let e,t,r,a;return{c(){e=$("img"),m(e,"class","absolute-img svelte-p3y7hu"),ge(e.src,t=i[25]||i[0]?.image||i[0])||m(e,"src",t),m(e,"alt","load-1"),G(e,"webcam",i[6]==="webcam"&&i[10])},m(n,s){S(n,e,s),i[58](e),r||(a=ee(e,"load",i[29]),r=!0)},p(n,s){s[0]&33554433&&!ge(e.src,t=n[25]||n[0]?.image||n[0])&&m(e,"src",t),s[0]&1088&&G(e,"webcam",n[6]==="webcam"&&n[10])},d(n){n&&A(e),i[58](null),r=!1,a()}}}function Vi(i){let e,t,r,a,n,s,l,o;function h(d){i[60](d)}function u(d){i[61](d)}let f={value:i[0],mode:i[21],width:i[19]||i[24],height:i[18]||i[23],container_height:i[20]||i[23],value_img:i[22],source:i[6]};i[2]!==void 0&&(f.brush_radius=i[2]),i[3]!==void 0&&(f.brush_color=i[3]),e=new hi({props:f}),i[59](e),F.push(()=>pe(e,"brush_radius",h)),F.push(()=>pe(e,"brush_color",u)),e.$on("change",i[28]),n=new ui({}),n.$on("undo",i[62]),n.$on("redraw",i[63]),n.$on("clear",i[30]),n.$on("remove_image",i[30]);let c=(i[1]==="color-sketch"||i[1]==="sketch")&&Gi(i);return{c(){W(e.$$.fragment),a=te(),W(n.$$.fragment),s=te(),c&&c.c(),l=He()},m(d,p){X(e,d,p),S(d,a,p),X(n,d,p),S(d,s,p),c&&c.m(d,p),S(d,l,p),o=!0},p(d,p){const v={};p[0]&1&&(v.value=d[0]),p[0]&2097152&&(v.mode=d[21]),p[0]&17301504&&(v.width=d[19]||d[24]),p[0]&8650752&&(v.height=d[18]||d[23]),p[0]&9437184&&(v.container_height=d[20]||d[23]),p[0]&4194304&&(v.value_img=d[22]),p[0]&64&&(v.source=d[6]),!t&&p[0]&4&&(t=!0,v.brush_radius=d[2],_e(()=>t=!1)),!r&&p[0]&8&&(r=!0,v.brush_color=d[3],_e(()=>r=!1)),e.$set(v),d[1]==="color-sketch"||d[1]==="sketch"?c?(c.p(d,p),p[0]&2&&y(c,1)):(c=Gi(d),c.c(),y(c,1),c.m(l.parentNode,l)):c&&(ye(),D(c,1,1,()=>{c=null}),Ee())},i(d){o||(y(e.$$.fragment,d),y(n.$$.fragment,d),y(c),o=!0)},o(d){D(e.$$.fragment,d),D(n.$$.fragment,d),D(c),o=!1},d(d){d&&(A(a),A(s),A(l)),i[59](null),Y(e,d),Y(n,d),c&&c.d(d)}}}function Gi(i){let e,t,r,a;function n(o){i[64](o)}function s(o){i[65](o)}let l={container_height:i[20]||i[23],img_width:i[19]||i[24],img_height:i[18]||i[23],mode:i[21]};return i[2]!==void 0&&(l.brush_radius=i[2]),i[3]!==void 0&&(l.brush_color=i[3]),e=new ci({props:l}),F.push(()=>pe(e,"brush_radius",n)),F.push(()=>pe(e,"brush_color",s)),{c(){W(e.$$.fragment)},m(o,h){X(e,o,h),a=!0},p(o,h){const u={};h[0]&9437184&&(u.container_height=o[20]||o[23]),h[0]&17301504&&(u.img_width=o[19]||o[24]),h[0]&8650752&&(u.img_height=o[18]||o[23]),h[0]&2097152&&(u.mode=o[21]),!t&&h[0]&4&&(t=!0,u.brush_radius=o[2],_e(()=>t=!1)),!r&&h[0]&8&&(r=!0,u.brush_color=o[3],_e(()=>r=!1)),e.$set(u)},i(o){a||(y(e.$$.fragment,o),a=!0)},o(o){D(e.$$.fragment,o),a=!1},d(o){Y(e,o)}}}function Fi(i){let e,t;return e=new mn({props:{streaming:i[8],pending:i[9],mirror_webcam:i[10]}}),e.$on("capture",i[53]),e.$on("stream",i[28]),e.$on("error",i[54]),{c(){W(e.$$.fragment)},m(r,a){X(e,r,a),t=!0},p(r,a){const n={};a[0]&256&&(n.streaming=r[8]),a[0]&512&&(n.pending=r[9]),a[0]&1024&&(n.mirror_webcam=r[10]),e.$set(n)},i(r){t||(y(e.$$.fragment,r),t=!0)},o(r){D(e.$$.fragment,r),t=!1},d(r){Y(e,r)}}}function Zi(i){let e,t,r,a;function n(o){i[48](o)}function s(o){i[49](o)}let l={container_height:i[20]||i[23],img_width:i[19]||i[24],img_height:i[18]||i[23]};return i[2]!==void 0&&(l.brush_radius=i[2]),i[3]!==void 0&&(l.brush_color=i[3]),e=new ci({props:l}),F.push(()=>pe(e,"brush_radius",n)),F.push(()=>pe(e,"brush_color",s)),e.$on("redraw",function(){ht(i[15].redraw())&&i[15].redraw().apply(this,arguments)}),{c(){W(e.$$.fragment)},m(o,h){X(e,o,h),a=!0},p(o,h){i=o;const u={};h[0]&9437184&&(u.container_height=i[20]||i[23]),h[0]&17301504&&(u.img_width=i[19]||i[24]),h[0]&8650752&&(u.img_height=i[18]||i[23]),!t&&h[0]&4&&(t=!0,u.brush_radius=i[2],_e(()=>t=!1)),!r&&h[0]&8&&(r=!0,u.brush_color=i[3],_e(()=>r=!1)),e.$set(u)},i(o){a||(y(e.$$.fragment,o),a=!0)},o(o){D(e.$$.fragment,o),a=!1},d(o){Y(e,o)}}}function Va(i){let e,t,r,a;return{c(){e=$("img"),ge(e.src,t=i[0].image||i[0])||m(e,"src",t),m(e,"alt","hello"),m(e,"class","svelte-p3y7hu"),G(e,"webcam",i[6]==="webcam"&&i[10]),G(e,"selectable",i[11])},m(n,s){S(n,e,s),r||(a=ee(e,"click",i[32]),r=!0)},p(n,s){s[0]&1&&!ge(e.src,t=n[0].image||n[0])&&m(e,"src",t),s[0]&1088&&G(e,"webcam",n[6]==="webcam"&&n[10]),s[0]&2048&&G(e,"selectable",n[11])},i:U,o:U,d(n){n&&A(e),r=!1,a()}}}function Ga(i){let e=i[25],t,r,a,n=Ki(i),s=i[19]>0&&Qi(i);return{c(){n.c(),t=te(),s&&s.c(),r=He()},m(l,o){n.m(l,o),S(l,t,o),s&&s.m(l,o),S(l,r,o),a=!0},p(l,o){o[0]&33554432&&ce(e,e=l[25])?(n.d(1),n=Ki(l),n.c(),n.m(t.parentNode,t)):n.p(l,o),l[19]>0?s?(s.p(l,o),o[0]&524288&&y(s,1)):(s=Qi(l),s.c(),y(s,1),s.m(r.parentNode,r)):s&&(ye(),D(s,1,1,()=>{s=null}),Ee())},i(l){a||(y(s),a=!0)},o(l){D(s),a=!1},d(l){l&&(A(t),A(r)),n.d(l),s&&s.d(l)}}}function Fa(i){let e,t,r,a,n,s,l;return e=new Tt({props:{editable:!0}}),e.$on("edit",i[36]),e.$on("clear",i[27]),{c(){W(e.$$.fragment),t=te(),r=$("img"),ge(r.src,a=i[0])||m(r,"src",a),m(r,"alt",""),m(r,"class","svelte-p3y7hu"),G(r,"scale-x-[-1]",i[6]==="webcam"&&i[10]),G(r,"selectable",i[11])},m(o,h){X(e,o,h),S(o,t,h),S(o,r,h),n=!0,s||(l=ee(r,"click",i[32]),s=!0)},p(o,h){(!n||h[0]&1&&!ge(r.src,a=o[0]))&&m(r,"src",a),(!n||h[0]&1088)&&G(r,"scale-x-[-1]",o[6]==="webcam"&&o[10]),(!n||h[0]&2048)&&G(r,"selectable",o[11])},i(o){n||(y(e.$$.fragment,o),n=!0)},o(o){D(e.$$.fragment,o),n=!1},d(o){o&&(A(t),A(r)),Y(e,o),s=!1,l()}}}function Za(i){let e,t,r,a,n={image:i[0]};return e=new pr({props:n}),i[34](e),e.$on("crop",i[28]),r=new Tt({}),r.$on("clear",i[35]),{c(){W(e.$$.fragment),t=te(),W(r.$$.fragment)},m(s,l){X(e,s,l),S(s,t,l),X(r,s,l),a=!0},p(s,l){const o={};l[0]&1&&(o.image=s[0]),e.$set(o)},i(s){a||(y(e.$$.fragment,s),y(r.$$.fragment,s),a=!0)},o(s){D(e.$$.fragment,s),D(r.$$.fragment,s),a=!1},d(s){s&&A(t),i[34](null),Y(e,s),Y(r,s)}}}function Ka(i){let e;const t=i[33].default,r=Ar(t,i,i[67],null);return{c(){r&&r.c()},m(a,n){r&&r.m(a,n),e=!0},p(a,n){r&&r.p&&(!e||n[2]&32)&&Ir(r,t,a,a[67],e?zr(t,a[67],n,null):Nr(a[67]),null)},i(a){e||(y(r,a),e=!0)},o(a){D(r,a),e=!1},d(a){r&&r.d(a)}}}function Ki(i){let e,t,r,a;return{c(){e=$("img"),m(e,"class","absolute-img svelte-p3y7hu"),ge(e.src,t=i[25]||i[0]?.image||i[0])||m(e,"src",t),m(e,"data-source",i[16]),m(e,"data-isupload",i[17]),m(e,"alt","load-2"),G(e,"webcam",i[6]==="webcam"&&i[10])},m(n,s){S(n,e,s),i[37](e),r||(a=ee(e,"load",i[29]),r=!0)},p(n,s){s[0]&33554433&&!ge(e.src,t=n[25]||n[0]?.image||n[0])&&m(e,"src",t),s[0]&65536&&m(e,"data-source",n[16]),s[0]&131072&&m(e,"data-isupload",n[17]),s[0]&1088&&G(e,"webcam",n[6]==="webcam"&&n[10])},d(n){n&&A(e),i[37](null),r=!1,a()}}}function Qi(i){let e,t,r,a,n,s,l,o;function h(d){i[39](d)}function u(d){i[40](d)}let f={value:i[0],mask_opacity:i[12],mode:i[21],width:i[19]||i[24],height:i[18]||i[23],container_height:i[20]||i[23],value_img:i[22],source:i[6],shape:i[7]};i[2]!==void 0&&(f.brush_radius=i[2]),i[3]!==void 0&&(f.brush_color=i[3]),e=new hi({props:f}),i[38](e),F.push(()=>pe(e,"brush_radius",h)),F.push(()=>pe(e,"brush_color",u)),e.$on("change",i[28]),e.$on("redraw",function(){ht(i[15].redraw())&&i[15].redraw().apply(this,arguments)}),n=new ui({props:{show_eraser:i[22]}}),n.$on("undo",i[41]),n.$on("redraw",i[42]),n.$on("clear_mask",i[31]),n.$on("remove_image",i[30]);let c=(i[1]==="color-sketch"||i[1]==="sketch")&&Ji(i);return{c(){W(e.$$.fragment),a=te(),W(n.$$.fragment),s=te(),c&&c.c(),l=He()},m(d,p){X(e,d,p),S(d,a,p),X(n,d,p),S(d,s,p),c&&c.m(d,p),S(d,l,p),o=!0},p(d,p){i=d;const v={};p[0]&1&&(v.value=i[0]),p[0]&4096&&(v.mask_opacity=i[12]),p[0]&2097152&&(v.mode=i[21]),p[0]&17301504&&(v.width=i[19]||i[24]),p[0]&8650752&&(v.height=i[18]||i[23]),p[0]&9437184&&(v.container_height=i[20]||i[23]),p[0]&4194304&&(v.value_img=i[22]),p[0]&64&&(v.source=i[6]),p[0]&128&&(v.shape=i[7]),!t&&p[0]&4&&(t=!0,v.brush_radius=i[2],_e(()=>t=!1)),!r&&p[0]&8&&(r=!0,v.brush_color=i[3],_e(()=>r=!1)),e.$set(v);const O={};p[0]&4194304&&(O.show_eraser=i[22]),n.$set(O),i[1]==="color-sketch"||i[1]==="sketch"?c?(c.p(i,p),p[0]&2&&y(c,1)):(c=Ji(i),c.c(),y(c,1),c.m(l.parentNode,l)):c&&(ye(),D(c,1,1,()=>{c=null}),Ee())},i(d){o||(y(e.$$.fragment,d),y(n.$$.fragment,d),y(c),o=!0)},o(d){D(e.$$.fragment,d),D(n.$$.fragment,d),D(c),o=!1},d(d){d&&(A(a),A(s),A(l)),i[38](null),Y(e,d),Y(n,d),c&&c.d(d)}}}function Ji(i){let e,t,r,a;function n(o){i[43](o)}function s(o){i[44](o)}let l={container_height:i[20]||i[23],img_width:i[19]||i[24],img_height:i[18]||i[23],mode:i[21]};return i[2]!==void 0&&(l.brush_radius=i[2]),i[3]!==void 0&&(l.brush_color=i[3]),e=new ci({props:l}),F.push(()=>pe(e,"brush_radius",n)),F.push(()=>pe(e,"brush_color",s)),e.$on("redraw",function(){ht(i[15].redraw())&&i[15].redraw().apply(this,arguments)}),{c(){W(e.$$.fragment)},m(o,h){X(e,o,h),a=!0},p(o,h){i=o;const u={};h[0]&9437184&&(u.container_height=i[20]||i[23]),h[0]&17301504&&(u.img_width=i[19]||i[24]),h[0]&8650752&&(u.img_height=i[18]||i[23]),h[0]&2097152&&(u.mode=i[21]),!t&&h[0]&4&&(t=!0,u.brush_radius=i[2],_e(()=>t=!1)),!r&&h[0]&8&&(r=!0,u.brush_color=i[3],_e(()=>r=!1)),e.$set(u)},i(o){a||(y(e.$$.fragment,o),a=!0)},o(o){D(e.$$.fragment,o),a=!1},d(o){Y(e,o)}}}function Qa(i){let e,t,r,a;const n=[Ka,Za,Fa,Ga,Va],s=[];function l(o,h){return o[0]===null&&!o[25]||o[8]?0:o[1]==="select"?1:o[1]==="editor"?2:(o[1]==="sketch"||o[1]==="color-sketch")&&(o[0]!==null||o[25])?3:4}return e=l(i),t=s[e]=n[e](i),{c(){t.c(),r=He()},m(o,h){s[e].m(o,h),S(o,r,h),a=!0},p(o,h){let u=e;e=l(o),e===u?s[e].p(o,h):(ye(),D(s[u],1,1,()=>{s[u]=null}),Ee(),t=s[e],t?t.p(o,h):(t=s[e]=n[e](o),t.c()),y(t,1),t.m(r.parentNode,r))},i(o){a||(y(t),a=!0)},o(o){D(t),a=!1},d(o){o&&A(r),s[e].d(o)}}}function Ja(i){let e,t,r,a,n,s,l;e=new Xr({props:{show_label:i[5],Icon:i[6]==="canvas"?bi:_i,label:i[4]||(i[6]==="canvas"?"Sketch":"Image")}});const o=[qa,ja,Ua,Ya,Xa,Wa,Ha],h=[];function u(f,c){return f[6]==="upload"?0:f[6]==="canvas"?1:f[0]===null&&!f[25]||f[8]?2:f[1]==="select"?3:f[1]==="editor"?4:(f[1]==="sketch"||f[1]==="color-sketch")&&(f[0]!==null||f[25])?5:6}return a=u(i),n=h[a]=o[a](i),{c(){W(e.$$.fragment),t=te(),r=$("div"),n.c(),m(r,"class","image-container svelte-p3y7hu"),m(r,"data-testid","image"),ii(()=>i[66].call(r))},m(f,c){X(e,f,c),S(f,t,c),S(f,r,c),h[a].m(r,null),s=$i(r,i[66].bind(r)),l=!0},p(f,c){const d={};c[0]&32&&(d.show_label=f[5]),c[0]&64&&(d.Icon=f[6]==="canvas"?bi:_i),c[0]&80&&(d.label=f[4]||(f[6]==="canvas"?"Sketch":"Image")),e.$set(d);let p=a;a=u(f),a===p?h[a].p(f,c):(ye(),D(h[p],1,1,()=>{h[p]=null}),Ee(),n=h[a],n?n.p(f,c):(n=h[a]=o[a](f),n.c()),y(n,1),n.m(r,null))},i(f){l||(y(e.$$.fragment,f),y(n),l=!0)},o(f){D(e.$$.fragment,f),D(n),l=!1},d(f){f&&(A(t),A(r)),Y(e,f),h[a].d(),s()}}}function xa(i,e,t){let{$$slots:r={},$$scope:a}=e,{value:n}=e,{label:s=void 0}=e,{show_label:l}=e,{source:o="upload"}=e,{tool:h="editor"}=e,{shape:u}=e,{streaming:f=!1}=e,{pending:c=!1}=e,{mirror_webcam:d}=e,{brush_radius:p}=e,{brush_color:v="#000000"}=e,{selectable:O=!1}=e,{mask_opacity:z}=e,T,E,V="",R=!1;n&&(o==="upload"||o==="webcam")&&h==="sketch"&&(n={image:n,mask:null});function _({detail:b}){h==="color-sketch"?t(25,fe=b):t(0,n=(o==="upload"||o==="webcam")&&h==="sketch"?{image:b,mask:null}:b),t(17,R=!0),localStorage.setItem("resetLines","true"),M("upload",b)}function I({detail:b}){t(0,n=null),t(25,fe=void 0),M("clear")}async function H({detail:b},g,C=!1){q==="mask"?o==="webcam"&&g?t(0,n={image:b,mask:null}):t(0,n={image:typeof n=="string"?n:n?.image||null,mask:b}):(o==="upload"||o==="webcam")&&h==="sketch"?t(0,n={image:b,mask:null}):(V===""&&t(16,V=b),t(0,n=b)),await Le(),M(f?"stream":"edit")}const M=Je();let w=!1;function ie(b){const g=b.currentTarget;t(19,K=g.naturalWidth),t(18,ne=g.naturalHeight),t(20,ue=g.getBoundingClientRect().height)}async function j(){T.clear(),await Le(),t(0,n=null),t(25,fe=void 0),t(16,V=""),t(17,R=!1)}async function he(){T.clear_mask(),await Le()}let ne=0,K=0,ue=0,q,ae,we,k,fe;ti(async()=>{h==="color-sketch"&&n&&typeof n=="string"&&(t(25,fe=n),await Le(),ie({currentTarget:ae}))});const Ae=b=>{let g=Yr(b);g&&M("select",{index:g,value:null})};function We(b){F[b?"unshift":"push"](()=>{E=b,t(13,E),t(0,n)})}const Xe=b=>(I(b),t(1,h="editor")),xe=()=>t(1,h="select");function At(b){F[b?"unshift":"push"](()=>{ae=b,t(22,ae)})}function Ye(b){F[b?"unshift":"push"](()=>{T=b,t(15,T)})}function It(b){p=b,t(2,p)}function Nt(b){v=b,t(3,v)}const ut=()=>T.undo(),zt=()=>T.redraw();function ct(b){p=b,t(2,p)}function ft(b){v=b,t(3,v)}function dt(b){w=b,t(14,w)}const mt=()=>T.undo(),gt=()=>T.redraw();function Ue(b){p=b,t(2,p)}function pt(b){v=b,t(3,v)}function Bt(b){p=b,t(2,p)}function _t(b){v=b,t(3,v)}function $e(b){F[b?"unshift":"push"](()=>{T=b,t(15,T)})}const Lt=b=>h==="color-sketch"?_(b):H(b,!0,"");function Pt(b){er.call(this,i,b)}function bt(b){F[b?"unshift":"push"](()=>{E=b,t(13,E),t(0,n)})}const je=b=>(I(b),t(1,h="editor")),Me=()=>t(1,h="select");function Ie(b){F[b?"unshift":"push"](()=>{ae=b,t(22,ae)})}function et(b){F[b?"unshift":"push"](()=>{T=b,t(15,T)})}function tt(b){p=b,t(2,p)}function Ht(b){v=b,t(3,v)}const vt=()=>T.undo(),Wt=()=>T.redraw();function Xt(b){p=b,t(2,p)}function Yt(b){v=b,t(3,v)}function Ut(){we=this.offsetHeight,k=this.offsetWidth,t(23,we),t(24,k)}return i.$$set=b=>{"value"in b&&t(0,n=b.value),"label"in b&&t(4,s=b.label),"show_label"in b&&t(5,l=b.show_label),"source"in b&&t(6,o=b.source),"tool"in b&&t(1,h=b.tool),"shape"in b&&t(7,u=b.shape),"streaming"in b&&t(8,f=b.streaming),"pending"in b&&t(9,c=b.pending),"mirror_webcam"in b&&t(10,d=b.mirror_webcam),"brush_radius"in b&&t(2,p=b.brush_radius),"brush_color"in b&&t(3,v=b.brush_color),"selectable"in b&&t(11,O=b.selectable),"mask_opacity"in b&&t(12,z=b.mask_opacity),"$$scope"in b&&t(67,a=b.$$scope)},i.$$.update=()=>{i.$$.dirty[0]&1&&M("change",n),i.$$.dirty[0]&16384&&M("drag",w),i.$$.dirty[0]&66&&(o==="canvas"&&h==="sketch"?t(21,q="bw-sketch"):h==="color-sketch"?t(21,q="color-sketch"):(o==="upload"||o==="webcam")&&h==="sketch"?t(21,q="mask"):t(21,q="editor")),i.$$.dirty[0]&1&&(n===null||n.image===null&&n.mask===null)&&t(25,fe=void 0),i.$$.dirty[0]&8193&&E&&(n?(t(13,E.image=n,E),E.create()):E.destroy())},[n,h,p,v,s,l,o,u,f,c,d,O,z,E,w,T,V,R,ne,K,ue,q,ae,we,k,fe,_,I,H,ie,j,he,Ae,r,We,Xe,xe,At,Ye,It,Nt,ut,zt,ct,ft,dt,mt,gt,Ue,pt,Bt,_t,$e,Lt,Pt,bt,je,Me,Ie,et,tt,Ht,vt,Wt,Xt,Yt,Ut,a]}class $a extends be{constructor(e){super(),ve(this,e,xa,Ja,ce,{value:0,label:4,show_label:5,source:6,tool:1,shape:7,streaming:8,pending:9,mirror_webcam:10,brush_radius:2,brush_color:3,selectable:11,mask_opacity:12},null,[-1,-1,-1])}}function es(i){let e,t;return e=new Gr({props:{type:"image"}}),{c(){W(e.$$.fragment)},m(r,a){X(e,r,a),t=!0},p:U,i(r){t||(y(e.$$.fragment,r),t=!0)},o(r){D(e.$$.fragment,r),t=!1},d(r){Y(e,r)}}}function ts(i){let e,t,r,a,n;const s=[i[1]];let l={};for(let u=0;u<s.length;u+=1)l=Br(l,s[u]);e=new Lr({props:l});function o(u){i[24](u)}let h={brush_radius:i[15],brush_color:i[16],shape:i[14],source:i[5],tool:i[6],selectable:i[18],mask_opacity:i[17],label:i[7],show_label:i[8],pending:i[10],streaming:i[9],mirror_webcam:i[13],$$slots:{default:[es]},$$scope:{ctx:i}};return i[0]!==void 0&&(h.value=i[0]),r=new $a({props:h}),F.push(()=>pe(r,"value",o)),r.$on("edit",i[25]),r.$on("clear",i[26]),r.$on("stream",i[27]),r.$on("drag",i[28]),r.$on("upload",i[29]),r.$on("select",i[30]),r.$on("share",i[31]),r.$on("error",i[32]),{c(){W(e.$$.fragment),t=te(),W(r.$$.fragment)},m(u,f){X(e,u,f),S(u,t,f),X(r,u,f),n=!0},p(u,f){const c=f[0]&2?Pr(s,[Hr(u[1])]):{};e.$set(c);const d={};f[0]&32768&&(d.brush_radius=u[15]),f[0]&65536&&(d.brush_color=u[16]),f[0]&16384&&(d.shape=u[14]),f[0]&32&&(d.source=u[5]),f[0]&64&&(d.tool=u[6]),f[0]&262144&&(d.selectable=u[18]),f[0]&131072&&(d.mask_opacity=u[17]),f[0]&128&&(d.label=u[7]),f[0]&256&&(d.show_label=u[8]),f[0]&1024&&(d.pending=u[10]),f[0]&512&&(d.streaming=u[9]),f[0]&8192&&(d.mirror_webcam=u[13]),f[1]&4&&(d.$$scope={dirty:f,ctx:u}),!a&&f[0]&1&&(a=!0,d.value=u[0],_e(()=>a=!1)),r.$set(d)},i(u){n||(y(e.$$.fragment,u),y(r.$$.fragment,u),n=!0)},o(u){D(e.$$.fragment,u),D(r.$$.fragment,u),n=!1},d(u){u&&A(t),Y(e,u),Y(r,u)}}}function is(i){let e,t;return e=new Wr({props:{visible:i[4],variant:i[0]===null&&i[5]==="upload"?"dashed":"solid",border_mode:i[23]?"focus":"base",padding:!1,elem_id:i[2],elem_classes:i[3],height:i[11]||(i[5]==="webcam"?void 0:xi),width:i[12],allow_overflow:!1,container:i[19],scale:i[20],min_width:i[21],$$slots:{default:[ts]},$$scope:{ctx:i}}}),{c(){W(e.$$.fragment)},m(r,a){X(e,r,a),t=!0},p(r,a){const n={};a[0]&16&&(n.visible=r[4]),a[0]&33&&(n.variant=r[0]===null&&r[5]==="upload"?"dashed":"solid"),a[0]&8388608&&(n.border_mode=r[23]?"focus":"base"),a[0]&4&&(n.elem_id=r[2]),a[0]&8&&(n.elem_classes=r[3]),a[0]&2080&&(n.height=r[11]||(r[5]==="webcam"?void 0:xi)),a[0]&4096&&(n.width=r[12]),a[0]&524288&&(n.container=r[19]),a[0]&1048576&&(n.scale=r[20]),a[0]&2097152&&(n.min_width=r[21]),a[0]&13101027|a[1]&4&&(n.$$scope={dirty:a,ctx:r}),e.$set(n)},i(r){t||(y(e.$$.fragment,r),t=!0)},o(r){D(e.$$.fragment,r),t=!1},d(r){Y(e,r)}}}const xi=240;function rs(i,e,t){let{elem_id:r=""}=e,{elem_classes:a=[]}=e,{visible:n=!0}=e,{value:s=null}=e,{source:l="upload"}=e,{tool:o="editor"}=e,{label:h}=e,{show_label:u}=e,{streaming:f}=e,{pending:c}=e,{height:d}=e,{width:p}=e,{mirror_webcam:v}=e,{shape:O}=e,{brush_radius:z}=e,{brush_color:T}=e,{mask_opacity:E}=e,{selectable:V=!1}=e,{container:R=!0}=e,{scale:_=null}=e,{min_width:I=void 0}=e,{loading_status:H}=e,{gradio:M}=e,w;function ie(k){s=k,t(0,s)}const j=()=>M.dispatch("edit"),he=()=>M.dispatch("clear"),ne=()=>M.dispatch("stream"),K=({detail:k})=>t(23,w=k),ue=()=>M.dispatch("upload"),q=({detail:k})=>M.dispatch("select",k),ae=({detail:k})=>M.dispatch("share",k),we=({detail:k})=>{t(1,H=H||{}),t(1,H.status="error",H),M.dispatch("error",k)};return i.$$set=k=>{"elem_id"in k&&t(2,r=k.elem_id),"elem_classes"in k&&t(3,a=k.elem_classes),"visible"in k&&t(4,n=k.visible),"value"in k&&t(0,s=k.value),"source"in k&&t(5,l=k.source),"tool"in k&&t(6,o=k.tool),"label"in k&&t(7,h=k.label),"show_label"in k&&t(8,u=k.show_label),"streaming"in k&&t(9,f=k.streaming),"pending"in k&&t(10,c=k.pending),"height"in k&&t(11,d=k.height),"width"in k&&t(12,p=k.width),"mirror_webcam"in k&&t(13,v=k.mirror_webcam),"shape"in k&&t(14,O=k.shape),"brush_radius"in k&&t(15,z=k.brush_radius),"brush_color"in k&&t(16,T=k.brush_color),"mask_opacity"in k&&t(17,E=k.mask_opacity),"selectable"in k&&t(18,V=k.selectable),"container"in k&&t(19,R=k.container),"scale"in k&&t(20,_=k.scale),"min_width"in k&&t(21,I=k.min_width),"loading_status"in k&&t(1,H=k.loading_status),"gradio"in k&&t(22,M=k.gradio)},i.$$.update=()=>{i.$$.dirty[0]&1&&t(0,s=s||null),i.$$.dirty[0]&4194305&&M.dispatch("change")},[s,H,r,a,n,l,o,h,u,f,c,d,p,v,O,z,T,E,V,R,_,I,M,w,ie,j,he,ne,K,ue,q,ae,we]}class ns extends be{constructor(e){super(),ve(this,e,rs,is,ce,{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,brush_color:16,mask_opacity:17,selectable:18,container:19,scale:20,min_width:21,loading_status:1,gradio:22},null,[-1,-1])}get elem_id(){return this.$$.ctx[2]}set elem_id(e){this.$$set({elem_id:e}),Q()}get elem_classes(){return this.$$.ctx[3]}set elem_classes(e){this.$$set({elem_classes:e}),Q()}get visible(){return this.$$.ctx[4]}set visible(e){this.$$set({visible:e}),Q()}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),Q()}get source(){return this.$$.ctx[5]}set source(e){this.$$set({source:e}),Q()}get tool(){return this.$$.ctx[6]}set tool(e){this.$$set({tool:e}),Q()}get label(){return this.$$.ctx[7]}set label(e){this.$$set({label:e}),Q()}get show_label(){return this.$$.ctx[8]}set show_label(e){this.$$set({show_label:e}),Q()}get streaming(){return this.$$.ctx[9]}set streaming(e){this.$$set({streaming:e}),Q()}get pending(){return this.$$.ctx[10]}set pending(e){this.$$set({pending:e}),Q()}get height(){return this.$$.ctx[11]}set height(e){this.$$set({height:e}),Q()}get width(){return this.$$.ctx[12]}set width(e){this.$$set({width:e}),Q()}get mirror_webcam(){return this.$$.ctx[13]}set mirror_webcam(e){this.$$set({mirror_webcam:e}),Q()}get shape(){return this.$$.ctx[14]}set shape(e){this.$$set({shape:e}),Q()}get brush_radius(){return this.$$.ctx[15]}set brush_radius(e){this.$$set({brush_radius:e}),Q()}get brush_color(){return this.$$.ctx[16]}set brush_color(e){this.$$set({brush_color:e}),Q()}get mask_opacity(){return this.$$.ctx[17]}set mask_opacity(e){this.$$set({mask_opacity:e}),Q()}get selectable(){return this.$$.ctx[18]}set selectable(e){this.$$set({selectable:e}),Q()}get container(){return this.$$.ctx[19]}set container(e){this.$$set({container:e}),Q()}get scale(){return this.$$.ctx[20]}set scale(e){this.$$set({scale:e}),Q()}get min_width(){return this.$$.ctx[21]}set min_width(e){this.$$set({min_width:e}),Q()}get loading_status(){return this.$$.ctx[1]}set loading_status(e){this.$$set({loading_status:e}),Q()}get gradio(){return this.$$.ctx[22]}set gradio(e){this.$$set({gradio:e}),Q()}}const _s=ns;export{_s as I,mn as W};
//# sourceMappingURL=InteractiveImage-aec85637.js.map