diff --git a/dist/workspace_web/App-YT7a4Gj6.js b/dist/workspace_web/App-bXo9NVT7.js similarity index 81% rename from dist/workspace_web/App-YT7a4Gj6.js rename to dist/workspace_web/App-bXo9NVT7.js index ed4fae0..cc80ee0 100644 --- a/dist/workspace_web/App-YT7a4Gj6.js +++ b/dist/workspace_web/App-bXo9NVT7.js @@ -1,15 +1,15 @@ -var jl=Object.defineProperty;var Pl=(t,e,n)=>e in t?jl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(Pl(t,typeof e!="symbol"?e+"":e,n),n);import{u as Al,a as Nl,r as P,c as Fl,b as rt,m as Me,d as Lt,f as fe,j as k,e as Na,g as de,h as _e,B as Rl,i as Te,k as Tl,o as Ye,l as Rt,n as it,I as Hr,p as Hn,q as lo,s as Oe,t as Fa,v as Ml,w as Bl,x as zl,y as qr,z as Ll,A as Wl,C as Ul,D as Kl,E as vs,F as Ra,G as gs,H as Ta,J as $l,K as Vl,L as Hl,P as Ma,M as Gr,N as ws,O as Zr,Q as bs,R as _s,S as Jr,T as xs,U as Xs,_ as yn,V as Ba,W as za,X as tr,Y as La}from"./input.js";import{app as we}from"/scripts/app.js";import{api as ql}from"/scripts/api.js";function Gl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function Wa(t){var e;return Gl(t)&&(e=t.ownerDocument)!=null?e:document}function Zl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Jl=Zl();function Yl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function Ua(t){const{theme:e}=Al(),n=Nl();return P.useMemo(()=>Fl(e.direction,{...n,...t}),[t,e.direction,n])}var Xl=Object.defineProperty,Ql=(t,e,n)=>e in t?Xl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n)=>(Ql(t,typeof e!="symbol"?e+"":e,n),n);function Qs(t){return t.sort((e,n)=>{const r=e.compareDocumentPosition(n);if(r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY)return-1;if(r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS)return 1;if(r&Node.DOCUMENT_POSITION_DISCONNECTED||r&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC)throw Error("Cannot sort the given nodes.");return 0})}var ec=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function ea(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function ta(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var Io=typeof window<"u"?P.useLayoutEffect:P.useEffect,Ir=t=>t,tc=class{constructor(){De(this,"descendants",new Map),De(this,"register",t=>{if(t!=null)return ec(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),De(this,"unregister",t=>{this.descendants.delete(t);const e=Qs(Array.from(this.descendants.keys()));this.assignIndex(e)}),De(this,"destroy",()=>{this.descendants.clear()}),De(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),De(this,"count",()=>this.descendants.size),De(this,"enabledCount",()=>this.enabledValues().length),De(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),De(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),De(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),De(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),De(this,"first",()=>this.item(0)),De(this,"firstEnabled",()=>this.enabledItem(0)),De(this,"last",()=>this.item(this.descendants.size-1)),De(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),De(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),De(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),De(this,"next",(t,e=!0)=>{const n=ea(t,this.count(),e);return this.item(n)}),De(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=ea(r,this.enabledCount(),e);return this.enabledItem(o)}),De(this,"prev",(t,e=!0)=>{const n=ta(t,this.count()-1,e);return this.item(n)}),De(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=ta(r,this.enabledCount()-1,e);return this.enabledItem(o)}),De(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=Qs(n);e!=null&&e.disabled&&(e.disabled=!!e.disabled);const o={node:t,index:-1,...e};this.descendants.set(t,o),this.assignIndex(r)})}};function nc(){const t=P.useRef(new tc);return Io(()=>()=>t.current.destroy()),t.current}var[rc,Ka]=rt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function oc(t){const e=Ka(),[n,r]=P.useState(-1),o=P.useRef(null);Io(()=>()=>{o.current&&e.unregister(o.current)},[]),Io(()=>{if(!o.current)return;const i=Number(o.current.dataset.index);n!=i&&!Number.isNaN(i)&&r(i)});const s=Ir(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Me(s,o)}}function $a(){return[Ir(rc),()=>Ir(Ka()),()=>nc(),o=>oc(o)]}function Va(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,h)=>p!==h}=t,s=Lt(r),i=Lt(o),[a,l]=P.useState(n),u=e!==void 0,c=u?e:a,d=Lt(p=>{const v=typeof p=="function"?p(c):p;i(c,v)&&(u||l(v),s(v))},[u,s,c,i]);return[c,d]}var Oo=fe(function(e,n){const{htmlWidth:r,htmlHeight:o,alt:s,...i}=e;return k.jsx("img",{width:r,height:o,ref:n,alt:s,...i})});Oo.displayName="NativeImage";function sc(t){const{loading:e,src:n,srcSet:r,onLoad:o,onError:s,crossOrigin:i,sizes:a,ignoreFallback:l}=t,[u,c]=P.useState("pending");P.useEffect(()=>{c(n?"loading":"pending")},[n]);const d=P.useRef(),p=P.useCallback(()=>{if(!n)return;h();const v=new Image;v.src=n,i&&(v.crossOrigin=i),r&&(v.srcset=r),a&&(v.sizes=a),e&&(v.loading=e),v.onload=f=>{h(),c("loaded"),o==null||o(f)},v.onerror=f=>{h(),c("failed"),s==null||s(f)},d.current=v},[n,i,r,a,o,s,e]),h=()=>{d.current&&(d.current.onload=null,d.current.onerror=null,d.current=null)};return Na(()=>{if(!l)return u==="loading"&&p(),()=>{h()}},[u,p,l]),l?"loaded":u}var ac=(t,e)=>t!=="loaded"&&e==="beforeLoadOrError"||t==="failed"&&e==="onError";function ic(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}var Ha=fe(function(e,n){const{fallbackSrc:r,fallback:o,src:s,srcSet:i,align:a,fit:l,loading:u,ignoreFallback:c,crossOrigin:d,fallbackStrategy:p="beforeLoadOrError",referrerPolicy:h,...v}=e,f=r!==void 0||o!==void 0,m=u!=null||c||!f,y=sc({...e,crossOrigin:d,ignoreFallback:m}),g=ac(y,p),_={ref:n,objectFit:l,objectPosition:a,...m?v:ic(v,["onError","onLoad"])};return g?o||k.jsx(de.img,{as:Oo,className:"chakra-image__placeholder",src:r,..._}):k.jsx(de.img,{as:Oo,src:s,srcSet:i,crossOrigin:d,loading:u,referrerPolicy:h,className:"chakra-image",..._})});Ha.displayName="Image";function ks(t){return P.Children.toArray(t).filter(e=>P.isValidElement(e))}var lc={horizontal:{"> *:first-of-type:not(:last-of-type)":{borderEndRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderStartRadius:0}},vertical:{"> *:first-of-type:not(:last-of-type)":{borderBottomRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderTopRadius:0}}},cc={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},qa=fe(function(e,n){const{size:r,colorScheme:o,variant:s,className:i,spacing:a="0.5rem",isAttached:l,isDisabled:u,orientation:c="horizontal",...d}=e,p=_e("chakra-button__group",i),h=P.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:u}),[r,o,s,u]);let v={display:"inline-flex",...l?lc[c]:cc[c](a)};const f=c==="vertical";return k.jsx(Rl,{value:h,children:k.jsx(de.div,{ref:n,role:"group",__css:v,className:p,"data-attached":l?"":void 0,"data-orientation":c,flexDir:f?"column":void 0,...d})})});qa.displayName="ButtonGroup";var un=fe((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=P.isValidElement(a)?P.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return k.jsx(Te,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});un.displayName="IconButton";var[uc,Ga]=Tl("Card"),dc=fe(function(e,n){const{className:r,...o}=e,s=Ga();return k.jsx(de.div,{ref:n,className:_e("chakra-card__body",r),__css:s.body,...o})}),fc=fe(function(e,n){const{className:r,...o}=e,s=Ga();return k.jsx(de.div,{ref:n,className:_e("chakra-card__header",r),__css:s.header,...o})}),hc=fe(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=Ye(e),u=Rt("Card",e);return k.jsx(de.div,{ref:n,className:_e("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:i,alignItems:a,position:"relative",minWidth:0,wordWrap:"break-word",...u.container},...l,children:k.jsx(uc,{value:u,children:o})})}),[pc,Za]=rt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[mc,vn]=rt({strict:!1,name:"FormControlContext"});function yc(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=P.useId(),l=e||`field-${a}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[p,h]=P.useState(!1),[v,f]=P.useState(!1),[m,y]=P.useState(!1),g=P.useCallback((E={},F=null)=>({id:d,...E,ref:Me(F,I=>{I&&f(!0)})}),[d]),_=P.useCallback((E={},F=null)=>({...E,ref:F,"data-focus":it(m),"data-disabled":it(o),"data-invalid":it(r),"data-readonly":it(s),id:E.id!==void 0?E.id:u,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,m,r,s,u]),x=P.useCallback((E={},F=null)=>({id:c,...E,ref:Me(F,I=>{I&&h(!0)}),"aria-live":"polite"}),[c]),C=P.useCallback((E={},F=null)=>({...E,...i,ref:F,role:"group","data-focus":it(m),"data-disabled":it(o),"data-invalid":it(r),"data-readonly":it(s)}),[i,o,m,r,s]),D=P.useCallback((E={},F=null)=>({...E,ref:F,role:"presentation","aria-hidden":!0,children:E.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!m,onFocus:()=>y(!0),onBlur:()=>y(!1),hasFeedbackText:p,setHasFeedbackText:h,hasHelpText:v,setHasHelpText:f,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:i,getHelpTextProps:g,getErrorMessageProps:x,getRootProps:C,getLabelProps:_,getRequiredIndicatorProps:D}}var Yr=fe(function(e,n){const r=Rt("Form",e),o=Ye(e),{getRootProps:s,htmlProps:i,...a}=yc(o),l=_e("chakra-form-control",e.className);return k.jsx(mc,{value:a,children:k.jsx(pc,{value:r,children:k.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});Yr.displayName="FormControl";var vc=fe(function(e,n){const r=vn(),o=Za(),s=_e("chakra-form__helper-text",e.className);return k.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});vc.displayName="FormHelperText";var[gc,wc]=rt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Xr=fe((t,e)=>{const n=Rt("FormError",t),r=Ye(t),o=vn();return o!=null&&o.isInvalid?k.jsx(gc,{value:n,children:k.jsx(de.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:_e("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Xr.displayName="FormErrorMessage";var bc=fe((t,e)=>{const n=wc(),r=vn();if(!(r!=null&&r.isInvalid))return null;const o=_e("chakra-form__error-icon",t.className);return k.jsx(Hr,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:k.jsx("path",{fill:"currentColor",d:"M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z"})})});bc.displayName="FormErrorIcon";var Qr=fe(function(e,n){var r;const o=Hn("FormLabel",e),s=Ye(e),{className:i,children:a,requiredIndicator:l=k.jsx(Ja,{}),optionalIndicator:u=null,...c}=s,d=vn(),p=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return k.jsxs(de.label,{...p,className:_e("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[a,d!=null&&d.isRequired?l:u]})});Qr.displayName="FormLabel";var Ja=fe(function(e,n){const r=vn(),o=Za();if(!(r!=null&&r.isRequired))return null;const s=_e("chakra-form__required-indicator",e.className);return k.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});Ja.displayName="RequiredIndicator";function _c(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=xc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":lo(n),"aria-required":lo(o),"aria-readonly":lo(r)}}function xc(t){var e,n,r;const o=vn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:p,onFocus:h,onBlur:v,...f}=t,m=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&m.push(o.feedbackId),o!=null&&o.hasHelpText&&m.push(o.helpTextId),{...f,"aria-describedby":m.join(" ")||void 0,id:s??(o==null?void 0:o.id),isDisabled:(e=i??p)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=a??d)!=null?n:o==null?void 0:o.isReadOnly,isRequired:(r=l??u)!=null?r:o==null?void 0:o.isRequired,isInvalid:c??(o==null?void 0:o.isInvalid),onFocus:Oe(o==null?void 0:o.onFocus,h),onBlur:Oe(o==null?void 0:o.onBlur,v)}}function on(t,e,n,r){const o=Lt(n);return P.useEffect(()=>{const s=typeof t=="function"?t():t??document;if(!(!n||!s))return s.addEventListener(e,o,r),()=>{s.removeEventListener(e,o,r)}},[e,t,r,o,n]),()=>{const s=typeof t=="function"?t():t??document;s==null||s.removeEventListener(e,o,r)}}function kc(t){return"current"in t}var Ya=()=>typeof window<"u";function Ec(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var Cc=t=>Ya()&&t.test(navigator.vendor),Sc=t=>Ya()&&t.test(Ec()),Ic=()=>Sc(/mac|iphone|ipad|ipod/i),Oc=()=>Ic()&&Cc(/apple/i);function Dc(t){const{ref:e,elements:n,enabled:r}=t,o=()=>{var s,i;return(i=(s=e.current)==null?void 0:s.ownerDocument)!=null?i:document};on(o,"pointerdown",s=>{if(!Oc()||!r)return;const i=s.target,l=(n??[e]).some(u=>{const c=kc(u)?u.current:u;return(c==null?void 0:c.contains(i))||c===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var Xa={exports:{}},jc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Pc=jc,Ac=Pc;function Qa(){}function ei(){}ei.resetWarningCache=Qa;var Nc=function(){function t(r,o,s,i,a,l){if(l!==Ac){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:ei,resetWarningCache:Qa};return n.PropTypes=n,n};Xa.exports=Nc();var Fc=Xa.exports;const Mt=Fa(Fc);function Rc(t){const e=t.ownerDocument.defaultView||window,{overflow:n,overflowX:r,overflowY:o}=e.getComputedStyle(t);return/auto|scroll|overlay|hidden/.test(n+o+r)}function Tc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function ti(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:Ml(t)&&Rc(t)?t:ti(Tc(t))}var Mc=Jl?P.useLayoutEffect:P.useEffect;function Do(t,e=[]){const n=P.useRef(t);return Mc(()=>{n.current=t}),P.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function Bc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Do(n),i=P.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;P.useEffect(()=>{if(!r)return;const a=d=>{co(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&co(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&co(d,e)&&(i.isPointerDown=!1,o(d))},c=Wa(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function co(t,e){var n;const r=t.target;return r&&!Wa(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function zc(t,e){const n=P.useId();return P.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function Lc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function Wc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Do(n),i=Do(e),[a,l]=P.useState(t.defaultIsOpen||!1),[u,c]=Lc(r,a),d=zc(o,"disclosure"),p=P.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),h=P.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),v=P.useCallback(()=>{(c?p:h)()},[c,h,p]);return{isOpen:!!c,onOpen:h,onClose:p,onToggle:v,isControlled:u,getButtonProps:(f={})=>({...f,"aria-expanded":c,"aria-controls":d,onClick:Bl(f.onClick,v)}),getDisclosureProps:(f={})=>({...f,hidden:!c,id:d})}}var gn=fe(function(e,n){const{htmlSize:r,...o}=e,s=Rt("Input",o),i=Ye(o),a=_c(i),l=_e("chakra-input",e.className);return k.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});gn.displayName="Input";gn.id="Input";function Uc(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):zl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}var wt=fe(function(e,n){const r=Hn("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=Ye(e),u=Yl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return k.jsx(de.p,{ref:n,className:_e("chakra-text",e.className),...u,...l,__css:r})});wt.displayName="Text";var jo=t=>k.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});jo.displayName="StackDivider";var ni=t=>k.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});ni.displayName="StackItem";function Kc(t){const{spacing:e,direction:n}=t,r={column:{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},"column-reverse":{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},row:{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0},"row-reverse":{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0}};return{"&":Uc(n,o=>r[o])}}var Ke=fe((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:i="0.5rem",wrap:a,children:l,divider:u,className:c,shouldWrapChildren:d,...p}=t,h=n?"row":r??"column",v=P.useMemo(()=>Kc({spacing:i,direction:h}),[i,h]),f=!!u,m=!d&&!f,y=P.useMemo(()=>{const _=ks(l);return m?_:_.map((x,C)=>{const D=typeof x.key<"u"?x.key:C,E=C+1===_.length,I=d?k.jsx(ni,{children:x},D):x;if(!f)return I;const R=P.cloneElement(u,{__css:v}),K=E?null:R;return k.jsxs(P.Fragment,{children:[I,K]},D)})},[u,v,f,m,d,l]),g=_e("chakra-stack",c);return k.jsx(de.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:h,flexWrap:a,gap:f?void 0:i,className:g,...p,children:y})});Ke.displayName="Stack";var ot=fe((t,e)=>k.jsx(Ke,{align:"center",...t,direction:"row",ref:e}));ot.displayName="HStack";var sn=fe(function(e,n){const r=Hn("Heading",e),{className:o,...s}=Ye(e);return k.jsx(de.h2,{ref:n,className:_e("chakra-heading",e.className),...s,__css:r})});sn.displayName="Heading";var jt=de("div");jt.displayName="Box";var ri=fe(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return k.jsx(jt,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});ri.displayName="Square";var $c=fe(function(e,n){const{size:r,...o}=e;return k.jsx(ri,{size:r,ref:n,borderRadius:"9999px",...o})});$c.displayName="Circle";var oi=fe(function(e,n){const r=Hn("Badge",e),{className:o,...s}=Ye(e);return k.jsx(de.span,{ref:n,className:_e("chakra-badge",e.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});oi.displayName="Badge";var Wt=fe(function(e,n){const{direction:r,align:o,justify:s,wrap:i,basis:a,grow:l,shrink:u,...c}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:i,flexBasis:a,flexGrow:l,flexShrink:u};return k.jsx(de.div,{ref:n,__css:d,...c})});Wt.displayName="Flex";function Vc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Hc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=P.useState([]),s=P.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};P.useEffect(()=>i,[]);function l(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Vc(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),a()}}}return l}function qc(t,e,n,r){if(e==null)return r;if(!r)return t.find(i=>n(i).toLowerCase().startsWith(e.toLowerCase()));const o=t.filter(s=>n(s).toLowerCase().startsWith(e.toLowerCase()));if(o.length>0){let s;return o.includes(r)?(s=o.indexOf(r)+1,s===o.length&&(s=0),o[s]):(s=t.indexOf(o[0]),t[s])}return r}function Gc(){const t=P.useRef(new Map),e=t.current,n=P.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=P.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return P.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function uo(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function si(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:i,onMouseUp:a,onClick:l,onKeyDown:u,onKeyUp:c,tabIndex:d,onMouseOver:p,onMouseLeave:h,...v}=t,[f,m]=P.useState(!0),[y,g]=P.useState(!1),_=Gc(),x=A=>{A&&A.tagName!=="BUTTON"&&m(!1)},C=f?d:d||0,D=n&&!r,E=P.useCallback(A=>{if(n){A.stopPropagation(),A.preventDefault();return}A.currentTarget.focus(),l==null||l(A)},[n,l]),F=P.useCallback(A=>{y&&uo(A)&&(A.preventDefault(),A.stopPropagation(),g(!1),_.remove(document,"keyup",F,!1))},[y,_]),I=P.useCallback(A=>{if(u==null||u(A),n||A.defaultPrevented||A.metaKey||!uo(A.nativeEvent)||f)return;const X=o&&A.key==="Enter";s&&A.key===" "&&(A.preventDefault(),g(!0)),X&&(A.preventDefault(),A.currentTarget.click()),_.add(document,"keyup",F,!1)},[n,f,u,o,s,_,F]),R=P.useCallback(A=>{if(c==null||c(A),n||A.defaultPrevented||A.metaKey||!uo(A.nativeEvent)||f)return;s&&A.key===" "&&(A.preventDefault(),g(!1),A.currentTarget.click())},[s,f,n,c]),K=P.useCallback(A=>{A.button===0&&(g(!1),_.remove(document,"mouseup",K,!1))},[_]),j=P.useCallback(A=>{if(A.button!==0)return;if(n){A.stopPropagation(),A.preventDefault();return}f||g(!0),A.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",K,!1),i==null||i(A)},[n,f,i,_,K]),M=P.useCallback(A=>{A.button===0&&(f||g(!1),a==null||a(A))},[a,f]),b=P.useCallback(A=>{if(n){A.preventDefault();return}p==null||p(A)},[n,p]),N=P.useCallback(A=>{y&&(A.preventDefault(),g(!1)),h==null||h(A)},[y,h]),H=Me(e,x);return f?{...v,ref:H,type:"button","aria-disabled":D?void 0:n,disabled:D,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:c,onKeyDown:u,onMouseOver:p,onMouseLeave:h}:{...v,ref:H,role:"button","data-active":it(y),"aria-disabled":n?"true":void 0,tabIndex:D?void 0:C,onClick:E,onMouseDown:j,onMouseUp:M,onKeyUp:R,onKeyDown:I,onMouseOver:b,onMouseLeave:N}}function Zc(t){const e=t.current;if(!e)return!1;const n=Wl(e);return!n||e.contains(n)?!1:!!Ul(n)}function ai(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;qr(()=>{if(!s||Zc(t))return;const i=(o==null?void 0:o.current)||t.current;let a;if(i)return a=requestAnimationFrame(()=>{i.focus({preventScroll:!0})}),()=>{cancelAnimationFrame(a)}},[s,t,o])}var Jc={preventScroll:!0,shouldFocus:!1};function Yc(t,e=Jc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=Xc(t)?t.current:t,a=o&&s,l=P.useRef(a),u=P.useRef(s);Na(()=>{!u.current&&s&&(l.current=a),u.current=s},[s,a]);const c=P.useCallback(()=>{if(!(!s||!i||!l.current)&&(l.current=!1,!i.contains(document.activeElement)))if(n!=null&&n.current)requestAnimationFrame(()=>{var d;(d=n.current)==null||d.focus({preventScroll:r})});else{const d=Ll(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);qr(()=>{c()},[c]),on(i,"transitionend",c)}function Xc(t){return"current"in t}var Qt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),Ae={arrowShadowColor:Qt("--popper-arrow-shadow-color"),arrowSize:Qt("--popper-arrow-size","8px"),arrowSizeHalf:Qt("--popper-arrow-size-half"),arrowBg:Qt("--popper-arrow-bg"),transformOrigin:Qt("--popper-transform-origin"),arrowOffset:Qt("--popper-arrow-offset")};function Qc(t){if(t.includes("top"))return"1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("bottom"))return"-1px -1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("right"))return"-1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("left"))return"1px -1px 0px 0 var(--popper-arrow-shadow-color)"}var eu={top:"bottom center","top-start":"bottom left","top-end":"bottom right",bottom:"top center","bottom-start":"top left","bottom-end":"top right",left:"right center","left-start":"right top","left-end":"right bottom",right:"left center","right-start":"left top","right-end":"left bottom"},tu=t=>eu[t],na={scroll:!0,resize:!0};function nu(t){let e;return typeof t=="object"?e={enabled:!0,options:{...na,...t}}:e={enabled:t,options:na},e}var ru={name:"matchWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>()=>{const e=t.elements.reference;t.elements.popper.style.width=`${e.offsetWidth}px`}},ou={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{ra(t)},effect:({state:t})=>()=>{ra(t)}},ra=t=>{t.elements.popper.style.setProperty(Ae.transformOrigin.var,tu(t.placement))},su={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{au(t)}},au=t=>{var e;if(!t.placement)return;const n=iu(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:Ae.arrowSize.varRef,height:Ae.arrowSize.varRef,zIndex:-1});const r={[Ae.arrowSizeHalf.var]:`calc(${Ae.arrowSize.varRef} / 2 - 1px)`,[Ae.arrowOffset.var]:`calc(${Ae.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},iu=t=>{if(t.startsWith("top"))return{property:"bottom",value:Ae.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:Ae.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:Ae.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:Ae.arrowOffset.varRef}},lu={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{oa(t)},effect:({state:t})=>()=>{oa(t)}},oa=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Qc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:Ae.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},cu={"start-start":{ltr:"left-start",rtl:"right-start"},"start-end":{ltr:"left-end",rtl:"right-end"},"end-start":{ltr:"right-start",rtl:"left-start"},"end-end":{ltr:"right-end",rtl:"left-end"},start:{ltr:"left",rtl:"right"},end:{ltr:"right",rtl:"left"}},uu={"auto-start":"auto-end","auto-end":"auto-start","top-start":"top-end","top-end":"top-start","bottom-start":"bottom-end","bottom-end":"bottom-start"};function du(t,e="ltr"){var n,r;const o=((n=cu[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=uu[t])!=null?r:o}var $e="top",tt="bottom",nt="right",Ve="left",Es="auto",qn=[$e,tt,nt,Ve],dn="start",Mn="end",fu="clippingParents",ii="viewport",Cn="popper",hu="reference",sa=qn.reduce(function(t,e){return t.concat([e+"-"+dn,e+"-"+Mn])},[]),li=[].concat(qn,[Es]).reduce(function(t,e){return t.concat([e,e+"-"+dn,e+"-"+Mn])},[]),pu="beforeRead",mu="read",yu="afterRead",vu="beforeMain",gu="main",wu="afterMain",bu="beforeWrite",_u="write",xu="afterWrite",ku=[pu,mu,yu,vu,gu,wu,bu,_u,xu];function dt(t){return t?(t.nodeName||"").toLowerCase():null}function Ze(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function qt(t){var e=Ze(t).Element;return t instanceof e||t instanceof Element}function et(t){var e=Ze(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Cs(t){if(typeof ShadowRoot>"u")return!1;var e=Ze(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Eu(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},s=e.elements[n];!et(s)||!dt(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function Cu(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var o=e.elements[r],s=e.attributes[r]||{},i=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=i.reduce(function(l,u){return l[u]="",l},{});!et(o)||!dt(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Su={name:"applyStyles",enabled:!0,phase:"write",fn:Eu,effect:Cu,requires:["computeStyles"]};function ut(t){return t.split("-")[0]}var Ut=Math.max,Or=Math.min,fn=Math.round;function Po(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function ci(){return!/^((?!chrome|android).)*safari/i.test(Po())}function hn(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&et(t)&&(o=t.offsetWidth>0&&fn(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&fn(r.height)/t.offsetHeight||1);var i=qt(t)?Ze(t):window,a=i.visualViewport,l=!ci()&&n,u=(r.left+(l&&a?a.offsetLeft:0))/o,c=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,p=r.height/s;return{width:d,height:p,top:c,right:u+d,bottom:c+p,left:u,x:u,y:c}}function Ss(t){var e=hn(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function ui(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Cs(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function kt(t){return Ze(t).getComputedStyle(t)}function Iu(t){return["table","td","th"].indexOf(dt(t))>=0}function Tt(t){return((qt(t)?t.ownerDocument:t.document)||window.document).documentElement}function eo(t){return dt(t)==="html"?t:t.assignedSlot||t.parentNode||(Cs(t)?t.host:null)||Tt(t)}function aa(t){return!et(t)||kt(t).position==="fixed"?null:t.offsetParent}function Ou(t){var e=/firefox/i.test(Po()),n=/Trident/i.test(Po());if(n&&et(t)){var r=kt(t);if(r.position==="fixed")return null}var o=eo(t);for(Cs(o)&&(o=o.host);et(o)&&["html","body"].indexOf(dt(o))<0;){var s=kt(o);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return o;o=o.parentNode}return null}function Gn(t){for(var e=Ze(t),n=aa(t);n&&Iu(n)&&kt(n).position==="static";)n=aa(n);return n&&(dt(n)==="html"||dt(n)==="body"&&kt(n).position==="static")?e:n||Ou(t)||e}function Is(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function jn(t,e,n){return Ut(t,Or(e,n))}function Du(t,e,n){var r=jn(t,e,n);return r>n?n:r}function di(){return{top:0,right:0,bottom:0,left:0}}function fi(t){return Object.assign({},di(),t)}function hi(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var ju=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,fi(typeof e!="number"?e:hi(e,qn))};function Pu(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=ut(n.placement),l=Is(a),u=[Ve,nt].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!i)){var d=ju(o.padding,n),p=Ss(s),h=l==="y"?$e:Ve,v=l==="y"?tt:nt,f=n.rects.reference[c]+n.rects.reference[l]-i[l]-n.rects.popper[c],m=i[l]-n.rects.reference[l],y=Gn(s),g=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,_=f/2-m/2,x=d[h],C=g-p[c]-d[v],D=g/2-p[c]/2+_,E=jn(x,D,C),F=l;n.modifiersData[r]=(e={},e[F]=E,e.centerOffset=E-D,e)}}function Au(t){var e=t.state,n=t.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=e.elements.popper.querySelector(o),!o)||ui(e.elements.popper,o)&&(e.elements.arrow=o))}const Nu={name:"arrow",enabled:!0,phase:"main",fn:Pu,effect:Au,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function pn(t){return t.split("-")[1]}var Fu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ru(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:fn(n*o)/o||0,y:fn(r*o)/o||0}}function ia(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,p=i.x,h=p===void 0?0:p,v=i.y,f=v===void 0?0:v,m=typeof c=="function"?c({x:h,y:f}):{x:h,y:f};h=m.x,f=m.y;var y=i.hasOwnProperty("x"),g=i.hasOwnProperty("y"),_=Ve,x=$e,C=window;if(u){var D=Gn(n),E="clientHeight",F="clientWidth";if(D===Ze(n)&&(D=Tt(n),kt(D).position!=="static"&&a==="absolute"&&(E="scrollHeight",F="scrollWidth")),D=D,o===$e||(o===Ve||o===nt)&&s===Mn){x=tt;var I=d&&D===C&&C.visualViewport?C.visualViewport.height:D[E];f-=I-r.height,f*=l?1:-1}if(o===Ve||(o===$e||o===tt)&&s===Mn){_=nt;var R=d&&D===C&&C.visualViewport?C.visualViewport.width:D[F];h-=R-r.width,h*=l?1:-1}}var K=Object.assign({position:a},u&&Fu),j=c===!0?Ru({x:h,y:f},Ze(n)):{x:h,y:f};if(h=j.x,f=j.y,l){var M;return Object.assign({},K,(M={},M[x]=g?"0":"",M[_]=y?"0":"",M.transform=(C.devicePixelRatio||1)<=1?"translate("+h+"px, "+f+"px)":"translate3d("+h+"px, "+f+"px, 0)",M))}return Object.assign({},K,(e={},e[x]=g?f+"px":"",e[_]=y?h+"px":"",e.transform="",e))}function Tu(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,u={placement:ut(e.placement),variation:pn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,ia(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,ia(Object.assign({},u,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Mu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Tu,data:{}};var nr={passive:!0};function Bu(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,s=o===void 0?!0:o,i=r.resize,a=i===void 0?!0:i,l=Ze(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,nr)}),a&&l.addEventListener("resize",n.update,nr),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,nr)}),a&&l.removeEventListener("resize",n.update,nr)}}const zu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Bu,data:{}};var Lu={left:"right",right:"left",bottom:"top",top:"bottom"};function hr(t){return t.replace(/left|right|bottom|top/g,function(e){return Lu[e]})}var Wu={start:"end",end:"start"};function la(t){return t.replace(/start|end/g,function(e){return Wu[e]})}function Os(t){var e=Ze(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Ds(t){return hn(Tt(t)).left+Os(t).scrollLeft}function Uu(t,e){var n=Ze(t),r=Tt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var u=ci();(u||!u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+Ds(t),y:l}}function Ku(t){var e,n=Tt(t),r=Os(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Ut(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Ut(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+Ds(t),l=-r.scrollTop;return kt(o||n).direction==="rtl"&&(a+=Ut(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function js(t){var e=kt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function pi(t){return["html","body","#document"].indexOf(dt(t))>=0?t.ownerDocument.body:et(t)&&js(t)?t:pi(eo(t))}function Pn(t,e){var n;e===void 0&&(e=[]);var r=pi(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ze(r),i=o?[s].concat(s.visualViewport||[],js(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Pn(eo(i)))}function Ao(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function $u(t,e){var n=hn(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function ca(t,e,n){return e===ii?Ao(Uu(t,n)):qt(e)?$u(e,n):Ao(Ku(Tt(t)))}function Vu(t){var e=Pn(eo(t)),n=["absolute","fixed"].indexOf(kt(t).position)>=0,r=n&&et(t)?Gn(t):t;return qt(r)?e.filter(function(o){return qt(o)&&ui(o,r)&&dt(o)!=="body"}):[]}function Hu(t,e,n,r){var o=e==="clippingParents"?Vu(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,u){var c=ca(t,u,r);return l.top=Ut(c.top,l.top),l.right=Or(c.right,l.right),l.bottom=Or(c.bottom,l.bottom),l.left=Ut(c.left,l.left),l},ca(t,i,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function mi(t){var e=t.reference,n=t.element,r=t.placement,o=r?ut(r):null,s=r?pn(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case $e:l={x:i,y:e.y-n.height};break;case tt:l={x:i,y:e.y+e.height};break;case nt:l={x:e.x+e.width,y:a};break;case Ve:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=o?Is(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case dn:l[u]=l[u]-(e[c]/2-n[c]/2);break;case Mn:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function Bn(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,s=n.strategy,i=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?fu:a,u=n.rootBoundary,c=u===void 0?ii:u,d=n.elementContext,p=d===void 0?Cn:d,h=n.altBoundary,v=h===void 0?!1:h,f=n.padding,m=f===void 0?0:f,y=fi(typeof m!="number"?m:hi(m,qn)),g=p===Cn?hu:Cn,_=t.rects.popper,x=t.elements[v?g:p],C=Hu(qt(x)?x:x.contextElement||Tt(t.elements.popper),l,c,i),D=hn(t.elements.reference),E=mi({reference:D,element:_,strategy:"absolute",placement:o}),F=Ao(Object.assign({},_,E)),I=p===Cn?F:D,R={top:C.top-I.top+y.top,bottom:I.bottom-C.bottom+y.bottom,left:C.left-I.left+y.left,right:I.right-C.right+y.right},K=t.modifiersData.offset;if(p===Cn&&K){var j=K[o];Object.keys(R).forEach(function(M){var b=[nt,tt].indexOf(M)>=0?1:-1,N=[$e,tt].indexOf(M)>=0?"y":"x";R[M]+=j[N]*b})}return R}function qu(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?li:l,c=pn(r),d=c?a?sa:sa.filter(function(v){return pn(v)===c}):qn,p=d.filter(function(v){return u.indexOf(v)>=0});p.length===0&&(p=d);var h=p.reduce(function(v,f){return v[f]=Bn(t,{placement:f,boundary:o,rootBoundary:s,padding:i})[ut(f)],v},{});return Object.keys(h).sort(function(v,f){return h[v]-h[f]})}function Gu(t){if(ut(t)===Es)return[];var e=hr(t);return[la(t),e,la(e)]}function Zu(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,p=n.altBoundary,h=n.flipVariations,v=h===void 0?!0:h,f=n.allowedAutoPlacements,m=e.options.placement,y=ut(m),g=y===m,_=l||(g||!v?[hr(m)]:Gu(m)),x=[m].concat(_).reduce(function(Y,Z){return Y.concat(ut(Z)===Es?qu(e,{placement:Z,boundary:c,rootBoundary:d,padding:u,flipVariations:v,allowedAutoPlacements:f}):Z)},[]),C=e.rects.reference,D=e.rects.popper,E=new Map,F=!0,I=x[0],R=0;R=0,N=b?"width":"height",H=Bn(e,{placement:K,boundary:c,rootBoundary:d,altBoundary:p,padding:u}),A=b?M?nt:Ve:M?tt:$e;C[N]>D[N]&&(A=hr(A));var X=hr(A),V=[];if(s&&V.push(H[j]<=0),a&&V.push(H[A]<=0,H[X]<=0),V.every(function(Y){return Y})){I=K,F=!1;break}E.set(K,V)}if(F)for(var te=v?3:1,z=function(Z){var he=x.find(function(ye){var le=E.get(ye);if(le)return le.slice(0,Z).every(function(ue){return ue})});if(he)return I=he,"break"},B=te;B>0;B--){var ne=z(B);if(ne==="break")break}e.placement!==I&&(e.modifiersData[r]._skip=!0,e.placement=I,e.reset=!0)}}const Ju={name:"flip",enabled:!0,phase:"main",fn:Zu,requiresIfExists:["offset"],data:{_skip:!1}};function ua(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function da(t){return[$e,nt,tt,Ve].some(function(e){return t[e]>=0})}function Yu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Bn(e,{elementContext:"reference"}),a=Bn(e,{altBoundary:!0}),l=ua(i,r),u=ua(a,o,s),c=da(l),d=da(u);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:c,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const Xu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Yu};function Qu(t,e,n){var r=ut(t),o=[Ve,$e].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,i=s[0],a=s[1];return i=i||0,a=(a||0)*o,[Ve,nt].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function ed(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=li.reduce(function(c,d){return c[d]=Qu(d,e.rects,s),c},{}),a=i[e.placement],l=a.x,u=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=i}const td={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:ed};function nd(t){var e=t.state,n=t.name;e.modifiersData[n]=mi({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const rd={name:"popperOffsets",enabled:!0,phase:"read",fn:nd,data:{}};function od(t){return t==="x"?"y":"x"}function sd(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,p=n.tether,h=p===void 0?!0:p,v=n.tetherOffset,f=v===void 0?0:v,m=Bn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),y=ut(e.placement),g=pn(e.placement),_=!g,x=Is(y),C=od(x),D=e.modifiersData.popperOffsets,E=e.rects.reference,F=e.rects.popper,I=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,R=typeof I=="number"?{mainAxis:I,altAxis:I}:Object.assign({mainAxis:0,altAxis:0},I),K=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,j={x:0,y:0};if(D){if(s){var M,b=x==="y"?$e:Ve,N=x==="y"?tt:nt,H=x==="y"?"height":"width",A=D[x],X=A+m[b],V=A-m[N],te=h?-F[H]/2:0,z=g===dn?E[H]:F[H],B=g===dn?-F[H]:-E[H],ne=e.elements.arrow,Y=h&&ne?Ss(ne):{width:0,height:0},Z=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:di(),he=Z[b],ye=Z[N],le=jn(0,E[H],Y[H]),ue=_?E[H]/2-te-le-he-R.mainAxis:z-le-he-R.mainAxis,ke=_?-E[H]/2+te+le+ye+R.mainAxis:B+le+ye+R.mainAxis,ve=e.elements.arrow&&Gn(e.elements.arrow),me=ve?x==="y"?ve.clientTop||0:ve.clientLeft||0:0,Ee=(M=K==null?void 0:K[x])!=null?M:0,w=A+ue-Ee-me,U=A+ke-Ee,W=jn(h?Or(X,w):X,A,h?Ut(V,U):V);D[x]=W,j[x]=W-A}if(a){var O,S=x==="x"?$e:Ve,T=x==="x"?tt:nt,q=D[C],J=C==="y"?"height":"width",L=q+m[S],Q=q-m[T],re=[$e,Ve].indexOf(y)!==-1,ee=(O=K==null?void 0:K[C])!=null?O:0,se=re?L:q-E[J]-F[J]-ee+R.altAxis,ge=re?q+E[J]+F[J]-ee-R.altAxis:Q,pe=h&&re?Du(se,q,ge):jn(h?se:L,q,h?ge:Q);D[C]=pe,j[C]=pe-q}e.modifiersData[r]=j}}const ad={name:"preventOverflow",enabled:!0,phase:"main",fn:sd,requiresIfExists:["offset"]};function id(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function ld(t){return t===Ze(t)||!et(t)?Os(t):id(t)}function cd(t){var e=t.getBoundingClientRect(),n=fn(e.width)/t.offsetWidth||1,r=fn(e.height)/t.offsetHeight||1;return n!==1||r!==1}function ud(t,e,n){n===void 0&&(n=!1);var r=et(e),o=et(e)&&cd(e),s=Tt(e),i=hn(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((dt(e)!=="body"||js(s))&&(a=ld(e)),et(e)?(l=hn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Ds(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function dd(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function o(s){n.add(s.name);var i=[].concat(s.requires||[],s.requiresIfExists||[]);i.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&o(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||o(s)}),r}function fd(t){var e=dd(t);return ku.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function hd(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function pd(t){var e=t.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var fa={placement:"bottom",modifiers:[],strategy:"absolute"};function ha(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=P.useCallback(()=>{var R;!e||!v.current||!f.current||((R=g.current)==null||R.call(g),m.current=vd(v.current,f.current,{placement:y,modifiers:[lu,su,ou,{...ru,enabled:!!p},{name:"eventListeners",...nu(i)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:a??[0,l]}},{name:"flip",enabled:!!u,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:c}},...n??[]],strategy:o}),m.current.forceUpdate(),g.current=m.current.destroy)},[y,e,n,p,i,s,a,l,u,d,c,o]);P.useEffect(()=>()=>{var R;!v.current&&!f.current&&((R=m.current)==null||R.destroy(),m.current=null)},[]);const x=P.useCallback(R=>{v.current=R,_()},[_]),C=P.useCallback((R={},K=null)=>({...R,ref:Me(x,K)}),[x]),D=P.useCallback(R=>{f.current=R,_()},[_]),E=P.useCallback((R={},K=null)=>({...R,ref:Me(D,K),style:{...R.style,position:o,minWidth:p?void 0:"max-content",inset:"0 auto auto 0"}}),[o,D,p]),F=P.useCallback((R={},K=null)=>{const{size:j,shadowColor:M,bg:b,style:N,...H}=R;return{...H,ref:K,"data-popper-arrow":"",style:gd(R)}},[]),I=P.useCallback((R={},K=null)=>({...R,ref:K,"data-popper-arrow-inner":""}),[]);return{update(){var R;(R=m.current)==null||R.update()},forceUpdate(){var R;(R=m.current)==null||R.forceUpdate()},transformOrigin:Ae.transformOrigin.varRef,referenceRef:x,popperRef:D,getPopperProps:E,getArrowProps:F,getArrowInnerProps:I,getReferenceProps:C}}function gd(t){const{size:e,shadowColor:n,bg:r,style:o}=t,s={...o,position:"absolute"};return e&&(s["--popper-arrow-size"]=e),n&&(s["--popper-arrow-shadow-color"]=n),r&&(s["--popper-arrow-bg"]=r),s}function As(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Lt(n),i=Lt(e),[a,l]=P.useState(t.defaultIsOpen||!1),u=r!==void 0?r:a,c=r!==void 0,d=P.useId(),p=o??`disclosure-${d}`,h=P.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),v=P.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),f=P.useCallback(()=>{u?h():v()},[u,v,h]);function m(g={}){return{...g,"aria-expanded":u,"aria-controls":p,onClick(_){var x;(x=g.onClick)==null||x.call(g,_),f()}}}function y(g={}){return{...g,hidden:!u,id:p}}return{isOpen:u,onOpen:v,onClose:h,onToggle:f,isControlled:c,getButtonProps:m,getDisclosureProps:y}}function wd(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Lt(n),i=P.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;P.useEffect(()=>{if(!r)return;const a=d=>{fo(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&fo(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&fo(d,e)&&(i.isPointerDown=!1,o(d))},c=yi(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function fo(t,e){var n;const r=t.target;return r&&!yi(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function yi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function vi(t){const{isOpen:e,ref:n}=t,[r,o]=P.useState(e),[s,i]=P.useState(!1);return P.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),on(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=Kl(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function Ns(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[bd,_d,xd,kd]=$a(),[Ed,Zn]=rt({strict:!1,name:"MenuContext"});function Cd(t,...e){const n=P.useId(),r=t||n;return P.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function gi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function pa(t){return gi(t).activeElement===t}function Sd(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:i,isOpen:a,defaultIsOpen:l,onClose:u,onOpen:c,placement:d="bottom-start",lazyBehavior:p="unmount",direction:h,computePositionOnMount:v=!1,...f}=t,m=P.useRef(null),y=P.useRef(null),g=xd(),_=P.useCallback(()=>{requestAnimationFrame(()=>{var ne;(ne=m.current)==null||ne.focus({preventScroll:!1})})},[]),x=P.useCallback(()=>{const ne=setTimeout(()=>{var Y;if(o)(Y=o.current)==null||Y.focus();else{const Z=g.firstEnabled();Z&&M(Z.index)}});X.current.add(ne)},[g,o]),C=P.useCallback(()=>{const ne=setTimeout(()=>{const Y=g.lastEnabled();Y&&M(Y.index)});X.current.add(ne)},[g]),D=P.useCallback(()=>{c==null||c(),s?x():_()},[s,x,_,c]),{isOpen:E,onOpen:F,onClose:I,onToggle:R}=As({isOpen:a,defaultIsOpen:l,onClose:u,onOpen:D});wd({enabled:E&&r,ref:m,handler:ne=>{var Y;(Y=y.current)!=null&&Y.contains(ne.target)||I()}});const K=Ps({...f,enabled:E||v,placement:d,direction:h}),[j,M]=P.useState(-1);qr(()=>{E||M(-1)},[E]),ai(m,{focusRef:y,visible:E,shouldFocus:!0});const b=vi({isOpen:E,ref:m}),[N,H]=Cd(e,"menu-button","menu-list"),A=P.useCallback(()=>{F(),_()},[F,_]),X=P.useRef(new Set([]));P.useEffect(()=>{const ne=X.current;return()=>{ne.forEach(Y=>clearTimeout(Y)),ne.clear()}},[]);const V=P.useCallback(()=>{F(),x()},[x,F]),te=P.useCallback(()=>{F(),C()},[F,C]),z=P.useCallback(()=>{var ne,Y;const Z=gi(m.current),he=(ne=m.current)==null?void 0:ne.contains(Z.activeElement);if(!(E&&!he))return;const le=(Y=g.item(j))==null?void 0:Y.node;le==null||le.focus({preventScroll:!0})},[E,j,g]),B=P.useRef(null);return{openAndFocusMenu:A,openAndFocusFirstItem:V,openAndFocusLastItem:te,onTransitionEnd:z,unstable__animationState:b,descendants:g,popper:K,buttonId:N,menuId:H,forceUpdate:K.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:F,onClose:I,menuRef:m,buttonRef:y,focusedIndex:j,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:M,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:B}}function Zp(t={},e=null){const n=Zn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=P.useCallback(l=>{const u=l.key,d={Enter:s,ArrowDown:s,ArrowUp:i}[u];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,i]);return{...t,ref:Me(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":it(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Oe(t.onClick,r),onKeyDown:Oe(t.onKeyDown,a)}}function No(t){var e;return Dd(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function Id(t={},e=null){const n=Zn();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:s,isOpen:i,onClose:a,menuId:l,isLazy:u,lazyBehavior:c,unstable__animationState:d}=n,p=_d(),h=Hc({preventDefault:y=>y.key!==" "&&No(y.target)}),v=P.useCallback(y=>{if(!y.currentTarget.contains(y.target))return;const g=y.key,x={Tab:D=>D.preventDefault(),Escape:a,ArrowDown:()=>{const D=p.nextEnabled(r);D&&o(D.index)},ArrowUp:()=>{const D=p.prevEnabled(r);D&&o(D.index)}}[g];if(x){y.preventDefault(),x(y);return}const C=h(D=>{const E=qc(p.values(),D,F=>{var I,R;return(R=(I=F==null?void 0:F.node)==null?void 0:I.textContent)!=null?R:""},p.item(r));if(E){const F=p.indexOf(E.node);o(F)}});No(y.target)&&C(y)},[p,r,h,a,o]),f=P.useRef(!1);i&&(f.current=!0);const m=Ns({wasSelected:f.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:Me(s,e),children:m?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:Oe(t.onKeyDown,v)}}function Od(t={}){const{popper:e,isOpen:n}=Zn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function wi(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:i,isDisabled:a,isFocusable:l,closeOnSelect:u,type:c,...d}=t,p=Zn(),{setFocusedIndex:h,focusedIndex:v,closeOnSelect:f,onClose:m,menuRef:y,isOpen:g,menuId:_,rafId:x}=p,C=P.useRef(null),D=`${_}-menuitem-${P.useId()}`,{index:E,register:F}=kd({disabled:a&&!l}),I=P.useCallback(A=>{n==null||n(A),!a&&h(E)},[h,E,a,n]),R=P.useCallback(A=>{r==null||r(A),C.current&&!pa(C.current)&&I(A)},[I,r]),K=P.useCallback(A=>{o==null||o(A),!a&&h(-1)},[h,a,o]),j=P.useCallback(A=>{s==null||s(A),No(A.currentTarget)&&(u??f)&&m()},[m,s,f,u]),M=P.useCallback(A=>{i==null||i(A),h(E)},[h,i,E]),b=E===v,N=a&&!l;qr(()=>{if(g)return b&&!N&&C.current?(x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var A;(A=C.current)==null||A.focus({preventScroll:!0}),x.current=null})):y.current&&!pa(y.current)&&y.current.focus({preventScroll:!0}),()=>{x.current&&cancelAnimationFrame(x.current)}},[b,N,y,g]);const H=si({onClick:j,onFocus:M,onMouseEnter:I,onMouseMove:R,onMouseLeave:K,ref:Me(F,C,e),isDisabled:a,isFocusable:l});return{...d,...H,type:c??H.type,id:D,role:"menuitem",tabIndex:b?0:-1}}function Jp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...wi(o,e),role:`menuitem${n}`,"aria-checked":r}}function Yp(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...i}=t,l=n==="radio"?"":[],[u,c]=Va({defaultValue:o??l,value:r,onChange:s}),d=P.useCallback(v=>{if(n==="radio"&&typeof u=="string"&&c(v),n==="checkbox"&&Array.isArray(u)){const f=u.includes(v)?u.filter(m=>m!==v):u.concat(v);c(f)}},[u,c,n]),h=ks(e).map(v=>{if(v.type.id!=="MenuItemOption")return v;const f=y=>{var g,_;d(v.props.value),(_=(g=v.props).onClick)==null||_.call(g,y)},m=n==="radio"?v.props.value===u:u.includes(v.props.value);return P.cloneElement(v,{type:n,onClick:f,isChecked:m})});return{...i,children:h}}function Dd(t){var e;if(!jd(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function jd(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[Pd,to]=rt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Fs=t=>{const{children:e}=t,n=Rt("Menu",t),r=Ye(t),{direction:o}=vs(),{descendants:s,...i}=Sd({...r,direction:o}),a=P.useMemo(()=>i,[i]),{isOpen:l,onClose:u,forceUpdate:c}=a;return k.jsx(bd,{value:s,children:k.jsx(Ed,{value:a,children:k.jsx(Pd,{value:n,children:Ra(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};Fs.displayName="Menu";var bi=fe((t,e)=>{const n=to();return k.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});bi.displayName="MenuCommand";var Ad=fe((t,e)=>{const{type:n,...r}=t,o=to(),s=r.as||n?n??void 0:"button",i=P.useMemo(()=>({textDecoration:"none",color:"inherit",userSelect:"none",display:"flex",width:"100%",alignItems:"center",textAlign:"start",flex:"0 0 auto",outline:0,...o.item}),[o.item]);return k.jsx(de.button,{ref:e,type:s,...r,__css:i})}),_i=t=>{const{className:e,children:n,...r}=t,o=to(),s=P.Children.only(n),i=P.isValidElement(s)?P.cloneElement(s,{focusable:"false","aria-hidden":!0,className:_e("chakra-menu__icon",s.props.className)}):null,a=_e("chakra-menu__icon-wrapper",e);return k.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};_i.displayName="MenuIcon";var mt=fe((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=wi(a,e),c=n||o?k.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return k.jsxs(Ad,{...l,className:_e("chakra-menu__menuitem",l.className),children:[n&&k.jsx(_i,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&k.jsx(bi,{marginStart:s,children:o})]})});mt.displayName="MenuItem";var Nd={enter:{visibility:"visible",opacity:1,scale:1,transition:{duration:.2,ease:[.4,0,.2,1]}},exit:{transitionEnd:{visibility:"hidden"},opacity:0,scale:.8,transition:{duration:.1,easings:"easeOut"}}},Fd=de(gs.div),Rs=fe(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=Zn(),d=Id(a,n),p=Od(s),h=to();return k.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=h.list)==null?void 0:r.zIndex},children:k.jsx(Fd,{variants:Nd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...h.list},...i,className:_e("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:Ta(c.onComplete,d.onAnimationComplete)})})});Rs.displayName="MenuList";var[Rd,wn]=rt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[Td,no]=rt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function xi(t){const e=P.Children.only(t.children),{getTriggerProps:n}=wn();return P.cloneElement(e,n(e.props,e.ref))}xi.displayName="PopoverTrigger";var en={click:"click",hover:"hover"};function Md(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:u=en.click,openDelay:c=200,closeDelay:d=200,isLazy:p,lazyBehavior:h="unmount",computePositionOnMount:v,...f}=t,{isOpen:m,onClose:y,onOpen:g,onToggle:_}=As(t),x=P.useRef(null),C=P.useRef(null),D=P.useRef(null),E=P.useRef(!1),F=P.useRef(!1);m&&(F.current=!0);const[I,R]=P.useState(!1),[K,j]=P.useState(!1),M=P.useId(),b=o??M,[N,H,A,X]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${b}`),{referenceRef:V,getArrowProps:te,getPopperProps:z,getArrowInnerProps:B,forceUpdate:ne}=Ps({...f,enabled:m||!!v}),Y=vi({isOpen:m,ref:D});Dc({enabled:m,ref:C}),ai(D,{focusRef:C,visible:m,shouldFocus:s&&u===en.click}),Yc(D,{focusRef:r,visible:m,shouldFocus:i&&u===en.click});const Z=Ns({wasSelected:F.current,enabled:p,mode:h,isSelected:Y.present}),he=P.useCallback((U={},W=null)=>{const O={...U,style:{...U.style,transformOrigin:Ae.transformOrigin.varRef,[Ae.arrowSize.var]:a?`${a}px`:void 0,[Ae.arrowShadowColor.var]:l},ref:Me(D,W),children:Z?U.children:null,id:H,tabIndex:-1,role:"dialog",onKeyDown:Oe(U.onKeyDown,S=>{n&&S.key==="Escape"&&y()}),onBlur:Oe(U.onBlur,S=>{const T=ma(S),q=ho(D.current,T),J=ho(C.current,T);m&&e&&(!q&&!J)&&y()}),"aria-labelledby":I?A:void 0,"aria-describedby":K?X:void 0};return u===en.hover&&(O.role="tooltip",O.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0}),O.onMouseLeave=Oe(U.onMouseLeave,S=>{S.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>y(),d))})),O},[Z,H,I,A,K,X,u,n,y,m,e,d,l,a]),ye=P.useCallback((U={},W=null)=>z({...U,style:{visibility:m?"visible":"hidden",...U.style}},W),[m,z]),le=P.useCallback((U,W=null)=>({...U,ref:Me(W,x,V)}),[x,V]),ue=P.useRef(),ke=P.useRef(),ve=P.useCallback(U=>{x.current==null&&V(U)},[V]),me=P.useCallback((U={},W=null)=>{const O={...U,ref:Me(C,W,ve),id:N,"aria-haspopup":"dialog","aria-expanded":m,"aria-controls":H};return u===en.click&&(O.onClick=Oe(U.onClick,_)),u===en.hover&&(O.onFocus=Oe(U.onFocus,()=>{ue.current===void 0&&g()}),O.onBlur=Oe(U.onBlur,S=>{const T=ma(S),q=!ho(D.current,T);m&&e&&q&&y()}),O.onKeyDown=Oe(U.onKeyDown,S=>{S.key==="Escape"&&y()}),O.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0,ue.current=window.setTimeout(()=>g(),c)}),O.onMouseLeave=Oe(U.onMouseLeave,()=>{E.current=!1,ue.current&&(clearTimeout(ue.current),ue.current=void 0),ke.current=window.setTimeout(()=>{E.current===!1&&y()},d)})),O},[N,m,H,u,ve,_,g,e,y,c,d]);P.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current),ke.current&&clearTimeout(ke.current)},[]);const Ee=P.useCallback((U={},W=null)=>({...U,id:A,ref:Me(W,O=>{R(!!O)})}),[A]),w=P.useCallback((U={},W=null)=>({...U,id:X,ref:Me(W,O=>{j(!!O)})}),[X]);return{forceUpdate:ne,isOpen:m,onAnimationComplete:Y.onComplete,onClose:y,getAnchorProps:le,getArrowProps:te,getArrowInnerProps:B,getPopoverPositionerProps:ye,getPopoverProps:he,getTriggerProps:me,getHeaderProps:Ee,getBodyProps:w}}function ho(t,e){return t===e||(t==null?void 0:t.contains(e))}function ma(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function ki(t){const e=Rt("Popover",t),{children:n,...r}=Ye(t),o=vs(),s=Md({...r,direction:o.direction});return k.jsx(Rd,{value:s,children:k.jsx(Td,{value:e,children:Ra(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}ki.displayName="Popover";var po=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Ei(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:i,shadowColor:a}=t,{getArrowProps:l,getArrowInnerProps:u}=wn(),c=no(),d=(e=n??r)!=null?e:o,p=s??i;return k.jsx(de.div,{...l(),className:"chakra-popover__arrow-positioner",children:k.jsx(de.div,{className:_e("chakra-popover__arrow",t.className),...u(t),__css:{"--popper-arrow-shadow-color":po("colors",a),"--popper-arrow-bg":po("colors",d),"--popper-arrow-shadow":po("shadows",p),...c.arrow}})})}Ei.displayName="PopoverArrow";var Ci=fe(function(e,n){const{getBodyProps:r}=wn(),o=no();return k.jsx(de.div,{...r(e,n),className:_e("chakra-popover__body",e.className),__css:o.body})});Ci.displayName="PopoverBody";var Si=fe(function(e,n){const{onClose:r}=wn(),o=no();return k.jsx($l,{size:"sm",onClick:r,className:_e("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});Si.displayName="PopoverCloseButton";function Bd(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var zd={exit:{opacity:0,scale:.95,transition:{duration:.1,ease:[.4,0,1,1]}},enter:{scale:1,opacity:1,transition:{duration:.15,ease:[0,0,.2,1]}}},Ld=de(gs.section),Ii=fe(function(e,n){const{variants:r=zd,...o}=e,{isOpen:s}=wn();return k.jsx(Ld,{ref:n,variants:Bd(r),initial:!1,animate:s?"enter":"exit",...o})});Ii.displayName="PopoverTransition";var Oi=fe(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=wn(),u=no(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return k.jsx(de.div,{...a(r),__css:u.popper,className:"chakra-popover__popper",children:k.jsx(Ii,{...o,...i(s,n),onAnimationComplete:Ta(l,s.onAnimationComplete),className:_e("chakra-popover__content",e.className),__css:c})})});Oi.displayName="PopoverContent";var[Wd,Ud,Kd,$d]=$a();function Vd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:i,lazyBehavior:a="unmount",orientation:l="horizontal",direction:u="ltr",...c}=t,[d,p]=P.useState(n??0),[h,v]=Va({defaultValue:n??0,value:o,onChange:r});P.useEffect(()=>{o!=null&&p(o)},[o]);const f=Kd(),m=P.useId();return{id:`tabs-${(e=t.id)!=null?e:m}`,selectedIndex:h,focusedIndex:d,setSelectedIndex:v,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:f,direction:u,htmlProps:c}}var[Hd,ro]=rt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function qd(t){const{focusedIndex:e,orientation:n,direction:r}=ro(),o=Ud(),s=P.useCallback(i=>{const a=()=>{var g;const _=o.nextEnabled(e);_&&((g=_.node)==null||g.focus())},l=()=>{var g;const _=o.prevEnabled(e);_&&((g=_.node)==null||g.focus())},u=()=>{var g;const _=o.firstEnabled();_&&((g=_.node)==null||g.focus())},c=()=>{var g;const _=o.lastEnabled();_&&((g=_.node)==null||g.focus())},d=n==="horizontal",p=n==="vertical",h=i.key,v=r==="ltr"?"ArrowLeft":"ArrowRight",f=r==="ltr"?"ArrowRight":"ArrowLeft",y={[v]:()=>d&&l(),[f]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:u,End:c}[h];y&&(i.preventDefault(),y(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Oe(t.onKeyDown,s)}}function Gd(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=ro(),{index:u,register:c}=$d({disabled:e&&!n}),d=u===l,p=()=>{o(u)},h=()=>{a(u),!s&&!(e&&n)&&o(u)},v=si({...r,ref:Me(c,t.ref),isDisabled:e,isFocusable:n,onClick:Oe(t.onClick,p)}),f="button";return{...v,id:Di(i,u),role:"tab",tabIndex:d?0:-1,type:f,"aria-selected":d,"aria-controls":ji(i,u),onFocus:e?void 0:Oe(t.onFocus,h)}}var[Zd,Jd]=rt({});function Yd(t){const e=ro(),{id:n,selectedIndex:r}=e,s=ks(t.children).map((i,a)=>P.createElement(Zd,{key:a,value:{isSelected:a===r,id:ji(n,a),tabId:Di(n,a),selectedIndex:r}},i));return{...t,children:s}}function Xd(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=ro(),{isSelected:s,id:i,tabId:a}=Jd(),l=P.useRef(!1);s&&(l.current=!0);const u=Ns({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:u?e:null,role:"tabpanel","aria-labelledby":a,hidden:!s,id:i}}function Di(t,e){return`${t}--tab-${e}`}function ji(t,e){return`${t}--tabpanel-${e}`}var[Qd,oo]=rt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Pi=fe(function(e,n){const r=Rt("Tabs",e),{children:o,className:s,...i}=Ye(e),{htmlProps:a,descendants:l,...u}=Vd(i),c=P.useMemo(()=>u,[u]),{isFitted:d,...p}=a,h={position:"relative",...r.root};return k.jsx(Wd,{value:l,children:k.jsx(Hd,{value:c,children:k.jsx(Qd,{value:r,children:k.jsx(de.div,{className:_e("chakra-tabs",s),ref:n,...p,__css:h,children:o})})})})});Pi.displayName="Tabs";var Ai=fe(function(e,n){const r=qd({...e,ref:n}),s={display:"flex",...oo().tablist};return k.jsx(de.div,{...r,className:_e("chakra-tabs__tablist",e.className),__css:s})});Ai.displayName="TabList";var Fo=fe(function(e,n){const r=Xd({...e,ref:n}),o=oo();return k.jsx(de.div,{outline:"0",...r,className:_e("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Fo.displayName="TabPanel";var Ni=fe(function(e,n){const r=Yd(e),o=oo();return k.jsx(de.div,{...r,width:"100%",ref:n,className:_e("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});Ni.displayName="TabPanels";var Ro=fe(function(e,n){const r=oo(),o=Gd({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return k.jsx(de.button,{...o,className:_e("chakra-tabs__tab",e.className),__css:s})});Ro.displayName="Tab";var[ef,Fi]=rt({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Gt=fe((t,e)=>{const n=Rt("Tag",t),r=Ye(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return k.jsx(ef,{value:n,children:k.jsx(de.span,{ref:e,...r,__css:o})})});Gt.displayName="Tag";var tf=fe((t,e)=>{const n=Fi();return k.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});tf.displayName="TagLabel";var nf=fe((t,e)=>k.jsx(Hr,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));nf.displayName="TagLeftIcon";var rf=fe((t,e)=>k.jsx(Hr,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));rf.displayName="TagRightIcon";var Ri=t=>k.jsx(Hr,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:k.jsx("path",{fill:"currentColor",d:"M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z"})});Ri.displayName="TagCloseIcon";var of=fe((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...Fi().closeButton};return k.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||k.jsx(Ri,{})})});of.displayName="TagCloseButton";var sf={exit:{scale:.85,opacity:0,transition:{opacity:{duration:.15,easings:"easeInOut"},scale:{duration:.2,easings:"easeInOut"}}},enter:{scale:1,opacity:1,transition:{opacity:{easings:"easeOut",duration:.2},scale:{duration:.2,ease:[.175,.885,.4,1.1]}}}},To=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},pr=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function af(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:i=o,closeOnEsc:a=!0,onOpen:l,onClose:u,placement:c,id:d,isOpen:p,defaultIsOpen:h,arrowSize:v=10,arrowShadowColor:f,arrowPadding:m,modifiers:y,isDisabled:g,gutter:_,offset:x,direction:C,...D}=t,{isOpen:E,onOpen:F,onClose:I}=As({isOpen:p,defaultIsOpen:h,onOpen:l,onClose:u}),{referenceRef:R,getPopperProps:K,getArrowInnerProps:j,getArrowProps:M}=Ps({enabled:E,placement:c,arrowPadding:m,modifiers:y,gutter:_,offset:x,direction:C}),b=P.useId(),H=`tooltip-${d??b}`,A=P.useRef(null),X=P.useRef(),V=P.useCallback(()=>{X.current&&(clearTimeout(X.current),X.current=void 0)},[]),te=P.useRef(),z=P.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=void 0)},[]),B=P.useCallback(()=>{z(),I()},[I,z]),ne=lf(A,B),Y=P.useCallback(()=>{if(!g&&!X.current){E&&ne();const me=pr(A);X.current=me.setTimeout(F,e)}},[ne,g,E,F,e]),Z=P.useCallback(()=>{V();const me=pr(A);te.current=me.setTimeout(B,n)},[n,B,V]),he=P.useCallback(()=>{E&&r&&Z()},[r,Z,E]),ye=P.useCallback(()=>{E&&i&&Z()},[i,Z,E]),le=P.useCallback(me=>{E&&me.key==="Escape"&&Z()},[E,Z]);on(()=>To(A),"keydown",a?le:void 0),on(()=>{if(!s)return null;const me=A.current;if(!me)return null;const Ee=ti(me);return Ee.localName==="body"?pr(A):Ee},"scroll",()=>{E&&s&&B()},{passive:!0,capture:!0}),P.useEffect(()=>{g&&(V(),E&&I())},[g,E,I,V]),P.useEffect(()=>()=>{V(),z()},[V,z]),on(()=>A.current,"pointerleave",Z);const ue=P.useCallback((me={},Ee=null)=>({...me,ref:Me(A,Ee,R),onPointerEnter:Oe(me.onPointerEnter,U=>{U.pointerType!=="touch"&&Y()}),onClick:Oe(me.onClick,he),onPointerDown:Oe(me.onPointerDown,ye),onFocus:Oe(me.onFocus,Y),onBlur:Oe(me.onBlur,Z),"aria-describedby":E?H:void 0}),[Y,Z,ye,E,H,he,R]),ke=P.useCallback((me={},Ee=null)=>K({...me,style:{...me.style,[Ae.arrowSize.var]:v?`${v}px`:void 0,[Ae.arrowShadowColor.var]:f}},Ee),[K,v,f]),ve=P.useCallback((me={},Ee=null)=>{const w={...me.style,position:"relative",transformOrigin:Ae.transformOrigin.varRef};return{ref:Ee,...D,...me,id:H,role:"tooltip",style:w}},[D,H]);return{isOpen:E,show:Y,hide:Z,getTriggerProps:ue,getTooltipProps:ve,getTooltipPositionerProps:ke,getArrowProps:M,getArrowInnerProps:j}}var mo="chakra-ui:close-tooltip";function lf(t,e){return P.useEffect(()=>{const n=To(t);return n.addEventListener(mo,e),()=>n.removeEventListener(mo,e)},[e,t]),()=>{const n=To(t),r=pr(t);n.dispatchEvent(new r.CustomEvent(mo))}}function cf(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function uf(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var df=de(gs.div),bt=fe((t,e)=>{var n,r;const o=Hn("Tooltip",t),s=Ye(t),i=vs(),{children:a,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:p,portalProps:h,background:v,backgroundColor:f,bgColor:m,motionProps:y,...g}=s,_=(r=(n=v??f)!=null?n:p)!=null?r:m;if(_){o.bg=_;const K=Vl(i,"colors",_);o[Ae.arrowBg.var]=K}const x=af({...g,direction:i.direction}),C=typeof a=="string"||u;let D;if(C)D=k.jsx(de.span,{display:"inline-block",tabIndex:0,...x.getTriggerProps(),children:a});else{const K=P.Children.only(a);D=P.cloneElement(K,x.getTriggerProps(K.props,K.ref))}const E=!!c,F=x.getTooltipProps({},e),I=E?cf(F,["role","id"]):F,R=uf(F,["role","id"]);return l?k.jsxs(k.Fragment,{children:[D,k.jsx(Hl,{children:x.isOpen&&k.jsx(Ma,{...h,children:k.jsx(de.div,{...x.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:k.jsxs(df,{variants:sf,initial:"exit",animate:"enter",exit:"exit",...y,...I,__css:o,children:[l,E&&k.jsx(de.span,{srOnly:!0,...R,children:c}),d&&k.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:k.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):k.jsx(k.Fragment,{children:a})});bt.displayName="Tooltip";let rr;const ff=new Uint8Array(16);function hf(){if(!rr&&(rr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!rr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return rr(ff)}const Re=[];for(let t=0;t<256;++t)Re.push((t+256).toString(16).slice(1));function pf(t,e=0){return Re[t[e+0]]+Re[t[e+1]]+Re[t[e+2]]+Re[t[e+3]]+"-"+Re[t[e+4]]+Re[t[e+5]]+"-"+Re[t[e+6]]+Re[t[e+7]]+"-"+Re[t[e+8]]+Re[t[e+9]]+"-"+Re[t[e+10]]+Re[t[e+11]]+Re[t[e+12]]+Re[t[e+13]]+Re[t[e+14]]+Re[t[e+15]]}const mf=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ya={randomUUID:mf};function Dr(t,e,n){if(ya.randomUUID&&!e&&!t)return ya.randomUUID();t=t||{};const r=t.random||(t.rng||hf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=r[o];return e}return pf(r)}async function yf(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await fetch(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function vf(t,e){try{return await(await fetch("/workspace/save_db",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:t,json:e})})).text()}catch(n){console.error("Error saving workspace:",n)}}async function gf(t,e){try{return await(await fetch("/workspace/update_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,json_str:e})})).text()}catch(n){alert("Error saving workflow .json file: "+n),console.error("Error saving workspace:",n)}}async function Ti(t,e=!1){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,deleteEmptyFolder:e})})).text()}catch(n){console.error("Error deleting file:",n)}}async function Xp(t){try{return await(await fetch("/workspace/get_system_dir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absolute_dir:t??""})})).json()}catch(e){console.error("Error getting workflows dir:",e)}}async function Qp(){try{return await(await fetch("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function wf(){const e=await(await fetch("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function bf(){try{return await(await fetch("/model_manager/get_model_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function em(){try{return await(await fetch("/model_manager/get_folder_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function tm(t){try{return await(await fetch("/model_manager/cancel_installation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({save_path:t})})).text()}catch(e){console.error("Error move file:",e)}}async function nm(t,e){try{return await(await fetch("/workspace/copy_json_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:t,dst:e})})).json()}catch(n){console.error("Error copy flows to new directory:",n)}}const _f="backup",jr="workspace";let or=null;function xf(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(jr)||o.createObjectStore(jr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function kf(){try{return or==null&&(or=await xf()),new Promise((t,e)=>{if(or==null)return e("indexDB is null");const o=or.transaction([jr],"readonly").objectStore(jr).get(_f);o.onsuccess=()=>{o.result?t(o.result.value):t(void 0)},o.onerror=()=>e(o.error)})}catch(t){console.error("Error while reading from database:",t)}}async function Ef(){try{return await kf()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const Ce=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ne=Object.keys,ze=Array.isArray;function Ue(t,e){return typeof e!="object"||Ne(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||Ce.Promise||(Ce.Promise=Promise);const zn=Object.getPrototypeOf,Cf={}.hasOwnProperty;function Je(t,e){return Cf.call(t,e)}function mn(t,e){typeof e=="function"&&(e=e(zn(t))),(typeof Reflect>"u"?Ne:Reflect.ownKeys)(e).forEach(n=>{_t(t,n,e[n])})}const Mi=Object.defineProperty;function _t(t,e,n,r){Mi(t,e,Ue(n&&Je(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function an(t){return{from:function(e){return t.prototype=Object.create(e.prototype),_t(t.prototype,"constructor",t),{extend:mn.bind(null,t.prototype)}}}}const Sf=Object.getOwnPropertyDescriptor;function Ts(t,e){let n;return Sf(t,e)||(n=zn(t))&&Ts(n,e)}const If=[].slice;function Pr(t,e,n){return If.call(t,e,n)}function Bi(t,e){return e(t)}function In(t){if(!t)throw new Error("Assertion Failed")}function zi(t){Ce.setImmediate?setImmediate(t):setTimeout(t,0)}function Li(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function xt(t,e){if(Je(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,o=e.length;r["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>Ce[t]),Df=Ki.map(t=>Ce[t]);Li(Ki,t=>[t,!0]);let It=null;function Jn(t){It=typeof WeakMap<"u"&&new WeakMap;const e=Mo(t);return It=null,e}function Mo(t){if(!t||typeof t!="object")return t;let e=It&&It.get(t);if(e)return e;if(ze(t)){e=[],It&&It.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=zn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),It&&It.set(t,e),t)Je(t,o)&&(e[o]=Mo(t[o]))}return e}const{toString:jf}={};function Bo(t){return jf.call(t).slice(8,-1)}const zo=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Pf=typeof zo=="symbol"?function(t){var e;return t!=null&&(e=t[zo])&&e.apply(t)}:function(){return null},rn={};function vt(t){var e,n,r,o;if(arguments.length===1){if(ze(t))return t.slice();if(this===rn&&typeof t=="string")return[t];if(o=Pf(t)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const Ms=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var ft=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function $i(t,e){ft=t,Vi=e}var Vi=()=>!0;const Af=!new Error("").stack;function Yt(){if(Af)try{throw Yt.arguments,new Error}catch(t){return t}return new Error}function Lo(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` +var jl=Object.defineProperty;var Pl=(t,e,n)=>e in t?jl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(Pl(t,typeof e!="symbol"?e+"":e,n),n);import{u as Al,a as Nl,r as P,c as Fl,b as rt,m as Me,d as Lt,f as fe,j as k,e as Na,g as de,h as _e,B as Rl,i as Te,k as Tl,o as Ye,l as Rt,n as it,I as Hr,p as Hn,q as lo,s as Oe,t as Fa,v as Ml,w as Bl,x as zl,y as qr,z as Ll,A as Wl,C as Ul,D as Kl,E as vs,F as Ra,G as gs,H as Ta,J as $l,K as Vl,L as Hl,P as Ma,M as Gr,N as ws,O as Zr,Q as bs,R as _s,S as Jr,T as xs,U as Xs,_ as yn,V as Ba,W as za,X as tr,Y as La}from"./input.js";import{app as we}from"/scripts/app.js";import{api as ql}from"/scripts/api.js";function Gl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function Wa(t){var e;return Gl(t)&&(e=t.ownerDocument)!=null?e:document}function Zl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Jl=Zl();function Yl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function Ua(t){const{theme:e}=Al(),n=Nl();return P.useMemo(()=>Fl(e.direction,{...n,...t}),[t,e.direction,n])}var Xl=Object.defineProperty,Ql=(t,e,n)=>e in t?Xl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n)=>(Ql(t,typeof e!="symbol"?e+"":e,n),n);function Qs(t){return t.sort((e,n)=>{const r=e.compareDocumentPosition(n);if(r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY)return-1;if(r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS)return 1;if(r&Node.DOCUMENT_POSITION_DISCONNECTED||r&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC)throw Error("Cannot sort the given nodes.");return 0})}var ec=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function ea(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function ta(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var Io=typeof window<"u"?P.useLayoutEffect:P.useEffect,Ir=t=>t,tc=class{constructor(){De(this,"descendants",new Map),De(this,"register",t=>{if(t!=null)return ec(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),De(this,"unregister",t=>{this.descendants.delete(t);const e=Qs(Array.from(this.descendants.keys()));this.assignIndex(e)}),De(this,"destroy",()=>{this.descendants.clear()}),De(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),De(this,"count",()=>this.descendants.size),De(this,"enabledCount",()=>this.enabledValues().length),De(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),De(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),De(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),De(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),De(this,"first",()=>this.item(0)),De(this,"firstEnabled",()=>this.enabledItem(0)),De(this,"last",()=>this.item(this.descendants.size-1)),De(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),De(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),De(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),De(this,"next",(t,e=!0)=>{const n=ea(t,this.count(),e);return this.item(n)}),De(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=ea(r,this.enabledCount(),e);return this.enabledItem(o)}),De(this,"prev",(t,e=!0)=>{const n=ta(t,this.count()-1,e);return this.item(n)}),De(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=ta(r,this.enabledCount()-1,e);return this.enabledItem(o)}),De(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=Qs(n);e!=null&&e.disabled&&(e.disabled=!!e.disabled);const o={node:t,index:-1,...e};this.descendants.set(t,o),this.assignIndex(r)})}};function nc(){const t=P.useRef(new tc);return Io(()=>()=>t.current.destroy()),t.current}var[rc,Ka]=rt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function oc(t){const e=Ka(),[n,r]=P.useState(-1),o=P.useRef(null);Io(()=>()=>{o.current&&e.unregister(o.current)},[]),Io(()=>{if(!o.current)return;const i=Number(o.current.dataset.index);n!=i&&!Number.isNaN(i)&&r(i)});const s=Ir(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Me(s,o)}}function $a(){return[Ir(rc),()=>Ir(Ka()),()=>nc(),o=>oc(o)]}function Va(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,h)=>p!==h}=t,s=Lt(r),i=Lt(o),[a,l]=P.useState(n),c=e!==void 0,u=c?e:a,d=Lt(p=>{const v=typeof p=="function"?p(u):p;i(u,v)&&(c||l(v),s(v))},[c,s,u,i]);return[u,d]}var Oo=fe(function(e,n){const{htmlWidth:r,htmlHeight:o,alt:s,...i}=e;return k.jsx("img",{width:r,height:o,ref:n,alt:s,...i})});Oo.displayName="NativeImage";function sc(t){const{loading:e,src:n,srcSet:r,onLoad:o,onError:s,crossOrigin:i,sizes:a,ignoreFallback:l}=t,[c,u]=P.useState("pending");P.useEffect(()=>{u(n?"loading":"pending")},[n]);const d=P.useRef(),p=P.useCallback(()=>{if(!n)return;h();const v=new Image;v.src=n,i&&(v.crossOrigin=i),r&&(v.srcset=r),a&&(v.sizes=a),e&&(v.loading=e),v.onload=f=>{h(),u("loaded"),o==null||o(f)},v.onerror=f=>{h(),u("failed"),s==null||s(f)},d.current=v},[n,i,r,a,o,s,e]),h=()=>{d.current&&(d.current.onload=null,d.current.onerror=null,d.current=null)};return Na(()=>{if(!l)return c==="loading"&&p(),()=>{h()}},[c,p,l]),l?"loaded":c}var ac=(t,e)=>t!=="loaded"&&e==="beforeLoadOrError"||t==="failed"&&e==="onError";function ic(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}var Ha=fe(function(e,n){const{fallbackSrc:r,fallback:o,src:s,srcSet:i,align:a,fit:l,loading:c,ignoreFallback:u,crossOrigin:d,fallbackStrategy:p="beforeLoadOrError",referrerPolicy:h,...v}=e,f=r!==void 0||o!==void 0,m=c!=null||u||!f,y=sc({...e,crossOrigin:d,ignoreFallback:m}),g=ac(y,p),_={ref:n,objectFit:l,objectPosition:a,...m?v:ic(v,["onError","onLoad"])};return g?o||k.jsx(de.img,{as:Oo,className:"chakra-image__placeholder",src:r,..._}):k.jsx(de.img,{as:Oo,src:s,srcSet:i,crossOrigin:d,loading:c,referrerPolicy:h,className:"chakra-image",..._})});Ha.displayName="Image";function ks(t){return P.Children.toArray(t).filter(e=>P.isValidElement(e))}var lc={horizontal:{"> *:first-of-type:not(:last-of-type)":{borderEndRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderStartRadius:0}},vertical:{"> *:first-of-type:not(:last-of-type)":{borderBottomRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderTopRadius:0}}},cc={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},qa=fe(function(e,n){const{size:r,colorScheme:o,variant:s,className:i,spacing:a="0.5rem",isAttached:l,isDisabled:c,orientation:u="horizontal",...d}=e,p=_e("chakra-button__group",i),h=P.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:c}),[r,o,s,c]);let v={display:"inline-flex",...l?lc[u]:cc[u](a)};const f=u==="vertical";return k.jsx(Rl,{value:h,children:k.jsx(de.div,{ref:n,role:"group",__css:v,className:p,"data-attached":l?"":void 0,"data-orientation":u,flexDir:f?"column":void 0,...d})})});qa.displayName="ButtonGroup";var un=fe((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=P.isValidElement(a)?P.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return k.jsx(Te,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});un.displayName="IconButton";var[uc,Ga]=Tl("Card"),dc=fe(function(e,n){const{className:r,...o}=e,s=Ga();return k.jsx(de.div,{ref:n,className:_e("chakra-card__body",r),__css:s.body,...o})}),fc=fe(function(e,n){const{className:r,...o}=e,s=Ga();return k.jsx(de.div,{ref:n,className:_e("chakra-card__header",r),__css:s.header,...o})}),hc=fe(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=Ye(e),c=Rt("Card",e);return k.jsx(de.div,{ref:n,className:_e("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:i,alignItems:a,position:"relative",minWidth:0,wordWrap:"break-word",...c.container},...l,children:k.jsx(uc,{value:c,children:o})})}),[pc,Za]=rt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[mc,vn]=rt({strict:!1,name:"FormControlContext"});function yc(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=P.useId(),l=e||`field-${a}`,c=`${l}-label`,u=`${l}-feedback`,d=`${l}-helptext`,[p,h]=P.useState(!1),[v,f]=P.useState(!1),[m,y]=P.useState(!1),g=P.useCallback((E={},F=null)=>({id:d,...E,ref:Me(F,I=>{I&&f(!0)})}),[d]),_=P.useCallback((E={},F=null)=>({...E,ref:F,"data-focus":it(m),"data-disabled":it(o),"data-invalid":it(r),"data-readonly":it(s),id:E.id!==void 0?E.id:c,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,m,r,s,c]),x=P.useCallback((E={},F=null)=>({id:u,...E,ref:Me(F,I=>{I&&h(!0)}),"aria-live":"polite"}),[u]),C=P.useCallback((E={},F=null)=>({...E,...i,ref:F,role:"group","data-focus":it(m),"data-disabled":it(o),"data-invalid":it(r),"data-readonly":it(s)}),[i,o,m,r,s]),D=P.useCallback((E={},F=null)=>({...E,ref:F,role:"presentation","aria-hidden":!0,children:E.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!m,onFocus:()=>y(!0),onBlur:()=>y(!1),hasFeedbackText:p,setHasFeedbackText:h,hasHelpText:v,setHasHelpText:f,id:l,labelId:c,feedbackId:u,helpTextId:d,htmlProps:i,getHelpTextProps:g,getErrorMessageProps:x,getRootProps:C,getLabelProps:_,getRequiredIndicatorProps:D}}var Yr=fe(function(e,n){const r=Rt("Form",e),o=Ye(e),{getRootProps:s,htmlProps:i,...a}=yc(o),l=_e("chakra-form-control",e.className);return k.jsx(mc,{value:a,children:k.jsx(pc,{value:r,children:k.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});Yr.displayName="FormControl";var vc=fe(function(e,n){const r=vn(),o=Za(),s=_e("chakra-form__helper-text",e.className);return k.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});vc.displayName="FormHelperText";var[gc,wc]=rt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Xr=fe((t,e)=>{const n=Rt("FormError",t),r=Ye(t),o=vn();return o!=null&&o.isInvalid?k.jsx(gc,{value:n,children:k.jsx(de.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:_e("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Xr.displayName="FormErrorMessage";var bc=fe((t,e)=>{const n=wc(),r=vn();if(!(r!=null&&r.isInvalid))return null;const o=_e("chakra-form__error-icon",t.className);return k.jsx(Hr,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:k.jsx("path",{fill:"currentColor",d:"M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z"})})});bc.displayName="FormErrorIcon";var Qr=fe(function(e,n){var r;const o=Hn("FormLabel",e),s=Ye(e),{className:i,children:a,requiredIndicator:l=k.jsx(Ja,{}),optionalIndicator:c=null,...u}=s,d=vn(),p=(r=d==null?void 0:d.getLabelProps(u,n))!=null?r:{ref:n,...u};return k.jsxs(de.label,{...p,className:_e("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[a,d!=null&&d.isRequired?l:c]})});Qr.displayName="FormLabel";var Ja=fe(function(e,n){const r=vn(),o=Za();if(!(r!=null&&r.isRequired))return null;const s=_e("chakra-form__required-indicator",e.className);return k.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});Ja.displayName="RequiredIndicator";function _c(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=xc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":lo(n),"aria-required":lo(o),"aria-readonly":lo(r)}}function xc(t){var e,n,r;const o=vn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:c,isInvalid:u,isReadOnly:d,isDisabled:p,onFocus:h,onBlur:v,...f}=t,m=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&m.push(o.feedbackId),o!=null&&o.hasHelpText&&m.push(o.helpTextId),{...f,"aria-describedby":m.join(" ")||void 0,id:s??(o==null?void 0:o.id),isDisabled:(e=i??p)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=a??d)!=null?n:o==null?void 0:o.isReadOnly,isRequired:(r=l??c)!=null?r:o==null?void 0:o.isRequired,isInvalid:u??(o==null?void 0:o.isInvalid),onFocus:Oe(o==null?void 0:o.onFocus,h),onBlur:Oe(o==null?void 0:o.onBlur,v)}}function on(t,e,n,r){const o=Lt(n);return P.useEffect(()=>{const s=typeof t=="function"?t():t??document;if(!(!n||!s))return s.addEventListener(e,o,r),()=>{s.removeEventListener(e,o,r)}},[e,t,r,o,n]),()=>{const s=typeof t=="function"?t():t??document;s==null||s.removeEventListener(e,o,r)}}function kc(t){return"current"in t}var Ya=()=>typeof window<"u";function Ec(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var Cc=t=>Ya()&&t.test(navigator.vendor),Sc=t=>Ya()&&t.test(Ec()),Ic=()=>Sc(/mac|iphone|ipad|ipod/i),Oc=()=>Ic()&&Cc(/apple/i);function Dc(t){const{ref:e,elements:n,enabled:r}=t,o=()=>{var s,i;return(i=(s=e.current)==null?void 0:s.ownerDocument)!=null?i:document};on(o,"pointerdown",s=>{if(!Oc()||!r)return;const i=s.target,l=(n??[e]).some(c=>{const u=kc(c)?c.current:c;return(u==null?void 0:u.contains(i))||u===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var Xa={exports:{}},jc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Pc=jc,Ac=Pc;function Qa(){}function ei(){}ei.resetWarningCache=Qa;var Nc=function(){function t(r,o,s,i,a,l){if(l!==Ac){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:ei,resetWarningCache:Qa};return n.PropTypes=n,n};Xa.exports=Nc();var Fc=Xa.exports;const Mt=Fa(Fc);function Rc(t){const e=t.ownerDocument.defaultView||window,{overflow:n,overflowX:r,overflowY:o}=e.getComputedStyle(t);return/auto|scroll|overlay|hidden/.test(n+o+r)}function Tc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function ti(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:Ml(t)&&Rc(t)?t:ti(Tc(t))}var Mc=Jl?P.useLayoutEffect:P.useEffect;function Do(t,e=[]){const n=P.useRef(t);return Mc(()=>{n.current=t}),P.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function Bc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Do(n),i=P.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;P.useEffect(()=>{if(!r)return;const a=d=>{co(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&co(d,e)&&(i.isPointerDown=!1,o(d))},c=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&co(d,e)&&(i.isPointerDown=!1,o(d))},u=Wa(e.current);return u.addEventListener("mousedown",a,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",a,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",a,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",a,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,i,r])}function co(t,e){var n;const r=t.target;return r&&!Wa(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function zc(t,e){const n=P.useId();return P.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function Lc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function Wc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Do(n),i=Do(e),[a,l]=P.useState(t.defaultIsOpen||!1),[c,u]=Lc(r,a),d=zc(o,"disclosure"),p=P.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),h=P.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),v=P.useCallback(()=>{(u?p:h)()},[u,h,p]);return{isOpen:!!u,onOpen:h,onClose:p,onToggle:v,isControlled:c,getButtonProps:(f={})=>({...f,"aria-expanded":u,"aria-controls":d,onClick:Bl(f.onClick,v)}),getDisclosureProps:(f={})=>({...f,hidden:!u,id:d})}}var gn=fe(function(e,n){const{htmlSize:r,...o}=e,s=Rt("Input",o),i=Ye(o),a=_c(i),l=_e("chakra-input",e.className);return k.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});gn.displayName="Input";gn.id="Input";function Uc(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):zl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}var wt=fe(function(e,n){const r=Hn("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=Ye(e),c=Yl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return k.jsx(de.p,{ref:n,className:_e("chakra-text",e.className),...c,...l,__css:r})});wt.displayName="Text";var jo=t=>k.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});jo.displayName="StackDivider";var ni=t=>k.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});ni.displayName="StackItem";function Kc(t){const{spacing:e,direction:n}=t,r={column:{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},"column-reverse":{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},row:{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0},"row-reverse":{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0}};return{"&":Uc(n,o=>r[o])}}var Ke=fe((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:i="0.5rem",wrap:a,children:l,divider:c,className:u,shouldWrapChildren:d,...p}=t,h=n?"row":r??"column",v=P.useMemo(()=>Kc({spacing:i,direction:h}),[i,h]),f=!!c,m=!d&&!f,y=P.useMemo(()=>{const _=ks(l);return m?_:_.map((x,C)=>{const D=typeof x.key<"u"?x.key:C,E=C+1===_.length,I=d?k.jsx(ni,{children:x},D):x;if(!f)return I;const R=P.cloneElement(c,{__css:v}),K=E?null:R;return k.jsxs(P.Fragment,{children:[I,K]},D)})},[c,v,f,m,d,l]),g=_e("chakra-stack",u);return k.jsx(de.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:h,flexWrap:a,gap:f?void 0:i,className:g,...p,children:y})});Ke.displayName="Stack";var ot=fe((t,e)=>k.jsx(Ke,{align:"center",...t,direction:"row",ref:e}));ot.displayName="HStack";var sn=fe(function(e,n){const r=Hn("Heading",e),{className:o,...s}=Ye(e);return k.jsx(de.h2,{ref:n,className:_e("chakra-heading",e.className),...s,__css:r})});sn.displayName="Heading";var jt=de("div");jt.displayName="Box";var ri=fe(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return k.jsx(jt,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});ri.displayName="Square";var $c=fe(function(e,n){const{size:r,...o}=e;return k.jsx(ri,{size:r,ref:n,borderRadius:"9999px",...o})});$c.displayName="Circle";var oi=fe(function(e,n){const r=Hn("Badge",e),{className:o,...s}=Ye(e);return k.jsx(de.span,{ref:n,className:_e("chakra-badge",e.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});oi.displayName="Badge";var Wt=fe(function(e,n){const{direction:r,align:o,justify:s,wrap:i,basis:a,grow:l,shrink:c,...u}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:i,flexBasis:a,flexGrow:l,flexShrink:c};return k.jsx(de.div,{ref:n,__css:d,...u})});Wt.displayName="Flex";function Vc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Hc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=P.useState([]),s=P.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};P.useEffect(()=>i,[]);function l(c){return u=>{if(u.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Vc(u)){const d=r.concat(u.key);n(u)&&(u.preventDefault(),u.stopPropagation()),o(d),c(d.join("")),a()}}}return l}function qc(t,e,n,r){if(e==null)return r;if(!r)return t.find(i=>n(i).toLowerCase().startsWith(e.toLowerCase()));const o=t.filter(s=>n(s).toLowerCase().startsWith(e.toLowerCase()));if(o.length>0){let s;return o.includes(r)?(s=o.indexOf(r)+1,s===o.length&&(s=0),o[s]):(s=t.indexOf(o[0]),t[s])}return r}function Gc(){const t=P.useRef(new Map),e=t.current,n=P.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=P.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return P.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function uo(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function si(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:i,onMouseUp:a,onClick:l,onKeyDown:c,onKeyUp:u,tabIndex:d,onMouseOver:p,onMouseLeave:h,...v}=t,[f,m]=P.useState(!0),[y,g]=P.useState(!1),_=Gc(),x=A=>{A&&A.tagName!=="BUTTON"&&m(!1)},C=f?d:d||0,D=n&&!r,E=P.useCallback(A=>{if(n){A.stopPropagation(),A.preventDefault();return}A.currentTarget.focus(),l==null||l(A)},[n,l]),F=P.useCallback(A=>{y&&uo(A)&&(A.preventDefault(),A.stopPropagation(),g(!1),_.remove(document,"keyup",F,!1))},[y,_]),I=P.useCallback(A=>{if(c==null||c(A),n||A.defaultPrevented||A.metaKey||!uo(A.nativeEvent)||f)return;const X=o&&A.key==="Enter";s&&A.key===" "&&(A.preventDefault(),g(!0)),X&&(A.preventDefault(),A.currentTarget.click()),_.add(document,"keyup",F,!1)},[n,f,c,o,s,_,F]),R=P.useCallback(A=>{if(u==null||u(A),n||A.defaultPrevented||A.metaKey||!uo(A.nativeEvent)||f)return;s&&A.key===" "&&(A.preventDefault(),g(!1),A.currentTarget.click())},[s,f,n,u]),K=P.useCallback(A=>{A.button===0&&(g(!1),_.remove(document,"mouseup",K,!1))},[_]),j=P.useCallback(A=>{if(A.button!==0)return;if(n){A.stopPropagation(),A.preventDefault();return}f||g(!0),A.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",K,!1),i==null||i(A)},[n,f,i,_,K]),M=P.useCallback(A=>{A.button===0&&(f||g(!1),a==null||a(A))},[a,f]),b=P.useCallback(A=>{if(n){A.preventDefault();return}p==null||p(A)},[n,p]),N=P.useCallback(A=>{y&&(A.preventDefault(),g(!1)),h==null||h(A)},[y,h]),H=Me(e,x);return f?{...v,ref:H,type:"button","aria-disabled":D?void 0:n,disabled:D,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:u,onKeyDown:c,onMouseOver:p,onMouseLeave:h}:{...v,ref:H,role:"button","data-active":it(y),"aria-disabled":n?"true":void 0,tabIndex:D?void 0:C,onClick:E,onMouseDown:j,onMouseUp:M,onKeyUp:R,onKeyDown:I,onMouseOver:b,onMouseLeave:N}}function Zc(t){const e=t.current;if(!e)return!1;const n=Wl(e);return!n||e.contains(n)?!1:!!Ul(n)}function ai(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;qr(()=>{if(!s||Zc(t))return;const i=(o==null?void 0:o.current)||t.current;let a;if(i)return a=requestAnimationFrame(()=>{i.focus({preventScroll:!0})}),()=>{cancelAnimationFrame(a)}},[s,t,o])}var Jc={preventScroll:!0,shouldFocus:!1};function Yc(t,e=Jc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=Xc(t)?t.current:t,a=o&&s,l=P.useRef(a),c=P.useRef(s);Na(()=>{!c.current&&s&&(l.current=a),c.current=s},[s,a]);const u=P.useCallback(()=>{if(!(!s||!i||!l.current)&&(l.current=!1,!i.contains(document.activeElement)))if(n!=null&&n.current)requestAnimationFrame(()=>{var d;(d=n.current)==null||d.focus({preventScroll:r})});else{const d=Ll(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);qr(()=>{u()},[u]),on(i,"transitionend",u)}function Xc(t){return"current"in t}var Qt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),Ae={arrowShadowColor:Qt("--popper-arrow-shadow-color"),arrowSize:Qt("--popper-arrow-size","8px"),arrowSizeHalf:Qt("--popper-arrow-size-half"),arrowBg:Qt("--popper-arrow-bg"),transformOrigin:Qt("--popper-transform-origin"),arrowOffset:Qt("--popper-arrow-offset")};function Qc(t){if(t.includes("top"))return"1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("bottom"))return"-1px -1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("right"))return"-1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("left"))return"1px -1px 0px 0 var(--popper-arrow-shadow-color)"}var eu={top:"bottom center","top-start":"bottom left","top-end":"bottom right",bottom:"top center","bottom-start":"top left","bottom-end":"top right",left:"right center","left-start":"right top","left-end":"right bottom",right:"left center","right-start":"left top","right-end":"left bottom"},tu=t=>eu[t],na={scroll:!0,resize:!0};function nu(t){let e;return typeof t=="object"?e={enabled:!0,options:{...na,...t}}:e={enabled:t,options:na},e}var ru={name:"matchWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>()=>{const e=t.elements.reference;t.elements.popper.style.width=`${e.offsetWidth}px`}},ou={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{ra(t)},effect:({state:t})=>()=>{ra(t)}},ra=t=>{t.elements.popper.style.setProperty(Ae.transformOrigin.var,tu(t.placement))},su={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{au(t)}},au=t=>{var e;if(!t.placement)return;const n=iu(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:Ae.arrowSize.varRef,height:Ae.arrowSize.varRef,zIndex:-1});const r={[Ae.arrowSizeHalf.var]:`calc(${Ae.arrowSize.varRef} / 2 - 1px)`,[Ae.arrowOffset.var]:`calc(${Ae.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},iu=t=>{if(t.startsWith("top"))return{property:"bottom",value:Ae.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:Ae.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:Ae.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:Ae.arrowOffset.varRef}},lu={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{oa(t)},effect:({state:t})=>()=>{oa(t)}},oa=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Qc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:Ae.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},cu={"start-start":{ltr:"left-start",rtl:"right-start"},"start-end":{ltr:"left-end",rtl:"right-end"},"end-start":{ltr:"right-start",rtl:"left-start"},"end-end":{ltr:"right-end",rtl:"left-end"},start:{ltr:"left",rtl:"right"},end:{ltr:"right",rtl:"left"}},uu={"auto-start":"auto-end","auto-end":"auto-start","top-start":"top-end","top-end":"top-start","bottom-start":"bottom-end","bottom-end":"bottom-start"};function du(t,e="ltr"){var n,r;const o=((n=cu[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=uu[t])!=null?r:o}var $e="top",tt="bottom",nt="right",Ve="left",Es="auto",qn=[$e,tt,nt,Ve],dn="start",Mn="end",fu="clippingParents",ii="viewport",Cn="popper",hu="reference",sa=qn.reduce(function(t,e){return t.concat([e+"-"+dn,e+"-"+Mn])},[]),li=[].concat(qn,[Es]).reduce(function(t,e){return t.concat([e,e+"-"+dn,e+"-"+Mn])},[]),pu="beforeRead",mu="read",yu="afterRead",vu="beforeMain",gu="main",wu="afterMain",bu="beforeWrite",_u="write",xu="afterWrite",ku=[pu,mu,yu,vu,gu,wu,bu,_u,xu];function dt(t){return t?(t.nodeName||"").toLowerCase():null}function Ze(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function qt(t){var e=Ze(t).Element;return t instanceof e||t instanceof Element}function et(t){var e=Ze(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Cs(t){if(typeof ShadowRoot>"u")return!1;var e=Ze(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Eu(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},s=e.elements[n];!et(s)||!dt(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function Cu(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var o=e.elements[r],s=e.attributes[r]||{},i=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=i.reduce(function(l,c){return l[c]="",l},{});!et(o)||!dt(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Su={name:"applyStyles",enabled:!0,phase:"write",fn:Eu,effect:Cu,requires:["computeStyles"]};function ut(t){return t.split("-")[0]}var Ut=Math.max,Or=Math.min,fn=Math.round;function Po(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function ci(){return!/^((?!chrome|android).)*safari/i.test(Po())}function hn(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&et(t)&&(o=t.offsetWidth>0&&fn(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&fn(r.height)/t.offsetHeight||1);var i=qt(t)?Ze(t):window,a=i.visualViewport,l=!ci()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/o,u=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,p=r.height/s;return{width:d,height:p,top:u,right:c+d,bottom:u+p,left:c,x:c,y:u}}function Ss(t){var e=hn(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function ui(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Cs(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function kt(t){return Ze(t).getComputedStyle(t)}function Iu(t){return["table","td","th"].indexOf(dt(t))>=0}function Tt(t){return((qt(t)?t.ownerDocument:t.document)||window.document).documentElement}function eo(t){return dt(t)==="html"?t:t.assignedSlot||t.parentNode||(Cs(t)?t.host:null)||Tt(t)}function aa(t){return!et(t)||kt(t).position==="fixed"?null:t.offsetParent}function Ou(t){var e=/firefox/i.test(Po()),n=/Trident/i.test(Po());if(n&&et(t)){var r=kt(t);if(r.position==="fixed")return null}var o=eo(t);for(Cs(o)&&(o=o.host);et(o)&&["html","body"].indexOf(dt(o))<0;){var s=kt(o);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return o;o=o.parentNode}return null}function Gn(t){for(var e=Ze(t),n=aa(t);n&&Iu(n)&&kt(n).position==="static";)n=aa(n);return n&&(dt(n)==="html"||dt(n)==="body"&&kt(n).position==="static")?e:n||Ou(t)||e}function Is(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function jn(t,e,n){return Ut(t,Or(e,n))}function Du(t,e,n){var r=jn(t,e,n);return r>n?n:r}function di(){return{top:0,right:0,bottom:0,left:0}}function fi(t){return Object.assign({},di(),t)}function hi(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var ju=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,fi(typeof e!="number"?e:hi(e,qn))};function Pu(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=ut(n.placement),l=Is(a),c=[Ve,nt].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!i)){var d=ju(o.padding,n),p=Ss(s),h=l==="y"?$e:Ve,v=l==="y"?tt:nt,f=n.rects.reference[u]+n.rects.reference[l]-i[l]-n.rects.popper[u],m=i[l]-n.rects.reference[l],y=Gn(s),g=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,_=f/2-m/2,x=d[h],C=g-p[u]-d[v],D=g/2-p[u]/2+_,E=jn(x,D,C),F=l;n.modifiersData[r]=(e={},e[F]=E,e.centerOffset=E-D,e)}}function Au(t){var e=t.state,n=t.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=e.elements.popper.querySelector(o),!o)||ui(e.elements.popper,o)&&(e.elements.arrow=o))}const Nu={name:"arrow",enabled:!0,phase:"main",fn:Pu,effect:Au,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function pn(t){return t.split("-")[1]}var Fu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ru(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:fn(n*o)/o||0,y:fn(r*o)/o||0}}function ia(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,p=i.x,h=p===void 0?0:p,v=i.y,f=v===void 0?0:v,m=typeof u=="function"?u({x:h,y:f}):{x:h,y:f};h=m.x,f=m.y;var y=i.hasOwnProperty("x"),g=i.hasOwnProperty("y"),_=Ve,x=$e,C=window;if(c){var D=Gn(n),E="clientHeight",F="clientWidth";if(D===Ze(n)&&(D=Tt(n),kt(D).position!=="static"&&a==="absolute"&&(E="scrollHeight",F="scrollWidth")),D=D,o===$e||(o===Ve||o===nt)&&s===Mn){x=tt;var I=d&&D===C&&C.visualViewport?C.visualViewport.height:D[E];f-=I-r.height,f*=l?1:-1}if(o===Ve||(o===$e||o===tt)&&s===Mn){_=nt;var R=d&&D===C&&C.visualViewport?C.visualViewport.width:D[F];h-=R-r.width,h*=l?1:-1}}var K=Object.assign({position:a},c&&Fu),j=u===!0?Ru({x:h,y:f},Ze(n)):{x:h,y:f};if(h=j.x,f=j.y,l){var M;return Object.assign({},K,(M={},M[x]=g?"0":"",M[_]=y?"0":"",M.transform=(C.devicePixelRatio||1)<=1?"translate("+h+"px, "+f+"px)":"translate3d("+h+"px, "+f+"px, 0)",M))}return Object.assign({},K,(e={},e[x]=g?f+"px":"",e[_]=y?h+"px":"",e.transform="",e))}function Tu(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,c={placement:ut(e.placement),variation:pn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,ia(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,ia(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Mu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Tu,data:{}};var nr={passive:!0};function Bu(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,s=o===void 0?!0:o,i=r.resize,a=i===void 0?!0:i,l=Ze(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,nr)}),a&&l.addEventListener("resize",n.update,nr),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,nr)}),a&&l.removeEventListener("resize",n.update,nr)}}const zu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Bu,data:{}};var Lu={left:"right",right:"left",bottom:"top",top:"bottom"};function hr(t){return t.replace(/left|right|bottom|top/g,function(e){return Lu[e]})}var Wu={start:"end",end:"start"};function la(t){return t.replace(/start|end/g,function(e){return Wu[e]})}function Os(t){var e=Ze(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Ds(t){return hn(Tt(t)).left+Os(t).scrollLeft}function Uu(t,e){var n=Ze(t),r=Tt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var c=ci();(c||!c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+Ds(t),y:l}}function Ku(t){var e,n=Tt(t),r=Os(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Ut(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Ut(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+Ds(t),l=-r.scrollTop;return kt(o||n).direction==="rtl"&&(a+=Ut(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function js(t){var e=kt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function pi(t){return["html","body","#document"].indexOf(dt(t))>=0?t.ownerDocument.body:et(t)&&js(t)?t:pi(eo(t))}function Pn(t,e){var n;e===void 0&&(e=[]);var r=pi(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ze(r),i=o?[s].concat(s.visualViewport||[],js(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Pn(eo(i)))}function Ao(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function $u(t,e){var n=hn(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function ca(t,e,n){return e===ii?Ao(Uu(t,n)):qt(e)?$u(e,n):Ao(Ku(Tt(t)))}function Vu(t){var e=Pn(eo(t)),n=["absolute","fixed"].indexOf(kt(t).position)>=0,r=n&&et(t)?Gn(t):t;return qt(r)?e.filter(function(o){return qt(o)&&ui(o,r)&&dt(o)!=="body"}):[]}function Hu(t,e,n,r){var o=e==="clippingParents"?Vu(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,c){var u=ca(t,c,r);return l.top=Ut(u.top,l.top),l.right=Or(u.right,l.right),l.bottom=Or(u.bottom,l.bottom),l.left=Ut(u.left,l.left),l},ca(t,i,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function mi(t){var e=t.reference,n=t.element,r=t.placement,o=r?ut(r):null,s=r?pn(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case $e:l={x:i,y:e.y-n.height};break;case tt:l={x:i,y:e.y+e.height};break;case nt:l={x:e.x+e.width,y:a};break;case Ve:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var c=o?Is(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case dn:l[c]=l[c]-(e[u]/2-n[u]/2);break;case Mn:l[c]=l[c]+(e[u]/2-n[u]/2);break}}return l}function Bn(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,s=n.strategy,i=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?fu:a,c=n.rootBoundary,u=c===void 0?ii:c,d=n.elementContext,p=d===void 0?Cn:d,h=n.altBoundary,v=h===void 0?!1:h,f=n.padding,m=f===void 0?0:f,y=fi(typeof m!="number"?m:hi(m,qn)),g=p===Cn?hu:Cn,_=t.rects.popper,x=t.elements[v?g:p],C=Hu(qt(x)?x:x.contextElement||Tt(t.elements.popper),l,u,i),D=hn(t.elements.reference),E=mi({reference:D,element:_,strategy:"absolute",placement:o}),F=Ao(Object.assign({},_,E)),I=p===Cn?F:D,R={top:C.top-I.top+y.top,bottom:I.bottom-C.bottom+y.bottom,left:C.left-I.left+y.left,right:I.right-C.right+y.right},K=t.modifiersData.offset;if(p===Cn&&K){var j=K[o];Object.keys(R).forEach(function(M){var b=[nt,tt].indexOf(M)>=0?1:-1,N=[$e,tt].indexOf(M)>=0?"y":"x";R[M]+=j[N]*b})}return R}function qu(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=l===void 0?li:l,u=pn(r),d=u?a?sa:sa.filter(function(v){return pn(v)===u}):qn,p=d.filter(function(v){return c.indexOf(v)>=0});p.length===0&&(p=d);var h=p.reduce(function(v,f){return v[f]=Bn(t,{placement:f,boundary:o,rootBoundary:s,padding:i})[ut(f)],v},{});return Object.keys(h).sort(function(v,f){return h[v]-h[f]})}function Gu(t){if(ut(t)===Es)return[];var e=hr(t);return[la(t),e,la(e)]}function Zu(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,p=n.altBoundary,h=n.flipVariations,v=h===void 0?!0:h,f=n.allowedAutoPlacements,m=e.options.placement,y=ut(m),g=y===m,_=l||(g||!v?[hr(m)]:Gu(m)),x=[m].concat(_).reduce(function(Y,Z){return Y.concat(ut(Z)===Es?qu(e,{placement:Z,boundary:u,rootBoundary:d,padding:c,flipVariations:v,allowedAutoPlacements:f}):Z)},[]),C=e.rects.reference,D=e.rects.popper,E=new Map,F=!0,I=x[0],R=0;R=0,N=b?"width":"height",H=Bn(e,{placement:K,boundary:u,rootBoundary:d,altBoundary:p,padding:c}),A=b?M?nt:Ve:M?tt:$e;C[N]>D[N]&&(A=hr(A));var X=hr(A),V=[];if(s&&V.push(H[j]<=0),a&&V.push(H[A]<=0,H[X]<=0),V.every(function(Y){return Y})){I=K,F=!1;break}E.set(K,V)}if(F)for(var te=v?3:1,z=function(Z){var he=x.find(function(ye){var le=E.get(ye);if(le)return le.slice(0,Z).every(function(ue){return ue})});if(he)return I=he,"break"},B=te;B>0;B--){var ne=z(B);if(ne==="break")break}e.placement!==I&&(e.modifiersData[r]._skip=!0,e.placement=I,e.reset=!0)}}const Ju={name:"flip",enabled:!0,phase:"main",fn:Zu,requiresIfExists:["offset"],data:{_skip:!1}};function ua(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function da(t){return[$e,nt,tt,Ve].some(function(e){return t[e]>=0})}function Yu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Bn(e,{elementContext:"reference"}),a=Bn(e,{altBoundary:!0}),l=ua(i,r),c=ua(a,o,s),u=da(l),d=da(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const Xu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Yu};function Qu(t,e,n){var r=ut(t),o=[Ve,$e].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,i=s[0],a=s[1];return i=i||0,a=(a||0)*o,[Ve,nt].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function ed(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=li.reduce(function(u,d){return u[d]=Qu(d,e.rects,s),u},{}),a=i[e.placement],l=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=i}const td={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:ed};function nd(t){var e=t.state,n=t.name;e.modifiersData[n]=mi({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const rd={name:"popperOffsets",enabled:!0,phase:"read",fn:nd,data:{}};function od(t){return t==="x"?"y":"x"}function sd(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,p=n.tether,h=p===void 0?!0:p,v=n.tetherOffset,f=v===void 0?0:v,m=Bn(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),y=ut(e.placement),g=pn(e.placement),_=!g,x=Is(y),C=od(x),D=e.modifiersData.popperOffsets,E=e.rects.reference,F=e.rects.popper,I=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,R=typeof I=="number"?{mainAxis:I,altAxis:I}:Object.assign({mainAxis:0,altAxis:0},I),K=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,j={x:0,y:0};if(D){if(s){var M,b=x==="y"?$e:Ve,N=x==="y"?tt:nt,H=x==="y"?"height":"width",A=D[x],X=A+m[b],V=A-m[N],te=h?-F[H]/2:0,z=g===dn?E[H]:F[H],B=g===dn?-F[H]:-E[H],ne=e.elements.arrow,Y=h&&ne?Ss(ne):{width:0,height:0},Z=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:di(),he=Z[b],ye=Z[N],le=jn(0,E[H],Y[H]),ue=_?E[H]/2-te-le-he-R.mainAxis:z-le-he-R.mainAxis,ke=_?-E[H]/2+te+le+ye+R.mainAxis:B+le+ye+R.mainAxis,ve=e.elements.arrow&&Gn(e.elements.arrow),me=ve?x==="y"?ve.clientTop||0:ve.clientLeft||0:0,Ee=(M=K==null?void 0:K[x])!=null?M:0,w=A+ue-Ee-me,U=A+ke-Ee,W=jn(h?Or(X,w):X,A,h?Ut(V,U):V);D[x]=W,j[x]=W-A}if(a){var O,S=x==="x"?$e:Ve,T=x==="x"?tt:nt,q=D[C],J=C==="y"?"height":"width",L=q+m[S],Q=q-m[T],re=[$e,Ve].indexOf(y)!==-1,ee=(O=K==null?void 0:K[C])!=null?O:0,se=re?L:q-E[J]-F[J]-ee+R.altAxis,ge=re?q+E[J]+F[J]-ee-R.altAxis:Q,pe=h&&re?Du(se,q,ge):jn(h?se:L,q,h?ge:Q);D[C]=pe,j[C]=pe-q}e.modifiersData[r]=j}}const ad={name:"preventOverflow",enabled:!0,phase:"main",fn:sd,requiresIfExists:["offset"]};function id(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function ld(t){return t===Ze(t)||!et(t)?Os(t):id(t)}function cd(t){var e=t.getBoundingClientRect(),n=fn(e.width)/t.offsetWidth||1,r=fn(e.height)/t.offsetHeight||1;return n!==1||r!==1}function ud(t,e,n){n===void 0&&(n=!1);var r=et(e),o=et(e)&&cd(e),s=Tt(e),i=hn(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((dt(e)!=="body"||js(s))&&(a=ld(e)),et(e)?(l=hn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Ds(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function dd(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function o(s){n.add(s.name);var i=[].concat(s.requires||[],s.requiresIfExists||[]);i.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&o(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||o(s)}),r}function fd(t){var e=dd(t);return ku.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function hd(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function pd(t){var e=t.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var fa={placement:"bottom",modifiers:[],strategy:"absolute"};function ha(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=P.useCallback(()=>{var R;!e||!v.current||!f.current||((R=g.current)==null||R.call(g),m.current=vd(v.current,f.current,{placement:y,modifiers:[lu,su,ou,{...ru,enabled:!!p},{name:"eventListeners",...nu(i)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:a??[0,l]}},{name:"flip",enabled:!!c,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:u}},...n??[]],strategy:o}),m.current.forceUpdate(),g.current=m.current.destroy)},[y,e,n,p,i,s,a,l,c,d,u,o]);P.useEffect(()=>()=>{var R;!v.current&&!f.current&&((R=m.current)==null||R.destroy(),m.current=null)},[]);const x=P.useCallback(R=>{v.current=R,_()},[_]),C=P.useCallback((R={},K=null)=>({...R,ref:Me(x,K)}),[x]),D=P.useCallback(R=>{f.current=R,_()},[_]),E=P.useCallback((R={},K=null)=>({...R,ref:Me(D,K),style:{...R.style,position:o,minWidth:p?void 0:"max-content",inset:"0 auto auto 0"}}),[o,D,p]),F=P.useCallback((R={},K=null)=>{const{size:j,shadowColor:M,bg:b,style:N,...H}=R;return{...H,ref:K,"data-popper-arrow":"",style:gd(R)}},[]),I=P.useCallback((R={},K=null)=>({...R,ref:K,"data-popper-arrow-inner":""}),[]);return{update(){var R;(R=m.current)==null||R.update()},forceUpdate(){var R;(R=m.current)==null||R.forceUpdate()},transformOrigin:Ae.transformOrigin.varRef,referenceRef:x,popperRef:D,getPopperProps:E,getArrowProps:F,getArrowInnerProps:I,getReferenceProps:C}}function gd(t){const{size:e,shadowColor:n,bg:r,style:o}=t,s={...o,position:"absolute"};return e&&(s["--popper-arrow-size"]=e),n&&(s["--popper-arrow-shadow-color"]=n),r&&(s["--popper-arrow-bg"]=r),s}function As(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Lt(n),i=Lt(e),[a,l]=P.useState(t.defaultIsOpen||!1),c=r!==void 0?r:a,u=r!==void 0,d=P.useId(),p=o??`disclosure-${d}`,h=P.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),v=P.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),f=P.useCallback(()=>{c?h():v()},[c,v,h]);function m(g={}){return{...g,"aria-expanded":c,"aria-controls":p,onClick(_){var x;(x=g.onClick)==null||x.call(g,_),f()}}}function y(g={}){return{...g,hidden:!c,id:p}}return{isOpen:c,onOpen:v,onClose:h,onToggle:f,isControlled:u,getButtonProps:m,getDisclosureProps:y}}function wd(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Lt(n),i=P.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;P.useEffect(()=>{if(!r)return;const a=d=>{fo(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&fo(d,e)&&(i.isPointerDown=!1,o(d))},c=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&fo(d,e)&&(i.isPointerDown=!1,o(d))},u=yi(e.current);return u.addEventListener("mousedown",a,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",a,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",a,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",a,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,i,r])}function fo(t,e){var n;const r=t.target;return r&&!yi(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function yi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function vi(t){const{isOpen:e,ref:n}=t,[r,o]=P.useState(e),[s,i]=P.useState(!1);return P.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),on(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const c=Kl(n.current),u=new c.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(u)}}}function Ns(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[bd,_d,xd,kd]=$a(),[Ed,Zn]=rt({strict:!1,name:"MenuContext"});function Cd(t,...e){const n=P.useId(),r=t||n;return P.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function gi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function pa(t){return gi(t).activeElement===t}function Sd(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:i,isOpen:a,defaultIsOpen:l,onClose:c,onOpen:u,placement:d="bottom-start",lazyBehavior:p="unmount",direction:h,computePositionOnMount:v=!1,...f}=t,m=P.useRef(null),y=P.useRef(null),g=xd(),_=P.useCallback(()=>{requestAnimationFrame(()=>{var ne;(ne=m.current)==null||ne.focus({preventScroll:!1})})},[]),x=P.useCallback(()=>{const ne=setTimeout(()=>{var Y;if(o)(Y=o.current)==null||Y.focus();else{const Z=g.firstEnabled();Z&&M(Z.index)}});X.current.add(ne)},[g,o]),C=P.useCallback(()=>{const ne=setTimeout(()=>{const Y=g.lastEnabled();Y&&M(Y.index)});X.current.add(ne)},[g]),D=P.useCallback(()=>{u==null||u(),s?x():_()},[s,x,_,u]),{isOpen:E,onOpen:F,onClose:I,onToggle:R}=As({isOpen:a,defaultIsOpen:l,onClose:c,onOpen:D});wd({enabled:E&&r,ref:m,handler:ne=>{var Y;(Y=y.current)!=null&&Y.contains(ne.target)||I()}});const K=Ps({...f,enabled:E||v,placement:d,direction:h}),[j,M]=P.useState(-1);qr(()=>{E||M(-1)},[E]),ai(m,{focusRef:y,visible:E,shouldFocus:!0});const b=vi({isOpen:E,ref:m}),[N,H]=Cd(e,"menu-button","menu-list"),A=P.useCallback(()=>{F(),_()},[F,_]),X=P.useRef(new Set([]));P.useEffect(()=>{const ne=X.current;return()=>{ne.forEach(Y=>clearTimeout(Y)),ne.clear()}},[]);const V=P.useCallback(()=>{F(),x()},[x,F]),te=P.useCallback(()=>{F(),C()},[F,C]),z=P.useCallback(()=>{var ne,Y;const Z=gi(m.current),he=(ne=m.current)==null?void 0:ne.contains(Z.activeElement);if(!(E&&!he))return;const le=(Y=g.item(j))==null?void 0:Y.node;le==null||le.focus({preventScroll:!0})},[E,j,g]),B=P.useRef(null);return{openAndFocusMenu:A,openAndFocusFirstItem:V,openAndFocusLastItem:te,onTransitionEnd:z,unstable__animationState:b,descendants:g,popper:K,buttonId:N,menuId:H,forceUpdate:K.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:F,onClose:I,menuRef:m,buttonRef:y,focusedIndex:j,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:M,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:B}}function Zp(t={},e=null){const n=Zn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=P.useCallback(l=>{const c=l.key,d={Enter:s,ArrowDown:s,ArrowUp:i}[c];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,i]);return{...t,ref:Me(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":it(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Oe(t.onClick,r),onKeyDown:Oe(t.onKeyDown,a)}}function No(t){var e;return Dd(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function Id(t={},e=null){const n=Zn();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:s,isOpen:i,onClose:a,menuId:l,isLazy:c,lazyBehavior:u,unstable__animationState:d}=n,p=_d(),h=Hc({preventDefault:y=>y.key!==" "&&No(y.target)}),v=P.useCallback(y=>{if(!y.currentTarget.contains(y.target))return;const g=y.key,x={Tab:D=>D.preventDefault(),Escape:a,ArrowDown:()=>{const D=p.nextEnabled(r);D&&o(D.index)},ArrowUp:()=>{const D=p.prevEnabled(r);D&&o(D.index)}}[g];if(x){y.preventDefault(),x(y);return}const C=h(D=>{const E=qc(p.values(),D,F=>{var I,R;return(R=(I=F==null?void 0:F.node)==null?void 0:I.textContent)!=null?R:""},p.item(r));if(E){const F=p.indexOf(E.node);o(F)}});No(y.target)&&C(y)},[p,r,h,a,o]),f=P.useRef(!1);i&&(f.current=!0);const m=Ns({wasSelected:f.current,enabled:c,mode:u,isSelected:d.present});return{...t,ref:Me(s,e),children:m?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:Oe(t.onKeyDown,v)}}function Od(t={}){const{popper:e,isOpen:n}=Zn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function wi(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:i,isDisabled:a,isFocusable:l,closeOnSelect:c,type:u,...d}=t,p=Zn(),{setFocusedIndex:h,focusedIndex:v,closeOnSelect:f,onClose:m,menuRef:y,isOpen:g,menuId:_,rafId:x}=p,C=P.useRef(null),D=`${_}-menuitem-${P.useId()}`,{index:E,register:F}=kd({disabled:a&&!l}),I=P.useCallback(A=>{n==null||n(A),!a&&h(E)},[h,E,a,n]),R=P.useCallback(A=>{r==null||r(A),C.current&&!pa(C.current)&&I(A)},[I,r]),K=P.useCallback(A=>{o==null||o(A),!a&&h(-1)},[h,a,o]),j=P.useCallback(A=>{s==null||s(A),No(A.currentTarget)&&(c??f)&&m()},[m,s,f,c]),M=P.useCallback(A=>{i==null||i(A),h(E)},[h,i,E]),b=E===v,N=a&&!l;qr(()=>{if(g)return b&&!N&&C.current?(x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var A;(A=C.current)==null||A.focus({preventScroll:!0}),x.current=null})):y.current&&!pa(y.current)&&y.current.focus({preventScroll:!0}),()=>{x.current&&cancelAnimationFrame(x.current)}},[b,N,y,g]);const H=si({onClick:j,onFocus:M,onMouseEnter:I,onMouseMove:R,onMouseLeave:K,ref:Me(F,C,e),isDisabled:a,isFocusable:l});return{...d,...H,type:u??H.type,id:D,role:"menuitem",tabIndex:b?0:-1}}function Jp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...wi(o,e),role:`menuitem${n}`,"aria-checked":r}}function Yp(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...i}=t,l=n==="radio"?"":[],[c,u]=Va({defaultValue:o??l,value:r,onChange:s}),d=P.useCallback(v=>{if(n==="radio"&&typeof c=="string"&&u(v),n==="checkbox"&&Array.isArray(c)){const f=c.includes(v)?c.filter(m=>m!==v):c.concat(v);u(f)}},[c,u,n]),h=ks(e).map(v=>{if(v.type.id!=="MenuItemOption")return v;const f=y=>{var g,_;d(v.props.value),(_=(g=v.props).onClick)==null||_.call(g,y)},m=n==="radio"?v.props.value===c:c.includes(v.props.value);return P.cloneElement(v,{type:n,onClick:f,isChecked:m})});return{...i,children:h}}function Dd(t){var e;if(!jd(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function jd(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[Pd,to]=rt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Fs=t=>{const{children:e}=t,n=Rt("Menu",t),r=Ye(t),{direction:o}=vs(),{descendants:s,...i}=Sd({...r,direction:o}),a=P.useMemo(()=>i,[i]),{isOpen:l,onClose:c,forceUpdate:u}=a;return k.jsx(bd,{value:s,children:k.jsx(Ed,{value:a,children:k.jsx(Pd,{value:n,children:Ra(e,{isOpen:l,onClose:c,forceUpdate:u})})})})};Fs.displayName="Menu";var bi=fe((t,e)=>{const n=to();return k.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});bi.displayName="MenuCommand";var Ad=fe((t,e)=>{const{type:n,...r}=t,o=to(),s=r.as||n?n??void 0:"button",i=P.useMemo(()=>({textDecoration:"none",color:"inherit",userSelect:"none",display:"flex",width:"100%",alignItems:"center",textAlign:"start",flex:"0 0 auto",outline:0,...o.item}),[o.item]);return k.jsx(de.button,{ref:e,type:s,...r,__css:i})}),_i=t=>{const{className:e,children:n,...r}=t,o=to(),s=P.Children.only(n),i=P.isValidElement(s)?P.cloneElement(s,{focusable:"false","aria-hidden":!0,className:_e("chakra-menu__icon",s.props.className)}):null,a=_e("chakra-menu__icon-wrapper",e);return k.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};_i.displayName="MenuIcon";var mt=fe((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=wi(a,e),u=n||o?k.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return k.jsxs(Ad,{...l,className:_e("chakra-menu__menuitem",l.className),children:[n&&k.jsx(_i,{fontSize:"0.8em",marginEnd:r,children:n}),u,o&&k.jsx(bi,{marginStart:s,children:o})]})});mt.displayName="MenuItem";var Nd={enter:{visibility:"visible",opacity:1,scale:1,transition:{duration:.2,ease:[.4,0,.2,1]}},exit:{transitionEnd:{visibility:"hidden"},opacity:0,scale:.8,transition:{duration:.1,easings:"easeOut"}}},Fd=de(gs.div),Rs=fe(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:c,unstable__animationState:u}=Zn(),d=Id(a,n),p=Od(s),h=to();return k.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=h.list)==null?void 0:r.zIndex},children:k.jsx(Fd,{variants:Nd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...h.list},...i,className:_e("chakra-menu__menu-list",d.className),...d,onUpdate:c,onAnimationComplete:Ta(u.onComplete,d.onAnimationComplete)})})});Rs.displayName="MenuList";var[Rd,wn]=rt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[Td,no]=rt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function xi(t){const e=P.Children.only(t.children),{getTriggerProps:n}=wn();return P.cloneElement(e,n(e.props,e.ref))}xi.displayName="PopoverTrigger";var en={click:"click",hover:"hover"};function Md(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:c=en.click,openDelay:u=200,closeDelay:d=200,isLazy:p,lazyBehavior:h="unmount",computePositionOnMount:v,...f}=t,{isOpen:m,onClose:y,onOpen:g,onToggle:_}=As(t),x=P.useRef(null),C=P.useRef(null),D=P.useRef(null),E=P.useRef(!1),F=P.useRef(!1);m&&(F.current=!0);const[I,R]=P.useState(!1),[K,j]=P.useState(!1),M=P.useId(),b=o??M,[N,H,A,X]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${b}`),{referenceRef:V,getArrowProps:te,getPopperProps:z,getArrowInnerProps:B,forceUpdate:ne}=Ps({...f,enabled:m||!!v}),Y=vi({isOpen:m,ref:D});Dc({enabled:m,ref:C}),ai(D,{focusRef:C,visible:m,shouldFocus:s&&c===en.click}),Yc(D,{focusRef:r,visible:m,shouldFocus:i&&c===en.click});const Z=Ns({wasSelected:F.current,enabled:p,mode:h,isSelected:Y.present}),he=P.useCallback((U={},W=null)=>{const O={...U,style:{...U.style,transformOrigin:Ae.transformOrigin.varRef,[Ae.arrowSize.var]:a?`${a}px`:void 0,[Ae.arrowShadowColor.var]:l},ref:Me(D,W),children:Z?U.children:null,id:H,tabIndex:-1,role:"dialog",onKeyDown:Oe(U.onKeyDown,S=>{n&&S.key==="Escape"&&y()}),onBlur:Oe(U.onBlur,S=>{const T=ma(S),q=ho(D.current,T),J=ho(C.current,T);m&&e&&(!q&&!J)&&y()}),"aria-labelledby":I?A:void 0,"aria-describedby":K?X:void 0};return c===en.hover&&(O.role="tooltip",O.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0}),O.onMouseLeave=Oe(U.onMouseLeave,S=>{S.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>y(),d))})),O},[Z,H,I,A,K,X,c,n,y,m,e,d,l,a]),ye=P.useCallback((U={},W=null)=>z({...U,style:{visibility:m?"visible":"hidden",...U.style}},W),[m,z]),le=P.useCallback((U,W=null)=>({...U,ref:Me(W,x,V)}),[x,V]),ue=P.useRef(),ke=P.useRef(),ve=P.useCallback(U=>{x.current==null&&V(U)},[V]),me=P.useCallback((U={},W=null)=>{const O={...U,ref:Me(C,W,ve),id:N,"aria-haspopup":"dialog","aria-expanded":m,"aria-controls":H};return c===en.click&&(O.onClick=Oe(U.onClick,_)),c===en.hover&&(O.onFocus=Oe(U.onFocus,()=>{ue.current===void 0&&g()}),O.onBlur=Oe(U.onBlur,S=>{const T=ma(S),q=!ho(D.current,T);m&&e&&q&&y()}),O.onKeyDown=Oe(U.onKeyDown,S=>{S.key==="Escape"&&y()}),O.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0,ue.current=window.setTimeout(()=>g(),u)}),O.onMouseLeave=Oe(U.onMouseLeave,()=>{E.current=!1,ue.current&&(clearTimeout(ue.current),ue.current=void 0),ke.current=window.setTimeout(()=>{E.current===!1&&y()},d)})),O},[N,m,H,c,ve,_,g,e,y,u,d]);P.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current),ke.current&&clearTimeout(ke.current)},[]);const Ee=P.useCallback((U={},W=null)=>({...U,id:A,ref:Me(W,O=>{R(!!O)})}),[A]),w=P.useCallback((U={},W=null)=>({...U,id:X,ref:Me(W,O=>{j(!!O)})}),[X]);return{forceUpdate:ne,isOpen:m,onAnimationComplete:Y.onComplete,onClose:y,getAnchorProps:le,getArrowProps:te,getArrowInnerProps:B,getPopoverPositionerProps:ye,getPopoverProps:he,getTriggerProps:me,getHeaderProps:Ee,getBodyProps:w}}function ho(t,e){return t===e||(t==null?void 0:t.contains(e))}function ma(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function ki(t){const e=Rt("Popover",t),{children:n,...r}=Ye(t),o=vs(),s=Md({...r,direction:o.direction});return k.jsx(Rd,{value:s,children:k.jsx(Td,{value:e,children:Ra(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}ki.displayName="Popover";var po=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Ei(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:i,shadowColor:a}=t,{getArrowProps:l,getArrowInnerProps:c}=wn(),u=no(),d=(e=n??r)!=null?e:o,p=s??i;return k.jsx(de.div,{...l(),className:"chakra-popover__arrow-positioner",children:k.jsx(de.div,{className:_e("chakra-popover__arrow",t.className),...c(t),__css:{"--popper-arrow-shadow-color":po("colors",a),"--popper-arrow-bg":po("colors",d),"--popper-arrow-shadow":po("shadows",p),...u.arrow}})})}Ei.displayName="PopoverArrow";var Ci=fe(function(e,n){const{getBodyProps:r}=wn(),o=no();return k.jsx(de.div,{...r(e,n),className:_e("chakra-popover__body",e.className),__css:o.body})});Ci.displayName="PopoverBody";var Si=fe(function(e,n){const{onClose:r}=wn(),o=no();return k.jsx($l,{size:"sm",onClick:r,className:_e("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});Si.displayName="PopoverCloseButton";function Bd(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var zd={exit:{opacity:0,scale:.95,transition:{duration:.1,ease:[.4,0,1,1]}},enter:{scale:1,opacity:1,transition:{duration:.15,ease:[0,0,.2,1]}}},Ld=de(gs.section),Ii=fe(function(e,n){const{variants:r=zd,...o}=e,{isOpen:s}=wn();return k.jsx(Ld,{ref:n,variants:Bd(r),initial:!1,animate:s?"enter":"exit",...o})});Ii.displayName="PopoverTransition";var Oi=fe(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=wn(),c=no(),u={position:"relative",display:"flex",flexDirection:"column",...c.content};return k.jsx(de.div,{...a(r),__css:c.popper,className:"chakra-popover__popper",children:k.jsx(Ii,{...o,...i(s,n),onAnimationComplete:Ta(l,s.onAnimationComplete),className:_e("chakra-popover__content",e.className),__css:u})})});Oi.displayName="PopoverContent";var[Wd,Ud,Kd,$d]=$a();function Vd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:i,lazyBehavior:a="unmount",orientation:l="horizontal",direction:c="ltr",...u}=t,[d,p]=P.useState(n??0),[h,v]=Va({defaultValue:n??0,value:o,onChange:r});P.useEffect(()=>{o!=null&&p(o)},[o]);const f=Kd(),m=P.useId();return{id:`tabs-${(e=t.id)!=null?e:m}`,selectedIndex:h,focusedIndex:d,setSelectedIndex:v,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:f,direction:c,htmlProps:u}}var[Hd,ro]=rt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function qd(t){const{focusedIndex:e,orientation:n,direction:r}=ro(),o=Ud(),s=P.useCallback(i=>{const a=()=>{var g;const _=o.nextEnabled(e);_&&((g=_.node)==null||g.focus())},l=()=>{var g;const _=o.prevEnabled(e);_&&((g=_.node)==null||g.focus())},c=()=>{var g;const _=o.firstEnabled();_&&((g=_.node)==null||g.focus())},u=()=>{var g;const _=o.lastEnabled();_&&((g=_.node)==null||g.focus())},d=n==="horizontal",p=n==="vertical",h=i.key,v=r==="ltr"?"ArrowLeft":"ArrowRight",f=r==="ltr"?"ArrowRight":"ArrowLeft",y={[v]:()=>d&&l(),[f]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:c,End:u}[h];y&&(i.preventDefault(),y(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Oe(t.onKeyDown,s)}}function Gd(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=ro(),{index:c,register:u}=$d({disabled:e&&!n}),d=c===l,p=()=>{o(c)},h=()=>{a(c),!s&&!(e&&n)&&o(c)},v=si({...r,ref:Me(u,t.ref),isDisabled:e,isFocusable:n,onClick:Oe(t.onClick,p)}),f="button";return{...v,id:Di(i,c),role:"tab",tabIndex:d?0:-1,type:f,"aria-selected":d,"aria-controls":ji(i,c),onFocus:e?void 0:Oe(t.onFocus,h)}}var[Zd,Jd]=rt({});function Yd(t){const e=ro(),{id:n,selectedIndex:r}=e,s=ks(t.children).map((i,a)=>P.createElement(Zd,{key:a,value:{isSelected:a===r,id:ji(n,a),tabId:Di(n,a),selectedIndex:r}},i));return{...t,children:s}}function Xd(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=ro(),{isSelected:s,id:i,tabId:a}=Jd(),l=P.useRef(!1);s&&(l.current=!0);const c=Ns({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:c?e:null,role:"tabpanel","aria-labelledby":a,hidden:!s,id:i}}function Di(t,e){return`${t}--tab-${e}`}function ji(t,e){return`${t}--tabpanel-${e}`}var[Qd,oo]=rt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Pi=fe(function(e,n){const r=Rt("Tabs",e),{children:o,className:s,...i}=Ye(e),{htmlProps:a,descendants:l,...c}=Vd(i),u=P.useMemo(()=>c,[c]),{isFitted:d,...p}=a,h={position:"relative",...r.root};return k.jsx(Wd,{value:l,children:k.jsx(Hd,{value:u,children:k.jsx(Qd,{value:r,children:k.jsx(de.div,{className:_e("chakra-tabs",s),ref:n,...p,__css:h,children:o})})})})});Pi.displayName="Tabs";var Ai=fe(function(e,n){const r=qd({...e,ref:n}),s={display:"flex",...oo().tablist};return k.jsx(de.div,{...r,className:_e("chakra-tabs__tablist",e.className),__css:s})});Ai.displayName="TabList";var Fo=fe(function(e,n){const r=Xd({...e,ref:n}),o=oo();return k.jsx(de.div,{outline:"0",...r,className:_e("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Fo.displayName="TabPanel";var Ni=fe(function(e,n){const r=Yd(e),o=oo();return k.jsx(de.div,{...r,width:"100%",ref:n,className:_e("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});Ni.displayName="TabPanels";var Ro=fe(function(e,n){const r=oo(),o=Gd({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return k.jsx(de.button,{...o,className:_e("chakra-tabs__tab",e.className),__css:s})});Ro.displayName="Tab";var[ef,Fi]=rt({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Gt=fe((t,e)=>{const n=Rt("Tag",t),r=Ye(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return k.jsx(ef,{value:n,children:k.jsx(de.span,{ref:e,...r,__css:o})})});Gt.displayName="Tag";var tf=fe((t,e)=>{const n=Fi();return k.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});tf.displayName="TagLabel";var nf=fe((t,e)=>k.jsx(Hr,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));nf.displayName="TagLeftIcon";var rf=fe((t,e)=>k.jsx(Hr,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));rf.displayName="TagRightIcon";var Ri=t=>k.jsx(Hr,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:k.jsx("path",{fill:"currentColor",d:"M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z"})});Ri.displayName="TagCloseIcon";var of=fe((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...Fi().closeButton};return k.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||k.jsx(Ri,{})})});of.displayName="TagCloseButton";var sf={exit:{scale:.85,opacity:0,transition:{opacity:{duration:.15,easings:"easeInOut"},scale:{duration:.2,easings:"easeInOut"}}},enter:{scale:1,opacity:1,transition:{opacity:{easings:"easeOut",duration:.2},scale:{duration:.2,ease:[.175,.885,.4,1.1]}}}},To=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},pr=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function af(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:i=o,closeOnEsc:a=!0,onOpen:l,onClose:c,placement:u,id:d,isOpen:p,defaultIsOpen:h,arrowSize:v=10,arrowShadowColor:f,arrowPadding:m,modifiers:y,isDisabled:g,gutter:_,offset:x,direction:C,...D}=t,{isOpen:E,onOpen:F,onClose:I}=As({isOpen:p,defaultIsOpen:h,onOpen:l,onClose:c}),{referenceRef:R,getPopperProps:K,getArrowInnerProps:j,getArrowProps:M}=Ps({enabled:E,placement:u,arrowPadding:m,modifiers:y,gutter:_,offset:x,direction:C}),b=P.useId(),H=`tooltip-${d??b}`,A=P.useRef(null),X=P.useRef(),V=P.useCallback(()=>{X.current&&(clearTimeout(X.current),X.current=void 0)},[]),te=P.useRef(),z=P.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=void 0)},[]),B=P.useCallback(()=>{z(),I()},[I,z]),ne=lf(A,B),Y=P.useCallback(()=>{if(!g&&!X.current){E&&ne();const me=pr(A);X.current=me.setTimeout(F,e)}},[ne,g,E,F,e]),Z=P.useCallback(()=>{V();const me=pr(A);te.current=me.setTimeout(B,n)},[n,B,V]),he=P.useCallback(()=>{E&&r&&Z()},[r,Z,E]),ye=P.useCallback(()=>{E&&i&&Z()},[i,Z,E]),le=P.useCallback(me=>{E&&me.key==="Escape"&&Z()},[E,Z]);on(()=>To(A),"keydown",a?le:void 0),on(()=>{if(!s)return null;const me=A.current;if(!me)return null;const Ee=ti(me);return Ee.localName==="body"?pr(A):Ee},"scroll",()=>{E&&s&&B()},{passive:!0,capture:!0}),P.useEffect(()=>{g&&(V(),E&&I())},[g,E,I,V]),P.useEffect(()=>()=>{V(),z()},[V,z]),on(()=>A.current,"pointerleave",Z);const ue=P.useCallback((me={},Ee=null)=>({...me,ref:Me(A,Ee,R),onPointerEnter:Oe(me.onPointerEnter,U=>{U.pointerType!=="touch"&&Y()}),onClick:Oe(me.onClick,he),onPointerDown:Oe(me.onPointerDown,ye),onFocus:Oe(me.onFocus,Y),onBlur:Oe(me.onBlur,Z),"aria-describedby":E?H:void 0}),[Y,Z,ye,E,H,he,R]),ke=P.useCallback((me={},Ee=null)=>K({...me,style:{...me.style,[Ae.arrowSize.var]:v?`${v}px`:void 0,[Ae.arrowShadowColor.var]:f}},Ee),[K,v,f]),ve=P.useCallback((me={},Ee=null)=>{const w={...me.style,position:"relative",transformOrigin:Ae.transformOrigin.varRef};return{ref:Ee,...D,...me,id:H,role:"tooltip",style:w}},[D,H]);return{isOpen:E,show:Y,hide:Z,getTriggerProps:ue,getTooltipProps:ve,getTooltipPositionerProps:ke,getArrowProps:M,getArrowInnerProps:j}}var mo="chakra-ui:close-tooltip";function lf(t,e){return P.useEffect(()=>{const n=To(t);return n.addEventListener(mo,e),()=>n.removeEventListener(mo,e)},[e,t]),()=>{const n=To(t),r=pr(t);n.dispatchEvent(new r.CustomEvent(mo))}}function cf(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function uf(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var df=de(gs.div),bt=fe((t,e)=>{var n,r;const o=Hn("Tooltip",t),s=Ye(t),i=vs(),{children:a,label:l,shouldWrapChildren:c,"aria-label":u,hasArrow:d,bg:p,portalProps:h,background:v,backgroundColor:f,bgColor:m,motionProps:y,...g}=s,_=(r=(n=v??f)!=null?n:p)!=null?r:m;if(_){o.bg=_;const K=Vl(i,"colors",_);o[Ae.arrowBg.var]=K}const x=af({...g,direction:i.direction}),C=typeof a=="string"||c;let D;if(C)D=k.jsx(de.span,{display:"inline-block",tabIndex:0,...x.getTriggerProps(),children:a});else{const K=P.Children.only(a);D=P.cloneElement(K,x.getTriggerProps(K.props,K.ref))}const E=!!u,F=x.getTooltipProps({},e),I=E?cf(F,["role","id"]):F,R=uf(F,["role","id"]);return l?k.jsxs(k.Fragment,{children:[D,k.jsx(Hl,{children:x.isOpen&&k.jsx(Ma,{...h,children:k.jsx(de.div,{...x.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:k.jsxs(df,{variants:sf,initial:"exit",animate:"enter",exit:"exit",...y,...I,__css:o,children:[l,E&&k.jsx(de.span,{srOnly:!0,...R,children:u}),d&&k.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:k.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):k.jsx(k.Fragment,{children:a})});bt.displayName="Tooltip";let rr;const ff=new Uint8Array(16);function hf(){if(!rr&&(rr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!rr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return rr(ff)}const Re=[];for(let t=0;t<256;++t)Re.push((t+256).toString(16).slice(1));function pf(t,e=0){return Re[t[e+0]]+Re[t[e+1]]+Re[t[e+2]]+Re[t[e+3]]+"-"+Re[t[e+4]]+Re[t[e+5]]+"-"+Re[t[e+6]]+Re[t[e+7]]+"-"+Re[t[e+8]]+Re[t[e+9]]+"-"+Re[t[e+10]]+Re[t[e+11]]+Re[t[e+12]]+Re[t[e+13]]+Re[t[e+14]]+Re[t[e+15]]}const mf=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ya={randomUUID:mf};function Dr(t,e,n){if(ya.randomUUID&&!e&&!t)return ya.randomUUID();t=t||{};const r=t.random||(t.rng||hf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=r[o];return e}return pf(r)}async function yf(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await fetch(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function vf(t,e){try{return await(await fetch("/workspace/save_db",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:t,json:e})})).text()}catch(n){console.error("Error saving workspace:",n)}}async function gf(t,e){try{return await(await fetch("/workspace/update_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,json_str:e})})).text()}catch(n){alert("Error saving workflow .json file: "+n),console.error("Error saving workspace:",n)}}async function Ti(t,e=!1){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,deleteEmptyFolder:e})})).text()}catch(n){console.error("Error deleting file:",n)}}async function Xp(t){try{return await(await fetch("/workspace/get_system_dir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absolute_dir:t??""})})).json()}catch(e){console.error("Error getting workflows dir:",e)}}async function Qp(){try{return await(await fetch("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function wf(){const e=await(await fetch("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function bf(){try{return await(await fetch("/model_manager/get_model_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function em(){try{return await(await fetch("/model_manager/get_folder_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function tm(t){try{return await(await fetch("/model_manager/cancel_installation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({save_path:t})})).text()}catch(e){console.error("Error move file:",e)}}async function nm(t,e){try{return await(await fetch("/workspace/copy_json_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:t,dst:e})})).json()}catch(n){console.error("Error copy flows to new directory:",n)}}const _f="backup",jr="workspace";let or=null;function xf(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(jr)||o.createObjectStore(jr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function kf(){try{return or==null&&(or=await xf()),new Promise((t,e)=>{if(or==null)return e("indexDB is null");const o=or.transaction([jr],"readonly").objectStore(jr).get(_f);o.onsuccess=()=>{o.result?t(o.result.value):t(void 0)},o.onerror=()=>e(o.error)})}catch(t){console.error("Error while reading from database:",t)}}async function Ef(){try{return await kf()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const Ce=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ne=Object.keys,ze=Array.isArray;function Ue(t,e){return typeof e!="object"||Ne(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||Ce.Promise||(Ce.Promise=Promise);const zn=Object.getPrototypeOf,Cf={}.hasOwnProperty;function Je(t,e){return Cf.call(t,e)}function mn(t,e){typeof e=="function"&&(e=e(zn(t))),(typeof Reflect>"u"?Ne:Reflect.ownKeys)(e).forEach(n=>{_t(t,n,e[n])})}const Mi=Object.defineProperty;function _t(t,e,n,r){Mi(t,e,Ue(n&&Je(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function an(t){return{from:function(e){return t.prototype=Object.create(e.prototype),_t(t.prototype,"constructor",t),{extend:mn.bind(null,t.prototype)}}}}const Sf=Object.getOwnPropertyDescriptor;function Ts(t,e){let n;return Sf(t,e)||(n=zn(t))&&Ts(n,e)}const If=[].slice;function Pr(t,e,n){return If.call(t,e,n)}function Bi(t,e){return e(t)}function In(t){if(!t)throw new Error("Assertion Failed")}function zi(t){Ce.setImmediate?setImmediate(t):setTimeout(t,0)}function Li(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function xt(t,e){if(Je(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,o=e.length;r["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>Ce[t]),Df=Ki.map(t=>Ce[t]);Li(Ki,t=>[t,!0]);let It=null;function Jn(t){It=typeof WeakMap<"u"&&new WeakMap;const e=Mo(t);return It=null,e}function Mo(t){if(!t||typeof t!="object")return t;let e=It&&It.get(t);if(e)return e;if(ze(t)){e=[],It&&It.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=zn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),It&&It.set(t,e),t)Je(t,o)&&(e[o]=Mo(t[o]))}return e}const{toString:jf}={};function Bo(t){return jf.call(t).slice(8,-1)}const zo=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Pf=typeof zo=="symbol"?function(t){var e;return t!=null&&(e=t[zo])&&e.apply(t)}:function(){return null},rn={};function vt(t){var e,n,r,o;if(arguments.length===1){if(ze(t))return t.slice();if(this===rn&&typeof t=="string")return[t];if(o=Pf(t)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const Ms=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var ft=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function $i(t,e){ft=t,Vi=e}var Vi=()=>!0;const Af=!new Error("").stack;function Yt(){if(Af)try{throw Yt.arguments,new Error}catch(t){return t}return new Error}function Lo(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` `).length),n.split(` `).slice(e).filter(Vi).map(r=>` `+r).join("")):""}var Hi=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Bs=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Hi),Nf={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function ln(t,e){this._e=Yt(),this.name=t,this.message=e}function qi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` `)}function Ar(t,e,n,r){this._e=Yt(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=qi(t,e)}function An(t,e){this._e=Yt(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=qi(t,e)}an(ln).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Lo(this._e,2))}},toString:function(){return this.name+": "+this.message}}),an(Ar).from(ln),an(An).from(ln);var zs=Bs.reduce((t,e)=>(t[e]=e+"Error",t),{});const Ff=ln;var ce=Bs.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Yt(),this.name=n,o?typeof o=="string"?(this.message=`${o}${s?` - `+s:""}`,this.inner=s||null):typeof o=="object"&&(this.message=`${o.name} ${o.message}`,this.inner=o):(this.message=Nf[e]||n,this.inner=null)}return an(r).from(Ff),t[e]=r,t},{});ce.Syntax=SyntaxError,ce.Type=TypeError,ce.Range=RangeError;var va=Hi.reduce((t,e)=>(t[e+"Error"]=ce[e],t),{}),mr=Bs.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=ce[e]),t),{});function xe(){}function Ln(t){return t}function Rf(t,e){return t==null||t===Ln?e:function(n){return e(t(n))}}function Zt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Tf(t,e){return t===xe?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Zt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Zt(o,this.onerror):o),s!==void 0?s:n}}function Mf(t,e){return t===xe?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Zt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Zt(r,this.onerror):r)}}function Bf(t,e){return t===xe?e:function(n){var r=t.apply(this,arguments);Ue(n,r);var o=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?Zt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Zt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:Ue(r,i)}}function zf(t,e){return t===xe?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ls(t,e){return t===xe?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,o=arguments.length,s=new Array(o);o--;)s[o]=arguments[o];return n.then(function(){return e.apply(r,s)})}return e.apply(this,arguments)}}mr.ModifyError=Ar,mr.DexieError=ln,mr.BulkError=An;var Wn={};const Gi=100,[Wo,Nr,Uo]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,zn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,zn(e),t]})(),Zi=Nr&&Nr.then,yr=Wo&&Wo.constructor,Ws=!!Uo;var Ko=!1,Lf=Uo?()=>{Uo.then(sr)}:Ce.setImmediate?setImmediate.bind(null,sr):Ce.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{sr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(sr,0)},Nn=function(t,e){On.push([t,e]),Fr&&(Lf(),Fr=!1)},$o=!0,Fr=!0,Kt=[],vr=[],Vo=null,Ho=Ln,cn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ba,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{ba(t[0],t[1])}catch{}})}},ae=cn,On=[],$t=0,gr=[];function oe(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=xe,this._lib=!1;var e=this._PSD=ae;if(ft&&(this._stackHolder=Yt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Wn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Go(this,this._value))}this._state=null,this._value=null,++e.ref,Yi(this,t)}const qo={get:function(){var t=ae,e=Rr;function n(r,o){var s=!t.global&&(t!==ae||e!==Rr);const i=s&&!Et();var a=new oe((l,u)=>{Us(this,new Ji(Tr(r,t,s,i),Tr(o,t,s,i),l,u,t))});return ft&&el(a,this),a}return n.prototype=Wn,n},set:function(t){_t(this,"then",t&&t.prototype===Wn?qo:{get:function(){return t},set:qo.set})}};function Ji(t,e,n,r,o){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=o}function Yi(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Yn();n&&typeof n.then=="function"?Yi(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,Xi(t)),r&&Xn()}},Go.bind(null,t))}catch(n){Go(t,n)}}function Go(t,e){if(vr.push(e),t._state===null){var n=t._lib&&Yn();e=Ho(e),t._state=!1,t._value=e,ft&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Ts(e,"stack");e._promise=t,_t(e,"stack",{get:()=>Ko?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Kt.some(o=>o._value===r._value)||Kt.push(r)}(t),Xi(t),n&&Xn()}}function Xi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--$t==0&&Ks()},[]))}function Us(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++$t,Nn(Wf,[n,t,e])}else t._listeners.push(e)}function Wf(t,e,n){try{Vo=e;var r,o=e._value;e._state?r=t(o):(vr.length&&(vr=[]),r=t(o),vr.indexOf(o)===-1&&function(s){for(var i=Kt.length;i;)if(Kt[--i]._value===s._value)return void Kt.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Vo=null,--$t==0&&Ks(),--n.psd.ref||n.psd.finalize()}}function Qi(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var o,s,i=t._value;i!=null?(o=i.name||"Error",s=i.message||i,r=Lo(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return ft&&((r=Lo(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Qi(t._prev,e,n)),e}function el(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function sr(){Yn()&&Xn()}function Yn(){var t=$o;return $o=!1,Fr=!1,t}function Xn(){var t,e,n;do for(;On.length>0;)for(t=On,On=[],n=t.length,e=0;e0);$o=!0,Fr=!0}function Ks(){var t=Kt;Kt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=gr.slice(0),n=e.length;n;)e[--n]()}function ar(t){return new oe(Wn,!1,t)}function Se(t,e){var n=ae;return function(){var r=Yn(),o=ae;try{return At(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{At(o,!1),r&&Xn()}}}mn(oe.prototype,{then:qo,_then:function(t,e){Us(this,new Ji(null,null,t,e,ae))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):ar(r)):this.then(null,r=>r&&r.name===e?n(r):ar(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),ar(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Ko=!0;var t=Qi(this,[],20).join(` -From previous: `);return this._state!==null&&(this._stack=t),t}finally{Ko=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new ce.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&_t(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),cn.env=tl(),mn(oe,{all:function(){var t=vt.apply(null,arguments).map(ir);return new oe(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>oe.resolve(o).then(i=>{t[s]=i,--r||e(t)},n))})},resolve:t=>{if(t instanceof oe)return t;if(t&&typeof t.then=="function")return new oe((n,r)=>{t.then(n,r)});var e=new oe(Wn,!0,t);return el(e,Vo),e},reject:ar,race:function(){var t=vt.apply(null,arguments).map(ir);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ae,set:t=>ae=t},totalEchoes:{get:()=>Rr},newPSD:Pt,usePSD:_n,scheduler:{get:()=>Nn,set:t=>{Nn=t}},rejectionMapper:{get:()=>Ho,set:t=>{Ho=t}},follow:(t,e)=>new oe((n,r)=>Pt((o,s)=>{var i=ae;i.unhandleds=[],i.onunhandled=s,i.finalize=Zt(function(){(function(a){function l(){a(),gr.splice(gr.indexOf(l),1)}gr.push(l),++$t,Nn(()=>{--$t==0&&Ks()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),yr&&(yr.allSettled&&_t(oe,"allSettled",function(){const t=vt.apply(null,arguments).map(ir);return new oe(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>oe.resolve(o).then(i=>r[s]={status:"fulfilled",value:i},i=>r[s]={status:"rejected",reason:i}).then(()=>--n||e(r)))})}),yr.any&&typeof AggregateError<"u"&&_t(oe,"any",function(){const t=vt.apply(null,arguments).map(ir);return new oe((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,i)=>oe.resolve(s).then(a=>e(a),a=>{o[i]=a,--r||n(new AggregateError(o))}))})}));const Be={awaits:0,echoes:0,id:0};var Uf=0,wr=[],yo=0,Rr=0,Kf=0;function Pt(t,e,n,r){var o=ae,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Kf;var i=cn.env;s.env=Ws?{Promise:oe,PromiseProp:{value:oe,configurable:!0,writable:!0},all:oe.all,race:oe.race,allSettled:oe.allSettled,any:oe.any,resolve:oe.resolve,reject:oe.reject,nthen:ga(i.nthen,s),gthen:ga(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=_n(s,t,n,r);return s.ref===0&&s.finalize(),a}function bn(){return Be.id||(Be.id=++Uf),++Be.awaits,Be.echoes+=Gi,Be.id}function Et(){return!!Be.awaits&&(--Be.awaits==0&&(Be.id=0),Be.echoes=Be.awaits*Gi,!0)}function ir(t){return Be.echoes&&t&&t.constructor===yr?(bn(),t.then(e=>(Et(),e),e=>(Et(),Fe(e)))):t}function $f(t){++Rr,Be.echoes&&--Be.echoes!=0||(Be.echoes=Be.id=0),wr.push(ae),At(t,!0)}function Vf(){var t=wr[wr.length-1];wr.pop(),At(t,!1)}function At(t,e){var n=ae;if((e?!Be.echoes||yo++&&t===ae:!yo||--yo&&t===ae)||nl(e?$f.bind(null,t):Vf),t!==ae&&(ae=t,n===cn&&(cn.env=tl()),Ws)){var r=cn.env.Promise,o=t.env;Nr.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ce,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function tl(){var t=Ce.Promise;return Ws?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ce,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:Nr.then,gthen:t.prototype.then}:{}}function _n(t,e,n,r,o){var s=ae;try{return At(t,!0),e(n,r,o)}finally{At(s,!1)}}function nl(t){Zi.call(Wo,t)}function Tr(t,e,n,r){return typeof t!="function"?t:function(){var o=ae;n&&bn(),At(e,!0);try{return t.apply(this,arguments)}finally{At(o,!1),r&&nl(Et)}}}function ga(t,e){return function(n,r){return t.call(this,Tr(n,e),Tr(r,e))}}(""+Zi).indexOf("[native code]")===-1&&(bn=Et=xe);const wa="unhandledrejection";function ba(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ce.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(wa,!0,!0),Ue(r,o)):Ce.CustomEvent&&Ue(r=new CustomEvent(wa,{detail:o}),o),r&&Ce.dispatchEvent&&(dispatchEvent(r),!Ce.PromiseRejectionEvent&&Ce.onunhandledrejection))try{Ce.onunhandledrejection(r)}catch{}ft&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Fe=oe.reject;function Zo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||ae.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===zs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Zo(t,e,n,r))):Fe(s)}return o._promise(e,(s,i)=>Pt(()=>(ae.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Fe(new ce.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Fe(new ce.DatabaseClosed);t.open().catch(xe)}return t._state.dbReadyPromise.then(()=>Zo(t,e,n,r))}const _a="3.2.4",zt="￿",Jo=-1/0,pt="Invalid key provided. Keys must be of type string, number, Date or Array.",rl="String expected.",Fn=[],so=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Hf=so,qf=so,ol=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),ao="__dbnames",vo="readonly",go="readwrite";function Jt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const sl={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lr(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Jn(e))[t],e)}class Gf{_trans(e,n,r){const o=this._tx||ae.trans,s=this.name;function i(l,u,c){if(!c.schema[s])throw new ce.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const a=Yn();try{return o&&o.db===this.db?o===ae.trans?o._promise(e,i,r):Pt(()=>o._promise(e,i,r),{trans:o,transless:ae.transless||ae}):Zo(this.db,e,[this.name],i)}finally{a&&Xn()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(o=>this.hook.reading.fire(o))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(ze(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=Ne(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(u=>u.compound&&n.every(c=>u.keyPath.indexOf(c)>=0)&&u.keyPath.every(c=>n.indexOf(c)>=0))[0];if(r&&this.db._maxKey!==zt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&ft&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,s=this.db._deps.indexedDB;function i(u,c){try{return s.cmp(u,c)===0}catch{return!1}}const[a,l]=n.reduce(([u,c],d)=>{const p=o[d],h=e[d];return[u||p,u||!p?Jt(c,p&&p.multi?v=>{const f=xt(v,d);return ze(f)&&f.some(m=>i(h,m))}:v=>i(h,xt(v,d))):c]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):r?this.filter(l):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,ze(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const o=Object.create(e.prototype);for(var s in r)if(Je(r,s))try{o[s]=r[s]}catch{}return o};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){Ue(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=lr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"add",keys:n!=null?[n]:null,values:[s]})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{st(e,o,i)}catch{}return i})}update(e,n){if(typeof e!="object"||ze(e))return this.where(":id").equals(e).modify(n);{const r=xt(e,this.schema.primKey.keyPath);if(r===void 0)return Fe(new ce.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ne(n).forEach(o=>{st(e,o,n[o])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=lr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"put",values:[s],keys:n!=null?[n]:null})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{st(e,o,i)}catch{}return i})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?oe.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:sl})).then(e=>e.numFailures?oe.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(o=>this.hook.reading.fire(o))))}bulkAdd(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(lr(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:v})=>{if(d===0)return s?p:h;throw new An(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,v)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(lr(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:v})=>{if(d===0)return s?p:h;throw new An(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,v)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:o,failures:s})=>{if(r===0)return o;throw new An(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function Rn(t){var e={},n=function(i,a){if(a){for(var l=arguments.length,u=new Array(l-1);--l;)u[l-1]=arguments[l];return e[i].subscribe.apply(null,u),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rJt(r(),e()):e,t.justLimit=n&&!r}function br(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new ce.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function xa(t,e,n){const r=br(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function cr(t,e,n,r){const o=t.replayFilter?Jt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,u)=>{if(!o||o(l,u,p=>l.stop(p),p=>l.fail(p))){var c=l.primaryKey,d=""+c;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(c)),Je(s,d)||(s[d]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(i,n),ka(xa(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return ka(xa(t,r,n),Jt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ka(t,e,n,r){var o=Se(r?(s,i,a)=>n(r(s),i,a):n);return t.then(s=>{if(s)return s.start(()=>{var i=()=>s.continue();e&&!e(s,a=>i=a,a=>{s.stop(a),i=xe},a=>{s.fail(a),i=xe})||o(s.value,s,a=>i=a),i()})})}function We(t,e){try{const n=Ea(t),r=Ea(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:tcr(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(tn(r,!0))return o.count({trans:n,query:{index:br(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return cr(r,()=>(++s,!1),n,o).then(()=>s)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),o=r[0],s=r.length-1;function i(u,c){return c?i(u[r[c]],c-1):u[o]}var a=this._ctx.dir==="next"?1:-1;function l(u,c){var d=i(u,s),p=i(c,s);return dp?a:0}return this.toArray(function(u){return u.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&tn(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=br(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:s,range:r.range}}).then(({result:i})=>o?i.map(o):i)}{const o=[];return cr(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,tn(n)?bo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):bo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),bo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return wo(this._ctx,function(r,o,s){return!e(r.value)||(o(s),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return wo(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Jt(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.key,o)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.primaryKey,o)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&tn(n,!0)&&n.limit>0)return this._read(o=>{var s=br(n,n.table.core.schema);return n.table.core.query({trans:o,values:!1,limit:n.limit,query:{index:s,range:n.range}})}).then(({result:o})=>o).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return wo(this._ctx,function(o){var s=o.primaryKey.toString(),i=Je(r,s);return r[s]=!0,!i}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var s=Ne(e),i=s.length;o=function(f){for(var m=!1,y=0;y{const{failures:y,numFailures:g}=m;p+=f-g;for(let _ of Ne(y))d.push(y[_])};return this.clone().primaryKeys().then(f=>{const m=y=>{const g=Math.min(c,f.length-y);return a.getMany({trans:r,keys:f.slice(y,y+g),cache:"immutable"}).then(_=>{const x=[],C=[],D=l?[]:null,E=[];for(let I=0;I0&&a.mutate({trans:r,type:"add",values:x}).then(I=>{for(let R in I.failures)E.splice(parseInt(R),1);v(x.length,I)})).then(()=>(C.length>0||F&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:D,values:C,criteria:F,changeSpec:typeof e!="function"&&e}).then(I=>v(C.length,I))).then(()=>(E.length>0||F&&e===_o)&&a.mutate({trans:r,type:"delete",keys:E,criteria:F}).then(I=>v(E.length,I))).then(()=>f.length>y+g&&m(y+c))})};return m(0).then(()=>{if(d.length>0)throw new Ar("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return tn(e)&&(e.isPrimKey&&!qf||n.type===3)?this._write(r=>{const{primaryKey:o}=e.table.core.schema,s=n;return e.table.core.count({trans:r,query:{index:o,range:s}}).then(i=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:a,lastResult:l,results:u,numFailures:c})=>{if(c)throw new Ar("Could not delete some values",Object.keys(a).map(d=>a[d]),i-c);return i-c}))}):this.modify(_o)}}const _o=(t,e)=>e.value=null;function Jf(t,e){return te?-1:t===e?0:1}function He(t,e,n){var r=t instanceof il?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function nn(t){return new t.Collection(t,()=>al("")).limit(0)}function Xf(t,e,n,r,o,s){for(var i=Math.min(t.length,r.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+n.substr(a+1):null;o(t[l],u)<0&&(a=l)}return itypeof f=="string"))return He(t,rl);function p(f){o=function(y){return y==="next"?g=>g.toUpperCase():g=>g.toLowerCase()}(f),s=function(y){return y==="next"?g=>g.toLowerCase():g=>g.toUpperCase()}(f),i=f==="next"?Jf:Yf;var m=n.map(function(y){return{lower:s(y),upper:o(y)}}).sort(function(y,g){return i(y.lower,g.lower)});a=m.map(function(y){return y.upper}),l=m.map(function(y){return y.lower}),u=f,c=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>St(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var v=0;return h._addAlgorithm(function(f,m,y){var g=f.key;if(typeof g!="string")return!1;var _=s(g);if(e(_,l,v))return!0;for(var x=null,C=v;C0)&&(x=D)}return m(x!==null?function(){f.continue(x+c)}:y),!1}),h}function St(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function al(t){return{type:1,lower:t,upper:t}}class il{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,o){r=r!==!1,o=o===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||o)&&(!r||!o)?nn(this):new this.Collection(this,()=>St(e,n,!r,!o))}catch{return He(this,pt)}}equals(e){return e==null?He(this,pt):new this.Collection(this,()=>al(e))}above(e){return e==null?He(this,pt):new this.Collection(this,()=>St(e,void 0,!0))}aboveOrEqual(e){return e==null?He(this,pt):new this.Collection(this,()=>St(e,void 0,!1))}below(e){return e==null?He(this,pt):new this.Collection(this,()=>St(void 0,e,!1,!0))}belowOrEqual(e){return e==null?He(this,pt):new this.Collection(this,()=>St(void 0,e))}startsWith(e){return typeof e!="string"?He(this,rl):this.between(e,e+zt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ur(this,(n,r)=>n.indexOf(r[0])===0,[e],zt)}equalsIgnoreCase(e){return ur(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=vt.apply(rn,arguments);return e.length===0?nn(this):ur(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=vt.apply(rn,arguments);return e.length===0?nn(this):ur(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,zt)}anyOf(){const e=vt.apply(rn,arguments);let n=this._cmp;try{e.sort(n)}catch{return He(this,pt)}if(e.length===0)return nn(this);const r=new this.Collection(this,()=>St(e[0],e[e.length-1]));r._ondirectionchange=s=>{n=s==="next"?this._ascending:this._descending,e.sort(n)};let o=0;return r._addAlgorithm((s,i,a)=>{const l=s.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return i(a),!1;return n(l,e[o])===0||(i(()=>{s.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[Jo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=vt.apply(rn,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return He(this,pt)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Jo,o]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,o=this._ascending,s=this._descending,i=this._min,a=this._max;if(e.length===0)return nn(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&o(g[0],g[1])<=0))return He(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ce.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function p(g,_){return d(g[0],_[0])}try{c=e.reduce(function(g,_){let x=0,C=g.length;for(;x0){D[0]=i(D[0],_[0]),D[1]=a(D[1],_[1]);break}}return x===C&&g.push(_),g},[]),c.sort(p)}catch{return He(this,pt)}let h=0;const v=u?g=>o(g,c[h][1])>0:g=>o(g,c[h][1])>=0,f=l?g=>s(g,c[h][0])>0:g=>s(g,c[h][0])>=0;let m=v;const y=new this.Collection(this,()=>St(c[0][0],c[c.length-1][1],!l,!u));return y._ondirectionchange=g=>{g==="next"?(m=v,d=o):(m=f,d=s),c.sort(p)},y._addAlgorithm((g,_,x)=>{for(var C=g.key;m(C);)if(++h,h===c.length)return _(x),!1;return!!function(D){return!v(D)&&!f(D)}(C)||(this._cmp(C,c[h][1])===0||this._cmp(C,c[h][0])===0||_(()=>{d===o?g.continue(c[h][0]):g.continue(c[h][1])}),!1)}),y}startsWithAnyOf(){const e=vt.apply(rn,arguments);return e.every(n=>typeof n=="string")?e.length===0?nn(this):this.inAnyRange(e.map(n=>[n,n+zt])):He(this,"startsWithAnyOf() only works with strings")}}function lt(t){return Se(function(e){return Un(e),t(e.target.error),!1})}function Un(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Kn="storagemutated",Ot="x-storagemutated-1",Nt=Rn(null,Kn);class Qf{_lock(){return In(!ae.global),++this._reculock,this._reculock!==1||ae.global||(ae.lockOwnerFor=this),this}_unlock(){if(In(!ae.global),--this._reculock==0)for(ae.global||(ae.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{_n(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&ae.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(In(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new ce.DatabaseClosed(r);case"MissingAPIError":throw new ce.MissingAPI(r.message,r);default:throw new ce.OpenFailed(r)}if(!this.active)throw new ce.TransactionInactive;return In(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Se(o=>{Un(o),this._reject(e.error)}),e.onabort=Se(o=>{Un(o),this.active&&this._reject(new ce.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Nt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Fe(new ce.ReadOnly("Transaction is readonly"));if(!this.active)return Fe(new ce.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ae])});if(r)return Pt(()=>{var s=new oe((i,a)=>{this._lock();const l=n(i,a,this);l&&l.then&&l.then(i,a)});return s.finally(()=>this._unlock()),s._lib=!0,s});var o=new oe((s,i)=>{var a=n(s,i,this);a&&a.then&&a.then(s,i)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=oe.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);(function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=i)})()}var s=n._waitingFor;return new oe((i,a)=>{r.then(l=>n._waitingQueue.push(Se(i.bind(null,l))),l=>n._waitingQueue.push(Se(a.bind(null,l)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new ce.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Je(n,e))return n[e];const r=this.schema[e];if(!r)throw new ce.NotFound("Table "+e+" not part of transaction");const o=new this.db.Table(e,r,this);return o.core=this.db.core.table(e),n[e]=o,o}}function Yo(t,e,n,r,o,s,i){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:s,src:(n&&!i?"&":"")+(r?"*":"")+(o?"++":"")+ll(e)}}function ll(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function cl(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Li(n,r=>[r.name,r])}}let $n=t=>{try{return t.only([[]]),$n=()=>[[]],[[]]}catch{return $n=()=>zt,zt}};function Xo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>xt(r,e)}(t):e=>xt(e,t)}function Sa(t){return[].slice.call(t)}let eh=0;function Tn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function th(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:u,upper:c,lowerOpen:d,upperOpen:p}=l;return u===void 0?c===void 0?null:e.upperBound(c,!!p):c===void 0?e.lowerBound(u,!!d):e.bound(u,c,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,u){const c=Sa(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,v=ze(p),f=p==null,m={},y={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:v,keyPath:p,autoIncrement:h,unique:!0,extractKey:Xo(p)},indexes:Sa(d.indexNames).map(g=>d.index(g)).map(g=>{const{name:_,unique:x,multiEntry:C,keyPath:D}=g,E={name:_,compound:ze(D),keyPath:D,unique:x,multiEntry:C,extractKey:Xo(D)};return m[Tn(D)]=E,E}),getIndexByKeyPath:g=>m[Tn(g)]};return m[":id"]=y.primaryKey,p!=null&&(m[Tn(p)]=y.primaryKey),y})},hasGetAll:c.length>0&&"getAll"in u.objectStore(c[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),i=o.tables.map(l=>function(u){const c=u.name;return{name:c,schema:u,mutate:function({trans:d,type:p,keys:h,values:v,range:f}){return new Promise((m,y)=>{m=Se(m);const g=d.objectStore(c),_=g.keyPath==null,x=p==="put"||p==="add";if(!x&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:C}=h||v||{length:1};if(h&&v&&h.length!==v.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return m({numFailures:0,failures:{},results:[],lastResult:void 0});let D;const E=[],F=[];let I=0;const R=j=>{++I,Un(j)};if(p==="deleteRange"){if(f.type===4)return m({numFailures:I,failures:F,results:[],lastResult:void 0});f.type===3?E.push(D=g.clear()):E.push(D=g.delete(r(f)))}else{const[j,M]=x?_?[v,h]:[v,null]:[h,null];if(x)for(let b=0;b{const M=j.target.result;E.forEach((b,N)=>b.error!=null&&(F[N]=b.error)),m({numFailures:I,failures:F,results:p==="delete"?h:E.map(b=>b.result),lastResult:M})};D.onerror=j=>{R(j),K(j)},D.onsuccess=K})},getMany:({trans:d,keys:p})=>new Promise((h,v)=>{h=Se(h);const f=d.objectStore(c),m=p.length,y=new Array(m);let g,_=0,x=0;const C=E=>{const F=E.target;y[F._pos]=F.result,++x===_&&h(y)},D=lt(v);for(let E=0;Enew Promise((h,v)=>{h=Se(h);const f=d.objectStore(c).get(p);f.onsuccess=m=>h(m.target.result),f.onerror=lt(v)}),query:function(d){return p=>new Promise((h,v)=>{h=Se(h);const{trans:f,values:m,limit:y,query:g}=p,_=y===1/0?void 0:y,{index:x,range:C}=g,D=f.objectStore(c),E=x.isPrimaryKey?D:D.index(x.name),F=r(C);if(y===0)return h({result:[]});if(d){const I=m?E.getAll(F,_):E.getAllKeys(F,_);I.onsuccess=R=>h({result:R.target.result}),I.onerror=lt(v)}else{let I=0;const R=m||!("openKeyCursor"in E)?E.openCursor(F):E.openKeyCursor(F),K=[];R.onsuccess=j=>{const M=R.result;return M?(K.push(m?M.value:M.primaryKey),++I===y?h({result:K}):void M.continue()):h({result:K})},R.onerror=lt(v)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:v,unique:f}){return new Promise((m,y)=>{m=Se(m);const{index:g,range:_}=h,x=d.objectStore(c),C=g.isPrimaryKey?x:x.index(g.name),D=v?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in C)?C.openCursor(r(_),D):C.openKeyCursor(r(_),D);E.onerror=lt(y),E.onsuccess=Se(F=>{const I=E.result;if(!I)return void m(null);I.___id=++eh,I.done=!1;const R=I.continue.bind(I);let K=I.continuePrimaryKey;K&&(K=K.bind(I));const j=I.advance.bind(I),M=()=>{throw new Error("Cursor not stopped")};I.trans=d,I.stop=I.continue=I.continuePrimaryKey=I.advance=()=>{throw new Error("Cursor not started")},I.fail=Se(y),I.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},I.start=b=>{const N=new Promise((A,X)=>{A=Se(A),E.onerror=lt(X),I.fail=X,I.stop=V=>{I.stop=I.continue=I.continuePrimaryKey=I.advance=M,A(V)}}),H=()=>{if(E.result)try{b()}catch(A){I.fail(A)}else I.done=!0,I.start=()=>{throw new Error("Cursor behind last entry")},I.stop()};return E.onsuccess=Se(A=>{E.onsuccess=H,H()}),I.continue=R,I.continuePrimaryKey=K,I.advance=j,H(),N},m(I)},y)})},count({query:d,trans:p}){const{index:h,range:v}=d;return new Promise((f,m)=>{const y=p.objectStore(c),g=h.isPrimaryKey?y:y.index(h.name),_=r(v),x=_?g.count(_):g.count();x.onsuccess=Se(C=>f(C.target.result)),x.onerror=lt(m)})}}}(l)),a={};return i.forEach(l=>a[l.name]=l),{stack:"dbcore",transaction:t.transaction.bind(t),table(l){if(!a[l])throw new Error(`Table '${l}' not found`);return a[l]},MIN_KEY:-1/0,MAX_KEY:$n(e),schema:o}}function Qo({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(c,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),c)}(th(s,i,l),o.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(o=>{const s=o.name;t.core.schema.tables.some(i=>i.name===s)&&(o.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=o.core))})}function Mr({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Ts(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?_t(i,o,{get(){return this.table(o)},set(l){Mi(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function es({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function nh(t,e){return t._cfg.version-e._cfg.version}function rh(t,e,n,r){const o=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,o);s.create(n),s._completion.catch(r);const i=s._reject.bind(s),a=ae.transless||ae;Pt(()=>{ae.trans=s,ae.transless=a,e===0?(Ne(o).forEach(l=>{xo(n,l,o[l].primKey,o[l].indexes)}),Qo(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},u,c,d){const p=[],h=l._versions;let v=l._dbSchema=ns(l,l.idbdb,d),f=!1;const m=h.filter(g=>g._cfg.version>=u);function y(){return p.length?oe.resolve(p.shift()(c.idbtrans)).then(y):oe.resolve()}return m.forEach(g=>{p.push(()=>{const _=v,x=g._cfg.dbschema;rs(l,_,d),rs(l,x,d),v=l._dbSchema=x;const C=ul(_,x);C.add.forEach(E=>{xo(d,E[0],E[1].primKey,E[1].indexes)}),C.change.forEach(E=>{if(E.recreate)throw new ce.Upgrade("Not yet support for changing primary key");{const F=d.objectStore(E.name);E.add.forEach(I=>ts(F,I)),E.change.forEach(I=>{F.deleteIndex(I.name),ts(F,I)}),E.del.forEach(I=>F.deleteIndex(I))}});const D=g._cfg.contentUpgrade;if(D&&g._cfg.version>u){Qo(l,d),c._memoizedTables={},f=!0;let E=Wi(x);C.del.forEach(K=>{E[K]=_[K]}),es(l,[l.Transaction.prototype]),Mr(l,[l.Transaction.prototype],Ne(E),E),c.schema=E;const F=Ms(D);let I;F&&bn();const R=oe.follow(()=>{if(I=D(c),I&&F){var K=Et.bind(null,null);I.then(K,K)}});return I&&typeof I.then=="function"?oe.resolve(I):R.then(()=>I)}}),p.push(_=>{(!f||!Hf)&&function(x,C){[].slice.call(C.db.objectStoreNames).forEach(D=>x[D]==null&&C.db.deleteObjectStore(D))}(g._cfg.dbschema,_),es(l,[l.Transaction.prototype]),Mr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),y().then(()=>{var g,_;_=d,Ne(g=v).forEach(x=>{_.db.objectStoreNames.contains(x)||xo(_,x,g[x].primKey,g[x].indexes)})})}(t,e,s,n).catch(i)})}function ul(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const o=t[r],s=e[r];if(o){const i={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||o.primKey.auto!==s.primKey.auto&&!so)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let u;for(u in a)l[u]||i.del.push(u);for(u in l){const c=a[u],d=l[u];c?c.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&n.change.push(i)}}else n.add.push([r,s])}return n}function xo(t,e,n,r){const o=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>ts(o,s)),o}function ts(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function ns(t,e,n){const r={};return Pr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=Yo(ll(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let c=0;c{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return Yo(l,u||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),ze(u),a===0)}),s=o.shift();if(s.multi)throw new ce.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new ce.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new ce.Schema("Index must have a name and cannot be an empty string")}),n[r]=cl(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Ue(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(i=>{Ue(o,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(o,s)}),n._dbSchema=s,es(n,[n._allTables,n,n.Transaction.prototype]),Mr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ne(s),s),n._storeNames=Ne(s),this}upgrade(e){return this._cfg.contentUpgrade=Ls(this._cfg.contentUpgrade||xe,e),this}}function $s(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Vt(ao,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Vs(t){return t&&typeof t.databases=="function"}function os(t){return Pt(function(){return ae.letThrough=!0,t()})}function sh(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function ah(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Fe(e.dbOpenError):t);ft&&(e.openCanceller._stackHolder=Yt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new ce.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():sh()).then(()=>new oe((l,u)=>{if(o(),!n)throw new ce.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new ce.MissingAPI;d.onerror=lt(u),d.onblocked=Se(t._fireOnBlocked),d.onupgradeneeded=Se(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Un,i.abort(),d.result.close();const v=n.deleteDatabase(c);v.onsuccess=v.onerror=Se(()=>{u(new ce.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{i.onerror=lt(u);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,rh(t,h/10,i,u)}},u),d.onsuccess=Se(()=>{i=null;const p=t._novip.idbdb=d.result,h=Pr(p.objectStoreNames);if(h.length>0)try{const f=p.transaction((v=h).length===1?v[0]:v,"readonly");e.autoSchema?function({_novip:m},y,g){m.verno=y.version/10;const _=m._dbSchema=ns(0,y,g);m._storeNames=Pr(y.objectStoreNames,0),Mr(m,[m._allTables],Ne(_),_)}(t,p,f):(rs(t,t._dbSchema,f),function(m,y){const g=ul(ns(0,m.idbdb,y),m._dbSchema);return!(g.add.length||g.change.some(_=>_.add.length||_.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Qo(t,f)}catch{}var v;Fn.push(t),p.onversionchange=Se(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),p.onclose=Se(f=>{t.on("close").fire(f)}),a&&function({indexedDB:f,IDBKeyRange:m},y){!Vs(f)&&y!==ao&&$s(f,m).put({name:y}).catch(xe)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(os(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(Ls,xe);return e.onReadyBeingFired=[],oe.resolve(os(()=>u(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{i&&i.abort()}catch{}return r===e.openCanceller&&t._close(),Fe(l)}).finally(()=>{e.openComplete=!0,s()})}function ss(t){var e=s=>t.next(s),n=o(e),r=o(s=>t.throw(s));function o(s){return i=>{var a=s(i),l=a.value;return a.done?l:l&&typeof l.then=="function"?l.then(n,r):ze(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function ih(t,e,n){var r=arguments.length;if(r<2)throw new ce.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Ui(o),n]}function dl(t,e,n,r,o){return oe.resolve().then(()=>{const s=ae.transless||ae,i=t._createTransaction(e,n,t._dbSchema,r),a={trans:i,transless:s};if(r)i.idbtrans=r.idbtrans;else try{i.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===zs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>dl(t,e,n,null,o))):Fe(d)}const l=Ms(o);let u;l&&bn();const c=oe.follow(()=>{if(u=o.call(i,i),u)if(l){var d=Et.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=ss(u))},a);return(u&&typeof u.then=="function"?oe.resolve(u).then(d=>i.active?d:Fe(new ce.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>u)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Fe(d)))})}function dr(t,e,n){const r=ze(t)?t.slice():[t];for(let o=0;o0,y={...p,isVirtual:m,keyTail:d,keyLength:f,extractKey:Xo(c),unique:!m&&p.unique};return v.push(y),y.isPrimaryKey||s.push(y),f>1&&i(f===2?c[0]:c.slice(0,f-1),d+1,p),v.sort((g,_)=>g.keyTail-_.keyTail),y}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const c of r.indexes)i(c.keyPath,0,c);function l(c){const d=c.query.index;return d.isVirtual?{...c,query:{index:d,range:(p=c.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:dr(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:dr(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:c;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(c){const d=o[Tn(c)];return d&&d[0]}},count:c=>n.count(l(c)),query:c=>n.query(l(c)),openCursor(c){const{keyTail:d,isVirtual:p,keyLength:h}=c.query.index;return p?n.openCursor(l(c)).then(v=>v&&function(f){return Object.create(f,{continue:{value:function(y){y!=null?f.continue(dr(y,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?f.continue(f.key.slice(0,h).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(y,g){f.continuePrimaryKey(dr(y,t.MAX_KEY,d),g)}},primaryKey:{get:()=>f.primaryKey},key:{get(){const y=f.key;return h===1?y[0]:y.slice(0,h)}},value:{get:()=>f.value}})}(v)):n.openCursor(c)}}}}}};function Hs(t,e,n,r){return n=n||{},r=r||"",Ne(t).forEach(o=>{if(Je(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Bo(s);a!==Bo(i)?n[r+o]=e[o]:a==="Object"?Hs(s,i,n,r+o+"."):s!==i&&(n[r+o]=e[o])}else s!==i&&(n[r+o]=e[o])}else n[r+o]=void 0}),Ne(e).forEach(o=>{Je(t,o)||(n[r+o]=e[o])}),n}const ch={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=ae.trans,{deleting:a,creating:l,updating:u}=i.table(e).hook;switch(s.type){case"add":if(l.fire===xe)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===xe&&u.fire===xe)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(a.fire===xe)break;return i._promise("readwrite",()=>c(s),!0);case"deleteRange":if(a.fire===xe)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function c(p){const h=ae.trans,v=p.keys||function(f,m){return m.type==="delete"?m.keys:m.keys||m.values.map(f.extractKey)}(r,p);if(!v)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:v}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(f,m,y){return m.type==="add"?Promise.resolve([]):f.getMany({trans:m.trans,keys:y,cache:"immutable"})}(n,p,v).then(f=>{const m=v.map((y,g)=>{const _=f[g],x={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(x,y,_,h);else if(p.type==="add"||_===void 0){const C=l.fire.call(x,y,p.values[g],h);y==null&&C!=null&&(y=C,p.keys[g]=y,r.outbound||st(p.values[g],r.keyPath,y))}else{const C=Hs(_,p.values[g]),D=u.fire.call(x,C,y,_,h);if(D){const E=p.values[g];Object.keys(D).forEach(F=>{Je(E,F)?E[F]=D[F]:st(E,F,D[F])})}}return x});return n.mutate(p).then(({failures:y,results:g,numFailures:_,lastResult:x})=>{for(let C=0;C(m.forEach(g=>g.onerror&&g.onerror(y)),Promise.reject(y)))})}function d(p,h,v){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:v}).then(({result:f})=>c({type:"delete",keys:f,trans:p}).then(m=>m.numFailures>0?Promise.reject(m.failures[0]):f.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=fl(r.keys,r.trans._cache,r.cache==="clone");return o?oe.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?Jn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function qs(t){return!("from"in t)}const yt=function(t,e){if(!this){const n=new yt;return t&&"d"in t&&Ue(n,t),n}Ue(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Vn(t,e,n){const r=We(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(qs(t))return Ue(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(We(n,t.from)<0)return o?Vn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},Ia(t);if(We(e,t.to)>0)return s?Vn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},Ia(t);We(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),We(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const i=!t.r;o&&!t.l&&Br(t,o),s&&i&&Br(t,s)}function Br(t,e){qs(e)||function n(r,{from:o,to:s,l:i,r:a}){Vn(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function dh(t,e){const n=as(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=as(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(We(a.from,o.to)<=0&&We(a.to,o.from)>=0)return!0;We(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function as(t){let e=qs(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&We(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||We(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Ia(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const s=o==="r"?"l":"r",i={...t},a=t[o];t.from=a.from,t.to=a.to,t[o]=a[o],i[o]=a[s],t[s]=i,i.d=Oa(i)}t.d=Oa(t)}function Oa({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}mn(yt.prototype,{add(t){return Br(this,t),this},addKey(t){return Vn(this,t,t),this},addKeys(t){return t.forEach(e=>Vn(this,e,e)),this},[zo](){return as(this)}});const fh={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new yt(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:i}=s,{extractKey:a,outbound:l}=i,u={...o,mutate:p=>{const h=p.trans,v=h.mutatedParts||(h.mutatedParts={}),f=D=>{const E=`idb://${e}/${r}/${D}`;return v[E]||(v[E]=new yt)},m=f(""),y=f(":dels"),{type:g}=p;let[_,x]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const C=p.trans._cache;return o.mutate(p).then(D=>{if(ze(_)){g!=="delete"&&(_=D.results),m.addKeys(_);const E=fl(_,C);E||g==="add"||y.addKeys(_),(E||x)&&function(F,I,R,K){function j(M){const b=F(M.name||"");function N(A){return A!=null?M.extractKey(A):null}const H=A=>M.multiEntry&&ze(A)?A.forEach(X=>b.addKey(X)):b.addKey(A);(R||K).forEach((A,X)=>{const V=R&&N(R[X]),te=K&&N(K[X]);We(V,te)!==0&&(V!=null&&H(V),te!=null&&H(te))})}I.indexes.forEach(j)}(f,s,E,x)}else if(_){const E={from:_.lower,to:_.upper};y.add(E),m.add(E)}else m.add(n),y.add(n),s.indexes.forEach(E=>f(E.name).add(n));return D})}},c=({query:{index:p,range:h}})=>{var v,f;return[p,new yt((v=h.lower)!==null&&v!==void 0?v:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new yt(p.key)],getMany:p=>[i,new yt().addKeys(p.keys)],count:c,query:c,openCursor:c};return Ne(d).forEach(p=>{u[p]=function(h){const{subscr:v}=ae;if(v){const f=x=>{const C=`idb://${e}/${r}/${x}`;return v[C]||(v[C]=new yt)},m=f(""),y=f(":dels"),[g,_]=d[p](h);if(f(g.name||"").add(_),!g.isPrimaryKey){if(p!=="count"){const x=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(C=>{if(p==="query"){if(l&&h.values)return x.then(({result:E})=>(m.addKeys(E),C));const D=h.values?C.result.map(a):C.result;h.values?m.addKeys(D):y.addKeys(D)}else if(p==="openCursor"){const D=C,E=h.values;return D&&Object.create(D,{key:{get:()=>(y.addKey(D.primaryKey),D.key)},primaryKey:{get(){const F=D.primaryKey;return y.addKey(F),F}},value:{get:()=>(E&&m.addKey(D.primaryKey),D.value)}})}return C})}y.add(n)}}return o[p].apply(this,arguments)}}),u}}}};class Vt{constructor(e,n){this._middlewares={},this.verno=0;const r=Vt.dependencies;this._options=n={addons:Vt.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:xe,dbReadyPromise:null,cancelOpen:xe,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new oe(a=>{s.dbReadyResolve=a}),s.openCanceller=new oe((a,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=Rn(this,"populate","blocked","versionchange","close",{ready:[Ls,xe]}),this.on.ready.subscribe=Bi(this.on.ready.subscribe,a=>(l,u)=>{Vt.vip(()=>{const c=this._state;if(c.openComplete)c.dbOpenError||oe.resolve().then(l),u&&a(l);else if(c.onReadyBeingFired)c.onReadyBeingFired.push(l),u&&a(l);else{a(l);const d=this;u||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,Sn(Zf.prototype,function(a,l){this.db=i;let u=sl,c=null;if(l)try{u=l()}catch(v){c=v}const d=a._ctx,p=d.table,h=p.hook.reading.fire;this._ctx={table:p,index:d.index,isPrimKey:!d.index||p.schema.primKey.keyPath&&d.index===p.schema.primKey.name,range:u,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:c,or:d.or,valueMapper:h!==Ln?h:null}})),this.Table=function(a){return Sn(Gf.prototype,function(l,u,c){this.db=a,this._tx=c,this.name=l,this.schema=u,this.hook=a._allTables[l]?a._allTables[l].hook:Rn(null,{creating:[Tf,xe],reading:[Rf,Ln],updating:[Bf,xe],deleting:[Mf,xe]})})}(this),this.Transaction=function(a){return Sn(Qf.prototype,function(l,u,c,d,p){this.db=a,this.mode=l,this.storeNames=u,this.schema=c,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Rn(this,"complete","error","abort"),this.parent=p||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new oe((h,v)=>{this._resolve=h,this._reject=v}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var v=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):v&&this.idbtrans&&this.idbtrans.abort(),Fe(h)})})}(this),this.Version=function(a){return Sn(oh.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return Sn(il.prototype,function(l,u,c){this.db=a,this._ctx={table:l,index:u===":id"?null:u,or:c};const d=a._deps.indexedDB;if(!d)throw new ce.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,h)=>d.cmp(h,p),this._max=(p,h)=>d.cmp(p,h)>0?p:h,this._min=(p,h)=>d.cmp(p,h)<0?p:h,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersionnew this.Transaction(a,l,u,this._options.chromeTransactionDurability,c),this._fireOnBlocked=a=>{this.on("blocked").fire(a),Fn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(lh),this.use(ch),this.use(fh),this.use(uh),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new ce.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ce.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(o=>o._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(nh),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ae.letThrough||this._vip)?e():new oe((n,r)=>{if(this._state.openComplete)return r(new ce.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new ce.DatabaseClosed);this.open().catch(xe)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:o}){o&&this.unuse({stack:e,name:o});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:n,level:r??10,name:o}),s.sort((i,a)=>i.level-a.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(o=>r?o.create!==r:!!n&&o.name!==n)),this}open(){return ah(this)}_close(){const e=this._state,n=Fn.indexOf(this);if(n>=0&&Fn.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new oe(r=>{e.dbReadyResolve=r}),e.openCanceller=new oe((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ce.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new oe((r,o)=>{const s=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Se(()=>{(function({indexedDB:a,IDBKeyRange:l},u){!Vs(a)&&u!==ao&&$s(a,l).delete(u).catch(xe)})(this._deps,this.name),r()}),i.onerror=lt(o),i.onblocked=this._fireOnBlocked};if(e)throw new ce.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Ne(this._allTables).map(e=>this._allTables[e])}transaction(){const e=ih.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=ae.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const s=e.indexOf("?")!==-1;let i,a;e=e.replace("!","").replace("?","");try{if(a=n.map(u=>{var c=u instanceof this.Table?u.name:u;if(typeof c!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return c}),e=="r"||e===vo)i=vo;else{if(e!="rw"&&e!=go)throw new ce.InvalidArgument("Invalid transaction mode: "+e);i=go}if(o){if(o.mode===vo&&i===go){if(!s)throw new ce.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(u=>{if(o&&o.storeNames.indexOf(u)===-1){if(!s)throw new ce.SubTransaction("Table "+u+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(u){return o?o._promise(null,(c,d)=>{d(u)}):Fe(u)}const l=dl.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ae.trans?_n(ae.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Je(this._allTables,e))throw new ce.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const hh=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class ph{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[hh](){return this}}function hl(t,e){return Ne(e).forEach(n=>{Br(t[n]||(t[n]=new yt),e[n])}),t}function mh(t){let e,n=!1;const r=new ph(o=>{const s=Ms(t);let i=!1,a={},l={};const u={get closed(){return i},unsubscribe:()=>{i=!0,Nt.storagemutated.unsubscribe(h)}};o.start&&o.start(u);let c=!1,d=!1;function p(){return Ne(l).some(f=>a[f]&&dh(a[f],l[f]))}const h=f=>{hl(a,f),p()&&v()},v=()=>{if(c||i)return;a={};const f={},m=function(y){s&&bn();const g=()=>Pt(t,{subscr:y,trans:null}),_=ae.trans?_n(ae.transless,g):g();return s&&_.then(Et,Et),_}(f);d||(Nt(Kn,h),d=!0),c=!0,Promise.resolve(m).then(y=>{n=!0,e=y,c=!1,i||(p()?v():(a={},l=f,o.next&&o.next(y)))},y=>{c=!1,n=!1,o.error&&o.error(y),u.unsubscribe()})};return v(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let is;try{is={indexedDB:Ce.indexedDB||Ce.mozIndexedDB||Ce.webkitIndexedDB||Ce.msIndexedDB,IDBKeyRange:Ce.IDBKeyRange||Ce.webkitIDBKeyRange}}catch{is={indexedDB:null,IDBKeyRange:null}}const Bt=Vt;function _r(t){let e=gt;try{gt=!0,Nt.storagemutated.fire(t)}finally{gt=e}}mn(Bt,{...mr,delete:t=>new Bt(t,{addons:[]}).delete(),exists:t=>new Bt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Vs(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==ao)):$s(e,n).toCollection().primaryKeys()}(Bt.dependencies).then(t)}catch{return Fe(new ce.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ae.trans?_n(ae.transless,t):t(),vip:os,async:function(t){return function(){try{var e=ss(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Fe(n)}}},spawn:function(t,e,n){try{var r=ss(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Fe(o)}},currentTransaction:{get:()=>ae.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Bt.ignoreTransaction(t):t).timeout(e||6e4);return ae.trans?ae.trans.waitFor(n):n},Promise:oe,debug:{get:()=>ft,set:t=>{$i(t,t==="dexie"?()=>!0:ol)}},derive:an,extend:Ue,props:mn,override:Bi,Events:Rn,on:Nt,liveQuery:mh,extendObservabilitySet:hl,getByKeyPath:xt,setByKeyPath:st,delByKeyPath:function(t,e){typeof e=="string"?st(t,e,void 0):"length"in e&&[].map.call(e,function(n){st(t,n,void 0)})},shallowClone:Wi,deepClone:Jn,getObjectDiff:Hs,cmp:We,asap:zi,minKey:Jo,addons:[],connections:Fn,errnames:zs,dependencies:is,semVer:_a,version:_a.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Bt.maxKey=$n(Bt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Nt(Kn,t=>{if(!gt){let e;so?(e=document.createEvent("CustomEvent"),e.initCustomEvent(Ot,!0,!0,t)):e=new CustomEvent(Ot,{detail:t}),gt=!0,dispatchEvent(e),gt=!1}}),addEventListener(Ot,({detail:t})=>{gt||_r(t)}));let gt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(Ot);typeof t.unref=="function"&&t.unref(),Nt(Kn,e=>{gt||t.postMessage(e)}),t.onmessage=e=>{e.data&&_r(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Nt(Kn,e=>{try{gt||(typeof localStorage<"u"&&localStorage.setItem(Ot,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Ot,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===Ot){const n=JSON.parse(e.newValue);n&&_r(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===Ot&&_r(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof ln||t instanceof TypeError||t instanceof SyntaxError||!t.name||!va[t.name])return t;var n=new va[t.name](e||t.message,t);return"stack"in t&&_t(n,"stack",{get:function(){return this.inner.stack}}),n},$i(ft,ol);var yh=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t.openSpotlightSearch="openSpotlightSearch",t))(yh||{}),xr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(xr||{});const vh="comfyui_workspace_db";class gh extends Vt{constructor(){super(vh);Ie(this,"workflows");Ie(this,"changelogs");Ie(this,"media");Ie(this,"folders");Ie(this,"tags");Ie(this,"userSettings");Ie(this,"models");Ie(this,"cache");Ie(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const ie=new gh,wh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ls=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=wh[n[t]&63];return e};class Xt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ie[this.tableName].toArray(),n={};e.forEach(r=>{r.id?n[r.id]=r:r.name?n[r.name]=r:console.error("TableBaseModel should have id or name")});try{vf(this.tableName,JSON.stringify(n))}catch(r){console.error("error saving disk db",r)}}async add(e){return e.id||(e.id=ls()),e.createTime||(e.createTime=Date.now()),await ie[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ie[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ie[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ie[this.tableName].update(e,n),this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ie[this.tableName].toArray()}async filter(e){return await ie[this.tableName].filter(e).toArray()}async batchQuery(e){return await ie[this.tableName].bulkGet(e)}async getRecords(){console.warn("[DEPRECATED] getRecords() call, should only be used for one-time backfill for indexdb",this.tableName);const e=await yf(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Ef()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ie[this.tableName].get(e)}async delete(e){await ie[this.tableName].delete(e),this.saveDiskDB()}async listByIndex(e,n){return await ie[this.tableName].where(e).equals(n).toArray()}}const bh=80,Lr=class Lr extends Xt{constructor(){super("changelogs")}static async load(){return new Lr}async listByWorkflowID(e){return await ie.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime")}async getLastestByWorkflowID(e){return(await this.listByWorkflowID(e))[0]}async create(e){const n=await this.getLastestByWorkflowID(e.workflowID);if(n!=null&&n.json===e.json)return null;const r={id:Dr(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return await this.deleteLogsExceedLimit(e.workflowID),await ie.changelogs.add(r),r}async deleteLogsExceedLimit(e){var o;const n=await ie.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=((o=G==null?void 0:G.settings)==null?void 0:o.maximumChangelogNumber)??bh;if(n.length>r){const s=n.slice(r);await ie.changelogs.bulkDelete(s.map(i=>i.id))}}};Ie(Lr,"TABLE_NAME","changelogs");let cs=Lr;const rm="CWM_WORKFLOWS_SORT_TYPE";var ct=(t=>(t.RECENTLY_OPENED="recentlyOpened",t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(ct||{});const om=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],_h="comfyspace_tracking",qe="workspace_info",xh=9999999,ko="upgrade_to_2way_sync",us=28,sm="SHORTCUT_TRIGGER_EVENT";function kr(...t){const e=t.filter(n=>n!=="").join("/");return Ft(e)}function Ft(t){let n=t.split("/").filter(r=>r!=="").join("/").replace(/\\/g,"/");return n=n.replace(/^\/+/,""),n}function Eo(t){return kr(t.parentFolderID??"",t.name+".json")}var Dt;(t=>{async function e({parentFolderID:a,name:l}){return Ft(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await fetch("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Ft(a.id)})})}t.createFolder=n;async function r(a,l){const c=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();c.error&&alert("Failed to move folder: "+c.error)}t.moveFolder=r;async function o(a){try{return await(await fetch("/workspace/folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).text()}catch(l){console.error("Error deleting file:",l)}}t.deleteFolder=o;async function s(a){try{const u=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return u.error&&console.error("Error counting files:",u.error),u.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const c=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();c.error&&alert("Failed to rename folder: "+c.error)}catch(u){console.error("Error renaming file:",u)}}t.renameFolder=i})(Dt||(Dt={}));async function Dn(t){const e=await Gs(t);if(e==null)return;const n=await pl(t);await($==null?void 0:$.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[qe]={id:t.id,name:t.name},delete o.extra[_h],await gf(e,JSON.stringify(o))}async function Co(t){if(t.name==null)return;const e=await Gs(t);e!=null&&Ti(e)}async function Gs(t){let e=Eh(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(Le==null?void 0:Le.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function kh(t){let e="",n=t;for(;n!=null;){const r=await(Le==null?void 0:Le.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function pl(t){const e=await Gs(t);let n=await(G==null?void 0:G.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function am(t){if(await(G==null?void 0:G.getSetting("twoWaySync")))return await Dt.genFilesCountInFolder(t)??0;const n=await($==null?void 0:$.listAll())??[],r=await(Le==null?void 0:Le.listAll())??[],o=[t];let s=0;for(;o.length>0;){const i=o.shift();if(i){for(const l of n)l.parentFolderID===i&&s++;const a=r.filter(l=>l.parentFolderID===i).map(l=>l.id);a.length&&o.push(...a)}}return s}function Eh(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function ml(t,e=!0,n=!1){const r=new Date(t),o=String(r.getDate()).padStart(2,"0"),s=String(r.getMonth()+1).padStart(2,"0"),i=r.getFullYear(),a=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),u=String(r.getSeconds()).padStart(2,"0"),c=`${s}-${o}-${i}`;return e?c+` ${a}:${l}`:n?c+`:${u}`:c}async function Ch(t=!1){if(await(G==null?void 0:G.getSetting("twoWaySync")))return;const n=await($==null?void 0:$.listAll())??[];for(const r of n){const o=await pl(r);r.filePath!=o&&(r.filePath!=null&&await Ti(r.filePath,t),await Dn(r))}}const Er=(t,e=ct.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case ct.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case ct.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case ct.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case ct.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break;case ct.RECENTLY_OPENED:n.sort((r,o)=>(o.lastOpenedTime??0)-(r.lastOpenedTime??0));break}return n};function Sh(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{var n;const e=(n=G==null?void 0:G.settings)==null?void 0:n.shortcuts;if(!e)return!1;for(const r in e){const s=e[r].split("+"),i={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const a in i)i[a]||delete i[a];if(s.length===Object.keys(i).length&&s.every(a=>i[a]))return r}};function cm(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function Ih(t){return`/workspace/view_media?filename=${t}`}function Da(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function yl(t){const e=window.location.hash.slice(1).split("/"),n=e.findIndex(o=>o.includes("workspaceId@")),r=`workspaceId@${t}`;return n>=0?e[n]=r:e.push(r),`${e.join("/")}`}const Oh=t=>{const e=yl(t);window.open(`${window.location.origin}/#${e}`)},Cr={last_node_id:9,last_link_id:9,nodes:[{id:7,type:"CLIPTextEncode",pos:[413,389],size:{0:425.27801513671875,1:180.6060791015625},flags:{},order:3,mode:0,inputs:[{name:"clip",type:"CLIP",link:5}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[6],slot_index:0}],properties:{},widgets_values:["text, watermark"]},{id:6,type:"CLIPTextEncode",pos:[415,186],size:{0:422.84503173828125,1:164.31304931640625},flags:{},order:2,mode:0,inputs:[{name:"clip",type:"CLIP",link:3}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[4],slot_index:0}],properties:{},widgets_values:["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{id:5,type:"EmptyLatentImage",pos:[473,609],size:{0:315,1:106},flags:{},order:1,mode:0,outputs:[{name:"LATENT",type:"LATENT",links:[2],slot_index:0}],properties:{},widgets_values:[512,512,1]},{id:3,type:"KSampler",pos:[863,186],size:{0:315,1:262},flags:{},order:4,mode:0,inputs:[{name:"model",type:"MODEL",link:1},{name:"positive",type:"CONDITIONING",link:4},{name:"negative",type:"CONDITIONING",link:6},{name:"latent_image",type:"LATENT",link:2}],outputs:[{name:"LATENT",type:"LATENT",links:[7],slot_index:0}],properties:{},widgets_values:[0x8e7ff42ed37e,!0,20,8,"euler","normal",1]},{id:8,type:"VAEDecode",pos:[1209,188],size:{0:210,1:46},flags:{},order:5,mode:0,inputs:[{name:"samples",type:"LATENT",link:7},{name:"vae",type:"VAE",link:8}],outputs:[{name:"IMAGE",type:"IMAGE",links:[9],slot_index:0}],properties:{}},{id:9,type:"SaveImage",pos:[1451,189],size:{0:210,1:26},flags:{},order:6,mode:0,inputs:[{name:"images",type:"IMAGE",link:9}],properties:{}},{id:4,type:"CheckpointLoaderSimple",pos:[26,474],size:{0:315,1:98},flags:{},order:0,mode:0,outputs:[{name:"MODEL",type:"MODEL",links:[1],slot_index:0},{name:"CLIP",type:"CLIP",links:[3,5],slot_index:1},{name:"VAE",type:"VAE",links:[8],slot_index:2}],properties:{},widgets_values:["v1-5-pruned-emaonly.ckpt"]}],links:[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],groups:[],config:{},extra:{},version:.4};var Qe;(t=>{async function e(l,u){try{const d=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Eo(l),newParentPath:u})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(c){console.error("Error deleting file:",c)}}t.moveWorkflow=e;async function n(l,u){try{const d=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:kr(u??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(c){console.error("Error deleting file:",c)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:u},c){try{const p=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:kr(l??"",u+".json"),newName:c})})).json();return p.error?(alert("Error rename file: "+p.error),!1):!0}catch(d){console.error("Error deleting file:",d)}}t.renameWorkflow=r;async function o(l){const u=l.json,c=JSON.parse(u);c.extra[qe]==null&&(c.extra[qe]={}),c.extra[qe].id=l.id;const p=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Eo(l),json:JSON.stringify(c)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} + `+s:""}`,this.inner=s||null):typeof o=="object"&&(this.message=`${o.name} ${o.message}`,this.inner=o):(this.message=Nf[e]||n,this.inner=null)}return an(r).from(Ff),t[e]=r,t},{});ce.Syntax=SyntaxError,ce.Type=TypeError,ce.Range=RangeError;var va=Hi.reduce((t,e)=>(t[e+"Error"]=ce[e],t),{}),mr=Bs.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=ce[e]),t),{});function xe(){}function Ln(t){return t}function Rf(t,e){return t==null||t===Ln?e:function(n){return e(t(n))}}function Zt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Tf(t,e){return t===xe?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Zt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Zt(o,this.onerror):o),s!==void 0?s:n}}function Mf(t,e){return t===xe?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Zt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Zt(r,this.onerror):r)}}function Bf(t,e){return t===xe?e:function(n){var r=t.apply(this,arguments);Ue(n,r);var o=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?Zt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Zt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:Ue(r,i)}}function zf(t,e){return t===xe?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ls(t,e){return t===xe?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,o=arguments.length,s=new Array(o);o--;)s[o]=arguments[o];return n.then(function(){return e.apply(r,s)})}return e.apply(this,arguments)}}mr.ModifyError=Ar,mr.DexieError=ln,mr.BulkError=An;var Wn={};const Gi=100,[Wo,Nr,Uo]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,zn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,zn(e),t]})(),Zi=Nr&&Nr.then,yr=Wo&&Wo.constructor,Ws=!!Uo;var Ko=!1,Lf=Uo?()=>{Uo.then(sr)}:Ce.setImmediate?setImmediate.bind(null,sr):Ce.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{sr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(sr,0)},Nn=function(t,e){On.push([t,e]),Fr&&(Lf(),Fr=!1)},$o=!0,Fr=!0,Kt=[],vr=[],Vo=null,Ho=Ln,cn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ba,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{ba(t[0],t[1])}catch{}})}},ae=cn,On=[],$t=0,gr=[];function oe(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=xe,this._lib=!1;var e=this._PSD=ae;if(ft&&(this._stackHolder=Yt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Wn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Go(this,this._value))}this._state=null,this._value=null,++e.ref,Yi(this,t)}const qo={get:function(){var t=ae,e=Rr;function n(r,o){var s=!t.global&&(t!==ae||e!==Rr);const i=s&&!Et();var a=new oe((l,c)=>{Us(this,new Ji(Tr(r,t,s,i),Tr(o,t,s,i),l,c,t))});return ft&&el(a,this),a}return n.prototype=Wn,n},set:function(t){_t(this,"then",t&&t.prototype===Wn?qo:{get:function(){return t},set:qo.set})}};function Ji(t,e,n,r,o){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=o}function Yi(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Yn();n&&typeof n.then=="function"?Yi(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,Xi(t)),r&&Xn()}},Go.bind(null,t))}catch(n){Go(t,n)}}function Go(t,e){if(vr.push(e),t._state===null){var n=t._lib&&Yn();e=Ho(e),t._state=!1,t._value=e,ft&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Ts(e,"stack");e._promise=t,_t(e,"stack",{get:()=>Ko?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Kt.some(o=>o._value===r._value)||Kt.push(r)}(t),Xi(t),n&&Xn()}}function Xi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--$t==0&&Ks()},[]))}function Us(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++$t,Nn(Wf,[n,t,e])}else t._listeners.push(e)}function Wf(t,e,n){try{Vo=e;var r,o=e._value;e._state?r=t(o):(vr.length&&(vr=[]),r=t(o),vr.indexOf(o)===-1&&function(s){for(var i=Kt.length;i;)if(Kt[--i]._value===s._value)return void Kt.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Vo=null,--$t==0&&Ks(),--n.psd.ref||n.psd.finalize()}}function Qi(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var o,s,i=t._value;i!=null?(o=i.name||"Error",s=i.message||i,r=Lo(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return ft&&((r=Lo(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Qi(t._prev,e,n)),e}function el(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function sr(){Yn()&&Xn()}function Yn(){var t=$o;return $o=!1,Fr=!1,t}function Xn(){var t,e,n;do for(;On.length>0;)for(t=On,On=[],n=t.length,e=0;e0);$o=!0,Fr=!0}function Ks(){var t=Kt;Kt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=gr.slice(0),n=e.length;n;)e[--n]()}function ar(t){return new oe(Wn,!1,t)}function Se(t,e){var n=ae;return function(){var r=Yn(),o=ae;try{return At(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{At(o,!1),r&&Xn()}}}mn(oe.prototype,{then:qo,_then:function(t,e){Us(this,new Ji(null,null,t,e,ae))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):ar(r)):this.then(null,r=>r&&r.name===e?n(r):ar(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),ar(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Ko=!0;var t=Qi(this,[],20).join(` +From previous: `);return this._state!==null&&(this._stack=t),t}finally{Ko=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new ce.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&_t(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),cn.env=tl(),mn(oe,{all:function(){var t=vt.apply(null,arguments).map(ir);return new oe(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>oe.resolve(o).then(i=>{t[s]=i,--r||e(t)},n))})},resolve:t=>{if(t instanceof oe)return t;if(t&&typeof t.then=="function")return new oe((n,r)=>{t.then(n,r)});var e=new oe(Wn,!0,t);return el(e,Vo),e},reject:ar,race:function(){var t=vt.apply(null,arguments).map(ir);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ae,set:t=>ae=t},totalEchoes:{get:()=>Rr},newPSD:Pt,usePSD:_n,scheduler:{get:()=>Nn,set:t=>{Nn=t}},rejectionMapper:{get:()=>Ho,set:t=>{Ho=t}},follow:(t,e)=>new oe((n,r)=>Pt((o,s)=>{var i=ae;i.unhandleds=[],i.onunhandled=s,i.finalize=Zt(function(){(function(a){function l(){a(),gr.splice(gr.indexOf(l),1)}gr.push(l),++$t,Nn(()=>{--$t==0&&Ks()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),yr&&(yr.allSettled&&_t(oe,"allSettled",function(){const t=vt.apply(null,arguments).map(ir);return new oe(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>oe.resolve(o).then(i=>r[s]={status:"fulfilled",value:i},i=>r[s]={status:"rejected",reason:i}).then(()=>--n||e(r)))})}),yr.any&&typeof AggregateError<"u"&&_t(oe,"any",function(){const t=vt.apply(null,arguments).map(ir);return new oe((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,i)=>oe.resolve(s).then(a=>e(a),a=>{o[i]=a,--r||n(new AggregateError(o))}))})}));const Be={awaits:0,echoes:0,id:0};var Uf=0,wr=[],yo=0,Rr=0,Kf=0;function Pt(t,e,n,r){var o=ae,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Kf;var i=cn.env;s.env=Ws?{Promise:oe,PromiseProp:{value:oe,configurable:!0,writable:!0},all:oe.all,race:oe.race,allSettled:oe.allSettled,any:oe.any,resolve:oe.resolve,reject:oe.reject,nthen:ga(i.nthen,s),gthen:ga(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=_n(s,t,n,r);return s.ref===0&&s.finalize(),a}function bn(){return Be.id||(Be.id=++Uf),++Be.awaits,Be.echoes+=Gi,Be.id}function Et(){return!!Be.awaits&&(--Be.awaits==0&&(Be.id=0),Be.echoes=Be.awaits*Gi,!0)}function ir(t){return Be.echoes&&t&&t.constructor===yr?(bn(),t.then(e=>(Et(),e),e=>(Et(),Fe(e)))):t}function $f(t){++Rr,Be.echoes&&--Be.echoes!=0||(Be.echoes=Be.id=0),wr.push(ae),At(t,!0)}function Vf(){var t=wr[wr.length-1];wr.pop(),At(t,!1)}function At(t,e){var n=ae;if((e?!Be.echoes||yo++&&t===ae:!yo||--yo&&t===ae)||nl(e?$f.bind(null,t):Vf),t!==ae&&(ae=t,n===cn&&(cn.env=tl()),Ws)){var r=cn.env.Promise,o=t.env;Nr.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ce,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function tl(){var t=Ce.Promise;return Ws?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ce,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:Nr.then,gthen:t.prototype.then}:{}}function _n(t,e,n,r,o){var s=ae;try{return At(t,!0),e(n,r,o)}finally{At(s,!1)}}function nl(t){Zi.call(Wo,t)}function Tr(t,e,n,r){return typeof t!="function"?t:function(){var o=ae;n&&bn(),At(e,!0);try{return t.apply(this,arguments)}finally{At(o,!1),r&&nl(Et)}}}function ga(t,e){return function(n,r){return t.call(this,Tr(n,e),Tr(r,e))}}(""+Zi).indexOf("[native code]")===-1&&(bn=Et=xe);const wa="unhandledrejection";function ba(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ce.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(wa,!0,!0),Ue(r,o)):Ce.CustomEvent&&Ue(r=new CustomEvent(wa,{detail:o}),o),r&&Ce.dispatchEvent&&(dispatchEvent(r),!Ce.PromiseRejectionEvent&&Ce.onunhandledrejection))try{Ce.onunhandledrejection(r)}catch{}ft&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Fe=oe.reject;function Zo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||ae.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===zs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Zo(t,e,n,r))):Fe(s)}return o._promise(e,(s,i)=>Pt(()=>(ae.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Fe(new ce.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Fe(new ce.DatabaseClosed);t.open().catch(xe)}return t._state.dbReadyPromise.then(()=>Zo(t,e,n,r))}const _a="3.2.4",zt="￿",Jo=-1/0,pt="Invalid key provided. Keys must be of type string, number, Date or Array.",rl="String expected.",Fn=[],so=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Hf=so,qf=so,ol=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),ao="__dbnames",vo="readonly",go="readwrite";function Jt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const sl={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lr(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Jn(e))[t],e)}class Gf{_trans(e,n,r){const o=this._tx||ae.trans,s=this.name;function i(l,c,u){if(!u.schema[s])throw new ce.NotFound("Table "+s+" not part of transaction");return n(u.idbtrans,u)}const a=Yn();try{return o&&o.db===this.db?o===ae.trans?o._promise(e,i,r):Pt(()=>o._promise(e,i,r),{trans:o,transless:ae.transless||ae}):Zo(this.db,e,[this.name],i)}finally{a&&Xn()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(o=>this.hook.reading.fire(o))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(ze(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=Ne(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)&&c.keyPath.every(u=>n.indexOf(u)>=0))[0];if(r&&this.db._maxKey!==zt)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&&ft&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,s=this.db._deps.indexedDB;function i(c,u){try{return s.cmp(c,u)===0}catch{return!1}}const[a,l]=n.reduce(([c,u],d)=>{const p=o[d],h=e[d];return[c||p,c||!p?Jt(u,p&&p.multi?v=>{const f=xt(v,d);return ze(f)&&f.some(m=>i(h,m))}:v=>i(h,xt(v,d))):u]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):r?this.filter(l):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,ze(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const o=Object.create(e.prototype);for(var s in r)if(Je(r,s))try{o[s]=r[s]}catch{}return o};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){Ue(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=lr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"add",keys:n!=null?[n]:null,values:[s]})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{st(e,o,i)}catch{}return i})}update(e,n){if(typeof e!="object"||ze(e))return this.where(":id").equals(e).modify(n);{const r=xt(e,this.schema.primKey.keyPath);if(r===void 0)return Fe(new ce.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ne(n).forEach(o=>{st(e,o,n[o])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=lr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"put",values:[s],keys:n!=null?[n]:null})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{st(e,o,i)}catch{}return i})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?oe.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:sl})).then(e=>e.numFailures?oe.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(o=>this.hook.reading.fire(o))))}bulkAdd(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(lr(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:v})=>{if(d===0)return s?p:h;throw new An(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,v)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(lr(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:v})=>{if(d===0)return s?p:h;throw new An(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,v)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:o,failures:s})=>{if(r===0)return o;throw new An(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function Rn(t){var e={},n=function(i,a){if(a){for(var l=arguments.length,c=new Array(l-1);--l;)c[l-1]=arguments[l];return e[i].subscribe.apply(null,c),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rJt(r(),e()):e,t.justLimit=n&&!r}function br(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new ce.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function xa(t,e,n){const r=br(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function cr(t,e,n,r){const o=t.replayFilter?Jt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,c)=>{if(!o||o(l,c,p=>l.stop(p),p=>l.fail(p))){var u=l.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),Je(s,d)||(s[d]=!0,e(a,l,c))}};return Promise.all([t.or._iterate(i,n),ka(xa(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return ka(xa(t,r,n),Jt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ka(t,e,n,r){var o=Se(r?(s,i,a)=>n(r(s),i,a):n);return t.then(s=>{if(s)return s.start(()=>{var i=()=>s.continue();e&&!e(s,a=>i=a,a=>{s.stop(a),i=xe},a=>{s.fail(a),i=xe})||o(s.value,s,a=>i=a),i()})})}function We(t,e){try{const n=Ea(t),r=Ea(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:tcr(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(tn(r,!0))return o.count({trans:n,query:{index:br(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return cr(r,()=>(++s,!1),n,o).then(()=>s)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),o=r[0],s=r.length-1;function i(c,u){return u?i(c[r[u]],u-1):c[o]}var a=this._ctx.dir==="next"?1:-1;function l(c,u){var d=i(c,s),p=i(u,s);return dp?a:0}return this.toArray(function(c){return c.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&tn(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=br(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:s,range:r.range}}).then(({result:i})=>o?i.map(o):i)}{const o=[];return cr(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,tn(n)?bo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):bo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),bo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return wo(this._ctx,function(r,o,s){return!e(r.value)||(o(s),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return wo(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Jt(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.key,o)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.primaryKey,o)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&tn(n,!0)&&n.limit>0)return this._read(o=>{var s=br(n,n.table.core.schema);return n.table.core.query({trans:o,values:!1,limit:n.limit,query:{index:s,range:n.range}})}).then(({result:o})=>o).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return wo(this._ctx,function(o){var s=o.primaryKey.toString(),i=Je(r,s);return r[s]=!0,!i}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var s=Ne(e),i=s.length;o=function(f){for(var m=!1,y=0;y{const{failures:y,numFailures:g}=m;p+=f-g;for(let _ of Ne(y))d.push(y[_])};return this.clone().primaryKeys().then(f=>{const m=y=>{const g=Math.min(u,f.length-y);return a.getMany({trans:r,keys:f.slice(y,y+g),cache:"immutable"}).then(_=>{const x=[],C=[],D=l?[]:null,E=[];for(let I=0;I0&&a.mutate({trans:r,type:"add",values:x}).then(I=>{for(let R in I.failures)E.splice(parseInt(R),1);v(x.length,I)})).then(()=>(C.length>0||F&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:D,values:C,criteria:F,changeSpec:typeof e!="function"&&e}).then(I=>v(C.length,I))).then(()=>(E.length>0||F&&e===_o)&&a.mutate({trans:r,type:"delete",keys:E,criteria:F}).then(I=>v(E.length,I))).then(()=>f.length>y+g&&m(y+u))})};return m(0).then(()=>{if(d.length>0)throw new Ar("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return tn(e)&&(e.isPrimKey&&!qf||n.type===3)?this._write(r=>{const{primaryKey:o}=e.table.core.schema,s=n;return e.table.core.count({trans:r,query:{index:o,range:s}}).then(i=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:a,lastResult:l,results:c,numFailures:u})=>{if(u)throw new Ar("Could not delete some values",Object.keys(a).map(d=>a[d]),i-u);return i-u}))}):this.modify(_o)}}const _o=(t,e)=>e.value=null;function Jf(t,e){return te?-1:t===e?0:1}function He(t,e,n){var r=t instanceof il?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function nn(t){return new t.Collection(t,()=>al("")).limit(0)}function Xf(t,e,n,r,o,s){for(var i=Math.min(t.length,r.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+n.substr(a+1):null;o(t[l],c)<0&&(a=l)}return itypeof f=="string"))return He(t,rl);function p(f){o=function(y){return y==="next"?g=>g.toUpperCase():g=>g.toLowerCase()}(f),s=function(y){return y==="next"?g=>g.toLowerCase():g=>g.toUpperCase()}(f),i=f==="next"?Jf:Yf;var m=n.map(function(y){return{lower:s(y),upper:o(y)}}).sort(function(y,g){return i(y.lower,g.lower)});a=m.map(function(y){return y.upper}),l=m.map(function(y){return y.lower}),c=f,u=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>St(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var v=0;return h._addAlgorithm(function(f,m,y){var g=f.key;if(typeof g!="string")return!1;var _=s(g);if(e(_,l,v))return!0;for(var x=null,C=v;C0)&&(x=D)}return m(x!==null?function(){f.continue(x+u)}:y),!1}),h}function St(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function al(t){return{type:1,lower:t,upper:t}}class il{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,o){r=r!==!1,o=o===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||o)&&(!r||!o)?nn(this):new this.Collection(this,()=>St(e,n,!r,!o))}catch{return He(this,pt)}}equals(e){return e==null?He(this,pt):new this.Collection(this,()=>al(e))}above(e){return e==null?He(this,pt):new this.Collection(this,()=>St(e,void 0,!0))}aboveOrEqual(e){return e==null?He(this,pt):new this.Collection(this,()=>St(e,void 0,!1))}below(e){return e==null?He(this,pt):new this.Collection(this,()=>St(void 0,e,!1,!0))}belowOrEqual(e){return e==null?He(this,pt):new this.Collection(this,()=>St(void 0,e))}startsWith(e){return typeof e!="string"?He(this,rl):this.between(e,e+zt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ur(this,(n,r)=>n.indexOf(r[0])===0,[e],zt)}equalsIgnoreCase(e){return ur(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=vt.apply(rn,arguments);return e.length===0?nn(this):ur(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=vt.apply(rn,arguments);return e.length===0?nn(this):ur(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,zt)}anyOf(){const e=vt.apply(rn,arguments);let n=this._cmp;try{e.sort(n)}catch{return He(this,pt)}if(e.length===0)return nn(this);const r=new this.Collection(this,()=>St(e[0],e[e.length-1]));r._ondirectionchange=s=>{n=s==="next"?this._ascending:this._descending,e.sort(n)};let o=0;return r._addAlgorithm((s,i,a)=>{const l=s.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return i(a),!1;return n(l,e[o])===0||(i(()=>{s.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[Jo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=vt.apply(rn,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return He(this,pt)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Jo,o]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,o=this._ascending,s=this._descending,i=this._min,a=this._max;if(e.length===0)return nn(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&o(g[0],g[1])<=0))return He(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ce.InvalidArgument);const l=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=o;function p(g,_){return d(g[0],_[0])}try{u=e.reduce(function(g,_){let x=0,C=g.length;for(;x0){D[0]=i(D[0],_[0]),D[1]=a(D[1],_[1]);break}}return x===C&&g.push(_),g},[]),u.sort(p)}catch{return He(this,pt)}let h=0;const v=c?g=>o(g,u[h][1])>0:g=>o(g,u[h][1])>=0,f=l?g=>s(g,u[h][0])>0:g=>s(g,u[h][0])>=0;let m=v;const y=new this.Collection(this,()=>St(u[0][0],u[u.length-1][1],!l,!c));return y._ondirectionchange=g=>{g==="next"?(m=v,d=o):(m=f,d=s),u.sort(p)},y._addAlgorithm((g,_,x)=>{for(var C=g.key;m(C);)if(++h,h===u.length)return _(x),!1;return!!function(D){return!v(D)&&!f(D)}(C)||(this._cmp(C,u[h][1])===0||this._cmp(C,u[h][0])===0||_(()=>{d===o?g.continue(u[h][0]):g.continue(u[h][1])}),!1)}),y}startsWithAnyOf(){const e=vt.apply(rn,arguments);return e.every(n=>typeof n=="string")?e.length===0?nn(this):this.inAnyRange(e.map(n=>[n,n+zt])):He(this,"startsWithAnyOf() only works with strings")}}function lt(t){return Se(function(e){return Un(e),t(e.target.error),!1})}function Un(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Kn="storagemutated",Ot="x-storagemutated-1",Nt=Rn(null,Kn);class Qf{_lock(){return In(!ae.global),++this._reculock,this._reculock!==1||ae.global||(ae.lockOwnerFor=this),this}_unlock(){if(In(!ae.global),--this._reculock==0)for(ae.global||(ae.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{_n(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&ae.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(In(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new ce.DatabaseClosed(r);case"MissingAPIError":throw new ce.MissingAPI(r.message,r);default:throw new ce.OpenFailed(r)}if(!this.active)throw new ce.TransactionInactive;return In(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Se(o=>{Un(o),this._reject(e.error)}),e.onabort=Se(o=>{Un(o),this.active&&this._reject(new ce.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Nt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Fe(new ce.ReadOnly("Transaction is readonly"));if(!this.active)return Fe(new ce.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ae])});if(r)return Pt(()=>{var s=new oe((i,a)=>{this._lock();const l=n(i,a,this);l&&l.then&&l.then(i,a)});return s.finally(()=>this._unlock()),s._lib=!0,s});var o=new oe((s,i)=>{var a=n(s,i,this);a&&a.then&&a.then(s,i)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=oe.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);(function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=i)})()}var s=n._waitingFor;return new oe((i,a)=>{r.then(l=>n._waitingQueue.push(Se(i.bind(null,l))),l=>n._waitingQueue.push(Se(a.bind(null,l)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new ce.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Je(n,e))return n[e];const r=this.schema[e];if(!r)throw new ce.NotFound("Table "+e+" not part of transaction");const o=new this.db.Table(e,r,this);return o.core=this.db.core.table(e),n[e]=o,o}}function Yo(t,e,n,r,o,s,i){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:s,src:(n&&!i?"&":"")+(r?"*":"")+(o?"++":"")+ll(e)}}function ll(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function cl(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Li(n,r=>[r.name,r])}}let $n=t=>{try{return t.only([[]]),$n=()=>[[]],[[]]}catch{return $n=()=>zt,zt}};function Xo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>xt(r,e)}(t):e=>xt(e,t)}function Sa(t){return[].slice.call(t)}let eh=0;function Tn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function th(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:p}=l;return c===void 0?u===void 0?null:e.upperBound(u,!!p):u===void 0?e.lowerBound(c,!!d):e.bound(c,u,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,c){const u=Sa(l.objectStoreNames);return{schema:{name:l.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,v=ze(p),f=p==null,m={},y={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:v,keyPath:p,autoIncrement:h,unique:!0,extractKey:Xo(p)},indexes:Sa(d.indexNames).map(g=>d.index(g)).map(g=>{const{name:_,unique:x,multiEntry:C,keyPath:D}=g,E={name:_,compound:ze(D),keyPath:D,unique:x,multiEntry:C,extractKey:Xo(D)};return m[Tn(D)]=E,E}),getIndexByKeyPath:g=>m[Tn(g)]};return m[":id"]=y.primaryKey,p!=null&&(m[Tn(p)]=y.primaryKey),y})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),i=o.tables.map(l=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:p,keys:h,values:v,range:f}){return new Promise((m,y)=>{m=Se(m);const g=d.objectStore(u),_=g.keyPath==null,x=p==="put"||p==="add";if(!x&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:C}=h||v||{length:1};if(h&&v&&h.length!==v.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return m({numFailures:0,failures:{},results:[],lastResult:void 0});let D;const E=[],F=[];let I=0;const R=j=>{++I,Un(j)};if(p==="deleteRange"){if(f.type===4)return m({numFailures:I,failures:F,results:[],lastResult:void 0});f.type===3?E.push(D=g.clear()):E.push(D=g.delete(r(f)))}else{const[j,M]=x?_?[v,h]:[v,null]:[h,null];if(x)for(let b=0;b{const M=j.target.result;E.forEach((b,N)=>b.error!=null&&(F[N]=b.error)),m({numFailures:I,failures:F,results:p==="delete"?h:E.map(b=>b.result),lastResult:M})};D.onerror=j=>{R(j),K(j)},D.onsuccess=K})},getMany:({trans:d,keys:p})=>new Promise((h,v)=>{h=Se(h);const f=d.objectStore(u),m=p.length,y=new Array(m);let g,_=0,x=0;const C=E=>{const F=E.target;y[F._pos]=F.result,++x===_&&h(y)},D=lt(v);for(let E=0;Enew Promise((h,v)=>{h=Se(h);const f=d.objectStore(u).get(p);f.onsuccess=m=>h(m.target.result),f.onerror=lt(v)}),query:function(d){return p=>new Promise((h,v)=>{h=Se(h);const{trans:f,values:m,limit:y,query:g}=p,_=y===1/0?void 0:y,{index:x,range:C}=g,D=f.objectStore(u),E=x.isPrimaryKey?D:D.index(x.name),F=r(C);if(y===0)return h({result:[]});if(d){const I=m?E.getAll(F,_):E.getAllKeys(F,_);I.onsuccess=R=>h({result:R.target.result}),I.onerror=lt(v)}else{let I=0;const R=m||!("openKeyCursor"in E)?E.openCursor(F):E.openKeyCursor(F),K=[];R.onsuccess=j=>{const M=R.result;return M?(K.push(m?M.value:M.primaryKey),++I===y?h({result:K}):void M.continue()):h({result:K})},R.onerror=lt(v)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:v,unique:f}){return new Promise((m,y)=>{m=Se(m);const{index:g,range:_}=h,x=d.objectStore(u),C=g.isPrimaryKey?x:x.index(g.name),D=v?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in C)?C.openCursor(r(_),D):C.openKeyCursor(r(_),D);E.onerror=lt(y),E.onsuccess=Se(F=>{const I=E.result;if(!I)return void m(null);I.___id=++eh,I.done=!1;const R=I.continue.bind(I);let K=I.continuePrimaryKey;K&&(K=K.bind(I));const j=I.advance.bind(I),M=()=>{throw new Error("Cursor not stopped")};I.trans=d,I.stop=I.continue=I.continuePrimaryKey=I.advance=()=>{throw new Error("Cursor not started")},I.fail=Se(y),I.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},I.start=b=>{const N=new Promise((A,X)=>{A=Se(A),E.onerror=lt(X),I.fail=X,I.stop=V=>{I.stop=I.continue=I.continuePrimaryKey=I.advance=M,A(V)}}),H=()=>{if(E.result)try{b()}catch(A){I.fail(A)}else I.done=!0,I.start=()=>{throw new Error("Cursor behind last entry")},I.stop()};return E.onsuccess=Se(A=>{E.onsuccess=H,H()}),I.continue=R,I.continuePrimaryKey=K,I.advance=j,H(),N},m(I)},y)})},count({query:d,trans:p}){const{index:h,range:v}=d;return new Promise((f,m)=>{const y=p.objectStore(u),g=h.isPrimaryKey?y:y.index(h.name),_=r(v),x=_?g.count(_):g.count();x.onsuccess=Se(C=>f(C.target.result)),x.onerror=lt(m)})}}}(l)),a={};return i.forEach(l=>a[l.name]=l),{stack:"dbcore",transaction:t.transaction.bind(t),table(l){if(!a[l])throw new Error(`Table '${l}' not found`);return a[l]},MIN_KEY:-1/0,MAX_KEY:$n(e),schema:o}}function Qo({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(u,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),u)}(th(s,i,l),o.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(o=>{const s=o.name;t.core.schema.tables.some(i=>i.name===s)&&(o.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=o.core))})}function Mr({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Ts(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?_t(i,o,{get(){return this.table(o)},set(l){Mi(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function es({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function nh(t,e){return t._cfg.version-e._cfg.version}function rh(t,e,n,r){const o=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,o);s.create(n),s._completion.catch(r);const i=s._reject.bind(s),a=ae.transless||ae;Pt(()=>{ae.trans=s,ae.transless=a,e===0?(Ne(o).forEach(l=>{xo(n,l,o[l].primKey,o[l].indexes)}),Qo(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},c,u,d){const p=[],h=l._versions;let v=l._dbSchema=ns(l,l.idbdb,d),f=!1;const m=h.filter(g=>g._cfg.version>=c);function y(){return p.length?oe.resolve(p.shift()(u.idbtrans)).then(y):oe.resolve()}return m.forEach(g=>{p.push(()=>{const _=v,x=g._cfg.dbschema;rs(l,_,d),rs(l,x,d),v=l._dbSchema=x;const C=ul(_,x);C.add.forEach(E=>{xo(d,E[0],E[1].primKey,E[1].indexes)}),C.change.forEach(E=>{if(E.recreate)throw new ce.Upgrade("Not yet support for changing primary key");{const F=d.objectStore(E.name);E.add.forEach(I=>ts(F,I)),E.change.forEach(I=>{F.deleteIndex(I.name),ts(F,I)}),E.del.forEach(I=>F.deleteIndex(I))}});const D=g._cfg.contentUpgrade;if(D&&g._cfg.version>c){Qo(l,d),u._memoizedTables={},f=!0;let E=Wi(x);C.del.forEach(K=>{E[K]=_[K]}),es(l,[l.Transaction.prototype]),Mr(l,[l.Transaction.prototype],Ne(E),E),u.schema=E;const F=Ms(D);let I;F&&bn();const R=oe.follow(()=>{if(I=D(u),I&&F){var K=Et.bind(null,null);I.then(K,K)}});return I&&typeof I.then=="function"?oe.resolve(I):R.then(()=>I)}}),p.push(_=>{(!f||!Hf)&&function(x,C){[].slice.call(C.db.objectStoreNames).forEach(D=>x[D]==null&&C.db.deleteObjectStore(D))}(g._cfg.dbschema,_),es(l,[l.Transaction.prototype]),Mr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),u.schema=l._dbSchema})}),y().then(()=>{var g,_;_=d,Ne(g=v).forEach(x=>{_.db.objectStoreNames.contains(x)||xo(_,x,g[x].primKey,g[x].indexes)})})}(t,e,s,n).catch(i)})}function ul(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const o=t[r],s=e[r];if(o){const i={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||o.primKey.auto!==s.primKey.auto&&!so)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let c;for(c in a)l[c]||i.del.push(c);for(c in l){const u=a[c],d=l[c];u?u.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&n.change.push(i)}}else n.add.push([r,s])}return n}function xo(t,e,n,r){const o=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>ts(o,s)),o}function ts(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function ns(t,e,n){const r={};return Pr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=Yo(ll(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let u=0;u{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return Yo(l,c||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),ze(c),a===0)}),s=o.shift();if(s.multi)throw new ce.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new ce.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new ce.Schema("Index must have a name and cannot be an empty string")}),n[r]=cl(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Ue(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(i=>{Ue(o,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(o,s)}),n._dbSchema=s,es(n,[n._allTables,n,n.Transaction.prototype]),Mr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ne(s),s),n._storeNames=Ne(s),this}upgrade(e){return this._cfg.contentUpgrade=Ls(this._cfg.contentUpgrade||xe,e),this}}function $s(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Vt(ao,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Vs(t){return t&&typeof t.databases=="function"}function os(t){return Pt(function(){return ae.letThrough=!0,t()})}function sh(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function ah(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Fe(e.dbOpenError):t);ft&&(e.openCanceller._stackHolder=Yt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new ce.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():sh()).then(()=>new oe((l,c)=>{if(o(),!n)throw new ce.MissingAPI;const u=t.name,d=e.autoSchema?n.open(u):n.open(u,Math.round(10*t.verno));if(!d)throw new ce.MissingAPI;d.onerror=lt(c),d.onblocked=Se(t._fireOnBlocked),d.onupgradeneeded=Se(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Un,i.abort(),d.result.close();const v=n.deleteDatabase(u);v.onsuccess=v.onerror=Se(()=>{c(new ce.NoSuchDatabase(`Database ${u} doesnt exist`))})}else{i.onerror=lt(c);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,rh(t,h/10,i,c)}},c),d.onsuccess=Se(()=>{i=null;const p=t._novip.idbdb=d.result,h=Pr(p.objectStoreNames);if(h.length>0)try{const f=p.transaction((v=h).length===1?v[0]:v,"readonly");e.autoSchema?function({_novip:m},y,g){m.verno=y.version/10;const _=m._dbSchema=ns(0,y,g);m._storeNames=Pr(y.objectStoreNames,0),Mr(m,[m._allTables],Ne(_),_)}(t,p,f):(rs(t,t._dbSchema,f),function(m,y){const g=ul(ns(0,m.idbdb,y),m._dbSchema);return!(g.add.length||g.change.some(_=>_.add.length||_.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Qo(t,f)}catch{}var v;Fn.push(t),p.onversionchange=Se(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),p.onclose=Se(f=>{t.on("close").fire(f)}),a&&function({indexedDB:f,IDBKeyRange:m},y){!Vs(f)&&y!==ao&&$s(f,m).put({name:y}).catch(xe)}(t._deps,u),l()},c)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(os(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(Ls,xe);return e.onReadyBeingFired=[],oe.resolve(os(()=>c(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{i&&i.abort()}catch{}return r===e.openCanceller&&t._close(),Fe(l)}).finally(()=>{e.openComplete=!0,s()})}function ss(t){var e=s=>t.next(s),n=o(e),r=o(s=>t.throw(s));function o(s){return i=>{var a=s(i),l=a.value;return a.done?l:l&&typeof l.then=="function"?l.then(n,r):ze(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function ih(t,e,n){var r=arguments.length;if(r<2)throw new ce.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Ui(o),n]}function dl(t,e,n,r,o){return oe.resolve().then(()=>{const s=ae.transless||ae,i=t._createTransaction(e,n,t._dbSchema,r),a={trans:i,transless:s};if(r)i.idbtrans=r.idbtrans;else try{i.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===zs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>dl(t,e,n,null,o))):Fe(d)}const l=Ms(o);let c;l&&bn();const u=oe.follow(()=>{if(c=o.call(i,i),c)if(l){var d=Et.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=ss(c))},a);return(c&&typeof c.then=="function"?oe.resolve(c).then(d=>i.active?d:Fe(new ce.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Fe(d)))})}function dr(t,e,n){const r=ze(t)?t.slice():[t];for(let o=0;o0,y={...p,isVirtual:m,keyTail:d,keyLength:f,extractKey:Xo(u),unique:!m&&p.unique};return v.push(y),y.isPrimaryKey||s.push(y),f>1&&i(f===2?u[0]:u.slice(0,f-1),d+1,p),v.sort((g,_)=>g.keyTail-_.keyTail),y}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const u of r.indexes)i(u.keyPath,0,u);function l(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(p=u.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:dr(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:dr(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:u;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(u){const d=o[Tn(u)];return d&&d[0]}},count:u=>n.count(l(u)),query:u=>n.query(l(u)),openCursor(u){const{keyTail:d,isVirtual:p,keyLength:h}=u.query.index;return p?n.openCursor(l(u)).then(v=>v&&function(f){return Object.create(f,{continue:{value:function(y){y!=null?f.continue(dr(y,u.reverse?t.MAX_KEY:t.MIN_KEY,d)):u.unique?f.continue(f.key.slice(0,h).concat(u.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(y,g){f.continuePrimaryKey(dr(y,t.MAX_KEY,d),g)}},primaryKey:{get:()=>f.primaryKey},key:{get(){const y=f.key;return h===1?y[0]:y.slice(0,h)}},value:{get:()=>f.value}})}(v)):n.openCursor(u)}}}}}};function Hs(t,e,n,r){return n=n||{},r=r||"",Ne(t).forEach(o=>{if(Je(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Bo(s);a!==Bo(i)?n[r+o]=e[o]:a==="Object"?Hs(s,i,n,r+o+"."):s!==i&&(n[r+o]=e[o])}else s!==i&&(n[r+o]=e[o])}else n[r+o]=void 0}),Ne(e).forEach(o=>{Je(t,o)||(n[r+o]=e[o])}),n}const ch={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=ae.trans,{deleting:a,creating:l,updating:c}=i.table(e).hook;switch(s.type){case"add":if(l.fire===xe)break;return i._promise("readwrite",()=>u(s),!0);case"put":if(l.fire===xe&&c.fire===xe)break;return i._promise("readwrite",()=>u(s),!0);case"delete":if(a.fire===xe)break;return i._promise("readwrite",()=>u(s),!0);case"deleteRange":if(a.fire===xe)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function u(p){const h=ae.trans,v=p.keys||function(f,m){return m.type==="delete"?m.keys:m.keys||m.values.map(f.extractKey)}(r,p);if(!v)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:v}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(f,m,y){return m.type==="add"?Promise.resolve([]):f.getMany({trans:m.trans,keys:y,cache:"immutable"})}(n,p,v).then(f=>{const m=v.map((y,g)=>{const _=f[g],x={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(x,y,_,h);else if(p.type==="add"||_===void 0){const C=l.fire.call(x,y,p.values[g],h);y==null&&C!=null&&(y=C,p.keys[g]=y,r.outbound||st(p.values[g],r.keyPath,y))}else{const C=Hs(_,p.values[g]),D=c.fire.call(x,C,y,_,h);if(D){const E=p.values[g];Object.keys(D).forEach(F=>{Je(E,F)?E[F]=D[F]:st(E,F,D[F])})}}return x});return n.mutate(p).then(({failures:y,results:g,numFailures:_,lastResult:x})=>{for(let C=0;C(m.forEach(g=>g.onerror&&g.onerror(y)),Promise.reject(y)))})}function d(p,h,v){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:v}).then(({result:f})=>u({type:"delete",keys:f,trans:p}).then(m=>m.numFailures>0?Promise.reject(m.failures[0]):f.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=fl(r.keys,r.trans._cache,r.cache==="clone");return o?oe.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?Jn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function qs(t){return!("from"in t)}const yt=function(t,e){if(!this){const n=new yt;return t&&"d"in t&&Ue(n,t),n}Ue(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Vn(t,e,n){const r=We(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(qs(t))return Ue(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(We(n,t.from)<0)return o?Vn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},Ia(t);if(We(e,t.to)>0)return s?Vn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},Ia(t);We(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),We(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const i=!t.r;o&&!t.l&&Br(t,o),s&&i&&Br(t,s)}function Br(t,e){qs(e)||function n(r,{from:o,to:s,l:i,r:a}){Vn(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function dh(t,e){const n=as(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=as(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(We(a.from,o.to)<=0&&We(a.to,o.from)>=0)return!0;We(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function as(t){let e=qs(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&We(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||We(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Ia(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const s=o==="r"?"l":"r",i={...t},a=t[o];t.from=a.from,t.to=a.to,t[o]=a[o],i[o]=a[s],t[s]=i,i.d=Oa(i)}t.d=Oa(t)}function Oa({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}mn(yt.prototype,{add(t){return Br(this,t),this},addKey(t){return Vn(this,t,t),this},addKeys(t){return t.forEach(e=>Vn(this,e,e)),this},[zo](){return as(this)}});const fh={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new yt(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:i}=s,{extractKey:a,outbound:l}=i,c={...o,mutate:p=>{const h=p.trans,v=h.mutatedParts||(h.mutatedParts={}),f=D=>{const E=`idb://${e}/${r}/${D}`;return v[E]||(v[E]=new yt)},m=f(""),y=f(":dels"),{type:g}=p;let[_,x]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const C=p.trans._cache;return o.mutate(p).then(D=>{if(ze(_)){g!=="delete"&&(_=D.results),m.addKeys(_);const E=fl(_,C);E||g==="add"||y.addKeys(_),(E||x)&&function(F,I,R,K){function j(M){const b=F(M.name||"");function N(A){return A!=null?M.extractKey(A):null}const H=A=>M.multiEntry&&ze(A)?A.forEach(X=>b.addKey(X)):b.addKey(A);(R||K).forEach((A,X)=>{const V=R&&N(R[X]),te=K&&N(K[X]);We(V,te)!==0&&(V!=null&&H(V),te!=null&&H(te))})}I.indexes.forEach(j)}(f,s,E,x)}else if(_){const E={from:_.lower,to:_.upper};y.add(E),m.add(E)}else m.add(n),y.add(n),s.indexes.forEach(E=>f(E.name).add(n));return D})}},u=({query:{index:p,range:h}})=>{var v,f;return[p,new yt((v=h.lower)!==null&&v!==void 0?v:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new yt(p.key)],getMany:p=>[i,new yt().addKeys(p.keys)],count:u,query:u,openCursor:u};return Ne(d).forEach(p=>{c[p]=function(h){const{subscr:v}=ae;if(v){const f=x=>{const C=`idb://${e}/${r}/${x}`;return v[C]||(v[C]=new yt)},m=f(""),y=f(":dels"),[g,_]=d[p](h);if(f(g.name||"").add(_),!g.isPrimaryKey){if(p!=="count"){const x=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(C=>{if(p==="query"){if(l&&h.values)return x.then(({result:E})=>(m.addKeys(E),C));const D=h.values?C.result.map(a):C.result;h.values?m.addKeys(D):y.addKeys(D)}else if(p==="openCursor"){const D=C,E=h.values;return D&&Object.create(D,{key:{get:()=>(y.addKey(D.primaryKey),D.key)},primaryKey:{get(){const F=D.primaryKey;return y.addKey(F),F}},value:{get:()=>(E&&m.addKey(D.primaryKey),D.value)}})}return C})}y.add(n)}}return o[p].apply(this,arguments)}}),c}}}};class Vt{constructor(e,n){this._middlewares={},this.verno=0;const r=Vt.dependencies;this._options=n={addons:Vt.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:xe,dbReadyPromise:null,cancelOpen:xe,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new oe(a=>{s.dbReadyResolve=a}),s.openCanceller=new oe((a,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=Rn(this,"populate","blocked","versionchange","close",{ready:[Ls,xe]}),this.on.ready.subscribe=Bi(this.on.ready.subscribe,a=>(l,c)=>{Vt.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||oe.resolve().then(l),c&&a(l);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(l),c&&a(l);else{a(l);const d=this;c||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,Sn(Zf.prototype,function(a,l){this.db=i;let c=sl,u=null;if(l)try{c=l()}catch(v){u=v}const d=a._ctx,p=d.table,h=p.hook.reading.fire;this._ctx={table:p,index:d.index,isPrimKey:!d.index||p.schema.primKey.keyPath&&d.index===p.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:h!==Ln?h:null}})),this.Table=function(a){return Sn(Gf.prototype,function(l,c,u){this.db=a,this._tx=u,this.name=l,this.schema=c,this.hook=a._allTables[l]?a._allTables[l].hook:Rn(null,{creating:[Tf,xe],reading:[Rf,Ln],updating:[Bf,xe],deleting:[Mf,xe]})})}(this),this.Transaction=function(a){return Sn(Qf.prototype,function(l,c,u,d,p){this.db=a,this.mode=l,this.storeNames=c,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Rn(this,"complete","error","abort"),this.parent=p||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new oe((h,v)=>{this._resolve=h,this._reject=v}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var v=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):v&&this.idbtrans&&this.idbtrans.abort(),Fe(h)})})}(this),this.Version=function(a){return Sn(oh.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return Sn(il.prototype,function(l,c,u){this.db=a,this._ctx={table:l,index:c===":id"?null:c,or:u};const d=a._deps.indexedDB;if(!d)throw new ce.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,h)=>d.cmp(h,p),this._max=(p,h)=>d.cmp(p,h)>0?p:h,this._min=(p,h)=>d.cmp(p,h)<0?p:h,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersionnew this.Transaction(a,l,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=a=>{this.on("blocked").fire(a),Fn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(lh),this.use(ch),this.use(fh),this.use(uh),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new ce.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ce.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(o=>o._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(nh),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ae.letThrough||this._vip)?e():new oe((n,r)=>{if(this._state.openComplete)return r(new ce.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new ce.DatabaseClosed);this.open().catch(xe)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:o}){o&&this.unuse({stack:e,name:o});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:n,level:r??10,name:o}),s.sort((i,a)=>i.level-a.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(o=>r?o.create!==r:!!n&&o.name!==n)),this}open(){return ah(this)}_close(){const e=this._state,n=Fn.indexOf(this);if(n>=0&&Fn.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new oe(r=>{e.dbReadyResolve=r}),e.openCanceller=new oe((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ce.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new oe((r,o)=>{const s=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Se(()=>{(function({indexedDB:a,IDBKeyRange:l},c){!Vs(a)&&c!==ao&&$s(a,l).delete(c).catch(xe)})(this._deps,this.name),r()}),i.onerror=lt(o),i.onblocked=this._fireOnBlocked};if(e)throw new ce.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Ne(this._allTables).map(e=>this._allTables[e])}transaction(){const e=ih.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=ae.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const s=e.indexOf("?")!==-1;let i,a;e=e.replace("!","").replace("?","");try{if(a=n.map(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),e=="r"||e===vo)i=vo;else{if(e!="rw"&&e!=go)throw new ce.InvalidArgument("Invalid transaction mode: "+e);i=go}if(o){if(o.mode===vo&&i===go){if(!s)throw new ce.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(c=>{if(o&&o.storeNames.indexOf(c)===-1){if(!s)throw new ce.SubTransaction("Table "+c+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(c){return o?o._promise(null,(u,d)=>{d(c)}):Fe(c)}const l=dl.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ae.trans?_n(ae.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Je(this._allTables,e))throw new ce.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const hh=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class ph{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[hh](){return this}}function hl(t,e){return Ne(e).forEach(n=>{Br(t[n]||(t[n]=new yt),e[n])}),t}function mh(t){let e,n=!1;const r=new ph(o=>{const s=Ms(t);let i=!1,a={},l={};const c={get closed(){return i},unsubscribe:()=>{i=!0,Nt.storagemutated.unsubscribe(h)}};o.start&&o.start(c);let u=!1,d=!1;function p(){return Ne(l).some(f=>a[f]&&dh(a[f],l[f]))}const h=f=>{hl(a,f),p()&&v()},v=()=>{if(u||i)return;a={};const f={},m=function(y){s&&bn();const g=()=>Pt(t,{subscr:y,trans:null}),_=ae.trans?_n(ae.transless,g):g();return s&&_.then(Et,Et),_}(f);d||(Nt(Kn,h),d=!0),u=!0,Promise.resolve(m).then(y=>{n=!0,e=y,u=!1,i||(p()?v():(a={},l=f,o.next&&o.next(y)))},y=>{u=!1,n=!1,o.error&&o.error(y),c.unsubscribe()})};return v(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let is;try{is={indexedDB:Ce.indexedDB||Ce.mozIndexedDB||Ce.webkitIndexedDB||Ce.msIndexedDB,IDBKeyRange:Ce.IDBKeyRange||Ce.webkitIDBKeyRange}}catch{is={indexedDB:null,IDBKeyRange:null}}const Bt=Vt;function _r(t){let e=gt;try{gt=!0,Nt.storagemutated.fire(t)}finally{gt=e}}mn(Bt,{...mr,delete:t=>new Bt(t,{addons:[]}).delete(),exists:t=>new Bt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Vs(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==ao)):$s(e,n).toCollection().primaryKeys()}(Bt.dependencies).then(t)}catch{return Fe(new ce.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ae.trans?_n(ae.transless,t):t(),vip:os,async:function(t){return function(){try{var e=ss(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Fe(n)}}},spawn:function(t,e,n){try{var r=ss(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Fe(o)}},currentTransaction:{get:()=>ae.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Bt.ignoreTransaction(t):t).timeout(e||6e4);return ae.trans?ae.trans.waitFor(n):n},Promise:oe,debug:{get:()=>ft,set:t=>{$i(t,t==="dexie"?()=>!0:ol)}},derive:an,extend:Ue,props:mn,override:Bi,Events:Rn,on:Nt,liveQuery:mh,extendObservabilitySet:hl,getByKeyPath:xt,setByKeyPath:st,delByKeyPath:function(t,e){typeof e=="string"?st(t,e,void 0):"length"in e&&[].map.call(e,function(n){st(t,n,void 0)})},shallowClone:Wi,deepClone:Jn,getObjectDiff:Hs,cmp:We,asap:zi,minKey:Jo,addons:[],connections:Fn,errnames:zs,dependencies:is,semVer:_a,version:_a.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Bt.maxKey=$n(Bt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Nt(Kn,t=>{if(!gt){let e;so?(e=document.createEvent("CustomEvent"),e.initCustomEvent(Ot,!0,!0,t)):e=new CustomEvent(Ot,{detail:t}),gt=!0,dispatchEvent(e),gt=!1}}),addEventListener(Ot,({detail:t})=>{gt||_r(t)}));let gt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(Ot);typeof t.unref=="function"&&t.unref(),Nt(Kn,e=>{gt||t.postMessage(e)}),t.onmessage=e=>{e.data&&_r(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Nt(Kn,e=>{try{gt||(typeof localStorage<"u"&&localStorage.setItem(Ot,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Ot,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===Ot){const n=JSON.parse(e.newValue);n&&_r(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===Ot&&_r(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof ln||t instanceof TypeError||t instanceof SyntaxError||!t.name||!va[t.name])return t;var n=new va[t.name](e||t.message,t);return"stack"in t&&_t(n,"stack",{get:function(){return this.inner.stack}}),n},$i(ft,ol);var yh=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t.openSpotlightSearch="openSpotlightSearch",t))(yh||{}),xr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(xr||{});const vh="comfyui_workspace_db";class gh extends Vt{constructor(){super(vh);Ie(this,"workflows");Ie(this,"changelogs");Ie(this,"media");Ie(this,"folders");Ie(this,"tags");Ie(this,"userSettings");Ie(this,"models");Ie(this,"cache");Ie(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const ie=new gh,wh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ls=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=wh[n[t]&63];return e};class Xt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ie[this.tableName].toArray(),n={};e.forEach(r=>{r.id?n[r.id]=r:r.name?n[r.name]=r:console.error("TableBaseModel should have id or name")});try{vf(this.tableName,JSON.stringify(n))}catch(r){console.error("error saving disk db",r)}}async add(e){return e.id||(e.id=ls()),e.createTime||(e.createTime=Date.now()),await ie[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ie[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ie[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ie[this.tableName].update(e,n),this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ie[this.tableName].toArray()}async filter(e){return await ie[this.tableName].filter(e).toArray()}async batchQuery(e){return await ie[this.tableName].bulkGet(e)}async getRecords(){console.warn("[DEPRECATED] getRecords() call, should only be used for one-time backfill for indexdb",this.tableName);const e=await yf(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Ef()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ie[this.tableName].get(e)}async delete(e){await ie[this.tableName].delete(e),this.saveDiskDB()}async listByIndex(e,n){return await ie[this.tableName].where(e).equals(n).toArray()}}const bh=80,Lr=class Lr extends Xt{constructor(){super("changelogs")}static async load(){return new Lr}async listByWorkflowID(e){return await ie.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime")}async getLastestByWorkflowID(e){return(await this.listByWorkflowID(e))[0]}async create(e){const n=await this.getLastestByWorkflowID(e.workflowID);if(n!=null&&n.json===e.json)return null;const r={id:Dr(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return await this.deleteLogsExceedLimit(e.workflowID),await ie.changelogs.add(r),r}async deleteLogsExceedLimit(e){var o;const n=await ie.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=((o=G==null?void 0:G.settings)==null?void 0:o.maximumChangelogNumber)??bh;if(n.length>r){const s=n.slice(r);await ie.changelogs.bulkDelete(s.map(i=>i.id))}}};Ie(Lr,"TABLE_NAME","changelogs");let cs=Lr;const rm="CWM_WORKFLOWS_SORT_TYPE";var ct=(t=>(t.RECENTLY_OPENED="recentlyOpened",t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(ct||{});const om=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],_h="comfyspace_tracking",qe="workspace_info",xh=9999999,ko="upgrade_to_2way_sync",us=28,sm="SHORTCUT_TRIGGER_EVENT";function kr(...t){const e=t.filter(n=>n!=="").join("/");return Ft(e)}function Ft(t){let n=t.split("/").filter(r=>r!=="").join("/").replace(/\\/g,"/");return n=n.replace(/^\/+/,""),n}function Eo(t){return kr(t.parentFolderID??"",t.name+".json")}var Dt;(t=>{async function e({parentFolderID:a,name:l}){return Ft(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await fetch("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Ft(a.id)})})}t.createFolder=n;async function r(a,l){const u=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();u.error&&alert("Failed to move folder: "+u.error)}t.moveFolder=r;async function o(a){try{return await(await fetch("/workspace/folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).text()}catch(l){console.error("Error deleting file:",l)}}t.deleteFolder=o;async function s(a){try{const c=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return c.error&&console.error("Error counting files:",c.error),c.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const u=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();u.error&&alert("Failed to rename folder: "+u.error)}catch(c){console.error("Error renaming file:",c)}}t.renameFolder=i})(Dt||(Dt={}));async function Dn(t){const e=await Gs(t);if(e==null)return;const n=await pl(t);await($==null?void 0:$.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[qe]={id:t.id,name:t.name},delete o.extra[_h],await gf(e,JSON.stringify(o))}async function Co(t){if(t.name==null)return;const e=await Gs(t);e!=null&&Ti(e)}async function Gs(t){let e=Eh(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(Le==null?void 0:Le.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function kh(t){let e="",n=t;for(;n!=null;){const r=await(Le==null?void 0:Le.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function pl(t){const e=await Gs(t);let n=await(G==null?void 0:G.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function am(t){if(await(G==null?void 0:G.getSetting("twoWaySync")))return await Dt.genFilesCountInFolder(t)??0;const n=await($==null?void 0:$.listAll())??[],r=await(Le==null?void 0:Le.listAll())??[],o=[t];let s=0;for(;o.length>0;){const i=o.shift();if(i){for(const l of n)l.parentFolderID===i&&s++;const a=r.filter(l=>l.parentFolderID===i).map(l=>l.id);a.length&&o.push(...a)}}return s}function Eh(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function ml(t,e=!0,n=!1,r="-"){const o=new Date(t),s=String(o.getDate()).padStart(2,"0"),i=String(o.getMonth()+1).padStart(2,"0"),a=o.getFullYear(),l=String(o.getHours()).padStart(2,"0"),c=String(o.getMinutes()).padStart(2,"0"),u=String(o.getSeconds()).padStart(2,"0"),d=`${i}${r}${s}${r}${a}`;return e?d+` ${l}:${c}`:n?d+`:${u}`:d}async function Ch(t=!1){if(await(G==null?void 0:G.getSetting("twoWaySync")))return;const n=await($==null?void 0:$.listAll())??[];for(const r of n){const o=await pl(r);r.filePath!=o&&(r.filePath!=null&&await Ti(r.filePath,t),await Dn(r))}}const Er=(t,e=ct.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case ct.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case ct.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case ct.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case ct.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break;case ct.RECENTLY_OPENED:n.sort((r,o)=>(o.lastOpenedTime??0)-(r.lastOpenedTime??0));break}return n};function Sh(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{var n;const e=(n=G==null?void 0:G.settings)==null?void 0:n.shortcuts;if(!e)return!1;for(const r in e){const s=e[r].split("+"),i={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const a in i)i[a]||delete i[a];if(s.length===Object.keys(i).length&&s.every(a=>i[a]))return r}};function cm(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function Ih(t){return`/workspace/view_media?filename=${t}`}function Da(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function yl(t){const e=window.location.hash.slice(1).split("/"),n=e.findIndex(o=>o.includes("workspaceId@")),r=`workspaceId@${t}`;return n>=0?e[n]=r:e.push(r),`${e.join("/")}`}const Oh=t=>{const e=yl(t);window.open(`${window.location.origin}/#${e}`)},Cr={last_node_id:9,last_link_id:9,nodes:[{id:7,type:"CLIPTextEncode",pos:[413,389],size:{0:425.27801513671875,1:180.6060791015625},flags:{},order:3,mode:0,inputs:[{name:"clip",type:"CLIP",link:5}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[6],slot_index:0}],properties:{},widgets_values:["text, watermark"]},{id:6,type:"CLIPTextEncode",pos:[415,186],size:{0:422.84503173828125,1:164.31304931640625},flags:{},order:2,mode:0,inputs:[{name:"clip",type:"CLIP",link:3}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[4],slot_index:0}],properties:{},widgets_values:["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{id:5,type:"EmptyLatentImage",pos:[473,609],size:{0:315,1:106},flags:{},order:1,mode:0,outputs:[{name:"LATENT",type:"LATENT",links:[2],slot_index:0}],properties:{},widgets_values:[512,512,1]},{id:3,type:"KSampler",pos:[863,186],size:{0:315,1:262},flags:{},order:4,mode:0,inputs:[{name:"model",type:"MODEL",link:1},{name:"positive",type:"CONDITIONING",link:4},{name:"negative",type:"CONDITIONING",link:6},{name:"latent_image",type:"LATENT",link:2}],outputs:[{name:"LATENT",type:"LATENT",links:[7],slot_index:0}],properties:{},widgets_values:[0x8e7ff42ed37e,!0,20,8,"euler","normal",1]},{id:8,type:"VAEDecode",pos:[1209,188],size:{0:210,1:46},flags:{},order:5,mode:0,inputs:[{name:"samples",type:"LATENT",link:7},{name:"vae",type:"VAE",link:8}],outputs:[{name:"IMAGE",type:"IMAGE",links:[9],slot_index:0}],properties:{}},{id:9,type:"SaveImage",pos:[1451,189],size:{0:210,1:26},flags:{},order:6,mode:0,inputs:[{name:"images",type:"IMAGE",link:9}],properties:{}},{id:4,type:"CheckpointLoaderSimple",pos:[26,474],size:{0:315,1:98},flags:{},order:0,mode:0,outputs:[{name:"MODEL",type:"MODEL",links:[1],slot_index:0},{name:"CLIP",type:"CLIP",links:[3,5],slot_index:1},{name:"VAE",type:"VAE",links:[8],slot_index:2}],properties:{},widgets_values:["v1-5-pruned-emaonly.ckpt"]}],links:[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],groups:[],config:{},extra:{},version:.4};var Qe;(t=>{async function e(l,c){try{const d=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Eo(l),newParentPath:c})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(u){console.error("Error deleting file:",u)}}t.moveWorkflow=e;async function n(l,c){try{const d=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:kr(c??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(u){console.error("Error deleting file:",u)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:c},u){try{const p=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:kr(l??"",c+".json"),newName:u})})).json();return p.error?(alert("Error rename file: "+p.error),!1):!0}catch(d){console.error("Error deleting file:",d)}}t.renameWorkflow=r;async function o(l){const c=l.json,u=JSON.parse(c);u.extra[qe]==null&&(u.extra[qe]={}),u.extra[qe].id=l.id;const p=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Eo(l),json:JSON.stringify(u)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} 👉Please try "Save as" from "Files" dropdown menu - `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:Eo(l),deleteEmptyFolder:!1})})).text()}catch(u){alert("Error deleting workflow .json file: "+u),console.error("Error deleting file:",u)}}t.deleteWorkflow=s;async function i({parentFolderID:l,name:u,json:c,id:d}){var v;let p=JSON.parse(c);p.extra==null&&(p.extra={}),p.extra[qe]==null&&(p.extra[qe]={}),p.extra[qe].id=d;const h={parentFolderPath:Ft(l??""),name:u,json:JSON.stringify(p)};try{const m=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).json();return m.name&&await((v=ie.workflows)==null?void 0:v.update(d,{name:m.name})),m}catch(f){return console.error(`Error creating file <${d}> at "${l}"`,f),alert(`Error creating file <${d}> at "${l}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:u,id:c}){const d=kr(l??"",u+".json");try{const h=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:c})})).json();return h.error&&(console.error(`Error getting file <${c}> at "${d}"`,h.error),alert({message:`Error getting file <${c}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${c}> at "${d}"`,p),{}}}t.getFile=a})(Qe||(Qe={}));async function Zs(t,e=!1,n=!1){try{return await(await fetch("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Ft(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function Dh(t,e){const n=Ft(t??""),o=(await Zs(n)).map(async a=>{var c;const l=a.name,u=[n,l].join("/");return jh(a)?{id:Ft(u),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((c=ie.workflows)==null?void 0:c.get(a.id))??{createTime:Date.now(),updateTime:Date.now()},id:a.id,json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime}}),s=await Promise.all(o);ie.workflows.bulkPut(s.filter(a=>!zh(a)));const i=s.filter(a=>a!=null);return Er(i,e??ct.RECENTLY_MODIFIED)}function jh(t){return"type"in t&&t.type==="folder"}const Wr=class Wr extends Xt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Wr}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await ie.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async listByIndex(n,r){const o=await super.listByIndex(n,r);return await(G==null?void 0:G.getSetting("twoWaySync"))?(await Promise.all(o.map(async a=>await this.get(a.id)))).filter(a=>a!=null):o}async generateUniqueName(n,r){if(await(G==null?void 0:G.getSetting("twoWaySync"))){const l=await Qe.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(a.includes(s)){let l=2,u=!0;for(;u;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,u=!1)}return s}async createFlow(n){const{name:r}=n,o=await this.generateUniqueName(r,n.parentFolderID??void 0),s=Date.now(),i={...n,id:n.id??ls(),json:n.json??JSON.stringify(Cr),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ie.workflows.add(i),this.saveDiskDB(),await(G==null?void 0:G.getSetting("twoWaySync"))?(await Qe.createWorkflow(i),await this.get(i.id)):(Dn(i),i)}async update(n,r){throw new Error("Method not allowed.")}async updateTopFields(n,r){return this._update(n,r)}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ie.workflows.update(n,r);const o=await ie.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var a;const o=await(G==null?void 0:G.getSetting("twoWaySync")),s=await this.get(n),i=await this.updateMetaInfo(n,r);!i||!s||(o?await Qe.moveWorkflow(s,r.parentFolderID):(await Dn(i),await Co(s),(i==null?void 0:i.parentFolderID)!=null&&await((a=ie.folders)==null?void 0:a.update(i.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Ge==null?void 0:Ge.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(G==null?void 0:G.getSetting("twoWaySync"))&&o&&await Qe.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const s=JSON.stringify(o.json),i=JSON.stringify(r.json);if(s===i)return;const a=await this._update(n,{updateTime:Date.now(),json:r.json});await(G==null?void 0:G.getSetting("twoWaySync"))?a&&await Qe.saveWorkflow(a):a&&await Dn(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const u=l.name&&r?l.name:await this.generateUniqueName(l.name,o),c=ls(),d=Date.now(),p={id:c,name:u,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(G==null?void 0:G.getSetting("twoWaySync")))try{const v=JSON.parse(l.json),f=(a=(i=v==null?void 0:v.extra)==null?void 0:i[qe])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Qe.createWorkflow(p)}catch(v){console.error("batchCreateFlows error",v)}else await Dn(p)}try{await ie.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&(await(G==null?void 0:G.getSetting("twoWaySync"))?await Qe.deleteWorkflow(r):Co({...r})),await ie.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ie.workflows.bulkGet(n);for(const o of r){if(!o)return;await(G==null?void 0:G.getSetting("twoWaySync"))?await Qe.deleteWorkflow(o):Co({...o})}await ie.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(G==null?void 0:G.getSetting("twoWaySync"))){const l=await Dh(n??null);return Er(l,r??ct.RECENTLY_MODIFIED)}const s=await this.listAll().then(l=>l.filter(u=>u.parentFolderID==n))??[],i=await(Le==null?void 0:Le.listAll().then(l=>l.filter(u=>u.parentFolderID==n)))??[],a=[...s,...i];return Er(a,r??ct.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(G==null?void 0:G.getSetting("twoWaySync")),s=await ie.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Qe.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(i.json)return{...s,json:JSON.stringify(i.json)}}async listAll(n){const r=await(G==null?void 0:G.getSetting("twoWaySync"));let o;if(r){const i=(await Zs("",!0)).filter(a=>(a==null?void 0:a.type)==="workflow").map(async a=>{const l=await ie.workflows.get(a.id);return a.updateTime=(l==null?void 0:l.updateTime)??Date.now(),l!=null&&l.lastOpenedTime&&(a.lastOpenedTime=l==null?void 0:l.lastOpenedTime),a});o=await Promise.all(i)}else o=await ie.workflows.toArray();return n?Er(o,n):o}async updateLastOpenedTime(n){await ie.workflows.update(n,{lastOpenedTime:Date.now()})}};Ie(Wr,"TABLE_NAME","workflows");let ds=Wr;const Ur=class Ur extends Xt{constructor(){super("folders")}static async load(){return new Ur}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(G==null?void 0:G.getSetting("twoWaySync")),o=await Dt.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:Dr(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await Dt.createFolder(s):(await ie.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(G==null?void 0:G.getSetting("twoWaySync")))return"parentFolderID"in n&&await Dt.moveFolder(e,n.parentFolderID??""),"name"in n&&await Dt.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const s="name"in n&&n.name!=o.name,i="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,a={...o,...n};return n.name!=null&&(a.updateTime=Date.now()),i&&(n.name=await this.generateUniqueName(a.name,a.parentFolderID??void 0)),await ie.folders.update(e,n),this.saveDiskDB(),(s||i)&&Ch(!0),a}async deleteFolder(e,n=xr.DELETE){if(await(G==null?void 0:G.getSetting("twoWaySync"))){await Zs(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&($==null||$.deleteFlow(l.id))})}),await Dt.deleteFolder(e);return}const o=await($==null?void 0:$.listAll())??[],s=await this.listAll(),i=[e];for(;i.length>0;){const a=i.shift();if(a){for(const u of o)if(u.parentFolderID===a)switch(n){case xr.DELETE:await($==null?void 0:$.deleteFlow(u.id));break;case xr.MOVE_TO_ROOT_FOLDER:await($==null?void 0:$.updateFolder(u.id,{parentFolderID:void 0}));break}await ie.folders.delete(a);const l=s.filter(u=>u.parentFolderID===a).map(u=>u.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(G==null?void 0:G.getSetting("twoWaySync")))return await Qe.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const s=await this.listAll().then(i=>i.filter(a=>a.parentFolderID==n).map(a=>a.name));if(s.includes(o)){let i=2,a=!0;for(;a;)s.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,a=!1)}return o}};Ie(Ur,"TABLE_NAME","folders");let fs=Ur;function Ph(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=o=>{const s=new Uint8Array(o.target.result),i=new DataView(s.buffer);i.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),n());let a=8;const l={};for(;aString.fromCharCode(f)).join("");l[p]=v}a+=12+u}e(l)},r.readAsArrayBuffer(t)})}function Ah(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function n(i,a,l){const u=t.slice(i,i+l);if(l===2)return new DataView(u.buffer,u.byteOffset,u.byteLength).getUint16(0,a);if(l===4)return new DataView(u.buffer,u.byteOffset,u.byteLength).getUint32(0,a)}const r=n(4,e,4);function o(i){const a=n(i,e,2),l={};for(let u=0;u{const n=new FileReader;n.onload=r=>{var l;const o=new Uint8Array((l=r==null?void 0:r.target)==null?void 0:l.result),s=new DataView(o.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let i=12;const a={};for(;i{const n=new FileReader;n.onload=r=>{const o=new Uint8Array(r.target.result),s=new DataView(o.buffer),i=new TextDecoder;if(s.getUint32(0)==440786851){let a=12;for(;a>8*(4-c)&~(1<<7*c),p=i.decode(o.slice(a+2+c,a+2+c+d)),h=JSON.parse(p);e(h);return}}a+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let a=o.length-4;for(;a>16;){if(s.getUint32(a)==1684108385&&s.getUint32(a-8)==2841865588){s.getUint32(a+4),s.getUint32(a+8);const l=s.getUint32(a-4)-4*4,u=i.decode(o.slice(a+12,a+12+l)),c=JSON.parse(u);e(c);return}a-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},n.readAsArrayBuffer(t)})}function Th(t){const e=t.split(".").pop();return fetch(t).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const r=t.split("/").pop()??"",o=new File([n],r);if(Fh(t))return Rh(o);if(e==="webp")return Nh(o);const s=await Ph(o),i=JSON.parse(s==null?void 0:s.prompt),a=JSON.parse(s==null?void 0:s.workflow);return{prompt:i,workflow:a}})}class vl extends Xt{constructor(){super("media")}async listByWorkflowID(e){return await ie.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r=await Th(`/workspace/view_media?filename=${e.localPath}`).catch(s=>(console.error("get meta error:",s),{prompt:""})),o={id:e.localPath,localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),workflowJSON:JSON.stringify(r==null?void 0:r.prompt),format:n};return await($==null?void 0:$.updateMetaInfo(e.workflowID,{latestImage:o.localPath})),ie.media.put(o),this.saveDiskDB(),o}async delete(e){var n,r;super.delete(e),((n=$==null?void 0:$.curWorkflow)==null?void 0:n.coverMediaPath)===e&&($==null||$.updateMetaInfo($.curWorkflow.id,{coverMediaPath:void 0})),((r=$==null?void 0:$.curWorkflow)==null?void 0:r.latestImage)===e&&($==null||$.updateMetaInfo($.curWorkflow.id,{latestImage:void 0}))}}Ie(vl,"TABLE_NAME","media");const um=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Mh={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function dm(t){return t.modelVersions!==void 0}function Bh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function fm(t,e){var r,o,s,i,a,l;if(!t)return;let n;return Bh(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(s=t.files)==null?void 0:s[0].name,sizeKB:(a=(i=t.files)==null?void 0:i[0])==null?void 0:a.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const Kr=class Kr extends Xt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);Ie(this,"_settings");this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S",openSpotlightSearch:"Control+P"},defaultFolders:Mh,autoSave:!1,autoSaveDuration:3,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.org",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:80,hideCoverImage:!1,disableUnsavedWarning:!1}}get settings(){return this._settings}get autoSave(){return this._autoSave}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return n==="shortcuts"&&(r!=null&&r.shortcuts)?{...this.defaultSettings.shortcuts,...r.shortcuts}:(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),this._settings={...this.defaultSettings,...o}}static async load(){const n=new Kr,r=await wf();return n.defaultSettings.myWorkflowsDir=r.path,await n.get(n.DEFAULT_USER).then(o=>{n._autoSave=(o==null?void 0:o.autoSave)??!1,n._settings={...n.defaultSettings,...o}}),await n.upsert({cloudHost:n.defaultSettings.cloudHost}),n}};Ie(Kr,"TABLE_NAME","userSettings");let hs=Kr;const $r=class $r extends Xt{constructor(){super("tags")}static async load(){return new $r}};Ie($r,"TABLE_NAME","tags");let ps=$r;const Vr=class Vr extends Xt{constructor(){super("workflowVersions")}static async load(){return new Vr}async listByWorkflowID(e){return await ie[this.tableName].where("workflowID").equals(e).reverse().sortBy("createTime")??[]}async getLatestByWorkflowID(e){const n=await this.listByWorkflowID(e);return n!=null&&n.length?n[0]:null}};Ie(Vr,"TABLE_NAME","workflowVersions");let ms=Vr;function zh(t){return"type"in t&&t.type==="folder"}let $=null,Sr=null,G=null,Le=null,Ge=null,Ht=null,be=null;async function Lh(){const t=async()=>{$=await ds.load()},e=async()=>{Sr=await ps.load()},n=async()=>{G=await hs.load()},r=async()=>{Le=await fs.load()},o=async()=>{Ge=await cs.load()},s=async()=>{Ht=new vl},i=async()=>{be=await ms.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Wh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Wh(){const t=async()=>{try{const a=await($==null?void 0:$.getRecords());a&&await ie.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(Le==null?void 0:Le.getRecords());a&&await ie.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Ht==null?void 0:Ht.getRecords());a&&await ie.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ge==null?void 0:Ge.getRecords());a&&await ie.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(Sr==null?void 0:Sr.getRecords());a&&await ie.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=G,l=await a.getRecords().then(u=>u[a.DEFAULT_USER]?u[a.DEFAULT_USER]:u);await ie.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(be==null?void 0:be.getRecords());a&&await ie.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const Ct=P.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{}}),hm=P.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),So={x:0,y:0};function Uh({children:t,onDragEnd:e,dragIconId:n}){const r=P.useRef(So),o=P.useRef(!1),[s,i]=P.useState(So),a=d=>{var p,h,v;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(v=(h=d.target)==null?void 0:h.parentNode)==null?void 0:v.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=P.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),u=P.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),So)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",u)},[e,l]),c={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return k.jsx("div",{style:c,onMouseDown:a,children:t})}var Kh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},$h=Object.defineProperty,Vh=Object.defineProperties,Hh=Object.getOwnPropertyDescriptors,zr=Object.getOwnPropertySymbols,gl=Object.prototype.hasOwnProperty,wl=Object.prototype.propertyIsEnumerable,ja=(t,e,n)=>e in t?$h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Pa=(t,e)=>{for(var n in e||(e={}))gl.call(e,n)&&ja(t,n,e[n]);if(zr)for(var n of zr(e))wl.call(e,n)&&ja(t,n,e[n]);return t},qh=(t,e)=>Vh(t,Hh(e)),Gh=(t,e)=>{var n={};for(var r in t)gl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&zr)for(var r of zr(t))e.indexOf(r)<0&&wl.call(t,r)&&(n[r]=t[r]);return n},Pe=(t,e,n)=>{const r=P.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:u=2,children:c}=i,d=Gh(i,["color","size","stroke","children"]);return P.createElement("svg",Pa(qh(Pa({ref:s},Kh),{width:l,height:l,stroke:a,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>P.createElement(p,h)),...c||[]])});return r.propTypes={color:Mt.string,size:Mt.oneOfType([Mt.string,Mt.number]),stroke:Mt.oneOfType([Mt.string,Mt.number])},r.displayName=`${e}`,r},Zh=Pe("arrow-back-up-double","IconArrowBackUpDouble",[["path",{d:"M13 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M8 14l-4 -4l4 -4",key:"svg-1"}],["path",{d:"M9 10h7a4 4 0 1 1 0 8h-1",key:"svg-2"}]]),Jh=Pe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),ys=Pe("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]),Aa=Pe("download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]),bl=Pe("external-link","IconExternalLink",[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]]),Yh=Pe("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]),Xh=Pe("grip-vertical","IconGripVertical",[["path",{d:"M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}],["path",{d:"M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-4"}],["path",{d:"M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-5"}]]),Qh=Pe("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]),ep=Pe("info-circle","IconInfoCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 9h.01",key:"svg-1"}],["path",{d:"M11 12h1v4h1",key:"svg-2"}]]),tp=Pe("link","IconLink",[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]]),_l=Pe("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]),np=Pe("pencil","IconPencil",[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]]),rp=Pe("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]),op=Pe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),sp=Pe("refresh","IconRefresh",[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]]),ap=Pe("share-2","IconShare2",[["path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M12 14v-11",key:"svg-1"}],["path",{d:"M9 6l3 -3l3 3",key:"svg-2"}]]),ip=Pe("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]),xl=Pe("triangle-inverted-filled","IconTriangleInvertedFilled",[["path",{d:"M20.118 3h-16.225a2.914 2.914 0 0 0 -2.503 4.371l8.116 13.549a2.917 2.917 0 0 0 4.987 .005l8.11 -13.539a2.914 2.914 0 0 0 -2.486 -4.386z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),lp=Pe("versions","IconVersions",[["path",{d:"M10 5m0 2a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]]),cp=Pe("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]),up=Pe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function dp(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return k.jsx(ki,{isLazy:!0,placement:"auto",children:({onClose:i})=>k.jsxs(k.Fragment,{children:[k.jsx(xi,{children:k.jsx(jt,{children:k.jsx(bt,{hasArrow:!0,label:s,placement:"bottom",children:k.jsx(un,{"aria-label":"Delete confirm",size:"sm",icon:k.jsx(ip,{color:"#F56565"}),isDisabled:o,variant:n})})})}),k.jsxs(Oi,{children:[k.jsx(Ei,{}),k.jsx(Si,{onClick:i}),k.jsxs(Ci,{children:[k.jsx(wt,{mb:4,pr:4,fontWeight:600,children:e}),k.jsx(Te,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function fp({onClose:t}){Ua();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=P.useContext(Ct),[s,i]=P.useState(0),[a,l]=P.useState(null),[u,c]=P.useState([]),[d,p]=P.useState([]),h=async m=>{var C;const y=await($==null?void 0:$.get(m)),g=await(Ge==null?void 0:Ge.listByWorkflowID(m));c(g??[]);const _=g==null?void 0:g.filter(D=>D.json===(y==null?void 0:y.json)),x=(C=_==null?void 0:_[0])==null?void 0:C.id;x&&l(x)},v=async()=>{const m=await(be==null?void 0:be.listByWorkflowID(e))??[];p(m)},f=m=>{be==null||be.delete(m).then(()=>{v()})};return P.useEffect(()=>{switch(s){case 0:v();break;case 1:h(e);break}},[s]),P.useEffect(()=>(we.canvasEl.addEventListener("click",t),()=>{we.canvasEl.removeEventListener("click",t)}),[s]),k.jsxs(hc,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[k.jsx(fc,{pb:1,mb:0,children:k.jsxs(Wt,{justifyContent:"space-between",alignItems:"center",children:[k.jsx(sn,{size:"md",children:"Version History"}),k.jsx(un,{size:"sm",icon:k.jsx(up,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),k.jsx(dc,{overflowY:"auto",gap:0,children:k.jsxs(Pi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[k.jsxs(Ai,{mb:"1em",children:[k.jsx(Ro,{children:"Versions"}),k.jsx(Ro,{children:"Change History"})]}),k.jsxs(Ni,{children:[k.jsx(Fo,{children:k.jsx(Ke,{divider:k.jsx(jo,{}),spacing:2,children:d==null?void 0:d.map(m=>k.jsxs(Wt,{w:"100%",mb:1,justify:"space-between",backgroundColor:m.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[k.jsxs(Ke,{textAlign:"left",gap:0,children:[k.jsx(wt,{fontWeight:"500",children:m.name??"untitled"}),k.jsxs(wt,{color:"GrayText",fontSize:"sm",children:["Created: ",ml(m.createTime)]})]}),k.jsxs(Wt,{alignItems:"center",gap:2,children:[k.jsx(Te,{size:"sm",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}we.loadGraphData(JSON.parse(m.json)),r(e,m.id),t()},children:"Load"}),k.jsx(dp,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(m.id)}})]})]},m.id))})}),k.jsxs(Fo,{children:[k.jsx(wt,{mb:4,children:"All the saved changes of this workflow"}),k.jsx(Ke,{divider:k.jsx(jo,{}),spacing:2,children:u==null?void 0:u.map(m=>k.jsxs(ot,{justifyContent:"space-between",children:[k.jsxs(Te,{size:"sm",variant:"ghost",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}we.loadGraphData(JSON.parse(m.json)),$==null||$.updateFlow(e,{json:m.json}),t()},isActive:m.id===a,children:["Saved at ",new Date(m.createTime).toLocaleString()]},m.id),m.isAutoSave?k.jsx(Gt,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},m.id))})]})]})]})})]})}function hp({workflowId:t,onClose:e}){const[n,r]=P.useState(""),[o,s]=P.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(be==null?void 0:be.listByWorkflowID(t))??[]).some(c=>c.name===l))s("The name is duplicated, please modify it and submit again.");else{const c=JSON.stringify(we.graph.serialize());await(be==null?void 0:be.add({name:n,workflowID:t,createTime:Date.now(),json:c})),e()}};return k.jsxs(Gr,{isOpen:!0,onClose:e,children:[k.jsx(ws,{}),k.jsxs(Zr,{children:[k.jsx(bs,{children:"Create Version"}),k.jsx(_s,{}),k.jsx(Jr,{children:k.jsxs(Yr,{isInvalid:!!o,children:[k.jsx(Qr,{children:"Name"}),k.jsx(gn,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&k.jsx(Xr,{children:o})]})}),k.jsxs(xs,{children:[k.jsx(Te,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),k.jsx(Te,{onClick:e,children:"Cancel"})]})]})]})}function pp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=P.useRef(null);return Bc({ref:o,handler:()=>r()}),k.jsxs(jt,{position:"relative",children:[k.jsx(jt,{children:e}),n&&k.jsx(jt,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function mp({menuButton:t,menuContent:e,onClose:n}){const r=P.useRef(),[o,s]=P.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return k.jsx(pp,{isOpen:o,onClose:i,menuButton:k.jsx(jt,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:k.jsx(Fs,{isOpen:!0,children:k.jsx(Rs,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}const kl="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function pm(){return localStorage.getItem(kl)}function mm(t){localStorage.setItem(kl,t)}function yp(t){return`https://civitai.com/api/download/models/${t}`}function vp(t,e){return e?`https://civitai.com/models/${t}?modelVersionId=${e}`:`https://civitai.com/models/${t}`}function El(t){return t.includes("huggingface")?t.replace("/resolve/","/blob/"):void 0}async function ym(t){var e,n;try{const r=`https://civitai.com/api/v1/model-versions/by-hash/${t}`,s=await(await fetch(r)).json();let i;if(await(G==null?void 0:G.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(e=s==null?void 0:s.images)==null?void 0:e[0])==null?void 0:n.url;else if(!s.model.nsfw){const l=s.images.find(u=>u.nsfwLevel==1);i=l==null?void 0:l.url}return{modelName:s.model.name,civitModelID:String(s.modelId),civitModelVersionID:String(s.id),imageUrl:i??void 0}}catch{return{}}}async function gp(t,e,n){const r=await ie.models.where("fileName").equals(t).toArray()??[],o=r.at(0);return{filename:t,nodeType:e,fileHash:(o==null?void 0:o.fileHash)??null,fileFolder:(o==null?void 0:o.fileFolder)??null,downloadUrl:o!=null&&o.civitModelVersionID?yp(o.civitModelVersionID):(o==null?void 0:o.downloadUrl)??null,inputName:n,length:r.length,infoUrl:o!=null&&o.civitModelID?vp(o.civitModelID,o.civitModelVersionID):El((o==null?void 0:o.downloadUrl)??"")??null}}async function wp(t){var p,h;let e=[],n={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],o=[".jpeg",".jpg",".png",".gif",".webp"],s=(h=(p=we.graph.extra)==null?void 0:p[qe])==null?void 0:h.deps,i=await we.graphToPrompt();Object.values(i.output).forEach(v=>{v.inputs&&Object.keys(v.inputs).forEach(f=>{var y,g;const m=(y=v.inputs)==null?void 0:y[f];typeof m=="string"&&(r.some(_=>m.endsWith(_))&&e.push(gp(m,v.class_type,f)),o.some(_=>m.endsWith(_))&&(n[m]=((g=s==null?void 0:s.images)==null?void 0:g[m])??{filename:m,nodeType:v.class_type}))})});const l=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:t.map(v=>v.type)})}).then(v=>v.ok?v.json():[]).catch(v=>(console.error("Error fetching node repos",v),[])),u=await Promise.all(e),c={};u.forEach(v=>{c[v.filename]=v});const d={};return Object.values(l).forEach(v=>{d[v.gitRepo]=v}),{models:c,images:n,nodeRepos:Object.values(d)}}function Cl(t,e){const n=new Blob([t],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${e}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}function bp(){const{setRoute:t,saveCurWorkflow:e}=P.useContext(Ct),[n,r]=P.useState(),[o,s]=P.useState({}),[i,a]=P.useState(!1),l=P.useCallback(async()=>{const f=we.graph.serialize();wp(f.nodes??[]).then(m=>{r(m)})},[]),u=P.useCallback(async()=>{r(void 0),await bf(),window.addEventListener("model_list_updated",()=>{l(),window.removeEventListener("model_list_updated",()=>{})})},[]);P.useEffect(()=>{l()},[]);const c=f=>!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(f),d=P.useCallback(f=>{let m=!0;return f.forEach(y=>{const g=y.filename;if(!y.downloadUrl){s(_=>({..._,[g]:"Invalid URL"})),m=!1;return}if(!c(y.downloadUrl)){s(_=>({..._,[g]:"Invalid URL"})),m=!1;return}if(!y.fileFolder){s(_=>({..._,[g]:"Model file not found, please re-scan models folder"})),m=!1;return}}),m},[]),p=async f=>{var E,F;f.preventDefault();const m=new FormData(f.target),y=Object.values((n==null?void 0:n.models)??{}).map(async I=>{var j,M;const R=(j=m.get(I.filename))==null?void 0:j.toString();if(R!=null&&R.length){const b=_p(I.filename);await ie.models.update(b+"@"+I.fileFolder,{downloadUrl:R})}const K=(M=I.infoUrl)!=null&&M.length?I.infoUrl:R?El(R):null;return{filename:I.filename,nodeType:I.nodeType,fileHash:I.fileHash,fileFolder:I.fileFolder,downloadUrl:R??I.downloadUrl??null,infoUrl:K??null,inputName:I.inputName}})??[],g=await Promise.all(y);if(!d(g))return;s({}),a(!0);const _=Object.values((n==null?void 0:n.images)??{}).filter(I=>!I.url).map(I=>I.filename),x=(n==null?void 0:n.images)??{};if(_.length){const R=await(await fetch("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:_})})).json();Object.keys(R).forEach(K=>{x!=null&&x[K]&&(x[K].url=R[K])})}a(!1);const C={};g.forEach(I=>{C[I.filename]=I});const D=we.graph.serialize();(E=D.extra||(D.extra={}))[qe]||(E[qe]={}),D.extra[qe].deps={models:C,images:x??{},nodeRepos:(n==null?void 0:n.nodeRepos)??[]},e(),console.log("json",D),Cl(JSON.stringify(D,null,2),(((F=$==null?void 0:$.curWorkflow)==null?void 0:F.name)??"unknown")+".runner")},h=Object.values((n==null?void 0:n.images)??{}),v=Object.values((n==null?void 0:n.models)??[]);return k.jsx(Gr,{isOpen:!0,onClose:()=>t("root"),size:"xl",children:k.jsx(Zr,{children:k.jsxs(Jr,{p:5,gap:5,children:[k.jsxs(ot,{children:[k.jsx(sn,{size:"md",children:"Workflow Resouce Dependencies"}),k.jsx(bt,{label:`.runner.json workflows include all resource dependecy download urls + `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:Eo(l),deleteEmptyFolder:!1})})).text()}catch(c){alert("Error deleting workflow .json file: "+c),console.error("Error deleting file:",c)}}t.deleteWorkflow=s;async function i({parentFolderID:l,name:c,json:u,id:d}){var v;let p=JSON.parse(u);p.extra==null&&(p.extra={}),p.extra[qe]==null&&(p.extra[qe]={}),p.extra[qe].id=d;const h={parentFolderPath:Ft(l??""),name:c,json:JSON.stringify(p)};try{const m=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).json();return m.name&&await((v=ie.workflows)==null?void 0:v.update(d,{name:m.name})),m}catch(f){return console.error(`Error creating file <${d}> at "${l}"`,f),alert(`Error creating file <${d}> at "${l}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:c,id:u}){const d=kr(l??"",c+".json");try{const h=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:u})})).json();return h.error&&(console.error(`Error getting file <${u}> at "${d}"`,h.error),alert({message:`Error getting file <${u}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${u}> at "${d}"`,p),{}}}t.getFile=a})(Qe||(Qe={}));async function Zs(t,e=!1,n=!1){try{return await(await fetch("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Ft(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function Dh(t,e){const n=Ft(t??""),o=(await Zs(n)).map(async a=>{var u;const l=a.name,c=[n,l].join("/");return jh(a)?{id:Ft(c),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((u=ie.workflows)==null?void 0:u.get(a.id))??{createTime:Date.now(),updateTime:Date.now()},id:a.id,json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime}}),s=await Promise.all(o);ie.workflows.bulkPut(s.filter(a=>!zh(a)));const i=s.filter(a=>a!=null);return Er(i,e??ct.RECENTLY_MODIFIED)}function jh(t){return"type"in t&&t.type==="folder"}const Wr=class Wr extends Xt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Wr}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await ie.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async listByIndex(n,r){const o=await super.listByIndex(n,r);return await(G==null?void 0:G.getSetting("twoWaySync"))?(await Promise.all(o.map(async a=>await this.get(a.id)))).filter(a=>a!=null):o}async generateUniqueName(n,r){if(await(G==null?void 0:G.getSetting("twoWaySync"))){const l=await Qe.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(a.includes(s)){let l=2,c=!0;for(;c;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,c=!1)}return s}async createFlow(n){const{name:r}=n,o=await this.generateUniqueName(r,n.parentFolderID??void 0),s=Date.now(),i={...n,id:n.id??ls(),json:n.json??JSON.stringify(Cr),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ie.workflows.add(i),this.saveDiskDB(),await(G==null?void 0:G.getSetting("twoWaySync"))?(await Qe.createWorkflow(i),await this.get(i.id)):(Dn(i),i)}async update(n,r){throw new Error("Method not allowed.")}async updateTopFields(n,r){return this._update(n,r)}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ie.workflows.update(n,r);const o=await ie.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var a;const o=await(G==null?void 0:G.getSetting("twoWaySync")),s=await this.get(n),i=await this.updateMetaInfo(n,r);!i||!s||(o?await Qe.moveWorkflow(s,r.parentFolderID):(await Dn(i),await Co(s),(i==null?void 0:i.parentFolderID)!=null&&await((a=ie.folders)==null?void 0:a.update(i.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Ge==null?void 0:Ge.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(G==null?void 0:G.getSetting("twoWaySync"))&&o&&await Qe.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const s=JSON.stringify(o.json),i=JSON.stringify(r.json);if(s===i)return;const a=await this._update(n,{updateTime:Date.now(),json:r.json});await(G==null?void 0:G.getSetting("twoWaySync"))?a&&await Qe.saveWorkflow(a):a&&await Dn(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const c=l.name&&r?l.name:await this.generateUniqueName(l.name,o),u=ls(),d=Date.now(),p={id:u,name:c,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(G==null?void 0:G.getSetting("twoWaySync")))try{const v=JSON.parse(l.json),f=(a=(i=v==null?void 0:v.extra)==null?void 0:i[qe])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Qe.createWorkflow(p)}catch(v){console.error("batchCreateFlows error",v)}else await Dn(p)}try{await ie.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&(await(G==null?void 0:G.getSetting("twoWaySync"))?await Qe.deleteWorkflow(r):Co({...r})),await ie.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ie.workflows.bulkGet(n);for(const o of r){if(!o)return;await(G==null?void 0:G.getSetting("twoWaySync"))?await Qe.deleteWorkflow(o):Co({...o})}await ie.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(G==null?void 0:G.getSetting("twoWaySync"))){const l=await Dh(n??null);return Er(l,r??ct.RECENTLY_MODIFIED)}const s=await this.listAll().then(l=>l.filter(c=>c.parentFolderID==n))??[],i=await(Le==null?void 0:Le.listAll().then(l=>l.filter(c=>c.parentFolderID==n)))??[],a=[...s,...i];return Er(a,r??ct.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(G==null?void 0:G.getSetting("twoWaySync")),s=await ie.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Qe.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(i.json)return{...s,json:JSON.stringify(i.json)}}async listAll(n){const r=await(G==null?void 0:G.getSetting("twoWaySync"));let o;if(r){const i=(await Zs("",!0)).filter(a=>(a==null?void 0:a.type)==="workflow").map(async a=>{const l=await ie.workflows.get(a.id);return a.updateTime=(l==null?void 0:l.updateTime)??Date.now(),l!=null&&l.lastOpenedTime&&(a.lastOpenedTime=l==null?void 0:l.lastOpenedTime),a});o=await Promise.all(i)}else o=await ie.workflows.toArray();return n?Er(o,n):o}async updateLastOpenedTime(n){await ie.workflows.update(n,{lastOpenedTime:Date.now()})}};Ie(Wr,"TABLE_NAME","workflows");let ds=Wr;const Ur=class Ur extends Xt{constructor(){super("folders")}static async load(){return new Ur}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(G==null?void 0:G.getSetting("twoWaySync")),o=await Dt.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:Dr(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await Dt.createFolder(s):(await ie.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(G==null?void 0:G.getSetting("twoWaySync")))return"parentFolderID"in n&&await Dt.moveFolder(e,n.parentFolderID??""),"name"in n&&await Dt.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const s="name"in n&&n.name!=o.name,i="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,a={...o,...n};return n.name!=null&&(a.updateTime=Date.now()),i&&(n.name=await this.generateUniqueName(a.name,a.parentFolderID??void 0)),await ie.folders.update(e,n),this.saveDiskDB(),(s||i)&&Ch(!0),a}async deleteFolder(e,n=xr.DELETE){if(await(G==null?void 0:G.getSetting("twoWaySync"))){await Zs(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&($==null||$.deleteFlow(l.id))})}),await Dt.deleteFolder(e);return}const o=await($==null?void 0:$.listAll())??[],s=await this.listAll(),i=[e];for(;i.length>0;){const a=i.shift();if(a){for(const c of o)if(c.parentFolderID===a)switch(n){case xr.DELETE:await($==null?void 0:$.deleteFlow(c.id));break;case xr.MOVE_TO_ROOT_FOLDER:await($==null?void 0:$.updateFolder(c.id,{parentFolderID:void 0}));break}await ie.folders.delete(a);const l=s.filter(c=>c.parentFolderID===a).map(c=>c.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(G==null?void 0:G.getSetting("twoWaySync")))return await Qe.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const s=await this.listAll().then(i=>i.filter(a=>a.parentFolderID==n).map(a=>a.name));if(s.includes(o)){let i=2,a=!0;for(;a;)s.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,a=!1)}return o}};Ie(Ur,"TABLE_NAME","folders");let fs=Ur;function Ph(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=o=>{const s=new Uint8Array(o.target.result),i=new DataView(s.buffer);i.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),n());let a=8;const l={};for(;aString.fromCharCode(f)).join("");l[p]=v}a+=12+c}e(l)},r.readAsArrayBuffer(t)})}function Ah(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function n(i,a,l){const c=t.slice(i,i+l);if(l===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,a);if(l===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,a)}const r=n(4,e,4);function o(i){const a=n(i,e,2),l={};for(let c=0;c{const n=new FileReader;n.onload=r=>{var l;const o=new Uint8Array((l=r==null?void 0:r.target)==null?void 0:l.result),s=new DataView(o.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let i=12;const a={};for(;i{const n=new FileReader;n.onload=r=>{const o=new Uint8Array(r.target.result),s=new DataView(o.buffer),i=new TextDecoder;if(s.getUint32(0)==440786851){let a=12;for(;a>8*(4-u)&~(1<<7*u),p=i.decode(o.slice(a+2+u,a+2+u+d)),h=JSON.parse(p);e(h);return}}a+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let a=o.length-4;for(;a>16;){if(s.getUint32(a)==1684108385&&s.getUint32(a-8)==2841865588){s.getUint32(a+4),s.getUint32(a+8);const l=s.getUint32(a-4)-4*4,c=i.decode(o.slice(a+12,a+12+l)),u=JSON.parse(c);e(u);return}a-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},n.readAsArrayBuffer(t)})}function Th(t){const e=t.split(".").pop();return fetch(t).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const r=t.split("/").pop()??"",o=new File([n],r);if(Fh(t))return Rh(o);if(e==="webp")return Nh(o);const s=await Ph(o),i=JSON.parse(s==null?void 0:s.prompt),a=JSON.parse(s==null?void 0:s.workflow);return{prompt:i,workflow:a}})}class vl extends Xt{constructor(){super("media")}async listByWorkflowID(e){return await ie.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r=await Th(`/workspace/view_media?filename=${e.localPath}`).catch(s=>(console.error("get meta error:",s),{prompt:""})),o={id:e.localPath,localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),workflowJSON:JSON.stringify(r==null?void 0:r.prompt),format:n};return await($==null?void 0:$.updateMetaInfo(e.workflowID,{latestImage:o.localPath})),ie.media.put(o),this.saveDiskDB(),o}async delete(e){var n,r;super.delete(e),((n=$==null?void 0:$.curWorkflow)==null?void 0:n.coverMediaPath)===e&&($==null||$.updateMetaInfo($.curWorkflow.id,{coverMediaPath:void 0})),((r=$==null?void 0:$.curWorkflow)==null?void 0:r.latestImage)===e&&($==null||$.updateMetaInfo($.curWorkflow.id,{latestImage:void 0}))}}Ie(vl,"TABLE_NAME","media");const um=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Mh={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function dm(t){return t.modelVersions!==void 0}function Bh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function fm(t,e){var r,o,s,i,a,l;if(!t)return;let n;return Bh(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(s=t.files)==null?void 0:s[0].name,sizeKB:(a=(i=t.files)==null?void 0:i[0])==null?void 0:a.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const Kr=class Kr extends Xt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);Ie(this,"_settings");this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S",openSpotlightSearch:"Control+P"},defaultFolders:Mh,autoSave:!1,autoSaveDuration:3,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.org",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:80,hideCoverImage:!1,disableUnsavedWarning:!1}}get settings(){return this._settings}get autoSave(){return this._autoSave}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return n==="shortcuts"&&(r!=null&&r.shortcuts)?{...this.defaultSettings.shortcuts,...r.shortcuts}:(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),this._settings={...this.defaultSettings,...o}}static async load(){const n=new Kr,r=await wf();return n.defaultSettings.myWorkflowsDir=r.path,await n.get(n.DEFAULT_USER).then(o=>{n._autoSave=(o==null?void 0:o.autoSave)??!1,n._settings={...n.defaultSettings,...o}}),await n.upsert({cloudHost:n.defaultSettings.cloudHost}),n}};Ie(Kr,"TABLE_NAME","userSettings");let hs=Kr;const $r=class $r extends Xt{constructor(){super("tags")}static async load(){return new $r}};Ie($r,"TABLE_NAME","tags");let ps=$r;const Vr=class Vr extends Xt{constructor(){super("workflowVersions")}static async load(){return new Vr}async listByWorkflowID(e){return await ie[this.tableName].where("workflowID").equals(e).reverse().sortBy("createTime")??[]}async getLatestByWorkflowID(e){const n=await this.listByWorkflowID(e);return n!=null&&n.length?n[0]:null}};Ie(Vr,"TABLE_NAME","workflowVersions");let ms=Vr;function zh(t){return"type"in t&&t.type==="folder"}let $=null,Sr=null,G=null,Le=null,Ge=null,Ht=null,be=null;async function Lh(){const t=async()=>{$=await ds.load()},e=async()=>{Sr=await ps.load()},n=async()=>{G=await hs.load()},r=async()=>{Le=await fs.load()},o=async()=>{Ge=await cs.load()},s=async()=>{Ht=new vl},i=async()=>{be=await ms.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Wh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Wh(){const t=async()=>{try{const a=await($==null?void 0:$.getRecords());a&&await ie.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(Le==null?void 0:Le.getRecords());a&&await ie.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Ht==null?void 0:Ht.getRecords());a&&await ie.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ge==null?void 0:Ge.getRecords());a&&await ie.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(Sr==null?void 0:Sr.getRecords());a&&await ie.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=G,l=await a.getRecords().then(c=>c[a.DEFAULT_USER]?c[a.DEFAULT_USER]:c);await ie.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(be==null?void 0:be.getRecords());a&&await ie.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const Ct=P.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{}}),hm=P.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),So={x:0,y:0};function Uh({children:t,onDragEnd:e,dragIconId:n}){const r=P.useRef(So),o=P.useRef(!1),[s,i]=P.useState(So),a=d=>{var p,h,v;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(v=(h=d.target)==null?void 0:h.parentNode)==null?void 0:v.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",c);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=P.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),c=P.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),So)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",c)},[e,l]),u={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return k.jsx("div",{style:u,onMouseDown:a,children:t})}var Kh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},$h=Object.defineProperty,Vh=Object.defineProperties,Hh=Object.getOwnPropertyDescriptors,zr=Object.getOwnPropertySymbols,gl=Object.prototype.hasOwnProperty,wl=Object.prototype.propertyIsEnumerable,ja=(t,e,n)=>e in t?$h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Pa=(t,e)=>{for(var n in e||(e={}))gl.call(e,n)&&ja(t,n,e[n]);if(zr)for(var n of zr(e))wl.call(e,n)&&ja(t,n,e[n]);return t},qh=(t,e)=>Vh(t,Hh(e)),Gh=(t,e)=>{var n={};for(var r in t)gl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&zr)for(var r of zr(t))e.indexOf(r)<0&&wl.call(t,r)&&(n[r]=t[r]);return n},Pe=(t,e,n)=>{const r=P.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:c=2,children:u}=i,d=Gh(i,["color","size","stroke","children"]);return P.createElement("svg",Pa(qh(Pa({ref:s},Kh),{width:l,height:l,stroke:a,strokeWidth:c,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>P.createElement(p,h)),...u||[]])});return r.propTypes={color:Mt.string,size:Mt.oneOfType([Mt.string,Mt.number]),stroke:Mt.oneOfType([Mt.string,Mt.number])},r.displayName=`${e}`,r},Zh=Pe("arrow-back-up-double","IconArrowBackUpDouble",[["path",{d:"M13 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M8 14l-4 -4l4 -4",key:"svg-1"}],["path",{d:"M9 10h7a4 4 0 1 1 0 8h-1",key:"svg-2"}]]),Jh=Pe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),ys=Pe("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]),Aa=Pe("download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]),bl=Pe("external-link","IconExternalLink",[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]]),Yh=Pe("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]),Xh=Pe("grip-vertical","IconGripVertical",[["path",{d:"M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}],["path",{d:"M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-4"}],["path",{d:"M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-5"}]]),Qh=Pe("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]),ep=Pe("info-circle","IconInfoCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 9h.01",key:"svg-1"}],["path",{d:"M11 12h1v4h1",key:"svg-2"}]]),tp=Pe("link","IconLink",[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]]),_l=Pe("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]),np=Pe("pencil","IconPencil",[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]]),rp=Pe("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]),op=Pe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),sp=Pe("refresh","IconRefresh",[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]]),ap=Pe("share-2","IconShare2",[["path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M12 14v-11",key:"svg-1"}],["path",{d:"M9 6l3 -3l3 3",key:"svg-2"}]]),ip=Pe("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]),xl=Pe("triangle-inverted-filled","IconTriangleInvertedFilled",[["path",{d:"M20.118 3h-16.225a2.914 2.914 0 0 0 -2.503 4.371l8.116 13.549a2.917 2.917 0 0 0 4.987 .005l8.11 -13.539a2.914 2.914 0 0 0 -2.486 -4.386z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),lp=Pe("versions","IconVersions",[["path",{d:"M10 5m0 2a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]]),cp=Pe("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]),up=Pe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function dp(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return k.jsx(ki,{isLazy:!0,placement:"auto",children:({onClose:i})=>k.jsxs(k.Fragment,{children:[k.jsx(xi,{children:k.jsx(jt,{children:k.jsx(bt,{hasArrow:!0,label:s,placement:"bottom",children:k.jsx(un,{"aria-label":"Delete confirm",size:"sm",icon:k.jsx(ip,{color:"#F56565",size:"20px"}),isDisabled:o,variant:n})})})}),k.jsxs(Oi,{children:[k.jsx(Ei,{}),k.jsx(Si,{onClick:i}),k.jsxs(Ci,{children:[k.jsx(wt,{mb:4,pr:4,fontWeight:600,children:e}),k.jsx(Te,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function fp({onClose:t}){Ua();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=P.useContext(Ct),[s,i]=P.useState(0),[a,l]=P.useState(null),[c,u]=P.useState([]),[d,p]=P.useState([]),h=async m=>{var C;const y=await($==null?void 0:$.get(m)),g=await(Ge==null?void 0:Ge.listByWorkflowID(m));u(g??[]);const _=g==null?void 0:g.filter(D=>D.json===(y==null?void 0:y.json)),x=(C=_==null?void 0:_[0])==null?void 0:C.id;x&&l(x)},v=async()=>{const m=await(be==null?void 0:be.listByWorkflowID(e))??[];p(m)},f=m=>{be==null||be.delete(m).then(()=>{v()})};return P.useEffect(()=>{switch(s){case 0:v();break;case 1:h(e);break}},[s]),P.useEffect(()=>(we.canvasEl.addEventListener("click",t),()=>{we.canvasEl.removeEventListener("click",t)}),[s]),k.jsxs(hc,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[k.jsx(fc,{pb:1,mb:0,children:k.jsxs(Wt,{justifyContent:"space-between",alignItems:"center",children:[k.jsx(sn,{size:"md",children:"Version History"}),k.jsx(un,{size:"sm",icon:k.jsx(up,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),k.jsx(dc,{overflowY:"auto",gap:0,children:k.jsxs(Pi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[k.jsxs(Ai,{mb:"1em",children:[k.jsx(Ro,{children:"Versions"}),k.jsx(Ro,{children:"Change History"})]}),k.jsxs(Ni,{children:[k.jsx(Fo,{children:k.jsx(Ke,{divider:k.jsx(jo,{}),spacing:2,children:d==null?void 0:d.map(m=>k.jsxs(Wt,{w:"100%",mb:1,justify:"space-between",backgroundColor:m.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[k.jsxs(Ke,{textAlign:"left",gap:0,children:[k.jsx(wt,{fontWeight:"500",children:m.name??"untitled"}),k.jsxs(wt,{color:"GrayText",fontSize:"sm",children:["Created: ",ml(m.createTime)]})]}),k.jsxs(Wt,{alignItems:"center",gap:2,children:[k.jsx(Te,{size:"sm",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}we.loadGraphData(JSON.parse(m.json)),r(e,m.id),t()},children:"Load"}),k.jsx(dp,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(m.id)}})]})]},m.id))})}),k.jsxs(Fo,{children:[k.jsx(wt,{mb:4,children:"All the saved changes of this workflow"}),k.jsx(Ke,{divider:k.jsx(jo,{}),spacing:2,children:c==null?void 0:c.map(m=>k.jsxs(ot,{justifyContent:"space-between",children:[k.jsxs(Te,{size:"sm",variant:"ghost",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}we.loadGraphData(JSON.parse(m.json)),$==null||$.updateFlow(e,{json:m.json}),t()},isActive:m.id===a,children:["Saved at ",new Date(m.createTime).toLocaleString()]},m.id),m.isAutoSave?k.jsx(Gt,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},m.id))})]})]})]})})]})}function hp({workflowId:t,onClose:e}){const[n,r]=P.useState(""),[o,s]=P.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(be==null?void 0:be.listByWorkflowID(t))??[]).some(u=>u.name===l))s("The name is duplicated, please modify it and submit again.");else{const u=JSON.stringify(we.graph.serialize());await(be==null?void 0:be.add({name:n,workflowID:t,createTime:Date.now(),json:u})),e()}};return k.jsxs(Gr,{isOpen:!0,onClose:e,children:[k.jsx(ws,{}),k.jsxs(Zr,{children:[k.jsx(bs,{children:"Create Version"}),k.jsx(_s,{}),k.jsx(Jr,{children:k.jsxs(Yr,{isInvalid:!!o,children:[k.jsx(Qr,{children:"Name"}),k.jsx(gn,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&k.jsx(Xr,{children:o})]})}),k.jsxs(xs,{children:[k.jsx(Te,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),k.jsx(Te,{onClick:e,children:"Cancel"})]})]})]})}function pp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=P.useRef(null);return Bc({ref:o,handler:()=>r()}),k.jsxs(jt,{position:"relative",children:[k.jsx(jt,{children:e}),n&&k.jsx(jt,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function mp({menuButton:t,menuContent:e,onClose:n}){const r=P.useRef(),[o,s]=P.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return k.jsx(pp,{isOpen:o,onClose:i,menuButton:k.jsx(jt,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:k.jsx(Fs,{isOpen:!0,children:k.jsx(Rs,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}const kl="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function pm(){return localStorage.getItem(kl)}function mm(t){localStorage.setItem(kl,t)}function yp(t){return`https://civitai.com/api/download/models/${t}`}function vp(t,e){return e?`https://civitai.com/models/${t}?modelVersionId=${e}`:`https://civitai.com/models/${t}`}function El(t){return t.includes("huggingface")?t.replace("/resolve/","/blob/"):void 0}async function ym(t){var e,n;try{const r=`https://civitai.com/api/v1/model-versions/by-hash/${t}`,s=await(await fetch(r)).json();let i;if(await(G==null?void 0:G.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(e=s==null?void 0:s.images)==null?void 0:e[0])==null?void 0:n.url;else if(!s.model.nsfw){const l=s.images.find(c=>c.nsfwLevel==1);i=l==null?void 0:l.url}return{modelName:s.model.name,civitModelID:String(s.modelId),civitModelVersionID:String(s.id),imageUrl:i??void 0}}catch{return{}}}async function gp(t,e,n){const r=await ie.models.where("fileName").equals(t).toArray()??[],o=r.at(0);return{filename:t,nodeType:e,fileHash:(o==null?void 0:o.fileHash)??null,fileFolder:(o==null?void 0:o.fileFolder)??null,downloadUrl:o!=null&&o.civitModelVersionID?yp(o.civitModelVersionID):(o==null?void 0:o.downloadUrl)??null,inputName:n,length:r.length,infoUrl:o!=null&&o.civitModelID?vp(o.civitModelID,o.civitModelVersionID):El((o==null?void 0:o.downloadUrl)??"")??null}}async function wp(t){var p,h;let e=[],n={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],o=[".jpeg",".jpg",".png",".gif",".webp"],s=(h=(p=we.graph.extra)==null?void 0:p[qe])==null?void 0:h.deps,i=await we.graphToPrompt();Object.values(i.output).forEach(v=>{v.inputs&&Object.keys(v.inputs).forEach(f=>{var y,g;const m=(y=v.inputs)==null?void 0:y[f];typeof m=="string"&&(r.some(_=>m.endsWith(_))&&e.push(gp(m,v.class_type,f)),o.some(_=>m.endsWith(_))&&(n[m]=((g=s==null?void 0:s.images)==null?void 0:g[m])??{filename:m,nodeType:v.class_type}))})});const l=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:t.map(v=>v.type)})}).then(v=>v.ok?v.json():[]).catch(v=>(console.error("Error fetching node repos",v),[])),c=await Promise.all(e),u={};c.forEach(v=>{u[v.filename]=v});const d={};return Object.values(l).forEach(v=>{d[v.gitRepo]=v}),{models:u,images:n,nodeRepos:Object.values(d)}}function Cl(t,e){const n=new Blob([t],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${e}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}function bp(){const{setRoute:t,saveCurWorkflow:e}=P.useContext(Ct),[n,r]=P.useState(),[o,s]=P.useState({}),[i,a]=P.useState(!1),l=P.useCallback(async()=>{const f=we.graph.serialize();wp(f.nodes??[]).then(m=>{r(m)})},[]),c=P.useCallback(async()=>{r(void 0),await bf(),window.addEventListener("model_list_updated",()=>{l(),window.removeEventListener("model_list_updated",()=>{})})},[]);P.useEffect(()=>{l()},[]);const u=f=>!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(f),d=P.useCallback(f=>{let m=!0;return f.forEach(y=>{const g=y.filename;if(!y.downloadUrl){s(_=>({..._,[g]:"Invalid URL"})),m=!1;return}if(!u(y.downloadUrl)){s(_=>({..._,[g]:"Invalid URL"})),m=!1;return}if(!y.fileFolder){s(_=>({..._,[g]:"Model file not found, please re-scan models folder"})),m=!1;return}}),m},[]),p=async f=>{var E,F;f.preventDefault();const m=new FormData(f.target),y=Object.values((n==null?void 0:n.models)??{}).map(async I=>{var j,M;const R=(j=m.get(I.filename))==null?void 0:j.toString();if(R!=null&&R.length){const b=_p(I.filename);await ie.models.update(b+"@"+I.fileFolder,{downloadUrl:R})}const K=(M=I.infoUrl)!=null&&M.length?I.infoUrl:R?El(R):null;return{filename:I.filename,nodeType:I.nodeType,fileHash:I.fileHash,fileFolder:I.fileFolder,downloadUrl:R??I.downloadUrl??null,infoUrl:K??null,inputName:I.inputName}})??[],g=await Promise.all(y);if(!d(g))return;s({}),a(!0);const _=Object.values((n==null?void 0:n.images)??{}).filter(I=>!I.url).map(I=>I.filename),x=(n==null?void 0:n.images)??{};if(_.length){const R=await(await fetch("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:_})})).json();Object.keys(R).forEach(K=>{x!=null&&x[K]&&(x[K].url=R[K])})}a(!1);const C={};g.forEach(I=>{C[I.filename]=I});const D=we.graph.serialize();(E=D.extra||(D.extra={}))[qe]||(E[qe]={}),D.extra[qe].deps={models:C,images:x??{},nodeRepos:(n==null?void 0:n.nodeRepos)??[]},e(),console.log("json",D),Cl(JSON.stringify(D,null,2),(((F=$==null?void 0:$.curWorkflow)==null?void 0:F.name)??"unknown")+".runner")},h=Object.values((n==null?void 0:n.images)??{}),v=Object.values((n==null?void 0:n.models)??[]);return k.jsx(Gr,{isOpen:!0,onClose:()=>t("root"),size:"xl",children:k.jsx(Zr,{children:k.jsxs(Jr,{p:5,gap:5,children:[k.jsxs(ot,{children:[k.jsx(sn,{size:"md",children:"Workflow Resouce Dependencies"}),k.jsx(bt,{label:`.runner.json workflows include all resource dependecy download urls (models, cursom nodes, input images) and can be one-click - installed and run in any ComfyUI with workpace-manager installed.`,children:k.jsx(oi,{borderRadius:10,children:k.jsx(ep,{size:20})})})]}),k.jsx(wt,{color:"GrayText",children:"Export one-click installable workflow"}),n==null&&k.jsx(Xs,{size:"md",color:"teal.400"}),n&&k.jsx("form",{onSubmit:p,children:k.jsxs(Ke,{gap:5,mt:5,children:[k.jsxs(Ke,{children:[k.jsxs(sn,{size:"sm",children:["Models (",v.length,")"]}),v.map((f,m)=>k.jsx(xp,{modelFile:f,errors:o,onClickRefetchModelList:u},m))]}),h.length>0&&k.jsxs(Ke,{children:[k.jsxs(ot,{children:[k.jsxs(sn,{size:"sm",children:["Images (",h.length,")"]}),k.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),i&&k.jsxs("span",{children:[k.jsx(Xs,{size:"md",color:"teal.400"})," Uploading"]}),h.map(f=>k.jsxs(Ke,{children:[k.jsx("p",{children:f.filename}),k.jsx(Ha,{width:250,src:`/workspace/view_media?filename=${f.filename}&isPreview=true&isInput=true`})]},f.filename))]}),k.jsx(Te,{width:"fit-content",colorScheme:"teal",type:"submit",mt:4,children:"Download .runner.json"})]})})]})})})}function _p(t){const e=t.split(".");return e.length>1?(e.pop(),e.join(".")):t}function xp({modelFile:t,errors:e,onClickRefetchModelList:n}){const r=t.filename,[o,s]=P.useState(!t.downloadUrl);return t.fileFolder?k.jsxs(Ke,{ml:2,children:[k.jsxs(Wt,{gap:2,children:[k.jsx(Gt,{height:"fit-content",colorScheme:"teal",children:t.fileFolder}),t.downloadUrl?k.jsxs(ot,{children:[k.jsx("a",{href:t.infoUrl??t.downloadUrl,target:"_blank",children:t.filename}),k.jsx(bl,{size:18}),k.jsx(un,{ml:3,"aria-label":"edit",icon:k.jsx(np,{size:18}),size:"xs",onClick:()=>s(!o)})]}):k.jsx(Ke,{children:k.jsxs("span",{children:[t.filename," ",k.jsx("span",{children:"❓"})]})})]},t.filename+t.nodeType),k.jsx(Ke,{style:{display:o?"block":"none"},children:k.jsx(bt,{label:"Model download link, supports Huggingface and Civitai",children:k.jsx(gn,{name:r,defaultValue:t.downloadUrl??"",size:"sm",isInvalid:e[r]!=null,placeholder:"https://civitai.com/api/download/models/324524"})})}),k.jsx(wt,{color:"red.400",children:e[r]})]}):k.jsxs(Ke,{children:[k.jsxs(Wt,{gap:2,children:[k.jsx("p",{children:t.filename}),k.jsx(Gt,{size:"sm",colorScheme:"red",children:"Model file not found"})]}),k.jsx(Te,{size:"sm",leftIcon:k.jsx(sp,{}),width:"fit-content",borderColor:"red",borderWidth:e[r]!=null?2:0,onClick:n,children:"Fetch model file"})]})}const kp=P.lazy(()=>yn(()=>import("./ShareDialog-ABShBZ_r.js"),__vite__mapDeps([0,1,2,3,4])));function Ep(){var D;const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=P.useContext(Ct),[i,a]=P.useState(!1),[l,u]=P.useState(""),[c,d]=P.useState(""),[p,h]=P.useState(),[v,f]=P.useState({save:"",saveAs:""}),[m,y]=P.useState(!1);P.useEffect(()=>{t&&($==null||$.get(t).then(E=>{u((E==null?void 0:E.name)??""),h(E)})),G==null||G.getSetting("shortcuts").then(E=>{f(E)})},[t]);const g=E=>{u(E.target.value),c&&d("")},_=async()=>{if(!t){alert("Flow ID is required");return}const E=JSON.stringify(we.graph.serialize()),F=await($==null?void 0:$.createFlow({json:E,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));F&&await e(F.id,null,!0),x()},x=()=>{o("root")},C=P.useCallback(async()=>{const E=$==null?void 0:$.curWorkflow;if(!E){alert("No current workflow!");return}const F=we.graph.serialize(),I=JSON.stringify(F,null,2);Cl(I,E.name)},[t]);return k.jsxs(k.Fragment,{children:[k.jsx(mp,{menuButton:k.jsx(Ba,{children:k.jsxs(Te,{px:1,height:us+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",k.jsx(Jh,{size:20})]})}),menuContent:k.jsx(Fs,{isOpen:!0,children:k.jsxs(Rs,{minWidth:150,zIndex:1e3,children:[k.jsx(mt,{onClick:r,icon:k.jsx(ys,{size:20}),iconSpacing:1,command:v.save,children:"Save"}),!((D=G==null?void 0:G.settings)!=null&&D.autoSave)&&k.jsx(bt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:k.jsx(mt,{onClick:n,icon:k.jsx(Zh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),k.jsx(mt,{onClick:C,icon:k.jsx(Aa,{size:20}),iconSpacing:1,children:"Download"}),k.jsxs(mt,{onClick:()=>o("downloadSpaceJson"),icon:k.jsx(Aa,{size:20}),iconSpacing:1,children:["Download .runner.json ",k.jsx(Gt,{size:"sm",children:"🧪beta"})]}),k.jsx(mt,{onClick:()=>o("saveAsModal"),icon:k.jsx(ys,{size:20}),iconSpacing:1,command:v.saveAs,children:"Save As"}),k.jsx(mt,{onClick:()=>a(!0),icon:k.jsx(lp,{size:20}),iconSpacing:1,children:"Create Version"}),k.jsx(mt,{onClick:()=>o("versionHistory"),icon:k.jsx(Qh,{size:20}),iconSpacing:1,children:"Versions History"}),k.jsx(mt,{onClick:()=>y(!0),icon:k.jsx(ap,{size:20}),iconSpacing:1,alignItems:"center",children:k.jsxs(ot,{children:[k.jsx("p",{children:"Share"})," ",k.jsx(Gt,{size:"sm",children:"🧪beta"})]})})]})})}),m&&k.jsx(kp,{onClose:()=>y(!1)}),s=="versionHistory"&&k.jsx(fp,{onClose:()=>o("root")}),s=="downloadSpaceJson"&&k.jsx(bp,{}),s==="saveAsModal"&&k.jsxs(Gr,{isOpen:!0,onClose:x,children:[k.jsx(ws,{}),k.jsxs(Zr,{children:[k.jsx(bs,{children:"Save As"}),k.jsx(_s,{}),k.jsx(Jr,{children:k.jsxs(Yr,{isInvalid:!!c,children:[k.jsx(Qr,{children:"Workflow name"}),k.jsx(gn,{value:l,onChange:g,autoFocus:!0,onKeyUp:E=>{E.code==="Enter"&&!c&&l&&_()}}),c&&k.jsx(Xr,{children:c})]})}),k.jsxs(xs,{children:[k.jsx(Te,{colorScheme:"teal",mr:3,onClick:_,isDisabled:!l||!!c,children:"Save"}),k.jsx(Te,{onClick:x,children:"Cancel"})]})]})]}),i&&k.jsx(hp,{workflowId:t,onClose:()=>a(!1)})]})}function Cp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Wc(),{curFlowID:i}=P.useContext(Ct),[a,l]=P.useState(t),[u,c]=P.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),u&&c("")},h=async()=>{var f;if(i){const m=a.trim();if(l(m),t===m)return v();await($==null?void 0:$.generateUniqueName(m,((f=$.curWorkflow)==null?void 0:f.parentFolderID)??""))!==m?c("The name is duplicated, please modify it and submit again."):(await($==null?void 0:$.updateName(i,{name:m})),e(m),v())}},v=()=>{c(""),s()};return i==null?null:k.jsxs(ot,{children:[k.jsx(bt,{label:t,placement:"bottom",children:k.jsxs(wt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[k.jsx("div",{style:{width:8,display:"inline-block"},children:k.jsx(wt,{as:"span",children:n&&"* "})}),t]})}),k.jsxs(Gr,{isOpen:r,onClose:v,children:[k.jsx(ws,{}),k.jsxs(Zr,{children:[k.jsx(bs,{children:"Edit workflow name"}),k.jsx(_s,{}),k.jsx(Jr,{children:k.jsxs(Yr,{isInvalid:!!u,children:[k.jsx(Qr,{children:"Workflow name"}),k.jsx(gn,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!u&&a&&h()}}),u&&k.jsx(Xr,{children:u})]})}),k.jsxs(xs,{children:[k.jsx(Te,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!u,children:"Save"}),k.jsx(Te,{onClick:v,children:"Cancel"})]})]})]})]})}function vm(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const gm=[{label:"Private",value:"PRIVATE",icon:k.jsx(_l,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:k.jsx(tp,{})},{label:"Public",value:"PUBLIC",icon:k.jsx(cp,{})}],wm=()=>{const t=we.graph._nodes,e={};for(let n of t)if(n.type in LiteGraph.registered_node_types){const r=structuredClone(LiteGraph.registered_node_types[n.type].nodeData);if(r==null)continue;for(let o in r.input){const s=r.input[o];for(let i in s){const a=s[i];Array.isArray(a[0])&&(a[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function Sp(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function bm({privacy:t,showEmoji:e=!1}){let n;return t==="PRIVATE"?(n="Private",e&&(n="🔒 Private")):t==="UNLISTED"?(n="Unlisted",e&&(n="🔗 Unlisted")):t==="PUBLIC"&&(n="Public",e&&(n="🌐 Public")),k.jsx("span",{children:n})}function Ip({}){const[t,e]=P.useState(),[n,r]=P.useState(),{curFlowID:o}=P.useContext(Ct);return P.useEffect(()=>{o&&($==null||$.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),Sp(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?k.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:k.jsx(Ba,{children:k.jsx(Gt,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}function Op({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=P.useContext(Ct);return P.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?k.jsx(Wt,{alignItems:"center",children:k.jsx(qa,{size:"sm",isAttached:!0,variant:"outline",children:k.jsx(Te,{rightIcon:k.jsx(xl,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}const Dp=P.lazy(()=>yn(()=>import("./AppIsDirtyEventListener-BH8Pedq1.js"),__vite__mapDeps([5,1,6]))),jp=P.lazy(()=>yn(()=>import("./ModelManagerTopbar-jwv1A1hH.js").then(t=>t.M),__vite__mapDeps([7,1,8,2,9,10]))),Pp=P.lazy(()=>yn(()=>import("./SpotlightSearch-ysZyuBYf.js"),__vite__mapDeps([11,1,6,12,13])));function Ap({curFlowName:t,setCurFlowName:e}){var d;const{isDirty:n,loadNewWorkflow:r,saveCurWorkflow:o,setRoute:s,curFlowID:i,route:a}=P.useContext(Ct),[l,u]=P.useState(),c=P.useCallback((p,h=!1)=>{const{top:v=0,left:f=0}=l||{};let{top:m=0,left:y=0}=p??{};m+=v,y+=f;const g=document.documentElement.clientWidth,_=document.documentElement.clientHeight,x=document.getElementById("workspaceManagerPanel"),C=(x==null?void 0:x.offsetWidth)||392;m+36>_&&(m=_-36),y+C>=g&&(y=g-C),u({top:Math.max(0,m),left:Math.max(0,y)}),h&&(G==null||G.upsert({topBarStyle:{top:m,left:y}}))},[l]);return P.useEffect(()=>{G==null||G.getSetting("topBarStyle").then(p=>{c(p,!1)})},[]),l?k.jsx(Uh,{onDragEnd:p=>{c({top:p.y,left:p.x},!0)},dragIconId:"dragPanelIcon",children:k.jsxs(ot,{style:{padding:2,position:"fixed",...l},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[k.jsx(Te,{size:"sm","aria-label":"workspace folder",height:us+"px",onClick:()=>s("recentFlows"),px:2,children:k.jsxs(ot,{gap:1,children:[k.jsx(Yh,{size:21}),k.jsx(xl,{size:8})]})}),k.jsx(P.Suspense,{fallback:k.jsx("div",{style:{width:"60px"}}),children:k.jsx(jp,{})}),k.jsx(bt,{label:"New workflow",children:k.jsx(Te,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:us+"px",onClick:()=>r(),px:1,children:k.jsx(ot,{gap:0,children:k.jsx(op,{size:16,color:"white"})})})}),k.jsx(Cp,{isDirty:n,displayName:t??"",updateFlowName:p=>{e(p),requestAnimationFrame(()=>{c()})}}),((d=$==null?void 0:$.curWorkflow)==null?void 0:d.saveLock)&&k.jsx(_l,{color:"#FFF",size:20}),i&&k.jsxs(ot,{gap:"4px",children:[k.jsx(bt,{label:"Open gallery",children:k.jsx(un,{onClick:()=>s("gallery"),icon:k.jsx(rp,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),k.jsx(Ep,{})]}),i&&n?k.jsx(bt,{label:"Save workflow",children:k.jsx(un,{onClick:o,icon:k.jsx(ys,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):k.jsx("div",{style:{width:1}}),k.jsx(Ip,{}),k.jsx(Op,{}),k.jsx(Dp,{}),k.jsx(Xh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"}),a==="spotlightSearch"&&k.jsx(Pp,{})]})}):null}function Np(){const{showDialog:t}=za(),{loadWorkflowID:e}=P.useContext(Ct),n=async(o,s)=>{var u,c;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(u=await($==null?void 0:$.listByIndex("cloudID",i.id)))==null?void 0:u.at(0);if(l){const d=(c=await(be==null?void 0:be.listByIndex("cloudID",a.id)))==null?void 0:c.at(0);if(d)await e(l.id,d.id);else{const p=await(be==null?void 0:be.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json}));p&&e(l.id,p.id)}}else{const d=await($==null?void 0:$.createFlow({cloudID:i.id,cloudOrigin:s,name:i.name,json:a.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}const p=await(be==null?void 0:be.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(Fp(s)){const i=o.origin;t(`Open workflow "${s.detail.workflow.name}", version "${s.detail.version.name}" from ${i}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(s,i)}}])}};return P.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function Fp(t){return t.type==="workspace_open_workflow"}const Rp=t=>typeof t=="function",Tp=t=>{const[e,n]=P.useState(t),r=P.useRef(e),o=P.useCallback(s=>{r.current=Rp(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function fr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sl={exports:{}};/*! + installed and run in any ComfyUI with workpace-manager installed.`,children:k.jsx(oi,{borderRadius:10,children:k.jsx(ep,{size:20})})})]}),k.jsx(wt,{color:"GrayText",children:"Export one-click installable workflow"}),n==null&&k.jsx(Xs,{size:"md",color:"teal.400"}),n&&k.jsx("form",{onSubmit:p,children:k.jsxs(Ke,{gap:5,mt:5,children:[k.jsxs(Ke,{children:[k.jsxs(sn,{size:"sm",children:["Models (",v.length,")"]}),v.map((f,m)=>k.jsx(xp,{modelFile:f,errors:o,onClickRefetchModelList:c},m))]}),h.length>0&&k.jsxs(Ke,{children:[k.jsxs(ot,{children:[k.jsxs(sn,{size:"sm",children:["Images (",h.length,")"]}),k.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),i&&k.jsxs("span",{children:[k.jsx(Xs,{size:"md",color:"teal.400"})," Uploading"]}),h.map(f=>k.jsxs(Ke,{children:[k.jsx("p",{children:f.filename}),k.jsx(Ha,{width:250,src:`/workspace/view_media?filename=${f.filename}&isPreview=true&isInput=true`})]},f.filename))]}),k.jsx(Te,{width:"fit-content",colorScheme:"teal",type:"submit",mt:4,children:"Download .runner.json"})]})})]})})})}function _p(t){const e=t.split(".");return e.length>1?(e.pop(),e.join(".")):t}function xp({modelFile:t,errors:e,onClickRefetchModelList:n}){const r=t.filename,[o,s]=P.useState(!t.downloadUrl);return t.fileFolder?k.jsxs(Ke,{ml:2,children:[k.jsxs(Wt,{gap:2,children:[k.jsx(Gt,{height:"fit-content",colorScheme:"teal",children:t.fileFolder}),t.downloadUrl?k.jsxs(ot,{children:[k.jsx("a",{href:t.infoUrl??t.downloadUrl,target:"_blank",children:t.filename}),k.jsx(bl,{size:18}),k.jsx(un,{ml:3,"aria-label":"edit",icon:k.jsx(np,{size:18}),size:"xs",onClick:()=>s(!o)})]}):k.jsx(Ke,{children:k.jsxs("span",{children:[t.filename," ",k.jsx("span",{children:"❓"})]})})]},t.filename+t.nodeType),k.jsx(Ke,{style:{display:o?"block":"none"},children:k.jsx(bt,{label:"Model download link, supports Huggingface and Civitai",children:k.jsx(gn,{name:r,defaultValue:t.downloadUrl??"",size:"sm",isInvalid:e[r]!=null,placeholder:"https://civitai.com/api/download/models/324524"})})}),k.jsx(wt,{color:"red.400",children:e[r]})]}):k.jsxs(Ke,{children:[k.jsxs(Wt,{gap:2,children:[k.jsx("p",{children:t.filename}),k.jsx(Gt,{size:"sm",colorScheme:"red",children:"Model file not found"})]}),k.jsx(Te,{size:"sm",leftIcon:k.jsx(sp,{}),width:"fit-content",borderColor:"red",borderWidth:e[r]!=null?2:0,onClick:n,children:"Fetch model file"})]})}const kp=P.lazy(()=>yn(()=>import("./ShareDialog-uq7XVWvD.js"),__vite__mapDeps([0,1,2,3,4])));function Ep(){var D;const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=P.useContext(Ct),[i,a]=P.useState(!1),[l,c]=P.useState(""),[u,d]=P.useState(""),[p,h]=P.useState(),[v,f]=P.useState({save:"",saveAs:""}),[m,y]=P.useState(!1);P.useEffect(()=>{t&&($==null||$.get(t).then(E=>{c((E==null?void 0:E.name)??""),h(E)})),G==null||G.getSetting("shortcuts").then(E=>{f(E)})},[t]);const g=E=>{c(E.target.value),u&&d("")},_=async()=>{if(!t){alert("Flow ID is required");return}const E=JSON.stringify(we.graph.serialize()),F=await($==null?void 0:$.createFlow({json:E,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));F&&await e(F.id,null,!0),x()},x=()=>{o("root")},C=P.useCallback(async()=>{const E=$==null?void 0:$.curWorkflow;if(!E){alert("No current workflow!");return}const F=we.graph.serialize(),I=JSON.stringify(F,null,2);Cl(I,E.name)},[t]);return k.jsxs(k.Fragment,{children:[k.jsx(mp,{menuButton:k.jsx(Ba,{children:k.jsxs(Te,{px:1,height:us+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",k.jsx(Jh,{size:20})]})}),menuContent:k.jsx(Fs,{isOpen:!0,children:k.jsxs(Rs,{minWidth:150,zIndex:1e3,children:[k.jsx(mt,{onClick:r,icon:k.jsx(ys,{size:20}),iconSpacing:1,command:v.save,children:"Save"}),!((D=G==null?void 0:G.settings)!=null&&D.autoSave)&&k.jsx(bt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:k.jsx(mt,{onClick:n,icon:k.jsx(Zh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),k.jsx(mt,{onClick:C,icon:k.jsx(Aa,{size:20}),iconSpacing:1,children:"Download"}),k.jsxs(mt,{onClick:()=>o("downloadSpaceJson"),icon:k.jsx(Aa,{size:20}),iconSpacing:1,children:["Download .runner.json ",k.jsx(Gt,{size:"sm",children:"🧪beta"})]}),k.jsx(mt,{onClick:()=>o("saveAsModal"),icon:k.jsx(ys,{size:20}),iconSpacing:1,command:v.saveAs,children:"Save As"}),k.jsx(mt,{onClick:()=>a(!0),icon:k.jsx(lp,{size:20}),iconSpacing:1,children:"Create Version"}),k.jsx(mt,{onClick:()=>o("versionHistory"),icon:k.jsx(Qh,{size:20}),iconSpacing:1,children:"Versions History"}),k.jsx(mt,{onClick:()=>y(!0),icon:k.jsx(ap,{size:20}),iconSpacing:1,alignItems:"center",children:k.jsxs(ot,{children:[k.jsx("p",{children:"Share"})," ",k.jsx(Gt,{size:"sm",children:"🧪beta"})]})})]})})}),m&&k.jsx(kp,{onClose:()=>y(!1)}),s=="versionHistory"&&k.jsx(fp,{onClose:()=>o("root")}),s=="downloadSpaceJson"&&k.jsx(bp,{}),s==="saveAsModal"&&k.jsxs(Gr,{isOpen:!0,onClose:x,children:[k.jsx(ws,{}),k.jsxs(Zr,{children:[k.jsx(bs,{children:"Save As"}),k.jsx(_s,{}),k.jsx(Jr,{children:k.jsxs(Yr,{isInvalid:!!u,children:[k.jsx(Qr,{children:"Workflow name"}),k.jsx(gn,{value:l,onChange:g,autoFocus:!0,onKeyUp:E=>{E.code==="Enter"&&!u&&l&&_()}}),u&&k.jsx(Xr,{children:u})]})}),k.jsxs(xs,{children:[k.jsx(Te,{colorScheme:"teal",mr:3,onClick:_,isDisabled:!l||!!u,children:"Save"}),k.jsx(Te,{onClick:x,children:"Cancel"})]})]})]}),i&&k.jsx(hp,{workflowId:t,onClose:()=>a(!1)})]})}function Cp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Wc(),{curFlowID:i}=P.useContext(Ct),[a,l]=P.useState(t),[c,u]=P.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),c&&u("")},h=async()=>{var f;if(i){const m=a.trim();if(l(m),t===m)return v();await($==null?void 0:$.generateUniqueName(m,((f=$.curWorkflow)==null?void 0:f.parentFolderID)??""))!==m?u("The name is duplicated, please modify it and submit again."):(await($==null?void 0:$.updateName(i,{name:m})),e(m),v())}},v=()=>{u(""),s()};return i==null?null:k.jsxs(ot,{children:[k.jsx(bt,{label:t,placement:"bottom",children:k.jsxs(wt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[k.jsx("div",{style:{width:8,display:"inline-block"},children:k.jsx(wt,{as:"span",children:n&&"* "})}),t]})}),k.jsxs(Gr,{isOpen:r,onClose:v,children:[k.jsx(ws,{}),k.jsxs(Zr,{children:[k.jsx(bs,{children:"Edit workflow name"}),k.jsx(_s,{}),k.jsx(Jr,{children:k.jsxs(Yr,{isInvalid:!!c,children:[k.jsx(Qr,{children:"Workflow name"}),k.jsx(gn,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!c&&a&&h()}}),c&&k.jsx(Xr,{children:c})]})}),k.jsxs(xs,{children:[k.jsx(Te,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!c,children:"Save"}),k.jsx(Te,{onClick:v,children:"Cancel"})]})]})]})]})}function vm(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const gm=[{label:"Private",value:"PRIVATE",icon:k.jsx(_l,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:k.jsx(tp,{})},{label:"Public",value:"PUBLIC",icon:k.jsx(cp,{})}],wm=()=>{const t=we.graph._nodes,e={};for(let n of t)if(n.type in LiteGraph.registered_node_types){const r=structuredClone(LiteGraph.registered_node_types[n.type].nodeData);if(r==null)continue;for(let o in r.input){const s=r.input[o];for(let i in s){const a=s[i];Array.isArray(a[0])&&(a[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function Sp(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function bm({privacy:t,showEmoji:e=!1}){let n;return t==="PRIVATE"?(n="Private",e&&(n="🔒 Private")):t==="UNLISTED"?(n="Unlisted",e&&(n="🔗 Unlisted")):t==="PUBLIC"&&(n="Public",e&&(n="🌐 Public")),k.jsx("span",{children:n})}function Ip({}){const[t,e]=P.useState(),[n,r]=P.useState(),{curFlowID:o}=P.useContext(Ct);return P.useEffect(()=>{o&&($==null||$.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),Sp(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?k.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:k.jsx(Ba,{children:k.jsx(Gt,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}function Op({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=P.useContext(Ct);return P.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?k.jsx(Wt,{alignItems:"center",children:k.jsx(qa,{size:"sm",isAttached:!0,variant:"outline",children:k.jsx(Te,{rightIcon:k.jsx(xl,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}const Dp=P.lazy(()=>yn(()=>import("./AppIsDirtyEventListener-09XYx3lY.js"),__vite__mapDeps([5,1,6]))),jp=P.lazy(()=>yn(()=>import("./ModelManagerTopbar-wj7k34WI.js").then(t=>t.M),__vite__mapDeps([7,1,8,2,9,10]))),Pp=P.lazy(()=>yn(()=>import("./SpotlightSearch-TbsT5AM9.js"),__vite__mapDeps([11,1,6,12,13])));function Ap({curFlowName:t,setCurFlowName:e}){var d;const{isDirty:n,loadNewWorkflow:r,saveCurWorkflow:o,setRoute:s,curFlowID:i,route:a}=P.useContext(Ct),[l,c]=P.useState(),u=P.useCallback((p,h=!1)=>{const{top:v=0,left:f=0}=l||{};let{top:m=0,left:y=0}=p??{};m+=v,y+=f;const g=document.documentElement.clientWidth,_=document.documentElement.clientHeight,x=document.getElementById("workspaceManagerPanel"),C=(x==null?void 0:x.offsetWidth)||392;m+36>_&&(m=_-36),y+C>=g&&(y=g-C),c({top:Math.max(0,m),left:Math.max(0,y)}),h&&(G==null||G.upsert({topBarStyle:{top:m,left:y}}))},[l]);return P.useEffect(()=>{G==null||G.getSetting("topBarStyle").then(p=>{u(p,!1)})},[]),l?k.jsx(Uh,{onDragEnd:p=>{u({top:p.y,left:p.x},!0)},dragIconId:"dragPanelIcon",children:k.jsxs(ot,{style:{padding:2,position:"fixed",...l},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[k.jsx(Te,{size:"sm","aria-label":"workspace folder",height:us+"px",onClick:()=>s("recentFlows"),px:2,children:k.jsxs(ot,{gap:1,children:[k.jsx(Yh,{size:21}),k.jsx(xl,{size:8})]})}),k.jsx(P.Suspense,{fallback:k.jsx("div",{style:{width:"60px"}}),children:k.jsx(jp,{})}),k.jsx(bt,{label:"New workflow",children:k.jsx(Te,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:us+"px",onClick:()=>r(),px:1,children:k.jsx(ot,{gap:0,children:k.jsx(op,{size:16,color:"white"})})})}),k.jsx(Cp,{isDirty:n,displayName:t??"",updateFlowName:p=>{e(p),requestAnimationFrame(()=>{u()})}}),((d=$==null?void 0:$.curWorkflow)==null?void 0:d.saveLock)&&k.jsx(_l,{color:"#FFF",size:20}),i&&k.jsxs(ot,{gap:"4px",children:[k.jsx(bt,{label:"Open gallery",children:k.jsx(un,{onClick:()=>s("gallery"),icon:k.jsx(rp,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),k.jsx(Ep,{})]}),i&&n?k.jsx(bt,{label:"Save workflow",children:k.jsx(un,{onClick:o,icon:k.jsx(ys,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):k.jsx("div",{style:{width:1}}),k.jsx(Ip,{}),k.jsx(Op,{}),k.jsx(Dp,{}),k.jsx(Xh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"}),a==="spotlightSearch"&&k.jsx(Pp,{})]})}):null}function Np(){const{showDialog:t}=za(),{loadWorkflowID:e}=P.useContext(Ct),n=async(o,s)=>{var c,u;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(c=await($==null?void 0:$.listByIndex("cloudID",i.id)))==null?void 0:c.at(0);if(l){const d=(u=await(be==null?void 0:be.listByIndex("cloudID",a.id)))==null?void 0:u.at(0);if(d)await e(l.id,d.id);else{const p=await(be==null?void 0:be.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json}));p&&e(l.id,p.id)}}else{const d=await($==null?void 0:$.createFlow({cloudID:i.id,cloudOrigin:s,name:i.name,json:a.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}const p=await(be==null?void 0:be.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(Fp(s)){const i=o.origin;t(`Open workflow "${s.detail.workflow.name}", version "${s.detail.version.name}" from ${i}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(s,i)}}])}};return P.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function Fp(t){return t.type==="workspace_open_workflow"}const Rp=t=>typeof t=="function",Tp=t=>{const[e,n]=P.useState(t),r=P.useRef(e),o=P.useCallback(s=>{r.current=Rp(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function fr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sl={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -19,11 +19,11 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE -*/(function(t,e){(function(n){t.exports=n()})(function(){return function n(r,o,s){function i(u,c){if(!o[u]){if(!r[u]){var d=typeof fr=="function"&&fr;if(!c&&d)return d(u,!0);if(a)return a(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var h=o[u]={exports:{}};r[u][0].call(h.exports,function(v){var f=r[u][1][v];return i(f||v)},h,h.exports,n,r,o,s)}return o[u].exports}for(var a=typeof fr=="function"&&fr,l=0;l>2,h=(3&u)<<4|c>>4,v=1<_?(15&c)<<2|d>>6:64,f=2<_?63&d:64,m.push(a.charAt(p)+a.charAt(h)+a.charAt(v)+a.charAt(f));return m.join("")},o.decode=function(l){var u,c,d,p,h,v,f=0,m=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var g,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&_--,l.charAt(l.length-2)===a.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(g=i.uint8array?new Uint8Array(0|_):new Array(0|_);f>4,c=(15&p)<<4|(h=a.indexOf(l.charAt(f++)))>>2,d=(3&h)<<6|(v=a.indexOf(l.charAt(f++))),g[m++]=u,h!==64&&(g[m++]=c),v!==64&&(g[m++]=d);return g}},{"./support":30,"./utils":32}],2:[function(n,r,o){var s=n("./external"),i=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function u(c,d,p,h,v){this.compressedSize=c,this.uncompressedSize=d,this.crc32=p,this.compression=h,this.compressedContent=v}u.prototype={getContentWorker:function(){var c=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return c.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new i(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(c,d,p){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var s=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var s=n("./utils"),i=function(){for(var a,l=[],u=0;u<256;u++){a=u;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;l[u]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(u,c,d,p){var h=i,v=p+d;u^=-1;for(var f=p;f>>8^h[255&(u^c[f])];return-1^u}(0|l,a,a.length,0):function(u,c,d,p){var h=i,v=p+d;u^=-1;for(var f=p;f>>8^h[255&(u^c.charCodeAt(f))];return-1^u}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),u=s?"uint8array":"array";function c(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(u,d.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},o.compressWorker=function(d){return new c("Deflate",d)},o.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(h,v){var f,m="";for(f=0;f>>=8;return m}function i(h,v,f,m,y,g){var _,x,C=h.file,D=h.compression,E=g!==u.utf8encode,F=a.transformTo("string",g(C.name)),I=a.transformTo("string",u.utf8encode(C.name)),R=C.comment,K=a.transformTo("string",g(R)),j=a.transformTo("string",u.utf8encode(R)),M=I.length!==C.name.length,b=j.length!==R.length,N="",H="",A="",X=C.dir,V=C.date,te={crc32:0,compressedSize:0,uncompressedSize:0};v&&!f||(te.crc32=h.crc32,te.compressedSize=h.compressedSize,te.uncompressedSize=h.uncompressedSize);var z=0;v&&(z|=8),E||!M&&!b||(z|=2048);var B=0,ne=0;X&&(B|=16),y==="UNIX"?(ne=798,B|=function(Z,he){var ye=Z;return Z||(ye=he?16893:33204),(65535&ye)<<16}(C.unixPermissions,X)):(ne=20,B|=function(Z){return 63&(Z||0)}(C.dosPermissions)),_=V.getUTCHours(),_<<=6,_|=V.getUTCMinutes(),_<<=5,_|=V.getUTCSeconds()/2,x=V.getUTCFullYear()-1980,x<<=4,x|=V.getUTCMonth()+1,x<<=5,x|=V.getUTCDate(),M&&(H=s(1,1)+s(c(F),4)+I,N+="up"+s(H.length,2)+H),b&&(A=s(1,1)+s(c(K),4)+j,N+="uc"+s(A.length,2)+A);var Y="";return Y+=` -\0`,Y+=s(z,2),Y+=D.magic,Y+=s(_,2),Y+=s(x,2),Y+=s(te.crc32,4),Y+=s(te.compressedSize,4),Y+=s(te.uncompressedSize,4),Y+=s(F.length,2),Y+=s(N.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Y+F+N,dirRecord:d.CENTRAL_FILE_HEADER+s(ne,2)+Y+s(K.length,2)+"\0\0\0\0"+s(B,4)+s(m,4)+F+N+K}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),c=n("../crc32"),d=n("../signature");function p(h,v,f,m){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=f,this.encodeFileName=m,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(h){var v=h.meta.percent||0,f=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:f?(v+100*(f-m-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var v=this.streamFiles&&!h.file.dir;if(v){var f=i(h,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var v=this.streamFiles&&!h.file.dir,f=i(h,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),v)this.push({data:function(m){return d.DATA_DESCRIPTOR+s(m.crc32,4)+s(m.compressedSize,4)+s(m.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,v=0;v=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),u=n("./NodeBufferReader"),c=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new u(d):i.uint8array?new c(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var s=n("./GenericWorker"),i=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}i.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:i.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=i(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,i),a.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}i.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){u.dataIsReady=!0,u.data=c,u.max=c&&c.length||0,u.type=s.getTypeOf(c),u.isPaused||u._tickAndRepeat()},function(c){u.error(c)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var l=0;l "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),u=n("../support"),c=n("../external"),d=null;if(u.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(v,f){return new c.Promise(function(m,y){var g=[],_=v._internalType,x=v._outputType,C=v._mimeType;v.on("data",function(D,E){g.push(D),f&&f(E)}).on("error",function(D){g=[],y(D)}).on("end",function(){try{var D=function(E,F,I){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",F),I);case"base64":return l.encode(F);default:return s.transformTo(E,F)}}(x,function(E,F){var I,R=0,K=null,j=0;for(I=0;I"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var s=n("./utils"),i=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),u=new Array(256),c=0;c<256;c++)u[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;u[254]=u[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(h){return i.nodebuffer?a.newBufferFrom(h,"utf-8"):function(v){var f,m,y,g,_,x=v.length,C=0;for(g=0;g>>6:(m<65536?f[_++]=224|m>>>12:(f[_++]=240|m>>>18,f[_++]=128|m>>>12&63),f[_++]=128|m>>>6&63),f[_++]=128|63&m);return f}(h)},o.utf8decode=function(h){return i.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(v){var f,m,y,g,_=v.length,x=new Array(2*_);for(f=m=0;f<_;)if((y=v[f++])<128)x[m++]=y;else if(4<(g=u[y]))x[m++]=65533,f+=g-1;else{for(y&=g===2?31:g===3?15:7;1>10&1023,x[m++]=56320|1023&y)}return x.length!==m&&(x.subarray?x=x.subarray(0,m):x.length=m),s.applyFromCharCode(x)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var v=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=v;(v=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),v.set(f,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var m=function(g,_){var x;for((_=_||g.length)>g.length&&(_=g.length),x=_-1;0<=x&&(192&g[x])==128;)x--;return x<0||x===0?_:x+u[g[x]]>_?x:_}(v),y=v;m!==v.length&&(i.uint8array?(y=v.subarray(0,m),this.leftOver=v.subarray(m,v.length)):(y=v.slice(0,m),this.leftOver=v.slice(m,v.length))),this.push({data:o.utf8decode(y),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function u(f){return f}function c(f,m){for(var y=0;y>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var v,f,m,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?p[m++]=224|h>>>12:(p[m++]=240|h>>>18,p[m++]=128|h>>>12&63),p[m++]=128|h>>>6&63),p[m++]=128|63&h);return p},o.buf2binstring=function(d){return c(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,v=p.length;h>10&1023,g[v++]=56320|1023&f)}return c(g,v)},o.utf8border=function(d,p){var h;for((p=p||d.length)>d.length&&(p=d.length),h=p-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?p:h+l[d[h]]>p?h:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,l){for(var u=65535&s|0,c=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:i>>>1;a[l]=i}return a}();r.exports=function(i,a,l,u){var c=s,d=u+l;i^=-1;for(var p=u;p>>8^c[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),u=n("./crc32"),c=n("./messages"),d=0,p=4,h=0,v=-2,f=-1,m=4,y=2,g=8,_=9,x=286,C=30,D=19,E=2*x+1,F=15,I=3,R=258,K=R+I+1,j=42,M=113,b=1,N=2,H=3,A=4;function X(w,U){return w.msg=c[U],U}function V(w){return(w<<1)-(4w.avail_out&&(W=w.avail_out),W!==0&&(i.arraySet(w.output,U.pending_buf,U.pending_out,W,w.next_out),w.next_out+=W,U.pending_out+=W,w.total_out+=W,w.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function B(w,U){a._tr_flush_block(w,0<=w.block_start?w.block_start:-1,w.strstart-w.block_start,U),w.block_start=w.strstart,z(w.strm)}function ne(w,U){w.pending_buf[w.pending++]=U}function Y(w,U){w.pending_buf[w.pending++]=U>>>8&255,w.pending_buf[w.pending++]=255&U}function Z(w,U){var W,O,S=w.max_chain_length,T=w.strstart,q=w.prev_length,J=w.nice_match,L=w.strstart>w.w_size-K?w.strstart-(w.w_size-K):0,Q=w.window,re=w.w_mask,ee=w.prev,se=w.strstart+R,ge=Q[T+q-1],pe=Q[T+q];w.prev_length>=w.good_match&&(S>>=2),J>w.lookahead&&(J=w.lookahead);do if(Q[(W=U)+q]===pe&&Q[W+q-1]===ge&&Q[W]===Q[T]&&Q[++W]===Q[T+1]){T+=2,W++;do;while(Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&TL&&--S!=0);return q<=w.lookahead?q:w.lookahead}function he(w){var U,W,O,S,T,q,J,L,Q,re,ee=w.w_size;do{if(S=w.window_size-w.lookahead-w.strstart,w.strstart>=ee+(ee-K)){for(i.arraySet(w.window,w.window,ee,ee,0),w.match_start-=ee,w.strstart-=ee,w.block_start-=ee,U=W=w.hash_size;O=w.head[--U],w.head[U]=ee<=O?O-ee:0,--W;);for(U=W=ee;O=w.prev[--U],w.prev[U]=ee<=O?O-ee:0,--W;);S+=ee}if(w.strm.avail_in===0)break;if(q=w.strm,J=w.window,L=w.strstart+w.lookahead,Q=S,re=void 0,re=q.avail_in,Q=I)for(T=w.strstart-w.insert,w.ins_h=w.window[T],w.ins_h=(w.ins_h<=I&&(w.ins_h=(w.ins_h<=I)if(O=a._tr_tally(w,w.strstart-w.match_start,w.match_length-I),w.lookahead-=w.match_length,w.match_length<=w.max_lazy_match&&w.lookahead>=I){for(w.match_length--;w.strstart++,w.ins_h=(w.ins_h<=I&&(w.ins_h=(w.ins_h<=I&&w.match_length<=w.prev_length){for(S=w.strstart+w.lookahead-I,O=a._tr_tally(w,w.strstart-1-w.prev_match,w.prev_length-I),w.lookahead-=w.prev_length-1,w.prev_length-=2;++w.strstart<=S&&(w.ins_h=(w.ins_h<w.pending_buf_size-5&&(W=w.pending_buf_size-5);;){if(w.lookahead<=1){if(he(w),w.lookahead===0&&U===d)return b;if(w.lookahead===0)break}w.strstart+=w.lookahead,w.lookahead=0;var O=w.block_start+W;if((w.strstart===0||w.strstart>=O)&&(w.lookahead=w.strstart-O,w.strstart=O,B(w,!1),w.strm.avail_out===0)||w.strstart-w.block_start>=w.w_size-K&&(B(w,!1),w.strm.avail_out===0))return b}return w.insert=0,U===p?(B(w,!0),w.strm.avail_out===0?H:A):(w.strstart>w.block_start&&(B(w,!1),w.strm.avail_out),b)}),new ue(4,4,8,4,ye),new ue(4,5,16,8,ye),new ue(4,6,32,32,ye),new ue(4,4,16,16,le),new ue(8,16,32,32,le),new ue(8,16,128,128,le),new ue(8,32,128,256,le),new ue(32,128,258,1024,le),new ue(32,258,258,4096,le)],o.deflateInit=function(w,U){return Ee(w,U,g,15,8,0)},o.deflateInit2=Ee,o.deflateReset=me,o.deflateResetKeep=ve,o.deflateSetHeader=function(w,U){return w&&w.state?w.state.wrap!==2?v:(w.state.gzhead=U,h):v},o.deflate=function(w,U){var W,O,S,T;if(!w||!w.state||5>8&255),ne(O,O.gzhead.time>>16&255),ne(O,O.gzhead.time>>24&255),ne(O,O.level===9?2:2<=O.strategy||O.level<2?4:0),ne(O,255&O.gzhead.os),O.gzhead.extra&&O.gzhead.extra.length&&(ne(O,255&O.gzhead.extra.length),ne(O,O.gzhead.extra.length>>8&255)),O.gzhead.hcrc&&(w.adler=u(w.adler,O.pending_buf,O.pending,0)),O.gzindex=0,O.status=69):(ne(O,0),ne(O,0),ne(O,0),ne(O,0),ne(O,0),ne(O,O.level===9?2:2<=O.strategy||O.level<2?4:0),ne(O,3),O.status=M);else{var q=g+(O.w_bits-8<<4)<<8;q|=(2<=O.strategy||O.level<2?0:O.level<6?1:O.level===6?2:3)<<6,O.strstart!==0&&(q|=32),q+=31-q%31,O.status=M,Y(O,q),O.strstart!==0&&(Y(O,w.adler>>>16),Y(O,65535&w.adler)),w.adler=1}if(O.status===69)if(O.gzhead.extra){for(S=O.pending;O.gzindex<(65535&O.gzhead.extra.length)&&(O.pending!==O.pending_buf_size||(O.gzhead.hcrc&&O.pending>S&&(w.adler=u(w.adler,O.pending_buf,O.pending-S,S)),z(w),S=O.pending,O.pending!==O.pending_buf_size));)ne(O,255&O.gzhead.extra[O.gzindex]),O.gzindex++;O.gzhead.hcrc&&O.pending>S&&(w.adler=u(w.adler,O.pending_buf,O.pending-S,S)),O.gzindex===O.gzhead.extra.length&&(O.gzindex=0,O.status=73)}else O.status=73;if(O.status===73)if(O.gzhead.name){S=O.pending;do{if(O.pending===O.pending_buf_size&&(O.gzhead.hcrc&&O.pending>S&&(w.adler=u(w.adler,O.pending_buf,O.pending-S,S)),z(w),S=O.pending,O.pending===O.pending_buf_size)){T=1;break}T=O.gzindexS&&(w.adler=u(w.adler,O.pending_buf,O.pending-S,S)),T===0&&(O.gzindex=0,O.status=91)}else O.status=91;if(O.status===91)if(O.gzhead.comment){S=O.pending;do{if(O.pending===O.pending_buf_size&&(O.gzhead.hcrc&&O.pending>S&&(w.adler=u(w.adler,O.pending_buf,O.pending-S,S)),z(w),S=O.pending,O.pending===O.pending_buf_size)){T=1;break}T=O.gzindexS&&(w.adler=u(w.adler,O.pending_buf,O.pending-S,S)),T===0&&(O.status=103)}else O.status=103;if(O.status===103&&(O.gzhead.hcrc?(O.pending+2>O.pending_buf_size&&z(w),O.pending+2<=O.pending_buf_size&&(ne(O,255&w.adler),ne(O,w.adler>>8&255),w.adler=0,O.status=M)):O.status=M),O.pending!==0){if(z(w),w.avail_out===0)return O.last_flush=-1,h}else if(w.avail_in===0&&V(U)<=V(W)&&U!==p)return X(w,-5);if(O.status===666&&w.avail_in!==0)return X(w,-5);if(w.avail_in!==0||O.lookahead!==0||U!==d&&O.status!==666){var J=O.strategy===2?function(L,Q){for(var re;;){if(L.lookahead===0&&(he(L),L.lookahead===0)){if(Q===d)return b;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(B(L,!1),L.strm.avail_out===0))return b}return L.insert=0,Q===p?(B(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(B(L,!1),L.strm.avail_out===0)?b:N}(O,U):O.strategy===3?function(L,Q){for(var re,ee,se,ge,pe=L.window;;){if(L.lookahead<=R){if(he(L),L.lookahead<=R&&Q===d)return b;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=I&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=I?(re=a._tr_tally(L,1,L.match_length-I),L.lookahead-=L.match_length,L.strstart+=L.match_length,L.match_length=0):(re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++),re&&(B(L,!1),L.strm.avail_out===0))return b}return L.insert=0,Q===p?(B(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(B(L,!1),L.strm.avail_out===0)?b:N}(O,U):s[O.level].func(O,U);if(J!==H&&J!==A||(O.status=666),J===b||J===H)return w.avail_out===0&&(O.last_flush=-1),h;if(J===N&&(U===1?a._tr_align(O):U!==5&&(a._tr_stored_block(O,0,0,!1),U===3&&(te(O.head),O.lookahead===0&&(O.strstart=0,O.block_start=0,O.insert=0))),z(w),w.avail_out===0))return O.last_flush=-1,h}return U!==p?h:O.wrap<=0?1:(O.wrap===2?(ne(O,255&w.adler),ne(O,w.adler>>8&255),ne(O,w.adler>>16&255),ne(O,w.adler>>24&255),ne(O,255&w.total_in),ne(O,w.total_in>>8&255),ne(O,w.total_in>>16&255),ne(O,w.total_in>>24&255)):(Y(O,w.adler>>>16),Y(O,65535&w.adler)),z(w),0=W.w_size&&(T===0&&(te(W.head),W.strstart=0,W.block_start=0,W.insert=0),Q=new i.Buf8(W.w_size),i.arraySet(Q,U,re-W.w_size,W.w_size,0),U=Q,re=W.w_size),q=w.avail_in,J=w.next_in,L=w.input,w.avail_in=re,w.next_in=0,w.input=U,he(W);W.lookahead>=I;){for(O=W.strstart,S=W.lookahead-(I-1);W.ins_h=(W.ins_h<>>=I=F>>>24,_-=I,(I=F>>>16&255)===0)N[c++]=65535&F;else{if(!(16&I)){if(!(64&I)){F=x[(65535&F)+(g&(1<>>=I,_-=I),_<15&&(g+=b[l++]<<_,_+=8,g+=b[l++]<<_,_+=8),F=C[g&E];n:for(;;){if(g>>>=I=F>>>24,_-=I,!(16&(I=F>>>16&255))){if(!(64&I)){F=C[(65535&F)+(g&(1<>>=I,_-=I,(I=c-d)>3,g&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<24)}function g(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(j){var M;return j&&j.state?(M=j.state,j.total_in=j.total_out=M.total=0,j.msg="",M.wrap&&(j.adler=1&M.wrap),M.mode=v,M.last=0,M.havedict=0,M.dmax=32768,M.head=null,M.hold=0,M.bits=0,M.lencode=M.lendyn=new s.Buf32(f),M.distcode=M.distdyn=new s.Buf32(m),M.sane=1,M.back=-1,p):h}function x(j){var M;return j&&j.state?((M=j.state).wsize=0,M.whave=0,M.wnext=0,_(j)):h}function C(j,M){var b,N;return j&&j.state?(N=j.state,M<0?(b=0,M=-M):(b=1+(M>>4),M<48&&(M&=15)),M&&(M<8||15=A.wsize?(s.arraySet(A.window,M,b-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(N<(H=A.wsize-A.wnext)&&(H=N),s.arraySet(A.window,M,b-N,H,A.wnext),(N-=H)?(s.arraySet(A.window,M,b-N,N,0),A.wnext=N,A.whave=A.wsize):(A.wnext+=H,A.wnext===A.wsize&&(A.wnext=0),A.whave>>8&255,b.check=a(b.check,T,2,0),B=z=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&z)<<8)+(z>>8))%31){j.msg="incorrect header check",b.mode=30;break}if((15&z)!=8){j.msg="unknown compression method",b.mode=30;break}if(B-=4,w=8+(15&(z>>>=4)),b.wbits===0)b.wbits=w;else if(w>b.wbits){j.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(T[0]=255&z,T[1]=z>>>8&255,b.check=a(b.check,T,2,0)),B=z=0,b.mode=3;case 3:for(;B<32;){if(V===0)break e;V--,z+=N[A++]<>>8&255,T[2]=z>>>16&255,T[3]=z>>>24&255,b.check=a(b.check,T,4,0)),B=z=0,b.mode=4;case 4:for(;B<16;){if(V===0)break e;V--,z+=N[A++]<>8),512&b.flags&&(T[0]=255&z,T[1]=z>>>8&255,b.check=a(b.check,T,2,0)),B=z=0,b.mode=5;case 5:if(1024&b.flags){for(;B<16;){if(V===0)break e;V--,z+=N[A++]<>>8&255,b.check=a(b.check,T,2,0)),B=z=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(V<(Z=b.length)&&(Z=V),Z&&(b.head&&(w=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,N,A,Z,w)),512&b.flags&&(b.check=a(b.check,N,Z,A)),V-=Z,A+=Z,b.length-=Z),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(V===0)break e;for(Z=0;w=N[A+Z++],b.head&&w&&b.length<65536&&(b.head.name+=String.fromCharCode(w)),w&&Z>9&1,b.head.done=!0),j.adler=b.check=0,b.mode=12;break;case 10:for(;B<32;){if(V===0)break e;V--,z+=N[A++]<>>=7&B,B-=7&B,b.mode=27;break}for(;B<3;){if(V===0)break e;V--,z+=N[A++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,M!==6)break;z>>>=2,B-=2;break e;case 2:b.mode=17;break;case 3:j.msg="invalid block type",b.mode=30}z>>>=2,B-=2;break;case 14:for(z>>>=7&B,B-=7&B;B<32;){if(V===0)break e;V--,z+=N[A++]<>>16^65535)){j.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&z,B=z=0,b.mode=15,M===6)break e;case 15:b.mode=16;case 16:if(Z=b.length){if(V>>=5,B-=5,b.ndist=1+(31&z),z>>>=5,B-=5,b.ncode=4+(15&z),z>>>=4,B-=4,286>>=3,B-=3}for(;b.have<19;)b.lens[q[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},U=u(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,ke=65535&S,!((le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>>=le,B-=le,b.lens[b.have++]=ke;else{if(ke===16){for(O=le+2;B>>=le,B-=le,b.have===0){j.msg="invalid bit length repeat",b.mode=30;break}w=b.lens[b.have-1],Z=3+(3&z),z>>>=2,B-=2}else if(ke===17){for(O=le+3;B>>=le)),z>>>=3,B-=3}else{for(O=le+7;B>>=le)),z>>>=7,B-=7}if(b.have+Z>b.nlen+b.ndist){j.msg="invalid bit length repeat",b.mode=30;break}for(;Z--;)b.lens[b.have++]=w}}if(b.mode===30)break;if(b.lens[256]===0){j.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},U=u(c,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},U=u(d,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,U){j.msg="invalid distances set",b.mode=30;break}if(b.mode=20,M===6)break e;case 20:b.mode=21;case 21:if(6<=V&&258<=te){j.next_out=X,j.avail_out=te,j.next_in=A,j.avail_in=V,b.hold=z,b.bits=B,l(j,Y),X=j.next_out,H=j.output,te=j.avail_out,A=j.next_in,N=j.input,V=j.avail_in,z=b.hold,B=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;ue=(S=b.lencode[z&(1<>>16&255,ke=65535&S,!((le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>ve)])>>>16&255,ke=65535&S,!(ve+(le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>>=ve,B-=ve,b.back+=ve}if(z>>>=le,B-=le,b.back+=le,b.length=ke,ue===0){b.mode=26;break}if(32&ue){b.back=-1,b.mode=12;break}if(64&ue){j.msg="invalid literal/length code",b.mode=30;break}b.extra=15&ue,b.mode=22;case 22:if(b.extra){for(O=b.extra;B>>=b.extra,B-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;ue=(S=b.distcode[z&(1<>>16&255,ke=65535&S,!((le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>ve)])>>>16&255,ke=65535&S,!(ve+(le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>>=ve,B-=ve,b.back+=ve}if(z>>>=le,B-=le,b.back+=le,64&ue){j.msg="invalid distance code",b.mode=30;break}b.offset=ke,b.extra=15&ue,b.mode=24;case 24:if(b.extra){for(O=b.extra;B>>=b.extra,B-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){j.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(te===0)break e;if(Z=Y-te,b.offset>Z){if((Z=b.offset-Z)>b.whave&&b.sane){j.msg="invalid distance too far back",b.mode=30;break}he=Z>b.wnext?(Z-=b.wnext,b.wsize-Z):b.wnext-Z,Z>b.length&&(Z=b.length),ye=b.window}else ye=H,he=X-b.offset,Z=b.length;for(teE?(I=he[ye+m[M]],B[ne+m[M]]):(I=96,0),g=1<>X)+(_-=g)]=F<<24|I<<16|R|0,_!==0;);for(g=1<>=1;if(g!==0?(z&=g-1,z+=g):z=0,M++,--Y[j]==0){if(j===N)break;j=d[p+m[M]]}if(H>>7)]}function ne(S,T){S.pending_buf[S.pending++]=255&T,S.pending_buf[S.pending++]=T>>>8&255}function Y(S,T,q){S.bi_valid>y-q?(S.bi_buf|=T<>y-S.bi_valid,S.bi_valid+=q-y):(S.bi_buf|=T<>>=1,q<<=1,0<--T;);return q>>>1}function ye(S,T,q){var J,L,Q=new Array(m+1),re=0;for(J=1;J<=m;J++)Q[J]=re=re+q[J-1]<<1;for(L=0;L<=T;L++){var ee=S[2*L+1];ee!==0&&(S[2*L]=he(Q[ee]++,ee))}}function le(S){var T;for(T=0;T>1;1<=q;q--)ve(S,Q,q);for(L=se;q=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ve(S,Q,1),J=S.heap[1],S.heap[--S.heap_max]=q,S.heap[--S.heap_max]=J,Q[2*L]=Q[2*q]+Q[2*J],S.depth[L]=(S.depth[q]>=S.depth[J]?S.depth[q]:S.depth[J])+1,Q[2*q+1]=Q[2*J+1]=L,S.heap[1]=L++,ve(S,Q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(pe,Xe){var xn,at,kn,je,Qn,io,ht=Xe.dyn_tree,Js=Xe.max_code,Il=Xe.stat_desc.static_tree,Ol=Xe.stat_desc.has_stree,Dl=Xe.stat_desc.extra_bits,Ys=Xe.stat_desc.extra_base,En=Xe.stat_desc.max_length,er=0;for(je=0;je<=m;je++)pe.bl_count[je]=0;for(ht[2*pe.heap[pe.heap_max]+1]=0,xn=pe.heap_max+1;xn>=7;L>>=1)if(1&ge&&ee.dyn_ltree[2*se]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(se=32;se>>3,(Q=S.static_len+3+7>>>3)<=L&&(L=Q)):L=Q=q+5,q+4<=L&&T!==-1?O(S,T,q,J):S.strategy===4||Q===L?(Y(S,2+(J?1:0),3),me(S,K,j)):(Y(S,4+(J?1:0),3),function(ee,se,ge,pe){var Xe;for(Y(ee,se-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Xe=0;Xe>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&T,S.pending_buf[S.l_buf+S.last_lit]=255&q,S.last_lit++,T===0?S.dyn_ltree[2*q]++:(S.matches++,T--,S.dyn_ltree[2*(b[q]+d+1)]++,S.dyn_dtree[2*B(T)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){Y(S,2,3),Z(S,_,K),function(T){T.bi_valid===16?(ne(T,T.bi_buf),T.bi_buf=0,T.bi_valid=0):8<=T.bi_valid&&(T.pending_buf[T.pending++]=255&T.bi_buf,T.bi_buf>>=8,T.bi_valid-=8)}(S)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){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}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,u,c,d,p=1,h={},v=!1,f=i.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(i);m=m&&m.setTimeout?m:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){g(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,C=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=C,x}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(x){i.postMessage(d+x,"*")}):i.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){g(x.data)},function(x){c.port2.postMessage(x)}):f&&"onreadystatechange"in f.createElement("script")?(u=f.documentElement,function(x){var C=f.createElement("script");C.onreadystatechange=function(){g(x),C.onreadystatechange=null,u.removeChild(C),C=null},u.appendChild(C)}):function(x){setTimeout(g,0,x)},m.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var C=new Array(arguments.length-1),D=0;D"u"?s===void 0?this:s:self)}).call(this,typeof tr<"u"?tr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Sl);var Mp=Sl.exports;const Bp=Fa(Mp),zp=async t=>{const e=`ComfyUI workspace workflows ${ml(Date.now())}`,n=new Bp,r=await(G==null?void 0:G.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await kh(o.parentFolderID??null).then(async a=>Ft(a??""));const i=n.folder(s);i==null||i.file(`${o.name}.json`,o.json)}n.generateAsync({type:"blob"}).then(function(o){const s=document.createElement("a");s.href=window.URL.createObjectURL(o),s.download=`${e}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s)})};function Lp({myWorkflowsDir:t}){return k.jsxs(Ke,{gap:3,children:[k.jsx(sn,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),k.jsx("p",{children:"Your workflows will be synced to and from path:"}),k.jsx("p",{children:k.jsx("b",{children:t})}),k.jsxs("p",{children:["You can manually put workflow files into this folder using File Explorer to sync them with your workspace. You can change this path anytime in Settings ",">"," Workspace Save Directory"]}),k.jsxs("p",{children:[k.jsx("b",{children:"Please download all your workflows before enabling two way sync as a backup!"})," ","So you can manually import some workflows into your workspace in case something unexpected happens."]}),k.jsx(Te,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await($==null?void 0:$.listAll());zp(e??[])},children:"👉 Download All My Workflows"})]})}const Wp=(t,e)=>{const n=t.nodes==null?[]:t.nodes,r=e.nodes==null?[]:e.nodes;t.nodes=[],e.nodes=[];let o=JSON.stringify(t)===JSON.stringify(e);if(o){const s=(a,l)=>{const u=l.order,c=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",c),l.order=u,l.pos=c,a},i=(a,l,u)=>Math.abs(a-l)>u;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[u,c]of a){if(!l.has(u)){o=!1;break}if(typeof u=="string"&&u.includes("_pos")){const d=l.get(u);if(d==null||c==null||i(d[0],c[0],5)||i(d[1],c[1],5)){o=!1;break}}else if(l.get(u)!==c){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},Up=La.lazy(()=>yn(()=>import("./RecentFilesDrawer-qy9dTPVG.js"),__vite__mapDeps([14,1,8,2,13,15,12,4]))),Kp=La.lazy(()=>yn(()=>import("./GalleryModal-cB6QErx6.js"),__vite__mapDeps([16,1,15,12,9,8,2,3])));function $p(){const[t,e]=P.useState(null),[n,r]=P.useState("root"),[o,s]=P.useState(!0),[i,a]=P.useState(null),l=P.useRef(null),[u,c]=P.useState(!1),d=P.useRef(null),{showDialog:p}=za(),[h,v]=P.useState(!1);P.useRef(!1);const f=Ua(),[m,y]=Tp(null),g=P.useCallback(async()=>{var N,H;if(l.current){if((N=$==null?void 0:$.curWorkflow)!=null&&N.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const A=JSON.stringify(we.graph.serialize());await Promise.all([$==null?void 0:$.updateFlow(l.current,{json:A}),Ge==null?void 0:Ge.create({workflowID:l.current,json:A,isAutoSave:!1})]),(H=G==null?void 0:G.settings)!=null&&H.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),c(!1)}},[]),_=async()=>{var H,A,X;if((H=G==null?void 0:G.settings)!=null&&H.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const V=(A=$==null?void 0:$.curWorkflow)==null?void 0:A.id;if(V==null)return;const te=(X=await($==null?void 0:$.get(V)))==null?void 0:X.json;te?($==null||$.updateCurWorkflow({...$.curWorkflow,json:te}),await we.loadGraphData(JSON.parse(te)),c(!1)):alert("Error: No last saved version found")}},x=N=>{const H=(N==null?void 0:N.id)??null;if($==null||$.updateCurWorkflow(N),l.current=H,a(H),e((N==null?void 0:N.name)??""),H==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Da()){const A=yl(H);window.location.hash=A,document.title=N.name+" - ComfyUI"}else localStorage.setItem("curFlowID",H),document.title="ComfyUI - "+N.name;N&&($==null||$.updateLastOpenedTime(N.id))},C=async()=>{localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Lh()}catch(A){console.error("error loading db",A)}s(!1);let N=null;N=Da(),N==null&&(N=localStorage.getItem("curFlowID")),N&&E(N),fetch("/workspace/deduplicate_workflow_ids"),!await(G==null?void 0:G.getSetting("twoWaySync"))&&ie.cache.get(ko).then(async A=>{if((A==null?void 0:A.value)!=="true"){if(await ie.workflows.count()==0){await(G==null?void 0:G.upsert({twoWaySync:!0})),await ie.cache.put({id:ko,value:"true"});return}const V=await(G==null?void 0:G.getSetting("myWorkflowsDir"));p(k.jsx(Lp,{myWorkflowsDir:V??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(G==null?void 0:G.upsert({twoWaySync:!0})),await(G==null?void 0:G.getSetting("twoWaySync"))&&(ie.cache.put({id:ko,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},D=()=>{if(l.current==null)return!1;const N=$==null?void 0:$.curWorkflow;if(N==null)return!1;if(N.json==null)return!0;const H=we.graph.serialize()??{};let A={};try{A=N!=null&&N.json?JSON.parse(N==null?void 0:N.json):{}}catch(V){console.error("error parsing json",V)}return!Wp(H,A)},E=async(N,H)=>{if(we.graph==null)return;const A=await($==null?void 0:$.get(N));if(A==null){alert("Error: Workflow not found! id: "+N),x(null);return}const X=H?await(be==null?void 0:be.get(H)):null;we.ui.dialog.close(),X?(y(X),x({...A,json:X.json}),we.loadGraphData(JSON.parse(X.json))):(x(A),y(null),we.loadGraphData(JSON.parse(A.json))),r("root"),u&&c(!1)},F=async(N,H,A=!1)=>{var X;if(N===null){x(null),we.graph.clear();return}if(!u||A||(X=G==null?void 0:G.settings)!=null&&X.autoSave||($==null?void 0:$.curWorkflow)==null){E(N,H);return}I(N)},I=async N=>{var A;const H=[N?{label:"Open in new tab",icon:k.jsx(bl,{}),onClick:()=>{Oh(N)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await g(),N&&E(N)}}];H.push({label:"Discard",colorScheme:"red",onClick:async()=>{N&&E(N)}}),p(`Please save or discard your changes to "${(A=$==null?void 0:$.curWorkflow)==null?void 0:A.name}" before leaving, or your changes will be lost.`,H)},R=async N=>{const H=(N==null?void 0:N.json)??JSON.stringify(Cr),A=await($==null?void 0:$.createFlow({json:H,name:N==null?void 0:N.name}));A&&await F(A.id),r("root")},K=async(N,H=!1)=>{const A=N.split("/").pop()??N;H?g():R({name:A});const X=await fetch(Ih(N)),V=await X.blob(),te=new File([V],A,{type:X.headers.get("Content-Type")||""});await we.handleFile(te),r("root")},j=async(N,H)=>{const A=await($==null?void 0:$.get(N));if(A==null)return;const X=await($==null?void 0:$.createFlow({json:A.json,name:H||A.name,parentFolderID:A.parentFolderID,tags:A.tags}));X&&await F(X.id)},M=P.useCallback(N=>{if(l.current==null)return;let H=N.filename;N.subfolder!=null&&N.subfolder!==""&&(H=N.subfolder+"/"+H),Ht==null||Ht.create({workflowID:l.current,localPath:H})},[]),b=P.useCallback(()=>{r("root")},[]);return P.useEffect(()=>{C(),v(!0);const N=document.getElementById("comfy-file-input"),H=async()=>{if(N&&N.files&&N.files.length>0){const te={id:Dr(),name:N.files[0].name,json:JSON.stringify(Cr),updateTime:Date.now(),createTime:Date.now()};x(te),await($==null?void 0:$.createFlow(te))}};N==null||N.addEventListener("change",H);const A=te=>{var ne,Y;const z=((ne=G==null?void 0:G.settings)==null?void 0:ne.autoSave)??!0;if((Y=$==null?void 0:$.curWorkflow)!=null&&Y.saveLock)return;const B=D();!z&&B&&(te.preventDefault(),te.returnValue="You have unsaved changes!",I())};window.addEventListener("beforeunload",A);const X=te=>{var z,B,ne,Y,Z,he;(ne=(B=(z=te.detail)==null?void 0:z.output)==null?void 0:B.images)==null||ne.forEach(ye=>{ye.type==="output"&&M(ye)}),(he=(Z=(Y=te.detail)==null?void 0:Y.output)==null?void 0:Z.gifs)==null||he.forEach(ye=>{ye.type==="output"&&M(ye)})};ql.addEventListener("executed",X);const V=async te=>{var Y,Z;const z=(Z=(Y=te.dataTransfer)==null?void 0:Y.files[0])==null?void 0:Z.name,B=we.dragOverNode;if(B&&B.onDragDrop)return;if(!(await(G==null?void 0:G.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&z){const he={id:Dr(),name:z,json:JSON.stringify(Cr),updateTime:Date.now(),createTime:Date.now()};x(he),await($==null?void 0:$.createFlow(he))}};return we.canvasEl.addEventListener("drop",V),()=>{window.removeEventListener("change",H),window.removeEventListener("beforeunload",A),window.removeEventListener("executed",X),we.canvasEl.removeEventListener("drop",V)}},[]),o?null:k.jsx(Ct.Provider,{value:{curFlowID:i,onDuplicateWorkflow:j,loadWorkflowID:F,discardUnsavedChanges:_,saveCurWorkflow:g,isDirty:u,setIsDirty:c,loadNewWorkflow:R,loadFilePath:K,setRoute:r,route:n,curVersion:m,setCurVersion:y},children:k.jsx("div",{ref:d,className:"workspace_manager",children:k.jsxs(Ma,{containerRef:d,children:[k.jsxs(jt,{style:{position:"absolute",top:0,right:0,left:0},zIndex:xh,draggable:!1,children:[k.jsx(Ap,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&k.jsx(P.Suspense,{children:k.jsx(Up,{onClose:b,onClickNewFlow:()=>{R(),r("root")}})}),n==="gallery"&&k.jsx(P.Suspense,{children:k.jsx(Kp,{onclose:()=>r("root")})})]}),k.jsx(Np,{})]})})})}const _m=Object.freeze(Object.defineProperty({__proto__:null,default:$p},Symbol.toStringTag,{value:"Module"}));export{Ht as $,Jh as A,jt as B,om as C,dp as D,yh as E,Wt as F,Yh as G,ot as H,un as I,Ph as J,Le as K,Yr as L,_i as M,Qr as N,Xr as O,np as P,op as Q,hm as R,Ad as S,Gt as T,Cr as U,am as V,xr as W,zh as X,rm as Y,Ct as Z,_l as _,Yp as a,Oh as a0,bl as a1,ml as a2,ct as a3,hc as a4,xh as a5,Qp as a6,Er as a7,im as a8,Va as a9,Tp as aA,Mh as aB,um as aC,pm as aD,us as aE,ks as aF,vn as aG,gm as aH,oi as aI,be as aJ,vm as aK,wm as aL,Sp as aM,bm as aN,qe as aO,fc as aP,_m as aQ,_c as aa,cm as ab,Ha as ac,Th as ad,sn as ae,on as af,xc as ag,Wp as ah,sm as ai,lm as aj,Ge as ak,Yl as al,ie as am,ym as an,bf as ao,dm as ap,fm as aq,em as ar,tm as as,Wc as at,ki as au,xi as av,Oi as aw,Ei as ax,Si as ay,mm as az,Zp as b,Jp as c,Pe as d,ip as e,Ua as f,Ke as g,wt as h,bt as i,gn as j,G as k,Lp as l,Uc as m,wf as n,Xp as o,nm as p,jo as q,Fs as r,Rs as s,Sr as t,to as u,mt as v,Aa as w,$ as x,up as y,zp as z}; +*/(function(t,e){(function(n){t.exports=n()})(function(){return function n(r,o,s){function i(c,u){if(!o[c]){if(!r[c]){var d=typeof fr=="function"&&fr;if(!u&&d)return d(c,!0);if(a)return a(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var h=o[c]={exports:{}};r[c][0].call(h.exports,function(v){var f=r[c][1][v];return i(f||v)},h,h.exports,n,r,o,s)}return o[c].exports}for(var a=typeof fr=="function"&&fr,l=0;l>2,h=(3&c)<<4|u>>4,v=1<_?(15&u)<<2|d>>6:64,f=2<_?63&d:64,m.push(a.charAt(p)+a.charAt(h)+a.charAt(v)+a.charAt(f));return m.join("")},o.decode=function(l){var c,u,d,p,h,v,f=0,m=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var g,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&_--,l.charAt(l.length-2)===a.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(g=i.uint8array?new Uint8Array(0|_):new Array(0|_);f>4,u=(15&p)<<4|(h=a.indexOf(l.charAt(f++)))>>2,d=(3&h)<<6|(v=a.indexOf(l.charAt(f++))),g[m++]=c,h!==64&&(g[m++]=u),v!==64&&(g[m++]=d);return g}},{"./support":30,"./utils":32}],2:[function(n,r,o){var s=n("./external"),i=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,d,p,h,v){this.compressedSize=u,this.uncompressedSize=d,this.crc32=p,this.compression=h,this.compressedContent=v}c.prototype={getContentWorker:function(){var u=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new i(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,d,p){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var s=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var s=n("./utils"),i=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(c,u,d,p){var h=i,v=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u[f])];return-1^c}(0|l,a,a.length,0):function(c,u,d,p){var h=i,v=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u.charCodeAt(f))];return-1^c}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),c=s?"uint8array":"array";function u(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},o.compressWorker=function(d){return new u("Deflate",d)},o.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(h,v){var f,m="";for(f=0;f>>=8;return m}function i(h,v,f,m,y,g){var _,x,C=h.file,D=h.compression,E=g!==c.utf8encode,F=a.transformTo("string",g(C.name)),I=a.transformTo("string",c.utf8encode(C.name)),R=C.comment,K=a.transformTo("string",g(R)),j=a.transformTo("string",c.utf8encode(R)),M=I.length!==C.name.length,b=j.length!==R.length,N="",H="",A="",X=C.dir,V=C.date,te={crc32:0,compressedSize:0,uncompressedSize:0};v&&!f||(te.crc32=h.crc32,te.compressedSize=h.compressedSize,te.uncompressedSize=h.uncompressedSize);var z=0;v&&(z|=8),E||!M&&!b||(z|=2048);var B=0,ne=0;X&&(B|=16),y==="UNIX"?(ne=798,B|=function(Z,he){var ye=Z;return Z||(ye=he?16893:33204),(65535&ye)<<16}(C.unixPermissions,X)):(ne=20,B|=function(Z){return 63&(Z||0)}(C.dosPermissions)),_=V.getUTCHours(),_<<=6,_|=V.getUTCMinutes(),_<<=5,_|=V.getUTCSeconds()/2,x=V.getUTCFullYear()-1980,x<<=4,x|=V.getUTCMonth()+1,x<<=5,x|=V.getUTCDate(),M&&(H=s(1,1)+s(u(F),4)+I,N+="up"+s(H.length,2)+H),b&&(A=s(1,1)+s(u(K),4)+j,N+="uc"+s(A.length,2)+A);var Y="";return Y+=` +\0`,Y+=s(z,2),Y+=D.magic,Y+=s(_,2),Y+=s(x,2),Y+=s(te.crc32,4),Y+=s(te.compressedSize,4),Y+=s(te.uncompressedSize,4),Y+=s(F.length,2),Y+=s(N.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Y+F+N,dirRecord:d.CENTRAL_FILE_HEADER+s(ne,2)+Y+s(K.length,2)+"\0\0\0\0"+s(B,4)+s(m,4)+F+N+K}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function p(h,v,f,m){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=f,this.encodeFileName=m,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(h){var v=h.meta.percent||0,f=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:f?(v+100*(f-m-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var v=this.streamFiles&&!h.file.dir;if(v){var f=i(h,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var v=this.streamFiles&&!h.file.dir,f=i(h,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),v)this.push({data:function(m){return d.DATA_DESCRIPTOR+s(m.crc32,4)+s(m.compressedSize,4)+s(m.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,v=0;v=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new c(d):i.uint8array?new u(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var s=n("./GenericWorker"),i=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}i.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:i.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=i(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,i),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}i.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=s.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var l=0;l "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(v,f){return new u.Promise(function(m,y){var g=[],_=v._internalType,x=v._outputType,C=v._mimeType;v.on("data",function(D,E){g.push(D),f&&f(E)}).on("error",function(D){g=[],y(D)}).on("end",function(){try{var D=function(E,F,I){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",F),I);case"base64":return l.encode(F);default:return s.transformTo(E,F)}}(x,function(E,F){var I,R=0,K=null,j=0;for(I=0;I"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var s=n("./utils"),i=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(h){return i.nodebuffer?a.newBufferFrom(h,"utf-8"):function(v){var f,m,y,g,_,x=v.length,C=0;for(g=0;g>>6:(m<65536?f[_++]=224|m>>>12:(f[_++]=240|m>>>18,f[_++]=128|m>>>12&63),f[_++]=128|m>>>6&63),f[_++]=128|63&m);return f}(h)},o.utf8decode=function(h){return i.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(v){var f,m,y,g,_=v.length,x=new Array(2*_);for(f=m=0;f<_;)if((y=v[f++])<128)x[m++]=y;else if(4<(g=c[y]))x[m++]=65533,f+=g-1;else{for(y&=g===2?31:g===3?15:7;1>10&1023,x[m++]=56320|1023&y)}return x.length!==m&&(x.subarray?x=x.subarray(0,m):x.length=m),s.applyFromCharCode(x)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var v=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=v;(v=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),v.set(f,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var m=function(g,_){var x;for((_=_||g.length)>g.length&&(_=g.length),x=_-1;0<=x&&(192&g[x])==128;)x--;return x<0||x===0?_:x+c[g[x]]>_?x:_}(v),y=v;m!==v.length&&(i.uint8array?(y=v.subarray(0,m),this.leftOver=v.subarray(m,v.length)):(y=v.slice(0,m),this.leftOver=v.slice(m,v.length))),this.push({data:o.utf8decode(y),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(f){return f}function u(f,m){for(var y=0;y>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var v,f,m,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?p[m++]=224|h>>>12:(p[m++]=240|h>>>18,p[m++]=128|h>>>12&63),p[m++]=128|h>>>6&63),p[m++]=128|63&h);return p},o.buf2binstring=function(d){return u(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,v=p.length;h>10&1023,g[v++]=56320|1023&f)}return u(g,v)},o.utf8border=function(d,p){var h;for((p=p||d.length)>d.length&&(p=d.length),h=p-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?p:h+l[d[h]]>p?h:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,l){for(var c=65535&s|0,u=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:i>>>1;a[l]=i}return a}();r.exports=function(i,a,l,c){var u=s,d=c+l;i^=-1;for(var p=c;p>>8^u[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,p=4,h=0,v=-2,f=-1,m=4,y=2,g=8,_=9,x=286,C=30,D=19,E=2*x+1,F=15,I=3,R=258,K=R+I+1,j=42,M=113,b=1,N=2,H=3,A=4;function X(w,U){return w.msg=u[U],U}function V(w){return(w<<1)-(4w.avail_out&&(W=w.avail_out),W!==0&&(i.arraySet(w.output,U.pending_buf,U.pending_out,W,w.next_out),w.next_out+=W,U.pending_out+=W,w.total_out+=W,w.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function B(w,U){a._tr_flush_block(w,0<=w.block_start?w.block_start:-1,w.strstart-w.block_start,U),w.block_start=w.strstart,z(w.strm)}function ne(w,U){w.pending_buf[w.pending++]=U}function Y(w,U){w.pending_buf[w.pending++]=U>>>8&255,w.pending_buf[w.pending++]=255&U}function Z(w,U){var W,O,S=w.max_chain_length,T=w.strstart,q=w.prev_length,J=w.nice_match,L=w.strstart>w.w_size-K?w.strstart-(w.w_size-K):0,Q=w.window,re=w.w_mask,ee=w.prev,se=w.strstart+R,ge=Q[T+q-1],pe=Q[T+q];w.prev_length>=w.good_match&&(S>>=2),J>w.lookahead&&(J=w.lookahead);do if(Q[(W=U)+q]===pe&&Q[W+q-1]===ge&&Q[W]===Q[T]&&Q[++W]===Q[T+1]){T+=2,W++;do;while(Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&Q[++T]===Q[++W]&&TL&&--S!=0);return q<=w.lookahead?q:w.lookahead}function he(w){var U,W,O,S,T,q,J,L,Q,re,ee=w.w_size;do{if(S=w.window_size-w.lookahead-w.strstart,w.strstart>=ee+(ee-K)){for(i.arraySet(w.window,w.window,ee,ee,0),w.match_start-=ee,w.strstart-=ee,w.block_start-=ee,U=W=w.hash_size;O=w.head[--U],w.head[U]=ee<=O?O-ee:0,--W;);for(U=W=ee;O=w.prev[--U],w.prev[U]=ee<=O?O-ee:0,--W;);S+=ee}if(w.strm.avail_in===0)break;if(q=w.strm,J=w.window,L=w.strstart+w.lookahead,Q=S,re=void 0,re=q.avail_in,Q=I)for(T=w.strstart-w.insert,w.ins_h=w.window[T],w.ins_h=(w.ins_h<=I&&(w.ins_h=(w.ins_h<=I)if(O=a._tr_tally(w,w.strstart-w.match_start,w.match_length-I),w.lookahead-=w.match_length,w.match_length<=w.max_lazy_match&&w.lookahead>=I){for(w.match_length--;w.strstart++,w.ins_h=(w.ins_h<=I&&(w.ins_h=(w.ins_h<=I&&w.match_length<=w.prev_length){for(S=w.strstart+w.lookahead-I,O=a._tr_tally(w,w.strstart-1-w.prev_match,w.prev_length-I),w.lookahead-=w.prev_length-1,w.prev_length-=2;++w.strstart<=S&&(w.ins_h=(w.ins_h<w.pending_buf_size-5&&(W=w.pending_buf_size-5);;){if(w.lookahead<=1){if(he(w),w.lookahead===0&&U===d)return b;if(w.lookahead===0)break}w.strstart+=w.lookahead,w.lookahead=0;var O=w.block_start+W;if((w.strstart===0||w.strstart>=O)&&(w.lookahead=w.strstart-O,w.strstart=O,B(w,!1),w.strm.avail_out===0)||w.strstart-w.block_start>=w.w_size-K&&(B(w,!1),w.strm.avail_out===0))return b}return w.insert=0,U===p?(B(w,!0),w.strm.avail_out===0?H:A):(w.strstart>w.block_start&&(B(w,!1),w.strm.avail_out),b)}),new ue(4,4,8,4,ye),new ue(4,5,16,8,ye),new ue(4,6,32,32,ye),new ue(4,4,16,16,le),new ue(8,16,32,32,le),new ue(8,16,128,128,le),new ue(8,32,128,256,le),new ue(32,128,258,1024,le),new ue(32,258,258,4096,le)],o.deflateInit=function(w,U){return Ee(w,U,g,15,8,0)},o.deflateInit2=Ee,o.deflateReset=me,o.deflateResetKeep=ve,o.deflateSetHeader=function(w,U){return w&&w.state?w.state.wrap!==2?v:(w.state.gzhead=U,h):v},o.deflate=function(w,U){var W,O,S,T;if(!w||!w.state||5>8&255),ne(O,O.gzhead.time>>16&255),ne(O,O.gzhead.time>>24&255),ne(O,O.level===9?2:2<=O.strategy||O.level<2?4:0),ne(O,255&O.gzhead.os),O.gzhead.extra&&O.gzhead.extra.length&&(ne(O,255&O.gzhead.extra.length),ne(O,O.gzhead.extra.length>>8&255)),O.gzhead.hcrc&&(w.adler=c(w.adler,O.pending_buf,O.pending,0)),O.gzindex=0,O.status=69):(ne(O,0),ne(O,0),ne(O,0),ne(O,0),ne(O,0),ne(O,O.level===9?2:2<=O.strategy||O.level<2?4:0),ne(O,3),O.status=M);else{var q=g+(O.w_bits-8<<4)<<8;q|=(2<=O.strategy||O.level<2?0:O.level<6?1:O.level===6?2:3)<<6,O.strstart!==0&&(q|=32),q+=31-q%31,O.status=M,Y(O,q),O.strstart!==0&&(Y(O,w.adler>>>16),Y(O,65535&w.adler)),w.adler=1}if(O.status===69)if(O.gzhead.extra){for(S=O.pending;O.gzindex<(65535&O.gzhead.extra.length)&&(O.pending!==O.pending_buf_size||(O.gzhead.hcrc&&O.pending>S&&(w.adler=c(w.adler,O.pending_buf,O.pending-S,S)),z(w),S=O.pending,O.pending!==O.pending_buf_size));)ne(O,255&O.gzhead.extra[O.gzindex]),O.gzindex++;O.gzhead.hcrc&&O.pending>S&&(w.adler=c(w.adler,O.pending_buf,O.pending-S,S)),O.gzindex===O.gzhead.extra.length&&(O.gzindex=0,O.status=73)}else O.status=73;if(O.status===73)if(O.gzhead.name){S=O.pending;do{if(O.pending===O.pending_buf_size&&(O.gzhead.hcrc&&O.pending>S&&(w.adler=c(w.adler,O.pending_buf,O.pending-S,S)),z(w),S=O.pending,O.pending===O.pending_buf_size)){T=1;break}T=O.gzindexS&&(w.adler=c(w.adler,O.pending_buf,O.pending-S,S)),T===0&&(O.gzindex=0,O.status=91)}else O.status=91;if(O.status===91)if(O.gzhead.comment){S=O.pending;do{if(O.pending===O.pending_buf_size&&(O.gzhead.hcrc&&O.pending>S&&(w.adler=c(w.adler,O.pending_buf,O.pending-S,S)),z(w),S=O.pending,O.pending===O.pending_buf_size)){T=1;break}T=O.gzindexS&&(w.adler=c(w.adler,O.pending_buf,O.pending-S,S)),T===0&&(O.status=103)}else O.status=103;if(O.status===103&&(O.gzhead.hcrc?(O.pending+2>O.pending_buf_size&&z(w),O.pending+2<=O.pending_buf_size&&(ne(O,255&w.adler),ne(O,w.adler>>8&255),w.adler=0,O.status=M)):O.status=M),O.pending!==0){if(z(w),w.avail_out===0)return O.last_flush=-1,h}else if(w.avail_in===0&&V(U)<=V(W)&&U!==p)return X(w,-5);if(O.status===666&&w.avail_in!==0)return X(w,-5);if(w.avail_in!==0||O.lookahead!==0||U!==d&&O.status!==666){var J=O.strategy===2?function(L,Q){for(var re;;){if(L.lookahead===0&&(he(L),L.lookahead===0)){if(Q===d)return b;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(B(L,!1),L.strm.avail_out===0))return b}return L.insert=0,Q===p?(B(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(B(L,!1),L.strm.avail_out===0)?b:N}(O,U):O.strategy===3?function(L,Q){for(var re,ee,se,ge,pe=L.window;;){if(L.lookahead<=R){if(he(L),L.lookahead<=R&&Q===d)return b;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=I&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=I?(re=a._tr_tally(L,1,L.match_length-I),L.lookahead-=L.match_length,L.strstart+=L.match_length,L.match_length=0):(re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++),re&&(B(L,!1),L.strm.avail_out===0))return b}return L.insert=0,Q===p?(B(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(B(L,!1),L.strm.avail_out===0)?b:N}(O,U):s[O.level].func(O,U);if(J!==H&&J!==A||(O.status=666),J===b||J===H)return w.avail_out===0&&(O.last_flush=-1),h;if(J===N&&(U===1?a._tr_align(O):U!==5&&(a._tr_stored_block(O,0,0,!1),U===3&&(te(O.head),O.lookahead===0&&(O.strstart=0,O.block_start=0,O.insert=0))),z(w),w.avail_out===0))return O.last_flush=-1,h}return U!==p?h:O.wrap<=0?1:(O.wrap===2?(ne(O,255&w.adler),ne(O,w.adler>>8&255),ne(O,w.adler>>16&255),ne(O,w.adler>>24&255),ne(O,255&w.total_in),ne(O,w.total_in>>8&255),ne(O,w.total_in>>16&255),ne(O,w.total_in>>24&255)):(Y(O,w.adler>>>16),Y(O,65535&w.adler)),z(w),0=W.w_size&&(T===0&&(te(W.head),W.strstart=0,W.block_start=0,W.insert=0),Q=new i.Buf8(W.w_size),i.arraySet(Q,U,re-W.w_size,W.w_size,0),U=Q,re=W.w_size),q=w.avail_in,J=w.next_in,L=w.input,w.avail_in=re,w.next_in=0,w.input=U,he(W);W.lookahead>=I;){for(O=W.strstart,S=W.lookahead-(I-1);W.ins_h=(W.ins_h<>>=I=F>>>24,_-=I,(I=F>>>16&255)===0)N[u++]=65535&F;else{if(!(16&I)){if(!(64&I)){F=x[(65535&F)+(g&(1<>>=I,_-=I),_<15&&(g+=b[l++]<<_,_+=8,g+=b[l++]<<_,_+=8),F=C[g&E];n:for(;;){if(g>>>=I=F>>>24,_-=I,!(16&(I=F>>>16&255))){if(!(64&I)){F=C[(65535&F)+(g&(1<>>=I,_-=I,(I=u-d)>3,g&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=u,s.avail_in=l>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<24)}function g(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(j){var M;return j&&j.state?(M=j.state,j.total_in=j.total_out=M.total=0,j.msg="",M.wrap&&(j.adler=1&M.wrap),M.mode=v,M.last=0,M.havedict=0,M.dmax=32768,M.head=null,M.hold=0,M.bits=0,M.lencode=M.lendyn=new s.Buf32(f),M.distcode=M.distdyn=new s.Buf32(m),M.sane=1,M.back=-1,p):h}function x(j){var M;return j&&j.state?((M=j.state).wsize=0,M.whave=0,M.wnext=0,_(j)):h}function C(j,M){var b,N;return j&&j.state?(N=j.state,M<0?(b=0,M=-M):(b=1+(M>>4),M<48&&(M&=15)),M&&(M<8||15=A.wsize?(s.arraySet(A.window,M,b-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(N<(H=A.wsize-A.wnext)&&(H=N),s.arraySet(A.window,M,b-N,H,A.wnext),(N-=H)?(s.arraySet(A.window,M,b-N,N,0),A.wnext=N,A.whave=A.wsize):(A.wnext+=H,A.wnext===A.wsize&&(A.wnext=0),A.whave>>8&255,b.check=a(b.check,T,2,0),B=z=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&z)<<8)+(z>>8))%31){j.msg="incorrect header check",b.mode=30;break}if((15&z)!=8){j.msg="unknown compression method",b.mode=30;break}if(B-=4,w=8+(15&(z>>>=4)),b.wbits===0)b.wbits=w;else if(w>b.wbits){j.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(T[0]=255&z,T[1]=z>>>8&255,b.check=a(b.check,T,2,0)),B=z=0,b.mode=3;case 3:for(;B<32;){if(V===0)break e;V--,z+=N[A++]<>>8&255,T[2]=z>>>16&255,T[3]=z>>>24&255,b.check=a(b.check,T,4,0)),B=z=0,b.mode=4;case 4:for(;B<16;){if(V===0)break e;V--,z+=N[A++]<>8),512&b.flags&&(T[0]=255&z,T[1]=z>>>8&255,b.check=a(b.check,T,2,0)),B=z=0,b.mode=5;case 5:if(1024&b.flags){for(;B<16;){if(V===0)break e;V--,z+=N[A++]<>>8&255,b.check=a(b.check,T,2,0)),B=z=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(V<(Z=b.length)&&(Z=V),Z&&(b.head&&(w=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,N,A,Z,w)),512&b.flags&&(b.check=a(b.check,N,Z,A)),V-=Z,A+=Z,b.length-=Z),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(V===0)break e;for(Z=0;w=N[A+Z++],b.head&&w&&b.length<65536&&(b.head.name+=String.fromCharCode(w)),w&&Z>9&1,b.head.done=!0),j.adler=b.check=0,b.mode=12;break;case 10:for(;B<32;){if(V===0)break e;V--,z+=N[A++]<>>=7&B,B-=7&B,b.mode=27;break}for(;B<3;){if(V===0)break e;V--,z+=N[A++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,M!==6)break;z>>>=2,B-=2;break e;case 2:b.mode=17;break;case 3:j.msg="invalid block type",b.mode=30}z>>>=2,B-=2;break;case 14:for(z>>>=7&B,B-=7&B;B<32;){if(V===0)break e;V--,z+=N[A++]<>>16^65535)){j.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&z,B=z=0,b.mode=15,M===6)break e;case 15:b.mode=16;case 16:if(Z=b.length){if(V>>=5,B-=5,b.ndist=1+(31&z),z>>>=5,B-=5,b.ncode=4+(15&z),z>>>=4,B-=4,286>>=3,B-=3}for(;b.have<19;)b.lens[q[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},U=c(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,ke=65535&S,!((le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>>=le,B-=le,b.lens[b.have++]=ke;else{if(ke===16){for(O=le+2;B>>=le,B-=le,b.have===0){j.msg="invalid bit length repeat",b.mode=30;break}w=b.lens[b.have-1],Z=3+(3&z),z>>>=2,B-=2}else if(ke===17){for(O=le+3;B>>=le)),z>>>=3,B-=3}else{for(O=le+7;B>>=le)),z>>>=7,B-=7}if(b.have+Z>b.nlen+b.ndist){j.msg="invalid bit length repeat",b.mode=30;break}for(;Z--;)b.lens[b.have++]=w}}if(b.mode===30)break;if(b.lens[256]===0){j.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},U=c(u,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},U=c(d,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,U){j.msg="invalid distances set",b.mode=30;break}if(b.mode=20,M===6)break e;case 20:b.mode=21;case 21:if(6<=V&&258<=te){j.next_out=X,j.avail_out=te,j.next_in=A,j.avail_in=V,b.hold=z,b.bits=B,l(j,Y),X=j.next_out,H=j.output,te=j.avail_out,A=j.next_in,N=j.input,V=j.avail_in,z=b.hold,B=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;ue=(S=b.lencode[z&(1<>>16&255,ke=65535&S,!((le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>ve)])>>>16&255,ke=65535&S,!(ve+(le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>>=ve,B-=ve,b.back+=ve}if(z>>>=le,B-=le,b.back+=le,b.length=ke,ue===0){b.mode=26;break}if(32&ue){b.back=-1,b.mode=12;break}if(64&ue){j.msg="invalid literal/length code",b.mode=30;break}b.extra=15&ue,b.mode=22;case 22:if(b.extra){for(O=b.extra;B>>=b.extra,B-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;ue=(S=b.distcode[z&(1<>>16&255,ke=65535&S,!((le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>ve)])>>>16&255,ke=65535&S,!(ve+(le=S>>>24)<=B);){if(V===0)break e;V--,z+=N[A++]<>>=ve,B-=ve,b.back+=ve}if(z>>>=le,B-=le,b.back+=le,64&ue){j.msg="invalid distance code",b.mode=30;break}b.offset=ke,b.extra=15&ue,b.mode=24;case 24:if(b.extra){for(O=b.extra;B>>=b.extra,B-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){j.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(te===0)break e;if(Z=Y-te,b.offset>Z){if((Z=b.offset-Z)>b.whave&&b.sane){j.msg="invalid distance too far back",b.mode=30;break}he=Z>b.wnext?(Z-=b.wnext,b.wsize-Z):b.wnext-Z,Z>b.length&&(Z=b.length),ye=b.window}else ye=H,he=X-b.offset,Z=b.length;for(teE?(I=he[ye+m[M]],B[ne+m[M]]):(I=96,0),g=1<>X)+(_-=g)]=F<<24|I<<16|R|0,_!==0;);for(g=1<>=1;if(g!==0?(z&=g-1,z+=g):z=0,M++,--Y[j]==0){if(j===N)break;j=d[p+m[M]]}if(H>>7)]}function ne(S,T){S.pending_buf[S.pending++]=255&T,S.pending_buf[S.pending++]=T>>>8&255}function Y(S,T,q){S.bi_valid>y-q?(S.bi_buf|=T<>y-S.bi_valid,S.bi_valid+=q-y):(S.bi_buf|=T<>>=1,q<<=1,0<--T;);return q>>>1}function ye(S,T,q){var J,L,Q=new Array(m+1),re=0;for(J=1;J<=m;J++)Q[J]=re=re+q[J-1]<<1;for(L=0;L<=T;L++){var ee=S[2*L+1];ee!==0&&(S[2*L]=he(Q[ee]++,ee))}}function le(S){var T;for(T=0;T>1;1<=q;q--)ve(S,Q,q);for(L=se;q=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ve(S,Q,1),J=S.heap[1],S.heap[--S.heap_max]=q,S.heap[--S.heap_max]=J,Q[2*L]=Q[2*q]+Q[2*J],S.depth[L]=(S.depth[q]>=S.depth[J]?S.depth[q]:S.depth[J])+1,Q[2*q+1]=Q[2*J+1]=L,S.heap[1]=L++,ve(S,Q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(pe,Xe){var xn,at,kn,je,Qn,io,ht=Xe.dyn_tree,Js=Xe.max_code,Il=Xe.stat_desc.static_tree,Ol=Xe.stat_desc.has_stree,Dl=Xe.stat_desc.extra_bits,Ys=Xe.stat_desc.extra_base,En=Xe.stat_desc.max_length,er=0;for(je=0;je<=m;je++)pe.bl_count[je]=0;for(ht[2*pe.heap[pe.heap_max]+1]=0,xn=pe.heap_max+1;xn>=7;L>>=1)if(1&ge&&ee.dyn_ltree[2*se]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(se=32;se>>3,(Q=S.static_len+3+7>>>3)<=L&&(L=Q)):L=Q=q+5,q+4<=L&&T!==-1?O(S,T,q,J):S.strategy===4||Q===L?(Y(S,2+(J?1:0),3),me(S,K,j)):(Y(S,4+(J?1:0),3),function(ee,se,ge,pe){var Xe;for(Y(ee,se-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Xe=0;Xe>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&T,S.pending_buf[S.l_buf+S.last_lit]=255&q,S.last_lit++,T===0?S.dyn_ltree[2*q]++:(S.matches++,T--,S.dyn_ltree[2*(b[q]+d+1)]++,S.dyn_dtree[2*B(T)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){Y(S,2,3),Z(S,_,K),function(T){T.bi_valid===16?(ne(T,T.bi_buf),T.bi_buf=0,T.bi_valid=0):8<=T.bi_valid&&(T.pending_buf[T.pending++]=255&T.bi_buf,T.bi_buf>>=8,T.bi_valid-=8)}(S)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){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}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,c,u,d,p=1,h={},v=!1,f=i.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(i);m=m&&m.setTimeout?m:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){g(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,C=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=C,x}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(x){i.postMessage(d+x,"*")}):i.MessageChannel?((u=new MessageChannel).port1.onmessage=function(x){g(x.data)},function(x){u.port2.postMessage(x)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(x){var C=f.createElement("script");C.onreadystatechange=function(){g(x),C.onreadystatechange=null,c.removeChild(C),C=null},c.appendChild(C)}):function(x){setTimeout(g,0,x)},m.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var C=new Array(arguments.length-1),D=0;D"u"?s===void 0?this:s:self)}).call(this,typeof tr<"u"?tr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Sl);var Mp=Sl.exports;const Bp=Fa(Mp),zp=async t=>{const e=`ComfyUI workspace workflows ${ml(Date.now())}`,n=new Bp,r=await(G==null?void 0:G.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await kh(o.parentFolderID??null).then(async a=>Ft(a??""));const i=n.folder(s);i==null||i.file(`${o.name}.json`,o.json)}n.generateAsync({type:"blob"}).then(function(o){const s=document.createElement("a");s.href=window.URL.createObjectURL(o),s.download=`${e}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s)})};function Lp({myWorkflowsDir:t}){return k.jsxs(Ke,{gap:3,children:[k.jsx(sn,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),k.jsx("p",{children:"Your workflows will be synced to and from path:"}),k.jsx("p",{children:k.jsx("b",{children:t})}),k.jsxs("p",{children:["You can manually put workflow files into this folder using File Explorer to sync them with your workspace. You can change this path anytime in Settings ",">"," Workspace Save Directory"]}),k.jsxs("p",{children:[k.jsx("b",{children:"Please download all your workflows before enabling two way sync as a backup!"})," ","So you can manually import some workflows into your workspace in case something unexpected happens."]}),k.jsx(Te,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await($==null?void 0:$.listAll());zp(e??[])},children:"👉 Download All My Workflows"})]})}const Wp=(t,e)=>{const n=t.nodes==null?[]:t.nodes,r=e.nodes==null?[]:e.nodes;t.nodes=[],e.nodes=[];let o=JSON.stringify(t)===JSON.stringify(e);if(o){const s=(a,l)=>{const c=l.order,u=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",u),l.order=c,l.pos=u,a},i=(a,l,c)=>Math.abs(a-l)>c;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[c,u]of a){if(!l.has(c)){o=!1;break}if(typeof c=="string"&&c.includes("_pos")){const d=l.get(c);if(d==null||u==null||i(d[0],u[0],5)||i(d[1],u[1],5)){o=!1;break}}else if(l.get(c)!==u){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},Up=La.lazy(()=>yn(()=>import("./RecentFilesDrawer-ouPPEt3o.js"),__vite__mapDeps([14,1,8,2,13,15,12,4]))),Kp=La.lazy(()=>yn(()=>import("./GalleryModal-pPf4t3nM.js"),__vite__mapDeps([16,1,15,12,9,8,2,3])));function $p(){const[t,e]=P.useState(null),[n,r]=P.useState("root"),[o,s]=P.useState(!0),[i,a]=P.useState(null),l=P.useRef(null),[c,u]=P.useState(!1),d=P.useRef(null),{showDialog:p}=za(),[h,v]=P.useState(!1);P.useRef(!1);const f=Ua(),[m,y]=Tp(null),g=P.useCallback(async()=>{var N,H;if(l.current){if((N=$==null?void 0:$.curWorkflow)!=null&&N.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const A=JSON.stringify(we.graph.serialize());await Promise.all([$==null?void 0:$.updateFlow(l.current,{json:A}),Ge==null?void 0:Ge.create({workflowID:l.current,json:A,isAutoSave:!1})]),(H=G==null?void 0:G.settings)!=null&&H.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),u(!1)}},[]),_=async()=>{var H,A,X;if((H=G==null?void 0:G.settings)!=null&&H.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const V=(A=$==null?void 0:$.curWorkflow)==null?void 0:A.id;if(V==null)return;const te=(X=await($==null?void 0:$.get(V)))==null?void 0:X.json;te?($==null||$.updateCurWorkflow({...$.curWorkflow,json:te}),await we.loadGraphData(JSON.parse(te)),u(!1)):alert("Error: No last saved version found")}},x=N=>{const H=(N==null?void 0:N.id)??null;if($==null||$.updateCurWorkflow(N),l.current=H,a(H),e((N==null?void 0:N.name)??""),H==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Da()){const A=yl(H);window.location.hash=A,document.title=N.name+" - ComfyUI"}else localStorage.setItem("curFlowID",H),document.title="ComfyUI - "+N.name;N&&($==null||$.updateLastOpenedTime(N.id))},C=async()=>{localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Lh()}catch(A){console.error("error loading db",A)}s(!1);let N=null;N=Da(),N==null&&(N=localStorage.getItem("curFlowID")),N&&E(N),fetch("/workspace/deduplicate_workflow_ids"),!await(G==null?void 0:G.getSetting("twoWaySync"))&&ie.cache.get(ko).then(async A=>{if((A==null?void 0:A.value)!=="true"){if(await ie.workflows.count()==0){await(G==null?void 0:G.upsert({twoWaySync:!0})),await ie.cache.put({id:ko,value:"true"});return}const V=await(G==null?void 0:G.getSetting("myWorkflowsDir"));p(k.jsx(Lp,{myWorkflowsDir:V??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(G==null?void 0:G.upsert({twoWaySync:!0})),await(G==null?void 0:G.getSetting("twoWaySync"))&&(ie.cache.put({id:ko,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},D=()=>{if(l.current==null)return!1;const N=$==null?void 0:$.curWorkflow;if(N==null)return!1;if(N.json==null)return!0;const H=we.graph.serialize()??{};let A={};try{A=N!=null&&N.json?JSON.parse(N==null?void 0:N.json):{}}catch(V){console.error("error parsing json",V)}return!Wp(H,A)},E=async(N,H)=>{if(we.graph==null)return;const A=await($==null?void 0:$.get(N));if(A==null){alert("Error: Workflow not found! id: "+N),x(null);return}const X=H?await(be==null?void 0:be.get(H)):null;we.ui.dialog.close(),X?(y(X),x({...A,json:X.json}),we.loadGraphData(JSON.parse(X.json))):(x(A),y(null),we.loadGraphData(JSON.parse(A.json))),r("root"),c&&u(!1)},F=async(N,H,A=!1)=>{var X;if(N===null){x(null),we.graph.clear();return}if(!c||A||(X=G==null?void 0:G.settings)!=null&&X.autoSave||($==null?void 0:$.curWorkflow)==null){E(N,H);return}I(N)},I=async N=>{var A;const H=[N?{label:"Open in new tab",icon:k.jsx(bl,{}),onClick:()=>{Oh(N)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await g(),N&&E(N)}}];H.push({label:"Discard",colorScheme:"red",onClick:async()=>{N&&E(N)}}),p(`Please save or discard your changes to "${(A=$==null?void 0:$.curWorkflow)==null?void 0:A.name}" before leaving, or your changes will be lost.`,H)},R=async N=>{const H=(N==null?void 0:N.json)??JSON.stringify(Cr),A=await($==null?void 0:$.createFlow({json:H,name:N==null?void 0:N.name}));A&&await F(A.id),r("root")},K=async(N,H=!1)=>{const A=N.split("/").pop()??N;H?g():R({name:A});const X=await fetch(Ih(N)),V=await X.blob(),te=new File([V],A,{type:X.headers.get("Content-Type")||""});await we.handleFile(te),r("root")},j=async(N,H)=>{const A=await($==null?void 0:$.get(N));if(A==null)return;const X=await($==null?void 0:$.createFlow({json:A.json,name:H||A.name,parentFolderID:A.parentFolderID,tags:A.tags}));X&&await F(X.id)},M=P.useCallback(N=>{if(l.current==null)return;let H=N.filename;N.subfolder!=null&&N.subfolder!==""&&(H=N.subfolder+"/"+H),Ht==null||Ht.create({workflowID:l.current,localPath:H})},[]),b=P.useCallback(()=>{r("root")},[]);return P.useEffect(()=>{C(),v(!0);const N=document.getElementById("comfy-file-input"),H=async()=>{if(N&&N.files&&N.files.length>0){const te={id:Dr(),name:N.files[0].name,json:JSON.stringify(Cr),updateTime:Date.now(),createTime:Date.now()};x(te),await($==null?void 0:$.createFlow(te))}};N==null||N.addEventListener("change",H);const A=te=>{var ne,Y;const z=((ne=G==null?void 0:G.settings)==null?void 0:ne.autoSave)??!0;if((Y=$==null?void 0:$.curWorkflow)!=null&&Y.saveLock)return;const B=D();!z&&B&&(te.preventDefault(),te.returnValue="You have unsaved changes!",I())};window.addEventListener("beforeunload",A);const X=te=>{var z,B,ne,Y,Z,he;(ne=(B=(z=te.detail)==null?void 0:z.output)==null?void 0:B.images)==null||ne.forEach(ye=>{ye.type==="output"&&M(ye)}),(he=(Z=(Y=te.detail)==null?void 0:Y.output)==null?void 0:Z.gifs)==null||he.forEach(ye=>{ye.type==="output"&&M(ye)})};ql.addEventListener("executed",X);const V=async te=>{var Y,Z;const z=(Z=(Y=te.dataTransfer)==null?void 0:Y.files[0])==null?void 0:Z.name,B=we.dragOverNode;if(B&&B.onDragDrop)return;if(!(await(G==null?void 0:G.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&z){const he={id:Dr(),name:z,json:JSON.stringify(Cr),updateTime:Date.now(),createTime:Date.now()};x(he),await($==null?void 0:$.createFlow(he))}};return we.canvasEl.addEventListener("drop",V),()=>{window.removeEventListener("change",H),window.removeEventListener("beforeunload",A),window.removeEventListener("executed",X),we.canvasEl.removeEventListener("drop",V)}},[]),o?null:k.jsx(Ct.Provider,{value:{curFlowID:i,onDuplicateWorkflow:j,loadWorkflowID:F,discardUnsavedChanges:_,saveCurWorkflow:g,isDirty:c,setIsDirty:u,loadNewWorkflow:R,loadFilePath:K,setRoute:r,route:n,curVersion:m,setCurVersion:y},children:k.jsx("div",{ref:d,className:"workspace_manager",children:k.jsxs(Ma,{containerRef:d,children:[k.jsxs(jt,{style:{position:"absolute",top:0,right:0,left:0},zIndex:xh,draggable:!1,children:[k.jsx(Ap,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&k.jsx(P.Suspense,{children:k.jsx(Up,{onClose:b,onClickNewFlow:()=>{R(),r("root")}})}),n==="gallery"&&k.jsx(P.Suspense,{children:k.jsx(Kp,{onclose:()=>r("root")})})]}),k.jsx(Np,{})]})})})}const _m=Object.freeze(Object.defineProperty({__proto__:null,default:$p},Symbol.toStringTag,{value:"Module"}));export{Oh as $,Jh as A,jt as B,om as C,dp as D,yh as E,Wt as F,Yh as G,ot as H,un as I,Ph as J,Le as K,Yr as L,_i as M,Qr as N,Xr as O,np as P,op as Q,hm as R,Ad as S,Gt as T,Cr as U,am as V,xr as W,zh as X,rm as Y,Ct as Z,bl as _,Yp as a,_l as a0,Ht as a1,ml as a2,ct as a3,hc as a4,xh as a5,Qp as a6,Er as a7,im as a8,Va as a9,Tp as aA,Mh as aB,um as aC,pm as aD,us as aE,ks as aF,vn as aG,gm as aH,oi as aI,be as aJ,vm as aK,wm as aL,Sp as aM,bm as aN,qe as aO,fc as aP,_m as aQ,_c as aa,cm as ab,Ha as ac,Th as ad,sn as ae,on as af,xc as ag,Wp as ah,sm as ai,lm as aj,Ge as ak,Yl as al,ie as am,ym as an,bf as ao,dm as ap,fm as aq,em as ar,tm as as,Wc as at,ki as au,xi as av,Oi as aw,Ei as ax,Si as ay,mm as az,Zp as b,Jp as c,Pe as d,ip as e,Ua as f,Ke as g,wt as h,bt as i,gn as j,G as k,Lp as l,Uc as m,wf as n,Xp as o,nm as p,jo as q,Fs as r,Rs as s,Sr as t,to as u,mt as v,Aa as w,$ as x,up as y,zp as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-ABShBZ_r.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-Vyo84f0U.js","workspace_web/IconCopy-j3_qolNw.js","workspace_web/AppIsDirtyEventListener-BH8Pedq1.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-jwv1A1hH.js","workspace_web/chunk-JARCRF6W-66xSMED8.js","workspace_web/chunk-3RSXBRAN-xkXXv8lg.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-ysZyuBYf.js","workspace_web/IconSearch-yd7KVSRG.js","workspace_web/chunk-NTCQBYKE-7yeghZmZ.js","workspace_web/RecentFilesDrawer-qy9dTPVG.js","workspace_web/MediaPreview-IFYm2Mq_.js","workspace_web/GalleryModal-cB6QErx6.js"] + __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-uq7XVWvD.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-Vyo84f0U.js","workspace_web/IconCopy-wyTg5wiq.js","workspace_web/AppIsDirtyEventListener-09XYx3lY.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-wj7k34WI.js","workspace_web/chunk-JARCRF6W-xouhmv4h.js","workspace_web/chunk-3RSXBRAN-8cE0TZNF.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-TbsT5AM9.js","workspace_web/IconSearch-e7N1azjj.js","workspace_web/chunk-NTCQBYKE-nDCdQPx1.js","workspace_web/RecentFilesDrawer-ouPPEt3o.js","workspace_web/MediaPreview-KLEWGSXc.js","workspace_web/GalleryModal-pPf4t3nM.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/dist/workspace_web/AppIsDirtyEventListener-BH8Pedq1.js b/dist/workspace_web/AppIsDirtyEventListener-09XYx3lY.js similarity index 97% rename from dist/workspace_web/AppIsDirtyEventListener-BH8Pedq1.js rename to dist/workspace_web/AppIsDirtyEventListener-09XYx3lY.js index cfc6702..24e6954 100644 --- a/dist/workspace_web/AppIsDirtyEventListener-BH8Pedq1.js +++ b/dist/workspace_web/AppIsDirtyEventListener-09XYx3lY.js @@ -1 +1 @@ -import{r as l,j as S}from"./input.js";import{app as s}from"/scripts/app.js";import{Z as D,f as C,ah as j,i as x,T as W,E as d,ai as _,aj as I,x as r,k as h,ak as L}from"./App-YT7a4Gj6.js";import{u as R}from"./useDebounceFn-ld478fd0.js";import"/scripts/api.js";function F(){const{isDirty:p,setIsDirty:w,setRoute:g,saveCurWorkflow:y}=l.useContext(D),k=l.useRef(p),[m,E]=l.useState(!1);C();const v=l.useRef(null);l.useEffect(()=>{k.current=p},[p]),l.useEffect(()=>{var i,c;const n=t=>{var u;if(document.visibilityState==="hidden")return;const e=I(t);if(e)switch(e===d.openSpotlightSearch&&t.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:e}})),e){case d.SAVE:y();break;case d.SAVE_AS:g("saveAsModal");break;case d.openSpotlightSearch:g("spotlightSearch");break}else(u=t.target)!=null&&u.matches("input, textarea")&&Object.keys(s.canvas.selected_nodes??{}).length&&f()},o=s.canvas.onAfterChange;s.graph.onAfterChange=function(){o==null||o.apply(this,arguments),f()};const a=s.graph.onConfigure;return s.graph.onConfigure=function(){a==null||a.apply(this,arguments),setTimeout(()=>{var e,u;j(s.graph.serialize(),JSON.parse(((u=(e=r)==null?void 0:e.curWorkflow)==null?void 0:u.json)??"{}"))||f()},1e3)},document.addEventListener("click",t=>{Object.keys(s.canvas.selected_nodes??{}).length&&(s.canvas.node_over!=null||s.canvas.node_capturing_input!=null||s.canvas.node_widget!=null)&&f()}),document.addEventListener("keydown",n),(c=(i=h)==null?void 0:i.settings)!=null&&c.autoSave&&h.settings.autoSaveDuration&&(v.current=setInterval(()=>{T()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",n),v.current&&clearInterval(v.current)}},[]);const T=async()=>{var o,a,i,c,t,e;if((a=(o=r)==null?void 0:o.curWorkflow)!=null&&a.saveLock||!((c=(i=r)==null?void 0:i.curWorkflow)!=null&&c.id)||!k.current)return;const n=JSON.stringify(s.graph.serialize());await((t=r)==null?void 0:t.updateFlow(r.curWorkflow.id,{json:n})),(e=L)==null||e.create({workflowID:r.curWorkflow.id,isAutoSave:!0,json:n}),w(!1)},b=async()=>{var n,o,a,i,c,t,e;(o=(n=r)==null?void 0:n.curWorkflow)!=null&&o.saveLock||k.current||(w(!0),(i=(a=h)==null?void 0:a.settings)!=null&&i.autoSave&&((t=(c=r)==null?void 0:c.curWorkflow)!=null&&t.id)&&!m&&(await((e=r)==null?void 0:e.latestVersionCheck())||E(!0)))},[f,A]=R(b,900);return m?S.jsx(x,{label:"This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.",children:S.jsx(W,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{F as default}; +import{r as l,j as S}from"./input.js";import{app as s}from"/scripts/app.js";import{Z as D,f as C,ah as j,i as x,T as W,E as d,ai as _,aj as I,x as r,k as h,ak as L}from"./App-bXo9NVT7.js";import{u as R}from"./useDebounceFn-ld478fd0.js";import"/scripts/api.js";function F(){const{isDirty:p,setIsDirty:w,setRoute:g,saveCurWorkflow:y}=l.useContext(D),k=l.useRef(p),[m,E]=l.useState(!1);C();const v=l.useRef(null);l.useEffect(()=>{k.current=p},[p]),l.useEffect(()=>{var i,c;const n=t=>{var u;if(document.visibilityState==="hidden")return;const e=I(t);if(e)switch(e===d.openSpotlightSearch&&t.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:e}})),e){case d.SAVE:y();break;case d.SAVE_AS:g("saveAsModal");break;case d.openSpotlightSearch:g("spotlightSearch");break}else(u=t.target)!=null&&u.matches("input, textarea")&&Object.keys(s.canvas.selected_nodes??{}).length&&f()},o=s.canvas.onAfterChange;s.graph.onAfterChange=function(){o==null||o.apply(this,arguments),f()};const a=s.graph.onConfigure;return s.graph.onConfigure=function(){a==null||a.apply(this,arguments),setTimeout(()=>{var e,u;j(s.graph.serialize(),JSON.parse(((u=(e=r)==null?void 0:e.curWorkflow)==null?void 0:u.json)??"{}"))||f()},1e3)},document.addEventListener("click",t=>{Object.keys(s.canvas.selected_nodes??{}).length&&(s.canvas.node_over!=null||s.canvas.node_capturing_input!=null||s.canvas.node_widget!=null)&&f()}),document.addEventListener("keydown",n),(c=(i=h)==null?void 0:i.settings)!=null&&c.autoSave&&h.settings.autoSaveDuration&&(v.current=setInterval(()=>{T()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",n),v.current&&clearInterval(v.current)}},[]);const T=async()=>{var o,a,i,c,t,e;if((a=(o=r)==null?void 0:o.curWorkflow)!=null&&a.saveLock||!((c=(i=r)==null?void 0:i.curWorkflow)!=null&&c.id)||!k.current)return;const n=JSON.stringify(s.graph.serialize());await((t=r)==null?void 0:t.updateFlow(r.curWorkflow.id,{json:n})),(e=L)==null||e.create({workflowID:r.curWorkflow.id,isAutoSave:!0,json:n}),w(!1)},b=async()=>{var n,o,a,i,c,t,e;(o=(n=r)==null?void 0:n.curWorkflow)!=null&&o.saveLock||k.current||(w(!0),(i=(a=h)==null?void 0:a.settings)!=null&&i.autoSave&&((t=(c=r)==null?void 0:c.curWorkflow)!=null&&t.id)&&!m&&(await((e=r)==null?void 0:e.latestVersionCheck())||E(!0)))},[f,A]=R(b,900);return m?S.jsx(x,{label:"This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.",children:S.jsx(W,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{F as default}; diff --git a/dist/workspace_web/GalleryModal-cB6QErx6.js b/dist/workspace_web/GalleryModal-cB6QErx6.js deleted file mode 100644 index 3a0e243..0000000 --- a/dist/workspace_web/GalleryModal-cB6QErx6.js +++ /dev/null @@ -1 +0,0 @@ -import{r as d,d as Se,y as Wt,m as be,b as ct,f as V,l as ut,o as Ae,E as Yt,j as r,g as E,h as dt,p as Xt,W as ht,i as ft,M as Zt,N as qt,O as Jt,Q as Qt,R as en,S as tn}from"./input.js";import{a9 as nn,aa as sn,d as Fe,F as v,ab as rn,ac as on,I as M,j as an,g as Ee,B as xt,h as W,Z as oe,ad as ln,x as A,H as Y,i as F,w as mt,a2 as pt,e as gt,$,ae as cn,y as un}from"./App-YT7a4Gj6.js";import{c as je,p as dn,r as st,v as rt,I as hn,N as fn,a as xn,b as mn,d as pn,e as gn,M as vt,u as vn,S as yn}from"./MediaPreview-IFYm2Mq_.js";import{S as wn}from"./chunk-3RSXBRAN-xkXXv8lg.js";import{u as Sn,C as $e,G as bn}from"./chunk-JARCRF6W-66xSMED8.js";import{app as ot}from"/scripts/app.js";import{L as Ne}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import"/scripts/api.js";import"./IconSearch-yd7KVSRG.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,jn=typeof performance<"u"?()=>performance.now():()=>Date.now(),wt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(jn()),yt);function kn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,x=!1)=>{const f=x&&o,g=f?t:s;return u&&l.add(i),g.indexOf(i)===-1&&(g.push(i),f&&o&&(n=t.length)),i},cancel:i=>{const u=s.indexOf(i);u!==-1&&s.splice(u,1),l.delete(i)},process:i=>{if(o){a=!0;return}if(o=!0,[t,s]=[s,t],s.length=0,n=t.length,n)for(let u=0;u(e[t]=kn(()=>X=!0),e),{}),Cn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||En(),s.schedule(n,o,a)),e},{}),In=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(O),e),{});const Tn=e=>ae[e].process(O),St=e=>{X=!1,O.delta=_e?yt:Math.max(Math.min(e-O.timestamp,Pn),1),O.timestamp=e,Me=!0,Z.forEach(Tn),Me=!1,X&&(_e=!1,wt(St))},En=()=>{X=!0,_e=!0,Me||wt(St)},at=()=>O;var L=e=>e?"":void 0,ke=e=>e?!0:void 0,q=(...e)=>e.filter(Boolean).join(" ");function Pe(...e){return function(s){e.some(n=>(n==null||n(s),s==null?void 0:s.defaultPrevented))}}function Q(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}var te={width:0,height:0},ee=e=>e||te;function Nn(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var w;const N=(w=n[y])!=null?w:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${N.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${N.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,w)=>ee(y).height>ee(w).height?y:w,te):n.reduce((y,w)=>ee(y).width>ee(w).width?y:w,te),c={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...Q({orientation:t,vertical:l?{paddingLeft:l.width/2,paddingRight:l.width/2}:{},horizontal:l?{paddingTop:l.height/2,paddingBottom:l.height/2}:{}})},i={position:"absolute",...Q({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},u=s.length===1,x=[0,o?100-s[0]:s[0]],f=u?x:s;let g=f[0];!u&&o&&(g=100-g);const p=Math.abs(f[f.length-1]-f[0]),k={...i,...Q({orientation:t,vertical:o?{height:`${p}%`,top:`${g}%`}:{height:`${p}%`,bottom:`${g}%`},horizontal:o?{width:`${p}%`,right:`${g}%`}:{width:`${p}%`,left:`${g}%`}})};return{trackStyle:i,innerTrackStyle:k,rootStyle:c,getThumbStyle:a}}function _n(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Mn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Dn(e){const t=Rn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function bt(e){return!!e.touches}function zn(e){return bt(e)&&e.touches.length>1}function Rn(e){var t;return(t=e.view)!=null?t:window}function An(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Fn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function jt(e,t="page"){return bt(e)?An(e,t):Fn(e,t)}function $n(e){return t=>{const s=Dn(t);(!s||s&&t.button===0)&&e(t)}}function Vn(e,t=!1){function s(o){e(o,{point:jt(o)})}return t?$n(s):s}function ne(e,t,s,n){return Mn(e,t,Vn(s,t==="pointerdown"),n)}var Bn=Object.defineProperty,Ln=(e,t,s)=>t in e?Bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t,s)=>(Ln(e,typeof t!="symbol"?t+"":t,s),s),On=class{constructor(e,t,s){T(this,"history",[]),T(this,"startEvent",null),T(this,"lastEvent",null),T(this,"lastEventInfo",null),T(this,"handlers",{}),T(this,"removeListeners",()=>{}),T(this,"threshold",3),T(this,"win"),T(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Kn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:x}=at();this.history.push({...c.point,timestamp:x});const{onStart:f,onMove:g}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),g==null||g(this.lastEvent,c)}),T(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Cn.update(this.updatePoint,!0)}),T(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:x,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!x||!this.startEvent)&&(x==null||x(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,zn(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:jt(e)},{timestamp:a}=at();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Hn(ne(this.win,"pointermove",this.onPointerMove),ne(this.win,"pointerup",this.onPointerUp),ne(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),In.update(this.updatePoint)}};function lt(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:lt(e.point,t[t.length-1]),offset:lt(e.point,t[0]),velocity:Un(t,.1)}}var Gn=e=>e*1e3;function Un(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const o=e[e.length-1];for(;s>=0&&(n=e[s],!(o.timestamp-n.timestamp>Gn(t)));)s--;if(!n)return{x:0,y:0};const a=(o.timestamp-n.timestamp)/1e3;if(a===0)return{x:0,y:0};const l={x:(o.x-n.x)/a,y:(o.y-n.y)/a};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function Hn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function it(e){return"x"in e&&"y"in e}function Kn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(it(e)&&it(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function kt(e){const t=d.useRef(null);return t.current=e,t}function Wn(e,t){const{onPan:s,onPanStart:n,onPanEnd:o,onPanSessionStart:a,onPanSessionEnd:l,threshold:c}=t,i=!!(s||n||o||a||l),u=d.useRef(null),x=kt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,g){u.current=null,o==null||o(f,g)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(x.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function g(p){u.current=new On(p,x.current,c)}return ne(f,"pointerdown",g)},[e,i,x,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Yn(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const s=e.ownerDocument.defaultView??window,n=new s.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[a]=o;let l,c;if("borderBoxSize"in a){const i=a.borderBoxSize,u=Array.isArray(i)?i[0]:i;l=u.inlineSize,c=u.blockSize}else l=e.offsetWidth,c=e.offsetHeight;t({width:l,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}var Xn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Zn(e,t){var s,n;if(!e||!e.parentElement)return;const o=(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window,a=new o.MutationObserver(()=>{t()});return a.observe(e.parentElement,{childList:!0}),()=>{a.disconnect()}}function qn({getNodes:e,observeMutation:t=!0}){const[s,n]=d.useState([]),[o,a]=d.useState(0);return Xn(()=>{const l=e(),c=l.map((i,u)=>Yn(i,x=>{n(f=>[...f.slice(0,u),x,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Zn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function Jn(e){return typeof e=="object"&&e!==null&&"current"in e}function Qn(e){const[t]=qn({observeMutation:!1,getNodes(){return[Jn(e)?e.current:e]}});return t}function es(e){var t;const{min:s=0,max:n=100,onChange:o,value:a,defaultValue:l,isReversed:c,direction:i="ltr",orientation:u="horizontal",id:x,isDisabled:f,isReadOnly:g,onChangeStart:p,onChangeEnd:k,step:y=1,getAriaValueText:w,"aria-valuetext":N,"aria-label":B,"aria-labelledby":b,name:D,focusThumbOnChange:Dt=!0,...Ve}=e,Be=Se(p),G=Se(k),Le=Se(w),I=_n({isReversed:c,direction:i,orientation:u}),[zt,de]=nn({value:a,defaultValue:l??ns(s,n),onChange:o}),[he,Oe]=d.useState(!1),[fe,Ge]=d.useState(!1),xe=!(f||g),me=(n-s)/10,U=y||(n-s)/100,S=je(zt,s,n),Rt=n-S+s,Ue=rt(I?Rt:S,s,n),J=u==="vertical",j=kt({min:s,max:n,step:y,isDisabled:f,value:S,isInteractive:xe,isReversed:I,isVertical:J,eventSource:null,focusThumbOnChange:Dt,orientation:u}),pe=d.useRef(null),ge=d.useRef(null),He=d.useRef(null),At=d.useId(),Ke=x??At,[We,Ye]=[`slider-thumb-${Ke}`,`slider-track-${Ke}`],Ft=d.useCallback(h=>{var m,H;if(!pe.current)return;const P=j.current;P.eventSource="pointer";const _=pe.current.getBoundingClientRect(),{clientX:ye,clientY:Ut}=(H=(m=h.touches)==null?void 0:m[0])!=null?H:h,Ht=J?_.bottom-Ut:ye-_.left,Kt=J?_.height:_.width;let we=Ht/Kt;I&&(we=1-we);let K=dn(we,P.min,P.max);return P.step&&(K=parseFloat(st(K,P.min,P.step))),K=je(K,P.min,P.max),K},[J,I,j]),z=d.useCallback(h=>{const m=j.current;m.isInteractive&&(h=parseFloat(st(h,m.min,U)),h=je(h,m.min,m.max),de(h))},[U,de,j]),R=d.useMemo(()=>({stepUp(h=U){const m=I?S-h:S+h;z(m)},stepDown(h=U){const m=I?S+h:S-h;z(m)},reset(){z(l||0)},stepTo(h){z(h)}}),[z,I,S,U,l]),Xe=d.useCallback(h=>{const m=j.current,P={ArrowRight:()=>R.stepUp(),ArrowUp:()=>R.stepUp(),ArrowLeft:()=>R.stepDown(),ArrowDown:()=>R.stepDown(),PageUp:()=>R.stepUp(me),PageDown:()=>R.stepDown(me),Home:()=>z(m.min),End:()=>z(m.max)}[h.key];P&&(h.preventDefault(),h.stopPropagation(),P(h),m.eventSource="keyboard")},[R,z,me,j]),Ze=(t=Le==null?void 0:Le(S))!=null?t:N,ve=Qn(ge),{getThumbStyle:qe,rootStyle:Je,trackStyle:Qe,innerTrackStyle:et}=d.useMemo(()=>{const h=j.current,m=ve??{width:0,height:0};return Nn({isReversed:I,orientation:h.orientation,thumbRects:[m],thumbPercents:[Ue]})},[I,ve,Ue,j]),tt=d.useCallback(()=>{j.current.focusThumbOnChange&&setTimeout(()=>{var m;return(m=ge.current)==null?void 0:m.focus()})},[j]);Wt(()=>{const h=j.current;tt(),h.eventSource==="keyboard"&&(G==null||G(h.value))},[S,G]);function nt(h){const m=Ft(h);m!=null&&m!==j.current.value&&de(m)}Wn(He,{onPanSessionStart(h){const m=j.current;m.isInteractive&&(Oe(!0),tt(),nt(h),Be==null||Be(m.value))},onPanSessionEnd(){const h=j.current;h.isInteractive&&(Oe(!1),G==null||G(h.value))},onPan(h){j.current.isInteractive&&nt(h)}});const $t=d.useCallback((h={},m=null)=>({...h,...Ve,ref:be(m,He),tabIndex:-1,"aria-disabled":ke(f),"data-focused":L(fe),style:{...h.style,...Je}}),[Ve,f,fe,Je]),Vt=d.useCallback((h={},m=null)=>({...h,ref:be(m,pe),id:Ye,"data-disabled":L(f),style:{...h.style,...Qe}}),[f,Ye,Qe]),Bt=d.useCallback((h={},m=null)=>({...h,ref:m,style:{...h.style,...et}}),[et]),Lt=d.useCallback((h={},m=null)=>({...h,ref:be(m,ge),role:"slider",tabIndex:xe?0:void 0,id:We,"data-active":L(he),"aria-valuetext":Ze,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":S,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(g),"aria-label":B,"aria-labelledby":B?void 0:b,style:{...h.style,...qe(0)},onKeyDown:Pe(h.onKeyDown,Xe),onFocus:Pe(h.onFocus,()=>Ge(!0)),onBlur:Pe(h.onBlur,()=>Ge(!1))}),[xe,We,he,Ze,s,n,S,u,f,g,B,b,qe,Xe]),Ot=d.useCallback((h,m=null)=>{const H=!(h.valuen),P=S>=h.value,_=rt(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ts({orientation:u,vertical:{bottom:I?`${100-_}%`:`${_}%`},horizontal:{left:I?`${100-_}%`:`${_}%`}})};return{...h,ref:m,role:"presentation","aria-hidden":!0,"data-disabled":L(f),"data-invalid":L(!H),"data-highlighted":L(P),style:{...h.style,...ye}}},[f,I,n,s,u,S]),Gt=d.useCallback((h={},m=null)=>({...h,ref:m,type:"hidden",value:S,name:D}),[D,S]);return{state:{value:S,isFocused:fe,isDragging:he},actions:R,getRootProps:$t,getTrackProps:Vt,getInnerTrackProps:Bt,getThumbProps:Lt,getMarkerProps:Ot,getInputProps:Gt}}function ts(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function ns(e,t){return t"}),[rs,ie]=ct({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),Pt=V((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=ut("Slider",n),a=Ae(n),{direction:l}=Yt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=es(a),x=i(),f=c({},t);return r.jsx(ss,{value:u,children:r.jsx(rs,{value:o,children:r.jsxs(E.div,{...x,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});Pt.displayName="Slider";var Ct=V((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});Ct.displayName="SliderThumb";var It=V((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});It.displayName="SliderTrack";var Tt=V((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Tt.displayName="SliderFilledTrack";var os=V((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});os.displayName="SliderMark";var De=V(function(t,s){const n=ut("Switch",t),{spacing:o="0.5rem",children:a,...l}=Ae(t),{getIndicatorProps:c,getInputProps:i,getCheckboxProps:u,getRootProps:x,getLabelProps:f}=Sn(l),g=d.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...n.container}),[n.container]),p=d.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...n.track}),[n.track]),k=d.useMemo(()=>({userSelect:"none",marginStart:o,...n.label}),[o,n.label]);return r.jsxs(E.label,{...x(),className:dt("chakra-switch",t.className),__css:g,children:[r.jsx("input",{className:"chakra-switch__input",...i({},s)}),r.jsx(E.span,{...u(),className:"chakra-switch__track",__css:p,children:r.jsx(E.span,{__css:n.thumb,className:"chakra-switch__thumb",...c()})}),a&&r.jsx(E.span,{className:"chakra-switch__label",...f(),__css:k,children:a})]})});De.displayName="Switch";function as(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var ls=["h","minH","height","minHeight"],Et=V((e,t)=>{const s=Xt("Textarea",e),{className:n,rows:o,...a}=Ae(e),l=sn(a),c=o?as(s,ls):s;return r.jsx(E.textarea,{ref:t,rows:o,...l,className:dt("chakra-textarea",n),__css:c})});Et.displayName="Textarea";var is=Fe("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Nt=Fe("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),_t=Fe("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const cs=({setMediaAct:e,media:t,currentNum:s})=>{const n=l=>{const c=(s+l+t.length)%t.length;e&&e(t[c])},o={width:"100%",height:"100%"};if(t.length===0)return r.jsx("p",{children:"No images found, let's start generating 🪄"});const a=t.at(s);return a?r.jsxs(v,{justifyContent:"center",alignItems:"center",position:"relative",width:o.width,height:o.height,overflow:"hidden",children:[r.jsx("div",{style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%"},onClick:()=>{window.open(a.imageUrl)},children:rn(a.imageUrl)?r.jsx(on,{src:a.imageUrl,alt:`image-${a.id}`,width:"100%",height:"100%",objectFit:"contain"}):r.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:a.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:r.jsx("track",{kind:"captions"})})},a.id),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(is,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(hn,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null},us=({inputItem:e})=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(an,{value:e.inputValue,onChange:t=>{}})]}),ds=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(fn,{width:"100%",step:e==null?void 0:e.step,value:t.inputValue,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:s=>{},children:[r.jsx(xn,{}),r.jsxs(mn,{children:[r.jsx(pn,{}),r.jsx(gn,{})]})]})]}),r.jsx(v,{children:r.jsxs(Pt,{maxWidth:"400px",step:e==null?void 0:e.step,value:Number(t.inputValue),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:s=>{},children:[r.jsx(It,{children:r.jsx(Tt,{})}),r.jsx(Ct,{})]})})]})},hs=e=>{var s;const{inputItem:t}=e;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(wn,{value:t.inputValue,onChange:n=>{},children:(s=e==null?void 0:e.options)==null?void 0:s.map((n,o)=>r.jsx("option",{value:n,children:n},`select${t.nodeID}${t.inputName}${o}`))})]})},fs=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsx(v,{children:t.label??t.inputName}),r.jsx(Et,{value:t.inputValue,onChange:s=>{},rows:5})]})};var C=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(C||{});const xs=e=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(v,{children:"No Support"})]}),ms=e=>{const t=e.inputItem;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx($e,{defaultChecked:!!t.inputValue,onChange:s=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:s.target.checked})}})]})},ce=d.createContext({topFields:[],calcInputList:[],showNodeName:!1,updateTopField(){}}),ps={[C.Input]:us,[C.InputSlider]:ds,[C.Select]:hs,[C.Textarea]:fs,[C.Checkbox]:ms,NoSupport:xs},gs=LiteGraph.registered_node_types;function vs(e,t){var o,a,l,c,i;const s=(o=gs[e])==null?void 0:o.nodeData,n={...((a=s==null?void 0:s.input)==null?void 0:a.required)??{},...((l=s==null?void 0:s.input)==null?void 0:l.optional)??{}}[t];return(n==null?void 0:n[0])==="STRING"?(c=n==null?void 0:n[1])!=null&&c.multiline?{type:C.Textarea}:{type:C.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:C.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((i=n==null?void 0:n[0])!=null&&i.every(u=>typeof u=="string"))?{options:n==null?void 0:n[0],type:C.Select}:{type:C.NoSupport}}const ze=({inputItem:e})=>{const t=vs(e.classType,e.inputName),[s,n]=d.useState(!1),o=ps[t.type??"Input"],{updateTopField:a,topFields:l}=d.useContext(ce),c=e.children[0]==="negative"||e.children[0]==="positive"?`-${e.children[0]}`:"",i={...e,label:e.label??e.inputName+c};return r.jsxs(v,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(M,{size:"xs",onClick:()=>a==null?void 0:a({name:e.inputName,promptKey:e.nodeID,class_type:e.classType}),variant:"ghost",icon:re(l,{name:e.inputName,promptKey:e.nodeID,classType:e.classType})?r.jsx(Nt,{size:14}):r.jsx(_t,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function ys(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(v,{px:2,gap:2,direction:"column",children:e==null?void 0:e.map(n=>{const o=s.find(a=>a.nodeID==n.promptKey&&a.inputName===n.name&&a.classType===n.class_type);return!n.class_type||!o?null:r.jsx(ze,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function ws(){const{topFields:e,calcInputList:t,showNodeName:s}=d.useContext(ce),n=d.useCallback(a=>{const l=[];return a.forEach(c=>{const i=l[l.length-1];!i||i[0].nodeID!==c.nodeID||i[0].classType!==c.classType?l.push([c]):i.push(c)}),l},[]);if(d.useEffect(()=>{},[s]),!s)return r.jsx(Ee,{children:t.map(a=>re(e,{name:a.inputName,promptKey:a.nodeID,classType:a.classType})?null:r.jsx(ze,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(Ss,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(v,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(ze,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function Ss({title:e,children:t}){return r.jsxs(xt,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(W,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],Re=new Set;function Mt(e,t){if(!Re.has(e.nodeID))return Re.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Mt(t[o],t)}}),Object.entries(e.inputs).forEach(([s,n])=>{Array.isArray(n)||se.push({classType:e.class_type,inputName:s,inputValue:n,nodeID:e.nodeID,children:e.children||[]})}),se}function bs(e){se=[],Re=new Set;for(const t of Object.keys(e))e[t].nodeID=t,Object.entries(e[t].inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0],a=e[o];a.children||(a.children=[]),a.children.push(s)}});for(const t of Object.keys(e))Mt(e[t],e);return se}const re=(e,t)=>e==null?void 0:e.some(s=>s.promptKey===(t==null?void 0:t.promptKey)&&s.name===(t==null?void 0:t.name)&&s.class_type===t.classType);function js({media:e}){const[t,s]=d.useState([]),{curFlowID:n}=d.useContext(oe),[o,a]=d.useState(),[l,c]=d.useState(!0),[i,u]=d.useState(!0);d.useEffect(()=>{e?ln(`/workspace/view_media?filename=${e.localPath}`).then(p=>{a(p.prompt)}):ot.graphToPrompt(ot.graph).then(p=>{a(p.output)})},[e]),d.useEffect(()=>{if(!o)return;const p=bs(o);s(p)},[o]);const[x,f]=d.useState([]);d.useEffect(()=>{(async()=>{var p,k;if(n){const y=(k=await((p=A)==null?void 0:p.get(n)))==null?void 0:k.topFieldsConfig;y&&(f(y),c(!1))}})()},[n]);const g=p=>{var k,y;if(re(x,{name:p.name,promptKey:p==null?void 0:p.promptKey,classType:(p==null?void 0:p.class_type)??""})){const w=x.filter(N=>N.name!==p.name||N.promptKey!==p.promptKey);f(w),n&&((k=A)==null||k.updateTopFields(n,{topFieldsConfig:w}))}else{const w=[...x,p];f(w),n&&((y=A)==null||y.updateTopFields(n,{topFieldsConfig:w}))}};return r.jsx(ce.Provider,{value:{topFields:x,showNodeName:i,calcInputList:t,updateTopField:g},children:r.jsxs(v,{direction:"column",align:"stretch",gap:5,children:[r.jsx(ys,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(De,{isChecked:l,onChange:p=>c(!l)}),r.jsx("p",{children:"Show node names"}),r.jsx(De,{isChecked:i,onChange:p=>u(!i)})]}),l&&r.jsx(ws,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),ks=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ht();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=A)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(v,{flexWrap:"wrap",gap:3,children:[r.jsx(v,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:r.jsx(M,{size:"sm",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(v,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:pt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var u;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((u=$)==null?void 0:u.delete(e.id)),n(x=>x.filter(f=>f.id!==e.id)))}})}),((c=(l=A)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(F,{label:"Set as cover",children:r.jsx(M,{size:"sm",variant:"ghost",icon:t?r.jsx(Nt,{size:19}):r.jsx(_t,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=A)==null?void 0:i.updateMetaInfo(A.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(ft,{onClick:()=>a("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{o(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>o(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"})]}):null},Ps=({media:e})=>r.jsxs(v,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(ks,{media:e}),r.jsx(js,{media:e??null})]}),Te=120;function Cs({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(v,{gap:3,h:"100%",children:[r.jsxs(bn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(cs,{media:e.map(n=>({id:n.id,imageUrl:`/workspace/view_media?filename=${n.localPath}`})),currentNum:(e==null?void 0:e.findIndex(n=>n.id===(t==null?void 0:t.id)))??0,setMediaAct:n=>s((e==null?void 0:e.find(o=>o.id===n.id))??null)})}),r.jsx(v,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(xt,{display:"inline-block",p:1,borderRadius:"4px",width:`${Te+3}px`,height:`${Te+3}px`,cursor:"pointer",border:(t==null?void 0:t.id)===n.id?"1px solid gray":"",onClick:()=>s(n),children:r.jsx(vt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=$)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ps,{media:t??void 0})]})}const Is=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ht();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx($e,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(vt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=$)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(F,{label:pt(e.createTime,!0),children:i}),r.jsx(F,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(ft,{flexGrow:1,onClick:()=>c("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{l(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>l(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var x;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((x=$)==null?void 0:x.delete(e.id))}})})]})]})},Ts=Is;function Es({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=$)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=$)==null||i.filter(u=>{var x;return((x=u.workflowJSON)==null?void 0:x.includes(e))??!1}).then(u=>{s(u)})},[e]);const l=c=>{a([c].concat(t.filter(i=>i.id!==c.id))),n(c),o(!1)};return r.jsx(Y,{wrap:"wrap",children:t.map(c=>r.jsx(Ts,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Os({onclose:e}){const{curFlowID:t}=d.useContext(oe),[s,n]=d.useState(""),[o,a]=d.useState([]),[l,c]=d.useState(!1),[i,u]=d.useState([]),[x,f]=d.useState(),[g,p]=d.useState(""),k=vn(g,300),[y,w]=d.useState(!1),N=async()=>{var D;if(t==null)return;const b=await((D=$)==null?void 0:D.listByWorkflowID(t));u(b??[]),b!=null&&b.length&&f(b[0])};if(d.useEffect(()=>{var b;N(),t&&((b=A)==null||b.get(t).then(D=>{D&&n(D.name)}))},[]),t==null)return null;const B=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:x??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:w},children:r.jsxs(Zt,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[r.jsx(qt,{}),r.jsxs(Jt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[r.jsxs(Qt,{children:[r.jsxs(Y,{gap:2,mb:2,children:[r.jsxs(cn,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(yn,{searchValue:g,onUpdateSearchValue:b=>{p(b),y||w(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx($e,{isChecked:B,onChange:()=>{a(B?[]:i.map(b=>b.id))},children:"All"}),r.jsxs(W,{fontSize:16,children:[o.length," Selected"]}),r.jsx(M,{size:"sm",icon:r.jsx(un,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(Es,{searchQuery:k}):r.jsx(Cs,{mediaList:i})})]})]})})}export{Os as default}; diff --git a/dist/workspace_web/GalleryModal-pPf4t3nM.js b/dist/workspace_web/GalleryModal-pPf4t3nM.js new file mode 100644 index 0000000..1de97e7 --- /dev/null +++ b/dist/workspace_web/GalleryModal-pPf4t3nM.js @@ -0,0 +1 @@ +import{r as d,d as Se,y as Wt,m as be,b as ct,f as V,l as ut,o as Ae,E as Yt,j as r,g as E,h as dt,p as Xt,W as ht,i as ft,M as Zt,N as qt,O as Jt,Q as Qt,R as en,S as tn}from"./input.js";import{a9 as nn,aa as sn,d as Fe,F as v,ab as rn,ac as on,I as M,j as an,g as Ee,B as xt,h as W,Z as oe,ad as ln,x as A,H as Y,i as F,w as mt,a2 as pt,e as gt,a1 as $,ae as cn,y as un}from"./App-bXo9NVT7.js";import{c as je,p as dn,r as st,v as rt,I as hn,N as fn,a as xn,b as mn,d as pn,e as gn,M as vt,u as vn,S as yn}from"./MediaPreview-KLEWGSXc.js";import{S as wn}from"./chunk-3RSXBRAN-8cE0TZNF.js";import{u as Sn,C as $e,G as bn}from"./chunk-JARCRF6W-xouhmv4h.js";import{app as ot}from"/scripts/app.js";import{L as Ne}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import"/scripts/api.js";import"./IconSearch-e7N1azjj.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,jn=typeof performance<"u"?()=>performance.now():()=>Date.now(),wt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(jn()),yt);function kn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,x=!1)=>{const f=x&&o,g=f?t:s;return u&&l.add(i),g.indexOf(i)===-1&&(g.push(i),f&&o&&(n=t.length)),i},cancel:i=>{const u=s.indexOf(i);u!==-1&&s.splice(u,1),l.delete(i)},process:i=>{if(o){a=!0;return}if(o=!0,[t,s]=[s,t],s.length=0,n=t.length,n)for(let u=0;u(e[t]=kn(()=>X=!0),e),{}),Cn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||En(),s.schedule(n,o,a)),e},{}),In=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(O),e),{});const Tn=e=>ae[e].process(O),St=e=>{X=!1,O.delta=_e?yt:Math.max(Math.min(e-O.timestamp,Pn),1),O.timestamp=e,Me=!0,Z.forEach(Tn),Me=!1,X&&(_e=!1,wt(St))},En=()=>{X=!0,_e=!0,Me||wt(St)},at=()=>O;var L=e=>e?"":void 0,ke=e=>e?!0:void 0,q=(...e)=>e.filter(Boolean).join(" ");function Pe(...e){return function(s){e.some(n=>(n==null||n(s),s==null?void 0:s.defaultPrevented))}}function Q(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}var te={width:0,height:0},ee=e=>e||te;function Nn(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var w;const N=(w=n[y])!=null?w:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${N.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${N.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,w)=>ee(y).height>ee(w).height?y:w,te):n.reduce((y,w)=>ee(y).width>ee(w).width?y:w,te),c={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...Q({orientation:t,vertical:l?{paddingLeft:l.width/2,paddingRight:l.width/2}:{},horizontal:l?{paddingTop:l.height/2,paddingBottom:l.height/2}:{}})},i={position:"absolute",...Q({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},u=s.length===1,x=[0,o?100-s[0]:s[0]],f=u?x:s;let g=f[0];!u&&o&&(g=100-g);const p=Math.abs(f[f.length-1]-f[0]),k={...i,...Q({orientation:t,vertical:o?{height:`${p}%`,top:`${g}%`}:{height:`${p}%`,bottom:`${g}%`},horizontal:o?{width:`${p}%`,right:`${g}%`}:{width:`${p}%`,left:`${g}%`}})};return{trackStyle:i,innerTrackStyle:k,rootStyle:c,getThumbStyle:a}}function _n(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Mn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Dn(e){const t=Rn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function bt(e){return!!e.touches}function zn(e){return bt(e)&&e.touches.length>1}function Rn(e){var t;return(t=e.view)!=null?t:window}function An(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Fn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function jt(e,t="page"){return bt(e)?An(e,t):Fn(e,t)}function $n(e){return t=>{const s=Dn(t);(!s||s&&t.button===0)&&e(t)}}function Vn(e,t=!1){function s(o){e(o,{point:jt(o)})}return t?$n(s):s}function ne(e,t,s,n){return Mn(e,t,Vn(s,t==="pointerdown"),n)}var Bn=Object.defineProperty,Ln=(e,t,s)=>t in e?Bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t,s)=>(Ln(e,typeof t!="symbol"?t+"":t,s),s),On=class{constructor(e,t,s){T(this,"history",[]),T(this,"startEvent",null),T(this,"lastEvent",null),T(this,"lastEventInfo",null),T(this,"handlers",{}),T(this,"removeListeners",()=>{}),T(this,"threshold",3),T(this,"win"),T(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Kn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:x}=at();this.history.push({...c.point,timestamp:x});const{onStart:f,onMove:g}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),g==null||g(this.lastEvent,c)}),T(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Cn.update(this.updatePoint,!0)}),T(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:x,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!x||!this.startEvent)&&(x==null||x(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,zn(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:jt(e)},{timestamp:a}=at();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Hn(ne(this.win,"pointermove",this.onPointerMove),ne(this.win,"pointerup",this.onPointerUp),ne(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),In.update(this.updatePoint)}};function lt(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:lt(e.point,t[t.length-1]),offset:lt(e.point,t[0]),velocity:Un(t,.1)}}var Gn=e=>e*1e3;function Un(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const o=e[e.length-1];for(;s>=0&&(n=e[s],!(o.timestamp-n.timestamp>Gn(t)));)s--;if(!n)return{x:0,y:0};const a=(o.timestamp-n.timestamp)/1e3;if(a===0)return{x:0,y:0};const l={x:(o.x-n.x)/a,y:(o.y-n.y)/a};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function Hn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function it(e){return"x"in e&&"y"in e}function Kn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(it(e)&&it(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function kt(e){const t=d.useRef(null);return t.current=e,t}function Wn(e,t){const{onPan:s,onPanStart:n,onPanEnd:o,onPanSessionStart:a,onPanSessionEnd:l,threshold:c}=t,i=!!(s||n||o||a||l),u=d.useRef(null),x=kt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,g){u.current=null,o==null||o(f,g)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(x.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function g(p){u.current=new On(p,x.current,c)}return ne(f,"pointerdown",g)},[e,i,x,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Yn(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const s=e.ownerDocument.defaultView??window,n=new s.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[a]=o;let l,c;if("borderBoxSize"in a){const i=a.borderBoxSize,u=Array.isArray(i)?i[0]:i;l=u.inlineSize,c=u.blockSize}else l=e.offsetWidth,c=e.offsetHeight;t({width:l,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}var Xn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Zn(e,t){var s,n;if(!e||!e.parentElement)return;const o=(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window,a=new o.MutationObserver(()=>{t()});return a.observe(e.parentElement,{childList:!0}),()=>{a.disconnect()}}function qn({getNodes:e,observeMutation:t=!0}){const[s,n]=d.useState([]),[o,a]=d.useState(0);return Xn(()=>{const l=e(),c=l.map((i,u)=>Yn(i,x=>{n(f=>[...f.slice(0,u),x,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Zn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function Jn(e){return typeof e=="object"&&e!==null&&"current"in e}function Qn(e){const[t]=qn({observeMutation:!1,getNodes(){return[Jn(e)?e.current:e]}});return t}function es(e){var t;const{min:s=0,max:n=100,onChange:o,value:a,defaultValue:l,isReversed:c,direction:i="ltr",orientation:u="horizontal",id:x,isDisabled:f,isReadOnly:g,onChangeStart:p,onChangeEnd:k,step:y=1,getAriaValueText:w,"aria-valuetext":N,"aria-label":B,"aria-labelledby":b,name:D,focusThumbOnChange:Dt=!0,...Ve}=e,Be=Se(p),G=Se(k),Le=Se(w),I=_n({isReversed:c,direction:i,orientation:u}),[zt,de]=nn({value:a,defaultValue:l??ns(s,n),onChange:o}),[he,Oe]=d.useState(!1),[fe,Ge]=d.useState(!1),xe=!(f||g),me=(n-s)/10,U=y||(n-s)/100,S=je(zt,s,n),Rt=n-S+s,Ue=rt(I?Rt:S,s,n),J=u==="vertical",j=kt({min:s,max:n,step:y,isDisabled:f,value:S,isInteractive:xe,isReversed:I,isVertical:J,eventSource:null,focusThumbOnChange:Dt,orientation:u}),pe=d.useRef(null),ge=d.useRef(null),He=d.useRef(null),At=d.useId(),Ke=x??At,[We,Ye]=[`slider-thumb-${Ke}`,`slider-track-${Ke}`],Ft=d.useCallback(h=>{var m,H;if(!pe.current)return;const P=j.current;P.eventSource="pointer";const _=pe.current.getBoundingClientRect(),{clientX:ye,clientY:Ut}=(H=(m=h.touches)==null?void 0:m[0])!=null?H:h,Ht=J?_.bottom-Ut:ye-_.left,Kt=J?_.height:_.width;let we=Ht/Kt;I&&(we=1-we);let K=dn(we,P.min,P.max);return P.step&&(K=parseFloat(st(K,P.min,P.step))),K=je(K,P.min,P.max),K},[J,I,j]),z=d.useCallback(h=>{const m=j.current;m.isInteractive&&(h=parseFloat(st(h,m.min,U)),h=je(h,m.min,m.max),de(h))},[U,de,j]),R=d.useMemo(()=>({stepUp(h=U){const m=I?S-h:S+h;z(m)},stepDown(h=U){const m=I?S+h:S-h;z(m)},reset(){z(l||0)},stepTo(h){z(h)}}),[z,I,S,U,l]),Xe=d.useCallback(h=>{const m=j.current,P={ArrowRight:()=>R.stepUp(),ArrowUp:()=>R.stepUp(),ArrowLeft:()=>R.stepDown(),ArrowDown:()=>R.stepDown(),PageUp:()=>R.stepUp(me),PageDown:()=>R.stepDown(me),Home:()=>z(m.min),End:()=>z(m.max)}[h.key];P&&(h.preventDefault(),h.stopPropagation(),P(h),m.eventSource="keyboard")},[R,z,me,j]),Ze=(t=Le==null?void 0:Le(S))!=null?t:N,ve=Qn(ge),{getThumbStyle:qe,rootStyle:Je,trackStyle:Qe,innerTrackStyle:et}=d.useMemo(()=>{const h=j.current,m=ve??{width:0,height:0};return Nn({isReversed:I,orientation:h.orientation,thumbRects:[m],thumbPercents:[Ue]})},[I,ve,Ue,j]),tt=d.useCallback(()=>{j.current.focusThumbOnChange&&setTimeout(()=>{var m;return(m=ge.current)==null?void 0:m.focus()})},[j]);Wt(()=>{const h=j.current;tt(),h.eventSource==="keyboard"&&(G==null||G(h.value))},[S,G]);function nt(h){const m=Ft(h);m!=null&&m!==j.current.value&&de(m)}Wn(He,{onPanSessionStart(h){const m=j.current;m.isInteractive&&(Oe(!0),tt(),nt(h),Be==null||Be(m.value))},onPanSessionEnd(){const h=j.current;h.isInteractive&&(Oe(!1),G==null||G(h.value))},onPan(h){j.current.isInteractive&&nt(h)}});const $t=d.useCallback((h={},m=null)=>({...h,...Ve,ref:be(m,He),tabIndex:-1,"aria-disabled":ke(f),"data-focused":L(fe),style:{...h.style,...Je}}),[Ve,f,fe,Je]),Vt=d.useCallback((h={},m=null)=>({...h,ref:be(m,pe),id:Ye,"data-disabled":L(f),style:{...h.style,...Qe}}),[f,Ye,Qe]),Bt=d.useCallback((h={},m=null)=>({...h,ref:m,style:{...h.style,...et}}),[et]),Lt=d.useCallback((h={},m=null)=>({...h,ref:be(m,ge),role:"slider",tabIndex:xe?0:void 0,id:We,"data-active":L(he),"aria-valuetext":Ze,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":S,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(g),"aria-label":B,"aria-labelledby":B?void 0:b,style:{...h.style,...qe(0)},onKeyDown:Pe(h.onKeyDown,Xe),onFocus:Pe(h.onFocus,()=>Ge(!0)),onBlur:Pe(h.onBlur,()=>Ge(!1))}),[xe,We,he,Ze,s,n,S,u,f,g,B,b,qe,Xe]),Ot=d.useCallback((h,m=null)=>{const H=!(h.valuen),P=S>=h.value,_=rt(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ts({orientation:u,vertical:{bottom:I?`${100-_}%`:`${_}%`},horizontal:{left:I?`${100-_}%`:`${_}%`}})};return{...h,ref:m,role:"presentation","aria-hidden":!0,"data-disabled":L(f),"data-invalid":L(!H),"data-highlighted":L(P),style:{...h.style,...ye}}},[f,I,n,s,u,S]),Gt=d.useCallback((h={},m=null)=>({...h,ref:m,type:"hidden",value:S,name:D}),[D,S]);return{state:{value:S,isFocused:fe,isDragging:he},actions:R,getRootProps:$t,getTrackProps:Vt,getInnerTrackProps:Bt,getThumbProps:Lt,getMarkerProps:Ot,getInputProps:Gt}}function ts(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function ns(e,t){return t"}),[rs,ie]=ct({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),Pt=V((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=ut("Slider",n),a=Ae(n),{direction:l}=Yt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=es(a),x=i(),f=c({},t);return r.jsx(ss,{value:u,children:r.jsx(rs,{value:o,children:r.jsxs(E.div,{...x,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});Pt.displayName="Slider";var Ct=V((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});Ct.displayName="SliderThumb";var It=V((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});It.displayName="SliderTrack";var Tt=V((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Tt.displayName="SliderFilledTrack";var os=V((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});os.displayName="SliderMark";var De=V(function(t,s){const n=ut("Switch",t),{spacing:o="0.5rem",children:a,...l}=Ae(t),{getIndicatorProps:c,getInputProps:i,getCheckboxProps:u,getRootProps:x,getLabelProps:f}=Sn(l),g=d.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...n.container}),[n.container]),p=d.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...n.track}),[n.track]),k=d.useMemo(()=>({userSelect:"none",marginStart:o,...n.label}),[o,n.label]);return r.jsxs(E.label,{...x(),className:dt("chakra-switch",t.className),__css:g,children:[r.jsx("input",{className:"chakra-switch__input",...i({},s)}),r.jsx(E.span,{...u(),className:"chakra-switch__track",__css:p,children:r.jsx(E.span,{__css:n.thumb,className:"chakra-switch__thumb",...c()})}),a&&r.jsx(E.span,{className:"chakra-switch__label",...f(),__css:k,children:a})]})});De.displayName="Switch";function as(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var ls=["h","minH","height","minHeight"],Et=V((e,t)=>{const s=Xt("Textarea",e),{className:n,rows:o,...a}=Ae(e),l=sn(a),c=o?as(s,ls):s;return r.jsx(E.textarea,{ref:t,rows:o,...l,className:dt("chakra-textarea",n),__css:c})});Et.displayName="Textarea";var is=Fe("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Nt=Fe("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),_t=Fe("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const cs=({setMediaAct:e,media:t,currentNum:s})=>{const n=l=>{const c=(s+l+t.length)%t.length;e&&e(t[c])},o={width:"100%",height:"100%"};if(t.length===0)return r.jsx("p",{children:"No images found, let's start generating 🪄"});const a=t.at(s);return a?r.jsxs(v,{justifyContent:"center",alignItems:"center",position:"relative",width:o.width,height:o.height,overflow:"hidden",children:[r.jsx("div",{style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%"},onClick:()=>{window.open(a.imageUrl)},children:rn(a.imageUrl)?r.jsx(on,{src:a.imageUrl,alt:`image-${a.id}`,width:"100%",height:"100%",objectFit:"contain"}):r.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:a.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:r.jsx("track",{kind:"captions"})})},a.id),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(is,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(hn,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null},us=({inputItem:e})=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(an,{value:e.inputValue,onChange:t=>{}})]}),ds=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(fn,{width:"100%",step:e==null?void 0:e.step,value:t.inputValue,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:s=>{},children:[r.jsx(xn,{}),r.jsxs(mn,{children:[r.jsx(pn,{}),r.jsx(gn,{})]})]})]}),r.jsx(v,{children:r.jsxs(Pt,{maxWidth:"400px",step:e==null?void 0:e.step,value:Number(t.inputValue),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:s=>{},children:[r.jsx(It,{children:r.jsx(Tt,{})}),r.jsx(Ct,{})]})})]})},hs=e=>{var s;const{inputItem:t}=e;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(wn,{value:t.inputValue,onChange:n=>{},children:(s=e==null?void 0:e.options)==null?void 0:s.map((n,o)=>r.jsx("option",{value:n,children:n},`select${t.nodeID}${t.inputName}${o}`))})]})},fs=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsx(v,{children:t.label??t.inputName}),r.jsx(Et,{value:t.inputValue,onChange:s=>{},rows:5})]})};var C=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(C||{});const xs=e=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(v,{children:"No Support"})]}),ms=e=>{const t=e.inputItem;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx($e,{defaultChecked:!!t.inputValue,onChange:s=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:s.target.checked})}})]})},ce=d.createContext({topFields:[],calcInputList:[],showNodeName:!1,updateTopField(){}}),ps={[C.Input]:us,[C.InputSlider]:ds,[C.Select]:hs,[C.Textarea]:fs,[C.Checkbox]:ms,NoSupport:xs},gs=LiteGraph.registered_node_types;function vs(e,t){var o,a,l,c,i;const s=(o=gs[e])==null?void 0:o.nodeData,n={...((a=s==null?void 0:s.input)==null?void 0:a.required)??{},...((l=s==null?void 0:s.input)==null?void 0:l.optional)??{}}[t];return(n==null?void 0:n[0])==="STRING"?(c=n==null?void 0:n[1])!=null&&c.multiline?{type:C.Textarea}:{type:C.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:C.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((i=n==null?void 0:n[0])!=null&&i.every(u=>typeof u=="string"))?{options:n==null?void 0:n[0],type:C.Select}:{type:C.NoSupport}}const ze=({inputItem:e})=>{const t=vs(e.classType,e.inputName),[s,n]=d.useState(!1),o=ps[t.type??"Input"],{updateTopField:a,topFields:l}=d.useContext(ce),c=e.children[0]==="negative"||e.children[0]==="positive"?`-${e.children[0]}`:"",i={...e,label:e.label??e.inputName+c};return r.jsxs(v,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(M,{size:"xs",onClick:()=>a==null?void 0:a({name:e.inputName,promptKey:e.nodeID,class_type:e.classType}),variant:"ghost",icon:re(l,{name:e.inputName,promptKey:e.nodeID,classType:e.classType})?r.jsx(Nt,{size:14}):r.jsx(_t,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function ys(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(v,{px:2,gap:2,direction:"column",children:e==null?void 0:e.map(n=>{const o=s.find(a=>a.nodeID==n.promptKey&&a.inputName===n.name&&a.classType===n.class_type);return!n.class_type||!o?null:r.jsx(ze,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function ws(){const{topFields:e,calcInputList:t,showNodeName:s}=d.useContext(ce),n=d.useCallback(a=>{const l=[];return a.forEach(c=>{const i=l[l.length-1];!i||i[0].nodeID!==c.nodeID||i[0].classType!==c.classType?l.push([c]):i.push(c)}),l},[]);if(d.useEffect(()=>{},[s]),!s)return r.jsx(Ee,{children:t.map(a=>re(e,{name:a.inputName,promptKey:a.nodeID,classType:a.classType})?null:r.jsx(ze,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(Ss,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(v,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(ze,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function Ss({title:e,children:t}){return r.jsxs(xt,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(W,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],Re=new Set;function Mt(e,t){if(!Re.has(e.nodeID))return Re.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Mt(t[o],t)}}),Object.entries(e.inputs).forEach(([s,n])=>{Array.isArray(n)||se.push({classType:e.class_type,inputName:s,inputValue:n,nodeID:e.nodeID,children:e.children||[]})}),se}function bs(e){se=[],Re=new Set;for(const t of Object.keys(e))e[t].nodeID=t,Object.entries(e[t].inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0],a=e[o];a.children||(a.children=[]),a.children.push(s)}});for(const t of Object.keys(e))Mt(e[t],e);return se}const re=(e,t)=>e==null?void 0:e.some(s=>s.promptKey===(t==null?void 0:t.promptKey)&&s.name===(t==null?void 0:t.name)&&s.class_type===t.classType);function js({media:e}){const[t,s]=d.useState([]),{curFlowID:n}=d.useContext(oe),[o,a]=d.useState(),[l,c]=d.useState(!0),[i,u]=d.useState(!0);d.useEffect(()=>{e?ln(`/workspace/view_media?filename=${e.localPath}`).then(p=>{a(p.prompt)}):ot.graphToPrompt(ot.graph).then(p=>{a(p.output)})},[e]),d.useEffect(()=>{if(!o)return;const p=bs(o);s(p)},[o]);const[x,f]=d.useState([]);d.useEffect(()=>{(async()=>{var p,k;if(n){const y=(k=await((p=A)==null?void 0:p.get(n)))==null?void 0:k.topFieldsConfig;y&&(f(y),c(!1))}})()},[n]);const g=p=>{var k,y;if(re(x,{name:p.name,promptKey:p==null?void 0:p.promptKey,classType:(p==null?void 0:p.class_type)??""})){const w=x.filter(N=>N.name!==p.name||N.promptKey!==p.promptKey);f(w),n&&((k=A)==null||k.updateTopFields(n,{topFieldsConfig:w}))}else{const w=[...x,p];f(w),n&&((y=A)==null||y.updateTopFields(n,{topFieldsConfig:w}))}};return r.jsx(ce.Provider,{value:{topFields:x,showNodeName:i,calcInputList:t,updateTopField:g},children:r.jsxs(v,{direction:"column",align:"stretch",gap:5,children:[r.jsx(ys,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(De,{isChecked:l,onChange:p=>c(!l)}),r.jsx("p",{children:"Show node names"}),r.jsx(De,{isChecked:i,onChange:p=>u(!i)})]}),l&&r.jsx(ws,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),ks=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ht();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=A)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(v,{flexWrap:"wrap",gap:3,children:[r.jsx(v,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:r.jsx(M,{size:"sm",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(v,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:pt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var u;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((u=$)==null?void 0:u.delete(e.id)),n(x=>x.filter(f=>f.id!==e.id)))}})}),((c=(l=A)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(F,{label:"Set as cover",children:r.jsx(M,{size:"sm",variant:"ghost",icon:t?r.jsx(Nt,{size:19}):r.jsx(_t,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=A)==null?void 0:i.updateMetaInfo(A.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(ft,{onClick:()=>a("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{o(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>o(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"})]}):null},Ps=({media:e})=>r.jsxs(v,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(ks,{media:e}),r.jsx(js,{media:e??null})]}),Te=120;function Cs({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(v,{gap:3,h:"100%",children:[r.jsxs(bn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(cs,{media:e.map(n=>({id:n.id,imageUrl:`/workspace/view_media?filename=${n.localPath}`})),currentNum:(e==null?void 0:e.findIndex(n=>n.id===(t==null?void 0:t.id)))??0,setMediaAct:n=>s((e==null?void 0:e.find(o=>o.id===n.id))??null)})}),r.jsx(v,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(xt,{display:"inline-block",p:1,borderRadius:"4px",width:`${Te+3}px`,height:`${Te+3}px`,cursor:"pointer",border:(t==null?void 0:t.id)===n.id?"1px solid gray":"",onClick:()=>s(n),children:r.jsx(vt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=$)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ps,{media:t??void 0})]})}const Is=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ht();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx($e,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(vt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=$)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(F,{label:pt(e.createTime,!0),children:i}),r.jsx(F,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(ft,{flexGrow:1,onClick:()=>c("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{l(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>l(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var x;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((x=$)==null?void 0:x.delete(e.id))}})})]})]})},Ts=Is;function Es({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=$)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=$)==null||i.filter(u=>{var x;return((x=u.workflowJSON)==null?void 0:x.includes(e))??!1}).then(u=>{s(u)})},[e]);const l=c=>{a([c].concat(t.filter(i=>i.id!==c.id))),n(c),o(!1)};return r.jsx(Y,{wrap:"wrap",children:t.map(c=>r.jsx(Ts,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Os({onclose:e}){const{curFlowID:t}=d.useContext(oe),[s,n]=d.useState(""),[o,a]=d.useState([]),[l,c]=d.useState(!1),[i,u]=d.useState([]),[x,f]=d.useState(),[g,p]=d.useState(""),k=vn(g,300),[y,w]=d.useState(!1),N=async()=>{var D;if(t==null)return;const b=await((D=$)==null?void 0:D.listByWorkflowID(t));u(b??[]),b!=null&&b.length&&f(b[0])};if(d.useEffect(()=>{var b;N(),t&&((b=A)==null||b.get(t).then(D=>{D&&n(D.name)}))},[]),t==null)return null;const B=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:x??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:w},children:r.jsxs(Zt,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[r.jsx(qt,{}),r.jsxs(Jt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[r.jsxs(Qt,{children:[r.jsxs(Y,{gap:2,mb:2,children:[r.jsxs(cn,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(yn,{searchValue:g,onUpdateSearchValue:b=>{p(b),y||w(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx($e,{isChecked:B,onChange:()=>{a(B?[]:i.map(b=>b.id))},children:"All"}),r.jsxs(W,{fontSize:16,children:[o.length," Selected"]}),r.jsx(M,{size:"sm",icon:r.jsx(un,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(Es,{searchQuery:k}):r.jsx(Cs,{mediaList:i})})]})]})})}export{Os as default}; diff --git a/dist/workspace_web/IconCopy-j3_qolNw.js b/dist/workspace_web/IconCopy-wyTg5wiq.js similarity index 83% rename from dist/workspace_web/IconCopy-j3_qolNw.js rename to dist/workspace_web/IconCopy-wyTg5wiq.js index 896913e..5c66076 100644 --- a/dist/workspace_web/IconCopy-j3_qolNw.js +++ b/dist/workspace_web/IconCopy-wyTg5wiq.js @@ -1 +1 @@ -import{d as a}from"./App-YT7a4Gj6.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I}; +import{d as a}from"./App-bXo9NVT7.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I}; diff --git a/dist/workspace_web/IconSearch-yd7KVSRG.js b/dist/workspace_web/IconSearch-e7N1azjj.js similarity index 67% rename from dist/workspace_web/IconSearch-yd7KVSRG.js rename to dist/workspace_web/IconSearch-e7N1azjj.js index a924ef7..b404cef 100644 --- a/dist/workspace_web/IconSearch-yd7KVSRG.js +++ b/dist/workspace_web/IconSearch-e7N1azjj.js @@ -1 +1 @@ -import{d as a}from"./App-YT7a4Gj6.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I}; +import{d as a}from"./App-bXo9NVT7.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I}; diff --git a/dist/workspace_web/InstallMissingModelsButton-OE80g4ub.js b/dist/workspace_web/InstallMissingModelsButton-OE80g4ub.js new file mode 100644 index 0000000..82de30d --- /dev/null +++ b/dist/workspace_web/InstallMissingModelsButton-OE80g4ub.js @@ -0,0 +1 @@ +import{r as o,j as e,i as C,P as k}from"./input.js";import{app as x}from"/scripts/app.js";import{aO as b,g as I,h as v,H as y,i as S,ac as E,_ as F,am as D,Z as A,ar as z,f as H,B as L,a4 as P,a5 as O,aP as R,F as T,ae as G,aD as N}from"./App-bXo9NVT7.js";import{G as U,i as W}from"./ModelManagerTopbar-wj7k34WI.js";import{C as q,G as B}from"./chunk-JARCRF6W-xouhmv4h.js";import{S as K}from"./chunk-3RSXBRAN-8cE0TZNF.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const Y="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png",Z="https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa";function $({model:l,selectedModelDeps:c,setSelectedModelDeps:n,foldersList:d,setFoldersList:h}){var m,t,a,g,_;const[s,u]=o.useState(),p=(a=(t=(m=x.graph.extra)==null?void 0:m[b])==null?void 0:t.deps)==null?void 0:a.models;o.useEffect(()=>{(async()=>{var f;if(p){const M=p[l.received_value];if((f=p[l.received_value])!=null&&f.downloadUrl){const w=await D.models.where({fileHash:M.fileHash}).toArray();w[0]?u({existingModel:w[0].fileName}):u(M)}}})()},[]);const j=c.map(i=>i.filename);function r(i){return i.existingModel!=null}return e.jsx(U,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(I,{align:"start",children:[e.jsx(v,{children:l.class_type}),e.jsx(y,{ml:3,children:e.jsx(v,{color:"red.400",children:l.received_value})}),s&&r(s)&&e.jsxs(v,{children:["This model is already installed as"," ",e.jsx(v,{as:"span",color:"blue.400",fontWeight:600,children:s.existingModel})]}),s&&!r(s)&&s.fileFolder&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{children:[e.jsx(q,{size:"sm",isChecked:j.includes(s.filename),onChange:i=>{i.target.checked?n([...c,p[l.received_value]]):n(c.filter(f=>f.filename!==s.filename))}},s.filename),e.jsx(S,{label:s.infoUrl,children:e.jsx(C,{size:"sm",onClick:i=>{i.stopPropagation(),window.open(s.infoUrl??"","_blank")},leftIcon:e.jsx(E,{width:5,src:(g=s.downloadUrl)!=null&&g.includes("huggingface")?Y:Z}),rightIcon:e.jsx(F,{size:20}),children:s.filename})})]}),e.jsxs(I,{children:[e.jsx(v,{width:"fit-content",children:"Install path:"}),((_=d[s.fileFolder])==null?void 0:_.length)&&e.jsx(K,{value:d[s.fileFolder].at(0),onChange:i=>{const f={...d},M=f[s.fileFolder].filter(w=>w!==i.target.value);f[s.fileFolder]=[i.target.value,...M],h(f)},children:d[s.fileFolder].map(i=>e.jsx("option",{value:i,children:i},i))})]})]}),!s&&e.jsx(C,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(F,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v7&query=${l.received_value}`,"_blank")},children:"Search in CivitAI"})]})})}function V({onClose:l,missingModels:c}){o.useEffect(()=>(x.canvasEl.addEventListener("click",l),()=>{x.canvasEl.removeEventListener("click",l)}),[]);const[n,d]=o.useState([]),[h,s]=o.useState({}),{setRoute:u}=o.useContext(A),p=o.useCallback(async()=>{const t=await z();t&&s(t)},[]),j=H();o.useEffect(()=>{p()},[]);const r=480,m=()=>{n.forEach(t=>{let a=t.downloadUrl;if(!a||!t.fileFolder||!h[t.fileFolder][0]){j({title:"Error",description:a?"Model install folder path is missing":"Download URL is missing",status:"error",duration:4e3,isClosable:!0});return}if(a.includes("civitai")){const g=N();g&&(a+=`?token=${g}`)}W({file_hash:t.fileHash??void 0,filename:t.filename,save_path:h[t.fileFolder][0],url:a,force_filename:!0})}),j({title:"Installing...Please open Install Models modal or python terminal to view progress.",description:n.map(t=>t.filename).join(", "),status:"info",duration:4e3,isClosable:!0}),u("installModels")};return e.jsx(k,{children:e.jsx(L,{style:{width:r},children:e.jsxs(P,{width:r,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:O,overflowY:"auto",children:[e.jsx(R,{children:e.jsx(T,{justifyContent:"space-between",alignContent:"center",children:e.jsx(G,{size:"md",mr:2,children:"Missing Models"})})}),e.jsxs(C,{width:"fit-content",colorScheme:"teal",size:"sm",onClick:m,children:["Install Selected (",n.length,")"]}),e.jsx(B,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:c.map(t=>e.jsx($,{model:t,setSelectedModelDeps:d,selectedModelDeps:n,foldersList:h,setFoldersList:s},t.received_value))})]})})})}function le({}){const[l,c]=o.useState(!1),[n,d]=o.useState([]);return o.useEffect(()=>{const h=x.queuePrompt;x.queuePrompt=async function(){var s,u;try{await h.apply(this,arguments)}finally{if(!((u=(s=x.graph.extra)==null?void 0:s[b])==null?void 0:u.deps))return;const j=x.lastNodeErrors??{};d(Object.values(j).flatMap(r=>{var m,t;return(t=(m=r==null?void 0:r.errors)==null?void 0:m.filter(a=>(a==null?void 0:a.type)==="value_not_in_list"))==null?void 0:t.map(a=>{const{input_name:g,received_value:_}=a.extra_info;return{class_type:r.class_type,input_name:g,received_value:_}})}))}}},[]),n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(C,{size:"sm","aria-label":"missing models",px:2,onClick:()=>c(!0),colorScheme:"teal",children:["Install Missing (",n.length,")"]}),l&&e.jsx(V,{onClose:()=>c(!1),missingModels:n})]})}export{le as default}; diff --git a/dist/workspace_web/InstallMissingModelsButton-at3wACEK.js b/dist/workspace_web/InstallMissingModelsButton-at3wACEK.js deleted file mode 100644 index 9a0305d..0000000 --- a/dist/workspace_web/InstallMissingModelsButton-at3wACEK.js +++ /dev/null @@ -1 +0,0 @@ -import{r as o,j as e,i as C,P as k}from"./input.js";import{app as x}from"/scripts/app.js";import{aO as b,g as I,h as v,H as y,i as S,ac as E,a1 as F,am as D,Z as A,ar as z,f as H,B as L,a4 as P,a5 as O,aP as R,F as T,ae as G,aD as N}from"./App-YT7a4Gj6.js";import{G as U,i as W}from"./ModelManagerTopbar-jwv1A1hH.js";import{C as q,G as B}from"./chunk-JARCRF6W-66xSMED8.js";import{S as K}from"./chunk-3RSXBRAN-xkXXv8lg.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const Y="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png",Z="https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa";function $({model:l,selectedModelDeps:c,setSelectedModelDeps:n,foldersList:d,setFoldersList:h}){var m,t,a,g,_;const[s,u]=o.useState(),p=(a=(t=(m=x.graph.extra)==null?void 0:m[b])==null?void 0:t.deps)==null?void 0:a.models;o.useEffect(()=>{(async()=>{var f;if(p){const M=p[l.received_value];if((f=p[l.received_value])!=null&&f.downloadUrl){const w=await D.models.where({fileHash:M.fileHash}).toArray();w[0]?u({existingModel:w[0].fileName}):u(M)}}})()},[]);const j=c.map(i=>i.filename);function r(i){return i.existingModel!=null}return e.jsx(U,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(I,{align:"start",children:[e.jsx(v,{children:l.class_type}),e.jsx(y,{ml:3,children:e.jsx(v,{color:"red.400",children:l.received_value})}),s&&r(s)&&e.jsxs(v,{children:["This model is already installed as"," ",e.jsx(v,{as:"span",color:"blue.400",fontWeight:600,children:s.existingModel})]}),s&&!r(s)&&s.fileFolder&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{children:[e.jsx(q,{size:"sm",isChecked:j.includes(s.filename),onChange:i=>{i.target.checked?n([...c,p[l.received_value]]):n(c.filter(f=>f.filename!==s.filename))}},s.filename),e.jsx(S,{label:s.infoUrl,children:e.jsx(C,{size:"sm",onClick:i=>{i.stopPropagation(),window.open(s.infoUrl??"","_blank")},leftIcon:e.jsx(E,{width:5,src:(g=s.downloadUrl)!=null&&g.includes("huggingface")?Y:Z}),rightIcon:e.jsx(F,{size:20}),children:s.filename})})]}),e.jsxs(I,{children:[e.jsx(v,{width:"fit-content",children:"Install path:"}),((_=d[s.fileFolder])==null?void 0:_.length)&&e.jsx(K,{value:d[s.fileFolder].at(0),onChange:i=>{const f={...d},M=f[s.fileFolder].filter(w=>w!==i.target.value);f[s.fileFolder]=[i.target.value,...M],h(f)},children:d[s.fileFolder].map(i=>e.jsx("option",{value:i,children:i},i))})]})]}),!s&&e.jsx(C,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(F,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v7&query=${l.received_value}`,"_blank")},children:"Search in CivitAI"})]})})}function V({onClose:l,missingModels:c}){o.useEffect(()=>(x.canvasEl.addEventListener("click",l),()=>{x.canvasEl.removeEventListener("click",l)}),[]);const[n,d]=o.useState([]),[h,s]=o.useState({}),{setRoute:u}=o.useContext(A),p=o.useCallback(async()=>{const t=await z();t&&s(t)},[]),j=H();o.useEffect(()=>{p()},[]);const r=480,m=()=>{n.forEach(t=>{let a=t.downloadUrl;if(!a||!t.fileFolder||!h[t.fileFolder][0]){j({title:"Error",description:a?"Model install folder path is missing":"Download URL is missing",status:"error",duration:4e3,isClosable:!0});return}if(a.includes("civitai")){const g=N();g&&(a+=`?token=${g}`)}W({file_hash:t.fileHash??void 0,filename:t.filename,save_path:h[t.fileFolder][0],url:a,force_filename:!0})}),j({title:"Installing...Please open Install Models modal or python terminal to view progress.",description:n.map(t=>t.filename).join(", "),status:"info",duration:4e3,isClosable:!0}),u("installModels")};return e.jsx(k,{children:e.jsx(L,{style:{width:r},children:e.jsxs(P,{width:r,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:O,overflowY:"auto",children:[e.jsx(R,{children:e.jsx(T,{justifyContent:"space-between",alignContent:"center",children:e.jsx(G,{size:"md",mr:2,children:"Missing Models"})})}),e.jsxs(C,{width:"fit-content",colorScheme:"teal",size:"sm",onClick:m,children:["Install Selected (",n.length,")"]}),e.jsx(B,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:c.map(t=>e.jsx($,{model:t,setSelectedModelDeps:d,selectedModelDeps:n,foldersList:h,setFoldersList:s},t.received_value))})]})})})}function le({}){const[l,c]=o.useState(!1),[n,d]=o.useState([]);return o.useEffect(()=>{const h=x.queuePrompt;x.queuePrompt=async function(){var s,u;try{await h.apply(this,arguments)}finally{if(!((u=(s=x.graph.extra)==null?void 0:s[b])==null?void 0:u.deps))return;const j=x.lastNodeErrors??{};d(Object.values(j).flatMap(r=>{var m,t;return(t=(m=r==null?void 0:r.errors)==null?void 0:m.filter(a=>(a==null?void 0:a.type)==="value_not_in_list"))==null?void 0:t.map(a=>{const{input_name:g,received_value:_}=a.extra_info;return{class_type:r.class_type,input_name:g,received_value:_}})}))}}},[]),n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(C,{size:"sm","aria-label":"missing models",px:2,onClick:()=>c(!0),colorScheme:"teal",children:["Install Missing (",n.length,")"]}),l&&e.jsx(V,{onClose:()=>c(!1),missingModels:n})]})}export{le as default}; diff --git a/dist/workspace_web/MediaPreview-IFYm2Mq_.js b/dist/workspace_web/MediaPreview-KLEWGSXc.js similarity index 98% rename from dist/workspace_web/MediaPreview-IFYm2Mq_.js rename to dist/workspace_web/MediaPreview-KLEWGSXc.js index 21ff558..fe5c61a 100644 --- a/dist/workspace_web/MediaPreview-IFYm2Mq_.js +++ b/dist/workspace_web/MediaPreview-KLEWGSXc.js @@ -1 +1 @@ -import{d as M,r as s,j as f,I as ke,y as Oe,e as Be,m as ae,s as C,q as se,b as Pe,f as j,g as Y,l as Ke,o as Ue,h as Me}from"./input.js";import{af as Ge,ag as qe,d as He,B as Le,I as $e,y as ze,j as We,ab as Xe,ac as Ye}from"./App-YT7a4Gj6.js";import{I as Je}from"./IconSearch-yd7KVSRG.js";function Qe(n){const e=parseFloat(n);return typeof e!="number"||Number.isNaN(e)?0:e}function le(n,e){let r=Qe(n);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(n){if(!Number.isFinite(n))return 0;let e=1,r=0;for(;Math.round(n*e)/e!==n;)e*=10,r+=1;return r}function It(n,e,r){return(n-e)*100/(r-e)}function yt(n,e,r){return(r-e)*n+e}function Ct(n,e,r){const a=Math.round((n-e)/r)*r+e,u=oe(r);return le(a,u)}function Ze(n,e,r){return n==null?n:(r{var p;return a==null?"":(p=ue(a,o,r))!=null?p:""}),S=typeof u<"u",x=S?u:I,O=Fe(A(x),o),F=r??O,y=s.useCallback(p=>{p!==x&&(S||E(p.toString()),h==null||h(p.toString(),A(p)))},[h,S,x]),w=s.useCallback(p=>{let d=p;return b&&(d=Ze(d,i,m)),le(d,F)},[F,b,m,i]),B=s.useCallback((p=o)=>{let d;x===""?d=A(p):d=A(x)+p,d=w(d),y(d)},[w,o,y,x]),K=s.useCallback((p=o)=>{let d;x===""?d=A(-p):d=A(x)-p,d=w(d),y(d)},[w,o,y,x]),U=s.useCallback(()=>{var p;let d;a==null?d="":d=(p=ue(a,o,r))!=null?p:i,y(d)},[a,r,o,y,i]),Q=s.useCallback(p=>{var d;const ee=(d=ue(p,o,F))!=null?d:i;y(ee)},[F,o,y,i]),k=A(x);return{isOutOfRange:k>m||kf.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),nt=n=>f.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function Ae(n,e,r,a){s.useEffect(()=>{var u;if(!n.current||!a)return;const o=(u=n.current.ownerDocument.defaultView)!=null?u:window,i=Array.isArray(e)?e:[e],m=new o.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return m.observe(n.current,{attributes:!0,attributeFilter:i}),()=>m.disconnect()})}function rt(n,e){const r=M(n);s.useEffect(()=>{let a=null;const u=()=>r();return e!==null&&(a=window.setInterval(u,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,Ee=300;function st(n,e){const[r,a]=s.useState(!1),[u,o]=s.useState(null),[i,m]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);rt(()=>{u==="increment"&&n(),u==="decrement"&&e()},r?at:null);const I=s.useCallback(()=>{i&&n(),b.current=setTimeout(()=>{m(!1),a(!0),o("increment")},Ee)},[n,i]),E=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{m(!1),a(!0),o("decrement")},Ee)},[e,i]),S=s.useCallback(()=>{m(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:I,down:E,stop:S,isSpinning:r}}var ut=/^[Ee0-9+\-.]$/;function ot(n){return ut.test(n)}function lt(n,e){if(n.key==null)return!0;const r=n.ctrlKey||n.altKey||n.metaKey;return!(n.key.length===1)||r?!0:e(n.key)}function it(n={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:u=Number.MIN_SAFE_INTEGER,max:o=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:m,isDisabled:b,isRequired:h,isInvalid:I,pattern:E="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:y,name:w,"aria-describedby":B,"aria-label":K,"aria-labelledby":U,onFocus:Q,onBlur:k,onInvalid:ce,getAriaValueText:de,isValidCharacter:Z,format:p,parse:d,...ee}=n,te=M(Q),pe=M(k),V=M(ce),G=M(Z??ot),ne=M(de),l=et(n),{update:T,increment:me,decrement:fe}=l,[Ve,re]=s.useState(!1),q=!(m||b),_=s.useRef(null),H=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),L=s.useCallback(t=>t.split("").filter(G).join(""),[G]),$=s.useCallback(t=>{var c;return(c=d==null?void 0:d(t))!=null?c:t},[d]),R=s.useCallback(t=>{var c;return((c=p==null?void 0:p(t))!=null?c:t).toString()},[p]);Oe(()=>{(l.valueAsNumber>o||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=$(_.current.value);l.setValue(L(c))}},[$,L]);const z=s.useCallback((t=i)=>{q&&me(t)},[me,q,i]),W=s.useCallback((t=i)=>{q&&fe(t)},[fe,q,i]),g=st(z,W);Ae(be,"disabled",g.stop,g.isSpinning),Ae(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;const v=$(t.currentTarget.value);T(L(v)),H.current={start:t.currentTarget.selectionStart,end:t.currentTarget.selectionEnd}},[T,L,$]),ge=s.useCallback(t=>{var c,v,N;te==null||te(t),H.current&&(t.target.selectionStart=(v=H.current.start)!=null?v:(c=t.currentTarget.value)==null?void 0:c.length,t.currentTarget.selectionEnd=(N=H.current.end)!=null?N:t.currentTarget.selectionStart)},[te]),xe=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;lt(t,G)||t.preventDefault();const c=Ne(t)*i,v=t.key,P={ArrowUp:()=>z(c),ArrowDown:()=>W(c),Home:()=>T(u),End:()=>T(o)}[v];P&&(t.preventDefault(),P(t))},[G,i,z,W,T,u,o]),Ne=t=>{let c=1;return(t.metaKey||t.ctrlKey)&&(c=.1),t.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const t=ne==null?void 0:ne(l.value);if(t!=null)return t;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let t=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumbero&&(t=o),l.cast(t))},[l,o,u]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var t;(t=_.current)==null||t.focus()})},[e]),Se=s.useCallback(t=>{t.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(t=>{t.preventDefault(),g.down(),X()},[X,g]);Ge(()=>_.current,"wheel",t=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;t.preventDefault();const D=Ne(t)*i,_e=Math.sign(t.deltaY);_e===-1?z(D):_e===1&&W(D)},{passive:!1});const Te=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMax;return{...t,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),De=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMin;return{...t,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),je=s.useCallback((t={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:E,"aria-labelledby":U,"aria-label":K,"aria-describedby":B,id:O,disabled:b,...t,readOnly:(v=t.readOnly)!=null?v:m,"aria-readonly":(N=t.readOnly)!=null?N:m,"aria-required":(P=t.required)!=null?P:h,required:(D=t.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":u,"aria-valuemax":o,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(I??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:C(t.onChange,he),onKeyDown:C(t.onKeyDown,xe),onFocus:C(t.onFocus,ge,()=>re(!0)),onBlur:C(t.onBlur,pe,Ce)}},[w,S,E,U,K,R,B,O,b,h,m,I,l.value,l.valueAsNumber,l.isOutOfRange,u,o,Ie,he,xe,ge,pe,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:Ve,isDisabled:b,isReadOnly:m,getIncrementButtonProps:Te,getDecrementButtonProps:De,getInputProps:je,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[dt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),pt=j(function(e,r){const a=Ke("NumberInput",e),u=Ue(e),o=qe(u),{htmlProps:i,...m}=it(o),b=s.useMemo(()=>m,[m]);return f.jsx(dt,{value:b,children:f.jsx(ct,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});pt.displayName="NumberInput";var mt=j(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});mt.displayName="NumberInputStepper";var ft=j(function(e,r){const{getInputProps:a}=ie(),u=a(e,r),o=J();return f.jsx(Y.input,{...u,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...o.field}})});ft.displayName="NumberInputField";var Re=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=j(function(e,r){var a;const u=J(),{getDecrementButtonProps:o}=ie(),i=o(e,r);return f.jsx(Re,{...i,__css:u.stepper,children:(a=e.children)!=null?a:f.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var vt=j(function(e,r){var a;const{getIncrementButtonProps:u}=ie(),o=u(e,r),i=J();return f.jsx(Re,{...o,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(nt,{})})});vt.displayName="NumberIncrementStepper";var St=He("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const wt=(n,e)=>{const[r,a]=s.useState(n);return s.useEffect(()=>{const u=setTimeout(()=>{a(n)},e);return()=>{clearTimeout(u)}},[n,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function _t(n){const{searchValue:e,onUpdateSearchValue:r,style:a}=n,u=e!=="";return f.jsxs(Le,{style:{position:"relative",...a},mb:2,children:[f.jsx(Je,{style:ht}),u&&f.jsx($e,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(ze,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(We,{placeholder:n.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function At({mediaLocalPath:n,size:e,isPreview:r,autoPlay:a,hideBrokenImage:u,objectFit:o,onBrokenLink:i}){const[m,b]=s.useState(!0);return s.useEffect(()=>{u&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${n}`:`/workspace/view_media?filename=${n}`)).status==404){b(!1),i==null||i();return}}catch(I){console.error("Error checking media exists",I)}})()},[]),m?Xe(n)?f.jsx(Ye,{borderRadius:3,boxSize:`${e}px`,objectFit:o??"cover",src:`/workspace/view_media?filename=${n}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${n}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{St as I,At as M,pt as N,_t as S,ft as a,mt as b,Ze as c,vt as d,bt as e,yt as p,Ct as r,wt as u,It as v}; +import{d as M,r as s,j as f,I as ke,y as Oe,e as Be,m as ae,s as C,q as se,b as Pe,f as j,g as Y,l as Ke,o as Ue,h as Me}from"./input.js";import{af as Ge,ag as qe,d as He,B as Le,I as $e,y as ze,j as We,ab as Xe,ac as Ye}from"./App-bXo9NVT7.js";import{I as Je}from"./IconSearch-e7N1azjj.js";function Qe(n){const e=parseFloat(n);return typeof e!="number"||Number.isNaN(e)?0:e}function le(n,e){let r=Qe(n);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(n){if(!Number.isFinite(n))return 0;let e=1,r=0;for(;Math.round(n*e)/e!==n;)e*=10,r+=1;return r}function It(n,e,r){return(n-e)*100/(r-e)}function yt(n,e,r){return(r-e)*n+e}function Ct(n,e,r){const a=Math.round((n-e)/r)*r+e,u=oe(r);return le(a,u)}function Ze(n,e,r){return n==null?n:(r{var p;return a==null?"":(p=ue(a,o,r))!=null?p:""}),S=typeof u<"u",x=S?u:I,O=Fe(A(x),o),F=r??O,y=s.useCallback(p=>{p!==x&&(S||E(p.toString()),h==null||h(p.toString(),A(p)))},[h,S,x]),w=s.useCallback(p=>{let d=p;return b&&(d=Ze(d,i,m)),le(d,F)},[F,b,m,i]),B=s.useCallback((p=o)=>{let d;x===""?d=A(p):d=A(x)+p,d=w(d),y(d)},[w,o,y,x]),K=s.useCallback((p=o)=>{let d;x===""?d=A(-p):d=A(x)-p,d=w(d),y(d)},[w,o,y,x]),U=s.useCallback(()=>{var p;let d;a==null?d="":d=(p=ue(a,o,r))!=null?p:i,y(d)},[a,r,o,y,i]),Q=s.useCallback(p=>{var d;const ee=(d=ue(p,o,F))!=null?d:i;y(ee)},[F,o,y,i]),k=A(x);return{isOutOfRange:k>m||kf.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),nt=n=>f.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function Ae(n,e,r,a){s.useEffect(()=>{var u;if(!n.current||!a)return;const o=(u=n.current.ownerDocument.defaultView)!=null?u:window,i=Array.isArray(e)?e:[e],m=new o.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return m.observe(n.current,{attributes:!0,attributeFilter:i}),()=>m.disconnect()})}function rt(n,e){const r=M(n);s.useEffect(()=>{let a=null;const u=()=>r();return e!==null&&(a=window.setInterval(u,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,Ee=300;function st(n,e){const[r,a]=s.useState(!1),[u,o]=s.useState(null),[i,m]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);rt(()=>{u==="increment"&&n(),u==="decrement"&&e()},r?at:null);const I=s.useCallback(()=>{i&&n(),b.current=setTimeout(()=>{m(!1),a(!0),o("increment")},Ee)},[n,i]),E=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{m(!1),a(!0),o("decrement")},Ee)},[e,i]),S=s.useCallback(()=>{m(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:I,down:E,stop:S,isSpinning:r}}var ut=/^[Ee0-9+\-.]$/;function ot(n){return ut.test(n)}function lt(n,e){if(n.key==null)return!0;const r=n.ctrlKey||n.altKey||n.metaKey;return!(n.key.length===1)||r?!0:e(n.key)}function it(n={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:u=Number.MIN_SAFE_INTEGER,max:o=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:m,isDisabled:b,isRequired:h,isInvalid:I,pattern:E="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:y,name:w,"aria-describedby":B,"aria-label":K,"aria-labelledby":U,onFocus:Q,onBlur:k,onInvalid:ce,getAriaValueText:de,isValidCharacter:Z,format:p,parse:d,...ee}=n,te=M(Q),pe=M(k),V=M(ce),G=M(Z??ot),ne=M(de),l=et(n),{update:T,increment:me,decrement:fe}=l,[Ve,re]=s.useState(!1),q=!(m||b),_=s.useRef(null),H=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),L=s.useCallback(t=>t.split("").filter(G).join(""),[G]),$=s.useCallback(t=>{var c;return(c=d==null?void 0:d(t))!=null?c:t},[d]),R=s.useCallback(t=>{var c;return((c=p==null?void 0:p(t))!=null?c:t).toString()},[p]);Oe(()=>{(l.valueAsNumber>o||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=$(_.current.value);l.setValue(L(c))}},[$,L]);const z=s.useCallback((t=i)=>{q&&me(t)},[me,q,i]),W=s.useCallback((t=i)=>{q&&fe(t)},[fe,q,i]),g=st(z,W);Ae(be,"disabled",g.stop,g.isSpinning),Ae(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;const v=$(t.currentTarget.value);T(L(v)),H.current={start:t.currentTarget.selectionStart,end:t.currentTarget.selectionEnd}},[T,L,$]),ge=s.useCallback(t=>{var c,v,N;te==null||te(t),H.current&&(t.target.selectionStart=(v=H.current.start)!=null?v:(c=t.currentTarget.value)==null?void 0:c.length,t.currentTarget.selectionEnd=(N=H.current.end)!=null?N:t.currentTarget.selectionStart)},[te]),xe=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;lt(t,G)||t.preventDefault();const c=Ne(t)*i,v=t.key,P={ArrowUp:()=>z(c),ArrowDown:()=>W(c),Home:()=>T(u),End:()=>T(o)}[v];P&&(t.preventDefault(),P(t))},[G,i,z,W,T,u,o]),Ne=t=>{let c=1;return(t.metaKey||t.ctrlKey)&&(c=.1),t.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const t=ne==null?void 0:ne(l.value);if(t!=null)return t;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let t=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumbero&&(t=o),l.cast(t))},[l,o,u]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var t;(t=_.current)==null||t.focus()})},[e]),Se=s.useCallback(t=>{t.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(t=>{t.preventDefault(),g.down(),X()},[X,g]);Ge(()=>_.current,"wheel",t=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;t.preventDefault();const D=Ne(t)*i,_e=Math.sign(t.deltaY);_e===-1?z(D):_e===1&&W(D)},{passive:!1});const Te=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMax;return{...t,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),De=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMin;return{...t,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),je=s.useCallback((t={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:E,"aria-labelledby":U,"aria-label":K,"aria-describedby":B,id:O,disabled:b,...t,readOnly:(v=t.readOnly)!=null?v:m,"aria-readonly":(N=t.readOnly)!=null?N:m,"aria-required":(P=t.required)!=null?P:h,required:(D=t.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":u,"aria-valuemax":o,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(I??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:C(t.onChange,he),onKeyDown:C(t.onKeyDown,xe),onFocus:C(t.onFocus,ge,()=>re(!0)),onBlur:C(t.onBlur,pe,Ce)}},[w,S,E,U,K,R,B,O,b,h,m,I,l.value,l.valueAsNumber,l.isOutOfRange,u,o,Ie,he,xe,ge,pe,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:Ve,isDisabled:b,isReadOnly:m,getIncrementButtonProps:Te,getDecrementButtonProps:De,getInputProps:je,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[dt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),pt=j(function(e,r){const a=Ke("NumberInput",e),u=Ue(e),o=qe(u),{htmlProps:i,...m}=it(o),b=s.useMemo(()=>m,[m]);return f.jsx(dt,{value:b,children:f.jsx(ct,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});pt.displayName="NumberInput";var mt=j(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});mt.displayName="NumberInputStepper";var ft=j(function(e,r){const{getInputProps:a}=ie(),u=a(e,r),o=J();return f.jsx(Y.input,{...u,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...o.field}})});ft.displayName="NumberInputField";var Re=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=j(function(e,r){var a;const u=J(),{getDecrementButtonProps:o}=ie(),i=o(e,r);return f.jsx(Re,{...i,__css:u.stepper,children:(a=e.children)!=null?a:f.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var vt=j(function(e,r){var a;const{getIncrementButtonProps:u}=ie(),o=u(e,r),i=J();return f.jsx(Re,{...o,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(nt,{})})});vt.displayName="NumberIncrementStepper";var St=He("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const wt=(n,e)=>{const[r,a]=s.useState(n);return s.useEffect(()=>{const u=setTimeout(()=>{a(n)},e);return()=>{clearTimeout(u)}},[n,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function _t(n){const{searchValue:e,onUpdateSearchValue:r,style:a}=n,u=e!=="";return f.jsxs(Le,{style:{position:"relative",...a},mb:2,children:[f.jsx(Je,{style:ht}),u&&f.jsx($e,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(ze,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(We,{placeholder:n.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function At({mediaLocalPath:n,size:e,isPreview:r,autoPlay:a,hideBrokenImage:u,objectFit:o,onBrokenLink:i}){const[m,b]=s.useState(!0);return s.useEffect(()=>{u&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${n}`:`/workspace/view_media?filename=${n}`)).status==404){b(!1),i==null||i();return}}catch(I){console.error("Error checking media exists",I)}})()},[]),m?Xe(n)?f.jsx(Ye,{borderRadius:3,boxSize:`${e}px`,objectFit:o??"cover",src:`/workspace/view_media?filename=${n}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${n}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{St as I,At as M,pt as N,_t as S,ft as a,mt as b,Ze as c,vt as d,bt as e,yt as p,Ct as r,wt as u,It as v}; diff --git a/dist/workspace_web/ModelManagerTopbar-jwv1A1hH.js b/dist/workspace_web/ModelManagerTopbar-wj7k34WI.js similarity index 98% rename from dist/workspace_web/ModelManagerTopbar-jwv1A1hH.js rename to dist/workspace_web/ModelManagerTopbar-wj7k34WI.js index df2fbab..b125529 100644 --- a/dist/workspace_web/ModelManagerTopbar-jwv1A1hH.js +++ b/dist/workspace_web/ModelManagerTopbar-wj7k34WI.js @@ -1,7 +1,7 @@ -import{f as q,r as m,j as n,g as $,h as Se,a0 as X,b as $e,o as Ue,l as He,i as T,U as re,P as Ve,a1 as qe,N as be,a2 as Ye,Q as Ce,S as ke,T as Qe,$ as Je,M as Xe,O as Ze,R as et,_ as tt}from"./input.js";import{al as st,m as nt,am as G,an as ae,B as oe,F as R,ac as Le,h as N,i as ie,Z as Ie,ao as ot,k as H,a4 as Ee,a5 as it,ae as Te,j as Z,H as W,ap as Ae,aq as pe,g as Y,w as rt,ar as Ne,f as De,as as at,at as Fe,au as lt,av as ct,aw as dt,ax as ht,ay as ut,az as ft,aA as mt,aB as te,aC as pt,aD as gt,aE as xt}from"./App-YT7a4Gj6.js";import{G as yt,C as vt}from"./chunk-JARCRF6W-66xSMED8.js";import{app as z}from"/scripts/app.js";import{api as V}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-xkXXv8lg.js";var Pe=q(function(e,s){const{spacing:o="0.5rem",spacingX:i,spacingY:r,children:a,justify:l,direction:c,align:h,className:d,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(le,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",d),...u,children:n.jsx($.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:l,alignItems:h,flexDirection:c,listStyleType:"none",gap:o,columnGap:i,rowGap:r,padding:"0"},children:g})})});Pe.displayName="Wrap";var le=q(function(e,s){const{className:o,...i}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...i})});le.displayName="WrapItem";function ge(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Oe=q(function(e,s){const{area:o,colSpan:i,colStart:r,colEnd:a,rowEnd:l,rowSpan:c,rowStart:h,...d}=e,f=st({gridArea:o,gridColumn:ge(i),gridRow:ge(c),gridColumnStart:r,gridColumnEnd:a,gridRowStart:h,gridRowEnd:l});return n.jsx($.div,{ref:s,__css:f,...d})});Oe.displayName="GridItem";function Mt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var jt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),wt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function _t(t){const{value:e=0,min:s,max:o,valueText:i,getValueText:r,isIndeterminate:a,role:l="progressbar"}=t,c=Mt(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof r=="function"?r(e,c):i})(),role:l},percent:c,value:e}}var[St,bt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Ct=q((t,e)=>{const{min:s,max:o,value:i,isIndeterminate:r,role:a,...l}=t,c=_t({value:i,min:s,max:o,isIndeterminate:r,role:a}),d={height:"100%",...bt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${c.percent}%`,...l.style},...c.bind,...l,__css:d})}),ze=q((t,e)=>{var s;const{value:o,min:i=0,max:r=100,hasStripe:a,isAnimated:l,children:c,borderRadius:h,isIndeterminate:d,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=Ue(t),w=He("Progress",t),C=h??((s=w.track)==null?void 0:s.borderRadius),k={animation:`${wt} 1s linear infinite`},D={...!d&&a&&l&&k,...d&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${jt} 1s ease infinite normal none running`}},b={overflow:"hidden",position:"relative",...w.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:b,...j,children:n.jsxs(St,{value:w,children:[n.jsx(Ct,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:i,max:r,value:o,isIndeterminate:d,css:D,borderRadius:C,title:p,role:x}),c]})})});ze.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const kt=1/0;function Lt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-kt?"-0":s}(t)}function F(t){return typeof t=="string"}function Be(t){return typeof t=="number"}function It(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function A(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Et=t=>`Missing ${t} property in key`,Tt=t=>`Property 'weight' in key '${t}' must be a positive integer`,xe=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let i=We(o);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function We(t){let e=null,s=null,o=null,i=1,r=null;if(F(t)||K(t))o=t,e=ye(t),s=ve(t);else{if(!xe.call(t,"name"))throw new Error(Et("name"));const a=t.name;if(o=a,xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Tt(a));e=ye(a),s=ve(a),r=t.getFn}return{path:e,id:s,weight:i,src:o,getFn:r}}function ye(t){return K(t)?t:t.split(".")}function ve(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(A(r))if(a[l]){const c=r[a[l]];if(!A(c))return;if(l===a.length-1&&(F(c)||Be(c)||It(c)))s.push(Lt(c));else if(K(c)){o=!0;for(let h=0,d=c.length;h{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();F(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=i.getFn?i.getFn(e):this.getFn(e,i.path);if(A(a)){if(K(a)){let l=[];const c=[{nestedArrIndex:-1,value:a}];for(;c.length;){const{nestedArrIndex:h,value:d}=c.pop();if(A(d))if(F(d)&&!se(d)){let f={v:d,i:h,n:this.norm.get(d)};l.push(f)}else K(d)&&d.forEach((f,u)=>{c.push({nestedArrIndex:u,value:f})})}o.$[r]=l}else if(F(a)&&!se(a)){let l={v:a,n:this.norm.get(a)};o.$[r]=l}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ge(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const i=new ce({getFn:s,fieldNormWeight:o});return i.setKeys(t.map(We)),i.setSources(e),i.create(),i}function J(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:i=M.distance,ignoreLocation:r=M.ignoreLocation}={}){const a=e/t.length;if(r)return a;const l=Math.abs(o-s);return i?a+l/i:l?1:a}const B=32;function Dt(t,e,s,{location:o=M.location,distance:i=M.distance,threshold:r=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:l=M.minMatchCharLength,includeMatches:c=M.includeMatches,ignoreLocation:h=M.ignoreLocation}={}){if(e.length>B)throw new Error(`Pattern length exceeds max of ${B}.`);const d=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=r,p=u;const x=l>1||c,j=x?Array(f):[];let w;for(;(w=t.indexOf(e,p))>-1;){let b=J(e,{currentLocation:w,expectedLocation:u,distance:i,ignoreLocation:h});if(g=Math.min(b,g),p=w+d,x){let L=0;for(;L=O;v-=1){let _=v-1,S=s[t.charAt(_)];if(x&&(j[_]=+!!S),y[v]=(y[v+1]<<1|1)&S,b&&(y[v]|=(C[v+1]|C[v])<<1|1|C[v+1]),y[v]&Q&&(k=J(e,{errors:b,currentLocation:_,expectedLocation:u,distance:i,ignoreLocation:h}),k<=g)){if(g=k,p=_,p<=u)break;O=Math.max(1,2*u-p)}}if(J(e,{errors:b+1,currentLocation:u,expectedLocation:u,distance:i,ignoreLocation:h})>g)break;C=y}const D={isMatch:p>=0,score:Math.max(.001,k)};if(x){const b=function(L=[],I=M.minMatchCharLength){let O=[],E=-1,y=-1,v=0;for(let _=L.length;v<_;v+=1){let S=L[v];S&&E===-1?E=v:S||E===-1||(y=v-1,y-E+1>=I&&O.push([E,y]),E=-1)}return L[v-1]&&v-E>=I&&O.push([E,v-1]),O}(j,l);b.length?c&&(D.indices=b):D.isMatch=!1}return D}function Ft(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Ft(u),startIndex:g})},f=this.pattern.length;if(f>B){let u=0;const g=f%B,p=f-g;for(;u{const{isMatch:w,score:C,indices:k}=Dt(e,p,x,{location:i+j,distance:r,threshold:a,findAllMatches:l,minMatchCharLength:c,includeMatches:o,ignoreLocation:h});w&&(u=!0),f+=C,w&&k&&(d=[...d,...k])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=d),g}}const Me=[];function je(t,e){for(let s=0,o=Me.length;s{if(!A(o.indices)||!o.indices.length)return;const{indices:i,value:r}=o;let a={indices:i,value:r};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function zt(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new At(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof ce))throw new Error("Incorrect 'index' type");this._myIndex=s||Ge(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){A(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,i=this._docs.length;o{let u=1;f.matches.forEach(({key:g,norm:p,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(d?1:p))}),f.score=u})}(c,{ignoreFieldNorm:l}),r&&c.sort(a),Be(s)&&s>-1&&(c=c.slice(0,s)),function(h,d,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Ot),u&&g.push(zt),h.map(p=>{const{idx:x}=p,j={item:d[x],refIndex:x};return g.length&&g.forEach(w=>{w(p,j)}),j})}(c,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(e){const s=je(e,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=s.searchIn(r);c&&i.push({item:r,idx:a,matches:[{score:h,value:r,norm:l,indices:d}]})}),i}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=je(e,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:a,i:l})=>{if(!A(a))return;let c=[];o.forEach((h,d)=>{c.push(...this._findMatches({key:h,value:a[d],searcher:s}))}),c.length&&r.push({idx:l,item:a,matches:c})}),r}_findMatches({key:e,value:s,searcher:o}){if(!A(s))return[];let i=[];if(K(s))s.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=o.searchIn(r);c&&i.push({score:h,key:e,value:r,idx:a,norm:l,indices:d})});else{const{v:r,n:a}=s,{isMatch:l,score:c,indices:h}=o.searchIn(r);l&&i.push({score:c,key:e,value:r,norm:a,indices:h})}return i}}U.version="7.0.0",U.createIndex=Ge,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new ce({getFn:e,fieldNormWeight:s});return r.setKeys(o),r.setIndexRecords(i),r},U.config=M;function Bt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=i=>{e(i)};return n.jsx(Pe,{children:s.map(i=>n.jsx(le,{children:n.jsx(T,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const Rt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Wt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=m.useState(!t.file_hash),[r,a]=m.useState();m.useEffect(()=>{i(!t.file_hash),l()},[t.file_hash]);const l=async()=>{var d;const h=await G.models.get(t.model_name+"@"+t.model_type);if(h!=null&&(a(h),(d=h.imageUrl)!=null&&d.length&&s(h.imageUrl)),!(h!=null&&h.imageUrl)&&t.file_hash!=null)try{const f=await ae(t.file_hash),u=f.imageUrl;u&&s(u);const g={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:f.modelName??null,civitModelID:f.civitModelID,civitModelVersionID:f.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},c=h=>{const d=Rt[t.model_type];d&&(h.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),h.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),h.dataTransfer.setData("nodeType",d))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:c,children:[o?n.jsx(R,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(Le,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(r==null?void 0:r.civitModelID)!=null?"pointer":"auto",onClick:()=>{(r==null?void 0:r.civitModelID)==null||(r==null?void 0:r.civitModelVersionID)==null||window.open(`https://civitai.com/models/${r==null?void 0:r.civitModelID}?modelVersionId=${r==null?void 0:r.civitModelVersionID}`)}}),n.jsx(N,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(N,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Gt({list:t}){return n.jsx(yt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Oe,{children:n.jsx(Wt,{data:e})},e.model_name+e.date.getTime()))})}function Kt(){const{setRoute:t}=m.useContext(Ie);return n.jsx(n.Fragment,{children:n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const $t=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[i,r]=m.useState(!0);m.useEffect(()=>{a(),V.addEventListener("model_list",async c=>{l(c.detail)})},[]);const a=async()=>{const c=await ot();l(c)},l=async c=>{if(!c)return;r(!1);const h=Array.from(new Set(c.map(f=>f.model_type))),d=h.indexOf("checkpoints");d>=0&&h.splice(d,1),h.unshift("checkpoints"),e(h),o(c.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:i}};function Ut(){const[t,e]=m.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{s()},[]);const o=a=>{var c;const l=a.target.checked;(c=H)==null||c.upsert({showNsfwModelThumbnail:l}).then(()=>{s(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const a=await G.models.toArray();for(let l=0;l{try{if(a.fileHash==null)return;const c=(await ae(a.fileHash)).imageUrl;G.models.update(a.id,{imageUrl:c??null})}catch{}};return n.jsx(vt,{isChecked:t,onChange:o,children:"Show NSFW"})}function Ht(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),i=e.dataTransfer.getData("nodeType"),r=LiteGraph.createNode(i);r.pos=[e.canvasX,e.canvasY],r.configure({widgets_values:[o]}),z.graph.add(r)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function Vt({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,i]=m.useState(""),[r,a]=m.useState("name"),{loading:l,modelTypeList:c,modelsList:h}=$t(),[d,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const j=await G.models.toArray();f(h.map(w=>({...w,db:j.find(C=>C.id===w.model_name+"@"+w.model_type)})))}},[h]),m.useEffect(()=>{let x=[];o.length?x=new U(d,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=h.filter(j=>j.model_type===e).sort((j,w)=>r==="name"?j.model_name.localeCompare(w.model_name):w.date.getTime()-j.date.getTime()),g(x)},[e,h,o,r,d]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Ve,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ee,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:it,overflowY:"auto",children:[n.jsxs(R,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Kt,{})]}),n.jsx(R,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>i(x.target.value)})}),n.jsxs(R,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value:r,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(Ut,{})]}),!o.length&&n.jsx(Bt,{modelTypeList:c,setSelectedModel:s,selectedModel:e}),n.jsx(Gt,{list:u}),l&&n.jsx(R,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(Ht,{})]})})}const qt=async t=>{try{const s=await(await V.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function we(t,e=1){const i=t/1024;return i>=1024?(i/1024).toFixed(e)+" GB":i.toFixed(e)+" MB"}function _e(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Yt(t,e=280,s){var o,i,r,a;if(t)return Ae(t)?(r=_e((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,s))==null?void 0:r.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=_e(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Qt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,i]=m.useState();m.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(Yt(t,ne,x))}},[t]);const r=Ae(t)?t.modelVersions:t.versions,[a,l]=m.useState(((u=r==null?void 0:r[0])==null?void 0:u.name)??""),c=r==null?void 0:r.find(p=>(p==null?void 0:p.name)===a),h=()=>{window.open(`https://civitai.com/models/${t.id}`)},d=m.useCallback(()=>{if(c==null){console.error("no file is find by name",a);return}e(pe(c,t.name),t)},[a]),f=(g=pe(c))==null?void 0:g.sizeKB;return n.jsxs(Ee,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Le,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>h()}),n.jsxs(Y,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(N,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(R,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(N,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(rt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>d(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{size:"md",style:{paddingLeft:4},onChange:p=>{l(p.target.value)},children:r==null?void 0:r.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),f&&n.jsx(ie,{label:we(f),children:n.jsx(N,{flexShrink:1,noOfLines:1,width:"40%",children:we(f)})})]})]})]})}function Jt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(R,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function Xt({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[i,r]=m.useState(""),[a,l]=m.useState([]),[c,h]=m.useState(""),d=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Ne();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),l(Object.values(u).flatMap(g=>g)))};return n.jsx(qe,{isOpen:t,leastDestructiveRef:d,onClose:s,children:n.jsx(be,{children:n.jsxs(Ye,{children:[n.jsx(Ce,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(ke,{children:n.jsxs(Y,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(N,{children:"Model download url"}),n.jsx(Z,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>h(u.target.value),value:c})]}),n.jsx(N,{children:"Choose model install folder"}),n.jsx(ee,{placeholder:"Select option",value:i,onChange:u=>r(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Qe,{children:[n.jsx(T,{ref:d,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(i,c),ml:3,isDisabled:c.length===0,children:"Confirm"})]})]})})})}function Zt(){const{colorMode:t}=Je(),e=De(),[s,o]=m.useState([]);return m.useEffect(()=>{V.addEventListener("download_progress",i=>{o(i.detail)}),V.addEventListener("download_error",i=>{e({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(Y,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:i,progress:r})=>n.jsxs(W,{children:[n.jsx(N,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),n.jsx(ze,{isIndeterminate:!r,hasStripe:!0,width:"50%",value:r}),n.jsxs(N,{fontSize:16,width:"10%",children:[r.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>at(i),children:"Cancel"})]},i))})}function es(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:i}=Fe(),r=()=>{ft(t),o()};return n.jsxs(lt,{isOpen:i,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(ct,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(dt,{p:5,children:[n.jsx(ht,{}),n.jsx(ut,{}),n.jsxs(Y,{spacing:4,children:[n.jsx(N,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:r,children:"Save"})]})]})]})}async function ts(t,e){var a,l;const s={queries:[{q:t,indexUid:"models_v7",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((l=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:l.at(0)).hits??[]}function ss({onclose:t,searchQuery:e="",modelType:s}){const[o,i]=m.useState([]),[r,a]=m.useState(!1),[l,c]=m.useState(s),h=De(),[d,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:j}=Fe(),[w,C,k]=mt(),[P,Q]=m.useState({}),[D,b]=m.useState(te),L=m.useCallback(async()=>{var S;a(!0);const y=await ts(u,l);i(y);const v=await Ne();v&&Q(v);const _=await((S=H)==null?void 0:S.getSetting("defaultFolders"));_&&b(_),a(!1)},[u,l]),I=(y,v)=>{var he,ue,fe,me;if(!((he=k.current)!=null&&he.id)&&!v){console.error("no url to download");return}let _=v??`https://civitai.com/api/download/models/${(ue=k.current)==null?void 0:ue.id}`,S=(fe=k.current)==null?void 0:fe.name;if(!S&&(S=_.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}h({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&f(Ke=>[...Ke,S??""]);const de=gt();de&&(_+=`?token=${de}`),qt({file_hash:(me=k.current)==null?void 0:me.SHA256,filename:S,save_path:y,url:_}),C(void 0),j()},O=async(y,v)=>{const _=D[v.type];C(y),_==null?x():I(_)},E=async(y,v)=>{var S;const _={...D,[y]:v};await((S=H)==null?void 0:S.upsert({defaultFolders:_})),b(_)};return m.useEffect(()=>{L()},[l]),n.jsxs(n.Fragment,{children:[n.jsxs(Xe,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(be,{}),n.jsxs(Ze,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ce,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{searchQuery:u,setSearchQuery:g,onSearch:L}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(es,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{c(void 0)},isActive:l==null,children:"All"}),pt.map(y=>n.jsx(T,{size:"sm",py:1,isActive:l===y,onClick:()=>{c(y)},children:y},y)),l&&P[te[l]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(N,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:D[l],onChange:y=>E(l,y.target.value),children:P[te[l]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),r&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(et,{}),n.jsxs(ke,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(Qt,{model:y,onClickInstallModel:O,installing:d},y.id))}),n.jsx(Zt,{})]})]})]}),n.jsx(Xt,{fileSelected:!!w,isOpen:p,onClose:j,selectFolder:(y,v)=>{I(y,k.current?void 0:v)}})]})}const ns=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-at3wACEK.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function os(){const{setRoute:t,route:e}=m.useContext(Ie),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const r=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),l=LiteGraph.createNode(a);l.pos=[o.canvasX,o.canvasY],l.configure({widgets_values:[r]}),z.graph.add(l)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),V.addEventListener("model_list",async o=>{var a;const i=(a=o.detail)==null?void 0:a.map(async l=>{const c=await G.models.get(l.model_name+"@"+l.model_type);if(c!=null&&c.fileHash)return c;let h={id:l.model_name+"@"+l.model_type,modelName:null,fileHash:l.file_hash??null,fileFolder:l.model_type,fileName:l.model_name+l.model_extension};if(!l.file_hash)return h;const d=await ae(l.file_hash);return h={...h,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},h}),r=(await Promise.all(i)).filter(l=>l!=null);await G.models.clear(),await G.models.bulkPut(r.filter(l=>l!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))}),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(Y,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:xt+"px",children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(m.Suspense,{children:n.jsx(ns,{})})}),e==="modelList"&&n.jsx(Vt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(ss,{modelType:"Checkpoint",onclose:()=>t("root")})]})}const hs=Object.freeze(Object.defineProperty({__proto__:null,default:os},Symbol.toStringTag,{value:"Module"}));export{Oe as G,hs as M,qt as i}; +import{f as q,r as m,j as n,g as $,h as Se,a0 as X,b as $e,o as Ue,l as He,i as T,U as re,P as Ve,a1 as qe,N as be,a2 as Ye,Q as Ce,S as ke,T as Qe,$ as Je,M as Xe,O as Ze,R as et,_ as tt}from"./input.js";import{al as st,m as nt,am as G,an as ae,B as oe,F as R,ac as Le,h as N,i as ie,Z as Ie,ao as ot,k as H,a4 as Ee,a5 as it,ae as Te,j as Z,H as W,ap as Ae,aq as pe,g as Y,w as rt,ar as Ne,f as De,as as at,at as Fe,au as lt,av as ct,aw as dt,ax as ht,ay as ut,az as ft,aA as mt,aB as te,aC as pt,aD as gt,aE as xt}from"./App-bXo9NVT7.js";import{G as yt,C as vt}from"./chunk-JARCRF6W-xouhmv4h.js";import{app as z}from"/scripts/app.js";import{api as V}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-8cE0TZNF.js";var Pe=q(function(e,s){const{spacing:o="0.5rem",spacingX:i,spacingY:r,children:a,justify:l,direction:c,align:h,className:d,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(le,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",d),...u,children:n.jsx($.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:l,alignItems:h,flexDirection:c,listStyleType:"none",gap:o,columnGap:i,rowGap:r,padding:"0"},children:g})})});Pe.displayName="Wrap";var le=q(function(e,s){const{className:o,...i}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...i})});le.displayName="WrapItem";function ge(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Oe=q(function(e,s){const{area:o,colSpan:i,colStart:r,colEnd:a,rowEnd:l,rowSpan:c,rowStart:h,...d}=e,f=st({gridArea:o,gridColumn:ge(i),gridRow:ge(c),gridColumnStart:r,gridColumnEnd:a,gridRowStart:h,gridRowEnd:l});return n.jsx($.div,{ref:s,__css:f,...d})});Oe.displayName="GridItem";function Mt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var jt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),wt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function _t(t){const{value:e=0,min:s,max:o,valueText:i,getValueText:r,isIndeterminate:a,role:l="progressbar"}=t,c=Mt(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof r=="function"?r(e,c):i})(),role:l},percent:c,value:e}}var[St,bt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Ct=q((t,e)=>{const{min:s,max:o,value:i,isIndeterminate:r,role:a,...l}=t,c=_t({value:i,min:s,max:o,isIndeterminate:r,role:a}),d={height:"100%",...bt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${c.percent}%`,...l.style},...c.bind,...l,__css:d})}),ze=q((t,e)=>{var s;const{value:o,min:i=0,max:r=100,hasStripe:a,isAnimated:l,children:c,borderRadius:h,isIndeterminate:d,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=Ue(t),w=He("Progress",t),C=h??((s=w.track)==null?void 0:s.borderRadius),k={animation:`${wt} 1s linear infinite`},D={...!d&&a&&l&&k,...d&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${jt} 1s ease infinite normal none running`}},b={overflow:"hidden",position:"relative",...w.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:b,...j,children:n.jsxs(St,{value:w,children:[n.jsx(Ct,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:i,max:r,value:o,isIndeterminate:d,css:D,borderRadius:C,title:p,role:x}),c]})})});ze.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const kt=1/0;function Lt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-kt?"-0":s}(t)}function F(t){return typeof t=="string"}function Be(t){return typeof t=="number"}function It(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function A(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Et=t=>`Missing ${t} property in key`,Tt=t=>`Property 'weight' in key '${t}' must be a positive integer`,xe=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let i=We(o);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function We(t){let e=null,s=null,o=null,i=1,r=null;if(F(t)||K(t))o=t,e=ye(t),s=ve(t);else{if(!xe.call(t,"name"))throw new Error(Et("name"));const a=t.name;if(o=a,xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Tt(a));e=ye(a),s=ve(a),r=t.getFn}return{path:e,id:s,weight:i,src:o,getFn:r}}function ye(t){return K(t)?t:t.split(".")}function ve(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(A(r))if(a[l]){const c=r[a[l]];if(!A(c))return;if(l===a.length-1&&(F(c)||Be(c)||It(c)))s.push(Lt(c));else if(K(c)){o=!0;for(let h=0,d=c.length;h{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();F(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=i.getFn?i.getFn(e):this.getFn(e,i.path);if(A(a)){if(K(a)){let l=[];const c=[{nestedArrIndex:-1,value:a}];for(;c.length;){const{nestedArrIndex:h,value:d}=c.pop();if(A(d))if(F(d)&&!se(d)){let f={v:d,i:h,n:this.norm.get(d)};l.push(f)}else K(d)&&d.forEach((f,u)=>{c.push({nestedArrIndex:u,value:f})})}o.$[r]=l}else if(F(a)&&!se(a)){let l={v:a,n:this.norm.get(a)};o.$[r]=l}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ge(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const i=new ce({getFn:s,fieldNormWeight:o});return i.setKeys(t.map(We)),i.setSources(e),i.create(),i}function J(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:i=M.distance,ignoreLocation:r=M.ignoreLocation}={}){const a=e/t.length;if(r)return a;const l=Math.abs(o-s);return i?a+l/i:l?1:a}const B=32;function Dt(t,e,s,{location:o=M.location,distance:i=M.distance,threshold:r=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:l=M.minMatchCharLength,includeMatches:c=M.includeMatches,ignoreLocation:h=M.ignoreLocation}={}){if(e.length>B)throw new Error(`Pattern length exceeds max of ${B}.`);const d=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=r,p=u;const x=l>1||c,j=x?Array(f):[];let w;for(;(w=t.indexOf(e,p))>-1;){let b=J(e,{currentLocation:w,expectedLocation:u,distance:i,ignoreLocation:h});if(g=Math.min(b,g),p=w+d,x){let L=0;for(;L=O;v-=1){let _=v-1,S=s[t.charAt(_)];if(x&&(j[_]=+!!S),y[v]=(y[v+1]<<1|1)&S,b&&(y[v]|=(C[v+1]|C[v])<<1|1|C[v+1]),y[v]&Q&&(k=J(e,{errors:b,currentLocation:_,expectedLocation:u,distance:i,ignoreLocation:h}),k<=g)){if(g=k,p=_,p<=u)break;O=Math.max(1,2*u-p)}}if(J(e,{errors:b+1,currentLocation:u,expectedLocation:u,distance:i,ignoreLocation:h})>g)break;C=y}const D={isMatch:p>=0,score:Math.max(.001,k)};if(x){const b=function(L=[],I=M.minMatchCharLength){let O=[],E=-1,y=-1,v=0;for(let _=L.length;v<_;v+=1){let S=L[v];S&&E===-1?E=v:S||E===-1||(y=v-1,y-E+1>=I&&O.push([E,y]),E=-1)}return L[v-1]&&v-E>=I&&O.push([E,v-1]),O}(j,l);b.length?c&&(D.indices=b):D.isMatch=!1}return D}function Ft(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Ft(u),startIndex:g})},f=this.pattern.length;if(f>B){let u=0;const g=f%B,p=f-g;for(;u{const{isMatch:w,score:C,indices:k}=Dt(e,p,x,{location:i+j,distance:r,threshold:a,findAllMatches:l,minMatchCharLength:c,includeMatches:o,ignoreLocation:h});w&&(u=!0),f+=C,w&&k&&(d=[...d,...k])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=d),g}}const Me=[];function je(t,e){for(let s=0,o=Me.length;s{if(!A(o.indices)||!o.indices.length)return;const{indices:i,value:r}=o;let a={indices:i,value:r};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function zt(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new At(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof ce))throw new Error("Incorrect 'index' type");this._myIndex=s||Ge(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){A(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,i=this._docs.length;o{let u=1;f.matches.forEach(({key:g,norm:p,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(d?1:p))}),f.score=u})}(c,{ignoreFieldNorm:l}),r&&c.sort(a),Be(s)&&s>-1&&(c=c.slice(0,s)),function(h,d,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Ot),u&&g.push(zt),h.map(p=>{const{idx:x}=p,j={item:d[x],refIndex:x};return g.length&&g.forEach(w=>{w(p,j)}),j})}(c,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(e){const s=je(e,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=s.searchIn(r);c&&i.push({item:r,idx:a,matches:[{score:h,value:r,norm:l,indices:d}]})}),i}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=je(e,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:a,i:l})=>{if(!A(a))return;let c=[];o.forEach((h,d)=>{c.push(...this._findMatches({key:h,value:a[d],searcher:s}))}),c.length&&r.push({idx:l,item:a,matches:c})}),r}_findMatches({key:e,value:s,searcher:o}){if(!A(s))return[];let i=[];if(K(s))s.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=o.searchIn(r);c&&i.push({score:h,key:e,value:r,idx:a,norm:l,indices:d})});else{const{v:r,n:a}=s,{isMatch:l,score:c,indices:h}=o.searchIn(r);l&&i.push({score:c,key:e,value:r,norm:a,indices:h})}return i}}U.version="7.0.0",U.createIndex=Ge,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new ce({getFn:e,fieldNormWeight:s});return r.setKeys(o),r.setIndexRecords(i),r},U.config=M;function Bt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=i=>{e(i)};return n.jsx(Pe,{children:s.map(i=>n.jsx(le,{children:n.jsx(T,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const Rt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Wt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=m.useState(!t.file_hash),[r,a]=m.useState();m.useEffect(()=>{i(!t.file_hash),l()},[t.file_hash]);const l=async()=>{var d;const h=await G.models.get(t.model_name+"@"+t.model_type);if(h!=null&&(a(h),(d=h.imageUrl)!=null&&d.length&&s(h.imageUrl)),!(h!=null&&h.imageUrl)&&t.file_hash!=null)try{const f=await ae(t.file_hash),u=f.imageUrl;u&&s(u);const g={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:f.modelName??null,civitModelID:f.civitModelID,civitModelVersionID:f.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},c=h=>{const d=Rt[t.model_type];d&&(h.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),h.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),h.dataTransfer.setData("nodeType",d))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:c,children:[o?n.jsx(R,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(Le,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(r==null?void 0:r.civitModelID)!=null?"pointer":"auto",onClick:()=>{(r==null?void 0:r.civitModelID)==null||(r==null?void 0:r.civitModelVersionID)==null||window.open(`https://civitai.com/models/${r==null?void 0:r.civitModelID}?modelVersionId=${r==null?void 0:r.civitModelVersionID}`)}}),n.jsx(N,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(N,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Gt({list:t}){return n.jsx(yt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Oe,{children:n.jsx(Wt,{data:e})},e.model_name+e.date.getTime()))})}function Kt(){const{setRoute:t}=m.useContext(Ie);return n.jsx(n.Fragment,{children:n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const $t=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[i,r]=m.useState(!0);m.useEffect(()=>{a(),V.addEventListener("model_list",async c=>{l(c.detail)})},[]);const a=async()=>{const c=await ot();l(c)},l=async c=>{if(!c)return;r(!1);const h=Array.from(new Set(c.map(f=>f.model_type))),d=h.indexOf("checkpoints");d>=0&&h.splice(d,1),h.unshift("checkpoints"),e(h),o(c.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:i}};function Ut(){const[t,e]=m.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{s()},[]);const o=a=>{var c;const l=a.target.checked;(c=H)==null||c.upsert({showNsfwModelThumbnail:l}).then(()=>{s(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const a=await G.models.toArray();for(let l=0;l{try{if(a.fileHash==null)return;const c=(await ae(a.fileHash)).imageUrl;G.models.update(a.id,{imageUrl:c??null})}catch{}};return n.jsx(vt,{isChecked:t,onChange:o,children:"Show NSFW"})}function Ht(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),i=e.dataTransfer.getData("nodeType"),r=LiteGraph.createNode(i);r.pos=[e.canvasX,e.canvasY],r.configure({widgets_values:[o]}),z.graph.add(r)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function Vt({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,i]=m.useState(""),[r,a]=m.useState("name"),{loading:l,modelTypeList:c,modelsList:h}=$t(),[d,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const j=await G.models.toArray();f(h.map(w=>({...w,db:j.find(C=>C.id===w.model_name+"@"+w.model_type)})))}},[h]),m.useEffect(()=>{let x=[];o.length?x=new U(d,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=h.filter(j=>j.model_type===e).sort((j,w)=>r==="name"?j.model_name.localeCompare(w.model_name):w.date.getTime()-j.date.getTime()),g(x)},[e,h,o,r,d]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Ve,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ee,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:it,overflowY:"auto",children:[n.jsxs(R,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Kt,{})]}),n.jsx(R,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>i(x.target.value)})}),n.jsxs(R,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value:r,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(Ut,{})]}),!o.length&&n.jsx(Bt,{modelTypeList:c,setSelectedModel:s,selectedModel:e}),n.jsx(Gt,{list:u}),l&&n.jsx(R,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(Ht,{})]})})}const qt=async t=>{try{const s=await(await V.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function we(t,e=1){const i=t/1024;return i>=1024?(i/1024).toFixed(e)+" GB":i.toFixed(e)+" MB"}function _e(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Yt(t,e=280,s){var o,i,r,a;if(t)return Ae(t)?(r=_e((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,s))==null?void 0:r.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=_e(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Qt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,i]=m.useState();m.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(Yt(t,ne,x))}},[t]);const r=Ae(t)?t.modelVersions:t.versions,[a,l]=m.useState(((u=r==null?void 0:r[0])==null?void 0:u.name)??""),c=r==null?void 0:r.find(p=>(p==null?void 0:p.name)===a),h=()=>{window.open(`https://civitai.com/models/${t.id}`)},d=m.useCallback(()=>{if(c==null){console.error("no file is find by name",a);return}e(pe(c,t.name),t)},[a]),f=(g=pe(c))==null?void 0:g.sizeKB;return n.jsxs(Ee,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Le,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>h()}),n.jsxs(Y,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(N,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(R,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(N,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(rt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>d(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{size:"md",style:{paddingLeft:4},onChange:p=>{l(p.target.value)},children:r==null?void 0:r.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),f&&n.jsx(ie,{label:we(f),children:n.jsx(N,{flexShrink:1,noOfLines:1,width:"40%",children:we(f)})})]})]})]})}function Jt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(R,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function Xt({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[i,r]=m.useState(""),[a,l]=m.useState([]),[c,h]=m.useState(""),d=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Ne();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),l(Object.values(u).flatMap(g=>g)))};return n.jsx(qe,{isOpen:t,leastDestructiveRef:d,onClose:s,children:n.jsx(be,{children:n.jsxs(Ye,{children:[n.jsx(Ce,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(ke,{children:n.jsxs(Y,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(N,{children:"Model download url"}),n.jsx(Z,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>h(u.target.value),value:c})]}),n.jsx(N,{children:"Choose model install folder"}),n.jsx(ee,{placeholder:"Select option",value:i,onChange:u=>r(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Qe,{children:[n.jsx(T,{ref:d,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(i,c),ml:3,isDisabled:c.length===0,children:"Confirm"})]})]})})})}function Zt(){const{colorMode:t}=Je(),e=De(),[s,o]=m.useState([]);return m.useEffect(()=>{V.addEventListener("download_progress",i=>{o(i.detail)}),V.addEventListener("download_error",i=>{e({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(Y,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:i,progress:r})=>n.jsxs(W,{children:[n.jsx(N,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),n.jsx(ze,{isIndeterminate:!r,hasStripe:!0,width:"50%",value:r}),n.jsxs(N,{fontSize:16,width:"10%",children:[r.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>at(i),children:"Cancel"})]},i))})}function es(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:i}=Fe(),r=()=>{ft(t),o()};return n.jsxs(lt,{isOpen:i,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(ct,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(dt,{p:5,children:[n.jsx(ht,{}),n.jsx(ut,{}),n.jsxs(Y,{spacing:4,children:[n.jsx(N,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:r,children:"Save"})]})]})]})}async function ts(t,e){var a,l;const s={queries:[{q:t,indexUid:"models_v7",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((l=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:l.at(0)).hits??[]}function ss({onclose:t,searchQuery:e="",modelType:s}){const[o,i]=m.useState([]),[r,a]=m.useState(!1),[l,c]=m.useState(s),h=De(),[d,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:j}=Fe(),[w,C,k]=mt(),[P,Q]=m.useState({}),[D,b]=m.useState(te),L=m.useCallback(async()=>{var S;a(!0);const y=await ts(u,l);i(y);const v=await Ne();v&&Q(v);const _=await((S=H)==null?void 0:S.getSetting("defaultFolders"));_&&b(_),a(!1)},[u,l]),I=(y,v)=>{var he,ue,fe,me;if(!((he=k.current)!=null&&he.id)&&!v){console.error("no url to download");return}let _=v??`https://civitai.com/api/download/models/${(ue=k.current)==null?void 0:ue.id}`,S=(fe=k.current)==null?void 0:fe.name;if(!S&&(S=_.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}h({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&f(Ke=>[...Ke,S??""]);const de=gt();de&&(_+=`?token=${de}`),qt({file_hash:(me=k.current)==null?void 0:me.SHA256,filename:S,save_path:y,url:_}),C(void 0),j()},O=async(y,v)=>{const _=D[v.type];C(y),_==null?x():I(_)},E=async(y,v)=>{var S;const _={...D,[y]:v};await((S=H)==null?void 0:S.upsert({defaultFolders:_})),b(_)};return m.useEffect(()=>{L()},[l]),n.jsxs(n.Fragment,{children:[n.jsxs(Xe,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(be,{}),n.jsxs(Ze,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ce,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{searchQuery:u,setSearchQuery:g,onSearch:L}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(es,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{c(void 0)},isActive:l==null,children:"All"}),pt.map(y=>n.jsx(T,{size:"sm",py:1,isActive:l===y,onClick:()=>{c(y)},children:y},y)),l&&P[te[l]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(N,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:D[l],onChange:y=>E(l,y.target.value),children:P[te[l]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),r&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(et,{}),n.jsxs(ke,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(Qt,{model:y,onClickInstallModel:O,installing:d},y.id))}),n.jsx(Zt,{})]})]})]}),n.jsx(Xt,{fileSelected:!!w,isOpen:p,onClose:j,selectFolder:(y,v)=>{I(y,k.current?void 0:v)}})]})}const ns=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-OE80g4ub.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function os(){const{setRoute:t,route:e}=m.useContext(Ie),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const r=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),l=LiteGraph.createNode(a);l.pos=[o.canvasX,o.canvasY],l.configure({widgets_values:[r]}),z.graph.add(l)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),V.addEventListener("model_list",async o=>{var a;const i=(a=o.detail)==null?void 0:a.map(async l=>{const c=await G.models.get(l.model_name+"@"+l.model_type);if(c!=null&&c.fileHash)return c;let h={id:l.model_name+"@"+l.model_type,modelName:null,fileHash:l.file_hash??null,fileFolder:l.model_type,fileName:l.model_name+l.model_extension};if(!l.file_hash)return h;const d=await ae(l.file_hash);return h={...h,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},h}),r=(await Promise.all(i)).filter(l=>l!=null);await G.models.clear(),await G.models.bulkPut(r.filter(l=>l!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))}),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(Y,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:xt+"px",children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(m.Suspense,{children:n.jsx(ns,{})})}),e==="modelList"&&n.jsx(Vt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(ss,{modelType:"Checkpoint",onclose:()=>t("root")})]})}const hs=Object.freeze(Object.defineProperty({__proto__:null,default:os},Symbol.toStringTag,{value:"Module"}));export{Oe as G,hs as M,qt as i}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-at3wACEK.js","workspace_web/input.js","workspace_web/App-YT7a4Gj6.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-JARCRF6W-66xSMED8.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-xkXXv8lg.js"] + __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-OE80g4ub.js","workspace_web/input.js","workspace_web/App-bXo9NVT7.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-JARCRF6W-xouhmv4h.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-8cE0TZNF.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/dist/workspace_web/RecentFilesDrawer-ouPPEt3o.js b/dist/workspace_web/RecentFilesDrawer-ouPPEt3o.js new file mode 100644 index 0000000..a207fdd --- /dev/null +++ b/dist/workspace_web/RecentFilesDrawer-ouPPEt3o.js @@ -0,0 +1,5 @@ +import{f as J,E as qe,j as e,Z as Je,h as oe,g as ye,r as o,M as ie,N as re,O as le,Q as ce,R as de,S as ue,W as we,i as P,$ as ve,T as Qe}from"./input.js";import{m as Le,u as Ne,a as et,b as tt,c as st,S as nt,M as at,d as L,H as T,T as We,I as A,t as xe,e as Ae,f as Y,E as ge,g as K,h as z,i as _,j as ke,k as F,R as V,l as ot,n as Me,B as $,F as Z,o as Fe,p as it,q as rt,r as Q,s as ee,v as W,w as lt,D as Pe,x as E,y as Re,z as ct,A as Se,C as dt,G as _e,J as ut,K as G,L as ht,N as pt,O as gt,P as mt,Q as Be,U as ft,V as xt,W as jt,X as H,Y as je,Z as Ce,_ as yt,$ as wt,a0 as $e,a1 as vt,a2 as kt,a3 as q,a4 as St,a5 as Ct,a6 as bt,a7 as me,a8 as It}from"./App-bXo9NVT7.js";import{G as Mt,C as X}from"./chunk-JARCRF6W-xouhmv4h.js";import{V as Ke}from"./chunk-NTCQBYKE-nDCdQPx1.js";import{N as Ft,a as Dt,I as Et,M as Tt,u as Ot,S as zt}from"./MediaPreview-KLEWGSXc.js";import{app as ae}from"/scripts/app.js";import{I as Lt}from"./IconCopy-wyTg5wiq.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";import"./IconSearch-e7N1azjj.js";var Ge=J(function(t,r){const{columns:l,spacingX:a,spacingY:i,spacing:u,minChildWidth:p,...s}=t,h=qe(),d=p?Wt(p,h):At(l);return e.jsx(Mt,{ref:r,gap:u,columnGap:a,rowGap:i,templateColumns:d,...s})});Ge.displayName="SimpleGrid";function Nt(n){return typeof n=="number"?`${n}px`:n}function Wt(n,t){return Le(n,r=>{const l=Je("sizes",r,Nt(r))(t);return r===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function At(n){return Le(n,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ve=J((n,t)=>{const{title:r,children:l,className:a,...i}=n,u=oe("chakra-menu__group__title",a),p=Ne();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[r&&e.jsx(ye.p,{className:u,...i,__css:p.groupTitle,children:r}),l]})});Ve.displayName="MenuGroup";var Ue=n=>{const{className:t,title:r,...l}=n,a=et(l);return e.jsx(Ve,{title:r,className:oe("chakra-menu__option-group",t),...a})};Ue.displayName="MenuOptionGroup";var Pt=J((n,t)=>{const r=Ne();return e.jsx(ye.button,{ref:t,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...r.button}})}),te=J((n,t)=>{const{children:r,as:l,...a}=n,i=tt(a,t),u=l||Pt;return e.jsx(u,{...i,className:oe("chakra-menu__menu-button",n.className),children:e.jsx(ye.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});te.displayName="MenuButton";var Rt=n=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:e.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),be=J((n,t)=>{const{icon:r,iconSpacing:l="0.75rem",...a}=n,i=st(a,t);return e.jsxs(nt,{...i,className:oe("chakra-menu__menuitem-option",a.className),children:[r!==null&&e.jsx(at,{fontSize:"0.8em",marginEnd:l,opacity:n.isChecked?1:0,children:r||e.jsx(Rt,{})}),e.jsx("span",{style:{flex:1},children:i.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var _t=L("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Bt=L("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),$t=L("edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),De=L("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),Kt=L("file","IconFile",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}]]),He=L("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Gt=L("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Vt=L("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),Ut=L("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Ht=L("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Zt=L("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),Yt=L("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),Xt=L("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),qt=L("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function Jt({onclose:n}){const[t,r]=o.useState([]),l=async()=>{var i;const a=await((i=xe)==null?void 0:i.listAll());r(a??[])};return o.useEffect(()=>{l()},[]),e.jsxs(ie,{isOpen:!0,onClose:n,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"My Tags"}),e.jsx(de,{}),e.jsx(ue,{children:t.map(a=>e.jsxs(T,{children:[e.jsx(We,{children:a.name}),e.jsx(A,{onClick:async()=>{var i;await((i=xe)==null?void 0:i.delete(a.name)),l()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Ae,{})})]}))})]})]})}function Qt(){const n=Y(),t=o.useRef([{title:"Save current workflow",key:ge.SAVE},{title:"Save as current workflow",key:ge.SAVE_AS},{title:"Open spotlight search",key:ge.openSpotlightSearch}]),[r,l]=o.useState({save:"",saveAs:"",openSpotlightSearch:""}),[a,i]=o.useState(),u=async(s,h)=>{var g;s.preventDefault();let d="";if(s.ctrlKey&&(d+="Control+"),s.metaKey&&(d+="Command+"),s.shiftKey&&(d+="Shift+"),s.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){d+=s.key.toUpperCase();const m={...r};delete m[h],Object.values(m).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please + modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=F)==null?void 0:g.upsert({shortcuts:{...r,[h]:d}})),p())}},p=()=>{var s;(s=F)==null||s.getSetting("shortcuts").then(h=>{var g;const d=h??((g=F)==null?void 0:g.defaultSettings.shortcuts);l({...r,...d})})};return o.useEffect(()=>{p()},[]),e.jsxs(K,{children:[e.jsx(z,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(T,{children:[e.jsx(z,{fontSize:"sm",w:170,children:s.title}),e.jsx(_,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:a===s.key,children:e.jsx(ke,{value:r[s.key],onKeyDown:h=>{u(h,s.key)},onFocus:()=>{i(s.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function es(){const{setRefreshFolderStamp:n}=o.useContext(V),[t,r]=o.useState(!1),l=()=>{var i;(i=F)==null||i.getSetting("foldersOnTop").then(u=>{r(!!u)})},a=i=>{var p;const u=i.target.checked;(p=F)==null||p.upsert({foldersOnTop:u}).then(()=>{l(),n(Date.now())})};return o.useEffect(()=>{l()},[]),e.jsx(K,{children:e.jsx(X,{isChecked:t,onChange:a,children:"Folders always on top"})})}function ts(){const[n,t]=o.useState(!1),[r,l]=o.useState(""),{showDialog:a}=we(),i=()=>{var p,s;(p=F)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(s=F)==null||s.getSetting("twoWaySync").then(h=>{t(h??!1)})};o.useEffect(()=>{i()},[]);const u=async p=>{var h,d;if(!p.target.checked){await((h=F)==null?void 0:h.upsert({twoWaySync:p.target.checked})),i();return}const s=await((d=F)==null?void 0:d.getSetting("myWorkflowsDir"));a(e.jsx(ot,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=F)==null?void 0:g.upsert({twoWaySync:!0})),i()},colorScheme:"red"}])};return e.jsxs(K,{children:[e.jsx(z,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),e.jsx(X,{isChecked:n,onChange:u,children:"Enable two way sync"})]})}function Ee({settingKey:n,text:t,defaultChecked:r=!1}){const[l,a]=o.useState(r),i=Y(),u=()=>{var p;(p=F)==null||p.getSetting(n).then(s=>{a(!!s)})};return o.useEffect(()=>{u()},[]),e.jsx(K,{children:e.jsx(X,{isChecked:l,onChange:async p=>{var s;await((s=F)==null?void 0:s.upsert({[n]:p.target.checked})),u(),i({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ss(){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),[a,i]=o.useState([]),[u,p]=o.useState(""),[s,h]=o.useState([]),[d,g]=o.useState(!1),[m,c]=o.useState(!1),[f,v]=o.useState(!1),S=o.useRef(null),w=Y(),{showDialog:N}=we(),C=f?"\\":"/";o.useEffect(()=>{var y;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=F)==null||y.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const j=async y=>{const{dir_path:k="",dir_contents:D=[],error:x=""}=await Fe(y??"");return x.includes("Operation not permitted")?(c(!0),R(),{isError:!0}):{dirList:D,dirPath:k}},O=async()=>{const{isError:y=!1,dirList:k=[]}=await j(u);y||(i(k),l(!0),h(u&&u.split(C).filter(D=>!!D)||[]))},R=()=>{l(!1),t(!1),h([])},B=async(y,k=!1,D=!1)=>{var b,I;if(k){const{path:M}=await Me();M&&await it(M,y)}await((b=F)==null?void 0:b.upsert({myWorkflowsDir:y}));const x=await((I=F)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(x),D&&c(!1),R()},U=async y=>{if(y){const{error:D=""}=await Fe(y);if(D.includes("Not a directory")){w({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const k=y??`${f?"":C}${s.join(C)}`;N("Do you want to copy all workflows to new directory?",[{label:"Yes",onClick:()=>{B(k,!0,!!y)}},{label:"No",onClick:()=>{B(k,!1,!!y)}}])},he=async()=>{const{dirPath:y,dirList:k}=await j("");h(y.split(C).filter(D=>!!D)),i(k)},se=async(y,k)=>{var I;let D="";y===-1&&k?D=`${f?"":C}${s.concat([k]).join(C)}`:D=`${f?"":C}${s.slice(0,y+1).join(C)}`;const{isError:x=!1,dirList:b=[]}=await j(D);x||(i(b),h(f?D.split(C):(I=D.slice(1))==null?void 0:I.split(C)))},ne=e.jsxs($,{textAlign:"end",mb:4,children:[e.jsx(ke,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(P,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var y,k;(y=S==null?void 0:S.current)!=null&&y.value&&U((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),pe=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs($,{mb:4,children:[e.jsx(z,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),r?n?ne:e.jsxs(Ke,{spacing:2,alignItems:"start",children:[e.jsx(K,{spacing:"2px",direction:"row",wrap:"wrap",children:s.map((y,k)=>e.jsxs("span",{children:[k>0&&C,e.jsx(P,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{se(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Ge,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:a.map((y,k)=>e.jsx(P,{size:"sm",leftIcon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{se(-1,y)},children:y},`${y}-${k}`))}),e.jsxs($,{w:"100%",textAlign:"end",children:[e.jsx(P,{colorScheme:"teal",size:"sm",onClick:()=>{U()},children:"Save"}),e.jsx(P,{size:"sm",onClick:he,mr:2,ml:2,children:"Reset"}),e.jsx(P,{size:"sm",onClick:R,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(We,{overflowWrap:"anywhere",children:u}),e.jsx(_,{label:d?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(A,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!d,icon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:O})}),e.jsx(_,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(A,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:pe,variant:"ghost"})})]})]}),e.jsxs(ie,{isOpen:m,onClose:()=>c(!1),size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Kind tips"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs($,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?e.jsxs(z,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",e.jsx(P,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos + -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):e.jsx(z,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),ne]})})]})]})]})}function Ze({label:n,settingKey:t}){const[r,l]=o.useState(200),a=Y(),i=s=>{if(!s.length){l(0);return}l(parseInt(s))},u=async()=>{var s;r<0&&l(0),await((s=F)==null?void 0:s.upsert({[t]:Number(r)})),a({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=F)==null||s.getSetting(t).then(h=>{l(h)})};return o.useEffect(()=>{p()},[]),e.jsxs(K,{children:[e.jsx(z,{children:n}),e.jsx(Ft,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:r,onChange:s=>i(s),onBlur:()=>{u()},onKeyUp:s=>{s.key==="Enter"&&u()},children:e.jsx(Dt,{})})]})}function ns(){const[n,t]=o.useState(!1),r=Y(),l=()=>{var a;(a=F)==null||a.getSetting("autoSave").then(i=>{t(!!i)})};return o.useEffect(()=>{l()},[]),e.jsxs(K,{children:[e.jsx(X,{isChecked:n,onChange:async a=>{var i;await((i=F)==null?void 0:i.upsert({autoSave:a.target.checked})),l(),r({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),n&&e.jsx(Ze,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function as({onClose:n}){return e.jsx(e.Fragment,{children:e.jsxs(ie,{isOpen:!0,onClose:n,size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Settings"}),e.jsx(de,{}),e.jsx(ue,{pb:14,children:e.jsx(T,{children:e.jsxs(Ke,{divider:e.jsx(rt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ss,{}),e.jsx(ns,{}),e.jsx(Qt,{}),e.jsx(ts,{}),e.jsx(es,{}),e.jsx(Ee,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),e.jsx(Ze,{label:`Maximum number of save change history to store. This does not include + versions that you created by "Create Version", which are always stored + and has no limit.`,settingKey:"maximumChangelogNumber"}),e.jsx(Ee,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"})]})})})]})]})})}const fe=16;function os({}){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),{colorMode:a,toggleColorMode:i}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,children:[e.jsx(te,{as:A,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(ee,{children:[e.jsx(W,{onClick:()=>l(!0),icon:e.jsx(Zt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(W,{onClick:()=>t(!0),icon:e.jsx(Xt,{size:fe}),fontSize:16,children:"Manage Tags"}),e.jsxs(W,{onClick:i,icon:a==="light"?e.jsx(Ht,{size:fe}):e.jsx(Yt,{size:fe}),fontSize:16,children:[a==="light"?"Dark":"Light"," Mode"]})]})]}),n&&e.jsx(Jt,{onclose:()=>t(!1)}),r&&e.jsx(as,{onClose:()=>l(!1)})]})}function is(n){const{multipleState:t,changeMultipleState:r,selectedKeys:l,isSelectedAll:a,batchOperationCallback:i}=n,u=async()=>{var h;const s=await((h=E)==null?void 0:h.batchQuery(l))??[];ct(s)},p=l.length===0;return e.jsx(T,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(X,{isChecked:a,onChange:s=>{i("selectAll",s.target.checked)}}),e.jsx(_,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(A,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(lt,{size:21}),onClick:u})}),e.jsx(_,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Pe,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=E)==null?void 0:s.batchDeleteFlow(l)),i("batchDelete")}})}),l.length>0&&e.jsx(z,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(_,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(A,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{r(!1)}})})]}):e.jsx(_,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(A,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Gt,{size:21}),onClick:()=>{r(!0)}})})})}const Te=6;function rs({setSelectedTag:n,selectedTag:t}){const[r,l]=o.useState(!1),[a,i]=o.useState([]);return o.useEffect(()=>{var u;(u=xe)==null||u.listAll().then(p=>{i(p)})},[]),e.jsxs(T,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(A,{"aria-label":"Close",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{n(void 0)}}),a.slice(0,r?void 0:Te).map(u=>e.jsx(P,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(u.name)},isActive:t===u.name,children:u.name},u.name)),(a.length??0)>Te&&e.jsx(A,{"aria-label":"Show-all-tags",size:"sm",icon:r?e.jsx(_t,{}):e.jsx(Se,{}),onClick:()=>l(!r)})]})}function Ye({parentFolderID:n,onlyImportFile:t=!1}){const{onRefreshFilesList:r}=o.useContext(V),[l,a]=o.useState("file"),i=o.useRef(null),u=d=>{var g;a(d),d==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(g=i.current)==null||g.click()},p=async d=>{var g;if(d.type==="image/png"){const m=await ut(d),c=m==null?void 0:m.workflow;if(c)return{json:c,name:d.name.replace(".png","")}}else if(d.type==="application/json"||(g=d.name)!=null&&g.endsWith(".json"))return await new Promise((m,c)=>{const f=new FileReader;f.onload=v=>{var S;try{const w=(S=v.target)==null?void 0:S.result;typeof w=="string"?m({json:w,name:d.name.replace(".json","")}):c(new Error("File content is not a string"))}catch(w){c(w)}},f.onerror=c,f.readAsText(d)});return null},s=async d=>{var m,c;const g=[d];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=G)==null?void 0:m.create({name:f.name,parentFolderID:f.parentFolderID}));if(f.children&&f.children.length){const S=[];f.children.forEach(w=>{w.isFile&&w.file?S.push(w.file):(w.parentFolderID=v==null?void 0:v.id,g.push(w))}),S.length&&await((c=E)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}r==null||r()},h=async d=>{var m;const g=d.target.files;if(g)if(l==="folder"){const c={name:g[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const f of g)if(f.name!==".DS_Store"){const v=f.webkitRelativePath.split("/");let S=c.children??[];for(let w=1;wj.name===N);if(!C){if(C={name:N,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},C.isFile){const j=await p(f);j&&(C.file=j)}S.push(C)}C&&!C.isFile&&(S=C.children)}}s(c)}else{const c=[];for(const f of g){const v=await p(f);v&&c.push(v)}c.length&&(await((m=E)==null?void 0:m.batchCreateFlows(c,void 0,n)),r&&r())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(W,{onClick:d=>{d.stopPropagation(),u("file")},icon:e.jsx(De,{size:19}),children:"Import workflows"}):e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:P,leftIcon:e.jsx(De,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(ee,{children:dt.map((d,g)=>e.jsx(W,{onClick:()=>{u(d.type)},iconSpacing:2,icon:d.type==="folder"?e.jsx(_e,{size:18}):e.jsx(Kt,{size:18}),children:d.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:d=>{d.stopPropagation()}})]})}function ls({folder:n,onclose:t}){const[r,l]=o.useState(n.name),[a,i]=o.useState(""),{onRefreshFilesList:u}=o.useContext(V),p=h=>{l(h.target.value),a&&i("")},s=async()=>{var g,m;const h=r.trim();if(l(h),h===n.name)return t();await((g=G)==null?void 0:g.generateUniqueName(h,n.parentFolderID??""))!==h?i("The name is duplicated, please modify it and submit again."):(await((m=G)==null?void 0:m.update(n.id,{name:h})),u&&u(),t())};return e.jsxs(ie,{isOpen:!0,onClose:t,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Edit folder name"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs(ht,{isInvalid:!!a,children:[e.jsx(pt,{children:"Folder name"}),e.jsx(ke,{value:r,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!a&&r&&s()}}),a&&e.jsx(gt,{children:a})]})}),e.jsxs(Qe,{children:[e.jsx(P,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!r||!!a,children:"Save"}),e.jsx(P,{onClick:t,children:"Cancel"})]})]})]})}function cs({menuPosition:n,isopen:t,folder:r,onClose:l}){const[a,i]=o.useState(!1),{onRefreshFilesList:u}=o.useContext(V),{showDialog:p}=we(),s=async m=>{var c;m.stopPropagation(),await((c=G)==null?void 0:c.create({name:"New Folder",parentFolderID:r.id})),u&&u()},h=async m=>{var c;m.stopPropagation(),await((c=E)==null?void 0:c.createFlow({json:JSON.stringify(ft),parentFolderID:r.id})),u&&u()},d=async m=>{m.stopPropagation();const c=await xt(r.id);p(`Do you want to delete the ${c} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(jt.DELETE)}}])},g=async m=>{var c;await((c=G)==null?void 0:c.deleteFolder(r.id,m)),l(),u&&u()};return e.jsxs(e.Fragment,{children:[e.jsx($,{position:"absolute",top:n.y,left:n.x,children:e.jsx(Q,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(ee,{children:[e.jsx(W,{icon:e.jsx(mt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),i(!0)},children:"Rename"}),e.jsx(W,{icon:e.jsx(Ae,{size:19}),onClick:d,children:"Delete"}),e.jsx(W,{onClick:s,icon:e.jsx(He,{size:19}),children:"New folder"}),e.jsx(W,{onClick:h,icon:e.jsx(Be,{size:19}),children:"New file"}),e.jsx(Ye,{parentFolderID:r.id,onlyImportFile:!0})]})})}),a&&e.jsx(ls,{folder:r,onclose:()=>i(!1)})]})}const Oe=o.memo(function({folder:t}){const[r,l]=o.useState(!1),[a,i]=o.useState(t.isCollapse??!0),[u,p]=o.useState([]),[s,h]=o.useState({x:0,y:0}),[d,g]=o.useState(!1),{colorMode:m}=ve(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=o.useContext(V),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};o.useEffect(()=>{var j;a||(j=E)==null||j.listFolderContent(t.id,window.localStorage.getItem(je)).then(O=>{p(O)})},[t.id,v,a]);const N=j=>{j.preventDefault(),h({x:j.clientX,y:j.clientY}),g(!0)},C=async j=>{var O,R;if(j.preventDefault(),j.stopPropagation(),!c)return l(!1);if(H(c)){if(c.id===t.id)return l(!1);await((O=G)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else H(c)||await((R=E)==null?void 0:R.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return o.useEffect(()=>{var j;!!t.isCollapse!==a&&((j=G)==null||j.update(t.id,{isCollapse:a}))},[a]),o.useEffect(()=>{var U;const j=(U=E)==null?void 0:U.curWorkflow,O=(j==null?void 0:j.parentFolderID)+"/",R=t.id+"/";O.startsWith(R)&&i(!1)},[]),e.jsxs(K,{children:[e.jsxs(T,{w:"100%",as:"button",py:1,onClick:()=>{i(!a)},onContextMenu:N,draggable:"true",onDragOver:j=>{j.preventDefault(),j.stopPropagation(),l(!0)},onDragLeave:j=>{j.preventDefault(),j.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:C,_hover:w,style:r||d?w:void 0,className:"droppable",children:[e.jsxs(T,{gap:1,children:[a?e.jsx(Et,{size:20}):e.jsx(Se,{size:20}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),e.jsx(z,{children:t.name})]}),e.jsx(cs,{isopen:d,menuPosition:s,onClose:()=>g(!1),folder:t}),!a&&e.jsx(K,{ml:4,gap:0,children:e.jsx(Xe,{items:u})})]})});function ds({workflow:n}){const t=o.useRef(null),r=Y(),{onDuplicateWorkflow:l}=o.useContext(Ce),[a,i]=o.useState(n.saveLock??!1),u=async()=>{var h;const s=!a;i(s),await((h=E)==null?void 0:h.updateMetaInfo(n.id,{saveLock:s})),r({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const h=s.target.files;if(!h)return;const d=new FormData;Array.from(h).forEach((g,m)=>{d.append(`images[${m}]`,g,g.name)}),d.append("subfolder","workspace_manager"),await fetch("/workspace/images/save",{method:"POST",body:d}),Array.from(h).forEach(async g=>{var c,f;const m=`workspace_manager/${g.name}`;(c=vt)==null||c.create({workflowID:n.id,localPath:m}),(f=E)==null||f.updateMetaInfo(n.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(te,{border:0,as:A,"aria-label":"Options",icon:e.jsx(Bt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(ee,{zIndex:101,children:[e.jsx(W,{icon:e.jsx(Lt,{}),onClick:()=>l&&l(n.id),children:"Duplicate"}),e.jsx(W,{icon:e.jsx(yt,{size:20}),onClick:()=>wt(n.id),children:"Open in new tab"}),e.jsx(_,{hasArrow:!0,label:a?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(W,{icon:a?e.jsx($e,{}):e.jsx(Vt,{}),onClick:u,children:a?"Unlock":"Lock"})}),e.jsx(W,{icon:e.jsx(qt,{}),onClick:()=>{var s;(s=t.current)==null||s.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:s=>{s.stopPropagation()}})]})}function us({workflow:n}){const{onDeleteFlow:t}=o.useContext(V);return e.jsxs(Z,{justifyContent:"flex-end",children:[e.jsx(Pe,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(n.id)}}),e.jsx(ds,{workflow:n})]})}const ze=o.memo(function({workflow:t}){var v,S,w,N;const{colorMode:r}=ve(),{setDraggingFile:l,isMultiSelecting:a,onMultiSelectFlow:i,multiSelectedFlowsID:u}=o.useContext(V),p=u&&u.length>0&&u.includes(t.id),{curFlowID:s,loadWorkflowID:h}=o.useContext(Ce),d=s===t.id,g=r==="light"?"gray.200":"#4A5568",[m,c]=o.useState(!1),f=e.jsx($,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":void 0,color:d&&!a?"#333":void 0,draggable:!a,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!a&&h(t.id)},_hover:{bg:g},children:e.jsxs(T,{flexGrow:1,children:[!((S=(v=F)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((N=t.latestImage)==null?void 0:N.length))&&e.jsx(Tt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(T,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(Z,{alignItems:"center",children:[e.jsx(z,{fontWeight:"500",noOfLines:2,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx($e,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(T,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:r=="dark"?"gray.900":"gray.200",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:a?e.jsx(X,{isChecked:p,spacing:4,onChange:C=>{i&&i(t.id,C.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx("div",{style:{width:"80px"},children:m?e.jsx(us,{workflow:t}):e.jsx(z,{color:"GrayText",ml:"2px",fontSize:"sm",children:kt(t.updateTime,!1,!1,"/")})})]})})});function Xe({items:n}){var m;const[t,r]=o.useState(!1),l=n.filter(H),a=n.filter(c=>!H(c)),i=(m=a[0])==null?void 0:m.parentFolderID,[u,p]=o.useState(!1),{onRefreshFilesList:s,draggingFile:h,refreshFolderStamp:d}=o.useContext(V),g=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(H(h)){if(h.id===i)return p(!1);await((f=G)==null?void 0:f.update(h.id,{parentFolderID:i}))}else await((v=E)==null?void 0:v.updateFolder(h.id,{parentFolderID:i}));await(s==null?void 0:s()),p(!1)};return o.useEffect(()=>{var c;(c=F)==null||c.getSetting("foldersOnTop").then(f=>{r(f??!1)})},[d]),e.jsxs(e.Fragment,{children:[t&&l.map(c=>e.jsx(Oe,{folder:c},c.id)),e.jsx($,{border:u?"2px dashed #718096":"2px dashed transparent",onDragOver:c=>{c.preventDefault(),c.stopPropagation(),p(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?a.map(c=>e.jsx(ze,{workflow:c},c.id)):n.map(c=>H(c)?e.jsx(Oe,{folder:c},c.id):e.jsx(ze,{workflow:c},c.id))})]})}function ks({onClose:n,onClickNewFlow:t}){const[r,l]=o.useState([]),a=o.useRef([]),{loadWorkflowID:i,curFlowID:u}=o.useContext(Ce),[p,s]=o.useState(),[h,d]=o.useState(!1),[g,m]=o.useState([]),[c,f]=o.useState(0),[v,S]=o.useState(""),w=Ot(v,400),N=o.useRef(null),[C,j]=o.useState(null),O=o.useRef(window.localStorage.getItem(je)??q.RECENTLY_MODIFIED),R=!!p||!!w.length,B=async()=>{var b,I;const x=await((b=E)==null?void 0:b.listFolderContent())??[];l(me(x,O.current)),f(Date.now()),a.current=await((I=E)==null?void 0:I.listAll())??[]},U=()=>{const x=a.current.filter(b=>{var Ie;let I=!0,M=!0;return p&&(I=!!((Ie=b.tags)!=null&&Ie.includes(p))),w&&(M=!!b.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),I&&M});l(me(x,O.current))},he=x=>{l(me(r,x)),O.current=x,window.localStorage.setItem(je,x),!R&&f(Date.now())};o.useEffect(()=>{R?U():B()},[w,p]);const se=o.useCallback(async x=>{var b,I,M;await((b=E)==null?void 0:b.deleteFlow(x)),((M=(I=E)==null?void 0:I.curWorkflow)==null?void 0:M.id)===x&&await(i==null?void 0:i(null)),await B()},[p,w]);o.useEffect(()=>{const x=async b=>{var I;if(N.current){const M=await((I=E)==null?void 0:I.get(N.current));M&&M.json&&It(M.json,[b.canvasX,b.canvasY])}};return ae.canvasEl.addEventListener("drop",x),ae.canvasEl.addEventListener("click",n),()=>{ae.canvasEl.removeEventListener("drop",x),ae.canvasEl.removeEventListener("click",n)}},[]);const ne=o.useCallback((x,b)=>{m(I=>{const M=[...I];return b?M.push(x):M.splice(M.indexOf(x),1),M})},[]),pe=(x,b)=>{var I;switch(x){case"batchDelete":u&&((I=E)==null||I.get(u).then(M=>{M||i==null||i(null)})),B(),d(!1),m([]);return;case"selectAll":m(b?a.current.map(M=>M.id):[]);return}},y=x=>{j(x),H(x)||(N.current=x.id)},k=x=>{S(x)},D=450;return e.jsx(V.Provider,{value:{onRefreshFilesList:B,draggingFile:C??void 0,setDraggingFile:y,isMultiSelecting:h,onMultiSelectFlow:ne,multiSelectedFlowsID:g,onDeleteFlow:se,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx($,{style:{width:D},children:e.jsxs(St,{width:D,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Ct,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(T,{gap:4,children:[e.jsx(T,{gap:2,children:e.jsx(z,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ye,{}),e.jsx(_,{label:"Open workspace save directory",children:e.jsx(A,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(_e,{}),variant:"outline",colorScheme:"teal",onClick:()=>bt()})}),e.jsx(_,{label:"New workflow",children:e.jsx(A,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(T,{alignItems:"center",children:e.jsx(os,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(rs,{selectedTag:p,setSelectedTag:s}),e.jsxs(T,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(T,{children:[a.current.length>0?e.jsx(is,{multipleState:h,changeMultipleState:x=>{d(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===a.current.length,batchOperationCallback:pe}):e.jsx($,{}),!h&&e.jsx(_,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(A,{size:"sm",variant:"outline",icon:e.jsx(He,{size:21}),onClick:async()=>{var x;await((x=G)==null?void 0:x.create({name:"New Folder"})),B()},"aria-label":"new folder button"})})]}),e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:P,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(T,{children:[e.jsx(z,{children:"Sort by:"}),e.jsx(z,{display:"inline-block",children:O.current})]})}),e.jsx(ee,{children:e.jsx(Ue,{value:O.current,type:"radio",onChange:x=>he(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,b)=>e.jsx(be,{value:x,children:x},b))})})]})]}),e.jsx(zt,{searchValue:v,onUpdateSearchValue:k}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",children:e.jsx(Xe,{items:r})})]})]})})})}export{ks as default}; diff --git a/dist/workspace_web/RecentFilesDrawer-qy9dTPVG.js b/dist/workspace_web/RecentFilesDrawer-qy9dTPVG.js deleted file mode 100644 index 0816044..0000000 --- a/dist/workspace_web/RecentFilesDrawer-qy9dTPVG.js +++ /dev/null @@ -1,5 +0,0 @@ -import{f as J,E as qe,j as e,Z as Je,h as oe,g as ye,r as o,M as ie,N as re,O as le,Q as ce,R as de,S as ue,W as we,i as A,$ as ve,T as Qe}from"./input.js";import{m as Le,u as Ne,a as et,b as tt,c as st,S as nt,M as at,d as N,H as T,T as We,I as z,t as xe,e as Ae,f as Y,E as me,g as B,h as L,i as P,j as ke,k as F,R as G,l as ot,n as Me,B as K,F as Z,o as Fe,p as it,q as rt,r as Q,s as ee,v as R,w as lt,D as Pe,x as E,y as Re,z as ct,A as Se,C as dt,G as _e,J as ut,K as V,L as ht,N as pt,O as mt,P as gt,Q as Be,U as ft,V as xt,W as jt,X as H,Y as je,Z as Ce,_ as $e,$ as yt,a0 as wt,a1 as vt,a2 as kt,a3 as q,a4 as St,a5 as Ct,a6 as bt,a7 as ge,a8 as It}from"./App-YT7a4Gj6.js";import{G as Mt,C as X}from"./chunk-JARCRF6W-66xSMED8.js";import{V as Ke}from"./chunk-NTCQBYKE-7yeghZmZ.js";import{N as Ft,a as Dt,I as Et,M as Tt,u as Ot,S as zt}from"./MediaPreview-IFYm2Mq_.js";import{app as ae}from"/scripts/app.js";import{I as Lt}from"./IconCopy-j3_qolNw.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";import"./IconSearch-yd7KVSRG.js";var Ve=J(function(t,r){const{columns:l,spacingX:a,spacingY:i,spacing:u,minChildWidth:p,...s}=t,h=qe(),d=p?Wt(p,h):At(l);return e.jsx(Mt,{ref:r,gap:u,columnGap:a,rowGap:i,templateColumns:d,...s})});Ve.displayName="SimpleGrid";function Nt(n){return typeof n=="number"?`${n}px`:n}function Wt(n,t){return Le(n,r=>{const l=Je("sizes",r,Nt(r))(t);return r===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function At(n){return Le(n,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ge=J((n,t)=>{const{title:r,children:l,className:a,...i}=n,u=oe("chakra-menu__group__title",a),p=Ne();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[r&&e.jsx(ye.p,{className:u,...i,__css:p.groupTitle,children:r}),l]})});Ge.displayName="MenuGroup";var Ue=n=>{const{className:t,title:r,...l}=n,a=et(l);return e.jsx(Ge,{title:r,className:oe("chakra-menu__option-group",t),...a})};Ue.displayName="MenuOptionGroup";var Pt=J((n,t)=>{const r=Ne();return e.jsx(ye.button,{ref:t,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...r.button}})}),te=J((n,t)=>{const{children:r,as:l,...a}=n,i=tt(a,t),u=l||Pt;return e.jsx(u,{...i,className:oe("chakra-menu__menu-button",n.className),children:e.jsx(ye.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});te.displayName="MenuButton";var Rt=n=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:e.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),be=J((n,t)=>{const{icon:r,iconSpacing:l="0.75rem",...a}=n,i=st(a,t);return e.jsxs(nt,{...i,className:oe("chakra-menu__menuitem-option",a.className),children:[r!==null&&e.jsx(at,{fontSize:"0.8em",marginEnd:l,opacity:n.isChecked?1:0,children:r||e.jsx(Rt,{})}),e.jsx("span",{style:{flex:1},children:i.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var _t=N("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Bt=N("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),$t=N("edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),De=N("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),Kt=N("file","IconFile",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}]]),He=N("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Vt=N("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Gt=N("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),Ut=N("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Ht=N("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Zt=N("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),Yt=N("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),Xt=N("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),qt=N("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function Jt({onclose:n}){const[t,r]=o.useState([]),l=async()=>{var i;const a=await((i=xe)==null?void 0:i.listAll());r(a??[])};return o.useEffect(()=>{l()},[]),e.jsxs(ie,{isOpen:!0,onClose:n,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"My Tags"}),e.jsx(de,{}),e.jsx(ue,{children:t.map(a=>e.jsxs(T,{children:[e.jsx(We,{children:a.name}),e.jsx(z,{onClick:async()=>{var i;await((i=xe)==null?void 0:i.delete(a.name)),l()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Ae,{})})]}))})]})]})}function Qt(){const n=Y(),t=o.useRef([{title:"Save current workflow",key:me.SAVE},{title:"Save as current workflow",key:me.SAVE_AS},{title:"Open spotlight search",key:me.openSpotlightSearch}]),[r,l]=o.useState({save:"",saveAs:"",openSpotlightSearch:""}),[a,i]=o.useState(),u=async(s,h)=>{var m;s.preventDefault();let d="";if(s.ctrlKey&&(d+="Control+"),s.metaKey&&(d+="Command+"),s.shiftKey&&(d+="Shift+"),s.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){d+=s.key.toUpperCase();const g={...r};delete g[h],Object.values(g).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please - modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((m=F)==null?void 0:m.upsert({shortcuts:{...r,[h]:d}})),p())}},p=()=>{var s;(s=F)==null||s.getSetting("shortcuts").then(h=>{var m;const d=h??((m=F)==null?void 0:m.defaultSettings.shortcuts);l({...r,...d})})};return o.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(T,{children:[e.jsx(L,{fontSize:"sm",w:170,children:s.title}),e.jsx(P,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:a===s.key,children:e.jsx(ke,{value:r[s.key],onKeyDown:h=>{u(h,s.key)},onFocus:()=>{i(s.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function es(){const{setRefreshFolderStamp:n}=o.useContext(G),[t,r]=o.useState(!1),l=()=>{var i;(i=F)==null||i.getSetting("foldersOnTop").then(u=>{r(!!u)})},a=i=>{var p;const u=i.target.checked;(p=F)==null||p.upsert({foldersOnTop:u}).then(()=>{l(),n(Date.now())})};return o.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(X,{isChecked:t,onChange:a,children:"Folders always on top"})})}function ts(){const[n,t]=o.useState(!1),[r,l]=o.useState(""),{showDialog:a}=we(),i=()=>{var p,s;(p=F)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(s=F)==null||s.getSetting("twoWaySync").then(h=>{t(h??!1)})};o.useEffect(()=>{i()},[]);const u=async p=>{var h,d;if(!p.target.checked){await((h=F)==null?void 0:h.upsert({twoWaySync:p.target.checked})),i();return}const s=await((d=F)==null?void 0:d.getSetting("myWorkflowsDir"));a(e.jsx(ot,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var m;await((m=F)==null?void 0:m.upsert({twoWaySync:!0})),i()},colorScheme:"red"}])};return e.jsxs(B,{children:[e.jsx(L,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),e.jsx(X,{isChecked:n,onChange:u,children:"Enable two way sync"})]})}function Ee({settingKey:n,text:t,defaultChecked:r=!1}){const[l,a]=o.useState(r),i=Y(),u=()=>{var p;(p=F)==null||p.getSetting(n).then(s=>{a(!!s)})};return o.useEffect(()=>{u()},[]),e.jsx(B,{children:e.jsx(X,{isChecked:l,onChange:async p=>{var s;await((s=F)==null?void 0:s.upsert({[n]:p.target.checked})),u(),i({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ss(){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),[a,i]=o.useState([]),[u,p]=o.useState(""),[s,h]=o.useState([]),[d,m]=o.useState(!1),[g,c]=o.useState(!1),[f,v]=o.useState(!1),S=o.useRef(null),w=Y(),{showDialog:W}=we(),C=f?"\\":"/";o.useEffect(()=>{var y;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=F)==null||y.getSetting("twoWaySync").then(k=>{m(k??!1)})},[]);const j=async y=>{const{dir_path:k="",dir_contents:D=[],error:x=""}=await Fe(y??"");return x.includes("Operation not permitted")?(c(!0),_(),{isError:!0}):{dirList:D,dirPath:k}},O=async()=>{const{isError:y=!1,dirList:k=[]}=await j(u);y||(i(k),l(!0),h(u&&u.split(C).filter(D=>!!D)||[]))},_=()=>{l(!1),t(!1),h([])},$=async(y,k=!1,D=!1)=>{var b,I;if(k){const{path:M}=await Me();M&&await it(M,y)}await((b=F)==null?void 0:b.upsert({myWorkflowsDir:y}));const x=await((I=F)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(x),D&&c(!1),_()},U=async y=>{if(y){const{error:D=""}=await Fe(y);if(D.includes("Not a directory")){w({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const k=y??`${f?"":C}${s.join(C)}`;W("Do you want to copy all workflows to new directory?",[{label:"Yes",onClick:()=>{$(k,!0,!!y)}},{label:"No",onClick:()=>{$(k,!1,!!y)}}])},he=async()=>{const{dirPath:y,dirList:k}=await j("");h(y.split(C).filter(D=>!!D)),i(k)},se=async(y,k)=>{var I;let D="";y===-1&&k?D=`${f?"":C}${s.concat([k]).join(C)}`:D=`${f?"":C}${s.slice(0,y+1).join(C)}`;const{isError:x=!1,dirList:b=[]}=await j(D);x||(i(b),h(f?D.split(C):(I=D.slice(1))==null?void 0:I.split(C)))},ne=e.jsxs(K,{textAlign:"end",mb:4,children:[e.jsx(ke,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(A,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var y,k;(y=S==null?void 0:S.current)!=null&&y.value&&U((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),pe=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(K,{mb:4,children:[e.jsx(L,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),r?n?ne:e.jsxs(Ke,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:s.map((y,k)=>e.jsxs("span",{children:[k>0&&C,e.jsx(A,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{se(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Ve,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:a.map((y,k)=>e.jsx(A,{size:"sm",leftIcon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{se(-1,y)},children:y},`${y}-${k}`))}),e.jsxs(K,{w:"100%",textAlign:"end",children:[e.jsx(A,{colorScheme:"teal",size:"sm",onClick:()=>{U()},children:"Save"}),e.jsx(A,{size:"sm",onClick:he,mr:2,ml:2,children:"Reset"}),e.jsx(A,{size:"sm",onClick:_,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(We,{overflowWrap:"anywhere",children:u}),e.jsx(P,{label:d?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(z,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!d,icon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:O})}),e.jsx(P,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(z,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:pe,variant:"ghost"})})]})]}),e.jsxs(ie,{isOpen:g,onClose:()=>c(!1),size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Kind tips"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs(K,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?e.jsxs(L,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",e.jsx(A,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos - -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):e.jsx(L,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),ne]})})]})]})]})}function Ze({label:n,settingKey:t}){const[r,l]=o.useState(200),a=Y(),i=s=>{if(!s.length){l(0);return}l(parseInt(s))},u=async()=>{var s;r<0&&l(0),await((s=F)==null?void 0:s.upsert({[t]:Number(r)})),a({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=F)==null||s.getSetting(t).then(h=>{l(h)})};return o.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:n}),e.jsx(Ft,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:r,onChange:s=>i(s),onBlur:()=>{u()},onKeyUp:s=>{s.key==="Enter"&&u()},children:e.jsx(Dt,{})})]})}function ns(){const[n,t]=o.useState(!1),r=Y(),l=()=>{var a;(a=F)==null||a.getSetting("autoSave").then(i=>{t(!!i)})};return o.useEffect(()=>{l()},[]),e.jsxs(B,{children:[e.jsx(X,{isChecked:n,onChange:async a=>{var i;await((i=F)==null?void 0:i.upsert({autoSave:a.target.checked})),l(),r({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),n&&e.jsx(Ze,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function as({onClose:n}){return e.jsx(e.Fragment,{children:e.jsxs(ie,{isOpen:!0,onClose:n,size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Settings"}),e.jsx(de,{}),e.jsx(ue,{pb:14,children:e.jsx(T,{children:e.jsxs(Ke,{divider:e.jsx(rt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ss,{}),e.jsx(ns,{}),e.jsx(Qt,{}),e.jsx(ts,{}),e.jsx(es,{}),e.jsx(Ee,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),e.jsx(Ze,{label:`Maximum number of save change history to store. This does not include - versions that you created by "Create Version", which are always stored - and has no limit.`,settingKey:"maximumChangelogNumber"}),e.jsx(Ee,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"})]})})})]})]})})}const fe=16;function os({}){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),{colorMode:a,toggleColorMode:i}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,children:[e.jsx(te,{as:z,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(ee,{children:[e.jsx(R,{onClick:()=>l(!0),icon:e.jsx(Zt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(R,{onClick:()=>t(!0),icon:e.jsx(Xt,{size:fe}),fontSize:16,children:"Manage Tags"}),e.jsxs(R,{onClick:i,icon:a==="light"?e.jsx(Ht,{size:fe}):e.jsx(Yt,{size:fe}),fontSize:16,children:[a==="light"?"Dark":"Light"," Mode"]})]})]}),n&&e.jsx(Jt,{onclose:()=>t(!1)}),r&&e.jsx(as,{onClose:()=>l(!1)})]})}function is(n){const{multipleState:t,changeMultipleState:r,selectedKeys:l,isSelectedAll:a,batchOperationCallback:i}=n,u=async()=>{var h;const s=await((h=E)==null?void 0:h.batchQuery(l))??[];ct(s)},p=l.length===0;return e.jsx(T,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(X,{isChecked:a,onChange:s=>{i("selectAll",s.target.checked)}}),e.jsx(P,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(z,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(lt,{size:21}),onClick:u})}),e.jsx(P,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Pe,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=E)==null?void 0:s.batchDeleteFlow(l)),i("batchDelete")}})}),l.length>0&&e.jsx(L,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(P,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(z,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{r(!1)}})})]}):e.jsx(P,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(z,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Vt,{size:21}),onClick:()=>{r(!0)}})})})}const Te=6;function rs({setSelectedTag:n,selectedTag:t}){const[r,l]=o.useState(!1),[a,i]=o.useState([]);return o.useEffect(()=>{var u;(u=xe)==null||u.listAll().then(p=>{i(p)})},[]),e.jsxs(T,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(z,{"aria-label":"Close",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{n(void 0)}}),a.slice(0,r?void 0:Te).map(u=>e.jsx(A,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(u.name)},isActive:t===u.name,children:u.name},u.name)),(a.length??0)>Te&&e.jsx(z,{"aria-label":"Show-all-tags",size:"sm",icon:r?e.jsx(_t,{}):e.jsx(Se,{}),onClick:()=>l(!r)})]})}function Ye({parentFolderID:n,onlyImportFile:t=!1}){const{onRefreshFilesList:r}=o.useContext(G),[l,a]=o.useState("file"),i=o.useRef(null),u=d=>{var m;a(d),d==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(m=i.current)==null||m.click()},p=async d=>{var m;if(d.type==="image/png"){const g=await ut(d),c=g==null?void 0:g.workflow;if(c)return{json:c,name:d.name.replace(".png","")}}else if(d.type==="application/json"||(m=d.name)!=null&&m.endsWith(".json"))return await new Promise((g,c)=>{const f=new FileReader;f.onload=v=>{var S;try{const w=(S=v.target)==null?void 0:S.result;typeof w=="string"?g({json:w,name:d.name.replace(".json","")}):c(new Error("File content is not a string"))}catch(w){c(w)}},f.onerror=c,f.readAsText(d)});return null},s=async d=>{var g,c;const m=[d];for(;m.length>0;){const f=m.shift();if(f&&!f.isFile){const v=await((g=V)==null?void 0:g.create({name:f.name,parentFolderID:f.parentFolderID}));if(f.children&&f.children.length){const S=[];f.children.forEach(w=>{w.isFile&&w.file?S.push(w.file):(w.parentFolderID=v==null?void 0:v.id,m.push(w))}),S.length&&await((c=E)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}r==null||r()},h=async d=>{var g;const m=d.target.files;if(m)if(l==="folder"){const c={name:m[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const f of m)if(f.name!==".DS_Store"){const v=f.webkitRelativePath.split("/");let S=c.children??[];for(let w=1;wj.name===W);if(!C){if(C={name:W,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},C.isFile){const j=await p(f);j&&(C.file=j)}S.push(C)}C&&!C.isFile&&(S=C.children)}}s(c)}else{const c=[];for(const f of m){const v=await p(f);v&&c.push(v)}c.length&&(await((g=E)==null?void 0:g.batchCreateFlows(c,void 0,n)),r&&r())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(R,{onClick:d=>{d.stopPropagation(),u("file")},icon:e.jsx(De,{size:19}),children:"Import workflows"}):e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:A,leftIcon:e.jsx(De,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(ee,{children:dt.map((d,m)=>e.jsx(R,{onClick:()=>{u(d.type)},iconSpacing:2,icon:d.type==="folder"?e.jsx(_e,{size:18}):e.jsx(Kt,{size:18}),children:d.title},m))})]}),e.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:d=>{d.stopPropagation()}})]})}function ls({folder:n,onclose:t}){const[r,l]=o.useState(n.name),[a,i]=o.useState(""),{onRefreshFilesList:u}=o.useContext(G),p=h=>{l(h.target.value),a&&i("")},s=async()=>{var m,g;const h=r.trim();if(l(h),h===n.name)return t();await((m=V)==null?void 0:m.generateUniqueName(h,n.parentFolderID??""))!==h?i("The name is duplicated, please modify it and submit again."):(await((g=V)==null?void 0:g.update(n.id,{name:h})),u&&u(),t())};return e.jsxs(ie,{isOpen:!0,onClose:t,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Edit folder name"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs(ht,{isInvalid:!!a,children:[e.jsx(pt,{children:"Folder name"}),e.jsx(ke,{value:r,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!a&&r&&s()}}),a&&e.jsx(mt,{children:a})]})}),e.jsxs(Qe,{children:[e.jsx(A,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!r||!!a,children:"Save"}),e.jsx(A,{onClick:t,children:"Cancel"})]})]})]})}function cs({menuPosition:n,isopen:t,folder:r,onClose:l}){const[a,i]=o.useState(!1),{onRefreshFilesList:u}=o.useContext(G),{showDialog:p}=we(),s=async g=>{var c;g.stopPropagation(),await((c=V)==null?void 0:c.create({name:"New Folder",parentFolderID:r.id})),u&&u()},h=async g=>{var c;g.stopPropagation(),await((c=E)==null?void 0:c.createFlow({json:JSON.stringify(ft),parentFolderID:r.id})),u&&u()},d=async g=>{g.stopPropagation();const c=await xt(r.id);p(`Do you want to delete the ${c} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{m(jt.DELETE)}}])},m=async g=>{var c;await((c=V)==null?void 0:c.deleteFolder(r.id,g)),l(),u&&u()};return e.jsxs(e.Fragment,{children:[e.jsx(K,{position:"absolute",top:n.y,left:n.x,children:e.jsx(Q,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(ee,{children:[e.jsx(R,{icon:e.jsx(gt,{size:19}),onClick:g=>{g.preventDefault(),g.stopPropagation(),i(!0)},children:"Rename"}),e.jsx(R,{icon:e.jsx(Ae,{size:19}),onClick:d,children:"Delete"}),e.jsx(R,{onClick:s,icon:e.jsx(He,{size:19}),children:"New folder"}),e.jsx(R,{onClick:h,icon:e.jsx(Be,{size:19}),children:"New file"}),e.jsx(Ye,{parentFolderID:r.id,onlyImportFile:!0})]})})}),a&&e.jsx(ls,{folder:r,onclose:()=>i(!1)})]})}const Oe=o.memo(function({folder:t}){const[r,l]=o.useState(!1),[a,i]=o.useState(t.isCollapse??!0),[u,p]=o.useState([]),[s,h]=o.useState({x:0,y:0}),[d,m]=o.useState(!1),{colorMode:g}=ve(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=o.useContext(G),w=g==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};o.useEffect(()=>{var j;a||(j=E)==null||j.listFolderContent(t.id,window.localStorage.getItem(je)).then(O=>{p(O)})},[t.id,v,a]);const W=j=>{j.preventDefault(),h({x:j.clientX,y:j.clientY}),m(!0)},C=async j=>{var O,_;if(j.preventDefault(),j.stopPropagation(),!c)return l(!1);if(H(c)){if(c.id===t.id)return l(!1);await((O=V)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else H(c)||await((_=E)==null?void 0:_.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return o.useEffect(()=>{var j;!!t.isCollapse!==a&&((j=V)==null||j.update(t.id,{isCollapse:a}))},[a]),o.useEffect(()=>{var U;const j=(U=E)==null?void 0:U.curWorkflow,O=(j==null?void 0:j.parentFolderID)+"/",_=t.id+"/";O.startsWith(_)&&i(!1)},[]),e.jsxs(B,{children:[e.jsxs(T,{w:"100%",as:"button",py:1,onClick:()=>{i(!a)},onContextMenu:W,draggable:"true",onDragOver:j=>{j.preventDefault(),j.stopPropagation(),l(!0)},onDragLeave:j=>{j.preventDefault(),j.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:C,_hover:w,style:r||d?w:void 0,className:"droppable",children:[e.jsxs(T,{gap:1,children:[a?e.jsx(Et,{size:20}):e.jsx(Se,{size:20}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),e.jsx(L,{children:t.name})]}),e.jsx(cs,{isopen:d,menuPosition:s,onClose:()=>m(!1),folder:t}),!a&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Xe,{items:u})})]})});function ds({workflow:n}){const t=o.useRef(null),r=Y(),{onDuplicateWorkflow:l}=o.useContext(Ce),[a,i]=o.useState(n.saveLock??!1),u=async()=>{var h;const s=!a;i(s),await((h=E)==null?void 0:h.updateMetaInfo(n.id,{saveLock:s})),r({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const h=s.target.files;if(!h)return;const d=new FormData;Array.from(h).forEach((m,g)=>{d.append(`images[${g}]`,m,m.name)}),d.append("subfolder","workspace_manager"),await fetch("/workspace/images/save",{method:"POST",body:d}),Array.from(h).forEach(async m=>{var c,f;const g=`workspace_manager/${m.name}`;(c=yt)==null||c.create({workflowID:n.id,localPath:g}),(f=E)==null||f.updateMetaInfo(n.id,{coverMediaPath:g})})};return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,closeOnSelect:!1,children:[e.jsx(te,{border:0,as:z,"aria-label":"Options",icon:e.jsx(Bt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(ee,{zIndex:101,children:[e.jsx(R,{icon:e.jsx(Lt,{}),onClick:()=>l&&l(n.id),children:"Duplicate"}),e.jsx(P,{hasArrow:!0,label:a?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(R,{icon:a?e.jsx($e,{}):e.jsx(Gt,{}),onClick:u,children:a?"Unlock":"Lock"})}),e.jsx(R,{icon:e.jsx(qt,{}),onClick:()=>{var s;(s=t.current)==null||s.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:s=>{s.stopPropagation()}})]})}function us({workflow:n}){const{onDeleteFlow:t}=o.useContext(G);return e.jsxs(Z,{width:"90px",justifyContent:"flex-end",children:[e.jsx(P,{label:"Open in new tab",children:e.jsx(z,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>wt(n.id),icon:e.jsx(vt,{color:"#718096",size:23})})}),e.jsx(Pe,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(n.id)}}),e.jsx(ds,{workflow:n})]})}const ze=o.memo(function({workflow:t}){var v,S,w,W;const{colorMode:r}=ve(),{setDraggingFile:l,isMultiSelecting:a,onMultiSelectFlow:i,multiSelectedFlowsID:u}=o.useContext(G),p=u&&u.length>0&&u.includes(t.id),{curFlowID:s,loadWorkflowID:h}=o.useContext(Ce),d=s===t.id,m=r==="light"?"gray.200":"#4A5568",[g,c]=o.useState(!1),f=e.jsx(K,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":void 0,color:d&&!a?"#333":void 0,draggable:!a,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"3px",onClick:()=>{!a&&h(t.id)},_hover:{bg:m},children:e.jsxs(T,{children:[!((S=(v=F)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((W=t.latestImage)==null?void 0:W.length))&&e.jsx(Tt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsxs(B,{textAlign:"left",gap:0,children:[e.jsxs(Z,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:2,style:{display:"inline-block"},children:t.name??"untitled"}),t.saveLock&&e.jsx($e,{size:18,style:{display:"inline-block"}})]}),e.jsxs(L,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",kt(t.updateTime)]})]})]})});return e.jsx(T,{w:"100%",mb:1,justify:"space-between",onMouseEnter:()=>c(!0),children:a?e.jsx(X,{isChecked:p,spacing:4,onChange:C=>{i&&i(t.id,C.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,g&&e.jsx(us,{workflow:t})]})})});function Xe({items:n}){var g;const[t,r]=o.useState(!1),l=n.filter(H),a=n.filter(c=>!H(c)),i=(g=a[0])==null?void 0:g.parentFolderID,[u,p]=o.useState(!1),{onRefreshFilesList:s,draggingFile:h,refreshFolderStamp:d}=o.useContext(G),m=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(H(h)){if(h.id===i)return p(!1);await((f=V)==null?void 0:f.update(h.id,{parentFolderID:i}))}else await((v=E)==null?void 0:v.updateFolder(h.id,{parentFolderID:i}));await(s==null?void 0:s()),p(!1)};return o.useEffect(()=>{var c;(c=F)==null||c.getSetting("foldersOnTop").then(f=>{r(f??!1)})},[d]),e.jsxs(e.Fragment,{children:[t&&l.map(c=>e.jsx(Oe,{folder:c},c.id)),e.jsx(K,{border:u?"2px dashed #718096":"2px dashed transparent",onDragOver:c=>{c.preventDefault(),c.stopPropagation(),p(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),p(!1)},onDrop:m,className:"droppable",children:t?a.map(c=>e.jsx(ze,{workflow:c},c.id)):n.map(c=>H(c)?e.jsx(Oe,{folder:c},c.id):e.jsx(ze,{workflow:c},c.id))})]})}function ks({onClose:n,onClickNewFlow:t}){const[r,l]=o.useState([]),a=o.useRef([]),{loadWorkflowID:i,curFlowID:u}=o.useContext(Ce),[p,s]=o.useState(),[h,d]=o.useState(!1),[m,g]=o.useState([]),[c,f]=o.useState(0),[v,S]=o.useState(""),w=Ot(v,400),W=o.useRef(null),[C,j]=o.useState(null),O=o.useRef(window.localStorage.getItem(je)??q.RECENTLY_MODIFIED),_=!!p||!!w.length,$=async()=>{var b,I;const x=await((b=E)==null?void 0:b.listFolderContent())??[];l(ge(x,O.current)),f(Date.now()),a.current=await((I=E)==null?void 0:I.listAll())??[]},U=()=>{const x=a.current.filter(b=>{var Ie;let I=!0,M=!0;return p&&(I=!!((Ie=b.tags)!=null&&Ie.includes(p))),w&&(M=!!b.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),I&&M});l(ge(x,O.current))},he=x=>{l(ge(r,x)),O.current=x,window.localStorage.setItem(je,x),!_&&f(Date.now())};o.useEffect(()=>{_?U():$()},[w,p]);const se=o.useCallback(async x=>{var b,I,M;await((b=E)==null?void 0:b.deleteFlow(x)),((M=(I=E)==null?void 0:I.curWorkflow)==null?void 0:M.id)===x&&await(i==null?void 0:i(null)),await $()},[p,w]);o.useEffect(()=>{const x=async b=>{var I;if(W.current){const M=await((I=E)==null?void 0:I.get(W.current));M&&M.json&&It(M.json,[b.canvasX,b.canvasY])}};return ae.canvasEl.addEventListener("drop",x),ae.canvasEl.addEventListener("click",n),()=>{ae.canvasEl.removeEventListener("drop",x),ae.canvasEl.removeEventListener("click",n)}},[]);const ne=o.useCallback((x,b)=>{g(I=>{const M=[...I];return b?M.push(x):M.splice(M.indexOf(x),1),M})},[]),pe=(x,b)=>{var I;switch(x){case"batchDelete":u&&((I=E)==null||I.get(u).then(M=>{M||i==null||i(null)})),$(),d(!1),g([]);return;case"selectAll":g(b?a.current.map(M=>M.id):[]);return}},y=x=>{j(x),H(x)||(W.current=x.id)},k=x=>{S(x)},D=450;return e.jsx(G.Provider,{value:{onRefreshFilesList:$,draggingFile:C??void 0,setDraggingFile:y,isMultiSelecting:h,onMultiSelectFlow:ne,multiSelectedFlowsID:m,onDeleteFlow:se,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx(K,{style:{width:D},children:e.jsxs(St,{width:D,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Ct,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(T,{gap:4,children:[e.jsx(T,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ye,{}),e.jsx(P,{label:"Open workspace save directory",children:e.jsx(z,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(_e,{}),variant:"outline",colorScheme:"teal",onClick:()=>bt()})}),e.jsx(P,{label:"New workflow",children:e.jsx(z,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(T,{alignItems:"center",children:e.jsx(os,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(rs,{selectedTag:p,setSelectedTag:s}),e.jsxs(T,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(T,{children:[a.current.length>0?e.jsx(is,{multipleState:h,changeMultipleState:x=>{d(x),!x&&g([])},selectedKeys:m,isSelectedAll:m.length===a.current.length,batchOperationCallback:pe}):e.jsx(K,{}),!h&&e.jsx(P,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(z,{size:"sm",variant:"outline",icon:e.jsx(He,{size:21}),onClick:async()=>{var x;await((x=V)==null?void 0:x.create({name:"New Folder"})),$()},"aria-label":"new folder button"})})]}),e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:A,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(T,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:O.current})]})}),e.jsx(ee,{children:e.jsx(Ue,{value:O.current,type:"radio",onChange:x=>he(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,b)=>e.jsx(be,{value:x,children:x},b))})})]})]}),e.jsx(zt,{searchValue:v,onUpdateSearchValue:k}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",children:e.jsx(Xe,{items:r})})]})]})})})}export{ks as default}; diff --git a/dist/workspace_web/ShareDialog-ABShBZ_r.js b/dist/workspace_web/ShareDialog-ABShBZ_r.js deleted file mode 100644 index f27f4dd..0000000 --- a/dist/workspace_web/ShareDialog-ABShBZ_r.js +++ /dev/null @@ -1 +0,0 @@ -import{r as a,m as he,x as ae,b as fe,f as le,j as e,g as J,h as pe,n as y,s as M,q as Y,l as ge,o as me,H as ve,a3 as we,i as q,M as xe,N as ke,O as be,Q as ye,S as Ce}from"./input.js";import{aG as je,d as Se,B as Ie,A as De,a4 as Pe,H as Q,h as X,a2 as Re,a1 as ie,f as _e,k as ne,g as re,aH as Fe,j as Me,F as Ee,aI as Ne,x as K,aJ as U,aK as Le,aL as We,aM as Te,T as He,aN as Ve}from"./App-YT7a4Gj6.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Be}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import{I as Ke}from"./IconCopy-j3_qolNw.js";import"/scripts/api.js";function qe(t){return t&&ae(t)&&ae(t.target)}function Ge(t={}){const{onChange:p,value:c,defaultValue:s,name:d,isDisabled:h,isFocusable:u,isNative:g,...f}=t,[w,C]=a.useState(s||""),x=typeof c<"u",j=x?c:w,k=a.useRef(null),S=a.useCallback(()=>{const n=k.current;if(!n)return;let i="input:not(:disabled):checked";const I=n.querySelector(i);if(I){I.focus();return}i="input:not(:disabled)";const o=n.querySelector(i);o==null||o.focus()},[]),m=`radio-${a.useId()}`,N=d||m,R=a.useCallback(n=>{const i=qe(n)?n.target.value:n;x||C(i),p==null||p(String(i))},[p,x]),O=a.useCallback((n={},i=null)=>({...n,ref:he(i,k),role:"radiogroup"}),[]),_=a.useCallback((n={},i=null)=>({...n,ref:i,name:N,[g?"checked":"isChecked"]:j!=null?n.value===j:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,N,R,j]);return{getRootProps:O,getRadioProps:_,name:N,ref:k,focus:S,setValue:C,value:j,onChange:R,isDisabled:h,isFocusable:u,htmlProps:f}}var[$e,ce]=fe({name:"RadioGroupContext",strict:!1}),de=le((t,p)=>{const{colorScheme:c,size:s,variant:d,children:h,className:u,isDisabled:g,isFocusable:f,...w}=t,{value:C,onChange:x,getRootProps:j,name:k,htmlProps:S}=Ge(w),E=a.useMemo(()=>({name:k,size:s,onChange:x,colorScheme:c,value:C,variant:d,isDisabled:g,isFocusable:f}),[k,s,x,c,C,d,g,f]);return e.jsx($e,{value:E,children:e.jsx(J.div,{...j(S,p),className:pe("chakra-radio-group",u),children:h})})});de.displayName="RadioGroup";var ze={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Ue(t={}){const{defaultChecked:p,isChecked:c,isFocusable:s,isDisabled:d,isReadOnly:h,isRequired:u,onChange:g,isInvalid:f,name:w,value:C,id:x,"data-radiogroup":j,"aria-describedby":k,...S}=t,E=`radio-${a.useId()}`,m=je(),R=!!ce()||!!j;let _=!!m&&!R?m.id:E;_=x??_;const n=d??(m==null?void 0:m.isDisabled),i=h??(m==null?void 0:m.isReadOnly),I=u??(m==null?void 0:m.isRequired),o=f??(m==null?void 0:m.isInvalid),[r,P]=a.useState(!1),[v,D]=a.useState(!1),[b,L]=a.useState(!1),[W,T]=a.useState(!1),[G,$]=a.useState(!!p),A=typeof c<"u",F=A?c:G;a.useEffect(()=>Ae(P),[]);const H=a.useCallback(l=>{if(i||n){l.preventDefault();return}A||$(l.target.checked),g==null||g(l)},[A,n,i,g]),B=a.useCallback(l=>{l.key===" "&&T(!0)},[T]),z=a.useCallback(l=>{l.key===" "&&T(!1)},[T]),ee=a.useCallback((l={},V=null)=>({...l,ref:V,"data-active":y(W),"data-hover":y(b),"data-disabled":y(n),"data-invalid":y(o),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&r),"data-readonly":y(i),"aria-hidden":!0,onMouseDown:M(l.onMouseDown,()=>T(!0)),onMouseUp:M(l.onMouseUp,()=>T(!1)),onMouseEnter:M(l.onMouseEnter,()=>L(!0)),onMouseLeave:M(l.onMouseLeave,()=>L(!1))}),[W,b,n,o,F,v,i,r]),{onFocus:oe,onBlur:se}=m??{},ue=a.useCallback((l={},V=null)=>{const te=n&&!s;return{...l,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(l.onChange,H),onBlur:M(se,l.onBlur,()=>D(!1)),onFocus:M(oe,l.onFocus,()=>D(!0)),onKeyDown:M(l.onKeyDown,B),onKeyUp:M(l.onKeyUp,z),checked:F,disabled:te,readOnly:i,required:I,"aria-invalid":Y(o),"aria-disabled":Y(te),"aria-required":Y(I),"data-readonly":y(i),"aria-describedby":k,style:ze}},[n,s,_,w,C,H,se,oe,B,z,F,i,I,o,k]);return{state:{isInvalid:o,isFocused:v,isChecked:F,isActive:W,isHovered:b,isDisabled:n,isReadOnly:i,isRequired:I},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(l={},V=null)=>({...l,ref:V,onMouseDown:M(l.onMouseDown,Je),"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(l,V=null)=>({...l,ref:V,"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:S}}function Je(t){t.preventDefault(),t.stopPropagation()}function Qe(t,p){const c={},s={};for(const[d,h]of Object.entries(t))p.includes(d)?c[d]=h:s[d]=h;return[c,s]}var Z=le((t,p)=>{var c;const s=ce(),{onChange:d,value:h}=t,u=ge("Radio",{...s,...t}),g=me(t),{spacing:f="0.5rem",children:w,isDisabled:C=s==null?void 0:s.isDisabled,isFocusable:x=s==null?void 0:s.isFocusable,inputProps:j,...k}=g;let S=t.isChecked;(s==null?void 0:s.value)!=null&&h!=null&&(S=s.value===h);let E=d;s!=null&&s.onChange&&h!=null&&(E=ve(s.onChange,d));const m=(c=t==null?void 0:t.name)!=null?c:s==null?void 0:s.name,{getInputProps:N,getCheckboxProps:R,getLabelProps:O,getRootProps:_,htmlProps:n}=Ue({...k,isChecked:S,isFocusable:x,isDisabled:C,onChange:E,name:m}),[i,I]=Qe(n,we),o=R(I),r=N(j,p),P=O(),v=Object.assign({},i,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...u.container},b={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...u.control},L={userSelect:"none",marginStart:f,...u.label};return e.jsxs(J.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...r}),e.jsx(J.span,{className:"chakra-radio__control",...o,__css:b}),w&&e.jsx(J.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});Z.displayName="Radio";var Ye=Se("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Xe({options:t,value:p,onChange:c}){const[s,d]=a.useState(!1),h=a.useRef(null),u=t.find(f=>f.value===p);a.useEffect(()=>{const f=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[h]);const g=()=>d(!s);return e.jsxs(Ie,{position:"relative",children:[e.jsx(q,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:u==null?void 0:u.icon,children:u==null?void 0:u.label}),s&&e.jsx(Pe,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(f=>e.jsx(q,{onClick:()=>{d(!1),c(f.value)},leftIcon:f.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:f.label},f.label))})]})}function Ze({version:t,cloudHost:p,cloudWorkflowID:c}){const s=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:s.name}),e.jsx(X,{color:"GrayText",children:Re(s.createTime,!1)}),s.cloudID&&c&&e.jsx("a",{href:p+"/workflow/"+c+"/"+s.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(q,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Ye,{}),rightIcon:e.jsx(ie,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(Z,{value:s.id,mb:5,children:d},s.id)}function ho({onClose:t}){var i,I;const[p,c]=a.useState("v"+eo()),[s,d]=a.useState([]),[h,u]=a.useState(!1),[g,f]=a.useState(""),[w,C]=a.useState("PRIVATE"),[x,j]=a.useState("new_version"),k=a.useRef(""),[S,E]=a.useState(),m=_e(),N=async o=>{var L,W;const r=o.data;if(o.origin!==k.current||r.type!=="share_workflow_success")return;const P=r.localWorkflowID,v=r.localVersionID,D=r.version.id,b=r.version.workflowID;b&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:b,cloudOrigin:o.origin,privacy:w})),v&&D&&await((W=U)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:o.origin})),R(),window.open(k.current+"/workflow/"+b+"/"+D,"_blank"),u(!1)};a.useEffect(()=>(R(),window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[]);const R=async()=>{var P,v,D;const o=await((P=ne)==null?void 0:P.getSetting("cloudHost"));o&&(f(o),k.current=o);const r=((v=K)==null?void 0:v.curWorkflow)??void 0;E(r),r!=null&&r.cloudID&&r.cloudOrigin&&Te(r).then(b=>{C(b)}),(D=U)==null||D.listByWorkflowID(r.id).then(b=>{d(b)})},O=o=>{navigator.clipboard.writeText(o).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(r=>{console.error("Failed to copy text: ",r)})},_=async()=>{var $,A,F;u(!0);const o=Le(32),r=await(($=ne)==null?void 0:$.getSetting("cloudHost"));let P,v;try{if(P=We(),x==="new_version"?v=await((A=U)==null?void 0:A.add({workflowID:S.id,name:p,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=U)==null?void 0:F.get(x)),!v){alert(`Failed to find version: ${x}, please try again.`),u(!1);return}}catch(H){console.error(H),u(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,b=window.location.host,L=`${D}//${b}`,W=r+`/share_workflow_confirm/${o}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),G=H=>{var B;if(H.origin===r&&H.data==="child_ready"){const z=(B=K)==null?void 0:B.curWorkflow;T.postMessage({workflow:z,version:v,nodeDefs:P,privacy:w},r),window.removeEventListener("message",G)}};window.addEventListener("message",G)},n=(I=(i=K)==null?void 0:i.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ke,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',S==null?void 0:S.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(re,{gap:5,children:[n==null?e.jsx(Xe,{options:Fe,value:w,onChange:o=>{C(o)}}):e.jsx(He,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ve,{privacy:w,showEmoji:!0})}),n&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Be,{href:g+"/workflow/"+n,isExternal:!0,children:[g+"/workflow/"+n," ",e.jsx(ie,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(q,{width:"180px",size:"sm",leftIcon:e.jsx(Ke,{}),onClick:()=>{var o,r;O(g+"/workflow/"+((r=(o=K)==null?void 0:o.curWorkflow)==null?void 0:r.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(de,{gap:4,onChange:o=>{j(o)},value:x,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Me,{value:p,width:"60%",onFocus:()=>{j("new_version")},onChange:o=>{c(o.target.value)}}),e.jsx(Ee,{color:"green",children:e.jsx(Ne,{colorScheme:"purple",children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Ze,{version:o,cloudHost:g,cloudWorkflowID:n??null},o.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(q,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function eo(){const t=new Date,p=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${p}-${c}-${s}`}export{ho as default}; diff --git a/dist/workspace_web/ShareDialog-uq7XVWvD.js b/dist/workspace_web/ShareDialog-uq7XVWvD.js new file mode 100644 index 0000000..49c3a0d --- /dev/null +++ b/dist/workspace_web/ShareDialog-uq7XVWvD.js @@ -0,0 +1 @@ +import{r as n,m as he,x as ne,b as fe,f as le,j as e,g as J,h as pe,n as y,s as M,q as Y,l as ge,o as me,H as ve,a3 as we,i as q,M as xe,N as ke,O as be,Q as ye,S as Ce}from"./input.js";import{aG as je,d as Se,B as Ie,A as De,a4 as Pe,H as Q,h as X,a2 as Re,_ as ie,f as _e,k as ae,g as re,aH as Fe,j as Me,F as Ee,aI as Ne,x as K,aJ as U,aK as Le,aL as We,aM as Te,T as He,aN as Ve}from"./App-bXo9NVT7.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Be}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import{I as Ke}from"./IconCopy-wyTg5wiq.js";import"/scripts/api.js";function qe(t){return t&&ne(t)&&ne(t.target)}function Ge(t={}){const{onChange:p,value:c,defaultValue:s,name:d,isDisabled:h,isFocusable:u,isNative:g,...f}=t,[w,C]=n.useState(s||""),x=typeof c<"u",j=x?c:w,k=n.useRef(null),S=n.useCallback(()=>{const a=k.current;if(!a)return;let i="input:not(:disabled):checked";const I=a.querySelector(i);if(I){I.focus();return}i="input:not(:disabled)";const o=a.querySelector(i);o==null||o.focus()},[]),m=`radio-${n.useId()}`,N=d||m,R=n.useCallback(a=>{const i=qe(a)?a.target.value:a;x||C(i),p==null||p(String(i))},[p,x]),O=n.useCallback((a={},i=null)=>({...a,ref:he(i,k),role:"radiogroup"}),[]),_=n.useCallback((a={},i=null)=>({...a,ref:i,name:N,[g?"checked":"isChecked"]:j!=null?a.value===j:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,N,R,j]);return{getRootProps:O,getRadioProps:_,name:N,ref:k,focus:S,setValue:C,value:j,onChange:R,isDisabled:h,isFocusable:u,htmlProps:f}}var[$e,ce]=fe({name:"RadioGroupContext",strict:!1}),de=le((t,p)=>{const{colorScheme:c,size:s,variant:d,children:h,className:u,isDisabled:g,isFocusable:f,...w}=t,{value:C,onChange:x,getRootProps:j,name:k,htmlProps:S}=Ge(w),E=n.useMemo(()=>({name:k,size:s,onChange:x,colorScheme:c,value:C,variant:d,isDisabled:g,isFocusable:f}),[k,s,x,c,C,d,g,f]);return e.jsx($e,{value:E,children:e.jsx(J.div,{...j(S,p),className:pe("chakra-radio-group",u),children:h})})});de.displayName="RadioGroup";var ze={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Ue(t={}){const{defaultChecked:p,isChecked:c,isFocusable:s,isDisabled:d,isReadOnly:h,isRequired:u,onChange:g,isInvalid:f,name:w,value:C,id:x,"data-radiogroup":j,"aria-describedby":k,...S}=t,E=`radio-${n.useId()}`,m=je(),R=!!ce()||!!j;let _=!!m&&!R?m.id:E;_=x??_;const a=d??(m==null?void 0:m.isDisabled),i=h??(m==null?void 0:m.isReadOnly),I=u??(m==null?void 0:m.isRequired),o=f??(m==null?void 0:m.isInvalid),[r,P]=n.useState(!1),[v,D]=n.useState(!1),[b,L]=n.useState(!1),[W,T]=n.useState(!1),[G,$]=n.useState(!!p),A=typeof c<"u",F=A?c:G;n.useEffect(()=>Ae(P),[]);const H=n.useCallback(l=>{if(i||a){l.preventDefault();return}A||$(l.target.checked),g==null||g(l)},[A,a,i,g]),B=n.useCallback(l=>{l.key===" "&&T(!0)},[T]),z=n.useCallback(l=>{l.key===" "&&T(!1)},[T]),ee=n.useCallback((l={},V=null)=>({...l,ref:V,"data-active":y(W),"data-hover":y(b),"data-disabled":y(a),"data-invalid":y(o),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&r),"data-readonly":y(i),"aria-hidden":!0,onMouseDown:M(l.onMouseDown,()=>T(!0)),onMouseUp:M(l.onMouseUp,()=>T(!1)),onMouseEnter:M(l.onMouseEnter,()=>L(!0)),onMouseLeave:M(l.onMouseLeave,()=>L(!1))}),[W,b,a,o,F,v,i,r]),{onFocus:oe,onBlur:se}=m??{},ue=n.useCallback((l={},V=null)=>{const te=a&&!s;return{...l,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(l.onChange,H),onBlur:M(se,l.onBlur,()=>D(!1)),onFocus:M(oe,l.onFocus,()=>D(!0)),onKeyDown:M(l.onKeyDown,B),onKeyUp:M(l.onKeyUp,z),checked:F,disabled:te,readOnly:i,required:I,"aria-invalid":Y(o),"aria-disabled":Y(te),"aria-required":Y(I),"data-readonly":y(i),"aria-describedby":k,style:ze}},[a,s,_,w,C,H,se,oe,B,z,F,i,I,o,k]);return{state:{isInvalid:o,isFocused:v,isChecked:F,isActive:W,isHovered:b,isDisabled:a,isReadOnly:i,isRequired:I},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(l={},V=null)=>({...l,ref:V,onMouseDown:M(l.onMouseDown,Je),"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(l,V=null)=>({...l,ref:V,"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:S}}function Je(t){t.preventDefault(),t.stopPropagation()}function Qe(t,p){const c={},s={};for(const[d,h]of Object.entries(t))p.includes(d)?c[d]=h:s[d]=h;return[c,s]}var Z=le((t,p)=>{var c;const s=ce(),{onChange:d,value:h}=t,u=ge("Radio",{...s,...t}),g=me(t),{spacing:f="0.5rem",children:w,isDisabled:C=s==null?void 0:s.isDisabled,isFocusable:x=s==null?void 0:s.isFocusable,inputProps:j,...k}=g;let S=t.isChecked;(s==null?void 0:s.value)!=null&&h!=null&&(S=s.value===h);let E=d;s!=null&&s.onChange&&h!=null&&(E=ve(s.onChange,d));const m=(c=t==null?void 0:t.name)!=null?c:s==null?void 0:s.name,{getInputProps:N,getCheckboxProps:R,getLabelProps:O,getRootProps:_,htmlProps:a}=Ue({...k,isChecked:S,isFocusable:x,isDisabled:C,onChange:E,name:m}),[i,I]=Qe(a,we),o=R(I),r=N(j,p),P=O(),v=Object.assign({},i,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...u.container},b={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...u.control},L={userSelect:"none",marginStart:f,...u.label};return e.jsxs(J.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...r}),e.jsx(J.span,{className:"chakra-radio__control",...o,__css:b}),w&&e.jsx(J.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});Z.displayName="Radio";var Ye=Se("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Xe({options:t,value:p,onChange:c}){const[s,d]=n.useState(!1),h=n.useRef(null),u=t.find(f=>f.value===p);n.useEffect(()=>{const f=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[h]);const g=()=>d(!s);return e.jsxs(Ie,{position:"relative",children:[e.jsx(q,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:u==null?void 0:u.icon,children:u==null?void 0:u.label}),s&&e.jsx(Pe,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(f=>e.jsx(q,{onClick:()=>{d(!1),c(f.value)},leftIcon:f.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:f.label},f.label))})]})}function Ze({version:t,cloudHost:p,cloudWorkflowID:c}){const s=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:s.name}),e.jsx(X,{color:"GrayText",children:Re(s.createTime,!1)}),s.cloudID&&c&&e.jsx("a",{href:p+"/workflow/"+c+"/"+s.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(q,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Ye,{}),rightIcon:e.jsx(ie,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(Z,{value:s.id,mb:5,children:d},s.id)}function ho({onClose:t}){var i,I;const[p,c]=n.useState("v"+eo()),[s,d]=n.useState([]),[h,u]=n.useState(!1),[g,f]=n.useState(""),[w,C]=n.useState("PRIVATE"),[x,j]=n.useState("new_version"),k=n.useRef(""),[S,E]=n.useState(),m=_e(),N=async o=>{var L,W;const r=o.data;if(o.origin!==k.current||r.type!=="share_workflow_success")return;const P=r.localWorkflowID,v=r.localVersionID,D=r.version.id,b=r.version.workflowID;b&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:b,cloudOrigin:o.origin,privacy:w})),v&&D&&await((W=U)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:o.origin})),R(),window.open(k.current+"/workflow/"+b+"/"+D,"_blank"),u(!1)};n.useEffect(()=>(R(),window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[]);const R=async()=>{var P,v,D;const o=await((P=ae)==null?void 0:P.getSetting("cloudHost"));o&&(f(o),k.current=o);const r=((v=K)==null?void 0:v.curWorkflow)??void 0;E(r),r!=null&&r.cloudID&&r.cloudOrigin&&Te(r).then(b=>{C(b)}),(D=U)==null||D.listByWorkflowID(r.id).then(b=>{d(b)})},O=o=>{navigator.clipboard.writeText(o).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(r=>{console.error("Failed to copy text: ",r)})},_=async()=>{var $,A,F;u(!0);const o=Le(32),r=await(($=ae)==null?void 0:$.getSetting("cloudHost"));let P,v;try{if(P=We(),x==="new_version"?v=await((A=U)==null?void 0:A.add({workflowID:S.id,name:p,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=U)==null?void 0:F.get(x)),!v){alert(`Failed to find version: ${x}, please try again.`),u(!1);return}}catch(H){console.error(H),u(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,b=window.location.host,L=`${D}//${b}`,W=r+`/share_workflow_confirm/${o}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),G=H=>{var B;if(H.origin===r&&H.data==="child_ready"){const z=(B=K)==null?void 0:B.curWorkflow;T.postMessage({workflow:z,version:v,nodeDefs:P,privacy:w},r),window.removeEventListener("message",G)}};window.addEventListener("message",G)},a=(I=(i=K)==null?void 0:i.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ke,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',S==null?void 0:S.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(re,{gap:5,children:[a==null?e.jsx(Xe,{options:Fe,value:w,onChange:o=>{C(o)}}):e.jsx(He,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ve,{privacy:w,showEmoji:!0})}),a&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Be,{href:g+"/workflow/"+a,isExternal:!0,children:[g+"/workflow/"+a," ",e.jsx(ie,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(q,{width:"180px",size:"sm",leftIcon:e.jsx(Ke,{}),onClick:()=>{var o,r;O(g+"/workflow/"+((r=(o=K)==null?void 0:o.curWorkflow)==null?void 0:r.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(de,{gap:4,onChange:o=>{j(o)},value:x,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Me,{value:p,width:"60%",onFocus:()=>{j("new_version")},onChange:o=>{c(o.target.value)}}),e.jsx(Ee,{color:"green",children:e.jsx(Ne,{colorScheme:"purple",children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Ze,{version:o,cloudHost:g,cloudWorkflowID:a??null},o.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(q,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function eo(){const t=new Date,p=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${p}-${c}-${s}`}export{ho as default}; diff --git a/dist/workspace_web/SpotlightSearch-ysZyuBYf.js b/dist/workspace_web/SpotlightSearch-TbsT5AM9.js similarity index 96% rename from dist/workspace_web/SpotlightSearch-ysZyuBYf.js rename to dist/workspace_web/SpotlightSearch-TbsT5AM9.js index 21d494c..c211a05 100644 --- a/dist/workspace_web/SpotlightSearch-ysZyuBYf.js +++ b/dist/workspace_web/SpotlightSearch-TbsT5AM9.js @@ -1 +1 @@ -import{b as $,f as j,l as Z,o as q,h as w,r as g,j as n,g as A,$ as J,M as Q,O as X,U as ee,i as te}from"./input.js";import{aF as ne,al as se,Z as re,aA as T,ai as G,H as ae,j as oe,h as O,a2 as ie,x as ce,a3 as le,E as ue,k as D}from"./App-YT7a4Gj6.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-yd7KVSRG.js";import{V as he}from"./chunk-NTCQBYKE-7yeghZmZ.js";import"/scripts/app.js";import"/scripts/api.js";var[me,ge]=$({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=Z("Input",a),{children:c,className:l,...I}=q(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function ke(){const{colorMode:S}=J(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),F=()=>{u("root")},_=e=>{a(e.id),F()},U=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,W]=pe(U,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),W(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(O,{ml:2,children:"No matching results"}):n.jsx(n.Fragment,{children:E.map((e,i)=>n.jsxs(te,{colorScheme:"teal",variant:"ghost",size:"sm",justifyContent:"start",px:2,color:S==="light"?"#1A202C":"rgba(255, 255, 255, 0.92)",onClick:()=>{_(e)},minH:"26px",isActive:i===y,children:[e.name,e.updateTime&&n.jsxs(O,{color:S==="light"?"GrayText":"rgb(255, 255, 255, 0.6)",ml:2,fontSize:"sm",children:["Updated: ",ie(e.updateTime)]})]},e.id))}),Y=async()=>{var k;const e=h=>h.map(m=>({type:"workflow",updateTime:(m==null?void 0:m.updateTime)??Date.now(),id:m.id,name:m.name.replace(/\.json$/,"")}))??[],i=await((k=ce)==null?void 0:k.listAll(le.RECENTLY_OPENED))??[];c(e(i));const d=e(i.slice(0,20));t.current=d,o(d)},N=e=>{R(i=>{const d=i+e;return d<0?f.current.length-1:d>f.current.length-1?0:d})};return g.useEffect(()=>{var k;Y(),(k=D)==null||k.getSetting("shortcuts").then(h=>{var z;const L=(h.openSpotlightSearch??((z=D)==null?void 0:z.defaultSettings.shortcuts.openSpotlightSearch)).split("+");v.current.spotlightSearchShortcutFirstKey=L[0]==="Command"?"Meta":L[0],v.current.spotlightSearchShortcutLastKey=L[L.length-1]});const e=h=>{h.key===v.current.spotlightSearchShortcutFirstKey&&v.current.lastPressedKey===v.current.spotlightSearchShortcutLastKey&&b.current>0&&f.current[b.current]&&_(f.current[b.current])},i=h=>{const m=h.key.toUpperCase();switch(v.current.lastPressedKey=m,m){case"ARROWDOWN":N(1);break;case"ARROWUP":N(-1);break;case"ENTER":_(f.current[b.current]);break}},d=h=>{switch(h.detail.shortcutType){case ue.openSpotlightSearch:N(1);break}};return document.addEventListener("keyup",e),document.addEventListener("keydown",i),window.addEventListener(G,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(G,d)}},[]),n.jsx(Q,{isOpen:!0,onClose:F,size:"xl",children:n.jsxs(X,{bg:S==="light"?"rgba(255, 255, 255, 0.8)":"rgb(45, 55, 72, 0.8)",backdropFilter:"auto",backdropBlur:"8px",children:[n.jsxs(ae,{spacing:1,px:4,py:2,borderBottom:"1px",borderColor:"gray.400",children:[n.jsx(de,{size:20}),n.jsxs(M,{children:[n.jsx(oe,{value:l,onChange:V,autoFocus:!0,variant:"unstyled",fontSize:18}),s&&n.jsx(K,{h:"27px",children:n.jsx(ee,{size:"sm"})})]})]}),n.jsx(he,{spacing:1,align:"stretch",px:2,py:2,maxHeight:"calc(100vh - 200px)",overflowY:"auto",children:B()})]})})}export{ke as default}; +import{b as $,f as j,l as Z,o as q,h as w,r as g,j as n,g as A,$ as J,M as Q,O as X,U as ee,i as te}from"./input.js";import{aF as ne,al as se,Z as re,aA as T,ai as G,H as ae,j as oe,h as O,a2 as ie,x as ce,a3 as le,E as ue,k as D}from"./App-bXo9NVT7.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-e7N1azjj.js";import{V as he}from"./chunk-NTCQBYKE-nDCdQPx1.js";import"/scripts/app.js";import"/scripts/api.js";var[me,ge]=$({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=Z("Input",a),{children:c,className:l,...I}=q(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function ke(){const{colorMode:S}=J(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),F=()=>{u("root")},_=e=>{a(e.id),F()},U=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,W]=pe(U,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),W(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(O,{ml:2,children:"No matching results"}):n.jsx(n.Fragment,{children:E.map((e,i)=>n.jsxs(te,{colorScheme:"teal",variant:"ghost",size:"sm",justifyContent:"start",px:2,color:S==="light"?"#1A202C":"rgba(255, 255, 255, 0.92)",onClick:()=>{_(e)},minH:"26px",isActive:i===y,children:[e.name,e.updateTime&&n.jsxs(O,{color:S==="light"?"GrayText":"rgb(255, 255, 255, 0.6)",ml:2,fontSize:"sm",children:["Updated: ",ie(e.updateTime)]})]},e.id))}),Y=async()=>{var k;const e=h=>h.map(m=>({type:"workflow",updateTime:(m==null?void 0:m.updateTime)??Date.now(),id:m.id,name:m.name.replace(/\.json$/,"")}))??[],i=await((k=ce)==null?void 0:k.listAll(le.RECENTLY_OPENED))??[];c(e(i));const d=e(i.slice(0,20));t.current=d,o(d)},N=e=>{R(i=>{const d=i+e;return d<0?f.current.length-1:d>f.current.length-1?0:d})};return g.useEffect(()=>{var k;Y(),(k=D)==null||k.getSetting("shortcuts").then(h=>{var z;const L=(h.openSpotlightSearch??((z=D)==null?void 0:z.defaultSettings.shortcuts.openSpotlightSearch)).split("+");v.current.spotlightSearchShortcutFirstKey=L[0]==="Command"?"Meta":L[0],v.current.spotlightSearchShortcutLastKey=L[L.length-1]});const e=h=>{h.key===v.current.spotlightSearchShortcutFirstKey&&v.current.lastPressedKey===v.current.spotlightSearchShortcutLastKey&&b.current>0&&f.current[b.current]&&_(f.current[b.current])},i=h=>{const m=h.key.toUpperCase();switch(v.current.lastPressedKey=m,m){case"ARROWDOWN":N(1);break;case"ARROWUP":N(-1);break;case"ENTER":_(f.current[b.current]);break}},d=h=>{switch(h.detail.shortcutType){case ue.openSpotlightSearch:N(1);break}};return document.addEventListener("keyup",e),document.addEventListener("keydown",i),window.addEventListener(G,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(G,d)}},[]),n.jsx(Q,{isOpen:!0,onClose:F,size:"xl",children:n.jsxs(X,{bg:S==="light"?"rgba(255, 255, 255, 0.8)":"rgb(45, 55, 72, 0.8)",backdropFilter:"auto",backdropBlur:"8px",children:[n.jsxs(ae,{spacing:1,px:4,py:2,borderBottom:"1px",borderColor:"gray.400",children:[n.jsx(de,{size:20}),n.jsxs(M,{children:[n.jsx(oe,{value:l,onChange:V,autoFocus:!0,variant:"unstyled",fontSize:18}),s&&n.jsx(K,{h:"27px",children:n.jsx(ee,{size:"sm"})})]})]}),n.jsx(he,{spacing:1,align:"stretch",px:2,py:2,maxHeight:"calc(100vh - 200px)",overflowY:"auto",children:B()})]})})}export{ke as default}; diff --git a/dist/workspace_web/chunk-3RSXBRAN-xkXXv8lg.js b/dist/workspace_web/chunk-3RSXBRAN-8cE0TZNF.js similarity index 96% rename from dist/workspace_web/chunk-3RSXBRAN-xkXXv8lg.js rename to dist/workspace_web/chunk-3RSXBRAN-8cE0TZNF.js index 92eef33..d151714 100644 --- a/dist/workspace_web/chunk-3RSXBRAN-xkXXv8lg.js +++ b/dist/workspace_web/chunk-3RSXBRAN-8cE0TZNF.js @@ -1 +1 @@ -import{f as x,j as l,g as i,h as b,l as C,o as E,n as I,r as f,a3 as P}from"./input.js";import{aa as z}from"./App-YT7a4Gj6.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S}; +import{f as x,j as l,g as i,h as b,l as C,o as E,n as I,r as f,a3 as P}from"./input.js";import{aa as z}from"./App-bXo9NVT7.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S}; diff --git a/dist/workspace_web/chunk-JARCRF6W-66xSMED8.js b/dist/workspace_web/chunk-JARCRF6W-xouhmv4h.js similarity index 99% rename from dist/workspace_web/chunk-JARCRF6W-66xSMED8.js rename to dist/workspace_web/chunk-JARCRF6W-xouhmv4h.js index 559fc7d..3a125bc 100644 --- a/dist/workspace_web/chunk-JARCRF6W-66xSMED8.js +++ b/dist/workspace_web/chunk-JARCRF6W-xouhmv4h.js @@ -1 +1 @@ -import{b as de,r as o,j as u,g as I,d as $,e as z,y as ue,n,s as m,m as te,a0 as W,f as ae,l as fe,o as me,H as he,h as ke}from"./input.js";import{ag as be}from"./App-YT7a4Gj6.js";import{t as ve}from"./index-pz0vT7Or.js";var[Ne,pe]=de({name:"CheckboxGroupContext",strict:!1});function Ce(s){const[l,t]=o.useState(s),[a,f]=o.useState(!1);return s!==l&&(f(!0),t(s)),a}function ge(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...s,children:u.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function ye(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...s,children:u.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function xe(s){const{isIndeterminate:l,isChecked:t,...a}=s,f=l?ye:ge;return t||l?u.jsx(I.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:u.jsx(f,{...a})}):null}var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function we(s,l=[]){const t=Object.assign({},s);for(const a of l)a in t&&delete t[a];return t}function Se(s={}){const l=be(s),{isDisabled:t,isReadOnly:a,isRequired:f,isInvalid:r,id:b,onBlur:P,onFocus:A,"aria-describedby":C}=l,{defaultChecked:g,isChecked:y,isFocusable:D,onChange:R,isIndeterminate:c,name:x,value:M,tabIndex:N=void 0,"aria-label":_,"aria-labelledby":j,"aria-invalid":v,...q}=s,F=we(q,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),E=$(R),K=$(P),L=$(A),[w,T]=o.useState(!1),[p,U]=o.useState(!1),[B,X]=o.useState(!1),[G,S]=o.useState(!1);o.useEffect(()=>ve(T),[]);const h=o.useRef(null),[J,ne]=o.useState(!0),[oe,H]=o.useState(!!g),V=y!==void 0,i=V?y:oe,Q=o.useCallback(e=>{if(a||t){e.preventDefault();return}V||H(i?e.target.checked:c?!0:e.target.checked),E==null||E(e)},[a,t,i,V,c,E]);z(()=>{h.current&&(h.current.indeterminate=!!c)},[c]),ue(()=>{t&&U(!1)},[t,U]),z(()=>{const e=h.current;if(!(e!=null&&e.form))return;const d=()=>{H(!!g)};return e.form.addEventListener("reset",d),()=>{var k;return(k=e.form)==null?void 0:k.removeEventListener("reset",d)}},[]);const Y=t&&!D,Z=o.useCallback(e=>{e.key===" "&&S(!0)},[S]),ee=o.useCallback(e=>{e.key===" "&&S(!1)},[S]);z(()=>{if(!h.current)return;h.current.checked!==i&&H(h.current.checked)},[h.current]);const se=o.useCallback((e={},d=null)=>{const k=O=>{p&&O.preventDefault(),S(!0)};return{...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a),"aria-hidden":!0,onMouseDown:m(e.onMouseDown,k),onMouseUp:m(e.onMouseUp,()=>S(!1)),onMouseEnter:m(e.onMouseEnter,()=>X(!0)),onMouseLeave:m(e.onMouseLeave,()=>X(!1))}},[G,i,t,p,w,B,c,r,a]),re=o.useCallback((e={},d=null)=>({...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a)}),[G,i,t,p,w,B,c,r,a]),ie=o.useCallback((e={},d=null)=>({...F,...e,ref:te(d,k=>{k&&ne(k.tagName==="LABEL")}),onClick:m(e.onClick,()=>{var k;J||((k=h.current)==null||k.click(),requestAnimationFrame(()=>{var O;(O=h.current)==null||O.focus({preventScroll:!0})}))}),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[F,t,i,r,J]),le=o.useCallback((e={},d=null)=>({...e,ref:te(h,d),type:"checkbox",name:x,value:M,id:b,tabIndex:N,onChange:m(e.onChange,Q),onBlur:m(e.onBlur,K,()=>U(!1)),onFocus:m(e.onFocus,L,()=>U(!0)),onKeyDown:m(e.onKeyDown,Z),onKeyUp:m(e.onKeyUp,ee),required:f,checked:i,disabled:Y,readOnly:a,"aria-label":_,"aria-labelledby":j,"aria-invalid":v?!!v:r,"aria-describedby":C,"aria-disabled":t,style:Ie}),[x,M,b,Q,K,L,Z,ee,f,i,Y,a,_,j,v,r,C,t,N]),ce=o.useCallback((e={},d=null)=>({...e,ref:d,onMouseDown:m(e.onMouseDown,Pe),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[i,t,r]);return{state:{isInvalid:r,isFocused:p,isChecked:i,isActive:G,isHovered:B,isIndeterminate:c,isDisabled:t,isReadOnly:a,isRequired:f},getRootProps:ie,getCheckboxProps:se,getIndicatorProps:re,getInputProps:le,getLabelProps:ce,htmlProps:F}}function Pe(s){s.preventDefault(),s.stopPropagation()}var Ae={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},De={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Re=W({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),_e=W({from:{opacity:0},to:{opacity:1}}),je=W({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Fe=ae(function(l,t){const a=pe(),f={...a,...l},r=fe("Checkbox",f),b=me(l),{spacing:P="0.5rem",className:A,children:C,iconColor:g,iconSize:y,icon:D=u.jsx(xe,{}),isChecked:R,isDisabled:c=a==null?void 0:a.isDisabled,onChange:x,inputProps:M,...N}=b;let _=R;a!=null&&a.value&&b.value&&(_=a.value.includes(b.value));let j=x;a!=null&&a.onChange&&b.value&&(j=he(a.onChange,x));const{state:v,getInputProps:q,getCheckboxProps:F,getLabelProps:E,getRootProps:K}=Se({...N,isDisabled:c,isChecked:_,onChange:j}),L=Ce(v.isChecked),w=o.useMemo(()=>({animation:L?v.isIndeterminate?`${_e} 20ms linear, ${je} 200ms linear`:`${Re} 200ms linear`:void 0,fontSize:y,color:g,...r.icon}),[g,y,L,v.isIndeterminate,r.icon]),T=o.cloneElement(D,{__css:w,isIndeterminate:v.isIndeterminate,isChecked:v.isChecked});return u.jsxs(I.label,{__css:{...De,...r.container},className:ke("chakra-checkbox",A),...K(),children:[u.jsx("input",{className:"chakra-checkbox__input",...q(M,t)}),u.jsx(I.span,{__css:{...Ae,...r.control},className:"chakra-checkbox__control",...F(),children:T}),C&&u.jsx(I.span,{className:"chakra-checkbox__label",...E(),__css:{marginStart:P,...r.label},children:C})]})});Fe.displayName="Checkbox";var Ee=ae(function(l,t){const{templateAreas:a,gap:f,rowGap:r,columnGap:b,column:P,row:A,autoFlow:C,autoRows:g,templateRows:y,autoColumns:D,templateColumns:R,...c}=l,x={display:"grid",gridTemplateAreas:a,gridGap:f,gridRowGap:r,gridColumnGap:b,gridAutoColumns:D,gridColumn:P,gridRow:A,gridAutoFlow:C,gridAutoRows:g,gridTemplateRows:y,gridTemplateColumns:R};return u.jsx(I.div,{ref:t,__css:x,...c})});Ee.displayName="Grid";export{Fe as C,Ee as G,Se as u}; +import{b as de,r as o,j as u,g as I,d as $,e as z,y as ue,n,s as m,m as te,a0 as W,f as ae,l as fe,o as me,H as he,h as ke}from"./input.js";import{ag as be}from"./App-bXo9NVT7.js";import{t as ve}from"./index-pz0vT7Or.js";var[Ne,pe]=de({name:"CheckboxGroupContext",strict:!1});function Ce(s){const[l,t]=o.useState(s),[a,f]=o.useState(!1);return s!==l&&(f(!0),t(s)),a}function ge(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...s,children:u.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function ye(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...s,children:u.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function xe(s){const{isIndeterminate:l,isChecked:t,...a}=s,f=l?ye:ge;return t||l?u.jsx(I.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:u.jsx(f,{...a})}):null}var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function we(s,l=[]){const t=Object.assign({},s);for(const a of l)a in t&&delete t[a];return t}function Se(s={}){const l=be(s),{isDisabled:t,isReadOnly:a,isRequired:f,isInvalid:r,id:b,onBlur:P,onFocus:A,"aria-describedby":C}=l,{defaultChecked:g,isChecked:y,isFocusable:D,onChange:R,isIndeterminate:c,name:x,value:M,tabIndex:N=void 0,"aria-label":_,"aria-labelledby":j,"aria-invalid":v,...q}=s,F=we(q,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),E=$(R),K=$(P),L=$(A),[w,T]=o.useState(!1),[p,U]=o.useState(!1),[B,X]=o.useState(!1),[G,S]=o.useState(!1);o.useEffect(()=>ve(T),[]);const h=o.useRef(null),[J,ne]=o.useState(!0),[oe,H]=o.useState(!!g),V=y!==void 0,i=V?y:oe,Q=o.useCallback(e=>{if(a||t){e.preventDefault();return}V||H(i?e.target.checked:c?!0:e.target.checked),E==null||E(e)},[a,t,i,V,c,E]);z(()=>{h.current&&(h.current.indeterminate=!!c)},[c]),ue(()=>{t&&U(!1)},[t,U]),z(()=>{const e=h.current;if(!(e!=null&&e.form))return;const d=()=>{H(!!g)};return e.form.addEventListener("reset",d),()=>{var k;return(k=e.form)==null?void 0:k.removeEventListener("reset",d)}},[]);const Y=t&&!D,Z=o.useCallback(e=>{e.key===" "&&S(!0)},[S]),ee=o.useCallback(e=>{e.key===" "&&S(!1)},[S]);z(()=>{if(!h.current)return;h.current.checked!==i&&H(h.current.checked)},[h.current]);const se=o.useCallback((e={},d=null)=>{const k=O=>{p&&O.preventDefault(),S(!0)};return{...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a),"aria-hidden":!0,onMouseDown:m(e.onMouseDown,k),onMouseUp:m(e.onMouseUp,()=>S(!1)),onMouseEnter:m(e.onMouseEnter,()=>X(!0)),onMouseLeave:m(e.onMouseLeave,()=>X(!1))}},[G,i,t,p,w,B,c,r,a]),re=o.useCallback((e={},d=null)=>({...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a)}),[G,i,t,p,w,B,c,r,a]),ie=o.useCallback((e={},d=null)=>({...F,...e,ref:te(d,k=>{k&&ne(k.tagName==="LABEL")}),onClick:m(e.onClick,()=>{var k;J||((k=h.current)==null||k.click(),requestAnimationFrame(()=>{var O;(O=h.current)==null||O.focus({preventScroll:!0})}))}),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[F,t,i,r,J]),le=o.useCallback((e={},d=null)=>({...e,ref:te(h,d),type:"checkbox",name:x,value:M,id:b,tabIndex:N,onChange:m(e.onChange,Q),onBlur:m(e.onBlur,K,()=>U(!1)),onFocus:m(e.onFocus,L,()=>U(!0)),onKeyDown:m(e.onKeyDown,Z),onKeyUp:m(e.onKeyUp,ee),required:f,checked:i,disabled:Y,readOnly:a,"aria-label":_,"aria-labelledby":j,"aria-invalid":v?!!v:r,"aria-describedby":C,"aria-disabled":t,style:Ie}),[x,M,b,Q,K,L,Z,ee,f,i,Y,a,_,j,v,r,C,t,N]),ce=o.useCallback((e={},d=null)=>({...e,ref:d,onMouseDown:m(e.onMouseDown,Pe),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[i,t,r]);return{state:{isInvalid:r,isFocused:p,isChecked:i,isActive:G,isHovered:B,isIndeterminate:c,isDisabled:t,isReadOnly:a,isRequired:f},getRootProps:ie,getCheckboxProps:se,getIndicatorProps:re,getInputProps:le,getLabelProps:ce,htmlProps:F}}function Pe(s){s.preventDefault(),s.stopPropagation()}var Ae={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},De={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Re=W({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),_e=W({from:{opacity:0},to:{opacity:1}}),je=W({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Fe=ae(function(l,t){const a=pe(),f={...a,...l},r=fe("Checkbox",f),b=me(l),{spacing:P="0.5rem",className:A,children:C,iconColor:g,iconSize:y,icon:D=u.jsx(xe,{}),isChecked:R,isDisabled:c=a==null?void 0:a.isDisabled,onChange:x,inputProps:M,...N}=b;let _=R;a!=null&&a.value&&b.value&&(_=a.value.includes(b.value));let j=x;a!=null&&a.onChange&&b.value&&(j=he(a.onChange,x));const{state:v,getInputProps:q,getCheckboxProps:F,getLabelProps:E,getRootProps:K}=Se({...N,isDisabled:c,isChecked:_,onChange:j}),L=Ce(v.isChecked),w=o.useMemo(()=>({animation:L?v.isIndeterminate?`${_e} 20ms linear, ${je} 200ms linear`:`${Re} 200ms linear`:void 0,fontSize:y,color:g,...r.icon}),[g,y,L,v.isIndeterminate,r.icon]),T=o.cloneElement(D,{__css:w,isIndeterminate:v.isIndeterminate,isChecked:v.isChecked});return u.jsxs(I.label,{__css:{...De,...r.container},className:ke("chakra-checkbox",A),...K(),children:[u.jsx("input",{className:"chakra-checkbox__input",...q(M,t)}),u.jsx(I.span,{__css:{...Ae,...r.control},className:"chakra-checkbox__control",...F(),children:T}),C&&u.jsx(I.span,{className:"chakra-checkbox__label",...E(),__css:{marginStart:P,...r.label},children:C})]})});Fe.displayName="Checkbox";var Ee=ae(function(l,t){const{templateAreas:a,gap:f,rowGap:r,columnGap:b,column:P,row:A,autoFlow:C,autoRows:g,templateRows:y,autoColumns:D,templateColumns:R,...c}=l,x={display:"grid",gridTemplateAreas:a,gridGap:f,gridRowGap:r,gridColumnGap:b,gridAutoColumns:D,gridColumn:P,gridRow:A,gridAutoFlow:C,gridAutoRows:g,gridTemplateRows:y,gridTemplateColumns:R};return u.jsx(I.div,{ref:t,__css:x,...c})});Ee.displayName="Grid";export{Fe as C,Ee as G,Se as u}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-7yeghZmZ.js b/dist/workspace_web/chunk-NTCQBYKE-nDCdQPx1.js similarity index 65% rename from dist/workspace_web/chunk-NTCQBYKE-7yeghZmZ.js rename to dist/workspace_web/chunk-NTCQBYKE-nDCdQPx1.js index 88dbc32..4a3105a 100644 --- a/dist/workspace_web/chunk-NTCQBYKE-7yeghZmZ.js +++ b/dist/workspace_web/chunk-NTCQBYKE-nDCdQPx1.js @@ -1 +1 @@ -import{g as t}from"./App-YT7a4Gj6.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; +import{g as t}from"./App-bXo9NVT7.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js index cc2ca3f..a89aa4b 100644 --- a/dist/workspace_web/input.js +++ b/dist/workspace_web/input.js @@ -679,10 +679,10 @@ Error generating stack: `+i.message+` } ${aB} - `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-YT7a4Gj6.js").then(e=>e.aQ),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),uB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},cB=Pz({zIndices:uB});gd.createRoot(zw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(BI,{resetCSS:!1,disableGlobalStyle:!0,theme:cB,children:[E.jsx(sB,{scope:".workspace_manager"}),E.jsx(DP,{initialColorMode:"dark"}),E.jsx(iB,{children:E.jsx(S.Suspense,{children:E.jsx(lB,{})})})]})}));const Hf=document.body,dB={attributes:!0,attributeFilter:["class"]},fB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Hf.classList)o.includes("chakra")&&Hf.classList.remove(o)},hB=new MutationObserver(fB);hB.observe(Hf,dB);export{Qh as $,PB as A,CB as B,TB as C,_B as D,TP as E,lr as F,oi as G,vB as H,Ya as I,Ap as J,yB as K,Ka as L,yw as M,Ew as N,_w as O,ja as P,Tw as Q,Aw as R,$w as S,Pw as T,Tp as U,xb as V,EB as W,os as X,Ar as Y,pB as Z,Xk as _,kB as a,vP as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Bl as e,pt as f,_e as g,Be as h,Mx as i,E as j,SB as k,Xb as l,If as m,_v as n,Iu as o,Bu as p,mB as q,S as r,Ei as s,Gf as t,IP as u,uw as v,bB as w,Kt as x,yg as y,uO as z}; + `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-bXo9NVT7.js").then(e=>e.aQ),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),uB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},cB=Pz({zIndices:uB});gd.createRoot(zw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(BI,{resetCSS:!1,disableGlobalStyle:!0,theme:cB,children:[E.jsx(sB,{scope:".workspace_manager"}),E.jsx(DP,{initialColorMode:"dark"}),E.jsx(iB,{children:E.jsx(S.Suspense,{children:E.jsx(lB,{})})})]})}));const Hf=document.body,dB={attributes:!0,attributeFilter:["class"]},fB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Hf.classList)o.includes("chakra")&&Hf.classList.remove(o)},hB=new MutationObserver(fB);hB.observe(Hf,dB);export{Qh as $,PB as A,CB as B,TB as C,_B as D,TP as E,lr as F,oi as G,vB as H,Ya as I,Ap as J,yB as K,Ka as L,yw as M,Ew as N,_w as O,ja as P,Tw as Q,Aw as R,$w as S,Pw as T,Tp as U,xb as V,EB as W,os as X,Ar as Y,pB as Z,Xk as _,kB as a,vP as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Bl as e,pt as f,_e as g,Be as h,Mx as i,E as j,SB as k,Xb as l,If as m,_v as n,Iu as o,Bu as p,mB as q,S as r,Ei as s,Gf as t,IP as u,uw as v,bB as w,Kt as x,yg as y,uO as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/App-YT7a4Gj6.js","workspace_web/assets/App-JXePnJiV.css"] + __vite__mapDeps.viteFileDeps = ["workspace_web/App-bXo9NVT7.js","workspace_web/assets/App-JXePnJiV.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/service/file_sync_service.py b/service/file_sync_service.py index 805b763..e671df4 100644 --- a/service/file_sync_service.py +++ b/service/file_sync_service.py @@ -176,7 +176,7 @@ def dedupe_workflow_ids(): @server.PromptServer.instance.routes.get('/workspace/deduplicate_workflow_ids') async def deduplicate_workflow_ids(request): - dedupe_workflow_ids() + await asyncio.to_thread(dedupe_workflow_ids) return web.json_response(text="success", content_type='application/json') @server.PromptServer.instance.routes.post('/workspace/get_workflow_file') diff --git a/ui/src/RecentFilesDrawer/MoreActionMenu.tsx b/ui/src/RecentFilesDrawer/MoreActionMenu.tsx index d8c8e01..c9f4e74 100644 --- a/ui/src/RecentFilesDrawer/MoreActionMenu.tsx +++ b/ui/src/RecentFilesDrawer/MoreActionMenu.tsx @@ -11,6 +11,7 @@ import { import { IconCopy, IconDotsVertical, + IconExternalLink, IconLock, IconLockOpen, IconUpload, @@ -19,6 +20,7 @@ import AddTagToWorkflowPopover from "./AddTagToWorkflowPopover"; import { Workflow } from "../types/dbTypes"; import { mediaTable, workflowsTable } from "../db-tables/WorkspaceDB"; import { WorkspaceContext } from "../WorkspaceContext"; +import { openWorkflowInNewTab } from "../utils"; type Props = { workflow: Workflow; @@ -71,7 +73,7 @@ export default function MoreActionMenu({ workflow }: Props) { return ( <> - + Duplicate + } + onClick={() => openWorkflowInNewTab(workflow.id)} + > + Open in new tab + {/* */} setDraggingFile?.(workflow)} borderRadius={6} px={1} - py={"3px"} + py={"5px"} onClick={() => { !isMultiSelecting && loadWorkflowID(workflow.id); }} @@ -53,7 +52,7 @@ export default memo(function WorkflowListItem({ workflow }: Props) { bg: hoverBgColor, }} > - + {!userSettingsTable?.settings?.hideCoverImage && (workflow.coverMediaPath?.length || workflow.latestImage?.length) && ( )} - + - + {workflow.name ?? "untitled"} {workflow.saveLock && ( )} - - - Updated: {formatTimestamp(workflow.updateTime)} - - + ); @@ -91,9 +87,11 @@ export default memo(function WorkflowListItem({ workflow }: Props) { return ( setIsHovering(true)} + onMouseLeave={() => setIsHovering(false)} > {isMultiSelecting ? ( {basicInfoComp} - {isHovering && } +
+ {isHovering ? ( + + ) : ( + + {formatTimestamp(workflow.updateTime, false, false, "/")} + + )} +
)}
diff --git a/ui/src/RecentFilesDrawer/WorkflowListItemActionButtons.tsx b/ui/src/RecentFilesDrawer/WorkflowListItemActionButtons.tsx index 86b093e..8d932d6 100644 --- a/ui/src/RecentFilesDrawer/WorkflowListItemActionButtons.tsx +++ b/ui/src/RecentFilesDrawer/WorkflowListItemActionButtons.tsx @@ -1,8 +1,6 @@ import { Flex, IconButton, Tooltip } from "@chakra-ui/react"; -import { IconExternalLink } from "@tabler/icons-react"; import DeleteConfirm from "../components/DeleteConfirm"; import MoreActionMenu from "./MoreActionMenu"; -import { openWorkflowInNewTab } from "../utils"; import { useContext } from "react"; import { RecentFilesContext } from "../WorkspaceContext"; import { Workflow } from "../types/dbTypes"; @@ -14,17 +12,7 @@ export default function WorkflowListItemActionButtons({ }) { const { onDeleteFlow } = useContext(RecentFilesContext); return ( - - - openWorkflowInNewTab(workflow.id)} - icon={} - /> - - + { diff --git a/ui/src/components/DeleteConfirm.tsx b/ui/src/components/DeleteConfirm.tsx index b5c1948..4efc008 100644 --- a/ui/src/components/DeleteConfirm.tsx +++ b/ui/src/components/DeleteConfirm.tsx @@ -40,7 +40,7 @@ export default function DeleteConfirm(props: Props) { } + icon={} isDisabled={isDisabled} variant={variant} /> diff --git a/ui/src/utils.tsx b/ui/src/utils.tsx index b3fe6ab..1a58475 100644 --- a/ui/src/utils.tsx +++ b/ui/src/utils.tsx @@ -103,6 +103,7 @@ export function formatTimestamp( unixTimestamp: number, showHourMinue: boolean = true, showSec: boolean = false, + splitChar: string = "-", ) { // Create a new Date object from the UNIX timestamp const date = new Date(unixTimestamp); @@ -115,7 +116,7 @@ export function formatTimestamp( const minutes = String(date.getMinutes()).padStart(2, "0"); const seconds = String(date.getSeconds()).padStart(2, "0"); // Format the date and time string - const res = `${month}-${day}-${year}`; + const res = `${month}${splitChar}${day}${splitChar}${year}`; if (showHourMinue) { return res + ` ${hours}:${minutes}`; }