From b427dde1a57c9d553a59588234f0cd48c964e5a3 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sat, 30 May 2026 01:34:43 +0800 Subject: [PATCH] increase total frame cap once more to 160 --- embd_res/kcpp_sdui.embd | 2 +- koboldcpp.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/embd_res/kcpp_sdui.embd b/embd_res/kcpp_sdui.embd index af69f6931..62b592bcf 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=ie({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=ie({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>rn().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>rn().currentImageProps),v=ee({get:()=>i.value.drawing&&!r.value,set:A=>i.value.drawing=A}),o=ie(512),a=ie(512),u=ie(!1),h=ie(30),c=ie(!1),f=new Un.fabric.Circle({radius:h.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=ie("Erase"),d=ie("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 Un.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=rn();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,fe=0,me=A.width,ve=A.height,H=0,Y=0,k=W.width,K=W.height;switch(I){case"Stretch":break;case"ScaleAndCrop":{const X=W.width/A.width,$=W.height/A.height;X>$?(ve=W.height/X,fe=(A.height-ve)/2):(me=W.width/$,re=(A.width-me)/2);break}case"ScaleAndPad":{const X=W.width/A.width,$=W.height/A.height;X<$?(K=A.height*X,Y=(W.height-K)/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,fe=(A.height-W.height)/2):(K=A.height,Y=(W.height-A.height)/2);break}}return q.drawImage(A,re,fe,me,ve,H,Y,k,K),W}function P(){const A=rn(),L=Ht();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=rn();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=";Un.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 Un.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 Un.fabric.Rect({width:L||o.value,height:Q||a.value,left:0,top:0,fill:N||"transparent",absolutePositioned:I||!0,selectable:!1});return new Un.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=rn();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 iW={},aW={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},oW=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),sW=[oW];function lW(e,t){return z(),le("svg",aW,sW)}const uW=Zt(iW,[["render",lW]]);async function cW(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 fW(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 cW(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 cm=e=>(oi("data-v-d3bd38bf"),e=e(),si(),e),dW=cm(()=>ne("div",null,[Ue("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1)),hW={key:0},pW=cm(()=>ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),mW={class:"canvas-container"},gW=cm(()=>ne("canvas",{id:"canvas"},null,-1)),vW={class:"action-buttons",style:{left:"10px",right:"unset"}},yW={class:"action-buttons"},bW=ke({__name:"CustomCanvas",setup(e){const t=rn(),n=Wt(),r=Ps(),i=ie();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 yh(a.raw);t.currentImageProps.sourceImage=u,r.drawing=!1,Un.fabric.Image.fromURL(u,r.newImage)}function v(){t.currentImageProps.sourceImage="",r.resetCanvas()}tt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Un.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Xt(()=>{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(),le(je,null,[C(t).currentImageProps.sourceImage?ye("",!0):(z(),be(C(Np),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:he(()=>[C(t).generatorType==="Img2Img"?(z(),le("div",hW,[pW,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))},[ue(C(Re),{size:20,style:{"margin-right":"2px"}},{default:he(()=>[ue(C2)]),_:1}),Ue("draw something")])])):ye("",!0)]),default:he(()=>[ue(C(Re),{size:100},{default:he(()=>[ue(C(ip))]),_:1}),dW]),_:1},512)),St(ne("div",null,[ne("div",mW,[gW,ne("div",vW,[ue(C(ht),{onClick:u[1]||(u[1]=h=>C(r).undoAction()),icon:C(p_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),ue(C(ht),{onClick:u[2]||(u[2]=h=>C(r).redoAction()),icon:C(m_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",yW,[ue(C(ht),{onClick:u[3]||(u[3]=h=>C(r).resetDrawing()),icon:C(Or),plain:""},null,8,["icon"]),ue(C(ht),{onClick:v,icon:C(Fc),plain:""},null,8,["icon"]),ue(C(ht),{onClick:u[4]||(u[4]=h=>C(r).downloadMask()),icon:C(Ws),plain:""},null,8,["icon"]),ue(C(ht),{onClick:u[5]||(u[5]=h=>C(r).flipErase()),icon:C(r).erasing?C(o3):uW,plain:""},null,8,["icon"]),C(r).drawing?(z(),be(C(FB),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":u[6]||(u[6]=h=>C(r).drawColor=h),"show-alpha":""},null,8,["modelValue"])):ye("",!0)]),ue(C(Rp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:he(()=>[ue(gn,{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),[[jt,C(t).currentImageProps.sourceImage]])],64))}});const W0=Zt(bW,[["__scopeId","data-v-d3bd38bf"]]),_W={class:"centerIcons"},wW={class:"stackedIcons"},CW=ke({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return Bx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(z(),le("div",_W,[ne("div",wW,[ue(C(Re),{class:"firstIcon",size:e.size},{default:he(()=>[(z(),be(Et(t.iconOne)))]),_:1},8,["size"]),ue(C(Re),{class:"secondIcon",size:e.size},{default:he(()=>[(z(),be(Et(t.iconTwo)))]),_:1},8,["size"])])]))}});const SW=Zt(CW,[["__scopeId","data-v-74586a39"]]),xW={key:1,style:{width:"40px"}},du=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(()=>[ue(C(Bp),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:he(()=>[e.iconTwo?(z(),be(SW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(z(),le("div",xW,[ue(C(Re),{style:{width:"35px"},size:40},{default:he(()=>[(z(),be(Et(t.iconOne)))]),_:1})]))]),_:1},8,["index"])]),_:1},8,["content","placement"]))}});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const TW=4,Y0=0,X0=1,kW=2;function Xo(e){let t=e.length;for(;--t>=0;)e[t]=0}const EW=0,T2=1,OW=2,AW=3,PW=258,fm=29,Bl=256,dl=Bl+1+fm,bo=30,dm=19,k2=2*dl+1,ga=15,Hf=16,IW=7,hm=256,E2=16,O2=17,A2=18,bh=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]),Nu=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]),MW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),P2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),LW=512,Xr=new Array((dl+2)*2);Xo(Xr);const Is=new Array(bo*2);Xo(Is);const hl=new Array(LW);Xo(hl);const pl=new Array(PW-AW+1);Xo(pl);const pm=new Array(fm);Xo(pm);const yc=new Array(bo);Xo(yc);function Wf(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 I2,M2,L2;function Yf(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const R2=e=>e<256?hl[e]:hl[256+(e>>>7)],ml=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},xn=(e,t,n)=>{e.bi_valid>Hf-n?(e.bi_buf|=t<>Hf-e.bi_valid,e.bi_valid+=n-Hf):(e.bi_buf|=t<{xn(e,n[t*2],n[t*2+1])},D2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},RW=e=>{e.bi_valid===16?(ml(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)},DW=(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<=ga;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--)}},$2=(e,t,n)=>{const r=new Array(ga+1);let i=0,l,v;for(l=1;l<=ga;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]=D2(r[o]++,o))}},$W=()=>{let e,t,n,r,i;const l=new Array(ga+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?ml(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},K0=(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=pl[i],wr(e,v+Bl+1,t),o=bh[v],o!==0&&(i-=pm[v],xn(e,i,o)),r--,v=R2(r),wr(e,v,n),o=Nu[v],o!==0&&(r-=yc[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=k2,v=0;v>1;v>=1;v--)Xf(e,n,v);u=l;do v=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Xf(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++,Xf(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],DW(e,t),$2(n,a,e.bl_count)},q0=(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(q0(e,e.dyn_ltree,e.l_desc.max_code),q0(e,e.dyn_dtree,e.d_desc.max_code),_h(e,e.bl_desc),t=dm-1;t>=3&&e.bl_tree[P2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},FW=(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 Y0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return X0;for(n=32;n{J0||($W(),J0=!0),e.l_desc=new Yf(e.dyn_ltree,I2),e.d_desc=new Yf(e.dyn_dtree,M2),e.bl_desc=new Yf(e.bl_tree,L2),e.bi_buf=0,e.bi_valid=0,B2(e)},z2=(e,t,n,r)=>{xn(e,(EW<<1)+(r?1:0),3),F2(e),ml(e,n),ml(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},jW=e=>{xn(e,T2<<1,3),wr(e,hm,Xr),RW(e)},VW=(e,t,n,r)=>{let i,l,v=0;e.level>0?(e.strm.data_type===kW&&(e.strm.data_type=zW(e)),_h(e,e.l_desc),_h(e,e.d_desc),v=BW(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?z2(e,t,n,r):e.strategy===TW||l===i?(xn(e,(T2<<1)+(r?1:0),3),G0(e,Xr,Is)):(xn(e,(OW<<1)+(r?1:0),3),FW(e,e.l_desc.max_code+1,e.d_desc.max_code+1,v+1),G0(e,e.dyn_ltree,e.dyn_dtree)),B2(e),r&&F2(e)},UW=(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[(pl[n]+Bl+1)*2]++,e.dyn_dtree[R2(t)*2]++),e.sym_next===e.sym_end);var HW=NW,WW=z2,YW=VW,XW=UW,KW=jW,GW={_tr_init:HW,_tr_stored_block:WW,_tr_flush_block:YW,_tr_tally:XW,_tr_align:KW};const qW=(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 gl=qW;const ZW=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},JW=new Uint32Array(ZW()),QW=(e,t,n,r)=>{const i=JW,l=r+n;e^=-1;for(let v=r;v>>8^i[(e^t[v])&255];return e^-1};var Jt=QW,Ma={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"},Ko={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:eY,_tr_stored_block:wh,_tr_flush_block:tY,_tr_tally:Di,_tr_align:nY}=GW,{Z_NO_FLUSH:$i,Z_PARTIAL_FLUSH:rY,Z_FULL_FLUSH:iY,Z_FINISH:Hn,Z_BLOCK:Q0,Z_OK:nn,Z_STREAM_END:ey,Z_STREAM_ERROR:kr,Z_DATA_ERROR:aY,Z_BUF_ERROR:Kf,Z_DEFAULT_COMPRESSION:oY,Z_FILTERED:sY,Z_HUFFMAN_ONLY:hu,Z_RLE:lY,Z_FIXED:uY,Z_DEFAULT_STRATEGY:cY,Z_UNKNOWN:fY,Z_DEFLATED:ef}=Ko,dY=9,hY=15,pY=8,mY=29,gY=256,Ch=gY+1+mY,vY=30,yY=19,bY=2*Ch+1,_Y=15,ut=3,Ii=258,Er=Ii+ut+1,wY=32,Lo=42,mm=57,Sh=69,xh=73,Th=91,kh=103,va=113,ds=666,yn=1,Go=2,La=3,qo=4,CY=3,ya=(e,t)=>(e.msg=Ma[t],t),ty=e=>e*2-(e>4?9:0),Oi=e=>{let t=e.length;for(;--t>=0;)e[t]=0},SY=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 xY=(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))},$n=(e,t)=>{tY(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Mn(e.strm)},gt=(e,t)=>{e.pending_buf[e.pending++]=t},os=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Eh=(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=gl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Jt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},N2=(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+Ii;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},Ro=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),SY(e),r+=t),e.strm.avail_in===0)break;if(n=Eh(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=Bi(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Bi(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,Mn(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&&(Eh(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&&(Eh(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===Hn)&&t!==$i&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,v=t===Hn&&e.strm.avail_in===0&&r===i?1:0,wh(e,e.block_start,r,v),e.block_start+=r,Mn(e.strm)),v?La:yn)},Gf=(e,t)=>{let n,r;for(;;){if(e.lookahead=ut&&(e.ins_h=Bi(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=N2(e,n)),e.match_length>=ut)if(r=Di(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=Bi(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=Bi(e,e.ins_h,e.window[e.strstart+1]);else r=Di(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&($n(e,!1),e.strm.avail_out===0))return yn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=ut&&(e.ins_h=Bi(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=Di(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=Bi(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&&($n(e,!1),e.strm.avail_out===0))return yn}else if(e.match_available){if(r=Di(e,0,e.window[e.strstart-1]),r&&$n(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return yn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Di(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<=Ii){if(Ro(e),e.lookahead<=Ii&&t===$i)return yn;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+Ii;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=Di(e,1,e.match_length-ut),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Di(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&($n(e,!1),e.strm.avail_out===0))return yn}return e.insert=0,t===Hn?($n(e,!0),e.strm.avail_out===0?La:qo):e.sym_next&&($n(e,!1),e.strm.avail_out===0)?yn:Go},kY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Ro(e),e.lookahead===0)){if(t===$i)return yn;break}if(e.match_length=0,n=Di(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&($n(e,!1),e.strm.avail_out===0))return yn}return e.insert=0,t===Hn?($n(e,!0),e.strm.avail_out===0?La:qo):e.sym_next&&($n(e,!1),e.strm.avail_out===0)?yn:Go};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 hs=[new vr(0,0,0,0,j2),new vr(4,4,8,4,Gf),new vr(4,5,16,8,Gf),new vr(4,6,32,32,Gf),new vr(4,4,16,16,no),new vr(8,16,32,32,no),new vr(8,16,128,128,no),new vr(8,32,128,256,no),new vr(32,128,258,1024,no),new vr(32,258,258,4096,no)],EY=e=>{e.window_size=2*e.w_size,Oi(e.head),e.max_lazy_match=hs[e.level].max_lazy,e.good_match=hs[e.level].good_length,e.nice_match=hs[e.level].nice_length,e.max_chain_length=hs[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 OY(){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=ef,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(bY*2),this.dyn_dtree=new Uint16Array((2*vY+1)*2),this.bl_tree=new Uint16Array((2*yY+1)*2),Oi(this.dyn_ltree),Oi(this.dyn_dtree),Oi(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(_Y+1),this.heap=new Uint16Array(2*Ch+1),Oi(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Ch+1),Oi(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 Fl=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Lo&&t.status!==mm&&t.status!==Sh&&t.status!==xh&&t.status!==Th&&t.status!==kh&&t.status!==va&&t.status!==ds?1:0},V2=e=>{if(Fl(e))return ya(e,kr);e.total_in=e.total_out=0,e.data_type=fY;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?mm:t.wrap?Lo:va,e.adler=t.wrap===2?0:1,t.last_flush=-2,eY(t),nn},U2=e=>{const t=V2(e);return t===nn&&EY(e.state),t},AY=(e,t)=>Fl(e)||e.state.wrap!==2?kr:(e.state.gzhead=t,nn),H2=(e,t,n,r,i,l)=>{if(!e)return kr;let v=1;if(t===oY&&(t=6),r<0?(v=0,r=-r):r>15&&(v=2,r-=16),i<1||i>dY||n!==ef||r<8||r>15||t<0||t>9||l<0||l>uY||r===8&&v!==1)return ya(e,kr);r===8&&(r=9);const o=new OY;return e.state=o,o.strm=e,o.status=Lo,o.wrap=v,o.gzhead=null,o.w_bits=r,o.w_size=1<H2(e,t,ef,hY,pY,cY),IY=(e,t)=>{if(Fl(e)||t>Q0||t<0)return e?ya(e,kr):kr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===ds&&t!==Hn)return ya(e,e.avail_out===0?Kf:kr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Mn(e),e.avail_out===0)return n.last_flush=-1,nn}else if(e.avail_in===0&&ty(t)<=ty(r)&&t!==Hn)return ya(e,Kf);if(n.status===ds&&e.avail_in!==0)return ya(e,Kf);if(n.status===Lo&&n.wrap===0&&(n.status=va),n.status===Lo){let i=ef+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=hu||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=wY),i+=31-i%31,os(n,i),n.strstart!==0&&(os(n,e.adler>>>16),os(n,e.adler&65535)),e.adler=1,n.status=va,Mn(e),n.pending!==0)return n.last_flush=-1,nn}if(n.status===mm){if(e.adler=0,gt(n,31),gt(n,139),gt(n,8),n.gzhead)gt(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)),gt(n,n.gzhead.time&255),gt(n,n.gzhead.time>>8&255),gt(n,n.gzhead.time>>16&255),gt(n,n.gzhead.time>>24&255),gt(n,n.level===9?2:n.strategy>=hu||n.level<2?4:0),gt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(gt(n,n.gzhead.extra.length&255),gt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Jt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Sh;else if(gt(n,0),gt(n,0),gt(n,0),gt(n,0),gt(n,0),gt(n,n.level===9?2:n.strategy>=hu||n.level<2?4:0),gt(n,CY),n.status=va,Mn(e),n.pending!==0)return n.last_flush=-1,nn}if(n.status===Sh){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=Jt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,Mn(e),n.pending!==0)return n.last_flush=-1,nn;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=Jt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=xh}if(n.status===xh){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=Jt(e.adler,n.pending_buf,n.pending-i,i)),Mn(e),n.pending!==0)return n.last_flush=-1,nn;i=0}n.gzindexi&&(e.adler=Jt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Th}if(n.status===Th){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=Jt(e.adler,n.pending_buf,n.pending-i,i)),Mn(e),n.pending!==0)return n.last_flush=-1,nn;i=0}n.gzindexi&&(e.adler=Jt(e.adler,n.pending_buf,n.pending-i,i))}n.status=kh}if(n.status===kh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Mn(e),n.pending!==0))return n.last_flush=-1,nn;gt(n,e.adler&255),gt(n,e.adler>>8&255),e.adler=0}if(n.status=va,Mn(e),n.pending!==0)return n.last_flush=-1,nn}if(e.avail_in!==0||n.lookahead!==0||t!==$i&&n.status!==ds){let i=n.level===0?j2(n,t):n.strategy===hu?kY(n,t):n.strategy===lY?TY(n,t):hs[n.level].func(n,t);if((i===La||i===qo)&&(n.status=ds),i===yn||i===La)return e.avail_out===0&&(n.last_flush=-1),nn;if(i===Go&&(t===rY?nY(n):t!==Q0&&(wh(n,0,0,!1),t===iY&&(Oi(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Mn(e),e.avail_out===0))return n.last_flush=-1,nn}return t!==Hn?nn:n.wrap<=0?ey:(n.wrap===2?(gt(n,e.adler&255),gt(n,e.adler>>8&255),gt(n,e.adler>>16&255),gt(n,e.adler>>24&255),gt(n,e.total_in&255),gt(n,e.total_in>>8&255),gt(n,e.total_in>>16&255),gt(n,e.total_in>>24&255)):(os(n,e.adler>>>16),os(n,e.adler&65535)),Mn(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?nn:ey)},MY=e=>{if(Fl(e))return kr;const t=e.state.status;return e.state=null,t===va?ya(e,aY):nn},LY=(e,t)=>{let n=t.length;if(Fl(e))return kr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==Lo||r.lookahead)return kr;if(i===1&&(e.adler=gl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Oi(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,Ro(r);r.lookahead>=ut;){let a=r.strstart,u=r.lookahead-(ut-1);do r.ins_h=Bi(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,Ro(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,nn};var RY=PY,DY=H2,$Y=U2,BY=V2,FY=AY,zY=IY,NY=MY,jY=LY,VY="pako deflate (from Nodeca project)",Ms={deflateInit:RY,deflateInit2:DY,deflateReset:$Y,deflateResetKeep:BY,deflateSetHeader:FY,deflate:zY,deflateEnd:NY,deflateSetDictionary:jY,deflateInfo:VY};const UY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var HY=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)UY(n,r)&&(e[r]=n[r])}}return e},WY=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;vl[254]=vl[254]=1;var YY=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 XY=(e,t)=>{if(t<65534&&e.subarray&&W2)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 XY(l,i)},GY=(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+vl[e[n]]>t?n:t},yl={string2buf:YY,buf2string:KY,utf8border:GY};function qY(){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 Y2=qY;const X2=Object.prototype.toString,{Z_NO_FLUSH:ZY,Z_SYNC_FLUSH:JY,Z_FULL_FLUSH:QY,Z_FINISH:eX,Z_OK:bc,Z_STREAM_END:tX,Z_DEFAULT_COMPRESSION:nX,Z_DEFAULT_STRATEGY:rX,Z_DEFLATED:iX}=Ko;function zl(e){this.options=tf.assign({level:nX,method:iX,chunkSize:16384,windowBits:15,memLevel:8,strategy:rX},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 Y2,this.strm.avail_out=0;let n=Ms.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==bc)throw new Error(Ma[n]);if(t.header&&Ms.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=yl.string2buf(t.dictionary):X2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Ms.deflateSetDictionary(this.strm,r),n!==bc)throw new Error(Ma[n]);this._dict_set=!0}}zl.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?eX:ZY,typeof e=="string"?n.input=yl.string2buf(e):X2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(l===JY||l===QY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=Ms.deflate(n,l),i===tX)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Ms.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===bc;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};zl.prototype.onData=function(e){this.chunks.push(e)};zl.prototype.onEnd=function(e){e===bc&&(this.result=tf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function gm(e,t){const n=new zl(t);if(n.push(e,!0),n.err)throw n.msg||Ma[n.err];return n.result}function aX(e,t){return t=t||{},t.raw=!0,gm(e,t)}function oX(e,t){return t=t||{},t.gzip=!0,gm(e,t)}var sX=zl,lX=gm,uX=aX,cX=oX,fX=Ko,dX={Deflate:sX,deflate:lX,deflateRaw:uX,gzip:cX,constants:fX};const pu=16209,hX=16191;var pX=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=pu;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=pu;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(ro+1),j=new Uint16Array(ro+1);let R=null,B,E,V;for(u=0;u<=ro;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===iy||f!==1))return-1;for(j[1]=0,u=1;uny||e===ay&&y>ry)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<ny||e===ay&&y>ry)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 Ls=bX;const _X=0,K2=1,G2=2,{Z_FINISH:oy,Z_BLOCK:wX,Z_TREES:mu,Z_OK:Ra,Z_STREAM_END:CX,Z_NEED_DICT:SX,Z_STREAM_ERROR:qn,Z_DATA_ERROR:q2,Z_MEM_ERROR:Z2,Z_BUF_ERROR:xX,Z_DEFLATED:sy}=Ko,nf=16180,ly=16181,uy=16182,cy=16183,fy=16184,dy=16185,hy=16186,py=16187,my=16188,gy=16189,_c=16190,jr=16191,Zf=16192,vy=16193,Jf=16194,yy=16195,by=16196,_y=16197,wy=16198,gu=16199,vu=16200,Cy=16201,Sy=16202,xy=16203,Ty=16204,ky=16205,Qf=16206,Ey=16207,Oy=16208,Bt=16209,J2=16210,Q2=16211,TX=852,kX=592,EX=15,OX=EX,Ay=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function AX(){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 Wa=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modeQ2?1:0},eC=e=>{if(Wa(e))return qn;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=nf,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(TX),t.distcode=t.distdyn=new Int32Array(kX),t.sane=1,t.back=-1,Ra},tC=e=>{if(Wa(e))return qn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,eC(e)},nC=(e,t)=>{let n;if(Wa(e))return qn;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?qn:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,tC(e))},rC=(e,t)=>{if(!e)return qn;const n=new AX;e.state=n,n.strm=e,n.window=null,n.mode=nf;const r=nC(e,t);return r!==Ra&&(e.state=null),r},PX=e=>rC(e,OX);let Py=!0,ed,td;const IX=e=>{if(Py){ed=new Int32Array(512),td=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(Ls(K2,e.lens,0,288,ed,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ls(G2,e.lens,0,32,td,0,e.work,{bits:5}),Py=!1}e.lencode=ed,e.lenbits=9,e.distcode=td,e.distbits=5},iC=(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(Wa(e)||!e.output||!e.input&&e.avail_in!==0)return qn;n=e.state,n.mode===jr&&(n.mode=Zf),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=Ra;e:for(;;)switch(n.mode){case nf:if(n.wrap===0){n.mode=Zf;break}for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Jt(n.check,P,2,0),u=0,h=0,n.mode=ly;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Bt;break}if((u&15)!==sy){e.msg="unknown compression method",n.mode=Bt;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=Bt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(P[0]=u&255,P[1]=u>>>8&255,n.check=Jt(n.check,P,2,0)),u=0,h=0,n.mode=uy;case uy: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=Jt(n.check,P,4,0)),u=0,h=0,n.mode=cy;case cy: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=Jt(n.check,P,2,0)),u=0,h=0,n.mode=fy;case fy:if(n.flags&1024){for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Jt(n.check,P,2,0)),u=0,h=0}else n.head&&(n.head.extra=null);n.mode=dy;case dy: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=Jt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=hy;case hy: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 gy: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=vy;break;case 1:if(IX(n),n.mode=gu,t===mu){u>>>=2,h-=2;break e}break;case 2:n.mode=by;break;case 3:e.msg="invalid block type",n.mode=Bt}u>>>=2,h-=2;break;case vy: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=Bt;break}if(n.length=u&65535,u=0,h=0,n.mode=Jf,t===mu)break e;case Jf:n.mode=yy;case yy: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 by: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=Bt;break}n.have=0,n.mode=_y;case _y: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=Ls(_X,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid code lengths set",n.mode=Bt;break}n.have=0,n.mode=wy;case wy: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=Bt;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=Bt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===Bt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Bt;break}if(n.lenbits=9,D={bits:n.lenbits},O=Ls(K2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid literal/lengths set",n.mode=Bt;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},O=Ls(G2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,O){e.msg="invalid distances set",n.mode=Bt;break}if(n.mode=gu,t===mu)break e;case gu:n.mode=vu;case vu: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,pX(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=ky;break}if(b&32){n.back=-1,n.mode=jr;break}if(b&64){e.msg="invalid literal/length code",n.mode=Bt;break}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}n.was=n.length,n.mode=Sy;case Sy: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=Bt;break}n.offset=_,n.extra=b&15,n.mode=xy;case xy: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=Bt;break}n.mode=Ty;case Ty:if(a===0)break e;if(s=f-a,n.offset>s){if(s=n.offset-s,s>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Bt;break}s>n.wnext?(s-=n.wnext,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=vu);break;case ky:if(a===0)break e;i[v++]=n.length,a--,n.mode=vu;break;case Qf:if(n.wrap){for(;h<32;){if(o===0)break e;o--,u|=r[l++]<{if(Wa(e))return qn;let t=e.state;return t.window&&(t.window=null),e.state=null,Ra},RX=(e,t)=>{if(Wa(e))return qn;const n=e.state;return(n.wrap&2)===0?qn:(n.head=t,t.done=!1,Ra)},DX=(e,t)=>{const n=t.length;let r,i,l;return Wa(e)||(r=e.state,r.wrap!==0&&r.mode!==_c)?qn:r.mode===_c&&(i=1,i=gl(i,t,n,0),i!==r.check)?q2:(l=iC(e,t,n,n),l?(r.mode=J2,Z2):(r.havedict=1,Ra))};var $X=tC,BX=nC,FX=eC,zX=PX,NX=rC,jX=MX,VX=LX,UX=RX,HX=DX,WX="pako inflate (from Nodeca project)",Kr={inflateReset:$X,inflateReset2:BX,inflateResetKeep:FX,inflateInit:zX,inflateInit2:NX,inflate:jX,inflateEnd:VX,inflateGetHeader:UX,inflateSetDictionary:HX,inflateInfo:WX};function YX(){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 XX=YX;const aC=Object.prototype.toString,{Z_NO_FLUSH:KX,Z_FINISH:GX,Z_OK:bl,Z_STREAM_END:nd,Z_NEED_DICT:rd,Z_STREAM_ERROR:qX,Z_DATA_ERROR:Iy,Z_MEM_ERROR:ZX}=Ko;function Nl(e){this.options=tf.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 Y2,this.strm.avail_out=0;let n=Kr.inflateInit2(this.strm,t.windowBits);if(n!==bl)throw new Error(Ma[n]);if(this.header=new XX,Kr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=yl.string2buf(t.dictionary):aC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Kr.inflateSetDictionary(this.strm,t.dictionary),n!==bl)))throw new Error(Ma[n])}Nl.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?GX:KX,aC.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===rd&&i&&(l=Kr.inflateSetDictionary(n,i),l===bl?l=Kr.inflate(n,v):l===Iy&&(l=rd));n.avail_in>0&&l===nd&&n.state.wrap>0&&e[n.next_in]!==0;)Kr.inflateReset(n),l=Kr.inflate(n,v);switch(l){case qX:case Iy:case rd:case ZX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===nd))if(this.options.to==="string"){let a=yl.utf8border(n.output,n.next_out),u=n.next_out-a,h=yl.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===bl&&o===0)){if(l===nd)return l=Kr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Nl.prototype.onData=function(e){this.chunks.push(e)};Nl.prototype.onEnd=function(e){e===bl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=tf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function vm(e,t){const n=new Nl(t);if(n.push(e),n.err)throw n.msg||Ma[n.err];return n.result}function JX(e,t){return t=t||{},t.raw=!0,vm(e,t)}var QX=Nl,eK=vm,tK=JX,nK=vm,rK=Ko,iK={Inflate:QX,inflate:eK,inflateRaw:tK,ungzip:nK,constants:rK};const{Deflate:oq,deflate:sq,deflateRaw:aK,gzip:lq}=dX,{Inflate:uq,inflate:cq,inflateRaw:oK,ungzip:fq}=iK;var sK=aK,lK=oK;function My(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 uK=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=My(t);if(console.log("URL params:",n),n.get("share")){const l=lK(new Uint8Array(atob(n.get("share")).split("").map(v=>v.charCodeAt(0))),{to:"string"});if(!l){Wt().raiseError("Error when trying to decode share parameter!",!1);return}n=My(l.split("&")),console.log("Share URL params:",n)}const r={id:-1,image:"",prompt:n.get("prompt")||"",sampler_name:n.get("sampler_name")||"k_euler",seed:Number(n.get("seed"))||-1,steps:Number(n.get("steps")||20),cfg_scale:Number(n.get("cfg_scale")||5),height:Number(n.get("height")||512),width:Number(n.get("width")||512),clip_skip:Number(n.get("clip_skip")||0),frames:Number(n.get("frames")||1),fps:Number(n.get("fps")||16),scheduler:n.get("scheduler")||"default"};rn().generateText2Img(r,!1)},cK=10;function ju(e,t,n,r,i=l=>Wt().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 fK=$o("interrogate",()=>{const e=ie({}),t=ie(!1);async function n(v){Wt().raiseError(v,!1),t.value=!1,e.value={}}async function r(){const v=Ht(),{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();!ju(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}}),ym=e=>(oi("data-v-db184ac6"),e=e(),si(),e),dK={key:0,style:{"margin-top":"16px"}},hK=ym(()=>ne("div",null,[Ue("Drop file here OR "),ne("em",null,"click to upload")],-1)),pK={key:1,style:{"margin-top":"16px"}},mK={key:2},gK={style:{"margin-top":"8px"}},vK=ym(()=>ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),yK={key:0},bK=ym(()=>ne("h3",null,"Caption",-1)),_K={key:0},wK={key:1},CK=ke({__name:"InterrogationView",setup(e){const t=fK(),n=rn(),r=Wt(),i=ie();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 yh(u.raw);t.currentInterrogation.source_image=h,t.interrogateImage()}function v(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=S2();return(u,h)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(z(),le("div",mK,[ne("div",gK,[ue(C(ht),{icon:C(Eg),onClick:C(t).resetInterrogation},{default:he(()=>[Ue("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(z(),be(C(ht),{key:0,icon:C(Eg),onClick:v,disabled:!C(o)},{default:he(()=>[Ue("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):ye("",!0)]),vK,ue(C(Dp),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(z(),le("div",yK,[bK,C(o)?(z(),le("div",wK,[ne("strong",null,Ae(C(o)),1)])):(z(),le("div",_K,"Processing"+Ae(C(a)),1))])):ye("",!0)])):(z(),le("div",pK,[ne("strong",null,"Uploading image"+Ae(C(a)),1)])):(z(),le("div",dK,[ne("div",null,[ue(C(Np),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:he(()=>[ue(C(Re),{size:100},{default:he(()=>[ue(C(ip))]),_:1}),hK]),_:1},512)])]))}});const SK=Zt(CK,[["__scopeId","data-v-db184ac6"]]);function xK(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 TK={class:"form"},kK={key:0,style:{"padding-bottom":"50px"}},EK=ne("h1",{style:{margin:"0"}},"Interrogation",-1),OK=ne("div",null,"Interrogate images to get their predicted descriptions.",-1),AK={class:"sidebar"},PK=ne("span",{style:{height:"100%","font-size":"14px"}},[Ue("Reference Image: "),ne("br"),Ue("(Photomaker/Kontext) ")],-1),IK={class:"main"},MK={class:"image center-horizontal"},LK={key:0},RK=ke({__name:"GenerateView",setup(e){const n=bp(yp).smallerOrEqual("md"),r=rn(),i=Wt(),l=Ps();Ht();const v=fv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSamplers()).map(b=>b.name);return y.length===0?[]:u(y)},[]),o=fv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSchedulers()).map(b=>b.name);return y.length===0?[]:h(y)},[]),a=yt({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: "+xK(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(),uK(),(g,m)=>(z(),le(je,null,[ue(C(pw),{"default-active":C(r).generatorType,collapse:!0,onSelect:s,mode:C(n)?"horizontal":"vertical",class:ce(C(n)?"mobile-generator-types":"generator-types"),style:Ne(C(n)?"overflow-x: auto":"")},{default:he(()=>[ue(du,{index:"Text2Img","icon-one":C(EE),"icon-two":C(Kl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),ue(du,{index:"Img2Img","icon-one":C(Kl),"icon-two":C(Kl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),ue(du,{index:"Inpainting","icon-one":C2,"icon-two":C(Kl),isMobile:C(n)},null,8,["icon-two","isMobile"]),ue(du,{index:"Interrogation","icon-one":EH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",TK,[C(r).generatorType==="Interrogation"?(z(),le("div",kK,[EK,OK,ue(SK)])):(z(),be(C(Rp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:a,onSubmit:m[29]||(m[29]=rt(()=>{},["prevent"]))},{default:he(()=>[ne("div",AK,[ue(C(hB),{modelValue:C(i).activeCollapse,"onUpdate:modelValue":m[24]||(m[24]=y=>C(i).activeCollapse=y),style:{"margin-bottom":"24px"}},{default:he(()=>[ue(C(pB),{title:"Generation Options",name:"1"},{default:he(()=>[ue(WH),ue(vh,{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"]),ue(vh,{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(gE)},{append:he(()=>[ue(C(Lr),{content:"Randomize!",placement:"top"},{default:he(()=>[ue(C(ht),{icon:C(X3),onClick:m[1]||(m[1]=()=>C(r).params.seed=C(oC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(z(),be(C(m0),{key:0,gutter:10},{default:he(()=>[C(r).multiSelect.sampler.state==="Multiple"?(z(),be(C(Ja),{key:0,span:C(n)?24:12},{default:he(()=>[ue(co,{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(Ja),{key:1,span:C(n)?24:12},{default:he(()=>[ue(co,{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(Ja),{key:2,span:C(n)?24:12},{default:he(()=>[ue(co,{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(Ja),{key:3,span:C(n)?24:12},{default:he(()=>[ue(co,{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})),ue(gn,{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(gn,{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(gn,{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),ue(gn,{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"]),ue(gn,{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(gn,{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(gn,{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(gn,{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(gn,{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(gn,{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(gn,{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),ue(gn,{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 120 frames."},null,8,["modelValue","min","max"]),C(r).params.frames>1?(z(),be(gn,{key:9,label:"FPS",prop:"fps",modelValue:C(r).params.fps,"onUpdate:modelValue":m[19]||(m[19]=y=>C(r).params.fps=y),min:C(r).minFps,max:C(r).maxFps,disabled:C(r).params.frames<=1,info:"Frames per second for video generation."},null,8,["modelValue","min","max","disabled"])):ye("",!0),ne("div",null,[PK,ne("input",{class:"el-button",type:"file",id:"extra_image_input",onChange:m[20]||(m[20]=y=>C(r).setExtraImage(y)),accept:"image/*",multiple:""},null,32),ne("button",{onClick:m[21]||(m[21]=y=>C(r).clearExtraImage()),class:"el-button"},"Clear Image"),ue(C(m0),null,{default:he(()=>[ue(C(Ja),{span:C(n)?24:12},{default:he(()=>[ue(H0,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":m[22]||(m[22]=y=>C(r).params.enable_hr=y),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),ue(C(Ja),{span:C(n)?24:12},{default:he(()=>[C(r).generatorType==="Img2Img"?(z(),be(H0,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:C(r).params.send_as_refimg,"onUpdate:modelValue":m[23]||(m[23]=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",IK,[ue(C(ht),{onClick:m[25]||(m[25]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:he(()=>[Ue("Reset")]),_:1}),ue(C(ht),{type:"primary",class:"generate-cancel-btn",style:Ne(C(r).generating?"width: 55%;":""),onClick:m[26]||(m[26]=()=>C(r).generateImage(C(r).generatorType))},{default:he(()=>[ne("span",null," Generate "+Ae(C(r).totalImageCount)+" image"+Ae(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(z(),be(C(ht),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:m[27]||(m[27]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:he(()=>[Ue("Cancel all")]),_:1},8,["disabled"])):ye("",!0)]),ne("div",MK,[ue(C(m$),{class:"center-both generated-image"},{default:he(()=>[!C(r).generating&&C(r).outputs.length==0?(z(),le("div",LK,[/Inpainting/.test(C(r).generatorType)?(z(),be(W0,{key:0})):ye("",!0),/Img2Img/.test(C(r).generatorType)?(z(),be(W0,{key:1})):ye("",!0)])):ye("",!0),!C(i).showGeneratedImages&&C(r).generating?(z(),be(DH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:c(C(r).timer.seconds),onShowGenerated:m[28]||(m[28]=y=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):ye("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(z(),be(tW,{key:2})):ye("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Rs=lk({history:TT("./"),routes:[{path:"/",name:"generate",component:RK},{path:"/images",name:"images",component:()=>Vf(()=>Promise.resolve().then(()=>RG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>Vf(()=>Promise.resolve().then(()=>XG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>Vf(()=>Promise.resolve().then(()=>nq),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function DK(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 yu(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,eta:1,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,fps:16,enable_hr:!1,send_as_refimg:!0,scheduler:"default"}}function oC(){return Math.floor(Math.random()*9999999)+1}const rn=$o("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=ie("Text2Img"),r=ie(""),i=Sn("promptHistory",[]),l=ie(""),v=Sn("negativeLibrary",[]),o=ie(yu()),a=ie({interval:0,seconds:0}),u=ie({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=ie({...h(),sourceProcessing:"inpainting"}),f=ie({...h(),sourceProcessing:"img2img"}),s=we=>we==="Inpainting"?c.value:we==="Img2Img"?f.value:h(),d=ee(()=>s(n.value)),g=ie(""),m=ie(!1),y=ie(!1),b=ie([]),_=ie([]),w=ie(64),S=ee(()=>Ht().allowLargerParams==="Enabled"?3072:1024),x=ie(1),T=ie(20),O=ie(1),P=ee(()=>Ht().allowLargerParams==="Enabled"?150:50),D=ie(1),j=ie(24),R=ie(0),B=ie(1),E=ie(0),V=ie(1),te=ie(0),J=ie(10),se=ie(1),M=ie(120),U=ie(16),A=ie(24),L=(we,$e,Ve)=>Array.from({length:($e-we+1)/Ve},(Qe,at)=>(at+we)*Ve),Q=ie(L(te.value,J.value,1)),N=ie(L(D.value,j.value,.5)),I=ee(()=>{const we=(pi,mi,Dr=1)=>pi*(mi.state==="Multiple"&&mi.selected.length>0?mi.selected.length:Dr),Ve=o.value.n*F().length,Qe=we(Ve,u.value.sampler),at=we(Qe,u.value.scheduler),Ke=we(at,u.value.steps),Rt=we(Ke,u.value.guidance);return we(Rt,u.value.clipSkip)});function W(){return o.value=yu(),c.value=h(),f.value=h(),b.value=[],Wt().showGeneratedImages=!1,q(),!0}function q(){_.value=[]}function re(){b.value=[]}async function fe(){const we=Ht(),$e=we.baseURL.length===0?".":we.baseURL,Ve=await fetch(`${$e}/sdapi/v1/loras`),Qe=await Ve.json();return ju(Ve,Qe,200,"Failed to get available LoRAs")?Qe:[]}async function me(we){if(!e.includes(we))return[];if(r.value==="")return H("Failed to generate: No prompt submitted.");const $e=Ps(),Ve=Wt();$e.saveImages();const{sourceImage:Qe,maskImage:at,sourceProcessing:Ke}=s(we);_e(r.value);const Rt=[],pi=F().map(nt=>{const Vt=nt.split(" ### ");return{full_prompt:nt,prompt:Vt[0],negative_prompt:Vt[1]||""}}).map(nt=>{const[Vt,Br]=DK(nt.prompt);return{...nt,prompt:Vt,extractedLoras:Br}}),mi=pi.some(nt=>nt.extractedLoras.length>0)?await fe():[],Dr=pi.map(({extractedLoras:nt,...Vt})=>{const Br=nt.length>0&&mi.length>0?nt.map(er=>{const Ka=mi.find(Ut=>Ut.name===er.name||Ut.path===er.name);return{path:Ka?Ka.path:er.name,multiplier:er.multiplier,...er.is_high_noise?{is_high_noise:!0}:{}}}):[];return{...Vt,...Br.length>0?{lora:Br}:{}}}),{seed:mr,cfg_scale:_m,eta:$r,steps:fC,clip_skip:dC,sampler_name:hC,scheduler:pC,n:mC,...wm}=o.value,af=parseInt(mr.toString()),gC=isNaN(af)||af<0?oC():af,vC=Array.from({length:mC},(nt,Vt)=>gC+Vt),Xa=(nt,Vt)=>nt.state==="Disabled"?[]:nt.state==="Enabled"?[Vt]:nt.state==="Multiple"&&nt.selected.length===0?[]:nt.selected,yC={promptVariant:Dr,seed:vC,cfg_scale:Xa(u.value.guidance,_m),eta:Xa(u.value.eta,$r),steps:Xa(u.value.steps,fC),clip_skip:Xa(u.value.clipSkip,dC),sampler_name:Xa(u.value.sampler,hC),scheduler:Xa(u.value.scheduler,pC)},bC=(nt=>Object.entries(nt).filter(([Br,er])=>er.length>0).reduce((Br,[er,Ka])=>{const Ut=[];for(const wC of Br)for(const CC of Ka)Ut.push({...wC,[er]:CC});return Ut},[{}]))(yC),_C=[await oe()];for(const nt of bC){const{promptVariant:{full_prompt:Vt,...Br},...er}=nt,Ka=we==="Img2Img"?wm.send_as_refimg:!1;let Ut={prompt:Vt,params:{...wm,send_as_refimg:Ka,...er,...Br,init_images:Qe?[Qe.split(",")[1]]:[],mask:at,inpainting_mask_invert:at?0:null,inpainting_fill:at?1:null},source_image:Qe==null?void 0:Qe.split(",")[1],source_mask:at,source_processing:Ke,models:_C};Ut.params.sampler_name=="default"&&delete Ut.params.sampler_name,Ut.params.scheduler=="default"&&delete Ut.params.scheduler,!Ut.params.frames||Ut.params.frames<=1?(delete Ut.params.frames,delete Ut.params.fps):Ut.params.fps=Math.min(A.value,Math.max(U.value,Math.round(Number(Ut.params.fps)||yu().fps))),Me&&Me.length>0&&(Ut.params.extra_images=Me),Ht().alsoRequestAvi==="Enabled"&&Ut.params.frames&&Ut.params.frames>1&&(Ut.params.video_output_type=2),Rt.push(Ut)}let Cm=!1;m.value||(Cm=!0,b.value=[]),m.value=!0,Ve.showGeneratedImages=!1;let Sm=_.value.filter(nt=>!nt.gathered&&!nt.failed).length;for(let nt=0;nt{a.value.seconds++},1e3);!_.value.every(nt=>nt.gathered||nt.failed)&&!y.value;){const nt=_.value.find(Vt=>!Vt.gathered&&!Vt.failed);if(!nt)break;nt.gathered=!0;try{const Vt=await G(nt.params);if(!Vt){nt.failed=!0;continue}ve([{...Vt,...nt}])}catch(Vt){nt.failed=!0,console.error("Error fetching image:",Vt)}}}async function ve(we){const $e=Ia();console.log(we);const Ve=await Promise.all(we.map(async Ke=>{const Rt=Ke.images[0],pi=!!Ke.animated?"gif":"png",mi=Ke.extra_data?`data:video/avi;base64,${Ke.extra_data}`:"";let Dr={id:-1,image:`data:image/${pi};base64,${Rt}`,prompt:Ke.prompt,modelName:Ke.models[0],frames:Ke.params.frames,fps:Ke.params.fps,extra_avi:mi,enable_hr:Ke.params.enable_hr,send_as_refimg:Ke.params.send_as_refimg};if(Ke.info&&typeof Ke.info=="string"&&Ke.info.trim()!=="")try{const mr=JSON.parse(Ke.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip","fps"].forEach($r=>{mr[$r]!=null&&mr[$r]!=null?Dr[$r]=mr[$r]:Ke.params[$r]!=null&&(Dr[$r]=Ke.params[$r])}),mr.extra_generation_params&&mr.extra_generation_params["Schedule type"]?Dr.scheduler=mr.extra_generation_params["Schedule type"]:Dr.scheduler=Ke.params.scheduler}catch(mr){console.warn("Failed to parse info JSON:",mr)}return Dr})),Qe=await $e.pushOutputs(Ve),at=0;return b.value=[...Qe.map(Ke=>({type:"image",index:at,output:Ke})),...b.value].sort((Ke,Rt)=>Ke.index-Rt.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,Wt().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Ve}async function H(we){const $e=Wt();return we&&$e.raiseError(we,!1),[]}function Y(we,$e,Ve,Qe){return $e<=Ve?$e:(Wt().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${we}' to its default value instead of ${$e}.`,!0),Qe)}async function k(we,$e=!0){const Ve=yu();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",Rs.push("/"),$e&&(we.width=we.width||Ve.width,we.height=we.height||Ve.height),we.prompt){const Qe=we.prompt.split(" ### ");r.value=Qe[0],l.value=Qe[1]||""}if(we.sampler_name){o.value.sampler_name=we.sampler_name;const at=(await Ce()).find(Ke=>Ke.aliases&&Ke.aliases.includes(we.sampler_name));at&&(o.value.sampler_name=at.name)}we.steps&&(o.value.steps=Y("steps",we.steps,P.value,Ve.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=Y("width",we.width,S.value,Ve.width)),we.height&&(o.value.height=Y("height",we.height,S.value,Ve.height)),we.seed&&(o.value.seed=we.seed),we.clip_skip&&(o.value.clip_skip=Y("clip_skip",we.clip_skip,J.value,Ve.clip_skip)),we.scheduler&&(o.value.scheduler=we.scheduler),we.frames&&(o.value.frames=Y("frames",we.frames,M.value,Ve.frames)),we.fps&&(o.value.fps=Math.min(A.value,Math.max(U.value,Math.round(Y("fps",we.fps,A.value,Ve.fps)))))}function K(we){const $e=Ps();n.value="Img2Img",f.value.sourceImage=we,$e.drawing=!1,b.value=[],Rs.push("/"),Un.fabric.Image.fromURL(we,$e.newImage)}function X(we){const $e=Ps();b.value=[],c.value.sourceImage=we,n.value="Inpainting",Rs.push("/"),Un.fabric.Image.fromURL(we,$e.newImage)}function $(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function F(){const we=$(),$e=we.match(/\{(.*?)\}/g)||[];if($e.length===0)return[we];let Ve=[];return $e.forEach(Qe=>{const at=[],Ke=Qe.replace("{","").replace("}","").split("|");Ve.length===0?Ke.forEach(Rt=>{const Qn=we.replace(Qe,Rt);at.push(Qn)}):Ve.forEach(Rt=>{Ke.forEach(Qn=>{const pi=Rt.replace(Qe,Qn);at.push(pi)})}),Ve=[...at]}),Ve}async function G(we){const $e=Ht();try{const Ve=await fetch(`${$e.baseURL.length===0?".":$e.baseURL}/sdapi/v1/${we.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)}),Qe=await Ve.json();return ju(Ve,Qe,200,"Failed to fetch",de)?Qe:!1}catch{return!1}}function de(we){return Wt().raiseError(we,!1),y.value=!1,b.value=[],!1}async function oe(){const we=Ht(),$e=await fetch(`${we.baseURL.length===0?".":we.baseURL}/sdapi/v1/sd-models`),Ve=await $e.json();if(!!ju($e,Ve,200,"Failed to get available models"))return Ve.length===0?"(No model loaded)":Ve[0].model_name}const Z=ie(0),pe=new Map;function ae(){pe.clear(),Z.value++}xe(()=>Ht().baseURL,()=>{ae()});async function ge(we){const $e=Ht(),Qe=(($e.baseURL.length===0?".":$e.baseURL).replace(/\/+$/,"")||".")+"/"+we.replace(/^\/+/,"");if(pe.has(Qe))return pe.get(Qe);const at=(async()=>{try{const Ke=await fetch(Qe);if(Ke.ok)return await Ke.json();console.error(`API Error: ${Ke.status} ${Ke.statusText} at ${Qe}`)}catch(Ke){console.error(`Fetch error for ${Qe}:`,Ke)}return pe.delete(Qe),null})();return pe.set(Qe,at),at}async function Ce(){const we=await ge("/sdapi/v1/samplers");return Array.isArray(we)?we:[]}async function Ee(){const we=await ge("/sdapi/v1/schedulers");return Array.isArray(we)?we:[]}function Oe(we){v.value.indexOf(we)===-1&&(v.value=[...v.value,we])}function ze(we){v.value=v.value.filter($e=>$e!=we)}function _e(we){if(i.value.findIndex($e=>$e.prompt===we)===-1){if(i.value.length>=10+i.value.filter($e=>$e.starred).length){const $e=i.value.filter(Qe=>!Qe.starred),Ve=i.value.findIndex(Qe=>Qe===$e[$e.length-1]);i.value.splice(Ve,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:we}]}}function Te(we){i.value=i.value.filter($e=>$e.prompt!=we&&$e!=we)}function De(){return!1}var Me=[];function bt(we){let $e=we.target;if(Me=[],$e.files.length>0)for(let Ve=0;Ve<$e.files.length;++Ve){let Qe=$e.files[Ve];const at=new FileReader;at.onload=function(Ke){let Rt=Ke.target?Ke.target.result:"";Rt.includes("data:image")&&(Rt=Rt.split(",")[1]),console.log(Rt),Me.push(Rt)},at.onerror=function(){console.log("Error reading file.")},at.readAsDataURL(Qe)}else console.log("No file to load")}function _t(){Me=[];const we=document.getElementById("extra_image_input");we&&(we.value="")}return{generatorType:n,prompt:r,params:o,outputs:b,inpainting:c,img2img:f,uploadDimensions:g,cancelled:y,multiSelect:u,negativePrompt:l,generating:m,negativePromptLibrary:v,minDimensions:w,maxDimensions:S,minImages:x,maxImages:T,minSteps:O,maxSteps:P,minCfgScale:D,maxCfgScale:j,minDenoise:E,maxDenoise:V,minClipSkip:te,maxClipSkip:J,minFrames:se,maxFrames:M,minFps:U,maxFps:A,minEta:R,maxEta:B,clipSkipList:Q,cfgList:N,queue:_,promptHistory:i,timer:a,validGeneratorTypes:e,sourceGeneratorTypes:t,currentImageProps:d,totalImageCount:I,generateImage:me,generateText2Img:k,generateImg2Img:K,generateInpainting:X,getPrompt:De,resetStore:W,clearQueue:q,clearOutputs:re,pushToNegativeLibrary:Oe,removeFromNegativeLibrary:ze,pushToPromptHistory:_e,removeFromPromptHistory:Te,setExtraImage:bt,clearExtraImage:_t,getAvailableSamplers:Ce,getAvailableSchedulers:Ee,cacheVersion:Z,invalidateApiCaches:ae,getCachedEndpoint:ge}});"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var rf=e=>new DataView(new ArrayBuffer(e)),Ya=e=>new Uint8Array(e.buffer||e),fo=e=>new TextEncoder().encode(String(e));function $K(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:fo(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:Ya(e)};if(Symbol.asyncIterator in e)return{t,o:sC(e)};throw new TypeError("Unsupported input format.")}function sC(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=BK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function BK(e){return typeof e=="string"?fo(e):e instanceof Uint8Array?e:Ya(e)}function FK(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=fo(t)),e instanceof File)return{i:t||fo(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||fo(v),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:fo(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 zK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:NK,m:jK}=zK.exports,VK=Ya(jK).subarray(65536);function Ly(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))VK.set(n),t=NK(n.length,t);return t}function lC(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 UK(e){const t=rf(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),lC(e.t,t,10),t.setUint16(26,e.i.length,1),Ya(t)}async function*HK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=Ly(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=Ly(r,e.u),e.A+=r.length,yield r}}}function WK(e){const t=rf(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),Ya(t)}function YK(e,t){const n=rf(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),lC(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),Ya(n)}function XK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function KK(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(sC(async function*(r){const i=[];let l=0,v=0;for await(const u of r)yield UK(u),yield u.i,yield*HK(u),yield WK(u),i.push(YK(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=rf(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 Ya(a)}(async function*(r){for await(const i of r){const[l,v]=XK(i);yield Object.assign($K(...v),FK(...l))}}(e))),{headers:n})}async function uC(e,t=!0,n){const r=Ht();t&&Hi({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 ma(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await ma(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await ma(u,"image/gif")}):i.push({name:f+".webp",input:await ma(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await KK(i).blob(),v=document.createElement("a");v.href=URL.createObjectURL(l),v.download="sdui_images.zip",v.click()}async function GK(e,t){const n=Ht(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await ma(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await ma(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await ma(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 qK=ke({__name:"ImageActions",props:{imageData:null,onDelete:null,showDismiss:{type:Boolean}},setup(e){const t=e,n=rn(),r=Ia(),i=()=>{kw.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),Hi({type:"success",message:"Deleted Image"})})},l=()=>{rn().clearOutputs(),Wt().showGeneratedImages=!1,rn().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,fps:o.fps,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(sK(f)))),await navigator.clipboard.writeText(c),Hi({type:"success",message:"Copied shareable link to clipboard"})}return(o,a)=>(z(),le(je,null,[ue(C(ht),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:C(Fc),plain:""},{default:he(()=>[Ue("Delete")]),_:1},8,["icon"]),ue(C(ht),{class:"compact-button",onClick:a[0]||(a[0]=u=>C(GK)(e.imageData.image,`${e.imageData.seed}-${e.imageData.prompt}`)),type:"success",size:"small",icon:C(Ws),plain:""},{default:he(()=>[Ue("Download")]),_:1},8,["icon"]),e.imageData.starred?ye("",!0):(z(),be(C(ht),{key:0,class:"compact-button",onClick:a[1]||(a[1]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(w4),plain:""},{default:he(()=>[Ue("Star")]),_:1},8,["icon"])),e.imageData.starred?(z(),be(C(ht),{key:1,class:"compact-button",onClick:a[2]||(a[2]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(g_),plain:""},{default:he(()=>[Ue("Unstar")]),_:1},8,["icon"])):ye("",!0),ue(C(ht),{class:"compact-button",onClick:a[3]||(a[3]=u=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Txt2img")]),_:1}),ue(C(ht),{class:"compact-button",onClick:a[4]||(a[4]=u=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Img2img")]),_:1}),ue(C(ht),{class:"compact-button",onClick:a[5]||(a[5]=u=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Inpaint")]),_:1}),e.showDismiss?(z(),be(C(ht),{key:2,class:"compact-button",onClick:a[6]||(a[6]=u=>l()),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Dismiss")]),_:1})):ye("",!0),ue(C(ht),{class:"compact-button",onClick:a[7]||(a[7]=u=>v(e.imageData)),type:"success",icon:C($3),size:"small",plain:""},{default:he(()=>[Ue("Share")]),_:1},8,["icon"])],64))}});const cC=Zt(qK,[["__scopeId","data-v-ebc469c5"]]),ZK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},JK=["src"],QK={style:{"font-size":"18px","font-weight":"500"}},eG={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},tG={key:0},nG={key:1},rG=["onClick"],iG=ke({__name:"ImageDialog",setup(e){const t=Ia(),n=Wt(),r=ie();fM(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=ie(t.currentOutputs[0]);xe(()=>n.activeModal,async()=>{const a=t.currentOutputs.find(u=>u.id===n.activeModal);if(a)return l.value=a;l.value=await zt.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(nF),{"model-value":C(i),width:(h=l.value)==null?void 0:h.width,class:"image-viewer",onClosed:v,"align-center":""},{footer:he(()=>[ue(cC,{"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",ZK,[(c=l.value)!=null&&c.image?(z(),le("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,JK)):ye("",!0)])],512),ne("div",QK,Ae(((f=l.value.prompt)==null?void 0:f.split("###")[0])||"Unknown Creation"),1),ne("div",eG,[ne("div",null,"Negative Prompt: "+Ae(((s=l.value.prompt)==null?void 0:s.split("###")[1])||"None"),1),ne("span",null,"Model: "+Ae(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Ae(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Ae(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Ae(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Ae(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Ae(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Ae((d=l.value.clip_skip)!=null?d:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Ae(l.value.width||"???")+"x"+Ae(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Ae(l.value.frames||"1"),1),l.value.frames&&l.value.frames>1?(z(),le("span",tG," - FPS: "+Ae(l.value.fps||"Unknown"),1)):ye("",!0),l.value.extra_avi?(z(),le("span",nG,[Ue(" - "),ne("a",{href:"#",onClick:rt(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,rG)])):ye("",!0)])]}),_:1},8,["model-value","width"])}}});const aG=e=>(oi("data-v-8f4d2380"),e=e(),si(),e),oG=aG(()=>ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)),sG={class:"generator-icons"},lG=ke({__name:"App",setup(e){const n=bp(yp).smallerOrEqual("md"),r=Wt();Ht();const i=ck(),l=ie();return xe(()=>i.path,v=>{l.value&&l.value.open(v)}),(v,o)=>(z(),le(je,null,[ne("div",{class:ce({"menu-container":!C(n)})},[ue(C(pw),{"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(Bp),{key:0,class:"remove-item-styling center-vertical"},{title:he(()=>[oG]),_:1})),ue(as,{isMobile:C(n),index:"/"},{icon:he(()=>[ne("div",sG,[ue(C(Re),null,{default:he(()=>[ue(C(wO))]),_:1}),C(r).showGeneratorBadge?(z(),be(C(Re),{key:0,class:"generator-badge",size:10},{default:he(()=>[ue(dH)]),_:1})):ye("",!0)])]),title:he(()=>[Ue("Generate")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/images"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(Q3))]),_:1})]),title:he(()=>[Ue("Images")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/about"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(d_))]),_:1})]),title:he(()=>[Ue("About")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/options"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(M4))]),_:1})]),title:he(()=>[Ue("Options")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/return"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(l_))]),_:1})]),title:he(()=>[Ue("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:ce({view:!C(n)})},[ue(C(s_))],2),ue(iG)],64))}});const uG=Zt(lG,[["__scopeId","data-v-8f4d2380"]]);const bm=eT(uG);bm.use(rT());bm.use(Rs);bm.mount("#app");Rs.replace("/");window.addEventListener("beforeunload",e=>{rn().generating&&(e.preventDefault(),e.returnValue="")});const cG={key:1,class:"image-action"},fG=ke({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=Wt(),r=ie(null);VI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=ie(!1);cM(r,([{isIntersecting:v}])=>{v&&(i.value=v)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(v,o)=>(z(),le("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(z(),be(C(Dp),{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:Ne(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):ye("",!0),i.value?(z(),le("div",cG,[e.imageData.starred?(z(),be(C(Re),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:he(()=>[ue(C(g_))]),_:1})):ye("",!0),C(n).multiSelect?(z(),le("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[ue(C(Re),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:he(()=>[C(l)?ye("",!0):(z(),be(C(Sl),{key:0})),C(l)?(z(),be(C(c_),{key:1})):ye("",!0)]),_:1},8,["color"])])):ye("",!0)])):ye("",!0)],512))}});const Ry=Zt(fG,[["__scopeId","data-v-b9569bbd"]]);function dG({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=t1(),i=ee(()=>r.value<=e),l=ie(!0),{y:v}=uM(window);let o=v.value,a=0;return xe(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 hG={},pG={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},mG=ne("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-696 72h136v656H184V184zm656 656H384V384h456v456zM384 320V184h456v136H384z",fill:"currentColor"},null,-1),gG=[mG];function vG(e,t){return z(),le("svg",pG,gG)}const yG=Zt(hG,[["render",vG]]),bG=e=>(oi("data-v-b39b47c5"),e=e(),si(),e),_G={class:"options"},wG=["onClick"],CG=["onClick"],SG=["onClick"],xG={key:1,class:"center-both",style:{gap:"12px"}},TG={key:2},kG=bG(()=>ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),EG=[kG],OG={key:0},AG={key:0,style:{display:"flex",gap:"8px"}},PG={key:1,class:"images"},IG={key:1},MG=ke({__name:"ImagesView",setup(e){const{width:t}=t1(),{isVisible:n,isMobile:r}=dG(),i=Ia(),l=Ht(),v=Wt();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 zt.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=()=>{kw.confirm(`This action will permanently delete ${v.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(v.selected)})};dv(["a","A","ArrowLeft"],v.openModalToLeft),dv(["d","D","ArrowRight"],v.openModalToRight);async function f(){uC(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(),le(je,null,[ne("div",{class:ce(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[ne("div",_G,[ue(C(ru),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[ue(C(c4))]),_:1})]),_:1})]),default:he(()=>[(z(),le(je,null,Nt(["Newest","Oldest"],m=>ne("div",{key:m,onClick:()=>C(i).sortBy=m,class:ce(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Ae(m),11,wG)),64))]),_:1}),ue(C(ru),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[ue(C(d3))]),_:1})]),_:1})]),default:he(()=>[(z(),le(je,null,Nt(["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":""}`)},Ae(C(i).filterBy===m?"Showing":"Show")+" "+Ae(m),11,CG)),64))]),_:1}),ue(C(ru),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[ue(yG)]),_:1})]),_:1})]),default:he(()=>[(z(),le(je,null,Nt([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>ne("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:ce(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Ae(m.label),11,SG)),64))]),_:1}),ue(C(ru),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[C(v).multiSelect?(z(),be(C(c_),{key:0})):(z(),be(C(Sl),{key:1}))]),_:1})]),_:1})]),default:he(()=>[C(v).multiSelect?(z(),le("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(),le("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(),le("div",{key:2,class:"el-select-dropdown__item selected",onClick:h},"Deselect All")):(z(),le("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(),le("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(z(),le("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(z(),be(C(k9),{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(),le("div",xG,[ne("div",null,Ae(C(v).selected.length)+" selected",1),ue(C(ht),{type:"danger",onClick:c,icon:C(Fc),plain:""},{default:he(()=>[Ue("Delete")]),_:1},8,["icon"]),ue(C(ht),{type:"success",onClick:f,icon:C(Ws),plain:"",style:{margin:"0"}},{default:he(()=>[Ue("Download")]),_:1},8,["icon"])])):(z(),le("div",TG,EG))],2),C(i).outputsLength!=0?(z(),le("div",OG,[C(i).currentLayout==="dynamic"?(z(),le("div",AG,[(z(!0),le(je,null,Nt(C(s),(m,y)=>(z(),le("div",{key:y,style:{flex:"1 1 0%"}},[(z(!0),le(je,null,Nt(m,b=>(z(),be(Ry,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ye("",!0),C(i).currentLayout==="grid"?(z(),le("div",PG,[(z(!0),le(je,null,Nt(C(i).currentOutputs,m=>(z(),be(Ry,{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(),le("div",IG,[ue(C(GF),{description:"No Images Found"})])):ye("",!0)],64))}});const LG=Zt(MG,[["__scopeId","data-v-b39b47c5"]]),RG=Object.freeze(Object.defineProperty({__proto__:null,default:LG},Symbol.toStringTag,{value:"Module"})),DG=["href"],$G=ke({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=vt("router-link");return z(),le(je,null,[e.router?ye("",!0):(z(),le("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[Se(t.$slots,"default",{},void 0,!0)],8,DG)),e.router?(z(),be(r,{key:1,to:e.href},{default:he(()=>[Se(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ye("",!0)],64)}}});const BG=Zt($G,[["__scopeId","data-v-17b53b7d"]]),jl=e=>(oi("data-v-ecc278c5"),e=e(),si(),e),FG={class:"about"},zG={class:"about-content"},NG=jl(()=>ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),jG=jl(()=>ne("div",null,[Ue("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"),Ue(".")],-1)),VG=jl(()=>ne("br",null,null,-1)),UG=jl(()=>ne("div",null,"If you want to help improve this tool, you can find the currently maintained source code from this modified version on https://github.com/LostRuins/stable-ui and https://github.com/henk717/stable-ui, which is based off https://github.com/ayunami2000/stable-ui, which derives from the original AI Horde version on https://github.com/aqualxx/stable-ui (Original author aqualxx#5004). Feel free to contribute!",-1)),HG=jl(()=>ne("br",null,null,-1)),WG=ke({__name:"AboutView",setup(e){return(t,n)=>(z(),le("div",FG,[ne("div",zG,[NG,jG,VG,UG,HG,ne("div",null,[Ue("You can find the KoboldAI community and authors of this fork on the "),ue(BG,{href:"https://koboldai.org/discord"},{default:he(()=>[Ue("KoboldAI Discord")]),_:1})])])]))}});const YG=Zt(WG,[["__scopeId","data-v-ecc278c5"]]),XG=Object.freeze(Object.defineProperty({__proto__:null,default:YG},Symbol.toStringTag,{value:"Module"}));const io=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(Ri),{prop:e.prop},{label:he(()=>[ue($l,{info:e.info,"label-style":e.labelStyle},{default:he(()=>[Se(l.$slots,"label",{},()=>[Ue(Ae(e.label),1)])]),_:3},8,["info","label-style"])]),default:he(()=>[ue(C(U$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:he(()=>[(z(!0),le(je,null,Nt(e.options,o=>(z(),be(C(H$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),Se(l.$slots,"inline")]),_:3},8,["prop"]))}}),Zo=e=>(oi("data-v-0345ee1f"),e=e(),si(),e),KG=Zo(()=>ne("h1",null,"Options",-1)),GG=Zo(()=>ne("h2",null,"Generation Options",-1)),qG=Zo(()=>ne("h3",null,"Parameter Controls",-1)),ZG=Zo(()=>ne("h2",null,"Image Options",-1)),JG=Zo(()=>ne("div",null,[Ue("Drop file here OR "),ne("em",null,"click to upload")],-1)),QG=Zo(()=>ne("h2",null,"General Options",-1)),eq=ke({__name:"OptionsView",setup(e){const t=Ht(),n=Ia(),r=rn(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=ie([]),v=ie(),o=ie(!1),a=ie(0);async function u(c){n.importFromZip(c),v.value.clearFiles()}async function h(){Hi({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const c=await zt.outputs.toCollection().primaryKeys();await uC(c,!1,()=>{a.value++}),o.value=!1,a.value=0}return(c,f)=>(z(),le(je,null,[KG,ue(C(Rp),{"label-position":"top",model:C(t).options,onSubmit:f[10]||(f[10]=rt(()=>{},["prevent"]))},{default:he(()=>[ue(C(qj),{type:"border-card",style:{"min-height":"50vh"}},{default:he(()=>[ue(C(Mf),{label:"\u{1F5A8}\uFE0F Generation"},{default:he(()=>[GG,ue(C(Ri),{label:"Base URL"},{default:he(()=>[ue(C(Ua),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":f[0]||(f[0]=s=>C(t).baseURL=s)},null,8,["modelValue"])]),_:1}),qG,(z(!0),le(je,null,Nt(C(r).multiSelect,(s,d)=>{var g;return z(),le("div",{key:d},[ue(io,{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)),ue(io,{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"]),ue(co,{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"]),ue(io,{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}),ue(C(Mf),{label:"\u{1F4F7} Images"},{default:he(()=>[ZG,ue(gn,{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"]),ue(io,{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"]),ue(io,{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"]),ue(io,{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"]),ue(C(Ri),{label:"Export Images (ZIP File)"},{default:he(()=>[o.value?(z(),be(C(ht),{key:1,icon:C(Ws),disabled:""},{default:he(()=>[Ue("Downloading... ("+Ae(a.value)+" / "+Ae(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(z(),be(C(ht),{key:0,icon:C(Ws),onClick:f[8]||(f[8]=s=>h())},{default:he(()=>[Ue("Download "+Ae(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),ue(C(Ri),{label:"Import Images (ZIP File)"},{default:he(()=>[ue(C(Np),{drag:"",ref_key:"upload",ref:v,"auto-upload":!1,onChange:u,"file-list":l.value,limit:1,multiple:""},{default:he(()=>[ue(C(Re),{size:100},{default:he(()=>[ue(C(ip))]),_:1}),JG]),_:1},8,["file-list"])]),_:1})]),_:1}),ue(C(Mf),{label:"\u2699\uFE0F General"},{default:he(()=>[QG,ue(co,{label:"Color Scheme",prop:"colorScheme",modelValue:C(t).options.colorMode,"onUpdate:modelValue":f[9]||(f[9]=s=>C(t).options.colorMode=s),options:i},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}});const tq=Zt(eq,[["__scopeId","data-v-0345ee1f"]]),nq=Object.freeze(Object.defineProperty({__proto__:null,default:tq},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=ie({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=ie({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>rn().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>rn().currentImageProps),v=ee({get:()=>i.value.drawing&&!r.value,set:A=>i.value.drawing=A}),o=ie(512),a=ie(512),u=ie(!1),h=ie(30),c=ie(!1),f=new Un.fabric.Circle({radius:h.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=ie("Erase"),d=ie("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 Un.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=rn();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,fe=0,me=A.width,ve=A.height,H=0,Y=0,k=W.width,K=W.height;switch(I){case"Stretch":break;case"ScaleAndCrop":{const X=W.width/A.width,$=W.height/A.height;X>$?(ve=W.height/X,fe=(A.height-ve)/2):(me=W.width/$,re=(A.width-me)/2);break}case"ScaleAndPad":{const X=W.width/A.width,$=W.height/A.height;X<$?(K=A.height*X,Y=(W.height-K)/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,fe=(A.height-W.height)/2):(K=A.height,Y=(W.height-A.height)/2);break}}return q.drawImage(A,re,fe,me,ve,H,Y,k,K),W}function P(){const A=rn(),L=Ht();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=rn();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=";Un.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 Un.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 Un.fabric.Rect({width:L||o.value,height:Q||a.value,left:0,top:0,fill:N||"transparent",absolutePositioned:I||!0,selectable:!1});return new Un.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=rn();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 iW={},aW={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},oW=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),sW=[oW];function lW(e,t){return z(),le("svg",aW,sW)}const uW=Zt(iW,[["render",lW]]);async function cW(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 fW(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 cW(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 cm=e=>(oi("data-v-d3bd38bf"),e=e(),si(),e),dW=cm(()=>ne("div",null,[Ue("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1)),hW={key:0},pW=cm(()=>ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),mW={class:"canvas-container"},gW=cm(()=>ne("canvas",{id:"canvas"},null,-1)),vW={class:"action-buttons",style:{left:"10px",right:"unset"}},yW={class:"action-buttons"},bW=ke({__name:"CustomCanvas",setup(e){const t=rn(),n=Wt(),r=Ps(),i=ie();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 yh(a.raw);t.currentImageProps.sourceImage=u,r.drawing=!1,Un.fabric.Image.fromURL(u,r.newImage)}function v(){t.currentImageProps.sourceImage="",r.resetCanvas()}tt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Un.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Xt(()=>{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(),le(je,null,[C(t).currentImageProps.sourceImage?ye("",!0):(z(),be(C(Np),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:he(()=>[C(t).generatorType==="Img2Img"?(z(),le("div",hW,[pW,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))},[ue(C(Re),{size:20,style:{"margin-right":"2px"}},{default:he(()=>[ue(C2)]),_:1}),Ue("draw something")])])):ye("",!0)]),default:he(()=>[ue(C(Re),{size:100},{default:he(()=>[ue(C(ip))]),_:1}),dW]),_:1},512)),St(ne("div",null,[ne("div",mW,[gW,ne("div",vW,[ue(C(ht),{onClick:u[1]||(u[1]=h=>C(r).undoAction()),icon:C(p_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),ue(C(ht),{onClick:u[2]||(u[2]=h=>C(r).redoAction()),icon:C(m_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",yW,[ue(C(ht),{onClick:u[3]||(u[3]=h=>C(r).resetDrawing()),icon:C(Or),plain:""},null,8,["icon"]),ue(C(ht),{onClick:v,icon:C(Fc),plain:""},null,8,["icon"]),ue(C(ht),{onClick:u[4]||(u[4]=h=>C(r).downloadMask()),icon:C(Ws),plain:""},null,8,["icon"]),ue(C(ht),{onClick:u[5]||(u[5]=h=>C(r).flipErase()),icon:C(r).erasing?C(o3):uW,plain:""},null,8,["icon"]),C(r).drawing?(z(),be(C(FB),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":u[6]||(u[6]=h=>C(r).drawColor=h),"show-alpha":""},null,8,["modelValue"])):ye("",!0)]),ue(C(Rp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:he(()=>[ue(gn,{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),[[jt,C(t).currentImageProps.sourceImage]])],64))}});const W0=Zt(bW,[["__scopeId","data-v-d3bd38bf"]]),_W={class:"centerIcons"},wW={class:"stackedIcons"},CW=ke({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return Bx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(z(),le("div",_W,[ne("div",wW,[ue(C(Re),{class:"firstIcon",size:e.size},{default:he(()=>[(z(),be(Et(t.iconOne)))]),_:1},8,["size"]),ue(C(Re),{class:"secondIcon",size:e.size},{default:he(()=>[(z(),be(Et(t.iconTwo)))]),_:1},8,["size"])])]))}});const SW=Zt(CW,[["__scopeId","data-v-74586a39"]]),xW={key:1,style:{width:"40px"}},du=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(()=>[ue(C(Bp),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:he(()=>[e.iconTwo?(z(),be(SW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(z(),le("div",xW,[ue(C(Re),{style:{width:"35px"},size:40},{default:he(()=>[(z(),be(Et(t.iconOne)))]),_:1})]))]),_:1},8,["index"])]),_:1},8,["content","placement"]))}});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const TW=4,Y0=0,X0=1,kW=2;function Xo(e){let t=e.length;for(;--t>=0;)e[t]=0}const EW=0,T2=1,OW=2,AW=3,PW=258,fm=29,Bl=256,dl=Bl+1+fm,bo=30,dm=19,k2=2*dl+1,ga=15,Hf=16,IW=7,hm=256,E2=16,O2=17,A2=18,bh=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]),Nu=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]),MW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),P2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),LW=512,Xr=new Array((dl+2)*2);Xo(Xr);const Is=new Array(bo*2);Xo(Is);const hl=new Array(LW);Xo(hl);const pl=new Array(PW-AW+1);Xo(pl);const pm=new Array(fm);Xo(pm);const yc=new Array(bo);Xo(yc);function Wf(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 I2,M2,L2;function Yf(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const R2=e=>e<256?hl[e]:hl[256+(e>>>7)],ml=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},xn=(e,t,n)=>{e.bi_valid>Hf-n?(e.bi_buf|=t<>Hf-e.bi_valid,e.bi_valid+=n-Hf):(e.bi_buf|=t<{xn(e,n[t*2],n[t*2+1])},D2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},RW=e=>{e.bi_valid===16?(ml(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)},DW=(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<=ga;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--)}},$2=(e,t,n)=>{const r=new Array(ga+1);let i=0,l,v;for(l=1;l<=ga;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]=D2(r[o]++,o))}},$W=()=>{let e,t,n,r,i;const l=new Array(ga+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?ml(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},K0=(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=pl[i],wr(e,v+Bl+1,t),o=bh[v],o!==0&&(i-=pm[v],xn(e,i,o)),r--,v=R2(r),wr(e,v,n),o=Nu[v],o!==0&&(r-=yc[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=k2,v=0;v>1;v>=1;v--)Xf(e,n,v);u=l;do v=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Xf(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++,Xf(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],DW(e,t),$2(n,a,e.bl_count)},q0=(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(q0(e,e.dyn_ltree,e.l_desc.max_code),q0(e,e.dyn_dtree,e.d_desc.max_code),_h(e,e.bl_desc),t=dm-1;t>=3&&e.bl_tree[P2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},FW=(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 Y0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return X0;for(n=32;n{J0||($W(),J0=!0),e.l_desc=new Yf(e.dyn_ltree,I2),e.d_desc=new Yf(e.dyn_dtree,M2),e.bl_desc=new Yf(e.bl_tree,L2),e.bi_buf=0,e.bi_valid=0,B2(e)},z2=(e,t,n,r)=>{xn(e,(EW<<1)+(r?1:0),3),F2(e),ml(e,n),ml(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},jW=e=>{xn(e,T2<<1,3),wr(e,hm,Xr),RW(e)},VW=(e,t,n,r)=>{let i,l,v=0;e.level>0?(e.strm.data_type===kW&&(e.strm.data_type=zW(e)),_h(e,e.l_desc),_h(e,e.d_desc),v=BW(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?z2(e,t,n,r):e.strategy===TW||l===i?(xn(e,(T2<<1)+(r?1:0),3),G0(e,Xr,Is)):(xn(e,(OW<<1)+(r?1:0),3),FW(e,e.l_desc.max_code+1,e.d_desc.max_code+1,v+1),G0(e,e.dyn_ltree,e.dyn_dtree)),B2(e),r&&F2(e)},UW=(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[(pl[n]+Bl+1)*2]++,e.dyn_dtree[R2(t)*2]++),e.sym_next===e.sym_end);var HW=NW,WW=z2,YW=VW,XW=UW,KW=jW,GW={_tr_init:HW,_tr_stored_block:WW,_tr_flush_block:YW,_tr_tally:XW,_tr_align:KW};const qW=(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 gl=qW;const ZW=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},JW=new Uint32Array(ZW()),QW=(e,t,n,r)=>{const i=JW,l=r+n;e^=-1;for(let v=r;v>>8^i[(e^t[v])&255];return e^-1};var Jt=QW,Ma={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"},Ko={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:eY,_tr_stored_block:wh,_tr_flush_block:tY,_tr_tally:Di,_tr_align:nY}=GW,{Z_NO_FLUSH:$i,Z_PARTIAL_FLUSH:rY,Z_FULL_FLUSH:iY,Z_FINISH:Hn,Z_BLOCK:Q0,Z_OK:nn,Z_STREAM_END:ey,Z_STREAM_ERROR:kr,Z_DATA_ERROR:aY,Z_BUF_ERROR:Kf,Z_DEFAULT_COMPRESSION:oY,Z_FILTERED:sY,Z_HUFFMAN_ONLY:hu,Z_RLE:lY,Z_FIXED:uY,Z_DEFAULT_STRATEGY:cY,Z_UNKNOWN:fY,Z_DEFLATED:ef}=Ko,dY=9,hY=15,pY=8,mY=29,gY=256,Ch=gY+1+mY,vY=30,yY=19,bY=2*Ch+1,_Y=15,ut=3,Ii=258,Er=Ii+ut+1,wY=32,Lo=42,mm=57,Sh=69,xh=73,Th=91,kh=103,va=113,ds=666,yn=1,Go=2,La=3,qo=4,CY=3,ya=(e,t)=>(e.msg=Ma[t],t),ty=e=>e*2-(e>4?9:0),Oi=e=>{let t=e.length;for(;--t>=0;)e[t]=0},SY=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 xY=(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))},$n=(e,t)=>{tY(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Mn(e.strm)},gt=(e,t)=>{e.pending_buf[e.pending++]=t},os=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Eh=(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=gl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Jt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},N2=(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+Ii;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},Ro=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),SY(e),r+=t),e.strm.avail_in===0)break;if(n=Eh(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=Bi(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Bi(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,Mn(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&&(Eh(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&&(Eh(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===Hn)&&t!==$i&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,v=t===Hn&&e.strm.avail_in===0&&r===i?1:0,wh(e,e.block_start,r,v),e.block_start+=r,Mn(e.strm)),v?La:yn)},Gf=(e,t)=>{let n,r;for(;;){if(e.lookahead=ut&&(e.ins_h=Bi(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=N2(e,n)),e.match_length>=ut)if(r=Di(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=Bi(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=Bi(e,e.ins_h,e.window[e.strstart+1]);else r=Di(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&($n(e,!1),e.strm.avail_out===0))return yn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=ut&&(e.ins_h=Bi(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=Di(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=Bi(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&&($n(e,!1),e.strm.avail_out===0))return yn}else if(e.match_available){if(r=Di(e,0,e.window[e.strstart-1]),r&&$n(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return yn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Di(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<=Ii){if(Ro(e),e.lookahead<=Ii&&t===$i)return yn;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+Ii;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=Di(e,1,e.match_length-ut),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Di(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&($n(e,!1),e.strm.avail_out===0))return yn}return e.insert=0,t===Hn?($n(e,!0),e.strm.avail_out===0?La:qo):e.sym_next&&($n(e,!1),e.strm.avail_out===0)?yn:Go},kY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Ro(e),e.lookahead===0)){if(t===$i)return yn;break}if(e.match_length=0,n=Di(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&($n(e,!1),e.strm.avail_out===0))return yn}return e.insert=0,t===Hn?($n(e,!0),e.strm.avail_out===0?La:qo):e.sym_next&&($n(e,!1),e.strm.avail_out===0)?yn:Go};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 hs=[new vr(0,0,0,0,j2),new vr(4,4,8,4,Gf),new vr(4,5,16,8,Gf),new vr(4,6,32,32,Gf),new vr(4,4,16,16,no),new vr(8,16,32,32,no),new vr(8,16,128,128,no),new vr(8,32,128,256,no),new vr(32,128,258,1024,no),new vr(32,258,258,4096,no)],EY=e=>{e.window_size=2*e.w_size,Oi(e.head),e.max_lazy_match=hs[e.level].max_lazy,e.good_match=hs[e.level].good_length,e.nice_match=hs[e.level].nice_length,e.max_chain_length=hs[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 OY(){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=ef,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(bY*2),this.dyn_dtree=new Uint16Array((2*vY+1)*2),this.bl_tree=new Uint16Array((2*yY+1)*2),Oi(this.dyn_ltree),Oi(this.dyn_dtree),Oi(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(_Y+1),this.heap=new Uint16Array(2*Ch+1),Oi(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Ch+1),Oi(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 Fl=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Lo&&t.status!==mm&&t.status!==Sh&&t.status!==xh&&t.status!==Th&&t.status!==kh&&t.status!==va&&t.status!==ds?1:0},V2=e=>{if(Fl(e))return ya(e,kr);e.total_in=e.total_out=0,e.data_type=fY;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?mm:t.wrap?Lo:va,e.adler=t.wrap===2?0:1,t.last_flush=-2,eY(t),nn},U2=e=>{const t=V2(e);return t===nn&&EY(e.state),t},AY=(e,t)=>Fl(e)||e.state.wrap!==2?kr:(e.state.gzhead=t,nn),H2=(e,t,n,r,i,l)=>{if(!e)return kr;let v=1;if(t===oY&&(t=6),r<0?(v=0,r=-r):r>15&&(v=2,r-=16),i<1||i>dY||n!==ef||r<8||r>15||t<0||t>9||l<0||l>uY||r===8&&v!==1)return ya(e,kr);r===8&&(r=9);const o=new OY;return e.state=o,o.strm=e,o.status=Lo,o.wrap=v,o.gzhead=null,o.w_bits=r,o.w_size=1<H2(e,t,ef,hY,pY,cY),IY=(e,t)=>{if(Fl(e)||t>Q0||t<0)return e?ya(e,kr):kr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===ds&&t!==Hn)return ya(e,e.avail_out===0?Kf:kr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Mn(e),e.avail_out===0)return n.last_flush=-1,nn}else if(e.avail_in===0&&ty(t)<=ty(r)&&t!==Hn)return ya(e,Kf);if(n.status===ds&&e.avail_in!==0)return ya(e,Kf);if(n.status===Lo&&n.wrap===0&&(n.status=va),n.status===Lo){let i=ef+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=hu||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=wY),i+=31-i%31,os(n,i),n.strstart!==0&&(os(n,e.adler>>>16),os(n,e.adler&65535)),e.adler=1,n.status=va,Mn(e),n.pending!==0)return n.last_flush=-1,nn}if(n.status===mm){if(e.adler=0,gt(n,31),gt(n,139),gt(n,8),n.gzhead)gt(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)),gt(n,n.gzhead.time&255),gt(n,n.gzhead.time>>8&255),gt(n,n.gzhead.time>>16&255),gt(n,n.gzhead.time>>24&255),gt(n,n.level===9?2:n.strategy>=hu||n.level<2?4:0),gt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(gt(n,n.gzhead.extra.length&255),gt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Jt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Sh;else if(gt(n,0),gt(n,0),gt(n,0),gt(n,0),gt(n,0),gt(n,n.level===9?2:n.strategy>=hu||n.level<2?4:0),gt(n,CY),n.status=va,Mn(e),n.pending!==0)return n.last_flush=-1,nn}if(n.status===Sh){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=Jt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,Mn(e),n.pending!==0)return n.last_flush=-1,nn;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=Jt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=xh}if(n.status===xh){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=Jt(e.adler,n.pending_buf,n.pending-i,i)),Mn(e),n.pending!==0)return n.last_flush=-1,nn;i=0}n.gzindexi&&(e.adler=Jt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=Th}if(n.status===Th){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=Jt(e.adler,n.pending_buf,n.pending-i,i)),Mn(e),n.pending!==0)return n.last_flush=-1,nn;i=0}n.gzindexi&&(e.adler=Jt(e.adler,n.pending_buf,n.pending-i,i))}n.status=kh}if(n.status===kh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Mn(e),n.pending!==0))return n.last_flush=-1,nn;gt(n,e.adler&255),gt(n,e.adler>>8&255),e.adler=0}if(n.status=va,Mn(e),n.pending!==0)return n.last_flush=-1,nn}if(e.avail_in!==0||n.lookahead!==0||t!==$i&&n.status!==ds){let i=n.level===0?j2(n,t):n.strategy===hu?kY(n,t):n.strategy===lY?TY(n,t):hs[n.level].func(n,t);if((i===La||i===qo)&&(n.status=ds),i===yn||i===La)return e.avail_out===0&&(n.last_flush=-1),nn;if(i===Go&&(t===rY?nY(n):t!==Q0&&(wh(n,0,0,!1),t===iY&&(Oi(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Mn(e),e.avail_out===0))return n.last_flush=-1,nn}return t!==Hn?nn:n.wrap<=0?ey:(n.wrap===2?(gt(n,e.adler&255),gt(n,e.adler>>8&255),gt(n,e.adler>>16&255),gt(n,e.adler>>24&255),gt(n,e.total_in&255),gt(n,e.total_in>>8&255),gt(n,e.total_in>>16&255),gt(n,e.total_in>>24&255)):(os(n,e.adler>>>16),os(n,e.adler&65535)),Mn(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?nn:ey)},MY=e=>{if(Fl(e))return kr;const t=e.state.status;return e.state=null,t===va?ya(e,aY):nn},LY=(e,t)=>{let n=t.length;if(Fl(e))return kr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==Lo||r.lookahead)return kr;if(i===1&&(e.adler=gl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Oi(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,Ro(r);r.lookahead>=ut;){let a=r.strstart,u=r.lookahead-(ut-1);do r.ins_h=Bi(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,Ro(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,nn};var RY=PY,DY=H2,$Y=U2,BY=V2,FY=AY,zY=IY,NY=MY,jY=LY,VY="pako deflate (from Nodeca project)",Ms={deflateInit:RY,deflateInit2:DY,deflateReset:$Y,deflateResetKeep:BY,deflateSetHeader:FY,deflate:zY,deflateEnd:NY,deflateSetDictionary:jY,deflateInfo:VY};const UY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var HY=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)UY(n,r)&&(e[r]=n[r])}}return e},WY=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;vl[254]=vl[254]=1;var YY=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 XY=(e,t)=>{if(t<65534&&e.subarray&&W2)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 XY(l,i)},GY=(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+vl[e[n]]>t?n:t},yl={string2buf:YY,buf2string:KY,utf8border:GY};function qY(){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 Y2=qY;const X2=Object.prototype.toString,{Z_NO_FLUSH:ZY,Z_SYNC_FLUSH:JY,Z_FULL_FLUSH:QY,Z_FINISH:eX,Z_OK:bc,Z_STREAM_END:tX,Z_DEFAULT_COMPRESSION:nX,Z_DEFAULT_STRATEGY:rX,Z_DEFLATED:iX}=Ko;function zl(e){this.options=tf.assign({level:nX,method:iX,chunkSize:16384,windowBits:15,memLevel:8,strategy:rX},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 Y2,this.strm.avail_out=0;let n=Ms.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==bc)throw new Error(Ma[n]);if(t.header&&Ms.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=yl.string2buf(t.dictionary):X2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Ms.deflateSetDictionary(this.strm,r),n!==bc)throw new Error(Ma[n]);this._dict_set=!0}}zl.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?eX:ZY,typeof e=="string"?n.input=yl.string2buf(e):X2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(l===JY||l===QY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=Ms.deflate(n,l),i===tX)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Ms.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===bc;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};zl.prototype.onData=function(e){this.chunks.push(e)};zl.prototype.onEnd=function(e){e===bc&&(this.result=tf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function gm(e,t){const n=new zl(t);if(n.push(e,!0),n.err)throw n.msg||Ma[n.err];return n.result}function aX(e,t){return t=t||{},t.raw=!0,gm(e,t)}function oX(e,t){return t=t||{},t.gzip=!0,gm(e,t)}var sX=zl,lX=gm,uX=aX,cX=oX,fX=Ko,dX={Deflate:sX,deflate:lX,deflateRaw:uX,gzip:cX,constants:fX};const pu=16209,hX=16191;var pX=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=pu;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=pu;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(ro+1),j=new Uint16Array(ro+1);let R=null,B,E,V;for(u=0;u<=ro;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===iy||f!==1))return-1;for(j[1]=0,u=1;uny||e===ay&&y>ry)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<ny||e===ay&&y>ry)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 Ls=bX;const _X=0,K2=1,G2=2,{Z_FINISH:oy,Z_BLOCK:wX,Z_TREES:mu,Z_OK:Ra,Z_STREAM_END:CX,Z_NEED_DICT:SX,Z_STREAM_ERROR:qn,Z_DATA_ERROR:q2,Z_MEM_ERROR:Z2,Z_BUF_ERROR:xX,Z_DEFLATED:sy}=Ko,nf=16180,ly=16181,uy=16182,cy=16183,fy=16184,dy=16185,hy=16186,py=16187,my=16188,gy=16189,_c=16190,jr=16191,Zf=16192,vy=16193,Jf=16194,yy=16195,by=16196,_y=16197,wy=16198,gu=16199,vu=16200,Cy=16201,Sy=16202,xy=16203,Ty=16204,ky=16205,Qf=16206,Ey=16207,Oy=16208,Bt=16209,J2=16210,Q2=16211,TX=852,kX=592,EX=15,OX=EX,Ay=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function AX(){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 Wa=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modeQ2?1:0},eC=e=>{if(Wa(e))return qn;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=nf,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(TX),t.distcode=t.distdyn=new Int32Array(kX),t.sane=1,t.back=-1,Ra},tC=e=>{if(Wa(e))return qn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,eC(e)},nC=(e,t)=>{let n;if(Wa(e))return qn;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?qn:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,tC(e))},rC=(e,t)=>{if(!e)return qn;const n=new AX;e.state=n,n.strm=e,n.window=null,n.mode=nf;const r=nC(e,t);return r!==Ra&&(e.state=null),r},PX=e=>rC(e,OX);let Py=!0,ed,td;const IX=e=>{if(Py){ed=new Int32Array(512),td=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(Ls(K2,e.lens,0,288,ed,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ls(G2,e.lens,0,32,td,0,e.work,{bits:5}),Py=!1}e.lencode=ed,e.lenbits=9,e.distcode=td,e.distbits=5},iC=(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(Wa(e)||!e.output||!e.input&&e.avail_in!==0)return qn;n=e.state,n.mode===jr&&(n.mode=Zf),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=Ra;e:for(;;)switch(n.mode){case nf:if(n.wrap===0){n.mode=Zf;break}for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Jt(n.check,P,2,0),u=0,h=0,n.mode=ly;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Bt;break}if((u&15)!==sy){e.msg="unknown compression method",n.mode=Bt;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=Bt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(P[0]=u&255,P[1]=u>>>8&255,n.check=Jt(n.check,P,2,0)),u=0,h=0,n.mode=uy;case uy: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=Jt(n.check,P,4,0)),u=0,h=0,n.mode=cy;case cy: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=Jt(n.check,P,2,0)),u=0,h=0,n.mode=fy;case fy:if(n.flags&1024){for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Jt(n.check,P,2,0)),u=0,h=0}else n.head&&(n.head.extra=null);n.mode=dy;case dy: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=Jt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=hy;case hy: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 gy: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=vy;break;case 1:if(IX(n),n.mode=gu,t===mu){u>>>=2,h-=2;break e}break;case 2:n.mode=by;break;case 3:e.msg="invalid block type",n.mode=Bt}u>>>=2,h-=2;break;case vy: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=Bt;break}if(n.length=u&65535,u=0,h=0,n.mode=Jf,t===mu)break e;case Jf:n.mode=yy;case yy: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 by: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=Bt;break}n.have=0,n.mode=_y;case _y: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=Ls(_X,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid code lengths set",n.mode=Bt;break}n.have=0,n.mode=wy;case wy: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=Bt;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=Bt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===Bt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Bt;break}if(n.lenbits=9,D={bits:n.lenbits},O=Ls(K2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,O){e.msg="invalid literal/lengths set",n.mode=Bt;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},O=Ls(G2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,O){e.msg="invalid distances set",n.mode=Bt;break}if(n.mode=gu,t===mu)break e;case gu:n.mode=vu;case vu: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,pX(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=ky;break}if(b&32){n.back=-1,n.mode=jr;break}if(b&64){e.msg="invalid literal/length code",n.mode=Bt;break}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}n.was=n.length,n.mode=Sy;case Sy: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=Bt;break}n.offset=_,n.extra=b&15,n.mode=xy;case xy: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=Bt;break}n.mode=Ty;case Ty:if(a===0)break e;if(s=f-a,n.offset>s){if(s=n.offset-s,s>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Bt;break}s>n.wnext?(s-=n.wnext,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=vu);break;case ky:if(a===0)break e;i[v++]=n.length,a--,n.mode=vu;break;case Qf:if(n.wrap){for(;h<32;){if(o===0)break e;o--,u|=r[l++]<{if(Wa(e))return qn;let t=e.state;return t.window&&(t.window=null),e.state=null,Ra},RX=(e,t)=>{if(Wa(e))return qn;const n=e.state;return(n.wrap&2)===0?qn:(n.head=t,t.done=!1,Ra)},DX=(e,t)=>{const n=t.length;let r,i,l;return Wa(e)||(r=e.state,r.wrap!==0&&r.mode!==_c)?qn:r.mode===_c&&(i=1,i=gl(i,t,n,0),i!==r.check)?q2:(l=iC(e,t,n,n),l?(r.mode=J2,Z2):(r.havedict=1,Ra))};var $X=tC,BX=nC,FX=eC,zX=PX,NX=rC,jX=MX,VX=LX,UX=RX,HX=DX,WX="pako inflate (from Nodeca project)",Kr={inflateReset:$X,inflateReset2:BX,inflateResetKeep:FX,inflateInit:zX,inflateInit2:NX,inflate:jX,inflateEnd:VX,inflateGetHeader:UX,inflateSetDictionary:HX,inflateInfo:WX};function YX(){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 XX=YX;const aC=Object.prototype.toString,{Z_NO_FLUSH:KX,Z_FINISH:GX,Z_OK:bl,Z_STREAM_END:nd,Z_NEED_DICT:rd,Z_STREAM_ERROR:qX,Z_DATA_ERROR:Iy,Z_MEM_ERROR:ZX}=Ko;function Nl(e){this.options=tf.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 Y2,this.strm.avail_out=0;let n=Kr.inflateInit2(this.strm,t.windowBits);if(n!==bl)throw new Error(Ma[n]);if(this.header=new XX,Kr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=yl.string2buf(t.dictionary):aC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Kr.inflateSetDictionary(this.strm,t.dictionary),n!==bl)))throw new Error(Ma[n])}Nl.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?GX:KX,aC.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===rd&&i&&(l=Kr.inflateSetDictionary(n,i),l===bl?l=Kr.inflate(n,v):l===Iy&&(l=rd));n.avail_in>0&&l===nd&&n.state.wrap>0&&e[n.next_in]!==0;)Kr.inflateReset(n),l=Kr.inflate(n,v);switch(l){case qX:case Iy:case rd:case ZX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===nd))if(this.options.to==="string"){let a=yl.utf8border(n.output,n.next_out),u=n.next_out-a,h=yl.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===bl&&o===0)){if(l===nd)return l=Kr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Nl.prototype.onData=function(e){this.chunks.push(e)};Nl.prototype.onEnd=function(e){e===bl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=tf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function vm(e,t){const n=new Nl(t);if(n.push(e),n.err)throw n.msg||Ma[n.err];return n.result}function JX(e,t){return t=t||{},t.raw=!0,vm(e,t)}var QX=Nl,eK=vm,tK=JX,nK=vm,rK=Ko,iK={Inflate:QX,inflate:eK,inflateRaw:tK,ungzip:nK,constants:rK};const{Deflate:oq,deflate:sq,deflateRaw:aK,gzip:lq}=dX,{Inflate:uq,inflate:cq,inflateRaw:oK,ungzip:fq}=iK;var sK=aK,lK=oK;function My(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 uK=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=My(t);if(console.log("URL params:",n),n.get("share")){const l=lK(new Uint8Array(atob(n.get("share")).split("").map(v=>v.charCodeAt(0))),{to:"string"});if(!l){Wt().raiseError("Error when trying to decode share parameter!",!1);return}n=My(l.split("&")),console.log("Share URL params:",n)}const r={id:-1,image:"",prompt:n.get("prompt")||"",sampler_name:n.get("sampler_name")||"k_euler",seed:Number(n.get("seed"))||-1,steps:Number(n.get("steps")||20),cfg_scale:Number(n.get("cfg_scale")||5),height:Number(n.get("height")||512),width:Number(n.get("width")||512),clip_skip:Number(n.get("clip_skip")||0),frames:Number(n.get("frames")||1),fps:Number(n.get("fps")||16),scheduler:n.get("scheduler")||"default"};rn().generateText2Img(r,!1)},cK=10;function ju(e,t,n,r,i=l=>Wt().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 fK=$o("interrogate",()=>{const e=ie({}),t=ie(!1);async function n(v){Wt().raiseError(v,!1),t.value=!1,e.value={}}async function r(){const v=Ht(),{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();!ju(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}}),ym=e=>(oi("data-v-db184ac6"),e=e(),si(),e),dK={key:0,style:{"margin-top":"16px"}},hK=ym(()=>ne("div",null,[Ue("Drop file here OR "),ne("em",null,"click to upload")],-1)),pK={key:1,style:{"margin-top":"16px"}},mK={key:2},gK={style:{"margin-top":"8px"}},vK=ym(()=>ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),yK={key:0},bK=ym(()=>ne("h3",null,"Caption",-1)),_K={key:0},wK={key:1},CK=ke({__name:"InterrogationView",setup(e){const t=fK(),n=rn(),r=Wt(),i=ie();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 yh(u.raw);t.currentInterrogation.source_image=h,t.interrogateImage()}function v(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=S2();return(u,h)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(z(),le("div",mK,[ne("div",gK,[ue(C(ht),{icon:C(Eg),onClick:C(t).resetInterrogation},{default:he(()=>[Ue("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(z(),be(C(ht),{key:0,icon:C(Eg),onClick:v,disabled:!C(o)},{default:he(()=>[Ue("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):ye("",!0)]),vK,ue(C(Dp),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(z(),le("div",yK,[bK,C(o)?(z(),le("div",wK,[ne("strong",null,Ae(C(o)),1)])):(z(),le("div",_K,"Processing"+Ae(C(a)),1))])):ye("",!0)])):(z(),le("div",pK,[ne("strong",null,"Uploading image"+Ae(C(a)),1)])):(z(),le("div",dK,[ne("div",null,[ue(C(Np),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:he(()=>[ue(C(Re),{size:100},{default:he(()=>[ue(C(ip))]),_:1}),hK]),_:1},512)])]))}});const SK=Zt(CK,[["__scopeId","data-v-db184ac6"]]);function xK(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 TK={class:"form"},kK={key:0,style:{"padding-bottom":"50px"}},EK=ne("h1",{style:{margin:"0"}},"Interrogation",-1),OK=ne("div",null,"Interrogate images to get their predicted descriptions.",-1),AK={class:"sidebar"},PK=ne("span",{style:{height:"100%","font-size":"14px"}},[Ue("Reference Image: "),ne("br"),Ue("(Photomaker/Kontext) ")],-1),IK={class:"main"},MK={class:"image center-horizontal"},LK={key:0},RK=ke({__name:"GenerateView",setup(e){const n=bp(yp).smallerOrEqual("md"),r=rn(),i=Wt(),l=Ps();Ht();const v=fv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSamplers()).map(b=>b.name);return y.length===0?[]:u(y)},[]),o=fv(async()=>{const g=r.cacheVersion,y=(await r.getAvailableSchedulers()).map(b=>b.name);return y.length===0?[]:h(y)},[]),a=yt({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: "+xK(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(),uK(),(g,m)=>(z(),le(je,null,[ue(C(pw),{"default-active":C(r).generatorType,collapse:!0,onSelect:s,mode:C(n)?"horizontal":"vertical",class:ce(C(n)?"mobile-generator-types":"generator-types"),style:Ne(C(n)?"overflow-x: auto":"")},{default:he(()=>[ue(du,{index:"Text2Img","icon-one":C(EE),"icon-two":C(Kl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),ue(du,{index:"Img2Img","icon-one":C(Kl),"icon-two":C(Kl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),ue(du,{index:"Inpainting","icon-one":C2,"icon-two":C(Kl),isMobile:C(n)},null,8,["icon-two","isMobile"]),ue(du,{index:"Interrogation","icon-one":EH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",TK,[C(r).generatorType==="Interrogation"?(z(),le("div",kK,[EK,OK,ue(SK)])):(z(),be(C(Rp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:a,onSubmit:m[29]||(m[29]=rt(()=>{},["prevent"]))},{default:he(()=>[ne("div",AK,[ue(C(hB),{modelValue:C(i).activeCollapse,"onUpdate:modelValue":m[24]||(m[24]=y=>C(i).activeCollapse=y),style:{"margin-bottom":"24px"}},{default:he(()=>[ue(C(pB),{title:"Generation Options",name:"1"},{default:he(()=>[ue(WH),ue(vh,{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"]),ue(vh,{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(gE)},{append:he(()=>[ue(C(Lr),{content:"Randomize!",placement:"top"},{default:he(()=>[ue(C(ht),{icon:C(X3),onClick:m[1]||(m[1]=()=>C(r).params.seed=C(oC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(z(),be(C(m0),{key:0,gutter:10},{default:he(()=>[C(r).multiSelect.sampler.state==="Multiple"?(z(),be(C(Ja),{key:0,span:C(n)?24:12},{default:he(()=>[ue(co,{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(Ja),{key:1,span:C(n)?24:12},{default:he(()=>[ue(co,{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(Ja),{key:2,span:C(n)?24:12},{default:he(()=>[ue(co,{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(Ja),{key:3,span:C(n)?24:12},{default:he(()=>[ue(co,{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})),ue(gn,{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(gn,{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(gn,{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),ue(gn,{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"]),ue(gn,{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(gn,{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(gn,{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(gn,{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(gn,{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(gn,{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(gn,{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),ue(gn,{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). More frames increases memory usage."},null,8,["modelValue","min","max"]),C(r).params.frames>1?(z(),be(gn,{key:9,label:"FPS",prop:"fps",modelValue:C(r).params.fps,"onUpdate:modelValue":m[19]||(m[19]=y=>C(r).params.fps=y),min:C(r).minFps,max:C(r).maxFps,disabled:C(r).params.frames<=1,info:"Frames per second for video generation."},null,8,["modelValue","min","max","disabled"])):ye("",!0),ne("div",null,[PK,ne("input",{class:"el-button",type:"file",id:"extra_image_input",onChange:m[20]||(m[20]=y=>C(r).setExtraImage(y)),accept:"image/*",multiple:""},null,32),ne("button",{onClick:m[21]||(m[21]=y=>C(r).clearExtraImage()),class:"el-button"},"Clear Image"),ue(C(m0),null,{default:he(()=>[ue(C(Ja),{span:C(n)?24:12},{default:he(()=>[ue(H0,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":m[22]||(m[22]=y=>C(r).params.enable_hr=y),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),ue(C(Ja),{span:C(n)?24:12},{default:he(()=>[C(r).generatorType==="Img2Img"?(z(),be(H0,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:C(r).params.send_as_refimg,"onUpdate:modelValue":m[23]||(m[23]=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",IK,[ue(C(ht),{onClick:m[25]||(m[25]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:he(()=>[Ue("Reset")]),_:1}),ue(C(ht),{type:"primary",class:"generate-cancel-btn",style:Ne(C(r).generating?"width: 55%;":""),onClick:m[26]||(m[26]=()=>C(r).generateImage(C(r).generatorType))},{default:he(()=>[ne("span",null," Generate "+Ae(C(r).totalImageCount)+" image"+Ae(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(z(),be(C(ht),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:m[27]||(m[27]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:he(()=>[Ue("Cancel all")]),_:1},8,["disabled"])):ye("",!0)]),ne("div",MK,[ue(C(m$),{class:"center-both generated-image"},{default:he(()=>[!C(r).generating&&C(r).outputs.length==0?(z(),le("div",LK,[/Inpainting/.test(C(r).generatorType)?(z(),be(W0,{key:0})):ye("",!0),/Img2Img/.test(C(r).generatorType)?(z(),be(W0,{key:1})):ye("",!0)])):ye("",!0),!C(i).showGeneratedImages&&C(r).generating?(z(),be(DH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:c(C(r).timer.seconds),onShowGenerated:m[28]||(m[28]=y=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):ye("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(z(),be(tW,{key:2})):ye("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Rs=lk({history:TT("./"),routes:[{path:"/",name:"generate",component:RK},{path:"/images",name:"images",component:()=>Vf(()=>Promise.resolve().then(()=>RG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>Vf(()=>Promise.resolve().then(()=>XG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>Vf(()=>Promise.resolve().then(()=>nq),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function DK(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 yu(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,eta:1,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,fps:16,enable_hr:!1,send_as_refimg:!0,scheduler:"default"}}function oC(){return Math.floor(Math.random()*9999999)+1}const rn=$o("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=ie("Text2Img"),r=ie(""),i=Sn("promptHistory",[]),l=ie(""),v=Sn("negativeLibrary",[]),o=ie(yu()),a=ie({interval:0,seconds:0}),u=ie({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=ie({...h(),sourceProcessing:"inpainting"}),f=ie({...h(),sourceProcessing:"img2img"}),s=we=>we==="Inpainting"?c.value:we==="Img2Img"?f.value:h(),d=ee(()=>s(n.value)),g=ie(""),m=ie(!1),y=ie(!1),b=ie([]),_=ie([]),w=ie(64),S=ee(()=>Ht().allowLargerParams==="Enabled"?3072:1024),x=ie(1),T=ie(20),O=ie(1),P=ee(()=>Ht().allowLargerParams==="Enabled"?150:50),D=ie(1),j=ie(24),R=ie(0),B=ie(1),E=ie(0),V=ie(1),te=ie(0),J=ie(10),se=ie(1),M=ie(160),U=ie(16),A=ie(24),L=(we,$e,Ve)=>Array.from({length:($e-we+1)/Ve},(Qe,at)=>(at+we)*Ve),Q=ie(L(te.value,J.value,1)),N=ie(L(D.value,j.value,.5)),I=ee(()=>{const we=(pi,mi,Dr=1)=>pi*(mi.state==="Multiple"&&mi.selected.length>0?mi.selected.length:Dr),Ve=o.value.n*F().length,Qe=we(Ve,u.value.sampler),at=we(Qe,u.value.scheduler),Ke=we(at,u.value.steps),Rt=we(Ke,u.value.guidance);return we(Rt,u.value.clipSkip)});function W(){return o.value=yu(),c.value=h(),f.value=h(),b.value=[],Wt().showGeneratedImages=!1,q(),!0}function q(){_.value=[]}function re(){b.value=[]}async function fe(){const we=Ht(),$e=we.baseURL.length===0?".":we.baseURL,Ve=await fetch(`${$e}/sdapi/v1/loras`),Qe=await Ve.json();return ju(Ve,Qe,200,"Failed to get available LoRAs")?Qe:[]}async function me(we){if(!e.includes(we))return[];if(r.value==="")return H("Failed to generate: No prompt submitted.");const $e=Ps(),Ve=Wt();$e.saveImages();const{sourceImage:Qe,maskImage:at,sourceProcessing:Ke}=s(we);_e(r.value);const Rt=[],pi=F().map(nt=>{const Vt=nt.split(" ### ");return{full_prompt:nt,prompt:Vt[0],negative_prompt:Vt[1]||""}}).map(nt=>{const[Vt,Br]=DK(nt.prompt);return{...nt,prompt:Vt,extractedLoras:Br}}),mi=pi.some(nt=>nt.extractedLoras.length>0)?await fe():[],Dr=pi.map(({extractedLoras:nt,...Vt})=>{const Br=nt.length>0&&mi.length>0?nt.map(er=>{const Ka=mi.find(Ut=>Ut.name===er.name||Ut.path===er.name);return{path:Ka?Ka.path:er.name,multiplier:er.multiplier,...er.is_high_noise?{is_high_noise:!0}:{}}}):[];return{...Vt,...Br.length>0?{lora:Br}:{}}}),{seed:mr,cfg_scale:_m,eta:$r,steps:fC,clip_skip:dC,sampler_name:hC,scheduler:pC,n:mC,...wm}=o.value,af=parseInt(mr.toString()),gC=isNaN(af)||af<0?oC():af,vC=Array.from({length:mC},(nt,Vt)=>gC+Vt),Xa=(nt,Vt)=>nt.state==="Disabled"?[]:nt.state==="Enabled"?[Vt]:nt.state==="Multiple"&&nt.selected.length===0?[]:nt.selected,yC={promptVariant:Dr,seed:vC,cfg_scale:Xa(u.value.guidance,_m),eta:Xa(u.value.eta,$r),steps:Xa(u.value.steps,fC),clip_skip:Xa(u.value.clipSkip,dC),sampler_name:Xa(u.value.sampler,hC),scheduler:Xa(u.value.scheduler,pC)},bC=(nt=>Object.entries(nt).filter(([Br,er])=>er.length>0).reduce((Br,[er,Ka])=>{const Ut=[];for(const wC of Br)for(const CC of Ka)Ut.push({...wC,[er]:CC});return Ut},[{}]))(yC),_C=[await oe()];for(const nt of bC){const{promptVariant:{full_prompt:Vt,...Br},...er}=nt,Ka=we==="Img2Img"?wm.send_as_refimg:!1;let Ut={prompt:Vt,params:{...wm,send_as_refimg:Ka,...er,...Br,init_images:Qe?[Qe.split(",")[1]]:[],mask:at,inpainting_mask_invert:at?0:null,inpainting_fill:at?1:null},source_image:Qe==null?void 0:Qe.split(",")[1],source_mask:at,source_processing:Ke,models:_C};Ut.params.sampler_name=="default"&&delete Ut.params.sampler_name,Ut.params.scheduler=="default"&&delete Ut.params.scheduler,!Ut.params.frames||Ut.params.frames<=1?(delete Ut.params.frames,delete Ut.params.fps):Ut.params.fps=Math.min(A.value,Math.max(U.value,Math.round(Number(Ut.params.fps)||yu().fps))),Me&&Me.length>0&&(Ut.params.extra_images=Me),Ht().alsoRequestAvi==="Enabled"&&Ut.params.frames&&Ut.params.frames>1&&(Ut.params.video_output_type=2),Rt.push(Ut)}let Cm=!1;m.value||(Cm=!0,b.value=[]),m.value=!0,Ve.showGeneratedImages=!1;let Sm=_.value.filter(nt=>!nt.gathered&&!nt.failed).length;for(let nt=0;nt{a.value.seconds++},1e3);!_.value.every(nt=>nt.gathered||nt.failed)&&!y.value;){const nt=_.value.find(Vt=>!Vt.gathered&&!Vt.failed);if(!nt)break;nt.gathered=!0;try{const Vt=await G(nt.params);if(!Vt){nt.failed=!0;continue}ve([{...Vt,...nt}])}catch(Vt){nt.failed=!0,console.error("Error fetching image:",Vt)}}}async function ve(we){const $e=Ia();console.log(we);const Ve=await Promise.all(we.map(async Ke=>{const Rt=Ke.images[0],pi=!!Ke.animated?"gif":"png",mi=Ke.extra_data?`data:video/avi;base64,${Ke.extra_data}`:"";let Dr={id:-1,image:`data:image/${pi};base64,${Rt}`,prompt:Ke.prompt,modelName:Ke.models[0],frames:Ke.params.frames,fps:Ke.params.fps,extra_avi:mi,enable_hr:Ke.params.enable_hr,send_as_refimg:Ke.params.send_as_refimg};if(Ke.info&&typeof Ke.info=="string"&&Ke.info.trim()!=="")try{const mr=JSON.parse(Ke.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip","fps"].forEach($r=>{mr[$r]!=null&&mr[$r]!=null?Dr[$r]=mr[$r]:Ke.params[$r]!=null&&(Dr[$r]=Ke.params[$r])}),mr.extra_generation_params&&mr.extra_generation_params["Schedule type"]?Dr.scheduler=mr.extra_generation_params["Schedule type"]:Dr.scheduler=Ke.params.scheduler}catch(mr){console.warn("Failed to parse info JSON:",mr)}return Dr})),Qe=await $e.pushOutputs(Ve),at=0;return b.value=[...Qe.map(Ke=>({type:"image",index:at,output:Ke})),...b.value].sort((Ke,Rt)=>Ke.index-Rt.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,Wt().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Ve}async function H(we){const $e=Wt();return we&&$e.raiseError(we,!1),[]}function Y(we,$e,Ve,Qe){return $e<=Ve?$e:(Wt().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${we}' to its default value instead of ${$e}.`,!0),Qe)}async function k(we,$e=!0){const Ve=yu();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",Rs.push("/"),$e&&(we.width=we.width||Ve.width,we.height=we.height||Ve.height),we.prompt){const Qe=we.prompt.split(" ### ");r.value=Qe[0],l.value=Qe[1]||""}if(we.sampler_name){o.value.sampler_name=we.sampler_name;const at=(await Ce()).find(Ke=>Ke.aliases&&Ke.aliases.includes(we.sampler_name));at&&(o.value.sampler_name=at.name)}we.steps&&(o.value.steps=Y("steps",we.steps,P.value,Ve.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=Y("width",we.width,S.value,Ve.width)),we.height&&(o.value.height=Y("height",we.height,S.value,Ve.height)),we.seed&&(o.value.seed=we.seed),we.clip_skip&&(o.value.clip_skip=Y("clip_skip",we.clip_skip,J.value,Ve.clip_skip)),we.scheduler&&(o.value.scheduler=we.scheduler),we.frames&&(o.value.frames=Y("frames",we.frames,M.value,Ve.frames)),we.fps&&(o.value.fps=Math.min(A.value,Math.max(U.value,Math.round(Y("fps",we.fps,A.value,Ve.fps)))))}function K(we){const $e=Ps();n.value="Img2Img",f.value.sourceImage=we,$e.drawing=!1,b.value=[],Rs.push("/"),Un.fabric.Image.fromURL(we,$e.newImage)}function X(we){const $e=Ps();b.value=[],c.value.sourceImage=we,n.value="Inpainting",Rs.push("/"),Un.fabric.Image.fromURL(we,$e.newImage)}function $(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function F(){const we=$(),$e=we.match(/\{(.*?)\}/g)||[];if($e.length===0)return[we];let Ve=[];return $e.forEach(Qe=>{const at=[],Ke=Qe.replace("{","").replace("}","").split("|");Ve.length===0?Ke.forEach(Rt=>{const Qn=we.replace(Qe,Rt);at.push(Qn)}):Ve.forEach(Rt=>{Ke.forEach(Qn=>{const pi=Rt.replace(Qe,Qn);at.push(pi)})}),Ve=[...at]}),Ve}async function G(we){const $e=Ht();try{const Ve=await fetch(`${$e.baseURL.length===0?".":$e.baseURL}/sdapi/v1/${we.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)}),Qe=await Ve.json();return ju(Ve,Qe,200,"Failed to fetch",de)?Qe:!1}catch{return!1}}function de(we){return Wt().raiseError(we,!1),y.value=!1,b.value=[],!1}async function oe(){const we=Ht(),$e=await fetch(`${we.baseURL.length===0?".":we.baseURL}/sdapi/v1/sd-models`),Ve=await $e.json();if(!!ju($e,Ve,200,"Failed to get available models"))return Ve.length===0?"(No model loaded)":Ve[0].model_name}const Z=ie(0),pe=new Map;function ae(){pe.clear(),Z.value++}xe(()=>Ht().baseURL,()=>{ae()});async function ge(we){const $e=Ht(),Qe=(($e.baseURL.length===0?".":$e.baseURL).replace(/\/+$/,"")||".")+"/"+we.replace(/^\/+/,"");if(pe.has(Qe))return pe.get(Qe);const at=(async()=>{try{const Ke=await fetch(Qe);if(Ke.ok)return await Ke.json();console.error(`API Error: ${Ke.status} ${Ke.statusText} at ${Qe}`)}catch(Ke){console.error(`Fetch error for ${Qe}:`,Ke)}return pe.delete(Qe),null})();return pe.set(Qe,at),at}async function Ce(){const we=await ge("/sdapi/v1/samplers");return Array.isArray(we)?we:[]}async function Ee(){const we=await ge("/sdapi/v1/schedulers");return Array.isArray(we)?we:[]}function Oe(we){v.value.indexOf(we)===-1&&(v.value=[...v.value,we])}function ze(we){v.value=v.value.filter($e=>$e!=we)}function _e(we){if(i.value.findIndex($e=>$e.prompt===we)===-1){if(i.value.length>=10+i.value.filter($e=>$e.starred).length){const $e=i.value.filter(Qe=>!Qe.starred),Ve=i.value.findIndex(Qe=>Qe===$e[$e.length-1]);i.value.splice(Ve,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:we}]}}function Te(we){i.value=i.value.filter($e=>$e.prompt!=we&&$e!=we)}function De(){return!1}var Me=[];function bt(we){let $e=we.target;if(Me=[],$e.files.length>0)for(let Ve=0;Ve<$e.files.length;++Ve){let Qe=$e.files[Ve];const at=new FileReader;at.onload=function(Ke){let Rt=Ke.target?Ke.target.result:"";Rt.includes("data:image")&&(Rt=Rt.split(",")[1]),console.log(Rt),Me.push(Rt)},at.onerror=function(){console.log("Error reading file.")},at.readAsDataURL(Qe)}else console.log("No file to load")}function _t(){Me=[];const we=document.getElementById("extra_image_input");we&&(we.value="")}return{generatorType:n,prompt:r,params:o,outputs:b,inpainting:c,img2img:f,uploadDimensions:g,cancelled:y,multiSelect:u,negativePrompt:l,generating:m,negativePromptLibrary:v,minDimensions:w,maxDimensions:S,minImages:x,maxImages:T,minSteps:O,maxSteps:P,minCfgScale:D,maxCfgScale:j,minDenoise:E,maxDenoise:V,minClipSkip:te,maxClipSkip:J,minFrames:se,maxFrames:M,minFps:U,maxFps:A,minEta:R,maxEta:B,clipSkipList:Q,cfgList:N,queue:_,promptHistory:i,timer:a,validGeneratorTypes:e,sourceGeneratorTypes:t,currentImageProps:d,totalImageCount:I,generateImage:me,generateText2Img:k,generateImg2Img:K,generateInpainting:X,getPrompt:De,resetStore:W,clearQueue:q,clearOutputs:re,pushToNegativeLibrary:Oe,removeFromNegativeLibrary:ze,pushToPromptHistory:_e,removeFromPromptHistory:Te,setExtraImage:bt,clearExtraImage:_t,getAvailableSamplers:Ce,getAvailableSchedulers:Ee,cacheVersion:Z,invalidateApiCaches:ae,getCachedEndpoint:ge}});"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var rf=e=>new DataView(new ArrayBuffer(e)),Ya=e=>new Uint8Array(e.buffer||e),fo=e=>new TextEncoder().encode(String(e));function $K(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:fo(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:Ya(e)};if(Symbol.asyncIterator in e)return{t,o:sC(e)};throw new TypeError("Unsupported input format.")}function sC(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=BK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function BK(e){return typeof e=="string"?fo(e):e instanceof Uint8Array?e:Ya(e)}function FK(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=fo(t)),e instanceof File)return{i:t||fo(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||fo(v),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:fo(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 zK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:NK,m:jK}=zK.exports,VK=Ya(jK).subarray(65536);function Ly(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))VK.set(n),t=NK(n.length,t);return t}function lC(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 UK(e){const t=rf(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),lC(e.t,t,10),t.setUint16(26,e.i.length,1),Ya(t)}async function*HK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=Ly(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=Ly(r,e.u),e.A+=r.length,yield r}}}function WK(e){const t=rf(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),Ya(t)}function YK(e,t){const n=rf(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),lC(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),Ya(n)}function XK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function KK(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(sC(async function*(r){const i=[];let l=0,v=0;for await(const u of r)yield UK(u),yield u.i,yield*HK(u),yield WK(u),i.push(YK(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=rf(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 Ya(a)}(async function*(r){for await(const i of r){const[l,v]=XK(i);yield Object.assign($K(...v),FK(...l))}}(e))),{headers:n})}async function uC(e,t=!0,n){const r=Ht();t&&Hi({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 ma(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await ma(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await ma(u,"image/gif")}):i.push({name:f+".webp",input:await ma(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await KK(i).blob(),v=document.createElement("a");v.href=URL.createObjectURL(l),v.download="sdui_images.zip",v.click()}async function GK(e,t){const n=Ht(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await ma(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await ma(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await ma(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 qK=ke({__name:"ImageActions",props:{imageData:null,onDelete:null,showDismiss:{type:Boolean}},setup(e){const t=e,n=rn(),r=Ia(),i=()=>{kw.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),Hi({type:"success",message:"Deleted Image"})})},l=()=>{rn().clearOutputs(),Wt().showGeneratedImages=!1,rn().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,fps:o.fps,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(sK(f)))),await navigator.clipboard.writeText(c),Hi({type:"success",message:"Copied shareable link to clipboard"})}return(o,a)=>(z(),le(je,null,[ue(C(ht),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:C(Fc),plain:""},{default:he(()=>[Ue("Delete")]),_:1},8,["icon"]),ue(C(ht),{class:"compact-button",onClick:a[0]||(a[0]=u=>C(GK)(e.imageData.image,`${e.imageData.seed}-${e.imageData.prompt}`)),type:"success",size:"small",icon:C(Ws),plain:""},{default:he(()=>[Ue("Download")]),_:1},8,["icon"]),e.imageData.starred?ye("",!0):(z(),be(C(ht),{key:0,class:"compact-button",onClick:a[1]||(a[1]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(w4),plain:""},{default:he(()=>[Ue("Star")]),_:1},8,["icon"])),e.imageData.starred?(z(),be(C(ht),{key:1,class:"compact-button",onClick:a[2]||(a[2]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(g_),plain:""},{default:he(()=>[Ue("Unstar")]),_:1},8,["icon"])):ye("",!0),ue(C(ht),{class:"compact-button",onClick:a[3]||(a[3]=u=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Txt2img")]),_:1}),ue(C(ht),{class:"compact-button",onClick:a[4]||(a[4]=u=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Img2img")]),_:1}),ue(C(ht),{class:"compact-button",onClick:a[5]||(a[5]=u=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Inpaint")]),_:1}),e.showDismiss?(z(),be(C(ht),{key:2,class:"compact-button",onClick:a[6]||(a[6]=u=>l()),type:"success",size:"small",plain:""},{default:he(()=>[Ue("Dismiss")]),_:1})):ye("",!0),ue(C(ht),{class:"compact-button",onClick:a[7]||(a[7]=u=>v(e.imageData)),type:"success",icon:C($3),size:"small",plain:""},{default:he(()=>[Ue("Share")]),_:1},8,["icon"])],64))}});const cC=Zt(qK,[["__scopeId","data-v-ebc469c5"]]),ZK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},JK=["src"],QK={style:{"font-size":"18px","font-weight":"500"}},eG={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},tG={key:0},nG={key:1},rG=["onClick"],iG=ke({__name:"ImageDialog",setup(e){const t=Ia(),n=Wt(),r=ie();fM(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=ie(t.currentOutputs[0]);xe(()=>n.activeModal,async()=>{const a=t.currentOutputs.find(u=>u.id===n.activeModal);if(a)return l.value=a;l.value=await zt.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(nF),{"model-value":C(i),width:(h=l.value)==null?void 0:h.width,class:"image-viewer",onClosed:v,"align-center":""},{footer:he(()=>[ue(cC,{"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",ZK,[(c=l.value)!=null&&c.image?(z(),le("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,JK)):ye("",!0)])],512),ne("div",QK,Ae(((f=l.value.prompt)==null?void 0:f.split("###")[0])||"Unknown Creation"),1),ne("div",eG,[ne("div",null,"Negative Prompt: "+Ae(((s=l.value.prompt)==null?void 0:s.split("###")[1])||"None"),1),ne("span",null,"Model: "+Ae(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Ae(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Ae(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Ae(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Ae(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Ae(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Ae((d=l.value.clip_skip)!=null?d:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Ae(l.value.width||"???")+"x"+Ae(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Ae(l.value.frames||"1"),1),l.value.frames&&l.value.frames>1?(z(),le("span",tG," - FPS: "+Ae(l.value.fps||"Unknown"),1)):ye("",!0),l.value.extra_avi?(z(),le("span",nG,[Ue(" - "),ne("a",{href:"#",onClick:rt(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,rG)])):ye("",!0)])]}),_:1},8,["model-value","width"])}}});const aG=e=>(oi("data-v-8f4d2380"),e=e(),si(),e),oG=aG(()=>ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)),sG={class:"generator-icons"},lG=ke({__name:"App",setup(e){const n=bp(yp).smallerOrEqual("md"),r=Wt();Ht();const i=ck(),l=ie();return xe(()=>i.path,v=>{l.value&&l.value.open(v)}),(v,o)=>(z(),le(je,null,[ne("div",{class:ce({"menu-container":!C(n)})},[ue(C(pw),{"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(Bp),{key:0,class:"remove-item-styling center-vertical"},{title:he(()=>[oG]),_:1})),ue(as,{isMobile:C(n),index:"/"},{icon:he(()=>[ne("div",sG,[ue(C(Re),null,{default:he(()=>[ue(C(wO))]),_:1}),C(r).showGeneratorBadge?(z(),be(C(Re),{key:0,class:"generator-badge",size:10},{default:he(()=>[ue(dH)]),_:1})):ye("",!0)])]),title:he(()=>[Ue("Generate")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/images"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(Q3))]),_:1})]),title:he(()=>[Ue("Images")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/about"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(d_))]),_:1})]),title:he(()=>[Ue("About")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/options"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(M4))]),_:1})]),title:he(()=>[Ue("Options")]),_:1},8,["isMobile"]),ue(as,{isMobile:C(n),index:"/return"},{icon:he(()=>[ue(C(Re),null,{default:he(()=>[ue(C(l_))]),_:1})]),title:he(()=>[Ue("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:ce({view:!C(n)})},[ue(C(s_))],2),ue(iG)],64))}});const uG=Zt(lG,[["__scopeId","data-v-8f4d2380"]]);const bm=eT(uG);bm.use(rT());bm.use(Rs);bm.mount("#app");Rs.replace("/");window.addEventListener("beforeunload",e=>{rn().generating&&(e.preventDefault(),e.returnValue="")});const cG={key:1,class:"image-action"},fG=ke({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=Wt(),r=ie(null);VI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=ie(!1);cM(r,([{isIntersecting:v}])=>{v&&(i.value=v)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(v,o)=>(z(),le("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(z(),be(C(Dp),{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:Ne(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):ye("",!0),i.value?(z(),le("div",cG,[e.imageData.starred?(z(),be(C(Re),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:he(()=>[ue(C(g_))]),_:1})):ye("",!0),C(n).multiSelect?(z(),le("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[ue(C(Re),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:he(()=>[C(l)?ye("",!0):(z(),be(C(Sl),{key:0})),C(l)?(z(),be(C(c_),{key:1})):ye("",!0)]),_:1},8,["color"])])):ye("",!0)])):ye("",!0)],512))}});const Ry=Zt(fG,[["__scopeId","data-v-b9569bbd"]]);function dG({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=t1(),i=ee(()=>r.value<=e),l=ie(!0),{y:v}=uM(window);let o=v.value,a=0;return xe(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 hG={},pG={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},mG=ne("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-696 72h136v656H184V184zm656 656H384V384h456v456zM384 320V184h456v136H384z",fill:"currentColor"},null,-1),gG=[mG];function vG(e,t){return z(),le("svg",pG,gG)}const yG=Zt(hG,[["render",vG]]),bG=e=>(oi("data-v-b39b47c5"),e=e(),si(),e),_G={class:"options"},wG=["onClick"],CG=["onClick"],SG=["onClick"],xG={key:1,class:"center-both",style:{gap:"12px"}},TG={key:2},kG=bG(()=>ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),EG=[kG],OG={key:0},AG={key:0,style:{display:"flex",gap:"8px"}},PG={key:1,class:"images"},IG={key:1},MG=ke({__name:"ImagesView",setup(e){const{width:t}=t1(),{isVisible:n,isMobile:r}=dG(),i=Ia(),l=Ht(),v=Wt();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 zt.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=()=>{kw.confirm(`This action will permanently delete ${v.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(v.selected)})};dv(["a","A","ArrowLeft"],v.openModalToLeft),dv(["d","D","ArrowRight"],v.openModalToRight);async function f(){uC(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(),le(je,null,[ne("div",{class:ce(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[ne("div",_G,[ue(C(ru),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[ue(C(c4))]),_:1})]),_:1})]),default:he(()=>[(z(),le(je,null,Nt(["Newest","Oldest"],m=>ne("div",{key:m,onClick:()=>C(i).sortBy=m,class:ce(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Ae(m),11,wG)),64))]),_:1}),ue(C(ru),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[ue(C(d3))]),_:1})]),_:1})]),default:he(()=>[(z(),le(je,null,Nt(["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":""}`)},Ae(C(i).filterBy===m?"Showing":"Show")+" "+Ae(m),11,CG)),64))]),_:1}),ue(C(ru),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[ue(yG)]),_:1})]),_:1})]),default:he(()=>[(z(),le(je,null,Nt([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>ne("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:ce(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Ae(m.label),11,SG)),64))]),_:1}),ue(C(ru),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:he(()=>[ue(C(ht),{class:"btn-select"},{default:he(()=>[ue(C(Re),{size:16},{default:he(()=>[C(v).multiSelect?(z(),be(C(c_),{key:0})):(z(),be(C(Sl),{key:1}))]),_:1})]),_:1})]),default:he(()=>[C(v).multiSelect?(z(),le("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(),le("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(),le("div",{key:2,class:"el-select-dropdown__item selected",onClick:h},"Deselect All")):(z(),le("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(),le("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(z(),le("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(z(),be(C(k9),{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(),le("div",xG,[ne("div",null,Ae(C(v).selected.length)+" selected",1),ue(C(ht),{type:"danger",onClick:c,icon:C(Fc),plain:""},{default:he(()=>[Ue("Delete")]),_:1},8,["icon"]),ue(C(ht),{type:"success",onClick:f,icon:C(Ws),plain:"",style:{margin:"0"}},{default:he(()=>[Ue("Download")]),_:1},8,["icon"])])):(z(),le("div",TG,EG))],2),C(i).outputsLength!=0?(z(),le("div",OG,[C(i).currentLayout==="dynamic"?(z(),le("div",AG,[(z(!0),le(je,null,Nt(C(s),(m,y)=>(z(),le("div",{key:y,style:{flex:"1 1 0%"}},[(z(!0),le(je,null,Nt(m,b=>(z(),be(Ry,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ye("",!0),C(i).currentLayout==="grid"?(z(),le("div",PG,[(z(!0),le(je,null,Nt(C(i).currentOutputs,m=>(z(),be(Ry,{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(),le("div",IG,[ue(C(GF),{description:"No Images Found"})])):ye("",!0)],64))}});const LG=Zt(MG,[["__scopeId","data-v-b39b47c5"]]),RG=Object.freeze(Object.defineProperty({__proto__:null,default:LG},Symbol.toStringTag,{value:"Module"})),DG=["href"],$G=ke({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=vt("router-link");return z(),le(je,null,[e.router?ye("",!0):(z(),le("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[Se(t.$slots,"default",{},void 0,!0)],8,DG)),e.router?(z(),be(r,{key:1,to:e.href},{default:he(()=>[Se(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ye("",!0)],64)}}});const BG=Zt($G,[["__scopeId","data-v-17b53b7d"]]),jl=e=>(oi("data-v-ecc278c5"),e=e(),si(),e),FG={class:"about"},zG={class:"about-content"},NG=jl(()=>ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),jG=jl(()=>ne("div",null,[Ue("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"),Ue(".")],-1)),VG=jl(()=>ne("br",null,null,-1)),UG=jl(()=>ne("div",null,"If you want to help improve this tool, you can find the currently maintained source code from this modified version on https://github.com/LostRuins/stable-ui and https://github.com/henk717/stable-ui, which is based off https://github.com/ayunami2000/stable-ui, which derives from the original AI Horde version on https://github.com/aqualxx/stable-ui (Original author aqualxx#5004). Feel free to contribute!",-1)),HG=jl(()=>ne("br",null,null,-1)),WG=ke({__name:"AboutView",setup(e){return(t,n)=>(z(),le("div",FG,[ne("div",zG,[NG,jG,VG,UG,HG,ne("div",null,[Ue("You can find the KoboldAI community and authors of this fork on the "),ue(BG,{href:"https://koboldai.org/discord"},{default:he(()=>[Ue("KoboldAI Discord")]),_:1})])])]))}});const YG=Zt(WG,[["__scopeId","data-v-ecc278c5"]]),XG=Object.freeze(Object.defineProperty({__proto__:null,default:YG},Symbol.toStringTag,{value:"Module"}));const io=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(Ri),{prop:e.prop},{label:he(()=>[ue($l,{info:e.info,"label-style":e.labelStyle},{default:he(()=>[Se(l.$slots,"label",{},()=>[Ue(Ae(e.label),1)])]),_:3},8,["info","label-style"])]),default:he(()=>[ue(C(U$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:he(()=>[(z(!0),le(je,null,Nt(e.options,o=>(z(),be(C(H$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),Se(l.$slots,"inline")]),_:3},8,["prop"]))}}),Zo=e=>(oi("data-v-0345ee1f"),e=e(),si(),e),KG=Zo(()=>ne("h1",null,"Options",-1)),GG=Zo(()=>ne("h2",null,"Generation Options",-1)),qG=Zo(()=>ne("h3",null,"Parameter Controls",-1)),ZG=Zo(()=>ne("h2",null,"Image Options",-1)),JG=Zo(()=>ne("div",null,[Ue("Drop file here OR "),ne("em",null,"click to upload")],-1)),QG=Zo(()=>ne("h2",null,"General Options",-1)),eq=ke({__name:"OptionsView",setup(e){const t=Ht(),n=Ia(),r=rn(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=ie([]),v=ie(),o=ie(!1),a=ie(0);async function u(c){n.importFromZip(c),v.value.clearFiles()}async function h(){Hi({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const c=await zt.outputs.toCollection().primaryKeys();await uC(c,!1,()=>{a.value++}),o.value=!1,a.value=0}return(c,f)=>(z(),le(je,null,[KG,ue(C(Rp),{"label-position":"top",model:C(t).options,onSubmit:f[10]||(f[10]=rt(()=>{},["prevent"]))},{default:he(()=>[ue(C(qj),{type:"border-card",style:{"min-height":"50vh"}},{default:he(()=>[ue(C(Mf),{label:"\u{1F5A8}\uFE0F Generation"},{default:he(()=>[GG,ue(C(Ri),{label:"Base URL"},{default:he(()=>[ue(C(Ua),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":f[0]||(f[0]=s=>C(t).baseURL=s)},null,8,["modelValue"])]),_:1}),qG,(z(!0),le(je,null,Nt(C(r).multiSelect,(s,d)=>{var g;return z(),le("div",{key:d},[ue(io,{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)),ue(io,{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"]),ue(co,{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"]),ue(io,{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}),ue(C(Mf),{label:"\u{1F4F7} Images"},{default:he(()=>[ZG,ue(gn,{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"]),ue(io,{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"]),ue(io,{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"]),ue(io,{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"]),ue(C(Ri),{label:"Export Images (ZIP File)"},{default:he(()=>[o.value?(z(),be(C(ht),{key:1,icon:C(Ws),disabled:""},{default:he(()=>[Ue("Downloading... ("+Ae(a.value)+" / "+Ae(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(z(),be(C(ht),{key:0,icon:C(Ws),onClick:f[8]||(f[8]=s=>h())},{default:he(()=>[Ue("Download "+Ae(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),ue(C(Ri),{label:"Import Images (ZIP File)"},{default:he(()=>[ue(C(Np),{drag:"",ref_key:"upload",ref:v,"auto-upload":!1,onChange:u,"file-list":l.value,limit:1,multiple:""},{default:he(()=>[ue(C(Re),{size:100},{default:he(()=>[ue(C(ip))]),_:1}),JG]),_:1},8,["file-list"])]),_:1})]),_:1}),ue(C(Mf),{label:"\u2699\uFE0F General"},{default:he(()=>[QG,ue(co,{label:"Color Scheme",prop:"colorScheme",modelValue:C(t).options.colorMode,"onUpdate:modelValue":f[9]||(f[9]=s=>C(t).options.colorMode=s),options:i},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}});const tq=Zt(eq,[["__scopeId","data-v-0345ee1f"]]),nq=Object.freeze(Object.defineProperty({__proto__:null,default:tq},Symbol.toStringTag,{value:"Module"})); diff --git a/koboldcpp.py b/koboldcpp.py index b4c9b9dbe..b0e3eb59c 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -2808,7 +2808,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 (120 if vid_req_frames > 120 else vid_req_frames)) + vid_req_frames = (1 if vid_req_frames < 1 else (160 if vid_req_frames > 160 else vid_req_frames)) vid_fps = (16 if vid_fps < 16 else (24 if vid_fps > 24 else vid_fps)) swap_refimg = (True if tryparseint(genparams.get("send_as_refimg", 0),0) else False)