From e3c9601d37199077bb4ebc92f7beefbcd9faf794 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Thu, 18 Jun 2026 00:15:39 +0800 Subject: [PATCH] updated sdui --- embd_res/kcpp_sdui.embd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embd_res/kcpp_sdui.embd b/embd_res/kcpp_sdui.embd index 1fe8dcb96..50807c23b 100644 --- a/embd_res/kcpp_sdui.embd +++ b/embd_res/kcpp_sdui.embd @@ -506,9 +506,9 @@ gl_FragColor.rgb *= color.a; `?(s++,f[s]=0):f[s]++;f[0]>0&&(this.insertCharStyleObject(c.lineIndex,c.charIndex,f[0],d),d=d&&d.slice(f[0]+1)),s&&this.insertNewlineStyleObject(c.lineIndex,c.charIndex+f[0],s);for(var h=1;h0?this.insertCharStyleObject(c.lineIndex+h,0,f[h],d):d&&this.styles[c.lineIndex+h]&&d[0]&&(this.styles[c.lineIndex+h][0]=d[0]),d=d&&d.slice(f[h]+1);f[h]>0&&this.insertCharStyleObject(c.lineIndex+h,0,f[h],d)},setSelectionStartEndWithShift:function(a,u,d){d<=a?(u===a?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=a),this.selectionStart=d):d>a&&da?this.selectionStart=a:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>a?this.selectionEnd=a:this.selectionEnd<0&&(this.selectionEnd=0)}})}(),t.util.object.extend(t.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(o){if(!!this.canvas){this.__newClickTime=+new Date;var a=o.pointer;this.isTripleClick(a)&&(this.fire("tripleclick",o),this._stopEvent(o.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=a,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(o){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===o.x&&this.__lastPointer.y===o.y},_stopEvent:function(o){o.preventDefault&&o.preventDefault(),o.stopPropagation&&o.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(o){!this.isEditing||this.selectWord(this.getSelectionStartFromPointer(o.e))},tripleClickHandler:function(o){!this.isEditing||this.selectLine(this.getSelectionStartFromPointer(o.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(o){!this.canvas||!this.editable||o.e.button&&o.e.button!==1||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(o.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(o){!this.canvas||!this.editable||o.e.button&&o.e.button!==1||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(o){if(this.__isMousedown=!1,!(!this.editable||this.group||o.transform&&o.transform.actionPerformed||o.e.button&&o.e.button!==1)){if(this.canvas){var a=this.canvas._activeObject;if(a&&a!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(o.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(o){var a=this.getSelectionStartFromPointer(o),u=this.selectionStart,d=this.selectionEnd;o.shiftKey?this.setSelectionStartEndWithShift(u,d,a):(this.selectionStart=a,this.selectionEnd=a),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(o){for(var a=this.getLocalPointer(o),u=0,d=0,c=0,f=0,s=0,h,v,m=0,y=this._textLines.length;m0&&(f+=this._textLines[m-1].length+this.missingNewlineOffset(m-1));h=this._getLineLeftOffset(s),d=h*this.scaleX,v=this._textLines[s],this.direction==="rtl"&&(a.x=this.width*this.scaleX-a.x+d);for(var b=0,_=v.length;b<_&&(u=d,d+=this.__charBounds[s][b].kernedWidth*this.scaleX,d<=a.x);b++)f++;return this._getNewSelectionStartFromOffset(a,u,d,f,_)},_getNewSelectionStartFromOffset:function(o,a,u,d,c){var f=o.x-a,s=u-o.x,h=s>f||s<0?0:1,v=d+h;return this.flipX&&(v=c-v),v>this._text.length&&(v=this._text.length),v}}),t.util.object.extend(t.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=t.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var o=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+o.top+"; left: "+o.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uFF70top: "+o.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):t.document.body.appendChild(this.hiddenTextarea),t.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),t.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),t.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),t.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),t.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),t.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),t.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),t.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),t.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(t.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(o){if(!!this.isEditing){var a=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(o.keyCode in a)this[a[o.keyCode]](o);else if(o.keyCode in this.ctrlKeysMapDown&&(o.ctrlKey||o.metaKey))this[this.ctrlKeysMapDown[o.keyCode]](o);else return;o.stopImmediatePropagation(),o.preventDefault(),o.keyCode>=33&&o.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(o){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}if(o.keyCode in this.ctrlKeysMapUp&&(o.ctrlKey||o.metaKey))this[this.ctrlKeysMapUp[o.keyCode]](o);else return;o.stopImmediatePropagation(),o.preventDefault(),this.canvas&&this.canvas.requestRenderAll()},onInput:function(o){var a=this.fromPaste;if(this.fromPaste=!1,o&&o.stopPropagation(),!!this.isEditing){var u=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,d=this._text.length,c=u.length,f,s,h=c-d,v=this.selectionStart,m=this.selectionEnd,y=v!==m,b,_,w;if(this.hiddenTextarea.value===""){this.styles={},this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll());return}var S=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),x=v>S.selectionStart;y?(f=this._text.slice(v,m),h+=m-v):c0&&(d=this.__charBounds[o][a-1],u+=d.left+d.width),u},getDownCursorOffset:function(o,a){var u=this._getSelectionForOffset(o,a),d=this.get2DCursorLocation(u),c=d.lineIndex;if(c===this._textLines.length-1||o.metaKey||o.keyCode===34)return this._text.length-u;var f=d.charIndex,s=this._getWidthBeforeCursor(c,f),h=this._getIndexOnLine(c+1,s),v=this._textLines[c].slice(f);return v.length+h+1+this.missingNewlineOffset(c)},_getSelectionForOffset:function(o,a){return o.shiftKey&&this.selectionStart!==this.selectionEnd&&a?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(o,a){var u=this._getSelectionForOffset(o,a),d=this.get2DCursorLocation(u),c=d.lineIndex;if(c===0||o.metaKey||o.keyCode===33)return-u;var f=d.charIndex,s=this._getWidthBeforeCursor(c,f),h=this._getIndexOnLine(c-1,s),v=this._textLines[c].slice(0,f),m=this.missingNewlineOffset(c-1);return-this._textLines[c-1].length+h-v.length+(1-m)},_getIndexOnLine:function(o,a){for(var u=this._textLines[o],d=this._getLineLeftOffset(o),c=d,f=0,s,h,v=0,m=u.length;va){h=!0;var y=c-s,b=c,_=Math.abs(y-a),w=Math.abs(b-a);f=w<_?v:v-1;break}return h||(f=u.length-1),f},moveCursorDown:function(o){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",o)},moveCursorUp:function(o){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",o)},_moveCursorUpOrDown:function(o,a){var u="get"+o+"CursorOffset",d=this[u](a,this._selectionDirection==="right");a.shiftKey?this.moveCursorWithShift(d):this.moveCursorWithoutShift(d),d!==0&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(o){var a=this._selectionDirection==="left"?this.selectionStart+o:this.selectionEnd+o;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,a),o!==0},moveCursorWithoutShift:function(o){return o<0?(this.selectionStart+=o,this.selectionEnd=this.selectionStart):(this.selectionEnd+=o,this.selectionStart=this.selectionEnd),o!==0},moveCursorLeft:function(o){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",o)},_move:function(o,a,u){var d;if(o.altKey)d=this["findWordBoundary"+u](this[a]);else if(o.metaKey||o.keyCode===35||o.keyCode===36)d=this["findLineBoundary"+u](this[a]);else return this[a]+=u==="Left"?-1:1,!0;if(typeof d<"u"&&this[a]!==d)return this[a]=d,!0},_moveLeft:function(o,a){return this._move(o,a,"Left")},_moveRight:function(o,a){return this._move(o,a,"Right")},moveCursorLeftWithoutShift:function(o){var a=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(a=this._moveLeft(o,"selectionStart")),this.selectionEnd=this.selectionStart,a},moveCursorLeftWithShift:function(o){if(this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd)return this._moveLeft(o,"selectionEnd");if(this.selectionStart!==0)return this._selectionDirection="left",this._moveLeft(o,"selectionStart")},moveCursorRight:function(o){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",o)},_moveCursorLeftOrRight:function(o,a){var u="moveCursor"+o+"With";this._currentCursorOpacity=1,a.shiftKey?u+="Shift":u+="outShift",this[u](a)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(o){if(this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd)return this._moveRight(o,"selectionStart");if(this.selectionEnd!==this._text.length)return this._selectionDirection="right",this._moveRight(o,"selectionEnd")},moveCursorRightWithoutShift:function(o){var a=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(a=this._moveRight(o,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,a},removeChars:function(o,a){typeof a>"u"&&(a=o+1),this.removeStyleFromTo(o,a),this._text.splice(o,a-o),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(o,a,u,d){typeof d>"u"&&(d=u),d>u&&this.removeStyleFromTo(u,d);var c=t.util.string.graphemeSplit(o);this.insertNewStyleBlock(c,u,a),this._text=[].concat(this._text.slice(0,u),c,this._text.slice(d)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var o=t.util.toFixed,a=/ +/g;t.util.object.extend(t.Text.prototype,{_toSVG:function(){var u=this._getSVGLeftTopOffsets(),d=this._getSVGTextAndBg(u.textTop,u.textLeft);return this._wrapSVGTextAndBg(d)},toSVG:function(u){return this._createBaseSVGMarkup(this._toSVG(),{reviver:u,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(u){var d=!0,c=this.getSvgTextDecoration(this);return[u.textBgRects.join(""),' ",u.textSpans.join(""),` `]},_getSVGTextAndBg:function(u,d){var c=[],f=[],s=u,h;this._setSVGBg(f);for(var v=0,m=this._textLines.length;v",t.util.string.escapeXml(u),""].join("")},_setSVGTextLineText:function(u,d,c,f){var s=this.getHeightOfLine(d),h=this.textAlign.indexOf("justify")!==-1,v,m,y="",b,_,w=0,S=this._textLines[d],x;f+=s*(1-this._fontSizeFraction)/this.lineHeight;for(var T=0,E=S.length-1;T<=E;T++)x=T===E||this.charSpacing,y+=S[T],b=this.__charBounds[d][T],w===0?(c+=b.kernedWidth-b.width,w+=b.width):w+=b.kernedWidth,h&&!x&&this._reSpaceAndTab.test(S[T])&&(x=!0),x||(v=v||this.getCompleteStyleDeclaration(d,T),m=this.getCompleteStyleDeclaration(d,T+1),x=t.util.hasStyleChanged(v,m,!0)),x&&(_=this._getStyleDeclaration(d,T)||{},u.push(this._createTextCharSpan(y,_,c,f)),y="",v=m,c+=w,w=0)},_pushTextBgRect:function(u,d,c,f,s,h){var v=t.Object.NUM_FRACTION_DIGITS;u.push(" `)},_setSVGTextLineBg:function(u,d,c,f){for(var s=this._textLines[d],h=this.getHeightOfLine(d)/this.lineHeight,v=0,m=0,y,b,_=this.getValueOfPropertyAt(d,0,"textBackgroundColor"),w=0,S=s.length;wthis.width&&this._set("width",this.dynamicMinWidth),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(u){for(var d=0,c=0,f=0,s={},h=0;h0?(c=0,f++,d++):!this.splitByGrapheme&&this._reSpaceAndTab.test(u.graphemeText[f])&&h>0&&(c++,f++),s[h]={line:d,offset:c},f+=u.graphemeLines[h].length,c+=u.graphemeLines[h].length;return s},styleHas:function(u,d){if(this._styleMap&&!this.isWrapping){var c=this._styleMap[d];c&&(d=c.line)}return a.Text.prototype.styleHas.call(this,u,d)},isEmptyStyles:function(u){if(!this.styles)return!0;var d=0,c=u+1,f,s,h=!1,v=this._styleMap[u],m=this._styleMap[u+1];v&&(u=v.line,d=v.offset),m&&(c=m.line,h=c===u,f=m.offset),s=typeof u>"u"?this.styles:{line:this.styles[u]};for(var y in s)for(var b in s[y])if(b>=d&&(!h||bc&&!E?(v.push(m),m=[],s=S,E=!0):s+=I,!E&&!h&&m.push(w),m=m.concat(b),x=h?0:this._measureWord([w],d,_),_++,E=!1,S>T&&(T=S);return N&&v.push(m),T+D>this.dynamicMinWidth&&(this.dynamicMinWidth=T-I+D),v},isEndOfWrapping:function(u){return!this._styleMap[u+1]||this._styleMap[u+1].line!==this._styleMap[u].line},missingNewlineOffset:function(u){return this.splitByGrapheme?this.isEndOfWrapping(u)?1:0:1},_splitTextIntoLines:function(u){for(var d=a.Text.prototype._splitTextIntoLines.call(this,u),c=this._wrapText(d.lines,this.width),f=new Array(c.length),s=0;s{const e=()=>({canvas:void 0,brush:void 0,visibleImageLayer:void 0,imageLayer:void 0,visibleDrawLayer:void 0,drawLayer:void 0,cropPreviewLayer:void 0,maskPathColor:"",maskBackgroundColor:"",imageScale:1,undoHistory:[],redoHistory:[],drawing:!1}),t=oe({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=oe({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>Jt().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>Jt().currentImageProps),g=ee({get:()=>i.value.drawing&&!r.value,set:P=>i.value.drawing=P}),o=oe(512),a=oe(512),u=oe(!1),d=oe(30),c=oe(!1),f=new Kn.fabric.Circle({radius:d.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=oe("Erase"),h=oe("rgb(0, 0, 0, 1)");function v(){!i.value.canvas||i.value.canvas.renderAll()}function m(){u.value=!u.value,s.value=u.value?"Draw":"Erase"}function y(P=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=P||i.value.brush.color,i.value.brush.width=d.value)}async function b({history:P,erase:Q=!1,draw:j=!1}={}){if(!P||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;P.path.selectable=!1,P.path.opacity=1,P.drawPath=await M(P.path),P.visibleDrawPath=await M(P.path),Q?(P.visibleDrawPath.globalCompositeOperation="destination-out",P.drawPath.stroke=i.value.maskBackgroundColor):(P.visibleDrawPath.globalCompositeOperation="source-over",P.drawPath.stroke=j?h.value:i.value.maskPathColor);let A=await M(P.drawPath);A=A.scale(i.value.imageScale),A.left=A.left+P.drawPath.left*(i.value.imageScale-1),A.top=A.top+P.drawPath.top*(i.value.imageScale-1),j?(i.value.imageLayer.add(A),i.value.visibleImageLayer.addWithUpdate(P.visibleDrawPath)):(i.value.drawLayer.add(A),i.value.visibleDrawLayer.addWithUpdate(P.visibleDrawPath)),i.value.canvas.remove(P.path),v()}function _(){if(i.value.undoHistory.length===0)return;const P=i.value.undoHistory.pop();b({history:P,erase:!1,draw:g.value}),i.value.redoHistory.push(P)}function w(){if(i.value.redoHistory.length===0||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;const P=i.value.redoHistory.pop();i.value.undoHistory.push(P),g.value?(i.value.imageLayer.remove(P.drawPath),i.value.visibleImageLayer.remove(P.visibleDrawPath)):(i.value.drawLayer.remove(P.drawPath),i.value.visibleDrawLayer.remove(P.visibleDrawPath)),delete P.drawPath,delete P.visibleDrawPath,v()}function S(P){i.value.canvas=new Kn.fabric.Canvas(P,{isDrawingMode:!1,width:o.value,height:a.value,backgroundColor:"white"}),i.value.canvas.selection=!1,i.value.canvas.freeDrawingCursor="crosshair",y(i.value.maskPathColor),i.value.canvas.on("mouse:move",R),i.value.canvas.on("path:created",U),v()}function x(P,Q,j,A){let q=A,G=A;return Q>j?(P.scaleToWidth(A),q=A*(a.value/o.value)):(P.scaleToHeight(A),G=A*(o.value/a.value)),{newHeight:q,newWidth:G}}function T(P){const Q=Jt();if(re(),P.selectable=!1,o.value=P.width,a.value=P.height,o.value>Q.maxDimensions||a.value>Q.maxDimensions){const{newHeight:G,newWidth:te}=x(P,o.value,a.value,Q.maxDimensions);o.value=te,a.value=G}if(o.value{i.value.imageLayer=F({image:G,layerHeight:q,layerWidth:A})}),P.cloneAsImage(G=>{if(!i.value.canvas)return;if(o.value!==j||a.value!==j){const{newHeight:pe,newWidth:ve}=x(G,o.value,a.value,j);o.value=ve,a.value=pe}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=V(),i.value.visibleImageLayer=V({image:G}),i.value.drawLayer=F({layerHeight:q,layerWidth:A});const te=o.value*i.value.imageScale,fe=a.value*i.value.imageScale;Q.params.width=te-te%64,Q.params.height=fe-fe%64,i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleImageLayer),i.value.canvas.add(i.value.visibleDrawLayer),i.value.canvas.add(f),c.value=!0,N(),I()})}function E(P,Q,j,A,q,G){const te=G?G.width:P.width,fe=G?G.height:P.height;if(q==="Original")return P;const pe=document.createElement("canvas");pe.width=Q,pe.height=j;const ve=pe.getContext("2d");ve.fillStyle=A,ve.fillRect(0,0,pe.width,pe.height);let H=0,W=0,k=P.width,X=P.height,Y=0,$=0,B=pe.width,K=pe.height;switch(q){case"Stretch":break;case"ScaleAndCrop":{const ce=pe.width/te,ie=pe.height/fe;ce>ie?(X=pe.height/ce,W=(P.height-X)/2):(k=pe.width/ie,H=(P.width-k)/2);break}case"ScaleAndPad":{const ce=pe.width/te,ie=pe.height/fe;ceQ?(k=Q,H=ce-Q/2):(B=te,Y=Q/2-ce),fe>j?(X=j,W=ie-j/2):(K=fe,$=j/2-ie);break}}return ve.drawImage(P,H,W,k,X,Y,$,B,K),pe}function I(){const P=Jt(),Q=zt();if(!i.value.imageLayer||!i.value.drawLayer)return;const j=P.params.width,A=P.params.height,q=i.value.imageLayer.backgroundColor||"#FFFFFF",G=Q.imageResizeMode,te=i.value.imageLayer.toCanvasElement(),fe=E(te,j,A,q,G,te);if(l.value.sourceImage=fe.toDataURL("image/jpeg",1),l.value.maskImage=void 0,i.value.redoHistory.length>0&&!g.value){const ve=i.value.drawLayer.toCanvasElement(),H=E(ve,j,A,q,G,te);l.value.maskImage=H.toDataURL("image/jpeg",1).split(",")[1]}}let D;function N(){if(!i.value.canvas)return;const P=Jt();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),c.value&&(i.value.cropPreviewLayer=V({layerWidth:P.params.width/i.value.imageScale,layerHeight:P.params.height/i.value.imageScale,fill:"rgba(100, 0, 0, 0.5)"}),i.value.canvas.centerObject(i.value.cropPreviewLayer),i.value.canvas.add(i.value.cropPreviewLayer),D&&clearTimeout(D),D=setTimeout(()=>{c.value=!1,N(),D=void 0},5e3))}function L(P,Q){const j="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";Kn.fabric.Image.fromURL(j,A=>{A.set({height:P,width:Q});const q=A.toDataURL({format:"png"});l.value.sourceImage=q,g.value=!0,T(A)})}function F({image:P,layerWidth:Q,layerHeight:j}={}){const A=new Kn.fabric.Canvas(null);return A.selection=!1,A.backgroundColor=i.value.maskBackgroundColor,A.setHeight(j||a.value),A.setWidth(Q||o.value),P&&A.add(P),A}function O(){return i.value.imageLayer?{layerHeight:i.value.imageLayer.getHeight(),layerWidth:i.value.imageLayer.getWidth()}:{}}function V({image:P,layerWidth:Q,layerHeight:j,fill:A,abosolute:q}={}){const G=P||new Kn.fabric.Rect({width:Q||o.value,height:j||a.value,left:0,top:0,fill:A||"transparent",absolutePositioned:q||!0,selectable:!1});return new Kn.fabric.Group([G],{selectable:!1,absolutePositioned:q||!0})}function re(){!i.value.canvas||(i.value.visibleImageLayer&&(i.value.canvas.remove(i.value.visibleImageLayer),i.value.visibleImageLayer=void 0),i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),i.value.imageLayer=void 0,i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.canvas.isDrawingMode=!1)}function J(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),g.value){const P=Jt();L(P.params.height||512,P.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=V(),i.value.drawLayer=F(O()),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function ue(){var Q;I();const P=document.createElement("a");if(g.value){P.href="data:image/png;base64,"+((Q=l.value.sourceImage)==null?void 0:Q.split(",")[1]),P.download="image_drawing.png",P.click();return}P.href="data:image/png;base64,"+l.value.maskImage,P.download="image_mask.png",P.click()}async function M(P){return new Promise((Q,j)=>{try{P.clone(Q)}catch(A){j(A)}})}async function U(P){const Q={path:P.path};b({history:Q,erase:u.value,draw:g.value}),i.value.redoHistory.push(Q)}function R(P){if(!i.value.canvas)return;const Q=i.value.canvas.getPointer(P.e);f.left=Q.x,f.top=Q.y,f.opacity=.8,u.value?(f.set("strokeWidth",3),f.set("fill",""),y("red")):(f.set("strokeWidth",0),g.value?(f.set("fill",h.value),y(h.value)):(f.set("fill","white"),y("white"))),f.set("radius",d.value/2),v()}return{showCropPreview:c,erasing:u,switchToolText:s,brushSize:d,drawColor:h,drawing:g,imageProps:i,updateCropPreview:N,createNewCanvas:S,downloadMask:ue,resetCanvas:re,resetDrawing:J,flipErase:m,undoAction:w,redoAction:_,newImage:T,newBlankImage:L,setBrush:y,saveImages:I}});const XH={},KH={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},GH=ne("g",{fill:"none"},[ne("path",{d:"M11.197 2.44a1.5 1.5 0 0 1 2.121 0l4.243 4.242a1.5 1.5 0 0 1 0 2.121L9.364 17H14.5a.5.5 0 0 1 0 1H7.82a1.496 1.496 0 0 1-1.14-.437L2.437 13.32a1.5 1.5 0 0 1 0-2.121l8.76-8.76zm1.414.706a.5.5 0 0 0-.707 0L5.538 9.512l4.95 4.95l6.366-6.366a.5.5 0 0 0 0-.707L12.61 3.146zM9.781 15.17l-4.95-4.95l-1.687 1.687a.5.5 0 0 0 0 .707l4.243 4.243a.5.5 0 0 0 .707 0l1.687-1.687z",fill:"currentColor"})],-1),qH=[GH];function ZH(e,t){return z(),se("svg",KH,qH)}const JH=qt(XH,[["render",ZH]]);async function QH(e,t){const n=document.createElement("canvas"),r=n.getContext("2d"),i=new Image;return i.src=e,await new Promise(g=>i.onload=g),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function eW(e,t){const n=e.split(";base64,"),r=t!=null?t:n[0].split(":")[1],i=window.atob(r===n[0].split(":")[1]?n[1]:(await QH(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let g=0;g{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}const gm=e=>(ui("data-v-7dc3b5bb"),e=e(),ci(),e),tW=gm(()=>ne("div",null,[He("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1)),nW={key:0},rW=gm(()=>ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),iW={class:"canvas-container"},aW=gm(()=>ne("canvas",{id:"canvas"},null,-1)),oW={class:"action-buttons",style:{left:"10px",right:"unset"}},sW={class:"action-buttons"},lW=Ee({__name:"CustomCanvas",setup(e){const t=Jt(),n=Ut(),r=Ls(),i=oe();async function l(a){if(!a.raw.type.includes("image")){n.raiseError("Uploaded file needs to be a image!",!1),i.value.clearFiles();return}const u=await Tc(a.raw);t.currentImageProps.sourceImage=u,r.drawing=!1,Kn.fabric.Image.fromURL(u,r.newImage)}function g(){t.currentImageProps.sourceImage="",r.resetCanvas()}nt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Kn.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Yt(()=>{window.removeEventListener("paste",o)});async function o(a){var d;const u=(d=a.clipboardData)==null?void 0:d.items;if(!!u)for(let c=0;c(z(),se(je,null,[C(t).currentImageProps.sourceImage?ye("",!0):(z(),be(C(Yp),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:he(()=>[C(t).generatorType==="Img2Img"?(z(),se("div",nW,[rW,ne("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:u[0]||(u[0]=d=>C(r).newBlankImage(C(t).params.height||512,C(t).params.width||512))},[le(C(Le),{size:20,style:{"margin-right":"2px"}},{default:he(()=>[le(S2)]),_:1}),He("draw something")])])):ye("",!0)]),default:he(()=>[le(C(Le),{size:100},{default:he(()=>[le(C(dp))]),_:1}),tW]),_:1},512)),Et(ne("div",null,[ne("div",iW,[aW,ne("div",oW,[le(C(at),{onClick:u[1]||(u[1]=d=>C(r).undoAction()),icon:C(y_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),le(C(at),{onClick:u[2]||(u[2]=d=>C(r).redoAction()),icon:C(b_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",sW,[le(C(at),{onClick:u[3]||(u[3]=d=>C(r).resetDrawing()),icon:C(Mr),plain:""},null,8,["icon"]),le(C(at),{onClick:g,icon:C(Ol),plain:""},null,8,["icon"]),le(C(at),{onClick:u[4]||(u[4]=d=>C(r).downloadMask()),icon:C(Ks),plain:""},null,8,["icon"]),le(C(at),{onClick:u[5]||(u[5]=d=>C(r).flipErase()),icon:C(r).erasing?C(o3):JH,plain:""},null,8,["icon"]),C(r).drawing?(z(),be(C(EB),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":u[6]||(u[6]=d=>C(r).drawColor=d),"show-alpha":""},null,8,["modelValue"])):ye("",!0)]),le(C(jp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:he(()=>[le(bn,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:C(r).brushSize,"onUpdate:modelValue":u[7]||(u[7]=d=>C(r).brushSize=d),min:10,max:100,step:10,change:C(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[Ht,C(t).currentImageProps.sourceImage]])],64))}});const K0=qt(lW,[["__scopeId","data-v-7dc3b5bb"]]),uW={class:"centerIcons"},cW={class:"stackedIcons"},fW=Ee({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return Fx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(z(),se("div",uW,[ne("div",cW,[le(C(Le),{class:"firstIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconOne)))]),_:1},8,["size"]),le(C(Le),{class:"secondIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconTwo)))]),_:1},8,["size"])])]))}});const dW=qt(fW,[["__scopeId","data-v-74586a39"]]),hW={key:1,style:{width:"40px"}},bu=Ee({__name:"GeneratorMenuItem",props:{index:null,iconOne:null,iconTwo:null,isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(z(),be(C(zn),{content:e.index,placement:e.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:he(()=>[le(C(Up),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:he(()=>[e.iconTwo?(z(),be(dW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(z(),se("div",hW,[le(C(Le),{style:{width:"35px"},size:40},{default:he(()=>[(z(),be(kt(t.iconOne)))]),_:1})]))]),_:1},8,["index"])]),_:1},8,["content","placement"]))}});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const pW=4,G0=0,q0=1,mW=2;function Go(e){let t=e.length;for(;--t>=0;)e[t]=0}const gW=0,k2=1,vW=2,yW=3,bW=258,vm=29,Vl=256,pl=Vl+1+vm,Co=30,ym=19,E2=2*pl+1,_a=15,Jf=16,_W=7,bm=256,O2=16,A2=17,P2=18,Eh=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Xu=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),wW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),I2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),CW=512,Gr=new Array((pl+2)*2);Go(Gr);const Rs=new Array(Co*2);Go(Rs);const ml=new Array(CW);Go(ml);const gl=new Array(bW-yW+1);Go(gl);const _m=new Array(vm);Go(_m);const kc=new Array(Co);Go(kc);function Qf(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let M2,L2,R2;function ed(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const D2=e=>e<256?ml[e]:ml[256+(e>>>7)],vl=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},En=(e,t,n)=>{e.bi_valid>Jf-n?(e.bi_buf|=t<>Jf-e.bi_valid,e.bi_valid+=n-Jf):(e.bi_buf|=t<{En(e,n[t*2],n[t*2+1])},$2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},SW=e=>{e.bi_valid===16?(vl(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},xW=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,g=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let u,d,c,f,s,h,v=0;for(f=0;f<=_a;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;ua&&(f=a,v++),n[d*2+1]=f,!(d>r)&&(e.bl_count[f]++,s=0,d>=o&&(s=g[d-o]),h=n[d*2],e.opt_len+=h*(f+s),l&&(e.static_len+=h*(i[d*2+1]+s)));if(v!==0){do{for(f=a-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[a]--,v-=2}while(v>0);for(f=a;f!==0;f--)for(d=e.bl_count[f];d!==0;)c=e.heap[--u],!(c>r)&&(n[c*2+1]!==f&&(e.opt_len+=(f-n[c*2+1])*n[c*2],n[c*2+1]=f),d--)}},B2=(e,t,n)=>{const r=new Array(_a+1);let i=0,l,g;for(l=1;l<=_a;l++)i=i+n[l-1]<<1,r[l]=i;for(g=0;g<=t;g++){let o=e[g*2+1];o!==0&&(e[g*2]=$2(r[o]++,o))}},TW=()=>{let e,t,n,r,i;const l=new Array(_a+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?vl(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Z0=(e,t,n,r)=>{const i=t*2,l=n*2;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,l=0,g,o;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+l++]&255,r+=(e.pending_buf[e.sym_buf+l++]&255)<<8,i=e.pending_buf[e.sym_buf+l++],r===0?Tr(e,i,t):(g=gl[i],Tr(e,g+Vl+1,t),o=Eh[g],o!==0&&(i-=_m[g],En(e,i,o)),r--,g=D2(r),Tr(e,g,n),o=Xu[g],o!==0&&(r-=kc[g],En(e,r,o)));while(l{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,l=t.stat_desc.elems;let g,o,a=-1,u;for(e.heap_len=0,e.heap_max=E2,g=0;g>1;g>=1;g--)td(e,n,g);u=l;do g=e.heap[1],e.heap[1]=e.heap[e.heap_len--],td(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=g,e.heap[--e.heap_max]=o,n[u*2]=n[g*2]+n[o*2],e.depth[u]=(e.depth[g]>=e.depth[o]?e.depth[g]:e.depth[o])+1,n[g*2+1]=n[o*2+1]=u,e.heap[1]=u++,td(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],xW(e,t),B2(n,a,e.bl_count)},Q0=(e,t,n)=>{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=g,g=t[(r+1)*2+1],!(++o{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),r=0;r<=n;r++)if(l=g,g=t[(r+1)*2+1],!(++o{let t;for(Q0(e,e.dyn_ltree,e.l_desc.max_code),Q0(e,e.dyn_dtree,e.d_desc.max_code),Oh(e,e.bl_desc),t=ym-1;t>=3&&e.bl_tree[I2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},EW=(e,t,n,r)=>{let i;for(En(e,t-257,5),En(e,n-1,5),En(e,r-4,4),i=0;i{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return G0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return q0;for(n=32;n{ty||(TW(),ty=!0),e.l_desc=new ed(e.dyn_ltree,M2),e.d_desc=new ed(e.dyn_dtree,L2),e.bl_desc=new ed(e.bl_tree,R2),e.bi_buf=0,e.bi_valid=0,F2(e)},N2=(e,t,n,r)=>{En(e,(gW<<1)+(r?1:0),3),z2(e),vl(e,n),vl(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},PW=e=>{En(e,k2<<1,3),Tr(e,bm,Gr),SW(e)},IW=(e,t,n,r)=>{let i,l,g=0;e.level>0?(e.strm.data_type===mW&&(e.strm.data_type=OW(e)),Oh(e,e.l_desc),Oh(e,e.d_desc),g=kW(e),i=e.opt_len+3+7>>>3,l=e.static_len+3+7>>>3,l<=i&&(i=l)):i=l=n+5,n+4<=i&&t!==-1?N2(e,t,n,r):e.strategy===pW||l===i?(En(e,(k2<<1)+(r?1:0),3),J0(e,Gr,Rs)):(En(e,(vW<<1)+(r?1:0),3),EW(e,e.l_desc.max_code+1,e.d_desc.max_code+1,g+1),J0(e,e.dyn_ltree,e.dyn_dtree)),F2(e),r&&z2(e)},MW=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(gl[n]+Vl+1)*2]++,e.dyn_dtree[D2(t)*2]++),e.sym_next===e.sym_end);var LW=AW,RW=N2,DW=IW,$W=MW,BW=PW,FW={_tr_init:LW,_tr_stored_block:RW,_tr_flush_block:DW,_tr_tally:$W,_tr_align:BW};const zW=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,g=0;for(;n!==0;){g=n>2e3?2e3:n,n-=g;do i=i+t[r++]|0,l=l+i|0;while(--g);i%=65521,l%=65521}return i|l<<16|0};var yl=zW;const NW=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},jW=new Uint32Array(NW()),VW=(e,t,n,r)=>{const i=jW,l=r+n;e^=-1;for(let g=r;g>>8^i[(e^t[g])&255];return e^-1};var Zt=VW,$a={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},qo={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:UW,_tr_stored_block:Ah,_tr_flush_block:HW,_tr_tally:$i,_tr_align:WW}=FW,{Z_NO_FLUSH:Bi,Z_PARTIAL_FLUSH:YW,Z_FULL_FLUSH:XW,Z_FINISH:Gn,Z_BLOCK:ny,Z_OK:rn,Z_STREAM_END:ry,Z_STREAM_ERROR:Pr,Z_DATA_ERROR:KW,Z_BUF_ERROR:nd,Z_DEFAULT_COMPRESSION:GW,Z_FILTERED:qW,Z_HUFFMAN_ONLY:_u,Z_RLE:ZW,Z_FIXED:JW,Z_DEFAULT_STRATEGY:QW,Z_UNKNOWN:eY,Z_DEFLATED:lf}=qo,tY=9,nY=15,rY=8,iY=29,aY=256,Ph=aY+1+iY,oY=30,sY=19,lY=2*Ph+1,uY=15,lt=3,Mi=258,Ir=Mi+lt+1,cY=32,$o=42,wm=57,Ih=69,Mh=73,Lh=91,Rh=103,wa=113,ms=666,wn=1,Zo=2,Ba=3,Jo=4,fY=3,Ca=(e,t)=>(e.msg=$a[t],t),iy=e=>e*2-(e>4?9:0),Ai=e=>{let t=e.length;for(;--t>=0;)e[t]=0},dY=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)};let hY=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},jn=(e,t)=>{HW(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$n(e.strm)},mt=(e,t)=>{e.pending_buf[e.pending++]=t},us=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Dh=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=yl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Zt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},j2=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,g=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Ir?e.strstart-(e.w_size-Ir):0,u=e.window,d=e.w_mask,c=e.prev,f=e.strstart+Mi;let s=u[r+g-1],h=u[r+g];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+g]!==h||u[i+g-1]!==s||u[i]!==u[r]||u[++i]!==u[r+1])){r+=2,i++;do;while(u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&rg){if(e.match_start=t,g=l,l>=o)break;s=u[r+g-1],h=u[r+g]}}while((t=c[t&d])>a&&--n!==0);return g<=e.lookahead?g:e.lookahead},Bo=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Ir)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),dY(e),r+=t),e.strm.avail_in===0)break;if(n=Dh(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=lt)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Fi(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Fi(e,e.ins_h,e.window[i+lt-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,l,g=0,o=e.strm.avail_in;do{if(r=65535,l=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(r=i+e.strm.avail_in),r>l&&(r=l),r>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,$n(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(Dh(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(g===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_waterl&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,l+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),l>e.strm.avail_in&&(l=e.strm.avail_in),l&&(Dh(e.strm,e.window,e.strstart,l),e.strstart+=l,e.insert+=l>e.w_size-e.insert?e.w_size-e.insert:l),e.high_water>3,l=e.pending_buf_size-l>65535?65535:e.pending_buf_size-l,n=l>e.w_size?e.w_size:l,i=e.strstart-e.block_start,(i>=n||(i||t===Gn)&&t!==Bi&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,g=t===Gn&&e.strm.avail_in===0&&r===i?1:0,Ah(e,e.block_start,r,g),e.block_start+=r,$n(e.strm)),g?Ba:wn)},rd=(e,t)=>{let n,r;for(;;){if(e.lookahead=lt&&(e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-Ir&&(e.match_length=j2(e,n)),e.match_length>=lt)if(r=$i(e,e.strstart-e.match_start,e.match_length-lt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=lt){e.match_length--;do e.strstart++,e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+1]);else r=$i(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(jn(e,!1),e.strm.avail_out===0))return wn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=lt&&(e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=lt-1,n!==0&&e.prev_length4096)&&(e.match_length=lt-1)),e.prev_length>=lt&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-lt,r=$i(e,e.strstart-1-e.prev_match,e.prev_length-lt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=lt-1,e.strstart++,r&&(jn(e,!1),e.strm.avail_out===0))return wn}else if(e.match_available){if(r=$i(e,0,e.window[e.strstart-1]),r&&jn(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return wn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=$i(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const g=e.window;for(;;){if(e.lookahead<=Mi){if(Bo(e),e.lookahead<=Mi&&t===Bi)return wn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=lt&&e.strstart>0&&(i=e.strstart-1,r=g[i],r===g[++i]&&r===g[++i]&&r===g[++i])){l=e.strstart+Mi;do;while(r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=lt?(n=$i(e,1,e.match_length-lt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=$i(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(jn(e,!1),e.strm.avail_out===0))return wn}return e.insert=0,t===Gn?(jn(e,!0),e.strm.avail_out===0?Ba:Jo):e.sym_next&&(jn(e,!1),e.strm.avail_out===0)?wn:Zo},mY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Bo(e),e.lookahead===0)){if(t===Bi)return wn;break}if(e.match_length=0,n=$i(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(jn(e,!1),e.strm.avail_out===0))return wn}return e.insert=0,t===Gn?(jn(e,!0),e.strm.avail_out===0?Ba:Jo):e.sym_next&&(jn(e,!1),e.strm.avail_out===0)?wn:Zo};function wr(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const gs=[new wr(0,0,0,0,V2),new wr(4,4,8,4,rd),new wr(4,5,16,8,rd),new wr(4,6,32,32,rd),new wr(4,4,16,16,ao),new wr(8,16,32,32,ao),new wr(8,16,128,128,ao),new wr(8,32,128,256,ao),new wr(32,128,258,1024,ao),new wr(32,258,258,4096,ao)],gY=e=>{e.window_size=2*e.w_size,Ai(e.head),e.max_lazy_match=gs[e.level].max_lazy,e.good_match=gs[e.level].good_length,e.nice_match=gs[e.level].nice_length,e.max_chain_length=gs[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=lt-1,e.match_available=0,e.ins_h=0};function vY(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=lf,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(lY*2),this.dyn_dtree=new Uint16Array((2*oY+1)*2),this.bl_tree=new Uint16Array((2*sY+1)*2),Ai(this.dyn_ltree),Ai(this.dyn_dtree),Ai(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(uY+1),this.heap=new Uint16Array(2*Ph+1),Ai(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Ph+1),Ai(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ul=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==$o&&t.status!==wm&&t.status!==Ih&&t.status!==Mh&&t.status!==Lh&&t.status!==Rh&&t.status!==wa&&t.status!==ms?1:0},U2=e=>{if(Ul(e))return Ca(e,Pr);e.total_in=e.total_out=0,e.data_type=eY;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?wm:t.wrap?$o:wa,e.adler=t.wrap===2?0:1,t.last_flush=-2,UW(t),rn},H2=e=>{const t=U2(e);return t===rn&&gY(e.state),t},yY=(e,t)=>Ul(e)||e.state.wrap!==2?Pr:(e.state.gzhead=t,rn),W2=(e,t,n,r,i,l)=>{if(!e)return Pr;let g=1;if(t===GW&&(t=6),r<0?(g=0,r=-r):r>15&&(g=2,r-=16),i<1||i>tY||n!==lf||r<8||r>15||t<0||t>9||l<0||l>JW||r===8&&g!==1)return Ca(e,Pr);r===8&&(r=9);const o=new vY;return e.state=o,o.strm=e,o.status=$o,o.wrap=g,o.gzhead=null,o.w_bits=r,o.w_size=1<W2(e,t,lf,nY,rY,QW),_Y=(e,t)=>{if(Ul(e)||t>ny||t<0)return e?Ca(e,Pr):Pr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===ms&&t!==Gn)return Ca(e,e.avail_out===0?nd:Pr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if($n(e),e.avail_out===0)return n.last_flush=-1,rn}else if(e.avail_in===0&&iy(t)<=iy(r)&&t!==Gn)return Ca(e,nd);if(n.status===ms&&e.avail_in!==0)return Ca(e,nd);if(n.status===$o&&n.wrap===0&&(n.status=wa),n.status===$o){let i=lf+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=_u||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=cY),i+=31-i%31,us(n,i),n.strstart!==0&&(us(n,e.adler>>>16),us(n,e.adler&65535)),e.adler=1,n.status=wa,$n(e),n.pending!==0)return n.last_flush=-1,rn}if(n.status===wm){if(e.adler=0,mt(n,31),mt(n,139),mt(n,8),n.gzhead)mt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),mt(n,n.gzhead.time&255),mt(n,n.gzhead.time>>8&255),mt(n,n.gzhead.time>>16&255),mt(n,n.gzhead.time>>24&255),mt(n,n.level===9?2:n.strategy>=_u||n.level<2?4:0),mt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(mt(n,n.gzhead.extra.length&255),mt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Zt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Ih;else if(mt(n,0),mt(n,0),mt(n,0),mt(n,0),mt(n,0),mt(n,n.level===9?2:n.strategy>=_u||n.level<2?4:0),mt(n,fY),n.status=wa,$n(e),n.pending!==0)return n.last_flush=-1,rn}if(n.status===Ih){if(n.gzhead.extra){let i=n.pending,l=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+l>n.pending_buf_size;){let o=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+o),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,$n(e),n.pending!==0)return n.last_flush=-1,rn;i=0,l-=o}let g=new Uint8Array(n.gzhead.extra);n.pending_buf.set(g.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Mh}if(n.status===Mh){if(n.gzhead.name){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),$n(e),n.pending!==0)return n.last_flush=-1,rn;i=0}n.gzindexi&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Lh}if(n.status===Lh){if(n.gzhead.comment){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),$n(e),n.pending!==0)return n.last_flush=-1,rn;i=0}n.gzindexi&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i))}n.status=Rh}if(n.status===Rh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&($n(e),n.pending!==0))return n.last_flush=-1,rn;mt(n,e.adler&255),mt(n,e.adler>>8&255),e.adler=0}if(n.status=wa,$n(e),n.pending!==0)return n.last_flush=-1,rn}if(e.avail_in!==0||n.lookahead!==0||t!==Bi&&n.status!==ms){let i=n.level===0?V2(n,t):n.strategy===_u?mY(n,t):n.strategy===ZW?pY(n,t):gs[n.level].func(n,t);if((i===Ba||i===Jo)&&(n.status=ms),i===wn||i===Ba)return e.avail_out===0&&(n.last_flush=-1),rn;if(i===Zo&&(t===YW?WW(n):t!==ny&&(Ah(n,0,0,!1),t===XW&&(Ai(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),$n(e),e.avail_out===0))return n.last_flush=-1,rn}return t!==Gn?rn:n.wrap<=0?ry:(n.wrap===2?(mt(n,e.adler&255),mt(n,e.adler>>8&255),mt(n,e.adler>>16&255),mt(n,e.adler>>24&255),mt(n,e.total_in&255),mt(n,e.total_in>>8&255),mt(n,e.total_in>>16&255),mt(n,e.total_in>>24&255)):(us(n,e.adler>>>16),us(n,e.adler&65535)),$n(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?rn:ry)},wY=e=>{if(Ul(e))return Pr;const t=e.state.status;return e.state=null,t===wa?Ca(e,KW):rn},CY=(e,t)=>{let n=t.length;if(Ul(e))return Pr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==$o||r.lookahead)return Pr;if(i===1&&(e.adler=yl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Ai(r.head),r.strstart=0,r.block_start=0,r.insert=0);let a=new Uint8Array(r.w_size);a.set(t.subarray(n-r.w_size,n),0),t=a,n=r.w_size}const l=e.avail_in,g=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Bo(r);r.lookahead>=lt;){let a=r.strstart,u=r.lookahead-(lt-1);do r.ins_h=Fi(r,r.ins_h,r.window[a+lt-1]),r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++;while(--u);r.strstart=a,r.lookahead=lt-1,Bo(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=lt-1,r.match_available=0,e.next_in=g,e.input=o,e.avail_in=l,r.wrap=i,rn};var SY=bY,xY=W2,TY=H2,kY=U2,EY=yY,OY=_Y,AY=wY,PY=CY,IY="pako deflate (from Nodeca project)",Ds={deflateInit:SY,deflateInit2:xY,deflateReset:TY,deflateResetKeep:kY,deflateSetHeader:EY,deflate:OY,deflateEnd:AY,deflateSetDictionary:PY,deflateInfo:IY};const MY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var LY=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(!!n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)MY(n,r)&&(e[r]=n[r])}}return e},RY=e=>{let t=0;for(let r=0,i=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;bl[254]=bl[254]=1;var DY=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,g=e.length,o=0;for(i=0;i>>6,t[l++]=128|n&63):n<65536?(t[l++]=224|n>>>12,t[l++]=128|n>>>6&63,t[l++]=128|n&63):(t[l++]=240|n>>>18,t[l++]=128|n>>>12&63,t[l++]=128|n>>>6&63,t[l++]=128|n&63);return t};const $Y=(e,t)=>{if(t<65534&&e.subarray&&Y2)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i;const l=new Array(n*2);for(i=0,r=0;r4){l[i++]=65533,r+=o-1;continue}for(g&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}g<65536?l[i++]=g:(g-=65536,l[i++]=55296|g>>10&1023,l[i++]=56320|g&1023)}return $Y(l,i)},FY=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+bl[e[n]]>t?n:t},_l={string2buf:DY,buf2string:BY,utf8border:FY};function zY(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var X2=zY;const K2=Object.prototype.toString,{Z_NO_FLUSH:NY,Z_SYNC_FLUSH:jY,Z_FULL_FLUSH:VY,Z_FINISH:UY,Z_OK:Ec,Z_STREAM_END:HY,Z_DEFAULT_COMPRESSION:WY,Z_DEFAULT_STRATEGY:YY,Z_DEFLATED:XY}=qo;function Hl(e){this.options=uf.assign({level:WY,method:XY,chunkSize:16384,windowBits:15,memLevel:8,strategy:YY},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new X2,this.strm.avail_out=0;let n=Ds.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Ec)throw new Error($a[n]);if(t.header&&Ds.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=_l.string2buf(t.dictionary):K2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Ds.deflateSetDictionary(this.strm,r),n!==Ec)throw new Error($a[n]);this._dict_set=!0}}Hl.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,l;if(this.ended)return!1;for(t===~~t?l=t:l=t===!0?UY:NY,typeof e=="string"?n.input=_l.string2buf(e):K2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(l===jY||l===VY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=Ds.deflate(n,l),i===HY)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Ds.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Ec;if(n.avail_out===0){this.onData(n.output);continue}if(l>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};Hl.prototype.onData=function(e){this.chunks.push(e)};Hl.prototype.onEnd=function(e){e===Ec&&(this.result=uf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Cm(e,t){const n=new Hl(t);if(n.push(e,!0),n.err)throw n.msg||$a[n.err];return n.result}function KY(e,t){return t=t||{},t.raw=!0,Cm(e,t)}function GY(e,t){return t=t||{},t.gzip=!0,Cm(e,t)}var qY=Hl,ZY=Cm,JY=KY,QY=GY,eX=qo,tX={Deflate:qY,deflate:ZY,deflateRaw:JY,gzip:QY,constants:eX};const wu=16209,nX=16191;var rX=function(t,n){let r,i,l,g,o,a,u,d,c,f,s,h,v,m,y,b,_,w,S,x,T,E,I,D;const N=t.state;r=t.next_in,I=t.input,i=r+(t.avail_in-5),l=t.next_out,D=t.output,g=l-(n-t.avail_out),o=l+(t.avail_out-257),a=N.dmax,u=N.wsize,d=N.whave,c=N.wnext,f=N.window,s=N.hold,h=N.bits,v=N.lencode,m=N.distcode,y=(1<>>24,s>>>=w,h-=w,w=_>>>16&255,w===0)D[l++]=_&65535;else if(w&16){S=_&65535,w&=15,w&&(h>>=w,h-=w),h<15&&(s+=I[r++]<>>24,s>>>=w,h-=w,w=_>>>16&255,w&16){if(x=_&65535,w&=15,ha){t.msg="invalid distance too far back",N.mode=wu;break e}if(s>>>=w,h-=w,w=l-g,x>w){if(w=x-w,w>d&&N.sane){t.msg="invalid distance too far back",N.mode=wu;break e}if(T=0,E=f,c===0){if(T+=u-w,w2;)D[l++]=E[T++],D[l++]=E[T++],D[l++]=E[T++],S-=3;S&&(D[l++]=E[T++],S>1&&(D[l++]=E[T++]))}else{T=l-x;do D[l++]=D[T++],D[l++]=D[T++],D[l++]=D[T++],S-=3;while(S>2);S&&(D[l++]=D[T++],S>1&&(D[l++]=D[T++]))}}else if((w&64)===0){_=m[(_&65535)+(s&(1<>3,r-=S,h-=S<<3,s&=(1<{const a=o.bits;let u=0,d=0,c=0,f=0,s=0,h=0,v=0,m=0,y=0,b=0,_,w,S,x,T,E=null,I;const D=new Uint16Array(oo+1),N=new Uint16Array(oo+1);let L=null,F,O,V;for(u=0;u<=oo;u++)D[u]=0;for(d=0;d=1&&D[f]===0;f--);if(s>f&&(s=f),f===0)return i[l++]=1<<24|64<<16|0,i[l++]=1<<24|64<<16|0,o.bits=1,0;for(c=1;c0&&(e===sy||f!==1))return-1;for(N[1]=0,u=1;uay||e===ly&&y>oy)return 1;for(;;){F=u-v,g[d]+1=I?(O=L[g[d]-I],V=E[g[d]-I]):(O=32+64,V=0),_=1<>v)+w]=F<<24|O<<16|V|0;while(w!==0);for(_=1<>=1;if(_!==0?(b&=_-1,b+=_):b=0,d++,--D[u]===0){if(u===f)break;u=t[n+g[d]]}if(u>s&&(b&x)!==S){for(v===0&&(v=s),T+=c,h=u-v,m=1<ay||e===ly&&y>oy)return 1;S=b&x,i[S]=s<<24|h<<16|T-l|0}}return b!==0&&(i[T+b]=u-v<<24|64<<16|0),o.bits=s,0};var $s=lX;const uX=0,G2=1,q2=2,{Z_FINISH:uy,Z_BLOCK:cX,Z_TREES:Cu,Z_OK:Fa,Z_STREAM_END:fX,Z_NEED_DICT:dX,Z_STREAM_ERROR:tr,Z_DATA_ERROR:Z2,Z_MEM_ERROR:J2,Z_BUF_ERROR:hX,Z_DEFLATED:cy}=qo,cf=16180,fy=16181,dy=16182,hy=16183,py=16184,my=16185,gy=16186,vy=16187,yy=16188,by=16189,Oc=16190,Ur=16191,ad=16192,_y=16193,od=16194,wy=16195,Cy=16196,Sy=16197,xy=16198,Su=16199,xu=16200,Ty=16201,ky=16202,Ey=16203,Oy=16204,Ay=16205,sd=16206,Py=16207,Iy=16208,Bt=16209,Q2=16210,eC=16211,pX=852,mX=592,gX=15,vX=gX,My=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function yX(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ga=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modeeC?1:0},tC=e=>{if(Ga(e))return tr;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=cf,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(pX),t.distcode=t.distdyn=new Int32Array(mX),t.sane=1,t.back=-1,Fa},nC=e=>{if(Ga(e))return tr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,tC(e)},rC=(e,t)=>{let n;if(Ga(e))return tr;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?tr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,nC(e))},iC=(e,t)=>{if(!e)return tr;const n=new yX;e.state=n,n.strm=e,n.window=null,n.mode=cf;const r=rC(e,t);return r!==Fa&&(e.state=null),r},bX=e=>iC(e,vX);let Ly=!0,ld,ud;const _X=e=>{if(Ly){ld=new Int32Array(512),ud=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for($s(G2,e.lens,0,288,ld,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;$s(q2,e.lens,0,32,ud,0,e.work,{bits:5}),Ly=!1}e.lencode=ld,e.lenbits=9,e.distcode=ud,e.distbits=5},aC=(e,t,n,r)=>{let i;const l=e.state;return l.window===null&&(l.wsize=1<=l.wsize?(l.window.set(t.subarray(n-l.wsize,n),0),l.wnext=0,l.whave=l.wsize):(i=l.wsize-l.wnext,i>r&&(i=r),l.window.set(t.subarray(n-r,n-r+i),l.wnext),r-=i,r?(l.window.set(t.subarray(n-r,n),0),l.wnext=r,l.whave=l.wsize):(l.wnext+=i,l.wnext===l.wsize&&(l.wnext=0),l.whave{let n,r,i,l,g,o,a,u,d,c,f,s,h,v,m=0,y,b,_,w,S,x,T,E;const I=new Uint8Array(4);let D,N;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ga(e)||!e.output||!e.input&&e.avail_in!==0)return tr;n=e.state,n.mode===Ur&&(n.mode=ad),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,d=n.bits,c=o,f=a,E=Fa;e:for(;;)switch(n.mode){case cf:if(n.wrap===0){n.mode=ad;break}for(;d<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Zt(n.check,I,2,0),u=0,d=0,n.mode=fy;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Bt;break}if((u&15)!==cy){e.msg="unknown compression method",n.mode=Bt;break}if(u>>>=4,d-=4,T=(u&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=Bt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(I[0]=u&255,I[1]=u>>>8&255,n.check=Zt(n.check,I,2,0)),u=0,d=0,n.mode=dy;case dy:for(;d<32;){if(o===0)break e;o--,u+=r[l++]<>>8&255,I[2]=u>>>16&255,I[3]=u>>>24&255,n.check=Zt(n.check,I,4,0)),u=0,d=0,n.mode=hy;case hy:for(;d<16;){if(o===0)break e;o--,u+=r[l++]<>8),n.flags&512&&n.wrap&4&&(I[0]=u&255,I[1]=u>>>8&255,n.check=Zt(n.check,I,2,0)),u=0,d=0,n.mode=py;case py:if(n.flags&1024){for(;d<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Zt(n.check,I,2,0)),u=0,d=0}else n.head&&(n.head.extra=null);n.mode=my;case my:if(n.flags&1024&&(s=n.length,s>o&&(s=o),s&&(n.head&&(T=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(l,l+s),T)),n.flags&512&&n.wrap&4&&(n.check=Zt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=gy;case gy:if(n.flags&2048){if(o===0)break e;s=0;do T=r[l+s++],n.head&&T&&n.length<65536&&(n.head.name+=String.fromCharCode(T));while(T&&s>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Ur;break;case by:for(;d<32;){if(o===0)break e;o--,u+=r[l++]<>>=d&7,d-=d&7,n.mode=sd;break}for(;d<3;){if(o===0)break e;o--,u+=r[l++]<>>=1,d-=1,u&3){case 0:n.mode=_y;break;case 1:if(_X(n),n.mode=Su,t===Cu){u>>>=2,d-=2;break e}break;case 2:n.mode=Cy;break;case 3:e.msg="invalid block type",n.mode=Bt}u>>>=2,d-=2;break;case _y:for(u>>>=d&7,d-=d&7;d<32;){if(o===0)break e;o--,u+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Bt;break}if(n.length=u&65535,u=0,d=0,n.mode=od,t===Cu)break e;case od:n.mode=wy;case wy:if(s=n.length,s){if(s>o&&(s=o),s>a&&(s=a),s===0)break e;i.set(r.subarray(l,l+s),g),o-=s,l+=s,a-=s,g+=s,n.length-=s;break}n.mode=Ur;break;case Cy:for(;d<14;){if(o===0)break e;o--,u+=r[l++]<>>=5,d-=5,n.ndist=(u&31)+1,u>>>=5,d-=5,n.ncode=(u&15)+4,u>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Bt;break}n.have=0,n.mode=Sy;case Sy:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[L[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,D={bits:n.lenbits},E=$s(uX,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid code lengths set",n.mode=Bt;break}n.have=0,n.mode=xy;case xy:for(;n.have>>24,b=m>>>16&255,_=m&65535,!(y<=d);){if(o===0)break e;o--,u+=r[l++]<>>=y,d-=y,n.lens[n.have++]=_;else{if(_===16){for(N=y+2;d>>=y,d-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=Bt;break}T=n.lens[n.have-1],s=3+(u&3),u>>>=2,d-=2}else if(_===17){for(N=y+3;d>>=y,d-=y,T=0,s=3+(u&7),u>>>=3,d-=3}else{for(N=y+7;d>>=y,d-=y,T=0,s=11+(u&127),u>>>=7,d-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Bt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===Bt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Bt;break}if(n.lenbits=9,D={bits:n.lenbits},E=$s(G2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid literal/lengths set",n.mode=Bt;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},E=$s(q2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,E){e.msg="invalid distances set",n.mode=Bt;break}if(n.mode=Su,t===Cu)break e;case Su:n.mode=xu;case xu:if(o>=6&&a>=258){e.next_out=g,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=u,n.bits=d,rX(e,f),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,d=n.bits,n.mode===Ur&&(n.back=-1);break}for(n.back=0;m=n.lencode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=d);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=d);){if(o===0)break e;o--,u+=r[l++]<>>=w,d-=w,n.back+=w}if(u>>>=y,d-=y,n.back+=y,n.length=_,b===0){n.mode=Ay;break}if(b&32){n.back=-1,n.mode=Ur;break}if(b&64){e.msg="invalid literal/length code",n.mode=Bt;break}n.extra=b&15,n.mode=Ty;case Ty:if(n.extra){for(N=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=ky;case ky:for(;m=n.distcode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=d);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=d);){if(o===0)break e;o--,u+=r[l++]<>>=w,d-=w,n.back+=w}if(u>>>=y,d-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=Bt;break}n.offset=_,n.extra=b&15,n.mode=Ey;case Ey:if(n.extra){for(N=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Bt;break}n.mode=Oy;case Oy:if(a===0)break e;if(s=f-a,n.offset>s){if(s=n.offset-s,s>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Bt;break}s>n.wnext?(s-=n.wnext,h=n.wsize-s):h=n.wnext-s,s>n.length&&(s=n.length),v=n.window}else v=i,h=g-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[g++]=v[h++];while(--s);n.length===0&&(n.mode=xu);break;case Ay:if(a===0)break e;i[g++]=n.length,a--,n.mode=xu;break;case sd:if(n.wrap){for(;d<32;){if(o===0)break e;o--,u|=r[l++]<{if(Ga(e))return tr;let t=e.state;return t.window&&(t.window=null),e.state=null,Fa},SX=(e,t)=>{if(Ga(e))return tr;const n=e.state;return(n.wrap&2)===0?tr:(n.head=t,t.done=!1,Fa)},xX=(e,t)=>{const n=t.length;let r,i,l;return Ga(e)||(r=e.state,r.wrap!==0&&r.mode!==Oc)?tr:r.mode===Oc&&(i=1,i=yl(i,t,n,0),i!==r.check)?Z2:(l=aC(e,t,n,n),l?(r.mode=Q2,J2):(r.havedict=1,Fa))};var TX=nC,kX=rC,EX=tC,OX=bX,AX=iC,PX=wX,IX=CX,MX=SX,LX=xX,RX="pako inflate (from Nodeca project)",qr={inflateReset:TX,inflateReset2:kX,inflateResetKeep:EX,inflateInit:OX,inflateInit2:AX,inflate:PX,inflateEnd:IX,inflateGetHeader:MX,inflateSetDictionary:LX,inflateInfo:RX};function DX(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var $X=DX;const oC=Object.prototype.toString,{Z_NO_FLUSH:BX,Z_FINISH:FX,Z_OK:wl,Z_STREAM_END:cd,Z_NEED_DICT:fd,Z_STREAM_ERROR:zX,Z_DATA_ERROR:Ry,Z_MEM_ERROR:NX}=qo;function Wl(e){this.options=uf.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new X2,this.strm.avail_out=0;let n=qr.inflateInit2(this.strm,t.windowBits);if(n!==wl)throw new Error($a[n]);if(this.header=new $X,qr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=_l.string2buf(t.dictionary):oC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=qr.inflateSetDictionary(this.strm,t.dictionary),n!==wl)))throw new Error($a[n])}Wl.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,g,o;if(this.ended)return!1;for(t===~~t?g=t:g=t===!0?FX:BX,oC.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),l=qr.inflate(n,g),l===fd&&i&&(l=qr.inflateSetDictionary(n,i),l===wl?l=qr.inflate(n,g):l===Ry&&(l=fd));n.avail_in>0&&l===cd&&n.state.wrap>0&&e[n.next_in]!==0;)qr.inflateReset(n),l=qr.inflate(n,g);switch(l){case zX:case Ry:case fd:case NX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===cd))if(this.options.to==="string"){let a=_l.utf8border(n.output,n.next_out),u=n.next_out-a,d=_l.buf2string(n.output,a);n.next_out=u,n.avail_out=r-u,u&&n.output.set(n.output.subarray(a,a+u),0),this.onData(d)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===wl&&o===0)){if(l===cd)return l=qr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Wl.prototype.onData=function(e){this.chunks.push(e)};Wl.prototype.onEnd=function(e){e===wl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=uf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Sm(e,t){const n=new Wl(t);if(n.push(e),n.err)throw n.msg||$a[n.err];return n.result}function jX(e,t){return t=t||{},t.raw=!0,Sm(e,t)}var VX=Wl,UX=Sm,HX=jX,WX=Sm,YX=qo,XX={Inflate:VX,inflate:UX,inflateRaw:HX,ungzip:WX,constants:YX};const{Deflate:oq,deflate:sq,deflateRaw:KX,gzip:lq}=tX,{Inflate:uq,inflate:cq,inflateRaw:GX,ungzip:fq}=XX;var qX=KX,ZX=GX;function Dy(e){const t=new Map;for(const n of e){const[r,i]=n.split("="),l=decodeURIComponent(i);t.set(r,l)}return t}const JX=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=Dy(t);if(console.log("URL params:",n),n.get("share")){const l=ZX(new Uint8Array(atob(n.get("share")).split("").map(g=>g.charCodeAt(0))),{to:"string"});if(!l){Ut().raiseError("Error when trying to decode share parameter!",!1);return}n=Dy(l.split("&")),console.log("Share URL params:",n)}const r={id:-1,image:"",prompt:n.get("prompt")||"",sampler_name:n.get("sampler_name")||"k_euler",seed:Number(n.get("seed"))||-1,steps:Number(n.get("steps")||20),cfg_scale:Number(n.get("cfg_scale")||5),height:Number(n.get("height")||512),width:Number(n.get("width")||512),clip_skip:Number(n.get("clip_skip")||0),frames:Number(n.get("frames")||1),fps:Number(n.get("fps")||16),scheduler:n.get("scheduler")||"default"};Jt().generateText2Img(r,!1)},QX=10;function Ku(e,t,n,r,i=l=>Ut().raiseError(l,!1)){if(e.status===n&&t)return!0;if(!t.message)return i(`${r}: Got response code ${e.status}`);if(!t.errors)return i(`${r}: ${t.message}`);const l=Object.entries(t.errors).map(g=>`${g[0]} - ${g[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}const eK=zo("interrogate",()=>{const e=oe({}),t=oe(!1);async function n(g){Ut().raiseError(g,!1),t.value=!1,e.value={}}async function r(){const g=zt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/interrogate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),u=await a.json();!Ku(a,u,200,"Failed to get interrogation",n)||(e.value.id=u.id,e.value.status=u.caption)}function i(){e.value={},t.value=!1}function l(){return e.value.status||!1}return{currentInterrogation:e,interrogating:t,interrogateImage:r,getFormStatus:l,resetInterrogation:i}}),xm=e=>(ui("data-v-db184ac6"),e=e(),ci(),e),tK={key:0,style:{"margin-top":"16px"}},nK=xm(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),rK={key:1,style:{"margin-top":"16px"}},iK={key:2},aK={style:{"margin-top":"8px"}},oK=xm(()=>ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),sK={key:0},lK=xm(()=>ne("h3",null,"Caption",-1)),uK={key:0},cK={key:1},fK=Ee({__name:"InterrogationView",setup(e){const t=eK(),n=Jt(),r=Ut(),i=oe();async function l(u){if(i.value.clearFiles(),!u.raw.type.includes("image")){r.raiseError("Uploaded file needs to be a image!",!1);return}const d=await Tc(u.raw);t.currentInterrogation.source_image=d,t.interrogateImage()}function g(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=x2();return(u,d)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(z(),se("div",iK,[ne("div",aK,[le(C(at),{icon:C(Mg),onClick:C(t).resetInterrogation},{default:he(()=>[He("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(z(),be(C(at),{key:0,icon:C(Mg),onClick:g,disabled:!C(o)},{default:he(()=>[He("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):ye("",!0)]),oK,le(C(ef),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(z(),se("div",sK,[lK,C(o)?(z(),se("div",cK,[ne("strong",null,Ae(C(o)),1)])):(z(),se("div",uK,"Processing"+Ae(C(a)),1))])):ye("",!0)])):(z(),se("div",rK,[ne("strong",null,"Uploading image"+Ae(C(a)),1)])):(z(),se("div",tK,[ne("div",null,[le(C(Yp),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:he(()=>[le(C(Le),{size:100},{default:he(()=>[le(C(dp))]),_:1}),nK]),_:1},512)])]))}});const dK=qt(fK,[["__scopeId","data-v-db184ac6"]]);function hK(e,t,n){if(e===0)return"0"+(t?"s":"seconds");if(e==null)return"?";const r=Math.floor(e/86400),i=Math.floor(e%86400/3600),l=Math.floor(e%86400%3600/60),g=Math.floor(e%86400%3600%60),o=r>0?r+(t?"d":"days"):"",a=i>0?i+(t?"h":"hours"):"",u=l>0?l+(t?"m":"minutes"):"",d=g>0?g+(t?"s":"seconds"):"",c=[];return n!=null&&n.days&&c.push(o),n!=null&&n.hours&&c.push(a),n!=null&&n.minutes&&c.push(u),n!=null&&n.seconds&&c.push(d),c.join(" ")}const pK={class:"form"},mK={key:0,style:{"padding-bottom":"50px"}},gK=ne("h1",{style:{margin:"0"}},"Interrogation",-1),vK=ne("div",null,"Interrogate images to get their predicted descriptions.",-1),yK={class:"sidebar"},bK={class:"reference-images-header"},_K=ne("span",{class:"reference-images-label"},"Reference Images",-1),wK={class:"reference-images-actions"},CK={key:0,class:"reference-image-list"},SK={class:"reference-image-index"},xK=["title"],TK={class:"reference-image-controls"},kK={key:1,class:"reference-image-empty"},EK={class:"main"},OK={class:"image center-horizontal"},AK={key:0},PK=Ee({__name:"GenerateView",setup(e){const n=Ep(kp).smallerOrEqual("md"),r=Jt(),i=Ut(),l=Ls();zt();const g=gv(async()=>{const m=r.cacheVersion,b=(await r.getAvailableSamplers()).map(_=>_.name);return b.length===0?[]:u(b)},[]),o=gv(async()=>{const m=r.cacheVersion,b=(await r.getAvailableSchedulers()).map(_=>_.name);return b.length===0?[]:d(b)},[]),a=yt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function u(m){return!r.params||!r.params.sampler_name||m.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=m[0]),m}function d(m){return!r.params||!r.params.scheduler||m.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=m[0]),m}function c(m){return"Elapsed: "+hK(m,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function f(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function s(m){r.generatorType=m,f(),console.log(m)}function h(){l.showCropPreview=!0,l.updateCropPreview()}function v(){var m;(m=document.getElementById("extra_image_input"))==null||m.click()}return f(),JX(),(m,y)=>(z(),se(je,null,[le(C(mw),{"default-active":C(r).generatorType,collapse:!0,onSelect:s,mode:C(n)?"horizontal":"vertical",class:de(C(n)?"mobile-generator-types":"generator-types"),style:ze(C(n)?"overflow-x: auto":"")},{default:he(()=>[le(bu,{index:"Text2Img","icon-one":C(EE),"icon-two":C(tu),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(bu,{index:"Img2Img","icon-one":C(tu),"icon-two":C(tu),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(bu,{index:"Inpainting","icon-one":S2,"icon-two":C(tu),isMobile:C(n)},null,8,["icon-two","isMobile"]),le(bu,{index:"Interrogation","icon-one":gH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",pK,[C(r).generatorType==="Interrogation"?(z(),se("div",mK,[gK,vK,le(dK)])):(z(),be(C(jp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:a,onSubmit:y[31]||(y[31]=et(()=>{},["prevent"]))},{default:he(()=>[ne("div",yK,[le(RH),le(kh,{label:"Negative Prompt",prop:"negativePrompt",modelValue:C(r).negativePrompt,"onUpdate:modelValue":y[0]||(y[0]=b=>C(r).negativePrompt=b),autosize:{maxRows:15},resize:"vertical",type:"textarea",placeholder:"Enter negative prompt here",info:"What to exclude from the image. Not working? Try increasing the guidance.","label-position":"top"},null,8,["modelValue"]),le(kh,{label:"Seed",prop:"seed",modelValue:C(r).params.seed,"onUpdate:modelValue":y[2]||(y[2]=b=>C(r).params.seed=b),placeholder:"Enter seed here",clearable:"","clear-icon":C(gE)},{append:he(()=>[le(C(zn),{content:"Randomize!",placement:"top"},{default:he(()=>[le(C(at),{icon:C(X3),onClick:y[1]||(y[1]=()=>C(r).params.seed=C(sC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(z(),be(C(b0),{key:0,gutter:10},{default:he(()=>[C(r).multiSelect.sampler.state==="Multiple"?(z(),be(C(to),{key:0,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Sampler(s)",prop:"samplers",modelValue:C(r).multiSelect.sampler.selected,"onUpdate:modelValue":y[3]||(y[3]=b=>C(r).multiSelect.sampler.selected=b),options:C(g),info:"Multi-select enabled. Heun and DPM2 double generation time per step, but converge twice as fast.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0),C(r).multiSelect.sampler.state==="Enabled"?(z(),be(C(to),{key:1,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Sampler",prop:"sampler",modelValue:C(r).params.sampler_name,"onUpdate:modelValue":y[4]||(y[4]=b=>C(r).params.sampler_name=b),options:C(g),info:"Heun and DPM2 double generation time per step, but converge twice as fast."},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0),C(r).multiSelect.scheduler.state==="Multiple"?(z(),be(C(to),{key:2,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Scheduler(s)",prop:"schedulers",modelValue:C(r).multiSelect.scheduler.selected,"onUpdate:modelValue":y[5]||(y[5]=b=>C(r).multiSelect.scheduler.selected=b),options:C(o),info:"Multi-select enabled. Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0),C(r).multiSelect.scheduler.state==="Enabled"?(z(),be(C(to),{key:3,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Scheduler",prop:"scheduler",modelValue:C(r).params.scheduler,"onUpdate:modelValue":y[6]||(y[6]=b=>C(r).params.scheduler=b),options:C(o),info:"Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise."},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0)]),_:1})),le(bn,{label:"Batch Size",prop:"batchSize",modelValue:C(r).params.n,"onUpdate:modelValue":y[7]||(y[7]=b=>C(r).params.n=b),min:C(r).minImages,max:C(r).maxImages},null,8,["modelValue","min","max"]),C(r).multiSelect.steps.state==="Multiple"?(z(),be(bn,{key:1,label:"Steps(s)",prop:"multiSteps",modelValue:C(r).multiSelect.steps.selected,"onUpdate:modelValue":y[8]||(y[8]=b=>C(r).multiSelect.steps.selected=b),min:C(r).minSteps,max:C(r).maxSteps,info:"Multi-select enabled. Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed.",multiple:""},null,8,["modelValue","min","max"])):C(r).multiSelect.steps.state==="Enabled"?(z(),be(bn,{key:2,label:"Steps",prop:"steps",modelValue:C(r).params.steps,"onUpdate:modelValue":y[9]||(y[9]=b=>C(r).params.steps=b),min:C(r).minSteps,max:C(r).maxSteps,info:"Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed."},null,8,["modelValue","min","max"])):ye("",!0),le(bn,{label:"Width",prop:"width",modelValue:C(r).params.width,"onUpdate:modelValue":y[10]||(y[10]=b=>C(r).params.width=b),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:h},null,8,["modelValue","min","max"]),le(bn,{label:"Height",prop:"height",modelValue:C(r).params.height,"onUpdate:modelValue":y[11]||(y[11]=b=>C(r).params.height=b),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:h},null,8,["modelValue","min","max"]),C(r).multiSelect.guidance.state==="Multiple"?(z(),be(bn,{key:3,label:"Guidance(s)",prop:"cfgScales",modelValue:C(r).multiSelect.guidance.selected,"onUpdate:modelValue":y[12]||(y[12]=b=>C(r).multiSelect.guidance.selected=b),min:C(r).minCfgScale,max:C(r).maxCfgScale,info:"Multi-select enabled. Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative.",multiple:""},null,8,["modelValue","min","max"])):C(r).multiSelect.guidance.state==="Enabled"?(z(),be(bn,{key:4,label:"Guidance",prop:"cfgScale",modelValue:C(r).params.cfg_scale,"onUpdate:modelValue":y[13]||(y[13]=b=>C(r).params.cfg_scale=b),min:C(r).minCfgScale,max:C(r).maxCfgScale,step:.5,info:"Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative."},null,8,["modelValue","min","max","step"])):ye("",!0),C(r).multiSelect.eta.state==="Enabled"?(z(),be(bn,{key:5,label:"Eta",prop:"eta",modelValue:C(r).params.eta,"onUpdate:modelValue":y[14]||(y[14]=b=>C(r).params.eta=b),min:C(r).minEta,max:C(r).maxEta,step:.1,info:"Noise multiplier for ancestral samplers. 0 disables noise injection."},null,8,["modelValue","min","max","step"])):ye("",!0),C(r).multiSelect.clipSkip.state==="Multiple"?(z(),be(bn,{key:6,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:C(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":y[15]||(y[15]=b=>C(r).multiSelect.clipSkip.selected=b),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Multi-select enabled. Last layers of CLIP to ignore. For most situations this can be left alone.",multiple:""},null,8,["modelValue","min","max"])):C(r).multiSelect.clipSkip.state==="Enabled"?(z(),be(bn,{key:7,label:"CLIP Skip",prop:"clipSkip",modelValue:C(r).params.clip_skip,"onUpdate:modelValue":y[16]||(y[16]=b=>C(r).params.clip_skip=b),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Last layers of CLIP to ignore. For most situations this can be left alone."},null,8,["modelValue","min","max"])):ye("",!0),C(r).sourceGeneratorTypes.includes(C(r).generatorType)?(z(),be(bn,{key:8,label:"Init Strength",prop:"denoise",modelValue:C(r).params.denoising_strength,"onUpdate:modelValue":y[17]||(y[17]=b=>C(r).params.denoising_strength=b),min:C(r).minDenoise,max:C(r).maxDenoise,step:.01,info:"The final image will diverge from the starting image at higher values. 0=unchanged, 1=fullychanged"},null,8,["modelValue","min","max","step"])):ye("",!0),le(bn,{label:"Video Frames",prop:"frames",modelValue:C(r).params.frames,"onUpdate:modelValue":y[18]||(y[18]=b=>C(r).params.frames=b),min:C(r).minFrames,max:C(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). More frames increases memory usage."},null,8,["modelValue","min","max"]),C(r).params.frames>1?(z(),be(bn,{key:9,label:"FPS",prop:"fps",modelValue:C(r).params.fps,"onUpdate:modelValue":y[19]||(y[19]=b=>C(r).params.fps=b),min:C(r).minFps,max:C(r).maxFps,disabled:C(r).params.frames<=1,info:"Frames per second for video generation."},null,8,["modelValue","min","max","disabled"])):ye("",!0),ne("div",{class:"reference-images",onDragover:y[22]||(y[22]=et(()=>{},["prevent"])),onDrop:y[23]||(y[23]=et(b=>C(r).setExtraImage(b),["prevent"]))},[ne("div",bK,[_K,ne("div",wK,[ne("input",{class:"reference-images-input",type:"file",id:"extra_image_input",onChange:y[20]||(y[20]=b=>C(r).setExtraImage(b)),accept:"image/*",multiple:""},null,32),le(C(at),{onClick:v},{default:he(()=>[He(" Select or Drag Files ")]),_:1}),le(C(at),{onClick:y[21]||(y[21]=b=>C(r).clearExtraImage()),disabled:C(r).referenceImages.length===0},{default:he(()=>[He(" Clear Images ")]),_:1},8,["disabled"])])]),C(r).referenceImages.length>0?(z(),se("div",CK,[(z(!0),se(je,null,Nt(C(r).referenceImages,(b,_)=>(z(),se("div",{class:"reference-image-item",key:b.id},[ne("span",SK,Ae(_+1),1),le(C(ef),{class:"reference-image-thumb",src:b.dataUrl,fit:"cover","preview-src-list":C(r).referenceImages.map(w=>w.dataUrl),"initial-index":_,"preview-teleported":""},null,8,["src","preview-src-list","initial-index"]),ne("span",{class:"reference-image-name",title:b.name},Ae(b.name),9,xK),ne("div",TK,[le(C(zn),{content:"Move up",placement:"top"},{default:he(()=>[le(C(at),{class:"small-btn",icon:C(f_),disabled:_===0,onClick:w=>C(r).moveExtraImage(_,-1)},null,8,["icon","disabled","onClick"])]),_:2},1024),le(C(zn),{content:"Move down",placement:"top"},{default:he(()=>[le(C(at),{class:"small-btn",icon:C(Tl),disabled:_===C(r).referenceImages.length-1,onClick:w=>C(r).moveExtraImage(_,1)},null,8,["icon","disabled","onClick"])]),_:2},1024),le(C(zn),{content:"Remove",placement:"top"},{default:he(()=>[le(C(at),{class:"small-btn",type:"danger",icon:C(Ol),plain:"",onClick:w=>C(r).removeExtraImage(_)},null,8,["icon","onClick"])]),_:2},1024)])]))),128))])):(z(),se("div",kK," No reference images selected. "))],32),le(C(b0),null,{default:he(()=>[le(C(to),{span:C(n)?24:12},{default:he(()=>[le(qf,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":y[24]||(y[24]=b=>C(r).params.enable_hr=b),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),le(C(to),{span:C(n)?24:12},{default:he(()=>[C(r).generatorType==="Img2Img"?(z(),be(qf,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:C(r).params.send_as_refimg,"onUpdate:modelValue":y[25]||(y[25]=b=>C(r).params.send_as_refimg=b),info:"Instead of regular Img2Img, send the image as a reference image for edit models."},null,8,["modelValue"])):ye("",!0),C(r).generatorType==="Img2Img"&&C(r).params.send_as_refimg&&C(r).params.frames>1?(z(),be(qf,{key:1,label:"Reverse RefImg",prop:"reverse_refimg",modelValue:C(r).params.reverse_refimg,"onUpdate:modelValue":y[26]||(y[26]=b=>C(r).params.reverse_refimg=b),info:"Use the reference image as the final frame instead of the first frame."},null,8,["modelValue"])):ye("",!0)]),_:1},8,["span"])]),_:1})]),ne("div",EK,[le(C(at),{onClick:y[27]||(y[27]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:he(()=>[He("Reset")]),_:1}),le(C(at),{type:"primary",class:"generate-cancel-btn",style:ze(C(r).generating?"width: 55%;":""),onClick:y[28]||(y[28]=()=>C(r).generateImage(C(r).generatorType))},{default:he(()=>[ne("span",null," Generate "+Ae(C(r).totalImageCount)+" image"+Ae(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(z(),be(C(at),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:y[29]||(y[29]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:he(()=>[He("Cancel all")]),_:1},8,["disabled"])):ye("",!0)]),ne("div",OK,[le(C(g$),{class:"center-both generated-image"},{default:he(()=>[!C(r).generating&&C(r).outputs.length==0?(z(),se("div",AK,[/Inpainting/.test(C(r).generatorType)?(z(),be(K0,{key:0})):ye("",!0),/Img2Img/.test(C(r).generatorType)?(z(),be(K0,{key:1})):ye("",!0)])):ye("",!0),!C(i).showGeneratedImages&&C(r).generating?(z(),be(xH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:c(C(r).timer.seconds),onShowGenerated:y[30]||(y[30]=b=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):ye("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(z(),be(HH,{key:2})):ye("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Bs=uk({history:kT("./"),routes:[{path:"/",name:"generate",component:PK},{path:"/images",name:"images",component:()=>Gf(()=>Promise.resolve().then(()=>RG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>Gf(()=>Promise.resolve().then(()=>XG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>Gf(()=>Promise.resolve().then(()=>nq),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function IK(e){const t=[],n=/]+):([^>]+)>/g;return[e.replace(n,(i,l,g)=>{if(g.trim()==="")return"";const o=Number(g);if(isNaN(o))return"";let a=l,u=!1;const d="|high_noise|";return a.startsWith(d)&&(a=a.substring(d.length),u=!0),t.push({name:a,multiplier:o,...u?{is_high_noise:!0}:{}}),""}),t]}function Tu(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,eta:1,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,fps:16,enable_hr:!1,send_as_refimg:!0,reverse_refimg:!1,scheduler:"default"}}function sC(){return Math.floor(Math.random()*9999999)+1}const Jt=zo("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=oe("Text2Img"),r=oe(""),i=kn("promptHistory",[]),l=oe(""),g=kn("negativeLibrary",[]),o=oe(Tu()),a=oe({interval:0,seconds:0}),u=oe({sampler:{name:"Sampler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.sampler_name],mapToParam:Ce=>Ce.sampler_name},scheduler:{name:"Scheduler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.scheduler],mapToParam:Ce=>Ce.scheduler},steps:{name:"Steps",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.steps],mapToParam:Ce=>Ce.steps},guidance:{name:"CFG Scale",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.cfg_scale],mapToParam:Ce=>Ce.cfg_scale},clipSkip:{name:"Clip Skip",state:"Disabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.clip_skip],mapToParam:Ce=>Ce.clip_skip},eta:{name:"Eta",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.eta],mapToParam:Ce=>Ce.eta}}),d=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),c=oe({...d(),sourceProcessing:"inpainting"}),f=oe({...d(),sourceProcessing:"img2img"}),s=Ce=>Ce==="Inpainting"?c.value:Ce==="Img2Img"?f.value:d(),h=ee(()=>s(n.value)),v=oe(""),m=oe(!1),y=oe(!1),b=oe([]),_=oe([]),w=oe(64),S=ee(()=>zt().allowLargerParams==="Enabled"?3072:1024),x=oe(1),T=oe(20),E=oe(1),I=ee(()=>zt().allowLargerParams==="Enabled"?150:50),D=oe(1),N=oe(24),L=oe(0),F=oe(1),O=oe(0),V=oe(1),re=oe(0),J=oe(10),ue=oe(1),M=ee(()=>zt().allowLargerParams==="Enabled"?400:200),U=oe(16),R=ee(()=>zt().allowLargerParams==="Enabled"?32:24),P=(Ce,Ve,Ne)=>Array.from({length:(Ve-Ce+1)/Ne},(Ue,pt)=>(pt+Ce)*Ne),Q=oe(P(re.value,J.value,1)),j=oe(P(D.value,N.value,.5)),A=ee(()=>{const Ce=(yr,Ln,es=1)=>yr*(Ln.state==="Multiple"&&Ln.selected.length>0?Ln.selected.length:es),Ne=o.value.n*B().length,Ue=Ce(Ne,u.value.sampler),pt=Ce(Ue,u.value.scheduler),Ze=Ce(pt,u.value.steps),ln=Ce(Ze,u.value.guidance);return Ce(ln,u.value.clipSkip)});function q(){return o.value=Tu(),c.value=d(),f.value=d(),b.value=[],Ut().showGeneratedImages=!1,G(),!0}function G(){_.value=[]}function te(){b.value=[]}async function fe(){const Ce=zt(),Ve=Ce.baseURL.length===0?".":Ce.baseURL,Ne=await fetch(`${Ve}/sdapi/v1/loras`),Ue=await Ne.json();return Ku(Ne,Ue,200,"Failed to get available LoRAs")?Ue:[]}async function pe(Ce){if(!e.includes(Ce))return[];if(r.value==="")return H("Failed to generate: No prompt submitted.");const Ve=Ls(),Ne=Ut();Ve.saveImages();const{sourceImage:Ue,maskImage:pt,sourceProcessing:Ze}=s(Ce);_e(r.value);const ln=[],yr=B().map(rt=>{const Vt=rt.split(" ### ");return{full_prompt:rt,prompt:Vt[0],negative_prompt:Vt[1]||""}}).map(rt=>{const[Vt,zr]=IK(rt.prompt);return{...rt,prompt:Vt,extractedLoras:zr}}),Ln=yr.some(rt=>rt.extractedLoras.length>0)?await fe():[],es=yr.map(({extractedLoras:rt,...Vt})=>{const zr=rt.length>0&&Ln.length>0?rt.map(rr=>{const Ji=Ln.find(Qi=>Qi.name===rr.name||Qi.path===rr.name);return{path:Ji?Ji.path:rr.name,multiplier:rr.multiplier,...rr.is_high_noise?{is_high_noise:!0}:{}}}):[];return{...Vt,...zr.length>0?{lora:zr}:{}}}),{seed:Zi,cfg_scale:br,eta:km,steps:Fr,clip_skip:pC,sampler_name:mC,scheduler:gC,n:vC,...Xl}=o.value,df=parseInt(Zi.toString()),yC=isNaN(df)||df<0?sC():df,bC=Array.from({length:vC},(rt,Vt)=>yC+Vt),Za=(rt,Vt)=>rt.state==="Disabled"?[]:rt.state==="Enabled"?[Vt]:rt.state==="Multiple"&&rt.selected.length===0?[]:rt.selected,_C={promptVariant:es,seed:bC,cfg_scale:Za(u.value.guidance,br),eta:Za(u.value.eta,km),steps:Za(u.value.steps,Fr),clip_skip:Za(u.value.clipSkip,pC),sampler_name:Za(u.value.sampler,mC),scheduler:Za(u.value.scheduler,gC)},wC=(rt=>Object.entries(rt).filter(([zr,rr])=>rr.length>0).reduce((zr,[rr,Ji])=>{const Qi=[];for(const nn of zr)for(const Kl of Ji)Qi.push({...nn,[rr]:Kl});return Qi},[{}]))(_C),CC=[await ie()];for(const rt of wC){const{promptVariant:{full_prompt:Vt,...zr},...rr}=rt,Ji=Ce==="Img2Img"?Xl.send_as_refimg:!1,Qi=Ji&&Xl.frames>1?Xl.reverse_refimg:!1;let nn={prompt:Vt,params:{...Xl,send_as_refimg:Ji,reverse_refimg:Qi,...rr,...zr,init_images:Ue?[Ue.split(",")[1]]:[],mask:pt,inpainting_mask_invert:pt?0:null,inpainting_fill:pt?1:null},source_image:Ue==null?void 0:Ue.split(",")[1],source_mask:pt,source_processing:Ze,models:CC};nn.params.sampler_name=="default"&&delete nn.params.sampler_name,nn.params.scheduler=="default"&&delete nn.params.scheduler,!nn.params.frames||nn.params.frames<=1?(delete nn.params.frames,delete nn.params.fps):nn.params.fps=Math.min(R.value,Math.max(U.value,Math.round(Number(nn.params.fps)||Tu().fps)));const Kl=Me.value.map(SC=>SC.base64);Kl.length>0&&(nn.params.extra_images=Kl),zt().alsoRequestAvi==="Enabled"&&nn.params.frames&&nn.params.frames>1&&(nn.params.video_output_type=2),ln.push(nn)}let Em=!1;m.value||(Em=!0,b.value=[]),m.value=!0,Ne.showGeneratedImages=!1;let Om=_.value.filter(rt=>!rt.gathered&&!rt.failed).length;for(let rt=0;rt{a.value.seconds++},1e3);!_.value.every(rt=>rt.gathered||rt.failed)&&!y.value;){const rt=_.value.find(Vt=>!Vt.gathered&&!Vt.failed);if(!rt)break;rt.gathered=!0;try{const Vt=await K(rt.params);if(!Vt){rt.failed=!0;continue}ve([{...Vt,...rt}])}catch(Vt){rt.failed=!0,console.error("Error fetching image:",Vt)}}}async function ve(Ce){const Ve=Da();console.log(Ce);const Ne=await Promise.all(Ce.map(async Ze=>{const ln=Ze.images[0],yr=!!Ze.animated?"gif":"png",Ln=Ze.extra_data?`data:video/avi;base64,${Ze.extra_data}`:"",es=Ze.final_frame?`data:image/jpeg;base64,${Ze.final_frame}`:"";let Zi={id:-1,image:`data:image/${yr};base64,${ln}`,prompt:Ze.prompt,modelName:Ze.models[0],frames:Ze.params.frames,fps:Ze.params.fps,extra_avi:Ln,final_frame:es,enable_hr:Ze.params.enable_hr,send_as_refimg:Ze.params.send_as_refimg,reverse_refimg:Ze.params.reverse_refimg};if(Ze.info&&typeof Ze.info=="string"&&Ze.info.trim()!=="")try{const br=JSON.parse(Ze.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip","fps"].forEach(Fr=>{br[Fr]!=null&&br[Fr]!=null?Zi[Fr]=br[Fr]:Ze.params[Fr]!=null&&(Zi[Fr]=Ze.params[Fr])}),br.extra_generation_params&&br.extra_generation_params["Schedule type"]?Zi.scheduler=br.extra_generation_params["Schedule type"]:Zi.scheduler=Ze.params.scheduler}catch(br){console.warn("Failed to parse info JSON:",br)}return Zi})),Ue=await Ve.pushOutputs(Ne),pt=0;return b.value=[...Ue.map(Ze=>({type:"image",index:pt,output:Ze})),...b.value].sort((Ze,ln)=>Ze.index-ln.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,Ut().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Ne}async function H(Ce){const Ve=Ut();return Ce&&Ve.raiseError(Ce,!1),[]}function W(Ce,Ve,Ne,Ue){return Ve<=Ne?Ve:(Ut().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${Ce}' to its default value instead of ${Ve}.`,!0),Ue)}async function k(Ce,Ve=!0){const Ne=Tu();if(n.value="Text2Img",u.value.guidance.state="Enabled",u.value.sampler.state="Enabled",u.value.steps.state="Enabled",u.value.clipSkip.state="Disabled",u.value.scheduler.state="Enabled",Bs.push("/"),Ve&&(Ce.width=Ce.width||Ne.width,Ce.height=Ce.height||Ne.height),Ce.prompt){const Ue=Ce.prompt.split(" ### ");r.value=Ue[0],l.value=Ue[1]||""}if(Ce.sampler_name){o.value.sampler_name=Ce.sampler_name;const pt=(await we()).find(Ze=>Ze.aliases&&Ze.aliases.includes(Ce.sampler_name));pt&&(o.value.sampler_name=pt.name)}Ce.steps&&(o.value.steps=W("steps",Ce.steps,I.value,Ne.steps)),Ce.cfg_scale&&(o.value.cfg_scale=Ce.cfg_scale),(Ce.eta||Ce.eta===0)&&(o.value.eta=Ce.eta),Ce.width&&(o.value.width=W("width",Ce.width,S.value,Ne.width)),Ce.height&&(o.value.height=W("height",Ce.height,S.value,Ne.height)),Ce.seed&&(o.value.seed=Ce.seed),Ce.clip_skip&&(o.value.clip_skip=W("clip_skip",Ce.clip_skip,J.value,Ne.clip_skip)),Ce.scheduler&&(o.value.scheduler=Ce.scheduler),Ce.frames&&(o.value.frames=W("frames",Ce.frames,M.value,Ne.frames)),Ce.fps&&(o.value.fps=Math.min(R.value,Math.max(U.value,Math.round(W("fps",Ce.fps,R.value,Ne.fps)))))}function X(Ce){const Ve=Ls();n.value="Img2Img",f.value.sourceImage=Ce,Ve.drawing=!1,b.value=[],Bs.push("/"),Kn.fabric.Image.fromURL(Ce,Ve.newImage)}function Y(Ce){const Ve=Ls();b.value=[],c.value.sourceImage=Ce,n.value="Inpainting",Bs.push("/"),Kn.fabric.Image.fromURL(Ce,Ve.newImage)}function $(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function B(){const Ce=$(),Ve=Ce.match(/\{(.*?)\}/g)||[];if(Ve.length===0)return[Ce];let Ne=[];return Ve.forEach(Ue=>{const pt=[],Ze=Ue.replace("{","").replace("}","").split("|");Ne.length===0?Ze.forEach(ln=>{const gn=Ce.replace(Ue,ln);pt.push(gn)}):Ne.forEach(ln=>{Ze.forEach(gn=>{const yr=ln.replace(Ue,gn);pt.push(yr)})}),Ne=[...pt]}),Ne}async function K(Ce){const Ve=zt();try{const Ne=await fetch(`${Ve.baseURL.length===0?".":Ve.baseURL}/sdapi/v1/${Ce.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ce)}),Ue=await Ne.json();return Ku(Ne,Ue,200,"Failed to fetch",ce)?Ue:!1}catch{return!1}}function ce(Ce){return Ut().raiseError(Ce,!1),y.value=!1,b.value=[],!1}async function ie(){const Ce=zt(),Ve=await fetch(`${Ce.baseURL.length===0?".":Ce.baseURL}/sdapi/v1/sd-models`),Ne=await Ve.json();if(!!Ku(Ve,Ne,200,"Failed to get available models"))return Ne.length===0?"(No model loaded)":Ne[0].model_name}const Z=oe(0),me=new Map;function ae(){me.clear(),Z.value++}xe(()=>zt().baseURL,()=>{ae()});async function ge(Ce){const Ve=zt(),Ue=((Ve.baseURL.length===0?".":Ve.baseURL).replace(/\/+$/,"")||".")+"/"+Ce.replace(/^\/+/,"");if(me.has(Ue))return me.get(Ue);const pt=(async()=>{try{const Ze=await fetch(Ue);if(Ze.ok)return await Ze.json();console.error(`API Error: ${Ze.status} ${Ze.statusText} at ${Ue}`)}catch(Ze){console.error(`Fetch error for ${Ue}:`,Ze)}return me.delete(Ue),null})();return me.set(Ue,pt),pt}async function we(){const Ce=await ge("/sdapi/v1/samplers");return Array.isArray(Ce)?Ce:[]}async function ke(){const Ce=await ge("/sdapi/v1/schedulers");return Array.isArray(Ce)?Ce:[]}function Oe(Ce){g.value.indexOf(Ce)===-1&&(g.value=[...g.value,Ce])}function Fe(Ce){g.value=g.value.filter(Ve=>Ve!=Ce)}function _e(Ce){if(i.value.findIndex(Ve=>Ve.prompt===Ce)===-1){if(i.value.length>=10+i.value.filter(Ve=>Ve.starred).length){const Ve=i.value.filter(Ue=>!Ue.starred),Ne=i.value.findIndex(Ue=>Ue===Ve[Ve.length-1]);i.value.splice(Ne,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:Ce}]}}function Se(Ce){i.value=i.value.filter(Ve=>Ve.prompt!=Ce&&Ve!=Ce)}function De(){return!1}const Me=oe([]);async function bt(Ce){var Ze,ln;const Ve=Ce.target,Ne=(ln=Ve.files)!=null?ln:(Ze=Ce.dataTransfer)==null?void 0:Ze.files,Ue=Array.from(Ne!=null?Ne:[]);if(Ue.length===0)return;const pt=await Promise.all(Ue.map(async(gn,yr)=>{const Ln=await Tc(gn);return{id:`${Date.now()}-${yr}-${gn.name}`,name:gn.name,size:gn.size,dataUrl:Ln,base64:Ln.includes("data:image")?Ln.split(",")[1]:Ln}}));Me.value||(Me.value=[]);for(let gn=0;gn=Me.value.length)return;const Ue=[...Me.value],[pt]=Ue.splice(Ce,1);Ue.splice(Ne,0,pt),Me.value=Ue}function tn(){Me.value=[];const Ce=document.getElementById("extra_image_input");Ce&&(Ce.value="")}return{generatorType:n,prompt:r,params:o,outputs:b,inpainting:c,img2img:f,uploadDimensions:v,cancelled:y,multiSelect:u,referenceImages:Me,negativePrompt:l,generating:m,negativePromptLibrary:g,minDimensions:w,maxDimensions:S,minImages:x,maxImages:T,minSteps:E,maxSteps:I,minCfgScale:D,maxCfgScale:N,minDenoise:O,maxDenoise:V,minClipSkip:re,maxClipSkip:J,minFrames:ue,maxFrames:M,minFps:U,maxFps:R,minEta:L,maxEta:F,clipSkipList:Q,cfgList:j,queue:_,promptHistory:i,timer:a,validGeneratorTypes:e,sourceGeneratorTypes:t,currentImageProps:h,totalImageCount:A,generateImage:pe,generateText2Img:k,generateImg2Img:X,generateInpainting:Y,getPrompt:De,resetStore:q,clearQueue:G,clearOutputs:te,pushToNegativeLibrary:Oe,removeFromNegativeLibrary:Fe,pushToPromptHistory:_e,removeFromPromptHistory:Se,setExtraImage:bt,removeExtraImage:_t,moveExtraImage:ht,clearExtraImage:tn,getAvailableSamplers:we,getAvailableSchedulers:ke,cacheVersion:Z,invalidateApiCaches:ae,getCachedEndpoint:ge}});"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var ff=e=>new DataView(new ArrayBuffer(e)),qa=e=>new Uint8Array(e.buffer||e),mo=e=>new TextEncoder().encode(String(e));function MK(e,t){if(t===void 0||t instanceof Date||(t=new Date(t)),e instanceof File)return{t:t||new Date(e.lastModified),o:e.stream()};if(e instanceof Response)return{t:t||new Date(e.headers.get("Last-Modified")||Date.now()),o:e.body};if(t===void 0)t=new Date;else if(isNaN(t))throw new Error("Invalid modification date.");if(typeof e=="string")return{t,o:mo(e)};if(e instanceof Blob)return{t,o:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t,o:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t,o:qa(e)};if(Symbol.asyncIterator in e)return{t,o:lC(e)};throw new TypeError("Unsupported input format.")}function lC(e){const t="next"in e?e:e[Symbol.asyncIterator]();return new ReadableStream({async pull(n){let r=0;for(;n.desiredSize>r;){const i=await t.next();if(!i.value){n.close();break}{const l=LK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function LK(e){return typeof e=="string"?mo(e):e instanceof Uint8Array?e:qa(e)}function RK(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=mo(t)),e instanceof File)return{i:t||mo(e.name),A:e.size};if(e instanceof Response){const r=e.headers.get("content-disposition"),i=r&&r.match(/;\s*filename\*?=["']?(.*?)["']?$/i),l=i&&i[1]||new URL(e.url).pathname.split("/").pop(),g=l&&decodeURIComponent(l),o=n||+e.headers.get("content-length");return{i:t||mo(g),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:mo(e).length}:e instanceof Blob?{i:t,A:e.size}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{i:t,A:e.byteLength}:{i:t,A:n}}var DK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:$K,m:BK}=DK.exports,FK=qa(BK).subarray(65536);function $y(e,t=0){for(const n of function*(r){for(;r.length>65536;)yield r.subarray(0,65536),r=r.subarray(65536);r.length&&(yield r)}(e))FK.set(n),t=$K(n.length,t);return t}function uC(e,t,n=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,i=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;t.setUint16(n,r,1),t.setUint16(n+2,i,1)}function zK(e){const t=ff(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),uC(e.t,t,10),t.setUint16(26,e.i.length,1),qa(t)}async function*NK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=$y(t,0),e.A=t.length;else{e.A=0;const n=t.getReader();for(;;){const{value:r,done:i}=await n.read();if(i)break;e.u=$y(r,e.u),e.A+=r.length,yield r}}}function jK(e){const t=ff(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),qa(t)}function VK(e,t){const n=ff(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),uC(e.t,n,12),n.setUint32(16,e.u,1),n.setUint32(20,e.A,1),n.setUint32(24,e.A,1),n.setUint16(28,e.i.length,1),n.setUint16(40,33204,1),n.setUint32(42,t,1),qa(n)}function UK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function HK(e,t={}){const n={"Content-Type":"application/zip","Content-Disposition":"attachment"};return Number.isInteger(t.length)&&t.length>0&&(n["Content-Length"]=t.length),t.metadata&&(n["Content-Length"]=p(t.metadata)),new Response(lC(async function*(r){const i=[];let l=0,g=0;for await(const u of r)yield zK(u),yield u.i,yield*NK(u),yield jK(u),i.push(VK(u,l)),i.push(u.i),g++,l+=46+u.i.length+u.A;let o=0;for(const u of i)yield u,o+=u.length;const a=ff(22);a.setUint32(0,1347093766),a.setUint16(8,g,1),a.setUint16(10,g,1),a.setUint32(12,o,1),a.setUint32(16,l,1),yield qa(a)}(async function*(r){for await(const i of r){const[l,g]=UK(i);yield Object.assign(MK(...g),RK(...l))}}(e))),{headers:n})}async function cC(e,t=!0,n){const r=zt();t&&Wi({message:`Downloading ${e.length} image(s)...`,type:"info"});const i=[];for(let o=0;o]/g,"").substring(0,128).trimEnd();let s=r.imageDownloadType;u.startsWith("data:image/gif")&&(s="GIF"),s==="PNG"?i.push({name:f+".png",input:await ba(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await ba(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await ba(u,"image/gif")}):i.push({name:f+".webp",input:await ba(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await HK(i).blob(),g=document.createElement("a");g.href=URL.createObjectURL(l),g.download="sdui_images.zip",g.click()}async function fC(e,t){const n=zt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await ba(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await ba(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await ba(e,"image/gif"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".gif"):(r.href=e,r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".webp"),r.click(),i&&URL.revokeObjectURL(r.href)}function dC(e,t){const n=e;if(!n)return;const r=atob(n),i=r.length,l=new Uint8Array(i);for(let u=0;u{Ew.confirm("This action will permanently delete this image. Continue?","Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{r.deleteOutput(t.imageData.id),t.onDelete!==void 0&&t.onDelete(t.imageData.id),Wi({type:"success",message:"Deleted Image"})})},l=a=>{if(a.extra_avi){const u=a.extra_avi.split(",")[1];if(!u)return;const d=`${a.seed}-${a.prompt}.avi`;dC(u,d);return}else fC(a.image,`${a.seed}-${a.prompt}`)},g=()=>{Jt().clearOutputs(),Ut().showGeneratedImages=!1,Jt().clearQueue()};async function o(a){const u=window.location.origin,d={prompt:a.prompt,width:a.width?a.width:void 0,height:a.height?a.height:void 0,steps:a.steps,cfg_scale:a.cfg_scale,sampler_name:a.sampler_name,model_name:a.modelName,seed:a.seed,clip_skip:a.clip_skip,frames:a.frames,fps:a.fps,scheduler:a.scheduler,extra_avi:a.extra_avi,final_frame:a.final_frame,enable_hr:a.enable_hr,send_as_refimg:a.send_as_refimg,reverse_refimg:a.reverse_refimg},c=window.location.pathname.replace("images","");let f=`${u}${c}?share=`,s="",h="";for(const[m,y]of Object.entries(d)){if(!y)continue;let b=y;typeof y=="string"?b=encodeURIComponent(y):Array.isArray(y)&&(b=JSON.stringify(y)),s+=`${h}${m}=${b}`,h="&"}f+=btoa(String.fromCharCode.apply(null,Array.from(qX(s)))),await navigator.clipboard.writeText(f),Wi({type:"success",message:"Copied shareable link to clipboard"})}return(a,u)=>(z(),se(je,null,[le(C(at),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:C(Ol),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(at),{class:"compact-button",onClick:u[0]||(u[0]=d=>l(e.imageData)),type:"success",size:"small",icon:C(Ks),plain:""},{default:he(()=>[He("Download")]),_:1},8,["icon"]),e.imageData.starred?ye("",!0):(z(),be(C(at),{key:0,class:"compact-button",onClick:u[1]||(u[1]=d=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(w4),plain:""},{default:he(()=>[He("Star")]),_:1},8,["icon"])),e.imageData.starred?(z(),be(C(at),{key:1,class:"compact-button",onClick:u[2]||(u[2]=d=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(__),plain:""},{default:he(()=>[He("Unstar")]),_:1},8,["icon"])):ye("",!0),le(C(at),{class:"compact-button",onClick:u[3]||(u[3]=d=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:he(()=>[He("Txt2img")]),_:1}),le(C(at),{class:"compact-button",onClick:u[4]||(u[4]=d=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Img2img")]),_:1}),le(C(at),{class:"compact-button",onClick:u[5]||(u[5]=d=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Inpaint")]),_:1}),e.showDismiss?(z(),be(C(at),{key:2,class:"compact-button",onClick:u[6]||(u[6]=d=>g()),type:"success",size:"small",plain:""},{default:he(()=>[He("Dismiss")]),_:1})):ye("",!0),le(C(at),{class:"compact-button",onClick:u[7]||(u[7]=d=>o(e.imageData)),type:"success",icon:C($3),size:"small",plain:""},{default:he(()=>[He("Share")]),_:1},8,["icon"])],64))}});const hC=qt(WK,[["__scopeId","data-v-4d472d34"]]),YK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},XK=["src"],KK={style:{"font-size":"16px","font-weight":"500"}},GK={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},qK={key:0},ZK=ne("br",null,null,-1),JK={key:0},QK=["onClick"],eG={key:1},tG=["onClick"],nG={key:2},rG=["onClick"],iG=Ee({__name:"ImageDialog",setup(e){const t=Da(),n=Ut(),r=oe();fM(r,{onSwipeEnd(d,c){c==="RIGHT"&&n.openModalToLeft(),c==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=oe(t.currentOutputs[0]);xe(()=>n.activeModal,async()=>{const d=t.currentOutputs.find(c=>c.id===n.activeModal);if(d)return l.value=d;l.value=await jt.outputs.get(n.activeModal)||t.currentOutputs[0]});function g(){i.value=!1}function o(){var f;if(!((f=l.value)!=null&&f.final_frame))return;const d=l.value.final_frame;Jt().generateImg2Img(d)}function a(){var d;!((d=l.value)!=null&&d.image)||fC(l.value.image,`${l.value.seed}-${l.value.prompt}`)}function u(){var f,s;if(!((f=l.value)!=null&&f.extra_avi))return;const d=l.value.extra_avi.split(",")[1];if(!d)return;const c=`output-${(s=l.value.id)!=null?s:"video"}.avi`;dC(d,c)}return(d,c)=>{var f;return z(),be(C(WB),{"model-value":C(i),width:(f=l.value)==null?void 0:f.width,class:"image-viewer",onClosed:g,"align-center":""},{footer:he(()=>[le(hC,{"image-data":l.value,"on-delete":g},null,8,["image-data"])]),default:he(()=>{var s,h,v,m;return[ne("div",{class:"main-output-container",ref_key:"target",ref:r},[ne("div",YK,[(s=l.value)!=null&&s.image?(z(),se("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,XK)):ye("",!0)])],512),ne("div",KK,Ae(((h=l.value.prompt)==null?void 0:h.split("###")[0])||"Unknown Creation"),1),ne("div",GK,[ne("div",null,"Negative Prompt: "+Ae(((v=l.value.prompt)==null?void 0:v.split("###")[1])||"None"),1),ne("span",null,"Model: "+Ae(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Ae(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Ae(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Ae(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Ae(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Ae(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Ae((m=l.value.clip_skip)!=null?m:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Ae(l.value.width||"???")+"x"+Ae(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Ae(l.value.frames||"1"),1),l.value.frames&&l.value.frames>1?(z(),se("span",qK," - FPS: "+Ae(l.value.fps||"Unknown"),1)):ye("",!0),ZK,ne("b",null,[l.value.frames&&l.value.frames>1?(z(),se("span",JK,[ne("a",{href:"#",onClick:et(a,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download GIF]",8,QK)])):ye("",!0),l.value.extra_avi?(z(),se("span",eG,[He(" - "),ne("a",{href:"#",onClick:et(u,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,tG)])):ye("",!0),l.value.final_frame?(z(),se("span",nG,[He(" - "),ne("a",{href:"#",onClick:et(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Extend Video]",8,rG)])):ye("",!0)])])]}),_:1},8,["model-value","width"])}}});const aG=e=>(ui("data-v-8f4d2380"),e=e(),ci(),e),oG=aG(()=>ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)),sG={class:"generator-icons"},lG=Ee({__name:"App",setup(e){const n=Ep(kp).smallerOrEqual("md"),r=Ut();zt();const i=fk(),l=oe();return xe(()=>i.path,g=>{l.value&&l.value.open(g)}),(g,o)=>(z(),se(je,null,[ne("div",{class:de({"menu-container":!C(n)})},[le(C(mw),{"default-active":C(i).path,mode:"horizontal",router:!0,ellipsis:!C(n),class:de(C(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:he(()=>[C(n)?ye("",!0):(z(),be(C(Up),{key:0,class:"remove-item-styling center-vertical"},{title:he(()=>[oG]),_:1})),le(ls,{isMobile:C(n),index:"/"},{icon:he(()=>[ne("div",sG,[le(C(Le),null,{default:he(()=>[le(C(wO))]),_:1}),C(r).showGeneratorBadge?(z(),be(C(Le),{key:0,class:"generator-badge",size:10},{default:he(()=>[le(tH)]),_:1})):ye("",!0)])]),title:he(()=>[He("Generate")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/images"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(Q3))]),_:1})]),title:he(()=>[He("Images")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/about"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(g_))]),_:1})]),title:he(()=>[He("About")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/options"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(M4))]),_:1})]),title:he(()=>[He("Options")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/return"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(d_))]),_:1})]),title:he(()=>[He("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:de({view:!C(n)})},[le(C(c_))],2),le(iG)],64))}});const uG=qt(lG,[["__scopeId","data-v-8f4d2380"]]);const Tm=tT(uG);Tm.use(iT());Tm.use(Bs);Tm.mount("#app");Bs.replace("/");window.addEventListener("beforeunload",e=>{Jt().generating&&(e.preventDefault(),e.returnValue="")});const cG={key:1,class:"image-action"},fG=Ee({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=Ut(),r=oe(null);VI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=oe(!1);cM(r,([{isIntersecting:g}])=>{g&&(i.value=g)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(g,o)=>(z(),se("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(z(),be(C(ef),{key:0,class:"thumbnail",src:e.imageData.image,onClick:o[0]||(o[0]=a=>C(n).activeModal=e.imageData.id),fit:"cover",loading:"lazy",style:ze(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):ye("",!0),i.value?(z(),se("div",cG,[e.imageData.starred?(z(),be(C(Le),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:he(()=>[le(C(__))]),_:1})):ye("",!0),C(n).multiSelect?(z(),se("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[le(C(Le),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:he(()=>[C(l)?ye("",!0):(z(),be(C(El),{key:0})),C(l)?(z(),be(C(p_),{key:1})):ye("",!0)]),_:1},8,["color"])])):ye("",!0)])):ye("",!0)],512))}});const By=qt(fG,[["__scopeId","data-v-b9569bbd"]]);function dG({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=a1(),i=ee(()=>r.value<=e),l=oe(!0),{y:g}=uM(window);let o=g.value,a=0;return xe(g,u=>{if(!i.value)return;const d=u-o;if(o=u,d>0&&u>t){a+=d,a>=n&&(l.value=!1,a=0);return}d<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const hG={},pG={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},mG=ne("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-696 72h136v656H184V184zm656 656H384V384h456v456zM384 320V184h456v136H384z",fill:"currentColor"},null,-1),gG=[mG];function vG(e,t){return z(),se("svg",pG,gG)}const yG=qt(hG,[["render",vG]]),bG=e=>(ui("data-v-b39b47c5"),e=e(),ci(),e),_G={class:"options"},wG=["onClick"],CG=["onClick"],SG=["onClick"],xG={key:1,class:"center-both",style:{gap:"12px"}},TG={key:2},kG=bG(()=>ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),EG=[kG],OG={key:0},AG={key:0,style:{display:"flex",gap:"8px"}},PG={key:1,class:"images"},IG={key:1},MG=Ee({__name:"ImagesView",setup(e){const{width:t}=a1(),{isVisible:n,isMobile:r}=dG(),i=Da(),l=zt(),g=Ut();function o(){g.selected=g.selected.filter(h=>!i.currentOutputs.map(v=>v.id).includes(h)),g.selected=[...g.selected,...i.currentOutputs.map(h=>h.id)],g.multiSelect=!0}async function a(){const h=await jt.outputs.toCollection().primaryKeys();g.selected=h,g.multiSelect=!0}function u(){g.selected=g.selected.filter(h=>!i.currentOutputs.map(v=>v.id).includes(h)),g.selected.length===0&&(g.multiSelect=!1)}function d(){g.selected=[],g.multiSelect=!1}const c=()=>{Ew.confirm(`This action will permanently delete ${g.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(g.selected)})};vv(["a","A","ArrowLeft"],g.openModalToLeft),vv(["d","D","ArrowRight"],g.openModalToRight);async function f(){cC(g.selected)}const s=ee(()=>{let h=2;t.value>1440?h=6:t.value>1280?h=5:t.value>768?h=4:t.value>480&&(h=3);const v=[];for(let m=0;m(z(),se(je,null,[ne("div",{class:de(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[ne("div",_G,[le(C(cu),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[le(C(c4))]),_:1})]),_:1})]),default:he(()=>[(z(),se(je,null,Nt(["Newest","Oldest"],m=>ne("div",{key:m,onClick:()=>C(i).sortBy=m,class:de(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Ae(m),11,wG)),64))]),_:1}),le(C(cu),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[le(C(d3))]),_:1})]),_:1})]),default:he(()=>[(z(),se(je,null,Nt(["all","favourited","unfavourited","unrated"],m=>ne("div",{key:m,onClick:()=>C(i).filterBy=m,class:de(`el-select-dropdown__item ${C(i).filterBy===m?"selected":""}`)},Ae(C(i).filterBy===m?"Showing":"Show")+" "+Ae(m),11,CG)),64))]),_:1}),le(C(cu),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[le(yG)]),_:1})]),_:1})]),default:he(()=>[(z(),se(je,null,Nt([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>ne("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:de(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Ae(m.label),11,SG)),64))]),_:1}),le(C(cu),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[C(g).multiSelect?(z(),be(C(p_),{key:0})):(z(),be(C(El),{key:1}))]),_:1})]),_:1})]),default:he(()=>[C(g).multiSelect?(z(),se("div",{key:0,class:"el-select-dropdown__item selected",onClick:v[0]||(v[0]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Disable multi-select")):(z(),se("div",{key:1,class:"el-select-dropdown__item",onClick:v[1]||(v[1]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Enable multi-select")),C(g).selected.length>0?(z(),se("div",{key:2,class:"el-select-dropdown__item selected",onClick:d},"Deselect All")):(z(),se("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),C(g).selected.every(m=>!C(i).currentOutputs.map(y=>y.id).includes(m))?(z(),se("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(z(),se("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(z(),be(C(m9),{key:0,layout:"prev, pager, next",total:C(i).outputsLength,"page-size":C(l).pageSize,"current-page":C(i).currentPage,"onUpdate:currentPage":v[2]||(v[2]=m=>C(i).currentPage=m),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):ye("",!0),C(g).multiSelect?(z(),se("div",xG,[ne("div",null,Ae(C(g).selected.length)+" selected",1),le(C(at),{type:"danger",onClick:c,icon:C(Ol),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(at),{type:"success",onClick:f,icon:C(Ks),plain:"",style:{margin:"0"}},{default:he(()=>[He("Download")]),_:1},8,["icon"])])):(z(),se("div",TG,EG))],2),C(i).outputsLength!=0?(z(),se("div",OG,[C(i).currentLayout==="dynamic"?(z(),se("div",AG,[(z(!0),se(je,null,Nt(C(s),(m,y)=>(z(),se("div",{key:y,style:{flex:"1 1 0%"}},[(z(!0),se(je,null,Nt(m,b=>(z(),be(By,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ye("",!0),C(i).currentLayout==="grid"?(z(),se("div",PG,[(z(!0),se(je,null,Nt(C(i).currentOutputs,m=>(z(),be(By,{key:m.id,"image-data":m,style:{width:"200px",height:"200px"}},null,8,["image-data"]))),128))])):ye("",!0)])):ye("",!0),C(i).outputsLength==0?(z(),se("div",IG,[le(C(FF),{description:"No Images Found"})])):ye("",!0)],64))}});const LG=qt(MG,[["__scopeId","data-v-b39b47c5"]]),RG=Object.freeze(Object.defineProperty({__proto__:null,default:LG},Symbol.toStringTag,{value:"Module"})),DG=["href"],$G=Ee({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=gt("router-link");return z(),se(je,null,[e.router?ye("",!0):(z(),se("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[Te(t.$slots,"default",{},void 0,!0)],8,DG)),e.router?(z(),be(r,{key:1,to:e.href},{default:he(()=>[Te(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ye("",!0)],64)}}});const BG=qt($G,[["__scopeId","data-v-17b53b7d"]]),Yl=e=>(ui("data-v-ecc278c5"),e=e(),ci(),e),FG={class:"about"},zG={class:"about-content"},NG=Yl(()=>ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),jG=Yl(()=>ne("div",null,[He("This tool was originally a front-end for the AI Horde and has since been converted for local generations with the A1111 API, such as in "),ne("a",{href:"https://github.com/LostRuins/koboldcpp"},"KoboldCpp"),He(".")],-1)),VG=Yl(()=>ne("br",null,null,-1)),UG=Yl(()=>ne("div",null,"If you want to help improve this tool, you can find the currently maintained source code from this modified version on https://github.com/LostRuins/stable-ui and https://github.com/henk717/stable-ui, which is based off https://github.com/ayunami2000/stable-ui, which derives from the original AI Horde version on https://github.com/aqualxx/stable-ui (Original author aqualxx#5004). Feel free to contribute!",-1)),HG=Yl(()=>ne("br",null,null,-1)),WG=Ee({__name:"AboutView",setup(e){return(t,n)=>(z(),se("div",FG,[ne("div",zG,[NG,jG,VG,UG,HG,ne("div",null,[He("You can find the KoboldAI community and authors of this fork on the "),le(BG,{href:"https://koboldai.org/discord"},{default:he(()=>[He("KoboldAI Discord")]),_:1})])])]))}});const YG=qt(WG,[["__scopeId","data-v-ecc278c5"]]),XG=Object.freeze(Object.defineProperty({__proto__:null,default:YG},Symbol.toStringTag,{value:"Module"}));const so=Ee({__name:"FormRadio",props:{label:null,modelValue:null,prop:null,useBoolean:{type:Boolean},options:null,disabled:{type:Boolean},info:null,labelStyle:null,change:null},emits:["update:modelValue"],setup(e,{emit:t}){const n=e;function r(l){if(n.useBoolean&&l==="Enabled"?t("update:modelValue",!0):n.useBoolean&&l==="Disabled"?t("update:modelValue",!1):t("update:modelValue",l),!!n.change)return n.useBoolean&&l==="Enabled"?n.change(!0):n.useBoolean&&l==="Disabled"?n.change(!1):n.change(l)}const i=ee(()=>n.useBoolean?n.modelValue===!0?"Enabled":n.modelValue===!1?"Disabled":n.modelValue:n.modelValue);return(l,g)=>(z(),be(C(Di),{prop:e.prop},{label:he(()=>[le(jl,{info:e.info,"label-style":e.labelStyle},{default:he(()=>[Te(l.$slots,"label",{},()=>[He(Ae(e.label),1)])]),_:3},8,["info","label-style"])]),default:he(()=>[le(C(H$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:he(()=>[(z(!0),se(je,null,Nt(e.options,o=>(z(),be(C(W$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),Te(l.$slots,"inline")]),_:3},8,["prop"]))}}),Qo=e=>(ui("data-v-0345ee1f"),e=e(),ci(),e),KG=Qo(()=>ne("h1",null,"Options",-1)),GG=Qo(()=>ne("h2",null,"Generation Options",-1)),qG=Qo(()=>ne("h3",null,"Parameter Controls",-1)),ZG=Qo(()=>ne("h2",null,"Image Options",-1)),JG=Qo(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),QG=Qo(()=>ne("h2",null,"General Options",-1)),eq=Ee({__name:"OptionsView",setup(e){const t=zt(),n=Da(),r=Jt(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=oe([]),g=oe(),o=oe(!1),a=oe(0);async function u(c){n.importFromZip(c),g.value.clearFiles()}async function d(){Wi({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const c=await jt.outputs.toCollection().primaryKeys();await cC(c,!1,()=>{a.value++}),o.value=!1,a.value=0}return(c,f)=>(z(),se(je,null,[KG,le(C(jp),{"label-position":"top",model:C(t).options,onSubmit:f[10]||(f[10]=et(()=>{},["prevent"]))},{default:he(()=>[le(C(zj),{type:"border-card",style:{"min-height":"50vh"}},{default:he(()=>[le(C(zf),{label:"\u{1F5A8}\uFE0F Generation"},{default:he(()=>[GG,le(C(Di),{label:"Base URL"},{default:he(()=>[le(C(Xa),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":f[0]||(f[0]=s=>C(t).baseURL=s)},null,8,["modelValue"])]),_:1}),qG,(z(!0),se(je,null,Nt(C(r).multiSelect,(s,h)=>{var v;return z(),se("div",{key:h},[le(so,{label:s.name,prop:"pageless",modelValue:s.state,"onUpdate:modelValue":m=>s.state=m,options:(v=s.allowedStates)!=null?v:[]},null,8,["label","modelValue","onUpdate:modelValue","options"])])}),128)),le(so,{label:"Allow Larger Params",prop:"pageless",modelValue:C(t).allowLargerParams,"onUpdate:modelValue":f[1]||(f[1]=s=>C(t).allowLargerParams=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(po,{label:"Image Resize Mode",prop:"imageResizeMode",modelValue:C(t).imageResizeMode,"onUpdate:modelValue":f[2]||(f[2]=s=>C(t).imageResizeMode=s),options:[{label:"No Scale",value:"NoScale"},{label:"Scale and Crop",value:"ScaleAndCrop"},{label:"Scale and Pad",value:"ScaleAndPad"},{label:"Stretch",value:"Stretch"},{label:"Original",value:"Original"}],info:"How to adapt input image dimensions to the requested image size. No Scale: do not scale, just crop or pad each dimension to fit (default behavior). Scale and Crop: scale to match the smaller dimension, preserving aspect ratio, then crop to fit. Scale and Pad: scale to match the larger dimension, preserving aspect ratio, then pad to fit. Stretch: stretch both dimensions to fit, possibly not preserving aspect ratio. Original: send the input image as-is to the server, with no scaling, cropping or padding."},null,8,["modelValue"]),le(so,{label:"Video Gen: Request AVI download",prop:"pageless",modelValue:C(t).alsoRequestAvi,"onUpdate:modelValue":f[3]||(f[3]=s=>C(t).alsoRequestAvi=s),options:["Enabled","Disabled"]},null,8,["modelValue"])]),_:1}),le(C(zf),{label:"\u{1F4F7} Images"},{default:he(()=>[ZG,le(bn,{label:"Images Per Page",prop:"pageSize",modelValue:C(t).pageSize,"onUpdate:modelValue":f[4]||(f[4]=s=>C(t).pageSize=s),min:10,max:50,step:5,disabled:C(t).pageless==="Enabled"},null,8,["modelValue","disabled"]),le(so,{label:"Pageless Format",prop:"pageless",modelValue:C(t).pageless,"onUpdate:modelValue":f[5]||(f[5]=s=>C(t).pageless=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(so,{label:"Carousel Auto Cycle",prop:"autoCarousel",modelValue:C(t).autoCarousel,"onUpdate:modelValue":f[6]||(f[6]=s=>C(t).autoCarousel=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(so,{label:"Image Download Format",prop:"downloadType",modelValue:C(t).imageDownloadType,"onUpdate:modelValue":f[7]||(f[7]=s=>C(t).imageDownloadType=s),options:["PNG","JPG","WEBP","GIF"]},null,8,["modelValue"]),le(C(Di),{label:"Export Images (ZIP File)"},{default:he(()=>[o.value?(z(),be(C(at),{key:1,icon:C(Ks),disabled:""},{default:he(()=>[He("Downloading... ("+Ae(a.value)+" / "+Ae(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(z(),be(C(at),{key:0,icon:C(Ks),onClick:f[8]||(f[8]=s=>d())},{default:he(()=>[He("Download "+Ae(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),le(C(Di),{label:"Import Images (ZIP File)"},{default:he(()=>[le(C(Yp),{drag:"",ref_key:"upload",ref:g,"auto-upload":!1,onChange:u,"file-list":l.value,limit:1,multiple:""},{default:he(()=>[le(C(Le),{size:100},{default:he(()=>[le(C(dp))]),_:1}),JG]),_:1},8,["file-list"])]),_:1})]),_:1}),le(C(zf),{label:"\u2699\uFE0F General"},{default:he(()=>[QG,le(po,{label:"Color Scheme",prop:"colorScheme",modelValue:C(t).options.colorMode,"onUpdate:modelValue":f[9]||(f[9]=s=>C(t).options.colorMode=s),options:i},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}});const tq=qt(eq,[["__scopeId","data-v-0345ee1f"]]),nq=Object.freeze(Object.defineProperty({__proto__:null,default:tq},Symbol.toStringTag,{value:"Module"})); +`&&h>0?(c=0,f++,d++):!this.splitByGrapheme&&this._reSpaceAndTab.test(u.graphemeText[f])&&h>0&&(c++,f++),s[h]={line:d,offset:c},f+=u.graphemeLines[h].length,c+=u.graphemeLines[h].length;return s},styleHas:function(u,d){if(this._styleMap&&!this.isWrapping){var c=this._styleMap[d];c&&(d=c.line)}return a.Text.prototype.styleHas.call(this,u,d)},isEmptyStyles:function(u){if(!this.styles)return!0;var d=0,c=u+1,f,s,h=!1,v=this._styleMap[u],m=this._styleMap[u+1];v&&(u=v.line,d=v.offset),m&&(c=m.line,h=c===u,f=m.offset),s=typeof u>"u"?this.styles:{line:this.styles[u]};for(var y in s)for(var b in s[y])if(b>=d&&(!h||bc&&!E?(v.push(m),m=[],s=S,E=!0):s+=I,!E&&!h&&m.push(w),m=m.concat(b),x=h?0:this._measureWord([w],d,_),_++,E=!1,S>T&&(T=S);return N&&v.push(m),T+D>this.dynamicMinWidth&&(this.dynamicMinWidth=T-I+D),v},isEndOfWrapping:function(u){return!this._styleMap[u+1]||this._styleMap[u+1].line!==this._styleMap[u].line},missingNewlineOffset:function(u){return this.splitByGrapheme?this.isEndOfWrapping(u)?1:0:1},_splitTextIntoLines:function(u){for(var d=a.Text.prototype._splitTextIntoLines.call(this,u),c=this._wrapText(d.lines,this.width),f=new Array(c.length),s=0;s{const e=()=>({canvas:void 0,brush:void 0,visibleImageLayer:void 0,imageLayer:void 0,visibleDrawLayer:void 0,drawLayer:void 0,cropPreviewLayer:void 0,maskPathColor:"",maskBackgroundColor:"",imageScale:1,undoHistory:[],redoHistory:[],drawing:!1}),t=oe({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=oe({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>Jt().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>Jt().currentImageProps),g=ee({get:()=>i.value.drawing&&!r.value,set:P=>i.value.drawing=P}),o=oe(512),a=oe(512),u=oe(!1),d=oe(30),c=oe(!1),f=new Kn.fabric.Circle({radius:d.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=oe("Erase"),h=oe("rgb(0, 0, 0, 1)");function v(){!i.value.canvas||i.value.canvas.renderAll()}function m(){u.value=!u.value,s.value=u.value?"Draw":"Erase"}function y(P=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=P||i.value.brush.color,i.value.brush.width=d.value)}async function b({history:P,erase:Q=!1,draw:j=!1}={}){if(!P||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;P.path.selectable=!1,P.path.opacity=1,P.drawPath=await M(P.path),P.visibleDrawPath=await M(P.path),Q?(P.visibleDrawPath.globalCompositeOperation="destination-out",P.drawPath.stroke=i.value.maskBackgroundColor):(P.visibleDrawPath.globalCompositeOperation="source-over",P.drawPath.stroke=j?h.value:i.value.maskPathColor);let A=await M(P.drawPath);A=A.scale(i.value.imageScale),A.left=A.left+P.drawPath.left*(i.value.imageScale-1),A.top=A.top+P.drawPath.top*(i.value.imageScale-1),j?(i.value.imageLayer.add(A),i.value.visibleImageLayer.addWithUpdate(P.visibleDrawPath)):(i.value.drawLayer.add(A),i.value.visibleDrawLayer.addWithUpdate(P.visibleDrawPath)),i.value.canvas.remove(P.path),v()}function _(){if(i.value.undoHistory.length===0)return;const P=i.value.undoHistory.pop();b({history:P,erase:!1,draw:g.value}),i.value.redoHistory.push(P)}function w(){if(i.value.redoHistory.length===0||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;const P=i.value.redoHistory.pop();i.value.undoHistory.push(P),g.value?(i.value.imageLayer.remove(P.drawPath),i.value.visibleImageLayer.remove(P.visibleDrawPath)):(i.value.drawLayer.remove(P.drawPath),i.value.visibleDrawLayer.remove(P.visibleDrawPath)),delete P.drawPath,delete P.visibleDrawPath,v()}function S(P){i.value.canvas=new Kn.fabric.Canvas(P,{isDrawingMode:!1,width:o.value,height:a.value,backgroundColor:"white"}),i.value.canvas.selection=!1,i.value.canvas.freeDrawingCursor="crosshair",y(i.value.maskPathColor),i.value.canvas.on("mouse:move",R),i.value.canvas.on("path:created",U),v()}function x(P,Q,j,A){let q=A,G=A;return Q>j?(P.scaleToWidth(A),q=A*(a.value/o.value)):(P.scaleToHeight(A),G=A*(o.value/a.value)),{newHeight:q,newWidth:G}}function T(P){const Q=Jt();if(re(),P.selectable=!1,o.value=P.width,a.value=P.height,o.value>Q.maxDimensions||a.value>Q.maxDimensions){const{newHeight:G,newWidth:te}=x(P,o.value,a.value,Q.maxDimensions);o.value=te,a.value=G}if(o.value{i.value.imageLayer=F({image:G,layerHeight:q,layerWidth:A})}),P.cloneAsImage(G=>{if(!i.value.canvas)return;if(o.value!==j||a.value!==j){const{newHeight:pe,newWidth:ve}=x(G,o.value,a.value,j);o.value=ve,a.value=pe}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=V(),i.value.visibleImageLayer=V({image:G}),i.value.drawLayer=F({layerHeight:q,layerWidth:A});const te=o.value*i.value.imageScale,fe=a.value*i.value.imageScale;Q.params.width=te-te%64,Q.params.height=fe-fe%64,i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleImageLayer),i.value.canvas.add(i.value.visibleDrawLayer),i.value.canvas.add(f),c.value=!0,N(),I()})}function E(P,Q,j,A,q,G){const te=G?G.width:P.width,fe=G?G.height:P.height;if(q==="Original")return P;const pe=document.createElement("canvas");pe.width=Q,pe.height=j;const ve=pe.getContext("2d");ve.fillStyle=A,ve.fillRect(0,0,pe.width,pe.height);let H=0,W=0,k=P.width,X=P.height,Y=0,$=0,B=pe.width,K=pe.height;switch(q){case"Stretch":break;case"ScaleAndCrop":{const ce=pe.width/te,ie=pe.height/fe;ce>ie?(X=pe.height/ce,W=(P.height-X)/2):(k=pe.width/ie,H=(P.width-k)/2);break}case"ScaleAndPad":{const ce=pe.width/te,ie=pe.height/fe;ceQ?(k=Q,H=ce-Q/2):(B=te,Y=Q/2-ce),fe>j?(X=j,W=ie-j/2):(K=fe,$=j/2-ie);break}}return ve.drawImage(P,H,W,k,X,Y,$,B,K),pe}function I(){const P=Jt(),Q=zt();if(!i.value.imageLayer||!i.value.drawLayer)return;const j=P.params.width,A=P.params.height,q=i.value.imageLayer.backgroundColor||"#FFFFFF",G=Q.imageResizeMode,te=i.value.imageLayer.toCanvasElement(),fe=E(te,j,A,q,G,te);if(l.value.sourceImage=fe.toDataURL("image/jpeg",1),l.value.maskImage=void 0,i.value.redoHistory.length>0&&!g.value){const ve=i.value.drawLayer.toCanvasElement(),H=E(ve,j,A,q,G,te);l.value.maskImage=H.toDataURL("image/jpeg",1).split(",")[1]}}let D;function N(){if(!i.value.canvas)return;const P=Jt();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),c.value&&(i.value.cropPreviewLayer=V({layerWidth:P.params.width/i.value.imageScale,layerHeight:P.params.height/i.value.imageScale,fill:"rgba(100, 0, 0, 0.5)"}),i.value.canvas.centerObject(i.value.cropPreviewLayer),i.value.canvas.add(i.value.cropPreviewLayer),D&&clearTimeout(D),D=setTimeout(()=>{c.value=!1,N(),D=void 0},5e3))}function L(P,Q){const j="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";Kn.fabric.Image.fromURL(j,A=>{A.set({height:P,width:Q});const q=A.toDataURL({format:"png"});l.value.sourceImage=q,g.value=!0,T(A)})}function F({image:P,layerWidth:Q,layerHeight:j}={}){const A=new Kn.fabric.Canvas(null);return A.selection=!1,A.backgroundColor=i.value.maskBackgroundColor,A.setHeight(j||a.value),A.setWidth(Q||o.value),P&&A.add(P),A}function O(){return i.value.imageLayer?{layerHeight:i.value.imageLayer.getHeight(),layerWidth:i.value.imageLayer.getWidth()}:{}}function V({image:P,layerWidth:Q,layerHeight:j,fill:A,abosolute:q}={}){const G=P||new Kn.fabric.Rect({width:Q||o.value,height:j||a.value,left:0,top:0,fill:A||"transparent",absolutePositioned:q||!0,selectable:!1});return new Kn.fabric.Group([G],{selectable:!1,absolutePositioned:q||!0})}function re(){!i.value.canvas||(i.value.visibleImageLayer&&(i.value.canvas.remove(i.value.visibleImageLayer),i.value.visibleImageLayer=void 0),i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),i.value.imageLayer=void 0,i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.canvas.isDrawingMode=!1)}function J(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),g.value){const P=Jt();L(P.params.height||512,P.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=V(),i.value.drawLayer=F(O()),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function ue(){var Q;I();const P=document.createElement("a");if(g.value){P.href="data:image/png;base64,"+((Q=l.value.sourceImage)==null?void 0:Q.split(",")[1]),P.download="image_drawing.png",P.click();return}P.href="data:image/png;base64,"+l.value.maskImage,P.download="image_mask.png",P.click()}async function M(P){return new Promise((Q,j)=>{try{P.clone(Q)}catch(A){j(A)}})}async function U(P){const Q={path:P.path};b({history:Q,erase:u.value,draw:g.value}),i.value.redoHistory.push(Q)}function R(P){if(!i.value.canvas)return;const Q=i.value.canvas.getPointer(P.e);f.left=Q.x,f.top=Q.y,f.opacity=.8,u.value?(f.set("strokeWidth",3),f.set("fill",""),y("red")):(f.set("strokeWidth",0),g.value?(f.set("fill",h.value),y(h.value)):(f.set("fill","white"),y("white"))),f.set("radius",d.value/2),v()}return{showCropPreview:c,erasing:u,switchToolText:s,brushSize:d,drawColor:h,drawing:g,imageProps:i,updateCropPreview:N,createNewCanvas:S,downloadMask:ue,resetCanvas:re,resetDrawing:J,flipErase:m,undoAction:w,redoAction:_,newImage:T,newBlankImage:L,setBrush:y,saveImages:I}});const XH={},KH={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},GH=ne("g",{fill:"none"},[ne("path",{d:"M11.197 2.44a1.5 1.5 0 0 1 2.121 0l4.243 4.242a1.5 1.5 0 0 1 0 2.121L9.364 17H14.5a.5.5 0 0 1 0 1H7.82a1.496 1.496 0 0 1-1.14-.437L2.437 13.32a1.5 1.5 0 0 1 0-2.121l8.76-8.76zm1.414.706a.5.5 0 0 0-.707 0L5.538 9.512l4.95 4.95l6.366-6.366a.5.5 0 0 0 0-.707L12.61 3.146zM9.781 15.17l-4.95-4.95l-1.687 1.687a.5.5 0 0 0 0 .707l4.243 4.243a.5.5 0 0 0 .707 0l1.687-1.687z",fill:"currentColor"})],-1),qH=[GH];function ZH(e,t){return z(),se("svg",KH,qH)}const JH=qt(XH,[["render",ZH]]);async function QH(e,t){const n=document.createElement("canvas"),r=n.getContext("2d"),i=new Image;return i.src=e,await new Promise(g=>i.onload=g),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function eW(e,t){const n=e.split(";base64,"),r=t!=null?t:n[0].split(":")[1],i=window.atob(r===n[0].split(":")[1]?n[1]:(await QH(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let g=0;g{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}const gm=e=>(ui("data-v-7dc3b5bb"),e=e(),ci(),e),tW=gm(()=>ne("div",null,[He("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1)),nW={key:0},rW=gm(()=>ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),iW={class:"canvas-container"},aW=gm(()=>ne("canvas",{id:"canvas"},null,-1)),oW={class:"action-buttons",style:{left:"10px",right:"unset"}},sW={class:"action-buttons"},lW=Ee({__name:"CustomCanvas",setup(e){const t=Jt(),n=Ut(),r=Ls(),i=oe();async function l(a){if(!a.raw.type.includes("image")){n.raiseError("Uploaded file needs to be a image!",!1),i.value.clearFiles();return}const u=await Tc(a.raw);t.currentImageProps.sourceImage=u,r.drawing=!1,Kn.fabric.Image.fromURL(u,r.newImage)}function g(){t.currentImageProps.sourceImage="",r.resetCanvas()}nt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Kn.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Yt(()=>{window.removeEventListener("paste",o)});async function o(a){var d;const u=(d=a.clipboardData)==null?void 0:d.items;if(!!u)for(let c=0;c(z(),se(je,null,[C(t).currentImageProps.sourceImage?ye("",!0):(z(),be(C(Yp),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:he(()=>[C(t).generatorType==="Img2Img"?(z(),se("div",nW,[rW,ne("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:u[0]||(u[0]=d=>C(r).newBlankImage(C(t).params.height||512,C(t).params.width||512))},[le(C(Le),{size:20,style:{"margin-right":"2px"}},{default:he(()=>[le(S2)]),_:1}),He("draw something")])])):ye("",!0)]),default:he(()=>[le(C(Le),{size:100},{default:he(()=>[le(C(dp))]),_:1}),tW]),_:1},512)),Et(ne("div",null,[ne("div",iW,[aW,ne("div",oW,[le(C(at),{onClick:u[1]||(u[1]=d=>C(r).undoAction()),icon:C(y_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),le(C(at),{onClick:u[2]||(u[2]=d=>C(r).redoAction()),icon:C(b_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",sW,[le(C(at),{onClick:u[3]||(u[3]=d=>C(r).resetDrawing()),icon:C(Mr),plain:""},null,8,["icon"]),le(C(at),{onClick:g,icon:C(Ol),plain:""},null,8,["icon"]),le(C(at),{onClick:u[4]||(u[4]=d=>C(r).downloadMask()),icon:C(Ks),plain:""},null,8,["icon"]),le(C(at),{onClick:u[5]||(u[5]=d=>C(r).flipErase()),icon:C(r).erasing?C(o3):JH,plain:""},null,8,["icon"]),C(r).drawing?(z(),be(C(EB),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":u[6]||(u[6]=d=>C(r).drawColor=d),"show-alpha":""},null,8,["modelValue"])):ye("",!0)]),le(C(jp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:he(()=>[le(bn,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:C(r).brushSize,"onUpdate:modelValue":u[7]||(u[7]=d=>C(r).brushSize=d),min:10,max:100,step:10,change:C(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[Ht,C(t).currentImageProps.sourceImage]])],64))}});const K0=qt(lW,[["__scopeId","data-v-7dc3b5bb"]]),uW={class:"centerIcons"},cW={class:"stackedIcons"},fW=Ee({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return Fx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(z(),se("div",uW,[ne("div",cW,[le(C(Le),{class:"firstIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconOne)))]),_:1},8,["size"]),le(C(Le),{class:"secondIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconTwo)))]),_:1},8,["size"])])]))}});const dW=qt(fW,[["__scopeId","data-v-74586a39"]]),hW={key:1,style:{width:"40px"}},bu=Ee({__name:"GeneratorMenuItem",props:{index:null,iconOne:null,iconTwo:null,isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(z(),be(C(zn),{content:e.index,placement:e.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:he(()=>[le(C(Up),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:he(()=>[e.iconTwo?(z(),be(dW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(z(),se("div",hW,[le(C(Le),{style:{width:"35px"},size:40},{default:he(()=>[(z(),be(kt(t.iconOne)))]),_:1})]))]),_:1},8,["index"])]),_:1},8,["content","placement"]))}});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const pW=4,G0=0,q0=1,mW=2;function Go(e){let t=e.length;for(;--t>=0;)e[t]=0}const gW=0,k2=1,vW=2,yW=3,bW=258,vm=29,Vl=256,pl=Vl+1+vm,Co=30,ym=19,E2=2*pl+1,_a=15,Jf=16,_W=7,bm=256,O2=16,A2=17,P2=18,Eh=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Xu=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),wW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),I2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),CW=512,Gr=new Array((pl+2)*2);Go(Gr);const Rs=new Array(Co*2);Go(Rs);const ml=new Array(CW);Go(ml);const gl=new Array(bW-yW+1);Go(gl);const _m=new Array(vm);Go(_m);const kc=new Array(Co);Go(kc);function Qf(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let M2,L2,R2;function ed(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const D2=e=>e<256?ml[e]:ml[256+(e>>>7)],vl=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},En=(e,t,n)=>{e.bi_valid>Jf-n?(e.bi_buf|=t<>Jf-e.bi_valid,e.bi_valid+=n-Jf):(e.bi_buf|=t<{En(e,n[t*2],n[t*2+1])},$2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},SW=e=>{e.bi_valid===16?(vl(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},xW=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,g=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let u,d,c,f,s,h,v=0;for(f=0;f<=_a;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;ua&&(f=a,v++),n[d*2+1]=f,!(d>r)&&(e.bl_count[f]++,s=0,d>=o&&(s=g[d-o]),h=n[d*2],e.opt_len+=h*(f+s),l&&(e.static_len+=h*(i[d*2+1]+s)));if(v!==0){do{for(f=a-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[a]--,v-=2}while(v>0);for(f=a;f!==0;f--)for(d=e.bl_count[f];d!==0;)c=e.heap[--u],!(c>r)&&(n[c*2+1]!==f&&(e.opt_len+=(f-n[c*2+1])*n[c*2],n[c*2+1]=f),d--)}},B2=(e,t,n)=>{const r=new Array(_a+1);let i=0,l,g;for(l=1;l<=_a;l++)i=i+n[l-1]<<1,r[l]=i;for(g=0;g<=t;g++){let o=e[g*2+1];o!==0&&(e[g*2]=$2(r[o]++,o))}},TW=()=>{let e,t,n,r,i;const l=new Array(_a+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?vl(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Z0=(e,t,n,r)=>{const i=t*2,l=n*2;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,l=0,g,o;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+l++]&255,r+=(e.pending_buf[e.sym_buf+l++]&255)<<8,i=e.pending_buf[e.sym_buf+l++],r===0?Tr(e,i,t):(g=gl[i],Tr(e,g+Vl+1,t),o=Eh[g],o!==0&&(i-=_m[g],En(e,i,o)),r--,g=D2(r),Tr(e,g,n),o=Xu[g],o!==0&&(r-=kc[g],En(e,r,o)));while(l{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,l=t.stat_desc.elems;let g,o,a=-1,u;for(e.heap_len=0,e.heap_max=E2,g=0;g>1;g>=1;g--)td(e,n,g);u=l;do g=e.heap[1],e.heap[1]=e.heap[e.heap_len--],td(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=g,e.heap[--e.heap_max]=o,n[u*2]=n[g*2]+n[o*2],e.depth[u]=(e.depth[g]>=e.depth[o]?e.depth[g]:e.depth[o])+1,n[g*2+1]=n[o*2+1]=u,e.heap[1]=u++,td(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],xW(e,t),B2(n,a,e.bl_count)},Q0=(e,t,n)=>{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=g,g=t[(r+1)*2+1],!(++o{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),r=0;r<=n;r++)if(l=g,g=t[(r+1)*2+1],!(++o{let t;for(Q0(e,e.dyn_ltree,e.l_desc.max_code),Q0(e,e.dyn_dtree,e.d_desc.max_code),Oh(e,e.bl_desc),t=ym-1;t>=3&&e.bl_tree[I2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},EW=(e,t,n,r)=>{let i;for(En(e,t-257,5),En(e,n-1,5),En(e,r-4,4),i=0;i{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return G0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return q0;for(n=32;n{ty||(TW(),ty=!0),e.l_desc=new ed(e.dyn_ltree,M2),e.d_desc=new ed(e.dyn_dtree,L2),e.bl_desc=new ed(e.bl_tree,R2),e.bi_buf=0,e.bi_valid=0,F2(e)},N2=(e,t,n,r)=>{En(e,(gW<<1)+(r?1:0),3),z2(e),vl(e,n),vl(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},PW=e=>{En(e,k2<<1,3),Tr(e,bm,Gr),SW(e)},IW=(e,t,n,r)=>{let i,l,g=0;e.level>0?(e.strm.data_type===mW&&(e.strm.data_type=OW(e)),Oh(e,e.l_desc),Oh(e,e.d_desc),g=kW(e),i=e.opt_len+3+7>>>3,l=e.static_len+3+7>>>3,l<=i&&(i=l)):i=l=n+5,n+4<=i&&t!==-1?N2(e,t,n,r):e.strategy===pW||l===i?(En(e,(k2<<1)+(r?1:0),3),J0(e,Gr,Rs)):(En(e,(vW<<1)+(r?1:0),3),EW(e,e.l_desc.max_code+1,e.d_desc.max_code+1,g+1),J0(e,e.dyn_ltree,e.dyn_dtree)),F2(e),r&&z2(e)},MW=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(gl[n]+Vl+1)*2]++,e.dyn_dtree[D2(t)*2]++),e.sym_next===e.sym_end);var LW=AW,RW=N2,DW=IW,$W=MW,BW=PW,FW={_tr_init:LW,_tr_stored_block:RW,_tr_flush_block:DW,_tr_tally:$W,_tr_align:BW};const zW=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,g=0;for(;n!==0;){g=n>2e3?2e3:n,n-=g;do i=i+t[r++]|0,l=l+i|0;while(--g);i%=65521,l%=65521}return i|l<<16|0};var yl=zW;const NW=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},jW=new Uint32Array(NW()),VW=(e,t,n,r)=>{const i=jW,l=r+n;e^=-1;for(let g=r;g>>8^i[(e^t[g])&255];return e^-1};var Zt=VW,$a={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},qo={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:UW,_tr_stored_block:Ah,_tr_flush_block:HW,_tr_tally:$i,_tr_align:WW}=FW,{Z_NO_FLUSH:Bi,Z_PARTIAL_FLUSH:YW,Z_FULL_FLUSH:XW,Z_FINISH:Gn,Z_BLOCK:ny,Z_OK:rn,Z_STREAM_END:ry,Z_STREAM_ERROR:Pr,Z_DATA_ERROR:KW,Z_BUF_ERROR:nd,Z_DEFAULT_COMPRESSION:GW,Z_FILTERED:qW,Z_HUFFMAN_ONLY:_u,Z_RLE:ZW,Z_FIXED:JW,Z_DEFAULT_STRATEGY:QW,Z_UNKNOWN:eY,Z_DEFLATED:lf}=qo,tY=9,nY=15,rY=8,iY=29,aY=256,Ph=aY+1+iY,oY=30,sY=19,lY=2*Ph+1,uY=15,lt=3,Mi=258,Ir=Mi+lt+1,cY=32,$o=42,wm=57,Ih=69,Mh=73,Lh=91,Rh=103,wa=113,ms=666,wn=1,Zo=2,Ba=3,Jo=4,fY=3,Ca=(e,t)=>(e.msg=$a[t],t),iy=e=>e*2-(e>4?9:0),Ai=e=>{let t=e.length;for(;--t>=0;)e[t]=0},dY=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)};let hY=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},jn=(e,t)=>{HW(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$n(e.strm)},mt=(e,t)=>{e.pending_buf[e.pending++]=t},us=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Dh=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=yl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Zt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},j2=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,g=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Ir?e.strstart-(e.w_size-Ir):0,u=e.window,d=e.w_mask,c=e.prev,f=e.strstart+Mi;let s=u[r+g-1],h=u[r+g];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+g]!==h||u[i+g-1]!==s||u[i]!==u[r]||u[++i]!==u[r+1])){r+=2,i++;do;while(u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&rg){if(e.match_start=t,g=l,l>=o)break;s=u[r+g-1],h=u[r+g]}}while((t=c[t&d])>a&&--n!==0);return g<=e.lookahead?g:e.lookahead},Bo=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Ir)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),dY(e),r+=t),e.strm.avail_in===0)break;if(n=Dh(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=lt)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Fi(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Fi(e,e.ins_h,e.window[i+lt-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,l,g=0,o=e.strm.avail_in;do{if(r=65535,l=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(r=i+e.strm.avail_in),r>l&&(r=l),r>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,$n(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(Dh(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(g===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_waterl&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,l+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),l>e.strm.avail_in&&(l=e.strm.avail_in),l&&(Dh(e.strm,e.window,e.strstart,l),e.strstart+=l,e.insert+=l>e.w_size-e.insert?e.w_size-e.insert:l),e.high_water>3,l=e.pending_buf_size-l>65535?65535:e.pending_buf_size-l,n=l>e.w_size?e.w_size:l,i=e.strstart-e.block_start,(i>=n||(i||t===Gn)&&t!==Bi&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,g=t===Gn&&e.strm.avail_in===0&&r===i?1:0,Ah(e,e.block_start,r,g),e.block_start+=r,$n(e.strm)),g?Ba:wn)},rd=(e,t)=>{let n,r;for(;;){if(e.lookahead=lt&&(e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-Ir&&(e.match_length=j2(e,n)),e.match_length>=lt)if(r=$i(e,e.strstart-e.match_start,e.match_length-lt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=lt){e.match_length--;do e.strstart++,e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+1]);else r=$i(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(jn(e,!1),e.strm.avail_out===0))return wn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=lt&&(e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=lt-1,n!==0&&e.prev_length4096)&&(e.match_length=lt-1)),e.prev_length>=lt&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-lt,r=$i(e,e.strstart-1-e.prev_match,e.prev_length-lt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Fi(e,e.ins_h,e.window[e.strstart+lt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=lt-1,e.strstart++,r&&(jn(e,!1),e.strm.avail_out===0))return wn}else if(e.match_available){if(r=$i(e,0,e.window[e.strstart-1]),r&&jn(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return wn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=$i(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const g=e.window;for(;;){if(e.lookahead<=Mi){if(Bo(e),e.lookahead<=Mi&&t===Bi)return wn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=lt&&e.strstart>0&&(i=e.strstart-1,r=g[i],r===g[++i]&&r===g[++i]&&r===g[++i])){l=e.strstart+Mi;do;while(r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=lt?(n=$i(e,1,e.match_length-lt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=$i(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(jn(e,!1),e.strm.avail_out===0))return wn}return e.insert=0,t===Gn?(jn(e,!0),e.strm.avail_out===0?Ba:Jo):e.sym_next&&(jn(e,!1),e.strm.avail_out===0)?wn:Zo},mY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Bo(e),e.lookahead===0)){if(t===Bi)return wn;break}if(e.match_length=0,n=$i(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(jn(e,!1),e.strm.avail_out===0))return wn}return e.insert=0,t===Gn?(jn(e,!0),e.strm.avail_out===0?Ba:Jo):e.sym_next&&(jn(e,!1),e.strm.avail_out===0)?wn:Zo};function wr(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const gs=[new wr(0,0,0,0,V2),new wr(4,4,8,4,rd),new wr(4,5,16,8,rd),new wr(4,6,32,32,rd),new wr(4,4,16,16,ao),new wr(8,16,32,32,ao),new wr(8,16,128,128,ao),new wr(8,32,128,256,ao),new wr(32,128,258,1024,ao),new wr(32,258,258,4096,ao)],gY=e=>{e.window_size=2*e.w_size,Ai(e.head),e.max_lazy_match=gs[e.level].max_lazy,e.good_match=gs[e.level].good_length,e.nice_match=gs[e.level].nice_length,e.max_chain_length=gs[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=lt-1,e.match_available=0,e.ins_h=0};function vY(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=lf,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(lY*2),this.dyn_dtree=new Uint16Array((2*oY+1)*2),this.bl_tree=new Uint16Array((2*sY+1)*2),Ai(this.dyn_ltree),Ai(this.dyn_dtree),Ai(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(uY+1),this.heap=new Uint16Array(2*Ph+1),Ai(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Ph+1),Ai(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ul=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==$o&&t.status!==wm&&t.status!==Ih&&t.status!==Mh&&t.status!==Lh&&t.status!==Rh&&t.status!==wa&&t.status!==ms?1:0},U2=e=>{if(Ul(e))return Ca(e,Pr);e.total_in=e.total_out=0,e.data_type=eY;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?wm:t.wrap?$o:wa,e.adler=t.wrap===2?0:1,t.last_flush=-2,UW(t),rn},H2=e=>{const t=U2(e);return t===rn&&gY(e.state),t},yY=(e,t)=>Ul(e)||e.state.wrap!==2?Pr:(e.state.gzhead=t,rn),W2=(e,t,n,r,i,l)=>{if(!e)return Pr;let g=1;if(t===GW&&(t=6),r<0?(g=0,r=-r):r>15&&(g=2,r-=16),i<1||i>tY||n!==lf||r<8||r>15||t<0||t>9||l<0||l>JW||r===8&&g!==1)return Ca(e,Pr);r===8&&(r=9);const o=new vY;return e.state=o,o.strm=e,o.status=$o,o.wrap=g,o.gzhead=null,o.w_bits=r,o.w_size=1<W2(e,t,lf,nY,rY,QW),_Y=(e,t)=>{if(Ul(e)||t>ny||t<0)return e?Ca(e,Pr):Pr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===ms&&t!==Gn)return Ca(e,e.avail_out===0?nd:Pr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if($n(e),e.avail_out===0)return n.last_flush=-1,rn}else if(e.avail_in===0&&iy(t)<=iy(r)&&t!==Gn)return Ca(e,nd);if(n.status===ms&&e.avail_in!==0)return Ca(e,nd);if(n.status===$o&&n.wrap===0&&(n.status=wa),n.status===$o){let i=lf+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=_u||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=cY),i+=31-i%31,us(n,i),n.strstart!==0&&(us(n,e.adler>>>16),us(n,e.adler&65535)),e.adler=1,n.status=wa,$n(e),n.pending!==0)return n.last_flush=-1,rn}if(n.status===wm){if(e.adler=0,mt(n,31),mt(n,139),mt(n,8),n.gzhead)mt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),mt(n,n.gzhead.time&255),mt(n,n.gzhead.time>>8&255),mt(n,n.gzhead.time>>16&255),mt(n,n.gzhead.time>>24&255),mt(n,n.level===9?2:n.strategy>=_u||n.level<2?4:0),mt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(mt(n,n.gzhead.extra.length&255),mt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Zt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Ih;else if(mt(n,0),mt(n,0),mt(n,0),mt(n,0),mt(n,0),mt(n,n.level===9?2:n.strategy>=_u||n.level<2?4:0),mt(n,fY),n.status=wa,$n(e),n.pending!==0)return n.last_flush=-1,rn}if(n.status===Ih){if(n.gzhead.extra){let i=n.pending,l=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+l>n.pending_buf_size;){let o=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+o),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,$n(e),n.pending!==0)return n.last_flush=-1,rn;i=0,l-=o}let g=new Uint8Array(n.gzhead.extra);n.pending_buf.set(g.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Mh}if(n.status===Mh){if(n.gzhead.name){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),$n(e),n.pending!==0)return n.last_flush=-1,rn;i=0}n.gzindexi&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Lh}if(n.status===Lh){if(n.gzhead.comment){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i)),$n(e),n.pending!==0)return n.last_flush=-1,rn;i=0}n.gzindexi&&(e.adler=Zt(e.adler,n.pending_buf,n.pending-i,i))}n.status=Rh}if(n.status===Rh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&($n(e),n.pending!==0))return n.last_flush=-1,rn;mt(n,e.adler&255),mt(n,e.adler>>8&255),e.adler=0}if(n.status=wa,$n(e),n.pending!==0)return n.last_flush=-1,rn}if(e.avail_in!==0||n.lookahead!==0||t!==Bi&&n.status!==ms){let i=n.level===0?V2(n,t):n.strategy===_u?mY(n,t):n.strategy===ZW?pY(n,t):gs[n.level].func(n,t);if((i===Ba||i===Jo)&&(n.status=ms),i===wn||i===Ba)return e.avail_out===0&&(n.last_flush=-1),rn;if(i===Zo&&(t===YW?WW(n):t!==ny&&(Ah(n,0,0,!1),t===XW&&(Ai(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),$n(e),e.avail_out===0))return n.last_flush=-1,rn}return t!==Gn?rn:n.wrap<=0?ry:(n.wrap===2?(mt(n,e.adler&255),mt(n,e.adler>>8&255),mt(n,e.adler>>16&255),mt(n,e.adler>>24&255),mt(n,e.total_in&255),mt(n,e.total_in>>8&255),mt(n,e.total_in>>16&255),mt(n,e.total_in>>24&255)):(us(n,e.adler>>>16),us(n,e.adler&65535)),$n(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?rn:ry)},wY=e=>{if(Ul(e))return Pr;const t=e.state.status;return e.state=null,t===wa?Ca(e,KW):rn},CY=(e,t)=>{let n=t.length;if(Ul(e))return Pr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==$o||r.lookahead)return Pr;if(i===1&&(e.adler=yl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Ai(r.head),r.strstart=0,r.block_start=0,r.insert=0);let a=new Uint8Array(r.w_size);a.set(t.subarray(n-r.w_size,n),0),t=a,n=r.w_size}const l=e.avail_in,g=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Bo(r);r.lookahead>=lt;){let a=r.strstart,u=r.lookahead-(lt-1);do r.ins_h=Fi(r,r.ins_h,r.window[a+lt-1]),r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++;while(--u);r.strstart=a,r.lookahead=lt-1,Bo(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=lt-1,r.match_available=0,e.next_in=g,e.input=o,e.avail_in=l,r.wrap=i,rn};var SY=bY,xY=W2,TY=H2,kY=U2,EY=yY,OY=_Y,AY=wY,PY=CY,IY="pako deflate (from Nodeca project)",Ds={deflateInit:SY,deflateInit2:xY,deflateReset:TY,deflateResetKeep:kY,deflateSetHeader:EY,deflate:OY,deflateEnd:AY,deflateSetDictionary:PY,deflateInfo:IY};const MY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var LY=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(!!n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)MY(n,r)&&(e[r]=n[r])}}return e},RY=e=>{let t=0;for(let r=0,i=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;bl[254]=bl[254]=1;var DY=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,g=e.length,o=0;for(i=0;i>>6,t[l++]=128|n&63):n<65536?(t[l++]=224|n>>>12,t[l++]=128|n>>>6&63,t[l++]=128|n&63):(t[l++]=240|n>>>18,t[l++]=128|n>>>12&63,t[l++]=128|n>>>6&63,t[l++]=128|n&63);return t};const $Y=(e,t)=>{if(t<65534&&e.subarray&&Y2)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i;const l=new Array(n*2);for(i=0,r=0;r4){l[i++]=65533,r+=o-1;continue}for(g&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}g<65536?l[i++]=g:(g-=65536,l[i++]=55296|g>>10&1023,l[i++]=56320|g&1023)}return $Y(l,i)},FY=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+bl[e[n]]>t?n:t},_l={string2buf:DY,buf2string:BY,utf8border:FY};function zY(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var X2=zY;const K2=Object.prototype.toString,{Z_NO_FLUSH:NY,Z_SYNC_FLUSH:jY,Z_FULL_FLUSH:VY,Z_FINISH:UY,Z_OK:Ec,Z_STREAM_END:HY,Z_DEFAULT_COMPRESSION:WY,Z_DEFAULT_STRATEGY:YY,Z_DEFLATED:XY}=qo;function Hl(e){this.options=uf.assign({level:WY,method:XY,chunkSize:16384,windowBits:15,memLevel:8,strategy:YY},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new X2,this.strm.avail_out=0;let n=Ds.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Ec)throw new Error($a[n]);if(t.header&&Ds.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=_l.string2buf(t.dictionary):K2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Ds.deflateSetDictionary(this.strm,r),n!==Ec)throw new Error($a[n]);this._dict_set=!0}}Hl.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,l;if(this.ended)return!1;for(t===~~t?l=t:l=t===!0?UY:NY,typeof e=="string"?n.input=_l.string2buf(e):K2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(l===jY||l===VY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=Ds.deflate(n,l),i===HY)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Ds.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Ec;if(n.avail_out===0){this.onData(n.output);continue}if(l>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};Hl.prototype.onData=function(e){this.chunks.push(e)};Hl.prototype.onEnd=function(e){e===Ec&&(this.result=uf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Cm(e,t){const n=new Hl(t);if(n.push(e,!0),n.err)throw n.msg||$a[n.err];return n.result}function KY(e,t){return t=t||{},t.raw=!0,Cm(e,t)}function GY(e,t){return t=t||{},t.gzip=!0,Cm(e,t)}var qY=Hl,ZY=Cm,JY=KY,QY=GY,eX=qo,tX={Deflate:qY,deflate:ZY,deflateRaw:JY,gzip:QY,constants:eX};const wu=16209,nX=16191;var rX=function(t,n){let r,i,l,g,o,a,u,d,c,f,s,h,v,m,y,b,_,w,S,x,T,E,I,D;const N=t.state;r=t.next_in,I=t.input,i=r+(t.avail_in-5),l=t.next_out,D=t.output,g=l-(n-t.avail_out),o=l+(t.avail_out-257),a=N.dmax,u=N.wsize,d=N.whave,c=N.wnext,f=N.window,s=N.hold,h=N.bits,v=N.lencode,m=N.distcode,y=(1<>>24,s>>>=w,h-=w,w=_>>>16&255,w===0)D[l++]=_&65535;else if(w&16){S=_&65535,w&=15,w&&(h>>=w,h-=w),h<15&&(s+=I[r++]<>>24,s>>>=w,h-=w,w=_>>>16&255,w&16){if(x=_&65535,w&=15,ha){t.msg="invalid distance too far back",N.mode=wu;break e}if(s>>>=w,h-=w,w=l-g,x>w){if(w=x-w,w>d&&N.sane){t.msg="invalid distance too far back",N.mode=wu;break e}if(T=0,E=f,c===0){if(T+=u-w,w2;)D[l++]=E[T++],D[l++]=E[T++],D[l++]=E[T++],S-=3;S&&(D[l++]=E[T++],S>1&&(D[l++]=E[T++]))}else{T=l-x;do D[l++]=D[T++],D[l++]=D[T++],D[l++]=D[T++],S-=3;while(S>2);S&&(D[l++]=D[T++],S>1&&(D[l++]=D[T++]))}}else if((w&64)===0){_=m[(_&65535)+(s&(1<>3,r-=S,h-=S<<3,s&=(1<{const a=o.bits;let u=0,d=0,c=0,f=0,s=0,h=0,v=0,m=0,y=0,b=0,_,w,S,x,T,E=null,I;const D=new Uint16Array(oo+1),N=new Uint16Array(oo+1);let L=null,F,O,V;for(u=0;u<=oo;u++)D[u]=0;for(d=0;d=1&&D[f]===0;f--);if(s>f&&(s=f),f===0)return i[l++]=1<<24|64<<16|0,i[l++]=1<<24|64<<16|0,o.bits=1,0;for(c=1;c0&&(e===sy||f!==1))return-1;for(N[1]=0,u=1;uay||e===ly&&y>oy)return 1;for(;;){F=u-v,g[d]+1=I?(O=L[g[d]-I],V=E[g[d]-I]):(O=32+64,V=0),_=1<>v)+w]=F<<24|O<<16|V|0;while(w!==0);for(_=1<>=1;if(_!==0?(b&=_-1,b+=_):b=0,d++,--D[u]===0){if(u===f)break;u=t[n+g[d]]}if(u>s&&(b&x)!==S){for(v===0&&(v=s),T+=c,h=u-v,m=1<ay||e===ly&&y>oy)return 1;S=b&x,i[S]=s<<24|h<<16|T-l|0}}return b!==0&&(i[T+b]=u-v<<24|64<<16|0),o.bits=s,0};var $s=lX;const uX=0,G2=1,q2=2,{Z_FINISH:uy,Z_BLOCK:cX,Z_TREES:Cu,Z_OK:Fa,Z_STREAM_END:fX,Z_NEED_DICT:dX,Z_STREAM_ERROR:tr,Z_DATA_ERROR:Z2,Z_MEM_ERROR:J2,Z_BUF_ERROR:hX,Z_DEFLATED:cy}=qo,cf=16180,fy=16181,dy=16182,hy=16183,py=16184,my=16185,gy=16186,vy=16187,yy=16188,by=16189,Oc=16190,Ur=16191,ad=16192,_y=16193,od=16194,wy=16195,Cy=16196,Sy=16197,xy=16198,Su=16199,xu=16200,Ty=16201,ky=16202,Ey=16203,Oy=16204,Ay=16205,sd=16206,Py=16207,Iy=16208,Bt=16209,Q2=16210,eC=16211,pX=852,mX=592,gX=15,vX=gX,My=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function yX(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ga=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modeeC?1:0},tC=e=>{if(Ga(e))return tr;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=cf,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(pX),t.distcode=t.distdyn=new Int32Array(mX),t.sane=1,t.back=-1,Fa},nC=e=>{if(Ga(e))return tr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,tC(e)},rC=(e,t)=>{let n;if(Ga(e))return tr;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?tr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,nC(e))},iC=(e,t)=>{if(!e)return tr;const n=new yX;e.state=n,n.strm=e,n.window=null,n.mode=cf;const r=rC(e,t);return r!==Fa&&(e.state=null),r},bX=e=>iC(e,vX);let Ly=!0,ld,ud;const _X=e=>{if(Ly){ld=new Int32Array(512),ud=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for($s(G2,e.lens,0,288,ld,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;$s(q2,e.lens,0,32,ud,0,e.work,{bits:5}),Ly=!1}e.lencode=ld,e.lenbits=9,e.distcode=ud,e.distbits=5},aC=(e,t,n,r)=>{let i;const l=e.state;return l.window===null&&(l.wsize=1<=l.wsize?(l.window.set(t.subarray(n-l.wsize,n),0),l.wnext=0,l.whave=l.wsize):(i=l.wsize-l.wnext,i>r&&(i=r),l.window.set(t.subarray(n-r,n-r+i),l.wnext),r-=i,r?(l.window.set(t.subarray(n-r,n),0),l.wnext=r,l.whave=l.wsize):(l.wnext+=i,l.wnext===l.wsize&&(l.wnext=0),l.whave{let n,r,i,l,g,o,a,u,d,c,f,s,h,v,m=0,y,b,_,w,S,x,T,E;const I=new Uint8Array(4);let D,N;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ga(e)||!e.output||!e.input&&e.avail_in!==0)return tr;n=e.state,n.mode===Ur&&(n.mode=ad),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,d=n.bits,c=o,f=a,E=Fa;e:for(;;)switch(n.mode){case cf:if(n.wrap===0){n.mode=ad;break}for(;d<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Zt(n.check,I,2,0),u=0,d=0,n.mode=fy;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Bt;break}if((u&15)!==cy){e.msg="unknown compression method",n.mode=Bt;break}if(u>>>=4,d-=4,T=(u&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=Bt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(I[0]=u&255,I[1]=u>>>8&255,n.check=Zt(n.check,I,2,0)),u=0,d=0,n.mode=dy;case dy:for(;d<32;){if(o===0)break e;o--,u+=r[l++]<>>8&255,I[2]=u>>>16&255,I[3]=u>>>24&255,n.check=Zt(n.check,I,4,0)),u=0,d=0,n.mode=hy;case hy:for(;d<16;){if(o===0)break e;o--,u+=r[l++]<>8),n.flags&512&&n.wrap&4&&(I[0]=u&255,I[1]=u>>>8&255,n.check=Zt(n.check,I,2,0)),u=0,d=0,n.mode=py;case py:if(n.flags&1024){for(;d<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Zt(n.check,I,2,0)),u=0,d=0}else n.head&&(n.head.extra=null);n.mode=my;case my:if(n.flags&1024&&(s=n.length,s>o&&(s=o),s&&(n.head&&(T=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(l,l+s),T)),n.flags&512&&n.wrap&4&&(n.check=Zt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=gy;case gy:if(n.flags&2048){if(o===0)break e;s=0;do T=r[l+s++],n.head&&T&&n.length<65536&&(n.head.name+=String.fromCharCode(T));while(T&&s>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Ur;break;case by:for(;d<32;){if(o===0)break e;o--,u+=r[l++]<>>=d&7,d-=d&7,n.mode=sd;break}for(;d<3;){if(o===0)break e;o--,u+=r[l++]<>>=1,d-=1,u&3){case 0:n.mode=_y;break;case 1:if(_X(n),n.mode=Su,t===Cu){u>>>=2,d-=2;break e}break;case 2:n.mode=Cy;break;case 3:e.msg="invalid block type",n.mode=Bt}u>>>=2,d-=2;break;case _y:for(u>>>=d&7,d-=d&7;d<32;){if(o===0)break e;o--,u+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Bt;break}if(n.length=u&65535,u=0,d=0,n.mode=od,t===Cu)break e;case od:n.mode=wy;case wy:if(s=n.length,s){if(s>o&&(s=o),s>a&&(s=a),s===0)break e;i.set(r.subarray(l,l+s),g),o-=s,l+=s,a-=s,g+=s,n.length-=s;break}n.mode=Ur;break;case Cy:for(;d<14;){if(o===0)break e;o--,u+=r[l++]<>>=5,d-=5,n.ndist=(u&31)+1,u>>>=5,d-=5,n.ncode=(u&15)+4,u>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Bt;break}n.have=0,n.mode=Sy;case Sy:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[L[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,D={bits:n.lenbits},E=$s(uX,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid code lengths set",n.mode=Bt;break}n.have=0,n.mode=xy;case xy:for(;n.have>>24,b=m>>>16&255,_=m&65535,!(y<=d);){if(o===0)break e;o--,u+=r[l++]<>>=y,d-=y,n.lens[n.have++]=_;else{if(_===16){for(N=y+2;d>>=y,d-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=Bt;break}T=n.lens[n.have-1],s=3+(u&3),u>>>=2,d-=2}else if(_===17){for(N=y+3;d>>=y,d-=y,T=0,s=3+(u&7),u>>>=3,d-=3}else{for(N=y+7;d>>=y,d-=y,T=0,s=11+(u&127),u>>>=7,d-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Bt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===Bt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Bt;break}if(n.lenbits=9,D={bits:n.lenbits},E=$s(G2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid literal/lengths set",n.mode=Bt;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},E=$s(q2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,E){e.msg="invalid distances set",n.mode=Bt;break}if(n.mode=Su,t===Cu)break e;case Su:n.mode=xu;case xu:if(o>=6&&a>=258){e.next_out=g,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=u,n.bits=d,rX(e,f),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,d=n.bits,n.mode===Ur&&(n.back=-1);break}for(n.back=0;m=n.lencode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=d);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=d);){if(o===0)break e;o--,u+=r[l++]<>>=w,d-=w,n.back+=w}if(u>>>=y,d-=y,n.back+=y,n.length=_,b===0){n.mode=Ay;break}if(b&32){n.back=-1,n.mode=Ur;break}if(b&64){e.msg="invalid literal/length code",n.mode=Bt;break}n.extra=b&15,n.mode=Ty;case Ty:if(n.extra){for(N=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=ky;case ky:for(;m=n.distcode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=d);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=d);){if(o===0)break e;o--,u+=r[l++]<>>=w,d-=w,n.back+=w}if(u>>>=y,d-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=Bt;break}n.offset=_,n.extra=b&15,n.mode=Ey;case Ey:if(n.extra){for(N=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Bt;break}n.mode=Oy;case Oy:if(a===0)break e;if(s=f-a,n.offset>s){if(s=n.offset-s,s>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Bt;break}s>n.wnext?(s-=n.wnext,h=n.wsize-s):h=n.wnext-s,s>n.length&&(s=n.length),v=n.window}else v=i,h=g-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[g++]=v[h++];while(--s);n.length===0&&(n.mode=xu);break;case Ay:if(a===0)break e;i[g++]=n.length,a--,n.mode=xu;break;case sd:if(n.wrap){for(;d<32;){if(o===0)break e;o--,u|=r[l++]<{if(Ga(e))return tr;let t=e.state;return t.window&&(t.window=null),e.state=null,Fa},SX=(e,t)=>{if(Ga(e))return tr;const n=e.state;return(n.wrap&2)===0?tr:(n.head=t,t.done=!1,Fa)},xX=(e,t)=>{const n=t.length;let r,i,l;return Ga(e)||(r=e.state,r.wrap!==0&&r.mode!==Oc)?tr:r.mode===Oc&&(i=1,i=yl(i,t,n,0),i!==r.check)?Z2:(l=aC(e,t,n,n),l?(r.mode=Q2,J2):(r.havedict=1,Fa))};var TX=nC,kX=rC,EX=tC,OX=bX,AX=iC,PX=wX,IX=CX,MX=SX,LX=xX,RX="pako inflate (from Nodeca project)",qr={inflateReset:TX,inflateReset2:kX,inflateResetKeep:EX,inflateInit:OX,inflateInit2:AX,inflate:PX,inflateEnd:IX,inflateGetHeader:MX,inflateSetDictionary:LX,inflateInfo:RX};function DX(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var $X=DX;const oC=Object.prototype.toString,{Z_NO_FLUSH:BX,Z_FINISH:FX,Z_OK:wl,Z_STREAM_END:cd,Z_NEED_DICT:fd,Z_STREAM_ERROR:zX,Z_DATA_ERROR:Ry,Z_MEM_ERROR:NX}=qo;function Wl(e){this.options=uf.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new X2,this.strm.avail_out=0;let n=qr.inflateInit2(this.strm,t.windowBits);if(n!==wl)throw new Error($a[n]);if(this.header=new $X,qr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=_l.string2buf(t.dictionary):oC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=qr.inflateSetDictionary(this.strm,t.dictionary),n!==wl)))throw new Error($a[n])}Wl.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,g,o;if(this.ended)return!1;for(t===~~t?g=t:g=t===!0?FX:BX,oC.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),l=qr.inflate(n,g),l===fd&&i&&(l=qr.inflateSetDictionary(n,i),l===wl?l=qr.inflate(n,g):l===Ry&&(l=fd));n.avail_in>0&&l===cd&&n.state.wrap>0&&e[n.next_in]!==0;)qr.inflateReset(n),l=qr.inflate(n,g);switch(l){case zX:case Ry:case fd:case NX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===cd))if(this.options.to==="string"){let a=_l.utf8border(n.output,n.next_out),u=n.next_out-a,d=_l.buf2string(n.output,a);n.next_out=u,n.avail_out=r-u,u&&n.output.set(n.output.subarray(a,a+u),0),this.onData(d)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===wl&&o===0)){if(l===cd)return l=qr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Wl.prototype.onData=function(e){this.chunks.push(e)};Wl.prototype.onEnd=function(e){e===wl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=uf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Sm(e,t){const n=new Wl(t);if(n.push(e),n.err)throw n.msg||$a[n.err];return n.result}function jX(e,t){return t=t||{},t.raw=!0,Sm(e,t)}var VX=Wl,UX=Sm,HX=jX,WX=Sm,YX=qo,XX={Inflate:VX,inflate:UX,inflateRaw:HX,ungzip:WX,constants:YX};const{Deflate:oq,deflate:sq,deflateRaw:KX,gzip:lq}=tX,{Inflate:uq,inflate:cq,inflateRaw:GX,ungzip:fq}=XX;var qX=KX,ZX=GX;function Dy(e){const t=new Map;for(const n of e){const[r,i]=n.split("="),l=decodeURIComponent(i);t.set(r,l)}return t}const JX=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=Dy(t);if(console.log("URL params:",n),n.get("share")){const l=ZX(new Uint8Array(atob(n.get("share")).split("").map(g=>g.charCodeAt(0))),{to:"string"});if(!l){Ut().raiseError("Error when trying to decode share parameter!",!1);return}n=Dy(l.split("&")),console.log("Share URL params:",n)}const r={id:-1,image:"",prompt:n.get("prompt")||"",sampler_name:n.get("sampler_name")||"k_euler",seed:Number(n.get("seed"))||-1,steps:Number(n.get("steps")||20),cfg_scale:Number(n.get("cfg_scale")||5),height:Number(n.get("height")||512),width:Number(n.get("width")||512),clip_skip:Number(n.get("clip_skip")||0),frames:Number(n.get("frames")||1),fps:Number(n.get("fps")||16),scheduler:n.get("scheduler")||"default"};Jt().generateText2Img(r,!1)},QX=10;function Ku(e,t,n,r,i=l=>Ut().raiseError(l,!1)){if(e.status===n&&t)return!0;if(!t.message)return i(`${r}: Got response code ${e.status}`);if(!t.errors)return i(`${r}: ${t.message}`);const l=Object.entries(t.errors).map(g=>`${g[0]} - ${g[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}const eK=zo("interrogate",()=>{const e=oe({}),t=oe(!1);async function n(g){Ut().raiseError(g,!1),t.value=!1,e.value={}}async function r(){const g=zt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/interrogate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),u=await a.json();!Ku(a,u,200,"Failed to get interrogation",n)||(e.value.id=u.id,e.value.status=u.caption)}function i(){e.value={},t.value=!1}function l(){return e.value.status||!1}return{currentInterrogation:e,interrogating:t,interrogateImage:r,getFormStatus:l,resetInterrogation:i}}),xm=e=>(ui("data-v-db184ac6"),e=e(),ci(),e),tK={key:0,style:{"margin-top":"16px"}},nK=xm(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),rK={key:1,style:{"margin-top":"16px"}},iK={key:2},aK={style:{"margin-top":"8px"}},oK=xm(()=>ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),sK={key:0},lK=xm(()=>ne("h3",null,"Caption",-1)),uK={key:0},cK={key:1},fK=Ee({__name:"InterrogationView",setup(e){const t=eK(),n=Jt(),r=Ut(),i=oe();async function l(u){if(i.value.clearFiles(),!u.raw.type.includes("image")){r.raiseError("Uploaded file needs to be a image!",!1);return}const d=await Tc(u.raw);t.currentInterrogation.source_image=d,t.interrogateImage()}function g(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=x2();return(u,d)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(z(),se("div",iK,[ne("div",aK,[le(C(at),{icon:C(Mg),onClick:C(t).resetInterrogation},{default:he(()=>[He("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(z(),be(C(at),{key:0,icon:C(Mg),onClick:g,disabled:!C(o)},{default:he(()=>[He("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):ye("",!0)]),oK,le(C(ef),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(z(),se("div",sK,[lK,C(o)?(z(),se("div",cK,[ne("strong",null,Ae(C(o)),1)])):(z(),se("div",uK,"Processing"+Ae(C(a)),1))])):ye("",!0)])):(z(),se("div",rK,[ne("strong",null,"Uploading image"+Ae(C(a)),1)])):(z(),se("div",tK,[ne("div",null,[le(C(Yp),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:he(()=>[le(C(Le),{size:100},{default:he(()=>[le(C(dp))]),_:1}),nK]),_:1},512)])]))}});const dK=qt(fK,[["__scopeId","data-v-db184ac6"]]);function hK(e,t,n){if(e===0)return"0"+(t?"s":"seconds");if(e==null)return"?";const r=Math.floor(e/86400),i=Math.floor(e%86400/3600),l=Math.floor(e%86400%3600/60),g=Math.floor(e%86400%3600%60),o=r>0?r+(t?"d":"days"):"",a=i>0?i+(t?"h":"hours"):"",u=l>0?l+(t?"m":"minutes"):"",d=g>0?g+(t?"s":"seconds"):"",c=[];return n!=null&&n.days&&c.push(o),n!=null&&n.hours&&c.push(a),n!=null&&n.minutes&&c.push(u),n!=null&&n.seconds&&c.push(d),c.join(" ")}const pK={class:"form"},mK={key:0,style:{"padding-bottom":"50px"}},gK=ne("h1",{style:{margin:"0"}},"Interrogation",-1),vK=ne("div",null,"Interrogate images to get their predicted descriptions.",-1),yK={class:"sidebar"},bK={class:"reference-images-header"},_K=ne("span",{class:"reference-images-label"},"Reference Images",-1),wK={class:"reference-images-actions"},CK={key:0,class:"reference-image-list"},SK={class:"reference-image-index"},xK=["title"],TK={class:"reference-image-controls"},kK={key:1,class:"reference-image-empty"},EK={class:"main"},OK={class:"image center-horizontal"},AK={key:0},PK=Ee({__name:"GenerateView",setup(e){const n=Ep(kp).smallerOrEqual("md"),r=Jt(),i=Ut(),l=Ls();zt();const g=gv(async()=>{const _=r.cacheVersion,S=(await r.getAvailableSamplers()).map(x=>x.name);return S.length===0?[]:u(S)},[]),o=gv(async()=>{const _=r.cacheVersion,S=(await r.getAvailableSchedulers()).map(x=>x.name);return S.length===0?[]:d(S)},[]),a=yt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function u(_){return!r.params||!r.params.sampler_name||_.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=_[0]),_}function d(_){return!r.params||!r.params.scheduler||_.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=_[0]),_}function c(_){return"Elapsed: "+hK(_,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function f(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function s(_){r.generatorType=_,f(),console.log(_)}function h(){l.showCropPreview=!0,l.updateCropPreview()}function v(){var _;(_=document.getElementById("extra_image_input"))==null||_.click()}function m(_){var w;return(w=_.dataUrl)==null?void 0:w.startsWith("data:image")}function y(){return r.referenceImages.filter(m).map(_=>_.dataUrl)}function b(_){return r.referenceImages.slice(0,_).filter(m).length}return f(),JX(),(_,w)=>(z(),se(je,null,[le(C(mw),{"default-active":C(r).generatorType,collapse:!0,onSelect:s,mode:C(n)?"horizontal":"vertical",class:de(C(n)?"mobile-generator-types":"generator-types"),style:ze(C(n)?"overflow-x: auto":"")},{default:he(()=>[le(bu,{index:"Text2Img","icon-one":C(EE),"icon-two":C(tu),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(bu,{index:"Img2Img","icon-one":C(tu),"icon-two":C(tu),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(bu,{index:"Inpainting","icon-one":S2,"icon-two":C(tu),isMobile:C(n)},null,8,["icon-two","isMobile"]),le(bu,{index:"Interrogation","icon-one":gH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",pK,[C(r).generatorType==="Interrogation"?(z(),se("div",mK,[gK,vK,le(dK)])):(z(),be(C(jp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:a,onSubmit:w[31]||(w[31]=et(()=>{},["prevent"]))},{default:he(()=>[ne("div",yK,[le(RH),le(kh,{label:"Negative Prompt",prop:"negativePrompt",modelValue:C(r).negativePrompt,"onUpdate:modelValue":w[0]||(w[0]=S=>C(r).negativePrompt=S),autosize:{maxRows:15},resize:"vertical",type:"textarea",placeholder:"Enter negative prompt here",info:"What to exclude from the image. Not working? Try increasing the guidance.","label-position":"top"},null,8,["modelValue"]),le(kh,{label:"Seed",prop:"seed",modelValue:C(r).params.seed,"onUpdate:modelValue":w[2]||(w[2]=S=>C(r).params.seed=S),placeholder:"Enter seed here",clearable:"","clear-icon":C(gE)},{append:he(()=>[le(C(zn),{content:"Randomize!",placement:"top"},{default:he(()=>[le(C(at),{icon:C(X3),onClick:w[1]||(w[1]=()=>C(r).params.seed=C(sC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(z(),be(C(b0),{key:0,gutter:10},{default:he(()=>[C(r).multiSelect.sampler.state==="Multiple"?(z(),be(C(to),{key:0,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Sampler(s)",prop:"samplers",modelValue:C(r).multiSelect.sampler.selected,"onUpdate:modelValue":w[3]||(w[3]=S=>C(r).multiSelect.sampler.selected=S),options:C(g),info:"Multi-select enabled. Heun and DPM2 double generation time per step, but converge twice as fast.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0),C(r).multiSelect.sampler.state==="Enabled"?(z(),be(C(to),{key:1,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Sampler",prop:"sampler",modelValue:C(r).params.sampler_name,"onUpdate:modelValue":w[4]||(w[4]=S=>C(r).params.sampler_name=S),options:C(g),info:"Heun and DPM2 double generation time per step, but converge twice as fast."},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0),C(r).multiSelect.scheduler.state==="Multiple"?(z(),be(C(to),{key:2,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Scheduler(s)",prop:"schedulers",modelValue:C(r).multiSelect.scheduler.selected,"onUpdate:modelValue":w[5]||(w[5]=S=>C(r).multiSelect.scheduler.selected=S),options:C(o),info:"Multi-select enabled. Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0),C(r).multiSelect.scheduler.state==="Enabled"?(z(),be(C(to),{key:3,span:C(n)?24:12},{default:he(()=>[le(po,{label:"Scheduler",prop:"scheduler",modelValue:C(r).params.scheduler,"onUpdate:modelValue":w[6]||(w[6]=S=>C(r).params.scheduler=S),options:C(o),info:"Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise."},null,8,["modelValue","options"])]),_:1},8,["span"])):ye("",!0)]),_:1})),le(bn,{label:"Batch Size",prop:"batchSize",modelValue:C(r).params.n,"onUpdate:modelValue":w[7]||(w[7]=S=>C(r).params.n=S),min:C(r).minImages,max:C(r).maxImages},null,8,["modelValue","min","max"]),C(r).multiSelect.steps.state==="Multiple"?(z(),be(bn,{key:1,label:"Steps(s)",prop:"multiSteps",modelValue:C(r).multiSelect.steps.selected,"onUpdate:modelValue":w[8]||(w[8]=S=>C(r).multiSelect.steps.selected=S),min:C(r).minSteps,max:C(r).maxSteps,info:"Multi-select enabled. Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed.",multiple:""},null,8,["modelValue","min","max"])):C(r).multiSelect.steps.state==="Enabled"?(z(),be(bn,{key:2,label:"Steps",prop:"steps",modelValue:C(r).params.steps,"onUpdate:modelValue":w[9]||(w[9]=S=>C(r).params.steps=S),min:C(r).minSteps,max:C(r).maxSteps,info:"Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed."},null,8,["modelValue","min","max"])):ye("",!0),le(bn,{label:"Width",prop:"width",modelValue:C(r).params.width,"onUpdate:modelValue":w[10]||(w[10]=S=>C(r).params.width=S),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:h},null,8,["modelValue","min","max"]),le(bn,{label:"Height",prop:"height",modelValue:C(r).params.height,"onUpdate:modelValue":w[11]||(w[11]=S=>C(r).params.height=S),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:h},null,8,["modelValue","min","max"]),C(r).multiSelect.guidance.state==="Multiple"?(z(),be(bn,{key:3,label:"Guidance(s)",prop:"cfgScales",modelValue:C(r).multiSelect.guidance.selected,"onUpdate:modelValue":w[12]||(w[12]=S=>C(r).multiSelect.guidance.selected=S),min:C(r).minCfgScale,max:C(r).maxCfgScale,info:"Multi-select enabled. Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative.",multiple:""},null,8,["modelValue","min","max"])):C(r).multiSelect.guidance.state==="Enabled"?(z(),be(bn,{key:4,label:"Guidance",prop:"cfgScale",modelValue:C(r).params.cfg_scale,"onUpdate:modelValue":w[13]||(w[13]=S=>C(r).params.cfg_scale=S),min:C(r).minCfgScale,max:C(r).maxCfgScale,step:.5,info:"Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative."},null,8,["modelValue","min","max","step"])):ye("",!0),C(r).multiSelect.eta.state==="Enabled"?(z(),be(bn,{key:5,label:"Eta",prop:"eta",modelValue:C(r).params.eta,"onUpdate:modelValue":w[14]||(w[14]=S=>C(r).params.eta=S),min:C(r).minEta,max:C(r).maxEta,step:.1,info:"Noise multiplier for ancestral samplers. 0 disables noise injection."},null,8,["modelValue","min","max","step"])):ye("",!0),C(r).multiSelect.clipSkip.state==="Multiple"?(z(),be(bn,{key:6,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:C(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":w[15]||(w[15]=S=>C(r).multiSelect.clipSkip.selected=S),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Multi-select enabled. Last layers of CLIP to ignore. For most situations this can be left alone.",multiple:""},null,8,["modelValue","min","max"])):C(r).multiSelect.clipSkip.state==="Enabled"?(z(),be(bn,{key:7,label:"CLIP Skip",prop:"clipSkip",modelValue:C(r).params.clip_skip,"onUpdate:modelValue":w[16]||(w[16]=S=>C(r).params.clip_skip=S),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Last layers of CLIP to ignore. For most situations this can be left alone."},null,8,["modelValue","min","max"])):ye("",!0),C(r).sourceGeneratorTypes.includes(C(r).generatorType)?(z(),be(bn,{key:8,label:"Init Strength",prop:"denoise",modelValue:C(r).params.denoising_strength,"onUpdate:modelValue":w[17]||(w[17]=S=>C(r).params.denoising_strength=S),min:C(r).minDenoise,max:C(r).maxDenoise,step:.01,info:"The final image will diverge from the starting image at higher values. 0=unchanged, 1=fullychanged"},null,8,["modelValue","min","max","step"])):ye("",!0),le(bn,{label:"Video Frames",prop:"frames",modelValue:C(r).params.frames,"onUpdate:modelValue":w[18]||(w[18]=S=>C(r).params.frames=S),min:C(r).minFrames,max:C(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). More frames increases memory usage."},null,8,["modelValue","min","max"]),C(r).params.frames>1?(z(),be(bn,{key:9,label:"FPS",prop:"fps",modelValue:C(r).params.fps,"onUpdate:modelValue":w[19]||(w[19]=S=>C(r).params.fps=S),min:C(r).minFps,max:C(r).maxFps,disabled:C(r).params.frames<=1,info:"Frames per second for video generation."},null,8,["modelValue","min","max","disabled"])):ye("",!0),ne("div",{class:"reference-images",onDragover:w[22]||(w[22]=et(()=>{},["prevent"])),onDrop:w[23]||(w[23]=et(S=>C(r).setExtraImage(S),["prevent"]))},[ne("div",bK,[_K,ne("div",wK,[ne("input",{class:"reference-images-input",type:"file",id:"extra_image_input",onChange:w[20]||(w[20]=S=>C(r).setExtraImage(S)),accept:"image/*",multiple:""},null,32),le(C(at),{onClick:v},{default:he(()=>[He(" Select or Drag Files ")]),_:1}),le(C(at),{onClick:w[21]||(w[21]=S=>C(r).clearExtraImage()),disabled:C(r).referenceImages.length===0},{default:he(()=>[He(" Clear Images ")]),_:1},8,["disabled"])])]),C(r).referenceImages.length>0?(z(),se("div",CK,[(z(!0),se(je,null,Nt(C(r).referenceImages,(S,x)=>(z(),se("div",{class:de(["reference-image-item",{"reference-file-item":!m(S)}]),key:S.id},[ne("span",SK,Ae(x+1),1),m(S)?(z(),be(C(ef),{key:0,class:"reference-image-thumb",src:S.dataUrl,fit:"cover","preview-src-list":y(),"initial-index":b(x),"preview-teleported":""},null,8,["src","preview-src-list","initial-index"])):ye("",!0),ne("span",{class:"reference-image-name",title:S.name},Ae(S.name),9,xK),ne("div",TK,[le(C(zn),{content:"Move up",placement:"top"},{default:he(()=>[le(C(at),{class:"small-btn",icon:C(f_),disabled:x===0,onClick:T=>C(r).moveExtraImage(x,-1)},null,8,["icon","disabled","onClick"])]),_:2},1024),le(C(zn),{content:"Move down",placement:"top"},{default:he(()=>[le(C(at),{class:"small-btn",icon:C(Tl),disabled:x===C(r).referenceImages.length-1,onClick:T=>C(r).moveExtraImage(x,1)},null,8,["icon","disabled","onClick"])]),_:2},1024),le(C(zn),{content:"Remove",placement:"top"},{default:he(()=>[le(C(at),{class:"small-btn",type:"danger",icon:C(Ol),plain:"",onClick:T=>C(r).removeExtraImage(x)},null,8,["icon","onClick"])]),_:2},1024)])],2))),128))])):(z(),se("div",kK," No reference images selected. "))],32),le(C(b0),null,{default:he(()=>[le(C(to),{span:C(n)?24:12},{default:he(()=>[le(qf,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":w[24]||(w[24]=S=>C(r).params.enable_hr=S),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),le(C(to),{span:C(n)?24:12},{default:he(()=>[C(r).generatorType==="Img2Img"?(z(),be(qf,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:C(r).params.send_as_refimg,"onUpdate:modelValue":w[25]||(w[25]=S=>C(r).params.send_as_refimg=S),info:"Instead of regular Img2Img, send the image as a reference image for edit models."},null,8,["modelValue"])):ye("",!0),C(r).generatorType==="Img2Img"&&C(r).params.send_as_refimg&&C(r).params.frames>1?(z(),be(qf,{key:1,label:"Reverse RefImg",prop:"reverse_refimg",modelValue:C(r).params.reverse_refimg,"onUpdate:modelValue":w[26]||(w[26]=S=>C(r).params.reverse_refimg=S),info:"Use the reference image as the final frame instead of the first frame."},null,8,["modelValue"])):ye("",!0)]),_:1},8,["span"])]),_:1})]),ne("div",EK,[le(C(at),{onClick:w[27]||(w[27]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:he(()=>[He("Reset")]),_:1}),le(C(at),{type:"primary",class:"generate-cancel-btn",style:ze(C(r).generating?"width: 55%;":""),onClick:w[28]||(w[28]=()=>C(r).generateImage(C(r).generatorType))},{default:he(()=>[ne("span",null," Generate "+Ae(C(r).totalImageCount)+" image"+Ae(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(z(),be(C(at),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:w[29]||(w[29]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:he(()=>[He("Cancel all")]),_:1},8,["disabled"])):ye("",!0)]),ne("div",OK,[le(C(g$),{class:"center-both generated-image"},{default:he(()=>[!C(r).generating&&C(r).outputs.length==0?(z(),se("div",AK,[/Inpainting/.test(C(r).generatorType)?(z(),be(K0,{key:0})):ye("",!0),/Img2Img/.test(C(r).generatorType)?(z(),be(K0,{key:1})):ye("",!0)])):ye("",!0),!C(i).showGeneratedImages&&C(r).generating?(z(),be(xH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:c(C(r).timer.seconds),onShowGenerated:w[30]||(w[30]=S=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):ye("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(z(),be(HH,{key:2})):ye("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Bs=uk({history:kT("./"),routes:[{path:"/",name:"generate",component:PK},{path:"/images",name:"images",component:()=>Gf(()=>Promise.resolve().then(()=>RG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>Gf(()=>Promise.resolve().then(()=>XG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>Gf(()=>Promise.resolve().then(()=>nq),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function IK(e){const t=[],n=/]+):([^>]+)>/g;return[e.replace(n,(i,l,g)=>{if(g.trim()==="")return"";const o=Number(g);if(isNaN(o))return"";let a=l,u=!1;const d="|high_noise|";return a.startsWith(d)&&(a=a.substring(d.length),u=!0),t.push({name:a,multiplier:o,...u?{is_high_noise:!0}:{}}),""}),t]}function Tu(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,eta:1,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,fps:16,enable_hr:!1,send_as_refimg:!0,reverse_refimg:!1,scheduler:"default"}}function sC(){return Math.floor(Math.random()*9999999)+1}const Jt=zo("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=oe("Text2Img"),r=oe(""),i=kn("promptHistory",[]),l=oe(""),g=kn("negativeLibrary",[]),o=oe(Tu()),a=oe({interval:0,seconds:0}),u=oe({sampler:{name:"Sampler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.sampler_name],mapToParam:Ce=>Ce.sampler_name},scheduler:{name:"Scheduler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.scheduler],mapToParam:Ce=>Ce.scheduler},steps:{name:"Steps",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.steps],mapToParam:Ce=>Ce.steps},guidance:{name:"CFG Scale",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.cfg_scale],mapToParam:Ce=>Ce.cfg_scale},clipSkip:{name:"Clip Skip",state:"Disabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.clip_skip],mapToParam:Ce=>Ce.clip_skip},eta:{name:"Eta",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.eta],mapToParam:Ce=>Ce.eta}}),d=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),c=oe({...d(),sourceProcessing:"inpainting"}),f=oe({...d(),sourceProcessing:"img2img"}),s=Ce=>Ce==="Inpainting"?c.value:Ce==="Img2Img"?f.value:d(),h=ee(()=>s(n.value)),v=oe(""),m=oe(!1),y=oe(!1),b=oe([]),_=oe([]),w=oe(64),S=ee(()=>zt().allowLargerParams==="Enabled"?3072:1024),x=oe(1),T=oe(20),E=oe(1),I=ee(()=>zt().allowLargerParams==="Enabled"?150:50),D=oe(1),N=oe(24),L=oe(0),F=oe(1),O=oe(0),V=oe(1),re=oe(0),J=oe(10),ue=oe(1),M=ee(()=>zt().allowLargerParams==="Enabled"?400:200),U=oe(16),R=ee(()=>zt().allowLargerParams==="Enabled"?32:24),P=(Ce,Ve,Ne)=>Array.from({length:(Ve-Ce+1)/Ne},(Ue,pt)=>(pt+Ce)*Ne),Q=oe(P(re.value,J.value,1)),j=oe(P(D.value,N.value,.5)),A=ee(()=>{const Ce=(yr,Ln,es=1)=>yr*(Ln.state==="Multiple"&&Ln.selected.length>0?Ln.selected.length:es),Ne=o.value.n*B().length,Ue=Ce(Ne,u.value.sampler),pt=Ce(Ue,u.value.scheduler),Ze=Ce(pt,u.value.steps),ln=Ce(Ze,u.value.guidance);return Ce(ln,u.value.clipSkip)});function q(){return o.value=Tu(),c.value=d(),f.value=d(),b.value=[],Ut().showGeneratedImages=!1,G(),!0}function G(){_.value=[]}function te(){b.value=[]}async function fe(){const Ce=zt(),Ve=Ce.baseURL.length===0?".":Ce.baseURL,Ne=await fetch(`${Ve}/sdapi/v1/loras`),Ue=await Ne.json();return Ku(Ne,Ue,200,"Failed to get available LoRAs")?Ue:[]}async function pe(Ce){if(!e.includes(Ce))return[];if(r.value==="")return H("Failed to generate: No prompt submitted.");const Ve=Ls(),Ne=Ut();Ve.saveImages();const{sourceImage:Ue,maskImage:pt,sourceProcessing:Ze}=s(Ce);_e(r.value);const ln=[],yr=B().map(rt=>{const Vt=rt.split(" ### ");return{full_prompt:rt,prompt:Vt[0],negative_prompt:Vt[1]||""}}).map(rt=>{const[Vt,zr]=IK(rt.prompt);return{...rt,prompt:Vt,extractedLoras:zr}}),Ln=yr.some(rt=>rt.extractedLoras.length>0)?await fe():[],es=yr.map(({extractedLoras:rt,...Vt})=>{const zr=rt.length>0&&Ln.length>0?rt.map(rr=>{const Ji=Ln.find(Qi=>Qi.name===rr.name||Qi.path===rr.name);return{path:Ji?Ji.path:rr.name,multiplier:rr.multiplier,...rr.is_high_noise?{is_high_noise:!0}:{}}}):[];return{...Vt,...zr.length>0?{lora:zr}:{}}}),{seed:Zi,cfg_scale:br,eta:km,steps:Fr,clip_skip:pC,sampler_name:mC,scheduler:gC,n:vC,...Xl}=o.value,df=parseInt(Zi.toString()),yC=isNaN(df)||df<0?sC():df,bC=Array.from({length:vC},(rt,Vt)=>yC+Vt),Za=(rt,Vt)=>rt.state==="Disabled"?[]:rt.state==="Enabled"?[Vt]:rt.state==="Multiple"&&rt.selected.length===0?[]:rt.selected,_C={promptVariant:es,seed:bC,cfg_scale:Za(u.value.guidance,br),eta:Za(u.value.eta,km),steps:Za(u.value.steps,Fr),clip_skip:Za(u.value.clipSkip,pC),sampler_name:Za(u.value.sampler,mC),scheduler:Za(u.value.scheduler,gC)},wC=(rt=>Object.entries(rt).filter(([zr,rr])=>rr.length>0).reduce((zr,[rr,Ji])=>{const Qi=[];for(const nn of zr)for(const Kl of Ji)Qi.push({...nn,[rr]:Kl});return Qi},[{}]))(_C),CC=[await ie()];for(const rt of wC){const{promptVariant:{full_prompt:Vt,...zr},...rr}=rt,Ji=Ce==="Img2Img"?Xl.send_as_refimg:!1,Qi=Ji&&Xl.frames>1?Xl.reverse_refimg:!1;let nn={prompt:Vt,params:{...Xl,send_as_refimg:Ji,reverse_refimg:Qi,...rr,...zr,init_images:Ue?[Ue.split(",")[1]]:[],mask:pt,inpainting_mask_invert:pt?0:null,inpainting_fill:pt?1:null},source_image:Ue==null?void 0:Ue.split(",")[1],source_mask:pt,source_processing:Ze,models:CC};nn.params.sampler_name=="default"&&delete nn.params.sampler_name,nn.params.scheduler=="default"&&delete nn.params.scheduler,!nn.params.frames||nn.params.frames<=1?(delete nn.params.frames,delete nn.params.fps):nn.params.fps=Math.min(R.value,Math.max(U.value,Math.round(Number(nn.params.fps)||Tu().fps)));const Kl=Me.value.map(SC=>SC.base64);Kl.length>0&&(nn.params.extra_images=Kl),zt().alsoRequestAvi==="Enabled"&&nn.params.frames&&nn.params.frames>1&&(nn.params.video_output_type=2),ln.push(nn)}let Em=!1;m.value||(Em=!0,b.value=[]),m.value=!0,Ne.showGeneratedImages=!1;let Om=_.value.filter(rt=>!rt.gathered&&!rt.failed).length;for(let rt=0;rt{a.value.seconds++},1e3);!_.value.every(rt=>rt.gathered||rt.failed)&&!y.value;){const rt=_.value.find(Vt=>!Vt.gathered&&!Vt.failed);if(!rt)break;rt.gathered=!0;try{const Vt=await K(rt.params);if(!Vt){rt.failed=!0;continue}ve([{...Vt,...rt}])}catch(Vt){rt.failed=!0,console.error("Error fetching image:",Vt)}}}async function ve(Ce){const Ve=Da();console.log(Ce);const Ne=await Promise.all(Ce.map(async Ze=>{const ln=Ze.images[0],yr=!!Ze.animated?"gif":"png",Ln=Ze.extra_data?`data:video/avi;base64,${Ze.extra_data}`:"",es=Ze.final_frame?`data:image/jpeg;base64,${Ze.final_frame}`:"";let Zi={id:-1,image:`data:image/${yr};base64,${ln}`,prompt:Ze.prompt,modelName:Ze.models[0],frames:Ze.params.frames,fps:Ze.params.fps,extra_avi:Ln,final_frame:es,enable_hr:Ze.params.enable_hr,send_as_refimg:Ze.params.send_as_refimg,reverse_refimg:Ze.params.reverse_refimg};if(Ze.info&&typeof Ze.info=="string"&&Ze.info.trim()!=="")try{const br=JSON.parse(Ze.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip","fps"].forEach(Fr=>{br[Fr]!=null&&br[Fr]!=null?Zi[Fr]=br[Fr]:Ze.params[Fr]!=null&&(Zi[Fr]=Ze.params[Fr])}),br.extra_generation_params&&br.extra_generation_params["Schedule type"]?Zi.scheduler=br.extra_generation_params["Schedule type"]:Zi.scheduler=Ze.params.scheduler}catch(br){console.warn("Failed to parse info JSON:",br)}return Zi})),Ue=await Ve.pushOutputs(Ne),pt=0;return b.value=[...Ue.map(Ze=>({type:"image",index:pt,output:Ze})),...b.value].sort((Ze,ln)=>Ze.index-ln.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,Ut().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Ne}async function H(Ce){const Ve=Ut();return Ce&&Ve.raiseError(Ce,!1),[]}function W(Ce,Ve,Ne,Ue){return Ve<=Ne?Ve:(Ut().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${Ce}' to its default value instead of ${Ve}.`,!0),Ue)}async function k(Ce,Ve=!0){const Ne=Tu();if(n.value="Text2Img",u.value.guidance.state="Enabled",u.value.sampler.state="Enabled",u.value.steps.state="Enabled",u.value.clipSkip.state="Disabled",u.value.scheduler.state="Enabled",Bs.push("/"),Ve&&(Ce.width=Ce.width||Ne.width,Ce.height=Ce.height||Ne.height),Ce.prompt){const Ue=Ce.prompt.split(" ### ");r.value=Ue[0],l.value=Ue[1]||""}if(Ce.sampler_name){o.value.sampler_name=Ce.sampler_name;const pt=(await we()).find(Ze=>Ze.aliases&&Ze.aliases.includes(Ce.sampler_name));pt&&(o.value.sampler_name=pt.name)}Ce.steps&&(o.value.steps=W("steps",Ce.steps,I.value,Ne.steps)),Ce.cfg_scale&&(o.value.cfg_scale=Ce.cfg_scale),(Ce.eta||Ce.eta===0)&&(o.value.eta=Ce.eta),Ce.width&&(o.value.width=W("width",Ce.width,S.value,Ne.width)),Ce.height&&(o.value.height=W("height",Ce.height,S.value,Ne.height)),Ce.seed&&(o.value.seed=Ce.seed),Ce.clip_skip&&(o.value.clip_skip=W("clip_skip",Ce.clip_skip,J.value,Ne.clip_skip)),Ce.scheduler&&(o.value.scheduler=Ce.scheduler),Ce.frames&&(o.value.frames=W("frames",Ce.frames,M.value,Ne.frames)),Ce.fps&&(o.value.fps=Math.min(R.value,Math.max(U.value,Math.round(W("fps",Ce.fps,R.value,Ne.fps)))))}function X(Ce){const Ve=Ls();n.value="Img2Img",f.value.sourceImage=Ce,Ve.drawing=!1,b.value=[],Bs.push("/"),Kn.fabric.Image.fromURL(Ce,Ve.newImage)}function Y(Ce){const Ve=Ls();b.value=[],c.value.sourceImage=Ce,n.value="Inpainting",Bs.push("/"),Kn.fabric.Image.fromURL(Ce,Ve.newImage)}function $(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function B(){const Ce=$(),Ve=Ce.match(/\{(.*?)\}/g)||[];if(Ve.length===0)return[Ce];let Ne=[];return Ve.forEach(Ue=>{const pt=[],Ze=Ue.replace("{","").replace("}","").split("|");Ne.length===0?Ze.forEach(ln=>{const gn=Ce.replace(Ue,ln);pt.push(gn)}):Ne.forEach(ln=>{Ze.forEach(gn=>{const yr=ln.replace(Ue,gn);pt.push(yr)})}),Ne=[...pt]}),Ne}async function K(Ce){const Ve=zt();try{const Ne=await fetch(`${Ve.baseURL.length===0?".":Ve.baseURL}/sdapi/v1/${Ce.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ce)}),Ue=await Ne.json();return Ku(Ne,Ue,200,"Failed to fetch",ce)?Ue:!1}catch{return!1}}function ce(Ce){return Ut().raiseError(Ce,!1),y.value=!1,b.value=[],!1}async function ie(){const Ce=zt(),Ve=await fetch(`${Ce.baseURL.length===0?".":Ce.baseURL}/sdapi/v1/sd-models`),Ne=await Ve.json();if(!!Ku(Ve,Ne,200,"Failed to get available models"))return Ne.length===0?"(No model loaded)":Ne[0].model_name}const Z=oe(0),me=new Map;function ae(){me.clear(),Z.value++}xe(()=>zt().baseURL,()=>{ae()});async function ge(Ce){const Ve=zt(),Ue=((Ve.baseURL.length===0?".":Ve.baseURL).replace(/\/+$/,"")||".")+"/"+Ce.replace(/^\/+/,"");if(me.has(Ue))return me.get(Ue);const pt=(async()=>{try{const Ze=await fetch(Ue);if(Ze.ok)return await Ze.json();console.error(`API Error: ${Ze.status} ${Ze.statusText} at ${Ue}`)}catch(Ze){console.error(`Fetch error for ${Ue}:`,Ze)}return me.delete(Ue),null})();return me.set(Ue,pt),pt}async function we(){const Ce=await ge("/sdapi/v1/samplers");return Array.isArray(Ce)?Ce:[]}async function ke(){const Ce=await ge("/sdapi/v1/schedulers");return Array.isArray(Ce)?Ce:[]}function Oe(Ce){g.value.indexOf(Ce)===-1&&(g.value=[...g.value,Ce])}function Fe(Ce){g.value=g.value.filter(Ve=>Ve!=Ce)}function _e(Ce){if(i.value.findIndex(Ve=>Ve.prompt===Ce)===-1){if(i.value.length>=10+i.value.filter(Ve=>Ve.starred).length){const Ve=i.value.filter(Ue=>!Ue.starred),Ne=i.value.findIndex(Ue=>Ue===Ve[Ve.length-1]);i.value.splice(Ne,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:Ce}]}}function Se(Ce){i.value=i.value.filter(Ve=>Ve.prompt!=Ce&&Ve!=Ce)}function De(){return!1}const Me=oe([]);async function bt(Ce){var Ze,ln;const Ve=Ce.target,Ne=(ln=Ve.files)!=null?ln:(Ze=Ce.dataTransfer)==null?void 0:Ze.files,Ue=Array.from(Ne!=null?Ne:[]);if(Ue.length===0)return;const pt=await Promise.all(Ue.map(async(gn,yr)=>{const Ln=await Tc(gn);return{id:`${Date.now()}-${yr}-${gn.name}`,name:gn.name,size:gn.size,dataUrl:Ln,base64:Ln.includes("data:image")?Ln.split(",")[1]:Ln}}));Me.value||(Me.value=[]);for(let gn=0;gn=Me.value.length)return;const Ue=[...Me.value],[pt]=Ue.splice(Ce,1);Ue.splice(Ne,0,pt),Me.value=Ue}function tn(){Me.value=[];const Ce=document.getElementById("extra_image_input");Ce&&(Ce.value="")}return{generatorType:n,prompt:r,params:o,outputs:b,inpainting:c,img2img:f,uploadDimensions:v,cancelled:y,multiSelect:u,referenceImages:Me,negativePrompt:l,generating:m,negativePromptLibrary:g,minDimensions:w,maxDimensions:S,minImages:x,maxImages:T,minSteps:E,maxSteps:I,minCfgScale:D,maxCfgScale:N,minDenoise:O,maxDenoise:V,minClipSkip:re,maxClipSkip:J,minFrames:ue,maxFrames:M,minFps:U,maxFps:R,minEta:L,maxEta:F,clipSkipList:Q,cfgList:j,queue:_,promptHistory:i,timer:a,validGeneratorTypes:e,sourceGeneratorTypes:t,currentImageProps:h,totalImageCount:A,generateImage:pe,generateText2Img:k,generateImg2Img:X,generateInpainting:Y,getPrompt:De,resetStore:q,clearQueue:G,clearOutputs:te,pushToNegativeLibrary:Oe,removeFromNegativeLibrary:Fe,pushToPromptHistory:_e,removeFromPromptHistory:Se,setExtraImage:bt,removeExtraImage:_t,moveExtraImage:ht,clearExtraImage:tn,getAvailableSamplers:we,getAvailableSchedulers:ke,cacheVersion:Z,invalidateApiCaches:ae,getCachedEndpoint:ge}});"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var ff=e=>new DataView(new ArrayBuffer(e)),qa=e=>new Uint8Array(e.buffer||e),mo=e=>new TextEncoder().encode(String(e));function MK(e,t){if(t===void 0||t instanceof Date||(t=new Date(t)),e instanceof File)return{t:t||new Date(e.lastModified),o:e.stream()};if(e instanceof Response)return{t:t||new Date(e.headers.get("Last-Modified")||Date.now()),o:e.body};if(t===void 0)t=new Date;else if(isNaN(t))throw new Error("Invalid modification date.");if(typeof e=="string")return{t,o:mo(e)};if(e instanceof Blob)return{t,o:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t,o:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t,o:qa(e)};if(Symbol.asyncIterator in e)return{t,o:lC(e)};throw new TypeError("Unsupported input format.")}function lC(e){const t="next"in e?e:e[Symbol.asyncIterator]();return new ReadableStream({async pull(n){let r=0;for(;n.desiredSize>r;){const i=await t.next();if(!i.value){n.close();break}{const l=LK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function LK(e){return typeof e=="string"?mo(e):e instanceof Uint8Array?e:qa(e)}function RK(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=mo(t)),e instanceof File)return{i:t||mo(e.name),A:e.size};if(e instanceof Response){const r=e.headers.get("content-disposition"),i=r&&r.match(/;\s*filename\*?=["']?(.*?)["']?$/i),l=i&&i[1]||new URL(e.url).pathname.split("/").pop(),g=l&&decodeURIComponent(l),o=n||+e.headers.get("content-length");return{i:t||mo(g),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:mo(e).length}:e instanceof Blob?{i:t,A:e.size}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{i:t,A:e.byteLength}:{i:t,A:n}}var DK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:$K,m:BK}=DK.exports,FK=qa(BK).subarray(65536);function $y(e,t=0){for(const n of function*(r){for(;r.length>65536;)yield r.subarray(0,65536),r=r.subarray(65536);r.length&&(yield r)}(e))FK.set(n),t=$K(n.length,t);return t}function uC(e,t,n=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,i=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;t.setUint16(n,r,1),t.setUint16(n+2,i,1)}function zK(e){const t=ff(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),uC(e.t,t,10),t.setUint16(26,e.i.length,1),qa(t)}async function*NK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=$y(t,0),e.A=t.length;else{e.A=0;const n=t.getReader();for(;;){const{value:r,done:i}=await n.read();if(i)break;e.u=$y(r,e.u),e.A+=r.length,yield r}}}function jK(e){const t=ff(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),qa(t)}function VK(e,t){const n=ff(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),uC(e.t,n,12),n.setUint32(16,e.u,1),n.setUint32(20,e.A,1),n.setUint32(24,e.A,1),n.setUint16(28,e.i.length,1),n.setUint16(40,33204,1),n.setUint32(42,t,1),qa(n)}function UK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function HK(e,t={}){const n={"Content-Type":"application/zip","Content-Disposition":"attachment"};return Number.isInteger(t.length)&&t.length>0&&(n["Content-Length"]=t.length),t.metadata&&(n["Content-Length"]=p(t.metadata)),new Response(lC(async function*(r){const i=[];let l=0,g=0;for await(const u of r)yield zK(u),yield u.i,yield*NK(u),yield jK(u),i.push(VK(u,l)),i.push(u.i),g++,l+=46+u.i.length+u.A;let o=0;for(const u of i)yield u,o+=u.length;const a=ff(22);a.setUint32(0,1347093766),a.setUint16(8,g,1),a.setUint16(10,g,1),a.setUint32(12,o,1),a.setUint32(16,l,1),yield qa(a)}(async function*(r){for await(const i of r){const[l,g]=UK(i);yield Object.assign(MK(...g),RK(...l))}}(e))),{headers:n})}async function cC(e,t=!0,n){const r=zt();t&&Wi({message:`Downloading ${e.length} image(s)...`,type:"info"});const i=[];for(let o=0;o]/g,"").substring(0,128).trimEnd();let s=r.imageDownloadType;u.startsWith("data:image/gif")&&(s="GIF"),s==="PNG"?i.push({name:f+".png",input:await ba(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await ba(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await ba(u,"image/gif")}):i.push({name:f+".webp",input:await ba(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await HK(i).blob(),g=document.createElement("a");g.href=URL.createObjectURL(l),g.download="sdui_images.zip",g.click()}async function fC(e,t){const n=zt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await ba(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await ba(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await ba(e,"image/gif"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".gif"):(r.href=e,r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".webp"),r.click(),i&&URL.revokeObjectURL(r.href)}function dC(e,t){const n=e;if(!n)return;const r=atob(n),i=r.length,l=new Uint8Array(i);for(let u=0;u{Ew.confirm("This action will permanently delete this image. Continue?","Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{r.deleteOutput(t.imageData.id),t.onDelete!==void 0&&t.onDelete(t.imageData.id),Wi({type:"success",message:"Deleted Image"})})},l=a=>{if(a.extra_avi){const u=a.extra_avi.split(",")[1];if(!u)return;const d=`${a.seed}-${a.prompt}.avi`;dC(u,d);return}else fC(a.image,`${a.seed}-${a.prompt}`)},g=()=>{Jt().clearOutputs(),Ut().showGeneratedImages=!1,Jt().clearQueue()};async function o(a){const u=window.location.origin,d={prompt:a.prompt,width:a.width?a.width:void 0,height:a.height?a.height:void 0,steps:a.steps,cfg_scale:a.cfg_scale,sampler_name:a.sampler_name,model_name:a.modelName,seed:a.seed,clip_skip:a.clip_skip,frames:a.frames,fps:a.fps,scheduler:a.scheduler,extra_avi:a.extra_avi,final_frame:a.final_frame,enable_hr:a.enable_hr,send_as_refimg:a.send_as_refimg,reverse_refimg:a.reverse_refimg},c=window.location.pathname.replace("images","");let f=`${u}${c}?share=`,s="",h="";for(const[m,y]of Object.entries(d)){if(!y)continue;let b=y;typeof y=="string"?b=encodeURIComponent(y):Array.isArray(y)&&(b=JSON.stringify(y)),s+=`${h}${m}=${b}`,h="&"}f+=btoa(String.fromCharCode.apply(null,Array.from(qX(s)))),await navigator.clipboard.writeText(f),Wi({type:"success",message:"Copied shareable link to clipboard"})}return(a,u)=>(z(),se(je,null,[le(C(at),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:C(Ol),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(at),{class:"compact-button",onClick:u[0]||(u[0]=d=>l(e.imageData)),type:"success",size:"small",icon:C(Ks),plain:""},{default:he(()=>[He("Download")]),_:1},8,["icon"]),e.imageData.starred?ye("",!0):(z(),be(C(at),{key:0,class:"compact-button",onClick:u[1]||(u[1]=d=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(w4),plain:""},{default:he(()=>[He("Star")]),_:1},8,["icon"])),e.imageData.starred?(z(),be(C(at),{key:1,class:"compact-button",onClick:u[2]||(u[2]=d=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(__),plain:""},{default:he(()=>[He("Unstar")]),_:1},8,["icon"])):ye("",!0),le(C(at),{class:"compact-button",onClick:u[3]||(u[3]=d=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:he(()=>[He("Txt2img")]),_:1}),le(C(at),{class:"compact-button",onClick:u[4]||(u[4]=d=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Img2img")]),_:1}),le(C(at),{class:"compact-button",onClick:u[5]||(u[5]=d=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Inpaint")]),_:1}),e.showDismiss?(z(),be(C(at),{key:2,class:"compact-button",onClick:u[6]||(u[6]=d=>g()),type:"success",size:"small",plain:""},{default:he(()=>[He("Dismiss")]),_:1})):ye("",!0),le(C(at),{class:"compact-button",onClick:u[7]||(u[7]=d=>o(e.imageData)),type:"success",icon:C($3),size:"small",plain:""},{default:he(()=>[He("Share")]),_:1},8,["icon"])],64))}});const hC=qt(WK,[["__scopeId","data-v-4d472d34"]]),YK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},XK=["src"],KK={style:{"font-size":"16px","font-weight":"500"}},GK={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},qK={key:0},ZK=ne("br",null,null,-1),JK={key:0},QK=["onClick"],eG={key:1},tG=["onClick"],nG={key:2},rG=["onClick"],iG=Ee({__name:"ImageDialog",setup(e){const t=Da(),n=Ut(),r=oe();fM(r,{onSwipeEnd(d,c){c==="RIGHT"&&n.openModalToLeft(),c==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=oe(t.currentOutputs[0]);xe(()=>n.activeModal,async()=>{const d=t.currentOutputs.find(c=>c.id===n.activeModal);if(d)return l.value=d;l.value=await jt.outputs.get(n.activeModal)||t.currentOutputs[0]});function g(){i.value=!1}function o(){var f;if(!((f=l.value)!=null&&f.final_frame))return;const d=l.value.final_frame;Jt().generateImg2Img(d)}function a(){var d;!((d=l.value)!=null&&d.image)||fC(l.value.image,`${l.value.seed}-${l.value.prompt}`)}function u(){var f,s;if(!((f=l.value)!=null&&f.extra_avi))return;const d=l.value.extra_avi.split(",")[1];if(!d)return;const c=`output-${(s=l.value.id)!=null?s:"video"}.avi`;dC(d,c)}return(d,c)=>{var f;return z(),be(C(WB),{"model-value":C(i),width:(f=l.value)==null?void 0:f.width,class:"image-viewer",onClosed:g,"align-center":""},{footer:he(()=>[le(hC,{"image-data":l.value,"on-delete":g},null,8,["image-data"])]),default:he(()=>{var s,h,v,m;return[ne("div",{class:"main-output-container",ref_key:"target",ref:r},[ne("div",YK,[(s=l.value)!=null&&s.image?(z(),se("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,XK)):ye("",!0)])],512),ne("div",KK,Ae(((h=l.value.prompt)==null?void 0:h.split("###")[0])||"Unknown Creation"),1),ne("div",GK,[ne("div",null,"Negative Prompt: "+Ae(((v=l.value.prompt)==null?void 0:v.split("###")[1])||"None"),1),ne("span",null,"Model: "+Ae(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Ae(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Ae(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Ae(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Ae(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Ae(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Ae((m=l.value.clip_skip)!=null?m:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Ae(l.value.width||"???")+"x"+Ae(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Ae(l.value.frames||"1"),1),l.value.frames&&l.value.frames>1?(z(),se("span",qK," - FPS: "+Ae(l.value.fps||"Unknown"),1)):ye("",!0),ZK,ne("b",null,[l.value.frames&&l.value.frames>1?(z(),se("span",JK,[ne("a",{href:"#",onClick:et(a,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download GIF]",8,QK)])):ye("",!0),l.value.extra_avi?(z(),se("span",eG,[He(" - "),ne("a",{href:"#",onClick:et(u,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,tG)])):ye("",!0),l.value.final_frame?(z(),se("span",nG,[He(" - "),ne("a",{href:"#",onClick:et(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Extend Video]",8,rG)])):ye("",!0)])])]}),_:1},8,["model-value","width"])}}});const aG=e=>(ui("data-v-8f4d2380"),e=e(),ci(),e),oG=aG(()=>ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)),sG={class:"generator-icons"},lG=Ee({__name:"App",setup(e){const n=Ep(kp).smallerOrEqual("md"),r=Ut();zt();const i=fk(),l=oe();return xe(()=>i.path,g=>{l.value&&l.value.open(g)}),(g,o)=>(z(),se(je,null,[ne("div",{class:de({"menu-container":!C(n)})},[le(C(mw),{"default-active":C(i).path,mode:"horizontal",router:!0,ellipsis:!C(n),class:de(C(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:he(()=>[C(n)?ye("",!0):(z(),be(C(Up),{key:0,class:"remove-item-styling center-vertical"},{title:he(()=>[oG]),_:1})),le(ls,{isMobile:C(n),index:"/"},{icon:he(()=>[ne("div",sG,[le(C(Le),null,{default:he(()=>[le(C(wO))]),_:1}),C(r).showGeneratorBadge?(z(),be(C(Le),{key:0,class:"generator-badge",size:10},{default:he(()=>[le(tH)]),_:1})):ye("",!0)])]),title:he(()=>[He("Generate")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/images"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(Q3))]),_:1})]),title:he(()=>[He("Images")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/about"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(g_))]),_:1})]),title:he(()=>[He("About")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/options"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(M4))]),_:1})]),title:he(()=>[He("Options")]),_:1},8,["isMobile"]),le(ls,{isMobile:C(n),index:"/return"},{icon:he(()=>[le(C(Le),null,{default:he(()=>[le(C(d_))]),_:1})]),title:he(()=>[He("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:de({view:!C(n)})},[le(C(c_))],2),le(iG)],64))}});const uG=qt(lG,[["__scopeId","data-v-8f4d2380"]]);const Tm=tT(uG);Tm.use(iT());Tm.use(Bs);Tm.mount("#app");Bs.replace("/");window.addEventListener("beforeunload",e=>{Jt().generating&&(e.preventDefault(),e.returnValue="")});const cG={key:1,class:"image-action"},fG=Ee({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=Ut(),r=oe(null);VI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=oe(!1);cM(r,([{isIntersecting:g}])=>{g&&(i.value=g)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(g,o)=>(z(),se("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(z(),be(C(ef),{key:0,class:"thumbnail",src:e.imageData.image,onClick:o[0]||(o[0]=a=>C(n).activeModal=e.imageData.id),fit:"cover",loading:"lazy",style:ze(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):ye("",!0),i.value?(z(),se("div",cG,[e.imageData.starred?(z(),be(C(Le),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:he(()=>[le(C(__))]),_:1})):ye("",!0),C(n).multiSelect?(z(),se("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[le(C(Le),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:he(()=>[C(l)?ye("",!0):(z(),be(C(El),{key:0})),C(l)?(z(),be(C(p_),{key:1})):ye("",!0)]),_:1},8,["color"])])):ye("",!0)])):ye("",!0)],512))}});const By=qt(fG,[["__scopeId","data-v-b9569bbd"]]);function dG({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=a1(),i=ee(()=>r.value<=e),l=oe(!0),{y:g}=uM(window);let o=g.value,a=0;return xe(g,u=>{if(!i.value)return;const d=u-o;if(o=u,d>0&&u>t){a+=d,a>=n&&(l.value=!1,a=0);return}d<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const hG={},pG={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},mG=ne("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-696 72h136v656H184V184zm656 656H384V384h456v456zM384 320V184h456v136H384z",fill:"currentColor"},null,-1),gG=[mG];function vG(e,t){return z(),se("svg",pG,gG)}const yG=qt(hG,[["render",vG]]),bG=e=>(ui("data-v-b39b47c5"),e=e(),ci(),e),_G={class:"options"},wG=["onClick"],CG=["onClick"],SG=["onClick"],xG={key:1,class:"center-both",style:{gap:"12px"}},TG={key:2},kG=bG(()=>ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),EG=[kG],OG={key:0},AG={key:0,style:{display:"flex",gap:"8px"}},PG={key:1,class:"images"},IG={key:1},MG=Ee({__name:"ImagesView",setup(e){const{width:t}=a1(),{isVisible:n,isMobile:r}=dG(),i=Da(),l=zt(),g=Ut();function o(){g.selected=g.selected.filter(h=>!i.currentOutputs.map(v=>v.id).includes(h)),g.selected=[...g.selected,...i.currentOutputs.map(h=>h.id)],g.multiSelect=!0}async function a(){const h=await jt.outputs.toCollection().primaryKeys();g.selected=h,g.multiSelect=!0}function u(){g.selected=g.selected.filter(h=>!i.currentOutputs.map(v=>v.id).includes(h)),g.selected.length===0&&(g.multiSelect=!1)}function d(){g.selected=[],g.multiSelect=!1}const c=()=>{Ew.confirm(`This action will permanently delete ${g.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(g.selected)})};vv(["a","A","ArrowLeft"],g.openModalToLeft),vv(["d","D","ArrowRight"],g.openModalToRight);async function f(){cC(g.selected)}const s=ee(()=>{let h=2;t.value>1440?h=6:t.value>1280?h=5:t.value>768?h=4:t.value>480&&(h=3);const v=[];for(let m=0;m(z(),se(je,null,[ne("div",{class:de(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[ne("div",_G,[le(C(cu),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[le(C(c4))]),_:1})]),_:1})]),default:he(()=>[(z(),se(je,null,Nt(["Newest","Oldest"],m=>ne("div",{key:m,onClick:()=>C(i).sortBy=m,class:de(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Ae(m),11,wG)),64))]),_:1}),le(C(cu),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[le(C(d3))]),_:1})]),_:1})]),default:he(()=>[(z(),se(je,null,Nt(["all","favourited","unfavourited","unrated"],m=>ne("div",{key:m,onClick:()=>C(i).filterBy=m,class:de(`el-select-dropdown__item ${C(i).filterBy===m?"selected":""}`)},Ae(C(i).filterBy===m?"Showing":"Show")+" "+Ae(m),11,CG)),64))]),_:1}),le(C(cu),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[le(yG)]),_:1})]),_:1})]),default:he(()=>[(z(),se(je,null,Nt([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>ne("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:de(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Ae(m.label),11,SG)),64))]),_:1}),le(C(cu),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(at),{class:"btn-select"},{default:he(()=>[le(C(Le),{size:16},{default:he(()=>[C(g).multiSelect?(z(),be(C(p_),{key:0})):(z(),be(C(El),{key:1}))]),_:1})]),_:1})]),default:he(()=>[C(g).multiSelect?(z(),se("div",{key:0,class:"el-select-dropdown__item selected",onClick:v[0]||(v[0]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Disable multi-select")):(z(),se("div",{key:1,class:"el-select-dropdown__item",onClick:v[1]||(v[1]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Enable multi-select")),C(g).selected.length>0?(z(),se("div",{key:2,class:"el-select-dropdown__item selected",onClick:d},"Deselect All")):(z(),se("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),C(g).selected.every(m=>!C(i).currentOutputs.map(y=>y.id).includes(m))?(z(),se("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(z(),se("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(z(),be(C(m9),{key:0,layout:"prev, pager, next",total:C(i).outputsLength,"page-size":C(l).pageSize,"current-page":C(i).currentPage,"onUpdate:currentPage":v[2]||(v[2]=m=>C(i).currentPage=m),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):ye("",!0),C(g).multiSelect?(z(),se("div",xG,[ne("div",null,Ae(C(g).selected.length)+" selected",1),le(C(at),{type:"danger",onClick:c,icon:C(Ol),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(at),{type:"success",onClick:f,icon:C(Ks),plain:"",style:{margin:"0"}},{default:he(()=>[He("Download")]),_:1},8,["icon"])])):(z(),se("div",TG,EG))],2),C(i).outputsLength!=0?(z(),se("div",OG,[C(i).currentLayout==="dynamic"?(z(),se("div",AG,[(z(!0),se(je,null,Nt(C(s),(m,y)=>(z(),se("div",{key:y,style:{flex:"1 1 0%"}},[(z(!0),se(je,null,Nt(m,b=>(z(),be(By,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ye("",!0),C(i).currentLayout==="grid"?(z(),se("div",PG,[(z(!0),se(je,null,Nt(C(i).currentOutputs,m=>(z(),be(By,{key:m.id,"image-data":m,style:{width:"200px",height:"200px"}},null,8,["image-data"]))),128))])):ye("",!0)])):ye("",!0),C(i).outputsLength==0?(z(),se("div",IG,[le(C(FF),{description:"No Images Found"})])):ye("",!0)],64))}});const LG=qt(MG,[["__scopeId","data-v-b39b47c5"]]),RG=Object.freeze(Object.defineProperty({__proto__:null,default:LG},Symbol.toStringTag,{value:"Module"})),DG=["href"],$G=Ee({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=gt("router-link");return z(),se(je,null,[e.router?ye("",!0):(z(),se("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[Te(t.$slots,"default",{},void 0,!0)],8,DG)),e.router?(z(),be(r,{key:1,to:e.href},{default:he(()=>[Te(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ye("",!0)],64)}}});const BG=qt($G,[["__scopeId","data-v-17b53b7d"]]),Yl=e=>(ui("data-v-ecc278c5"),e=e(),ci(),e),FG={class:"about"},zG={class:"about-content"},NG=Yl(()=>ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),jG=Yl(()=>ne("div",null,[He("This tool was originally a front-end for the AI Horde and has since been converted for local generations with the A1111 API, such as in "),ne("a",{href:"https://github.com/LostRuins/koboldcpp"},"KoboldCpp"),He(".")],-1)),VG=Yl(()=>ne("br",null,null,-1)),UG=Yl(()=>ne("div",null,"If you want to help improve this tool, you can find the currently maintained source code from this modified version on https://github.com/LostRuins/stable-ui and https://github.com/henk717/stable-ui, which is based off https://github.com/ayunami2000/stable-ui, which derives from the original AI Horde version on https://github.com/aqualxx/stable-ui (Original author aqualxx#5004). Feel free to contribute!",-1)),HG=Yl(()=>ne("br",null,null,-1)),WG=Ee({__name:"AboutView",setup(e){return(t,n)=>(z(),se("div",FG,[ne("div",zG,[NG,jG,VG,UG,HG,ne("div",null,[He("You can find the KoboldAI community and authors of this fork on the "),le(BG,{href:"https://koboldai.org/discord"},{default:he(()=>[He("KoboldAI Discord")]),_:1})])])]))}});const YG=qt(WG,[["__scopeId","data-v-ecc278c5"]]),XG=Object.freeze(Object.defineProperty({__proto__:null,default:YG},Symbol.toStringTag,{value:"Module"}));const so=Ee({__name:"FormRadio",props:{label:null,modelValue:null,prop:null,useBoolean:{type:Boolean},options:null,disabled:{type:Boolean},info:null,labelStyle:null,change:null},emits:["update:modelValue"],setup(e,{emit:t}){const n=e;function r(l){if(n.useBoolean&&l==="Enabled"?t("update:modelValue",!0):n.useBoolean&&l==="Disabled"?t("update:modelValue",!1):t("update:modelValue",l),!!n.change)return n.useBoolean&&l==="Enabled"?n.change(!0):n.useBoolean&&l==="Disabled"?n.change(!1):n.change(l)}const i=ee(()=>n.useBoolean?n.modelValue===!0?"Enabled":n.modelValue===!1?"Disabled":n.modelValue:n.modelValue);return(l,g)=>(z(),be(C(Di),{prop:e.prop},{label:he(()=>[le(jl,{info:e.info,"label-style":e.labelStyle},{default:he(()=>[Te(l.$slots,"label",{},()=>[He(Ae(e.label),1)])]),_:3},8,["info","label-style"])]),default:he(()=>[le(C(H$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:he(()=>[(z(!0),se(je,null,Nt(e.options,o=>(z(),be(C(W$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),Te(l.$slots,"inline")]),_:3},8,["prop"]))}}),Qo=e=>(ui("data-v-0345ee1f"),e=e(),ci(),e),KG=Qo(()=>ne("h1",null,"Options",-1)),GG=Qo(()=>ne("h2",null,"Generation Options",-1)),qG=Qo(()=>ne("h3",null,"Parameter Controls",-1)),ZG=Qo(()=>ne("h2",null,"Image Options",-1)),JG=Qo(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),QG=Qo(()=>ne("h2",null,"General Options",-1)),eq=Ee({__name:"OptionsView",setup(e){const t=zt(),n=Da(),r=Jt(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=oe([]),g=oe(),o=oe(!1),a=oe(0);async function u(c){n.importFromZip(c),g.value.clearFiles()}async function d(){Wi({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const c=await jt.outputs.toCollection().primaryKeys();await cC(c,!1,()=>{a.value++}),o.value=!1,a.value=0}return(c,f)=>(z(),se(je,null,[KG,le(C(jp),{"label-position":"top",model:C(t).options,onSubmit:f[10]||(f[10]=et(()=>{},["prevent"]))},{default:he(()=>[le(C(zj),{type:"border-card",style:{"min-height":"50vh"}},{default:he(()=>[le(C(zf),{label:"\u{1F5A8}\uFE0F Generation"},{default:he(()=>[GG,le(C(Di),{label:"Base URL"},{default:he(()=>[le(C(Xa),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":f[0]||(f[0]=s=>C(t).baseURL=s)},null,8,["modelValue"])]),_:1}),qG,(z(!0),se(je,null,Nt(C(r).multiSelect,(s,h)=>{var v;return z(),se("div",{key:h},[le(so,{label:s.name,prop:"pageless",modelValue:s.state,"onUpdate:modelValue":m=>s.state=m,options:(v=s.allowedStates)!=null?v:[]},null,8,["label","modelValue","onUpdate:modelValue","options"])])}),128)),le(so,{label:"Allow Larger Params",prop:"pageless",modelValue:C(t).allowLargerParams,"onUpdate:modelValue":f[1]||(f[1]=s=>C(t).allowLargerParams=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(po,{label:"Image Resize Mode",prop:"imageResizeMode",modelValue:C(t).imageResizeMode,"onUpdate:modelValue":f[2]||(f[2]=s=>C(t).imageResizeMode=s),options:[{label:"No Scale",value:"NoScale"},{label:"Scale and Crop",value:"ScaleAndCrop"},{label:"Scale and Pad",value:"ScaleAndPad"},{label:"Stretch",value:"Stretch"},{label:"Original",value:"Original"}],info:"How to adapt input image dimensions to the requested image size. No Scale: do not scale, just crop or pad each dimension to fit (default behavior). Scale and Crop: scale to match the smaller dimension, preserving aspect ratio, then crop to fit. Scale and Pad: scale to match the larger dimension, preserving aspect ratio, then pad to fit. Stretch: stretch both dimensions to fit, possibly not preserving aspect ratio. Original: send the input image as-is to the server, with no scaling, cropping or padding."},null,8,["modelValue"]),le(so,{label:"Video Gen: Request AVI download",prop:"pageless",modelValue:C(t).alsoRequestAvi,"onUpdate:modelValue":f[3]||(f[3]=s=>C(t).alsoRequestAvi=s),options:["Enabled","Disabled"]},null,8,["modelValue"])]),_:1}),le(C(zf),{label:"\u{1F4F7} Images"},{default:he(()=>[ZG,le(bn,{label:"Images Per Page",prop:"pageSize",modelValue:C(t).pageSize,"onUpdate:modelValue":f[4]||(f[4]=s=>C(t).pageSize=s),min:10,max:50,step:5,disabled:C(t).pageless==="Enabled"},null,8,["modelValue","disabled"]),le(so,{label:"Pageless Format",prop:"pageless",modelValue:C(t).pageless,"onUpdate:modelValue":f[5]||(f[5]=s=>C(t).pageless=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(so,{label:"Carousel Auto Cycle",prop:"autoCarousel",modelValue:C(t).autoCarousel,"onUpdate:modelValue":f[6]||(f[6]=s=>C(t).autoCarousel=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(so,{label:"Image Download Format",prop:"downloadType",modelValue:C(t).imageDownloadType,"onUpdate:modelValue":f[7]||(f[7]=s=>C(t).imageDownloadType=s),options:["PNG","JPG","WEBP","GIF"]},null,8,["modelValue"]),le(C(Di),{label:"Export Images (ZIP File)"},{default:he(()=>[o.value?(z(),be(C(at),{key:1,icon:C(Ks),disabled:""},{default:he(()=>[He("Downloading... ("+Ae(a.value)+" / "+Ae(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(z(),be(C(at),{key:0,icon:C(Ks),onClick:f[8]||(f[8]=s=>d())},{default:he(()=>[He("Download "+Ae(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),le(C(Di),{label:"Import Images (ZIP File)"},{default:he(()=>[le(C(Yp),{drag:"",ref_key:"upload",ref:g,"auto-upload":!1,onChange:u,"file-list":l.value,limit:1,multiple:""},{default:he(()=>[le(C(Le),{size:100},{default:he(()=>[le(C(dp))]),_:1}),JG]),_:1},8,["file-list"])]),_:1})]),_:1}),le(C(zf),{label:"\u2699\uFE0F General"},{default:he(()=>[QG,le(po,{label:"Color Scheme",prop:"colorScheme",modelValue:C(t).options.colorMode,"onUpdate:modelValue":f[9]||(f[9]=s=>C(t).options.colorMode=s),options:i},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}});const tq=qt(eq,[["__scopeId","data-v-0345ee1f"]]),nq=Object.freeze(Object.defineProperty({__proto__:null,default:tq},Symbol.toStringTag,{value:"Module"})); -