IOPaint/lama_cleaner/app/build/static/js/main.994b5b32.chunk.js
2022-12-11 22:04:42 +08:00

1 line
82 KiB
JavaScript

(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{67:function(e,t,n){},74:function(e,t,n){"use strict";n.r(t);n(62);var a=n(0),c=n.n(a),i=n(13),r=n.n(i),o=(n(67),n(6)),s=n(7),l=n.n(s),u=n(12),d=n(3),b=n(57);var j=n(77),p=n(78),h=n(1),f=Object(o.b)({key:"themeState",default:"dark"}),O=function(){var e=Object(o.d)(f),t=Object(d.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.a,{}):Object(h.jsx)(p.a,{style:{color:"#ffcc00"}})})})},g=n(2),v=n(9),m=n(86),x=n(87),y=n(88),w=n(89),S=n(52),k=n(95),C=n(55),M=n(96),E=n(8);function I(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 L(e,t){return new Promise((function(n,a){var c=e.src,i=e;i.onload=n,i.onerror=function(e){i.src=c,a(e)},i.src=t}))}function N(e){var t=Object(a.useState)(new Image),n=Object(d.a)(t,1)[0],c=Object(a.useState)(!1),i=Object(d.a)(c,2),r=i[0],o=i[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,r]}function T(){function e(){return e=Object(u.a)(l.a.mark((function e(){var t,n,a=arguments;return l.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}))};t(),setInterval(t,3e3)}function P(e){return 2===e.nativeEvent.button}function z(e){return 1===e.nativeEvent.button}function R(e,t,n){return fetch(e).then((function(e){return e.arrayBuffer()})).then((function(e){return new File([e],t,{type:n})}))}function D(){return F.apply(this,arguments)}function F(){return(F=Object(u.a)(l.a.mark((function e(){var t,n;return l.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 B(e,t){return new Promise((function(n,a){return e.toBlob(function(){var e=Object(u.a)(l.a.mark((function e(t){return l.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 A=function(){var e=Object(u.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[new ClipboardItem(Object(E.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 H(e){return Z.apply(this,arguments)}function Z(){return(Z=Object(u.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B(t,"image/png");case 2:return n=e.sent,e.prev=3,e.next=6,A(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 V="".concat("");function _(e,t,n,a,c,i,r,o,s,l){return W.apply(this,arguments)}function W(){return(W=Object(u.a)(l.a.mark((function e(t,n,a,c,i,r,o,s,u,d){var b,j,p,h,f,O;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(b=new FormData).append("image",t),void 0!==s?b.append("mask",I(s)):void 0!==u&&b.append("mask",u),j=n.hdSettings[n.model],b.append("ldmSteps",n.ldmSteps.toString()),b.append("ldmSampler",n.ldmSampler.toString()),b.append("zitsWireframe",n.zitsWireframe.toString()),b.append("hdStrategy",j.hdStrategy),b.append("hdStrategyCropMargin",j.hdStrategyCropMargin.toString()),b.append("hdStrategyCropTrigerSize",j.hdStrategyCropTrigerSize.toString()),b.append("hdStrategyResizeLimit",j.hdStrategyResizeLimit.toString()),b.append("prompt",void 0===c?"":c),b.append("negativePrompt",void 0===i?"":i),b.append("croperX",a.x.toString()),b.append("croperY",a.y.toString()),b.append("croperHeight",a.height.toString()),b.append("croperWidth",a.width.toString()),b.append("useCroper",n.showCroper?"true":"false"),b.append("sdMaskBlur",n.sdMaskBlur.toString()),b.append("sdStrength",n.sdStrength.toString()),b.append("sdSteps",n.sdSteps.toString()),b.append("sdGuidanceScale",n.sdGuidanceScale.toString()),b.append("sdSampler",n.sdSampler.toString()),b.append("sdSeed",o?o.toString():"-1"),b.append("sdMatchHistograms",n.sdMatchHistograms?"true":"false"),b.append("cv2Radius",n.cv2Radius.toString()),b.append("cv2Flag",n.cv2Flag.toString()),b.append("paintByExampleSteps",n.paintByExampleSteps.toString()),b.append("paintByExampleGuidanceScale",n.paintByExampleGuidanceScale.toString()),b.append("paintByExampleSeed",o?o.toString():"-1"),b.append("paintByExampleMaskBlur",n.paintByExampleMaskBlur.toString()),b.append("paintByExampleMatchHistograms",n.paintByExampleMatchHistograms?"true":"false"),d&&b.append("paintByExampleImage",d),void 0===r?b.append("sizeLimit","1080"):b.append("sizeLimit",r),e.prev=34,e.next=37,fetch("".concat(V,"/inpaint"),{method:"POST",body:b});case 37:if(!(p=e.sent).ok){e.next=44;break}return e.next=41,p.blob();case 41:return h=e.sent,f=p.headers.get("x-seed"),e.abrupt("return",{blob:URL.createObjectURL(h),seed:f});case 44:return e.next=46,p.text();case 46:throw O=e.sent,new Error(O);case 50:throw e.prev=50,e.t0=e.catch(34),new Error("Something went wrong: ".concat(e.t0));case 53:case"end":return e.stop()}}),e,null,[[34,50]])})))).apply(this,arguments)}function Y(e){var t=new FormData;return t.append("name",e),fetch("".concat(V,"/model"),{method:"POST",body:t})}function G(){return fetch("".concat(V,"/model"),{method:"GET"})}function U(e,t,n){return X.apply(this,arguments)}function X(){return(X=Object(u.a)(l.a.mark((function e(t,n,a){var c,i,r,o;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(c=new FormData).append("image",t),c.append("clicks",JSON.stringify(a)),null!==n&&c.append("mask",n),e.prev=4,e.next=7,fetch("".concat(V,"/interactive_seg"),{method:"POST",body:c});case 7:if(!(i=e.sent).ok){e.next=13;break}return e.next=11,i.blob();case 11:return r=e.sent,e.abrupt("return",{blob:URL.createObjectURL(r)});case 13:return e.next=15,i.text();case 15:throw o=e.sent,new Error(o);case 19:throw e.prev=19,e.t0=e.catch(4),new Error("Something went wrong: ".concat(e.t0));case 22:case"end":return e.stop()}}),e,null,[[4,19]])})))).apply(this,arguments)}var K=function(e){var t=e.children,n=e.border,a=e.className,c=e.disabled,i=e.icon,r=e.toolTip,o=e.tooltipPosition,s=e.onKeyDown,l=e.onClick,u=e.onDown,d=e.onUp,b=e.style;return Object(h.jsxs)("div",{role:"button","data-tooltip":r,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":"",r?"info-tooltip":"",o?"info-tooltip-".concat(o):"",a,n?"btn-border":""].join(" "),children:[i,t?Object(h.jsx)("span",{children:t}):null]})};K.defaultProps={disabled:!1,border:!1};var J=K;function q(e){var t=e.value,n=e.onChange,a=e.onClick,c=e.label,i=e.min,r=e.max,o=((r||100)-(i||0))/100;return Object(h.jsxs)("div",{className:"editor-brush-slider",children:[Object(h.jsx)("span",{children:c}),Object(h.jsx)("input",{type:"range",step:o,min:i,max:r,value:t,onChange:function(e){e.preventDefault(),e.stopPropagation(),n(parseInt(e.currentTarget.value,10))},onClick:a})]})}var $=n(81),Q=n(82),ee=n(83),te=n(24),ne=function(e){var t=e.width,n=e.value,c=e.chevronDirection,i=e.options,r=e.autoFocusAfterClose,o=e.onChange,s=e.disabled,l=Object(a.useRef)(null);return Object(h.jsxs)(te.f,{value:n,onValueChange:o,onOpenChange:function(e){e||r||window.setTimeout((function(){var e;null===l||void 0===l||null===(e=l.current)||void 0===e||e.blur()}),100)},children:[Object(h.jsxs)(te.g,{className:"select-trigger",style:{width:t},ref:l,onKeyDown:function(e){return e.preventDefault()},disabled:s,children:[Object(h.jsx)(te.h,{}),Object(h.jsx)(te.b,{children:"up"===c?Object(h.jsx)($.a,{}):Object(h.jsx)(Q.a,{})})]}),Object(h.jsx)(te.a,{className:"select-content",children:Object(h.jsx)(te.i,{className:"select-viewport",children:i.map((function(e){return Object(h.jsxs)(te.c,{value:e,className:"select-item",children:[Object(h.jsx)(te.e,{children:e}),Object(h.jsx)(te.d,{className:"select-item-indicator",children:Object(h.jsx)(ee.a,{})})]},e)}))})})]})};ne.defaultProps={chevronDirection:"down",autoFocusAfterClose:!0,disabled:!1};var ae=ne,ce=["720","1080","2000","Original"];function ie(e){var t=e.originalHeight,n=e.originalWidth,c=e.onChange,i=Object(a.useState)("Original"),r=Object(d.a)(i,2),o=r[0],s=r[1],l=Math.max(n,t),u=Object(a.useCallback)((function(e){if("Original"===e)return"".concat(n,"x").concat(t);var a=parseInt(e,10)/l;if(n>t){var c=Math.ceil(t*a);return"".concat(e,"x").concat(c)}var i=Math.ceil(n*a);return"".concat(i,"x").concat(e)}),[n,t,l]),b=Object(a.useCallback)((function(){for(var e=[],t=0;t<ce.length;t+=1)"Original"===ce[t]&&e.push(u(ce[t])),parseInt(ce[t],10)<l&&e.push(u(ce[t]));return e}),[l,u]);return Object(h.jsx)(ae,{width:100,autoFocusAfterClose:!1,value:u(o.toString()),options:b(),onChange:function(e){var a=e.split("x");n>t?(s(a[0]),c(parseInt(a[0],10))):(s(a[1]),c(parseInt(a[1],10)))},chevronDirection:"up"})}var re=n(53),oe=n.n(re),se=n(84),le=n(4),ue=["onFocus","onBlur"],de=c.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,c=Object(le.a)(e,ue),i=Object(o.d)(Ie),r=Object(d.a)(i,2),s=(r[0],r[1]);return Object(h.jsx)("input",Object(g.a)(Object(g.a)({},c),{},{ref:t,type:"text",onFocus:function(e){s((function(e){return Object(g.a)(Object(g.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){s((function(e){return Object(g.a)(Object(g.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()}}))})),be=["value","allowFloat","onValue"],je=c.a.forwardRef((function(e,t){var n=e.value,c=e.allowFloat,i=e.onValue,r=Object(le.a)(e,be),o=Object(a.useState)(n),s=Object(d.a)(o,2),l=s[0],u=s[1];Object(a.useEffect)((function(){u(n)}),[n]);return Object(h.jsx)(de,Object(g.a)(Object(g.a)({value:l,onInput:function(e){var t=e.target.value;c?(t=t.replace(/[^0-9.]/g,"").replace(/(\..*?)\..*/g,"$1"),null===i||void 0===i||i(t)):(t=t.replace(/\D/g,""),null===i||void 0===i||i(t)),u(t)},className:"number-input"},r),{},{ref:t}))}));je.defaultProps={allowFloat:!1};var pe=je,he=n(29),fe=function(e){var t=e.content,n=e.children;return Object(h.jsx)(he.d,{children:Object(h.jsxs)(he.c,{children:[Object(h.jsx)(he.e,{className:"tooltip-trigger",children:n}),Object(h.jsxs)(he.b,{className:"tooltip-content",children:[t,Object(h.jsx)(he.a,{className:"tooltip-arrow"})]})]})})};function Oe(e){var t=e.title,n=e.titleSuffix,a=e.desc,c=e.input,i=e.optionDesc,r=e.className,o="h"===e.layout?"setting-block-content":"setting-block-content-v";return Object(h.jsxs)("div",{className:"setting-block ".concat(r),children:[Object(h.jsxs)("div",{className:o,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)(fe,{content:Object(h.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(h.jsx)("span",{children:t})}):Object(h.jsx)("span",{children:t}),n]})}),c]}),i&&Object(h.jsx)("div",{className:"option-desc",children:i})]})}Oe.defaultProps={layout:"h"};var ge=Oe;function ve(e){var t=e.title,n=e.allowFloat,c=e.desc,i=e.value,r=e.suffix,o=e.onValue,s=e.width,l=e.widthUnit,u=e.disable,d=Object(a.useRef)(null);return Object(se.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(h.jsx)(ge,{className:"sub-setting-block",title:t,desc:c,input:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(h.jsx)(pe,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:i,disabled:u,onValue:o,ref:d}),r&&Object(h.jsx)("span",{children:r})]})})}ve.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var me,xe,ye=ve;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(me||(me={})),function(e){e.ddim="ddim",e.plms="plms"}(xe||(xe={}));var we,Se,ke=function(){var e=Object(o.d)(Qe),t=Object(d.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 c=function(e){a({hdStrategy:e})},i=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyResizeLimit:t})},r=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropTrigerSize:t})},s=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropMargin:t})},l=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 c(me.RESIZE)},children:"Resize"})," or ",Object(h.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(me.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(h.jsx)(ge,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(h.jsx)(ae,{width:80,value:n.hdStrategy,options:Object.values(me),onChange:function(e){return c(e)}}),optionDesc:function(){switch(n.hdStrategy){case me.ORIGINAL:return l();case me.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)(ye,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:r}),Object(h.jsx)(ye,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:s})]});case me.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)(ye,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:i})]});default:return l()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm",e.ZITS="zits",e.MAT="mat",e.FCF="fcf",e.SD15="sd1.5",e.SD2="sd2",e.CV2="cv2",e.Mange="manga",e.PAINT_BY_EXAMPLE="paint_by_example"}(Se||(Se={}));var Ce,Me=Object(o.b)({key:"maskState",default:void 0}),Ee=Object(o.b)({key:"paintByExampleImageState",default:void 0}),Ie=Object(o.b)({key:"appState",default:{file:void 0,disableShortCuts:!1,isInpainting:!1,isDisableModelSwitch:!1,isInteractiveSeg:!1,isInteractiveSegRunning:!1,interactiveSegClicks:[]}}),Le=Object(o.b)({key:"promptState",default:""}),Ne=Object(o.b)({key:"negativePromptState",default:""}),Te=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(Ie).isInpainting},set:function(e,t){var n=e.get,a=e.set,c=n(Ie);a(Ie,Object(g.a)(Object(g.a)({},c),{},{isInpainting:t}))}}),Pe=Object(o.c)({key:"fileState",get:function(e){return(0,e.get)(Ie).file},set:function(e,t){var n=e.get,a=e.set,c=n(Ie);a(Ie,Object(g.a)(Object(g.a)({},c),{},{file:t,interactiveSegClicks:[],isInteractiveSeg:!1,isInteractiveSegRunning:!1}))}}),ze=Object(o.c)({key:"isInteractiveSegState",get:function(e){return(0,e.get)(Ie).isInteractiveSeg},set:function(e,t){var n=e.get,a=e.set,c=n(Ie);a(Ie,Object(g.a)(Object(g.a)({},c),{},{isInteractiveSeg:t}))}}),Re=Object(o.c)({key:"isInteractiveSegRunningState",get:function(e){return(0,e.get)(Ie).isInteractiveSegRunning},set:function(e,t){var n=e.get,a=e.set,c=n(Ie);a(Ie,Object(g.a)(Object(g.a)({},c),{},{isInteractiveSegRunning:t}))}}),De=Object(o.c)({key:"interactiveSegClicksState",get:function(e){return(0,e.get)(Ie).interactiveSegClicks},set:function(e,t){var n=e.get,a=e.set,c=n(Ie);a(Ie,Object(g.a)(Object(g.a)({},c),{},{interactiveSegClicks:t}))}}),Fe=Object(o.c)({key:"isDisableModelSwitchState",get:function(e){return(0,e.get)(Ie).isDisableModelSwitch},set:function(e,t){var n=e.get,a=e.set,c=n(Ie);a(Ie,Object(g.a)(Object(g.a)({},c),{},{isDisableModelSwitch:t}))}}),Be=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),Ae=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(Be).x},set:function(e,t){var n=e.get,a=e.set,c=n(Be);a(Be,Object(g.a)(Object(g.a)({},c),{},{x:t}))}}),He=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(Be).y},set:function(e,t){var n=e.get,a=e.set,c=n(Be);a(Be,Object(g.a)(Object(g.a)({},c),{},{y:t}))}}),Ze=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(Be).height},set:function(e,t){var n=e.get,a=e.set,c=n(Be);a(Be,Object(g.a)(Object(g.a)({},c),{},{height:t}))}}),Ve=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(Be).width},set:function(e,t){var n=e.get,a=e.set,c=n(Be);a(Be,Object(g.a)(Object(g.a)({},c),{},{width:t}))}}),_e=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),We=Object(o.b)({key:"shortcutsState",default:!1});!function(e){e.INPAINT_NS="INPAINT_NS",e.INPAINT_TELEA="INPAINT_TELEA"}(Ce||(Ce={}));var Ye,Ge,Ue=(we={},Object(E.a)(we,Se.LAMA,{hdStrategy:me.CROP,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:1280,hdStrategyCropMargin:196,enabled:!0}),Object(E.a)(we,Se.LDM,{hdStrategy:me.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(E.a)(we,Se.ZITS,{hdStrategy:me.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(E.a)(we,Se.MAT,{hdStrategy:me.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(E.a)(we,Se.FCF,{hdStrategy:me.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(E.a)(we,Se.SD15,{hdStrategy:me.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(E.a)(we,Se.SD2,{hdStrategy:me.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(E.a)(we,Se.PAINT_BY_EXAMPLE,{hdStrategy:me.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(E.a)(we,Se.Mange,{hdStrategy:me.CROP,hdStrategyResizeLimit:1280,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:196,enabled:!0}),Object(E.a)(we,Se.CV2,{hdStrategy:me.RESIZE,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),we);!function(e){e.ddim="ddim",e.pndm="pndm",e.klms="k_lms",e.kEuler="k_euler",e.kEulerA="k_euler_a",e.dpmPlusPlus="dpm++"}(Ye||(Ye={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(Ge||(Ge={}));var Xe,Ke={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:Se.LAMA,hdSettings:Ue,ldmSteps:25,ldmSampler:xe.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:Ge.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:Ye.pndm,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1,sdMatchHistograms:!1,cv2Radius:5,cv2Flag:Ce.INPAINT_NS,paintByExampleSteps:50,paintByExampleGuidanceScale:7.5,paintByExampleSeed:42,paintByExampleMaskBlur:5,paintByExampleSeedFixed:!1,paintByExampleMatchHistograms:!1},Je="settingsState4",qe=Object(o.b)({key:Je,default:Ke,effects:[(Xe=Je,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(Xe);if(null!=a){var c=JSON.parse(a);c.show=!1,t(oe.a.merge(oe.a.cloneDeep(Ke),c))}n((function(e,t,n){return n?localStorage.removeItem(Xe):localStorage.setItem(Xe,JSON.stringify(e))}))})]}),$e=Object(o.c)({key:"seed",get:function(e){var t=(0,e.get)(qe);return t.model===Se.PAINT_BY_EXAMPLE?t.paintByExampleSeedFixed?t.paintByExampleSeed:-1:t.sdSeedFixed?t.sdSeed:-1},set:function(e,t){var n=e.get,a=e.set,c=n(qe);if(c.model===Se.PAINT_BY_EXAMPLE)c.paintByExampleSeedFixed||a(qe,Object(g.a)(Object(g.a)({},c),{},{paintByExampleSeed:t}));else c.sdSeedFixed||a(qe,Object(g.a)(Object(g.a)({},c),{},{sdSeed:t}))}}),Qe=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(qe);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,c=n(qe),i=c.hdSettings[c.model],r=Object(g.a)(Object(g.a)({},i),t);a(qe,Object(g.a)(Object(g.a)({},c),{},{hdSettings:Object(g.a)(Object(g.a)({},c.hdSettings),{},Object(E.a)({},c.model,r))}))}}),et=Object(o.c)({key:"isSD",get:function(e){var t=(0,e.get)(qe);return t.model===Se.SD15||t.model===Se.SD2}}),tt=Object(o.c)({key:"isPaintByExampleState",get:function(e){return(0,e.get)(qe).model===Se.PAINT_BY_EXAMPLE}}),nt=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(qe),a=t(et),c=t(tt);return n.runInpaintingManually||a||c}}),at=n(58),ct=function(e,t,n,a){var c=Object(o.e)(Ie);return Object(at.a)(e,t,Object(g.a)(Object(g.a)({},n),{},{enabled:!c.disableShortCuts}),a)},it={capture:!0,passive:!1},rt=function(e,t,n,a,c,i){if(e!==n&&t===a){if(e<0)return[0,a];if(e+t>i)return[i-a,a]}else{if(t<c)return e===n?[e,c]:[e+t-c,c];if(e<0)return[0,e+t];if(e+t>i)return[e,i-e]}return[e,t]},ot=function(e){var t=e.minHeight,n=e.minWidth,c=e.maxHeight,i=e.maxWidth,r=e.scale,s=e.show,l=Object(o.d)(Ae),u=Object(d.a)(l,2),b=u[0],j=u[1],p=Object(o.d)(He),f=Object(d.a)(p,2),O=f[0],g=f[1],v=Object(o.d)(Ze),m=Object(d.a)(v,2),x=m[0],y=m[1],w=Object(o.d)(Ve),S=Object(d.a)(w,2),k=S[0],C=S[1],M=Object(o.e)(Te),E=Object(a.useState)(!1),I=Object(d.a)(E,2),L=I[0],N=I[1],T=Object(a.useState)(!1),P=Object(d.a)(T,2),z=P[0],R=P[1];Object(a.useEffect)((function(){j(Math.round((i-512)/2)),g(Math.round((c-512)/2))}),[c,i]);var D=Object(a.useState)({initX:0,initY:0,initHeight:0,initWidth:0,startResizeX:0,startResizeY:0,ord:"top"}),F=Object(d.a)(D,2),B=F[0],A=F[1],H=function(){console.log("focus")},Z=function(e,t){return rt(e,t,b,k,n,i)},V=function(e,n){return rt(e,n,O,x,t,c)},_=function(e){if(!M){var t=e.clientX,n=e.clientY,a=Math.round((n-B.startResizeY)/r),c=Math.round((t-B.startResizeX)/r),i=function(){var e=B.initHeight-a,t=B.initY+a,n=V(t,e),c=Object(d.a)(n,2),i=c[0],r=c[1];y(r),g(i)},o=function(){var e=B.initHeight+a,t=V(B.initY,e),n=Object(d.a)(t,2),c=n[0],i=n[1];y(i),g(c)},s=function(){var e=B.initWidth-c,t=B.initX+c,n=Z(t,e),a=Object(d.a)(n,2),i=a[0],r=a[1];C(r),j(i)},l=function(){var e=B.initWidth+c,t=Z(B.initX,e),n=Object(d.a)(t,2),a=n[0],i=n[1];C(i),j(a)};if(L)switch(B.ord){case"topleft":i(),s();break;case"topright":i(),l();break;case"bottomleft":o(),s();break;case"bottomright":o(),l();break;case"top":i();break;case"right":l();break;case"bottom":o();break;case"left":s()}if(z){var u=B.initX+c,b=B.initY+a,p=Z(u,B.initWidth),h=Object(d.a)(p,2),f=h[0],O=h[1],v=V(b,B.initHeight),m=Object(d.a)(v,2),x=m[0],w=m[1];C(O),y(w),j(f),g(x)}}},W=function(e){L&&N(!1),z&&R(!1)};Object(a.useEffect)((function(){if(L||z)return document.addEventListener("pointermove",_,it),document.addEventListener("pointerup",W,it),document.addEventListener("pointercancel",W,it),function(){document.removeEventListener("pointermove",_,it),document.removeEventListener("pointerup",W,it),document.removeEventListener("pointercancel",W,it)}}),[L,z,k,x,B]);var Y=function(e){var t=e.target.dataset.ord;t&&(N(!0),A({initX:b,initY:O,initHeight:x,initWidth:k,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},G=function(e){R(!0),A({initX:b,initY:O,initHeight:x,initWidth:k,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(h.jsx)("div",{className:"croper-wrapper",style:{visibility:s?"visible":"hidden"},children:Object(h.jsxs)("div",{className:"croper",style:{height:x,width:k,left:b,top:O},children:[Object(h.jsx)("div",{className:"crop-border",style:{height:x,width:k,outlineWidth:"".concat(2/r,"px")}}),Object(h.jsx)("div",{className:"info-bar",onPointerDown:G,style:{transform:"scale(".concat(1/r,")"),top:"".concat(10/r,"px"),left:"".concat(10/r,"px")},children:Object(h.jsxs)("div",{className:"crop-size",children:[k," x ",x]})}),Object(h.jsxs)("div",{className:"drag-elements",onFocus:H,onPointerDown:Y,children:[Object(h.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/r,")")}})]})]})})},st=n(56),lt="prompt",ut="custom_mask",dt="paint_by_example",bt=Object(st.a)(),jt=function(){var e=Object(a.useState)(window.innerWidth),t=Object(d.a)(e,2),n=t[0],c=t[1],i=Object(a.useCallback)((function(){c(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",i),function(){window.removeEventListener("resize",i)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function pt(e){var t=e.onSelection,n=Object(a.useState)(!1),c=Object(d.a)(n,2),i=c[0],r=c[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),s=Object(d.a)(o,1)[0],b=jt();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 p(e){return f.apply(this,arguments)}function f(){return(f=Object(u.a)(l.a.mark((function e(t){return l.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 g.apply(this,arguments)}function g(){return(g=Object(u.a)(l.a.mark((function e(t){var n,a,c,i,r;return l.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===(i=a.shift())||void 0===i?void 0:i.isFile)){e.next=12;break}return e.next=8,p(i);case 8:r=e.sent,n.push(r),e.next=21;break;case 12:if(!(null===i||void 0===i?void 0:i.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=v.a,e.next=18,m(i.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(u.a)(l.a.mark((function e(t){var n,a;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,y(t);case 3:a=e.sent;case 4:if(!(a.length>0)){e.next=11;break}return n.push.apply(n,Object(v.a)(a)),e.next=8,y(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 y(e){return w.apply(this,arguments)}function w(){return(w=Object(u.a)(l.a.mark((function e(t){return l.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(u.a)(l.a.mark((function e(t){var n;return l.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,r(!1),j(n[0]);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return Object(h.jsx)("label",{htmlFor:s,className:"file-select-label",children:Object(h.jsxs)("div",{className:["file-select-container",i?"file-select-label-hover":""].join(" "),onDrop:function(e){return S.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),r(!0)},onDragLeave:function(){return r(!1)},children:[Object(h.jsx)("input",{id:s,name:s,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"===b?"Click here or drag an image file":"Tap here to load your picture"})]})})}var ht=function(e){var t=e.x,n=e.y,a=e.positive?"click-item-positive":"click-item-negative";return Object(h.jsx)("div",{className:"click-item ".concat(a),style:{left:t,top:n}})},ft=function(){var e=Object(o.e)(De);return Object(h.jsx)("div",{className:"interactive-seg-wrapper",children:e.map((function(e){return Object(h.jsx)(ht,{x:e[0],y:e[1],positive:1===e[2]},e[3])}))})},Ot=function(e){var t=e.onCancelClick,n=e.onAcceptClick,a=Object(o.d)(ze),c=Object(d.a)(a,2),i=c[0],r=c[1],s=Object(o.d)(Re),l=Object(d.a)(s,2),u=(l[0],l[1]),b=Object(o.d)(De),j=Object(d.a)(b,2),p=(j[0],j[1]),f=function(){r(!1),u(!1),p([])};return Object(h.jsx)("div",{className:"interactive-seg-confirm-actions",style:{visibility:i?"visible":"hidden"},children:Object(h.jsxs)("div",{className:"action-buttons",children:[Object(h.jsx)(J,{onClick:function(){f(),t()},children:"Cancel"}),Object(h.jsx)(J,{border:!0,onClick:function(){f(),n()},children:"Accept"})]})})},gt=n(85),vt=n(28),mt=c.a.forwardRef((function(e,t){var n=e.show,a=e.children,c=e.onClose,i=e.className,r=e.title,s=e.showCloseIcon,l=Object(o.d)(Ie),u=Object(d.a)(l,2),b=(u[0],u[1]);return Object(h.jsx)(vt.d,{open:n,onOpenChange:function(e){e||(null===c||void 0===c||c(),b((function(e){return Object(g.a)(Object(g.a)({},e),{},{disableShortCuts:!1})})))},children:Object(h.jsxs)(vt.c,{children:[Object(h.jsx)(vt.b,{className:"modal-mask"}),Object(h.jsxs)(vt.a,{ref:t,className:"modal ".concat(i),children:[Object(h.jsxs)("div",{className:"modal-header",children:[Object(h.jsx)(vt.e,{children:r}),s?Object(h.jsx)(J,{icon:Object(h.jsx)(gt.a,{}),onClick:c}):Object(h.jsx)(h.Fragment,{})]}),a]})]})})}));mt.defaultProps={showCloseIcon:!0};var xt=mt,yt=function(e){var t=e.show,n=e.onClose,a=e.onCleanClick,c=e.onReplaceClick;return Object(h.jsxs)(xt,{onClose:n,title:"Mask exists",className:"modal-setting",show:t,showCloseIcon:!0,children:[Object(h.jsx)("h4",{style:{lineHeight:"24px"},children:"Do you want to remove it or create a new one?"}),Object(h.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"flex-end",alignItems:"center",gap:"12px"},children:[Object(h.jsx)(J,{onClick:function(){n(),a()},children:"Remove"}),Object(h.jsx)(J,{onClick:c,border:!0,children:"Create a new one"})]})]})},wt="#ffcc00bb";function St(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wt;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 kt(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function Ct(){var e=Object(o.d)(Pe),t=Object(d.a)(e,2),n=t[0],c=t[1],i=Object(o.e)(Le),r=Object(o.e)(Ne),s=Object(o.e)(qe),b=Object(o.d)($e),j=Object(d.a)(b,2),p=j[0],f=j[1],O=Object(o.e)(Be),g=Object(o.d)(_e),E=Object(d.a)(g,2),I=(E[0],E[1]),T=Object(o.d)(Te),F=Object(d.a)(T,2),B=F[0],A=F[1],Z=Object(o.e)(nt),V=Object(o.e)(et),W=Object(o.e)(tt),Y=Object(o.d)(ze),G=Object(d.a)(Y,2),X=G[0],K=G[1],$=Object(o.d)(Re),Q=Object(d.a)($,2),ee=Q[0],te=Q[1],ne=Object(a.useState)(!1),ae=Object(d.a)(ne,2),ce=ae[0],re=ae[1],oe=Object(a.useState)(null),se=Object(d.a)(oe,2),le=se[0],ue=se[1],de=Object(a.useState)(null),be=Object(d.a)(de,2),je=be[0],pe=be[1],he=Object(a.useState)(null),fe=Object(d.a)(he,2),Oe=fe[0],ge=fe[1],ve=Object(o.d)(De),me=Object(d.a)(ve,2),xe=me[0],ye=me[1],we=Object(a.useState)(40),Se=Object(d.a)(we,2),ke=Se[0],Ce=Se[1],Me=N(n),Ee=Object(d.a)(Me,2),Ie=Ee[0],Fe=Ee[1],Ae=Object(a.useState)([]),He=Object(d.a)(Ae,2),Ze=He[0],Ve=He[1],We=Object(a.useState)(),Ye=Object(d.a)(We,2),Ge=Ye[0],Ue=Ye[1],Xe=Object(a.useState)((function(){return document.createElement("canvas")})),Ke=Object(d.a)(Xe,1)[0],Je=Object(a.useState)([]),Qe=Object(d.a)(Je,2),at=Qe[0],it=Qe[1],rt=Object(a.useState)([]),st=Object(d.a)(rt,2),jt=st[0],ht=st[1],gt=Object(a.useState)([]),vt=Object(d.a)(gt,2),mt=vt[0],xt=vt[1],wt=Object(a.useState)({x:-1,y:-1}),Ct=Object(d.a)(wt,2),Mt=Ct[0],Et=Mt.x,It=Mt.y,Lt=Ct[1],Nt=Object(a.useState)(!1),Tt=Object(d.a)(Nt,2),Pt=Tt[0],zt=Tt[1],Rt=Object(a.useState)(!1),Dt=Object(d.a)(Rt,2),Ft=Dt[0],Bt=Dt[1],At=Object(a.useState)(!1),Ht=Object(d.a)(At,2),Zt=Ht[0],Vt=Ht[1],_t=Object(a.useState)(!1),Wt=Object(d.a)(_t,2),Yt=Wt[0],Gt=Wt[1],Ut=Object(a.useState)({x:-1,y:-1,brushSize:20}),Xt=Object(d.a)(Ut,2),Kt=Xt[0],Jt=Xt[1],qt=Object(a.useState)(!1),$t=Object(d.a)(qt,2),Qt=$t[0],en=$t[1],tn=Object(a.useState)(1),nn=Object(d.a)(tn,2),an=nn[0],cn=nn[1],rn=Object(a.useState)(!1),on=Object(d.a)(rn,2),sn=on[0],ln=on[1],un=Object(a.useState)(1),dn=Object(d.a)(un,2),bn=dn[0],jn=dn[1],pn=Object(a.useState)(1080),hn=Object(d.a)(pn,2),fn=hn[0],On=hn[1],gn=Object(k.a)(),vn=gn.width/2,mn=gn.height/2,xn=Object(a.useRef)(),yn=Object(a.useState)(!1),wn=Object(d.a)(yn,2),Sn=wn[0],kn=wn[1],Cn=Object(a.useState)(!1),Mn=Object(d.a)(Cn,2),En=Mn[0],In=Mn[1],Ln=Object(a.useState)(!1),Nn=Object(d.a)(Ln,2),Tn=Nn[0],Pn=Nn[1],zn=Object(a.useState)(0),Rn=Object(d.a)(zn,2),Dn=Rn[0],Fn=Rn[1],Bn=Object(a.useState)([]),An=Object(d.a)(Bn,2),Hn=An[0],Zn=An[1],Vn=Object(a.useState)([]),_n=Object(d.a)(Vn,2),Wn=_n[0],Yn=_n[1],Gn=Object(a.useState)([]),Un=Object(d.a)(Gn,2),Xn=Un[0],Kn=Un[1],Jn=Object(a.useCallback)((function(e,t){Ge&&(Ge.clearRect(0,0,Ge.canvas.width,Ge.canvas.height),Ge.drawImage(e,0,0,Ie.naturalWidth,Ie.naturalHeight),X&&null!==je&&Ge.drawImage(je,0,0,Ie.naturalWidth,Ie.naturalHeight),X||null===le||Ge.drawImage(le,0,0,Ie.naturalWidth,Ie.naturalHeight),St(Ge,t))}),[Ge,Ie,X,je,le]),qn=Object(a.useCallback)((function(e,t){if(!(null===Ge||void 0===Ge?void 0:Ge.canvas.width)||!(null===Ge||void 0===Ge?void 0:Ge.canvas.height))throw new Error("canvas has invalid size");Ke.width=null===Ge||void 0===Ge?void 0:Ge.canvas.width,Ke.height=null===Ge||void 0===Ge?void 0:Ge.canvas.height;var n=Ke.getContext("2d");if(!n)throw new Error("could not retrieve mask canvas");void 0!==t&&null!==t&&n.drawImage(t,0,0,Ie.naturalWidth,Ie.naturalHeight),e.forEach((function(e){St(n,e,"white")}))}),[Ge,Ke]),$n=Object(a.useCallback)((function(){return 0!==mt.length}),[mt]),Qn=Object(a.useCallback)((function(e){0===Ze.length?Jn(Ie,e):Jn(Ze[Ze.length-1],e)}),[Ie,Ze,Jn]),ea=Object(a.useCallback)(function(){var e=Object(u.a)(l.a.mark((function e(t,a,c,o){var u,d,b,j,h,g,m,x,y,w,S,k,C,M;return l.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(u=void 0!==a&&null!==a,d=void 0!==c&&null!==c,console.log("runInpainting"),console.log({useCustomMask:u,useMaskImage:d}),b=[],!0!==t){e.next=13;break}if(0!==jt.length){e.next=10;break}return e.abrupt("return");case 10:b=jt,e.next=18;break;case 13:if(u){e.next=18;break}if($n()||d){e.next=16;break}return e.abrupt("return");case 16:ht(mt),b=mt;case 18:if(j=[].concat(Object(v.a)(at),[b]),xt([]),In(!1),A(!0),s.graduallyInpainting?qn([b],c):qn(j),h=n,!0!==s.graduallyInpainting){e.next=39;break}if(!0!==t){e.next=33;break}if(!(Ze.length>1)){e.next=31;break}return g=Ze[Ze.length-2],e.next=30,R(g.currentSrc,n.name,n.type);case 30:h=e.sent;case 31:e.next=39;break;case 33:if(!(Ze.length>0)){e.next=39;break}return console.info("gradually inpainting on last result"),m=Ze[Ze.length-1],e.next=38,R(m.currentSrc,n.name,n.type);case 38:h=e.sent;case 39:return e.prev=39,e.next=42,_(h,s,O,i,r,fn.toString(),p,u?void 0:Ke.toDataURL(),u?a:void 0,o);case 42:if(x=e.sent){e.next=45;break}throw new Error("Something went wrong on server side.");case 45:return y=x.blob,(w=x.seed)&&f(parseInt(w,10)),S=new Image,e.next=50,L(S,y);case 50:!0===t?(k=Ze.slice(0,-1),C=[].concat(Object(v.a)(k),[S]),Ve(C)):(M=[].concat(Object(v.a)(Ze),[S]),Ve(M)),Jn(S,[]),it(j),ca(),e.next=60;break;case 56:e.prev=56,e.t0=e.catch(39),I({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),Qn([]);case 60:A(!1),ge(c),pe(null),ue(null);case 64:case"end":return e.stop()}}),e,null,[[39,56]])})));return function(t,n,a,c){return e.apply(this,arguments)}}(),[at,mt,Ke,s.graduallyInpainting,s,O,fn,i,r,Qn,$n,qn,p]);Object(a.useEffect)((function(){return bt.on(lt,(function(){$n()||le?ea(!1,void 0,le):0!==jt.length?ea(!0,void 0,Oe):Oe?ea(!1,void 0,Oe):I({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){bt.off(lt)}}),[$n,ea,i,le,Oe]),Object(a.useEffect)((function(){return bt.on(ut,(function(e){ea(!1,e.mask)})),function(){bt.off(ut)}}),[ea]),Object(a.useEffect)((function(){return bt.on(dt,(function(e){$n()||le?ea(!1,void 0,le,e.image):0!==jt.length?ea(!0,void 0,Oe,e.image):Oe?ea(!1,void 0,Oe,e.image):I({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){bt.off(dt)}}),[ea]);var ta=function(){return 0!==Ze.length},na=function(e){return"Control"===e.key||"Meta"===e.key};Object(C.a)(na,(function(){Tn&&(B||(Pn(!1),Z||ea()))}),{event:"keyup"},[B,Tn,$n]),Object(C.a)(na,(function(){B||Pn(!0)}),{event:"keydown"},[B]),Object(a.useEffect)((function(){if(Fe){var e=gn.width/Ie.naturalWidth,t=(gn.height-200)/Ie.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),jn(n),cn(n),(null===Ge||void 0===Ge?void 0:Ge.canvas)&&(Ge.canvas.width=Ie.naturalWidth,Ge.canvas.height=Ie.naturalHeight,Qn([])),!Sn){var a;null===(a=xn.current)||void 0===a||a.centerView(n,1),kn(!0);var c=Math.max(Ie.width,Ie.height);On(c)}}}),[null===Ge||void 0===Ge?void 0:Ge.canvas,xn,Ie,Fe,gn,Sn,Qn]);var aa=Object(a.useCallback)((function(){if(bn&&Ie&&gn){var e=xn.current;if(e){var t=(gn.width-Ie.width*bn)/2,n=(gn.height-Ie.height*bn)/2;e.setTransform(t,n,bn,200,"easeOutQuad"),e.state.scale=bn,cn(bn),ln(!1)}}}),[xn,gn,Ie,Ie.width,gn.height,bn]),ca=function(){Yn([]),Kn([]),Zn([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){aa()})),function(){window.removeEventListener("resize",(function(){aa()}))}}),[gn,aa]),Object(a.useEffect)((function(){return window.addEventListener("blur",(function(){Gt(!1)})),function(){window.removeEventListener("blur",(function(){Gt(!1)}))}}),[]);var ia=Object(a.useCallback)((function(){K(!1),te(!1),ye([]),pe(null)}),[]);Object(C.a)("Escape",(function(){B||(X?ia():En||Tn?(In(!1),xt([]),Qn([])):aa())}),{event:"keydown"},[En,B,Tn,X,ia,aa,Qn]);var ra=function(e){if(Yt){var t=Kt.x,n=Kt.brushSize+(Et-t);n<=200&&n>=10&&Ce(n)}else if(!X&&!Zt&&En&&0!==mt.length){var a=Object(v.a)(mt);a[a.length-1].pts.push(kt(e)),xt(a),Qn(a)}},oa=function(){var e=Object(u.a)(l.a.mark((function e(t){var a,c,i,r,o;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:if(te(!0),a=n,!(Ze.length>0)){e.next=9;break}return c=Ze[Ze.length-1],e.next=8,R(c.currentSrc,n.name,n.type);case 8:a=e.sent;case 9:return null,e.prev=10,e.next=13,U(a,null,t);case 13:if(i=e.sent){e.next=16;break}throw new Error("Something went wrong on server side.");case 16:r=i.blob,(o=new Image).onload=function(){pe(o)},o.src=r,e.next=25;break;case 22:e.prev=22,e.t0=e.catch(10),I({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3});case 25:te(!1);case 26:case"end":return e.stop()}}),e,null,[[10,22]])})));return function(t){return e.apply(this,arguments)}}(),sa=function(e){if(X){var t=kt(e),n=Object(v.a)(xe);P(e)?n.push([t.x,t.y,0,n.length]):n.push([t.x,t.y,1,n.length]),oa(n),ye(n)}},la=function(e){if(!X&&(!Yt&&!Zt&&Ie.src&&(null===Ge||void 0===Ge?void 0:Ge.canvas)&&!B&&!P(e)))if(z(e))Vt(!0);else if(!((V||W)&&s.showCroper&&(t=kt(e),t.x<O.x||t.y<O.y||t.x>O.x+O.width||t.y>O.y+O.height))){var t;In(!0);var n=[];(Tn||Z)&&(n=Object(v.a)(mt)),n.push({size:ke,pts:[kt(e)]}),xt(n),Qn(n)}},ua=Object(a.useCallback)((function(){if(0!==mt.length){ht([]);var e=mt.pop(),t=[].concat(Object(v.a)(Wn),[e]);Yn(t);var n=Object(v.a)(mt);xt(n),Qn(n)}}),[mt,Wn,Qn]),da=Object(a.useCallback)((function(){if(Ze.length){var e=at.pop();Kn([].concat(Object(v.a)(Xn),[e])),Yn([]),it(Object(v.a)(at)),xt([]),In(!1);var t=Ze.pop();Zn([].concat(Object(v.a)(Hn),[t]));var n=Object(v.a)(Ze);Ve(n),0===n.length?Jn(Ie,[]):Jn(n[n.length-1],[])}}),[Jn,Ze,Hn,Xn,at,Ie]),ba=function(){Z&&0!==mt.length?ua():da()};Object(C.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)}),ba,void 0,[ua,da,Z,mt]);var ja=Object(a.useCallback)((function(){if(0!==Wn.length){var e=Wn.pop();Yn(Object(v.a)(Wn));var t=[].concat(Object(v.a)(mt),[e]);xt(t),Qn(t)}}),[mt,Wn,Qn]),pa=Object(a.useCallback)((function(){if(0!==Hn.length){var e=Xn.pop();Kn(Object(v.a)(Xn)),it([].concat(Object(v.a)(at),[e])),xt([]),In(!1);var t=Hn.pop(),n=[].concat(Object(v.a)(Ze),[t]);Ve(n),Jn(n[n.length-1],[])}}),[Jn,Ze,Hn,Xn,at,Ie]),ha=function(){Z&&0!==Wn.length?ja():pa()};Object(C.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)}),ha,void 0,[ja,pa,Z,Wn]);Object(M.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ta()&&en((function(){return window.setTimeout((function(){Fn(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ta()&&(Fn(0),window.setTimeout((function(){en(!1)}),350))}));var fa=function(e){e===Pt||Zt||zt(e)},Oa=Object(a.useCallback)((function(){return Zt?"grab":Pt?"none":void 0}),[Pt,Zt]);ct("i",(function(){!X&&Fe&&(K(!0),null!==le&&re(!0))}),{},[X,le,Fe]),ct("[",(function(){Ce((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),ct("]",(function(){Ce((function(e){return e+10}))})),ct("shift+r",(function(){Z&&$n()&&ea()}),{},[Z,ea,$n]),ct("ctrl+c, cmd+c",Object(u.a)(l.a.mark((function e(){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D();case 2:if(!(e.sent&&Ze.length>0)){e.next=8;break}if(!(null===Ge||void 0===Ge?void 0:Ge.canvas)){e.next=8;break}return e.next=7,H(null===Ge||void 0===Ge?void 0:Ge.canvas);case 7:I({open:!0,desc:"Copy inpainting result to clipboard",state:"success",duration:3e3});case 8:case"end":return e.stop()}}),e)}))),{},[Ze,Ge]),Object(M.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),zt(!1),Vt(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),zt(!0),Vt(!1)})),Object(M.a)("Alt",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Gt(!0),Jt({x:Et,y:It,brushSize:ke})}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Gt(!1)}));var ga=function(e,t){var n=function(){var e,t,n=bn;return void 0!==(null===(e=xn.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=xn.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(ke*n,"px"),height:"".concat(ke*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;Lt({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(z(e)&&Vt(!1),X)||(Zt||Ie.src&&(null===Ge||void 0===Ge?void 0:Ge.canvas)&&(B||En&&(Tn||Z?In(!1):ea())))},children:[Object(h.jsx)(Ot,{onAcceptClick:function(){ue(je),pe(null),!Z&&je&&ea(!1,void 0,je)},onCancelClick:ia}),void 0===n?Object(h.jsx)("div",{className:"landing-file-selector",children:Object(h.jsx)(pt,{onSelection:function(){var e=Object(u.a)(l.a.mark((function e(t){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c(t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})}):Object(h.jsx)(S.b,{ref:function(e){e&&(xn.current=e)},panning:{disabled:!Zt,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:bn,minScale:.6*bn,onPanning:function(e){sn||ln(!0)},onZoom:function(e){cn(e.state.scale)},children:Object(h.jsxs)(S.a,{contentClass:B||ee?"editor-canvas-loading":"",contentStyle:{visibility:Sn?"visible":"hidden"},children:[Object(h.jsxs)("div",{className:"editor-canvas-container",children:[Object(h.jsx)("canvas",{className:"editor-canvas",style:{cursor:Oa(),clipPath:"inset(0 ".concat(Dn,"% 0 0)"),transition:"clip-path 300ms cubic-bezier(0.4, 0, 0.2, 1)"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){fa(!0),Bt(!1)},onFocus:function(){return fa(!0)},onMouseLeave:function(){return fa(!1)},onMouseDown:la,onMouseUp:sa,onMouseMove:ra,ref:function(e){if(e&&!Ge){var t=e.getContext("2d");t&&Ue(t)}}}),Object(h.jsxs)("div",{className:"original-image-container",style:{width:"".concat(Ie.naturalWidth,"px"),height:"".concat(Ie.naturalHeight,"px")},children:[Qt&&Object(h.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(Dn,"%")}}),Object(h.jsx)("img",{className:"original-image",src:Ie.src,alt:"original",style:{width:"".concat(Ie.naturalWidth,"px"),height:"".concat(Ie.naturalHeight,"px")}})]})]}),Object(h.jsx)(ot,{maxHeight:Ie.naturalHeight,maxWidth:Ie.naturalWidth,minHeight:Math.min(256,Ie.naturalHeight),minWidth:Math.min(256,Ie.naturalWidth),scale:an,show:(V||W)&&s.showCroper}),X?Object(h.jsx)(ft,{}):Object(h.jsx)(h.Fragment,{})]})}),Pt&&!B&&!Zt&&(X?Object(h.jsx)("div",{className:"interactive-seg-cursor",style:{left:"".concat(Et,"px"),top:"".concat(It,"px")},children:Object(h.jsx)(m.a,{})}):Object(h.jsx)("div",{className:"brush-shape",style:ga(Yt?Kt.x:Et,Yt?Kt.y:It)})),Ft&&Object(h.jsx)("div",{className:"brush-shape",style:ga(vn,mn)}),Object(h.jsxs)("div",{className:"editor-toolkit-panel",children:[V||W||void 0===n?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(ie,{onChange:function(e){On(e)},originalWidth:Ie.naturalWidth,originalHeight:Ie.naturalHeight}),Object(h.jsx)(q,{label:"Brush",min:10,max:200,value:ke,onChange:function(e){Ce(e),Ft||(Bt(!0),window.setTimeout((function(){Bt(!1)}),1e4))},onClick:function(){return Bt(!1)}}),Object(h.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(h.jsx)(J,{toolTip:"Interactive Segmentation",tooltipPosition:"top",icon:Object(h.jsx)(m.a,{}),disabled:X||B||!Fe,onClick:function(){K(!0),null!==le&&re(!0)}}),Object(h.jsx)(J,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(h.jsx)(x.a,{}),disabled:an===bn&&!1===sn,onClick:aa}),Object(h.jsx)(J,{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:ba,disabled:function(){if(X)return!0;if(B)return!0;if(Ze.length>0)return!1;if(Z){if(0===mt.length)return!0}else if(0===Ze.length)return!0;return!1}()}),Object(h.jsx)(J,{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:ha,disabled:function(){if(X)return!0;if(B)return!0;if(Hn.length>0)return!1;if(Z){if(0===Wn.length)return!0}else if(0===Hn.length)return!0;return!1}()}),Object(h.jsx)(J,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(h.jsx)(y.a,{}),className:Qt?"eyeicon-active":"",onDown:function(e){e.preventDefault(),en((function(){return window.setTimeout((function(){Fn(100)}),10),!0}))},onUp:function(){Fn(0),window.setTimeout((function(){en(!1)}),300)},disabled:0===Ze.length}),Object(h.jsx)(J,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(h.jsx)(w.a,{}),disabled:!Ze.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)}(Ze[Ze.length-1].currentSrc,e),s.downloadMask){var t=n.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");t=t.replace(/\.[^/.]+$/,".jpg"),qn(at);var a=document.createElement("a");a.download=t,a.href=Ke.toDataURL("image/jpeg"),a.click()}}}}),s.runInpaintingManually&&!V&&!W&&Object(h.jsx)(J,{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:B||X||!$n()&&null===le,onClick:function(){ea(!1,void 0,le)}})]})]}),Object(h.jsx)(yt,{show:ce,onClose:function(){ia(),re(!1)},onCleanClick:function(){ia(),ue(null)},onReplaceClick:function(){re(!1),K(!0)}})]})}function Mt(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 Et=/macintosh|mac os x/i.test(navigator.userAgent),It=(/windows|win32/i.test(navigator.userAgent),Et?"Cmd":"Ctrl");function Lt(){var e=Object(o.d)(We),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(xt,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(h.jsxs)("div",{className:"shortcut-options",children:[Object(h.jsx)(Mt,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(It)]}),Object(h.jsx)(Mt,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(h.jsx)(Mt,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(h.jsx)(Mt,{content:"Interactive Segmentation",keys:["I"]}),Object(h.jsx)(Mt,{content:"Undo Inpainting",keys:[It,"Z"]}),Object(h.jsx)(Mt,{content:"Redo Inpainting",keys:[It,"Shift","Z"]}),Object(h.jsx)(Mt,{content:"View Original Image",keys:["Hold Tab"]}),Object(h.jsx)(Mt,{content:"Pan",keys:["Space + Drag"]}),Object(h.jsx)(Mt,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(h.jsx)(Mt,{content:"Decrease Brush Size",keys:["["]}),Object(h.jsx)(Mt,{content:"Increase Brush Size",keys:["]"]}),Object(h.jsx)(Mt,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(h.jsx)(Mt,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(h.jsx)(Mt,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var Nt=n(54),Tt=["className"],Pt=["className"],zt=c.a.forwardRef((function(e,t){var n=e.className,a=Object(le.a)(e,Tt);return Object(h.jsx)(Nt.a,Object(g.a)(Object(g.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(le.a)(e,Pt);return Object(h.jsx)(Nt.b,Object(g.a)(Object(g.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),Dt=function(){var e=Object(o.d)(qe),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(ge,{title:"Manual Inpainting Mode",input:Object(h.jsx)(zt,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{runInpaintingManually:e})}))},children:Object(h.jsx)(Rt,{})})})};var Ft=function(){var e=Object(o.d)(qe),t=Object(d.a)(e,2),n=t[0],a=t[1],c=Object(o.e)(Fe),i=function(e,t,n){return Object(h.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(h.jsx)(fe,{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"})})})})})},r=function(){return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(ye,{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(g.a)(Object(g.a)({},e),{},{ldmSteps:t})}))}}),Object(h.jsx)(ge,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(ae,{width:80,value:n.ldmSampler,options:Object.values(xe),onChange:function(e){return t=e,void a((function(e){return Object(g.a)(Object(g.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(h.jsx)(ge,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case Se.LAMA:return i(0,0,"https://github.com/saic-mdal/lama");case Se.LDM:return i(0,0,"https://github.com/CompVis/latent-diffusion");case Se.ZITS:return i(0,0,"https://github.com/DQiaole/ZITS_inpainting");case Se.MAT:return i(0,0,"https://github.com/fenglinglwb/MAT");case Se.FCF:return i(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case Se.SD15:return i(0,0,"https://github.com/CompVis/stable-diffusion");case Se.SD2:return i(0,0,"https://github.com/Stability-AI/stablediffusion");case Se.Mange:return i(0,0,"https://github.com/msxie92/MangaInpainting");case Se.CV2:return i(0,0,"https://docs.opencv.org/4.6.0/df/d3d/tutorial_py_inpainting.html");case Se.PAINT_BY_EXAMPLE:return i(0,0,"https://github.com/Fantasy-Studio/Paint-by-Example");default:return Object(h.jsx)(h.Fragment,{})}}(),input:Object(h.jsx)(ae,{value:n.model,options:Object.values(Se),onChange:function(e){return t=e,void a((function(e){return Object(g.a)(Object(g.a)({},e),{},{model:t})}));var t},disabled:c}),optionDesc:function(){switch(n.model){case Se.LAMA:return;case Se.LDM:return r();case Se.ZITS:return Object(h.jsx)("div",{children:Object(h.jsx)(ge,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(h.jsx)(zt,{checked:n.zitsWireframe,onCheckedChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{zitsWireframe:e})}))},children:Object(h.jsx)(Rt,{})})})});case Se.MAT:return;case Se.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 Se.SD15:case Se.SD2:case Se.PAINT_BY_EXAMPLE:case Se.Mange:return;case Se.CV2:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(ye,{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(g.a)(Object(g.a)({},e),{},{cv2Radius:t})}))}}),Object(h.jsx)(ge,{className:"sub-setting-block",title:"Flag",desc:"Inpainting method",input:Object(h.jsx)(ae,{width:140,value:n.cv2Flag,options:Object.values(Ce),onChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{cv2Flag:e})}))}})})]});default:return Object(h.jsx)(h.Fragment,{})}}()})},Bt=function(){var e=Object(o.d)(qe),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(ge,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(h.jsx)(zt,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{downloadMask:e})}))},children:Object(h.jsx)(Rt,{})})})};function At(e){var t=e.onClose,n=Object(o.d)(qe),a=Object(d.a)(n,2),c=a[0],i=a[1],r=Object(o.e)(et),s=Object(o.e)(tt);return ct("s",(function(){i((function(e){return Object(g.a)(Object(g.a)({},e),{},{show:!e.show})}))}),{},[]),Object(h.jsxs)(xt,{onClose:function(){i((function(e){return Object(g.a)(Object(g.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:c.show,children:[r||s?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(Dt,{}),Object(h.jsx)(Bt,{}),Object(h.jsx)(Ft,{}),r?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(ke,{})]})}var Ht=n(37),Zt=n(90),Vt=["state","desc"],_t=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"})]})})},Wt=a.forwardRef((function(e,t){var n=e.state,a=e.desc,c=Object(le.a)(e,Vt);return Object(h.jsxs)(Ht.b,{children:[Object(h.jsxs)(Ht.c,Object(g.a)(Object(g.a)({},c),{},{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)(Zt.a,{className:"error-icon"});case"success":return Object(h.jsx)(ee.a,{className:"success-icon"});case"loading":return Object(h.jsx)(_t,{});default:return Object(h.jsx)(h.Fragment,{})}}()}),Object(h.jsx)(Ht.a,{className:"toast-desc",children:a})]})),Object(h.jsx)(Ht.d,{className:"toast-viewpoint"})]})}));Wt.defaultProps={desc:"",state:"loading"};var Yt=Wt,Gt=n(18),Ut=n(91),Xt=["onFocus","onBlur"],Kt=c.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,c=Object(le.a)(e,Xt),i=Object(o.d)(Ie),r=Object(d.a)(i,2),s=(r[0],r[1]);return Object(h.jsx)("textarea",Object(g.a)(Object(g.a)({},c),{},{ref:t,onFocus:function(e){s((function(e){return Object(g.a)(Object(g.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){s((function(e){return Object(g.a)(Object(g.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()}}))})),Jt=function(){var e=Object(Ut.a)(!0),t=Object(d.a)(e,2),n=t[0],a=t[1],c=Object(o.d)(qe),i=Object(d.a)(c,2),r=i[0],s=i[1],l=Object(o.d)(Ne),u=Object(d.a)(l,2),b=u[0],j=u[1],p=Object(o.e)(Te),f=Object(o.e)(Le);return Object(h.jsx)("div",{className:"side-panel",children:Object(h.jsxs)(Gt.c,{open:n,children:[Object(h.jsx)(Gt.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Configurations"}),Object(h.jsx)(Gt.b,{children:Object(h.jsxs)(Gt.a,{className:"side-panel-content",children:[Object(h.jsx)(ge,{title:"Croper",input:Object(h.jsx)(zt,{checked:r.showCroper,onCheckedChange:function(e){s((function(t){return Object(g.a)(Object(g.a)({},t),{},{showCroper:e})}))},children:Object(h.jsx)(Rt,{})})}),Object(h.jsx)(ye,{title:"Steps",width:30,value:"".concat(r.sdSteps),desc:"The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);s((function(e){return Object(g.a)(Object(g.a)({},e),{},{sdSteps:t})}))}}),Object(h.jsx)(ye,{title:"Guidance Scale",width:30,allowFloat:!0,value:"".concat(r.sdGuidanceScale),desc:"Higher guidance scale encourages to generate images that are closely linked to the text prompt, usually at the expense of lower image quality.",onValue:function(e){var t=0===e.length?0:parseFloat(e);s((function(e){return Object(g.a)(Object(g.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(h.jsx)(ye,{title:"Mask Blur",width:30,value:"".concat(r.sdMaskBlur),desc:"Blur the edge of mask area. The higher the number the smoother blend with the original image",onValue:function(e){var t=0===e.length?0:parseInt(e,10);s((function(e){return Object(g.a)(Object(g.a)({},e),{},{sdMaskBlur:t})}))}}),Object(h.jsx)(ge,{title:"Match Histograms",desc:"Match the inpainting result histogram to the source image histogram, will improves the inpainting quality for some images.",input:Object(h.jsx)(zt,{checked:r.sdMatchHistograms,onCheckedChange:function(e){s((function(t){return Object(g.a)(Object(g.a)({},t),{},{sdMatchHistograms:e})}))},children:Object(h.jsx)(Rt,{})})}),Object(h.jsx)(ge,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(ae,{width:80,value:r.sdSampler,options:Object.values(Ye),onChange:function(e){var t=e;s((function(e){return Object(g.a)(Object(g.a)({},e),{},{sdSampler:t})}))}})}),Object(h.jsx)(ge,{title:"Seed",input:Object(h.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(h.jsx)(ye,{title:"",width:80,value:"".concat(r.sdSeed),desc:"",disable:!r.sdSeedFixed,onValue:function(e){var t=0===e.length?0:parseInt(e,10);s((function(e){return Object(g.a)(Object(g.a)({},e),{},{sdSeed:t})}))}}),Object(h.jsx)(zt,{checked:r.sdSeedFixed,onCheckedChange:function(e){s((function(t){return Object(g.a)(Object(g.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(h.jsx)(Rt,{})})]})}),Object(h.jsx)(ge,{className:"sub-setting-block",title:"Negative prompt",layout:"v",input:Object(h.jsx)(Kt,{className:"negative-prompt",value:b,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;j(t.value)},onKeyUp:function(e){"Enter"!==e.key||!e.ctrlKey&&!e.metaKey||0===f.length||p||bt.emit(lt)},placeholder:""})})]})})]})})},qt=n(46),$t=function(){var e=Object(Ut.a)(!0),t=Object(d.a)(e,2),n=t[0],c=t[1],i=Object(o.d)(qe),r=Object(d.a)(i,2),s=r[0],l=r[1],u=Object(o.d)(Ee),b=Object(d.a)(u,2),j=b[0],p=b[1],f=Object(a.useState)("example-file-upload-".concat(Math.random().toString())),O=Object(d.a)(f,1)[0],v=N(j),m=Object(d.a)(v,2),x=m[0],y=m[1],w=Object(o.e)(Te);return Object(h.jsx)("div",{className:"side-panel",children:Object(h.jsxs)(Gt.c,{open:n,children:[Object(h.jsx)(Gt.d,{className:"btn-primary side-panel-trigger",onClick:function(){return c()},children:"Configurations"}),Object(h.jsx)(Gt.b,{children:Object(h.jsxs)(Gt.a,{className:"side-panel-content",children:[Object(h.jsx)(ge,{title:"Croper",input:Object(h.jsx)(zt,{checked:s.showCroper,onCheckedChange:function(e){l((function(t){return Object(g.a)(Object(g.a)({},t),{},{showCroper:e})}))},children:Object(h.jsx)(Rt,{})})}),Object(h.jsx)(ye,{title:"Steps",width:30,value:"".concat(s.paintByExampleSteps),desc:"The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(g.a)(Object(g.a)({},e),{},{paintByExampleSteps:t})}))}}),Object(h.jsx)(ye,{title:"Guidance Scale",width:30,allowFloat:!0,value:"".concat(s.paintByExampleGuidanceScale),desc:"Higher guidance scale encourages to generate images that are close to the example image",onValue:function(e){var t=0===e.length?0:parseFloat(e);l((function(e){return Object(g.a)(Object(g.a)({},e),{},{paintByExampleGuidanceScale:t})}))}}),Object(h.jsx)(ye,{title:"Mask Blur",width:30,value:"".concat(s.paintByExampleMaskBlur),desc:"Blur the edge of mask area. The higher the number the smoother blend with the original image",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(g.a)(Object(g.a)({},e),{},{paintByExampleMaskBlur:t})}))}}),Object(h.jsx)(ge,{title:"Match Histograms",desc:"Match the inpainting result histogram to the source image histogram, will improves the inpainting quality for some images.",input:Object(h.jsx)(zt,{checked:s.paintByExampleMatchHistograms,onCheckedChange:function(e){l((function(t){return Object(g.a)(Object(g.a)({},t),{},{paintByExampleMatchHistograms:e})}))},children:Object(h.jsx)(Rt,{})})}),Object(h.jsx)(ge,{title:"Seed",input:Object(h.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(h.jsx)(ye,{title:"",width:80,value:"".concat(s.paintByExampleSeed),desc:"",disable:!s.paintByExampleSeedFixed,onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(g.a)(Object(g.a)({},e),{},{paintByExampleSeed:t})}))}}),Object(h.jsx)(zt,{checked:s.paintByExampleSeedFixed,onCheckedChange:function(e){l((function(t){return Object(g.a)(Object(g.a)({},t),{},{paintByExampleSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(h.jsx)(Rt,{})})]})}),Object(h.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[Object(h.jsx)(ge,{title:"Example Image",input:Object(h.jsx)("label",{htmlFor:O,children:Object(h.jsx)(J,{border:!0,toolTip:"Upload example image",tooltipPosition:"top",icon:Object(h.jsx)(qt.b,{}),style:{padding:"0.3rem",gap:0},children:Object(h.jsx)("input",{style:{display:"none"},id:O,name:O,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&p(n)},accept:"image/png, image/jpeg"})})})}),j?Object(h.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:Object(h.jsx)("img",{src:x.src,alt:"example",style:{maxWidth:200,maxHeight:200,margin:12}})}):Object(h.jsx)(h.Fragment,{})]}),Object(h.jsx)(J,{border:!0,disabled:!y||w,style:{width:"100%"},onClick:function(){y&&bt.emit(dt,{image:j})},children:"Paint"})]})})]})})},Qt=function(){var e=Object(o.d)(Pe),t=Object(d.a)(e,2),n=(t[0],t[1],Object(o.d)(qe)),c=Object(d.a)(n,2),i=c[0],r=c[1],s=Object(o.d)(_e),b=Object(d.a)(s,2),j=b[0],p=b[1],f=Object(o.e)(et),O=Object(o.e)(tt),v=function(){var e=Object(u.a)(l.a.mark((function e(){var t,n,a,c,o;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,G().then((function(e){return e.text()}));case 2:if((t=e.sent)!==i.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=i.model,fetch("".concat(V,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=i.model,c="Switching to ".concat(a," model"),o=3e3,"False"===n&&(c="Downloading ".concat(a," model, this may take a while"),o=9999999999),p({open:!0,desc:c,state:"loading",duration:o}),Y(a).then((function(e){if(!e.ok)throw new Error("Server error");p({open:!0,desc:"Switch to ".concat(a," model success"),state:"success",duration:3e3})})).catch((function(){p({open:!0,desc:"Switch to ".concat(a," model failed"),state:"error",duration:3e3}),r((function(e){return Object(g.a)(Object(g.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(){G().then((function(e){return e.text()})).then((function(e){r((function(t){return Object(g.a)(Object(g.a)({},t),{},{model:e})}))}))}),[r]),Object(h.jsxs)(h.Fragment,{children:[f?Object(h.jsx)(Jt,{}):Object(h.jsx)(h.Fragment,{}),O?Object(h.jsx)($t,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsx)(Ct,{}),Object(h.jsx)(At,{onClose:v}),Object(h.jsx)(Lt,{}),Object(h.jsx)(Yt,Object(g.a)(Object(g.a)({},j),{},{onOpenChange:function(e){p((function(t){return Object(g.a)(Object(g.a)({},t),{},{open:e})}))}}))]})},en=n(93),tn=function(){var e=Object(o.d)(We),t=Object(d.a)(e,2),n=t[0],a=t[1],c=function(){a((function(e){return!e}))};return ct("h",(function(){c()})),Object(h.jsx)("div",{className:"shortcuts",children:Object(h.jsx)(J,{onClick:c,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"})]})]})})})},nn=function(){var e=Object(o.d)(qe),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)("div",{children:Object(h.jsx)(J,{onClick:function(){a(Object(g.a)(Object(g.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"})]})})})},an=function(){var e=Object(o.d)(Ie),t=Object(d.a)(e,2),n=t[0],c=(t[1],Object(o.d)(Le)),i=Object(d.a)(c,2),r=i[0],s=i[1],l=Object(o.e)(Te),u=Object(a.useRef)(null),b=function(){0===r.length||n.isInpainting||bt.emit(lt)};Object(se.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)(de,{ref:u,value:r,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;s(t.value)},onKeyUp:function(e){"Enter"!==e.key||l||b()},placeholder:"I want to repaint of..."}),Object(h.jsx)(J,{border:!0,onClick:b,disabled:0===r.length||n.isInpainting,children:"Dream"})]})},cn=n(92),rn=function(){var e=Object(a.useState)(!1),t=Object(d.a)(e,2),n=t[0],c=t[1];return Object(h.jsxs)("div",{children:[Object(h.jsx)(J,{onClick:function(){c(!0)},toolTip:"Buy me a coffee",tooltipPosition:"bottom",style:{border:0},icon:Object(h.jsx)(cn.a,{})}),Object(h.jsxs)(xt,{onClose:function(){return c(!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)(J,{onClick:function(){return c(!1)},children:" No thanks "}),Object(h.jsx)("a",{href:"https://ko-fi.com/Z8Z1CZJGY",target:"_blank",rel:"noreferrer",children:Object(h.jsx)(J,{border:!0,onClick:function(){return c(!1)},children:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:["Sure",Object(h.jsx)(cn.a,{})]})})})]})]})]})},on=function(){var e=Object(o.e)(Te),t=Object(o.d)(Pe),n=Object(d.a)(t,2),c=n[0],i=n[1],r=Object(o.d)(Me),s=Object(d.a)(r,2),l=s[0],u=s[1],b=N(l),j=Object(d.a)(b,2),p=j[0],f=j[1],g=Object(a.useState)("file-upload-".concat(Math.random().toString())),v=Object(d.a)(g,1)[0],m=Object(a.useState)("mask-upload-".concat(Math.random().toString())),x=Object(d.a)(m,1)[0],y=Object(o.e)(et),w=Object(o.e)(nt),S=Object(a.useState)(!1),k=Object(d.a)(S,2),C=k[0],M=k[1];return Object(h.jsxs)("header",{children:[Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:8},children:[Object(h.jsx)("label",{htmlFor:v,children:Object(h.jsxs)(J,{icon:Object(h.jsx)(en.a,{}),style:{border:0},disabled:e,toolTip:"Upload image",tooltipPosition:"bottom",children:[Object(h.jsx)("input",{style:{display:"none"},id:v,name:v,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&i(n)},accept:"image/png, image/jpeg"}),"Image"]})}),Object(h.jsxs)("div",{style:{visibility:c?"visible":"hidden",display:"flex",justifyContent:"center",alignItems:"center"},children:[Object(h.jsx)("label",{htmlFor:x,children:Object(h.jsxs)(J,{style:{border:0},disabled:e,toolTip:"Upload custom mask",tooltipPosition:"bottom",children:[Object(h.jsx)("input",{style:{display:"none"},id:x,name:x,type:"file",onClick:function(e){e.target.value=""},onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&(u(n),console.info("Send custom mask"),w||bt.emit(ut,{mask:n}))},accept:"image/png, image/jpeg"}),"Mask"]})}),Object(h.jsxs)(Gt.c,{open:C,children:[Object(h.jsx)(Gt.d,{className:"btn-primary side-panel-trigger",onMouseEnter:function(){return M(!0)},onMouseLeave:function(){return M(!1)},style:{visibility:l?"visible":"hidden",outline:"none"},onClick:function(){l&&bt.emit(ut,{mask:l})},children:Object(h.jsx)(qt.a,{})}),Object(h.jsx)(Gt.b,{children:Object(h.jsx)(Gt.a,{style:{outline:"none"},children:f?Object(h.jsx)("img",{src:p.src,alt:"mask",className:"mask-preview"}):Object(h.jsx)(h.Fragment,{})})})]})]})]}),y&&c?Object(h.jsx)(an,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsxs)("div",{className:"header-icons-wrapper",children:[Object(h.jsx)(rn,{}),Object(h.jsx)(O,{}),Object(h.jsxs)("div",{className:"header-icons",children:[Object(h.jsx)(tn,{}),Object(h.jsx)(nn,{})]})]})]})},sn=["image/jpeg","image/png","image/webp","image/bmp","image/tiff"];var ln=function(){var e=Object(o.d)(Pe),t=Object(d.a)(e,2),n=t[0],i=t[1],r=Object(o.d)(f),s=Object(d.a)(r,2),j=s[0],p=s[1],O=Object(o.d)(_e),g=Object(d.a)(O,2),v=(g[0],g[1]),m=function(){var e=Object(a.useState)(),t=Object(d.a)(e,2),n=t[0],c=t[1],i=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(u.a)(l.a.mark((function e(t){var n,a,i,r;return l.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:(i=e.sent)&&i.type.startsWith("image")&&(r=new File([i],void 0!==a?a:"inputImage"),c(r));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[c]);return Object(a.useEffect)((function(){i()}),[i]),n}(),x=Object(o.d)(Fe),y=Object(d.a)(x,2),w=(y[0],y[1]);Object(a.useEffect)((function(){i(m)}),[m,i]),Object(a.useEffect)((function(){var e=function(){var e=Object(u.a)(l.a.mark((function e(){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(V,"/is_desktop"),{method:"GET"}).then((function(e){return e.text()}));case 2:"True"===e.sent&&T();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]),Object(a.useEffect)((function(){var e=function(){var e=Object(u.a)(l.a.mark((function e(){var t;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(V,"/is_disable_model_switch"),{method:"GET"}).then((function(e){return e.text()}));case 2:t=e.sent,w("true"===t);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]),ct("shift+d",(function(){p("light"===j?"dark":"light")}),{},[j]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",j)}),[j]);var S=Object(a.useMemo)((function(){return Object(b.a)()}),[n]),k=c.a.useState(!1),C=Object(d.a)(k,2),M=(C[0],C[1]),E=c.a.useRef(0),I=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation()}),[]),L=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),E.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&M(!0)}),[]),N=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),E.current-=1,E.current>0||M(!1)}),[]),P=c.a.useCallback((function(e){if(e.preventDefault(),e.stopPropagation(),M(!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;sn.includes(n)?i(t):v({open:!0,desc:"Please drag and drop an image file",state:"error",duration:3e3})}e.dataTransfer.clearData()}}),[]),z=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&&i(a)}}}),[]);return c.a.useEffect((function(){return window.addEventListener("dragenter",L),window.addEventListener("dragleave",N),window.addEventListener("dragover",I),window.addEventListener("drop",P),window.addEventListener("paste",z),function(){window.removeEventListener("dragenter",L),window.removeEventListener("dragleave",N),window.removeEventListener("dragover",I),window.removeEventListener("drop",P),window.removeEventListener("paste",z)}})),Object(h.jsxs)("div",{className:"lama-cleaner",children:[Object(h.jsx)(on,{}),Object(h.jsx)(Qt,{},S)]})};r.a.render(Object(h.jsx)(c.a.StrictMode,{children:Object(h.jsx)(o.a,{children:Object(h.jsx)(ln,{})})}),document.getElementById("root"))}},[[74,1,2]]]);