IOPaint/lama_cleaner/app/build/static/js/main.e73104cb.chunk.js
2022-09-25 22:33:09 +08:00

1 line
63 KiB
JavaScript

(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{62:function(e,t,n){},67:function(e,t,n){"use strict";n.r(t);var a=n(0),c=n.n(a),r=n(12),i=n.n(r),o=(n(62),n(7)),s=n(3),l=n(53),u=n(9),d=n.n(u),b=n(13);var j=n(6),h=n(2),f=n(48),p=n.n(f),O=n(14),g=n(23),v=n(1),m=function(e){var t=e.width,n=e.value,c=e.chevronDirection,r=e.options,i=e.autoFocusAfterClose,o=e.onChange,s=Object(a.useRef)(null);return Object(v.jsxs)(g.f,{value:n,onValueChange:o,onOpenChange:function(e){e||i||window.setTimeout((function(){var e;null===s||void 0===s||null===(e=s.current)||void 0===e||e.blur()}),100)},children:[Object(v.jsxs)(g.g,{className:"select-trigger",style:{width:t},ref:s,onKeyDown:function(e){return e.preventDefault()},children:[Object(v.jsx)(g.h,{}),Object(v.jsx)(g.b,{children:"up"===c?Object(v.jsx)(O.d,{}):Object(v.jsx)(O.c,{})})]}),Object(v.jsx)(g.a,{className:"select-content",children:Object(v.jsx)(g.i,{className:"select-viewport",children:r.map((function(e){return Object(v.jsxs)(g.c,{value:e,className:"select-item",children:[Object(v.jsx)(g.e,{children:e}),Object(v.jsx)(g.d,{className:"select-item-indicator",children:Object(v.jsx)(O.b,{})})]},e)}))})})]})};m.defaultProps={chevronDirection:"down",autoFocusAfterClose:!0};var x=m,w=n(71),y=n(4),S=["onFocus","onBlur"],k=c.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,c=Object(y.a)(e,S),r=Object(o.d)(V),i=Object(s.a)(r,2),l=(i[0],i[1]);return Object(v.jsx)("input",Object(h.a)(Object(h.a)({},c),{},{ref:t,type:"text",onFocus:function(e){l((function(e){return Object(h.a)(Object(h.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){l((function(e){return Object(h.a)(Object(h.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur(),(e.ctrlKey||e.metaKey)&&"z"===e.key&&e.stopPropagation()}}))})),C=["value","allowFloat","onValue"],L=c.a.forwardRef((function(e,t){var n=e.value,c=e.allowFloat,r=e.onValue,i=Object(y.a)(e,C),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(v.jsx)(k,Object(h.a)(Object(h.a)({value:u,onInput:function(e){var t=e.target.value;c?(t=t.replace(/[^0-9.]/g,"").replace(/(\..*?)\..*/g,"$1"),null===r||void 0===r||r(t)):(t=t.replace(/\D/g,""),null===r||void 0===r||r(t)),d(t)},className:"number-input"},i),{},{ref:t}))}));L.defaultProps={allowFloat:!1};var M=L,N=n(28),I=function(e){var t=e.content,n=e.children;return Object(v.jsx)(N.d,{children:Object(v.jsxs)(N.c,{children:[Object(v.jsx)(N.e,{className:"tooltip-trigger",children:n}),Object(v.jsxs)(N.b,{className:"tooltip-content",children:[t,Object(v.jsx)(N.a,{className:"tooltip-arrow"})]})]})})};var z=function(e){var t=e.title,n=e.titleSuffix,a=e.desc,c=e.input,r=e.optionDesc,i=e.className;return Object(v.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(v.jsxs)("div",{className:"setting-block-content",children:[Object(v.jsx)("div",{className:"setting-block-content-title",children:Object(v.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a?Object(v.jsx)(I,{content:Object(v.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(v.jsx)("span",{children:t})}):Object(v.jsx)("span",{children:t}),n]})}),c]}),r&&Object(v.jsx)("div",{className:"option-desc",children:r})]})};function E(e){var t=e.title,n=e.allowFloat,c=e.desc,r=e.value,i=e.suffix,o=e.onValue,s=e.width,l=e.widthUnit,u=e.disable,d=Object(a.useRef)(null);return Object(w.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(v.jsx)(z,{className:"sub-setting-block",title:t,desc:c,input:Object(v.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(v.jsx)(M,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:r,disabled:u,onValue:o,ref:d}),i&&Object(v.jsx)("span",{children:i})]})})}E.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var T,D,R=E;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(T||(T={})),function(e){e.ddim="ddim",e.plms="plms"}(D||(D={}));var F,P,H=function(){var e=Object(o.d)(re),t=Object(s.a)(e,2),n=t[0],a=t[1];if(!n.enabled)return Object(v.jsx)(v.Fragment,{});var c=function(e){a({hdStrategy:e})},r=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(v.jsxs)("div",{children:["Use original picture, suitable for picture size below 2K. Try"," ",Object(v.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(T.RESIZE)},children:"Resize"})," or ",Object(v.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(T.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(v.jsx)(z,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(v.jsx)(x,{width:80,value:n.hdStrategy,options:Object.values(T),onChange:function(e){return c(e)}}),optionDesc:function(){switch(n.hdStrategy){case T.ORIGINAL:return u();case T.CROP:return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("div",{children:"Crop masking area from the original image to do inpainting."}),Object(v.jsx)(R,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:i}),Object(v.jsx)(R,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:l})]});case T.RESIZE:return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("div",{children:"Resize the longer side of the image to a specific size, then do inpainting on the resized image."}),Object(v.jsx)(R,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:r})]});default:return u()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm",e.ZITS="zits",e.MAT="mat",e.FCF="fcf",e.SD14="sd1.4",e.CV2="cv2"}(P||(P={}));var A,Z=Object(o.b)({key:"fileState",default:void 0}),V=Object(o.b)({key:"appState",default:{disableShortCuts:!1,isInpainting:!1}}),W=Object(o.b)({key:"promptState",default:""}),B=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(V).isInpainting},set:function(e,t){var n=e.get,a=e.set,c=n(V);a(V,Object(h.a)(Object(h.a)({},c),{},{isInpainting:t}))}}),U=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),Y=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(U).x},set:function(e,t){var n=e.get,a=e.set,c=n(U);a(U,Object(h.a)(Object(h.a)({},c),{},{x:t}))}}),X=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(U).y},set:function(e,t){var n=e.get,a=e.set,c=n(U);a(U,Object(h.a)(Object(h.a)({},c),{},{y:t}))}}),K=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(U).height},set:function(e,t){var n=e.get,a=e.set,c=n(U);a(U,Object(h.a)(Object(h.a)({},c),{},{height:t}))}}),G=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(U).width},set:function(e,t){var n=e.get,a=e.set,c=n(U);a(U,Object(h.a)(Object(h.a)({},c),{},{width:t}))}}),_=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),$=Object(o.b)({key:"shortcutsState",default:!1});!function(e){e.INPAINT_NS="INPAINT_NS",e.INPAINT_TELEA="INPAINT_TELEA"}(A||(A={}));var J,Q,q=(F={},Object(j.a)(F,P.LAMA,{hdStrategy:T.RESIZE,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:2048,hdStrategyCropMargin:128,enabled:!0}),Object(j.a)(F,P.LDM,{hdStrategy:T.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(j.a)(F,P.ZITS,{hdStrategy:T.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(j.a)(F,P.MAT,{hdStrategy:T.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(j.a)(F,P.FCF,{hdStrategy:T.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(j.a)(F,P.SD14,{hdStrategy:T.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(j.a)(F,P.CV2,{hdStrategy:T.RESIZE,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),F);!function(e){e.ddim="ddim",e.pndm="pndm"}(J||(J={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(Q||(Q={}));var ee,te={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:P.LAMA,hdSettings:q,ldmSteps:25,ldmSampler:D.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:Q.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:J.ddim,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1,cv2Radius:5,cv2Flag:A.INPAINT_NS},ne="settingsState3",ae=Object(o.b)({key:ne,default:te,effects:[(ee=ne,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(ee);if(null!=a){var c=JSON.parse(a);c.show=!1,t(p.a.merge(p.a.cloneDeep(te),c))}n((function(e,t,n){return n?localStorage.removeItem(ee):localStorage.setItem(ee,JSON.stringify(e))}))})]}),ce=Object(o.c)({key:"seed",get:function(e){return(0,e.get)(ae).sdSeed},set:function(e,t){var n=e.get,a=e.set,c=n(ae);a(ae,Object(h.a)(Object(h.a)({},c),{},{sdSeed:t}))}}),re=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(ae);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,c=n(ae),r=c.hdSettings[c.model],i=Object(h.a)(Object(h.a)({},r),t);a(ae,Object(h.a)(Object(h.a)({},c),{},{hdSettings:Object(h.a)(Object(h.a)({},c.hdSettings),{},Object(j.a)({},c.model,i))}))}}),ie=Object(o.c)({key:"isSD",get:function(e){return(0,e.get)(ae).model===P.SD14}}),oe=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(ae),a=t(ie);return n.runInpaintingManually||a}}),se=n(8),le=function(){var e=Object(a.useState)(window.innerWidth),t=Object(s.a)(e,2),n=t[0],c=t[1],r=Object(a.useCallback)((function(){c(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",r),function(){window.removeEventListener("resize",r)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function ue(e){var t=e.onSelection,n=Object(a.useState)(!1),c=Object(s.a)(n,2),r=c[0],i=c[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(o,1)[0],u=le();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 h(e){return f.apply(this,arguments)}function f(){return(f=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 p(e){return O.apply(this,arguments)}function O(){return(O=Object(b.a)(d.a.mark((function e(t){var n,a,c,r,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],c=0;c<t.length;c+=1)a.push(t[c].webkitGetAsEntry());case 3:if(!(a.length>0)){e.next=23;break}if(!(null===(r=a.shift())||void 0===r?void 0:r.isFile)){e.next=12;break}return e.next=8,h(r);case 8:i=e.sent,n.push(i),e.next=21;break;case 12:if(!(null===r||void 0===r?void 0:r.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=se.a,e.next=18,g(r.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 g(e){return m.apply(this,arguments)}function m(){return(m=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,x(t);case 3:a=e.sent;case 4:if(!(a.length>0)){e.next=11;break}return n.push.apply(n,Object(se.a)(a)),e.next=8,x(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 x(e){return w.apply(this,arguments)}function w(){return(w=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 y(){return(y=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,p(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(v.jsx)("label",{htmlFor:l,className:"file-select-label",children:Object(v.jsxs)("div",{className:["file-select-container",r?"file-select-label-hover":""].join(" "),onDrop:function(e){return y.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),i(!0)},onDragLeave:function(){return i(!1)},children:[Object(v.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(v.jsx)("p",{className:"file-select-message",children:"desktop"===u?"Click here or drag an image file":"Tap here to load your picture"})]})})}var de=function(){var e=Object(o.f)(Z);return Object(v.jsxs)("div",{className:"landing-page",children:[Object(v.jsxs)("h1",{children:["Image inpainting powered by \ud83e\udd99",Object(v.jsx)("a",{href:"https://github.com/saic-mdal/lama",children:"LaMa"})]}),Object(v.jsx)("div",{className:"landing-file-selector",children:Object(v.jsx)(ue,{onSelection:function(){var t=Object(b.a)(d.a.mark((function t(n){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e(n);case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()})})]})},be=Object(o.b)({key:"themeState",default:"light"}),je=function(){var e=Object(o.d)(be),t=Object(s.a)(e,2),n=t[0],c=t[1];Object(a.useEffect)((function(){window.matchMedia("(prefers-color-scheme: dark)").matches?c("dark"):c("light")}),[c]);return Object(v.jsx)("div",{className:"theme-toggle-ui",children:Object(v.jsx)("div",{className:"theme-btn",onClick:function(){c("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(v.jsx)(O.h,{}):Object(v.jsx)(O.i,{style:{color:"#ffcc00"}})})})},he=n(49),fe=n(74),pe=n(51),Oe=n(75);function ge(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],c=0;c<n.length;c+=1)a.push(n.charCodeAt(c));return new Blob([new Uint8Array(a)],{type:t})}function ve(e,t){return new Promise((function(n,a){var c=e.src,r=e;r.onload=n,r.onerror=function(e){r.src=c,a(e)},r.src=t}))}function me(e){return 1===e.nativeEvent.button}function xe(e,t,n){return fetch(e).then((function(e){return e.arrayBuffer()})).then((function(e){return new File([e],t,{type:n})}))}function we(){return ye.apply(this,arguments)}function ye(){return(ye=Object(b.a)(d.a.mark((function e(){var t,n;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"});case 3:return t=e.sent,n=t.state,e.abrupt("return","granted"===n);case 8:return e.prev=8,e.t0=e.catch(0),e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))).apply(this,arguments)}function Se(e,t){return new Promise((function(n,a){return e.toBlob(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:t?n(t):a(new Error("Expected toBlob() to be defined"));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t)}))}var ke=function(){var e=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 n=[new ClipboardItem(Object(j.a)({},t.type,t))],e.next=3,navigator.clipboard.write(n);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function Ce(e){return Le.apply(this,arguments)}function Le(){return(Le=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 e.next=2,Se(t,"image/png");case 2:return n=e.sent,e.prev=3,e.next=6,ke(n);case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(3),console.log("Copy image failed!");case 11:case"end":return e.stop()}}),e,null,[[3,8]])})))).apply(this,arguments)}var Me="".concat("");function Ne(e,t,n,a,c,r,i){return Ie.apply(this,arguments)}function Ie(){return(Ie=Object(b.a)(d.a.mark((function e(t,n,a,c,r,i,o){var s,l,u,b,j,h;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(s=new FormData).append("image",t),l=ge(n),s.append("mask",l),u=a.hdSettings[a.model],s.append("ldmSteps",a.ldmSteps.toString()),s.append("ldmSampler",a.ldmSampler.toString()),s.append("zitsWireframe",a.zitsWireframe.toString()),s.append("hdStrategy",u.hdStrategy),s.append("hdStrategyCropMargin",u.hdStrategyCropMargin.toString()),s.append("hdStrategyCropTrigerSize",u.hdStrategyCropTrigerSize.toString()),s.append("hdStrategyResizeLimit",u.hdStrategyResizeLimit.toString()),s.append("prompt",void 0===r?"":r),s.append("croperX",c.x.toString()),s.append("croperY",c.y.toString()),s.append("croperHeight",c.height.toString()),s.append("croperWidth",c.width.toString()),s.append("useCroper",a.showCroper?"true":"false"),s.append("sdMaskBlur",a.sdMaskBlur.toString()),s.append("sdStrength",a.sdStrength.toString()),s.append("sdSteps",a.sdSteps.toString()),s.append("sdGuidanceScale",a.sdGuidanceScale.toString()),s.append("sdSampler",a.sdSampler.toString()),s.append("sdSeed",o?o.toString():"-1"),void 0===i?s.append("sizeLimit","1080"):s.append("sizeLimit",i),e.prev=25,e.next=28,fetch("".concat(Me,"/inpaint"),{method:"POST",body:s});case 28:if(!(b=e.sent).ok){e.next=35;break}return e.next=32,b.blob();case 32:return j=e.sent,h=b.headers.get("x-seed"),e.abrupt("return",{blob:URL.createObjectURL(j),seed:h});case 35:e.next=40;break;case 37:throw e.prev=37,e.t0=e.catch(25),new Error("Something went wrong on server side.");case 40:case"end":return e.stop()}}),e,null,[[25,37]])})))).apply(this,arguments)}function ze(e){var t=new FormData;return t.append("name",e),fetch("".concat(Me,"/model"),{method:"POST",body:t})}function Ee(){return fetch("".concat(Me,"/model"),{method:"GET"})}var Te=function(e){var t=e.children,n=e.border,a=e.className,c=e.disabled,r=e.icon,i=e.toolTip,o=e.tooltipPosition,s=e.onKeyDown,l=e.onClick,u=e.onDown,d=e.onUp,b=e.style;return Object(v.jsxs)("div",{role:"button","data-tooltip":i,style:b,onKeyDown:s,onClick:function(e){e.currentTarget.blur(),null===l||void 0===l||l()},onPointerDown:function(e){null===u||void 0===u||u(e.nativeEvent)},onPointerUp:function(e){null===d||void 0===d||d(e.nativeEvent)},tabIndex:-1,className:["btn-primary",t?"btn-primary-content":"",!0===c?"btn-primary-disabled":"",i?"info-tooltip":"",o?"info-tooltip-".concat(o):"",a,n?"btn-border":""].join(" "),children:[r,t?Object(v.jsx)("span",{children:t}):null]})};Te.defaultProps={disabled:!1,border:!1};var De=Te;function Re(e){var t=e.value,n=e.onChange,a=e.onClick,c=e.label,r=e.min,i=e.max,o=((i||100)-(r||0))/100;return Object(v.jsxs)("div",{className:"editor-brush-slider",children:[Object(v.jsx)("span",{children:c}),Object(v.jsx)("input",{type:"range",step:o,min:r,max:i,value:t,onChange:function(e){e.preventDefault(),e.stopPropagation(),n(parseInt(e.currentTarget.value,10))},onClick:a})]})}var Fe=["720","1080","2000","Original"];function Pe(e){var t=e.originalHeight,n=e.originalWidth,c=e.onChange,r=Object(a.useState)("Original"),i=Object(s.a)(r,2),o=i[0],l=i[1],u=Math.max(n,t),d=Object(a.useCallback)((function(e){if("Original"===e)return"".concat(n,"x").concat(t);var a=parseInt(e,10)/u;if(n>t){var c=Math.ceil(t*a);return"".concat(e,"x").concat(c)}var r=Math.ceil(n*a);return"".concat(r,"x").concat(e)}),[n,t,u]),b=Object(a.useCallback)((function(){for(var e=[],t=0;t<Fe.length;t+=1)"Original"===Fe[t]&&e.push(d(Fe[t])),parseInt(Fe[t],10)<u&&e.push(d(Fe[t]));return e}),[u,d]);return Object(v.jsx)(x,{width:100,autoFocusAfterClose:!1,value:d(o.toString()),options:b(),onChange:function(e){var a=e.split("x");n>t?(l(a[0]),c(parseInt(a[0],10))):(l(a[1]),c(parseInt(a[1],10)))},chevronDirection:"up"})}var He=n(54),Ae=function(e,t,n,a){var c=Object(o.e)(V);return Object(He.a)(e,t,Object(h.a)(Object(h.a)({},n),{},{enabled:!c.disableShortCuts}),a)},Ze={capture:!0,passive:!1},Ve=function(e){var t=e.minHeight,n=e.minWidth,c=e.maxHeight,r=e.maxWidth,i=e.scale,l=Object(o.d)(Y),u=Object(s.a)(l,2),d=u[0],b=u[1],j=Object(o.d)(X),h=Object(s.a)(j,2),f=h[0],p=h[1],O=Object(o.d)(K),g=Object(s.a)(O,2),m=g[0],x=g[1],w=Object(o.d)(G),y=Object(s.a)(w,2),S=y[0],k=y[1],C=Object(o.e)(B),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),T=E[0],D=E[1];Object(a.useEffect)((function(){b(Math.round((r-512)/2)),p(Math.round((c-512)/2))}),[c,r,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<=c},V=function(e,t){return e>0&&t>n&&e+t<=r},W=function(e){if(!C){var t=e.clientX,n=e.clientY,a=Math.round((n-P.startResizeY)/i),c=Math.round((t-P.startResizeX)/i),r=function(){var e=P.initHeight-a,t=P.initY+a;Z(t,e)&&(x(e),p(t))},o=function(){var e=P.initHeight+a;Z(P.initY,e)&&x(e)},s=function(){var e=P.initWidth-c,t=P.initX+c;V(t,e)&&(k(e),b(t))},l=function(){var e=P.initWidth+c;V(P.initX,e)&&k(e)};if(N)switch(P.ord){case"topleft":r(),s();break;case"topright":r(),l();break;case"bottomleft":o(),s();break;case"bottomright":o(),l();break;case"top":r();break;case"right":l();break;case"bottom":o();break;case"left":s()}if(T){var u=P.initX+c,d=P.initY+a;V(u,P.initWidth)&&Z(d,P.initHeight)&&(b(u),p(d))}}},U=function(e){N&&I(!1),T&&D(!1)};Object(a.useEffect)((function(){if(N||T)return document.addEventListener("pointermove",W,Ze),document.addEventListener("pointerup",U,Ze),document.addEventListener("pointercancel",U,Ze),function(){document.removeEventListener("pointermove",W,Ze),document.removeEventListener("pointerup",U,Ze),document.removeEventListener("pointercancel",U,Ze)}}),[N,T,S,m,P]);var _=function(e){var t=e.target.dataset.ord;t&&(I(!0),H({initX:d,initY:f,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},$=function(e){D(!0),H({initX:d,initY:f,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(v.jsx)("div",{className:"croper-wrapper",children:Object(v.jsxs)("div",{className:"croper",style:{height:m,width:S,left:d,top:f},children:[Object(v.jsx)("div",{className:"crop-border",style:{height:m,width:S,outlineWidth:"".concat(2/i,"px")}}),Object(v.jsx)("div",{className:"info-bar",onPointerDown:$,style:{transform:"scale(".concat(1/i,")"),top:"".concat(10/i,"px"),left:"".concat(10/i,"px")},children:Object(v.jsxs)("div",{className:"crop-size",children:[S," x ",m]})}),Object(v.jsxs)("div",{className:"drag-elements",onFocus:A,onPointerDown:_,children:[Object(v.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}})]})]})})},We=n(52),Be="prompt",Ue=Object(We.a)(),Ye="#ffcc00bb";function Xe(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ye;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 Ke(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function Ge(e){var t=e.file,n=Object(o.e)(W),c=Object(o.e)(ae),r=Object(o.d)(ce),i=Object(s.a)(r,2),l=(i[0],i[1]),u=Object(o.e)(U),j=Object(o.d)(_),h=Object(s.a)(j,2),f=(h[0],h[1]),p=Object(o.d)(B),g=Object(s.a)(p,2),m=g[0],x=g[1],w=Object(o.e)(oe),y=Object(o.e)(ie),S=Object(a.useState)(40),k=Object(s.a)(S,2),C=k[0],L=k[1],M=function(e){var t=Object(a.useState)(new Image),n=Object(s.a)(t,1)[0],c=Object(a.useState)(!1),r=Object(s.a)(c,2),i=r[0],o=r[1];return Object(a.useEffect)((function(){return n.onload=function(){o(!0)},o(!1),n.src=URL.createObjectURL(e),function(){n.onload=null}}),[e,n]),[n,i]}(t),N=Object(s.a)(M,2),I=N[0],z=N[1],E=Object(a.useState)([]),T=Object(s.a)(E,2),D=T[0],R=T[1],F=Object(a.useState)(),P=Object(s.a)(F,2),H=P[0],A=P[1],Z=Object(a.useState)((function(){return document.createElement("canvas")})),V=Object(s.a)(Z,1)[0],Y=Object(a.useState)([]),X=Object(s.a)(Y,2),K=X[0],G=X[1],$=Object(a.useState)([]),J=Object(s.a)($,2),Q=J[0],q=J[1],ee=Object(a.useState)([]),te=Object(s.a)(ee,2),ne=te[0],re=te[1],le=Object(a.useState)({x:-1,y:-1}),ue=Object(s.a)(le,2),de=ue[0],be=de.x,je=de.y,ge=ue[1],ye=Object(a.useState)(!1),Se=Object(s.a)(ye,2),ke=Se[0],Le=Se[1],Me=Object(a.useState)(!1),Ie=Object(s.a)(Me,2),ze=Ie[0],Ee=Ie[1],Te=Object(a.useState)(!1),Fe=Object(s.a)(Te,2),He=Fe[0],Ze=Fe[1],We=Object(a.useState)(!1),Ye=Object(s.a)(We,2),Ge=Ye[0],_e=Ye[1],$e=Object(a.useState)(1),Je=Object(s.a)($e,2),Qe=Je[0],qe=Je[1],et=Object(a.useState)(!1),tt=Object(s.a)(et,2),nt=tt[0],at=tt[1],ct=Object(a.useState)(1),rt=Object(s.a)(ct,2),it=rt[0],ot=rt[1],st=Object(a.useState)(1080),lt=Object(s.a)(st,2),ut=lt[0],dt=lt[1],bt=Object(fe.a)(),jt=bt.width/2,ht=bt.height/2,ft=Object(a.useRef)(),pt=Object(a.useState)(!1),Ot=Object(s.a)(pt,2),gt=Ot[0],vt=Ot[1],mt=Object(a.useState)(!1),xt=Object(s.a)(mt,2),wt=xt[0],yt=xt[1],St=Object(a.useState)(!1),kt=Object(s.a)(St,2),Ct=kt[0],Lt=kt[1],Mt=Object(a.useState)(0),Nt=Object(s.a)(Mt,2),It=Nt[0],zt=Nt[1],Et=Object(a.useState)([]),Tt=Object(s.a)(Et,2),Dt=Tt[0],Rt=Tt[1],Ft=Object(a.useState)([]),Pt=Object(s.a)(Ft,2),Ht=Pt[0],At=Pt[1],Zt=Object(a.useState)([]),Vt=Object(s.a)(Zt,2),Wt=Vt[0],Bt=Vt[1],Ut=Object(a.useCallback)((function(e,t){H&&(H.clearRect(0,0,H.canvas.width,H.canvas.height),H.drawImage(e,0,0,I.naturalWidth,I.naturalHeight),Xe(H,t))}),[H,I]),Yt=Object(a.useCallback)((function(e){if(!(null===H||void 0===H?void 0:H.canvas.width)||!(null===H||void 0===H?void 0:H.canvas.height))throw new Error("canvas has invalid size");V.width=null===H||void 0===H?void 0:H.canvas.width,V.height=null===H||void 0===H?void 0:H.canvas.height;var t=V.getContext("2d");if(!t)throw new Error("could not retrieve mask canvas");e.forEach((function(e){Xe(t,e,"white")}))}),[H,V]),Xt=Object(a.useCallback)((function(){return 0!==ne.length}),[ne]),Kt=Object(a.useCallback)((function(e){0===D.length?Ut(I,e):Ut(D[D.length-1],e)}),[I,D,Ut]),Gt=Object(a.useCallback)(function(){var e=Object(b.a)(d.a.mark((function e(n,a){var r,i,o,s,b,j,h,p,O,g,v,m,w;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(console.log("runInpainting"),r=[],!0!==a){e.next=8;break}if(0!==Q.length){e.next=5;break}return e.abrupt("return");case 5:r=Q,e.next=12;break;case 8:if(Xt()){e.next=10;break}return e.abrupt("return");case 10:q(ne),r=ne;case 12:if(i=[].concat(Object(se.a)(K),[r]),re([]),yt(!1),x(!0),c.graduallyInpainting?Yt([r]):Yt(i),o=t,!0!==c.graduallyInpainting){e.next=33;break}if(!0!==a){e.next=27;break}if(!(D.length>1)){e.next=25;break}return s=D[D.length-2],e.next=24,xe(s.currentSrc,t.name,t.type);case 24:o=e.sent;case 25:e.next=33;break;case 27:if(!(D.length>0)){e.next=33;break}return console.info("gradually inpainting on last result"),b=D[D.length-1],e.next=32,xe(b.currentSrc,t.name,t.type);case 32:o=e.sent;case 33:return j=c.sdSeedFixed?c.sdSeed:-1,e.prev=34,e.next=37,Ne(o,V.toDataURL(),c,u,n,ut.toString(),j);case 37:if(h=e.sent){e.next=40;break}throw new Error("empty response");case 40:return p=h.blob,O=h.seed,console.log(O),console.log(c.sdSeedFixed),O&&!c.sdSeedFixed&&l(parseInt(O,10)),g=new Image,e.next=47,ve(g,p);case 47:!0===a?(v=D.slice(0,-1),m=[].concat(Object(se.a)(v),[g]),R(m)):(w=[].concat(Object(se.a)(D),[g]),R(w)),Ut(g,[]),G(i),Qt(),e.next=57;break;case 53:e.prev=53,e.t0=e.catch(34),f({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),Kt([]);case 57:x(!1);case 58:case"end":return e.stop()}}),e,null,[[34,53]])})));return function(t,n){return e.apply(this,arguments)}}(),[K,ne,V,c.graduallyInpainting,c,u,ut,n,Kt,Xt,Yt]);Object(a.useEffect)((function(){return Ue.on(Be,(function(){Xt()?Gt(n):0!==Q.length?Gt(n,!0):f({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){Ue.off(Be)}}),[Xt,Gt,prompt]);var _t=function(){return 0!==D.length},$t=function(e){return"Control"===e.key||"Meta"===e.key};Object(pe.a)($t,(function(){Ct&&(m||(Lt(!1),w||Gt()))}),{event:"keyup"},[m,Ct,Xt]),Object(pe.a)($t,(function(){m||Lt(!0)}),{event:"keydown"},[m]),Object(a.useEffect)((function(){if(z){var e=bt.width/I.naturalWidth,t=(bt.height-200)/I.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),ot(n),qe(n),(null===H||void 0===H?void 0:H.canvas)&&(H.canvas.width=I.naturalWidth,H.canvas.height=I.naturalHeight,Kt([])),!gt){var a;null===(a=ft.current)||void 0===a||a.centerView(n,1),vt(!0);var c=Math.max(I.width,I.height);dt(c)}}}),[null===H||void 0===H?void 0:H.canvas,ft,I,z,bt,gt,Kt]);var Jt=Object(a.useCallback)((function(){if(it&&I&&bt){var e=ft.current;if(e){var t=(bt.width-I.width*it)/2,n=(bt.height-I.height*it)/2;e.setTransform(t,n,it,200,"easeOutQuad"),e.state.scale=it,qe(it),at(!1)}}}),[ft,bt,I,I.width,bt.height,it]),Qt=function(){At([]),Bt([]),Rt([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){Jt()})),function(){window.removeEventListener("resize",(function(){Jt()}))}}),[bt,Jt]);Object(pe.a)("Escape",(function(){m||(wt||Ct?(yt(!1),re([]),Kt([])):Jt())}),{event:"keydown"},[wt,m,Ct,Jt,Kt]);var qt=Object(a.useCallback)((function(){if(0!==ne.length){q([]);var e=ne.pop(),t=[].concat(Object(se.a)(Ht),[e]);At(t);var n=Object(se.a)(ne);re(n),Kt(n)}}),[ne,Ht,Kt]),en=Object(a.useCallback)((function(){if(D.length){var e=K.pop();Bt([].concat(Object(se.a)(Wt),[e])),At([]),G(Object(se.a)(K)),re([]),yt(!1);var t=D.pop();Rt([].concat(Object(se.a)(Dt),[t]));var n=Object(se.a)(D);R(n),0===n.length?Ut(I,[]):Ut(n[n.length-1],[])}}),[Ut,D,Dt,Wt,K,I]),tn=function(){w&&0!==ne.length?qt():en()};Object(pe.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)}),tn,void 0,[qt,en,y]);var nn=Object(a.useCallback)((function(){if(0!==Ht.length){var e=Ht.pop();At(Object(se.a)(Ht));var t=[].concat(Object(se.a)(ne),[e]);re(t),Kt(t)}}),[ne,Ht,Kt]),an=Object(a.useCallback)((function(){if(0!==Dt.length){var e=Wt.pop();Bt(Object(se.a)(Wt)),G([].concat(Object(se.a)(K),[e])),re([]),yt(!1);var t=Dt.pop(),n=[].concat(Object(se.a)(D),[t]);R(n),Ut(n[n.length-1],[])}}),[Ut,D,Dt,Wt,K,I]),cn=function(){w&&0!==Ht.length?nn():an()};Object(pe.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)}),cn,void 0,[nn,an,y]);Object(Oe.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),_t()&&_e((function(){return window.setTimeout((function(){zt(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),_t()&&(zt(0),window.setTimeout((function(){_e(!1)}),350))}));var rn=function(e){e===ke||He||Le(e)},on=Object(a.useCallback)((function(){return He?"grab":ke?"none":void 0}),[ke,He]);Ae("[",(function(){L((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),Ae("]",(function(){L((function(e){return e+10}))})),Ae("shift+r",(function(){w&&Xt()&&Gt()}),{},[w,Gt,Xt]),Ae("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,we();case 2:if(!(e.sent&&D.length>0)){e.next=8;break}if(!(null===H||void 0===H?void 0:H.canvas)){e.next=8;break}return e.next=7,Ce(null===H||void 0===H?void 0:H.canvas);case 7:f({open:!0,desc:"Copy inpainting result to clipboard",state:"success",duration:3e3});case 8:case"end":return e.stop()}}),e)}))),{},[D,H]),Object(Oe.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Le(!1),Ze(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Le(!0),Ze(!1)}));var sn=function(e,t){var n=function(){var e,t,n=it;return void 0!==(null===(e=ft.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=ft.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(C*n,"px"),height:"".concat(C*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(v.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;ge({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(me(e)&&Ze(!1),He)||I.src&&(null===H||void 0===H?void 0:H.canvas)&&(m||wt&&(Ct||w?yt(!1):Gt()))},children:[Object(v.jsx)(he.b,{ref:function(e){e&&(ft.current=e)},panning:{disabled:!He,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:it,minScale:it,onPanning:function(e){nt||at(!0)},onZoom:function(e){qe(e.state.scale)},children:Object(v.jsxs)(he.a,{contentClass:m?"editor-canvas-loading":"",contentStyle:{visibility:gt?"visible":"hidden"},children:[Object(v.jsxs)("div",{className:"editor-canvas-container",children:[Object(v.jsx)("canvas",{className:"editor-canvas",style:{cursor:on(),clipPath:"inset(0 ".concat(It,"% 0 0)"),transition:"clip-path 350ms ease-in-out"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){rn(!0),Ee(!1)},onFocus:function(){return rn(!0)},onMouseLeave:function(){return rn(!1)},onMouseDown:function(e){if(!He&&(I.src&&(null===H||void 0===H?void 0:H.canvas)&&!m&&!function(e){return 2===e.nativeEvent.button}(e)))if(me(e))Ze(!0);else if(!(y&&c.showCroper&&(t=Ke(e),t.x<u.x||t.y<u.y||t.x>u.x+u.width||t.y>u.y+u.height))){var t;yt(!0);var n=[];(Ct||w)&&(n=Object(se.a)(ne)),n.push({size:C,pts:[Ke(e)]}),re(n),Kt(n)}},onMouseMove:function(e){if(!He&&wt&&0!==ne.length){var t=Object(se.a)(ne);t[t.length-1].pts.push(Ke(e)),re(t),Kt(t)}},ref:function(e){if(e&&!H){var t=e.getContext("2d");t&&A(t)}}}),Object(v.jsxs)("div",{className:"original-image-container",style:{width:"".concat(I.naturalWidth,"px"),height:"".concat(I.naturalHeight,"px")},children:[Ge&&Object(v.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(It,"%")}}),Object(v.jsx)("img",{className:"original-image",src:I.src,alt:"original",style:{width:"".concat(I.naturalWidth,"px"),height:"".concat(I.naturalHeight,"px")}})]})]}),c.showCroper?Object(v.jsx)(Ve,{maxHeight:I.naturalHeight,maxWidth:I.naturalWidth,minHeight:Math.min(256,I.naturalHeight),minWidth:Math.min(256,I.naturalWidth),scale:Qe}):Object(v.jsx)(v.Fragment,{})]})}),ke&&!m&&!He&&Object(v.jsx)("div",{className:"brush-shape",style:sn(be,je)}),ze&&Object(v.jsx)("div",{className:"brush-shape",style:sn(jt,ht)}),Object(v.jsxs)("div",{className:"editor-toolkit-panel",children:[y?Object(v.jsx)(v.Fragment,{}):Object(v.jsx)(Pe,{onChange:function(e){dt(e)},originalWidth:I.naturalWidth,originalHeight:I.naturalHeight}),Object(v.jsx)(Re,{label:"Brush",min:10,max:150,value:C,onChange:function(e){L(e),ze||(Ee(!0),window.setTimeout((function(){Ee(!1)}),1e4))},onClick:function(){return Ee(!1)}}),Object(v.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(v.jsx)(De,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(v.jsx)(O.a,{}),disabled:Qe===it&&!1===nt,onClick:Jt}),Object(v.jsx)(De,{toolTip:"Undo",tooltipPosition:"top",icon:Object(v.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(v.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:tn,disabled:function(){if(m)return!0;if(D.length>0)return!1;if(w){if(0===ne.length)return!0}else if(0===D.length)return!0;return!1}()}),Object(v.jsx)(De,{toolTip:"Redo",tooltipPosition:"top",icon:Object(v.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",transform:"scale(-1,1)",children:Object(v.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:cn,disabled:function(){if(m)return!0;if(Dt.length>0)return!1;if(w){if(0===Ht.length)return!0}else if(0===Dt.length)return!0;return!1}()}),Object(v.jsx)(De,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(v.jsx)(O.g,{}),className:Ge?"eyeicon-active":"",onDown:function(e){e.preventDefault(),_e((function(){return window.setTimeout((function(){zt(100)}),10),!0}))},onUp:function(){zt(0),window.setTimeout((function(){_e(!1)}),350)},disabled:0===D.length}),Object(v.jsx)(De,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(v.jsx)(O.e,{}),disabled:!D.length,onClick:function(){var e=t.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)}(D[D.length-1].currentSrc,e),c.downloadMask){var n=t.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");n=n.replace(/\.[^/.]+$/,".jpg"),Yt(K);var a=document.createElement("a");a.download=n,a.href=V.toDataURL("image/jpeg"),a.click()}}}),c.runInpaintingManually&&Object(v.jsx)(De,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(v.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(v.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:!Xt()||m,onClick:function(){!m&&Xt()&&Gt()}})]})]})]})}var _e=n(29),$e=c.a.forwardRef((function(e,t){var n=e.show,a=e.children,c=e.onClose,r=e.className,i=e.title,l=Object(o.d)(V),u=Object(s.a)(l,2),d=(u[0],u[1]);return Object(v.jsx)(_e.d,{open:n,onOpenChange:function(e){e||(null===c||void 0===c||c(),d((function(e){return Object(h.a)(Object(h.a)({},e),{},{disableShortCuts:!1})})))},children:Object(v.jsxs)(_e.c,{children:[Object(v.jsx)(_e.b,{className:"modal-mask"}),Object(v.jsxs)(_e.a,{ref:t,className:"modal ".concat(r),children:[Object(v.jsxs)("div",{className:"modal-header",children:[Object(v.jsx)(_e.e,{children:i}),Object(v.jsx)(De,{icon:Object(v.jsx)(O.k,{}),onClick:c})]}),a]})]})})}));function Je(e){var t=e.content,n=e.keys;return Object(v.jsxs)("div",{className:"shortcut-option",children:[Object(v.jsx)("div",{className:"shortcut-description",children:t}),Object(v.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(v.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)($),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)($e,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(v.jsxs)("div",{className:"shortcut-options",children:[Object(v.jsx)(Je,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(qe)]}),Object(v.jsx)(Je,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(v.jsx)(Je,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(v.jsx)(Je,{content:"Undo Inpainting",keys:[qe,"Z"]}),Object(v.jsx)(Je,{content:"Redo Inpainting",keys:[qe,"Shift","Z"]}),Object(v.jsx)(Je,{content:"View Original Image",keys:["Hold Tab"]}),Object(v.jsx)(Je,{content:"Pan",keys:["Space + Drag"]}),Object(v.jsx)(Je,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(v.jsx)(Je,{content:"Decrease Brush Size",keys:["["]}),Object(v.jsx)(Je,{content:"Increase Brush Size",keys:["]"]}),Object(v.jsx)(Je,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(v.jsx)(Je,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(v.jsx)(Je,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var tt=n(50),nt=["className"],at=["className"],ct=c.a.forwardRef((function(e,t){var n=e.className,a=Object(y.a)(e,nt);return Object(v.jsx)(tt.a,Object(h.a)(Object(h.a)({},a),{},{ref:t,className:"switch-root ".concat(n),onKeyDown:function(e){return e.preventDefault()}}))})),rt=c.a.forwardRef((function(e,t){var n=e.className,a=Object(y.a)(e,at);return Object(v.jsx)(tt.b,Object(h.a)(Object(h.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),it=function(){var e=Object(o.d)(ae),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)(z,{title:"Manual Inpainting Mode",input:Object(v.jsx)(ct,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(h.a)(Object(h.a)({},t),{},{runInpaintingManually:e})}))},children:Object(v.jsx)(rt,{})})})};var ot=function(){var e=Object(o.d)(ae),t=Object(s.a)(e,2),n=t[0],a=t[1],c=function(e,t,n){return Object(v.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(v.jsx)(I,{content:n,children:Object(v.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:Object(v.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(v.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"})})})})})},r=function(){return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)(R,{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(h.a)(Object(h.a)({},e),{},{ldmSteps:t})}))}}),Object(v.jsx)(z,{className:"sub-setting-block",title:"Sampler",input:Object(v.jsx)(x,{width:80,value:n.ldmSampler,options:Object.values(D),onChange:function(e){return t=e,void a((function(e){return Object(h.a)(Object(h.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(v.jsx)(z,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case P.LAMA:return c(0,0,"https://github.com/saic-mdal/lama");case P.LDM:return c(0,0,"https://github.com/CompVis/latent-diffusion");case P.ZITS:return c(0,0,"https://github.com/DQiaole/ZITS_inpainting");case P.MAT:return c(0,0,"https://github.com/fenglinglwb/MAT");case P.FCF:return c(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case P.SD14:return c(0,0,"https://github.com/CompVis/stable-diffusion");case P.CV2:return c(0,0,"https://docs.opencv.org/4.6.0/df/d3d/tutorial_py_inpainting.html");default:return Object(v.jsx)(v.Fragment,{})}}(),input:Object(v.jsx)(x,{width:80,value:n.model,options:Object.values(P),onChange:function(e){return t=e,void a((function(e){return Object(h.a)(Object(h.a)({},e),{},{model:t})}));var t}}),optionDesc:function(){switch(n.model){case P.LAMA:return;case P.LDM:return r();case P.ZITS:return Object(v.jsx)("div",{children:Object(v.jsx)(z,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(v.jsx)(ct,{checked:n.zitsWireframe,onCheckedChange:function(e){a((function(t){return Object(h.a)(Object(h.a)({},t),{},{zitsWireframe:e})}))},children:Object(v.jsx)(rt,{})})})});case P.MAT:return;case P.FCF:return Object(v.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 P.SD14:return;case P.CV2:return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)(R,{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(h.a)(Object(h.a)({},e),{},{cv2Radius:t})}))}}),Object(v.jsx)(z,{className:"sub-setting-block",title:"Flag",desc:"Inpainting method",input:Object(v.jsx)(x,{width:140,value:n.cv2Flag,options:Object.values(A),onChange:function(e){a((function(t){return Object(h.a)(Object(h.a)({},t),{},{cv2Flag:e})}))}})})]});default:return Object(v.jsx)(v.Fragment,{})}}()})},st=function(){var e=Object(o.d)(ae),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)(z,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(v.jsx)(ct,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(h.a)(Object(h.a)({},t),{},{downloadMask:e})}))},children:Object(v.jsx)(rt,{})})})};function lt(e){var t=e.onClose,n=Object(o.d)(ae),a=Object(s.a)(n,2),c=a[0],r=a[1],i=Object(o.e)(ie);return Ae("s",(function(){r((function(e){return Object(h.a)(Object(h.a)({},e),{},{show:!e.show})}))}),{},[]),Object(v.jsxs)($e,{onClose:function(){r((function(e){return Object(h.a)(Object(h.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:c.show,children:[i?Object(v.jsx)(v.Fragment,{}):Object(v.jsx)(it,{}),Object(v.jsx)(st,{}),Object(v.jsx)(ot,{}),i?Object(v.jsx)(v.Fragment,{}):Object(v.jsx)(H,{})]})}var ut=n(36),dt=["state","desc"],bt=function(){return Object(v.jsx)("span",{className:"loading-icon",children:Object(v.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(v.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(v.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(v.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(v.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(v.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(v.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(v.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(v.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,c=Object(y.a)(e,dt);return Object(v.jsxs)(ut.b,{children:[Object(v.jsxs)(ut.c,Object(h.a)(Object(h.a)({},c),{},{ref:t,className:"toast-root ".concat(n),children:[Object(v.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(v.jsx)(O.f,{className:"error-icon"});case"success":return Object(v.jsx)(O.b,{className:"success-icon"});case"loading":return Object(v.jsx)(bt,{});default:return Object(v.jsx)(v.Fragment,{})}}()}),Object(v.jsx)(ut.a,{className:"toast-desc",children:a})]})),Object(v.jsx)(ut.d,{className:"toast-viewpoint"})]})}));jt.defaultProps={desc:"",state:"loading"};var ht=jt,ft=n(35),pt=n(72),Ot=function(){var e=Object(pt.a)(!0),t=Object(s.a)(e,2),n=t[0],a=t[1],c=Object(o.d)(ae),r=Object(s.a)(c,2),i=r[0],l=r[1];return Object(v.jsx)("div",{className:"side-panel",children:Object(v.jsxs)(ft.c,{open:n,children:[Object(v.jsx)(ft.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Stable Diffusion"}),Object(v.jsx)(ft.b,{children:Object(v.jsxs)(ft.a,{className:"side-panel-content",children:[Object(v.jsx)(z,{title:"Show Croper",input:Object(v.jsx)(ct,{checked:i.showCroper,onCheckedChange:function(e){l((function(t){return Object(h.a)(Object(h.a)({},t),{},{showCroper:e})}))},children:Object(v.jsx)(rt,{})})}),Object(v.jsx)(R,{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(h.a)(Object(h.a)({},e),{},{sdSteps:t})}))}}),Object(v.jsx)(R,{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(h.a)(Object(h.a)({},e),{},{sdStrength:t})}))}}),Object(v.jsx)(R,{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(h.a)(Object(h.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(v.jsx)(R,{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(h.a)(Object(h.a)({},e),{},{sdMaskBlur:t})}))}}),Object(v.jsx)(z,{className:"sub-setting-block",title:"Sampler",input:Object(v.jsx)(x,{width:80,value:i.sdSampler,options:Object.values(J),onChange:function(e){var t=e;l((function(e){return Object(h.a)(Object(h.a)({},e),{},{sdSampler:t})}))}})}),Object(v.jsx)(z,{title:"Seed",input:Object(v.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(v.jsx)(R,{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(h.a)(Object(h.a)({},e),{},{sdSeed:t})}))}}),Object(v.jsx)(ct,{checked:i.sdSeedFixed,onCheckedChange:function(e){l((function(t){return Object(h.a)(Object(h.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(v.jsx)(rt,{})})]})})]})})]})})},gt=function(e){var t=e.file,n=Object(o.d)(ae),c=Object(s.a)(n,2),r=c[0],i=c[1],l=Object(o.d)(_),u=Object(s.a)(l,2),j=u[0],f=u[1],p=Object(o.e)(ie),O=function(){var e=Object(b.a)(d.a.mark((function e(){var t,n,a,c,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ee().then((function(e){return e.text()}));case 2:if((t=e.sent)!==r.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=r.model,fetch("".concat(Me,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=r.model,c="Switching to ".concat(a," model"),o=3e3,"False"===n&&(c="Downloading ".concat(a," model, this may take a while"),o=9999999999),f({open:!0,desc:c,state:"loading",duration:o}),ze(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(h.a)(Object(h.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(){Ee().then((function(e){return e.text()})).then((function(e){i((function(t){return Object(h.a)(Object(h.a)({},t),{},{model:e})}))}))}),[i]),Object(v.jsxs)(v.Fragment,{children:[p?Object(v.jsx)(Ot,{}):Object(v.jsx)(v.Fragment,{}),Object(v.jsx)(Ge,{file:t}),Object(v.jsx)(lt,{onClose:O}),Object(v.jsx)(et,{}),Object(v.jsx)(ht,Object(h.a)(Object(h.a)({},j),{},{onOpenChange:function(e){f((function(t){return Object(h.a)(Object(h.a)({},t),{},{open:e})}))}}))]})},vt=function(){var e=Object(o.d)($),t=Object(s.a)(e,2),n=t[0],a=t[1],c=function(){a((function(e){return!e}))};return Ae("h",(function(){c()})),Object(v.jsx)("div",{className:"shortcuts",children:Object(v.jsx)(De,{onClick:c,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(v.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(v.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(v.jsxs)("g",{fill:"currentColor",children:[Object(v.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(v.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)(ae),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)("div",{children:Object(v.jsx)(De,{onClick:function(){a(Object(h.a)(Object(h.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(v.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(v.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(v.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)(V),t=Object(s.a)(e,2),n=t[0],c=(t[1],Object(o.d)(W)),r=Object(s.a)(c,2),i=r[0],l=r[1],u=Object(a.useRef)(null),d=function(){0===i.length||n.isInpainting||Ue.emit(Be)};Object(w.a)(u,(function(){(null===u||void 0===u?void 0:u.current)&&u.current.blur()}));return Object(v.jsxs)("div",{className:"prompt-wrapper",children:[Object(v.jsx)(k,{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(v.jsx)(De,{border:!0,onClick:d,disabled:0===i.length||n.isInpainting,children:"Dream"})]})},wt=function(){var e=Object(o.d)(Z),t=Object(s.a)(e,2),n=t[0],c=t[1],r=le(),i=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(i,1)[0],u=Object(o.e)(ie);return Object(v.jsxs)("header",{children:[Object(v.jsx)("div",{style:{visibility:n?"visible":"hidden"},children:Object(v.jsx)("label",{htmlFor:l,children:Object(v.jsxs)(De,{icon:Object(v.jsx)(O.j,{}),style:{border:0},children:[Object(v.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&&c(n)},accept:"image/png, image/jpeg"}),"desktop"===r?"Upload New":void 0]})})}),u&&n?Object(v.jsx)(xt,{}):Object(v.jsx)(v.Fragment,{}),Object(v.jsxs)("div",{className:"header-icons-wrapper",children:[Object(v.jsx)(je,{}),n&&Object(v.jsxs)("div",{className:"header-icons",children:[Object(v.jsx)(vt,{}),Object(v.jsx)(mt,{})]})]})]})},yt=["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 St=function(){var e=Object(o.d)(Z),t=Object(s.a)(e,2),n=t[0],r=t[1],i=Object(o.d)(be),u=Object(s.a)(i,2),j=u[0],h=u[1],f=Object(o.d)(_),p=Object(s.a)(f,2),O=(p[0],p[1]),g=function(){var e=Object(a.useState)(),t=Object(s.a)(e,2),n=t[0],c=t[1],r=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,r,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:(r=e.sent)&&r.type.startsWith("image")&&(i=new File([r],void 0!==a?a:"inputImage"),c(i));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[c]);return Object(a.useEffect)((function(){r()}),[r]),n}();Object(a.useEffect)((function(){r(g)}),[g,r]),Ae("shift+d",(function(){h("light"===j?"dark":"light")}),{},[j]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",j)}),[j]);var m=Object(a.useMemo)((function(){return Object(l.a)()}),[n]),x=c.a.useState(!1),w=Object(s.a)(x,2),y=(w[0],w[1]),S=c.a.useRef(0),k=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation()}),[]),C=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),S.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&y(!0)}),[]),L=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),S.current-=1,S.current>0||y(!1)}),[]),M=c.a.useCallback((function(e){if(e.preventDefault(),e.stopPropagation(),y(!1),e.dataTransfer.files&&e.dataTransfer.files.length>0){if(e.dataTransfer.files.length>1)O({open:!0,desc:"Please drag and drop only one file",state:"error",duration:3e3});else{var t=e.dataTransfer.files[0],n=t.type;yt.includes(n)?r(t):O({open:!0,desc:"Please drag and drop an image file",state:"error",duration:3e3})}e.dataTransfer.clearData()}}),[]);return c.a.useEffect((function(){return window.addEventListener("dragenter",C),window.addEventListener("dragleave",L),window.addEventListener("dragover",k),window.addEventListener("drop",M),function(){window.removeEventListener("dragenter",C),window.removeEventListener("dragleave",L),window.removeEventListener("dragover",k),window.removeEventListener("drop",M)}})),Object(v.jsxs)("div",{className:"lama-cleaner",children:[Object(v.jsx)(wt,{}),n?Object(v.jsx)(gt,{file:n},m):Object(v.jsx)(de,{})]})};i.a.render(Object(v.jsx)(c.a.StrictMode,{children:Object(v.jsx)(o.a,{children:Object(v.jsx)(St,{})})}),document.getElementById("root"))}},[[67,1,2]]]);