IOPaint/lama_cleaner/app/build/static/js/main.c06ba56c.chunk.js
blessedcoolant e3e151716c new build
2022-04-08 17:05:58 +12:00

1 line
24 KiB
JavaScript

(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{23:function(e,t,n){},26:function(e,t,n){"use strict";n.r(t);var a=n(0),c=n.n(a),i=n(12),r=n.n(i),s=(n(23),n(4)),o=n(2),l=n(29);var u=n(3),d=n.n(u),h=n(5),j=Object(s.b)({key:"fileState",default:void 0}),b=Object(s.b)({key:"shortcutsState",default:!1}),v=n(6),f=function(){var e=Object(a.useState)(window.innerWidth),t=Object(o.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},p=n(1);function O(e){var t=e.onSelection,n=Object(a.useState)(!1),c=Object(o.a)(n,2),i=c[0],r=c[1],s=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(o.a)(s,1)[0],u=f();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 b(e){return O.apply(this,arguments)}function O(){return(O=Object(h.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 m(e){return x.apply(this,arguments)}function x(){return(x=Object(h.a)(d.a.mark((function e(t){var n,a,c,i,r;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===(i=a.shift())||void 0===i?void 0:i.isFile)){e.next=12;break}return e.next=8,b(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,g(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 g(e){return w.apply(this,arguments)}function w(){return(w=Object(h.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,k(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,k(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 k(e){return y.apply(this,arguments)}function y(){return(y=Object(h.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 C(){return(C=Object(h.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,m(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(p.jsx)("label",{htmlFor:l,className:"file-select-label",children:Object(p.jsxs)("div",{className:["file-select-container",i?"file-select-label-hover":""].join(" "),onDrop:function(e){return C.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),r(!0)},onDragLeave:function(){return r(!1)},children:[Object(p.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(p.jsx)("p",{className:"file-select-message",children:"desktop"===u?"Click here or drag an image file":"Tap here to load your picture"})]})})}var m=function(){var e=Object(s.e)(j);return Object(p.jsxs)("div",{className:"landing-page",children:[Object(p.jsxs)("h1",{children:["Image inpainting powered by \ud83e\udd99",Object(p.jsx)("a",{href:"https://github.com/saic-mdal/lama",children:"LaMa"})]}),Object(p.jsx)("div",{className:"landing-file-selector",children:Object(p.jsx)(O,{onSelection:function(){var t=Object(h.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)}}()})})]})},x=n(8),g=Object(s.b)({key:"themeState",default:"light"}),w=function(){var e=Object(s.c)(g),t=Object(o.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(p.jsx)("div",{className:"theme-toggle-ui",children:Object(p.jsx)("div",{className:"theme-btn",onClick:function(){c("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(p.jsx)(x.f,{}):Object(p.jsx)(x.g,{style:{color:"#ffcc00"}})})})},k=n(17),y=n(28),C=n(18);function S(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 z(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}))}var N="".concat("","/inpaint");function E(e,t,n){return M.apply(this,arguments)}function M(){return M=Object(h.a)(d.a.mark((function e(t,n,a){var c,i,r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(c=new FormData).append("image",t),i=S(n),c.append("mask",i),void 0===a?c.append("sizeLimit","1080"):c.append("sizeLimit",a),e.next=7,fetch(N,{method:"POST",body:c}).then(function(){var e=Object(h.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",t.blob());case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 7:return r=e.sent,e.abrupt("return",URL.createObjectURL(r));case 9:case"end":return e.stop()}}),e)}))),M.apply(this,arguments)}function D(e){var t=e.children,n=e.className,a=e.disabled,c=e.icon,i=e.onKeyDown,r=e.onClick,s=e.onDown,o=e.onUp,l=e.style;return Object(p.jsxs)("div",{role:"button",style:l,onKeyDown:i,onClick:function(e){e.currentTarget.blur(),null===r||void 0===r||r()},onPointerDown:function(e){null===s||void 0===s||s(e.nativeEvent)},onPointerUp:function(e){null===o||void 0===o||o(e.nativeEvent)},tabIndex:-1,className:["btn-primary",t?"btn-primary-content":"",a?"btn-primary-disabled":"",n].join(" "),children:[c,t?Object(p.jsx)("span",{children:t}):null]})}function L(e){var t=e.value,n=e.onChange,a=e.label,c=e.min,i=e.max,r=((i||100)-(c||0))/100;return Object(p.jsxs)("div",{className:"editor-brush-slider",children:[Object(p.jsx)("span",{children:a}),Object(p.jsx)("input",{type:"range",step:r,min:c,max:i,value:t,onChange:function(e){e.preventDefault(),e.stopPropagation(),n(parseInt(e.currentTarget.value,10))}})]})}var H=n(27),A=["720","1080","2000","Original"];function T(e){var t=e.originalHeight,n=e.originalWidth,c=e.onChange,i=Object(a.useState)(!1),r=Object(o.a)(i,2),s=r[0],l=r[1],u=Object(a.useRef)(null),d=Object(a.useState)("Original"),h=Object(o.a)(d,2),j=h[0],b=h[1],v=Math.max(n,t),f=Object(a.useCallback)((function(){for(var e=[],t=0;t<A.length;t+=1)"Original"===A[t]&&e.push(A[t]),parseInt(A[t],10)<v&&e.push(A[t]);return e}),[v]),O=Object(a.useCallback)((function(e){if("Original"===e)return"".concat(n,"x").concat(t);var a=parseInt(e,10)/v;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,v]);Object(H.a)(u,(function(){l(!1)}));var m=function(e){var a=e.target.textContent.split("x");n>t?(b(a[0]),c(a[0])):(b(a[1]),c(a[1])),l(!s)};return Object(p.jsxs)("div",{className:"editor-size-selector",ref:u,children:[Object(p.jsxs)("div",{className:"editor-size-selector-main",role:"button",tabIndex:0,onClick:function(){l((function(e){return!e}))},"aria-hidden":"true",children:[Object(p.jsx)("p",{children:O(j.toString())}),Object(p.jsx)("div",{className:"editor-size-selector-icon",children:Object(p.jsx)(x.c,{})})]}),s&&Object(p.jsx)("div",{className:"editor-size-options",children:f().map((function(e){return Object(p.jsx)("div",{className:"editor-size-option",role:"button",tabIndex:0,onClick:m,"aria-hidden":"true",children:O(e)},e)}))})]})}var I="#ffcc00bb";function P(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:I;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 R(e){var t=e.file,n=Object(a.useState)(40),c=Object(o.a)(n,2),i=c[0],r=c[1],s=function(e){var t=Object(a.useState)(new Image),n=Object(o.a)(t,1)[0],c=Object(a.useState)(!1),i=Object(o.a)(c,2),r=i[0],s=i[1];return Object(a.useEffect)((function(){return n.onload=function(){s(!0)},s(!1),n.src=URL.createObjectURL(e),function(){n.onload=null}}),[e,n]),[n,r]}(t),u=Object(o.a)(s,2),j=u[0],b=u[1],f=Object(a.useState)([]),O=Object(o.a)(f,2),m=O[0],g=O[1],w=Object(a.useState)(),S=Object(o.a)(w,2),N=S[0],M=S[1],H=Object(a.useState)((function(){return document.createElement("canvas")})),A=Object(o.a)(H,1)[0],I=Object(a.useState)([{pts:[]}]),R=Object(o.a)(I,2),Z=R[0],W=R[1],U=Object(a.useState)([{pts:[]}]),V=Object(o.a)(U,2),B=V[0],F=V[1],K=Object(a.useState)([]),Y=Object(o.a)(K,2),J=Y[0],X=Y[1],G=Object(a.useState)({x:-1,y:-1}),$=Object(o.a)(G,2),_=$[0],Q=_.x,q=_.y,ee=$[1],te=Object(a.useState)(!1),ne=Object(o.a)(te,2),ae=ne[0],ce=ne[1],ie=Object(a.useState)(!1),re=Object(o.a)(ie,2),se=re[0],oe=re[1],le=Object(a.useState)(!1),ue=Object(o.a)(le,2),de=ue[0],he=ue[1],je=Object(a.useState)(!1),be=Object(o.a)(je,2),ve=be[0],fe=be[1],pe=Object(a.useState)(1),Oe=Object(o.a)(pe,2),me=Oe[0],xe=Oe[1],ge=Object(a.useState)(),we=Object(o.a)(ge,2),ke=we[0],ye=we[1],Ce=Object(a.useState)(1080),Se=Object(o.a)(Ce,2),ze=Se[0],Ne=Se[1],Ee=Object(y.a)(),Me=Object(a.useRef)(),De=Object(a.useState)(!1),Le=Object(o.a)(De,2),He=Le[0],Ae=Le[1],Te=Object(a.useState)(!1),Ie=Object(o.a)(Te,2),Pe=Ie[0],Re=Ie[1],Ze=Object(a.useState)(0),We=Object(o.a)(Ze,2),Ue=We[0],Ve=We[1],Be=Object(a.useCallback)((function(){if(N){N.clearRect(0,0,N.canvas.width,N.canvas.height);var e=m[m.length-1];(null===e||void 0===e?void 0:e.src)?N.drawImage(e,0,0,j.naturalWidth,j.naturalHeight):N.drawImage(j,0,0),P(N,B)}}),[N,B,j,m]),Fe=Object(a.useCallback)((function(){if(!(null===N||void 0===N?void 0:N.canvas.width)||!(null===N||void 0===N?void 0:N.canvas.height))throw new Error("canvas has invalid size");A.width=null===N||void 0===N?void 0:N.canvas.width,A.height=null===N||void 0===N?void 0:N.canvas.height;var e=A.getContext("2d");if(!e)throw new Error("could not retrieve mask canvas");P(e,Z,"white")}),[null===N||void 0===N?void 0:N.canvas.height,null===N||void 0===N?void 0:N.canvas.width,Z,A]),Ke=Object(a.useCallback)(Object(h.a)(d.a.mark((function e(){var n,a;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return fe(!0),Fe(),e.prev=2,e.next=5,E(t,A.toDataURL(),ze.toString());case 5:if(n=e.sent){e.next=8;break}throw new Error("empty response");case 8:return a=new Image,e.next=11,z(a,n);case 11:m.push(a),Z.push({pts:[]}),g(Object(v.a)(m)),W(Object(v.a)(Z)),J.push(B.length),X(J),B.length=0,F([{pts:[]}]),e.next=24;break;case 21:e.prev=21,e.t0=e.catch(2),alert(e.t0.message?e.t0.message:e.t0.toString());case 24:fe(!1),Be();case 26:case"end":return e.stop()}}),e,null,[[2,21]])}))),[Be,t,Z,B,A,Fe,m,ze,J]),Ye=function(){return 0!==B.length&&0!==B[0].pts.length},Je=function(){return 0!==m.length},Xe=function(){Ae(!1),B.length=0,F([{pts:[]}])},Ge=function(e){return"Control"===e.key||"Meta"===e.key};Object(C.a)(Ge,(function(){Pe&&(ve||(Re(!1),Ye()&&Ke()))}),{event:"keyup"},[ve,Pe,Ye]),Object(C.a)(Ge,(function(){ve||Re(!0)}),{event:"keydown"},[ve]),Object(a.useEffect)((function(){if(j&&b){var e=Ee.width/j.naturalWidth,t=(Ee.height-200)/j.naturalHeight;if(e<1||t<1){var n=Math.min(e,t);ye(n),xe(n)}else ye(1);var a=Math.max(j.width,j.height);Ne(a),(null===N||void 0===N?void 0:N.canvas)&&(N.canvas.width=j.naturalWidth,N.canvas.height=j.naturalHeight),Be()}}),[null===N||void 0===N?void 0:N.canvas,Be,j,b,Ee]);var $e=Object(a.useCallback)((function(){if(ke&&j&&Ee){var e=Me.current;if(!e)throw new Error("no viewport");var t=(Ee.width-j.width*ke)/2,n=(Ee.height-j.height*ke)/2;e.setTransform(t,n,ke,200,"easeOutQuad"),e.state.scale=ke,xe(ke)}}),[Me,ke,j,Ee]);Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){$e()})),function(){window.removeEventListener("resize",(function(){$e()}))}}),[Ee,$e]);Object(C.a)("Escape",(function(){ve||(He||Pe?Xe():$e())}),{event:"keydown"},[He,ve,Pe,$e,Xe]);var _e=function(e,t){B[B.length-1].pts.push({x:e,y:t}),Z[Z.length-1].pts.push({x:e,y:t}),Be()},Qe=function(){if(m.length&&J.length){for(var e=Z,t=J[J.length-1],n=0;n<=t;n+=1)e.pop();W([].concat(Object(v.a)(e),[{pts:[]}])),J.pop(),X(J);var a=m;a.pop(),g(Object(v.a)(a))}};Object(C.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&"z"===e.key;return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),!0)}),Qe),Object(l.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Je()&&he((function(){return window.setTimeout((function(){Ve(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Je()&&(Ve(0),window.setTimeout((function(){he(!1)}),350))}));var qe=function(e){e===ae||se||ce(e)},et=Object(a.useCallback)((function(){return se?"grab":ae?"none":void 0}),[ae,se]);Object(l.a)("[",(function(){r((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),Object(l.a)("]",(function(){r((function(e){return e+10}))})),Object(l.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ce(!1),oe(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ce(!0),oe(!1)}));return j&&me&&ke?Object(p.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;ee({x:t.pageX,y:t.pageY})},onMouseUp:function(){if(!se&&(j.src&&(null===N||void 0===N?void 0:N.canvas)&&!ve&&He)){if(Ae(!1),Pe)return Z.push({pts:[]}),W(Object(v.a)(Z)),B.push({pts:[]}),void F(Object(v.a)(B));0!==B.length&&0!==B[0].pts.length&&Ke()}},children:[Object(p.jsx)(k.b,{ref:function(e){e&&(Me.current=e)},panning:{disabled:!se,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},centerOnInit:!0,limitToBounds:!1,doubleClick:{disabled:!0},initialScale:ke,minScale:ke,onZoom:function(e){xe(e.state.scale)},children:Object(p.jsx)(k.a,{contentClass:ve?"editor-canvas-loading":"",children:Object(p.jsxs)("div",{className:"editor-canvas-container",children:[Object(p.jsx)("canvas",{className:"editor-canvas",style:{cursor:et(),clipPath:"inset(0 ".concat(Ue,"% 0 0)"),transition:"clip-path 350ms ease-in-out"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){return qe(!0)},onFocus:function(){return qe(!0)},onMouseLeave:function(){return qe(!1)},onMouseDown:function(e){if(!se&&(j.src&&(null===N||void 0===N?void 0:N.canvas)&&!ve)){Ae(!0),B[B.length-1].size=i,Z[Z.length-1].size=i;var t=e.nativeEvent;_e(t.offsetX,t.offsetY)}},onMouseMove:function(e){if(!se&&He){var t=e.nativeEvent,n=t.offsetX,a=t.offsetY;_e(n,a)}},ref:function(e){if(e&&!N){var t=e.getContext("2d");t&&M(t)}}}),Object(p.jsxs)("div",{className:"original-image-container",style:{width:"".concat(j.naturalWidth,"px"),height:"".concat(j.naturalHeight,"px")},children:[de&&Object(p.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(Ue,"%")}}),Object(p.jsx)("img",{className:"original-image",src:j.src,alt:"original",style:{width:"".concat(j.naturalWidth,"px"),height:"".concat(j.naturalHeight,"px")}})]})]})})}),ae&&!ve&&!se&&Object(p.jsx)("div",{className:"brush-shape",style:function(){var e=function(){var e,t,n=ke;return void 0!==(null===(e=Me.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=Me.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(i*e,"px"),height:"".concat(i*e,"px"),left:"".concat(Q,"px"),top:"".concat(q,"px"),transform:"translate(-50%, -50%)"}}()}),Object(p.jsxs)("div",{className:"editor-toolkit-panel",children:[Object(p.jsx)(T,{onChange:function(e){Ne(e)},originalWidth:j.naturalWidth,originalHeight:j.naturalHeight}),Object(p.jsx)(L,{label:"Brush",min:10,max:150,value:i,onChange:r}),Object(p.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(p.jsx)(D,{icon:Object(p.jsx)(x.b,{}),disabled:me===ke,onClick:$e}),Object(p.jsx)(D,{icon:Object(p.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(p.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:Qe,disabled:0===m.length}),Object(p.jsx)(D,{icon:Object(p.jsx)(x.e,{}),className:de?"eyeicon-active":"",onDown:function(e){e.preventDefault(),he((function(){return window.setTimeout((function(){Ve(100)}),10),!0}))},onUp:function(){Ve(0),window.setTimeout((function(){he(!1)}),350)},disabled:0===m.length,children:void 0}),Object(p.jsx)(D,{icon:Object(p.jsx)(x.d,{}),disabled:!m.length,onClick:function(){var e=t.name.replace(/(\.[\w\d_-]+)$/i,"_cleanup$1");!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)}(m[m.length-1].currentSrc,e)},children:void 0})]})]})]}):Object(p.jsx)(p.Fragment,{})}function Z(e){var t=e.show,n=e.children,c=e.onClose,i=e.className,r=e.title,s=Object(a.useRef)(null);return Object(H.a)(s,(function(){null===c||void 0===c||c()})),Object(C.a)("Escape",c,{event:"keydown"}),Object(p.jsx)("div",{className:"modal-mask",style:{visibility:!0===t?"visible":"hidden"},children:Object(p.jsxs)("div",{ref:s,className:"modal ".concat(i),children:[Object(p.jsxs)("div",{className:"modal-header",children:[Object(p.jsx)("h3",{children:r}),Object(p.jsx)(D,{icon:Object(p.jsx)(x.h,{}),onClick:c})]}),n]})})}function W(e){var t=e.children,n=e.content;return Object(p.jsxs)("div",{className:"shortcut-option",children:[Object(p.jsx)("div",{className:"shortcut-description",children:n}),Object(p.jsx)("div",{className:"shortcut-key",children:t})]})}function U(e){var t=e.show,n=Object(s.e)(b);return Object(p.jsx)(Z,{onClose:function(){n(!1)},title:"Hotkeys",className:"modal-shortcuts",show:t,children:Object(p.jsxs)("div",{className:"shortcut-options",children:[Object(p.jsx)(W,{content:"Enable multi-stroke mask drawing",children:Object(p.jsx)("p",{children:"Hold Cmd/Ctrl"})}),Object(p.jsx)(W,{content:"Undo inpainting",children:Object(p.jsx)("p",{children:"Cmd/Ctrl + Z"})}),Object(p.jsx)(W,{content:"Pan",children:Object(p.jsx)("p",{children:"Space & Drag"})}),Object(p.jsx)(W,{content:"View original image",children:Object(p.jsx)("p",{children:"Hold Tab"})}),Object(p.jsx)(W,{content:"Reset zoom/pan",children:Object(p.jsx)("p",{children:"Esc"})}),Object(p.jsx)(W,{content:"Cancel mask drawing",children:Object(p.jsx)("p",{children:"Esc"})}),Object(p.jsx)(W,{content:"Decrease Brush Size",children:Object(p.jsx)("p",{children:"["})}),Object(p.jsx)(W,{content:"Increase Brush Size",children:Object(p.jsx)("p",{children:"]"})}),Object(p.jsx)(W,{content:"Toggle Dark Mode",children:Object(p.jsx)("p",{children:"Shift + D"})}),Object(p.jsx)(W,{content:"Toggle Hotkeys Panel",children:Object(p.jsx)("p",{children:"H"})})]})})}var V=function(e){var t=e.file,n=Object(s.d)(b);return Object(p.jsxs)(p.Fragment,{children:[Object(p.jsx)(R,{file:t}),Object(p.jsx)(U,{show:n})]})},B=function(){var e=Object(s.c)(b),t=Object(o.a)(e,2),n=t[0],a=t[1],c=function(){a((function(e){return!e}))};return Object(l.a)("h",(function(e){null===e||void 0===e||e.preventDefault(),c()})),Object(p.jsx)("div",{className:"shortcuts",children:Object(p.jsx)(D,{onClick:c,disabled:n,style:{border:0},icon:Object(p.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(p.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(p.jsxs)("g",{fill:"currentColor",children:[Object(p.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(p.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"})]})]})})})},F=function(){var e=Object(s.c)(j),t=Object(o.a)(e,2),n=t[0],a=t[1],c=f();return Object(p.jsxs)("header",{children:[Object(p.jsx)("div",{style:{visibility:n?"visible":"hidden"},children:Object(p.jsx)(D,{icon:Object(p.jsx)(x.a,{}),onClick:function(){a(void 0)},style:{border:0},children:"desktop"===c?"Start New":void 0})}),Object(p.jsxs)("div",{className:"header-icons-wrapper",children:[Object(p.jsx)("div",{style:{visibility:n?"visible":"hidden"},children:Object(p.jsx)(B,{})}),Object(p.jsx)(w,{})]})]})};!function(){function e(){return e=Object(h.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 K=function(){var e=Object(s.c)(j),t=Object(o.a)(e,2),n=t[0],c=t[1],i=Object(s.c)(g),r=Object(o.a)(i,2),u=r[0],d=r[1],h=function(){var e=Object(a.useState)(),t=Object(o.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(e){return e.blob()})).then((function(e){if(e&&e.type.startsWith("image")){var t=new File([e],"inputImage");c(t)}}))}),[c]);return Object(a.useEffect)((function(){i()}),[i]),n}();return Object(a.useEffect)((function(){c(h)}),[h,c]),Object(l.a)("D",(function(e){null===e||void 0===e||e.preventDefault(),d("light"===u?"dark":"light")})),Object(p.jsxs)("div",{className:"lama-cleaner","data-theme":u,children:[Object(p.jsx)(F,{}),n?Object(p.jsx)(V,{file:n}):Object(p.jsx)(m,{})]})};r.a.render(Object(p.jsx)(c.a.StrictMode,{children:Object(p.jsx)(s.a,{children:Object(p.jsx)(K,{})})}),document.getElementById("root"))}},[[26,1,2]]]);