diff --git a/embd_res/kcpp_sdui.embd b/embd_res/kcpp_sdui.embd index 5bb2deb33..7427156f0 100644 --- a/embd_res/kcpp_sdui.embd +++ b/embd_res/kcpp_sdui.embd @@ -506,7 +506,7 @@ gl_FragColor.rgb *= color.a; `?(s++,f[s]=0):f[s]++;f[0]>0&&(this.insertCharStyleObject(c.lineIndex,c.charIndex,f[0],h),h=h&&h.slice(f[0]+1)),s&&this.insertNewlineStyleObject(c.lineIndex,c.charIndex+f[0],s);for(var d=1;d0?this.insertCharStyleObject(c.lineIndex+d,0,f[d],h):h&&this.styles[c.lineIndex+d]&&h[0]&&(this.styles[c.lineIndex+d][0]=h[0]),h=h&&h.slice(f[d]+1);f[d]>0&&this.insertCharStyleObject(c.lineIndex+d,0,f[d],h)},setSelectionStartEndWithShift:function(a,u,h){h<=a?(u===a?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=a),this.selectionStart=h):h>a&&ha?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,h=this.selectionEnd;o.shiftKey?this.setSelectionStartEndWithShift(u,h,a):(this.selectionStart=a,this.selectionEnd=a),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(o){for(var a=this.getLocalPointer(o),u=0,h=0,c=0,f=0,s=0,d,g,m=0,y=this._textLines.length;m0&&(f+=this._textLines[m-1].length+this.missingNewlineOffset(m-1));d=this._getLineLeftOffset(s),h=d*this.scaleX,g=this._textLines[s],this.direction==="rtl"&&(a.x=this.width*this.scaleX-a.x+h);for(var b=0,_=g.length;b<_&&(u=h,h+=this.__charBounds[s][b].kernedWidth*this.scaleX,h<=a.x);b++)f++;return this._getNewSelectionStartFromOffset(a,u,h,f,_)},_getNewSelectionStartFromOffset:function(o,a,u,h,c){var f=o.x-a,s=u-o.x,d=s>f||s<0?0:1,g=h+d;return this.flipX&&(g=c-g),g>this._text.length&&(g=this._text.length),g}}),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,h=this._text.length,c=u.length,f,s,d=c-h,g=this.selectionStart,m=this.selectionEnd,y=g!==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=g>S.selectionStart;y?(f=this._text.slice(g,m),d+=m-g):c0&&(h=this.__charBounds[o][a-1],u+=h.left+h.width),u},getDownCursorOffset:function(o,a){var u=this._getSelectionForOffset(o,a),h=this.get2DCursorLocation(u),c=h.lineIndex;if(c===this._textLines.length-1||o.metaKey||o.keyCode===34)return this._text.length-u;var f=h.charIndex,s=this._getWidthBeforeCursor(c,f),d=this._getIndexOnLine(c+1,s),g=this._textLines[c].slice(f);return g.length+d+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),h=this.get2DCursorLocation(u),c=h.lineIndex;if(c===0||o.metaKey||o.keyCode===33)return-u;var f=h.charIndex,s=this._getWidthBeforeCursor(c,f),d=this._getIndexOnLine(c-1,s),g=this._textLines[c].slice(0,f),m=this.missingNewlineOffset(c-1);return-this._textLines[c-1].length+d-g.length+(1-m)},_getIndexOnLine:function(o,a){for(var u=this._textLines[o],h=this._getLineLeftOffset(o),c=h,f=0,s,d,g=0,m=u.length;ga){d=!0;var y=c-s,b=c,_=Math.abs(y-a),w=Math.abs(b-a);f=w<_?g:g-1;break}return d||(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",h=this[u](a,this._selectionDirection==="right");a.shiftKey?this.moveCursorWithShift(h):this.moveCursorWithoutShift(h),h!==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 h;if(o.altKey)h=this["findWordBoundary"+u](this[a]);else if(o.metaKey||o.keyCode===35||o.keyCode===36)h=this["findLineBoundary"+u](this[a]);else return this[a]+=u==="Left"?-1:1,!0;if(typeof h<"u"&&this[a]!==h)return this[a]=h,!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,h){typeof h>"u"&&(h=u),h>u&&this.removeStyleFromTo(u,h);var c=t.util.string.graphemeSplit(o);this.insertNewStyleBlock(c,u,a),this._text=[].concat(this._text.slice(0,u),c,this._text.slice(h)),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(),h=this._getSVGTextAndBg(u.textTop,u.textLeft);return this._wrapSVGTextAndBg(h)},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 h=!0,c=this.getSvgTextDecoration(this);return[u.textBgRects.join(""),' ",u.textSpans.join(""),` `]},_getSVGTextAndBg:function(u,h){var c=[],f=[],s=u,d;this._setSVGBg(f);for(var g=0,m=this._textLines.length;g",t.util.string.escapeXml(u),""].join("")},_setSVGTextLineText:function(u,h,c,f){var s=this.getHeightOfLine(h),d=this.textAlign.indexOf("justify")!==-1,g,m,y="",b,_,w=0,S=this._textLines[h],x;f+=s*(1-this._fontSizeFraction)/this.lineHeight;for(var T=0,O=S.length-1;T<=O;T++)x=T===O||this.charSpacing,y+=S[T],b=this.__charBounds[h][T],w===0?(c+=b.kernedWidth-b.width,w+=b.width):w+=b.kernedWidth,d&&!x&&this._reSpaceAndTab.test(S[T])&&(x=!0),x||(g=g||this.getCompleteStyleDeclaration(h,T),m=this.getCompleteStyleDeclaration(h,T+1),x=t.util.hasStyleChanged(g,m,!0)),x&&(_=this._getStyleDeclaration(h,T)||{},u.push(this._createTextCharSpan(y,_,c,f)),y="",g=m,c+=w,w=0)},_pushTextBgRect:function(u,h,c,f,s,d){var g=t.Object.NUM_FRACTION_DIGITS;u.push(" `)},_setSVGTextLineBg:function(u,h,c,f){for(var s=this._textLines[h],d=this.getHeightOfLine(h)/this.lineHeight,g=0,m=0,y,b,_=this.getValueOfPropertyAt(h,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 h=0,c=0,f=0,s={},d=0;d0?(c=0,f++,h++):!this.splitByGrapheme&&this._reSpaceAndTab.test(u.graphemeText[f])&&d>0&&(c++,f++),s[d]={line:h,offset:c},f+=u.graphemeLines[d].length,c+=u.graphemeLines[d].length;return s},styleHas:function(u,h){if(this._styleMap&&!this.isWrapping){var c=this._styleMap[h];c&&(h=c.line)}return a.Text.prototype.styleHas.call(this,u,h)},isEmptyStyles:function(u){if(!this.styles)return!0;var h=0,c=u+1,f,s,d=!1,g=this._styleMap[u],m=this._styleMap[u+1];g&&(u=g.line,h=g.offset),m&&(c=m.line,d=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>=h&&(!d||bc&&!O?(g.push(m),m=[],s=S,O=!0):s+=P,!O&&!d&&m.push(w),m=m.concat(b),x=d?0:this._measureWord([w],h,_),_++,O=!1,S>T&&(T=S);return j&&g.push(m),T+D>this.dynamicMinWidth&&(this.dynamicMinWidth=T-P+D),g},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 h=a.Text.prototype._splitTextIntoLines.call(this,u),c=this._wrapText(h.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=ae({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=ae({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>nn().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>nn().currentImageProps),v=ee({get:()=>i.value.drawing&&!r.value,set:A=>i.value.drawing=A}),o=ae(512),a=ae(512),u=ae(!1),h=ae(30),c=ae(!1),f=new Hn.fabric.Circle({radius:h.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=ae("Erase"),d=ae("rgb(0, 0, 0, 1)");function g(){!i.value.canvas||i.value.canvas.renderAll()}function m(){u.value=!u.value,s.value=u.value?"Draw":"Erase"}function y(A=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=A||i.value.brush.color,i.value.brush.width=h.value)}async function b({history:A,erase:L=!1,draw:Q=!1}={}){if(!A||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;A.path.selectable=!1,A.path.opacity=1,A.drawPath=await se(A.path),A.visibleDrawPath=await se(A.path),L?(A.visibleDrawPath.globalCompositeOperation="destination-out",A.drawPath.stroke=i.value.maskBackgroundColor):(A.visibleDrawPath.globalCompositeOperation="source-over",A.drawPath.stroke=Q?d.value:i.value.maskPathColor);let N=await se(A.drawPath);N=N.scale(i.value.imageScale),N.left=N.left+A.drawPath.left*(i.value.imageScale-1),N.top=N.top+A.drawPath.top*(i.value.imageScale-1),Q?(i.value.imageLayer.add(N),i.value.visibleImageLayer.addWithUpdate(A.visibleDrawPath)):(i.value.drawLayer.add(N),i.value.visibleDrawLayer.addWithUpdate(A.visibleDrawPath)),i.value.canvas.remove(A.path),g()}function _(){if(i.value.undoHistory.length===0)return;const A=i.value.undoHistory.pop();b({history:A,erase:!1,draw:v.value}),i.value.redoHistory.push(A)}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 A=i.value.redoHistory.pop();i.value.undoHistory.push(A),v.value?(i.value.imageLayer.remove(A.drawPath),i.value.visibleImageLayer.remove(A.visibleDrawPath)):(i.value.drawLayer.remove(A.drawPath),i.value.visibleDrawLayer.remove(A.visibleDrawPath)),delete A.drawPath,delete A.visibleDrawPath,g()}function S(A){i.value.canvas=new Hn.fabric.Canvas(A,{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",U),i.value.canvas.on("path:created",M),g()}function x(A,L,Q,N){let I=N,W=N;return L>Q?(A.scaleToWidth(N),I=N*(a.value/o.value)):(A.scaleToHeight(N),W=N*(o.value/a.value)),{newHeight:I,newWidth:W}}function T(A){const L=nn();if(V(),A.selectable=!1,o.value=A.width,a.value=A.height,o.value>L.maxDimensions||a.value>L.maxDimensions){const{newHeight:N,newWidth:I}=x(A,o.value,a.value,L.maxDimensions);o.value=I,a.value=N}if(o.value{o.value>a.value?i.value.imageScale=o.value/Q:i.value.imageScale=a.value/Q,i.value.imageLayer=B({image:N,layerHeight:N.height,layerWidth:N.width})}),A.cloneAsImage(N=>{if(!i.value.canvas)return;if(o.value!==Q||a.value!==Q){const{newHeight:q,newWidth:re}=x(N,o.value,a.value,Q);o.value=re,a.value=q}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=E(),i.value.visibleImageLayer=E({image:N}),i.value.drawLayer=B();const I=o.value*i.value.imageScale,W=a.value*i.value.imageScale;L.params.width=I-I%64,L.params.height=W-W%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,j(),P()})}function O(A,L,Q,N,I){if(I==="Original"||A.width===L&&A.height===Q)return A;const W=document.createElement("canvas");W.width=L,W.height=Q;const q=W.getContext("2d");q.fillStyle=N,q.fillRect(0,0,W.width,W.height);let re=0,de=0,me=A.width,ve=A.height,H=0,K=0,k=W.width,X=W.height;switch(I){case"Stretch":break;case"ScaleAndCrop":{const Y=W.width/A.width,$=W.height/A.height;Y>$?(ve=W.height/Y,de=(A.height-ve)/2):(me=W.width/$,re=(A.width-me)/2);break}case"ScaleAndPad":{const Y=W.width/A.width,$=W.height/A.height;Y<$?(X=A.height*Y,K=(W.height-X)/2):(k=A.width*$,H=(W.width-k)/2);break}case"NoScale":default:{A.width>W.width?(me=W.width,re=(A.width-W.width)/2):(k=A.width,H=(W.width-A.width)/2),A.height>W.height?(ve=W.height,de=(A.height-W.height)/2):(X=A.height,K=(W.height-A.height)/2);break}}return q.drawImage(A,re,de,me,ve,H,K,k,X),W}function P(){const A=nn(),L=jt();if(!i.value.imageLayer||!i.value.drawLayer)return;const Q=A.params.width,N=A.params.height,I=i.value.imageLayer.backgroundColor||"#FFFFFF",W=L.imageResizeMode,q=i.value.imageLayer.toCanvasElement(),re=O(q,Q,N,I,W);if(l.value.sourceImage=re.toDataURL("image/jpeg",1),l.value.maskImage=void 0,i.value.redoHistory.length>0&&!v.value){const me=i.value.drawLayer.toCanvasElement(),ve=O(me,Q,N,I,W);l.value.maskImage=ve.toDataURL("image/jpeg",1).split(",")[1]}}let D;function j(){if(!i.value.canvas)return;const A=nn();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),c.value&&(i.value.cropPreviewLayer=E({layerWidth:A.params.width/i.value.imageScale,layerHeight:A.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,j(),D=void 0},5e3))}function R(A,L){const Q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";Hn.fabric.Image.fromURL(Q,N=>{N.set({height:A,width:L});const I=N.toDataURL({format:"png"});l.value.sourceImage=I,v.value=!0,T(N)})}function B({image:A,layerWidth:L,layerHeight:Q}={}){const N=new Hn.fabric.Canvas(null);return N.selection=!1,N.backgroundColor=i.value.maskBackgroundColor,N.setHeight(Q||a.value),N.setWidth(L||o.value),A&&N.add(A),N}function E({image:A,layerWidth:L,layerHeight:Q,fill:N,abosolute:I}={}){const W=A||new Hn.fabric.Rect({width:L||o.value,height:Q||a.value,left:0,top:0,fill:N||"transparent",absolutePositioned:I||!0,selectable:!1});return new Hn.fabric.Group([W],{selectable:!1,absolutePositioned:I||!0})}function V(){!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 te(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),v.value){const A=nn();R(A.params.height||512,A.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=E(),i.value.drawLayer=B(),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function J(){var L;P();const A=document.createElement("a");if(v.value){A.href="data:image/png;base64,"+((L=l.value.sourceImage)==null?void 0:L.split(",")[1]),A.download="image_drawing.png",A.click();return}A.href="data:image/png;base64,"+l.value.maskImage,A.download="image_mask.png",A.click()}async function se(A){return new Promise((L,Q)=>{try{A.clone(L)}catch(N){Q(N)}})}async function M(A){const L={path:A.path};b({history:L,erase:u.value,draw:v.value}),i.value.redoHistory.push(L)}function U(A){if(!i.value.canvas)return;const L=i.value.canvas.getPointer(A.e);f.left=L.x,f.top=L.y,f.opacity=.8,u.value?(f.set("strokeWidth",3),f.set("fill",""),y("red")):(f.set("strokeWidth",0),v.value?(f.set("fill",d.value),y(d.value)):(f.set("fill","white"),y("white"))),f.set("radius",h.value/2),g()}return{showCropPreview:c,erasing:u,switchToolText:s,brushSize:h,drawColor:d,drawing:v,imageProps:i,updateCropPreview:j,createNewCanvas:S,downloadMask:J,resetCanvas:V,resetDrawing:te,flipErase:m,undoAction:w,redoAction:_,newImage:T,newBlankImage:R,setBrush:y,saveImages:P}});const nW={},rW={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},iW=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),aW=[iW];function oW(e,t){return z(),ue("svg",rW,aW)}const sW=Kt(nW,[["render",oW]]);async function lW(e,t){const n=document.createElement("canvas"),r=n.getContext("2d"),i=new Image;return i.src=e,await new Promise(v=>i.onload=v),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function uW(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 lW(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let v=0;v{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}const lm=e=>(oi("data-v-d3bd38bf"),e=e(),si(),e),cW=lm(()=>ne("div",null,[He("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1)),fW={key:0},dW=lm(()=>ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),hW={class:"canvas-container"},pW=lm(()=>ne("canvas",{id:"canvas"},null,-1)),mW={class:"action-buttons",style:{left:"10px",right:"unset"}},gW={class:"action-buttons"},vW=ke({__name:"CustomCanvas",setup(e){const t=nn(),n=Vt(),r=Os(),i=ae();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 gh(a.raw);t.currentImageProps.sourceImage=u,r.drawing=!1,Hn.fabric.Image.fromURL(u,r.newImage)}function v(){t.currentImageProps.sourceImage="",r.resetCanvas()}tt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Hn.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Ht(()=>{window.removeEventListener("paste",o)});async function o(a){var h;const u=(h=a.clipboardData)==null?void 0:h.items;if(!!u)for(let c=0;c(z(),ue(Ve,null,[C(t).currentImageProps.sourceImage?ye("",!0):(z(),be(C(Fp),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:he(()=>[C(t).generatorType==="Img2Img"?(z(),ue("div",fW,[dW,ne("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:u[0]||(u[0]=h=>C(r).newBlankImage(C(t).params.height||512,C(t).params.width||512))},[le(C(De),{size:20,style:{"margin-right":"2px"}},{default:he(()=>[le(_2)]),_:1}),He("draw something")])])):ye("",!0)]),default:he(()=>[le(C(De),{size:100},{default:he(()=>[le(C(np))]),_:1}),cW]),_:1},512)),Ct(ne("div",null,[ne("div",hW,[pW,ne("div",mW,[le(C(pt),{onClick:u[1]||(u[1]=h=>C(r).undoAction()),icon:C(d_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),le(C(pt),{onClick:u[2]||(u[2]=h=>C(r).redoAction()),icon:C(h_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",gW,[le(C(pt),{onClick:u[3]||(u[3]=h=>C(r).resetDrawing()),icon:C(Or),plain:""},null,8,["icon"]),le(C(pt),{onClick:v,icon:C(Dc),plain:""},null,8,["icon"]),le(C(pt),{onClick:u[4]||(u[4]=h=>C(r).downloadMask()),icon:C(Us),plain:""},null,8,["icon"]),le(C(pt),{onClick:u[5]||(u[5]=h=>C(r).flipErase()),icon:C(r).erasing?C(i3):sW,plain:""},null,8,["icon"]),C(r).drawing?(z(),be(C($B),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":u[6]||(u[6]=h=>C(r).drawColor=h),"show-alpha":""},null,8,["modelValue"])):ye("",!0)]),le(C(Mp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:he(()=>[le(wn,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:C(r).brushSize,"onUpdate:modelValue":u[7]||(u[7]=h=>C(r).brushSize=h),min:10,max:100,step:10,change:C(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[zt,C(t).currentImageProps.sourceImage]])],64))}});const U0=Kt(vW,[["__scopeId","data-v-d3bd38bf"]]),yW={class:"centerIcons"},bW={class:"stackedIcons"},_W=ke({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return Dx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(z(),ue("div",yW,[ne("div",bW,[le(C(De),{class:"firstIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconOne)))]),_:1},8,["size"]),le(C(De),{class:"secondIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconTwo)))]),_:1},8,["size"])])]))}});const wW=Kt(_W,[["__scopeId","data-v-74586a39"]]),CW={key:1,style:{width:"40px"}},cu=ke({__name:"GeneratorMenuItem",props:{index:null,iconOne:null,iconTwo:null,isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(z(),be(C(Lr),{content:e.index,placement:e.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:he(()=>[le(C(Dp),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:he(()=>[e.iconTwo?(z(),be(wW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(z(),ue("div",CW,[le(C(De),{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 SW=4,H0=0,W0=1,xW=2;function Wo(e){let t=e.length;for(;--t>=0;)e[t]=0}const TW=0,S2=1,kW=2,EW=3,OW=258,um=29,Dl=256,cl=Dl+1+um,vo=30,cm=19,x2=2*cl+1,pa=15,jf=16,AW=7,fm=256,T2=16,k2=17,E2=18,vh=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]),Bu=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]),PW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),O2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),IW=512,Xr=new Array((cl+2)*2);Wo(Xr);const As=new Array(vo*2);Wo(As);const fl=new Array(IW);Wo(fl);const dl=new Array(OW-EW+1);Wo(dl);const dm=new Array(um);Wo(dm);const mc=new Array(vo);Wo(mc);function Vf(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 A2,P2,I2;function Uf(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const M2=e=>e<256?fl[e]:fl[256+(e>>>7)],hl=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},xn=(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<{xn(e,n[t*2],n[t*2+1])},L2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},MW=e=>{e.bi_valid===16?(hl(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)},LW=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,v=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let u,h,c,f,s,d,g=0;for(f=0;f<=pa;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;ua&&(f=a,g++),n[h*2+1]=f,!(h>r)&&(e.bl_count[f]++,s=0,h>=o&&(s=v[h-o]),d=n[h*2],e.opt_len+=d*(f+s),l&&(e.static_len+=d*(i[h*2+1]+s)));if(g!==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]--,g-=2}while(g>0);for(f=a;f!==0;f--)for(h=e.bl_count[f];h!==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),h--)}},R2=(e,t,n)=>{const r=new Array(pa+1);let i=0,l,v;for(l=1;l<=pa;l++)i=i+n[l-1]<<1,r[l]=i;for(v=0;v<=t;v++){let o=e[v*2+1];o!==0&&(e[v*2]=L2(r[o]++,o))}},RW=()=>{let e,t,n,r,i;const l=new Array(pa+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?hl(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Y0=(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,v,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?wr(e,i,t):(v=dl[i],wr(e,v+Dl+1,t),o=vh[v],o!==0&&(i-=dm[v],xn(e,i,o)),r--,v=M2(r),wr(e,v,n),o=Bu[v],o!==0&&(r-=mc[v],xn(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 v,o,a=-1,u;for(e.heap_len=0,e.heap_max=x2,v=0;v>1;v>=1;v--)Hf(e,n,v);u=l;do v=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Hf(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=v,e.heap[--e.heap_max]=o,n[u*2]=n[v*2]+n[o*2],e.depth[u]=(e.depth[v]>=e.depth[o]?e.depth[v]:e.depth[o])+1,n[v*2+1]=n[o*2+1]=u,e.heap[1]=u++,Hf(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],LW(e,t),R2(n,a,e.bl_count)},K0=(e,t,n)=>{let r,i=-1,l,v=t[0*2+1],o=0,a=7,u=4;for(v===0&&(a=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=v,v=t[(r+1)*2+1],!(++o{let r,i=-1,l,v=t[0*2+1],o=0,a=7,u=4;for(v===0&&(a=138,u=3),r=0;r<=n;r++)if(l=v,v=t[(r+1)*2+1],!(++o{let t;for(K0(e,e.dyn_ltree,e.l_desc.max_code),K0(e,e.dyn_dtree,e.d_desc.max_code),yh(e,e.bl_desc),t=cm-1;t>=3&&e.bl_tree[O2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},$W=(e,t,n,r)=>{let i;for(xn(e,t-257,5),xn(e,n-1,5),xn(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 H0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return W0;for(n=32;n{q0||(RW(),q0=!0),e.l_desc=new Uf(e.dyn_ltree,A2),e.d_desc=new Uf(e.dyn_dtree,P2),e.bl_desc=new Uf(e.bl_tree,I2),e.bi_buf=0,e.bi_valid=0,D2(e)},B2=(e,t,n,r)=>{xn(e,(TW<<1)+(r?1:0),3),$2(e),hl(e,n),hl(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},zW=e=>{xn(e,S2<<1,3),wr(e,fm,Xr),MW(e)},NW=(e,t,n,r)=>{let i,l,v=0;e.level>0?(e.strm.data_type===xW&&(e.strm.data_type=BW(e)),yh(e,e.l_desc),yh(e,e.d_desc),v=DW(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?B2(e,t,n,r):e.strategy===SW||l===i?(xn(e,(S2<<1)+(r?1:0),3),X0(e,Xr,As)):(xn(e,(kW<<1)+(r?1:0),3),$W(e,e.l_desc.max_code+1,e.d_desc.max_code+1,v+1),X0(e,e.dyn_ltree,e.dyn_dtree)),D2(e),r&&$2(e)},jW=(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[(dl[n]+Dl+1)*2]++,e.dyn_dtree[M2(t)*2]++),e.sym_next===e.sym_end);var VW=FW,UW=B2,HW=NW,WW=jW,YW=zW,XW={_tr_init:VW,_tr_stored_block:UW,_tr_flush_block:HW,_tr_tally:WW,_tr_align:YW};const KW=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,v=0;for(;n!==0;){v=n>2e3?2e3:n,n-=v;do i=i+t[r++]|0,l=l+i|0;while(--v);i%=65521,l%=65521}return i|l<<16|0};var pl=KW;const GW=()=>{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},qW=new Uint32Array(GW()),ZW=(e,t,n,r)=>{const i=qW,l=r+n;e^=-1;for(let v=r;v>>8^i[(e^t[v])&255];return e^-1};var qt=ZW,Pa={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"},Yo={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:JW,_tr_stored_block:bh,_tr_flush_block:QW,_tr_tally:Li,_tr_align:eY}=XW,{Z_NO_FLUSH:Ri,Z_PARTIAL_FLUSH:tY,Z_FULL_FLUSH:nY,Z_FINISH:Wn,Z_BLOCK:Z0,Z_OK:tn,Z_STREAM_END:J0,Z_STREAM_ERROR:kr,Z_DATA_ERROR:rY,Z_BUF_ERROR:Wf,Z_DEFAULT_COMPRESSION:iY,Z_FILTERED:aY,Z_HUFFMAN_ONLY:fu,Z_RLE:oY,Z_FIXED:sY,Z_DEFAULT_STRATEGY:lY,Z_UNKNOWN:uY,Z_DEFLATED:Zc}=Yo,cY=9,fY=15,dY=8,hY=29,pY=256,_h=pY+1+hY,mY=30,gY=19,vY=2*_h+1,yY=15,ut=3,Ai=258,Er=Ai+ut+1,bY=32,Io=42,hm=57,wh=69,Ch=73,Sh=91,xh=103,ma=113,cs=666,gn=1,Xo=2,Ia=3,Ko=4,_Y=3,ga=(e,t)=>(e.msg=Pa[t],t),Q0=e=>e*2-(e>4?9:0),ki=e=>{let t=e.length;for(;--t>=0;)e[t]=0},wY=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 CY=(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))},Bn=(e,t)=>{QW(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ln(e.strm)},vt=(e,t)=>{e.pending_buf[e.pending++]=t},is=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Th=(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=pl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=qt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},F2=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,v=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Er?e.strstart-(e.w_size-Er):0,u=e.window,h=e.w_mask,c=e.prev,f=e.strstart+Ai;let s=u[r+v-1],d=u[r+v];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+v]!==d||u[i+v-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]&&rv){if(e.match_start=t,v=l,l>=o)break;s=u[r+v-1],d=u[r+v]}}while((t=c[t&h])>a&&--n!==0);return v<=e.lookahead?v:e.lookahead},Mo=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Er)&&(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),wY(e),r+=t),e.strm.avail_in===0)break;if(n=Th(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=ut)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Di(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Di(e,e.ins_h,e.window[i+ut-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,v=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,Ln(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&&(Th(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(v===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&&(Th(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===Wn)&&t!==Ri&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,v=t===Wn&&e.strm.avail_in===0&&r===i?1:0,bh(e,e.block_start,r,v),e.block_start+=r,Ln(e.strm)),v?Ia:gn)},Yf=(e,t)=>{let n,r;for(;;){if(e.lookahead=ut&&(e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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-Er&&(e.match_length=F2(e,n)),e.match_length>=ut)if(r=Li(e,e.strstart-e.match_start,e.match_length-ut),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=ut){e.match_length--;do e.strstart++,e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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=Di(e,e.ins_h,e.window[e.strstart+1]);else r=Li(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Bn(e,!1),e.strm.avail_out===0))return gn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=ut&&(e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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=ut-1,n!==0&&e.prev_length4096)&&(e.match_length=ut-1)),e.prev_length>=ut&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-ut,r=Li(e,e.strstart-1-e.prev_match,e.prev_length-ut),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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=ut-1,e.strstart++,r&&(Bn(e,!1),e.strm.avail_out===0))return gn}else if(e.match_available){if(r=Li(e,0,e.window[e.strstart-1]),r&&Bn(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return gn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Li(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const v=e.window;for(;;){if(e.lookahead<=Ai){if(Mo(e),e.lookahead<=Ai&&t===Ri)return gn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=ut&&e.strstart>0&&(i=e.strstart-1,r=v[i],r===v[++i]&&r===v[++i]&&r===v[++i])){l=e.strstart+Ai;do;while(r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=ut?(n=Li(e,1,e.match_length-ut),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Li(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Bn(e,!1),e.strm.avail_out===0))return gn}return e.insert=0,t===Wn?(Bn(e,!0),e.strm.avail_out===0?Ia:Ko):e.sym_next&&(Bn(e,!1),e.strm.avail_out===0)?gn:Xo},xY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Mo(e),e.lookahead===0)){if(t===Ri)return gn;break}if(e.match_length=0,n=Li(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Bn(e,!1),e.strm.avail_out===0))return gn}return e.insert=0,t===Wn?(Bn(e,!0),e.strm.avail_out===0?Ia:Ko):e.sym_next&&(Bn(e,!1),e.strm.avail_out===0)?gn:Xo};function vr(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 fs=[new vr(0,0,0,0,z2),new vr(4,4,8,4,Yf),new vr(4,5,16,8,Yf),new vr(4,6,32,32,Yf),new vr(4,4,16,16,eo),new vr(8,16,32,32,eo),new vr(8,16,128,128,eo),new vr(8,32,128,256,eo),new vr(32,128,258,1024,eo),new vr(32,258,258,4096,eo)],TY=e=>{e.window_size=2*e.w_size,ki(e.head),e.max_lazy_match=fs[e.level].max_lazy,e.good_match=fs[e.level].good_length,e.nice_match=fs[e.level].nice_length,e.max_chain_length=fs[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=ut-1,e.match_available=0,e.ins_h=0};function kY(){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=Zc,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(vY*2),this.dyn_dtree=new Uint16Array((2*mY+1)*2),this.bl_tree=new Uint16Array((2*gY+1)*2),ki(this.dyn_ltree),ki(this.dyn_dtree),ki(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(yY+1),this.heap=new Uint16Array(2*_h+1),ki(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*_h+1),ki(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 $l=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Io&&t.status!==hm&&t.status!==wh&&t.status!==Ch&&t.status!==Sh&&t.status!==xh&&t.status!==ma&&t.status!==cs?1:0},N2=e=>{if($l(e))return ga(e,kr);e.total_in=e.total_out=0,e.data_type=uY;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?hm:t.wrap?Io:ma,e.adler=t.wrap===2?0:1,t.last_flush=-2,JW(t),tn},j2=e=>{const t=N2(e);return t===tn&&TY(e.state),t},EY=(e,t)=>$l(e)||e.state.wrap!==2?kr:(e.state.gzhead=t,tn),V2=(e,t,n,r,i,l)=>{if(!e)return kr;let v=1;if(t===iY&&(t=6),r<0?(v=0,r=-r):r>15&&(v=2,r-=16),i<1||i>cY||n!==Zc||r<8||r>15||t<0||t>9||l<0||l>sY||r===8&&v!==1)return ga(e,kr);r===8&&(r=9);const o=new kY;return e.state=o,o.strm=e,o.status=Io,o.wrap=v,o.gzhead=null,o.w_bits=r,o.w_size=1<V2(e,t,Zc,fY,dY,lY),AY=(e,t)=>{if($l(e)||t>Z0||t<0)return e?ga(e,kr):kr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===cs&&t!==Wn)return ga(e,e.avail_out===0?Wf:kr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Ln(e),e.avail_out===0)return n.last_flush=-1,tn}else if(e.avail_in===0&&Q0(t)<=Q0(r)&&t!==Wn)return ga(e,Wf);if(n.status===cs&&e.avail_in!==0)return ga(e,Wf);if(n.status===Io&&n.wrap===0&&(n.status=ma),n.status===Io){let i=Zc+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=fu||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=bY),i+=31-i%31,is(n,i),n.strstart!==0&&(is(n,e.adler>>>16),is(n,e.adler&65535)),e.adler=1,n.status=ma,Ln(e),n.pending!==0)return n.last_flush=-1,tn}if(n.status===hm){if(e.adler=0,vt(n,31),vt(n,139),vt(n,8),n.gzhead)vt(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)),vt(n,n.gzhead.time&255),vt(n,n.gzhead.time>>8&255),vt(n,n.gzhead.time>>16&255),vt(n,n.gzhead.time>>24&255),vt(n,n.level===9?2:n.strategy>=fu||n.level<2?4:0),vt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(vt(n,n.gzhead.extra.length&255),vt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=qt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=wh;else if(vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,n.level===9?2:n.strategy>=fu||n.level<2?4:0),vt(n,_Y),n.status=ma,Ln(e),n.pending!==0)return n.last_flush=-1,tn}if(n.status===wh){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=qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,Ln(e),n.pending!==0)return n.last_flush=-1,tn;i=0,l-=o}let v=new Uint8Array(n.gzhead.extra);n.pending_buf.set(v.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Ch}if(n.status===Ch){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=qt(e.adler,n.pending_buf,n.pending-i,i)),Ln(e),n.pending!==0)return n.last_flush=-1,tn;i=0}n.gzindexi&&(e.adler=qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Sh}if(n.status===Sh){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=qt(e.adler,n.pending_buf,n.pending-i,i)),Ln(e),n.pending!==0)return n.last_flush=-1,tn;i=0}n.gzindexi&&(e.adler=qt(e.adler,n.pending_buf,n.pending-i,i))}n.status=xh}if(n.status===xh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ln(e),n.pending!==0))return n.last_flush=-1,tn;vt(n,e.adler&255),vt(n,e.adler>>8&255),e.adler=0}if(n.status=ma,Ln(e),n.pending!==0)return n.last_flush=-1,tn}if(e.avail_in!==0||n.lookahead!==0||t!==Ri&&n.status!==cs){let i=n.level===0?z2(n,t):n.strategy===fu?xY(n,t):n.strategy===oY?SY(n,t):fs[n.level].func(n,t);if((i===Ia||i===Ko)&&(n.status=cs),i===gn||i===Ia)return e.avail_out===0&&(n.last_flush=-1),tn;if(i===Xo&&(t===tY?eY(n):t!==Z0&&(bh(n,0,0,!1),t===nY&&(ki(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Ln(e),e.avail_out===0))return n.last_flush=-1,tn}return t!==Wn?tn:n.wrap<=0?J0:(n.wrap===2?(vt(n,e.adler&255),vt(n,e.adler>>8&255),vt(n,e.adler>>16&255),vt(n,e.adler>>24&255),vt(n,e.total_in&255),vt(n,e.total_in>>8&255),vt(n,e.total_in>>16&255),vt(n,e.total_in>>24&255)):(is(n,e.adler>>>16),is(n,e.adler&65535)),Ln(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?tn:J0)},PY=e=>{if($l(e))return kr;const t=e.state.status;return e.state=null,t===ma?ga(e,rY):tn},IY=(e,t)=>{let n=t.length;if($l(e))return kr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==Io||r.lookahead)return kr;if(i===1&&(e.adler=pl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(ki(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,v=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Mo(r);r.lookahead>=ut;){let a=r.strstart,u=r.lookahead-(ut-1);do r.ins_h=Di(r,r.ins_h,r.window[a+ut-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=ut-1,Mo(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=ut-1,r.match_available=0,e.next_in=v,e.input=o,e.avail_in=l,r.wrap=i,tn};var MY=OY,LY=V2,RY=j2,DY=N2,$Y=EY,BY=AY,FY=PY,zY=IY,NY="pako deflate (from Nodeca project)",Ps={deflateInit:MY,deflateInit2:LY,deflateReset:RY,deflateResetKeep:DY,deflateSetHeader:$Y,deflate:BY,deflateEnd:FY,deflateSetDictionary:zY,deflateInfo:NY};const jY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var VY=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)jY(n,r)&&(e[r]=n[r])}}return e},UY=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;ml[254]=ml[254]=1;var HY=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,v=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 WY=(e,t)=>{if(t<65534&&e.subarray&&U2)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(v&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}v<65536?l[i++]=v:(v-=65536,l[i++]=55296|v>>10&1023,l[i++]=56320|v&1023)}return WY(l,i)},XY=(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+ml[e[n]]>t?n:t},gl={string2buf:HY,buf2string:YY,utf8border:XY};function KY(){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 H2=KY;const W2=Object.prototype.toString,{Z_NO_FLUSH:GY,Z_SYNC_FLUSH:qY,Z_FULL_FLUSH:ZY,Z_FINISH:JY,Z_OK:gc,Z_STREAM_END:QY,Z_DEFAULT_COMPRESSION:eX,Z_DEFAULT_STRATEGY:tX,Z_DEFLATED:nX}=Yo;function Bl(e){this.options=Jc.assign({level:eX,method:nX,chunkSize:16384,windowBits:15,memLevel:8,strategy:tX},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 H2,this.strm.avail_out=0;let n=Ps.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==gc)throw new Error(Pa[n]);if(t.header&&Ps.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=gl.string2buf(t.dictionary):W2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Ps.deflateSetDictionary(this.strm,r),n!==gc)throw new Error(Pa[n]);this._dict_set=!0}}Bl.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?JY:GY,typeof e=="string"?n.input=gl.string2buf(e):W2.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===qY||l===ZY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=Ps.deflate(n,l),i===QY)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Ps.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===gc;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};Bl.prototype.onData=function(e){this.chunks.push(e)};Bl.prototype.onEnd=function(e){e===gc&&(this.result=Jc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function pm(e,t){const n=new Bl(t);if(n.push(e,!0),n.err)throw n.msg||Pa[n.err];return n.result}function rX(e,t){return t=t||{},t.raw=!0,pm(e,t)}function iX(e,t){return t=t||{},t.gzip=!0,pm(e,t)}var aX=Bl,oX=pm,sX=rX,lX=iX,uX=Yo,cX={Deflate:aX,deflate:oX,deflateRaw:sX,gzip:lX,constants:uX};const du=16209,fX=16191;var dX=function(t,n){let r,i,l,v,o,a,u,h,c,f,s,d,g,m,y,b,_,w,S,x,T,O,P,D;const j=t.state;r=t.next_in,P=t.input,i=r+(t.avail_in-5),l=t.next_out,D=t.output,v=l-(n-t.avail_out),o=l+(t.avail_out-257),a=j.dmax,u=j.wsize,h=j.whave,c=j.wnext,f=j.window,s=j.hold,d=j.bits,g=j.lencode,m=j.distcode,y=(1<>>24,s>>>=w,d-=w,w=_>>>16&255,w===0)D[l++]=_&65535;else if(w&16){S=_&65535,w&=15,w&&(d>>=w,d-=w),d<15&&(s+=P[r++]<>>24,s>>>=w,d-=w,w=_>>>16&255,w&16){if(x=_&65535,w&=15,da){t.msg="invalid distance too far back",j.mode=du;break e}if(s>>>=w,d-=w,w=l-v,x>w){if(w=x-w,w>h&&j.sane){t.msg="invalid distance too far back",j.mode=du;break e}if(T=0,O=f,c===0){if(T+=u-w,w2;)D[l++]=O[T++],D[l++]=O[T++],D[l++]=O[T++],S-=3;S&&(D[l++]=O[T++],S>1&&(D[l++]=O[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,d-=S<<3,s&=(1<{const a=o.bits;let u=0,h=0,c=0,f=0,s=0,d=0,g=0,m=0,y=0,b=0,_,w,S,x,T,O=null,P;const D=new Uint16Array(to+1),j=new Uint16Array(to+1);let R=null,B,E,V;for(u=0;u<=to;u++)D[u]=0;for(h=0;h=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===ny||f!==1))return-1;for(j[1]=0,u=1;uey||e===ry&&y>ty)return 1;for(;;){B=u-g,v[h]+1=P?(E=R[v[h]-P],V=O[v[h]-P]):(E=32+64,V=0),_=1<>g)+w]=B<<24|E<<16|V|0;while(w!==0);for(_=1<>=1;if(_!==0?(b&=_-1,b+=_):b=0,h++,--D[u]===0){if(u===f)break;u=t[n+v[h]]}if(u>s&&(b&x)!==S){for(g===0&&(g=s),T+=c,d=u-g,m=1<ey||e===ry&&y>ty)return 1;S=b&x,i[S]=s<<24|d<<16|T-l|0}}return b!==0&&(i[T+b]=u-g<<24|64<<16|0),o.bits=s,0};var Is=vX;const yX=0,Y2=1,X2=2,{Z_FINISH:iy,Z_BLOCK:bX,Z_TREES:hu,Z_OK:Ma,Z_STREAM_END:_X,Z_NEED_DICT:wX,Z_STREAM_ERROR:Zn,Z_DATA_ERROR:K2,Z_MEM_ERROR:G2,Z_BUF_ERROR:CX,Z_DEFLATED:ay}=Yo,Qc=16180,oy=16181,sy=16182,ly=16183,uy=16184,cy=16185,fy=16186,dy=16187,hy=16188,py=16189,vc=16190,jr=16191,Kf=16192,my=16193,Gf=16194,gy=16195,vy=16196,yy=16197,by=16198,pu=16199,mu=16200,_y=16201,wy=16202,Cy=16203,Sy=16204,xy=16205,qf=16206,Ty=16207,ky=16208,Dt=16209,q2=16210,Z2=16211,SX=852,xX=592,TX=15,kX=TX,Ey=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function EX(){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 Ua=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modeZ2?1:0},J2=e=>{if(Ua(e))return Zn;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=Qc,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(SX),t.distcode=t.distdyn=new Int32Array(xX),t.sane=1,t.back=-1,Ma},Q2=e=>{if(Ua(e))return Zn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,J2(e)},eC=(e,t)=>{let n;if(Ua(e))return Zn;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Zn:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Q2(e))},tC=(e,t)=>{if(!e)return Zn;const n=new EX;e.state=n,n.strm=e,n.window=null,n.mode=Qc;const r=eC(e,t);return r!==Ma&&(e.state=null),r},OX=e=>tC(e,kX);let Oy=!0,Zf,Jf;const AX=e=>{if(Oy){Zf=new Int32Array(512),Jf=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(Is(Y2,e.lens,0,288,Zf,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Is(X2,e.lens,0,32,Jf,0,e.work,{bits:5}),Oy=!1}e.lencode=Zf,e.lenbits=9,e.distcode=Jf,e.distbits=5},nC=(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,v,o,a,u,h,c,f,s,d,g,m=0,y,b,_,w,S,x,T,O;const P=new Uint8Array(4);let D,j;const R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ua(e)||!e.output||!e.input&&e.avail_in!==0)return Zn;n=e.state,n.mode===jr&&(n.mode=Kf),v=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,c=o,f=a,O=Ma;e:for(;;)switch(n.mode){case Qc:if(n.wrap===0){n.mode=Kf;break}for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=qt(n.check,P,2,0),u=0,h=0,n.mode=oy;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Dt;break}if((u&15)!==ay){e.msg="unknown compression method",n.mode=Dt;break}if(u>>>=4,h-=4,T=(u&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=Dt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(P[0]=u&255,P[1]=u>>>8&255,n.check=qt(n.check,P,2,0)),u=0,h=0,n.mode=sy;case sy:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>8&255,P[2]=u>>>16&255,P[3]=u>>>24&255,n.check=qt(n.check,P,4,0)),u=0,h=0,n.mode=ly;case ly:for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>8),n.flags&512&&n.wrap&4&&(P[0]=u&255,P[1]=u>>>8&255,n.check=qt(n.check,P,2,0)),u=0,h=0,n.mode=uy;case uy:if(n.flags&1024){for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=qt(n.check,P,2,0)),u=0,h=0}else n.head&&(n.head.extra=null);n.mode=cy;case cy: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=qt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=fy;case fy: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=jr;break;case py:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>=h&7,h-=h&7,n.mode=qf;break}for(;h<3;){if(o===0)break e;o--,u+=r[l++]<>>=1,h-=1,u&3){case 0:n.mode=my;break;case 1:if(AX(n),n.mode=pu,t===hu){u>>>=2,h-=2;break e}break;case 2:n.mode=vy;break;case 3:e.msg="invalid block type",n.mode=Dt}u>>>=2,h-=2;break;case my:for(u>>>=h&7,h-=h&7;h<32;){if(o===0)break e;o--,u+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Dt;break}if(n.length=u&65535,u=0,h=0,n.mode=Gf,t===hu)break e;case Gf:n.mode=gy;case gy: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),v),o-=s,l+=s,a-=s,v+=s,n.length-=s;break}n.mode=jr;break;case vy:for(;h<14;){if(o===0)break e;o--,u+=r[l++]<>>=5,h-=5,n.ndist=(u&31)+1,u>>>=5,h-=5,n.ncode=(u&15)+4,u>>>=4,h-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Dt;break}n.have=0,n.mode=yy;case yy:for(;n.have>>=3,h-=3}for(;n.have<19;)n.lens[R[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,D={bits:n.lenbits},O=Is(yX,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid code lengths set",n.mode=Dt;break}n.have=0,n.mode=by;case by:for(;n.have>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=y,h-=y,n.lens[n.have++]=_;else{if(_===16){for(j=y+2;h>>=y,h-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=Dt;break}T=n.lens[n.have-1],s=3+(u&3),u>>>=2,h-=2}else if(_===17){for(j=y+3;h>>=y,h-=y,T=0,s=3+(u&7),u>>>=3,h-=3}else{for(j=y+7;h>>=y,h-=y,T=0,s=11+(u&127),u>>>=7,h-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Dt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===Dt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Dt;break}if(n.lenbits=9,D={bits:n.lenbits},O=Is(Y2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid literal/lengths set",n.mode=Dt;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},O=Is(X2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,O){e.msg="invalid distances set",n.mode=Dt;break}if(n.mode=pu,t===hu)break e;case pu:n.mode=mu;case mu:if(o>=6&&a>=258){e.next_out=v,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=u,n.bits=h,dX(e,f),v=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,n.mode===jr&&(n.back=-1);break}for(n.back=0;m=n.lencode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,n.length=_,b===0){n.mode=xy;break}if(b&32){n.back=-1,n.mode=jr;break}if(b&64){e.msg="invalid literal/length code",n.mode=Dt;break}n.extra=b&15,n.mode=_y;case _y:if(n.extra){for(j=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=wy;case wy:for(;m=n.distcode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=Dt;break}n.offset=_,n.extra=b&15,n.mode=Cy;case Cy:if(n.extra){for(j=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Dt;break}n.mode=Sy;case Sy: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=Dt;break}s>n.wnext?(s-=n.wnext,d=n.wsize-s):d=n.wnext-s,s>n.length&&(s=n.length),g=n.window}else g=i,d=v-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[v++]=g[d++];while(--s);n.length===0&&(n.mode=mu);break;case xy:if(a===0)break e;i[v++]=n.length,a--,n.mode=mu;break;case qf:if(n.wrap){for(;h<32;){if(o===0)break e;o--,u|=r[l++]<{if(Ua(e))return Zn;let t=e.state;return t.window&&(t.window=null),e.state=null,Ma},MX=(e,t)=>{if(Ua(e))return Zn;const n=e.state;return(n.wrap&2)===0?Zn:(n.head=t,t.done=!1,Ma)},LX=(e,t)=>{const n=t.length;let r,i,l;return Ua(e)||(r=e.state,r.wrap!==0&&r.mode!==vc)?Zn:r.mode===vc&&(i=1,i=pl(i,t,n,0),i!==r.check)?K2:(l=nC(e,t,n,n),l?(r.mode=q2,G2):(r.havedict=1,Ma))};var RX=Q2,DX=eC,$X=J2,BX=OX,FX=tC,zX=PX,NX=IX,jX=MX,VX=LX,UX="pako inflate (from Nodeca project)",Kr={inflateReset:RX,inflateReset2:DX,inflateResetKeep:$X,inflateInit:BX,inflateInit2:FX,inflate:zX,inflateEnd:NX,inflateGetHeader:jX,inflateSetDictionary:VX,inflateInfo:UX};function HX(){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 WX=HX;const rC=Object.prototype.toString,{Z_NO_FLUSH:YX,Z_FINISH:XX,Z_OK:vl,Z_STREAM_END:Qf,Z_NEED_DICT:ed,Z_STREAM_ERROR:KX,Z_DATA_ERROR:Ay,Z_MEM_ERROR:GX}=Yo;function Fl(e){this.options=Jc.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 H2,this.strm.avail_out=0;let n=Kr.inflateInit2(this.strm,t.windowBits);if(n!==vl)throw new Error(Pa[n]);if(this.header=new WX,Kr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=gl.string2buf(t.dictionary):rC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Kr.inflateSetDictionary(this.strm,t.dictionary),n!==vl)))throw new Error(Pa[n])}Fl.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,v,o;if(this.ended)return!1;for(t===~~t?v=t:v=t===!0?XX:YX,rC.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=Kr.inflate(n,v),l===ed&&i&&(l=Kr.inflateSetDictionary(n,i),l===vl?l=Kr.inflate(n,v):l===Ay&&(l=ed));n.avail_in>0&&l===Qf&&n.state.wrap>0&&e[n.next_in]!==0;)Kr.inflateReset(n),l=Kr.inflate(n,v);switch(l){case KX:case Ay:case ed:case GX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===Qf))if(this.options.to==="string"){let a=gl.utf8border(n.output,n.next_out),u=n.next_out-a,h=gl.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(h)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===vl&&o===0)){if(l===Qf)return l=Kr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Fl.prototype.onData=function(e){this.chunks.push(e)};Fl.prototype.onEnd=function(e){e===vl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Jc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function mm(e,t){const n=new Fl(t);if(n.push(e),n.err)throw n.msg||Pa[n.err];return n.result}function qX(e,t){return t=t||{},t.raw=!0,mm(e,t)}var ZX=Fl,JX=mm,QX=qX,eK=mm,tK=Yo,nK={Inflate:ZX,inflate:JX,inflateRaw:QX,ungzip:eK,constants:tK};const{Deflate:rq,deflate:iq,deflateRaw:rK,gzip:aq}=cX,{Inflate:oq,inflate:sq,inflateRaw:iK,ungzip:lq}=nK;var aK=rK,oK=iK;function Py(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 sK=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=Py(t);if(console.log("URL params:",n),n.get("share")){const l=oK(new Uint8Array(atob(n.get("share")).split("").map(v=>v.charCodeAt(0))),{to:"string"});if(!l){Vt().raiseError("Error when trying to decode share parameter!",!1);return}n=Py(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),scheduler:n.get("scheduler")||"default"};nn().generateText2Img(r,!1)},lK=10;function Fu(e,t,n,r,i=l=>Vt().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(v=>`${v[0]} - ${v[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}const uK=Ro("interrogate",()=>{const e=ae({}),t=ae(!1);async function n(v){Vt().raiseError(v,!1),t.value=!1,e.value={}}async function r(){const v=jt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(`${v.baseURL.length===0?".":v.baseURL}/sdapi/v1/interrogate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),u=await a.json();!Fu(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}}),gm=e=>(oi("data-v-db184ac6"),e=e(),si(),e),cK={key:0,style:{"margin-top":"16px"}},fK=gm(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),dK={key:1,style:{"margin-top":"16px"}},hK={key:2},pK={style:{"margin-top":"8px"}},mK=gm(()=>ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),gK={key:0},vK=gm(()=>ne("h3",null,"Caption",-1)),yK={key:0},bK={key:1},_K=ke({__name:"InterrogationView",setup(e){const t=uK(),n=nn(),r=Vt(),i=ae();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 h=await gh(u.raw);t.currentInterrogation.source_image=h,t.interrogateImage()}function v(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=w2();return(u,h)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(z(),ue("div",hK,[ne("div",pK,[le(C(pt),{icon:C(Tg),onClick:C(t).resetInterrogation},{default:he(()=>[He("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(z(),be(C(pt),{key:0,icon:C(Tg),onClick:v,disabled:!C(o)},{default:he(()=>[He("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):ye("",!0)]),mK,le(C(Lp),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(z(),ue("div",gK,[vK,C(o)?(z(),ue("div",bK,[ne("strong",null,Pe(C(o)),1)])):(z(),ue("div",yK,"Processing"+Pe(C(a)),1))])):ye("",!0)])):(z(),ue("div",dK,[ne("strong",null,"Uploading image"+Pe(C(a)),1)])):(z(),ue("div",cK,[ne("div",null,[le(C(Fp),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:he(()=>[le(C(De),{size:100},{default:he(()=>[le(C(np))]),_:1}),fK]),_:1},512)])]))}});const wK=Kt(_K,[["__scopeId","data-v-db184ac6"]]);function CK(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),v=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"):"",h=v>0?v+(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(h),c.join(" ")}const SK={class:"form"},xK={key:0,style:{"padding-bottom":"50px"}},TK=ne("h1",{style:{margin:"0"}},"Interrogation",-1),kK=ne("div",null,"Interrogate images to get their predicted descriptions.",-1),EK={class:"sidebar"},OK=ne("span",{style:{height:"100%","font-size":"14px"}},[He("Reference Image: "),ne("br"),He("(Photomaker/Kontext) ")],-1),AK={class:"main"},PK={class:"image center-horizontal"},IK={key:0},MK=ke({__name:"GenerateView",setup(e){const n=vp(gp).smallerOrEqual("md"),r=nn(),i=Vt(),l=Os();jt();const v=uv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSamplers()).map(b=>b.name);return y.length===0?[]:u(y)},[]),o=uv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSchedulers()).map(b=>b.name);return y.length===0?[]:h(y)},[]),a=bt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function u(g){return!r.params||!r.params.sampler_name||g.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=g[0]),g}function h(g){return!r.params||!r.params.scheduler||g.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=g[0]),g}function c(g){return"Elapsed: "+CK(g,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function f(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function s(g){r.generatorType=g,f(),console.log(g)}function d(){l.showCropPreview=!0,l.updateCropPreview()}return f(),sK(),(g,m)=>(z(),ue(Ve,null,[le(C(dw),{"default-active":C(r).generatorType,collapse:!0,onSelect:s,mode:C(n)?"horizontal":"vertical",class:ce(C(n)?"mobile-generator-types":"generator-types"),style:je(C(n)?"overflow-x: auto":"")},{default:he(()=>[le(cu,{index:"Text2Img","icon-one":C(TE),"icon-two":C(Yl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(cu,{index:"Img2Img","icon-one":C(Yl),"icon-two":C(Yl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(cu,{index:"Inpainting","icon-one":_2,"icon-two":C(Yl),isMobile:C(n)},null,8,["icon-two","isMobile"]),le(cu,{index:"Interrogation","icon-one":TH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",SK,[C(r).generatorType==="Interrogation"?(z(),ue("div",xK,[TK,kK,le(wK)])):(z(),be(C(Mp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:a,onSubmit:m[28]||(m[28]=it(()=>{},["prevent"]))},{default:he(()=>[ne("div",EK,[le(C(fB),{modelValue:C(i).activeCollapse,"onUpdate:modelValue":m[23]||(m[23]=y=>C(i).activeCollapse=y),style:{"margin-bottom":"24px"}},{default:he(()=>[le(C(dB),{title:"Generation Options",name:"1"},{default:he(()=>[le(UH),le(mh,{label:"Negative Prompt",prop:"negativePrompt",modelValue:C(r).negativePrompt,"onUpdate:modelValue":m[0]||(m[0]=y=>C(r).negativePrompt=y),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(mh,{label:"Seed",prop:"seed",modelValue:C(r).params.seed,"onUpdate:modelValue":m[2]||(m[2]=y=>C(r).params.seed=y),placeholder:"Enter seed here",clearable:"","clear-icon":C(pE)},{append:he(()=>[le(C(Lr),{content:"Randomize!",placement:"top"},{default:he(()=>[le(C(pt),{icon:C(W3),onClick:m[1]||(m[1]=()=>C(r).params.seed=C(iC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(z(),be(C(h0),{key:0,gutter:10},{default:he(()=>[C(r).multiSelect.sampler.state==="Multiple"?(z(),be(C(qa),{key:0,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Sampler(s)",prop:"samplers",modelValue:C(r).multiSelect.sampler.selected,"onUpdate:modelValue":m[3]||(m[3]=y=>C(r).multiSelect.sampler.selected=y),options:C(v),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(qa),{key:1,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Sampler",prop:"sampler",modelValue:C(r).params.sampler_name,"onUpdate:modelValue":m[4]||(m[4]=y=>C(r).params.sampler_name=y),options:C(v),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(qa),{key:2,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Scheduler(s)",prop:"schedulers",modelValue:C(r).multiSelect.scheduler.selected,"onUpdate:modelValue":m[5]||(m[5]=y=>C(r).multiSelect.scheduler.selected=y),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(qa),{key:3,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Scheduler",prop:"scheduler",modelValue:C(r).params.scheduler,"onUpdate:modelValue":m[6]||(m[6]=y=>C(r).params.scheduler=y),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(wn,{label:"Batch Size",prop:"batchSize",modelValue:C(r).params.n,"onUpdate:modelValue":m[7]||(m[7]=y=>C(r).params.n=y),min:C(r).minImages,max:C(r).maxImages},null,8,["modelValue","min","max"]),C(r).multiSelect.steps.state==="Multiple"?(z(),be(wn,{key:1,label:"Steps(s)",prop:"multiSteps",modelValue:C(r).multiSelect.steps.selected,"onUpdate:modelValue":m[8]||(m[8]=y=>C(r).multiSelect.steps.selected=y),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(wn,{key:2,label:"Steps",prop:"steps",modelValue:C(r).params.steps,"onUpdate:modelValue":m[9]||(m[9]=y=>C(r).params.steps=y),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(wn,{label:"Width",prop:"width",modelValue:C(r).params.width,"onUpdate:modelValue":m[10]||(m[10]=y=>C(r).params.width=y),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:d},null,8,["modelValue","min","max"]),le(wn,{label:"Height",prop:"height",modelValue:C(r).params.height,"onUpdate:modelValue":m[11]||(m[11]=y=>C(r).params.height=y),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:d},null,8,["modelValue","min","max"]),C(r).multiSelect.guidance.state==="Multiple"?(z(),be(wn,{key:3,label:"Guidance(s)",prop:"cfgScales",modelValue:C(r).multiSelect.guidance.selected,"onUpdate:modelValue":m[12]||(m[12]=y=>C(r).multiSelect.guidance.selected=y),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(wn,{key:4,label:"Guidance",prop:"cfgScale",modelValue:C(r).params.cfg_scale,"onUpdate:modelValue":m[13]||(m[13]=y=>C(r).params.cfg_scale=y),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(wn,{key:5,label:"Eta",prop:"eta",modelValue:C(r).params.eta,"onUpdate:modelValue":m[14]||(m[14]=y=>C(r).params.eta=y),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(wn,{key:6,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:C(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":m[15]||(m[15]=y=>C(r).multiSelect.clipSkip.selected=y),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(wn,{key:7,label:"CLIP Skip",prop:"clipSkip",modelValue:C(r).params.clip_skip,"onUpdate:modelValue":m[16]||(m[16]=y=>C(r).params.clip_skip=y),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(wn,{key:8,label:"Init Strength",prop:"denoise",modelValue:C(r).params.denoising_strength,"onUpdate:modelValue":m[17]||(m[17]=y=>C(r).params.denoising_strength=y),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(wn,{label:"Video Frames",prop:"frames",modelValue:C(r).params.frames,"onUpdate:modelValue":m[18]||(m[18]=y=>C(r).params.frames=y),min:C(r).minFrames,max:C(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). Max 80 frames, about 5 seconds of video."},null,8,["modelValue","min","max"]),ne("div",null,[OK,ne("input",{class:"el-button",type:"file",id:"extra_image_input",onChange:m[19]||(m[19]=y=>C(r).setExtraImage(y)),accept:"image/*",multiple:""},null,32),ne("button",{onClick:m[20]||(m[20]=y=>C(r).clearExtraImage()),class:"el-button"},"Clear Image"),le(C(h0),null,{default:he(()=>[le(C(qa),{span:C(n)?24:12},{default:he(()=>[le(V0,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":m[21]||(m[21]=y=>C(r).params.enable_hr=y),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),le(C(qa),{span:C(n)?24:12},{default:he(()=>[C(r).generatorType==="Img2Img"?(z(),be(V0,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:C(r).params.send_as_refimg,"onUpdate:modelValue":m[22]||(m[22]=y=>C(r).params.send_as_refimg=y),info:"Instead of regular Img2Img, send the image as a reference image for edit models."},null,8,["modelValue"])):ye("",!0)]),_:1},8,["span"])]),_:1})])]),_:1})]),_:1},8,["modelValue"])]),ne("div",AK,[le(C(pt),{onClick:m[24]||(m[24]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:he(()=>[He("Reset")]),_:1}),le(C(pt),{type:"primary",class:"generate-cancel-btn",style:je(C(r).generating?"width: 55%;":""),onClick:m[25]||(m[25]=()=>C(r).generateImage(C(r).generatorType))},{default:he(()=>[ne("span",null," Generate "+Pe(C(r).totalImageCount)+" image"+Pe(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(z(),be(C(pt),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:m[26]||(m[26]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:he(()=>[He("Cancel all")]),_:1},8,["disabled"])):ye("",!0)]),ne("div",PK,[le(C(h$),{class:"center-both generated-image"},{default:he(()=>[!C(r).generating&&C(r).outputs.length==0?(z(),ue("div",IK,[/Inpainting/.test(C(r).generatorType)?(z(),be(U0,{key:0})):ye("",!0),/Img2Img/.test(C(r).generatorType)?(z(),be(U0,{key:1})):ye("",!0)])):ye("",!0),!C(i).showGeneratedImages&&C(r).generating?(z(),be(LH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:c(C(r).timer.seconds),onShowGenerated:m[27]||(m[27]=y=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):ye("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(z(),be(QH,{key:2})):ye("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Ms=ok({history:ST("./"),routes:[{path:"/",name:"generate",component:MK},{path:"/images",name:"images",component:()=>zf(()=>Promise.resolve().then(()=>IG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>zf(()=>Promise.resolve().then(()=>HG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>zf(()=>Promise.resolve().then(()=>QG),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function LK(e){const t=[],n=/]+):([^>]+)>/g;return[e.replace(n,(i,l,v)=>{if(v.trim()==="")return"";const o=Number(v);if(isNaN(o))return"";let a=l,u=!1;const h="|high_noise|";return a.startsWith(h)&&(a=a.substring(h.length),u=!0),t.push({name:a,multiplier:o,...u?{is_high_noise:!0}:{}}),""}),t]}function td(){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,enable_hr:!1,send_as_refimg:!0,scheduler:"default"}}function iC(){return Math.floor(Math.random()*9999999)+1}const nn=Ro("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=ae("Text2Img"),r=ae(""),i=Sn("promptHistory",[]),l=ae(""),v=Sn("negativeLibrary",[]),o=ae(td()),a=ae({interval:0,seconds:0}),u=ae({sampler:{name:"Sampler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.sampler_name],mapToParam:we=>we.sampler_name},scheduler:{name:"Scheduler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.scheduler],mapToParam:we=>we.scheduler},steps:{name:"Steps",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.steps],mapToParam:we=>we.steps},guidance:{name:"CFG Scale",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.cfg_scale],mapToParam:we=>we.cfg_scale},clipSkip:{name:"Clip Skip",state:"Disabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.clip_skip],mapToParam:we=>we.clip_skip},eta:{name:"Eta",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.eta],mapToParam:we=>we.eta}}),h=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),c=ae({...h(),sourceProcessing:"inpainting"}),f=ae({...h(),sourceProcessing:"img2img"}),s=we=>we==="Inpainting"?c.value:we==="Img2Img"?f.value:h(),d=ee(()=>s(n.value)),g=ae(""),m=ae(!1),y=ae(!1),b=ae([]),_=ae([]),w=ae(64),S=ee(()=>jt().allowLargerParams==="Enabled"?3072:1024),x=ae(1),T=ae(20),O=ae(1),P=ee(()=>jt().allowLargerParams==="Enabled"?150:50),D=ae(1),j=ae(24),R=ae(0),B=ae(1),E=ae(0),V=ae(1),te=ae(0),J=ae(10),se=ae(1),M=ae(80),U=(we,Me,Le)=>Array.from({length:(Me-we+1)/Le},(Ue,nt)=>(nt+we)*Le),A=ae(U(te.value,J.value,1)),L=ae(U(D.value,j.value,.5)),Q=ee(()=>{const we=(bn,Pn,Dr=1)=>bn*(Pn.state==="Multiple"&&Pn.selected.length>0?Pn.selected.length:Dr),Le=o.value.n*Y().length,Ue=we(Le,u.value.sampler),nt=we(Ue,u.value.scheduler),Qe=we(nt,u.value.steps),ht=we(Qe,u.value.guidance);return we(ht,u.value.clipSkip)});function N(){return o.value=td(),c.value=h(),f.value=h(),b.value=[],Vt().showGeneratedImages=!1,I(),!0}function I(){_.value=[]}function W(){b.value=[]}async function q(){const we=jt(),Me=we.baseURL.length===0?".":we.baseURL,Le=await fetch(`${Me}/sdapi/v1/loras`),Ue=await Le.json();return Fu(Le,Ue,200,"Failed to get available LoRAs")?Ue:[]}async function re(we){if(!e.includes(we))return[];if(r.value==="")return me("Failed to generate: No prompt submitted.");const Me=Os(),Le=Vt();Me.saveImages();const{sourceImage:Ue,maskImage:nt,sourceProcessing:Qe}=s(we);Oe(r.value);const ht=[],bn=Y().map(rt=>{const Nt=rt.split(" ### ");return{full_prompt:rt,prompt:Nt[0],negative_prompt:Nt[1]||""}}).map(rt=>{const[Nt,Br]=LK(rt.prompt);return{...rt,prompt:Nt,extractedLoras:Br}}),Pn=bn.some(rt=>rt.extractedLoras.length>0)?await q():[],Dr=bn.map(({extractedLoras:rt,...Nt})=>{const Br=rt.length>0&&Pn.length>0?rt.map(er=>{const Ya=Pn.find(Gt=>Gt.name===er.name||Gt.path===er.name);return{path:Ya?Ya.path:er.name,multiplier:er.multiplier,...er.is_high_noise?{is_high_noise:!0}:{}}}):[];return{...Nt,...Br.length>0?{lora:Br}:{}}}),{seed:mr,cfg_scale:ym,eta:$r,steps:uC,clip_skip:cC,sampler_name:fC,scheduler:dC,n:hC,...bm}=o.value,tf=parseInt(mr.toString()),pC=isNaN(tf)||tf<0?iC():tf,mC=Array.from({length:hC},(rt,Nt)=>pC+Nt),Wa=(rt,Nt)=>rt.state==="Disabled"?[]:rt.state==="Enabled"?[Nt]:rt.state==="Multiple"&&rt.selected.length===0?[]:rt.selected,gC={promptVariant:Dr,seed:mC,cfg_scale:Wa(u.value.guidance,ym),eta:Wa(u.value.eta,$r),steps:Wa(u.value.steps,uC),clip_skip:Wa(u.value.clipSkip,cC),sampler_name:Wa(u.value.sampler,fC),scheduler:Wa(u.value.scheduler,dC)},vC=(rt=>Object.entries(rt).filter(([Br,er])=>er.length>0).reduce((Br,[er,Ya])=>{const Gt=[];for(const bC of Br)for(const _C of Ya)Gt.push({...bC,[er]:_C});return Gt},[{}]))(gC),yC=[await G()];for(const rt of vC){const{promptVariant:{full_prompt:Nt,...Br},...er}=rt,Ya=we==="Img2Img"?bm.send_as_refimg:!1;let Gt={prompt:Nt,params:{...bm,send_as_refimg:Ya,...er,...Br,init_images:Ue?[Ue.split(",")[1]]:[],mask:nt,inpainting_mask_invert:nt?0:null,inpainting_fill:nt?1:null},source_image:Ue==null?void 0:Ue.split(",")[1],source_mask:nt,source_processing:Qe,models:yC};Gt.params.sampler_name=="default"&&delete Gt.params.sampler_name,Gt.params.scheduler=="default"&&delete Gt.params.scheduler,Gt.params.frames&&Gt.params.frames<=1&&delete Gt.params.frames,Se&&Se.length>0&&(Gt.params.extra_images=Se),jt().alsoRequestAvi==="Enabled"&&Gt.params.frames&&Gt.params.frames>1&&(Gt.params.video_output_type=2),ht.push(Gt)}let _m=!1;m.value||(_m=!0,b.value=[]),m.value=!0,Le.showGeneratedImages=!1;let wm=_.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(Nt=>!Nt.gathered&&!Nt.failed);if(!rt)break;rt.gathered=!0;try{const Nt=await $(rt.params);if(!Nt){rt.failed=!0;continue}de([{...Nt,...rt}])}catch(Nt){rt.failed=!0,console.error("Error fetching image:",Nt)}}}async function de(we){const Me=Aa();console.log(we);const Le=await Promise.all(we.map(async Qe=>{const ht=Qe.images[0],bn=!!Qe.animated?"gif":"png",Pn=Qe.extra_data?`data:video/avi;base64,${Qe.extra_data}`:"";let Dr={id:-1,image:`data:image/${bn};base64,${ht}`,prompt:Qe.prompt,modelName:Qe.models[0],frames:Qe.params.frames,extra_avi:Pn,enable_hr:Qe.params.enable_hr,send_as_refimg:Qe.params.send_as_refimg};if(Qe.info&&typeof Qe.info=="string"&&Qe.info.trim()!=="")try{const mr=JSON.parse(Qe.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip"].forEach($r=>{mr[$r]!=null&&mr[$r]!=null?Dr[$r]=mr[$r]:Qe.params[$r]!=null&&(Dr[$r]=Qe.params[$r])}),mr.extra_generation_params&&mr.extra_generation_params["Schedule type"]?Dr.scheduler=mr.extra_generation_params["Schedule type"]:Dr.scheduler=Qe.params.scheduler}catch(mr){console.warn("Failed to parse info JSON:",mr)}return Dr})),Ue=await Me.pushOutputs(Le),nt=0;return b.value=[...Ue.map(Qe=>({type:"image",index:nt,output:Qe})),...b.value].sort((Qe,ht)=>Qe.index-ht.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,Vt().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Le}async function me(we){const Me=Vt();return we&&Me.raiseError(we,!1),[]}function ve(we,Me,Le,Ue){return Me<=Le?Me:(Vt().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${we}' to its default value instead of ${Me}.`,!0),Ue)}async function H(we,Me=!0){const Le=td();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",Ms.push("/"),Me&&(we.width=we.width||Le.width,we.height=we.height||Le.height),we.prompt){const Ue=we.prompt.split(" ### ");r.value=Ue[0],l.value=Ue[1]||""}if(we.sampler_name){o.value.sampler_name=we.sampler_name;const nt=(await ie()).find(Qe=>Qe.aliases&&Qe.aliases.includes(we.sampler_name));nt&&(o.value.sampler_name=nt.name)}we.steps&&(o.value.steps=ve("steps",we.steps,P.value,Le.steps)),we.cfg_scale&&(o.value.cfg_scale=we.cfg_scale),(we.eta||we.eta===0)&&(o.value.eta=we.eta),we.width&&(o.value.width=ve("width",we.width,S.value,Le.width)),we.height&&(o.value.height=ve("height",we.height,S.value,Le.height)),we.seed&&(o.value.seed=we.seed),we.clip_skip&&(o.value.clip_skip=ve("clip_skip",we.clip_skip,J.value,Le.clip_skip)),we.scheduler&&(o.value.scheduler=we.scheduler),we.frames&&(o.value.frames=ve("frames",we.frames,M.value,Le.frames))}function K(we){const Me=Os();n.value="Img2Img",f.value.sourceImage=we,Me.drawing=!1,b.value=[],Ms.push("/"),Hn.fabric.Image.fromURL(we,Me.newImage)}function k(we){const Me=Os();b.value=[],c.value.sourceImage=we,n.value="Inpainting",Ms.push("/"),Hn.fabric.Image.fromURL(we,Me.newImage)}function X(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function Y(){const we=X(),Me=we.match(/\{(.*?)\}/g)||[];if(Me.length===0)return[we];let Le=[];return Me.forEach(Ue=>{const nt=[],Qe=Ue.replace("{","").replace("}","").split("|");Le.length===0?Qe.forEach(ht=>{const en=we.replace(Ue,ht);nt.push(en)}):Le.forEach(ht=>{Qe.forEach(en=>{const bn=ht.replace(Ue,en);nt.push(bn)})}),Le=[...nt]}),Le}async function $(we){const Me=jt();try{const Le=await fetch(`${Me.baseURL.length===0?".":Me.baseURL}/sdapi/v1/${we.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)}),Ue=await Le.json();return Fu(Le,Ue,200,"Failed to fetch",F)?Ue:!1}catch{return!1}}function F(we){return Vt().raiseError(we,!1),y.value=!1,b.value=[],!1}async function G(){const we=jt(),Me=await fetch(`${we.baseURL.length===0?".":we.baseURL}/sdapi/v1/sd-models`),Le=await Me.json();if(!!Fu(Me,Le,200,"Failed to get available models"))return Le.length===0?"(No model loaded)":Le[0].model_name}const fe=ae(0),oe=new Map;function Z(){oe.clear(),fe.value++}Te(()=>jt().baseURL,()=>{Z()});async function pe(we){const Me=jt(),Ue=((Me.baseURL.length===0?".":Me.baseURL).replace(/\/+$/,"")||".")+"/"+we.replace(/^\/+/,"");if(oe.has(Ue))return oe.get(Ue);const nt=(async()=>{try{const Qe=await fetch(Ue);if(Qe.ok)return await Qe.json();console.error(`API Error: ${Qe.status} ${Qe.statusText} at ${Ue}`)}catch(Qe){console.error(`Fetch error for ${Ue}:`,Qe)}return oe.delete(Ue),null})();return oe.set(Ue,nt),nt}async function ie(){const we=await pe("/sdapi/v1/samplers");return Array.isArray(we)?we:[]}async function ge(){const we=await pe("/sdapi/v1/schedulers");return Array.isArray(we)?we:[]}function Ce(we){v.value.indexOf(we)===-1&&(v.value=[...v.value,we])}function Ee(we){v.value=v.value.filter(Me=>Me!=we)}function Oe(we){if(i.value.findIndex(Me=>Me.prompt===we)===-1){if(i.value.length>=10+i.value.filter(Me=>Me.starred).length){const Me=i.value.filter(Ue=>!Ue.starred),Le=i.value.findIndex(Ue=>Ue===Me[Me.length-1]);i.value.splice(Le,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:we}]}}function Ne(we){i.value=i.value.filter(Me=>Me.prompt!=we&&Me!=we)}function _e(){return!1}var Se=[];function Be(we){let Me=we.target;if(Se=[],Me.files.length>0)for(let Le=0;Lenew DataView(new ArrayBuffer(e)),Ha=e=>new Uint8Array(e.buffer||e),uo=e=>new TextEncoder().encode(String(e));function RK(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:uo(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:Ha(e)};if(Symbol.asyncIterator in e)return{t,o:aC(e)};throw new TypeError("Unsupported input format.")}function aC(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=DK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function DK(e){return typeof e=="string"?uo(e):e instanceof Uint8Array?e:Ha(e)}function $K(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=uo(t)),e instanceof File)return{i:t||uo(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(),v=l&&decodeURIComponent(l),o=n||+e.headers.get("content-length");return{i:t||uo(v),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:uo(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 BK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:FK,m:zK}=BK.exports,NK=Ha(zK).subarray(65536);function Iy(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))NK.set(n),t=FK(n.length,t);return t}function oC(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 jK(e){const t=ef(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),oC(e.t,t,10),t.setUint16(26,e.i.length,1),Ha(t)}async function*VK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=Iy(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=Iy(r,e.u),e.A+=r.length,yield r}}}function UK(e){const t=ef(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),Ha(t)}function HK(e,t){const n=ef(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),oC(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),Ha(n)}function WK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function YK(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(aC(async function*(r){const i=[];let l=0,v=0;for await(const u of r)yield jK(u),yield u.i,yield*VK(u),yield UK(u),i.push(HK(u,l)),i.push(u.i),v++,l+=46+u.i.length+u.A;let o=0;for(const u of i)yield u,o+=u.length;const a=ef(22);a.setUint32(0,1347093766),a.setUint16(8,v,1),a.setUint16(10,v,1),a.setUint32(12,o,1),a.setUint32(16,l,1),yield Ha(a)}(async function*(r){for await(const i of r){const[l,v]=WK(i);yield Object.assign(RK(...v),$K(...l))}}(e))),{headers:n})}async function sC(e,t=!0,n){const r=jt();t&&Vi({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 ha(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await ha(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await ha(u,"image/gif")}):i.push({name:f+".webp",input:await ha(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await YK(i).blob(),v=document.createElement("a");v.href=URL.createObjectURL(l),v.download="sdui_images.zip",v.click()}async function XK(e,t){const n=jt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await ha(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await ha(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await ha(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)}const KK=ke({__name:"ImageActions",props:{imageData:null,onDelete:null,showDismiss:{type:Boolean}},setup(e){const t=e,n=nn(),r=Aa(),i=()=>{xw.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),Vi({type:"success",message:"Deleted Image"})})},l=()=>{nn().clearOutputs(),Vt().showGeneratedImages=!1,nn().clearQueue()};async function v(o){const a=window.location.origin,u={prompt:o.prompt,width:o.width?o.width:void 0,height:o.height?o.height:void 0,steps:o.steps,cfg_scale:o.cfg_scale,sampler_name:o.sampler_name,model_name:o.modelName,seed:o.seed,clip_skip:o.clip_skip,frames:o.frames,scheduler:o.scheduler,extra_avi:o.extra_avi,enable_hr:o.enable_hr,send_as_refimg:o.send_as_refimg},h=window.location.pathname.replace("images","");let c=`${a}${h}?share=`,f="",s="";for(const[g,m]of Object.entries(u)){if(!m)continue;let y=m;typeof m=="string"?y=encodeURIComponent(m):Array.isArray(m)&&(y=JSON.stringify(m)),f+=`${s}${g}=${y}`,s="&"}c+=btoa(String.fromCharCode.apply(null,Array.from(aK(f)))),await navigator.clipboard.writeText(c),Vi({type:"success",message:"Copied shareable link to clipboard"})}return(o,a)=>(z(),ue(Ve,null,[le(C(pt),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:C(Dc),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(pt),{class:"compact-button",onClick:a[0]||(a[0]=u=>C(XK)(e.imageData.image,`${e.imageData.seed}-${e.imageData.prompt}`)),type:"success",size:"small",icon:C(Us),plain:""},{default:he(()=>[He("Download")]),_:1},8,["icon"]),e.imageData.starred?ye("",!0):(z(),be(C(pt),{key:0,class:"compact-button",onClick:a[1]||(a[1]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(b4),plain:""},{default:he(()=>[He("Star")]),_:1},8,["icon"])),e.imageData.starred?(z(),be(C(pt),{key:1,class:"compact-button",onClick:a[2]||(a[2]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(p_),plain:""},{default:he(()=>[He("Unstar")]),_:1},8,["icon"])):ye("",!0),le(C(pt),{class:"compact-button",onClick:a[3]||(a[3]=u=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:he(()=>[He("Txt2img")]),_:1}),le(C(pt),{class:"compact-button",onClick:a[4]||(a[4]=u=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Img2img")]),_:1}),le(C(pt),{class:"compact-button",onClick:a[5]||(a[5]=u=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Inpaint")]),_:1}),e.showDismiss?(z(),be(C(pt),{key:2,class:"compact-button",onClick:a[6]||(a[6]=u=>l()),type:"success",size:"small",plain:""},{default:he(()=>[He("Dismiss")]),_:1})):ye("",!0),le(C(pt),{class:"compact-button",onClick:a[7]||(a[7]=u=>v(e.imageData)),type:"success",icon:C(R3),size:"small",plain:""},{default:he(()=>[He("Share")]),_:1},8,["icon"])],64))}});const lC=Kt(KK,[["__scopeId","data-v-f69f1ca8"]]),GK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},qK=["src"],ZK={style:{"font-size":"18px","font-weight":"500"}},JK={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},QK={key:0},eG=["onClick"],tG=ke({__name:"ImageDialog",setup(e){const t=Aa(),n=Vt(),r=ae();uM(r,{onSwipeEnd(a,u){u==="RIGHT"&&n.openModalToLeft(),u==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=ae(t.currentOutputs[0]);Te(()=>n.activeModal,async()=>{const a=t.currentOutputs.find(u=>u.id===n.activeModal);if(a)return l.value=a;l.value=await Bt.outputs.get(n.activeModal)||t.currentOutputs[0]});function v(){i.value=!1}function o(){var g,m;if(!((g=l.value)!=null&&g.extra_avi))return;const a=l.value.extra_avi.split(",")[1];if(!a)return;const u=atob(a),h=u.length,c=new Uint8Array(h);for(let y=0;y{var h;return z(),be(C(eF),{"model-value":C(i),width:(h=l.value)==null?void 0:h.width,class:"image-viewer",onClosed:v,"align-center":""},{footer:he(()=>[le(lC,{"image-data":l.value,"on-delete":v},null,8,["image-data"])]),default:he(()=>{var c,f,s,d;return[ne("div",{class:"main-output-container",ref_key:"target",ref:r},[ne("div",GK,[(c=l.value)!=null&&c.image?(z(),ue("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,qK)):ye("",!0)])],512),ne("div",ZK,Pe(((f=l.value.prompt)==null?void 0:f.split("###")[0])||"Unknown Creation"),1),ne("div",JK,[ne("div",null,"Negative Prompt: "+Pe(((s=l.value.prompt)==null?void 0:s.split("###")[1])||"None"),1),ne("span",null,"Model: "+Pe(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Pe(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Pe(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Pe(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Pe(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Pe(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Pe((d=l.value.clip_skip)!=null?d:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Pe(l.value.width||"???")+"x"+Pe(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Pe(l.value.frames||"1"),1),l.value.extra_avi?(z(),ue("span",QK,[He(" - "),ne("a",{href:"#",onClick:it(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,eG)])):ye("",!0)])]}),_:1},8,["model-value","width"])}}});const nG=e=>(oi("data-v-8f4d2380"),e=e(),si(),e),rG=nG(()=>ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)),iG={class:"generator-icons"},aG=ke({__name:"App",setup(e){const n=vp(gp).smallerOrEqual("md"),r=Vt();jt();const i=lk(),l=ae();return Te(()=>i.path,v=>{l.value&&l.value.open(v)}),(v,o)=>(z(),ue(Ve,null,[ne("div",{class:ce({"menu-container":!C(n)})},[le(C(dw),{"default-active":C(i).path,mode:"horizontal",router:!0,ellipsis:!C(n),class:ce(C(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:he(()=>[C(n)?ye("",!0):(z(),be(C(Dp),{key:0,class:"remove-item-styling center-vertical"},{title:he(()=>[rG]),_:1})),le(rs,{isMobile:C(n),index:"/"},{icon:he(()=>[ne("div",iG,[le(C(De),null,{default:he(()=>[le(C(bO))]),_:1}),C(r).showGeneratorBadge?(z(),be(C(De),{key:0,class:"generator-badge",size:10},{default:he(()=>[le(cH)]),_:1})):ye("",!0)])]),title:he(()=>[He("Generate")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/images"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(Z3))]),_:1})]),title:he(()=>[He("Images")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/about"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(c_))]),_:1})]),title:he(()=>[He("About")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/options"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(P4))]),_:1})]),title:he(()=>[He("Options")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/return"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(o_))]),_:1})]),title:he(()=>[He("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:ce({view:!C(n)})},[le(C(a_))],2),le(tG)],64))}});const oG=Kt(aG,[["__scopeId","data-v-8f4d2380"]]);const vm=Jx(oG);vm.use(tT());vm.use(Ms);vm.mount("#app");Ms.replace("/");window.addEventListener("beforeunload",e=>{nn().generating&&(e.preventDefault(),e.returnValue="")});const sG={key:1,class:"image-action"},lG=ke({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=Vt(),r=ae(null);NI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=ae(!1);lM(r,([{isIntersecting:v}])=>{v&&(i.value=v)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(v,o)=>(z(),ue("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(z(),be(C(Lp),{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:je(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):ye("",!0),i.value?(z(),ue("div",sG,[e.imageData.starred?(z(),be(C(De),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:he(()=>[le(C(p_))]),_:1})):ye("",!0),C(n).multiSelect?(z(),ue("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[le(C(De),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:he(()=>[C(l)?ye("",!0):(z(),be(C(wl),{key:0})),C(l)?(z(),be(C(l_),{key:1})):ye("",!0)]),_:1},8,["color"])])):ye("",!0)])):ye("",!0)],512))}});const My=Kt(lG,[["__scopeId","data-v-b9569bbd"]]);function uG({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=Q_(),i=ee(()=>r.value<=e),l=ae(!0),{y:v}=sM(window);let o=v.value,a=0;return Te(v,u=>{if(!i.value)return;const h=u-o;if(o=u,h>0&&u>t){a+=h,a>=n&&(l.value=!1,a=0);return}h<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const cG={},fG={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},dG=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),hG=[dG];function pG(e,t){return z(),ue("svg",fG,hG)}const mG=Kt(cG,[["render",pG]]),gG=e=>(oi("data-v-b39b47c5"),e=e(),si(),e),vG={class:"options"},yG=["onClick"],bG=["onClick"],_G=["onClick"],wG={key:1,class:"center-both",style:{gap:"12px"}},CG={key:2},SG=gG(()=>ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),xG=[SG],TG={key:0},kG={key:0,style:{display:"flex",gap:"8px"}},EG={key:1,class:"images"},OG={key:1},AG=ke({__name:"ImagesView",setup(e){const{width:t}=Q_(),{isVisible:n,isMobile:r}=uG(),i=Aa(),l=jt(),v=Vt();function o(){v.selected=v.selected.filter(d=>!i.currentOutputs.map(g=>g.id).includes(d)),v.selected=[...v.selected,...i.currentOutputs.map(d=>d.id)],v.multiSelect=!0}async function a(){const d=await Bt.outputs.toCollection().primaryKeys();v.selected=d,v.multiSelect=!0}function u(){v.selected=v.selected.filter(d=>!i.currentOutputs.map(g=>g.id).includes(d)),v.selected.length===0&&(v.multiSelect=!1)}function h(){v.selected=[],v.multiSelect=!1}const c=()=>{xw.confirm(`This action will permanently delete ${v.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(v.selected)})};cv(["a","A","ArrowLeft"],v.openModalToLeft),cv(["d","D","ArrowRight"],v.openModalToRight);async function f(){sC(v.selected)}const s=ee(()=>{let d=2;t.value>1440?d=6:t.value>1280?d=5:t.value>768?d=4:t.value>480&&(d=3);const g=[];for(let m=0;m(z(),ue(Ve,null,[ne("div",{class:ce(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[ne("div",vG,[le(C(tu),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[le(C(l4))]),_:1})]),_:1})]),default:he(()=>[(z(),ue(Ve,null,Ft(["Newest","Oldest"],m=>ne("div",{key:m,onClick:()=>C(i).sortBy=m,class:ce(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Pe(m),11,yG)),64))]),_:1}),le(C(tu),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[le(C(c3))]),_:1})]),_:1})]),default:he(()=>[(z(),ue(Ve,null,Ft(["all","favourited","unfavourited","unrated"],m=>ne("div",{key:m,onClick:()=>C(i).filterBy=m,class:ce(`el-select-dropdown__item ${C(i).filterBy===m?"selected":""}`)},Pe(C(i).filterBy===m?"Showing":"Show")+" "+Pe(m),11,bG)),64))]),_:1}),le(C(tu),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[le(mG)]),_:1})]),_:1})]),default:he(()=>[(z(),ue(Ve,null,Ft([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>ne("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:ce(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Pe(m.label),11,_G)),64))]),_:1}),le(C(tu),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[C(v).multiSelect?(z(),be(C(l_),{key:0})):(z(),be(C(wl),{key:1}))]),_:1})]),_:1})]),default:he(()=>[C(v).multiSelect?(z(),ue("div",{key:0,class:"el-select-dropdown__item selected",onClick:g[0]||(g[0]=(...m)=>C(v).toggleMultiSelect&&C(v).toggleMultiSelect(...m))},"Disable multi-select")):(z(),ue("div",{key:1,class:"el-select-dropdown__item",onClick:g[1]||(g[1]=(...m)=>C(v).toggleMultiSelect&&C(v).toggleMultiSelect(...m))},"Enable multi-select")),C(v).selected.length>0?(z(),ue("div",{key:2,class:"el-select-dropdown__item selected",onClick:h},"Deselect All")):(z(),ue("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),C(v).selected.every(m=>!C(i).currentOutputs.map(y=>y.id).includes(m))?(z(),ue("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(z(),ue("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(z(),be(C(x9),{key:0,layout:"prev, pager, next",total:C(i).outputsLength,"page-size":C(l).pageSize,"current-page":C(i).currentPage,"onUpdate:currentPage":g[2]||(g[2]=m=>C(i).currentPage=m),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):ye("",!0),C(v).multiSelect?(z(),ue("div",wG,[ne("div",null,Pe(C(v).selected.length)+" selected",1),le(C(pt),{type:"danger",onClick:c,icon:C(Dc),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(pt),{type:"success",onClick:f,icon:C(Us),plain:"",style:{margin:"0"}},{default:he(()=>[He("Download")]),_:1},8,["icon"])])):(z(),ue("div",CG,xG))],2),C(i).outputsLength!=0?(z(),ue("div",TG,[C(i).currentLayout==="dynamic"?(z(),ue("div",kG,[(z(!0),ue(Ve,null,Ft(C(s),(m,y)=>(z(),ue("div",{key:y,style:{flex:"1 1 0%"}},[(z(!0),ue(Ve,null,Ft(m,b=>(z(),be(My,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ye("",!0),C(i).currentLayout==="grid"?(z(),ue("div",EG,[(z(!0),ue(Ve,null,Ft(C(i).currentOutputs,m=>(z(),be(My,{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(),ue("div",OG,[le(C(XF),{description:"No Images Found"})])):ye("",!0)],64))}});const PG=Kt(AG,[["__scopeId","data-v-b39b47c5"]]),IG=Object.freeze(Object.defineProperty({__proto__:null,default:PG},Symbol.toStringTag,{value:"Module"})),MG=["href"],LG=ke({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=yt("router-link");return z(),ue(Ve,null,[e.router?ye("",!0):(z(),ue("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[xe(t.$slots,"default",{},void 0,!0)],8,MG)),e.router?(z(),be(r,{key:1,to:e.href},{default:he(()=>[xe(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ye("",!0)],64)}}});const RG=Kt(LG,[["__scopeId","data-v-17b53b7d"]]),zl=e=>(oi("data-v-ecc278c5"),e=e(),si(),e),DG={class:"about"},$G={class:"about-content"},BG=zl(()=>ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),FG=zl(()=>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)),zG=zl(()=>ne("br",null,null,-1)),NG=zl(()=>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)),jG=zl(()=>ne("br",null,null,-1)),VG=ke({__name:"AboutView",setup(e){return(t,n)=>(z(),ue("div",DG,[ne("div",$G,[BG,FG,zG,NG,jG,ne("div",null,[He("You can find the KoboldAI community and authors of this fork on the "),le(RG,{href:"https://koboldai.org/discord"},{default:he(()=>[He("KoboldAI Discord")]),_:1})])])]))}});const UG=Kt(VG,[["__scopeId","data-v-ecc278c5"]]),HG=Object.freeze(Object.defineProperty({__proto__:null,default:UG},Symbol.toStringTag,{value:"Module"}));const no=ke({__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,v)=>(z(),be(C(Mi),{prop:e.prop},{label:he(()=>[le(Rl,{info:e.info,"label-style":e.labelStyle},{default:he(()=>[xe(l.$slots,"label",{},()=>[He(Pe(e.label),1)])]),_:3},8,["info","label-style"])]),default:he(()=>[le(C(j$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:he(()=>[(z(!0),ue(Ve,null,Ft(e.options,o=>(z(),be(C(V$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),xe(l.$slots,"inline")]),_:3},8,["prop"]))}}),Go=e=>(oi("data-v-0345ee1f"),e=e(),si(),e),WG=Go(()=>ne("h1",null,"Options",-1)),YG=Go(()=>ne("h2",null,"Generation Options",-1)),XG=Go(()=>ne("h3",null,"Parameter Controls",-1)),KG=Go(()=>ne("h2",null,"Image Options",-1)),GG=Go(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),qG=Go(()=>ne("h2",null,"General Options",-1)),ZG=ke({__name:"OptionsView",setup(e){const t=jt(),n=Aa(),r=nn(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=ae([]),v=ae(),o=ae(!1),a=ae(0);async function u(c){n.importFromZip(c),v.value.clearFiles()}async function h(){Vi({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const c=await Bt.outputs.toCollection().primaryKeys();await sC(c,!1,()=>{a.value++}),o.value=!1,a.value=0}return(c,f)=>(z(),ue(Ve,null,[WG,le(C(Mp),{"label-position":"top",model:C(t).options,onSubmit:f[10]||(f[10]=it(()=>{},["prevent"]))},{default:he(()=>[le(C(Kj),{type:"border-card",style:{"min-height":"50vh"}},{default:he(()=>[le(C(Af),{label:"\u{1F5A8}\uFE0F Generation"},{default:he(()=>[YG,le(C(Mi),{label:"Base URL"},{default:he(()=>[le(C(ja),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":f[0]||(f[0]=s=>C(t).baseURL=s)},null,8,["modelValue"])]),_:1}),XG,(z(!0),ue(Ve,null,Ft(C(r).multiSelect,(s,d)=>{var g;return z(),ue("div",{key:d},[le(no,{label:s.name,prop:"pageless",modelValue:s.state,"onUpdate:modelValue":m=>s.state=m,options:(g=s.allowedStates)!=null?g:[]},null,8,["label","modelValue","onUpdate:modelValue","options"])])}),128)),le(no,{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(lo,{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(no,{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(Af),{label:"\u{1F4F7} Images"},{default:he(()=>[KG,le(wn,{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(no,{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(no,{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(no,{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(Mi),{label:"Export Images (ZIP File)"},{default:he(()=>[o.value?(z(),be(C(pt),{key:1,icon:C(Us),disabled:""},{default:he(()=>[He("Downloading... ("+Pe(a.value)+" / "+Pe(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(z(),be(C(pt),{key:0,icon:C(Us),onClick:f[8]||(f[8]=s=>h())},{default:he(()=>[He("Download "+Pe(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),le(C(Mi),{label:"Import Images (ZIP File)"},{default:he(()=>[le(C(Fp),{drag:"",ref_key:"upload",ref:v,"auto-upload":!1,onChange:u,"file-list":l.value,limit:1,multiple:""},{default:he(()=>[le(C(De),{size:100},{default:he(()=>[le(C(np))]),_:1}),GG]),_:1},8,["file-list"])]),_:1})]),_:1}),le(C(Af),{label:"\u2699\uFE0F General"},{default:he(()=>[qG,le(lo,{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 JG=Kt(ZG,[["__scopeId","data-v-0345ee1f"]]),QG=Object.freeze(Object.defineProperty({__proto__:null,default:JG},Symbol.toStringTag,{value:"Module"})); +`&&d>0?(c=0,f++,h++):!this.splitByGrapheme&&this._reSpaceAndTab.test(u.graphemeText[f])&&d>0&&(c++,f++),s[d]={line:h,offset:c},f+=u.graphemeLines[d].length,c+=u.graphemeLines[d].length;return s},styleHas:function(u,h){if(this._styleMap&&!this.isWrapping){var c=this._styleMap[h];c&&(h=c.line)}return a.Text.prototype.styleHas.call(this,u,h)},isEmptyStyles:function(u){if(!this.styles)return!0;var h=0,c=u+1,f,s,d=!1,g=this._styleMap[u],m=this._styleMap[u+1];g&&(u=g.line,h=g.offset),m&&(c=m.line,d=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>=h&&(!d||bc&&!O?(g.push(m),m=[],s=S,O=!0):s+=P,!O&&!d&&m.push(w),m=m.concat(b),x=d?0:this._measureWord([w],h,_),_++,O=!1,S>T&&(T=S);return j&&g.push(m),T+D>this.dynamicMinWidth&&(this.dynamicMinWidth=T-P+D),g},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 h=a.Text.prototype._splitTextIntoLines.call(this,u),c=this._wrapText(h.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=ae({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=ae({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>nn().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>nn().currentImageProps),v=ee({get:()=>i.value.drawing&&!r.value,set:A=>i.value.drawing=A}),o=ae(512),a=ae(512),u=ae(!1),h=ae(30),c=ae(!1),f=new Hn.fabric.Circle({radius:h.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=ae("Erase"),d=ae("rgb(0, 0, 0, 1)");function g(){!i.value.canvas||i.value.canvas.renderAll()}function m(){u.value=!u.value,s.value=u.value?"Draw":"Erase"}function y(A=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=A||i.value.brush.color,i.value.brush.width=h.value)}async function b({history:A,erase:L=!1,draw:Q=!1}={}){if(!A||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;A.path.selectable=!1,A.path.opacity=1,A.drawPath=await se(A.path),A.visibleDrawPath=await se(A.path),L?(A.visibleDrawPath.globalCompositeOperation="destination-out",A.drawPath.stroke=i.value.maskBackgroundColor):(A.visibleDrawPath.globalCompositeOperation="source-over",A.drawPath.stroke=Q?d.value:i.value.maskPathColor);let N=await se(A.drawPath);N=N.scale(i.value.imageScale),N.left=N.left+A.drawPath.left*(i.value.imageScale-1),N.top=N.top+A.drawPath.top*(i.value.imageScale-1),Q?(i.value.imageLayer.add(N),i.value.visibleImageLayer.addWithUpdate(A.visibleDrawPath)):(i.value.drawLayer.add(N),i.value.visibleDrawLayer.addWithUpdate(A.visibleDrawPath)),i.value.canvas.remove(A.path),g()}function _(){if(i.value.undoHistory.length===0)return;const A=i.value.undoHistory.pop();b({history:A,erase:!1,draw:v.value}),i.value.redoHistory.push(A)}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 A=i.value.redoHistory.pop();i.value.undoHistory.push(A),v.value?(i.value.imageLayer.remove(A.drawPath),i.value.visibleImageLayer.remove(A.visibleDrawPath)):(i.value.drawLayer.remove(A.drawPath),i.value.visibleDrawLayer.remove(A.visibleDrawPath)),delete A.drawPath,delete A.visibleDrawPath,g()}function S(A){i.value.canvas=new Hn.fabric.Canvas(A,{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",U),i.value.canvas.on("path:created",M),g()}function x(A,L,Q,N){let I=N,W=N;return L>Q?(A.scaleToWidth(N),I=N*(a.value/o.value)):(A.scaleToHeight(N),W=N*(o.value/a.value)),{newHeight:I,newWidth:W}}function T(A){const L=nn();if(V(),A.selectable=!1,o.value=A.width,a.value=A.height,o.value>L.maxDimensions||a.value>L.maxDimensions){const{newHeight:N,newWidth:I}=x(A,o.value,a.value,L.maxDimensions);o.value=I,a.value=N}if(o.value{o.value>a.value?i.value.imageScale=o.value/Q:i.value.imageScale=a.value/Q,i.value.imageLayer=B({image:N,layerHeight:N.height,layerWidth:N.width})}),A.cloneAsImage(N=>{if(!i.value.canvas)return;if(o.value!==Q||a.value!==Q){const{newHeight:q,newWidth:re}=x(N,o.value,a.value,Q);o.value=re,a.value=q}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=E(),i.value.visibleImageLayer=E({image:N}),i.value.drawLayer=B();const I=o.value*i.value.imageScale,W=a.value*i.value.imageScale;L.params.width=I-I%64,L.params.height=W-W%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,j(),P()})}function O(A,L,Q,N,I){if(I==="Original"||A.width===L&&A.height===Q)return A;const W=document.createElement("canvas");W.width=L,W.height=Q;const q=W.getContext("2d");q.fillStyle=N,q.fillRect(0,0,W.width,W.height);let re=0,de=0,me=A.width,ve=A.height,H=0,K=0,k=W.width,X=W.height;switch(I){case"Stretch":break;case"ScaleAndCrop":{const Y=W.width/A.width,$=W.height/A.height;Y>$?(ve=W.height/Y,de=(A.height-ve)/2):(me=W.width/$,re=(A.width-me)/2);break}case"ScaleAndPad":{const Y=W.width/A.width,$=W.height/A.height;Y<$?(X=A.height*Y,K=(W.height-X)/2):(k=A.width*$,H=(W.width-k)/2);break}case"NoScale":default:{A.width>W.width?(me=W.width,re=(A.width-W.width)/2):(k=A.width,H=(W.width-A.width)/2),A.height>W.height?(ve=W.height,de=(A.height-W.height)/2):(X=A.height,K=(W.height-A.height)/2);break}}return q.drawImage(A,re,de,me,ve,H,K,k,X),W}function P(){const A=nn(),L=jt();if(!i.value.imageLayer||!i.value.drawLayer)return;const Q=A.params.width,N=A.params.height,I=i.value.imageLayer.backgroundColor||"#FFFFFF",W=L.imageResizeMode,q=i.value.imageLayer.toCanvasElement(),re=O(q,Q,N,I,W);if(l.value.sourceImage=re.toDataURL("image/jpeg",1),l.value.maskImage=void 0,i.value.redoHistory.length>0&&!v.value){const me=i.value.drawLayer.toCanvasElement(),ve=O(me,Q,N,I,W);l.value.maskImage=ve.toDataURL("image/jpeg",1).split(",")[1]}}let D;function j(){if(!i.value.canvas)return;const A=nn();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),c.value&&(i.value.cropPreviewLayer=E({layerWidth:A.params.width/i.value.imageScale,layerHeight:A.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,j(),D=void 0},5e3))}function R(A,L){const Q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";Hn.fabric.Image.fromURL(Q,N=>{N.set({height:A,width:L});const I=N.toDataURL({format:"png"});l.value.sourceImage=I,v.value=!0,T(N)})}function B({image:A,layerWidth:L,layerHeight:Q}={}){const N=new Hn.fabric.Canvas(null);return N.selection=!1,N.backgroundColor=i.value.maskBackgroundColor,N.setHeight(Q||a.value),N.setWidth(L||o.value),A&&N.add(A),N}function E({image:A,layerWidth:L,layerHeight:Q,fill:N,abosolute:I}={}){const W=A||new Hn.fabric.Rect({width:L||o.value,height:Q||a.value,left:0,top:0,fill:N||"transparent",absolutePositioned:I||!0,selectable:!1});return new Hn.fabric.Group([W],{selectable:!1,absolutePositioned:I||!0})}function V(){!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 te(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),v.value){const A=nn();R(A.params.height||512,A.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=E(),i.value.drawLayer=B(),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function J(){var L;P();const A=document.createElement("a");if(v.value){A.href="data:image/png;base64,"+((L=l.value.sourceImage)==null?void 0:L.split(",")[1]),A.download="image_drawing.png",A.click();return}A.href="data:image/png;base64,"+l.value.maskImage,A.download="image_mask.png",A.click()}async function se(A){return new Promise((L,Q)=>{try{A.clone(L)}catch(N){Q(N)}})}async function M(A){const L={path:A.path};b({history:L,erase:u.value,draw:v.value}),i.value.redoHistory.push(L)}function U(A){if(!i.value.canvas)return;const L=i.value.canvas.getPointer(A.e);f.left=L.x,f.top=L.y,f.opacity=.8,u.value?(f.set("strokeWidth",3),f.set("fill",""),y("red")):(f.set("strokeWidth",0),v.value?(f.set("fill",d.value),y(d.value)):(f.set("fill","white"),y("white"))),f.set("radius",h.value/2),g()}return{showCropPreview:c,erasing:u,switchToolText:s,brushSize:h,drawColor:d,drawing:v,imageProps:i,updateCropPreview:j,createNewCanvas:S,downloadMask:J,resetCanvas:V,resetDrawing:te,flipErase:m,undoAction:w,redoAction:_,newImage:T,newBlankImage:R,setBrush:y,saveImages:P}});const nW={},rW={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},iW=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),aW=[iW];function oW(e,t){return z(),ue("svg",rW,aW)}const sW=Kt(nW,[["render",oW]]);async function lW(e,t){const n=document.createElement("canvas"),r=n.getContext("2d"),i=new Image;return i.src=e,await new Promise(v=>i.onload=v),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function uW(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 lW(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let v=0;v{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}const lm=e=>(oi("data-v-d3bd38bf"),e=e(),si(),e),cW=lm(()=>ne("div",null,[He("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1)),fW={key:0},dW=lm(()=>ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),hW={class:"canvas-container"},pW=lm(()=>ne("canvas",{id:"canvas"},null,-1)),mW={class:"action-buttons",style:{left:"10px",right:"unset"}},gW={class:"action-buttons"},vW=ke({__name:"CustomCanvas",setup(e){const t=nn(),n=Vt(),r=Os(),i=ae();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 gh(a.raw);t.currentImageProps.sourceImage=u,r.drawing=!1,Hn.fabric.Image.fromURL(u,r.newImage)}function v(){t.currentImageProps.sourceImage="",r.resetCanvas()}tt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Hn.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Ht(()=>{window.removeEventListener("paste",o)});async function o(a){var h;const u=(h=a.clipboardData)==null?void 0:h.items;if(!!u)for(let c=0;c(z(),ue(Ve,null,[C(t).currentImageProps.sourceImage?ye("",!0):(z(),be(C(Fp),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:he(()=>[C(t).generatorType==="Img2Img"?(z(),ue("div",fW,[dW,ne("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:u[0]||(u[0]=h=>C(r).newBlankImage(C(t).params.height||512,C(t).params.width||512))},[le(C(De),{size:20,style:{"margin-right":"2px"}},{default:he(()=>[le(_2)]),_:1}),He("draw something")])])):ye("",!0)]),default:he(()=>[le(C(De),{size:100},{default:he(()=>[le(C(np))]),_:1}),cW]),_:1},512)),Ct(ne("div",null,[ne("div",hW,[pW,ne("div",mW,[le(C(pt),{onClick:u[1]||(u[1]=h=>C(r).undoAction()),icon:C(d_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),le(C(pt),{onClick:u[2]||(u[2]=h=>C(r).redoAction()),icon:C(h_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",gW,[le(C(pt),{onClick:u[3]||(u[3]=h=>C(r).resetDrawing()),icon:C(Or),plain:""},null,8,["icon"]),le(C(pt),{onClick:v,icon:C(Dc),plain:""},null,8,["icon"]),le(C(pt),{onClick:u[4]||(u[4]=h=>C(r).downloadMask()),icon:C(Us),plain:""},null,8,["icon"]),le(C(pt),{onClick:u[5]||(u[5]=h=>C(r).flipErase()),icon:C(r).erasing?C(i3):sW,plain:""},null,8,["icon"]),C(r).drawing?(z(),be(C($B),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":u[6]||(u[6]=h=>C(r).drawColor=h),"show-alpha":""},null,8,["modelValue"])):ye("",!0)]),le(C(Mp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:he(()=>[le(wn,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:C(r).brushSize,"onUpdate:modelValue":u[7]||(u[7]=h=>C(r).brushSize=h),min:10,max:100,step:10,change:C(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[zt,C(t).currentImageProps.sourceImage]])],64))}});const U0=Kt(vW,[["__scopeId","data-v-d3bd38bf"]]),yW={class:"centerIcons"},bW={class:"stackedIcons"},_W=ke({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return Dx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(z(),ue("div",yW,[ne("div",bW,[le(C(De),{class:"firstIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconOne)))]),_:1},8,["size"]),le(C(De),{class:"secondIcon",size:e.size},{default:he(()=>[(z(),be(kt(t.iconTwo)))]),_:1},8,["size"])])]))}});const wW=Kt(_W,[["__scopeId","data-v-74586a39"]]),CW={key:1,style:{width:"40px"}},cu=ke({__name:"GeneratorMenuItem",props:{index:null,iconOne:null,iconTwo:null,isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(z(),be(C(Lr),{content:e.index,placement:e.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:he(()=>[le(C(Dp),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:he(()=>[e.iconTwo?(z(),be(wW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(z(),ue("div",CW,[le(C(De),{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 SW=4,H0=0,W0=1,xW=2;function Wo(e){let t=e.length;for(;--t>=0;)e[t]=0}const TW=0,S2=1,kW=2,EW=3,OW=258,um=29,Dl=256,cl=Dl+1+um,vo=30,cm=19,x2=2*cl+1,pa=15,jf=16,AW=7,fm=256,T2=16,k2=17,E2=18,vh=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]),Bu=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]),PW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),O2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),IW=512,Xr=new Array((cl+2)*2);Wo(Xr);const As=new Array(vo*2);Wo(As);const fl=new Array(IW);Wo(fl);const dl=new Array(OW-EW+1);Wo(dl);const dm=new Array(um);Wo(dm);const mc=new Array(vo);Wo(mc);function Vf(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 A2,P2,I2;function Uf(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const M2=e=>e<256?fl[e]:fl[256+(e>>>7)],hl=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},xn=(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<{xn(e,n[t*2],n[t*2+1])},L2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},MW=e=>{e.bi_valid===16?(hl(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)},LW=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,v=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let u,h,c,f,s,d,g=0;for(f=0;f<=pa;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;ua&&(f=a,g++),n[h*2+1]=f,!(h>r)&&(e.bl_count[f]++,s=0,h>=o&&(s=v[h-o]),d=n[h*2],e.opt_len+=d*(f+s),l&&(e.static_len+=d*(i[h*2+1]+s)));if(g!==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]--,g-=2}while(g>0);for(f=a;f!==0;f--)for(h=e.bl_count[f];h!==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),h--)}},R2=(e,t,n)=>{const r=new Array(pa+1);let i=0,l,v;for(l=1;l<=pa;l++)i=i+n[l-1]<<1,r[l]=i;for(v=0;v<=t;v++){let o=e[v*2+1];o!==0&&(e[v*2]=L2(r[o]++,o))}},RW=()=>{let e,t,n,r,i;const l=new Array(pa+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?hl(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Y0=(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,v,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?wr(e,i,t):(v=dl[i],wr(e,v+Dl+1,t),o=vh[v],o!==0&&(i-=dm[v],xn(e,i,o)),r--,v=M2(r),wr(e,v,n),o=Bu[v],o!==0&&(r-=mc[v],xn(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 v,o,a=-1,u;for(e.heap_len=0,e.heap_max=x2,v=0;v>1;v>=1;v--)Hf(e,n,v);u=l;do v=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Hf(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=v,e.heap[--e.heap_max]=o,n[u*2]=n[v*2]+n[o*2],e.depth[u]=(e.depth[v]>=e.depth[o]?e.depth[v]:e.depth[o])+1,n[v*2+1]=n[o*2+1]=u,e.heap[1]=u++,Hf(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],LW(e,t),R2(n,a,e.bl_count)},K0=(e,t,n)=>{let r,i=-1,l,v=t[0*2+1],o=0,a=7,u=4;for(v===0&&(a=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=v,v=t[(r+1)*2+1],!(++o{let r,i=-1,l,v=t[0*2+1],o=0,a=7,u=4;for(v===0&&(a=138,u=3),r=0;r<=n;r++)if(l=v,v=t[(r+1)*2+1],!(++o{let t;for(K0(e,e.dyn_ltree,e.l_desc.max_code),K0(e,e.dyn_dtree,e.d_desc.max_code),yh(e,e.bl_desc),t=cm-1;t>=3&&e.bl_tree[O2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},$W=(e,t,n,r)=>{let i;for(xn(e,t-257,5),xn(e,n-1,5),xn(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 H0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return W0;for(n=32;n{q0||(RW(),q0=!0),e.l_desc=new Uf(e.dyn_ltree,A2),e.d_desc=new Uf(e.dyn_dtree,P2),e.bl_desc=new Uf(e.bl_tree,I2),e.bi_buf=0,e.bi_valid=0,D2(e)},B2=(e,t,n,r)=>{xn(e,(TW<<1)+(r?1:0),3),$2(e),hl(e,n),hl(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},zW=e=>{xn(e,S2<<1,3),wr(e,fm,Xr),MW(e)},NW=(e,t,n,r)=>{let i,l,v=0;e.level>0?(e.strm.data_type===xW&&(e.strm.data_type=BW(e)),yh(e,e.l_desc),yh(e,e.d_desc),v=DW(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?B2(e,t,n,r):e.strategy===SW||l===i?(xn(e,(S2<<1)+(r?1:0),3),X0(e,Xr,As)):(xn(e,(kW<<1)+(r?1:0),3),$W(e,e.l_desc.max_code+1,e.d_desc.max_code+1,v+1),X0(e,e.dyn_ltree,e.dyn_dtree)),D2(e),r&&$2(e)},jW=(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[(dl[n]+Dl+1)*2]++,e.dyn_dtree[M2(t)*2]++),e.sym_next===e.sym_end);var VW=FW,UW=B2,HW=NW,WW=jW,YW=zW,XW={_tr_init:VW,_tr_stored_block:UW,_tr_flush_block:HW,_tr_tally:WW,_tr_align:YW};const KW=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,v=0;for(;n!==0;){v=n>2e3?2e3:n,n-=v;do i=i+t[r++]|0,l=l+i|0;while(--v);i%=65521,l%=65521}return i|l<<16|0};var pl=KW;const GW=()=>{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},qW=new Uint32Array(GW()),ZW=(e,t,n,r)=>{const i=qW,l=r+n;e^=-1;for(let v=r;v>>8^i[(e^t[v])&255];return e^-1};var qt=ZW,Pa={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"},Yo={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:JW,_tr_stored_block:bh,_tr_flush_block:QW,_tr_tally:Li,_tr_align:eY}=XW,{Z_NO_FLUSH:Ri,Z_PARTIAL_FLUSH:tY,Z_FULL_FLUSH:nY,Z_FINISH:Wn,Z_BLOCK:Z0,Z_OK:tn,Z_STREAM_END:J0,Z_STREAM_ERROR:kr,Z_DATA_ERROR:rY,Z_BUF_ERROR:Wf,Z_DEFAULT_COMPRESSION:iY,Z_FILTERED:aY,Z_HUFFMAN_ONLY:fu,Z_RLE:oY,Z_FIXED:sY,Z_DEFAULT_STRATEGY:lY,Z_UNKNOWN:uY,Z_DEFLATED:Zc}=Yo,cY=9,fY=15,dY=8,hY=29,pY=256,_h=pY+1+hY,mY=30,gY=19,vY=2*_h+1,yY=15,ut=3,Ai=258,Er=Ai+ut+1,bY=32,Io=42,hm=57,wh=69,Ch=73,Sh=91,xh=103,ma=113,cs=666,gn=1,Xo=2,Ia=3,Ko=4,_Y=3,ga=(e,t)=>(e.msg=Pa[t],t),Q0=e=>e*2-(e>4?9:0),ki=e=>{let t=e.length;for(;--t>=0;)e[t]=0},wY=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 CY=(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))},Bn=(e,t)=>{QW(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ln(e.strm)},vt=(e,t)=>{e.pending_buf[e.pending++]=t},is=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Th=(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=pl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=qt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},F2=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,v=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Er?e.strstart-(e.w_size-Er):0,u=e.window,h=e.w_mask,c=e.prev,f=e.strstart+Ai;let s=u[r+v-1],d=u[r+v];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+v]!==d||u[i+v-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]&&rv){if(e.match_start=t,v=l,l>=o)break;s=u[r+v-1],d=u[r+v]}}while((t=c[t&h])>a&&--n!==0);return v<=e.lookahead?v:e.lookahead},Mo=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Er)&&(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),wY(e),r+=t),e.strm.avail_in===0)break;if(n=Th(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=ut)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Di(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Di(e,e.ins_h,e.window[i+ut-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,v=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,Ln(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&&(Th(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(v===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&&(Th(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===Wn)&&t!==Ri&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,v=t===Wn&&e.strm.avail_in===0&&r===i?1:0,bh(e,e.block_start,r,v),e.block_start+=r,Ln(e.strm)),v?Ia:gn)},Yf=(e,t)=>{let n,r;for(;;){if(e.lookahead=ut&&(e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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-Er&&(e.match_length=F2(e,n)),e.match_length>=ut)if(r=Li(e,e.strstart-e.match_start,e.match_length-ut),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=ut){e.match_length--;do e.strstart++,e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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=Di(e,e.ins_h,e.window[e.strstart+1]);else r=Li(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Bn(e,!1),e.strm.avail_out===0))return gn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=ut&&(e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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=ut-1,n!==0&&e.prev_length4096)&&(e.match_length=ut-1)),e.prev_length>=ut&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-ut,r=Li(e,e.strstart-1-e.prev_match,e.prev_length-ut),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Di(e,e.ins_h,e.window[e.strstart+ut-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=ut-1,e.strstart++,r&&(Bn(e,!1),e.strm.avail_out===0))return gn}else if(e.match_available){if(r=Li(e,0,e.window[e.strstart-1]),r&&Bn(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return gn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Li(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const v=e.window;for(;;){if(e.lookahead<=Ai){if(Mo(e),e.lookahead<=Ai&&t===Ri)return gn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=ut&&e.strstart>0&&(i=e.strstart-1,r=v[i],r===v[++i]&&r===v[++i]&&r===v[++i])){l=e.strstart+Ai;do;while(r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&r===v[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=ut?(n=Li(e,1,e.match_length-ut),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Li(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Bn(e,!1),e.strm.avail_out===0))return gn}return e.insert=0,t===Wn?(Bn(e,!0),e.strm.avail_out===0?Ia:Ko):e.sym_next&&(Bn(e,!1),e.strm.avail_out===0)?gn:Xo},xY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Mo(e),e.lookahead===0)){if(t===Ri)return gn;break}if(e.match_length=0,n=Li(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Bn(e,!1),e.strm.avail_out===0))return gn}return e.insert=0,t===Wn?(Bn(e,!0),e.strm.avail_out===0?Ia:Ko):e.sym_next&&(Bn(e,!1),e.strm.avail_out===0)?gn:Xo};function vr(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 fs=[new vr(0,0,0,0,z2),new vr(4,4,8,4,Yf),new vr(4,5,16,8,Yf),new vr(4,6,32,32,Yf),new vr(4,4,16,16,eo),new vr(8,16,32,32,eo),new vr(8,16,128,128,eo),new vr(8,32,128,256,eo),new vr(32,128,258,1024,eo),new vr(32,258,258,4096,eo)],TY=e=>{e.window_size=2*e.w_size,ki(e.head),e.max_lazy_match=fs[e.level].max_lazy,e.good_match=fs[e.level].good_length,e.nice_match=fs[e.level].nice_length,e.max_chain_length=fs[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=ut-1,e.match_available=0,e.ins_h=0};function kY(){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=Zc,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(vY*2),this.dyn_dtree=new Uint16Array((2*mY+1)*2),this.bl_tree=new Uint16Array((2*gY+1)*2),ki(this.dyn_ltree),ki(this.dyn_dtree),ki(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(yY+1),this.heap=new Uint16Array(2*_h+1),ki(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*_h+1),ki(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 $l=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Io&&t.status!==hm&&t.status!==wh&&t.status!==Ch&&t.status!==Sh&&t.status!==xh&&t.status!==ma&&t.status!==cs?1:0},N2=e=>{if($l(e))return ga(e,kr);e.total_in=e.total_out=0,e.data_type=uY;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?hm:t.wrap?Io:ma,e.adler=t.wrap===2?0:1,t.last_flush=-2,JW(t),tn},j2=e=>{const t=N2(e);return t===tn&&TY(e.state),t},EY=(e,t)=>$l(e)||e.state.wrap!==2?kr:(e.state.gzhead=t,tn),V2=(e,t,n,r,i,l)=>{if(!e)return kr;let v=1;if(t===iY&&(t=6),r<0?(v=0,r=-r):r>15&&(v=2,r-=16),i<1||i>cY||n!==Zc||r<8||r>15||t<0||t>9||l<0||l>sY||r===8&&v!==1)return ga(e,kr);r===8&&(r=9);const o=new kY;return e.state=o,o.strm=e,o.status=Io,o.wrap=v,o.gzhead=null,o.w_bits=r,o.w_size=1<V2(e,t,Zc,fY,dY,lY),AY=(e,t)=>{if($l(e)||t>Z0||t<0)return e?ga(e,kr):kr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===cs&&t!==Wn)return ga(e,e.avail_out===0?Wf:kr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Ln(e),e.avail_out===0)return n.last_flush=-1,tn}else if(e.avail_in===0&&Q0(t)<=Q0(r)&&t!==Wn)return ga(e,Wf);if(n.status===cs&&e.avail_in!==0)return ga(e,Wf);if(n.status===Io&&n.wrap===0&&(n.status=ma),n.status===Io){let i=Zc+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=fu||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=bY),i+=31-i%31,is(n,i),n.strstart!==0&&(is(n,e.adler>>>16),is(n,e.adler&65535)),e.adler=1,n.status=ma,Ln(e),n.pending!==0)return n.last_flush=-1,tn}if(n.status===hm){if(e.adler=0,vt(n,31),vt(n,139),vt(n,8),n.gzhead)vt(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)),vt(n,n.gzhead.time&255),vt(n,n.gzhead.time>>8&255),vt(n,n.gzhead.time>>16&255),vt(n,n.gzhead.time>>24&255),vt(n,n.level===9?2:n.strategy>=fu||n.level<2?4:0),vt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(vt(n,n.gzhead.extra.length&255),vt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=qt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=wh;else if(vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,n.level===9?2:n.strategy>=fu||n.level<2?4:0),vt(n,_Y),n.status=ma,Ln(e),n.pending!==0)return n.last_flush=-1,tn}if(n.status===wh){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=qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,Ln(e),n.pending!==0)return n.last_flush=-1,tn;i=0,l-=o}let v=new Uint8Array(n.gzhead.extra);n.pending_buf.set(v.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Ch}if(n.status===Ch){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=qt(e.adler,n.pending_buf,n.pending-i,i)),Ln(e),n.pending!==0)return n.last_flush=-1,tn;i=0}n.gzindexi&&(e.adler=qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Sh}if(n.status===Sh){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=qt(e.adler,n.pending_buf,n.pending-i,i)),Ln(e),n.pending!==0)return n.last_flush=-1,tn;i=0}n.gzindexi&&(e.adler=qt(e.adler,n.pending_buf,n.pending-i,i))}n.status=xh}if(n.status===xh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ln(e),n.pending!==0))return n.last_flush=-1,tn;vt(n,e.adler&255),vt(n,e.adler>>8&255),e.adler=0}if(n.status=ma,Ln(e),n.pending!==0)return n.last_flush=-1,tn}if(e.avail_in!==0||n.lookahead!==0||t!==Ri&&n.status!==cs){let i=n.level===0?z2(n,t):n.strategy===fu?xY(n,t):n.strategy===oY?SY(n,t):fs[n.level].func(n,t);if((i===Ia||i===Ko)&&(n.status=cs),i===gn||i===Ia)return e.avail_out===0&&(n.last_flush=-1),tn;if(i===Xo&&(t===tY?eY(n):t!==Z0&&(bh(n,0,0,!1),t===nY&&(ki(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Ln(e),e.avail_out===0))return n.last_flush=-1,tn}return t!==Wn?tn:n.wrap<=0?J0:(n.wrap===2?(vt(n,e.adler&255),vt(n,e.adler>>8&255),vt(n,e.adler>>16&255),vt(n,e.adler>>24&255),vt(n,e.total_in&255),vt(n,e.total_in>>8&255),vt(n,e.total_in>>16&255),vt(n,e.total_in>>24&255)):(is(n,e.adler>>>16),is(n,e.adler&65535)),Ln(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?tn:J0)},PY=e=>{if($l(e))return kr;const t=e.state.status;return e.state=null,t===ma?ga(e,rY):tn},IY=(e,t)=>{let n=t.length;if($l(e))return kr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==Io||r.lookahead)return kr;if(i===1&&(e.adler=pl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(ki(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,v=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Mo(r);r.lookahead>=ut;){let a=r.strstart,u=r.lookahead-(ut-1);do r.ins_h=Di(r,r.ins_h,r.window[a+ut-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=ut-1,Mo(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=ut-1,r.match_available=0,e.next_in=v,e.input=o,e.avail_in=l,r.wrap=i,tn};var MY=OY,LY=V2,RY=j2,DY=N2,$Y=EY,BY=AY,FY=PY,zY=IY,NY="pako deflate (from Nodeca project)",Ps={deflateInit:MY,deflateInit2:LY,deflateReset:RY,deflateResetKeep:DY,deflateSetHeader:$Y,deflate:BY,deflateEnd:FY,deflateSetDictionary:zY,deflateInfo:NY};const jY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var VY=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)jY(n,r)&&(e[r]=n[r])}}return e},UY=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;ml[254]=ml[254]=1;var HY=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,v=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 WY=(e,t)=>{if(t<65534&&e.subarray&&U2)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(v&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}v<65536?l[i++]=v:(v-=65536,l[i++]=55296|v>>10&1023,l[i++]=56320|v&1023)}return WY(l,i)},XY=(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+ml[e[n]]>t?n:t},gl={string2buf:HY,buf2string:YY,utf8border:XY};function KY(){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 H2=KY;const W2=Object.prototype.toString,{Z_NO_FLUSH:GY,Z_SYNC_FLUSH:qY,Z_FULL_FLUSH:ZY,Z_FINISH:JY,Z_OK:gc,Z_STREAM_END:QY,Z_DEFAULT_COMPRESSION:eX,Z_DEFAULT_STRATEGY:tX,Z_DEFLATED:nX}=Yo;function Bl(e){this.options=Jc.assign({level:eX,method:nX,chunkSize:16384,windowBits:15,memLevel:8,strategy:tX},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 H2,this.strm.avail_out=0;let n=Ps.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==gc)throw new Error(Pa[n]);if(t.header&&Ps.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=gl.string2buf(t.dictionary):W2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Ps.deflateSetDictionary(this.strm,r),n!==gc)throw new Error(Pa[n]);this._dict_set=!0}}Bl.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?JY:GY,typeof e=="string"?n.input=gl.string2buf(e):W2.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===qY||l===ZY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=Ps.deflate(n,l),i===QY)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Ps.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===gc;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};Bl.prototype.onData=function(e){this.chunks.push(e)};Bl.prototype.onEnd=function(e){e===gc&&(this.result=Jc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function pm(e,t){const n=new Bl(t);if(n.push(e,!0),n.err)throw n.msg||Pa[n.err];return n.result}function rX(e,t){return t=t||{},t.raw=!0,pm(e,t)}function iX(e,t){return t=t||{},t.gzip=!0,pm(e,t)}var aX=Bl,oX=pm,sX=rX,lX=iX,uX=Yo,cX={Deflate:aX,deflate:oX,deflateRaw:sX,gzip:lX,constants:uX};const du=16209,fX=16191;var dX=function(t,n){let r,i,l,v,o,a,u,h,c,f,s,d,g,m,y,b,_,w,S,x,T,O,P,D;const j=t.state;r=t.next_in,P=t.input,i=r+(t.avail_in-5),l=t.next_out,D=t.output,v=l-(n-t.avail_out),o=l+(t.avail_out-257),a=j.dmax,u=j.wsize,h=j.whave,c=j.wnext,f=j.window,s=j.hold,d=j.bits,g=j.lencode,m=j.distcode,y=(1<>>24,s>>>=w,d-=w,w=_>>>16&255,w===0)D[l++]=_&65535;else if(w&16){S=_&65535,w&=15,w&&(d>>=w,d-=w),d<15&&(s+=P[r++]<>>24,s>>>=w,d-=w,w=_>>>16&255,w&16){if(x=_&65535,w&=15,da){t.msg="invalid distance too far back",j.mode=du;break e}if(s>>>=w,d-=w,w=l-v,x>w){if(w=x-w,w>h&&j.sane){t.msg="invalid distance too far back",j.mode=du;break e}if(T=0,O=f,c===0){if(T+=u-w,w2;)D[l++]=O[T++],D[l++]=O[T++],D[l++]=O[T++],S-=3;S&&(D[l++]=O[T++],S>1&&(D[l++]=O[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,d-=S<<3,s&=(1<{const a=o.bits;let u=0,h=0,c=0,f=0,s=0,d=0,g=0,m=0,y=0,b=0,_,w,S,x,T,O=null,P;const D=new Uint16Array(to+1),j=new Uint16Array(to+1);let R=null,B,E,V;for(u=0;u<=to;u++)D[u]=0;for(h=0;h=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===ny||f!==1))return-1;for(j[1]=0,u=1;uey||e===ry&&y>ty)return 1;for(;;){B=u-g,v[h]+1=P?(E=R[v[h]-P],V=O[v[h]-P]):(E=32+64,V=0),_=1<>g)+w]=B<<24|E<<16|V|0;while(w!==0);for(_=1<>=1;if(_!==0?(b&=_-1,b+=_):b=0,h++,--D[u]===0){if(u===f)break;u=t[n+v[h]]}if(u>s&&(b&x)!==S){for(g===0&&(g=s),T+=c,d=u-g,m=1<ey||e===ry&&y>ty)return 1;S=b&x,i[S]=s<<24|d<<16|T-l|0}}return b!==0&&(i[T+b]=u-g<<24|64<<16|0),o.bits=s,0};var Is=vX;const yX=0,Y2=1,X2=2,{Z_FINISH:iy,Z_BLOCK:bX,Z_TREES:hu,Z_OK:Ma,Z_STREAM_END:_X,Z_NEED_DICT:wX,Z_STREAM_ERROR:Zn,Z_DATA_ERROR:K2,Z_MEM_ERROR:G2,Z_BUF_ERROR:CX,Z_DEFLATED:ay}=Yo,Qc=16180,oy=16181,sy=16182,ly=16183,uy=16184,cy=16185,fy=16186,dy=16187,hy=16188,py=16189,vc=16190,jr=16191,Kf=16192,my=16193,Gf=16194,gy=16195,vy=16196,yy=16197,by=16198,pu=16199,mu=16200,_y=16201,wy=16202,Cy=16203,Sy=16204,xy=16205,qf=16206,Ty=16207,ky=16208,Dt=16209,q2=16210,Z2=16211,SX=852,xX=592,TX=15,kX=TX,Ey=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function EX(){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 Ua=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modeZ2?1:0},J2=e=>{if(Ua(e))return Zn;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=Qc,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(SX),t.distcode=t.distdyn=new Int32Array(xX),t.sane=1,t.back=-1,Ma},Q2=e=>{if(Ua(e))return Zn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,J2(e)},eC=(e,t)=>{let n;if(Ua(e))return Zn;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Zn:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Q2(e))},tC=(e,t)=>{if(!e)return Zn;const n=new EX;e.state=n,n.strm=e,n.window=null,n.mode=Qc;const r=eC(e,t);return r!==Ma&&(e.state=null),r},OX=e=>tC(e,kX);let Oy=!0,Zf,Jf;const AX=e=>{if(Oy){Zf=new Int32Array(512),Jf=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(Is(Y2,e.lens,0,288,Zf,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Is(X2,e.lens,0,32,Jf,0,e.work,{bits:5}),Oy=!1}e.lencode=Zf,e.lenbits=9,e.distcode=Jf,e.distbits=5},nC=(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,v,o,a,u,h,c,f,s,d,g,m=0,y,b,_,w,S,x,T,O;const P=new Uint8Array(4);let D,j;const R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ua(e)||!e.output||!e.input&&e.avail_in!==0)return Zn;n=e.state,n.mode===jr&&(n.mode=Kf),v=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,c=o,f=a,O=Ma;e:for(;;)switch(n.mode){case Qc:if(n.wrap===0){n.mode=Kf;break}for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=qt(n.check,P,2,0),u=0,h=0,n.mode=oy;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Dt;break}if((u&15)!==ay){e.msg="unknown compression method",n.mode=Dt;break}if(u>>>=4,h-=4,T=(u&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=Dt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(P[0]=u&255,P[1]=u>>>8&255,n.check=qt(n.check,P,2,0)),u=0,h=0,n.mode=sy;case sy:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>8&255,P[2]=u>>>16&255,P[3]=u>>>24&255,n.check=qt(n.check,P,4,0)),u=0,h=0,n.mode=ly;case ly:for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>8),n.flags&512&&n.wrap&4&&(P[0]=u&255,P[1]=u>>>8&255,n.check=qt(n.check,P,2,0)),u=0,h=0,n.mode=uy;case uy:if(n.flags&1024){for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=qt(n.check,P,2,0)),u=0,h=0}else n.head&&(n.head.extra=null);n.mode=cy;case cy: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=qt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=fy;case fy: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=jr;break;case py:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>=h&7,h-=h&7,n.mode=qf;break}for(;h<3;){if(o===0)break e;o--,u+=r[l++]<>>=1,h-=1,u&3){case 0:n.mode=my;break;case 1:if(AX(n),n.mode=pu,t===hu){u>>>=2,h-=2;break e}break;case 2:n.mode=vy;break;case 3:e.msg="invalid block type",n.mode=Dt}u>>>=2,h-=2;break;case my:for(u>>>=h&7,h-=h&7;h<32;){if(o===0)break e;o--,u+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Dt;break}if(n.length=u&65535,u=0,h=0,n.mode=Gf,t===hu)break e;case Gf:n.mode=gy;case gy: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),v),o-=s,l+=s,a-=s,v+=s,n.length-=s;break}n.mode=jr;break;case vy:for(;h<14;){if(o===0)break e;o--,u+=r[l++]<>>=5,h-=5,n.ndist=(u&31)+1,u>>>=5,h-=5,n.ncode=(u&15)+4,u>>>=4,h-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Dt;break}n.have=0,n.mode=yy;case yy:for(;n.have>>=3,h-=3}for(;n.have<19;)n.lens[R[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,D={bits:n.lenbits},O=Is(yX,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid code lengths set",n.mode=Dt;break}n.have=0,n.mode=by;case by:for(;n.have>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=y,h-=y,n.lens[n.have++]=_;else{if(_===16){for(j=y+2;h>>=y,h-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=Dt;break}T=n.lens[n.have-1],s=3+(u&3),u>>>=2,h-=2}else if(_===17){for(j=y+3;h>>=y,h-=y,T=0,s=3+(u&7),u>>>=3,h-=3}else{for(j=y+7;h>>=y,h-=y,T=0,s=11+(u&127),u>>>=7,h-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Dt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===Dt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Dt;break}if(n.lenbits=9,D={bits:n.lenbits},O=Is(Y2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid literal/lengths set",n.mode=Dt;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},O=Is(X2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,O){e.msg="invalid distances set",n.mode=Dt;break}if(n.mode=pu,t===hu)break e;case pu:n.mode=mu;case mu:if(o>=6&&a>=258){e.next_out=v,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=u,n.bits=h,dX(e,f),v=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,n.mode===jr&&(n.back=-1);break}for(n.back=0;m=n.lencode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,n.length=_,b===0){n.mode=xy;break}if(b&32){n.back=-1,n.mode=jr;break}if(b&64){e.msg="invalid literal/length code",n.mode=Dt;break}n.extra=b&15,n.mode=_y;case _y:if(n.extra){for(j=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=wy;case wy:for(;m=n.distcode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=Dt;break}n.offset=_,n.extra=b&15,n.mode=Cy;case Cy:if(n.extra){for(j=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Dt;break}n.mode=Sy;case Sy: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=Dt;break}s>n.wnext?(s-=n.wnext,d=n.wsize-s):d=n.wnext-s,s>n.length&&(s=n.length),g=n.window}else g=i,d=v-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[v++]=g[d++];while(--s);n.length===0&&(n.mode=mu);break;case xy:if(a===0)break e;i[v++]=n.length,a--,n.mode=mu;break;case qf:if(n.wrap){for(;h<32;){if(o===0)break e;o--,u|=r[l++]<{if(Ua(e))return Zn;let t=e.state;return t.window&&(t.window=null),e.state=null,Ma},MX=(e,t)=>{if(Ua(e))return Zn;const n=e.state;return(n.wrap&2)===0?Zn:(n.head=t,t.done=!1,Ma)},LX=(e,t)=>{const n=t.length;let r,i,l;return Ua(e)||(r=e.state,r.wrap!==0&&r.mode!==vc)?Zn:r.mode===vc&&(i=1,i=pl(i,t,n,0),i!==r.check)?K2:(l=nC(e,t,n,n),l?(r.mode=q2,G2):(r.havedict=1,Ma))};var RX=Q2,DX=eC,$X=J2,BX=OX,FX=tC,zX=PX,NX=IX,jX=MX,VX=LX,UX="pako inflate (from Nodeca project)",Kr={inflateReset:RX,inflateReset2:DX,inflateResetKeep:$X,inflateInit:BX,inflateInit2:FX,inflate:zX,inflateEnd:NX,inflateGetHeader:jX,inflateSetDictionary:VX,inflateInfo:UX};function HX(){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 WX=HX;const rC=Object.prototype.toString,{Z_NO_FLUSH:YX,Z_FINISH:XX,Z_OK:vl,Z_STREAM_END:Qf,Z_NEED_DICT:ed,Z_STREAM_ERROR:KX,Z_DATA_ERROR:Ay,Z_MEM_ERROR:GX}=Yo;function Fl(e){this.options=Jc.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 H2,this.strm.avail_out=0;let n=Kr.inflateInit2(this.strm,t.windowBits);if(n!==vl)throw new Error(Pa[n]);if(this.header=new WX,Kr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=gl.string2buf(t.dictionary):rC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Kr.inflateSetDictionary(this.strm,t.dictionary),n!==vl)))throw new Error(Pa[n])}Fl.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,v,o;if(this.ended)return!1;for(t===~~t?v=t:v=t===!0?XX:YX,rC.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=Kr.inflate(n,v),l===ed&&i&&(l=Kr.inflateSetDictionary(n,i),l===vl?l=Kr.inflate(n,v):l===Ay&&(l=ed));n.avail_in>0&&l===Qf&&n.state.wrap>0&&e[n.next_in]!==0;)Kr.inflateReset(n),l=Kr.inflate(n,v);switch(l){case KX:case Ay:case ed:case GX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===Qf))if(this.options.to==="string"){let a=gl.utf8border(n.output,n.next_out),u=n.next_out-a,h=gl.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(h)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===vl&&o===0)){if(l===Qf)return l=Kr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Fl.prototype.onData=function(e){this.chunks.push(e)};Fl.prototype.onEnd=function(e){e===vl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Jc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function mm(e,t){const n=new Fl(t);if(n.push(e),n.err)throw n.msg||Pa[n.err];return n.result}function qX(e,t){return t=t||{},t.raw=!0,mm(e,t)}var ZX=Fl,JX=mm,QX=qX,eK=mm,tK=Yo,nK={Inflate:ZX,inflate:JX,inflateRaw:QX,ungzip:eK,constants:tK};const{Deflate:rq,deflate:iq,deflateRaw:rK,gzip:aq}=cX,{Inflate:oq,inflate:sq,inflateRaw:iK,ungzip:lq}=nK;var aK=rK,oK=iK;function Py(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 sK=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=Py(t);if(console.log("URL params:",n),n.get("share")){const l=oK(new Uint8Array(atob(n.get("share")).split("").map(v=>v.charCodeAt(0))),{to:"string"});if(!l){Vt().raiseError("Error when trying to decode share parameter!",!1);return}n=Py(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),scheduler:n.get("scheduler")||"default"};nn().generateText2Img(r,!1)},lK=10;function Fu(e,t,n,r,i=l=>Vt().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(v=>`${v[0]} - ${v[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}const uK=Ro("interrogate",()=>{const e=ae({}),t=ae(!1);async function n(v){Vt().raiseError(v,!1),t.value=!1,e.value={}}async function r(){const v=jt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(`${v.baseURL.length===0?".":v.baseURL}/sdapi/v1/interrogate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),u=await a.json();!Fu(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}}),gm=e=>(oi("data-v-db184ac6"),e=e(),si(),e),cK={key:0,style:{"margin-top":"16px"}},fK=gm(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),dK={key:1,style:{"margin-top":"16px"}},hK={key:2},pK={style:{"margin-top":"8px"}},mK=gm(()=>ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),gK={key:0},vK=gm(()=>ne("h3",null,"Caption",-1)),yK={key:0},bK={key:1},_K=ke({__name:"InterrogationView",setup(e){const t=uK(),n=nn(),r=Vt(),i=ae();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 h=await gh(u.raw);t.currentInterrogation.source_image=h,t.interrogateImage()}function v(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=w2();return(u,h)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(z(),ue("div",hK,[ne("div",pK,[le(C(pt),{icon:C(Tg),onClick:C(t).resetInterrogation},{default:he(()=>[He("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(z(),be(C(pt),{key:0,icon:C(Tg),onClick:v,disabled:!C(o)},{default:he(()=>[He("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):ye("",!0)]),mK,le(C(Lp),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(z(),ue("div",gK,[vK,C(o)?(z(),ue("div",bK,[ne("strong",null,Pe(C(o)),1)])):(z(),ue("div",yK,"Processing"+Pe(C(a)),1))])):ye("",!0)])):(z(),ue("div",dK,[ne("strong",null,"Uploading image"+Pe(C(a)),1)])):(z(),ue("div",cK,[ne("div",null,[le(C(Fp),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:he(()=>[le(C(De),{size:100},{default:he(()=>[le(C(np))]),_:1}),fK]),_:1},512)])]))}});const wK=Kt(_K,[["__scopeId","data-v-db184ac6"]]);function CK(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),v=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"):"",h=v>0?v+(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(h),c.join(" ")}const SK={class:"form"},xK={key:0,style:{"padding-bottom":"50px"}},TK=ne("h1",{style:{margin:"0"}},"Interrogation",-1),kK=ne("div",null,"Interrogate images to get their predicted descriptions.",-1),EK={class:"sidebar"},OK=ne("span",{style:{height:"100%","font-size":"14px"}},[He("Reference Image: "),ne("br"),He("(Photomaker/Kontext) ")],-1),AK={class:"main"},PK={class:"image center-horizontal"},IK={key:0},MK=ke({__name:"GenerateView",setup(e){const n=vp(gp).smallerOrEqual("md"),r=nn(),i=Vt(),l=Os();jt();const v=uv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSamplers()).map(b=>b.name);return y.length===0?[]:u(y)},[]),o=uv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSchedulers()).map(b=>b.name);return y.length===0?[]:h(y)},[]),a=bt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function u(g){return!r.params||!r.params.sampler_name||g.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=g[0]),g}function h(g){return!r.params||!r.params.scheduler||g.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=g[0]),g}function c(g){return"Elapsed: "+CK(g,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function f(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function s(g){r.generatorType=g,f(),console.log(g)}function d(){l.showCropPreview=!0,l.updateCropPreview()}return f(),sK(),(g,m)=>(z(),ue(Ve,null,[le(C(dw),{"default-active":C(r).generatorType,collapse:!0,onSelect:s,mode:C(n)?"horizontal":"vertical",class:ce(C(n)?"mobile-generator-types":"generator-types"),style:je(C(n)?"overflow-x: auto":"")},{default:he(()=>[le(cu,{index:"Text2Img","icon-one":C(TE),"icon-two":C(Yl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(cu,{index:"Img2Img","icon-one":C(Yl),"icon-two":C(Yl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(cu,{index:"Inpainting","icon-one":_2,"icon-two":C(Yl),isMobile:C(n)},null,8,["icon-two","isMobile"]),le(cu,{index:"Interrogation","icon-one":TH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",SK,[C(r).generatorType==="Interrogation"?(z(),ue("div",xK,[TK,kK,le(wK)])):(z(),be(C(Mp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:a,onSubmit:m[28]||(m[28]=it(()=>{},["prevent"]))},{default:he(()=>[ne("div",EK,[le(C(fB),{modelValue:C(i).activeCollapse,"onUpdate:modelValue":m[23]||(m[23]=y=>C(i).activeCollapse=y),style:{"margin-bottom":"24px"}},{default:he(()=>[le(C(dB),{title:"Generation Options",name:"1"},{default:he(()=>[le(UH),le(mh,{label:"Negative Prompt",prop:"negativePrompt",modelValue:C(r).negativePrompt,"onUpdate:modelValue":m[0]||(m[0]=y=>C(r).negativePrompt=y),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(mh,{label:"Seed",prop:"seed",modelValue:C(r).params.seed,"onUpdate:modelValue":m[2]||(m[2]=y=>C(r).params.seed=y),placeholder:"Enter seed here",clearable:"","clear-icon":C(pE)},{append:he(()=>[le(C(Lr),{content:"Randomize!",placement:"top"},{default:he(()=>[le(C(pt),{icon:C(W3),onClick:m[1]||(m[1]=()=>C(r).params.seed=C(iC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(z(),be(C(h0),{key:0,gutter:10},{default:he(()=>[C(r).multiSelect.sampler.state==="Multiple"?(z(),be(C(qa),{key:0,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Sampler(s)",prop:"samplers",modelValue:C(r).multiSelect.sampler.selected,"onUpdate:modelValue":m[3]||(m[3]=y=>C(r).multiSelect.sampler.selected=y),options:C(v),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(qa),{key:1,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Sampler",prop:"sampler",modelValue:C(r).params.sampler_name,"onUpdate:modelValue":m[4]||(m[4]=y=>C(r).params.sampler_name=y),options:C(v),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(qa),{key:2,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Scheduler(s)",prop:"schedulers",modelValue:C(r).multiSelect.scheduler.selected,"onUpdate:modelValue":m[5]||(m[5]=y=>C(r).multiSelect.scheduler.selected=y),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(qa),{key:3,span:C(n)?24:12},{default:he(()=>[le(lo,{label:"Scheduler",prop:"scheduler",modelValue:C(r).params.scheduler,"onUpdate:modelValue":m[6]||(m[6]=y=>C(r).params.scheduler=y),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(wn,{label:"Batch Size",prop:"batchSize",modelValue:C(r).params.n,"onUpdate:modelValue":m[7]||(m[7]=y=>C(r).params.n=y),min:C(r).minImages,max:C(r).maxImages},null,8,["modelValue","min","max"]),C(r).multiSelect.steps.state==="Multiple"?(z(),be(wn,{key:1,label:"Steps(s)",prop:"multiSteps",modelValue:C(r).multiSelect.steps.selected,"onUpdate:modelValue":m[8]||(m[8]=y=>C(r).multiSelect.steps.selected=y),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(wn,{key:2,label:"Steps",prop:"steps",modelValue:C(r).params.steps,"onUpdate:modelValue":m[9]||(m[9]=y=>C(r).params.steps=y),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(wn,{label:"Width",prop:"width",modelValue:C(r).params.width,"onUpdate:modelValue":m[10]||(m[10]=y=>C(r).params.width=y),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:d},null,8,["modelValue","min","max"]),le(wn,{label:"Height",prop:"height",modelValue:C(r).params.height,"onUpdate:modelValue":m[11]||(m[11]=y=>C(r).params.height=y),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:d},null,8,["modelValue","min","max"]),C(r).multiSelect.guidance.state==="Multiple"?(z(),be(wn,{key:3,label:"Guidance(s)",prop:"cfgScales",modelValue:C(r).multiSelect.guidance.selected,"onUpdate:modelValue":m[12]||(m[12]=y=>C(r).multiSelect.guidance.selected=y),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(wn,{key:4,label:"Guidance",prop:"cfgScale",modelValue:C(r).params.cfg_scale,"onUpdate:modelValue":m[13]||(m[13]=y=>C(r).params.cfg_scale=y),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(wn,{key:5,label:"Eta",prop:"eta",modelValue:C(r).params.eta,"onUpdate:modelValue":m[14]||(m[14]=y=>C(r).params.eta=y),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(wn,{key:6,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:C(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":m[15]||(m[15]=y=>C(r).multiSelect.clipSkip.selected=y),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(wn,{key:7,label:"CLIP Skip",prop:"clipSkip",modelValue:C(r).params.clip_skip,"onUpdate:modelValue":m[16]||(m[16]=y=>C(r).params.clip_skip=y),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(wn,{key:8,label:"Init Strength",prop:"denoise",modelValue:C(r).params.denoising_strength,"onUpdate:modelValue":m[17]||(m[17]=y=>C(r).params.denoising_strength=y),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(wn,{label:"Video Frames",prop:"frames",modelValue:C(r).params.frames,"onUpdate:modelValue":m[18]||(m[18]=y=>C(r).params.frames=y),min:C(r).minFrames,max:C(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). Max 80 frames, about 5 seconds of video."},null,8,["modelValue","min","max"]),ne("div",null,[OK,ne("input",{class:"el-button",type:"file",id:"extra_image_input",onChange:m[19]||(m[19]=y=>C(r).setExtraImage(y)),accept:"image/*",multiple:""},null,32),ne("button",{onClick:m[20]||(m[20]=y=>C(r).clearExtraImage()),class:"el-button"},"Clear Image"),le(C(h0),null,{default:he(()=>[le(C(qa),{span:C(n)?24:12},{default:he(()=>[le(V0,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":m[21]||(m[21]=y=>C(r).params.enable_hr=y),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),le(C(qa),{span:C(n)?24:12},{default:he(()=>[C(r).generatorType==="Img2Img"?(z(),be(V0,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:C(r).params.send_as_refimg,"onUpdate:modelValue":m[22]||(m[22]=y=>C(r).params.send_as_refimg=y),info:"Instead of regular Img2Img, send the image as a reference image for edit models."},null,8,["modelValue"])):ye("",!0)]),_:1},8,["span"])]),_:1})])]),_:1})]),_:1},8,["modelValue"])]),ne("div",AK,[le(C(pt),{onClick:m[24]||(m[24]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:he(()=>[He("Reset")]),_:1}),le(C(pt),{type:"primary",class:"generate-cancel-btn",style:je(C(r).generating?"width: 55%;":""),onClick:m[25]||(m[25]=()=>C(r).generateImage(C(r).generatorType))},{default:he(()=>[ne("span",null," Generate "+Pe(C(r).totalImageCount)+" image"+Pe(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(z(),be(C(pt),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:m[26]||(m[26]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:he(()=>[He("Cancel all")]),_:1},8,["disabled"])):ye("",!0)]),ne("div",PK,[le(C(h$),{class:"center-both generated-image"},{default:he(()=>[!C(r).generating&&C(r).outputs.length==0?(z(),ue("div",IK,[/Inpainting/.test(C(r).generatorType)?(z(),be(U0,{key:0})):ye("",!0),/Img2Img/.test(C(r).generatorType)?(z(),be(U0,{key:1})):ye("",!0)])):ye("",!0),!C(i).showGeneratedImages&&C(r).generating?(z(),be(LH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:c(C(r).timer.seconds),onShowGenerated:m[27]||(m[27]=y=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):ye("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(z(),be(QH,{key:2})):ye("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Ms=ok({history:ST("./"),routes:[{path:"/",name:"generate",component:MK},{path:"/images",name:"images",component:()=>zf(()=>Promise.resolve().then(()=>IG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>zf(()=>Promise.resolve().then(()=>HG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>zf(()=>Promise.resolve().then(()=>QG),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function LK(e){const t=[],n=/]+):([^>]+)>/g;return[e.replace(n,(i,l,v)=>{if(v.trim()==="")return"";const o=Number(v);if(isNaN(o))return"";let a=l,u=!1;const h="|high_noise|";return a.startsWith(h)&&(a=a.substring(h.length),u=!0),t.push({name:a,multiplier:o,...u?{is_high_noise:!0}:{}}),""}),t]}function td(){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,enable_hr:!1,send_as_refimg:!0,scheduler:"default"}}function iC(){return Math.floor(Math.random()*9999999)+1}const nn=Ro("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=ae("Text2Img"),r=ae(""),i=Sn("promptHistory",[]),l=ae(""),v=Sn("negativeLibrary",[]),o=ae(td()),a=ae({interval:0,seconds:0}),u=ae({sampler:{name:"Sampler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.sampler_name],mapToParam:we=>we.sampler_name},scheduler:{name:"Scheduler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.scheduler],mapToParam:we=>we.scheduler},steps:{name:"Steps",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.steps],mapToParam:we=>we.steps},guidance:{name:"CFG Scale",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.cfg_scale],mapToParam:we=>we.cfg_scale},clipSkip:{name:"Clip Skip",state:"Disabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.clip_skip],mapToParam:we=>we.clip_skip},eta:{name:"Eta",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.eta],mapToParam:we=>we.eta}}),h=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),c=ae({...h(),sourceProcessing:"inpainting"}),f=ae({...h(),sourceProcessing:"img2img"}),s=we=>we==="Inpainting"?c.value:we==="Img2Img"?f.value:h(),d=ee(()=>s(n.value)),g=ae(""),m=ae(!1),y=ae(!1),b=ae([]),_=ae([]),w=ae(64),S=ee(()=>jt().allowLargerParams==="Enabled"?3072:1024),x=ae(1),T=ae(20),O=ae(1),P=ee(()=>jt().allowLargerParams==="Enabled"?150:50),D=ae(1),j=ae(24),R=ae(0),B=ae(1),E=ae(0),V=ae(1),te=ae(0),J=ae(10),se=ae(1),M=ae(120),U=(we,Me,Le)=>Array.from({length:(Me-we+1)/Le},(Ue,nt)=>(nt+we)*Le),A=ae(U(te.value,J.value,1)),L=ae(U(D.value,j.value,.5)),Q=ee(()=>{const we=(bn,Pn,Dr=1)=>bn*(Pn.state==="Multiple"&&Pn.selected.length>0?Pn.selected.length:Dr),Le=o.value.n*Y().length,Ue=we(Le,u.value.sampler),nt=we(Ue,u.value.scheduler),Qe=we(nt,u.value.steps),ht=we(Qe,u.value.guidance);return we(ht,u.value.clipSkip)});function N(){return o.value=td(),c.value=h(),f.value=h(),b.value=[],Vt().showGeneratedImages=!1,I(),!0}function I(){_.value=[]}function W(){b.value=[]}async function q(){const we=jt(),Me=we.baseURL.length===0?".":we.baseURL,Le=await fetch(`${Me}/sdapi/v1/loras`),Ue=await Le.json();return Fu(Le,Ue,200,"Failed to get available LoRAs")?Ue:[]}async function re(we){if(!e.includes(we))return[];if(r.value==="")return me("Failed to generate: No prompt submitted.");const Me=Os(),Le=Vt();Me.saveImages();const{sourceImage:Ue,maskImage:nt,sourceProcessing:Qe}=s(we);Oe(r.value);const ht=[],bn=Y().map(rt=>{const Nt=rt.split(" ### ");return{full_prompt:rt,prompt:Nt[0],negative_prompt:Nt[1]||""}}).map(rt=>{const[Nt,Br]=LK(rt.prompt);return{...rt,prompt:Nt,extractedLoras:Br}}),Pn=bn.some(rt=>rt.extractedLoras.length>0)?await q():[],Dr=bn.map(({extractedLoras:rt,...Nt})=>{const Br=rt.length>0&&Pn.length>0?rt.map(er=>{const Ya=Pn.find(Gt=>Gt.name===er.name||Gt.path===er.name);return{path:Ya?Ya.path:er.name,multiplier:er.multiplier,...er.is_high_noise?{is_high_noise:!0}:{}}}):[];return{...Nt,...Br.length>0?{lora:Br}:{}}}),{seed:mr,cfg_scale:ym,eta:$r,steps:uC,clip_skip:cC,sampler_name:fC,scheduler:dC,n:hC,...bm}=o.value,tf=parseInt(mr.toString()),pC=isNaN(tf)||tf<0?iC():tf,mC=Array.from({length:hC},(rt,Nt)=>pC+Nt),Wa=(rt,Nt)=>rt.state==="Disabled"?[]:rt.state==="Enabled"?[Nt]:rt.state==="Multiple"&&rt.selected.length===0?[]:rt.selected,gC={promptVariant:Dr,seed:mC,cfg_scale:Wa(u.value.guidance,ym),eta:Wa(u.value.eta,$r),steps:Wa(u.value.steps,uC),clip_skip:Wa(u.value.clipSkip,cC),sampler_name:Wa(u.value.sampler,fC),scheduler:Wa(u.value.scheduler,dC)},vC=(rt=>Object.entries(rt).filter(([Br,er])=>er.length>0).reduce((Br,[er,Ya])=>{const Gt=[];for(const bC of Br)for(const _C of Ya)Gt.push({...bC,[er]:_C});return Gt},[{}]))(gC),yC=[await G()];for(const rt of vC){const{promptVariant:{full_prompt:Nt,...Br},...er}=rt,Ya=we==="Img2Img"?bm.send_as_refimg:!1;let Gt={prompt:Nt,params:{...bm,send_as_refimg:Ya,...er,...Br,init_images:Ue?[Ue.split(",")[1]]:[],mask:nt,inpainting_mask_invert:nt?0:null,inpainting_fill:nt?1:null},source_image:Ue==null?void 0:Ue.split(",")[1],source_mask:nt,source_processing:Qe,models:yC};Gt.params.sampler_name=="default"&&delete Gt.params.sampler_name,Gt.params.scheduler=="default"&&delete Gt.params.scheduler,Gt.params.frames&&Gt.params.frames<=1&&delete Gt.params.frames,Se&&Se.length>0&&(Gt.params.extra_images=Se),jt().alsoRequestAvi==="Enabled"&&Gt.params.frames&&Gt.params.frames>1&&(Gt.params.video_output_type=2),ht.push(Gt)}let _m=!1;m.value||(_m=!0,b.value=[]),m.value=!0,Le.showGeneratedImages=!1;let wm=_.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(Nt=>!Nt.gathered&&!Nt.failed);if(!rt)break;rt.gathered=!0;try{const Nt=await $(rt.params);if(!Nt){rt.failed=!0;continue}de([{...Nt,...rt}])}catch(Nt){rt.failed=!0,console.error("Error fetching image:",Nt)}}}async function de(we){const Me=Aa();console.log(we);const Le=await Promise.all(we.map(async Qe=>{const ht=Qe.images[0],bn=!!Qe.animated?"gif":"png",Pn=Qe.extra_data?`data:video/avi;base64,${Qe.extra_data}`:"";let Dr={id:-1,image:`data:image/${bn};base64,${ht}`,prompt:Qe.prompt,modelName:Qe.models[0],frames:Qe.params.frames,extra_avi:Pn,enable_hr:Qe.params.enable_hr,send_as_refimg:Qe.params.send_as_refimg};if(Qe.info&&typeof Qe.info=="string"&&Qe.info.trim()!=="")try{const mr=JSON.parse(Qe.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip"].forEach($r=>{mr[$r]!=null&&mr[$r]!=null?Dr[$r]=mr[$r]:Qe.params[$r]!=null&&(Dr[$r]=Qe.params[$r])}),mr.extra_generation_params&&mr.extra_generation_params["Schedule type"]?Dr.scheduler=mr.extra_generation_params["Schedule type"]:Dr.scheduler=Qe.params.scheduler}catch(mr){console.warn("Failed to parse info JSON:",mr)}return Dr})),Ue=await Me.pushOutputs(Le),nt=0;return b.value=[...Ue.map(Qe=>({type:"image",index:nt,output:Qe})),...b.value].sort((Qe,ht)=>Qe.index-ht.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,Vt().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Le}async function me(we){const Me=Vt();return we&&Me.raiseError(we,!1),[]}function ve(we,Me,Le,Ue){return Me<=Le?Me:(Vt().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${we}' to its default value instead of ${Me}.`,!0),Ue)}async function H(we,Me=!0){const Le=td();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",Ms.push("/"),Me&&(we.width=we.width||Le.width,we.height=we.height||Le.height),we.prompt){const Ue=we.prompt.split(" ### ");r.value=Ue[0],l.value=Ue[1]||""}if(we.sampler_name){o.value.sampler_name=we.sampler_name;const nt=(await ie()).find(Qe=>Qe.aliases&&Qe.aliases.includes(we.sampler_name));nt&&(o.value.sampler_name=nt.name)}we.steps&&(o.value.steps=ve("steps",we.steps,P.value,Le.steps)),we.cfg_scale&&(o.value.cfg_scale=we.cfg_scale),(we.eta||we.eta===0)&&(o.value.eta=we.eta),we.width&&(o.value.width=ve("width",we.width,S.value,Le.width)),we.height&&(o.value.height=ve("height",we.height,S.value,Le.height)),we.seed&&(o.value.seed=we.seed),we.clip_skip&&(o.value.clip_skip=ve("clip_skip",we.clip_skip,J.value,Le.clip_skip)),we.scheduler&&(o.value.scheduler=we.scheduler),we.frames&&(o.value.frames=ve("frames",we.frames,M.value,Le.frames))}function K(we){const Me=Os();n.value="Img2Img",f.value.sourceImage=we,Me.drawing=!1,b.value=[],Ms.push("/"),Hn.fabric.Image.fromURL(we,Me.newImage)}function k(we){const Me=Os();b.value=[],c.value.sourceImage=we,n.value="Inpainting",Ms.push("/"),Hn.fabric.Image.fromURL(we,Me.newImage)}function X(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function Y(){const we=X(),Me=we.match(/\{(.*?)\}/g)||[];if(Me.length===0)return[we];let Le=[];return Me.forEach(Ue=>{const nt=[],Qe=Ue.replace("{","").replace("}","").split("|");Le.length===0?Qe.forEach(ht=>{const en=we.replace(Ue,ht);nt.push(en)}):Le.forEach(ht=>{Qe.forEach(en=>{const bn=ht.replace(Ue,en);nt.push(bn)})}),Le=[...nt]}),Le}async function $(we){const Me=jt();try{const Le=await fetch(`${Me.baseURL.length===0?".":Me.baseURL}/sdapi/v1/${we.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)}),Ue=await Le.json();return Fu(Le,Ue,200,"Failed to fetch",F)?Ue:!1}catch{return!1}}function F(we){return Vt().raiseError(we,!1),y.value=!1,b.value=[],!1}async function G(){const we=jt(),Me=await fetch(`${we.baseURL.length===0?".":we.baseURL}/sdapi/v1/sd-models`),Le=await Me.json();if(!!Fu(Me,Le,200,"Failed to get available models"))return Le.length===0?"(No model loaded)":Le[0].model_name}const fe=ae(0),oe=new Map;function Z(){oe.clear(),fe.value++}Te(()=>jt().baseURL,()=>{Z()});async function pe(we){const Me=jt(),Ue=((Me.baseURL.length===0?".":Me.baseURL).replace(/\/+$/,"")||".")+"/"+we.replace(/^\/+/,"");if(oe.has(Ue))return oe.get(Ue);const nt=(async()=>{try{const Qe=await fetch(Ue);if(Qe.ok)return await Qe.json();console.error(`API Error: ${Qe.status} ${Qe.statusText} at ${Ue}`)}catch(Qe){console.error(`Fetch error for ${Ue}:`,Qe)}return oe.delete(Ue),null})();return oe.set(Ue,nt),nt}async function ie(){const we=await pe("/sdapi/v1/samplers");return Array.isArray(we)?we:[]}async function ge(){const we=await pe("/sdapi/v1/schedulers");return Array.isArray(we)?we:[]}function Ce(we){v.value.indexOf(we)===-1&&(v.value=[...v.value,we])}function Ee(we){v.value=v.value.filter(Me=>Me!=we)}function Oe(we){if(i.value.findIndex(Me=>Me.prompt===we)===-1){if(i.value.length>=10+i.value.filter(Me=>Me.starred).length){const Me=i.value.filter(Ue=>!Ue.starred),Le=i.value.findIndex(Ue=>Ue===Me[Me.length-1]);i.value.splice(Le,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:we}]}}function Ne(we){i.value=i.value.filter(Me=>Me.prompt!=we&&Me!=we)}function _e(){return!1}var Se=[];function Be(we){let Me=we.target;if(Se=[],Me.files.length>0)for(let Le=0;Lenew DataView(new ArrayBuffer(e)),Ha=e=>new Uint8Array(e.buffer||e),uo=e=>new TextEncoder().encode(String(e));function RK(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:uo(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:Ha(e)};if(Symbol.asyncIterator in e)return{t,o:aC(e)};throw new TypeError("Unsupported input format.")}function aC(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=DK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function DK(e){return typeof e=="string"?uo(e):e instanceof Uint8Array?e:Ha(e)}function $K(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=uo(t)),e instanceof File)return{i:t||uo(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(),v=l&&decodeURIComponent(l),o=n||+e.headers.get("content-length");return{i:t||uo(v),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:uo(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 BK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:FK,m:zK}=BK.exports,NK=Ha(zK).subarray(65536);function Iy(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))NK.set(n),t=FK(n.length,t);return t}function oC(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 jK(e){const t=ef(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),oC(e.t,t,10),t.setUint16(26,e.i.length,1),Ha(t)}async function*VK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=Iy(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=Iy(r,e.u),e.A+=r.length,yield r}}}function UK(e){const t=ef(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),Ha(t)}function HK(e,t){const n=ef(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),oC(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),Ha(n)}function WK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function YK(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(aC(async function*(r){const i=[];let l=0,v=0;for await(const u of r)yield jK(u),yield u.i,yield*VK(u),yield UK(u),i.push(HK(u,l)),i.push(u.i),v++,l+=46+u.i.length+u.A;let o=0;for(const u of i)yield u,o+=u.length;const a=ef(22);a.setUint32(0,1347093766),a.setUint16(8,v,1),a.setUint16(10,v,1),a.setUint32(12,o,1),a.setUint32(16,l,1),yield Ha(a)}(async function*(r){for await(const i of r){const[l,v]=WK(i);yield Object.assign(RK(...v),$K(...l))}}(e))),{headers:n})}async function sC(e,t=!0,n){const r=jt();t&&Vi({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 ha(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await ha(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await ha(u,"image/gif")}):i.push({name:f+".webp",input:await ha(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await YK(i).blob(),v=document.createElement("a");v.href=URL.createObjectURL(l),v.download="sdui_images.zip",v.click()}async function XK(e,t){const n=jt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await ha(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await ha(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await ha(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)}const KK=ke({__name:"ImageActions",props:{imageData:null,onDelete:null,showDismiss:{type:Boolean}},setup(e){const t=e,n=nn(),r=Aa(),i=()=>{xw.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),Vi({type:"success",message:"Deleted Image"})})},l=()=>{nn().clearOutputs(),Vt().showGeneratedImages=!1,nn().clearQueue()};async function v(o){const a=window.location.origin,u={prompt:o.prompt,width:o.width?o.width:void 0,height:o.height?o.height:void 0,steps:o.steps,cfg_scale:o.cfg_scale,sampler_name:o.sampler_name,model_name:o.modelName,seed:o.seed,clip_skip:o.clip_skip,frames:o.frames,scheduler:o.scheduler,extra_avi:o.extra_avi,enable_hr:o.enable_hr,send_as_refimg:o.send_as_refimg},h=window.location.pathname.replace("images","");let c=`${a}${h}?share=`,f="",s="";for(const[g,m]of Object.entries(u)){if(!m)continue;let y=m;typeof m=="string"?y=encodeURIComponent(m):Array.isArray(m)&&(y=JSON.stringify(m)),f+=`${s}${g}=${y}`,s="&"}c+=btoa(String.fromCharCode.apply(null,Array.from(aK(f)))),await navigator.clipboard.writeText(c),Vi({type:"success",message:"Copied shareable link to clipboard"})}return(o,a)=>(z(),ue(Ve,null,[le(C(pt),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:C(Dc),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(pt),{class:"compact-button",onClick:a[0]||(a[0]=u=>C(XK)(e.imageData.image,`${e.imageData.seed}-${e.imageData.prompt}`)),type:"success",size:"small",icon:C(Us),plain:""},{default:he(()=>[He("Download")]),_:1},8,["icon"]),e.imageData.starred?ye("",!0):(z(),be(C(pt),{key:0,class:"compact-button",onClick:a[1]||(a[1]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(b4),plain:""},{default:he(()=>[He("Star")]),_:1},8,["icon"])),e.imageData.starred?(z(),be(C(pt),{key:1,class:"compact-button",onClick:a[2]||(a[2]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(p_),plain:""},{default:he(()=>[He("Unstar")]),_:1},8,["icon"])):ye("",!0),le(C(pt),{class:"compact-button",onClick:a[3]||(a[3]=u=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:he(()=>[He("Txt2img")]),_:1}),le(C(pt),{class:"compact-button",onClick:a[4]||(a[4]=u=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Img2img")]),_:1}),le(C(pt),{class:"compact-button",onClick:a[5]||(a[5]=u=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[He("Inpaint")]),_:1}),e.showDismiss?(z(),be(C(pt),{key:2,class:"compact-button",onClick:a[6]||(a[6]=u=>l()),type:"success",size:"small",plain:""},{default:he(()=>[He("Dismiss")]),_:1})):ye("",!0),le(C(pt),{class:"compact-button",onClick:a[7]||(a[7]=u=>v(e.imageData)),type:"success",icon:C(R3),size:"small",plain:""},{default:he(()=>[He("Share")]),_:1},8,["icon"])],64))}});const lC=Kt(KK,[["__scopeId","data-v-f69f1ca8"]]),GK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},qK=["src"],ZK={style:{"font-size":"18px","font-weight":"500"}},JK={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},QK={key:0},eG=["onClick"],tG=ke({__name:"ImageDialog",setup(e){const t=Aa(),n=Vt(),r=ae();uM(r,{onSwipeEnd(a,u){u==="RIGHT"&&n.openModalToLeft(),u==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=ae(t.currentOutputs[0]);Te(()=>n.activeModal,async()=>{const a=t.currentOutputs.find(u=>u.id===n.activeModal);if(a)return l.value=a;l.value=await Bt.outputs.get(n.activeModal)||t.currentOutputs[0]});function v(){i.value=!1}function o(){var g,m;if(!((g=l.value)!=null&&g.extra_avi))return;const a=l.value.extra_avi.split(",")[1];if(!a)return;const u=atob(a),h=u.length,c=new Uint8Array(h);for(let y=0;y{var h;return z(),be(C(eF),{"model-value":C(i),width:(h=l.value)==null?void 0:h.width,class:"image-viewer",onClosed:v,"align-center":""},{footer:he(()=>[le(lC,{"image-data":l.value,"on-delete":v},null,8,["image-data"])]),default:he(()=>{var c,f,s,d;return[ne("div",{class:"main-output-container",ref_key:"target",ref:r},[ne("div",GK,[(c=l.value)!=null&&c.image?(z(),ue("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,qK)):ye("",!0)])],512),ne("div",ZK,Pe(((f=l.value.prompt)==null?void 0:f.split("###")[0])||"Unknown Creation"),1),ne("div",JK,[ne("div",null,"Negative Prompt: "+Pe(((s=l.value.prompt)==null?void 0:s.split("###")[1])||"None"),1),ne("span",null,"Model: "+Pe(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Pe(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Pe(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Pe(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Pe(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Pe(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Pe((d=l.value.clip_skip)!=null?d:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Pe(l.value.width||"???")+"x"+Pe(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Pe(l.value.frames||"1"),1),l.value.extra_avi?(z(),ue("span",QK,[He(" - "),ne("a",{href:"#",onClick:it(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,eG)])):ye("",!0)])]}),_:1},8,["model-value","width"])}}});const nG=e=>(oi("data-v-8f4d2380"),e=e(),si(),e),rG=nG(()=>ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)),iG={class:"generator-icons"},aG=ke({__name:"App",setup(e){const n=vp(gp).smallerOrEqual("md"),r=Vt();jt();const i=lk(),l=ae();return Te(()=>i.path,v=>{l.value&&l.value.open(v)}),(v,o)=>(z(),ue(Ve,null,[ne("div",{class:ce({"menu-container":!C(n)})},[le(C(dw),{"default-active":C(i).path,mode:"horizontal",router:!0,ellipsis:!C(n),class:ce(C(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:he(()=>[C(n)?ye("",!0):(z(),be(C(Dp),{key:0,class:"remove-item-styling center-vertical"},{title:he(()=>[rG]),_:1})),le(rs,{isMobile:C(n),index:"/"},{icon:he(()=>[ne("div",iG,[le(C(De),null,{default:he(()=>[le(C(bO))]),_:1}),C(r).showGeneratorBadge?(z(),be(C(De),{key:0,class:"generator-badge",size:10},{default:he(()=>[le(cH)]),_:1})):ye("",!0)])]),title:he(()=>[He("Generate")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/images"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(Z3))]),_:1})]),title:he(()=>[He("Images")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/about"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(c_))]),_:1})]),title:he(()=>[He("About")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/options"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(P4))]),_:1})]),title:he(()=>[He("Options")]),_:1},8,["isMobile"]),le(rs,{isMobile:C(n),index:"/return"},{icon:he(()=>[le(C(De),null,{default:he(()=>[le(C(o_))]),_:1})]),title:he(()=>[He("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:ce({view:!C(n)})},[le(C(a_))],2),le(tG)],64))}});const oG=Kt(aG,[["__scopeId","data-v-8f4d2380"]]);const vm=Jx(oG);vm.use(tT());vm.use(Ms);vm.mount("#app");Ms.replace("/");window.addEventListener("beforeunload",e=>{nn().generating&&(e.preventDefault(),e.returnValue="")});const sG={key:1,class:"image-action"},lG=ke({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=Vt(),r=ae(null);NI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=ae(!1);lM(r,([{isIntersecting:v}])=>{v&&(i.value=v)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(v,o)=>(z(),ue("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(z(),be(C(Lp),{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:je(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):ye("",!0),i.value?(z(),ue("div",sG,[e.imageData.starred?(z(),be(C(De),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:he(()=>[le(C(p_))]),_:1})):ye("",!0),C(n).multiSelect?(z(),ue("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[le(C(De),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:he(()=>[C(l)?ye("",!0):(z(),be(C(wl),{key:0})),C(l)?(z(),be(C(l_),{key:1})):ye("",!0)]),_:1},8,["color"])])):ye("",!0)])):ye("",!0)],512))}});const My=Kt(lG,[["__scopeId","data-v-b9569bbd"]]);function uG({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=Q_(),i=ee(()=>r.value<=e),l=ae(!0),{y:v}=sM(window);let o=v.value,a=0;return Te(v,u=>{if(!i.value)return;const h=u-o;if(o=u,h>0&&u>t){a+=h,a>=n&&(l.value=!1,a=0);return}h<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const cG={},fG={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},dG=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),hG=[dG];function pG(e,t){return z(),ue("svg",fG,hG)}const mG=Kt(cG,[["render",pG]]),gG=e=>(oi("data-v-b39b47c5"),e=e(),si(),e),vG={class:"options"},yG=["onClick"],bG=["onClick"],_G=["onClick"],wG={key:1,class:"center-both",style:{gap:"12px"}},CG={key:2},SG=gG(()=>ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),xG=[SG],TG={key:0},kG={key:0,style:{display:"flex",gap:"8px"}},EG={key:1,class:"images"},OG={key:1},AG=ke({__name:"ImagesView",setup(e){const{width:t}=Q_(),{isVisible:n,isMobile:r}=uG(),i=Aa(),l=jt(),v=Vt();function o(){v.selected=v.selected.filter(d=>!i.currentOutputs.map(g=>g.id).includes(d)),v.selected=[...v.selected,...i.currentOutputs.map(d=>d.id)],v.multiSelect=!0}async function a(){const d=await Bt.outputs.toCollection().primaryKeys();v.selected=d,v.multiSelect=!0}function u(){v.selected=v.selected.filter(d=>!i.currentOutputs.map(g=>g.id).includes(d)),v.selected.length===0&&(v.multiSelect=!1)}function h(){v.selected=[],v.multiSelect=!1}const c=()=>{xw.confirm(`This action will permanently delete ${v.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(v.selected)})};cv(["a","A","ArrowLeft"],v.openModalToLeft),cv(["d","D","ArrowRight"],v.openModalToRight);async function f(){sC(v.selected)}const s=ee(()=>{let d=2;t.value>1440?d=6:t.value>1280?d=5:t.value>768?d=4:t.value>480&&(d=3);const g=[];for(let m=0;m(z(),ue(Ve,null,[ne("div",{class:ce(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[ne("div",vG,[le(C(tu),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[le(C(l4))]),_:1})]),_:1})]),default:he(()=>[(z(),ue(Ve,null,Ft(["Newest","Oldest"],m=>ne("div",{key:m,onClick:()=>C(i).sortBy=m,class:ce(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Pe(m),11,yG)),64))]),_:1}),le(C(tu),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[le(C(c3))]),_:1})]),_:1})]),default:he(()=>[(z(),ue(Ve,null,Ft(["all","favourited","unfavourited","unrated"],m=>ne("div",{key:m,onClick:()=>C(i).filterBy=m,class:ce(`el-select-dropdown__item ${C(i).filterBy===m?"selected":""}`)},Pe(C(i).filterBy===m?"Showing":"Show")+" "+Pe(m),11,bG)),64))]),_:1}),le(C(tu),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[le(mG)]),_:1})]),_:1})]),default:he(()=>[(z(),ue(Ve,null,Ft([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>ne("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:ce(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Pe(m.label),11,_G)),64))]),_:1}),le(C(tu),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[le(C(pt),{class:"btn-select"},{default:he(()=>[le(C(De),{size:16},{default:he(()=>[C(v).multiSelect?(z(),be(C(l_),{key:0})):(z(),be(C(wl),{key:1}))]),_:1})]),_:1})]),default:he(()=>[C(v).multiSelect?(z(),ue("div",{key:0,class:"el-select-dropdown__item selected",onClick:g[0]||(g[0]=(...m)=>C(v).toggleMultiSelect&&C(v).toggleMultiSelect(...m))},"Disable multi-select")):(z(),ue("div",{key:1,class:"el-select-dropdown__item",onClick:g[1]||(g[1]=(...m)=>C(v).toggleMultiSelect&&C(v).toggleMultiSelect(...m))},"Enable multi-select")),C(v).selected.length>0?(z(),ue("div",{key:2,class:"el-select-dropdown__item selected",onClick:h},"Deselect All")):(z(),ue("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),C(v).selected.every(m=>!C(i).currentOutputs.map(y=>y.id).includes(m))?(z(),ue("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(z(),ue("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(z(),be(C(x9),{key:0,layout:"prev, pager, next",total:C(i).outputsLength,"page-size":C(l).pageSize,"current-page":C(i).currentPage,"onUpdate:currentPage":g[2]||(g[2]=m=>C(i).currentPage=m),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):ye("",!0),C(v).multiSelect?(z(),ue("div",wG,[ne("div",null,Pe(C(v).selected.length)+" selected",1),le(C(pt),{type:"danger",onClick:c,icon:C(Dc),plain:""},{default:he(()=>[He("Delete")]),_:1},8,["icon"]),le(C(pt),{type:"success",onClick:f,icon:C(Us),plain:"",style:{margin:"0"}},{default:he(()=>[He("Download")]),_:1},8,["icon"])])):(z(),ue("div",CG,xG))],2),C(i).outputsLength!=0?(z(),ue("div",TG,[C(i).currentLayout==="dynamic"?(z(),ue("div",kG,[(z(!0),ue(Ve,null,Ft(C(s),(m,y)=>(z(),ue("div",{key:y,style:{flex:"1 1 0%"}},[(z(!0),ue(Ve,null,Ft(m,b=>(z(),be(My,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ye("",!0),C(i).currentLayout==="grid"?(z(),ue("div",EG,[(z(!0),ue(Ve,null,Ft(C(i).currentOutputs,m=>(z(),be(My,{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(),ue("div",OG,[le(C(XF),{description:"No Images Found"})])):ye("",!0)],64))}});const PG=Kt(AG,[["__scopeId","data-v-b39b47c5"]]),IG=Object.freeze(Object.defineProperty({__proto__:null,default:PG},Symbol.toStringTag,{value:"Module"})),MG=["href"],LG=ke({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=yt("router-link");return z(),ue(Ve,null,[e.router?ye("",!0):(z(),ue("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[xe(t.$slots,"default",{},void 0,!0)],8,MG)),e.router?(z(),be(r,{key:1,to:e.href},{default:he(()=>[xe(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ye("",!0)],64)}}});const RG=Kt(LG,[["__scopeId","data-v-17b53b7d"]]),zl=e=>(oi("data-v-ecc278c5"),e=e(),si(),e),DG={class:"about"},$G={class:"about-content"},BG=zl(()=>ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),FG=zl(()=>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)),zG=zl(()=>ne("br",null,null,-1)),NG=zl(()=>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)),jG=zl(()=>ne("br",null,null,-1)),VG=ke({__name:"AboutView",setup(e){return(t,n)=>(z(),ue("div",DG,[ne("div",$G,[BG,FG,zG,NG,jG,ne("div",null,[He("You can find the KoboldAI community and authors of this fork on the "),le(RG,{href:"https://koboldai.org/discord"},{default:he(()=>[He("KoboldAI Discord")]),_:1})])])]))}});const UG=Kt(VG,[["__scopeId","data-v-ecc278c5"]]),HG=Object.freeze(Object.defineProperty({__proto__:null,default:UG},Symbol.toStringTag,{value:"Module"}));const no=ke({__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,v)=>(z(),be(C(Mi),{prop:e.prop},{label:he(()=>[le(Rl,{info:e.info,"label-style":e.labelStyle},{default:he(()=>[xe(l.$slots,"label",{},()=>[He(Pe(e.label),1)])]),_:3},8,["info","label-style"])]),default:he(()=>[le(C(j$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:he(()=>[(z(!0),ue(Ve,null,Ft(e.options,o=>(z(),be(C(V$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),xe(l.$slots,"inline")]),_:3},8,["prop"]))}}),Go=e=>(oi("data-v-0345ee1f"),e=e(),si(),e),WG=Go(()=>ne("h1",null,"Options",-1)),YG=Go(()=>ne("h2",null,"Generation Options",-1)),XG=Go(()=>ne("h3",null,"Parameter Controls",-1)),KG=Go(()=>ne("h2",null,"Image Options",-1)),GG=Go(()=>ne("div",null,[He("Drop file here OR "),ne("em",null,"click to upload")],-1)),qG=Go(()=>ne("h2",null,"General Options",-1)),ZG=ke({__name:"OptionsView",setup(e){const t=jt(),n=Aa(),r=nn(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=ae([]),v=ae(),o=ae(!1),a=ae(0);async function u(c){n.importFromZip(c),v.value.clearFiles()}async function h(){Vi({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const c=await Bt.outputs.toCollection().primaryKeys();await sC(c,!1,()=>{a.value++}),o.value=!1,a.value=0}return(c,f)=>(z(),ue(Ve,null,[WG,le(C(Mp),{"label-position":"top",model:C(t).options,onSubmit:f[10]||(f[10]=it(()=>{},["prevent"]))},{default:he(()=>[le(C(Kj),{type:"border-card",style:{"min-height":"50vh"}},{default:he(()=>[le(C(Af),{label:"\u{1F5A8}\uFE0F Generation"},{default:he(()=>[YG,le(C(Mi),{label:"Base URL"},{default:he(()=>[le(C(ja),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":f[0]||(f[0]=s=>C(t).baseURL=s)},null,8,["modelValue"])]),_:1}),XG,(z(!0),ue(Ve,null,Ft(C(r).multiSelect,(s,d)=>{var g;return z(),ue("div",{key:d},[le(no,{label:s.name,prop:"pageless",modelValue:s.state,"onUpdate:modelValue":m=>s.state=m,options:(g=s.allowedStates)!=null?g:[]},null,8,["label","modelValue","onUpdate:modelValue","options"])])}),128)),le(no,{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(lo,{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(no,{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(Af),{label:"\u{1F4F7} Images"},{default:he(()=>[KG,le(wn,{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(no,{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(no,{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(no,{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(Mi),{label:"Export Images (ZIP File)"},{default:he(()=>[o.value?(z(),be(C(pt),{key:1,icon:C(Us),disabled:""},{default:he(()=>[He("Downloading... ("+Pe(a.value)+" / "+Pe(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(z(),be(C(pt),{key:0,icon:C(Us),onClick:f[8]||(f[8]=s=>h())},{default:he(()=>[He("Download "+Pe(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),le(C(Mi),{label:"Import Images (ZIP File)"},{default:he(()=>[le(C(Fp),{drag:"",ref_key:"upload",ref:v,"auto-upload":!1,onChange:u,"file-list":l.value,limit:1,multiple:""},{default:he(()=>[le(C(De),{size:100},{default:he(()=>[le(C(np))]),_:1}),GG]),_:1},8,["file-list"])]),_:1})]),_:1}),le(C(Af),{label:"\u2699\uFE0F General"},{default:he(()=>[qG,le(lo,{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 JG=Kt(ZG,[["__scopeId","data-v-0345ee1f"]]),QG=Object.freeze(Object.defineProperty({__proto__:null,default:JG},Symbol.toStringTag,{value:"Module"})); diff --git a/koboldcpp.py b/koboldcpp.py index ea21ab1e0..3bc2a23f2 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -2806,7 +2806,7 @@ def sd_generate(genparams): if flow_shift is not None and flow_shift < 0: flow_shift = None # fall back to the default sample_steps = (1 if sample_steps < 1 else (forced_steplimit if sample_steps > forced_steplimit else sample_steps)) - vid_req_frames = (1 if vid_req_frames < 1 else (100 if vid_req_frames > 100 else vid_req_frames)) + vid_req_frames = (1 if vid_req_frames < 1 else (120 if vid_req_frames > 120 else vid_req_frames)) swap_refimg = (True if tryparseint(genparams.get("send_as_refimg", 0),0) else False) if len(extra_images_arr)==0 and swap_refimg and init_images and init_images!="" and not mask: diff --git a/otherarch/sdcpp/stable-diffusion.cpp b/otherarch/sdcpp/stable-diffusion.cpp index 0f04d6d8c..fbc1eced4 100644 --- a/otherarch/sdcpp/stable-diffusion.cpp +++ b/otherarch/sdcpp/stable-diffusion.cpp @@ -285,6 +285,7 @@ public: std::string t5_path_fixed = SAFE_STR(sd_ctx_params->t5xxl_path); std::string taesd_path_fixed = SAFE_STR(sd_ctx_params->taesd_path); std::string embed_connector_fixed = SAFE_STR(sd_ctx_params->embeddings_connectors_path); + std::string vae_path_fixed = SAFE_STR(sd_ctx_params->vae_path); ModelLoader model_loader; @@ -483,6 +484,24 @@ public: sd_ctx_params->photo_maker_path = ""; } + //for models with TAE suppport, if vae is set, tae is off, and it looks like a tae, swap to tae + if(taesd_path_fixed=="" && vae_path_fixed!="" && toLowerCase(vae_path_fixed).rfind("tae")!=std::string::npos) + { + try { + const uintmax_t tae_size_limit = 64 * 1024 * 1024; //if its less than 64mb, it might be a TAE + // Get the file size in bytes cross-platform + uintmax_t size = std::filesystem::file_size(vae_path_fixed); + if (size > 0 && size < tae_size_limit) { + printf("\nVAE appears to be a TAE, loading as TAE instead!\n"); + taesd_path_fixed = vae_path_fixed; + vae_path_fixed = ""; + } + } + catch (const std::filesystem::filesystem_error& e) { + std::printf("Error accessing file: %s\n", e.what()); + } + } + sd_ctx_params->clip_g_path = clipg_path_fixed.c_str(); sd_ctx_params->clip_l_path = clipl_path_fixed.c_str(); sd_ctx_params->clip_vision_path = clip_vision_fixed.c_str(); @@ -491,6 +510,7 @@ public: sd_ctx_params->t5xxl_path = t5_path_fixed.c_str(); sd_ctx_params->taesd_path = taesd_path_fixed.c_str(); sd_ctx_params->embeddings_connectors_path = embed_connector_fixed.c_str(); + sd_ctx_params->vae_path = vae_path_fixed.c_str(); //debug print // printf("\n\nclip_g: %s\nclip_l: %s\nclip_vision: %s\nllm: %s\nllm_vision: %s\nt5xxl: %s\ntaesd: %s\n", // sd_ctx_params->clip_g_path, sd_ctx_params->clip_l_path, sd_ctx_params->clip_vision_path,