diff --git a/lama_cleaner/app/build/asset-manifest.json b/lama_cleaner/app/build/asset-manifest.json
index 164e03d..aecf22a 100644
--- a/lama_cleaner/app/build/asset-manifest.json
+++ b/lama_cleaner/app/build/asset-manifest.json
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.77e9be72.chunk.css",
- "main.js": "/static/js/main.02edcea0.chunk.js",
+ "main.js": "/static/js/main.924b1592.chunk.js",
"runtime-main.js": "/static/js/runtime-main.5e86ac81.js",
"static/js/2.17f9840f.chunk.js": "/static/js/2.17f9840f.chunk.js",
"index.html": "/index.html",
@@ -12,6 +12,6 @@
"static/js/runtime-main.5e86ac81.js",
"static/js/2.17f9840f.chunk.js",
"static/css/main.77e9be72.chunk.css",
- "static/js/main.02edcea0.chunk.js"
+ "static/js/main.924b1592.chunk.js"
]
}
\ No newline at end of file
diff --git a/lama_cleaner/app/build/index.html b/lama_cleaner/app/build/index.html
index 365d8ef..929730b 100644
--- a/lama_cleaner/app/build/index.html
+++ b/lama_cleaner/app/build/index.html
@@ -1 +1 @@
-
lama-cleaner - Image inpainting powered by SOTA AI model
\ No newline at end of file
+lama-cleaner - Image inpainting powered by SOTA AI model
\ No newline at end of file
diff --git a/lama_cleaner/app/build/static/js/main.02edcea0.chunk.js b/lama_cleaner/app/build/static/js/main.924b1592.chunk.js
similarity index 80%
rename from lama_cleaner/app/build/static/js/main.02edcea0.chunk.js
rename to lama_cleaner/app/build/static/js/main.924b1592.chunk.js
index 92afbcd..ce9a471 100644
--- a/lama_cleaner/app/build/static/js/main.02edcea0.chunk.js
+++ b/lama_cleaner/app/build/static/js/main.924b1592.chunk.js
@@ -1 +1 @@
-(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{65:function(e,t,n){},72:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),c=n(12),i=n.n(c),o=(n(65),n(6)),s=n(3),l=n(56),u=n(9),d=n.n(u),b=n(13);var j=n(16),h=n(1),f=Object(o.b)({key:"themeState",default:"dark"}),p=function(){var e=Object(o.d)(f),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)("div",{className:"theme-toggle-ui",children:Object(h.jsx)("div",{className:"theme-btn",onClick:function(){a("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(h.jsx)(j.h,{}):Object(h.jsx)(j.i,{style:{color:"#ffcc00"}})})})},O=n(2),g=n(8),v=n(51),m=n(81),x=n(54),w=n(82),y=n(7);function S(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],r=0;rt){var r=Math.ceil(t*a);return"".concat(e,"x").concat(r)}var c=Math.ceil(n*a);return"".concat(c,"x").concat(e)}),[n,t,u]),b=Object(a.useCallback)((function(){for(var e=[],t=0;tt?(l(a[0]),r(parseInt(a[0],10))):(l(a[1]),r(parseInt(a[1],10)))},chevronDirection:"up"})}var _=n(52),G=n.n(_),K=n(77),J=n(4),$=["onFocus","onBlur"],Q=r.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,r=Object(J.a)(e,$),c=Object(o.d)(he),i=Object(s.a)(c,2),l=(i[0],i[1]);return Object(h.jsx)("input",Object(O.a)(Object(O.a)({},r),{},{ref:t,type:"text",onFocus:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onPaste:function(e){return e.stopPropagation()},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur(),(e.ctrlKey||e.metaKey)&&"z"===e.key&&e.stopPropagation()}}))})),q=["value","allowFloat","onValue"],ee=r.a.forwardRef((function(e,t){var n=e.value,r=e.allowFloat,c=e.onValue,i=Object(J.a)(e,q),o=Object(a.useState)(n),l=Object(s.a)(o,2),u=l[0],d=l[1];Object(a.useEffect)((function(){d(n)}),[n]);return Object(h.jsx)(Q,Object(O.a)(Object(O.a)({value:u,onInput:function(e){var t=e.target.value;r?(t=t.replace(/[^0-9.]/g,"").replace(/(\..*?)\..*/g,"$1"),null===c||void 0===c||c(t)):(t=t.replace(/\D/g,""),null===c||void 0===c||c(t)),d(t)},className:"number-input"},i),{},{ref:t}))}));ee.defaultProps={allowFloat:!1};var te=ee,ne=n(29),ae=function(e){var t=e.content,n=e.children;return Object(h.jsx)(ne.d,{children:Object(h.jsxs)(ne.c,{children:[Object(h.jsx)(ne.e,{className:"tooltip-trigger",children:n}),Object(h.jsxs)(ne.b,{className:"tooltip-content",children:[t,Object(h.jsx)(ne.a,{className:"tooltip-arrow"})]})]})})};var re=function(e){var t=e.title,n=e.titleSuffix,a=e.desc,r=e.input,c=e.optionDesc,i=e.className;return Object(h.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(h.jsxs)("div",{className:"setting-block-content",children:[Object(h.jsx)("div",{className:"setting-block-content-title",children:Object(h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a?Object(h.jsx)(ae,{content:Object(h.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(h.jsx)("span",{children:t})}):Object(h.jsx)("span",{children:t}),n]})}),r]}),c&&Object(h.jsx)("div",{className:"option-desc",children:c})]})};function ce(e){var t=e.title,n=e.allowFloat,r=e.desc,c=e.value,i=e.suffix,o=e.onValue,s=e.width,l=e.widthUnit,u=e.disable,d=Object(a.useRef)(null);return Object(K.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(h.jsx)(re,{className:"sub-setting-block",title:t,desc:r,input:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(h.jsx)(te,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:c,disabled:u,onValue:o,ref:d}),i&&Object(h.jsx)("span",{children:i})]})})}ce.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var ie,oe,se=ce;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(ie||(ie={})),function(e){e.ddim="ddim",e.plms="plms"}(oe||(oe={}));var le,ue,de=function(){var e=Object(o.d)(Ee),t=Object(s.a)(e,2),n=t[0],a=t[1];if(!(null===n||void 0===n?void 0:n.enabled))return Object(h.jsx)(h.Fragment,{});var r=function(e){a({hdStrategy:e})},c=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyResizeLimit:t})},i=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropTrigerSize:t})},l=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropMargin:t})},u=function(){return Object(h.jsxs)("div",{children:["Use original picture, suitable for picture size below 2K. Try"," ",Object(h.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(ie.RESIZE)},children:"Resize"})," or ",Object(h.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(ie.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(h.jsx)(re,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(h.jsx)(U,{width:80,value:n.hdStrategy,options:Object.values(ie),onChange:function(e){return r(e)}}),optionDesc:function(){switch(n.hdStrategy){case ie.ORIGINAL:return u();case ie.CROP:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)("div",{children:"Crop masking area from the original image to do inpainting."}),Object(h.jsx)(se,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:i}),Object(h.jsx)(se,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:l})]});case ie.RESIZE:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)("div",{children:"Resize the longer side of the image to a specific size, then do inpainting on the resized image."}),Object(h.jsx)(se,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:c})]});default:return u()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm",e.ZITS="zits",e.MAT="mat",e.FCF="fcf",e.SD15="sd1.5",e.CV2="cv2"}(ue||(ue={}));var be,je=Object(o.b)({key:"fileState",default:void 0}),he=Object(o.b)({key:"appState",default:{disableShortCuts:!1,isInpainting:!1}}),fe=Object(o.b)({key:"promptState",default:""}),pe=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(he).isInpainting},set:function(e,t){var n=e.get,a=e.set,r=n(he);a(he,Object(O.a)(Object(O.a)({},r),{},{isInpainting:t}))}}),Oe=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),ge=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(Oe).x},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{x:t}))}}),ve=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(Oe).y},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{y:t}))}}),me=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(Oe).height},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{height:t}))}}),xe=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(Oe).width},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{width:t}))}}),we=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),ye=Object(o.b)({key:"shortcutsState",default:!1});!function(e){e.INPAINT_NS="INPAINT_NS",e.INPAINT_TELEA="INPAINT_TELEA"}(be||(be={}));var Se,ke,Ce=(le={},Object(y.a)(le,ue.LAMA,{hdStrategy:ie.CROP,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:1280,hdStrategyCropMargin:196,enabled:!0}),Object(y.a)(le,ue.LDM,{hdStrategy:ie.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.ZITS,{hdStrategy:ie.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.MAT,{hdStrategy:ie.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.FCF,{hdStrategy:ie.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(y.a)(le,ue.SD15,{hdStrategy:ie.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.CV2,{hdStrategy:ie.RESIZE,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),le);!function(e){e.ddim="ddim",e.pndm="pndm",e.klms="k_lms"}(Se||(Se={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(ke||(ke={}));var Le,Me={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:ue.LAMA,hdSettings:Ce,ldmSteps:25,ldmSampler:oe.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:ke.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:Se.pndm,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1,cv2Radius:5,cv2Flag:be.INPAINT_NS},Ne="settingsState4",Ie=Object(o.b)({key:Ne,default:Me,effects:[(Le=Ne,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(Le);if(null!=a){var r=JSON.parse(a);r.show=!1,t(G.a.merge(G.a.cloneDeep(Me),r))}n((function(e,t,n){return n?localStorage.removeItem(Le):localStorage.setItem(Le,JSON.stringify(e))}))})]}),ze=Object(o.c)({key:"seed",get:function(e){return(0,e.get)(Ie).sdSeed},set:function(e,t){var n=e.get,a=e.set,r=n(Ie);a(Ie,Object(O.a)(Object(O.a)({},r),{},{sdSeed:t}))}}),Ee=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(Ie);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,r=n(Ie),c=r.hdSettings[r.model],i=Object(O.a)(Object(O.a)({},c),t);a(Ie,Object(O.a)(Object(O.a)({},r),{},{hdSettings:Object(O.a)(Object(O.a)({},r.hdSettings),{},Object(y.a)({},r.model,i))}))}}),De=Object(o.c)({key:"isSD",get:function(e){return(0,e.get)(Ie).model===ue.SD15}}),Te=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(Ie),a=t(De);return n.runInpaintingManually||a}}),Re=n(57),Fe=function(e,t,n,a){var r=Object(o.e)(he);return Object(Re.a)(e,t,Object(O.a)(Object(O.a)({},n),{},{enabled:!r.disableShortCuts}),a)},Pe={capture:!0,passive:!1},He=function(e){var t=e.minHeight,n=e.minWidth,r=e.maxHeight,c=e.maxWidth,i=e.scale,l=Object(o.d)(ge),u=Object(s.a)(l,2),d=u[0],b=u[1],j=Object(o.d)(ve),f=Object(s.a)(j,2),p=f[0],O=f[1],g=Object(o.d)(me),v=Object(s.a)(g,2),m=v[0],x=v[1],w=Object(o.d)(xe),y=Object(s.a)(w,2),S=y[0],k=y[1],C=Object(o.e)(pe),L=Object(a.useState)(!1),M=Object(s.a)(L,2),N=M[0],I=M[1],z=Object(a.useState)(!1),E=Object(s.a)(z,2),D=E[0],T=E[1];Object(a.useEffect)((function(){b(Math.round((c-512)/2)),O(Math.round((r-512)/2))}),[r,c,t,n]);var R=Object(a.useState)({initX:0,initY:0,initHeight:0,initWidth:0,startResizeX:0,startResizeY:0,ord:"top"}),F=Object(s.a)(R,2),P=F[0],H=F[1],A=function(){console.log("focus")},Z=function(e,n){return e>0&&n>t&&e+n<=r},V=function(e,t){return e>0&&t>n&&e+t<=c},W=function(e){if(!C){var t=e.clientX,n=e.clientY,a=Math.round((n-P.startResizeY)/i),r=Math.round((t-P.startResizeX)/i),c=function(){var e=P.initHeight-a,t=P.initY+a;Z(t,e)&&(x(e),O(t))},o=function(){var e=P.initHeight+a;Z(P.initY,e)&&x(e)},s=function(){var e=P.initWidth-r,t=P.initX+r;V(t,e)&&(k(e),b(t))},l=function(){var e=P.initWidth+r;V(P.initX,e)&&k(e)};if(N)switch(P.ord){case"topleft":c(),s();break;case"topright":c(),l();break;case"bottomleft":o(),s();break;case"bottomright":o(),l();break;case"top":c();break;case"right":l();break;case"bottom":o();break;case"left":s()}if(D){var u=P.initX+r,d=P.initY+a;V(u,P.initWidth)&&Z(d,P.initHeight)&&(b(u),O(d))}}},B=function(e){N&&I(!1),D&&T(!1)};Object(a.useEffect)((function(){if(N||D)return document.addEventListener("pointermove",W,Pe),document.addEventListener("pointerup",B,Pe),document.addEventListener("pointercancel",B,Pe),function(){document.removeEventListener("pointermove",W,Pe),document.removeEventListener("pointerup",B,Pe),document.removeEventListener("pointercancel",B,Pe)}}),[N,D,S,m,P]);var U=function(e){var t=e.target.dataset.ord;t&&(I(!0),H({initX:d,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},Y=function(e){T(!0),H({initX:d,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(h.jsx)("div",{className:"croper-wrapper",children:Object(h.jsxs)("div",{className:"croper",style:{height:m,width:S,left:d,top:p},children:[Object(h.jsx)("div",{className:"crop-border",style:{height:m,width:S,outlineWidth:"".concat(2/i,"px")}}),Object(h.jsx)("div",{className:"info-bar",onPointerDown:Y,style:{transform:"scale(".concat(1/i,")"),top:"".concat(10/i,"px"),left:"".concat(10/i,"px")},children:Object(h.jsxs)("div",{className:"crop-size",children:[S," x ",m]})}),Object(h.jsxs)("div",{className:"drag-elements",onFocus:A,onPointerDown:U,children:[Object(h.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}})]})]})})},Ae=n(55),Ze="prompt",Ve=Object(Ae.a)(),We=function(){var e=Object(a.useState)(window.innerWidth),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){r(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",c),function(){window.removeEventListener("resize",c)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function Be(e){var t=e.onSelection,n=Object(a.useState)(!1),r=Object(s.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(o,1)[0],u=We();function j(e){if(e&&e.type.match("image.*"))try{if(e.size>20971520)throw new Error("file too large");t(e)}catch(n){alert("error: ".concat(n.message))}}function f(e){return p.apply(this,arguments)}function p(){return(p=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){t.file((function(t){return e(t)}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e){return v.apply(this,arguments)}function v(){return(v=Object(b.a)(d.a.mark((function e(t){var n,a,r,c,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],r=0;r0)){e.next=23;break}if(!(null===(c=a.shift())||void 0===c?void 0:c.isFile)){e.next=12;break}return e.next=8,f(c);case 8:i=e.sent,n.push(i),e.next=21;break;case 12:if(!(null===c||void 0===c?void 0:c.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=g.a,e.next=18,m(c.createReader());case 18:e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.t0.apply.call(e.t0,e.t1,e.t4);case 21:e.next=3;break;case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return x.apply(this,arguments)}function x(){return(x=Object(b.a)(d.a.mark((function e(t){var n,a;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,w(t);case 3:a=e.sent;case 4:if(!(a.length>0)){e.next=11;break}return n.push.apply(n,Object(g.a)(a)),e.next=8,w(t);case 8:a=e.sent,e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e){return y.apply(this,arguments)}function y(){return(y=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){t.readEntries(e,n)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(){return(S=Object(b.a)(d.a.mark((function e(t){var n;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.next=3,O(t.dataTransfer.items);case 3:n=e.sent,i(!1),j(n[0]);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return Object(h.jsx)("label",{htmlFor:l,className:"file-select-label",children:Object(h.jsxs)("div",{className:["file-select-container",c?"file-select-label-hover":""].join(" "),onDrop:function(e){return S.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),i(!0)},onDragLeave:function(){return i(!1)},children:[Object(h.jsx)("input",{id:l,name:l,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&j(n)},accept:"image/png, image/jpeg"}),Object(h.jsx)("p",{className:"file-select-message",children:"desktop"===u?"Click here or drag an image file":"Tap here to load your picture"})]})})}var Ue="#ffcc00bb";function Ye(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ue;e.strokeStyle=n,e.lineCap="round",e.lineJoin="round",t.forEach((function(t){(null===t||void 0===t?void 0:t.pts.length)&&t.size&&(e.lineWidth=t.size,e.beginPath(),e.moveTo(t.pts[0].x,t.pts[0].y),t.pts.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}))}function Xe(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function _e(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(o.e)(fe),i=Object(o.e)(Ie),l=Object(o.d)(ze),u=Object(s.a)(l,2),f=(u[0],u[1]),p=Object(o.e)(Oe),O=Object(o.d)(we),y=Object(s.a)(O,2),S=(y[0],y[1]),N=Object(o.d)(pe),I=Object(s.a)(N,2),z=I[0],D=I[1],T=Object(o.e)(Te),F=Object(o.e)(De),P=Object(a.useState)(40),H=Object(s.a)(P,2),A=H[0],W=H[1],B=function(e){var t=Object(a.useState)(new Image),n=Object(s.a)(t,1)[0],r=Object(a.useState)(!1),c=Object(s.a)(r,2),i=c[0],o=c[1];return Object(a.useEffect)((function(){if(void 0!==e)return n.onload=function(){o(!0)},o(!1),n.src=URL.createObjectURL(e),function(){n.onload=null}}),[e,n]),[n,i]}(n),U=Object(s.a)(B,2),Y=U[0],_=U[1],G=Object(a.useState)([]),K=Object(s.a)(G,2),J=K[0],$=K[1],Q=Object(a.useState)(),q=Object(s.a)(Q,2),ee=q[0],te=q[1],ne=Object(a.useState)((function(){return document.createElement("canvas")})),ae=Object(s.a)(ne,1)[0],re=Object(a.useState)([]),ce=Object(s.a)(re,2),ie=ce[0],oe=ce[1],se=Object(a.useState)([]),le=Object(s.a)(se,2),ue=le[0],de=le[1],be=Object(a.useState)([]),he=Object(s.a)(be,2),ge=he[0],ve=he[1],me=Object(a.useState)({x:-1,y:-1}),xe=Object(s.a)(me,2),ye=xe[0],Se=ye.x,ke=ye.y,Ce=xe[1],Le=Object(a.useState)(!1),Me=Object(s.a)(Le,2),Ne=Me[0],Ee=Me[1],Re=Object(a.useState)(!1),Pe=Object(s.a)(Re,2),Ae=Pe[0],We=Pe[1],Ue=Object(a.useState)(!1),_e=Object(s.a)(Ue,2),Ge=_e[0],Ke=_e[1],Je=Object(a.useState)(!1),$e=Object(s.a)(Je,2),Qe=$e[0],qe=$e[1],et=Object(a.useState)({x:-1,y:-1,brushSize:20}),tt=Object(s.a)(et,2),nt=tt[0],at=tt[1],rt=Object(a.useState)(!1),ct=Object(s.a)(rt,2),it=ct[0],ot=ct[1],st=Object(a.useState)(1),lt=Object(s.a)(st,2),ut=lt[0],dt=lt[1],bt=Object(a.useState)(!1),jt=Object(s.a)(bt,2),ht=jt[0],ft=jt[1],pt=Object(a.useState)(1),Ot=Object(s.a)(pt,2),gt=Ot[0],vt=Ot[1],mt=Object(a.useState)(1080),xt=Object(s.a)(mt,2),wt=xt[0],yt=xt[1],St=Object(m.a)(),kt=St.width/2,Ct=St.height/2,Lt=Object(a.useRef)(),Mt=Object(a.useState)(!1),Nt=Object(s.a)(Mt,2),It=Nt[0],zt=Nt[1],Et=Object(a.useState)(!1),Dt=Object(s.a)(Et,2),Tt=Dt[0],Rt=Dt[1],Ft=Object(a.useState)(!1),Pt=Object(s.a)(Ft,2),Ht=Pt[0],At=Pt[1],Zt=Object(a.useState)(0),Vt=Object(s.a)(Zt,2),Wt=Vt[0],Bt=Vt[1],Ut=Object(a.useState)([]),Yt=Object(s.a)(Ut,2),Xt=Yt[0],_t=Yt[1],Gt=Object(a.useState)([]),Kt=Object(s.a)(Gt,2),Jt=Kt[0],$t=Kt[1],Qt=Object(a.useState)([]),qt=Object(s.a)(Qt,2),en=qt[0],tn=qt[1],nn=Object(a.useCallback)((function(e,t){ee&&(ee.clearRect(0,0,ee.canvas.width,ee.canvas.height),ee.drawImage(e,0,0,Y.naturalWidth,Y.naturalHeight),Ye(ee,t))}),[ee,Y]),an=Object(a.useCallback)((function(e){if(!(null===ee||void 0===ee?void 0:ee.canvas.width)||!(null===ee||void 0===ee?void 0:ee.canvas.height))throw new Error("canvas has invalid size");ae.width=null===ee||void 0===ee?void 0:ee.canvas.width,ae.height=null===ee||void 0===ee?void 0:ee.canvas.height;var t=ae.getContext("2d");if(!t)throw new Error("could not retrieve mask canvas");e.forEach((function(e){Ye(t,e,"white")}))}),[ee,ae]),rn=Object(a.useCallback)((function(){return 0!==ge.length}),[ge]),cn=Object(a.useCallback)((function(e){0===J.length?nn(Y,e):nn(J[J.length-1],e)}),[Y,J,nn]),on=Object(a.useCallback)(function(){var e=Object(b.a)(d.a.mark((function e(t,a){var r,c,o,s,l,u,b,j,h,O,v,m,x;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==n){e.next=2;break}return e.abrupt("return");case 2:if(console.log("runInpainting"),r=[],!0!==a){e.next=10;break}if(0!==ue.length){e.next=7;break}return e.abrupt("return");case 7:r=ue,e.next=14;break;case 10:if(rn()){e.next=12;break}return e.abrupt("return");case 12:de(ge),r=ge;case 14:if(c=[].concat(Object(g.a)(ie),[r]),ve([]),Rt(!1),D(!0),i.graduallyInpainting?an([r]):an(c),o=n,!0!==i.graduallyInpainting){e.next=35;break}if(!0!==a){e.next=29;break}if(!(J.length>1)){e.next=27;break}return s=J[J.length-2],e.next=26,L(s.currentSrc,n.name,n.type);case 26:o=e.sent;case 27:e.next=35;break;case 29:if(!(J.length>0)){e.next=35;break}return console.info("gradually inpainting on last result"),l=J[J.length-1],e.next=34,L(l.currentSrc,n.name,n.type);case 34:o=e.sent;case 35:return u=i.sdSeedFixed?i.sdSeed:-1,e.prev=36,e.next=39,R(o,ae.toDataURL(),i,p,t,wt.toString(),u);case 39:if(b=e.sent){e.next=42;break}throw new Error("empty response");case 42:return j=b.blob,h=b.seed,console.log(h),console.log(i.sdSeedFixed),h&&!i.sdSeedFixed&&f(parseInt(h,10)),O=new Image,e.next=49,k(O,j);case 49:!0===a?(v=J.slice(0,-1),m=[].concat(Object(g.a)(v),[O]),$(m)):(x=[].concat(Object(g.a)(J),[O]),$(x)),nn(O,[]),oe(c),dn(),e.next=59;break;case 55:e.prev=55,e.t0=e.catch(36),S({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),cn([]);case 59:D(!1);case 60:case"end":return e.stop()}}),e,null,[[36,55]])})));return function(t,n){return e.apply(this,arguments)}}(),[ie,ge,ae,i.graduallyInpainting,i,p,wt,c,cn,rn,an]);Object(a.useEffect)((function(){return Ve.on(Ze,(function(){rn()?on(c):0!==ue.length?on(c,!0):S({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){Ve.off(Ze)}}),[rn,on,prompt]);var sn=function(){return 0!==J.length},ln=function(e){return"Control"===e.key||"Meta"===e.key};Object(x.a)(ln,(function(){Ht&&(z||(At(!1),T||on()))}),{event:"keyup"},[z,Ht,rn]),Object(x.a)(ln,(function(){z||At(!0)}),{event:"keydown"},[z]),Object(a.useEffect)((function(){if(_){var e=St.width/Y.naturalWidth,t=(St.height-200)/Y.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),vt(n),dt(n),(null===ee||void 0===ee?void 0:ee.canvas)&&(ee.canvas.width=Y.naturalWidth,ee.canvas.height=Y.naturalHeight,cn([])),!It){var a;null===(a=Lt.current)||void 0===a||a.centerView(n,1),zt(!0);var r=Math.max(Y.width,Y.height);yt(r)}}}),[null===ee||void 0===ee?void 0:ee.canvas,Lt,Y,_,St,It,cn]);var un=Object(a.useCallback)((function(){if(gt&&Y&&St){var e=Lt.current;if(e){var t=(St.width-Y.width*gt)/2,n=(St.height-Y.height*gt)/2;e.setTransform(t,n,gt,200,"easeOutQuad"),e.state.scale=gt,dt(gt),ft(!1)}}}),[Lt,St,Y,Y.width,St.height,gt]),dn=function(){$t([]),tn([]),_t([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){un()})),function(){window.removeEventListener("resize",(function(){un()}))}}),[St,un]),Object(a.useEffect)((function(){return window.addEventListener("blur",(function(){qe(!1)})),function(){window.removeEventListener("blur",(function(){qe(!1)}))}}),[]);Object(x.a)("Escape",(function(){z||(Tt||Ht?(Rt(!1),ve([]),cn([])):un())}),{event:"keydown"},[Tt,z,Ht,un,cn]);var bn=function(e){if(Qe){var t=nt.x,n=nt.brushSize+(Se-t);n<=200&&n>=10&&W(n)}else if(!Ge&&Tt&&0!==ge.length){var a=Object(g.a)(ge);a[a.length-1].pts.push(Xe(e)),ve(a),cn(a)}},jn=function(e){if(!Qe&&(!Ge&&Y.src&&(null===ee||void 0===ee?void 0:ee.canvas)&&!z&&!function(e){return 2===e.nativeEvent.button}(e)))if(C(e))Ke(!0);else if(!(F&&i.showCroper&&(t=Xe(e),t.xp.x+p.width||t.y>p.y+p.height))){var t;Rt(!0);var n=[];(Ht||T)&&(n=Object(g.a)(ge)),n.push({size:A,pts:[Xe(e)]}),ve(n),cn(n)}},hn=Object(a.useCallback)((function(){if(0!==ge.length){de([]);var e=ge.pop(),t=[].concat(Object(g.a)(Jt),[e]);$t(t);var n=Object(g.a)(ge);ve(n),cn(n)}}),[ge,Jt,cn]),fn=Object(a.useCallback)((function(){if(J.length){var e=ie.pop();tn([].concat(Object(g.a)(en),[e])),$t([]),oe(Object(g.a)(ie)),ve([]),Rt(!1);var t=J.pop();_t([].concat(Object(g.a)(Xt),[t]));var n=Object(g.a)(J);$(n),0===n.length?nn(Y,[]):nn(n[n.length-1],[])}}),[nn,J,Xt,en,ie,Y]),pn=function(){T&&0!==ge.length?hn():fn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"z"===e.key;return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("undo"),!0)}),pn,void 0,[hn,fn,F]);var On=Object(a.useCallback)((function(){if(0!==Jt.length){var e=Jt.pop();$t(Object(g.a)(Jt));var t=[].concat(Object(g.a)(ge),[e]);ve(t),cn(t)}}),[ge,Jt,cn]),gn=Object(a.useCallback)((function(){if(0!==Xt.length){var e=en.pop();tn(Object(g.a)(en)),oe([].concat(Object(g.a)(ie),[e])),ve([]),Rt(!1);var t=Xt.pop(),n=[].concat(Object(g.a)(J),[t]);$(n),nn(n[n.length-1],[])}}),[nn,J,Xt,en,ie,Y]),vn=function(){T&&0!==Jt.length?On():gn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&e.shiftKey&&"z"===e.key.toLowerCase();return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("redo"),!0)}),vn,void 0,[On,gn,F]);Object(w.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),sn()&&ot((function(){return window.setTimeout((function(){Bt(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),sn()&&(Bt(0),window.setTimeout((function(){ot(!1)}),350))}));var mn=function(e){e===Ne||Ge||Ee(e)},xn=Object(a.useCallback)((function(){return Ge?"grab":Ne?"none":void 0}),[Ne,Ge]);Fe("[",(function(){W((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),Fe("]",(function(){W((function(e){return e+10}))})),Fe("shift+r",(function(){T&&rn()&&on()}),{},[T,on,rn]),Fe("ctrl+c, cmd+c",Object(b.a)(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,M();case 2:if(!(e.sent&&J.length>0)){e.next=8;break}if(!(null===ee||void 0===ee?void 0:ee.canvas)){e.next=8;break}return e.next=7,E(null===ee||void 0===ee?void 0:ee.canvas);case 7:S({open:!0,desc:"Copy inpainting result to clipboard",state:"success",duration:3e3});case 8:case"end":return e.stop()}}),e)}))),{},[J,ee]),Object(w.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Ee(!1),Ke(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Ee(!0),Ke(!1)})),Object(w.a)("Alt",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),qe(!0),at({x:Se,y:ke,brushSize:A})}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),qe(!1)}));var wn=function(e,t){var n=function(){var e,t,n=gt;return void 0!==(null===(e=Lt.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=Lt.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(A*n,"px"),height:"".concat(A*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(h.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;Ce({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(C(e)&&Ke(!1),Ge)||Y.src&&(null===ee||void 0===ee?void 0:ee.canvas)&&(z||Tt&&(Ht||T?Rt(!1):on()))},children:[void 0===n?Object(h.jsx)("div",{className:"landing-file-selector",children:Object(h.jsx)(Be,{onSelection:function(){var e=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r(t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})}):Object(h.jsx)(v.b,{ref:function(e){e&&(Lt.current=e)},panning:{disabled:!Ge,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:gt,minScale:.6*gt,onPanning:function(e){ht||ft(!0)},onZoom:function(e){dt(e.state.scale)},children:Object(h.jsxs)(v.a,{contentClass:z?"editor-canvas-loading":"",contentStyle:{visibility:It?"visible":"hidden"},children:[Object(h.jsxs)("div",{className:"editor-canvas-container",children:[Object(h.jsx)("canvas",{className:"editor-canvas",style:{cursor:xn(),clipPath:"inset(0 ".concat(Wt,"% 0 0)"),transition:"clip-path 300ms cubic-bezier(0.4, 0, 0.2, 1)"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){mn(!0),We(!1)},onFocus:function(){return mn(!0)},onMouseLeave:function(){return mn(!1)},onMouseDown:jn,onMouseMove:bn,ref:function(e){if(e&&!ee){var t=e.getContext("2d");t&&te(t)}}}),Object(h.jsxs)("div",{className:"original-image-container",style:{width:"".concat(Y.naturalWidth,"px"),height:"".concat(Y.naturalHeight,"px")},children:[it&&Object(h.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(Wt,"%")}}),Object(h.jsx)("img",{className:"original-image",src:Y.src,alt:"original",style:{width:"".concat(Y.naturalWidth,"px"),height:"".concat(Y.naturalHeight,"px")}})]})]}),i.showCroper?Object(h.jsx)(He,{maxHeight:Y.naturalHeight,maxWidth:Y.naturalWidth,minHeight:Math.min(256,Y.naturalHeight),minWidth:Math.min(256,Y.naturalWidth),scale:ut}):Object(h.jsx)(h.Fragment,{})]})}),Ne&&!z&&!Ge&&Object(h.jsx)("div",{className:"brush-shape",style:wn(Qe?nt.x:Se,Qe?nt.y:ke)}),Ae&&Object(h.jsx)("div",{className:"brush-shape",style:wn(kt,Ct)}),Object(h.jsxs)("div",{className:"editor-toolkit-panel",children:[F||void 0===n?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(X,{onChange:function(e){yt(e)},originalWidth:Y.naturalWidth,originalHeight:Y.naturalHeight}),Object(h.jsx)(V,{label:"Brush",min:10,max:200,value:A,onChange:function(e){W(e),Ae||(We(!0),window.setTimeout((function(){We(!1)}),1e4))},onClick:function(){return We(!1)}}),Object(h.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(h.jsx)(Z,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(h.jsx)(j.a,{}),disabled:ut===gt&&!1===ht,onClick:un}),Object(h.jsx)(Z,{toolTip:"Undo",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:pn,disabled:function(){if(z)return!0;if(J.length>0)return!1;if(T){if(0===ge.length)return!0}else if(0===J.length)return!0;return!1}()}),Object(h.jsx)(Z,{toolTip:"Redo",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:"scale(-1,1)"},children:Object(h.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:vn,disabled:function(){if(z)return!0;if(Xt.length>0)return!1;if(T){if(0===Jt.length)return!0}else if(0===Xt.length)return!0;return!1}()}),Object(h.jsx)(Z,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(h.jsx)(j.g,{}),className:it?"eyeicon-active":"",onDown:function(e){e.preventDefault(),ot((function(){return window.setTimeout((function(){Bt(100)}),10),!0}))},onUp:function(){Bt(0),window.setTimeout((function(){ot(!1)}),300)},disabled:0===J.length}),Object(h.jsx)(Z,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(h.jsx)(j.e,{}),disabled:!J.length,onClick:function(){if(void 0!==n){var e=n.name.replace(/(\.[\w\d_-]+)$/i,"_cleanup$1");if(function(e,t){var n=document.createElement("a");n.href=e,n.download=t,n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),setTimeout((function(){n.remove()}),100)}(J[J.length-1].currentSrc,e),i.downloadMask){var t=n.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");t=t.replace(/\.[^/.]+$/,".jpg"),an(ie);var a=document.createElement("a");a.download=t,a.href=ae.toDataURL("image/jpeg"),a.click()}}}}),i.runInpaintingManually&&Object(h.jsx)(Z,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.jsx)("path",{d:"M2 13L1.34921 12.2407C1.16773 12.3963 1.04797 12.6117 1.01163 12.8479L2 13ZM22.5 4L23.49 4.14142C23.5309 3.85444 23.4454 3.5638 23.2555 3.3448C23.0655 3.1258 22.7899 3 22.5 3V4ZM12.5 4V3C12.2613 3 12.0305 3.08539 11.8492 3.24074L12.5 4ZM1 19.5L0.0116283 19.3479C-0.0327373 19.6363 0.051055 19.9297 0.241035 20.1511C0.431014 20.3726 0.708231 20.5 1 20.5V19.5ZM11.5 19.5V20.5C11.7373 20.5 11.9668 20.4156 12.1476 20.2619L11.5 19.5ZM21.5 11L22.1476 11.7619C22.3337 11.6038 22.4554 11.3831 22.49 11.1414L21.5 11ZM2 14H12.5V12H2V14ZM13.169 13.7433L23.169 4.74329L21.831 3.25671L11.831 12.2567L13.169 13.7433ZM22.5 3H12.5V5H22.5V3ZM11.8492 3.24074L1.34921 12.2407L2.65079 13.7593L13.1508 4.75926L11.8492 3.24074ZM1.01163 12.8479L0.0116283 19.3479L1.98837 19.6521L2.98837 13.1521L1.01163 12.8479ZM1 20.5H11.5V18.5H1V20.5ZM12.4884 19.6521L13.4884 13.1521L11.5116 12.8479L10.5116 19.3479L12.4884 19.6521ZM21.51 3.85858L20.51 10.8586L22.49 11.1414L23.49 4.14142L21.51 3.85858ZM20.8524 10.2381L10.8524 18.7381L12.1476 20.2619L22.1476 11.7619L20.8524 10.2381Z",fill:"currentColor"})}),disabled:!rn()||z,onClick:function(){!z&&rn()&&on()}})]})]})]})}var Ge=n(28),Ke=r.a.forwardRef((function(e,t){var n=e.show,a=e.children,r=e.onClose,c=e.className,i=e.title,l=e.showCloseIcon,u=Object(o.d)(he),d=Object(s.a)(u,2),b=(d[0],d[1]);return Object(h.jsx)(Ge.d,{open:n,onOpenChange:function(e){e||(null===r||void 0===r||r(),b((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})))},children:Object(h.jsxs)(Ge.c,{children:[Object(h.jsx)(Ge.b,{className:"modal-mask"}),Object(h.jsxs)(Ge.a,{ref:t,className:"modal ".concat(c),children:[Object(h.jsxs)("div",{className:"modal-header",children:[Object(h.jsx)(Ge.e,{children:i}),l?Object(h.jsx)(Z,{icon:Object(h.jsx)(j.k,{}),onClick:r}):Object(h.jsx)(h.Fragment,{})]}),a]})]})})}));Ke.defaultProps={showCloseIcon:!0};var Je=Ke;function $e(e){var t=e.content,n=e.keys;return Object(h.jsxs)("div",{className:"shortcut-option",children:[Object(h.jsx)("div",{className:"shortcut-description",children:t}),Object(h.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(h.jsx)("div",{className:"shortcut-key",children:e},e)}))})]})}var Qe=/macintosh|mac os x/i.test(navigator.userAgent),qe=(/windows|win32/i.test(navigator.userAgent),Qe?"Cmd":"Ctrl");function et(){var e=Object(o.d)(ye),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(Je,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(h.jsxs)("div",{className:"shortcut-options",children:[Object(h.jsx)($e,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(qe)]}),Object(h.jsx)($e,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(h.jsx)($e,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(h.jsx)($e,{content:"Undo Inpainting",keys:[qe,"Z"]}),Object(h.jsx)($e,{content:"Redo Inpainting",keys:[qe,"Shift","Z"]}),Object(h.jsx)($e,{content:"View Original Image",keys:["Hold Tab"]}),Object(h.jsx)($e,{content:"Pan",keys:["Space + Drag"]}),Object(h.jsx)($e,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(h.jsx)($e,{content:"Decrease Brush Size",keys:["["]}),Object(h.jsx)($e,{content:"Increase Brush Size",keys:["]"]}),Object(h.jsx)($e,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(h.jsx)($e,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(h.jsx)($e,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var tt=n(53),nt=["className"],at=["className"],rt=r.a.forwardRef((function(e,t){var n=e.className,a=Object(J.a)(e,nt);return Object(h.jsx)(tt.a,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-root ".concat(n),onKeyDown:function(e){return e.preventDefault()}}))})),ct=r.a.forwardRef((function(e,t){var n=e.className,a=Object(J.a)(e,at);return Object(h.jsx)(tt.b,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),it=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(re,{title:"Manual Inpainting Mode",input:Object(h.jsx)(rt,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{runInpaintingManually:e})}))},children:Object(h.jsx)(ct,{})})})};var ot=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1],r=function(e,t,n){return Object(h.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(h.jsx)(ae,{content:n,children:Object(h.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:Object(h.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.jsx)("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})})})},c=function(){return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(se,{title:"Steps",value:"".concat(n.ldmSteps),desc:"Large steps result in better result, but more time-consuming",onValue:function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSteps:t})}))}}),Object(h.jsx)(re,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(U,{width:80,value:n.ldmSampler,options:Object.values(oe),onChange:function(e){return t=e,void a((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(h.jsx)(re,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case ue.LAMA:return r(0,0,"https://github.com/saic-mdal/lama");case ue.LDM:return r(0,0,"https://github.com/CompVis/latent-diffusion");case ue.ZITS:return r(0,0,"https://github.com/DQiaole/ZITS_inpainting");case ue.MAT:return r(0,0,"https://github.com/fenglinglwb/MAT");case ue.FCF:return r(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case ue.SD15:return r(0,0,"https://github.com/CompVis/stable-diffusion");case ue.CV2:return r(0,0,"https://docs.opencv.org/4.6.0/df/d3d/tutorial_py_inpainting.html");default:return Object(h.jsx)(h.Fragment,{})}}(),input:Object(h.jsx)(U,{width:80,value:n.model,options:Object.values(ue),onChange:function(e){return t=e,void a((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}));var t}}),optionDesc:function(){switch(n.model){case ue.LAMA:return;case ue.LDM:return c();case ue.ZITS:return Object(h.jsx)("div",{children:Object(h.jsx)(re,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(h.jsx)(rt,{checked:n.zitsWireframe,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{zitsWireframe:e})}))},children:Object(h.jsx)(ct,{})})})});case ue.MAT:return;case ue.FCF:return Object(h.jsx)("div",{children:"FcF only support fixed size(512x512) image input. Lama Cleaner will take care of resize and crop process, it still recommended applies to small defects."});case ue.SD15:return;case ue.CV2:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(se,{title:"Radius",value:"".concat(n.cv2Radius),desc:"Radius of a circular neighborhood of each point inpainted that is considered by the algorithm.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(O.a)(Object(O.a)({},e),{},{cv2Radius:t})}))}}),Object(h.jsx)(re,{className:"sub-setting-block",title:"Flag",desc:"Inpainting method",input:Object(h.jsx)(U,{width:140,value:n.cv2Flag,options:Object.values(be),onChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{cv2Flag:e})}))}})})]});default:return Object(h.jsx)(h.Fragment,{})}}()})},st=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(re,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(h.jsx)(rt,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{downloadMask:e})}))},children:Object(h.jsx)(ct,{})})})};function lt(e){var t=e.onClose,n=Object(o.d)(Ie),a=Object(s.a)(n,2),r=a[0],c=a[1],i=Object(o.e)(De);return Fe("s",(function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!e.show})}))}),{},[]),Object(h.jsxs)(Je,{onClose:function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:r.show,children:[i?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(it,{}),Object(h.jsx)(st,{}),Object(h.jsx)(ot,{}),i?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(de,{})]})}var ut=n(37),dt=["state","desc"],bt=function(){return Object(h.jsx)("span",{className:"loading-icon",children:Object(h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Object(h.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(h.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(h.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(h.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(h.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(h.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(h.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(h.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})})},jt=a.forwardRef((function(e,t){var n=e.state,a=e.desc,r=Object(J.a)(e,dt);return Object(h.jsxs)(ut.b,{children:[Object(h.jsxs)(ut.c,Object(O.a)(Object(O.a)({},r),{},{ref:t,className:"toast-root ".concat(n),children:[Object(h.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(h.jsx)(j.f,{className:"error-icon"});case"success":return Object(h.jsx)(j.b,{className:"success-icon"});case"loading":return Object(h.jsx)(bt,{});default:return Object(h.jsx)(h.Fragment,{})}}()}),Object(h.jsx)(ut.a,{className:"toast-desc",children:a})]})),Object(h.jsx)(ut.d,{className:"toast-viewpoint"})]})}));jt.defaultProps={desc:"",state:"loading"};var ht=jt,ft=n(36),pt=n(78),Ot=function(){var e=Object(pt.a)(!0),t=Object(s.a)(e,2),n=t[0],a=t[1],r=Object(o.d)(Ie),c=Object(s.a)(r,2),i=c[0],l=c[1];return Object(h.jsx)("div",{className:"side-panel",children:Object(h.jsxs)(ft.c,{open:n,children:[Object(h.jsx)(ft.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Configurations"}),Object(h.jsx)(ft.b,{children:Object(h.jsxs)(ft.a,{className:"side-panel-content",children:[Object(h.jsx)(re,{title:"Croper",input:Object(h.jsx)(rt,{checked:i.showCroper,onCheckedChange:function(e){l((function(t){return Object(O.a)(Object(O.a)({},t),{},{showCroper:e})}))},children:Object(h.jsx)(ct,{})})}),Object(h.jsx)(se,{title:"Steps",width:30,value:"".concat(i.sdSteps),desc:"Large steps result in better result, but more time-consuming",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSteps:t})}))}}),Object(h.jsx)(se,{title:"Strength",width:30,allowFloat:!0,value:"".concat(i.sdStrength),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseFloat(e);console.log(t),l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdStrength:t})}))}}),Object(h.jsx)(se,{title:"Guidance Scale",width:30,allowFloat:!0,value:"".concat(i.sdGuidanceScale),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseFloat(e);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(h.jsx)(se,{title:"Mask Blur",width:30,value:"".concat(i.sdMaskBlur),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdMaskBlur:t})}))}}),Object(h.jsx)(re,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(U,{width:80,value:i.sdSampler,options:Object.values(Se),onChange:function(e){var t=e;l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSampler:t})}))}})}),Object(h.jsx)(re,{title:"Seed",input:Object(h.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(h.jsx)(se,{title:"",width:80,value:"".concat(i.sdSeed),desc:"",disable:!i.sdSeedFixed,onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSeed:t})}))}}),Object(h.jsx)(rt,{checked:i.sdSeedFixed,onCheckedChange:function(e){l((function(t){return Object(O.a)(Object(O.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(h.jsx)(ct,{})})]})})]})})]})})},gt=function(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=(t[0],t[1],Object(o.d)(Ie)),r=Object(s.a)(n,2),c=r[0],i=r[1],l=Object(o.d)(we),u=Object(s.a)(l,2),j=u[0],f=u[1],p=Object(o.e)(De),g=function(){var e=Object(b.a)(d.a.mark((function e(){var t,n,a,r,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,H().then((function(e){return e.text()}));case 2:if((t=e.sent)!==c.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=c.model,fetch("".concat(T,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=c.model,r="Switching to ".concat(a," model"),o=3e3,"False"===n&&(r="Downloading ".concat(a," model, this may take a while"),o=9999999999),f({open:!0,desc:r,state:"loading",duration:o}),P(a).then((function(e){if(!e.ok)throw new Error("Server error");f({open:!0,desc:"Switch to ".concat(a," model success"),state:"success",duration:3e3})})).catch((function(){f({open:!0,desc:"Switch to ".concat(a," model failed"),state:"error",duration:3e3}),i((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}))}));case 14:case"end":return e.stop()}var s}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){H().then((function(e){return e.text()})).then((function(e){i((function(t){return Object(O.a)(Object(O.a)({},t),{},{model:e})}))}))}),[i]),Object(h.jsxs)(h.Fragment,{children:[p?Object(h.jsx)(Ot,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsx)(_e,{}),Object(h.jsx)(lt,{onClose:g}),Object(h.jsx)(et,{}),Object(h.jsx)(ht,Object(O.a)(Object(O.a)({},j),{},{onOpenChange:function(e){f((function(t){return Object(O.a)(Object(O.a)({},t),{},{open:e})}))}}))]})},vt=function(){var e=Object(o.d)(ye),t=Object(s.a)(e,2),n=t[0],a=t[1],r=function(){a((function(e){return!e}))};return Fe("h",(function(){r()})),Object(h.jsx)("div",{className:"shortcuts",children:Object(h.jsx)(Z,{onClick:r,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"28",height:"28",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 16 16",children:[Object(h.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(h.jsxs)("g",{fill:"currentColor",children:[Object(h.jsx)("path",{d:"M14 5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h12zM2 4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H2z"}),Object(h.jsx)("path",{d:"M13 10.25a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm0-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5 0A.25.25 0 0 1 8.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 8 8.75v-.5zm2 0a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25v-.5zm1 2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5-2A.25.25 0 0 1 6.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 6 8.75v-.5zm-2 0A.25.25 0 0 1 4.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 4 8.75v-.5zm-2 0A.25.25 0 0 1 2.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 2 8.75v-.5zm11-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0A.25.25 0 0 1 9.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 9 6.75v-.5zm-2 0A.25.25 0 0 1 7.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 7 6.75v-.5zm-2 0A.25.25 0 0 1 5.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 5 6.75v-.5zm-3 0A.25.25 0 0 1 2.25 6h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5A.25.25 0 0 1 2 6.75v-.5zm0 4a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm2 0a.25.25 0 0 1 .25-.25h5.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-5.5a.25.25 0 0 1-.25-.25v-.5z"})]})]})})})},mt=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)("div",{children:Object(h.jsx)(Z,{onClick:function(){a(Object(O.a)(Object(O.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",role:"img",width:"28",height:"28",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:[Object(h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),Object(h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})})},xt=function(){var e=Object(o.d)(he),t=Object(s.a)(e,2),n=t[0],r=(t[1],Object(o.d)(fe)),c=Object(s.a)(r,2),i=c[0],l=c[1],u=Object(a.useRef)(null),d=function(){0===i.length||n.isInpainting||Ve.emit(Ze)};Object(K.a)(u,(function(){(null===u||void 0===u?void 0:u.current)&&u.current.blur()}));return Object(h.jsxs)("div",{className:"prompt-wrapper",children:[Object(h.jsx)(Q,{ref:u,value:i,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;l(t.value)},onKeyUp:function(e){"Enter"===e.key&&d()},placeholder:"I want to repaint of..."}),Object(h.jsx)(Z,{border:!0,onClick:d,disabled:0===i.length||n.isInpainting,children:"Dream"})]})},wt=n(79),yt=function(){var e=Object(a.useState)(!1),t=Object(s.a)(e,2),n=t[0],r=t[1];return Object(h.jsxs)("div",{children:[Object(h.jsx)(Z,{onClick:function(){r(!0)},toolTip:"Buy me a coffee",tooltipPosition:"bottom",style:{border:0},icon:Object(h.jsx)(wt.a,{})}),Object(h.jsxs)(Je,{onClose:function(){return r(!1)},title:"Buy Me a Coffee",className:"modal-setting",show:n,showCloseIcon:!1,children:[Object(h.jsx)("h4",{style:{lineHeight:"24px"},children:"Hi there, If you found my project is useful, and want to help keep it alive please consider donating! Thank you for your support!"}),Object(h.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"flex-end",alignItems:"center",gap:"12px"},children:[Object(h.jsx)(Z,{onClick:function(){return r(!1)},children:" No thanks "}),Object(h.jsx)("a",{href:"https://ko-fi.com/Z8Z1CZJGY",target:"_blank",rel:"noreferrer",children:Object(h.jsx)(Z,{border:!0,onClick:function(){return r(!1)},children:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:["Sure",Object(h.jsx)(wt.a,{})]})})})]})]})]})},St=function(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=t[0],r=t[1],c=We(),i=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(i,1)[0],u=Object(o.e)(De);return Object(h.jsxs)("header",{children:[Object(h.jsx)("div",{children:Object(h.jsx)("label",{htmlFor:l,children:Object(h.jsxs)(Z,{icon:Object(h.jsx)(j.j,{}),style:{border:0},children:[Object(h.jsx)("input",{style:{display:"none"},id:l,name:l,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&r(n)},accept:"image/png, image/jpeg"}),"desktop"===c?"Upload New":void 0]})})}),u&&n?Object(h.jsx)(xt,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsxs)("div",{className:"header-icons-wrapper",children:[Object(h.jsx)(yt,{}),Object(h.jsx)(p,{}),Object(h.jsxs)("div",{className:"header-icons",children:[Object(h.jsx)(vt,{}),Object(h.jsx)(mt,{})]})]})]})},kt=["image/jpeg","image/png","image/webp","image/bmp","image/tiff"];!function(){function e(){return e=Object(b.a)(d.a.mark((function e(){var t,n,a=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:"",e.next=3,fetch(t,{method:"GET",cache:"no-cache"});case 3:return n=e.sent,e.abrupt("return",n.json());case 5:case"end":return e.stop()}}),e)}))),e.apply(this,arguments)}var t=function(){(function(){return e.apply(this,arguments)})(document.location+"/flaskwebgui-keep-server-alive").then((function(e){return e}))};document.addEventListener("DOMContentLoaded",(function(){t(),setInterval(t,3e3)}))}();var Ct=function(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=t[0],c=t[1],i=Object(o.d)(f),u=Object(s.a)(i,2),j=u[0],p=u[1],O=Object(o.d)(we),g=Object(s.a)(O,2),v=(g[0],g[1]),m=function(){var e=Object(a.useState)(),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){var e=new Headers;e.append("pragma","no-cache"),e.append("cache-control","no-cache"),fetch("/inputimage",{headers:e}).then(function(){var e=Object(b.a)(d.a.mark((function e(t){var n,a,c,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=null===(n=t.headers.get("content-disposition"))||void 0===n?void 0:n.split("filename=")[1].split(";")[0],e.next=3,t.blob();case 3:(c=e.sent)&&c.type.startsWith("image")&&(i=new File([c],void 0!==a?a:"inputImage"),r(i));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[r]);return Object(a.useEffect)((function(){c()}),[c]),n}(),x=Object(a.useState)(!1),w=Object(s.a)(x,2);w[0],w[1],Object(a.useEffect)((function(){c(m)}),[m,c]),Fe("shift+d",(function(){p("light"===j?"dark":"light")}),{},[j]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",j)}),[j]);var y=Object(a.useMemo)((function(){return Object(l.a)()}),[n]),S=r.a.useState(!1),k=Object(s.a)(S,2),C=(k[0],k[1]),L=r.a.useRef(0),M=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation()}),[]),N=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&C(!0)}),[]),I=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current-=1,L.current>0||C(!1)}),[]),z=r.a.useCallback((function(e){if(e.preventDefault(),e.stopPropagation(),C(!1),e.dataTransfer.files&&e.dataTransfer.files.length>0){if(e.dataTransfer.files.length>1)v({open:!0,desc:"Please drag and drop only one file",state:"error",duration:3e3});else{var t=e.dataTransfer.files[0],n=t.type;kt.includes(n)?c(t):v({open:!0,desc:"Please drag and drop an image file",state:"error",duration:3e3})}e.dataTransfer.clearData()}}),[]),E=Object(a.useCallback)((function(e){if(e.clipboardData){var t=e.clipboardData.items,n=[].slice.call(t).filter((function(e){return-1!==e.type.indexOf("image")}));if(0!==n.length){e.preventDefault(),e.stopPropagation();var a=n[0].getAsFile();a&&c(a)}}}),[]);return r.a.useEffect((function(){return window.addEventListener("dragenter",N),window.addEventListener("dragleave",I),window.addEventListener("dragover",M),window.addEventListener("drop",z),window.addEventListener("paste",E),function(){window.removeEventListener("dragenter",N),window.removeEventListener("dragleave",I),window.removeEventListener("dragover",M),window.removeEventListener("drop",z),window.removeEventListener("paste",E)}})),Object(h.jsxs)("div",{className:"lama-cleaner",children:[Object(h.jsx)(St,{}),Object(h.jsx)(gt,{},y)]})};i.a.render(Object(h.jsx)(r.a.StrictMode,{children:Object(h.jsx)(o.a,{children:Object(h.jsx)(Ct,{})})}),document.getElementById("root"))}},[[72,1,2]]]);
\ No newline at end of file
+(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{65:function(e,t,n){},72:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),c=n(12),i=n.n(c),o=(n(65),n(6)),s=n(3),l=n(56),u=n(9),d=n.n(u),b=n(13);var j=n(16),h=n(1),f=Object(o.b)({key:"themeState",default:"dark"}),p=function(){var e=Object(o.d)(f),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)("div",{className:"theme-toggle-ui",children:Object(h.jsx)("div",{className:"theme-btn",onClick:function(){a("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(h.jsx)(j.h,{}):Object(h.jsx)(j.i,{style:{color:"#ffcc00"}})})})},O=n(2),g=n(8),v=n(51),m=n(81),x=n(54),w=n(82),y=n(7);function S(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],r=0;rt){var r=Math.ceil(t*a);return"".concat(e,"x").concat(r)}var c=Math.ceil(n*a);return"".concat(c,"x").concat(e)}),[n,t,u]),b=Object(a.useCallback)((function(){for(var e=[],t=0;tt?(l(a[0]),r(parseInt(a[0],10))):(l(a[1]),r(parseInt(a[1],10)))},chevronDirection:"up"})}var _=n(52),G=n.n(_),K=n(77),J=n(4),$=["onFocus","onBlur"],Q=r.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,r=Object(J.a)(e,$),c=Object(o.d)(he),i=Object(s.a)(c,2),l=(i[0],i[1]);return Object(h.jsx)("input",Object(O.a)(Object(O.a)({},r),{},{ref:t,type:"text",onFocus:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onPaste:function(e){return e.stopPropagation()},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur(),(e.ctrlKey||e.metaKey)&&"z"===e.key&&e.stopPropagation()}}))})),q=["value","allowFloat","onValue"],ee=r.a.forwardRef((function(e,t){var n=e.value,r=e.allowFloat,c=e.onValue,i=Object(J.a)(e,q),o=Object(a.useState)(n),l=Object(s.a)(o,2),u=l[0],d=l[1];Object(a.useEffect)((function(){d(n)}),[n]);return Object(h.jsx)(Q,Object(O.a)(Object(O.a)({value:u,onInput:function(e){var t=e.target.value;r?(t=t.replace(/[^0-9.]/g,"").replace(/(\..*?)\..*/g,"$1"),null===c||void 0===c||c(t)):(t=t.replace(/\D/g,""),null===c||void 0===c||c(t)),d(t)},className:"number-input"},i),{},{ref:t}))}));ee.defaultProps={allowFloat:!1};var te=ee,ne=n(29),ae=function(e){var t=e.content,n=e.children;return Object(h.jsx)(ne.d,{children:Object(h.jsxs)(ne.c,{children:[Object(h.jsx)(ne.e,{className:"tooltip-trigger",children:n}),Object(h.jsxs)(ne.b,{className:"tooltip-content",children:[t,Object(h.jsx)(ne.a,{className:"tooltip-arrow"})]})]})})};var re=function(e){var t=e.title,n=e.titleSuffix,a=e.desc,r=e.input,c=e.optionDesc,i=e.className;return Object(h.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(h.jsxs)("div",{className:"setting-block-content",children:[Object(h.jsx)("div",{className:"setting-block-content-title",children:Object(h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a?Object(h.jsx)(ae,{content:Object(h.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(h.jsx)("span",{children:t})}):Object(h.jsx)("span",{children:t}),n]})}),r]}),c&&Object(h.jsx)("div",{className:"option-desc",children:c})]})};function ce(e){var t=e.title,n=e.allowFloat,r=e.desc,c=e.value,i=e.suffix,o=e.onValue,s=e.width,l=e.widthUnit,u=e.disable,d=Object(a.useRef)(null);return Object(K.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(h.jsx)(re,{className:"sub-setting-block",title:t,desc:r,input:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(h.jsx)(te,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:c,disabled:u,onValue:o,ref:d}),i&&Object(h.jsx)("span",{children:i})]})})}ce.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var ie,oe,se=ce;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(ie||(ie={})),function(e){e.ddim="ddim",e.plms="plms"}(oe||(oe={}));var le,ue,de=function(){var e=Object(o.d)(Ee),t=Object(s.a)(e,2),n=t[0],a=t[1];if(!(null===n||void 0===n?void 0:n.enabled))return Object(h.jsx)(h.Fragment,{});var r=function(e){a({hdStrategy:e})},c=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyResizeLimit:t})},i=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropTrigerSize:t})},l=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropMargin:t})},u=function(){return Object(h.jsxs)("div",{children:["Use original picture, suitable for picture size below 2K. Try"," ",Object(h.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(ie.RESIZE)},children:"Resize"})," or ",Object(h.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(ie.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(h.jsx)(re,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(h.jsx)(U,{width:80,value:n.hdStrategy,options:Object.values(ie),onChange:function(e){return r(e)}}),optionDesc:function(){switch(n.hdStrategy){case ie.ORIGINAL:return u();case ie.CROP:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)("div",{children:"Crop masking area from the original image to do inpainting."}),Object(h.jsx)(se,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:i}),Object(h.jsx)(se,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:l})]});case ie.RESIZE:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)("div",{children:"Resize the longer side of the image to a specific size, then do inpainting on the resized image."}),Object(h.jsx)(se,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:c})]});default:return u()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm",e.ZITS="zits",e.MAT="mat",e.FCF="fcf",e.SD15="sd1.5",e.CV2="cv2"}(ue||(ue={}));var be,je=Object(o.b)({key:"fileState",default:void 0}),he=Object(o.b)({key:"appState",default:{disableShortCuts:!1,isInpainting:!1}}),fe=Object(o.b)({key:"promptState",default:""}),pe=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(he).isInpainting},set:function(e,t){var n=e.get,a=e.set,r=n(he);a(he,Object(O.a)(Object(O.a)({},r),{},{isInpainting:t}))}}),Oe=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),ge=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(Oe).x},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{x:t}))}}),ve=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(Oe).y},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{y:t}))}}),me=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(Oe).height},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{height:t}))}}),xe=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(Oe).width},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{width:t}))}}),we=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),ye=Object(o.b)({key:"shortcutsState",default:!1});!function(e){e.INPAINT_NS="INPAINT_NS",e.INPAINT_TELEA="INPAINT_TELEA"}(be||(be={}));var Se,ke,Ce=(le={},Object(y.a)(le,ue.LAMA,{hdStrategy:ie.CROP,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:1280,hdStrategyCropMargin:196,enabled:!0}),Object(y.a)(le,ue.LDM,{hdStrategy:ie.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.ZITS,{hdStrategy:ie.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.MAT,{hdStrategy:ie.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.FCF,{hdStrategy:ie.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(y.a)(le,ue.SD15,{hdStrategy:ie.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(y.a)(le,ue.CV2,{hdStrategy:ie.RESIZE,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),le);!function(e){e.ddim="ddim",e.pndm="pndm",e.klms="k_lms"}(Se||(Se={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(ke||(ke={}));var Le,Me={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:ue.LAMA,hdSettings:Ce,ldmSteps:25,ldmSampler:oe.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:ke.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:Se.pndm,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1,cv2Radius:5,cv2Flag:be.INPAINT_NS},Ne="settingsState4",Ie=Object(o.b)({key:Ne,default:Me,effects:[(Le=Ne,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(Le);if(null!=a){var r=JSON.parse(a);r.show=!1,t(G.a.merge(G.a.cloneDeep(Me),r))}n((function(e,t,n){return n?localStorage.removeItem(Le):localStorage.setItem(Le,JSON.stringify(e))}))})]}),ze=Object(o.c)({key:"seed",get:function(e){return(0,e.get)(Ie).sdSeed},set:function(e,t){var n=e.get,a=e.set,r=n(Ie);a(Ie,Object(O.a)(Object(O.a)({},r),{},{sdSeed:t}))}}),Ee=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(Ie);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,r=n(Ie),c=r.hdSettings[r.model],i=Object(O.a)(Object(O.a)({},c),t);a(Ie,Object(O.a)(Object(O.a)({},r),{},{hdSettings:Object(O.a)(Object(O.a)({},r.hdSettings),{},Object(y.a)({},r.model,i))}))}}),De=Object(o.c)({key:"isSD",get:function(e){return(0,e.get)(Ie).model===ue.SD15}}),Te=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(Ie),a=t(De);return n.runInpaintingManually||a}}),Re=n(57),Fe=function(e,t,n,a){var r=Object(o.e)(he);return Object(Re.a)(e,t,Object(O.a)(Object(O.a)({},n),{},{enabled:!r.disableShortCuts}),a)},Pe={capture:!0,passive:!1},He=function(e){var t=e.minHeight,n=e.minWidth,r=e.maxHeight,c=e.maxWidth,i=e.scale,l=Object(o.d)(ge),u=Object(s.a)(l,2),d=u[0],b=u[1],j=Object(o.d)(ve),f=Object(s.a)(j,2),p=f[0],O=f[1],g=Object(o.d)(me),v=Object(s.a)(g,2),m=v[0],x=v[1],w=Object(o.d)(xe),y=Object(s.a)(w,2),S=y[0],k=y[1],C=Object(o.e)(pe),L=Object(a.useState)(!1),M=Object(s.a)(L,2),N=M[0],I=M[1],z=Object(a.useState)(!1),E=Object(s.a)(z,2),D=E[0],T=E[1];Object(a.useEffect)((function(){b(Math.round((c-512)/2)),O(Math.round((r-512)/2))}),[r,c,t,n]);var R=Object(a.useState)({initX:0,initY:0,initHeight:0,initWidth:0,startResizeX:0,startResizeY:0,ord:"top"}),F=Object(s.a)(R,2),P=F[0],H=F[1],A=function(){console.log("focus")},Z=function(e,n){return e>0&&n>t&&e+n<=r},V=function(e,t){return e>0&&t>n&&e+t<=c},W=function(e){if(!C){var t=e.clientX,n=e.clientY,a=Math.round((n-P.startResizeY)/i),r=Math.round((t-P.startResizeX)/i),c=function(){var e=P.initHeight-a,t=P.initY+a;Z(t,e)&&(x(e),O(t))},o=function(){var e=P.initHeight+a;Z(P.initY,e)&&x(e)},s=function(){var e=P.initWidth-r,t=P.initX+r;V(t,e)&&(k(e),b(t))},l=function(){var e=P.initWidth+r;V(P.initX,e)&&k(e)};if(N)switch(P.ord){case"topleft":c(),s();break;case"topright":c(),l();break;case"bottomleft":o(),s();break;case"bottomright":o(),l();break;case"top":c();break;case"right":l();break;case"bottom":o();break;case"left":s()}if(D){var u=P.initX+r,d=P.initY+a;V(u,P.initWidth)&&Z(d,P.initHeight)&&(b(u),O(d))}}},B=function(e){N&&I(!1),D&&T(!1)};Object(a.useEffect)((function(){if(N||D)return document.addEventListener("pointermove",W,Pe),document.addEventListener("pointerup",B,Pe),document.addEventListener("pointercancel",B,Pe),function(){document.removeEventListener("pointermove",W,Pe),document.removeEventListener("pointerup",B,Pe),document.removeEventListener("pointercancel",B,Pe)}}),[N,D,S,m,P]);var U=function(e){var t=e.target.dataset.ord;t&&(I(!0),H({initX:d,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},Y=function(e){T(!0),H({initX:d,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(h.jsx)("div",{className:"croper-wrapper",children:Object(h.jsxs)("div",{className:"croper",style:{height:m,width:S,left:d,top:p},children:[Object(h.jsx)("div",{className:"crop-border",style:{height:m,width:S,outlineWidth:"".concat(2/i,"px")}}),Object(h.jsx)("div",{className:"info-bar",onPointerDown:Y,style:{transform:"scale(".concat(1/i,")"),top:"".concat(10/i,"px"),left:"".concat(10/i,"px")},children:Object(h.jsxs)("div",{className:"crop-size",children:[S," x ",m]})}),Object(h.jsxs)("div",{className:"drag-elements",onFocus:A,onPointerDown:U,children:[Object(h.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}})]})]})})},Ae=n(55),Ze="prompt",Ve=Object(Ae.a)(),We=function(){var e=Object(a.useState)(window.innerWidth),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){r(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",c),function(){window.removeEventListener("resize",c)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function Be(e){var t=e.onSelection,n=Object(a.useState)(!1),r=Object(s.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(o,1)[0],u=We();function j(e){if(e&&e.type.match("image.*"))try{if(e.size>20971520)throw new Error("file too large");t(e)}catch(n){alert("error: ".concat(n.message))}}function f(e){return p.apply(this,arguments)}function p(){return(p=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){t.file((function(t){return e(t)}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e){return v.apply(this,arguments)}function v(){return(v=Object(b.a)(d.a.mark((function e(t){var n,a,r,c,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],r=0;r0)){e.next=23;break}if(!(null===(c=a.shift())||void 0===c?void 0:c.isFile)){e.next=12;break}return e.next=8,f(c);case 8:i=e.sent,n.push(i),e.next=21;break;case 12:if(!(null===c||void 0===c?void 0:c.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=g.a,e.next=18,m(c.createReader());case 18:e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.t0.apply.call(e.t0,e.t1,e.t4);case 21:e.next=3;break;case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return x.apply(this,arguments)}function x(){return(x=Object(b.a)(d.a.mark((function e(t){var n,a;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,w(t);case 3:a=e.sent;case 4:if(!(a.length>0)){e.next=11;break}return n.push.apply(n,Object(g.a)(a)),e.next=8,w(t);case 8:a=e.sent,e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e){return y.apply(this,arguments)}function y(){return(y=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){t.readEntries(e,n)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(){return(S=Object(b.a)(d.a.mark((function e(t){var n;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.next=3,O(t.dataTransfer.items);case 3:n=e.sent,i(!1),j(n[0]);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return Object(h.jsx)("label",{htmlFor:l,className:"file-select-label",children:Object(h.jsxs)("div",{className:["file-select-container",c?"file-select-label-hover":""].join(" "),onDrop:function(e){return S.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),i(!0)},onDragLeave:function(){return i(!1)},children:[Object(h.jsx)("input",{id:l,name:l,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&j(n)},accept:"image/png, image/jpeg"}),Object(h.jsx)("p",{className:"file-select-message",children:"desktop"===u?"Click here or drag an image file":"Tap here to load your picture"})]})})}var Ue="#ffcc00bb";function Ye(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ue;e.strokeStyle=n,e.lineCap="round",e.lineJoin="round",t.forEach((function(t){(null===t||void 0===t?void 0:t.pts.length)&&t.size&&(e.lineWidth=t.size,e.beginPath(),e.moveTo(t.pts[0].x,t.pts[0].y),t.pts.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}))}function Xe(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function _e(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(o.e)(fe),i=Object(o.e)(Ie),l=Object(o.d)(ze),u=Object(s.a)(l,2),f=(u[0],u[1]),p=Object(o.e)(Oe),O=Object(o.d)(we),y=Object(s.a)(O,2),S=(y[0],y[1]),N=Object(o.d)(pe),I=Object(s.a)(N,2),z=I[0],D=I[1],T=Object(o.e)(Te),F=Object(o.e)(De),P=Object(a.useState)(40),H=Object(s.a)(P,2),A=H[0],W=H[1],B=function(e){var t=Object(a.useState)(new Image),n=Object(s.a)(t,1)[0],r=Object(a.useState)(!1),c=Object(s.a)(r,2),i=c[0],o=c[1];return Object(a.useEffect)((function(){if(void 0!==e)return n.onload=function(){o(!0)},o(!1),n.src=URL.createObjectURL(e),function(){n.onload=null}}),[e,n]),[n,i]}(n),U=Object(s.a)(B,2),Y=U[0],_=U[1],G=Object(a.useState)([]),K=Object(s.a)(G,2),J=K[0],$=K[1],Q=Object(a.useState)(),q=Object(s.a)(Q,2),ee=q[0],te=q[1],ne=Object(a.useState)((function(){return document.createElement("canvas")})),ae=Object(s.a)(ne,1)[0],re=Object(a.useState)([]),ce=Object(s.a)(re,2),ie=ce[0],oe=ce[1],se=Object(a.useState)([]),le=Object(s.a)(se,2),ue=le[0],de=le[1],be=Object(a.useState)([]),he=Object(s.a)(be,2),ge=he[0],ve=he[1],me=Object(a.useState)({x:-1,y:-1}),xe=Object(s.a)(me,2),ye=xe[0],Se=ye.x,ke=ye.y,Ce=xe[1],Le=Object(a.useState)(!1),Me=Object(s.a)(Le,2),Ne=Me[0],Ee=Me[1],Re=Object(a.useState)(!1),Pe=Object(s.a)(Re,2),Ae=Pe[0],We=Pe[1],Ue=Object(a.useState)(!1),_e=Object(s.a)(Ue,2),Ge=_e[0],Ke=_e[1],Je=Object(a.useState)(!1),$e=Object(s.a)(Je,2),Qe=$e[0],qe=$e[1],et=Object(a.useState)({x:-1,y:-1,brushSize:20}),tt=Object(s.a)(et,2),nt=tt[0],at=tt[1],rt=Object(a.useState)(!1),ct=Object(s.a)(rt,2),it=ct[0],ot=ct[1],st=Object(a.useState)(1),lt=Object(s.a)(st,2),ut=lt[0],dt=lt[1],bt=Object(a.useState)(!1),jt=Object(s.a)(bt,2),ht=jt[0],ft=jt[1],pt=Object(a.useState)(1),Ot=Object(s.a)(pt,2),gt=Ot[0],vt=Ot[1],mt=Object(a.useState)(1080),xt=Object(s.a)(mt,2),wt=xt[0],yt=xt[1],St=Object(m.a)(),kt=St.width/2,Ct=St.height/2,Lt=Object(a.useRef)(),Mt=Object(a.useState)(!1),Nt=Object(s.a)(Mt,2),It=Nt[0],zt=Nt[1],Et=Object(a.useState)(!1),Dt=Object(s.a)(Et,2),Tt=Dt[0],Rt=Dt[1],Ft=Object(a.useState)(!1),Pt=Object(s.a)(Ft,2),Ht=Pt[0],At=Pt[1],Zt=Object(a.useState)(0),Vt=Object(s.a)(Zt,2),Wt=Vt[0],Bt=Vt[1],Ut=Object(a.useState)([]),Yt=Object(s.a)(Ut,2),Xt=Yt[0],_t=Yt[1],Gt=Object(a.useState)([]),Kt=Object(s.a)(Gt,2),Jt=Kt[0],$t=Kt[1],Qt=Object(a.useState)([]),qt=Object(s.a)(Qt,2),en=qt[0],tn=qt[1],nn=Object(a.useCallback)((function(e,t){ee&&(ee.clearRect(0,0,ee.canvas.width,ee.canvas.height),ee.drawImage(e,0,0,Y.naturalWidth,Y.naturalHeight),Ye(ee,t))}),[ee,Y]),an=Object(a.useCallback)((function(e){if(!(null===ee||void 0===ee?void 0:ee.canvas.width)||!(null===ee||void 0===ee?void 0:ee.canvas.height))throw new Error("canvas has invalid size");ae.width=null===ee||void 0===ee?void 0:ee.canvas.width,ae.height=null===ee||void 0===ee?void 0:ee.canvas.height;var t=ae.getContext("2d");if(!t)throw new Error("could not retrieve mask canvas");e.forEach((function(e){Ye(t,e,"white")}))}),[ee,ae]),rn=Object(a.useCallback)((function(){return 0!==ge.length}),[ge]),cn=Object(a.useCallback)((function(e){0===J.length?nn(Y,e):nn(J[J.length-1],e)}),[Y,J,nn]),on=Object(a.useCallback)(function(){var e=Object(b.a)(d.a.mark((function e(t,a){var r,c,o,s,l,u,b,j,h,O,v,m,x;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==n){e.next=2;break}return e.abrupt("return");case 2:if(console.log("runInpainting"),r=[],!0!==a){e.next=10;break}if(0!==ue.length){e.next=7;break}return e.abrupt("return");case 7:r=ue,e.next=14;break;case 10:if(rn()){e.next=12;break}return e.abrupt("return");case 12:de(ge),r=ge;case 14:if(c=[].concat(Object(g.a)(ie),[r]),ve([]),Rt(!1),D(!0),i.graduallyInpainting?an([r]):an(c),o=n,!0!==i.graduallyInpainting){e.next=35;break}if(!0!==a){e.next=29;break}if(!(J.length>1)){e.next=27;break}return s=J[J.length-2],e.next=26,L(s.currentSrc,n.name,n.type);case 26:o=e.sent;case 27:e.next=35;break;case 29:if(!(J.length>0)){e.next=35;break}return console.info("gradually inpainting on last result"),l=J[J.length-1],e.next=34,L(l.currentSrc,n.name,n.type);case 34:o=e.sent;case 35:return u=i.sdSeedFixed?i.sdSeed:-1,e.prev=36,e.next=39,R(o,ae.toDataURL(),i,p,t,wt.toString(),u);case 39:if(b=e.sent){e.next=42;break}throw new Error("empty response");case 42:return j=b.blob,h=b.seed,console.log(h),console.log(i.sdSeedFixed),h&&!i.sdSeedFixed&&f(parseInt(h,10)),O=new Image,e.next=49,k(O,j);case 49:!0===a?(v=J.slice(0,-1),m=[].concat(Object(g.a)(v),[O]),$(m)):(x=[].concat(Object(g.a)(J),[O]),$(x)),nn(O,[]),oe(c),dn(),e.next=59;break;case 55:e.prev=55,e.t0=e.catch(36),S({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),cn([]);case 59:D(!1);case 60:case"end":return e.stop()}}),e,null,[[36,55]])})));return function(t,n){return e.apply(this,arguments)}}(),[ie,ge,ae,i.graduallyInpainting,i,p,wt,c,cn,rn,an]);Object(a.useEffect)((function(){return Ve.on(Ze,(function(){rn()?on(c):0!==ue.length?on(c,!0):S({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){Ve.off(Ze)}}),[rn,on,prompt]);var sn=function(){return 0!==J.length},ln=function(e){return"Control"===e.key||"Meta"===e.key};Object(x.a)(ln,(function(){Ht&&(z||(At(!1),T||on()))}),{event:"keyup"},[z,Ht,rn]),Object(x.a)(ln,(function(){z||At(!0)}),{event:"keydown"},[z]),Object(a.useEffect)((function(){if(_){var e=St.width/Y.naturalWidth,t=(St.height-200)/Y.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),vt(n),dt(n),(null===ee||void 0===ee?void 0:ee.canvas)&&(ee.canvas.width=Y.naturalWidth,ee.canvas.height=Y.naturalHeight,cn([])),!It){var a;null===(a=Lt.current)||void 0===a||a.centerView(n,1),zt(!0);var r=Math.max(Y.width,Y.height);yt(r)}}}),[null===ee||void 0===ee?void 0:ee.canvas,Lt,Y,_,St,It,cn]);var un=Object(a.useCallback)((function(){if(gt&&Y&&St){var e=Lt.current;if(e){var t=(St.width-Y.width*gt)/2,n=(St.height-Y.height*gt)/2;e.setTransform(t,n,gt,200,"easeOutQuad"),e.state.scale=gt,dt(gt),ft(!1)}}}),[Lt,St,Y,Y.width,St.height,gt]),dn=function(){$t([]),tn([]),_t([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){un()})),function(){window.removeEventListener("resize",(function(){un()}))}}),[St,un]),Object(a.useEffect)((function(){return window.addEventListener("blur",(function(){qe(!1)})),function(){window.removeEventListener("blur",(function(){qe(!1)}))}}),[]);Object(x.a)("Escape",(function(){z||(Tt||Ht?(Rt(!1),ve([]),cn([])):un())}),{event:"keydown"},[Tt,z,Ht,un,cn]);var bn=function(e){if(Qe){var t=nt.x,n=nt.brushSize+(Se-t);n<=200&&n>=10&&W(n)}else if(!Ge&&Tt&&0!==ge.length){var a=Object(g.a)(ge);a[a.length-1].pts.push(Xe(e)),ve(a),cn(a)}},jn=function(e){if(!Qe&&(!Ge&&Y.src&&(null===ee||void 0===ee?void 0:ee.canvas)&&!z&&!function(e){return 2===e.nativeEvent.button}(e)))if(C(e))Ke(!0);else if(!(F&&i.showCroper&&(t=Xe(e),t.xp.x+p.width||t.y>p.y+p.height))){var t;Rt(!0);var n=[];(Ht||T)&&(n=Object(g.a)(ge)),n.push({size:A,pts:[Xe(e)]}),ve(n),cn(n)}},hn=Object(a.useCallback)((function(){if(0!==ge.length){de([]);var e=ge.pop(),t=[].concat(Object(g.a)(Jt),[e]);$t(t);var n=Object(g.a)(ge);ve(n),cn(n)}}),[ge,Jt,cn]),fn=Object(a.useCallback)((function(){if(J.length){var e=ie.pop();tn([].concat(Object(g.a)(en),[e])),$t([]),oe(Object(g.a)(ie)),ve([]),Rt(!1);var t=J.pop();_t([].concat(Object(g.a)(Xt),[t]));var n=Object(g.a)(J);$(n),0===n.length?nn(Y,[]):nn(n[n.length-1],[])}}),[nn,J,Xt,en,ie,Y]),pn=function(){T&&0!==ge.length?hn():fn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"z"===e.key;return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("undo"),!0)}),pn,void 0,[hn,fn,F]);var On=Object(a.useCallback)((function(){if(0!==Jt.length){var e=Jt.pop();$t(Object(g.a)(Jt));var t=[].concat(Object(g.a)(ge),[e]);ve(t),cn(t)}}),[ge,Jt,cn]),gn=Object(a.useCallback)((function(){if(0!==Xt.length){var e=en.pop();tn(Object(g.a)(en)),oe([].concat(Object(g.a)(ie),[e])),ve([]),Rt(!1);var t=Xt.pop(),n=[].concat(Object(g.a)(J),[t]);$(n),nn(n[n.length-1],[])}}),[nn,J,Xt,en,ie,Y]),vn=function(){T&&0!==Jt.length?On():gn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&e.shiftKey&&"z"===e.key.toLowerCase();return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("redo"),!0)}),vn,void 0,[On,gn,F]);Object(w.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),sn()&&ot((function(){return window.setTimeout((function(){Bt(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),sn()&&(Bt(0),window.setTimeout((function(){ot(!1)}),350))}));var mn=function(e){e===Ne||Ge||Ee(e)},xn=Object(a.useCallback)((function(){return Ge?"grab":Ne?"none":void 0}),[Ne,Ge]);Fe("[",(function(){W((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),Fe("]",(function(){W((function(e){return e+10}))})),Fe("shift+r",(function(){T&&rn()&&on()}),{},[T,on,rn]),Fe("ctrl+c, cmd+c",Object(b.a)(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,M();case 2:if(!(e.sent&&J.length>0)){e.next=8;break}if(!(null===ee||void 0===ee?void 0:ee.canvas)){e.next=8;break}return e.next=7,E(null===ee||void 0===ee?void 0:ee.canvas);case 7:S({open:!0,desc:"Copy inpainting result to clipboard",state:"success",duration:3e3});case 8:case"end":return e.stop()}}),e)}))),{},[J,ee]),Object(w.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Ee(!1),Ke(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Ee(!0),Ke(!1)})),Object(w.a)("Alt",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),qe(!0),at({x:Se,y:ke,brushSize:A})}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),qe(!1)}));var wn=function(e,t){var n=function(){var e,t,n=gt;return void 0!==(null===(e=Lt.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=Lt.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(A*n,"px"),height:"".concat(A*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(h.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;Ce({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(C(e)&&Ke(!1),Ge)||Y.src&&(null===ee||void 0===ee?void 0:ee.canvas)&&(z||Tt&&(Ht||T?Rt(!1):on()))},children:[void 0===n?Object(h.jsx)("div",{className:"landing-file-selector",children:Object(h.jsx)(Be,{onSelection:function(){var e=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r(t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})}):Object(h.jsx)(v.b,{ref:function(e){e&&(Lt.current=e)},panning:{disabled:!Ge,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:gt,minScale:.6*gt,onPanning:function(e){ht||ft(!0)},onZoom:function(e){dt(e.state.scale)},children:Object(h.jsxs)(v.a,{contentClass:z?"editor-canvas-loading":"",contentStyle:{visibility:It?"visible":"hidden"},children:[Object(h.jsxs)("div",{className:"editor-canvas-container",children:[Object(h.jsx)("canvas",{className:"editor-canvas",style:{cursor:xn(),clipPath:"inset(0 ".concat(Wt,"% 0 0)"),transition:"clip-path 300ms cubic-bezier(0.4, 0, 0.2, 1)"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){mn(!0),We(!1)},onFocus:function(){return mn(!0)},onMouseLeave:function(){return mn(!1)},onMouseDown:jn,onMouseMove:bn,ref:function(e){if(e&&!ee){var t=e.getContext("2d");t&&te(t)}}}),Object(h.jsxs)("div",{className:"original-image-container",style:{width:"".concat(Y.naturalWidth,"px"),height:"".concat(Y.naturalHeight,"px")},children:[it&&Object(h.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(Wt,"%")}}),Object(h.jsx)("img",{className:"original-image",src:Y.src,alt:"original",style:{width:"".concat(Y.naturalWidth,"px"),height:"".concat(Y.naturalHeight,"px")}})]})]}),i.showCroper?Object(h.jsx)(He,{maxHeight:Y.naturalHeight,maxWidth:Y.naturalWidth,minHeight:Math.min(256,Y.naturalHeight),minWidth:Math.min(256,Y.naturalWidth),scale:ut}):Object(h.jsx)(h.Fragment,{})]})}),Ne&&!z&&!Ge&&Object(h.jsx)("div",{className:"brush-shape",style:wn(Qe?nt.x:Se,Qe?nt.y:ke)}),Ae&&Object(h.jsx)("div",{className:"brush-shape",style:wn(kt,Ct)}),Object(h.jsxs)("div",{className:"editor-toolkit-panel",children:[F||void 0===n?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(X,{onChange:function(e){yt(e)},originalWidth:Y.naturalWidth,originalHeight:Y.naturalHeight}),Object(h.jsx)(V,{label:"Brush",min:10,max:200,value:A,onChange:function(e){W(e),Ae||(We(!0),window.setTimeout((function(){We(!1)}),1e4))},onClick:function(){return We(!1)}}),Object(h.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(h.jsx)(Z,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(h.jsx)(j.a,{}),disabled:ut===gt&&!1===ht,onClick:un}),Object(h.jsx)(Z,{toolTip:"Undo",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:pn,disabled:function(){if(z)return!0;if(J.length>0)return!1;if(T){if(0===ge.length)return!0}else if(0===J.length)return!0;return!1}()}),Object(h.jsx)(Z,{toolTip:"Redo",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:"scale(-1,1)"},children:Object(h.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:vn,disabled:function(){if(z)return!0;if(Xt.length>0)return!1;if(T){if(0===Jt.length)return!0}else if(0===Xt.length)return!0;return!1}()}),Object(h.jsx)(Z,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(h.jsx)(j.g,{}),className:it?"eyeicon-active":"",onDown:function(e){e.preventDefault(),ot((function(){return window.setTimeout((function(){Bt(100)}),10),!0}))},onUp:function(){Bt(0),window.setTimeout((function(){ot(!1)}),300)},disabled:0===J.length}),Object(h.jsx)(Z,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(h.jsx)(j.e,{}),disabled:!J.length,onClick:function(){if(void 0!==n){var e=n.name.replace(/(\.[\w\d_-]+)$/i,"_cleanup$1");if(function(e,t){var n=document.createElement("a");n.href=e,n.download=t,n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),setTimeout((function(){n.remove()}),100)}(J[J.length-1].currentSrc,e),i.downloadMask){var t=n.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");t=t.replace(/\.[^/.]+$/,".jpg"),an(ie);var a=document.createElement("a");a.download=t,a.href=ae.toDataURL("image/jpeg"),a.click()}}}}),i.runInpaintingManually&&Object(h.jsx)(Z,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.jsx)("path",{d:"M2 13L1.34921 12.2407C1.16773 12.3963 1.04797 12.6117 1.01163 12.8479L2 13ZM22.5 4L23.49 4.14142C23.5309 3.85444 23.4454 3.5638 23.2555 3.3448C23.0655 3.1258 22.7899 3 22.5 3V4ZM12.5 4V3C12.2613 3 12.0305 3.08539 11.8492 3.24074L12.5 4ZM1 19.5L0.0116283 19.3479C-0.0327373 19.6363 0.051055 19.9297 0.241035 20.1511C0.431014 20.3726 0.708231 20.5 1 20.5V19.5ZM11.5 19.5V20.5C11.7373 20.5 11.9668 20.4156 12.1476 20.2619L11.5 19.5ZM21.5 11L22.1476 11.7619C22.3337 11.6038 22.4554 11.3831 22.49 11.1414L21.5 11ZM2 14H12.5V12H2V14ZM13.169 13.7433L23.169 4.74329L21.831 3.25671L11.831 12.2567L13.169 13.7433ZM22.5 3H12.5V5H22.5V3ZM11.8492 3.24074L1.34921 12.2407L2.65079 13.7593L13.1508 4.75926L11.8492 3.24074ZM1.01163 12.8479L0.0116283 19.3479L1.98837 19.6521L2.98837 13.1521L1.01163 12.8479ZM1 20.5H11.5V18.5H1V20.5ZM12.4884 19.6521L13.4884 13.1521L11.5116 12.8479L10.5116 19.3479L12.4884 19.6521ZM21.51 3.85858L20.51 10.8586L22.49 11.1414L23.49 4.14142L21.51 3.85858ZM20.8524 10.2381L10.8524 18.7381L12.1476 20.2619L22.1476 11.7619L20.8524 10.2381Z",fill:"currentColor"})}),disabled:!rn()||z,onClick:function(){!z&&rn()&&on()}})]})]})]})}var Ge=n(28),Ke=r.a.forwardRef((function(e,t){var n=e.show,a=e.children,r=e.onClose,c=e.className,i=e.title,l=e.showCloseIcon,u=Object(o.d)(he),d=Object(s.a)(u,2),b=(d[0],d[1]);return Object(h.jsx)(Ge.d,{open:n,onOpenChange:function(e){e||(null===r||void 0===r||r(),b((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})))},children:Object(h.jsxs)(Ge.c,{children:[Object(h.jsx)(Ge.b,{className:"modal-mask"}),Object(h.jsxs)(Ge.a,{ref:t,className:"modal ".concat(c),children:[Object(h.jsxs)("div",{className:"modal-header",children:[Object(h.jsx)(Ge.e,{children:i}),l?Object(h.jsx)(Z,{icon:Object(h.jsx)(j.k,{}),onClick:r}):Object(h.jsx)(h.Fragment,{})]}),a]})]})})}));Ke.defaultProps={showCloseIcon:!0};var Je=Ke;function $e(e){var t=e.content,n=e.keys;return Object(h.jsxs)("div",{className:"shortcut-option",children:[Object(h.jsx)("div",{className:"shortcut-description",children:t}),Object(h.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(h.jsx)("div",{className:"shortcut-key",children:e},e)}))})]})}var Qe=/macintosh|mac os x/i.test(navigator.userAgent),qe=(/windows|win32/i.test(navigator.userAgent),Qe?"Cmd":"Ctrl");function et(){var e=Object(o.d)(ye),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(Je,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(h.jsxs)("div",{className:"shortcut-options",children:[Object(h.jsx)($e,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(qe)]}),Object(h.jsx)($e,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(h.jsx)($e,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(h.jsx)($e,{content:"Undo Inpainting",keys:[qe,"Z"]}),Object(h.jsx)($e,{content:"Redo Inpainting",keys:[qe,"Shift","Z"]}),Object(h.jsx)($e,{content:"View Original Image",keys:["Hold Tab"]}),Object(h.jsx)($e,{content:"Pan",keys:["Space + Drag"]}),Object(h.jsx)($e,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(h.jsx)($e,{content:"Decrease Brush Size",keys:["["]}),Object(h.jsx)($e,{content:"Increase Brush Size",keys:["]"]}),Object(h.jsx)($e,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(h.jsx)($e,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(h.jsx)($e,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var tt=n(53),nt=["className"],at=["className"],rt=r.a.forwardRef((function(e,t){var n=e.className,a=Object(J.a)(e,nt);return Object(h.jsx)(tt.a,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-root ".concat(n),onKeyDown:function(e){return e.preventDefault()}}))})),ct=r.a.forwardRef((function(e,t){var n=e.className,a=Object(J.a)(e,at);return Object(h.jsx)(tt.b,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),it=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(re,{title:"Manual Inpainting Mode",input:Object(h.jsx)(rt,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{runInpaintingManually:e})}))},children:Object(h.jsx)(ct,{})})})};var ot=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1],r=function(e,t,n){return Object(h.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(h.jsx)(ae,{content:n,children:Object(h.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:Object(h.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.jsx)("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})})})},c=function(){return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(se,{title:"Steps",value:"".concat(n.ldmSteps),desc:"Large steps result in better result, but more time-consuming",onValue:function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSteps:t})}))}}),Object(h.jsx)(re,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(U,{width:80,value:n.ldmSampler,options:Object.values(oe),onChange:function(e){return t=e,void a((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(h.jsx)(re,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case ue.LAMA:return r(0,0,"https://github.com/saic-mdal/lama");case ue.LDM:return r(0,0,"https://github.com/CompVis/latent-diffusion");case ue.ZITS:return r(0,0,"https://github.com/DQiaole/ZITS_inpainting");case ue.MAT:return r(0,0,"https://github.com/fenglinglwb/MAT");case ue.FCF:return r(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case ue.SD15:return r(0,0,"https://github.com/CompVis/stable-diffusion");case ue.CV2:return r(0,0,"https://docs.opencv.org/4.6.0/df/d3d/tutorial_py_inpainting.html");default:return Object(h.jsx)(h.Fragment,{})}}(),input:Object(h.jsx)(U,{width:80,value:n.model,options:Object.values(ue),onChange:function(e){return t=e,void a((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}));var t}}),optionDesc:function(){switch(n.model){case ue.LAMA:return;case ue.LDM:return c();case ue.ZITS:return Object(h.jsx)("div",{children:Object(h.jsx)(re,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(h.jsx)(rt,{checked:n.zitsWireframe,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{zitsWireframe:e})}))},children:Object(h.jsx)(ct,{})})})});case ue.MAT:return;case ue.FCF:return Object(h.jsx)("div",{children:"FcF only support fixed size(512x512) image input. Lama Cleaner will take care of resize and crop process, it still recommended applies to small defects."});case ue.SD15:return;case ue.CV2:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(se,{title:"Radius",value:"".concat(n.cv2Radius),desc:"Radius of a circular neighborhood of each point inpainted that is considered by the algorithm.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(O.a)(Object(O.a)({},e),{},{cv2Radius:t})}))}}),Object(h.jsx)(re,{className:"sub-setting-block",title:"Flag",desc:"Inpainting method",input:Object(h.jsx)(U,{width:140,value:n.cv2Flag,options:Object.values(be),onChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{cv2Flag:e})}))}})})]});default:return Object(h.jsx)(h.Fragment,{})}}()})},st=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(re,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(h.jsx)(rt,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{downloadMask:e})}))},children:Object(h.jsx)(ct,{})})})};function lt(e){var t=e.onClose,n=Object(o.d)(Ie),a=Object(s.a)(n,2),r=a[0],c=a[1],i=Object(o.e)(De);return Fe("s",(function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!e.show})}))}),{},[]),Object(h.jsxs)(Je,{onClose:function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:r.show,children:[i?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(it,{}),Object(h.jsx)(st,{}),Object(h.jsx)(ot,{}),i?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(de,{})]})}var ut=n(37),dt=["state","desc"],bt=function(){return Object(h.jsx)("span",{className:"loading-icon",children:Object(h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Object(h.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(h.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(h.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(h.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(h.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(h.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(h.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(h.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})})},jt=a.forwardRef((function(e,t){var n=e.state,a=e.desc,r=Object(J.a)(e,dt);return Object(h.jsxs)(ut.b,{children:[Object(h.jsxs)(ut.c,Object(O.a)(Object(O.a)({},r),{},{ref:t,className:"toast-root ".concat(n),children:[Object(h.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(h.jsx)(j.f,{className:"error-icon"});case"success":return Object(h.jsx)(j.b,{className:"success-icon"});case"loading":return Object(h.jsx)(bt,{});default:return Object(h.jsx)(h.Fragment,{})}}()}),Object(h.jsx)(ut.a,{className:"toast-desc",children:a})]})),Object(h.jsx)(ut.d,{className:"toast-viewpoint"})]})}));jt.defaultProps={desc:"",state:"loading"};var ht=jt,ft=n(36),pt=n(78),Ot=function(){var e=Object(pt.a)(!0),t=Object(s.a)(e,2),n=t[0],a=t[1],r=Object(o.d)(Ie),c=Object(s.a)(r,2),i=c[0],l=c[1];return Object(h.jsx)("div",{className:"side-panel",children:Object(h.jsxs)(ft.c,{open:n,children:[Object(h.jsx)(ft.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Configurations"}),Object(h.jsx)(ft.b,{children:Object(h.jsxs)(ft.a,{className:"side-panel-content",children:[Object(h.jsx)(re,{title:"Croper",input:Object(h.jsx)(rt,{checked:i.showCroper,onCheckedChange:function(e){l((function(t){return Object(O.a)(Object(O.a)({},t),{},{showCroper:e})}))},children:Object(h.jsx)(ct,{})})}),Object(h.jsx)(se,{title:"Steps",width:30,value:"".concat(i.sdSteps),desc:"Large steps result in better result, but more time-consuming",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSteps:t})}))}}),Object(h.jsx)(se,{title:"Guidance Scale",width:30,allowFloat:!0,value:"".concat(i.sdGuidanceScale),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseFloat(e);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(h.jsx)(se,{title:"Mask Blur",width:30,value:"".concat(i.sdMaskBlur),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdMaskBlur:t})}))}}),Object(h.jsx)(re,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(U,{width:80,value:i.sdSampler,options:Object.values(Se),onChange:function(e){var t=e;l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSampler:t})}))}})}),Object(h.jsx)(re,{title:"Seed",input:Object(h.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(h.jsx)(se,{title:"",width:80,value:"".concat(i.sdSeed),desc:"",disable:!i.sdSeedFixed,onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSeed:t})}))}}),Object(h.jsx)(rt,{checked:i.sdSeedFixed,onCheckedChange:function(e){l((function(t){return Object(O.a)(Object(O.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(h.jsx)(ct,{})})]})})]})})]})})},gt=function(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=(t[0],t[1],Object(o.d)(Ie)),r=Object(s.a)(n,2),c=r[0],i=r[1],l=Object(o.d)(we),u=Object(s.a)(l,2),j=u[0],f=u[1],p=Object(o.e)(De),g=function(){var e=Object(b.a)(d.a.mark((function e(){var t,n,a,r,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,H().then((function(e){return e.text()}));case 2:if((t=e.sent)!==c.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=c.model,fetch("".concat(T,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=c.model,r="Switching to ".concat(a," model"),o=3e3,"False"===n&&(r="Downloading ".concat(a," model, this may take a while"),o=9999999999),f({open:!0,desc:r,state:"loading",duration:o}),P(a).then((function(e){if(!e.ok)throw new Error("Server error");f({open:!0,desc:"Switch to ".concat(a," model success"),state:"success",duration:3e3})})).catch((function(){f({open:!0,desc:"Switch to ".concat(a," model failed"),state:"error",duration:3e3}),i((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}))}));case 14:case"end":return e.stop()}var s}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){H().then((function(e){return e.text()})).then((function(e){i((function(t){return Object(O.a)(Object(O.a)({},t),{},{model:e})}))}))}),[i]),Object(h.jsxs)(h.Fragment,{children:[p?Object(h.jsx)(Ot,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsx)(_e,{}),Object(h.jsx)(lt,{onClose:g}),Object(h.jsx)(et,{}),Object(h.jsx)(ht,Object(O.a)(Object(O.a)({},j),{},{onOpenChange:function(e){f((function(t){return Object(O.a)(Object(O.a)({},t),{},{open:e})}))}}))]})},vt=function(){var e=Object(o.d)(ye),t=Object(s.a)(e,2),n=t[0],a=t[1],r=function(){a((function(e){return!e}))};return Fe("h",(function(){r()})),Object(h.jsx)("div",{className:"shortcuts",children:Object(h.jsx)(Z,{onClick:r,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"28",height:"28",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 16 16",children:[Object(h.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(h.jsxs)("g",{fill:"currentColor",children:[Object(h.jsx)("path",{d:"M14 5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h12zM2 4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H2z"}),Object(h.jsx)("path",{d:"M13 10.25a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm0-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5 0A.25.25 0 0 1 8.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 8 8.75v-.5zm2 0a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25v-.5zm1 2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5-2A.25.25 0 0 1 6.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 6 8.75v-.5zm-2 0A.25.25 0 0 1 4.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 4 8.75v-.5zm-2 0A.25.25 0 0 1 2.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 2 8.75v-.5zm11-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0A.25.25 0 0 1 9.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 9 6.75v-.5zm-2 0A.25.25 0 0 1 7.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 7 6.75v-.5zm-2 0A.25.25 0 0 1 5.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 5 6.75v-.5zm-3 0A.25.25 0 0 1 2.25 6h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5A.25.25 0 0 1 2 6.75v-.5zm0 4a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm2 0a.25.25 0 0 1 .25-.25h5.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-5.5a.25.25 0 0 1-.25-.25v-.5z"})]})]})})})},mt=function(){var e=Object(o.d)(Ie),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)("div",{children:Object(h.jsx)(Z,{onClick:function(){a(Object(O.a)(Object(O.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",role:"img",width:"28",height:"28",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:[Object(h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),Object(h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})})},xt=function(){var e=Object(o.d)(he),t=Object(s.a)(e,2),n=t[0],r=(t[1],Object(o.d)(fe)),c=Object(s.a)(r,2),i=c[0],l=c[1],u=Object(a.useRef)(null),d=function(){0===i.length||n.isInpainting||Ve.emit(Ze)};Object(K.a)(u,(function(){(null===u||void 0===u?void 0:u.current)&&u.current.blur()}));return Object(h.jsxs)("div",{className:"prompt-wrapper",children:[Object(h.jsx)(Q,{ref:u,value:i,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;l(t.value)},onKeyUp:function(e){"Enter"===e.key&&d()},placeholder:"I want to repaint of..."}),Object(h.jsx)(Z,{border:!0,onClick:d,disabled:0===i.length||n.isInpainting,children:"Dream"})]})},wt=n(79),yt=function(){var e=Object(a.useState)(!1),t=Object(s.a)(e,2),n=t[0],r=t[1];return Object(h.jsxs)("div",{children:[Object(h.jsx)(Z,{onClick:function(){r(!0)},toolTip:"Buy me a coffee",tooltipPosition:"bottom",style:{border:0},icon:Object(h.jsx)(wt.a,{})}),Object(h.jsxs)(Je,{onClose:function(){return r(!1)},title:"Buy Me a Coffee",className:"modal-setting",show:n,showCloseIcon:!1,children:[Object(h.jsx)("h4",{style:{lineHeight:"24px"},children:"Hi there, If you found my project is useful, and want to help keep it alive please consider donating! Thank you for your support!"}),Object(h.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"flex-end",alignItems:"center",gap:"12px"},children:[Object(h.jsx)(Z,{onClick:function(){return r(!1)},children:" No thanks "}),Object(h.jsx)("a",{href:"https://ko-fi.com/Z8Z1CZJGY",target:"_blank",rel:"noreferrer",children:Object(h.jsx)(Z,{border:!0,onClick:function(){return r(!1)},children:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:["Sure",Object(h.jsx)(wt.a,{})]})})})]})]})]})},St=function(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=t[0],r=t[1],c=We(),i=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(i,1)[0],u=Object(o.e)(De);return Object(h.jsxs)("header",{children:[Object(h.jsx)("div",{children:Object(h.jsx)("label",{htmlFor:l,children:Object(h.jsxs)(Z,{icon:Object(h.jsx)(j.j,{}),style:{border:0},children:[Object(h.jsx)("input",{style:{display:"none"},id:l,name:l,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&r(n)},accept:"image/png, image/jpeg"}),"desktop"===c?"Upload New":void 0]})})}),u&&n?Object(h.jsx)(xt,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsxs)("div",{className:"header-icons-wrapper",children:[Object(h.jsx)(yt,{}),Object(h.jsx)(p,{}),Object(h.jsxs)("div",{className:"header-icons",children:[Object(h.jsx)(vt,{}),Object(h.jsx)(mt,{})]})]})]})},kt=["image/jpeg","image/png","image/webp","image/bmp","image/tiff"];!function(){function e(){return e=Object(b.a)(d.a.mark((function e(){var t,n,a=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:"",e.next=3,fetch(t,{method:"GET",cache:"no-cache"});case 3:return n=e.sent,e.abrupt("return",n.json());case 5:case"end":return e.stop()}}),e)}))),e.apply(this,arguments)}var t=function(){(function(){return e.apply(this,arguments)})(document.location+"/flaskwebgui-keep-server-alive").then((function(e){return e}))};document.addEventListener("DOMContentLoaded",(function(){t(),setInterval(t,3e3)}))}();var Ct=function(){var e=Object(o.d)(je),t=Object(s.a)(e,2),n=t[0],c=t[1],i=Object(o.d)(f),u=Object(s.a)(i,2),j=u[0],p=u[1],O=Object(o.d)(we),g=Object(s.a)(O,2),v=(g[0],g[1]),m=function(){var e=Object(a.useState)(),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){var e=new Headers;e.append("pragma","no-cache"),e.append("cache-control","no-cache"),fetch("/inputimage",{headers:e}).then(function(){var e=Object(b.a)(d.a.mark((function e(t){var n,a,c,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=null===(n=t.headers.get("content-disposition"))||void 0===n?void 0:n.split("filename=")[1].split(";")[0],e.next=3,t.blob();case 3:(c=e.sent)&&c.type.startsWith("image")&&(i=new File([c],void 0!==a?a:"inputImage"),r(i));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[r]);return Object(a.useEffect)((function(){c()}),[c]),n}(),x=Object(a.useState)(!1),w=Object(s.a)(x,2);w[0],w[1],Object(a.useEffect)((function(){c(m)}),[m,c]),Fe("shift+d",(function(){p("light"===j?"dark":"light")}),{},[j]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",j)}),[j]);var y=Object(a.useMemo)((function(){return Object(l.a)()}),[n]),S=r.a.useState(!1),k=Object(s.a)(S,2),C=(k[0],k[1]),L=r.a.useRef(0),M=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation()}),[]),N=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&C(!0)}),[]),I=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current-=1,L.current>0||C(!1)}),[]),z=r.a.useCallback((function(e){if(e.preventDefault(),e.stopPropagation(),C(!1),e.dataTransfer.files&&e.dataTransfer.files.length>0){if(e.dataTransfer.files.length>1)v({open:!0,desc:"Please drag and drop only one file",state:"error",duration:3e3});else{var t=e.dataTransfer.files[0],n=t.type;kt.includes(n)?c(t):v({open:!0,desc:"Please drag and drop an image file",state:"error",duration:3e3})}e.dataTransfer.clearData()}}),[]),E=Object(a.useCallback)((function(e){if(e.clipboardData){var t=e.clipboardData.items,n=[].slice.call(t).filter((function(e){return-1!==e.type.indexOf("image")}));if(0!==n.length){e.preventDefault(),e.stopPropagation();var a=n[0].getAsFile();a&&c(a)}}}),[]);return r.a.useEffect((function(){return window.addEventListener("dragenter",N),window.addEventListener("dragleave",I),window.addEventListener("dragover",M),window.addEventListener("drop",z),window.addEventListener("paste",E),function(){window.removeEventListener("dragenter",N),window.removeEventListener("dragleave",I),window.removeEventListener("dragover",M),window.removeEventListener("drop",z),window.removeEventListener("paste",E)}})),Object(h.jsxs)("div",{className:"lama-cleaner",children:[Object(h.jsx)(St,{}),Object(h.jsx)(gt,{},y)]})};i.a.render(Object(h.jsx)(r.a.StrictMode,{children:Object(h.jsx)(o.a,{children:Object(h.jsx)(Ct,{})})}),document.getElementById("root"))}},[[72,1,2]]]);
\ No newline at end of file