diff --git a/dist/workspace_web/App-ZTJclgGW.js b/dist/workspace_web/App-9GIQJeUY.js similarity index 89% rename from dist/workspace_web/App-ZTJclgGW.js rename to dist/workspace_web/App-9GIQJeUY.js index 29cbc62..10bccdf 100644 --- a/dist/workspace_web/App-ZTJclgGW.js +++ b/dist/workspace_web/App-9GIQJeUY.js @@ -1,13 +1,13 @@ -var pl=Object.defineProperty;var ml=(t,e,n)=>e in t?pl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(ml(t,typeof e!="symbol"?e+"":e,n),n);import{u as yl,a as vl,r as j,c as gl,b as tt,m as Be,d as zt,f as fe,e as _e,j as C,B as wl,g as de,h as Le,i as bl,o as nt,k as Nt,l as at,I as Hr,n as qr,p as so,q as Se,s as xa,t as _l,v as xl,w as kl,x as Vr,y as El,z as Cl,A as Sl,C as Il,D as Ol,E as is,F as ka,G as ls,H as Ea,J as Dl,K as Pl,L as jl,P as Ca,_ as Ft,M as xr,N as kr,O as Er,Q as cs,R as us,S as Sa,T as Ia,U as Oa,V as Da,W as Xn,X as Pa}from"./input.js";function Al(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function ja(t){var e;return Al(t)&&(e=t.ownerDocument)!=null?e:document}function Nl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Fl=Nl();function Rl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function Aa(t){const{theme:e}=yl(),n=vl();return j.useMemo(()=>gl(e.direction,{...n,...t}),[t,e.direction,n])}var Tl=Object.defineProperty,Bl=(t,e,n)=>e in t?Tl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Oe=(t,e,n)=>(Bl(t,typeof e!="symbol"?e+"":e,n),n);function Ks(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 Ml=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function $s(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Hs(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var _o=typeof window<"u"?j.useLayoutEffect:j.useEffect,Cr=t=>t,zl=class{constructor(){Oe(this,"descendants",new Map),Oe(this,"register",t=>{if(t!=null)return Ml(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),Oe(this,"unregister",t=>{this.descendants.delete(t);const e=Ks(Array.from(this.descendants.keys()));this.assignIndex(e)}),Oe(this,"destroy",()=>{this.descendants.clear()}),Oe(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),Oe(this,"count",()=>this.descendants.size),Oe(this,"enabledCount",()=>this.enabledValues().length),Oe(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),Oe(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),Oe(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),Oe(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),Oe(this,"first",()=>this.item(0)),Oe(this,"firstEnabled",()=>this.enabledItem(0)),Oe(this,"last",()=>this.item(this.descendants.size-1)),Oe(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),Oe(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),Oe(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),Oe(this,"next",(t,e=!0)=>{const n=$s(t,this.count(),e);return this.item(n)}),Oe(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=$s(r,this.enabledCount(),e);return this.enabledItem(o)}),Oe(this,"prev",(t,e=!0)=>{const n=Hs(t,this.count()-1,e);return this.item(n)}),Oe(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Hs(r,this.enabledCount()-1,e);return this.enabledItem(o)}),Oe(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=Ks(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 Ll(){const t=j.useRef(new zl);return _o(()=>()=>t.current.destroy()),t.current}var[Wl,Na]=tt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Ul(t){const e=Na(),[n,r]=j.useState(-1),o=j.useRef(null);_o(()=>()=>{o.current&&e.unregister(o.current)},[]),_o(()=>{if(!o.current)return;const i=Number(o.current.dataset.index);n!=i&&!Number.isNaN(i)&&r(i)});const s=Cr(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Be(s,o)}}function Fa(){return[Cr(Wl),()=>Cr(Na()),()=>Ll(),o=>Ul(o)]}function Ra(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,f)=>p!==f}=t,s=zt(r),i=zt(o),[a,l]=j.useState(n),u=e!==void 0,c=u?e:a,d=zt(p=>{const w=typeof p=="function"?p(c):p;i(c,w)&&(u||l(w),s(w))},[u,s,c,i]);return[c,d]}function ds(t){return j.Children.toArray(t).filter(e=>j.isValidElement(e))}var Kl={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}}},$l={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},Ta=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),f=j.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:u}),[r,o,s,u]);let w={display:"inline-flex",...l?Kl[c]:$l[c](a)};const h=c==="vertical";return C.jsx(wl,{value:f,children:C.jsx(de.div,{ref:n,role:"group",__css:w,className:p,"data-attached":l?"":void 0,"data-orientation":c,flexDir:h?"column":void 0,...d})})});Ta.displayName="ButtonGroup";var Nn=fe((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=j.isValidElement(a)?j.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return C.jsx(Le,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});Nn.displayName="IconButton";var[Hl,Ba]=bl("Card"),ql=fe(function(e,n){const{className:r,...o}=e,s=Ba();return C.jsx(de.div,{ref:n,className:_e("chakra-card__body",r),__css:s.body,...o})}),Vl=fe(function(e,n){const{className:r,...o}=e,s=Ba();return C.jsx(de.div,{ref:n,className:_e("chakra-card__header",r),__css:s.header,...o})}),Gl=fe(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=nt(e),u=Nt("Card",e);return C.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:C.jsx(Hl,{value:u,children:o})})}),[Zl,Ma]=tt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Yl,mn]=tt({strict:!1,name:"FormControlContext"});function Jl(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=j.useId(),l=e||`field-${a}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[p,f]=j.useState(!1),[w,h]=j.useState(!1),[y,m]=j.useState(!1),v=j.useCallback((E={},N=null)=>({id:d,...E,ref:Be(N,D=>{D&&h(!0)})}),[d]),_=j.useCallback((E={},N=null)=>({...E,ref:N,"data-focus":at(y),"data-disabled":at(o),"data-invalid":at(r),"data-readonly":at(s),id:E.id!==void 0?E.id:u,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,y,r,s,u]),x=j.useCallback((E={},N=null)=>({id:c,...E,ref:Be(N,D=>{D&&f(!0)}),"aria-live":"polite"}),[c]),k=j.useCallback((E={},N=null)=>({...E,...i,ref:N,role:"group","data-focus":at(y),"data-disabled":at(o),"data-invalid":at(r),"data-readonly":at(s)}),[i,o,y,r,s]),O=j.useCallback((E={},N=null)=>({...E,ref:N,role:"presentation","aria-hidden":!0,children:E.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!y,onFocus:()=>m(!0),onBlur:()=>m(!1),hasFeedbackText:p,setHasFeedbackText:f,hasHelpText:w,setHasHelpText:h,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:i,getHelpTextProps:v,getErrorMessageProps:x,getRootProps:k,getLabelProps:_,getRequiredIndicatorProps:O}}var Gr=fe(function(e,n){const r=Nt("Form",e),o=nt(e),{getRootProps:s,htmlProps:i,...a}=Jl(o),l=_e("chakra-form-control",e.className);return C.jsx(Yl,{value:a,children:C.jsx(Zl,{value:r,children:C.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});Gr.displayName="FormControl";var Xl=fe(function(e,n){const r=mn(),o=Ma(),s=_e("chakra-form__helper-text",e.className);return C.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});Xl.displayName="FormHelperText";var[Ql,ec]=tt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Zr=fe((t,e)=>{const n=Nt("FormError",t),r=nt(t),o=mn();return o!=null&&o.isInvalid?C.jsx(Ql,{value:n,children:C.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});Zr.displayName="FormErrorMessage";var tc=fe((t,e)=>{const n=ec(),r=mn();if(!(r!=null&&r.isInvalid))return null;const o=_e("chakra-form__error-icon",t.className);return C.jsx(Hr,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:C.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"})})});tc.displayName="FormErrorIcon";var Yr=fe(function(e,n){var r;const o=qr("FormLabel",e),s=nt(e),{className:i,children:a,requiredIndicator:l=C.jsx(za,{}),optionalIndicator:u=null,...c}=s,d=mn(),p=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return C.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]})});Yr.displayName="FormLabel";var za=fe(function(e,n){const r=mn(),o=Ma();if(!(r!=null&&r.isRequired))return null;const s=_e("chakra-form__required-indicator",e.className);return C.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});za.displayName="RequiredIndicator";function nc(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=rc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":so(n),"aria-required":so(o),"aria-readonly":so(r)}}function rc(t){var e,n,r;const o=mn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:p,onFocus:f,onBlur:w,...h}=t,y=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&y.push(o.feedbackId),o!=null&&o.hasHelpText&&y.push(o.helpTextId),{...h,"aria-describedby":y.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:Se(o==null?void 0:o.onFocus,f),onBlur:Se(o==null?void 0:o.onBlur,w)}}function rn(t,e,n,r){const o=zt(n);return j.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 oc(t){return"current"in t}var La=()=>typeof window<"u";function sc(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var ac=t=>La()&&t.test(navigator.vendor),ic=t=>La()&&t.test(sc()),lc=()=>ic(/mac|iphone|ipad|ipod/i),cc=()=>lc()&&ac(/apple/i);function uc(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};rn(o,"pointerdown",s=>{if(!cc()||!r)return;const i=s.target,l=(n??[e]).some(u=>{const c=oc(u)?u.current:u;return(c==null?void 0:c.contains(i))||c===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var Wa={exports:{}},dc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",fc=dc,hc=fc;function Ua(){}function Ka(){}Ka.resetWarningCache=Ua;var pc=function(){function t(r,o,s,i,a,l){if(l!==hc){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:Ka,resetWarningCache:Ua};return n.PropTypes=n,n};Wa.exports=pc();var mc=Wa.exports;const Tt=xa(mc);function yc(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 vc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function $a(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:_l(t)&&yc(t)?t:$a(vc(t))}var gc=Fl?j.useLayoutEffect:j.useEffect;function xo(t,e=[]){const n=j.useRef(t);return gc(()=>{n.current=t}),j.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function wc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=xo(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{ao(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&ao(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&ao(d,e)&&(i.isPointerDown=!1,o(d))},c=ja(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 ao(t,e){var n;const r=t.target;return r&&!ja(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function bc(t,e){const n=j.useId();return j.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function _c(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function xc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=xo(n),i=xo(e),[a,l]=j.useState(t.defaultIsOpen||!1),[u,c]=_c(r,a),d=bc(o,"disclosure"),p=j.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),f=j.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),w=j.useCallback(()=>{(c?p:f)()},[c,f,p]);return{isOpen:!!c,onOpen:f,onClose:p,onToggle:w,isControlled:u,getButtonProps:(h={})=>({...h,"aria-expanded":c,"aria-controls":d,onClick:xl(h.onClick,w)}),getDisclosureProps:(h={})=>({...h,hidden:!c,id:d})}}var yn=fe(function(e,n){const{htmlSize:r,...o}=e,s=Nt("Input",o),i=nt(o),a=nc(i),l=_e("chakra-input",e.className);return C.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});yn.displayName="Input";yn.id="Input";function kc(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):kl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}var mt=fe(function(e,n){const r=qr("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=nt(e),u=Rl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return C.jsx(de.p,{ref:n,className:_e("chakra-text",e.className),...u,...l,__css:r})});mt.displayName="Text";var ko=t=>C.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});ko.displayName="StackDivider";var Ha=t=>C.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});Ha.displayName="StackItem";function Ec(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{"&":kc(n,o=>r[o])}}var It=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,f=n?"row":r??"column",w=j.useMemo(()=>Ec({spacing:i,direction:f}),[i,f]),h=!!u,y=!d&&!h,m=j.useMemo(()=>{const _=ds(l);return y?_:_.map((x,k)=>{const O=typeof x.key<"u"?x.key:k,E=k+1===_.length,D=d?C.jsx(Ha,{children:x},O):x;if(!h)return D;const R=j.cloneElement(u,{__css:w}),q=E?null:R;return C.jsxs(j.Fragment,{children:[D,q]},O)})},[u,w,h,y,d,l]),v=_e("chakra-stack",c);return C.jsx(de.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:f,flexWrap:a,gap:h?void 0:i,className:v,...p,children:m})});It.displayName="Stack";var Lt=fe((t,e)=>C.jsx(It,{align:"center",...t,direction:"row",ref:e}));Lt.displayName="HStack";var fs=fe(function(e,n){const r=qr("Heading",e),{className:o,...s}=nt(e);return C.jsx(de.h2,{ref:n,className:_e("chakra-heading",e.className),...s,__css:r})});fs.displayName="Heading";var Ot=de("div");Ot.displayName="Box";var qa=fe(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return C.jsx(Ot,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});qa.displayName="Square";var Cc=fe(function(e,n){const{size:r,...o}=e;return C.jsx(qa,{size:r,ref:n,borderRadius:"9999px",...o})});Cc.displayName="Circle";var on=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 C.jsx(de.div,{ref:n,__css:d,...c})});on.displayName="Flex";function Sc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Ic(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=j.useState([]),s=j.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};j.useEffect(()=>i,[]);function l(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Sc(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),a()}}}return l}function Oc(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 Dc(){const t=j.useRef(new Map),e=t.current,n=j.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=j.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return j.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function io(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Va(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:f,...w}=t,[h,y]=j.useState(!0),[m,v]=j.useState(!1),_=Dc(),x=A=>{A&&A.tagName!=="BUTTON"&&y(!1)},k=h?d:d||0,O=n&&!r,E=j.useCallback(A=>{if(n){A.stopPropagation(),A.preventDefault();return}A.currentTarget.focus(),l==null||l(A)},[n,l]),N=j.useCallback(A=>{m&&io(A)&&(A.preventDefault(),A.stopPropagation(),v(!1),_.remove(document,"keyup",N,!1))},[m,_]),D=j.useCallback(A=>{if(u==null||u(A),n||A.defaultPrevented||A.metaKey||!io(A.nativeEvent)||h)return;const G=o&&A.key==="Enter";s&&A.key===" "&&(A.preventDefault(),v(!0)),G&&(A.preventDefault(),A.currentTarget.click()),_.add(document,"keyup",N,!1)},[n,h,u,o,s,_,N]),R=j.useCallback(A=>{if(c==null||c(A),n||A.defaultPrevented||A.metaKey||!io(A.nativeEvent)||h)return;s&&A.key===" "&&(A.preventDefault(),v(!1),A.currentTarget.click())},[s,h,n,c]),q=j.useCallback(A=>{A.button===0&&(v(!1),_.remove(document,"mouseup",q,!1))},[_]),P=j.useCallback(A=>{if(A.button!==0)return;if(n){A.stopPropagation(),A.preventDefault();return}h||v(!0),A.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",q,!1),i==null||i(A)},[n,h,i,_,q]),T=j.useCallback(A=>{A.button===0&&(h||v(!1),a==null||a(A))},[a,h]),b=j.useCallback(A=>{if(n){A.preventDefault();return}p==null||p(A)},[n,p]),K=j.useCallback(A=>{m&&(A.preventDefault(),v(!1)),f==null||f(A)},[m,f]),$=Be(e,x);return h?{...w,ref:$,type:"button","aria-disabled":O?void 0:n,disabled:O,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:c,onKeyDown:u,onMouseOver:p,onMouseLeave:f}:{...w,ref:$,role:"button","data-active":at(m),"aria-disabled":n?"true":void 0,tabIndex:O?void 0:k,onClick:E,onMouseDown:P,onMouseUp:T,onKeyUp:R,onKeyDown:D,onMouseOver:b,onMouseLeave:K}}function Pc(t){const e=t.current;if(!e)return!1;const n=Sl(e);return!n||e.contains(n)?!1:!!Il(n)}function Ga(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;Vr(()=>{if(!s||Pc(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 Ac(t,e=jc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=Nc(t)?t.current:t,a=o&&s,l=j.useRef(a),u=j.useRef(s);El(()=>{!u.current&&s&&(l.current=a),u.current=s},[s,a]);const c=j.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=Cl(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);Vr(()=>{c()},[c]),rn(i,"transitionend",c)}function Nc(t){return"current"in t}var Xt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),Ae={arrowShadowColor:Xt("--popper-arrow-shadow-color"),arrowSize:Xt("--popper-arrow-size","8px"),arrowSizeHalf:Xt("--popper-arrow-size-half"),arrowBg:Xt("--popper-arrow-bg"),transformOrigin:Xt("--popper-transform-origin"),arrowOffset:Xt("--popper-arrow-offset")};function Fc(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 Rc={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"},Tc=t=>Rc[t],qs={scroll:!0,resize:!0};function Bc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...qs,...t}}:e={enabled:t,options:qs},e}var Mc={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`}},zc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{Vs(t)},effect:({state:t})=>()=>{Vs(t)}},Vs=t=>{t.elements.popper.style.setProperty(Ae.transformOrigin.var,Tc(t.placement))},Lc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{Wc(t)}},Wc=t=>{var e;if(!t.placement)return;const n=Uc(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])}},Uc=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}},Kc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{Gs(t)},effect:({state:t})=>()=>{Gs(t)}},Gs=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Fc(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))"})},$c={"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"}},Hc={"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 qc(t,e="ltr"){var n,r;const o=((n=$c[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=Hc[t])!=null?r:o}var Ke="top",Qe="bottom",et="right",$e="left",hs="auto",Kn=[Ke,Qe,et,$e],cn="start",Fn="end",Vc="clippingParents",Za="viewport",xn="popper",Gc="reference",Zs=Kn.reduce(function(t,e){return t.concat([e+"-"+cn,e+"-"+Fn])},[]),Ya=[].concat(Kn,[hs]).reduce(function(t,e){return t.concat([e,e+"-"+cn,e+"-"+Fn])},[]),Zc="beforeRead",Yc="read",Jc="afterRead",Xc="beforeMain",Qc="main",eu="afterMain",tu="beforeWrite",nu="write",ru="afterWrite",ou=[Zc,Yc,Jc,Xc,Qc,eu,tu,nu,ru];function ut(t){return t?(t.nodeName||"").toLowerCase():null}function Ge(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=Ge(t).Element;return t instanceof e||t instanceof Element}function Xe(t){var e=Ge(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ps(t){if(typeof ShadowRoot>"u")return!1;var e=Ge(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function su(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];!Xe(s)||!ut(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 au(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},{});!Xe(o)||!ut(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const iu={name:"applyStyles",enabled:!0,phase:"write",fn:su,effect:au,requires:["computeStyles"]};function ct(t){return t.split("-")[0]}var Wt=Math.max,Sr=Math.min,un=Math.round;function Eo(){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 Ja(){return!/^((?!chrome|android).)*safari/i.test(Eo())}function dn(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Xe(t)&&(o=t.offsetWidth>0&&un(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&un(r.height)/t.offsetHeight||1);var i=qt(t)?Ge(t):window,a=i.visualViewport,l=!Ja()&&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 ms(t){var e=dn(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 Xa(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&ps(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function bt(t){return Ge(t).getComputedStyle(t)}function lu(t){return["table","td","th"].indexOf(ut(t))>=0}function Rt(t){return((qt(t)?t.ownerDocument:t.document)||window.document).documentElement}function Jr(t){return ut(t)==="html"?t:t.assignedSlot||t.parentNode||(ps(t)?t.host:null)||Rt(t)}function Ys(t){return!Xe(t)||bt(t).position==="fixed"?null:t.offsetParent}function cu(t){var e=/firefox/i.test(Eo()),n=/Trident/i.test(Eo());if(n&&Xe(t)){var r=bt(t);if(r.position==="fixed")return null}var o=Jr(t);for(ps(o)&&(o=o.host);Xe(o)&&["html","body"].indexOf(ut(o))<0;){var s=bt(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 $n(t){for(var e=Ge(t),n=Ys(t);n&&lu(n)&&bt(n).position==="static";)n=Ys(n);return n&&(ut(n)==="html"||ut(n)==="body"&&bt(n).position==="static")?e:n||cu(t)||e}function ys(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Sn(t,e,n){return Wt(t,Sr(e,n))}function uu(t,e,n){var r=Sn(t,e,n);return r>n?n:r}function Qa(){return{top:0,right:0,bottom:0,left:0}}function ei(t){return Object.assign({},Qa(),t)}function ti(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var du=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,ei(typeof e!="number"?e:ti(e,Kn))};function fu(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=ct(n.placement),l=ys(a),u=[$e,et].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!i)){var d=du(o.padding,n),p=ms(s),f=l==="y"?Ke:$e,w=l==="y"?Qe:et,h=n.rects.reference[c]+n.rects.reference[l]-i[l]-n.rects.popper[c],y=i[l]-n.rects.reference[l],m=$n(s),v=m?l==="y"?m.clientHeight||0:m.clientWidth||0:0,_=h/2-y/2,x=d[f],k=v-p[c]-d[w],O=v/2-p[c]/2+_,E=Sn(x,O,k),N=l;n.modifiersData[r]=(e={},e[N]=E,e.centerOffset=E-O,e)}}function hu(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)||Xa(e.elements.popper,o)&&(e.elements.arrow=o))}const pu={name:"arrow",enabled:!0,phase:"main",fn:fu,effect:hu,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function fn(t){return t.split("-")[1]}var mu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function yu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:un(n*o)/o||0,y:un(r*o)/o||0}}function Js(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,f=p===void 0?0:p,w=i.y,h=w===void 0?0:w,y=typeof c=="function"?c({x:f,y:h}):{x:f,y:h};f=y.x,h=y.y;var m=i.hasOwnProperty("x"),v=i.hasOwnProperty("y"),_=$e,x=Ke,k=window;if(u){var O=$n(n),E="clientHeight",N="clientWidth";if(O===Ge(n)&&(O=Rt(n),bt(O).position!=="static"&&a==="absolute"&&(E="scrollHeight",N="scrollWidth")),O=O,o===Ke||(o===$e||o===et)&&s===Fn){x=Qe;var D=d&&O===k&&k.visualViewport?k.visualViewport.height:O[E];h-=D-r.height,h*=l?1:-1}if(o===$e||(o===Ke||o===Qe)&&s===Fn){_=et;var R=d&&O===k&&k.visualViewport?k.visualViewport.width:O[N];f-=R-r.width,f*=l?1:-1}}var q=Object.assign({position:a},u&&mu),P=c===!0?yu({x:f,y:h},Ge(n)):{x:f,y:h};if(f=P.x,h=P.y,l){var T;return Object.assign({},q,(T={},T[x]=v?"0":"",T[_]=m?"0":"",T.transform=(k.devicePixelRatio||1)<=1?"translate("+f+"px, "+h+"px)":"translate3d("+f+"px, "+h+"px, 0)",T))}return Object.assign({},q,(e={},e[x]=v?h+"px":"",e[_]=m?f+"px":"",e.transform="",e))}function vu(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:ct(e.placement),variation:fn(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,Js(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,Js(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 gu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:vu,data:{}};var Qn={passive:!0};function wu(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=Ge(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,Qn)}),a&&l.addEventListener("resize",n.update,Qn),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,Qn)}),a&&l.removeEventListener("resize",n.update,Qn)}}const bu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:wu,data:{}};var _u={left:"right",right:"left",bottom:"top",top:"bottom"};function cr(t){return t.replace(/left|right|bottom|top/g,function(e){return _u[e]})}var xu={start:"end",end:"start"};function Xs(t){return t.replace(/start|end/g,function(e){return xu[e]})}function vs(t){var e=Ge(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function gs(t){return dn(Rt(t)).left+vs(t).scrollLeft}function ku(t,e){var n=Ge(t),r=Rt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var u=Ja();(u||!u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+gs(t),y:l}}function Eu(t){var e,n=Rt(t),r=vs(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Wt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Wt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+gs(t),l=-r.scrollTop;return bt(o||n).direction==="rtl"&&(a+=Wt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function ws(t){var e=bt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function ni(t){return["html","body","#document"].indexOf(ut(t))>=0?t.ownerDocument.body:Xe(t)&&ws(t)?t:ni(Jr(t))}function In(t,e){var n;e===void 0&&(e=[]);var r=ni(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ge(r),i=o?[s].concat(s.visualViewport||[],ws(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(In(Jr(i)))}function Co(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Cu(t,e){var n=dn(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 Qs(t,e,n){return e===Za?Co(ku(t,n)):qt(e)?Cu(e,n):Co(Eu(Rt(t)))}function Su(t){var e=In(Jr(t)),n=["absolute","fixed"].indexOf(bt(t).position)>=0,r=n&&Xe(t)?$n(t):t;return qt(r)?e.filter(function(o){return qt(o)&&Xa(o,r)&&ut(o)!=="body"}):[]}function Iu(t,e,n,r){var o=e==="clippingParents"?Su(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,u){var c=Qs(t,u,r);return l.top=Wt(c.top,l.top),l.right=Sr(c.right,l.right),l.bottom=Sr(c.bottom,l.bottom),l.left=Wt(c.left,l.left),l},Qs(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 ri(t){var e=t.reference,n=t.element,r=t.placement,o=r?ct(r):null,s=r?fn(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case Ke:l={x:i,y:e.y-n.height};break;case Qe:l={x:i,y:e.y+e.height};break;case et:l={x:e.x+e.width,y:a};break;case $e:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=o?ys(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case cn:l[u]=l[u]-(e[c]/2-n[c]/2);break;case Fn:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function Rn(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?Vc:a,u=n.rootBoundary,c=u===void 0?Za:u,d=n.elementContext,p=d===void 0?xn:d,f=n.altBoundary,w=f===void 0?!1:f,h=n.padding,y=h===void 0?0:h,m=ei(typeof y!="number"?y:ti(y,Kn)),v=p===xn?Gc:xn,_=t.rects.popper,x=t.elements[w?v:p],k=Iu(qt(x)?x:x.contextElement||Rt(t.elements.popper),l,c,i),O=dn(t.elements.reference),E=ri({reference:O,element:_,strategy:"absolute",placement:o}),N=Co(Object.assign({},_,E)),D=p===xn?N:O,R={top:k.top-D.top+m.top,bottom:D.bottom-k.bottom+m.bottom,left:k.left-D.left+m.left,right:D.right-k.right+m.right},q=t.modifiersData.offset;if(p===xn&&q){var P=q[o];Object.keys(R).forEach(function(T){var b=[et,Qe].indexOf(T)>=0?1:-1,K=[Ke,Qe].indexOf(T)>=0?"y":"x";R[T]+=P[K]*b})}return R}function Ou(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?Ya:l,c=fn(r),d=c?a?Zs:Zs.filter(function(w){return fn(w)===c}):Kn,p=d.filter(function(w){return u.indexOf(w)>=0});p.length===0&&(p=d);var f=p.reduce(function(w,h){return w[h]=Rn(t,{placement:h,boundary:o,rootBoundary:s,padding:i})[ct(h)],w},{});return Object.keys(f).sort(function(w,h){return f[w]-f[h]})}function Du(t){if(ct(t)===hs)return[];var e=cr(t);return[Xs(t),e,Xs(e)]}function Pu(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,f=n.flipVariations,w=f===void 0?!0:f,h=n.allowedAutoPlacements,y=e.options.placement,m=ct(y),v=m===y,_=l||(v||!w?[cr(y)]:Du(y)),x=[y].concat(_).reduce(function(X,Y){return X.concat(ct(Y)===hs?Ou(e,{placement:Y,boundary:c,rootBoundary:d,padding:u,flipVariations:w,allowedAutoPlacements:h}):Y)},[]),k=e.rects.reference,O=e.rects.popper,E=new Map,N=!0,D=x[0],R=0;R=0,K=b?"width":"height",$=Rn(e,{placement:q,boundary:c,rootBoundary:d,altBoundary:p,padding:u}),A=b?T?et:$e:T?Qe:Ke;k[K]>O[K]&&(A=cr(A));var G=cr(A),L=[];if(s&&L.push($[P]<=0),a&&L.push($[A]<=0,$[G]<=0),L.every(function(X){return X})){D=q,N=!1;break}E.set(q,L)}if(N)for(var ne=w?3:1,z=function(Y){var me=x.find(function(ge){var ie=E.get(ge);if(ie)return ie.slice(0,Y).every(function(ue){return ue})});if(me)return D=me,"break"},B=ne;B>0;B--){var te=z(B);if(te==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const ju={name:"flip",enabled:!0,phase:"main",fn:Pu,requiresIfExists:["offset"],data:{_skip:!1}};function ea(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 ta(t){return[Ke,et,Qe,$e].some(function(e){return t[e]>=0})}function Au(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Rn(e,{elementContext:"reference"}),a=Rn(e,{altBoundary:!0}),l=ea(i,r),u=ea(a,o,s),c=ta(l),d=ta(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 Nu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Au};function Fu(t,e,n){var r=ct(t),o=[$e,Ke].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,[$e,et].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function Ru(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=Ya.reduce(function(c,d){return c[d]=Fu(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 Tu={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Ru};function Bu(t){var e=t.state,n=t.name;e.modifiersData[n]=ri({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Mu={name:"popperOffsets",enabled:!0,phase:"read",fn:Bu,data:{}};function zu(t){return t==="x"?"y":"x"}function Lu(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,f=p===void 0?!0:p,w=n.tetherOffset,h=w===void 0?0:w,y=Rn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),m=ct(e.placement),v=fn(e.placement),_=!v,x=ys(m),k=zu(x),O=e.modifiersData.popperOffsets,E=e.rects.reference,N=e.rects.popper,D=typeof h=="function"?h(Object.assign({},e.rects,{placement:e.placement})):h,R=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),q=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(O){if(s){var T,b=x==="y"?Ke:$e,K=x==="y"?Qe:et,$=x==="y"?"height":"width",A=O[x],G=A+y[b],L=A-y[K],ne=f?-N[$]/2:0,z=v===cn?E[$]:N[$],B=v===cn?-N[$]:-E[$],te=e.elements.arrow,X=f&&te?ms(te):{width:0,height:0},Y=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Qa(),me=Y[b],ge=Y[K],ie=Sn(0,E[$],X[$]),ue=_?E[$]/2-ne-ie-me-R.mainAxis:z-ie-me-R.mainAxis,be=_?-E[$]/2+ne+ie+ge+R.mainAxis:B+ie+ge+R.mainAxis,ye=e.elements.arrow&&$n(e.elements.arrow),pe=ye?x==="y"?ye.clientTop||0:ye.clientLeft||0:0,xe=(T=q==null?void 0:q[x])!=null?T:0,g=A+ue-xe-pe,U=A+be-xe,W=Sn(f?Sr(G,g):G,A,f?Wt(L,U):L);O[x]=W,P[x]=W-A}if(a){var I,S=x==="x"?Ke:$e,F=x==="x"?Qe:et,V=O[k],Z=k==="y"?"height":"width",M=V+y[S],Q=V-y[F],re=[Ke,$e].indexOf(m)!==-1,ee=(I=q==null?void 0:q[k])!=null?I:0,se=re?M:V-E[Z]-N[Z]-ee+R.altAxis,ve=re?V+E[Z]+N[Z]-ee-R.altAxis:Q,he=f&&re?uu(se,V,ve):Sn(f?se:M,V,f?ve:Q);O[k]=he,P[k]=he-V}e.modifiersData[r]=P}}const Wu={name:"preventOverflow",enabled:!0,phase:"main",fn:Lu,requiresIfExists:["offset"]};function Uu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Ku(t){return t===Ge(t)||!Xe(t)?vs(t):Uu(t)}function $u(t){var e=t.getBoundingClientRect(),n=un(e.width)/t.offsetWidth||1,r=un(e.height)/t.offsetHeight||1;return n!==1||r!==1}function Hu(t,e,n){n===void 0&&(n=!1);var r=Xe(e),o=Xe(e)&&$u(e),s=Rt(e),i=dn(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((ut(e)!=="body"||ws(s))&&(a=Ku(e)),Xe(e)?(l=dn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=gs(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function qu(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 Vu(t){var e=qu(t);return ou.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function Gu(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Zu(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 na={placement:"bottom",modifiers:[],strategy:"absolute"};function ra(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=j.useCallback(()=>{var R;!e||!w.current||!h.current||((R=v.current)==null||R.call(v),y.current=Xu(w.current,h.current,{placement:m,modifiers:[Kc,Lc,zc,{...Mc,enabled:!!p},{name:"eventListeners",...Bc(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}),y.current.forceUpdate(),v.current=y.current.destroy)},[m,e,n,p,i,s,a,l,u,d,c,o]);j.useEffect(()=>()=>{var R;!w.current&&!h.current&&((R=y.current)==null||R.destroy(),y.current=null)},[]);const x=j.useCallback(R=>{w.current=R,_()},[_]),k=j.useCallback((R={},q=null)=>({...R,ref:Be(x,q)}),[x]),O=j.useCallback(R=>{h.current=R,_()},[_]),E=j.useCallback((R={},q=null)=>({...R,ref:Be(O,q),style:{...R.style,position:o,minWidth:p?void 0:"max-content",inset:"0 auto auto 0"}}),[o,O,p]),N=j.useCallback((R={},q=null)=>{const{size:P,shadowColor:T,bg:b,style:K,...$}=R;return{...$,ref:q,"data-popper-arrow":"",style:Qu(R)}},[]),D=j.useCallback((R={},q=null)=>({...R,ref:q,"data-popper-arrow-inner":""}),[]);return{update(){var R;(R=y.current)==null||R.update()},forceUpdate(){var R;(R=y.current)==null||R.forceUpdate()},transformOrigin:Ae.transformOrigin.varRef,referenceRef:x,popperRef:O,getPopperProps:E,getArrowProps:N,getArrowInnerProps:D,getReferenceProps:k}}function Qu(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 _s(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=zt(n),i=zt(e),[a,l]=j.useState(t.defaultIsOpen||!1),u=r!==void 0?r:a,c=r!==void 0,d=j.useId(),p=o??`disclosure-${d}`,f=j.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),w=j.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),h=j.useCallback(()=>{u?f():w()},[u,w,f]);function y(v={}){return{...v,"aria-expanded":u,"aria-controls":p,onClick(_){var x;(x=v.onClick)==null||x.call(v,_),h()}}}function m(v={}){return{...v,hidden:!u,id:p}}return{isOpen:u,onOpen:w,onClose:f,onToggle:h,isControlled:c,getButtonProps:y,getDisclosureProps:m}}function ed(t){const{ref:e,handler:n,enabled:r=!0}=t,o=zt(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{lo(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&lo(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&lo(d,e)&&(i.isPointerDown=!1,o(d))},c=oi(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 lo(t,e){var n;const r=t.target;return r&&!oi(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function oi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function si(t){const{isOpen:e,ref:n}=t,[r,o]=j.useState(e),[s,i]=j.useState(!1);return j.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),rn(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=Ol(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function xs(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[td,nd,rd,od]=Fa(),[sd,Hn]=tt({strict:!1,name:"MenuContext"});function ad(t,...e){const n=j.useId(),r=t||n;return j.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function ai(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function oa(t){return ai(t).activeElement===t}function id(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:f,computePositionOnMount:w=!1,...h}=t,y=j.useRef(null),m=j.useRef(null),v=rd(),_=j.useCallback(()=>{requestAnimationFrame(()=>{var te;(te=y.current)==null||te.focus({preventScroll:!1})})},[]),x=j.useCallback(()=>{const te=setTimeout(()=>{var X;if(o)(X=o.current)==null||X.focus();else{const Y=v.firstEnabled();Y&&T(Y.index)}});G.current.add(te)},[v,o]),k=j.useCallback(()=>{const te=setTimeout(()=>{const X=v.lastEnabled();X&&T(X.index)});G.current.add(te)},[v]),O=j.useCallback(()=>{c==null||c(),s?x():_()},[s,x,_,c]),{isOpen:E,onOpen:N,onClose:D,onToggle:R}=_s({isOpen:a,defaultIsOpen:l,onClose:u,onOpen:O});ed({enabled:E&&r,ref:y,handler:te=>{var X;(X=m.current)!=null&&X.contains(te.target)||D()}});const q=bs({...h,enabled:E||w,placement:d,direction:f}),[P,T]=j.useState(-1);Vr(()=>{E||T(-1)},[E]),Ga(y,{focusRef:m,visible:E,shouldFocus:!0});const b=si({isOpen:E,ref:y}),[K,$]=ad(e,"menu-button","menu-list"),A=j.useCallback(()=>{N(),_()},[N,_]),G=j.useRef(new Set([]));j.useEffect(()=>{const te=G.current;return()=>{te.forEach(X=>clearTimeout(X)),te.clear()}},[]);const L=j.useCallback(()=>{N(),x()},[x,N]),ne=j.useCallback(()=>{N(),k()},[N,k]),z=j.useCallback(()=>{var te,X;const Y=ai(y.current),me=(te=y.current)==null?void 0:te.contains(Y.activeElement);if(!(E&&!me))return;const ie=(X=v.item(P))==null?void 0:X.node;ie==null||ie.focus({preventScroll:!0})},[E,P,v]),B=j.useRef(null);return{openAndFocusMenu:A,openAndFocusFirstItem:L,openAndFocusLastItem:ne,onTransitionEnd:z,unstable__animationState:b,descendants:v,popper:q,buttonId:K,menuId:$,forceUpdate:q.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:N,onClose:D,menuRef:y,buttonRef:m,focusedIndex:P,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:T,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:B}}function dp(t={},e=null){const n=Hn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=j.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:Be(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":at(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Se(t.onClick,r),onKeyDown:Se(t.onKeyDown,a)}}function So(t){var e;return ud(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function ld(t={},e=null){const n=Hn();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=nd(),f=Ic({preventDefault:m=>m.key!==" "&&So(m.target)}),w=j.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const v=m.key,x={Tab:O=>O.preventDefault(),Escape:a,ArrowDown:()=>{const O=p.nextEnabled(r);O&&o(O.index)},ArrowUp:()=>{const O=p.prevEnabled(r);O&&o(O.index)}}[v];if(x){m.preventDefault(),x(m);return}const k=f(O=>{const E=Oc(p.values(),O,N=>{var D,R;return(R=(D=N==null?void 0:N.node)==null?void 0:D.textContent)!=null?R:""},p.item(r));if(E){const N=p.indexOf(E.node);o(N)}});So(m.target)&&k(m)},[p,r,f,a,o]),h=j.useRef(!1);i&&(h.current=!0);const y=xs({wasSelected:h.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:Be(s,e),children:y?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:Se(t.onKeyDown,w)}}function cd(t={}){const{popper:e,isOpen:n}=Hn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function ii(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=Hn(),{setFocusedIndex:f,focusedIndex:w,closeOnSelect:h,onClose:y,menuRef:m,isOpen:v,menuId:_,rafId:x}=p,k=j.useRef(null),O=`${_}-menuitem-${j.useId()}`,{index:E,register:N}=od({disabled:a&&!l}),D=j.useCallback(A=>{n==null||n(A),!a&&f(E)},[f,E,a,n]),R=j.useCallback(A=>{r==null||r(A),k.current&&!oa(k.current)&&D(A)},[D,r]),q=j.useCallback(A=>{o==null||o(A),!a&&f(-1)},[f,a,o]),P=j.useCallback(A=>{s==null||s(A),So(A.currentTarget)&&(u??h)&&y()},[y,s,h,u]),T=j.useCallback(A=>{i==null||i(A),f(E)},[f,i,E]),b=E===w,K=a&&!l;Vr(()=>{if(v)return b&&!K&&k.current?(x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var A;(A=k.current)==null||A.focus({preventScroll:!0}),x.current=null})):m.current&&!oa(m.current)&&m.current.focus({preventScroll:!0}),()=>{x.current&&cancelAnimationFrame(x.current)}},[b,K,m,v]);const $=Va({onClick:P,onFocus:T,onMouseEnter:D,onMouseMove:R,onMouseLeave:q,ref:Be(N,k,e),isDisabled:a,isFocusable:l});return{...d,...$,type:c??$.type,id:O,role:"menuitem",tabIndex:b?0:-1}}function fp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...ii(o,e),role:`menuitem${n}`,"aria-checked":r}}function hp(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...i}=t,l=n==="radio"?"":[],[u,c]=Ra({defaultValue:o??l,value:r,onChange:s}),d=j.useCallback(w=>{if(n==="radio"&&typeof u=="string"&&c(w),n==="checkbox"&&Array.isArray(u)){const h=u.includes(w)?u.filter(y=>y!==w):u.concat(w);c(h)}},[u,c,n]),f=ds(e).map(w=>{if(w.type.id!=="MenuItemOption")return w;const h=m=>{var v,_;d(w.props.value),(_=(v=w.props).onClick)==null||_.call(v,m)},y=n==="radio"?w.props.value===u:u.includes(w.props.value);return j.cloneElement(w,{type:n,onClick:h,isChecked:y})});return{...i,children:f}}function ud(t){var e;if(!dd(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function dd(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[fd,Xr]=tt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),ks=t=>{const{children:e}=t,n=Nt("Menu",t),r=nt(t),{direction:o}=is(),{descendants:s,...i}=id({...r,direction:o}),a=j.useMemo(()=>i,[i]),{isOpen:l,onClose:u,forceUpdate:c}=a;return C.jsx(td,{value:s,children:C.jsx(sd,{value:a,children:C.jsx(fd,{value:n,children:ka(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};ks.displayName="Menu";var li=fe((t,e)=>{const n=Xr();return C.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});li.displayName="MenuCommand";var hd=fe((t,e)=>{const{type:n,...r}=t,o=Xr(),s=r.as||n?n??void 0:"button",i=j.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 C.jsx(de.button,{ref:e,type:s,...r,__css:i})}),ci=t=>{const{className:e,children:n,...r}=t,o=Xr(),s=j.Children.only(n),i=j.isValidElement(s)?j.cloneElement(s,{focusable:"false","aria-hidden":!0,className:_e("chakra-menu__icon",s.props.className)}):null,a=_e("chakra-menu__icon-wrapper",e);return C.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};ci.displayName="MenuIcon";var xt=fe((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=ii(a,e),c=n||o?C.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return C.jsxs(hd,{...l,className:_e("chakra-menu__menuitem",l.className),children:[n&&C.jsx(ci,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&C.jsx(li,{marginStart:s,children:o})]})});xt.displayName="MenuItem";var pd={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"}}},md=de(ls.div),Es=fe(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=Hn(),d=ld(a,n),p=cd(s),f=Xr();return C.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=f.list)==null?void 0:r.zIndex},children:C.jsx(md,{variants:pd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...f.list},...i,className:_e("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:Ea(c.onComplete,d.onAnimationComplete)})})});Es.displayName="MenuList";var[yd,qn]=tt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[vd,Cs]=tt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function ui(t){const e=j.Children.only(t.children),{getTriggerProps:n}=qn();return j.cloneElement(e,n(e.props,e.ref))}ui.displayName="PopoverTrigger";var Qt={click:"click",hover:"hover"};function gd(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:u=Qt.click,openDelay:c=200,closeDelay:d=200,isLazy:p,lazyBehavior:f="unmount",computePositionOnMount:w,...h}=t,{isOpen:y,onClose:m,onOpen:v,onToggle:_}=_s(t),x=j.useRef(null),k=j.useRef(null),O=j.useRef(null),E=j.useRef(!1),N=j.useRef(!1);y&&(N.current=!0);const[D,R]=j.useState(!1),[q,P]=j.useState(!1),T=j.useId(),b=o??T,[K,$,A,G]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${b}`),{referenceRef:L,getArrowProps:ne,getPopperProps:z,getArrowInnerProps:B,forceUpdate:te}=bs({...h,enabled:y||!!w}),X=si({isOpen:y,ref:O});uc({enabled:y,ref:k}),Ga(O,{focusRef:k,visible:y,shouldFocus:s&&u===Qt.click}),Ac(O,{focusRef:r,visible:y,shouldFocus:i&&u===Qt.click});const Y=xs({wasSelected:N.current,enabled:p,mode:f,isSelected:X.present}),me=j.useCallback((U={},W=null)=>{const I={...U,style:{...U.style,transformOrigin:Ae.transformOrigin.varRef,[Ae.arrowSize.var]:a?`${a}px`:void 0,[Ae.arrowShadowColor.var]:l},ref:Be(O,W),children:Y?U.children:null,id:$,tabIndex:-1,role:"dialog",onKeyDown:Se(U.onKeyDown,S=>{n&&S.key==="Escape"&&m()}),onBlur:Se(U.onBlur,S=>{const F=sa(S),V=co(O.current,F),Z=co(k.current,F);y&&e&&(!V&&!Z)&&m()}),"aria-labelledby":D?A:void 0,"aria-describedby":q?G:void 0};return u===Qt.hover&&(I.role="tooltip",I.onMouseEnter=Se(U.onMouseEnter,()=>{E.current=!0}),I.onMouseLeave=Se(U.onMouseLeave,S=>{S.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>m(),d))})),I},[Y,$,D,A,q,G,u,n,m,y,e,d,l,a]),ge=j.useCallback((U={},W=null)=>z({...U,style:{visibility:y?"visible":"hidden",...U.style}},W),[y,z]),ie=j.useCallback((U,W=null)=>({...U,ref:Be(W,x,L)}),[x,L]),ue=j.useRef(),be=j.useRef(),ye=j.useCallback(U=>{x.current==null&&L(U)},[L]),pe=j.useCallback((U={},W=null)=>{const I={...U,ref:Be(k,W,ye),id:K,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":$};return u===Qt.click&&(I.onClick=Se(U.onClick,_)),u===Qt.hover&&(I.onFocus=Se(U.onFocus,()=>{ue.current===void 0&&v()}),I.onBlur=Se(U.onBlur,S=>{const F=sa(S),V=!co(O.current,F);y&&e&&V&&m()}),I.onKeyDown=Se(U.onKeyDown,S=>{S.key==="Escape"&&m()}),I.onMouseEnter=Se(U.onMouseEnter,()=>{E.current=!0,ue.current=window.setTimeout(()=>v(),c)}),I.onMouseLeave=Se(U.onMouseLeave,()=>{E.current=!1,ue.current&&(clearTimeout(ue.current),ue.current=void 0),be.current=window.setTimeout(()=>{E.current===!1&&m()},d)})),I},[K,y,$,u,ye,_,v,e,m,c,d]);j.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current),be.current&&clearTimeout(be.current)},[]);const xe=j.useCallback((U={},W=null)=>({...U,id:A,ref:Be(W,I=>{R(!!I)})}),[A]),g=j.useCallback((U={},W=null)=>({...U,id:G,ref:Be(W,I=>{P(!!I)})}),[G]);return{forceUpdate:te,isOpen:y,onAnimationComplete:X.onComplete,onClose:m,getAnchorProps:ie,getArrowProps:ne,getArrowInnerProps:B,getPopoverPositionerProps:ge,getPopoverProps:me,getTriggerProps:pe,getHeaderProps:xe,getBodyProps:g}}function co(t,e){return t===e||(t==null?void 0:t.contains(e))}function sa(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function di(t){const e=Nt("Popover",t),{children:n,...r}=nt(t),o=is(),s=gd({...r,direction:o.direction});return C.jsx(yd,{value:s,children:C.jsx(vd,{value:e,children:ka(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}di.displayName="Popover";var fi=fe(function(e,n){const{getBodyProps:r}=qn(),o=Cs();return C.jsx(de.div,{...r(e,n),className:_e("chakra-popover__body",e.className),__css:o.body})});fi.displayName="PopoverBody";var hi=fe(function(e,n){const{onClose:r}=qn(),o=Cs();return C.jsx(Dl,{size:"sm",onClick:r,className:_e("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});hi.displayName="PopoverCloseButton";function wd(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var bd={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]}}},_d=de(ls.section),pi=fe(function(e,n){const{variants:r=bd,...o}=e,{isOpen:s}=qn();return C.jsx(_d,{ref:n,variants:wd(r),initial:!1,animate:s?"enter":"exit",...o})});pi.displayName="PopoverTransition";var mi=fe(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=qn(),u=Cs(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return C.jsx(de.div,{...a(r),__css:u.popper,className:"chakra-popover__popper",children:C.jsx(pi,{...o,...i(s,n),onAnimationComplete:Ea(l,s.onAnimationComplete),className:_e("chakra-popover__content",e.className),__css:c})})});mi.displayName="PopoverContent";var[xd,kd,Ed,Cd]=Fa();function Sd(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]=j.useState(n??0),[f,w]=Ra({defaultValue:n??0,value:o,onChange:r});j.useEffect(()=>{o!=null&&p(o)},[o]);const h=Ed(),y=j.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:f,focusedIndex:d,setSelectedIndex:w,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:h,direction:u,htmlProps:c}}var[Id,Qr]=tt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function Od(t){const{focusedIndex:e,orientation:n,direction:r}=Qr(),o=kd(),s=j.useCallback(i=>{const a=()=>{var v;const _=o.nextEnabled(e);_&&((v=_.node)==null||v.focus())},l=()=>{var v;const _=o.prevEnabled(e);_&&((v=_.node)==null||v.focus())},u=()=>{var v;const _=o.firstEnabled();_&&((v=_.node)==null||v.focus())},c=()=>{var v;const _=o.lastEnabled();_&&((v=_.node)==null||v.focus())},d=n==="horizontal",p=n==="vertical",f=i.key,w=r==="ltr"?"ArrowLeft":"ArrowRight",h=r==="ltr"?"ArrowRight":"ArrowLeft",m={[w]:()=>d&&l(),[h]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:u,End:c}[f];m&&(i.preventDefault(),m(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Se(t.onKeyDown,s)}}function Dd(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=Qr(),{index:u,register:c}=Cd({disabled:e&&!n}),d=u===l,p=()=>{o(u)},f=()=>{a(u),!s&&!(e&&n)&&o(u)},w=Va({...r,ref:Be(c,t.ref),isDisabled:e,isFocusable:n,onClick:Se(t.onClick,p)}),h="button";return{...w,id:yi(i,u),role:"tab",tabIndex:d?0:-1,type:h,"aria-selected":d,"aria-controls":vi(i,u),onFocus:e?void 0:Se(t.onFocus,f)}}var[Pd,jd]=tt({});function Ad(t){const e=Qr(),{id:n,selectedIndex:r}=e,s=ds(t.children).map((i,a)=>j.createElement(Pd,{key:a,value:{isSelected:a===r,id:vi(n,a),tabId:yi(n,a),selectedIndex:r}},i));return{...t,children:s}}function Nd(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Qr(),{isSelected:s,id:i,tabId:a}=jd(),l=j.useRef(!1);s&&(l.current=!0);const u=xs({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 yi(t,e){return`${t}--tab-${e}`}function vi(t,e){return`${t}--tabpanel-${e}`}var[Fd,eo]=tt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),gi=fe(function(e,n){const r=Nt("Tabs",e),{children:o,className:s,...i}=nt(e),{htmlProps:a,descendants:l,...u}=Sd(i),c=j.useMemo(()=>u,[u]),{isFitted:d,...p}=a,f={position:"relative",...r.root};return C.jsx(xd,{value:l,children:C.jsx(Id,{value:c,children:C.jsx(Fd,{value:r,children:C.jsx(de.div,{className:_e("chakra-tabs",s),ref:n,...p,__css:f,children:o})})})})});gi.displayName="Tabs";var wi=fe(function(e,n){const r=Od({...e,ref:n}),s={display:"flex",...eo().tablist};return C.jsx(de.div,{...r,className:_e("chakra-tabs__tablist",e.className),__css:s})});wi.displayName="TabList";var Io=fe(function(e,n){const r=Nd({...e,ref:n}),o=eo();return C.jsx(de.div,{outline:"0",...r,className:_e("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Io.displayName="TabPanel";var bi=fe(function(e,n){const r=Ad(e),o=eo();return C.jsx(de.div,{...r,width:"100%",ref:n,className:_e("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});bi.displayName="TabPanels";var Oo=fe(function(e,n){const r=eo(),o=Dd({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return C.jsx(de.button,{...o,className:_e("chakra-tabs__tab",e.className),__css:s})});Oo.displayName="Tab";var[Rd,_i]=tt({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),to=fe((t,e)=>{const n=Nt("Tag",t),r=nt(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return C.jsx(Rd,{value:n,children:C.jsx(de.span,{ref:e,...r,__css:o})})});to.displayName="Tag";var Td=fe((t,e)=>{const n=_i();return C.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});Td.displayName="TagLabel";var Bd=fe((t,e)=>C.jsx(Hr,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));Bd.displayName="TagLeftIcon";var Md=fe((t,e)=>C.jsx(Hr,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));Md.displayName="TagRightIcon";var xi=t=>C.jsx(Hr,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:C.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"})});xi.displayName="TagCloseIcon";var zd=fe((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",..._i().closeButton};return C.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||C.jsx(xi,{})})});zd.displayName="TagCloseButton";var Ld={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]}}}},Do=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},ur=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function Wd(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:f,arrowSize:w=10,arrowShadowColor:h,arrowPadding:y,modifiers:m,isDisabled:v,gutter:_,offset:x,direction:k,...O}=t,{isOpen:E,onOpen:N,onClose:D}=_s({isOpen:p,defaultIsOpen:f,onOpen:l,onClose:u}),{referenceRef:R,getPopperProps:q,getArrowInnerProps:P,getArrowProps:T}=bs({enabled:E,placement:c,arrowPadding:y,modifiers:m,gutter:_,offset:x,direction:k}),b=j.useId(),$=`tooltip-${d??b}`,A=j.useRef(null),G=j.useRef(),L=j.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=void 0)},[]),ne=j.useRef(),z=j.useCallback(()=>{ne.current&&(clearTimeout(ne.current),ne.current=void 0)},[]),B=j.useCallback(()=>{z(),D()},[D,z]),te=Ud(A,B),X=j.useCallback(()=>{if(!v&&!G.current){E&&te();const pe=ur(A);G.current=pe.setTimeout(N,e)}},[te,v,E,N,e]),Y=j.useCallback(()=>{L();const pe=ur(A);ne.current=pe.setTimeout(B,n)},[n,B,L]),me=j.useCallback(()=>{E&&r&&Y()},[r,Y,E]),ge=j.useCallback(()=>{E&&i&&Y()},[i,Y,E]),ie=j.useCallback(pe=>{E&&pe.key==="Escape"&&Y()},[E,Y]);rn(()=>Do(A),"keydown",a?ie:void 0),rn(()=>{if(!s)return null;const pe=A.current;if(!pe)return null;const xe=$a(pe);return xe.localName==="body"?ur(A):xe},"scroll",()=>{E&&s&&B()},{passive:!0,capture:!0}),j.useEffect(()=>{v&&(L(),E&&D())},[v,E,D,L]),j.useEffect(()=>()=>{L(),z()},[L,z]),rn(()=>A.current,"pointerleave",Y);const ue=j.useCallback((pe={},xe=null)=>({...pe,ref:Be(A,xe,R),onPointerEnter:Se(pe.onPointerEnter,U=>{U.pointerType!=="touch"&&X()}),onClick:Se(pe.onClick,me),onPointerDown:Se(pe.onPointerDown,ge),onFocus:Se(pe.onFocus,X),onBlur:Se(pe.onBlur,Y),"aria-describedby":E?$:void 0}),[X,Y,ge,E,$,me,R]),be=j.useCallback((pe={},xe=null)=>q({...pe,style:{...pe.style,[Ae.arrowSize.var]:w?`${w}px`:void 0,[Ae.arrowShadowColor.var]:h}},xe),[q,w,h]),ye=j.useCallback((pe={},xe=null)=>{const g={...pe.style,position:"relative",transformOrigin:Ae.transformOrigin.varRef};return{ref:xe,...O,...pe,id:$,role:"tooltip",style:g}},[O,$]);return{isOpen:E,show:X,hide:Y,getTriggerProps:ue,getTooltipProps:ye,getTooltipPositionerProps:be,getArrowProps:T,getArrowInnerProps:P}}var uo="chakra-ui:close-tooltip";function Ud(t,e){return j.useEffect(()=>{const n=Do(t);return n.addEventListener(uo,e),()=>n.removeEventListener(uo,e)},[e,t]),()=>{const n=Do(t),r=ur(t);n.dispatchEvent(new r.CustomEvent(uo))}}function Kd(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function $d(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var Hd=de(ls.div),Vt=fe((t,e)=>{var n,r;const o=qr("Tooltip",t),s=nt(t),i=is(),{children:a,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:p,portalProps:f,background:w,backgroundColor:h,bgColor:y,motionProps:m,...v}=s,_=(r=(n=w??h)!=null?n:p)!=null?r:y;if(_){o.bg=_;const q=Pl(i,"colors",_);o[Ae.arrowBg.var]=q}const x=Wd({...v,direction:i.direction}),k=typeof a=="string"||u;let O;if(k)O=C.jsx(de.span,{display:"inline-block",tabIndex:0,...x.getTriggerProps(),children:a});else{const q=j.Children.only(a);O=j.cloneElement(q,x.getTriggerProps(q.props,q.ref))}const E=!!c,N=x.getTooltipProps({},e),D=E?Kd(N,["role","id"]):N,R=$d(N,["role","id"]);return l?C.jsxs(C.Fragment,{children:[O,C.jsx(jl,{children:x.isOpen&&C.jsx(Ca,{...f,children:C.jsx(de.div,{...x.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:C.jsxs(Hd,{variants:Ld,initial:"exit",animate:"enter",exit:"exit",...m,...D,__css:o,children:[l,E&&C.jsx(de.span,{srOnly:!0,...R,children:c}),d&&C.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:C.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):C.jsx(C.Fragment,{children:a})});Vt.displayName="Tooltip";const qd="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let hn=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=qd[n[t]&63];return e},Pe=null;const ki=location.pathname.split("/").slice(0,-1).join("/");let Ir=null;Ft(()=>import(ki+"/scripts/api.js"),__vite__mapDeps([])).then(t=>{Ir=t==null?void 0:t.api});Ft(()=>import(ki+"/scripts/app.js"),__vite__mapDeps([])).then(t=>{Pe=t==null?void 0:t.app});function ke(t,e){if(Ir==null)throw console.error("api is null!"),new Error("api is null!");return Ir.fetchApi(t,e)}async function Vd(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await ke(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function Gd(t,e){try{return await(await ke("/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 pp(t){try{return await(await ke("/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 mp(){try{return await(await ke("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function Zd(){const e=await(await ke("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function yp(){try{return await(await ke("/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 vp(){try{return await(await ke("/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 gp(t){try{return await(await ke("/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 wp(t,e){try{return await(await ke("/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 Yd="backup",Or="workspace";let er=null;function Jd(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(Or)||o.createObjectStore(Or,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Xd(){try{return er==null&&(er=await Jd()),new Promise((t,e)=>{if(er==null)return e("indexDB is null");const o=er.transaction([Or],"readonly").objectStore(Or).get(Yd);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 Qd(){try{return await Xd()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const Ee=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"||Ee.Promise||(Ee.Promise=Promise);const Tn=Object.getPrototypeOf,ef={}.hasOwnProperty;function Ze(t,e){return ef.call(t,e)}function pn(t,e){typeof e=="function"&&(e=e(Tn(t))),(typeof Reflect>"u"?Ne:Reflect.ownKeys)(e).forEach(n=>{gt(t,n,e[n])})}const Ei=Object.defineProperty;function gt(t,e,n,r){Ei(t,e,Ue(n&&Ze(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function sn(t){return{from:function(e){return t.prototype=Object.create(e.prototype),gt(t.prototype,"constructor",t),{extend:pn.bind(null,t.prototype)}}}}const tf=Object.getOwnPropertyDescriptor;function Ss(t,e){let n;return tf(t,e)||(n=Tn(t))&&Ss(n,e)}const nf=[].slice;function Dr(t,e,n){return nf.call(t,e,n)}function Ci(t,e){return e(t)}function En(t){if(!t)throw new Error("Assertion Failed")}function Si(t){Ee.setImmediate?setImmediate(t):setTimeout(t,0)}function Ii(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function wt(t,e){if(Ze(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=>Ee[t]),of=Pi.map(t=>Ee[t]);Ii(Pi,t=>[t,!0]);let Et=null;function Vn(t){Et=typeof WeakMap<"u"&&new WeakMap;const e=Po(t);return Et=null,e}function Po(t){if(!t||typeof t!="object")return t;let e=Et&&Et.get(t);if(e)return e;if(ze(t)){e=[],Et&&Et.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=Tn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),Et&&Et.set(t,e),t)Ze(t,o)&&(e[o]=Po(t[o]))}return e}const{toString:sf}={};function jo(t){return sf.call(t).slice(8,-1)}const Ao=typeof Symbol<"u"?Symbol.iterator:"@@iterator",af=typeof Ao=="symbol"?function(t){var e;return t!=null&&(e=t[Ao])&&e.apply(t)}:function(){return null},nn={};function yt(t){var e,n,r,o;if(arguments.length===1){if(ze(t))return t.slice();if(this===nn&&typeof t=="string")return[t];if(o=af(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 Is=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var dt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ji(t,e){dt=t,Ai=e}var Ai=()=>!0;const lf=!new Error("").stack;function Yt(){if(lf)try{throw Yt.arguments,new Error}catch(t){return t}return new Error}function No(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` +var pl=Object.defineProperty;var ml=(t,e,n)=>e in t?pl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(ml(t,typeof e!="symbol"?e+"":e,n),n);import{u as yl,a as vl,r as j,c as gl,b as tt,m as Be,d as zt,f as fe,e as _e,j as C,B as wl,g as de,h as Le,i as bl,o as nt,k as Nt,l as at,I as Hr,n as qr,p as so,q as Se,s as ka,t as _l,v as xl,w as kl,x as Vr,y as El,z as Cl,A as Sl,C as Il,D as Ol,E as is,F as Ea,G as ls,H as Ca,J as Dl,K as Pl,L as jl,P as Sa,_ as Ft,M as xr,N as kr,O as Er,Q as cs,R as us,S as Ia,T as Oa,U as Da,V as Pa,W as Xn,X as ja}from"./input.js";function Al(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function Aa(t){var e;return Al(t)&&(e=t.ownerDocument)!=null?e:document}function Nl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Fl=Nl();function Rl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function ds(t){const{theme:e}=yl(),n=vl();return j.useMemo(()=>gl(e.direction,{...n,...t}),[t,e.direction,n])}var Tl=Object.defineProperty,Bl=(t,e,n)=>e in t?Tl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Oe=(t,e,n)=>(Bl(t,typeof e!="symbol"?e+"":e,n),n);function $s(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 Ml=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Hs(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function qs(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var _o=typeof window<"u"?j.useLayoutEffect:j.useEffect,Cr=t=>t,zl=class{constructor(){Oe(this,"descendants",new Map),Oe(this,"register",t=>{if(t!=null)return Ml(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),Oe(this,"unregister",t=>{this.descendants.delete(t);const e=$s(Array.from(this.descendants.keys()));this.assignIndex(e)}),Oe(this,"destroy",()=>{this.descendants.clear()}),Oe(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),Oe(this,"count",()=>this.descendants.size),Oe(this,"enabledCount",()=>this.enabledValues().length),Oe(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),Oe(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),Oe(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),Oe(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),Oe(this,"first",()=>this.item(0)),Oe(this,"firstEnabled",()=>this.enabledItem(0)),Oe(this,"last",()=>this.item(this.descendants.size-1)),Oe(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),Oe(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),Oe(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),Oe(this,"next",(t,e=!0)=>{const n=Hs(t,this.count(),e);return this.item(n)}),Oe(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Hs(r,this.enabledCount(),e);return this.enabledItem(o)}),Oe(this,"prev",(t,e=!0)=>{const n=qs(t,this.count()-1,e);return this.item(n)}),Oe(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=qs(r,this.enabledCount()-1,e);return this.enabledItem(o)}),Oe(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=$s(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 Ll(){const t=j.useRef(new zl);return _o(()=>()=>t.current.destroy()),t.current}var[Wl,Na]=tt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Ul(t){const e=Na(),[n,r]=j.useState(-1),o=j.useRef(null);_o(()=>()=>{o.current&&e.unregister(o.current)},[]),_o(()=>{if(!o.current)return;const i=Number(o.current.dataset.index);n!=i&&!Number.isNaN(i)&&r(i)});const s=Cr(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Be(s,o)}}function Fa(){return[Cr(Wl),()=>Cr(Na()),()=>Ll(),o=>Ul(o)]}function Ra(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,f)=>p!==f}=t,s=zt(r),i=zt(o),[a,l]=j.useState(n),u=e!==void 0,c=u?e:a,d=zt(p=>{const w=typeof p=="function"?p(c):p;i(c,w)&&(u||l(w),s(w))},[u,s,c,i]);return[c,d]}function fs(t){return j.Children.toArray(t).filter(e=>j.isValidElement(e))}var Kl={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}}},$l={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},Ta=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),f=j.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:u}),[r,o,s,u]);let w={display:"inline-flex",...l?Kl[c]:$l[c](a)};const h=c==="vertical";return C.jsx(wl,{value:f,children:C.jsx(de.div,{ref:n,role:"group",__css:w,className:p,"data-attached":l?"":void 0,"data-orientation":c,flexDir:h?"column":void 0,...d})})});Ta.displayName="ButtonGroup";var Nn=fe((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=j.isValidElement(a)?j.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return C.jsx(Le,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});Nn.displayName="IconButton";var[Hl,Ba]=bl("Card"),ql=fe(function(e,n){const{className:r,...o}=e,s=Ba();return C.jsx(de.div,{ref:n,className:_e("chakra-card__body",r),__css:s.body,...o})}),Vl=fe(function(e,n){const{className:r,...o}=e,s=Ba();return C.jsx(de.div,{ref:n,className:_e("chakra-card__header",r),__css:s.header,...o})}),Gl=fe(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=nt(e),u=Nt("Card",e);return C.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:C.jsx(Hl,{value:u,children:o})})}),[Zl,Ma]=tt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Yl,mn]=tt({strict:!1,name:"FormControlContext"});function Jl(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=j.useId(),l=e||`field-${a}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[p,f]=j.useState(!1),[w,h]=j.useState(!1),[y,m]=j.useState(!1),v=j.useCallback((E={},N=null)=>({id:d,...E,ref:Be(N,D=>{D&&h(!0)})}),[d]),_=j.useCallback((E={},N=null)=>({...E,ref:N,"data-focus":at(y),"data-disabled":at(o),"data-invalid":at(r),"data-readonly":at(s),id:E.id!==void 0?E.id:u,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,y,r,s,u]),x=j.useCallback((E={},N=null)=>({id:c,...E,ref:Be(N,D=>{D&&f(!0)}),"aria-live":"polite"}),[c]),k=j.useCallback((E={},N=null)=>({...E,...i,ref:N,role:"group","data-focus":at(y),"data-disabled":at(o),"data-invalid":at(r),"data-readonly":at(s)}),[i,o,y,r,s]),O=j.useCallback((E={},N=null)=>({...E,ref:N,role:"presentation","aria-hidden":!0,children:E.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!y,onFocus:()=>m(!0),onBlur:()=>m(!1),hasFeedbackText:p,setHasFeedbackText:f,hasHelpText:w,setHasHelpText:h,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:i,getHelpTextProps:v,getErrorMessageProps:x,getRootProps:k,getLabelProps:_,getRequiredIndicatorProps:O}}var Gr=fe(function(e,n){const r=Nt("Form",e),o=nt(e),{getRootProps:s,htmlProps:i,...a}=Jl(o),l=_e("chakra-form-control",e.className);return C.jsx(Yl,{value:a,children:C.jsx(Zl,{value:r,children:C.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});Gr.displayName="FormControl";var Xl=fe(function(e,n){const r=mn(),o=Ma(),s=_e("chakra-form__helper-text",e.className);return C.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});Xl.displayName="FormHelperText";var[Ql,ec]=tt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Zr=fe((t,e)=>{const n=Nt("FormError",t),r=nt(t),o=mn();return o!=null&&o.isInvalid?C.jsx(Ql,{value:n,children:C.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});Zr.displayName="FormErrorMessage";var tc=fe((t,e)=>{const n=ec(),r=mn();if(!(r!=null&&r.isInvalid))return null;const o=_e("chakra-form__error-icon",t.className);return C.jsx(Hr,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:C.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"})})});tc.displayName="FormErrorIcon";var Yr=fe(function(e,n){var r;const o=qr("FormLabel",e),s=nt(e),{className:i,children:a,requiredIndicator:l=C.jsx(za,{}),optionalIndicator:u=null,...c}=s,d=mn(),p=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return C.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]})});Yr.displayName="FormLabel";var za=fe(function(e,n){const r=mn(),o=Ma();if(!(r!=null&&r.isRequired))return null;const s=_e("chakra-form__required-indicator",e.className);return C.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});za.displayName="RequiredIndicator";function nc(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=rc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":so(n),"aria-required":so(o),"aria-readonly":so(r)}}function rc(t){var e,n,r;const o=mn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:p,onFocus:f,onBlur:w,...h}=t,y=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&y.push(o.feedbackId),o!=null&&o.hasHelpText&&y.push(o.helpTextId),{...h,"aria-describedby":y.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:Se(o==null?void 0:o.onFocus,f),onBlur:Se(o==null?void 0:o.onBlur,w)}}function rn(t,e,n,r){const o=zt(n);return j.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 oc(t){return"current"in t}var La=()=>typeof window<"u";function sc(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var ac=t=>La()&&t.test(navigator.vendor),ic=t=>La()&&t.test(sc()),lc=()=>ic(/mac|iphone|ipad|ipod/i),cc=()=>lc()&&ac(/apple/i);function uc(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};rn(o,"pointerdown",s=>{if(!cc()||!r)return;const i=s.target,l=(n??[e]).some(u=>{const c=oc(u)?u.current:u;return(c==null?void 0:c.contains(i))||c===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var Wa={exports:{}},dc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",fc=dc,hc=fc;function Ua(){}function Ka(){}Ka.resetWarningCache=Ua;var pc=function(){function t(r,o,s,i,a,l){if(l!==hc){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:Ka,resetWarningCache:Ua};return n.PropTypes=n,n};Wa.exports=pc();var mc=Wa.exports;const Tt=ka(mc);function yc(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 vc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function $a(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:_l(t)&&yc(t)?t:$a(vc(t))}var gc=Fl?j.useLayoutEffect:j.useEffect;function xo(t,e=[]){const n=j.useRef(t);return gc(()=>{n.current=t}),j.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function wc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=xo(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{ao(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&ao(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&ao(d,e)&&(i.isPointerDown=!1,o(d))},c=Aa(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 ao(t,e){var n;const r=t.target;return r&&!Aa(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function bc(t,e){const n=j.useId();return j.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function _c(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function xc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=xo(n),i=xo(e),[a,l]=j.useState(t.defaultIsOpen||!1),[u,c]=_c(r,a),d=bc(o,"disclosure"),p=j.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),f=j.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),w=j.useCallback(()=>{(c?p:f)()},[c,f,p]);return{isOpen:!!c,onOpen:f,onClose:p,onToggle:w,isControlled:u,getButtonProps:(h={})=>({...h,"aria-expanded":c,"aria-controls":d,onClick:xl(h.onClick,w)}),getDisclosureProps:(h={})=>({...h,hidden:!c,id:d})}}var yn=fe(function(e,n){const{htmlSize:r,...o}=e,s=Nt("Input",o),i=nt(o),a=nc(i),l=_e("chakra-input",e.className);return C.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});yn.displayName="Input";yn.id="Input";function kc(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):kl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}var mt=fe(function(e,n){const r=qr("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=nt(e),u=Rl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return C.jsx(de.p,{ref:n,className:_e("chakra-text",e.className),...u,...l,__css:r})});mt.displayName="Text";var ko=t=>C.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});ko.displayName="StackDivider";var Ha=t=>C.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});Ha.displayName="StackItem";function Ec(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{"&":kc(n,o=>r[o])}}var It=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,f=n?"row":r??"column",w=j.useMemo(()=>Ec({spacing:i,direction:f}),[i,f]),h=!!u,y=!d&&!h,m=j.useMemo(()=>{const _=fs(l);return y?_:_.map((x,k)=>{const O=typeof x.key<"u"?x.key:k,E=k+1===_.length,D=d?C.jsx(Ha,{children:x},O):x;if(!h)return D;const R=j.cloneElement(u,{__css:w}),q=E?null:R;return C.jsxs(j.Fragment,{children:[D,q]},O)})},[u,w,h,y,d,l]),v=_e("chakra-stack",c);return C.jsx(de.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:f,flexWrap:a,gap:h?void 0:i,className:v,...p,children:m})});It.displayName="Stack";var Lt=fe((t,e)=>C.jsx(It,{align:"center",...t,direction:"row",ref:e}));Lt.displayName="HStack";var hs=fe(function(e,n){const r=qr("Heading",e),{className:o,...s}=nt(e);return C.jsx(de.h2,{ref:n,className:_e("chakra-heading",e.className),...s,__css:r})});hs.displayName="Heading";var Ot=de("div");Ot.displayName="Box";var qa=fe(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return C.jsx(Ot,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});qa.displayName="Square";var Cc=fe(function(e,n){const{size:r,...o}=e;return C.jsx(qa,{size:r,ref:n,borderRadius:"9999px",...o})});Cc.displayName="Circle";var on=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 C.jsx(de.div,{ref:n,__css:d,...c})});on.displayName="Flex";function Sc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Ic(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=j.useState([]),s=j.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};j.useEffect(()=>i,[]);function l(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Sc(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),a()}}}return l}function Oc(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 Dc(){const t=j.useRef(new Map),e=t.current,n=j.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=j.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return j.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function io(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Va(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:f,...w}=t,[h,y]=j.useState(!0),[m,v]=j.useState(!1),_=Dc(),x=A=>{A&&A.tagName!=="BUTTON"&&y(!1)},k=h?d:d||0,O=n&&!r,E=j.useCallback(A=>{if(n){A.stopPropagation(),A.preventDefault();return}A.currentTarget.focus(),l==null||l(A)},[n,l]),N=j.useCallback(A=>{m&&io(A)&&(A.preventDefault(),A.stopPropagation(),v(!1),_.remove(document,"keyup",N,!1))},[m,_]),D=j.useCallback(A=>{if(u==null||u(A),n||A.defaultPrevented||A.metaKey||!io(A.nativeEvent)||h)return;const G=o&&A.key==="Enter";s&&A.key===" "&&(A.preventDefault(),v(!0)),G&&(A.preventDefault(),A.currentTarget.click()),_.add(document,"keyup",N,!1)},[n,h,u,o,s,_,N]),R=j.useCallback(A=>{if(c==null||c(A),n||A.defaultPrevented||A.metaKey||!io(A.nativeEvent)||h)return;s&&A.key===" "&&(A.preventDefault(),v(!1),A.currentTarget.click())},[s,h,n,c]),q=j.useCallback(A=>{A.button===0&&(v(!1),_.remove(document,"mouseup",q,!1))},[_]),P=j.useCallback(A=>{if(A.button!==0)return;if(n){A.stopPropagation(),A.preventDefault();return}h||v(!0),A.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",q,!1),i==null||i(A)},[n,h,i,_,q]),T=j.useCallback(A=>{A.button===0&&(h||v(!1),a==null||a(A))},[a,h]),b=j.useCallback(A=>{if(n){A.preventDefault();return}p==null||p(A)},[n,p]),K=j.useCallback(A=>{m&&(A.preventDefault(),v(!1)),f==null||f(A)},[m,f]),$=Be(e,x);return h?{...w,ref:$,type:"button","aria-disabled":O?void 0:n,disabled:O,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:c,onKeyDown:u,onMouseOver:p,onMouseLeave:f}:{...w,ref:$,role:"button","data-active":at(m),"aria-disabled":n?"true":void 0,tabIndex:O?void 0:k,onClick:E,onMouseDown:P,onMouseUp:T,onKeyUp:R,onKeyDown:D,onMouseOver:b,onMouseLeave:K}}function Pc(t){const e=t.current;if(!e)return!1;const n=Sl(e);return!n||e.contains(n)?!1:!!Il(n)}function Ga(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;Vr(()=>{if(!s||Pc(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 Ac(t,e=jc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=Nc(t)?t.current:t,a=o&&s,l=j.useRef(a),u=j.useRef(s);El(()=>{!u.current&&s&&(l.current=a),u.current=s},[s,a]);const c=j.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=Cl(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);Vr(()=>{c()},[c]),rn(i,"transitionend",c)}function Nc(t){return"current"in t}var Xt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),Ae={arrowShadowColor:Xt("--popper-arrow-shadow-color"),arrowSize:Xt("--popper-arrow-size","8px"),arrowSizeHalf:Xt("--popper-arrow-size-half"),arrowBg:Xt("--popper-arrow-bg"),transformOrigin:Xt("--popper-transform-origin"),arrowOffset:Xt("--popper-arrow-offset")};function Fc(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 Rc={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"},Tc=t=>Rc[t],Vs={scroll:!0,resize:!0};function Bc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Vs,...t}}:e={enabled:t,options:Vs},e}var Mc={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`}},zc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{Gs(t)},effect:({state:t})=>()=>{Gs(t)}},Gs=t=>{t.elements.popper.style.setProperty(Ae.transformOrigin.var,Tc(t.placement))},Lc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{Wc(t)}},Wc=t=>{var e;if(!t.placement)return;const n=Uc(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])}},Uc=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}},Kc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{Zs(t)},effect:({state:t})=>()=>{Zs(t)}},Zs=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Fc(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))"})},$c={"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"}},Hc={"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 qc(t,e="ltr"){var n,r;const o=((n=$c[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=Hc[t])!=null?r:o}var Ke="top",Qe="bottom",et="right",$e="left",ps="auto",Kn=[Ke,Qe,et,$e],cn="start",Fn="end",Vc="clippingParents",Za="viewport",xn="popper",Gc="reference",Ys=Kn.reduce(function(t,e){return t.concat([e+"-"+cn,e+"-"+Fn])},[]),Ya=[].concat(Kn,[ps]).reduce(function(t,e){return t.concat([e,e+"-"+cn,e+"-"+Fn])},[]),Zc="beforeRead",Yc="read",Jc="afterRead",Xc="beforeMain",Qc="main",eu="afterMain",tu="beforeWrite",nu="write",ru="afterWrite",ou=[Zc,Yc,Jc,Xc,Qc,eu,tu,nu,ru];function ut(t){return t?(t.nodeName||"").toLowerCase():null}function Ge(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=Ge(t).Element;return t instanceof e||t instanceof Element}function Xe(t){var e=Ge(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ms(t){if(typeof ShadowRoot>"u")return!1;var e=Ge(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function su(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];!Xe(s)||!ut(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 au(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},{});!Xe(o)||!ut(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const iu={name:"applyStyles",enabled:!0,phase:"write",fn:su,effect:au,requires:["computeStyles"]};function ct(t){return t.split("-")[0]}var Wt=Math.max,Sr=Math.min,un=Math.round;function Eo(){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 Ja(){return!/^((?!chrome|android).)*safari/i.test(Eo())}function dn(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Xe(t)&&(o=t.offsetWidth>0&&un(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&un(r.height)/t.offsetHeight||1);var i=qt(t)?Ge(t):window,a=i.visualViewport,l=!Ja()&&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 ys(t){var e=dn(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 Xa(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&ms(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function bt(t){return Ge(t).getComputedStyle(t)}function lu(t){return["table","td","th"].indexOf(ut(t))>=0}function Rt(t){return((qt(t)?t.ownerDocument:t.document)||window.document).documentElement}function Jr(t){return ut(t)==="html"?t:t.assignedSlot||t.parentNode||(ms(t)?t.host:null)||Rt(t)}function Js(t){return!Xe(t)||bt(t).position==="fixed"?null:t.offsetParent}function cu(t){var e=/firefox/i.test(Eo()),n=/Trident/i.test(Eo());if(n&&Xe(t)){var r=bt(t);if(r.position==="fixed")return null}var o=Jr(t);for(ms(o)&&(o=o.host);Xe(o)&&["html","body"].indexOf(ut(o))<0;){var s=bt(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 $n(t){for(var e=Ge(t),n=Js(t);n&&lu(n)&&bt(n).position==="static";)n=Js(n);return n&&(ut(n)==="html"||ut(n)==="body"&&bt(n).position==="static")?e:n||cu(t)||e}function vs(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Sn(t,e,n){return Wt(t,Sr(e,n))}function uu(t,e,n){var r=Sn(t,e,n);return r>n?n:r}function Qa(){return{top:0,right:0,bottom:0,left:0}}function ei(t){return Object.assign({},Qa(),t)}function ti(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var du=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,ei(typeof e!="number"?e:ti(e,Kn))};function fu(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=ct(n.placement),l=vs(a),u=[$e,et].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!i)){var d=du(o.padding,n),p=ys(s),f=l==="y"?Ke:$e,w=l==="y"?Qe:et,h=n.rects.reference[c]+n.rects.reference[l]-i[l]-n.rects.popper[c],y=i[l]-n.rects.reference[l],m=$n(s),v=m?l==="y"?m.clientHeight||0:m.clientWidth||0:0,_=h/2-y/2,x=d[f],k=v-p[c]-d[w],O=v/2-p[c]/2+_,E=Sn(x,O,k),N=l;n.modifiersData[r]=(e={},e[N]=E,e.centerOffset=E-O,e)}}function hu(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)||Xa(e.elements.popper,o)&&(e.elements.arrow=o))}const pu={name:"arrow",enabled:!0,phase:"main",fn:fu,effect:hu,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function fn(t){return t.split("-")[1]}var mu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function yu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:un(n*o)/o||0,y:un(r*o)/o||0}}function Xs(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,f=p===void 0?0:p,w=i.y,h=w===void 0?0:w,y=typeof c=="function"?c({x:f,y:h}):{x:f,y:h};f=y.x,h=y.y;var m=i.hasOwnProperty("x"),v=i.hasOwnProperty("y"),_=$e,x=Ke,k=window;if(u){var O=$n(n),E="clientHeight",N="clientWidth";if(O===Ge(n)&&(O=Rt(n),bt(O).position!=="static"&&a==="absolute"&&(E="scrollHeight",N="scrollWidth")),O=O,o===Ke||(o===$e||o===et)&&s===Fn){x=Qe;var D=d&&O===k&&k.visualViewport?k.visualViewport.height:O[E];h-=D-r.height,h*=l?1:-1}if(o===$e||(o===Ke||o===Qe)&&s===Fn){_=et;var R=d&&O===k&&k.visualViewport?k.visualViewport.width:O[N];f-=R-r.width,f*=l?1:-1}}var q=Object.assign({position:a},u&&mu),P=c===!0?yu({x:f,y:h},Ge(n)):{x:f,y:h};if(f=P.x,h=P.y,l){var T;return Object.assign({},q,(T={},T[x]=v?"0":"",T[_]=m?"0":"",T.transform=(k.devicePixelRatio||1)<=1?"translate("+f+"px, "+h+"px)":"translate3d("+f+"px, "+h+"px, 0)",T))}return Object.assign({},q,(e={},e[x]=v?h+"px":"",e[_]=m?f+"px":"",e.transform="",e))}function vu(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:ct(e.placement),variation:fn(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,Xs(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,Xs(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 gu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:vu,data:{}};var Qn={passive:!0};function wu(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=Ge(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,Qn)}),a&&l.addEventListener("resize",n.update,Qn),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,Qn)}),a&&l.removeEventListener("resize",n.update,Qn)}}const bu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:wu,data:{}};var _u={left:"right",right:"left",bottom:"top",top:"bottom"};function cr(t){return t.replace(/left|right|bottom|top/g,function(e){return _u[e]})}var xu={start:"end",end:"start"};function Qs(t){return t.replace(/start|end/g,function(e){return xu[e]})}function gs(t){var e=Ge(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function ws(t){return dn(Rt(t)).left+gs(t).scrollLeft}function ku(t,e){var n=Ge(t),r=Rt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var u=Ja();(u||!u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+ws(t),y:l}}function Eu(t){var e,n=Rt(t),r=gs(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Wt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Wt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+ws(t),l=-r.scrollTop;return bt(o||n).direction==="rtl"&&(a+=Wt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function bs(t){var e=bt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function ni(t){return["html","body","#document"].indexOf(ut(t))>=0?t.ownerDocument.body:Xe(t)&&bs(t)?t:ni(Jr(t))}function In(t,e){var n;e===void 0&&(e=[]);var r=ni(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ge(r),i=o?[s].concat(s.visualViewport||[],bs(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(In(Jr(i)))}function Co(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Cu(t,e){var n=dn(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 ea(t,e,n){return e===Za?Co(ku(t,n)):qt(e)?Cu(e,n):Co(Eu(Rt(t)))}function Su(t){var e=In(Jr(t)),n=["absolute","fixed"].indexOf(bt(t).position)>=0,r=n&&Xe(t)?$n(t):t;return qt(r)?e.filter(function(o){return qt(o)&&Xa(o,r)&&ut(o)!=="body"}):[]}function Iu(t,e,n,r){var o=e==="clippingParents"?Su(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,u){var c=ea(t,u,r);return l.top=Wt(c.top,l.top),l.right=Sr(c.right,l.right),l.bottom=Sr(c.bottom,l.bottom),l.left=Wt(c.left,l.left),l},ea(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 ri(t){var e=t.reference,n=t.element,r=t.placement,o=r?ct(r):null,s=r?fn(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case Ke:l={x:i,y:e.y-n.height};break;case Qe:l={x:i,y:e.y+e.height};break;case et:l={x:e.x+e.width,y:a};break;case $e:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=o?vs(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case cn:l[u]=l[u]-(e[c]/2-n[c]/2);break;case Fn:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function Rn(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?Vc:a,u=n.rootBoundary,c=u===void 0?Za:u,d=n.elementContext,p=d===void 0?xn:d,f=n.altBoundary,w=f===void 0?!1:f,h=n.padding,y=h===void 0?0:h,m=ei(typeof y!="number"?y:ti(y,Kn)),v=p===xn?Gc:xn,_=t.rects.popper,x=t.elements[w?v:p],k=Iu(qt(x)?x:x.contextElement||Rt(t.elements.popper),l,c,i),O=dn(t.elements.reference),E=ri({reference:O,element:_,strategy:"absolute",placement:o}),N=Co(Object.assign({},_,E)),D=p===xn?N:O,R={top:k.top-D.top+m.top,bottom:D.bottom-k.bottom+m.bottom,left:k.left-D.left+m.left,right:D.right-k.right+m.right},q=t.modifiersData.offset;if(p===xn&&q){var P=q[o];Object.keys(R).forEach(function(T){var b=[et,Qe].indexOf(T)>=0?1:-1,K=[Ke,Qe].indexOf(T)>=0?"y":"x";R[T]+=P[K]*b})}return R}function Ou(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?Ya:l,c=fn(r),d=c?a?Ys:Ys.filter(function(w){return fn(w)===c}):Kn,p=d.filter(function(w){return u.indexOf(w)>=0});p.length===0&&(p=d);var f=p.reduce(function(w,h){return w[h]=Rn(t,{placement:h,boundary:o,rootBoundary:s,padding:i})[ct(h)],w},{});return Object.keys(f).sort(function(w,h){return f[w]-f[h]})}function Du(t){if(ct(t)===ps)return[];var e=cr(t);return[Qs(t),e,Qs(e)]}function Pu(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,f=n.flipVariations,w=f===void 0?!0:f,h=n.allowedAutoPlacements,y=e.options.placement,m=ct(y),v=m===y,_=l||(v||!w?[cr(y)]:Du(y)),x=[y].concat(_).reduce(function(X,Y){return X.concat(ct(Y)===ps?Ou(e,{placement:Y,boundary:c,rootBoundary:d,padding:u,flipVariations:w,allowedAutoPlacements:h}):Y)},[]),k=e.rects.reference,O=e.rects.popper,E=new Map,N=!0,D=x[0],R=0;R=0,K=b?"width":"height",$=Rn(e,{placement:q,boundary:c,rootBoundary:d,altBoundary:p,padding:u}),A=b?T?et:$e:T?Qe:Ke;k[K]>O[K]&&(A=cr(A));var G=cr(A),L=[];if(s&&L.push($[P]<=0),a&&L.push($[A]<=0,$[G]<=0),L.every(function(X){return X})){D=q,N=!1;break}E.set(q,L)}if(N)for(var ne=w?3:1,z=function(Y){var me=x.find(function(ge){var ie=E.get(ge);if(ie)return ie.slice(0,Y).every(function(ue){return ue})});if(me)return D=me,"break"},B=ne;B>0;B--){var te=z(B);if(te==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const ju={name:"flip",enabled:!0,phase:"main",fn:Pu,requiresIfExists:["offset"],data:{_skip:!1}};function ta(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 na(t){return[Ke,et,Qe,$e].some(function(e){return t[e]>=0})}function Au(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Rn(e,{elementContext:"reference"}),a=Rn(e,{altBoundary:!0}),l=ta(i,r),u=ta(a,o,s),c=na(l),d=na(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 Nu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Au};function Fu(t,e,n){var r=ct(t),o=[$e,Ke].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,[$e,et].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function Ru(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=Ya.reduce(function(c,d){return c[d]=Fu(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 Tu={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Ru};function Bu(t){var e=t.state,n=t.name;e.modifiersData[n]=ri({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Mu={name:"popperOffsets",enabled:!0,phase:"read",fn:Bu,data:{}};function zu(t){return t==="x"?"y":"x"}function Lu(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,f=p===void 0?!0:p,w=n.tetherOffset,h=w===void 0?0:w,y=Rn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),m=ct(e.placement),v=fn(e.placement),_=!v,x=vs(m),k=zu(x),O=e.modifiersData.popperOffsets,E=e.rects.reference,N=e.rects.popper,D=typeof h=="function"?h(Object.assign({},e.rects,{placement:e.placement})):h,R=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),q=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(O){if(s){var T,b=x==="y"?Ke:$e,K=x==="y"?Qe:et,$=x==="y"?"height":"width",A=O[x],G=A+y[b],L=A-y[K],ne=f?-N[$]/2:0,z=v===cn?E[$]:N[$],B=v===cn?-N[$]:-E[$],te=e.elements.arrow,X=f&&te?ys(te):{width:0,height:0},Y=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Qa(),me=Y[b],ge=Y[K],ie=Sn(0,E[$],X[$]),ue=_?E[$]/2-ne-ie-me-R.mainAxis:z-ie-me-R.mainAxis,be=_?-E[$]/2+ne+ie+ge+R.mainAxis:B+ie+ge+R.mainAxis,ye=e.elements.arrow&&$n(e.elements.arrow),pe=ye?x==="y"?ye.clientTop||0:ye.clientLeft||0:0,xe=(T=q==null?void 0:q[x])!=null?T:0,g=A+ue-xe-pe,U=A+be-xe,W=Sn(f?Sr(G,g):G,A,f?Wt(L,U):L);O[x]=W,P[x]=W-A}if(a){var I,S=x==="x"?Ke:$e,F=x==="x"?Qe:et,V=O[k],Z=k==="y"?"height":"width",M=V+y[S],Q=V-y[F],re=[Ke,$e].indexOf(m)!==-1,ee=(I=q==null?void 0:q[k])!=null?I:0,se=re?M:V-E[Z]-N[Z]-ee+R.altAxis,ve=re?V+E[Z]+N[Z]-ee-R.altAxis:Q,he=f&&re?uu(se,V,ve):Sn(f?se:M,V,f?ve:Q);O[k]=he,P[k]=he-V}e.modifiersData[r]=P}}const Wu={name:"preventOverflow",enabled:!0,phase:"main",fn:Lu,requiresIfExists:["offset"]};function Uu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Ku(t){return t===Ge(t)||!Xe(t)?gs(t):Uu(t)}function $u(t){var e=t.getBoundingClientRect(),n=un(e.width)/t.offsetWidth||1,r=un(e.height)/t.offsetHeight||1;return n!==1||r!==1}function Hu(t,e,n){n===void 0&&(n=!1);var r=Xe(e),o=Xe(e)&&$u(e),s=Rt(e),i=dn(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((ut(e)!=="body"||bs(s))&&(a=Ku(e)),Xe(e)?(l=dn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=ws(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function qu(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 Vu(t){var e=qu(t);return ou.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function Gu(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Zu(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 ra={placement:"bottom",modifiers:[],strategy:"absolute"};function oa(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=j.useCallback(()=>{var R;!e||!w.current||!h.current||((R=v.current)==null||R.call(v),y.current=Xu(w.current,h.current,{placement:m,modifiers:[Kc,Lc,zc,{...Mc,enabled:!!p},{name:"eventListeners",...Bc(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}),y.current.forceUpdate(),v.current=y.current.destroy)},[m,e,n,p,i,s,a,l,u,d,c,o]);j.useEffect(()=>()=>{var R;!w.current&&!h.current&&((R=y.current)==null||R.destroy(),y.current=null)},[]);const x=j.useCallback(R=>{w.current=R,_()},[_]),k=j.useCallback((R={},q=null)=>({...R,ref:Be(x,q)}),[x]),O=j.useCallback(R=>{h.current=R,_()},[_]),E=j.useCallback((R={},q=null)=>({...R,ref:Be(O,q),style:{...R.style,position:o,minWidth:p?void 0:"max-content",inset:"0 auto auto 0"}}),[o,O,p]),N=j.useCallback((R={},q=null)=>{const{size:P,shadowColor:T,bg:b,style:K,...$}=R;return{...$,ref:q,"data-popper-arrow":"",style:Qu(R)}},[]),D=j.useCallback((R={},q=null)=>({...R,ref:q,"data-popper-arrow-inner":""}),[]);return{update(){var R;(R=y.current)==null||R.update()},forceUpdate(){var R;(R=y.current)==null||R.forceUpdate()},transformOrigin:Ae.transformOrigin.varRef,referenceRef:x,popperRef:O,getPopperProps:E,getArrowProps:N,getArrowInnerProps:D,getReferenceProps:k}}function Qu(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 xs(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=zt(n),i=zt(e),[a,l]=j.useState(t.defaultIsOpen||!1),u=r!==void 0?r:a,c=r!==void 0,d=j.useId(),p=o??`disclosure-${d}`,f=j.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),w=j.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),h=j.useCallback(()=>{u?f():w()},[u,w,f]);function y(v={}){return{...v,"aria-expanded":u,"aria-controls":p,onClick(_){var x;(x=v.onClick)==null||x.call(v,_),h()}}}function m(v={}){return{...v,hidden:!u,id:p}}return{isOpen:u,onOpen:w,onClose:f,onToggle:h,isControlled:c,getButtonProps:y,getDisclosureProps:m}}function ed(t){const{ref:e,handler:n,enabled:r=!0}=t,o=zt(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{lo(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&lo(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&lo(d,e)&&(i.isPointerDown=!1,o(d))},c=oi(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 lo(t,e){var n;const r=t.target;return r&&!oi(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function oi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function si(t){const{isOpen:e,ref:n}=t,[r,o]=j.useState(e),[s,i]=j.useState(!1);return j.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),rn(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=Ol(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function ks(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[td,nd,rd,od]=Fa(),[sd,Hn]=tt({strict:!1,name:"MenuContext"});function ad(t,...e){const n=j.useId(),r=t||n;return j.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function ai(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function sa(t){return ai(t).activeElement===t}function id(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:f,computePositionOnMount:w=!1,...h}=t,y=j.useRef(null),m=j.useRef(null),v=rd(),_=j.useCallback(()=>{requestAnimationFrame(()=>{var te;(te=y.current)==null||te.focus({preventScroll:!1})})},[]),x=j.useCallback(()=>{const te=setTimeout(()=>{var X;if(o)(X=o.current)==null||X.focus();else{const Y=v.firstEnabled();Y&&T(Y.index)}});G.current.add(te)},[v,o]),k=j.useCallback(()=>{const te=setTimeout(()=>{const X=v.lastEnabled();X&&T(X.index)});G.current.add(te)},[v]),O=j.useCallback(()=>{c==null||c(),s?x():_()},[s,x,_,c]),{isOpen:E,onOpen:N,onClose:D,onToggle:R}=xs({isOpen:a,defaultIsOpen:l,onClose:u,onOpen:O});ed({enabled:E&&r,ref:y,handler:te=>{var X;(X=m.current)!=null&&X.contains(te.target)||D()}});const q=_s({...h,enabled:E||w,placement:d,direction:f}),[P,T]=j.useState(-1);Vr(()=>{E||T(-1)},[E]),Ga(y,{focusRef:m,visible:E,shouldFocus:!0});const b=si({isOpen:E,ref:y}),[K,$]=ad(e,"menu-button","menu-list"),A=j.useCallback(()=>{N(),_()},[N,_]),G=j.useRef(new Set([]));j.useEffect(()=>{const te=G.current;return()=>{te.forEach(X=>clearTimeout(X)),te.clear()}},[]);const L=j.useCallback(()=>{N(),x()},[x,N]),ne=j.useCallback(()=>{N(),k()},[N,k]),z=j.useCallback(()=>{var te,X;const Y=ai(y.current),me=(te=y.current)==null?void 0:te.contains(Y.activeElement);if(!(E&&!me))return;const ie=(X=v.item(P))==null?void 0:X.node;ie==null||ie.focus({preventScroll:!0})},[E,P,v]),B=j.useRef(null);return{openAndFocusMenu:A,openAndFocusFirstItem:L,openAndFocusLastItem:ne,onTransitionEnd:z,unstable__animationState:b,descendants:v,popper:q,buttonId:K,menuId:$,forceUpdate:q.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:N,onClose:D,menuRef:y,buttonRef:m,focusedIndex:P,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:T,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:B}}function fp(t={},e=null){const n=Hn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=j.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:Be(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":at(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Se(t.onClick,r),onKeyDown:Se(t.onKeyDown,a)}}function So(t){var e;return ud(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function ld(t={},e=null){const n=Hn();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=nd(),f=Ic({preventDefault:m=>m.key!==" "&&So(m.target)}),w=j.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const v=m.key,x={Tab:O=>O.preventDefault(),Escape:a,ArrowDown:()=>{const O=p.nextEnabled(r);O&&o(O.index)},ArrowUp:()=>{const O=p.prevEnabled(r);O&&o(O.index)}}[v];if(x){m.preventDefault(),x(m);return}const k=f(O=>{const E=Oc(p.values(),O,N=>{var D,R;return(R=(D=N==null?void 0:N.node)==null?void 0:D.textContent)!=null?R:""},p.item(r));if(E){const N=p.indexOf(E.node);o(N)}});So(m.target)&&k(m)},[p,r,f,a,o]),h=j.useRef(!1);i&&(h.current=!0);const y=ks({wasSelected:h.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:Be(s,e),children:y?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:Se(t.onKeyDown,w)}}function cd(t={}){const{popper:e,isOpen:n}=Hn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function ii(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=Hn(),{setFocusedIndex:f,focusedIndex:w,closeOnSelect:h,onClose:y,menuRef:m,isOpen:v,menuId:_,rafId:x}=p,k=j.useRef(null),O=`${_}-menuitem-${j.useId()}`,{index:E,register:N}=od({disabled:a&&!l}),D=j.useCallback(A=>{n==null||n(A),!a&&f(E)},[f,E,a,n]),R=j.useCallback(A=>{r==null||r(A),k.current&&!sa(k.current)&&D(A)},[D,r]),q=j.useCallback(A=>{o==null||o(A),!a&&f(-1)},[f,a,o]),P=j.useCallback(A=>{s==null||s(A),So(A.currentTarget)&&(u??h)&&y()},[y,s,h,u]),T=j.useCallback(A=>{i==null||i(A),f(E)},[f,i,E]),b=E===w,K=a&&!l;Vr(()=>{if(v)return b&&!K&&k.current?(x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var A;(A=k.current)==null||A.focus({preventScroll:!0}),x.current=null})):m.current&&!sa(m.current)&&m.current.focus({preventScroll:!0}),()=>{x.current&&cancelAnimationFrame(x.current)}},[b,K,m,v]);const $=Va({onClick:P,onFocus:T,onMouseEnter:D,onMouseMove:R,onMouseLeave:q,ref:Be(N,k,e),isDisabled:a,isFocusable:l});return{...d,...$,type:c??$.type,id:O,role:"menuitem",tabIndex:b?0:-1}}function hp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...ii(o,e),role:`menuitem${n}`,"aria-checked":r}}function pp(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...i}=t,l=n==="radio"?"":[],[u,c]=Ra({defaultValue:o??l,value:r,onChange:s}),d=j.useCallback(w=>{if(n==="radio"&&typeof u=="string"&&c(w),n==="checkbox"&&Array.isArray(u)){const h=u.includes(w)?u.filter(y=>y!==w):u.concat(w);c(h)}},[u,c,n]),f=fs(e).map(w=>{if(w.type.id!=="MenuItemOption")return w;const h=m=>{var v,_;d(w.props.value),(_=(v=w.props).onClick)==null||_.call(v,m)},y=n==="radio"?w.props.value===u:u.includes(w.props.value);return j.cloneElement(w,{type:n,onClick:h,isChecked:y})});return{...i,children:f}}function ud(t){var e;if(!dd(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function dd(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[fd,Xr]=tt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Es=t=>{const{children:e}=t,n=Nt("Menu",t),r=nt(t),{direction:o}=is(),{descendants:s,...i}=id({...r,direction:o}),a=j.useMemo(()=>i,[i]),{isOpen:l,onClose:u,forceUpdate:c}=a;return C.jsx(td,{value:s,children:C.jsx(sd,{value:a,children:C.jsx(fd,{value:n,children:Ea(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};Es.displayName="Menu";var li=fe((t,e)=>{const n=Xr();return C.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});li.displayName="MenuCommand";var hd=fe((t,e)=>{const{type:n,...r}=t,o=Xr(),s=r.as||n?n??void 0:"button",i=j.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 C.jsx(de.button,{ref:e,type:s,...r,__css:i})}),ci=t=>{const{className:e,children:n,...r}=t,o=Xr(),s=j.Children.only(n),i=j.isValidElement(s)?j.cloneElement(s,{focusable:"false","aria-hidden":!0,className:_e("chakra-menu__icon",s.props.className)}):null,a=_e("chakra-menu__icon-wrapper",e);return C.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};ci.displayName="MenuIcon";var xt=fe((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=ii(a,e),c=n||o?C.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return C.jsxs(hd,{...l,className:_e("chakra-menu__menuitem",l.className),children:[n&&C.jsx(ci,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&C.jsx(li,{marginStart:s,children:o})]})});xt.displayName="MenuItem";var pd={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"}}},md=de(ls.div),Cs=fe(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=Hn(),d=ld(a,n),p=cd(s),f=Xr();return C.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=f.list)==null?void 0:r.zIndex},children:C.jsx(md,{variants:pd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...f.list},...i,className:_e("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:Ca(c.onComplete,d.onAnimationComplete)})})});Cs.displayName="MenuList";var[yd,qn]=tt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[vd,Ss]=tt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function ui(t){const e=j.Children.only(t.children),{getTriggerProps:n}=qn();return j.cloneElement(e,n(e.props,e.ref))}ui.displayName="PopoverTrigger";var Qt={click:"click",hover:"hover"};function gd(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:u=Qt.click,openDelay:c=200,closeDelay:d=200,isLazy:p,lazyBehavior:f="unmount",computePositionOnMount:w,...h}=t,{isOpen:y,onClose:m,onOpen:v,onToggle:_}=xs(t),x=j.useRef(null),k=j.useRef(null),O=j.useRef(null),E=j.useRef(!1),N=j.useRef(!1);y&&(N.current=!0);const[D,R]=j.useState(!1),[q,P]=j.useState(!1),T=j.useId(),b=o??T,[K,$,A,G]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${b}`),{referenceRef:L,getArrowProps:ne,getPopperProps:z,getArrowInnerProps:B,forceUpdate:te}=_s({...h,enabled:y||!!w}),X=si({isOpen:y,ref:O});uc({enabled:y,ref:k}),Ga(O,{focusRef:k,visible:y,shouldFocus:s&&u===Qt.click}),Ac(O,{focusRef:r,visible:y,shouldFocus:i&&u===Qt.click});const Y=ks({wasSelected:N.current,enabled:p,mode:f,isSelected:X.present}),me=j.useCallback((U={},W=null)=>{const I={...U,style:{...U.style,transformOrigin:Ae.transformOrigin.varRef,[Ae.arrowSize.var]:a?`${a}px`:void 0,[Ae.arrowShadowColor.var]:l},ref:Be(O,W),children:Y?U.children:null,id:$,tabIndex:-1,role:"dialog",onKeyDown:Se(U.onKeyDown,S=>{n&&S.key==="Escape"&&m()}),onBlur:Se(U.onBlur,S=>{const F=aa(S),V=co(O.current,F),Z=co(k.current,F);y&&e&&(!V&&!Z)&&m()}),"aria-labelledby":D?A:void 0,"aria-describedby":q?G:void 0};return u===Qt.hover&&(I.role="tooltip",I.onMouseEnter=Se(U.onMouseEnter,()=>{E.current=!0}),I.onMouseLeave=Se(U.onMouseLeave,S=>{S.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>m(),d))})),I},[Y,$,D,A,q,G,u,n,m,y,e,d,l,a]),ge=j.useCallback((U={},W=null)=>z({...U,style:{visibility:y?"visible":"hidden",...U.style}},W),[y,z]),ie=j.useCallback((U,W=null)=>({...U,ref:Be(W,x,L)}),[x,L]),ue=j.useRef(),be=j.useRef(),ye=j.useCallback(U=>{x.current==null&&L(U)},[L]),pe=j.useCallback((U={},W=null)=>{const I={...U,ref:Be(k,W,ye),id:K,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":$};return u===Qt.click&&(I.onClick=Se(U.onClick,_)),u===Qt.hover&&(I.onFocus=Se(U.onFocus,()=>{ue.current===void 0&&v()}),I.onBlur=Se(U.onBlur,S=>{const F=aa(S),V=!co(O.current,F);y&&e&&V&&m()}),I.onKeyDown=Se(U.onKeyDown,S=>{S.key==="Escape"&&m()}),I.onMouseEnter=Se(U.onMouseEnter,()=>{E.current=!0,ue.current=window.setTimeout(()=>v(),c)}),I.onMouseLeave=Se(U.onMouseLeave,()=>{E.current=!1,ue.current&&(clearTimeout(ue.current),ue.current=void 0),be.current=window.setTimeout(()=>{E.current===!1&&m()},d)})),I},[K,y,$,u,ye,_,v,e,m,c,d]);j.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current),be.current&&clearTimeout(be.current)},[]);const xe=j.useCallback((U={},W=null)=>({...U,id:A,ref:Be(W,I=>{R(!!I)})}),[A]),g=j.useCallback((U={},W=null)=>({...U,id:G,ref:Be(W,I=>{P(!!I)})}),[G]);return{forceUpdate:te,isOpen:y,onAnimationComplete:X.onComplete,onClose:m,getAnchorProps:ie,getArrowProps:ne,getArrowInnerProps:B,getPopoverPositionerProps:ge,getPopoverProps:me,getTriggerProps:pe,getHeaderProps:xe,getBodyProps:g}}function co(t,e){return t===e||(t==null?void 0:t.contains(e))}function aa(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function di(t){const e=Nt("Popover",t),{children:n,...r}=nt(t),o=is(),s=gd({...r,direction:o.direction});return C.jsx(yd,{value:s,children:C.jsx(vd,{value:e,children:Ea(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}di.displayName="Popover";var fi=fe(function(e,n){const{getBodyProps:r}=qn(),o=Ss();return C.jsx(de.div,{...r(e,n),className:_e("chakra-popover__body",e.className),__css:o.body})});fi.displayName="PopoverBody";var hi=fe(function(e,n){const{onClose:r}=qn(),o=Ss();return C.jsx(Dl,{size:"sm",onClick:r,className:_e("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});hi.displayName="PopoverCloseButton";function wd(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var bd={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]}}},_d=de(ls.section),pi=fe(function(e,n){const{variants:r=bd,...o}=e,{isOpen:s}=qn();return C.jsx(_d,{ref:n,variants:wd(r),initial:!1,animate:s?"enter":"exit",...o})});pi.displayName="PopoverTransition";var mi=fe(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=qn(),u=Ss(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return C.jsx(de.div,{...a(r),__css:u.popper,className:"chakra-popover__popper",children:C.jsx(pi,{...o,...i(s,n),onAnimationComplete:Ca(l,s.onAnimationComplete),className:_e("chakra-popover__content",e.className),__css:c})})});mi.displayName="PopoverContent";var[xd,kd,Ed,Cd]=Fa();function Sd(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]=j.useState(n??0),[f,w]=Ra({defaultValue:n??0,value:o,onChange:r});j.useEffect(()=>{o!=null&&p(o)},[o]);const h=Ed(),y=j.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:f,focusedIndex:d,setSelectedIndex:w,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:h,direction:u,htmlProps:c}}var[Id,Qr]=tt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function Od(t){const{focusedIndex:e,orientation:n,direction:r}=Qr(),o=kd(),s=j.useCallback(i=>{const a=()=>{var v;const _=o.nextEnabled(e);_&&((v=_.node)==null||v.focus())},l=()=>{var v;const _=o.prevEnabled(e);_&&((v=_.node)==null||v.focus())},u=()=>{var v;const _=o.firstEnabled();_&&((v=_.node)==null||v.focus())},c=()=>{var v;const _=o.lastEnabled();_&&((v=_.node)==null||v.focus())},d=n==="horizontal",p=n==="vertical",f=i.key,w=r==="ltr"?"ArrowLeft":"ArrowRight",h=r==="ltr"?"ArrowRight":"ArrowLeft",m={[w]:()=>d&&l(),[h]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:u,End:c}[f];m&&(i.preventDefault(),m(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Se(t.onKeyDown,s)}}function Dd(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=Qr(),{index:u,register:c}=Cd({disabled:e&&!n}),d=u===l,p=()=>{o(u)},f=()=>{a(u),!s&&!(e&&n)&&o(u)},w=Va({...r,ref:Be(c,t.ref),isDisabled:e,isFocusable:n,onClick:Se(t.onClick,p)}),h="button";return{...w,id:yi(i,u),role:"tab",tabIndex:d?0:-1,type:h,"aria-selected":d,"aria-controls":vi(i,u),onFocus:e?void 0:Se(t.onFocus,f)}}var[Pd,jd]=tt({});function Ad(t){const e=Qr(),{id:n,selectedIndex:r}=e,s=fs(t.children).map((i,a)=>j.createElement(Pd,{key:a,value:{isSelected:a===r,id:vi(n,a),tabId:yi(n,a),selectedIndex:r}},i));return{...t,children:s}}function Nd(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Qr(),{isSelected:s,id:i,tabId:a}=jd(),l=j.useRef(!1);s&&(l.current=!0);const u=ks({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 yi(t,e){return`${t}--tab-${e}`}function vi(t,e){return`${t}--tabpanel-${e}`}var[Fd,eo]=tt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),gi=fe(function(e,n){const r=Nt("Tabs",e),{children:o,className:s,...i}=nt(e),{htmlProps:a,descendants:l,...u}=Sd(i),c=j.useMemo(()=>u,[u]),{isFitted:d,...p}=a,f={position:"relative",...r.root};return C.jsx(xd,{value:l,children:C.jsx(Id,{value:c,children:C.jsx(Fd,{value:r,children:C.jsx(de.div,{className:_e("chakra-tabs",s),ref:n,...p,__css:f,children:o})})})})});gi.displayName="Tabs";var wi=fe(function(e,n){const r=Od({...e,ref:n}),s={display:"flex",...eo().tablist};return C.jsx(de.div,{...r,className:_e("chakra-tabs__tablist",e.className),__css:s})});wi.displayName="TabList";var Io=fe(function(e,n){const r=Nd({...e,ref:n}),o=eo();return C.jsx(de.div,{outline:"0",...r,className:_e("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Io.displayName="TabPanel";var bi=fe(function(e,n){const r=Ad(e),o=eo();return C.jsx(de.div,{...r,width:"100%",ref:n,className:_e("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});bi.displayName="TabPanels";var Oo=fe(function(e,n){const r=eo(),o=Dd({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return C.jsx(de.button,{...o,className:_e("chakra-tabs__tab",e.className),__css:s})});Oo.displayName="Tab";var[Rd,_i]=tt({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),to=fe((t,e)=>{const n=Nt("Tag",t),r=nt(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return C.jsx(Rd,{value:n,children:C.jsx(de.span,{ref:e,...r,__css:o})})});to.displayName="Tag";var Td=fe((t,e)=>{const n=_i();return C.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});Td.displayName="TagLabel";var Bd=fe((t,e)=>C.jsx(Hr,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));Bd.displayName="TagLeftIcon";var Md=fe((t,e)=>C.jsx(Hr,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));Md.displayName="TagRightIcon";var xi=t=>C.jsx(Hr,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:C.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"})});xi.displayName="TagCloseIcon";var zd=fe((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",..._i().closeButton};return C.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||C.jsx(xi,{})})});zd.displayName="TagCloseButton";var Ld={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]}}}},Do=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},ur=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function Wd(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:f,arrowSize:w=10,arrowShadowColor:h,arrowPadding:y,modifiers:m,isDisabled:v,gutter:_,offset:x,direction:k,...O}=t,{isOpen:E,onOpen:N,onClose:D}=xs({isOpen:p,defaultIsOpen:f,onOpen:l,onClose:u}),{referenceRef:R,getPopperProps:q,getArrowInnerProps:P,getArrowProps:T}=_s({enabled:E,placement:c,arrowPadding:y,modifiers:m,gutter:_,offset:x,direction:k}),b=j.useId(),$=`tooltip-${d??b}`,A=j.useRef(null),G=j.useRef(),L=j.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=void 0)},[]),ne=j.useRef(),z=j.useCallback(()=>{ne.current&&(clearTimeout(ne.current),ne.current=void 0)},[]),B=j.useCallback(()=>{z(),D()},[D,z]),te=Ud(A,B),X=j.useCallback(()=>{if(!v&&!G.current){E&&te();const pe=ur(A);G.current=pe.setTimeout(N,e)}},[te,v,E,N,e]),Y=j.useCallback(()=>{L();const pe=ur(A);ne.current=pe.setTimeout(B,n)},[n,B,L]),me=j.useCallback(()=>{E&&r&&Y()},[r,Y,E]),ge=j.useCallback(()=>{E&&i&&Y()},[i,Y,E]),ie=j.useCallback(pe=>{E&&pe.key==="Escape"&&Y()},[E,Y]);rn(()=>Do(A),"keydown",a?ie:void 0),rn(()=>{if(!s)return null;const pe=A.current;if(!pe)return null;const xe=$a(pe);return xe.localName==="body"?ur(A):xe},"scroll",()=>{E&&s&&B()},{passive:!0,capture:!0}),j.useEffect(()=>{v&&(L(),E&&D())},[v,E,D,L]),j.useEffect(()=>()=>{L(),z()},[L,z]),rn(()=>A.current,"pointerleave",Y);const ue=j.useCallback((pe={},xe=null)=>({...pe,ref:Be(A,xe,R),onPointerEnter:Se(pe.onPointerEnter,U=>{U.pointerType!=="touch"&&X()}),onClick:Se(pe.onClick,me),onPointerDown:Se(pe.onPointerDown,ge),onFocus:Se(pe.onFocus,X),onBlur:Se(pe.onBlur,Y),"aria-describedby":E?$:void 0}),[X,Y,ge,E,$,me,R]),be=j.useCallback((pe={},xe=null)=>q({...pe,style:{...pe.style,[Ae.arrowSize.var]:w?`${w}px`:void 0,[Ae.arrowShadowColor.var]:h}},xe),[q,w,h]),ye=j.useCallback((pe={},xe=null)=>{const g={...pe.style,position:"relative",transformOrigin:Ae.transformOrigin.varRef};return{ref:xe,...O,...pe,id:$,role:"tooltip",style:g}},[O,$]);return{isOpen:E,show:X,hide:Y,getTriggerProps:ue,getTooltipProps:ye,getTooltipPositionerProps:be,getArrowProps:T,getArrowInnerProps:P}}var uo="chakra-ui:close-tooltip";function Ud(t,e){return j.useEffect(()=>{const n=Do(t);return n.addEventListener(uo,e),()=>n.removeEventListener(uo,e)},[e,t]),()=>{const n=Do(t),r=ur(t);n.dispatchEvent(new r.CustomEvent(uo))}}function Kd(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function $d(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var Hd=de(ls.div),Vt=fe((t,e)=>{var n,r;const o=qr("Tooltip",t),s=nt(t),i=is(),{children:a,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:p,portalProps:f,background:w,backgroundColor:h,bgColor:y,motionProps:m,...v}=s,_=(r=(n=w??h)!=null?n:p)!=null?r:y;if(_){o.bg=_;const q=Pl(i,"colors",_);o[Ae.arrowBg.var]=q}const x=Wd({...v,direction:i.direction}),k=typeof a=="string"||u;let O;if(k)O=C.jsx(de.span,{display:"inline-block",tabIndex:0,...x.getTriggerProps(),children:a});else{const q=j.Children.only(a);O=j.cloneElement(q,x.getTriggerProps(q.props,q.ref))}const E=!!c,N=x.getTooltipProps({},e),D=E?Kd(N,["role","id"]):N,R=$d(N,["role","id"]);return l?C.jsxs(C.Fragment,{children:[O,C.jsx(jl,{children:x.isOpen&&C.jsx(Sa,{...f,children:C.jsx(de.div,{...x.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:C.jsxs(Hd,{variants:Ld,initial:"exit",animate:"enter",exit:"exit",...m,...D,__css:o,children:[l,E&&C.jsx(de.span,{srOnly:!0,...R,children:c}),d&&C.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:C.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):C.jsx(C.Fragment,{children:a})});Vt.displayName="Tooltip";const qd="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let hn=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=qd[n[t]&63];return e},Pe=null;const ki=location.pathname.split("/").slice(0,-1).join("/");let Ir=null;Ft(()=>import(ki+"/scripts/api.js"),__vite__mapDeps([])).then(t=>{Ir=t==null?void 0:t.api});Ft(()=>import(ki+"/scripts/app.js"),__vite__mapDeps([])).then(t=>{Pe=t==null?void 0:t.app});function ke(t,e){if(Ir==null)throw console.error("api is null!"),new Error("api is null!");return Ir.fetchApi(t,e)}async function Vd(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await ke(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function Gd(t,e){try{return await(await ke("/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 mp(t){try{return await(await ke("/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 yp(){try{return await(await ke("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function Zd(){const e=await(await ke("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function vp(){try{return await(await ke("/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 gp(){try{return await(await ke("/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 wp(t){try{return await(await ke("/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 bp(t,e){try{return await(await ke("/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 Yd="backup",Or="workspace";let er=null;function Jd(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(Or)||o.createObjectStore(Or,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Xd(){try{return er==null&&(er=await Jd()),new Promise((t,e)=>{if(er==null)return e("indexDB is null");const o=er.transaction([Or],"readonly").objectStore(Or).get(Yd);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 Qd(){try{return await Xd()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const Ee=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"||Ee.Promise||(Ee.Promise=Promise);const Tn=Object.getPrototypeOf,ef={}.hasOwnProperty;function Ze(t,e){return ef.call(t,e)}function pn(t,e){typeof e=="function"&&(e=e(Tn(t))),(typeof Reflect>"u"?Ne:Reflect.ownKeys)(e).forEach(n=>{gt(t,n,e[n])})}const Ei=Object.defineProperty;function gt(t,e,n,r){Ei(t,e,Ue(n&&Ze(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function sn(t){return{from:function(e){return t.prototype=Object.create(e.prototype),gt(t.prototype,"constructor",t),{extend:pn.bind(null,t.prototype)}}}}const tf=Object.getOwnPropertyDescriptor;function Is(t,e){let n;return tf(t,e)||(n=Tn(t))&&Is(n,e)}const nf=[].slice;function Dr(t,e,n){return nf.call(t,e,n)}function Ci(t,e){return e(t)}function En(t){if(!t)throw new Error("Assertion Failed")}function Si(t){Ee.setImmediate?setImmediate(t):setTimeout(t,0)}function Ii(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function wt(t,e){if(Ze(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=>Ee[t]),of=Pi.map(t=>Ee[t]);Ii(Pi,t=>[t,!0]);let Et=null;function Vn(t){Et=typeof WeakMap<"u"&&new WeakMap;const e=Po(t);return Et=null,e}function Po(t){if(!t||typeof t!="object")return t;let e=Et&&Et.get(t);if(e)return e;if(ze(t)){e=[],Et&&Et.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=Tn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),Et&&Et.set(t,e),t)Ze(t,o)&&(e[o]=Po(t[o]))}return e}const{toString:sf}={};function jo(t){return sf.call(t).slice(8,-1)}const Ao=typeof Symbol<"u"?Symbol.iterator:"@@iterator",af=typeof Ao=="symbol"?function(t){var e;return t!=null&&(e=t[Ao])&&e.apply(t)}:function(){return null},nn={};function yt(t){var e,n,r,o;if(arguments.length===1){if(ze(t))return t.slice();if(this===nn&&typeof t=="string")return[t];if(o=af(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 Os=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var dt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ji(t,e){dt=t,Ai=e}var Ai=()=>!0;const lf=!new Error("").stack;function Yt(){if(lf)try{throw Yt.arguments,new Error}catch(t){return t}return new Error}function No(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(Ai).map(r=>` -`+r).join("")):""}var Ni=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Os=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Ni),cf={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 an(t,e){this._e=Yt(),this.name=t,this.message=e}function Fi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` -`)}function Pr(t,e,n,r){this._e=Yt(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Fi(t,e)}function On(t,e){this._e=Yt(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Fi(t,e)}sn(an).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+No(this._e,2))}},toString:function(){return this.name+": "+this.message}}),sn(Pr).from(an),sn(On).from(an);var Ds=Os.reduce((t,e)=>(t[e]=e+"Error",t),{});const uf=an;var le=Os.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=cf[e]||n,this.inner=null)}return sn(r).from(uf),t[e]=r,t},{});le.Syntax=SyntaxError,le.Type=TypeError,le.Range=RangeError;var aa=Ni.reduce((t,e)=>(t[e+"Error"]=le[e],t),{}),dr=Os.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=le[e]),t),{});function we(){}function Bn(t){return t}function df(t,e){return t==null||t===Bn?e:function(n){return e(t(n))}}function Gt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function ff(t,e){return t===we?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?Gt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Gt(o,this.onerror):o),s!==void 0?s:n}}function hf(t,e){return t===we?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?Gt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Gt(r,this.onerror):r)}}function pf(t,e){return t===we?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?Gt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Gt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:Ue(r,i)}}function mf(t,e){return t===we?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ps(t,e){return t===we?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)}}dr.ModifyError=Pr,dr.DexieError=an,dr.BulkError=On;var Mn={};const Ri=100,[Fo,jr,Ro]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Tn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Tn(e),t]})(),Ti=jr&&jr.then,fr=Fo&&Fo.constructor,js=!!Ro;var To=!1,yf=Ro?()=>{Ro.then(tr)}:Ee.setImmediate?setImmediate.bind(null,tr):Ee.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{tr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(tr,0)},Dn=function(t,e){Cn.push([t,e]),Ar&&(yf(),Ar=!1)},Bo=!0,Ar=!0,Ut=[],hr=[],Mo=null,zo=Bn,ln={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ca,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{ca(t[0],t[1])}catch{}})}},ae=ln,Cn=[],Kt=0,pr=[];function oe(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=we,this._lib=!1;var e=this._PSD=ae;if(dt&&(this._stackHolder=Yt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Mn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Wo(this,this._value))}this._state=null,this._value=null,++e.ref,Mi(this,t)}const Lo={get:function(){var t=ae,e=Nr;function n(r,o){var s=!t.global&&(t!==ae||e!==Nr);const i=s&&!_t();var a=new oe((l,u)=>{As(this,new Bi(Fr(r,t,s,i),Fr(o,t,s,i),l,u,t))});return dt&&Wi(a,this),a}return n.prototype=Mn,n},set:function(t){gt(this,"then",t&&t.prototype===Mn?Lo:{get:function(){return t},set:Lo.set})}};function Bi(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 Mi(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&&Gn();n&&typeof n.then=="function"?Mi(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,zi(t)),r&&Zn()}},Wo.bind(null,t))}catch(n){Wo(t,n)}}function Wo(t,e){if(hr.push(e),t._state===null){var n=t._lib&&Gn();e=zo(e),t._state=!1,t._value=e,dt&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Ss(e,"stack");e._promise=t,gt(e,"stack",{get:()=>To?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Ut.some(o=>o._value===r._value)||Ut.push(r)}(t),zi(t),n&&Zn()}}function zi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Kt==0&&Ns()},[]))}function As(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,++Kt,Dn(vf,[n,t,e])}else t._listeners.push(e)}function vf(t,e,n){try{Mo=e;var r,o=e._value;e._state?r=t(o):(hr.length&&(hr=[]),r=t(o),hr.indexOf(o)===-1&&function(s){for(var i=Ut.length;i;)if(Ut[--i]._value===s._value)return void Ut.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Mo=null,--Kt==0&&Ns(),--n.psd.ref||n.psd.finalize()}}function Li(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=No(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return dt&&((r=No(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Li(t._prev,e,n)),e}function Wi(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function tr(){Gn()&&Zn()}function Gn(){var t=Bo;return Bo=!1,Ar=!1,t}function Zn(){var t,e,n;do for(;Cn.length>0;)for(t=Cn,Cn=[],n=t.length,e=0;e0);Bo=!0,Ar=!0}function Ns(){var t=Ut;Ut=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=pr.slice(0),n=e.length;n;)e[--n]()}function nr(t){return new oe(Mn,!1,t)}function Ce(t,e){var n=ae;return function(){var r=Gn(),o=ae;try{return Pt(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{Pt(o,!1),r&&Zn()}}}pn(oe.prototype,{then:Lo,_then:function(t,e){As(this,new Bi(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):nr(r)):this.then(null,r=>r&&r.name===e?n(r):nr(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),nr(e)))},stack:{get:function(){if(this._stack)return this._stack;try{To=!0;var t=Li(this,[],20).join(` -From previous: `);return this._state!==null&&(this._stack=t),t}finally{To=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new le.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&>(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),ln.env=Ui(),pn(oe,{all:function(){var t=yt.apply(null,arguments).map(rr);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(Mn,!0,t);return Wi(e,Mo),e},reject:nr,race:function(){var t=yt.apply(null,arguments).map(rr);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ae,set:t=>ae=t},totalEchoes:{get:()=>Nr},newPSD:Dt,usePSD:gn,scheduler:{get:()=>Dn,set:t=>{Dn=t}},rejectionMapper:{get:()=>zo,set:t=>{zo=t}},follow:(t,e)=>new oe((n,r)=>Dt((o,s)=>{var i=ae;i.unhandleds=[],i.onunhandled=s,i.finalize=Gt(function(){(function(a){function l(){a(),pr.splice(pr.indexOf(l),1)}pr.push(l),++Kt,Dn(()=>{--Kt==0&&Ns()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),fr&&(fr.allSettled&>(oe,"allSettled",function(){const t=yt.apply(null,arguments).map(rr);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)))})}),fr.any&&typeof AggregateError<"u"&>(oe,"any",function(){const t=yt.apply(null,arguments).map(rr);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 Me={awaits:0,echoes:0,id:0};var gf=0,mr=[],fo=0,Nr=0,wf=0;function Dt(t,e,n,r){var o=ae,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++wf;var i=ln.env;s.env=js?{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:ia(i.nthen,s),gthen:ia(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=gn(s,t,n,r);return s.ref===0&&s.finalize(),a}function vn(){return Me.id||(Me.id=++gf),++Me.awaits,Me.echoes+=Ri,Me.id}function _t(){return!!Me.awaits&&(--Me.awaits==0&&(Me.id=0),Me.echoes=Me.awaits*Ri,!0)}function rr(t){return Me.echoes&&t&&t.constructor===fr?(vn(),t.then(e=>(_t(),e),e=>(_t(),Fe(e)))):t}function bf(t){++Nr,Me.echoes&&--Me.echoes!=0||(Me.echoes=Me.id=0),mr.push(ae),Pt(t,!0)}function _f(){var t=mr[mr.length-1];mr.pop(),Pt(t,!1)}function Pt(t,e){var n=ae;if((e?!Me.echoes||fo++&&t===ae:!fo||--fo&&t===ae)||Ki(e?bf.bind(null,t):_f),t!==ae&&(ae=t,n===ln&&(ln.env=Ui()),js)){var r=ln.env.Promise,o=t.env;jr.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ee,"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 Ui(){var t=Ee.Promise;return js?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ee,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:jr.then,gthen:t.prototype.then}:{}}function gn(t,e,n,r,o){var s=ae;try{return Pt(t,!0),e(n,r,o)}finally{Pt(s,!1)}}function Ki(t){Ti.call(Fo,t)}function Fr(t,e,n,r){return typeof t!="function"?t:function(){var o=ae;n&&vn(),Pt(e,!0);try{return t.apply(this,arguments)}finally{Pt(o,!1),r&&Ki(_t)}}}function ia(t,e){return function(n,r){return t.call(this,Fr(n,e),Fr(r,e))}}(""+Ti).indexOf("[native code]")===-1&&(vn=_t=we);const la="unhandledrejection";function ca(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ee.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(la,!0,!0),Ue(r,o)):Ee.CustomEvent&&Ue(r=new CustomEvent(la,{detail:o}),o),r&&Ee.dispatchEvent&&(dispatchEvent(r),!Ee.PromiseRejectionEvent&&Ee.onunhandledrejection))try{Ee.onunhandledrejection(r)}catch{}dt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Fe=oe.reject;function Uo(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===Ds.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Uo(t,e,n,r))):Fe(s)}return o._promise(e,(s,i)=>Dt(()=>(ae.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Fe(new le.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Fe(new le.DatabaseClosed);t.open().catch(we)}return t._state.dbReadyPromise.then(()=>Uo(t,e,n,r))}const ua="3.2.4",Mt="￿",Ko=-1/0,ht="Invalid key provided. Keys must be of type string, number, Date or Array.",$i="String expected.",Pn=[],no=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),xf=no,kf=no,Hi=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),ro="__dbnames",ho="readonly",po="readwrite";function Zt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const qi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function or(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Vn(e))[t],e)}class Ef{_trans(e,n,r){const o=this._tx||ae.trans,s=this.name;function i(l,u,c){if(!c.schema[s])throw new le.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const a=Gn();try{return o&&o.db===this.db?o===ae.trans?o._promise(e,i,r):Dt(()=>o._promise(e,i,r),{trans:o,transless:ae.transless||ae}):Uo(this.db,e,[this.name],i)}finally{a&&Zn()}}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!==Mt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&dt&&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],f=e[d];return[u||p,u||!p?Zt(c,p&&p.multi?w=>{const h=wt(w,d);return ze(h)&&h.some(y=>i(f,y))}:w=>i(f,wt(w,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(Ze(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=or(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{rt(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=wt(e,this.schema.primKey.keyPath);if(r===void 0)return Fe(new le.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ne(n).forEach(o=>{rt(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=or(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{rt(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:qi})).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 le.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:f,failures:w})=>{if(d===0)return s?p:f;throw new On(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,w)})})}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 le.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:f,failures:w})=>{if(d===0)return s?p:f;throw new On(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,w)})})}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 On(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function jn(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;rZt(r(),e()):e,t.justLimit=n&&!r}function yr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new le.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function da(t,e,n){const r=yr(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 sr(t,e,n,r){const o=t.replayFilter?Zt(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)),Ze(s,d)||(s[d]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(i,n),fa(da(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return fa(da(t,r,n),Zt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function fa(t,e,n,r){var o=Ce(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=we},a=>{s.fail(a),i=we})||o(s.value,s,a=>i=a),i()})})}function We(t,e){try{const n=ha(t),r=ha(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:tsr(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(en(r,!0))return o.count({trans:n,query:{index:yr(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return sr(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"&&en(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=yr(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 sr(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,en(n)?yo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):yo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),yo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return mo(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 mo(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Zt(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"&&en(n,!0)&&n.limit>0)return this._read(o=>{var s=yr(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 mo(this._ctx,function(o){var s=o.primaryKey.toString(),i=Ze(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(h){for(var y=!1,m=0;m{const{failures:m,numFailures:v}=y;p+=h-v;for(let _ of Ne(m))d.push(m[_])};return this.clone().primaryKeys().then(h=>{const y=m=>{const v=Math.min(c,h.length-m);return a.getMany({trans:r,keys:h.slice(m,m+v),cache:"immutable"}).then(_=>{const x=[],k=[],O=l?[]:null,E=[];for(let D=0;D0&&a.mutate({trans:r,type:"add",values:x}).then(D=>{for(let R in D.failures)E.splice(parseInt(R),1);w(x.length,D)})).then(()=>(k.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:O,values:k,criteria:N,changeSpec:typeof e!="function"&&e}).then(D=>w(k.length,D))).then(()=>(E.length>0||N&&e===vo)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(D=>w(E.length,D))).then(()=>h.length>m+v&&y(m+c))})};return y(0).then(()=>{if(d.length>0)throw new Pr("Error modifying one or more objects",d,p,f);return h.length})})})}delete(){var e=this._ctx,n=e.range;return en(e)&&(e.isPrimKey&&!kf||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 Pr("Could not delete some values",Object.keys(a).map(d=>a[d]),i-c);return i-c}))}):this.modify(vo)}}const vo=(t,e)=>e.value=null;function Sf(t,e){return te?-1:t===e?0:1}function He(t,e,n){var r=t instanceof Gi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function tn(t){return new t.Collection(t,()=>Vi("")).limit(0)}function Of(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 h=="string"))return He(t,$i);function p(h){o=function(m){return m==="next"?v=>v.toUpperCase():v=>v.toLowerCase()}(h),s=function(m){return m==="next"?v=>v.toLowerCase():v=>v.toUpperCase()}(h),i=h==="next"?Sf:If;var y=n.map(function(m){return{lower:s(m),upper:o(m)}}).sort(function(m,v){return i(m.lower,v.lower)});a=y.map(function(m){return m.upper}),l=y.map(function(m){return m.lower}),u=h,c=h==="next"?"":r}p("next");var f=new t.Collection(t,()=>kt(a[0],l[d-1]+r));f._ondirectionchange=function(h){p(h)};var w=0;return f._addAlgorithm(function(h,y,m){var v=h.key;if(typeof v!="string")return!1;var _=s(v);if(e(_,l,w))return!0;for(var x=null,k=w;k0)&&(x=O)}return y(x!==null?function(){h.continue(x+c)}:m),!1}),f}function kt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Vi(t){return{type:1,lower:t,upper:t}}class Gi{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)?tn(this):new this.Collection(this,()=>kt(e,n,!r,!o))}catch{return He(this,ht)}}equals(e){return e==null?He(this,ht):new this.Collection(this,()=>Vi(e))}above(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(e,void 0,!0))}aboveOrEqual(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(e,void 0,!1))}below(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(void 0,e))}startsWith(e){return typeof e!="string"?He(this,$i):this.between(e,e+Mt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ar(this,(n,r)=>n.indexOf(r[0])===0,[e],Mt)}equalsIgnoreCase(e){return ar(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=yt.apply(nn,arguments);return e.length===0?tn(this):ar(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=yt.apply(nn,arguments);return e.length===0?tn(this):ar(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Mt)}anyOf(){const e=yt.apply(nn,arguments);let n=this._cmp;try{e.sort(n)}catch{return He(this,ht)}if(e.length===0)return tn(this);const r=new this.Collection(this,()=>kt(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([[Ko,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=yt.apply(nn,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return He(this,ht)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Ko,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 tn(this);if(!e.every(v=>v[0]!==void 0&&v[1]!==void 0&&o(v[0],v[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",le.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function p(v,_){return d(v[0],_[0])}try{c=e.reduce(function(v,_){let x=0,k=v.length;for(;x0){O[0]=i(O[0],_[0]),O[1]=a(O[1],_[1]);break}}return x===k&&v.push(_),v},[]),c.sort(p)}catch{return He(this,ht)}let f=0;const w=u?v=>o(v,c[f][1])>0:v=>o(v,c[f][1])>=0,h=l?v=>s(v,c[f][0])>0:v=>s(v,c[f][0])>=0;let y=w;const m=new this.Collection(this,()=>kt(c[0][0],c[c.length-1][1],!l,!u));return m._ondirectionchange=v=>{v==="next"?(y=w,d=o):(y=h,d=s),c.sort(p)},m._addAlgorithm((v,_,x)=>{for(var k=v.key;y(k);)if(++f,f===c.length)return _(x),!1;return!!function(O){return!w(O)&&!h(O)}(k)||(this._cmp(k,c[f][1])===0||this._cmp(k,c[f][0])===0||_(()=>{d===o?v.continue(c[f][0]):v.continue(c[f][1])}),!1)}),m}startsWithAnyOf(){const e=yt.apply(nn,arguments);return e.every(n=>typeof n=="string")?e.length===0?tn(this):this.inAnyRange(e.map(n=>[n,n+Mt])):He(this,"startsWithAnyOf() only works with strings")}}function it(t){return Ce(function(e){return zn(e),t(e.target.error),!1})}function zn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Ln="storagemutated",Ct="x-storagemutated-1",jt=jn(null,Ln);class Df{_lock(){return En(!ae.global),++this._reculock,this._reculock!==1||ae.global||(ae.lockOwnerFor=this),this}_unlock(){if(En(!ae.global),--this._reculock==0)for(ae.global||(ae.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{gn(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(En(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new le.DatabaseClosed(r);case"MissingAPIError":throw new le.MissingAPI(r.message,r);default:throw new le.OpenFailed(r)}if(!this.active)throw new le.TransactionInactive;return En(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=Ce(o=>{zn(o),this._reject(e.error)}),e.onabort=Ce(o=>{zn(o),this.active&&this._reject(new le.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Ce(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&jt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Fe(new le.ReadOnly("Transaction is readonly"));if(!this.active)return Fe(new le.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ae])});if(r)return Dt(()=>{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(Ce(i.bind(null,l))),l=>n._waitingQueue.push(Ce(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 le.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Ze(n,e))return n[e];const r=this.schema[e];if(!r)throw new le.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 $o(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?"++":"")+Zi(e)}}function Zi(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Yi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Ii(n,r=>[r.name,r])}}let Wn=t=>{try{return t.only([[]]),Wn=()=>[[]],[[]]}catch{return Wn=()=>Mt,Mt}};function Ho(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>wt(r,e)}(t):e=>wt(e,t)}function ma(t){return[].slice.call(t)}let Pf=0;function An(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function jf(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=ma(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:f}=d,w=ze(p),h=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:w,keyPath:p,autoIncrement:f,unique:!0,extractKey:Ho(p)},indexes:ma(d.indexNames).map(v=>d.index(v)).map(v=>{const{name:_,unique:x,multiEntry:k,keyPath:O}=v,E={name:_,compound:ze(O),keyPath:O,unique:x,multiEntry:k,extractKey:Ho(O)};return y[An(O)]=E,E}),getIndexByKeyPath:v=>y[An(v)]};return y[":id"]=m.primaryKey,p!=null&&(y[An(p)]=m.primaryKey),m})},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:f,values:w,range:h}){return new Promise((y,m)=>{y=Ce(y);const v=d.objectStore(c),_=v.keyPath==null,x=p==="put"||p==="add";if(!x&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:k}=f||w||{length:1};if(f&&w&&f.length!==w.length)throw new Error("Given keys array must have same length as given values array.");if(k===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let O;const E=[],N=[];let D=0;const R=P=>{++D,zn(P)};if(p==="deleteRange"){if(h.type===4)return y({numFailures:D,failures:N,results:[],lastResult:void 0});h.type===3?E.push(O=v.clear()):E.push(O=v.delete(r(h)))}else{const[P,T]=x?_?[w,f]:[w,null]:[f,null];if(x)for(let b=0;b{const T=P.target.result;E.forEach((b,K)=>b.error!=null&&(N[K]=b.error)),y({numFailures:D,failures:N,results:p==="delete"?f:E.map(b=>b.result),lastResult:T})};O.onerror=P=>{R(P),q(P)},O.onsuccess=q})},getMany:({trans:d,keys:p})=>new Promise((f,w)=>{f=Ce(f);const h=d.objectStore(c),y=p.length,m=new Array(y);let v,_=0,x=0;const k=E=>{const N=E.target;m[N._pos]=N.result,++x===_&&f(m)},O=it(w);for(let E=0;Enew Promise((f,w)=>{f=Ce(f);const h=d.objectStore(c).get(p);h.onsuccess=y=>f(y.target.result),h.onerror=it(w)}),query:function(d){return p=>new Promise((f,w)=>{f=Ce(f);const{trans:h,values:y,limit:m,query:v}=p,_=m===1/0?void 0:m,{index:x,range:k}=v,O=h.objectStore(c),E=x.isPrimaryKey?O:O.index(x.name),N=r(k);if(m===0)return f({result:[]});if(d){const D=y?E.getAll(N,_):E.getAllKeys(N,_);D.onsuccess=R=>f({result:R.target.result}),D.onerror=it(w)}else{let D=0;const R=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),q=[];R.onsuccess=P=>{const T=R.result;return T?(q.push(y?T.value:T.primaryKey),++D===m?f({result:q}):void T.continue()):f({result:q})},R.onerror=it(w)}})}(s),openCursor:function({trans:d,values:p,query:f,reverse:w,unique:h}){return new Promise((y,m)=>{y=Ce(y);const{index:v,range:_}=f,x=d.objectStore(c),k=v.isPrimaryKey?x:x.index(v.name),O=w?h?"prevunique":"prev":h?"nextunique":"next",E=p||!("openKeyCursor"in k)?k.openCursor(r(_),O):k.openKeyCursor(r(_),O);E.onerror=it(m),E.onsuccess=Ce(N=>{const D=E.result;if(!D)return void y(null);D.___id=++Pf,D.done=!1;const R=D.continue.bind(D);let q=D.continuePrimaryKey;q&&(q=q.bind(D));const P=D.advance.bind(D),T=()=>{throw new Error("Cursor not stopped")};D.trans=d,D.stop=D.continue=D.continuePrimaryKey=D.advance=()=>{throw new Error("Cursor not started")},D.fail=Ce(m),D.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},D.start=b=>{const K=new Promise((A,G)=>{A=Ce(A),E.onerror=it(G),D.fail=G,D.stop=L=>{D.stop=D.continue=D.continuePrimaryKey=D.advance=T,A(L)}}),$=()=>{if(E.result)try{b()}catch(A){D.fail(A)}else D.done=!0,D.start=()=>{throw new Error("Cursor behind last entry")},D.stop()};return E.onsuccess=Ce(A=>{E.onsuccess=$,$()}),D.continue=R,D.continuePrimaryKey=q,D.advance=P,$(),K},y(D)},m)})},count({query:d,trans:p}){const{index:f,range:w}=d;return new Promise((h,y)=>{const m=p.objectStore(c),v=f.isPrimaryKey?m:m.index(f.name),_=r(w),x=_?v.count(_):v.count();x.onsuccess=Ce(k=>h(k.target.result)),x.onerror=it(y)})}}}(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:Wn(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:f})=>({...p,...f(p)}),c)}(jf(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 Rr({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Ss(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?gt(i,o,{get(){return this.table(o)},set(l){Ei(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function Vo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Af(t,e){return t._cfg.version-e._cfg.version}function Nf(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;Dt(()=>{ae.trans=s,ae.transless=a,e===0?(Ne(o).forEach(l=>{go(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=[],f=l._versions;let w=l._dbSchema=Zo(l,l.idbdb,d),h=!1;const y=f.filter(v=>v._cfg.version>=u);function m(){return p.length?oe.resolve(p.shift()(c.idbtrans)).then(m):oe.resolve()}return y.forEach(v=>{p.push(()=>{const _=w,x=v._cfg.dbschema;Yo(l,_,d),Yo(l,x,d),w=l._dbSchema=x;const k=Ji(_,x);k.add.forEach(E=>{go(d,E[0],E[1].primKey,E[1].indexes)}),k.change.forEach(E=>{if(E.recreate)throw new le.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(D=>Go(N,D)),E.change.forEach(D=>{N.deleteIndex(D.name),Go(N,D)}),E.del.forEach(D=>N.deleteIndex(D))}});const O=v._cfg.contentUpgrade;if(O&&v._cfg.version>u){qo(l,d),c._memoizedTables={},h=!0;let E=Oi(x);k.del.forEach(q=>{E[q]=_[q]}),Vo(l,[l.Transaction.prototype]),Rr(l,[l.Transaction.prototype],Ne(E),E),c.schema=E;const N=Is(O);let D;N&&vn();const R=oe.follow(()=>{if(D=O(c),D&&N){var q=_t.bind(null,null);D.then(q,q)}});return D&&typeof D.then=="function"?oe.resolve(D):R.then(()=>D)}}),p.push(_=>{(!h||!xf)&&function(x,k){[].slice.call(k.db.objectStoreNames).forEach(O=>x[O]==null&&k.db.deleteObjectStore(O))}(v._cfg.dbschema,_),Vo(l,[l.Transaction.prototype]),Rr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),m().then(()=>{var v,_;_=d,Ne(v=w).forEach(x=>{_.db.objectStoreNames.contains(x)||go(_,x,v[x].primKey,v[x].indexes)})})}(t,e,s,n).catch(i)})}function Ji(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&&!no)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 go(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=>Go(o,s)),o}function Go(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Zo(t,e,n){const r={};return Dr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=$o(Zi(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 $o(l,u||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),ze(u),a===0)}),s=o.shift();if(s.multi)throw new le.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new le.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new le.Schema("Index must have a name and cannot be an empty string")}),n[r]=Yi(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,Vo(n,[n._allTables,n,n.Transaction.prototype]),Rr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ne(s),s),n._storeNames=Ne(s),this}upgrade(e){return this._cfg.contentUpgrade=Ps(this._cfg.contentUpgrade||we,e),this}}function Fs(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new $t(ro,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Rs(t){return t&&typeof t.databases=="function"}function Jo(t){return Dt(function(){return ae.letThrough=!0,t()})}function Rf(){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 Tf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Fe(e.dbOpenError):t);dt&&(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 le.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():Rf()).then(()=>new oe((l,u)=>{if(o(),!n)throw new le.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new le.MissingAPI;d.onerror=it(u),d.onblocked=Ce(t._fireOnBlocked),d.onupgradeneeded=Ce(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=zn,i.abort(),d.result.close();const w=n.deleteDatabase(c);w.onsuccess=w.onerror=Ce(()=>{u(new le.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{i.onerror=it(u);var f=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=f<1,t._novip.idbdb=d.result,Nf(t,f/10,i,u)}},u),d.onsuccess=Ce(()=>{i=null;const p=t._novip.idbdb=d.result,f=Dr(p.objectStoreNames);if(f.length>0)try{const h=p.transaction((w=f).length===1?w[0]:w,"readonly");e.autoSchema?function({_novip:y},m,v){y.verno=m.version/10;const _=y._dbSchema=Zo(0,m,v);y._storeNames=Dr(m.objectStoreNames,0),Rr(y,[y._allTables],Ne(_),_)}(t,p,h):(Yo(t,t._dbSchema,h),function(y,m){const v=Ji(Zo(0,y.idbdb,m),y._dbSchema);return!(v.add.length||v.change.some(_=>_.add.length||_.change.length))}(t,h)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),qo(t,h)}catch{}var w;Pn.push(t),p.onversionchange=Ce(h=>{e.vcFired=!0,t.on("versionchange").fire(h)}),p.onclose=Ce(h=>{t.on("close").fire(h)}),a&&function({indexedDB:h,IDBKeyRange:y},m){!Rs(h)&&m!==ro&&Fs(h,y).put({name:m}).catch(we)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(Jo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(Ps,we);return e.onReadyBeingFired=[],oe.resolve(Jo(()=>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 Xo(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 Bf(t,e,n){var r=arguments.length;if(r<2)throw new le.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Di(o),n]}function Xi(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===Ds.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Xi(t,e,n,null,o))):Fe(d)}const l=Is(o);let u;l&&vn();const c=oe.follow(()=>{if(u=o.call(i,i),u)if(l){var d=_t.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=Xo(u))},a);return(u&&typeof u.then=="function"?oe.resolve(u).then(d=>i.active?d:Fe(new le.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 ir(t,e,n){const r=ze(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:h,extractKey:Ho(c),unique:!y&&p.unique};return w.push(m),m.isPrimaryKey||s.push(m),h>1&&i(h===2?c[0]:c.slice(0,h-1),d+1,p),w.sort((v,_)=>v.keyTail-_.keyTail),m}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,f=d.keyTail,{type:p.type===1?2:p.type,lower:ir(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,f),lowerOpen:!0,upper:ir(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,f),upperOpen:!0})}}:c;var p,f}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(c){const d=o[An(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:f}=c.query.index;return p?n.openCursor(l(c)).then(w=>w&&function(h){return Object.create(h,{continue:{value:function(m){m!=null?h.continue(ir(m,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?h.continue(h.key.slice(0,f).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):h.continue()}},continuePrimaryKey:{value(m,v){h.continuePrimaryKey(ir(m,t.MAX_KEY,d),v)}},primaryKey:{get:()=>h.primaryKey},key:{get(){const m=h.key;return f===1?m[0]:m.slice(0,f)}},value:{get:()=>h.value}})}(w)):n.openCursor(c)}}}}}};function Ts(t,e,n,r){return n=n||{},r=r||"",Ne(t).forEach(o=>{if(Ze(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=jo(s);a!==jo(i)?n[r+o]=e[o]:a==="Object"?Ts(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=>{Ze(t,o)||(n[r+o]=e[o])}),n}const zf={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===we)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===we&&u.fire===we)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(a.fire===we)break;return i._promise("readwrite",()=>c(s),!0);case"deleteRange":if(a.fire===we)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function c(p){const f=ae.trans,w=p.keys||function(h,y){return y.type==="delete"?y.keys:y.keys||y.values.map(h.extractKey)}(r,p);if(!w)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:w}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(h,y,m){return y.type==="add"?Promise.resolve([]):h.getMany({trans:y.trans,keys:m,cache:"immutable"})}(n,p,w).then(h=>{const y=w.map((m,v)=>{const _=h[v],x={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(x,m,_,f);else if(p.type==="add"||_===void 0){const k=l.fire.call(x,m,p.values[v],f);m==null&&k!=null&&(m=k,p.keys[v]=m,r.outbound||rt(p.values[v],r.keyPath,m))}else{const k=Ts(_,p.values[v]),O=u.fire.call(x,k,m,_,f);if(O){const E=p.values[v];Object.keys(O).forEach(N=>{Ze(E,N)?E[N]=O[N]:rt(E,N,O[N])})}}return x});return n.mutate(p).then(({failures:m,results:v,numFailures:_,lastResult:x})=>{for(let k=0;k(y.forEach(v=>v.onerror&&v.onerror(m)),Promise.reject(m)))})}function d(p,f,w){return n.query({trans:p,values:!1,query:{index:r,range:f},limit:w}).then(({result:h})=>c({type:"delete",keys:h,trans:p}).then(y=>y.numFailures>0?Promise.reject(y.failures[0]):h.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=Qi(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"?Vn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function Bs(t){return!("from"in t)}const pt=function(t,e){if(!this){const n=new pt;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 Un(t,e,n){const r=We(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(Bs(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?Un(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},ya(t);if(We(e,t.to)>0)return s?Un(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},ya(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&&Tr(t,o),s&&i&&Tr(t,s)}function Tr(t,e){Bs(e)||function n(r,{from:o,to:s,l:i,r:a}){Un(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function Wf(t,e){const n=Qo(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=Qo(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 Qo(t){let e=Bs(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 ya(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=va(i)}t.d=va(t)}function va({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}pn(pt.prototype,{add(t){return Tr(this,t),this},addKey(t){return Un(this,t,t),this},addKeys(t){return t.forEach(e=>Un(this,e,e)),this},[Ao](){return Qo(this)}});const Uf={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new pt(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 f=p.trans,w=f.mutatedParts||(f.mutatedParts={}),h=O=>{const E=`idb://${e}/${r}/${O}`;return w[E]||(w[E]=new pt)},y=h(""),m=h(":dels"),{type:v}=p;let[_,x]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const k=p.trans._cache;return o.mutate(p).then(O=>{if(ze(_)){v!=="delete"&&(_=O.results),y.addKeys(_);const E=Qi(_,k);E||v==="add"||m.addKeys(_),(E||x)&&function(N,D,R,q){function P(T){const b=N(T.name||"");function K(A){return A!=null?T.extractKey(A):null}const $=A=>T.multiEntry&&ze(A)?A.forEach(G=>b.addKey(G)):b.addKey(A);(R||q).forEach((A,G)=>{const L=R&&K(R[G]),ne=q&&K(q[G]);We(L,ne)!==0&&(L!=null&&$(L),ne!=null&&$(ne))})}D.indexes.forEach(P)}(h,s,E,x)}else if(_){const E={from:_.lower,to:_.upper};m.add(E),y.add(E)}else y.add(n),m.add(n),s.indexes.forEach(E=>h(E.name).add(n));return O})}},c=({query:{index:p,range:f}})=>{var w,h;return[p,new pt((w=f.lower)!==null&&w!==void 0?w:t.MIN_KEY,(h=f.upper)!==null&&h!==void 0?h:t.MAX_KEY)]},d={get:p=>[i,new pt(p.key)],getMany:p=>[i,new pt().addKeys(p.keys)],count:c,query:c,openCursor:c};return Ne(d).forEach(p=>{u[p]=function(f){const{subscr:w}=ae;if(w){const h=x=>{const k=`idb://${e}/${r}/${x}`;return w[k]||(w[k]=new pt)},y=h(""),m=h(":dels"),[v,_]=d[p](f);if(h(v.name||"").add(_),!v.isPrimaryKey){if(p!=="count"){const x=p==="query"&&l&&f.values&&o.query({...f,values:!1});return o[p].apply(this,arguments).then(k=>{if(p==="query"){if(l&&f.values)return x.then(({result:E})=>(y.addKeys(E),k));const O=f.values?k.result.map(a):k.result;f.values?y.addKeys(O):m.addKeys(O)}else if(p==="openCursor"){const O=k,E=f.values;return O&&Object.create(O,{key:{get:()=>(m.addKey(O.primaryKey),O.key)},primaryKey:{get(){const N=O.primaryKey;return m.addKey(N),N}},value:{get:()=>(E&&y.addKey(O.primaryKey),O.value)}})}return k})}m.add(n)}}return o[p].apply(this,arguments)}}),u}}}};class $t{constructor(e,n){this._middlewares={},this.verno=0;const r=$t.dependencies;this._options=n={addons:$t.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:we,dbReadyPromise:null,cancelOpen:we,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=jn(this,"populate","blocked","versionchange","close",{ready:[Ps,we]}),this.on.ready.subscribe=Ci(this.on.ready.subscribe,a=>(l,u)=>{$t.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,kn(Cf.prototype,function(a,l){this.db=i;let u=qi,c=null;if(l)try{u=l()}catch(w){c=w}const d=a._ctx,p=d.table,f=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:f!==Bn?f:null}})),this.Table=function(a){return kn(Ef.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:jn(null,{creating:[ff,we],reading:[df,Bn],updating:[pf,we],deleting:[hf,we]})})}(this),this.Transaction=function(a){return kn(Df.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=jn(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((f,w)=>{this._resolve=f,this._reject=w}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},f=>{var w=this.active;return this.active=!1,this.on.error.fire(f),this.parent?this.parent._reject(f):w&&this.idbtrans&&this.idbtrans.abort(),Fe(f)})})}(this),this.Version=function(a){return kn(Ff.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return kn(Gi.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 le.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,f)=>d.cmp(f,p),this._max=(p,f)=>d.cmp(p,f)>0?p:f,this._min=(p,f)=>d.cmp(p,f)<0?p:f,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),Pn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(Mf),this.use(zf),this.use(Uf),this.use(Lf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new le.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new le.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(Af),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 le.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new le.DatabaseClosed);this.open().catch(we)}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 Tf(this)}_close(){const e=this._state,n=Pn.indexOf(this);if(n>=0&&Pn.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 le.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=Ce(()=>{(function({indexedDB:a,IDBKeyRange:l},u){!Rs(a)&&u!==ro&&Fs(a,l).delete(u).catch(we)})(this._deps,this.name),r()}),i.onerror=it(o),i.onblocked=this._fireOnBlocked};if(e)throw new le.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=Bf.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===ho)i=ho;else{if(e!="rw"&&e!=po)throw new le.InvalidArgument("Invalid transaction mode: "+e);i=po}if(o){if(o.mode===ho&&i===po){if(!s)throw new le.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 le.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=Xi.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ae.trans?gn(ae.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ze(this._allTables,e))throw new le.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Kf=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class $f{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Kf](){return this}}function el(t,e){return Ne(e).forEach(n=>{Tr(t[n]||(t[n]=new pt),e[n])}),t}function Hf(t){let e,n=!1;const r=new $f(o=>{const s=Is(t);let i=!1,a={},l={};const u={get closed(){return i},unsubscribe:()=>{i=!0,jt.storagemutated.unsubscribe(f)}};o.start&&o.start(u);let c=!1,d=!1;function p(){return Ne(l).some(h=>a[h]&&Wf(a[h],l[h]))}const f=h=>{el(a,h),p()&&w()},w=()=>{if(c||i)return;a={};const h={},y=function(m){s&&vn();const v=()=>Dt(t,{subscr:m,trans:null}),_=ae.trans?gn(ae.transless,v):v();return s&&_.then(_t,_t),_}(h);d||(jt(Ln,f),d=!0),c=!0,Promise.resolve(y).then(m=>{n=!0,e=m,c=!1,i||(p()?w():(a={},l=h,o.next&&o.next(m)))},m=>{c=!1,n=!1,o.error&&o.error(m),u.unsubscribe()})};return w(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let es;try{es={indexedDB:Ee.indexedDB||Ee.mozIndexedDB||Ee.webkitIndexedDB||Ee.msIndexedDB,IDBKeyRange:Ee.IDBKeyRange||Ee.webkitIDBKeyRange}}catch{es={indexedDB:null,IDBKeyRange:null}}const Bt=$t;function vr(t){let e=vt;try{vt=!0,jt.storagemutated.fire(t)}finally{vt=e}}pn(Bt,{...dr,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 Rs(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==ro)):Fs(e,n).toCollection().primaryKeys()}(Bt.dependencies).then(t)}catch{return Fe(new le.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ae.trans?gn(ae.transless,t):t(),vip:Jo,async:function(t){return function(){try{var e=Xo(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=Xo(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:()=>dt,set:t=>{ji(t,t==="dexie"?()=>!0:Hi)}},derive:sn,extend:Ue,props:pn,override:Ci,Events:jn,on:jt,liveQuery:Hf,extendObservabilitySet:el,getByKeyPath:wt,setByKeyPath:rt,delByKeyPath:function(t,e){typeof e=="string"?rt(t,e,void 0):"length"in e&&[].map.call(e,function(n){rt(t,n,void 0)})},shallowClone:Oi,deepClone:Vn,getObjectDiff:Ts,cmp:We,asap:Si,minKey:Ko,addons:[],connections:Pn,errnames:Ds,dependencies:es,semVer:ua,version:ua.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Bt.maxKey=Wn(Bt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(jt(Ln,t=>{if(!vt){let e;no?(e=document.createEvent("CustomEvent"),e.initCustomEvent(Ct,!0,!0,t)):e=new CustomEvent(Ct,{detail:t}),vt=!0,dispatchEvent(e),vt=!1}}),addEventListener(Ct,({detail:t})=>{vt||vr(t)}));let vt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(Ct);typeof t.unref=="function"&&t.unref(),jt(Ln,e=>{vt||t.postMessage(e)}),t.onmessage=e=>{e.data&&vr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){jt(Ln,e=>{try{vt||(typeof localStorage<"u"&&localStorage.setItem(Ct,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Ct,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===Ct){const n=JSON.parse(e.newValue);n&&vr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===Ct&&vr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof an||t instanceof TypeError||t instanceof SyntaxError||!t.name||!aa[t.name])return t;var n=new aa[t.name](e||t.message,t);return"stack"in t&>(n,"stack",{get:function(){return this.inner.stack}}),n},ji(dt,Hi);var qf=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t.openSpotlightSearch="openSpotlightSearch",t))(qf||{}),gr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(gr||{}),tl=(t=>(t.PRIVATE="PRIVATE",t.PUBLIC="PUBLIC",t.UNLISTED="UNLISTED",t))(tl||{});const Vf="comfyui_workspace_db";class Gf extends $t{constructor(){super(Vf);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 ce=new Gf;class Jt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ce[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{Gd(this.tableName,JSON.stringify(n))}catch(r){console.error("error saving disk db",r)}}async add(e){return e.id||(e.id=hn()),e.createTime||(e.createTime=Date.now()),await ce[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ce[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ce[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ce[this.tableName].update(e,n),this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ce[this.tableName].toArray()}async filter(e){return await ce[this.tableName].filter(e).toArray()}async batchQuery(e){return await ce[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 Vd(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Qd()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ce[this.tableName].get(e)}async delete(e){await ce[this.tableName].delete(e),this.saveDiskDB()}async listByIndex(e,n){return await ce[this.tableName].where(e).equals(n).toArray()}}const Zf=80,zr=class zr extends Jt{constructor(){super("changelogs")}static async load(){return new zr}async listByWorkflowID(e){return await ce.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:hn(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return await ce.changelogs.add(r),await this.deleteLogsExceedLimit(e.workflowID),r}async deleteLogsExceedLimit(e){var o;const n=await ce.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=((o=J==null?void 0:J.settings)==null?void 0:o.maximumChangelogNumber)??Zf;if(n.length>r){const s=n.slice(r);await ce.changelogs.bulkDelete(s.map(i=>i.id))}}};Ie(zr,"TABLE_NAME","changelogs");let ts=zr;const bp="CWM_WORKFLOWS_SORT_TYPE";var lt=(t=>(t.RECENTLY_OPENED="recentlyOpened",t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(lt||{});const _p=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}];function Yf(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"),u=String(o.getMinutes()).padStart(2,"0"),c=String(o.getSeconds()).padStart(2,"0"),d=`${i}${r}${s}${r}${a}`;return e?d+` ${l}:${u}`:n?d+`:${c}`:d}const wr=(t,e=lt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case lt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case lt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case lt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case lt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break;case lt.RECENTLY_OPENED:n.sort((r,o)=>(o.lastOpenedTime??0)-(r.lastOpenedTime??0));break}return n};function Jf(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{var n;const e=(n=J==null?void 0:J.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 Ep(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function Xf(t){return`/workspace/view_media?filename=${t}`}function ga(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function nl(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 Qf=t=>{const e=nl(t);window.open(`${window.location.origin}/#${e}`)},rl={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},Te="workspace_info",eh=9999999,wa="upgrade_to_2way_sync",Ms=28,Cp="SHORTCUT_TRIGGER_EVENT",zs={os:null},Sp=()=>zs.os==="Windows"?"\\":"/";function br(...t){const e=t.filter(n=>n!=="").join("/");return At(e)}function At(t){const e=t.split("/").filter(r=>r!=="").join("/");let n=e.replace(/\\/g,"/");return n=n.replace(/^\/+/,""),zs.os==="Windows"&&(n=e.replace(/\//g,"\\")),n}function wo(t){return br(t.parentFolderID??"",t.name+".json")}var Je;(t=>{async function e(l,u){try{const d=await(await ke("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(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 ke("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(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 ke("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(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[Te]==null&&(c.extra[Te]={}),c.extra[Te].id=l.id,c.extra[Te].saveLock=l.saveLock,c.extra[Te].cloudID=l.cloudID,c.extra[Te].coverMediaPath=l.coverMediaPath;const p=await(await ke("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),json:JSON.stringify(c)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} +`+r).join("")):""}var Ni=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ds=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Ni),cf={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 an(t,e){this._e=Yt(),this.name=t,this.message=e}function Fi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` +`)}function Pr(t,e,n,r){this._e=Yt(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Fi(t,e)}function On(t,e){this._e=Yt(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Fi(t,e)}sn(an).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+No(this._e,2))}},toString:function(){return this.name+": "+this.message}}),sn(Pr).from(an),sn(On).from(an);var Ps=Ds.reduce((t,e)=>(t[e]=e+"Error",t),{});const uf=an;var le=Ds.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=cf[e]||n,this.inner=null)}return sn(r).from(uf),t[e]=r,t},{});le.Syntax=SyntaxError,le.Type=TypeError,le.Range=RangeError;var ia=Ni.reduce((t,e)=>(t[e+"Error"]=le[e],t),{}),dr=Ds.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=le[e]),t),{});function we(){}function Bn(t){return t}function df(t,e){return t==null||t===Bn?e:function(n){return e(t(n))}}function Gt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function ff(t,e){return t===we?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?Gt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Gt(o,this.onerror):o),s!==void 0?s:n}}function hf(t,e){return t===we?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?Gt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Gt(r,this.onerror):r)}}function pf(t,e){return t===we?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?Gt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Gt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:Ue(r,i)}}function mf(t,e){return t===we?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function js(t,e){return t===we?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)}}dr.ModifyError=Pr,dr.DexieError=an,dr.BulkError=On;var Mn={};const Ri=100,[Fo,jr,Ro]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Tn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Tn(e),t]})(),Ti=jr&&jr.then,fr=Fo&&Fo.constructor,As=!!Ro;var To=!1,yf=Ro?()=>{Ro.then(tr)}:Ee.setImmediate?setImmediate.bind(null,tr):Ee.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{tr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(tr,0)},Dn=function(t,e){Cn.push([t,e]),Ar&&(yf(),Ar=!1)},Bo=!0,Ar=!0,Ut=[],hr=[],Mo=null,zo=Bn,ln={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ua,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{ua(t[0],t[1])}catch{}})}},ae=ln,Cn=[],Kt=0,pr=[];function oe(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=we,this._lib=!1;var e=this._PSD=ae;if(dt&&(this._stackHolder=Yt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Mn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Wo(this,this._value))}this._state=null,this._value=null,++e.ref,Mi(this,t)}const Lo={get:function(){var t=ae,e=Nr;function n(r,o){var s=!t.global&&(t!==ae||e!==Nr);const i=s&&!_t();var a=new oe((l,u)=>{Ns(this,new Bi(Fr(r,t,s,i),Fr(o,t,s,i),l,u,t))});return dt&&Wi(a,this),a}return n.prototype=Mn,n},set:function(t){gt(this,"then",t&&t.prototype===Mn?Lo:{get:function(){return t},set:Lo.set})}};function Bi(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 Mi(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&&Gn();n&&typeof n.then=="function"?Mi(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,zi(t)),r&&Zn()}},Wo.bind(null,t))}catch(n){Wo(t,n)}}function Wo(t,e){if(hr.push(e),t._state===null){var n=t._lib&&Gn();e=zo(e),t._state=!1,t._value=e,dt&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Is(e,"stack");e._promise=t,gt(e,"stack",{get:()=>To?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Ut.some(o=>o._value===r._value)||Ut.push(r)}(t),zi(t),n&&Zn()}}function zi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Kt==0&&Fs()},[]))}function Ns(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,++Kt,Dn(vf,[n,t,e])}else t._listeners.push(e)}function vf(t,e,n){try{Mo=e;var r,o=e._value;e._state?r=t(o):(hr.length&&(hr=[]),r=t(o),hr.indexOf(o)===-1&&function(s){for(var i=Ut.length;i;)if(Ut[--i]._value===s._value)return void Ut.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Mo=null,--Kt==0&&Fs(),--n.psd.ref||n.psd.finalize()}}function Li(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=No(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return dt&&((r=No(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Li(t._prev,e,n)),e}function Wi(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function tr(){Gn()&&Zn()}function Gn(){var t=Bo;return Bo=!1,Ar=!1,t}function Zn(){var t,e,n;do for(;Cn.length>0;)for(t=Cn,Cn=[],n=t.length,e=0;e0);Bo=!0,Ar=!0}function Fs(){var t=Ut;Ut=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=pr.slice(0),n=e.length;n;)e[--n]()}function nr(t){return new oe(Mn,!1,t)}function Ce(t,e){var n=ae;return function(){var r=Gn(),o=ae;try{return Pt(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{Pt(o,!1),r&&Zn()}}}pn(oe.prototype,{then:Lo,_then:function(t,e){Ns(this,new Bi(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):nr(r)):this.then(null,r=>r&&r.name===e?n(r):nr(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),nr(e)))},stack:{get:function(){if(this._stack)return this._stack;try{To=!0;var t=Li(this,[],20).join(` +From previous: `);return this._state!==null&&(this._stack=t),t}finally{To=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new le.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&>(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),ln.env=Ui(),pn(oe,{all:function(){var t=yt.apply(null,arguments).map(rr);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(Mn,!0,t);return Wi(e,Mo),e},reject:nr,race:function(){var t=yt.apply(null,arguments).map(rr);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ae,set:t=>ae=t},totalEchoes:{get:()=>Nr},newPSD:Dt,usePSD:gn,scheduler:{get:()=>Dn,set:t=>{Dn=t}},rejectionMapper:{get:()=>zo,set:t=>{zo=t}},follow:(t,e)=>new oe((n,r)=>Dt((o,s)=>{var i=ae;i.unhandleds=[],i.onunhandled=s,i.finalize=Gt(function(){(function(a){function l(){a(),pr.splice(pr.indexOf(l),1)}pr.push(l),++Kt,Dn(()=>{--Kt==0&&Fs()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),fr&&(fr.allSettled&>(oe,"allSettled",function(){const t=yt.apply(null,arguments).map(rr);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)))})}),fr.any&&typeof AggregateError<"u"&>(oe,"any",function(){const t=yt.apply(null,arguments).map(rr);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 Me={awaits:0,echoes:0,id:0};var gf=0,mr=[],fo=0,Nr=0,wf=0;function Dt(t,e,n,r){var o=ae,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++wf;var i=ln.env;s.env=As?{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:la(i.nthen,s),gthen:la(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=gn(s,t,n,r);return s.ref===0&&s.finalize(),a}function vn(){return Me.id||(Me.id=++gf),++Me.awaits,Me.echoes+=Ri,Me.id}function _t(){return!!Me.awaits&&(--Me.awaits==0&&(Me.id=0),Me.echoes=Me.awaits*Ri,!0)}function rr(t){return Me.echoes&&t&&t.constructor===fr?(vn(),t.then(e=>(_t(),e),e=>(_t(),Fe(e)))):t}function bf(t){++Nr,Me.echoes&&--Me.echoes!=0||(Me.echoes=Me.id=0),mr.push(ae),Pt(t,!0)}function _f(){var t=mr[mr.length-1];mr.pop(),Pt(t,!1)}function Pt(t,e){var n=ae;if((e?!Me.echoes||fo++&&t===ae:!fo||--fo&&t===ae)||Ki(e?bf.bind(null,t):_f),t!==ae&&(ae=t,n===ln&&(ln.env=Ui()),As)){var r=ln.env.Promise,o=t.env;jr.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ee,"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 Ui(){var t=Ee.Promise;return As?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ee,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:jr.then,gthen:t.prototype.then}:{}}function gn(t,e,n,r,o){var s=ae;try{return Pt(t,!0),e(n,r,o)}finally{Pt(s,!1)}}function Ki(t){Ti.call(Fo,t)}function Fr(t,e,n,r){return typeof t!="function"?t:function(){var o=ae;n&&vn(),Pt(e,!0);try{return t.apply(this,arguments)}finally{Pt(o,!1),r&&Ki(_t)}}}function la(t,e){return function(n,r){return t.call(this,Fr(n,e),Fr(r,e))}}(""+Ti).indexOf("[native code]")===-1&&(vn=_t=we);const ca="unhandledrejection";function ua(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ee.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ca,!0,!0),Ue(r,o)):Ee.CustomEvent&&Ue(r=new CustomEvent(ca,{detail:o}),o),r&&Ee.dispatchEvent&&(dispatchEvent(r),!Ee.PromiseRejectionEvent&&Ee.onunhandledrejection))try{Ee.onunhandledrejection(r)}catch{}dt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Fe=oe.reject;function Uo(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===Ps.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Uo(t,e,n,r))):Fe(s)}return o._promise(e,(s,i)=>Dt(()=>(ae.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Fe(new le.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Fe(new le.DatabaseClosed);t.open().catch(we)}return t._state.dbReadyPromise.then(()=>Uo(t,e,n,r))}const da="3.2.4",Mt="￿",Ko=-1/0,ht="Invalid key provided. Keys must be of type string, number, Date or Array.",$i="String expected.",Pn=[],no=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),xf=no,kf=no,Hi=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),ro="__dbnames",ho="readonly",po="readwrite";function Zt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const qi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function or(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Vn(e))[t],e)}class Ef{_trans(e,n,r){const o=this._tx||ae.trans,s=this.name;function i(l,u,c){if(!c.schema[s])throw new le.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const a=Gn();try{return o&&o.db===this.db?o===ae.trans?o._promise(e,i,r):Dt(()=>o._promise(e,i,r),{trans:o,transless:ae.transless||ae}):Uo(this.db,e,[this.name],i)}finally{a&&Zn()}}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!==Mt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&dt&&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],f=e[d];return[u||p,u||!p?Zt(c,p&&p.multi?w=>{const h=wt(w,d);return ze(h)&&h.some(y=>i(f,y))}:w=>i(f,wt(w,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(Ze(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=or(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{rt(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=wt(e,this.schema.primKey.keyPath);if(r===void 0)return Fe(new le.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ne(n).forEach(o=>{rt(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=or(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{rt(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:qi})).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 le.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:f,failures:w})=>{if(d===0)return s?p:f;throw new On(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,w)})})}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 le.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:f,failures:w})=>{if(d===0)return s?p:f;throw new On(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,w)})})}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 On(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function jn(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;rZt(r(),e()):e,t.justLimit=n&&!r}function yr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new le.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function fa(t,e,n){const r=yr(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 sr(t,e,n,r){const o=t.replayFilter?Zt(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)),Ze(s,d)||(s[d]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(i,n),ha(fa(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return ha(fa(t,r,n),Zt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ha(t,e,n,r){var o=Ce(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=we},a=>{s.fail(a),i=we})||o(s.value,s,a=>i=a),i()})})}function We(t,e){try{const n=pa(t),r=pa(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:tsr(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(en(r,!0))return o.count({trans:n,query:{index:yr(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return sr(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"&&en(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=yr(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 sr(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,en(n)?yo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):yo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),yo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return mo(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 mo(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Zt(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"&&en(n,!0)&&n.limit>0)return this._read(o=>{var s=yr(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 mo(this._ctx,function(o){var s=o.primaryKey.toString(),i=Ze(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(h){for(var y=!1,m=0;m{const{failures:m,numFailures:v}=y;p+=h-v;for(let _ of Ne(m))d.push(m[_])};return this.clone().primaryKeys().then(h=>{const y=m=>{const v=Math.min(c,h.length-m);return a.getMany({trans:r,keys:h.slice(m,m+v),cache:"immutable"}).then(_=>{const x=[],k=[],O=l?[]:null,E=[];for(let D=0;D0&&a.mutate({trans:r,type:"add",values:x}).then(D=>{for(let R in D.failures)E.splice(parseInt(R),1);w(x.length,D)})).then(()=>(k.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:O,values:k,criteria:N,changeSpec:typeof e!="function"&&e}).then(D=>w(k.length,D))).then(()=>(E.length>0||N&&e===vo)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(D=>w(E.length,D))).then(()=>h.length>m+v&&y(m+c))})};return y(0).then(()=>{if(d.length>0)throw new Pr("Error modifying one or more objects",d,p,f);return h.length})})})}delete(){var e=this._ctx,n=e.range;return en(e)&&(e.isPrimKey&&!kf||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 Pr("Could not delete some values",Object.keys(a).map(d=>a[d]),i-c);return i-c}))}):this.modify(vo)}}const vo=(t,e)=>e.value=null;function Sf(t,e){return te?-1:t===e?0:1}function He(t,e,n){var r=t instanceof Gi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function tn(t){return new t.Collection(t,()=>Vi("")).limit(0)}function Of(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 h=="string"))return He(t,$i);function p(h){o=function(m){return m==="next"?v=>v.toUpperCase():v=>v.toLowerCase()}(h),s=function(m){return m==="next"?v=>v.toLowerCase():v=>v.toUpperCase()}(h),i=h==="next"?Sf:If;var y=n.map(function(m){return{lower:s(m),upper:o(m)}}).sort(function(m,v){return i(m.lower,v.lower)});a=y.map(function(m){return m.upper}),l=y.map(function(m){return m.lower}),u=h,c=h==="next"?"":r}p("next");var f=new t.Collection(t,()=>kt(a[0],l[d-1]+r));f._ondirectionchange=function(h){p(h)};var w=0;return f._addAlgorithm(function(h,y,m){var v=h.key;if(typeof v!="string")return!1;var _=s(v);if(e(_,l,w))return!0;for(var x=null,k=w;k0)&&(x=O)}return y(x!==null?function(){h.continue(x+c)}:m),!1}),f}function kt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Vi(t){return{type:1,lower:t,upper:t}}class Gi{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)?tn(this):new this.Collection(this,()=>kt(e,n,!r,!o))}catch{return He(this,ht)}}equals(e){return e==null?He(this,ht):new this.Collection(this,()=>Vi(e))}above(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(e,void 0,!0))}aboveOrEqual(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(e,void 0,!1))}below(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?He(this,ht):new this.Collection(this,()=>kt(void 0,e))}startsWith(e){return typeof e!="string"?He(this,$i):this.between(e,e+Mt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ar(this,(n,r)=>n.indexOf(r[0])===0,[e],Mt)}equalsIgnoreCase(e){return ar(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=yt.apply(nn,arguments);return e.length===0?tn(this):ar(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=yt.apply(nn,arguments);return e.length===0?tn(this):ar(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Mt)}anyOf(){const e=yt.apply(nn,arguments);let n=this._cmp;try{e.sort(n)}catch{return He(this,ht)}if(e.length===0)return tn(this);const r=new this.Collection(this,()=>kt(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([[Ko,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=yt.apply(nn,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return He(this,ht)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Ko,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 tn(this);if(!e.every(v=>v[0]!==void 0&&v[1]!==void 0&&o(v[0],v[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",le.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function p(v,_){return d(v[0],_[0])}try{c=e.reduce(function(v,_){let x=0,k=v.length;for(;x0){O[0]=i(O[0],_[0]),O[1]=a(O[1],_[1]);break}}return x===k&&v.push(_),v},[]),c.sort(p)}catch{return He(this,ht)}let f=0;const w=u?v=>o(v,c[f][1])>0:v=>o(v,c[f][1])>=0,h=l?v=>s(v,c[f][0])>0:v=>s(v,c[f][0])>=0;let y=w;const m=new this.Collection(this,()=>kt(c[0][0],c[c.length-1][1],!l,!u));return m._ondirectionchange=v=>{v==="next"?(y=w,d=o):(y=h,d=s),c.sort(p)},m._addAlgorithm((v,_,x)=>{for(var k=v.key;y(k);)if(++f,f===c.length)return _(x),!1;return!!function(O){return!w(O)&&!h(O)}(k)||(this._cmp(k,c[f][1])===0||this._cmp(k,c[f][0])===0||_(()=>{d===o?v.continue(c[f][0]):v.continue(c[f][1])}),!1)}),m}startsWithAnyOf(){const e=yt.apply(nn,arguments);return e.every(n=>typeof n=="string")?e.length===0?tn(this):this.inAnyRange(e.map(n=>[n,n+Mt])):He(this,"startsWithAnyOf() only works with strings")}}function it(t){return Ce(function(e){return zn(e),t(e.target.error),!1})}function zn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Ln="storagemutated",Ct="x-storagemutated-1",jt=jn(null,Ln);class Df{_lock(){return En(!ae.global),++this._reculock,this._reculock!==1||ae.global||(ae.lockOwnerFor=this),this}_unlock(){if(En(!ae.global),--this._reculock==0)for(ae.global||(ae.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{gn(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(En(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new le.DatabaseClosed(r);case"MissingAPIError":throw new le.MissingAPI(r.message,r);default:throw new le.OpenFailed(r)}if(!this.active)throw new le.TransactionInactive;return En(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=Ce(o=>{zn(o),this._reject(e.error)}),e.onabort=Ce(o=>{zn(o),this.active&&this._reject(new le.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Ce(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&jt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Fe(new le.ReadOnly("Transaction is readonly"));if(!this.active)return Fe(new le.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ae])});if(r)return Dt(()=>{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(Ce(i.bind(null,l))),l=>n._waitingQueue.push(Ce(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 le.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Ze(n,e))return n[e];const r=this.schema[e];if(!r)throw new le.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 $o(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?"++":"")+Zi(e)}}function Zi(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Yi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Ii(n,r=>[r.name,r])}}let Wn=t=>{try{return t.only([[]]),Wn=()=>[[]],[[]]}catch{return Wn=()=>Mt,Mt}};function Ho(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>wt(r,e)}(t):e=>wt(e,t)}function ya(t){return[].slice.call(t)}let Pf=0;function An(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function jf(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=ya(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:f}=d,w=ze(p),h=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:w,keyPath:p,autoIncrement:f,unique:!0,extractKey:Ho(p)},indexes:ya(d.indexNames).map(v=>d.index(v)).map(v=>{const{name:_,unique:x,multiEntry:k,keyPath:O}=v,E={name:_,compound:ze(O),keyPath:O,unique:x,multiEntry:k,extractKey:Ho(O)};return y[An(O)]=E,E}),getIndexByKeyPath:v=>y[An(v)]};return y[":id"]=m.primaryKey,p!=null&&(y[An(p)]=m.primaryKey),m})},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:f,values:w,range:h}){return new Promise((y,m)=>{y=Ce(y);const v=d.objectStore(c),_=v.keyPath==null,x=p==="put"||p==="add";if(!x&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:k}=f||w||{length:1};if(f&&w&&f.length!==w.length)throw new Error("Given keys array must have same length as given values array.");if(k===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let O;const E=[],N=[];let D=0;const R=P=>{++D,zn(P)};if(p==="deleteRange"){if(h.type===4)return y({numFailures:D,failures:N,results:[],lastResult:void 0});h.type===3?E.push(O=v.clear()):E.push(O=v.delete(r(h)))}else{const[P,T]=x?_?[w,f]:[w,null]:[f,null];if(x)for(let b=0;b{const T=P.target.result;E.forEach((b,K)=>b.error!=null&&(N[K]=b.error)),y({numFailures:D,failures:N,results:p==="delete"?f:E.map(b=>b.result),lastResult:T})};O.onerror=P=>{R(P),q(P)},O.onsuccess=q})},getMany:({trans:d,keys:p})=>new Promise((f,w)=>{f=Ce(f);const h=d.objectStore(c),y=p.length,m=new Array(y);let v,_=0,x=0;const k=E=>{const N=E.target;m[N._pos]=N.result,++x===_&&f(m)},O=it(w);for(let E=0;Enew Promise((f,w)=>{f=Ce(f);const h=d.objectStore(c).get(p);h.onsuccess=y=>f(y.target.result),h.onerror=it(w)}),query:function(d){return p=>new Promise((f,w)=>{f=Ce(f);const{trans:h,values:y,limit:m,query:v}=p,_=m===1/0?void 0:m,{index:x,range:k}=v,O=h.objectStore(c),E=x.isPrimaryKey?O:O.index(x.name),N=r(k);if(m===0)return f({result:[]});if(d){const D=y?E.getAll(N,_):E.getAllKeys(N,_);D.onsuccess=R=>f({result:R.target.result}),D.onerror=it(w)}else{let D=0;const R=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),q=[];R.onsuccess=P=>{const T=R.result;return T?(q.push(y?T.value:T.primaryKey),++D===m?f({result:q}):void T.continue()):f({result:q})},R.onerror=it(w)}})}(s),openCursor:function({trans:d,values:p,query:f,reverse:w,unique:h}){return new Promise((y,m)=>{y=Ce(y);const{index:v,range:_}=f,x=d.objectStore(c),k=v.isPrimaryKey?x:x.index(v.name),O=w?h?"prevunique":"prev":h?"nextunique":"next",E=p||!("openKeyCursor"in k)?k.openCursor(r(_),O):k.openKeyCursor(r(_),O);E.onerror=it(m),E.onsuccess=Ce(N=>{const D=E.result;if(!D)return void y(null);D.___id=++Pf,D.done=!1;const R=D.continue.bind(D);let q=D.continuePrimaryKey;q&&(q=q.bind(D));const P=D.advance.bind(D),T=()=>{throw new Error("Cursor not stopped")};D.trans=d,D.stop=D.continue=D.continuePrimaryKey=D.advance=()=>{throw new Error("Cursor not started")},D.fail=Ce(m),D.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},D.start=b=>{const K=new Promise((A,G)=>{A=Ce(A),E.onerror=it(G),D.fail=G,D.stop=L=>{D.stop=D.continue=D.continuePrimaryKey=D.advance=T,A(L)}}),$=()=>{if(E.result)try{b()}catch(A){D.fail(A)}else D.done=!0,D.start=()=>{throw new Error("Cursor behind last entry")},D.stop()};return E.onsuccess=Ce(A=>{E.onsuccess=$,$()}),D.continue=R,D.continuePrimaryKey=q,D.advance=P,$(),K},y(D)},m)})},count({query:d,trans:p}){const{index:f,range:w}=d;return new Promise((h,y)=>{const m=p.objectStore(c),v=f.isPrimaryKey?m:m.index(f.name),_=r(w),x=_?v.count(_):v.count();x.onsuccess=Ce(k=>h(k.target.result)),x.onerror=it(y)})}}}(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:Wn(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:f})=>({...p,...f(p)}),c)}(jf(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 Rr({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Is(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?gt(i,o,{get(){return this.table(o)},set(l){Ei(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function Vo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Af(t,e){return t._cfg.version-e._cfg.version}function Nf(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;Dt(()=>{ae.trans=s,ae.transless=a,e===0?(Ne(o).forEach(l=>{go(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=[],f=l._versions;let w=l._dbSchema=Zo(l,l.idbdb,d),h=!1;const y=f.filter(v=>v._cfg.version>=u);function m(){return p.length?oe.resolve(p.shift()(c.idbtrans)).then(m):oe.resolve()}return y.forEach(v=>{p.push(()=>{const _=w,x=v._cfg.dbschema;Yo(l,_,d),Yo(l,x,d),w=l._dbSchema=x;const k=Ji(_,x);k.add.forEach(E=>{go(d,E[0],E[1].primKey,E[1].indexes)}),k.change.forEach(E=>{if(E.recreate)throw new le.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(D=>Go(N,D)),E.change.forEach(D=>{N.deleteIndex(D.name),Go(N,D)}),E.del.forEach(D=>N.deleteIndex(D))}});const O=v._cfg.contentUpgrade;if(O&&v._cfg.version>u){qo(l,d),c._memoizedTables={},h=!0;let E=Oi(x);k.del.forEach(q=>{E[q]=_[q]}),Vo(l,[l.Transaction.prototype]),Rr(l,[l.Transaction.prototype],Ne(E),E),c.schema=E;const N=Os(O);let D;N&&vn();const R=oe.follow(()=>{if(D=O(c),D&&N){var q=_t.bind(null,null);D.then(q,q)}});return D&&typeof D.then=="function"?oe.resolve(D):R.then(()=>D)}}),p.push(_=>{(!h||!xf)&&function(x,k){[].slice.call(k.db.objectStoreNames).forEach(O=>x[O]==null&&k.db.deleteObjectStore(O))}(v._cfg.dbschema,_),Vo(l,[l.Transaction.prototype]),Rr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),m().then(()=>{var v,_;_=d,Ne(v=w).forEach(x=>{_.db.objectStoreNames.contains(x)||go(_,x,v[x].primKey,v[x].indexes)})})}(t,e,s,n).catch(i)})}function Ji(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&&!no)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 go(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=>Go(o,s)),o}function Go(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Zo(t,e,n){const r={};return Dr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=$o(Zi(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 $o(l,u||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),ze(u),a===0)}),s=o.shift();if(s.multi)throw new le.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new le.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new le.Schema("Index must have a name and cannot be an empty string")}),n[r]=Yi(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,Vo(n,[n._allTables,n,n.Transaction.prototype]),Rr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ne(s),s),n._storeNames=Ne(s),this}upgrade(e){return this._cfg.contentUpgrade=js(this._cfg.contentUpgrade||we,e),this}}function Rs(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new $t(ro,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Ts(t){return t&&typeof t.databases=="function"}function Jo(t){return Dt(function(){return ae.letThrough=!0,t()})}function Rf(){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 Tf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Fe(e.dbOpenError):t);dt&&(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 le.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():Rf()).then(()=>new oe((l,u)=>{if(o(),!n)throw new le.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new le.MissingAPI;d.onerror=it(u),d.onblocked=Ce(t._fireOnBlocked),d.onupgradeneeded=Ce(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=zn,i.abort(),d.result.close();const w=n.deleteDatabase(c);w.onsuccess=w.onerror=Ce(()=>{u(new le.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{i.onerror=it(u);var f=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=f<1,t._novip.idbdb=d.result,Nf(t,f/10,i,u)}},u),d.onsuccess=Ce(()=>{i=null;const p=t._novip.idbdb=d.result,f=Dr(p.objectStoreNames);if(f.length>0)try{const h=p.transaction((w=f).length===1?w[0]:w,"readonly");e.autoSchema?function({_novip:y},m,v){y.verno=m.version/10;const _=y._dbSchema=Zo(0,m,v);y._storeNames=Dr(m.objectStoreNames,0),Rr(y,[y._allTables],Ne(_),_)}(t,p,h):(Yo(t,t._dbSchema,h),function(y,m){const v=Ji(Zo(0,y.idbdb,m),y._dbSchema);return!(v.add.length||v.change.some(_=>_.add.length||_.change.length))}(t,h)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),qo(t,h)}catch{}var w;Pn.push(t),p.onversionchange=Ce(h=>{e.vcFired=!0,t.on("versionchange").fire(h)}),p.onclose=Ce(h=>{t.on("close").fire(h)}),a&&function({indexedDB:h,IDBKeyRange:y},m){!Ts(h)&&m!==ro&&Rs(h,y).put({name:m}).catch(we)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(Jo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(js,we);return e.onReadyBeingFired=[],oe.resolve(Jo(()=>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 Xo(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 Bf(t,e,n){var r=arguments.length;if(r<2)throw new le.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Di(o),n]}function Xi(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===Ps.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Xi(t,e,n,null,o))):Fe(d)}const l=Os(o);let u;l&&vn();const c=oe.follow(()=>{if(u=o.call(i,i),u)if(l){var d=_t.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=Xo(u))},a);return(u&&typeof u.then=="function"?oe.resolve(u).then(d=>i.active?d:Fe(new le.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 ir(t,e,n){const r=ze(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:h,extractKey:Ho(c),unique:!y&&p.unique};return w.push(m),m.isPrimaryKey||s.push(m),h>1&&i(h===2?c[0]:c.slice(0,h-1),d+1,p),w.sort((v,_)=>v.keyTail-_.keyTail),m}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,f=d.keyTail,{type:p.type===1?2:p.type,lower:ir(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,f),lowerOpen:!0,upper:ir(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,f),upperOpen:!0})}}:c;var p,f}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(c){const d=o[An(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:f}=c.query.index;return p?n.openCursor(l(c)).then(w=>w&&function(h){return Object.create(h,{continue:{value:function(m){m!=null?h.continue(ir(m,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?h.continue(h.key.slice(0,f).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):h.continue()}},continuePrimaryKey:{value(m,v){h.continuePrimaryKey(ir(m,t.MAX_KEY,d),v)}},primaryKey:{get:()=>h.primaryKey},key:{get(){const m=h.key;return f===1?m[0]:m.slice(0,f)}},value:{get:()=>h.value}})}(w)):n.openCursor(c)}}}}}};function Bs(t,e,n,r){return n=n||{},r=r||"",Ne(t).forEach(o=>{if(Ze(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=jo(s);a!==jo(i)?n[r+o]=e[o]:a==="Object"?Bs(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=>{Ze(t,o)||(n[r+o]=e[o])}),n}const zf={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===we)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===we&&u.fire===we)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(a.fire===we)break;return i._promise("readwrite",()=>c(s),!0);case"deleteRange":if(a.fire===we)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function c(p){const f=ae.trans,w=p.keys||function(h,y){return y.type==="delete"?y.keys:y.keys||y.values.map(h.extractKey)}(r,p);if(!w)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:w}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(h,y,m){return y.type==="add"?Promise.resolve([]):h.getMany({trans:y.trans,keys:m,cache:"immutable"})}(n,p,w).then(h=>{const y=w.map((m,v)=>{const _=h[v],x={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(x,m,_,f);else if(p.type==="add"||_===void 0){const k=l.fire.call(x,m,p.values[v],f);m==null&&k!=null&&(m=k,p.keys[v]=m,r.outbound||rt(p.values[v],r.keyPath,m))}else{const k=Bs(_,p.values[v]),O=u.fire.call(x,k,m,_,f);if(O){const E=p.values[v];Object.keys(O).forEach(N=>{Ze(E,N)?E[N]=O[N]:rt(E,N,O[N])})}}return x});return n.mutate(p).then(({failures:m,results:v,numFailures:_,lastResult:x})=>{for(let k=0;k(y.forEach(v=>v.onerror&&v.onerror(m)),Promise.reject(m)))})}function d(p,f,w){return n.query({trans:p,values:!1,query:{index:r,range:f},limit:w}).then(({result:h})=>c({type:"delete",keys:h,trans:p}).then(y=>y.numFailures>0?Promise.reject(y.failures[0]):h.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=Qi(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"?Vn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function Ms(t){return!("from"in t)}const pt=function(t,e){if(!this){const n=new pt;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 Un(t,e,n){const r=We(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(Ms(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?Un(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},va(t);if(We(e,t.to)>0)return s?Un(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},va(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&&Tr(t,o),s&&i&&Tr(t,s)}function Tr(t,e){Ms(e)||function n(r,{from:o,to:s,l:i,r:a}){Un(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function Wf(t,e){const n=Qo(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=Qo(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 Qo(t){let e=Ms(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 va(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=ga(i)}t.d=ga(t)}function ga({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}pn(pt.prototype,{add(t){return Tr(this,t),this},addKey(t){return Un(this,t,t),this},addKeys(t){return t.forEach(e=>Un(this,e,e)),this},[Ao](){return Qo(this)}});const Uf={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new pt(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 f=p.trans,w=f.mutatedParts||(f.mutatedParts={}),h=O=>{const E=`idb://${e}/${r}/${O}`;return w[E]||(w[E]=new pt)},y=h(""),m=h(":dels"),{type:v}=p;let[_,x]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const k=p.trans._cache;return o.mutate(p).then(O=>{if(ze(_)){v!=="delete"&&(_=O.results),y.addKeys(_);const E=Qi(_,k);E||v==="add"||m.addKeys(_),(E||x)&&function(N,D,R,q){function P(T){const b=N(T.name||"");function K(A){return A!=null?T.extractKey(A):null}const $=A=>T.multiEntry&&ze(A)?A.forEach(G=>b.addKey(G)):b.addKey(A);(R||q).forEach((A,G)=>{const L=R&&K(R[G]),ne=q&&K(q[G]);We(L,ne)!==0&&(L!=null&&$(L),ne!=null&&$(ne))})}D.indexes.forEach(P)}(h,s,E,x)}else if(_){const E={from:_.lower,to:_.upper};m.add(E),y.add(E)}else y.add(n),m.add(n),s.indexes.forEach(E=>h(E.name).add(n));return O})}},c=({query:{index:p,range:f}})=>{var w,h;return[p,new pt((w=f.lower)!==null&&w!==void 0?w:t.MIN_KEY,(h=f.upper)!==null&&h!==void 0?h:t.MAX_KEY)]},d={get:p=>[i,new pt(p.key)],getMany:p=>[i,new pt().addKeys(p.keys)],count:c,query:c,openCursor:c};return Ne(d).forEach(p=>{u[p]=function(f){const{subscr:w}=ae;if(w){const h=x=>{const k=`idb://${e}/${r}/${x}`;return w[k]||(w[k]=new pt)},y=h(""),m=h(":dels"),[v,_]=d[p](f);if(h(v.name||"").add(_),!v.isPrimaryKey){if(p!=="count"){const x=p==="query"&&l&&f.values&&o.query({...f,values:!1});return o[p].apply(this,arguments).then(k=>{if(p==="query"){if(l&&f.values)return x.then(({result:E})=>(y.addKeys(E),k));const O=f.values?k.result.map(a):k.result;f.values?y.addKeys(O):m.addKeys(O)}else if(p==="openCursor"){const O=k,E=f.values;return O&&Object.create(O,{key:{get:()=>(m.addKey(O.primaryKey),O.key)},primaryKey:{get(){const N=O.primaryKey;return m.addKey(N),N}},value:{get:()=>(E&&y.addKey(O.primaryKey),O.value)}})}return k})}m.add(n)}}return o[p].apply(this,arguments)}}),u}}}};class $t{constructor(e,n){this._middlewares={},this.verno=0;const r=$t.dependencies;this._options=n={addons:$t.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:we,dbReadyPromise:null,cancelOpen:we,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=jn(this,"populate","blocked","versionchange","close",{ready:[js,we]}),this.on.ready.subscribe=Ci(this.on.ready.subscribe,a=>(l,u)=>{$t.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,kn(Cf.prototype,function(a,l){this.db=i;let u=qi,c=null;if(l)try{u=l()}catch(w){c=w}const d=a._ctx,p=d.table,f=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:f!==Bn?f:null}})),this.Table=function(a){return kn(Ef.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:jn(null,{creating:[ff,we],reading:[df,Bn],updating:[pf,we],deleting:[hf,we]})})}(this),this.Transaction=function(a){return kn(Df.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=jn(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((f,w)=>{this._resolve=f,this._reject=w}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},f=>{var w=this.active;return this.active=!1,this.on.error.fire(f),this.parent?this.parent._reject(f):w&&this.idbtrans&&this.idbtrans.abort(),Fe(f)})})}(this),this.Version=function(a){return kn(Ff.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return kn(Gi.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 le.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,f)=>d.cmp(f,p),this._max=(p,f)=>d.cmp(p,f)>0?p:f,this._min=(p,f)=>d.cmp(p,f)<0?p:f,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),Pn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(Mf),this.use(zf),this.use(Uf),this.use(Lf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new le.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new le.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(Af),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 le.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new le.DatabaseClosed);this.open().catch(we)}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 Tf(this)}_close(){const e=this._state,n=Pn.indexOf(this);if(n>=0&&Pn.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 le.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=Ce(()=>{(function({indexedDB:a,IDBKeyRange:l},u){!Ts(a)&&u!==ro&&Rs(a,l).delete(u).catch(we)})(this._deps,this.name),r()}),i.onerror=it(o),i.onblocked=this._fireOnBlocked};if(e)throw new le.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=Bf.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===ho)i=ho;else{if(e!="rw"&&e!=po)throw new le.InvalidArgument("Invalid transaction mode: "+e);i=po}if(o){if(o.mode===ho&&i===po){if(!s)throw new le.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 le.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=Xi.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ae.trans?gn(ae.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ze(this._allTables,e))throw new le.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Kf=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class $f{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Kf](){return this}}function el(t,e){return Ne(e).forEach(n=>{Tr(t[n]||(t[n]=new pt),e[n])}),t}function Hf(t){let e,n=!1;const r=new $f(o=>{const s=Os(t);let i=!1,a={},l={};const u={get closed(){return i},unsubscribe:()=>{i=!0,jt.storagemutated.unsubscribe(f)}};o.start&&o.start(u);let c=!1,d=!1;function p(){return Ne(l).some(h=>a[h]&&Wf(a[h],l[h]))}const f=h=>{el(a,h),p()&&w()},w=()=>{if(c||i)return;a={};const h={},y=function(m){s&&vn();const v=()=>Dt(t,{subscr:m,trans:null}),_=ae.trans?gn(ae.transless,v):v();return s&&_.then(_t,_t),_}(h);d||(jt(Ln,f),d=!0),c=!0,Promise.resolve(y).then(m=>{n=!0,e=m,c=!1,i||(p()?w():(a={},l=h,o.next&&o.next(m)))},m=>{c=!1,n=!1,o.error&&o.error(m),u.unsubscribe()})};return w(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let es;try{es={indexedDB:Ee.indexedDB||Ee.mozIndexedDB||Ee.webkitIndexedDB||Ee.msIndexedDB,IDBKeyRange:Ee.IDBKeyRange||Ee.webkitIDBKeyRange}}catch{es={indexedDB:null,IDBKeyRange:null}}const Bt=$t;function vr(t){let e=vt;try{vt=!0,jt.storagemutated.fire(t)}finally{vt=e}}pn(Bt,{...dr,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 Ts(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==ro)):Rs(e,n).toCollection().primaryKeys()}(Bt.dependencies).then(t)}catch{return Fe(new le.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ae.trans?gn(ae.transless,t):t(),vip:Jo,async:function(t){return function(){try{var e=Xo(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=Xo(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:()=>dt,set:t=>{ji(t,t==="dexie"?()=>!0:Hi)}},derive:sn,extend:Ue,props:pn,override:Ci,Events:jn,on:jt,liveQuery:Hf,extendObservabilitySet:el,getByKeyPath:wt,setByKeyPath:rt,delByKeyPath:function(t,e){typeof e=="string"?rt(t,e,void 0):"length"in e&&[].map.call(e,function(n){rt(t,n,void 0)})},shallowClone:Oi,deepClone:Vn,getObjectDiff:Bs,cmp:We,asap:Si,minKey:Ko,addons:[],connections:Pn,errnames:Ps,dependencies:es,semVer:da,version:da.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Bt.maxKey=Wn(Bt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(jt(Ln,t=>{if(!vt){let e;no?(e=document.createEvent("CustomEvent"),e.initCustomEvent(Ct,!0,!0,t)):e=new CustomEvent(Ct,{detail:t}),vt=!0,dispatchEvent(e),vt=!1}}),addEventListener(Ct,({detail:t})=>{vt||vr(t)}));let vt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(Ct);typeof t.unref=="function"&&t.unref(),jt(Ln,e=>{vt||t.postMessage(e)}),t.onmessage=e=>{e.data&&vr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){jt(Ln,e=>{try{vt||(typeof localStorage<"u"&&localStorage.setItem(Ct,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Ct,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===Ct){const n=JSON.parse(e.newValue);n&&vr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===Ct&&vr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof an||t instanceof TypeError||t instanceof SyntaxError||!t.name||!ia[t.name])return t;var n=new ia[t.name](e||t.message,t);return"stack"in t&>(n,"stack",{get:function(){return this.inner.stack}}),n},ji(dt,Hi);var qf=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t.openSpotlightSearch="openSpotlightSearch",t))(qf||{}),gr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(gr||{}),tl=(t=>(t.PRIVATE="PRIVATE",t.PUBLIC="PUBLIC",t.UNLISTED="UNLISTED",t))(tl||{});const Vf="comfyui_workspace_db";class Gf extends $t{constructor(){super(Vf);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 ce=new Gf;class Jt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ce[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{Gd(this.tableName,JSON.stringify(n))}catch(r){console.error("error saving disk db",r)}}async add(e){return e.id||(e.id=hn()),e.createTime||(e.createTime=Date.now()),await ce[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ce[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ce[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ce[this.tableName].update(e,n),this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ce[this.tableName].toArray()}async filter(e){return await ce[this.tableName].filter(e).toArray()}async batchQuery(e){return await ce[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 Vd(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Qd()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ce[this.tableName].get(e)}async delete(e){await ce[this.tableName].delete(e),this.saveDiskDB()}async listByIndex(e,n){return await ce[this.tableName].where(e).equals(n).toArray()}}const Zf=80,zr=class zr extends Jt{constructor(){super("changelogs")}static async load(){return new zr}async listByWorkflowID(e){return await ce.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:hn(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return await ce.changelogs.add(r),await this.deleteLogsExceedLimit(e.workflowID),r}async deleteLogsExceedLimit(e){var o;const n=await ce.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=((o=J==null?void 0:J.settings)==null?void 0:o.maximumChangelogNumber)??Zf;if(n.length>r){const s=n.slice(r);await ce.changelogs.bulkDelete(s.map(i=>i.id))}}};Ie(zr,"TABLE_NAME","changelogs");let ts=zr;const _p="CWM_WORKFLOWS_SORT_TYPE";var lt=(t=>(t.RECENTLY_OPENED="recentlyOpened",t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(lt||{});const xp=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}];function Yf(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"),u=String(o.getMinutes()).padStart(2,"0"),c=String(o.getSeconds()).padStart(2,"0"),d=`${i}${r}${s}${r}${a}`;return e?d+` ${l}:${u}`:n?d+`:${c}`:d}const wr=(t,e=lt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case lt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case lt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case lt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case lt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break;case lt.RECENTLY_OPENED:n.sort((r,o)=>(o.lastOpenedTime??0)-(r.lastOpenedTime??0));break}return n};function Jf(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{var n;const e=(n=J==null?void 0:J.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 Cp(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function Xf(t){return`/workspace/view_media?filename=${t}`}function wa(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function nl(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 Qf=t=>{const e=nl(t);window.open(`${window.location.origin}/#${e}`)},rl={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},Te="workspace_info",eh=9999999,ba="upgrade_to_2way_sync",zs=28,Sp="SHORTCUT_TRIGGER_EVENT",Ls={os:null},Ip=()=>Ls.os==="Windows"?"\\":"/";function br(...t){const e=t.filter(n=>n!=="").join("/");return At(e)}function At(t){const e=t.split("/").filter(r=>r!=="").join("/");let n=e.replace(/\\/g,"/");return n=n.replace(/^\/+/,""),Ls.os==="Windows"&&(n=e.replace(/\//g,"\\")),n}function wo(t){return br(t.parentFolderID??"",t.name+".json")}var Je;(t=>{async function e(l,u){try{const d=await(await ke("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(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 ke("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(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 ke("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(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[Te]==null&&(c.extra[Te]={}),c.extra[Te].id=l.id,c.extra[Te].saveLock=l.saveLock,c.extra[Te].cloudID=l.cloudID,c.extra[Te].coverMediaPath=l.coverMediaPath;const p=await(await ke("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),json:JSON.stringify(c)})})).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 ke("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:wo(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(l){var h;const{parentFolderID:u,name:c,json:d,id:p}=l;let f=JSON.parse(d);f.extra==null&&(f.extra={}),f.extra[Te]==null&&(f.extra[Te]={}),f.extra[Te].id=p,f.extra[Te].saveLock=l.saveLock,f.extra[Te].cloudID=l.cloudID,f.extra[Te].coverMediaPath=l.coverMediaPath;const w={parentFolderPath:At(u??""),name:c,json:JSON.stringify(f)};try{const m=await(await ke("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)})).json();return m.name&&await((h=ce.workflows)==null?void 0:h.update(p,{name:m.name})),m}catch(y){return console.error(`Error creating file <${p}> at "${u}"`,y),alert(`Error creating file <${p}> at "${u}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:u,id:c}){const d=br(l??"",u+".json");try{const f=await(await ke("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:c})})).json();return f.error&&(console.error(`Error getting file <${c}> at "${d}"`,f.error),alert({message:`Error getting file <${c}> at "${d}"`,level:"error"})),f}catch(p){return console.error(`Erro finding file <${c}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function Ls(t,e=!1,n=!1){try{return await(await ke("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:At(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function th(t,e){const n=At(t??""),o=(await Ls(n)).map(async a=>{var c;const l=a.name,u=[n,l].join("/");if(nh(a))return{id:At(u),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()};{const d=await((c=ce.workflows)==null?void 0:c.get(a.id).catch(f=>(console.error("Error getting workflow from indexdb",a.id,u,f),null)));return{cloudID:a.cloudID,coverMediaPath:a.coverMediaPath,saveLock:a.saveLock,...d,id:a.id,json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime,updateTime:a.updateTime}}}),s=await Promise.all(o);ce.workflows.bulkPut(s.filter(a=>!sh(a)));const i=s.filter(a=>a!=null);return wr(i,e??lt.RECENTLY_MODIFIED)}function nh(t){return"type"in t&&t.type==="folder"}const Lr=class Lr extends Jt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Lr}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 ce.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(J==null?void 0:J.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(J==null?void 0:J.getSetting("twoWaySync"))){const l=await Je.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??hn(),json:n.json??JSON.stringify(rl),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ce.workflows.add(i),this.saveDiskDB(),await(J==null?void 0:J.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):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 ce.workflows.update(n,r);const o=await ce.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){const o=await(J==null?void 0:J.getSetting("twoWaySync")),s=await this.get(n);!await this.updateMetaInfo(n,r)||!s||o&&await Je.moveWorkflow(s,r.parentFolderID)}async genLastManualSavedJson(n){const r=await(Ve==null?void 0:Ve.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(J==null?void 0:J.getSetting("twoWaySync"))&&o&&await Je.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(J==null?void 0:J.getSetting("twoWaySync"))&&a&&await Je.saveWorkflow(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=hn(),d=Date.now(),p={id:c,name:u,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(J==null?void 0:J.getSetting("twoWaySync")))try{const w=JSON.parse(l.json),h=(a=(i=w==null?void 0:w.extra)==null?void 0:i[Te])==null?void 0:a.id;h&&(await this.get(h)||(p.id=h)),Je.createWorkflow(p)}catch(w){console.error("batchCreateFlows error",w)}}try{await ce.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&await(J==null?void 0:J.getSetting("twoWaySync"))&&await Je.deleteWorkflow(r),await ce.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ce.workflows.bulkGet(n);for(const o of r){if(!o)return;await(J==null?void 0:J.getSetting("twoWaySync"))&&await Je.deleteWorkflow(o)}await ce.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(J==null?void 0:J.getSetting("twoWaySync"))){const l=await th(n??null);return wr(l,r??lt.RECENTLY_MODIFIED)}const s=await this.listAll().then(l=>l.filter(u=>u.parentFolderID==n))??[],i=await(qe==null?void 0:qe.listAll().then(l=>l.filter(u=>u.parentFolderID==n)))??[],a=[...s,...i];return wr(a,r??lt.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(J==null?void 0:J.getSetting("twoWaySync")),s=await ce.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Je.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(J==null?void 0:J.getSetting("twoWaySync"));let o;if(r){const i=(await Ls("",!0)).filter(a=>(a==null?void 0:a.type)==="workflow").map(async a=>{const l=await ce.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 ce.workflows.toArray();return n?wr(o,n):o}async updateLastOpenedTime(n){await ce.workflows.update(n,{lastOpenedTime:Date.now()})}};Ie(Lr,"TABLE_NAME","workflows");let ns=Lr;var St;(t=>{async function e({parentFolderID:a,name:l}){return At(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await ke("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:At(a.id)})})}t.createFolder=n;async function r(a,l){const c=await(await ke("/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 ke("/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 ke("/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 ke("/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})(St||(St={}));const Wr=class Wr extends Jt{constructor(){super("folders")}static async load(){return new Wr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(J==null?void 0:J.getSetting("twoWaySync")),o=await St.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:hn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await St.createFolder(s):(await ce.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(J==null?void 0:J.getSetting("twoWaySync")))return"parentFolderID"in n&&await St.moveFolder(e,n.parentFolderID??""),"name"in n&&await St.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;"name"in n&&n.name!=o.name;const s="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,i={...o,...n};return n.name!=null&&(i.updateTime=Date.now()),s&&(n.name=await this.generateUniqueName(i.name,i.parentFolderID??void 0)),await ce.folders.update(e,n),this.saveDiskDB(),i}async deleteFolder(e,n=gr.DELETE){if(await(J==null?void 0:J.getSetting("twoWaySync"))){await Ls(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(H==null||H.deleteFlow(l.id))})}),await St.deleteFolder(e);return}const o=await(H==null?void 0:H.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 gr.DELETE:await(H==null?void 0:H.deleteFlow(u.id));break;case gr.MOVE_TO_ROOT_FOLDER:await(H==null?void 0:H.updateFolder(u.id,{parentFolderID:void 0}));break}await ce.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(J==null?void 0:J.getSetting("twoWaySync")))return await Je.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(Wr,"TABLE_NAME","folders");let rs=Wr;class ol extends Jt{constructor(){super("media")}async listByWorkflowID(e){return await ce.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){if(e.localPath.split(".").pop()==null)return null;const r={id:e.localPath,localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now()};return await(H==null?void 0:H.updateMetaInfo(e.workflowID,{latestImage:r.localPath})),ce.media.put(r),this.saveDiskDB(),r}async delete(e){var n,r;super.delete(e),((n=H==null?void 0:H.curWorkflow)==null?void 0:n.coverMediaPath)===e&&(H==null||H.updateMetaInfo(H.curWorkflow.id,{coverMediaPath:void 0})),((r=H==null?void 0:H.curWorkflow)==null?void 0:r.latestImage)===e&&(H==null||H.updateMetaInfo(H.curWorkflow.id,{latestImage:void 0}))}}Ie(ol,"TABLE_NAME","media");const Ip=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Op=2,rh={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Dp(t){return t.modelVersions!==void 0}function oh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function Pp(t,e){var r,o,s,i,a,l;if(!t)return;let n;return oh(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 Ur=class Ur extends Jt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");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:rh,autoSave:!1,autoSaveDuration:3,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.co",maximumChangelogNumber:80,hideCoverImage:!1,disableUnsavedWarning:!1}}get settings(){return this._settings}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),await ke("/workspace/save_settings",{method:"POST",body:JSON.stringify(this._settings),headers:{"Content-Type":"application/json"}}),this._settings={...this.defaultSettings,...o}}static async load(){var o,s,i,a;const n=new Ur,r=await Zd();return n.defaultSettings.myWorkflowsDir=r.path,await n.get(n.DEFAULT_USER).then(l=>{n._settings={...n.defaultSettings,...l}}),((s=(o=n._settings)==null?void 0:o.cloudHost)!=null&&s.includes("nodecafe.org")||(a=(i=n._settings)==null?void 0:i.cloudHost)!=null&&a.includes("comfyspace.art"))&&await n.upsert({cloudHost:n.defaultSettings.cloudHost}),n}};Ie(Ur,"TABLE_NAME","userSettings");let os=Ur;const Kr=class Kr extends Jt{constructor(){super("tags")}static async load(){return new Kr}};Ie(Kr,"TABLE_NAME","tags");let ss=Kr;const $r=class $r extends Jt{constructor(){super("workflowVersions")}static async load(){return new $r}async listByWorkflowID(e){return await ce[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($r,"TABLE_NAME","workflowVersions");let as=$r;function sh(t){return"type"in t&&t.type==="folder"}let H=null,_r=null,J=null,qe=null,Ve=null,Ht=null,De=null;async function ah(){const t=async()=>{H=await ns.load()},e=async()=>{_r=await ss.load()},n=async()=>{J=await os.load()},r=async()=>{qe=await rs.load()},o=async()=>{Ve=await ts.load()},s=async()=>{Ht=new ol},i=async()=>{De=await as.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await ih(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function ih(){const t=async()=>{try{const a=await(H==null?void 0:H.getRecords());a&&await ce.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(qe==null?void 0:qe.getRecords());a&&await ce.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Ht==null?void 0:Ht.getRecords());a&&await ce.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ce.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(_r==null?void 0:_r.getRecords());a&&await ce.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=J,l=await a.getRecords().then(u=>u[a.DEFAULT_USER]?u[a.DEFAULT_USER]:u);await ce.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(De==null?void 0:De.getRecords());a&&await ce.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const ot=j.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:async()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{},setCurFlowIDAndName:()=>{},session:null,updateSession:()=>{}}),jp=j.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),bo={x:0,y:0};function lh({children:t,onDragEnd:e,dragIconId:n}){const r=j.useRef(bo),o=j.useRef(!1),[s,i]=j.useState(bo),a=d=>{var p,f,w;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(w=(f=d.target)==null?void 0:f.parentNode)==null?void 0:w.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const h=document.getElementsByTagName("body")[0];h.style.userSelect="none"}},l=j.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),u=j.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),bo)),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 C.jsx("div",{style:c,onMouseDown:a,children:t})}var ch={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"},uh=Object.defineProperty,dh=Object.defineProperties,fh=Object.getOwnPropertyDescriptors,Br=Object.getOwnPropertySymbols,sl=Object.prototype.hasOwnProperty,al=Object.prototype.propertyIsEnumerable,ba=(t,e,n)=>e in t?uh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_a=(t,e)=>{for(var n in e||(e={}))sl.call(e,n)&&ba(t,n,e[n]);if(Br)for(var n of Br(e))al.call(e,n)&&ba(t,n,e[n]);return t},hh=(t,e)=>dh(t,fh(e)),ph=(t,e)=>{var n={};for(var r in t)sl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Br)for(var r of Br(t))e.indexOf(r)<0&&al.call(t,r)&&(n[r]=t[r]);return n},Re=(t,e,n)=>{const r=j.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:u=2,children:c}=i,d=ph(i,["color","size","stroke","children"]);return j.createElement("svg",_a(hh(_a({ref:s},ch),{width:l,height:l,stroke:a,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,f])=>j.createElement(p,f)),...c||[]])});return r.propTypes={color:Tt.string,size:Tt.oneOfType([Tt.string,Tt.number]),stroke:Tt.oneOfType([Tt.string,Tt.number])},r.displayName=`${e}`,r},mh=Re("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"}]]),yh=Re("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),Mr=Re("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"}]]),vh=Re("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"}]]),gh=Re("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"}]]),wh=Re("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"}]]),bh=Re("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"}]]),_h=Re("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"}]]),xh=Re("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"}]]),il=Re("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"}]]),kh=Re("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"}]]),Eh=Re("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"}]]),Ch=Re("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"}]]),ll=Re("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"}]]),Sh=Re("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"}]]),Ih=Re("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"}]]),Oh=Re("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Dh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return C.jsx(di,{isLazy:!0,placement:"auto",gutter:0,children:({onClose:i})=>C.jsxs(C.Fragment,{children:[C.jsx(ui,{children:C.jsx(Ot,{children:C.jsx(Vt,{hasArrow:!0,label:s,placement:"bottom",children:C.jsx(Nn,{"aria-label":"Delete confirm",size:"sm",icon:C.jsx(Ch,{color:"#F56565",size:"20px"}),isDisabled:o,variant:n})})})}),C.jsxs(mi,{children:[C.jsx(hi,{onClick:i}),C.jsxs(fi,{children:[C.jsx(mt,{mb:4,pr:4,fontWeight:600,children:e}),C.jsx(Le,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Ph({onClose:t}){var x;const{isDirty:e,loadWorkflowID:n,curVersion:r,session:o}=j.useContext(ot),[s,i]=j.useState(0),[a,l]=j.useState(null),[u,c]=j.useState([]),[d,p]=j.useState([]),f=H==null?void 0:H.curWorkflow,w=(x=J==null?void 0:J.settings)==null?void 0:x.cloudHost,[h,y]=j.useState(!1),m=async k=>{var R;const O=await(H==null?void 0:H.get(k)),E=await(Ve==null?void 0:Ve.listByWorkflowID(k));c(E??[]);const N=E==null?void 0:E.filter(q=>q.json===(O==null?void 0:O.json)),D=(R=N==null?void 0:N[0])==null?void 0:R.id;D&&l(D)},v=async()=>{var O;let k=await(De==null?void 0:De.listByWorkflowID(f.id))??[];o!=null&&o.shareKey&&(f!=null&&f.cloudID)&&(y(!0),await fetch(((O=J==null?void 0:J.settings)==null?void 0:O.cloudHost)+"/api/listWorkflowVersionsByWorkflowID?workflowID="+(f==null?void 0:f.cloudID),{headers:{authorization:`Bearer ${o==null?void 0:o.shareKey}`}}).then(E=>E.json()).then(E=>{if(E.items){const N=E.items.map(D=>({...D,isCloud:!0}));k=k.concat(N)}}).catch(E=>{console.error(E)}),y(!1)),p(k)},_=k=>{De==null||De.delete(k).then(()=>{v()})};return j.useEffect(()=>{switch(s){case 0:v();break;case 1:m(f.id);break}},[s]),j.useEffect(()=>(Pe.canvasEl.addEventListener("click",t),()=>{Pe.canvasEl.removeEventListener("click",t)}),[s]),C.jsxs(Gl,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[C.jsx(Vl,{pb:1,mb:0,children:C.jsxs(on,{justifyContent:"space-between",alignItems:"center",children:[C.jsx(fs,{size:"md",children:"Version History"}),C.jsx(Nn,{size:"sm",icon:C.jsx(Oh,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),C.jsx(ql,{overflowY:"auto",gap:0,children:C.jsxs(gi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[C.jsxs(wi,{mb:"1em",children:[C.jsx(Oo,{children:"Versions"}),C.jsx(Oo,{children:"Change History"})]}),C.jsxs(bi,{children:[C.jsxs(Io,{children:[(o==null?void 0:o.shareKey)&&C.jsxs(mt,{color:"GrayText",mb:3,children:["Connected to"," ",C.jsx("a",{href:w,target:"_blank",children:w})]}),C.jsxs(It,{divider:C.jsx(ko,{}),spacing:2,children:[h&&C.jsx(mt,{children:"Loading..."}),d==null?void 0:d.map(k=>C.jsxs(on,{w:"100%",mb:1,justify:"space-between",backgroundColor:k.id===(r==null?void 0:r.id)?"teal.300":void 0,borderRadius:4,children:[C.jsxs(It,{textAlign:"left",gap:0,children:[k.isCloud?C.jsx("a",{target:"_blank",href:`${w}/workflow/${k.workflowID}/${k.id}`,children:k.name??"untitled"}):C.jsx(mt,{fontWeight:"500",children:k.name??"untitled"}),C.jsxs(mt,{color:"GrayText",fontSize:"sm",children:["Created:"," ",new Date(k.createTime??k.createdAt??k.created_at??"").toLocaleString()]})]}),C.jsxs(on,{alignItems:"center",gap:2,children:[C.jsx(Le,{size:"sm",onClick:()=>{if(e){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}Pe.loadGraphData(JSON.parse(k.json)),n(f.id,k.id),t()},children:"Load"}),!k.isCloud&&C.jsx(Dh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{_(k.id)}})]})]},k.id))]})]}),C.jsxs(Io,{children:[C.jsx(mt,{mb:4,children:"All the saved changes of this workflow"}),C.jsx(It,{divider:C.jsx(ko,{}),spacing:2,children:u==null?void 0:u.map(k=>C.jsxs(Lt,{justifyContent:"space-between",children:[C.jsxs(Le,{size:"sm",variant:"ghost",onClick:()=>{if(e){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}Pe.loadGraphData(JSON.parse(k.json)),t()},isActive:k.id===a,children:["Saved at ",new Date(k.createTime).toLocaleString()]},k.id),k.isAutoSave?C.jsx(to,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},k.id))})]})]})]})})]})}const cl="idk0087hcd";function jh(t,e=cl){const n=Math.floor(Math.random()*13)+1,o=Math.random().toString(36).substring(2,2+n)+e+t;return btoa(encodeURIComponent(o))}function Ah(t,e=cl){if(t=="")return null;const n=decodeURIComponent(atob(t)),r=n.indexOf(e);return r===-1?null:n.slice(r+e.length)}function Nh(t){const e=jh(t);localStorage.setItem("workspace_manager_shareKey",e)}function Fh(){var n;const t=(n=J==null?void 0:J.settings)==null?void 0:n.cloudHost,{updateSession:e}=j.useContext(ot);return C.jsxs(It,{p:"10px 10px",gap:3,children:[C.jsx("h2",{style:{fontSize:"1.2rem",fontWeight:"bold"},children:"✨New Version Control Exprience [beta]"}),C.jsxs("p",{children:["We have a new version control experience. Now your versions will be stored securely in cloud at"," ",C.jsx("a",{href:"www.nodecafe.co",children:"www.nodecafe.co"})]}),C.jsx("h3",{style:{fontWeight:"bold"},children:"Why cloud?"}),C.jsx("p",{children:"Previously workflow versions are stored locally in your browser storage. But people reported inconsistent versions when they switched browser or device. Therefore we are moving to cloud. So you can view your workflow versions from any devices, even your phone."}),C.jsx("h3",{style:{fontWeight:"bold"},children:"🤩Get Started"}),C.jsxs(on,{alignItems:"center",gap:2,mb:3,children:[C.jsx("a",{href:t+"/auth/shareKey",target:"_blank",children:C.jsx(Le,{colorScheme:"blue",children:"Login"})}),C.jsx("p",{children:" then copy your share key to below"})]}),C.jsx(yn,{placeholder:"Paste your share key here",onChange:r=>{!r.target.value||r.target.value===""||r.target.value.length<20||(Nh(r.target.value),e({shareKey:r.target.value,username:null}))}})]})}function Ap(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Np=[{label:"Private",value:"PRIVATE",icon:C.jsx(il,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:C.jsx(xh,{})},{label:"Public",value:"PUBLIC",icon:C.jsx(Ih,{})}],Rh=()=>{const t=Pe.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 Th(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 Fp({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")),C.jsx("span",{children:n})}function Bh({onClose:t}){var p;const[e,n]=j.useState(""),[r,o]=j.useState(""),{session:s}=j.useContext(ot),i=Aa(),[a,l]=j.useState(!1),u=f=>{n(f.target.value),r&&o("")},c=async()=>{var h,y,m;const f=e.trim();if(n(f),!(H!=null&&H.curWorkflow))throw new Error("No workflow selected");l(!0);const w={workflow:{name:(h=H==null?void 0:H.curWorkflow)==null?void 0:h.name,cloudID:(y=H==null?void 0:H.curWorkflow)==null?void 0:y.cloudID},version:{name:f,json:JSON.stringify(Pe.graph.serialize())},nodeDefs:Rh(),privacy:tl.PRIVATE};await fetch(((m=J==null?void 0:J.settings)==null?void 0:m.cloudHost)+"/api/createCloudflow",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s==null?void 0:s.shareKey}`},body:JSON.stringify(w)}).then(v=>v.json()).then(v=>{var _;if(v!=null&&v.data){const x=v.data.workflowID;H==null||H.updateMetaInfo((_=H==null?void 0:H.curWorkflow)==null?void 0:_.id,{cloudID:x}),i({title:"Version created",status:"success",duration:3e3}),t()}else o("Failed to create version. "+((v==null?void 0:v.error)??""))}).catch(v=>(o("Failed to create version"),null)),l(!1)};if(!(s!=null&&s.shareKey))return C.jsx(xr,{isOpen:!0,onClose:t,size:"xl",children:C.jsx(kr,{width:"90vw",children:C.jsx(Er,{children:C.jsx(Fh,{})})})});const d=new URL(J.settings.cloudHost).hostname;return C.jsx(xr,{isOpen:!0,onClose:t,children:C.jsxs(kr,{children:[C.jsx(cs,{}),C.jsxs(Er,{children:[C.jsxs(It,{mb:5,children:[C.jsx("p",{style:{fontSize:20,fontWeight:"bold"},children:"Create Version"}),C.jsxs("p",{style:{color:"GrayText"},children:["Saving to"," ",C.jsxs("a",{href:(p=J==null?void 0:J.settings)==null?void 0:p.cloudHost,children:[" ",d]})]})]}),C.jsxs(Gr,{isInvalid:!!r,children:[C.jsx(Yr,{children:"Name"}),C.jsx(yn,{value:e,onChange:u,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!r&&e&&c()}}),r&&C.jsx(Zr,{children:r})]})]}),C.jsxs(us,{children:[C.jsx(Le,{colorScheme:"teal",mr:3,onClick:c,isDisabled:!e,isLoading:a,children:"Create"}),C.jsx(Le,{onClick:t,children:"Cancel"})]})]})})}function Mh({options:t,menuButton:e,isOpen:n,onClose:r}){const o=j.useRef(null);return wc({ref:o,handler:()=>r()}),C.jsxs(Ot,{position:"relative",children:[C.jsx(Ot,{children:e}),n&&C.jsx(Ot,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function zh({menuButton:t,menuContent:e,onClose:n}){const r=j.useRef(),[o,s]=j.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return C.jsx(Mh,{isOpen:o,onClose:i,menuButton:C.jsx(Ot,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:C.jsx(ks,{isOpen:!0,children:C.jsx(Es,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}function Lh(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 Wh({}){const[t,e]=j.useState(),[n,r]=j.useState(),{curFlowID:o}=j.useContext(ot);return j.useEffect(()=>{o&&(H==null||H.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),Th(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?C.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:C.jsx(Sa,{children:C.jsx(to,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}const Uh=j.lazy(()=>Ft(()=>import("./ShareDialog-g_a6xMAM.js"),__vite__mapDeps([0,1,2,3,4,5])));function Kh(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=j.useContext(ot),[i,a]=j.useState(!1),[l,u]=j.useState(""),[c,d]=j.useState(""),[p,f]=j.useState(),[w,h]=j.useState({save:"",saveAs:""});j.useEffect(()=>{t&&(H==null||H.get(t).then(x=>{u((x==null?void 0:x.name)??""),f(x)})),J==null||J.getSetting("shortcuts").then(x=>{h(x)})},[t]);const y=x=>{u(x.target.value),c&&d("")},m=async()=>{if(!t){alert("Flow ID is required");return}const x=JSON.stringify(Pe.graph.serialize()),k=await(H==null?void 0:H.createFlow({json:x,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));k&&await e(k.id,null,!0),v()},v=()=>{o("root")},_=j.useCallback(async()=>{const x=H==null?void 0:H.curWorkflow;if(!x){alert("No current workflow!");return}const k=Pe.graph.serialize(),O=JSON.stringify(k,null,2);Lh(O,x.name)},[t]);return C.jsxs(C.Fragment,{children:[C.jsx(zh,{menuButton:C.jsx(Sa,{children:C.jsxs(Le,{px:1,height:Ms+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",C.jsx(yh,{size:20})]})}),menuContent:C.jsx(ks,{isOpen:!0,children:C.jsxs(Es,{minWidth:150,zIndex:1e3,children:[C.jsx(xt,{onClick:()=>r(),icon:C.jsx(Mr,{size:20}),iconSpacing:1,command:w.save,children:"Save"}),C.jsx(Vt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:C.jsx(xt,{onClick:n,icon:C.jsx(mh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),C.jsx(xt,{onClick:_,icon:C.jsx(vh,{size:20}),iconSpacing:1,children:"Download"}),C.jsx(xt,{onClick:()=>o("saveAsModal"),icon:C.jsx(Mr,{size:20}),iconSpacing:1,command:w.saveAs,children:"Save As"}),C.jsx(xt,{onClick:()=>a(!0),icon:C.jsx(Sh,{size:20}),iconSpacing:1,children:"Create Version"}),C.jsx(xt,{onClick:()=>o("versionHistory"),icon:C.jsx(_h,{size:20}),iconSpacing:1,children:"Versions History"}),C.jsx(xt,{onClick:()=>o("share"),icon:C.jsx(Eh,{size:20}),iconSpacing:1,alignItems:"center",children:C.jsxs(Lt,{children:[C.jsx("p",{children:"Share"})," ",C.jsx(to,{size:"sm",children:"🧪beta"}),C.jsx(Wh,{})]})})]})})}),s==="share"&&C.jsx(Uh,{onClose:()=>o("root")}),s=="versionHistory"&&C.jsx(Ph,{onClose:()=>o("root")}),s==="saveAsModal"&&C.jsxs(xr,{isOpen:!0,onClose:v,children:[C.jsx(Ia,{}),C.jsxs(kr,{children:[C.jsx(Oa,{children:"Save As"}),C.jsx(cs,{}),C.jsx(Er,{children:C.jsxs(Gr,{isInvalid:!!c,children:[C.jsx(Yr,{children:"Workflow name"}),C.jsx(yn,{value:l,onChange:y,autoFocus:!0,onKeyUp:x=>{x.code==="Enter"&&!c&&l&&m()}}),c&&C.jsx(Zr,{children:c})]})}),C.jsxs(us,{children:[C.jsx(Le,{colorScheme:"teal",mr:3,onClick:m,isDisabled:!l||!!c,children:"Save"}),C.jsx(Le,{onClick:v,children:"Cancel"})]})]})]}),i&&C.jsx(Bh,{workflowId:t,onClose:()=>a(!1)})]})}function $h({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=xc(),{curFlowID:i}=j.useContext(ot),[a,l]=j.useState(t),[u,c]=j.useState(""),d=()=>{l(t),o()},p=h=>{l(h.target.value),u&&c("")},f=async()=>{var h;if(i){const y=a.trim();if(l(y),t===y)return w();await(H==null?void 0:H.generateUniqueName(y,((h=H.curWorkflow)==null?void 0:h.parentFolderID)??""))!==y?c("The name is duplicated, please modify it and submit again."):(await(H==null?void 0:H.updateName(i,{name:y})),e(y),w())}},w=()=>{c(""),s()};return i==null?null:C.jsxs(Lt,{children:[C.jsx(Vt,{label:t,placement:"bottom",children:C.jsxs(mt,{as:"div",color:"white",onClick:d,maxW:160,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[C.jsx("div",{style:{width:8,display:"inline-block"},children:C.jsx(mt,{as:"span",children:n&&"* "})}),t]})}),C.jsxs(xr,{isOpen:r,onClose:w,children:[C.jsx(Ia,{}),C.jsxs(kr,{children:[C.jsx(Oa,{children:"Edit workflow name"}),C.jsx(cs,{}),C.jsx(Er,{children:C.jsxs(Gr,{isInvalid:!!u,children:[C.jsx(Yr,{children:"Workflow name"}),C.jsx(yn,{value:a,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!u&&a&&f()}}),u&&C.jsx(Zr,{children:u})]})}),C.jsxs(us,{children:[C.jsx(Le,{colorScheme:"teal",mr:3,onClick:f,isDisabled:!a||!!u,children:"Save"}),C.jsx(Le,{onClick:w,children:"Cancel"})]})]})]})]})}function Hh({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=j.useContext(ot);return j.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?C.jsx(on,{alignItems:"center",children:C.jsx(Ta,{size:"sm",isAttached:!0,variant:"outline",children:C.jsx(Le,{rightIcon:C.jsx(ll,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}function qh(){const{setCurFlowIDAndName:t,curFlowID:e}=j.useContext(ot),n=async()=>{const r=prompt("Enter workflow name","Untitled");if(!r)return;const o=hn(),s=Pe.graph.serialize();s.extra||(s.extra={}),s.extra[Te]||(s.extra[Te]={}),s.extra[Te].id=o;const i=await(H==null?void 0:H.createFlow({id:o,json:JSON.stringify(s),name:r}));i&&t(i)};return e?null:C.jsx(Vt,{label:"Save workflow",children:C.jsx(Le,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:Ms+"px",onClick:()=>n(),px:1,children:C.jsx(Mr,{size:16,color:"white"})})})}const Vh=j.lazy(()=>Ft(()=>import("./AppIsDirtyEventListener-4Wpnq-tF.js"),__vite__mapDeps([6,1,7]))),Gh=j.lazy(()=>Ft(()=>import("./ModelManagerTopbar-jjabvfOI.js"),__vite__mapDeps([8,1,3,2,9,10,11]))),Zh=j.lazy(()=>Ft(()=>import("./SpotlightSearch-T7ZdSk0R.js"),__vite__mapDeps([12,1,7,13,14])));function Yh({curFlowName:t,setCurFlowName:e}){var c;const{isDirty:n,saveCurWorkflow:r,setRoute:o,curFlowID:s,route:i}=j.useContext(ot),[a,l]=j.useState(),u=j.useCallback((d,p=!1)=>{const{top:f=0,left:w=0}=a||{};let{top:h=0,left:y=0}=d??{};h+=f,y+=w;const m=document.documentElement.clientWidth,v=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),x=(_==null?void 0:_.offsetWidth)||392;h+36>v&&(h=v-36),y+x>=m&&(y=m-x),l({top:Math.max(0,h),left:Math.max(0,y)}),p&&(J==null||J.upsert({topBarStyle:{top:h,left:y}}))},[a]);return j.useEffect(()=>{J==null||J.getSetting("topBarStyle").then(d=>{u(d,!1)})},[]),a?C.jsx(lh,{onDragEnd:d=>{u({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:C.jsxs(Lt,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[C.jsx(Le,{size:"sm","aria-label":"workspace folder",height:Ms+"px",onClick:()=>o("recentFlows"),px:2,children:C.jsxs(Lt,{gap:1,children:[C.jsx(wh,{size:21}),C.jsx(ll,{size:8})]})}),C.jsx(j.Suspense,{fallback:C.jsx("div",{style:{width:"60px"}}),children:C.jsx(Gh,{})}),C.jsx(qh,{}),C.jsx($h,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{u()})}}),((c=H==null?void 0:H.curWorkflow)==null?void 0:c.saveLock)&&C.jsx(il,{color:"#FFF",size:20}),s&&C.jsxs(Lt,{gap:"4px",children:[C.jsx(Vt,{label:"Open gallery",children:C.jsx(Nn,{onClick:()=>o("gallery"),icon:C.jsx(kh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),C.jsx(Kh,{})]}),s&&n?C.jsx(Vt,{label:"Save workflow",children:C.jsx(Nn,{onClick:()=>r(),icon:C.jsx(Mr,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):C.jsx("div",{style:{width:1}}),C.jsx(Hh,{}),C.jsx(Vh,{}),C.jsx(bh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"}),i==="spotlightSearch"&&C.jsx(Zh,{})]})}):null}function Jh(){const{showDialog:t}=Da(),{loadWorkflowID:e}=j.useContext(ot),n=async(o,s)=>{var u,c;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(u=await(H==null?void 0:H.listByIndex("cloudID",i.id)))==null?void 0:u.at(0);if(l){const d=(c=await(De==null?void 0:De.listByIndex("cloudID",a.id)))==null?void 0:c.at(0);if(d)await e(l.id,d.id);else{const p=await(De==null?void 0:De.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(H==null?void 0:H.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(De==null?void 0:De.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(Xh(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 j.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function Xh(t){return t.type==="workspace_open_workflow"}const Qh=t=>typeof t=="function",ep=t=>{const[e,n]=j.useState(t),r=j.useRef(e),o=j.useCallback(s=>{r.current=Qh(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function lr(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 ul={exports:{}};/*! + `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await ke("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:wo(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(l){var h;const{parentFolderID:u,name:c,json:d,id:p}=l;let f=JSON.parse(d);f.extra==null&&(f.extra={}),f.extra[Te]==null&&(f.extra[Te]={}),f.extra[Te].id=p,f.extra[Te].saveLock=l.saveLock,f.extra[Te].cloudID=l.cloudID,f.extra[Te].coverMediaPath=l.coverMediaPath;const w={parentFolderPath:At(u??""),name:c,json:JSON.stringify(f)};try{const m=await(await ke("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)})).json();return m.name&&await((h=ce.workflows)==null?void 0:h.update(p,{name:m.name})),m}catch(y){return console.error(`Error creating file <${p}> at "${u}"`,y),alert(`Error creating file <${p}> at "${u}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:u,id:c}){const d=br(l??"",u+".json");try{const f=await(await ke("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:c})})).json();return f.error&&(console.error(`Error getting file <${c}> at "${d}"`,f.error),alert({message:`Error getting file <${c}> at "${d}"`,level:"error"})),f}catch(p){return console.error(`Erro finding file <${c}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function Ws(t,e=!1,n=!1){try{return await(await ke("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:At(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function th(t,e){const n=At(t??""),o=(await Ws(n)).map(async a=>{var c;const l=a.name,u=[n,l].join("/");if(nh(a))return{id:At(u),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()};{const d=await((c=ce.workflows)==null?void 0:c.get(a.id).catch(f=>(console.error("Error getting workflow from indexdb",a.id,u,f),null)));return{cloudID:a.cloudID,coverMediaPath:a.coverMediaPath,saveLock:a.saveLock,...d,id:a.id,json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime,updateTime:a.updateTime}}}),s=await Promise.all(o);ce.workflows.bulkPut(s.filter(a=>!sh(a)));const i=s.filter(a=>a!=null);return wr(i,e??lt.RECENTLY_MODIFIED)}function nh(t){return"type"in t&&t.type==="folder"}const Lr=class Lr extends Jt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Lr}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 ce.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(J==null?void 0:J.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(J==null?void 0:J.getSetting("twoWaySync"))){const l=await Je.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??hn(),json:n.json??JSON.stringify(rl),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ce.workflows.add(i),this.saveDiskDB(),await(J==null?void 0:J.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):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 ce.workflows.update(n,r);const o=await ce.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){const o=await(J==null?void 0:J.getSetting("twoWaySync")),s=await this.get(n);!await this.updateMetaInfo(n,r)||!s||o&&await Je.moveWorkflow(s,r.parentFolderID)}async genLastManualSavedJson(n){const r=await(Ve==null?void 0:Ve.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(J==null?void 0:J.getSetting("twoWaySync"))&&o&&await Je.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(J==null?void 0:J.getSetting("twoWaySync"))&&a&&await Je.saveWorkflow(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=hn(),d=Date.now(),p={id:c,name:u,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(J==null?void 0:J.getSetting("twoWaySync")))try{const w=JSON.parse(l.json),h=(a=(i=w==null?void 0:w.extra)==null?void 0:i[Te])==null?void 0:a.id;h&&(await this.get(h)||(p.id=h)),Je.createWorkflow(p)}catch(w){console.error("batchCreateFlows error",w)}}try{await ce.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&await(J==null?void 0:J.getSetting("twoWaySync"))&&await Je.deleteWorkflow(r),await ce.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ce.workflows.bulkGet(n);for(const o of r){if(!o)return;await(J==null?void 0:J.getSetting("twoWaySync"))&&await Je.deleteWorkflow(o)}await ce.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(J==null?void 0:J.getSetting("twoWaySync"))){const l=await th(n??null);return wr(l,r??lt.RECENTLY_MODIFIED)}const s=await this.listAll().then(l=>l.filter(u=>u.parentFolderID==n))??[],i=await(qe==null?void 0:qe.listAll().then(l=>l.filter(u=>u.parentFolderID==n)))??[],a=[...s,...i];return wr(a,r??lt.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(J==null?void 0:J.getSetting("twoWaySync")),s=await ce.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Je.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(J==null?void 0:J.getSetting("twoWaySync"));let o;if(r){const i=(await Ws("",!0)).filter(a=>(a==null?void 0:a.type)==="workflow").map(async a=>{const l=await ce.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 ce.workflows.toArray();return n?wr(o,n):o}async updateLastOpenedTime(n){await ce.workflows.update(n,{lastOpenedTime:Date.now()})}};Ie(Lr,"TABLE_NAME","workflows");let ns=Lr;var St;(t=>{async function e({parentFolderID:a,name:l}){return At(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await ke("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:At(a.id)})})}t.createFolder=n;async function r(a,l){const c=await(await ke("/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 ke("/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 ke("/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 ke("/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})(St||(St={}));const Wr=class Wr extends Jt{constructor(){super("folders")}static async load(){return new Wr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(J==null?void 0:J.getSetting("twoWaySync")),o=await St.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:hn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await St.createFolder(s):(await ce.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(J==null?void 0:J.getSetting("twoWaySync")))return"parentFolderID"in n&&await St.moveFolder(e,n.parentFolderID??""),"name"in n&&await St.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;"name"in n&&n.name!=o.name;const s="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,i={...o,...n};return n.name!=null&&(i.updateTime=Date.now()),s&&(n.name=await this.generateUniqueName(i.name,i.parentFolderID??void 0)),await ce.folders.update(e,n),this.saveDiskDB(),i}async deleteFolder(e,n=gr.DELETE){if(await(J==null?void 0:J.getSetting("twoWaySync"))){await Ws(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(H==null||H.deleteFlow(l.id))})}),await St.deleteFolder(e);return}const o=await(H==null?void 0:H.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 gr.DELETE:await(H==null?void 0:H.deleteFlow(u.id));break;case gr.MOVE_TO_ROOT_FOLDER:await(H==null?void 0:H.updateFolder(u.id,{parentFolderID:void 0}));break}await ce.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(J==null?void 0:J.getSetting("twoWaySync")))return await Je.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(Wr,"TABLE_NAME","folders");let rs=Wr;class ol extends Jt{constructor(){super("media")}async listByWorkflowID(e){return await ce.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){if(e.localPath.split(".").pop()==null)return null;const r={id:e.localPath,localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now()};return await(H==null?void 0:H.updateMetaInfo(e.workflowID,{latestImage:r.localPath})),ce.media.put(r),this.saveDiskDB(),r}async delete(e){var n,r;super.delete(e),((n=H==null?void 0:H.curWorkflow)==null?void 0:n.coverMediaPath)===e&&(H==null||H.updateMetaInfo(H.curWorkflow.id,{coverMediaPath:void 0})),((r=H==null?void 0:H.curWorkflow)==null?void 0:r.latestImage)===e&&(H==null||H.updateMetaInfo(H.curWorkflow.id,{latestImage:void 0}))}}Ie(ol,"TABLE_NAME","media");const Op=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Dp=2,rh={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Pp(t){return t.modelVersions!==void 0}function oh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function jp(t,e){var r,o,s,i,a,l;if(!t)return;let n;return oh(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 Ur=class Ur extends Jt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");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:rh,autoSave:!1,autoSaveDuration:3,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.co",maximumChangelogNumber:80,hideCoverImage:!1,disableUnsavedWarning:!1}}get settings(){return this._settings}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),await ke("/workspace/save_settings",{method:"POST",body:JSON.stringify(this._settings),headers:{"Content-Type":"application/json"}}),this._settings={...this.defaultSettings,...o}}static async load(){var o,s,i,a;const n=new Ur,r=await Zd();return n.defaultSettings.myWorkflowsDir=r.path,await n.get(n.DEFAULT_USER).then(l=>{n._settings={...n.defaultSettings,...l}}),((s=(o=n._settings)==null?void 0:o.cloudHost)!=null&&s.includes("nodecafe.org")||(a=(i=n._settings)==null?void 0:i.cloudHost)!=null&&a.includes("comfyspace.art"))&&await n.upsert({cloudHost:n.defaultSettings.cloudHost}),n}};Ie(Ur,"TABLE_NAME","userSettings");let os=Ur;const Kr=class Kr extends Jt{constructor(){super("tags")}static async load(){return new Kr}};Ie(Kr,"TABLE_NAME","tags");let ss=Kr;const $r=class $r extends Jt{constructor(){super("workflowVersions")}static async load(){return new $r}async listByWorkflowID(e){return await ce[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($r,"TABLE_NAME","workflowVersions");let as=$r;function sh(t){return"type"in t&&t.type==="folder"}let H=null,_r=null,J=null,qe=null,Ve=null,Ht=null,De=null;async function ah(){const t=async()=>{H=await ns.load()},e=async()=>{_r=await ss.load()},n=async()=>{J=await os.load()},r=async()=>{qe=await rs.load()},o=async()=>{Ve=await ts.load()},s=async()=>{Ht=new ol},i=async()=>{De=await as.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await ih(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function ih(){const t=async()=>{try{const a=await(H==null?void 0:H.getRecords());a&&await ce.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(qe==null?void 0:qe.getRecords());a&&await ce.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Ht==null?void 0:Ht.getRecords());a&&await ce.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ce.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(_r==null?void 0:_r.getRecords());a&&await ce.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=J,l=await a.getRecords().then(u=>u[a.DEFAULT_USER]?u[a.DEFAULT_USER]:u);await ce.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(De==null?void 0:De.getRecords());a&&await ce.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const ot=j.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:async()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{},setCurFlowIDAndName:()=>{},session:null,updateSession:()=>{}}),Ap=j.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),bo={x:0,y:0};function lh({children:t,onDragEnd:e,dragIconId:n}){const r=j.useRef(bo),o=j.useRef(!1),[s,i]=j.useState(bo),a=d=>{var p,f,w;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(w=(f=d.target)==null?void 0:f.parentNode)==null?void 0:w.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const h=document.getElementsByTagName("body")[0];h.style.userSelect="none"}},l=j.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),u=j.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),bo)),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 C.jsx("div",{style:c,onMouseDown:a,children:t})}var ch={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"},uh=Object.defineProperty,dh=Object.defineProperties,fh=Object.getOwnPropertyDescriptors,Br=Object.getOwnPropertySymbols,sl=Object.prototype.hasOwnProperty,al=Object.prototype.propertyIsEnumerable,_a=(t,e,n)=>e in t?uh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xa=(t,e)=>{for(var n in e||(e={}))sl.call(e,n)&&_a(t,n,e[n]);if(Br)for(var n of Br(e))al.call(e,n)&&_a(t,n,e[n]);return t},hh=(t,e)=>dh(t,fh(e)),ph=(t,e)=>{var n={};for(var r in t)sl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Br)for(var r of Br(t))e.indexOf(r)<0&&al.call(t,r)&&(n[r]=t[r]);return n},Re=(t,e,n)=>{const r=j.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:u=2,children:c}=i,d=ph(i,["color","size","stroke","children"]);return j.createElement("svg",xa(hh(xa({ref:s},ch),{width:l,height:l,stroke:a,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,f])=>j.createElement(p,f)),...c||[]])});return r.propTypes={color:Tt.string,size:Tt.oneOfType([Tt.string,Tt.number]),stroke:Tt.oneOfType([Tt.string,Tt.number])},r.displayName=`${e}`,r},mh=Re("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"}]]),yh=Re("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),Mr=Re("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"}]]),vh=Re("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"}]]),gh=Re("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"}]]),wh=Re("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"}]]),bh=Re("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"}]]),_h=Re("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"}]]),xh=Re("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"}]]),il=Re("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"}]]),kh=Re("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"}]]),Eh=Re("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"}]]),Ch=Re("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"}]]),ll=Re("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"}]]),Sh=Re("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"}]]),Ih=Re("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"}]]),Oh=Re("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Dh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return C.jsx(di,{isLazy:!0,placement:"auto",gutter:0,children:({onClose:i})=>C.jsxs(C.Fragment,{children:[C.jsx(ui,{children:C.jsx(Ot,{children:C.jsx(Vt,{hasArrow:!0,label:s,placement:"bottom",children:C.jsx(Nn,{"aria-label":"Delete confirm",size:"sm",icon:C.jsx(Ch,{color:"#F56565",size:"20px"}),isDisabled:o,variant:n})})})}),C.jsxs(mi,{children:[C.jsx(hi,{onClick:i}),C.jsxs(fi,{children:[C.jsx(mt,{mb:4,pr:4,fontWeight:600,children:e}),C.jsx(Le,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Ph({onClose:t}){var x;const{isDirty:e,loadWorkflowID:n,curVersion:r,session:o}=j.useContext(ot),[s,i]=j.useState(0),[a,l]=j.useState(null),[u,c]=j.useState([]),[d,p]=j.useState([]),f=H==null?void 0:H.curWorkflow,w=(x=J==null?void 0:J.settings)==null?void 0:x.cloudHost,[h,y]=j.useState(!1),m=async k=>{var R;const O=await(H==null?void 0:H.get(k)),E=await(Ve==null?void 0:Ve.listByWorkflowID(k));c(E??[]);const N=E==null?void 0:E.filter(q=>q.json===(O==null?void 0:O.json)),D=(R=N==null?void 0:N[0])==null?void 0:R.id;D&&l(D)},v=async()=>{var O;let k=await(De==null?void 0:De.listByWorkflowID(f.id))??[];o!=null&&o.shareKey&&(f!=null&&f.cloudID)&&(y(!0),await fetch(((O=J==null?void 0:J.settings)==null?void 0:O.cloudHost)+"/api/listWorkflowVersionsByWorkflowID?workflowID="+(f==null?void 0:f.cloudID),{headers:{authorization:`Bearer ${o==null?void 0:o.shareKey}`}}).then(E=>E.json()).then(E=>{if(E.items){const N=E.items.map(D=>({...D,isCloud:!0}));k=k.concat(N)}}).catch(E=>{console.error(E)}),y(!1)),p(k)},_=k=>{De==null||De.delete(k).then(()=>{v()})};return j.useEffect(()=>{switch(s){case 0:v();break;case 1:m(f.id);break}},[s]),j.useEffect(()=>(Pe.canvasEl.addEventListener("click",t),()=>{Pe.canvasEl.removeEventListener("click",t)}),[s]),C.jsxs(Gl,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[C.jsx(Vl,{pb:1,mb:0,children:C.jsxs(on,{justifyContent:"space-between",alignItems:"center",children:[C.jsx(hs,{size:"md",children:"Version History"}),C.jsx(Nn,{size:"sm",icon:C.jsx(Oh,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),C.jsx(ql,{overflowY:"auto",gap:0,children:C.jsxs(gi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[C.jsxs(wi,{mb:"1em",children:[C.jsx(Oo,{children:"Versions"}),C.jsx(Oo,{children:"Change History"})]}),C.jsxs(bi,{children:[C.jsxs(Io,{children:[(o==null?void 0:o.shareKey)&&C.jsxs(mt,{color:"GrayText",mb:3,children:["Connected to"," ",C.jsx("a",{href:w,target:"_blank",children:w})]}),C.jsxs(It,{divider:C.jsx(ko,{}),spacing:2,children:[h&&C.jsx(mt,{children:"Loading..."}),d==null?void 0:d.map(k=>C.jsxs(on,{w:"100%",mb:1,justify:"space-between",backgroundColor:k.id===(r==null?void 0:r.id)?"teal.300":void 0,borderRadius:4,children:[C.jsxs(It,{textAlign:"left",gap:0,children:[k.isCloud?C.jsx("a",{target:"_blank",href:`${w}/workflow/${k.workflowID}/${k.id}`,children:k.name??"untitled"}):C.jsx(mt,{fontWeight:"500",children:k.name??"untitled"}),C.jsxs(mt,{color:"GrayText",fontSize:"sm",children:["Created:"," ",new Date(k.createTime??k.createdAt??k.created_at??"").toLocaleString()]})]}),C.jsxs(on,{alignItems:"center",gap:2,children:[C.jsx(Le,{size:"sm",onClick:()=>{if(e){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}Pe.loadGraphData(JSON.parse(k.json)),n(f.id,k.id),t()},children:"Load"}),!k.isCloud&&C.jsx(Dh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{_(k.id)}})]})]},k.id))]})]}),C.jsxs(Io,{children:[C.jsx(mt,{mb:4,children:"All the saved changes of this workflow"}),C.jsx(It,{divider:C.jsx(ko,{}),spacing:2,children:u==null?void 0:u.map(k=>C.jsxs(Lt,{justifyContent:"space-between",children:[C.jsxs(Le,{size:"sm",variant:"ghost",onClick:()=>{if(e){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}Pe.loadGraphData(JSON.parse(k.json)),t()},isActive:k.id===a,children:["Saved at ",new Date(k.createTime).toLocaleString()]},k.id),k.isAutoSave?C.jsx(to,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},k.id))})]})]})]})})]})}const cl="idk0087hcd";function jh(t,e=cl){const n=Math.floor(Math.random()*13)+1,o=Math.random().toString(36).substring(2,2+n)+e+t;return btoa(encodeURIComponent(o))}function Ah(t,e=cl){if(t=="")return null;const n=decodeURIComponent(atob(t)),r=n.indexOf(e);return r===-1?null:n.slice(r+e.length)}function Nh(t){const e=jh(t);localStorage.setItem("workspace_manager_shareKey",e)}function Fh(){var r;const t=(r=J==null?void 0:J.settings)==null?void 0:r.cloudHost,e=ds(),{updateSession:n}=j.useContext(ot);return C.jsxs(It,{p:"10px 10px",gap:3,children:[C.jsx("h2",{style:{fontSize:"1.2rem",fontWeight:"bold"},children:"✨New Version Control Exprience [beta]"}),C.jsxs("p",{children:["We have a new version control experience. Now your versions will be stored ",C.jsx("b",{children:"privately"})," and securely in cloud at"," ",C.jsx("a",{href:"www.nodecafe.co",children:"www.nodecafe.co"})]}),C.jsx("h3",{style:{fontWeight:"bold"},children:"Why cloud?"}),C.jsx("p",{children:"Previously workflow versions are stored locally in your browser storage. But people reported inconsistent versions when they switched browser or device. Therefore we are moving to cloud. So you can view your workflow versions from any devices, even your phone."}),C.jsx("h3",{style:{fontWeight:"bold"},children:"🤩Get Started"}),C.jsxs(on,{alignItems:"center",gap:2,mb:3,children:[C.jsx("a",{href:t+"/auth/shareKey",target:"_blank",children:C.jsx(Le,{colorScheme:"blue",children:"Login"})}),C.jsx("p",{children:" then copy your share key to below"})]}),C.jsx(yn,{placeholder:"Paste your share key here",onChange:o=>{!o.target.value||o.target.value===""||o.target.value.length<20||(Nh(o.target.value),n({shareKey:o.target.value,username:null}),e({title:"Share key saved. You can create versions now.",status:"success",duration:5e3}))}})]})}function Np(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Fp=[{label:"Private",value:"PRIVATE",icon:C.jsx(il,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:C.jsx(xh,{})},{label:"Public",value:"PUBLIC",icon:C.jsx(Ih,{})}],Rh=()=>{const t=Pe.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 Th(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 Rp({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")),C.jsx("span",{children:n})}function Bh(){const t=new Date,e=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${n}`}function Mh({onClose:t}){var p;const[e,n]=j.useState("v"+Bh()),[r,o]=j.useState(""),{session:s}=j.useContext(ot),i=ds(),[a,l]=j.useState(!1),u=f=>{n(f.target.value),r&&o("")},c=async()=>{var h,y,m;const f=e.trim();if(n(f),!(H!=null&&H.curWorkflow))throw new Error("No workflow selected");l(!0);const w={workflow:{name:(h=H==null?void 0:H.curWorkflow)==null?void 0:h.name,cloudID:(y=H==null?void 0:H.curWorkflow)==null?void 0:y.cloudID},version:{name:f,json:JSON.stringify(Pe.graph.serialize())},nodeDefs:Rh(),privacy:tl.PRIVATE};await fetch(((m=J==null?void 0:J.settings)==null?void 0:m.cloudHost)+"/api/createCloudflow",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s==null?void 0:s.shareKey}`},body:JSON.stringify(w)}).then(v=>v.json()).then(v=>{var _;if(v!=null&&v.data){const x=v.data.workflowID;H==null||H.updateMetaInfo((_=H==null?void 0:H.curWorkflow)==null?void 0:_.id,{cloudID:x}),i({title:"Version created",status:"success",duration:3e3}),t()}else o("Failed to create version. "+((v==null?void 0:v.error)??""))}).catch(v=>(o("Failed to create version"),null)),l(!1)};if(!(s!=null&&s.shareKey))return C.jsx(xr,{isOpen:!0,onClose:t,size:"xl",children:C.jsx(kr,{width:"90vw",children:C.jsx(Er,{children:C.jsx(Fh,{})})})});const d=new URL(J.settings.cloudHost).hostname;return C.jsx(xr,{isOpen:!0,onClose:t,children:C.jsxs(kr,{children:[C.jsx(cs,{}),C.jsxs(Er,{children:[C.jsxs(It,{mb:5,children:[C.jsx("p",{style:{fontSize:20,fontWeight:"bold"},children:"Create Version"}),C.jsxs("p",{style:{color:"GrayText"},children:["Saving to"," ",C.jsxs("a",{href:(p=J==null?void 0:J.settings)==null?void 0:p.cloudHost,children:[" ",d]})]})]}),C.jsxs(Gr,{isInvalid:!!r,children:[C.jsx(Yr,{children:"Name"}),C.jsx(yn,{value:e,onChange:u,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!r&&e&&c()}}),r&&C.jsx(Zr,{children:r})]})]}),C.jsxs(us,{children:[C.jsx(Le,{colorScheme:"teal",mr:3,onClick:c,isDisabled:!e,isLoading:a,children:"Create"}),C.jsx(Le,{onClick:t,children:"Cancel"})]})]})})}function zh({options:t,menuButton:e,isOpen:n,onClose:r}){const o=j.useRef(null);return wc({ref:o,handler:()=>r()}),C.jsxs(Ot,{position:"relative",children:[C.jsx(Ot,{children:e}),n&&C.jsx(Ot,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function Lh({menuButton:t,menuContent:e,onClose:n}){const r=j.useRef(),[o,s]=j.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return C.jsx(zh,{isOpen:o,onClose:i,menuButton:C.jsx(Ot,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:C.jsx(Es,{isOpen:!0,children:C.jsx(Cs,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}function Wh(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 Uh({}){const[t,e]=j.useState(),[n,r]=j.useState(),{curFlowID:o}=j.useContext(ot);return j.useEffect(()=>{o&&(H==null||H.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),Th(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?C.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:C.jsx(Ia,{children:C.jsx(to,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}const Kh=j.lazy(()=>Ft(()=>import("./ShareDialog-DSSo_bep.js"),__vite__mapDeps([0,1,2,3,4,5])));function $h(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=j.useContext(ot),[i,a]=j.useState(!1),[l,u]=j.useState(""),[c,d]=j.useState(""),[p,f]=j.useState(),[w,h]=j.useState({save:"",saveAs:""});j.useEffect(()=>{t&&(H==null||H.get(t).then(x=>{u((x==null?void 0:x.name)??""),f(x)})),J==null||J.getSetting("shortcuts").then(x=>{h(x)})},[t]);const y=x=>{u(x.target.value),c&&d("")},m=async()=>{if(!t){alert("Flow ID is required");return}const x=JSON.stringify(Pe.graph.serialize()),k=await(H==null?void 0:H.createFlow({json:x,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));k&&await e(k.id,null,!0),v()},v=()=>{o("root")},_=j.useCallback(async()=>{const x=H==null?void 0:H.curWorkflow;if(!x){alert("No current workflow!");return}const k=Pe.graph.serialize(),O=JSON.stringify(k,null,2);Wh(O,x.name)},[t]);return C.jsxs(C.Fragment,{children:[C.jsx(Lh,{menuButton:C.jsx(Ia,{children:C.jsxs(Le,{px:1,height:zs+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",C.jsx(yh,{size:20})]})}),menuContent:C.jsx(Es,{isOpen:!0,children:C.jsxs(Cs,{minWidth:150,zIndex:1e3,children:[C.jsx(xt,{onClick:()=>r(),icon:C.jsx(Mr,{size:20}),iconSpacing:1,command:w.save,children:"Save"}),C.jsx(Vt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:C.jsx(xt,{onClick:n,icon:C.jsx(mh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),C.jsx(xt,{onClick:_,icon:C.jsx(vh,{size:20}),iconSpacing:1,children:"Download"}),C.jsx(xt,{onClick:()=>o("saveAsModal"),icon:C.jsx(Mr,{size:20}),iconSpacing:1,command:w.saveAs,children:"Save As"}),C.jsx(xt,{onClick:()=>a(!0),icon:C.jsx(Sh,{size:20}),iconSpacing:1,children:"Create Version"}),C.jsx(xt,{onClick:()=>o("versionHistory"),icon:C.jsx(_h,{size:20}),iconSpacing:1,children:"Versions History"}),C.jsx(xt,{onClick:()=>o("share"),icon:C.jsx(Eh,{size:20}),iconSpacing:1,alignItems:"center",children:C.jsxs(Lt,{children:[C.jsx("p",{children:"Share"})," ",C.jsx(to,{size:"sm",children:"🧪beta"}),C.jsx(Uh,{})]})})]})})}),s==="share"&&C.jsx(Kh,{onClose:()=>o("root")}),s=="versionHistory"&&C.jsx(Ph,{onClose:()=>o("root")}),s==="saveAsModal"&&C.jsxs(xr,{isOpen:!0,onClose:v,children:[C.jsx(Oa,{}),C.jsxs(kr,{children:[C.jsx(Da,{children:"Save As"}),C.jsx(cs,{}),C.jsx(Er,{children:C.jsxs(Gr,{isInvalid:!!c,children:[C.jsx(Yr,{children:"Workflow name"}),C.jsx(yn,{value:l,onChange:y,autoFocus:!0,onKeyUp:x=>{x.code==="Enter"&&!c&&l&&m()}}),c&&C.jsx(Zr,{children:c})]})}),C.jsxs(us,{children:[C.jsx(Le,{colorScheme:"teal",mr:3,onClick:m,isDisabled:!l||!!c,children:"Save"}),C.jsx(Le,{onClick:v,children:"Cancel"})]})]})]}),i&&C.jsx(Mh,{workflowId:t,onClose:()=>a(!1)})]})}function Hh({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=xc(),{curFlowID:i}=j.useContext(ot),[a,l]=j.useState(t),[u,c]=j.useState(""),d=()=>{l(t),o()},p=h=>{l(h.target.value),u&&c("")},f=async()=>{var h;if(i){const y=a.trim();if(l(y),t===y)return w();await(H==null?void 0:H.generateUniqueName(y,((h=H.curWorkflow)==null?void 0:h.parentFolderID)??""))!==y?c("The name is duplicated, please modify it and submit again."):(await(H==null?void 0:H.updateName(i,{name:y})),e(y),w())}},w=()=>{c(""),s()};return i==null?null:C.jsxs(Lt,{children:[C.jsx(Vt,{label:t,placement:"bottom",children:C.jsxs(mt,{as:"div",color:"white",onClick:d,maxW:160,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[C.jsx("div",{style:{width:8,display:"inline-block"},children:C.jsx(mt,{as:"span",children:n&&"* "})}),t]})}),C.jsxs(xr,{isOpen:r,onClose:w,children:[C.jsx(Oa,{}),C.jsxs(kr,{children:[C.jsx(Da,{children:"Edit workflow name"}),C.jsx(cs,{}),C.jsx(Er,{children:C.jsxs(Gr,{isInvalid:!!u,children:[C.jsx(Yr,{children:"Workflow name"}),C.jsx(yn,{value:a,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!u&&a&&f()}}),u&&C.jsx(Zr,{children:u})]})}),C.jsxs(us,{children:[C.jsx(Le,{colorScheme:"teal",mr:3,onClick:f,isDisabled:!a||!!u,children:"Save"}),C.jsx(Le,{onClick:w,children:"Cancel"})]})]})]})]})}function qh({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=j.useContext(ot);return j.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?C.jsx(on,{alignItems:"center",children:C.jsx(Ta,{size:"sm",isAttached:!0,variant:"outline",children:C.jsx(Le,{rightIcon:C.jsx(ll,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}function Vh(){const{setCurFlowIDAndName:t,curFlowID:e}=j.useContext(ot),n=async()=>{const r=prompt("Enter workflow name","Untitled");if(!r)return;const o=hn(),s=Pe.graph.serialize();s.extra||(s.extra={}),s.extra[Te]||(s.extra[Te]={}),s.extra[Te].id=o;const i=await(H==null?void 0:H.createFlow({id:o,json:JSON.stringify(s),name:r}));i&&t(i)};return e?null:C.jsx(Vt,{label:"Save workflow",children:C.jsx(Le,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:zs+"px",onClick:()=>n(),px:1,children:C.jsx(Mr,{size:16,color:"white"})})})}const Gh=j.lazy(()=>Ft(()=>import("./AppIsDirtyEventListener-XYtSk7Rv.js"),__vite__mapDeps([6,1,7]))),Zh=j.lazy(()=>Ft(()=>import("./ModelManagerTopbar-d0zTxQle.js"),__vite__mapDeps([8,1,3,2,9,10,11]))),Yh=j.lazy(()=>Ft(()=>import("./SpotlightSearch-rjI_Y8hu.js"),__vite__mapDeps([12,1,7,13,14])));function Jh({curFlowName:t,setCurFlowName:e}){var c;const{isDirty:n,saveCurWorkflow:r,setRoute:o,curFlowID:s,route:i}=j.useContext(ot),[a,l]=j.useState(),u=j.useCallback((d,p=!1)=>{const{top:f=0,left:w=0}=a||{};let{top:h=0,left:y=0}=d??{};h+=f,y+=w;const m=document.documentElement.clientWidth,v=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),x=(_==null?void 0:_.offsetWidth)||392;h+36>v&&(h=v-36),y+x>=m&&(y=m-x),l({top:Math.max(0,h),left:Math.max(0,y)}),p&&(J==null||J.upsert({topBarStyle:{top:h,left:y}}))},[a]);return j.useEffect(()=>{J==null||J.getSetting("topBarStyle").then(d=>{u(d,!1)})},[]),a?C.jsx(lh,{onDragEnd:d=>{u({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:C.jsxs(Lt,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[C.jsx(Le,{size:"sm","aria-label":"workspace folder",height:zs+"px",onClick:()=>o("recentFlows"),px:2,children:C.jsxs(Lt,{gap:1,children:[C.jsx(wh,{size:21}),C.jsx(ll,{size:8})]})}),C.jsx(j.Suspense,{fallback:C.jsx("div",{style:{width:"60px"}}),children:C.jsx(Zh,{})}),C.jsx(Vh,{}),C.jsx(Hh,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{u()})}}),((c=H==null?void 0:H.curWorkflow)==null?void 0:c.saveLock)&&C.jsx(il,{color:"#FFF",size:20}),s&&C.jsxs(Lt,{gap:"4px",children:[C.jsx(Vt,{label:"Open gallery",children:C.jsx(Nn,{onClick:()=>o("gallery"),icon:C.jsx(kh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),C.jsx($h,{})]}),s&&n?C.jsx(Vt,{label:"Save workflow",children:C.jsx(Nn,{onClick:()=>r(),icon:C.jsx(Mr,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):C.jsx("div",{style:{width:1}}),C.jsx(qh,{}),C.jsx(Gh,{}),C.jsx(bh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"}),i==="spotlightSearch"&&C.jsx(Yh,{})]})}):null}function Xh(){const{showDialog:t}=Pa(),{loadWorkflowID:e}=j.useContext(ot),n=async(o,s)=>{var u,c;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(u=await(H==null?void 0:H.listByIndex("cloudID",i.id)))==null?void 0:u.at(0);if(l){const d=(c=await(De==null?void 0:De.listByIndex("cloudID",a.id)))==null?void 0:c.at(0);if(d)await e(l.id,d.id);else{const p=await(De==null?void 0:De.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(H==null?void 0:H.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(De==null?void 0:De.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(Qh(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 j.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function Qh(t){return t.type==="workspace_open_workflow"}const ep=t=>typeof t=="function",tp=t=>{const[e,n]=j.useState(t),r=j.useRef(e),o=j.useCallback(s=>{r.current=ep(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function lr(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 ul={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -18,10 +18,10 @@ 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 lr=="function"&&lr;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 f=o[u]={exports:{}};r[u][0].call(f.exports,function(w){var h=r[u][1][w];return i(h||w)},f,f.exports,n,r,o,s)}return o[u].exports}for(var a=typeof lr=="function"&&lr,l=0;l>2,f=(3&u)<<4|c>>4,w=1<_?(15&c)<<2|d>>6:64,h=2<_?63&d:64,y.push(a.charAt(p)+a.charAt(f)+a.charAt(w)+a.charAt(h));return y.join("")},o.decode=function(l){var u,c,d,p,f,w,h=0,y=0,m="data:";if(l.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var v,_=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(v=i.uint8array?new Uint8Array(0|_):new Array(0|_);h>4,c=(15&p)<<4|(f=a.indexOf(l.charAt(h++)))>>2,d=(3&f)<<6|(w=a.indexOf(l.charAt(h++))),v[y++]=u,f!==64&&(v[y++]=c),w!==64&&(v[y++]=d);return v}},{"./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,f,w){this.compressedSize=c,this.uncompressedSize=d,this.crc32=p,this.compression=f,this.compressedContent=w}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 f=i,w=p+d;u^=-1;for(var h=p;h>>8^f[255&(u^c[h])];return-1^u}(0|l,a,a.length,0):function(u,c,d,p){var f=i,w=p+d;u^=-1;for(var h=p;h>>8^f[255&(u^c.charCodeAt(h))];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(f,w){var h,y="";for(h=0;h>>=8;return y}function i(f,w,h,y,m,v){var _,x,k=f.file,O=f.compression,E=v!==u.utf8encode,N=a.transformTo("string",v(k.name)),D=a.transformTo("string",u.utf8encode(k.name)),R=k.comment,q=a.transformTo("string",v(R)),P=a.transformTo("string",u.utf8encode(R)),T=D.length!==k.name.length,b=P.length!==R.length,K="",$="",A="",G=k.dir,L=k.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};w&&!h||(ne.crc32=f.crc32,ne.compressedSize=f.compressedSize,ne.uncompressedSize=f.uncompressedSize);var z=0;w&&(z|=8),E||!T&&!b||(z|=2048);var B=0,te=0;G&&(B|=16),m==="UNIX"?(te=798,B|=function(Y,me){var ge=Y;return Y||(ge=me?16893:33204),(65535&ge)<<16}(k.unixPermissions,G)):(te=20,B|=function(Y){return 63&(Y||0)}(k.dosPermissions)),_=L.getUTCHours(),_<<=6,_|=L.getUTCMinutes(),_<<=5,_|=L.getUTCSeconds()/2,x=L.getUTCFullYear()-1980,x<<=4,x|=L.getUTCMonth()+1,x<<=5,x|=L.getUTCDate(),T&&($=s(1,1)+s(c(N),4)+D,K+="up"+s($.length,2)+$),b&&(A=s(1,1)+s(c(q),4)+P,K+="uc"+s(A.length,2)+A);var X="";return X+=` -\0`,X+=s(z,2),X+=O.magic,X+=s(_,2),X+=s(x,2),X+=s(ne.crc32,4),X+=s(ne.compressedSize,4),X+=s(ne.uncompressedSize,4),X+=s(N.length,2),X+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+X+N+K,dirRecord:d.CENTRAL_FILE_HEADER+s(te,2)+X+s(q.length,2)+"\0\0\0\0"+s(B,4)+s(y,4)+N+K+q}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),c=n("../crc32"),d=n("../signature");function p(f,w,h,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=w,this.zipPlatform=h,this.encodeFileName=y,this.streamFiles=f,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(f){var w=f.meta.percent||0,h=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,l.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:h?(w+100*(h-y-1))/h:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var w=this.streamFiles&&!f.file.dir;if(w){var h=i(f,w,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var w=this.streamFiles&&!f.file.dir,h=i(f,w,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),w)this.push({data:function(y){return d.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)}(f),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,w=0;w=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(w,h){return new c.Promise(function(y,m){var v=[],_=w._internalType,x=w._outputType,k=w._mimeType;w.on("data",function(O,E){v.push(O),h&&h(E)}).on("error",function(O){v=[],m(O)}).on("end",function(){try{var O=function(E,N,D){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),D);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(x,function(E,N){var D,R=0,q=null,P=0;for(D=0;D"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(f){return i.nodebuffer?a.newBufferFrom(f,"utf-8"):function(w){var h,y,m,v,_,x=w.length,k=0;for(v=0;v>>6:(y<65536?h[_++]=224|y>>>12:(h[_++]=240|y>>>18,h[_++]=128|y>>>12&63),h[_++]=128|y>>>6&63),h[_++]=128|63&y);return h}(f)},o.utf8decode=function(f){return i.nodebuffer?s.transformTo("nodebuffer",f).toString("utf-8"):function(w){var h,y,m,v,_=w.length,x=new Array(2*_);for(h=y=0;h<_;)if((m=w[h++])<128)x[y++]=m;else if(4<(v=u[m]))x[y++]=65533,h+=v-1;else{for(m&=v===2?31:v===3?15:7;1>10&1023,x[y++]=56320|1023&m)}return x.length!==y&&(x.subarray?x=x.subarray(0,y):x.length=y),s.applyFromCharCode(x)}(f=s.transformTo(i.uint8array?"uint8array":"array",f))},s.inherits(d,l),d.prototype.processChunk=function(f){var w=s.transformTo(i.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var h=w;(w=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),w.set(h,this.leftOver.length)}else w=this.leftOver.concat(w);this.leftOver=null}var y=function(v,_){var x;for((_=_||v.length)>v.length&&(_=v.length),x=_-1;0<=x&&(192&v[x])==128;)x--;return x<0||x===0?_:x+u[v[x]]>_?x:_}(w),m=w;y!==w.length&&(i.uint8array?(m=w.subarray(0,y),this.leftOver=w.subarray(y,w.length)):(m=w.slice(0,y),this.leftOver=w.slice(y,w.length))),this.push({data:o.utf8decode(m),meta:f.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(f){this.push({data:o.utf8encode(f.data),meta:f.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(h){return h}function c(h,y){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var w,h,y,m=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4>>6:(f<65536?p[y++]=224|f>>>12:(p[y++]=240|f>>>18,p[y++]=128|f>>>12&63),p[y++]=128|f>>>6&63),p[y++]=128|63&f);return p},o.buf2binstring=function(d){return c(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),f=0,w=p.length;f>10&1023,v[w++]=56320|1023&h)}return c(v,w)},o.utf8border=function(d,p){var f;for((p=p||d.length)>d.length&&(p=d.length),f=p-1;0<=f&&(192&d[f])==128;)f--;return f<0||f===0?p:f+l[d[f]]>p?f: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,f=0,w=-2,h=-1,y=4,m=2,v=8,_=9,x=286,k=30,O=19,E=2*x+1,N=15,D=3,R=258,q=R+D+1,P=42,T=113,b=1,K=2,$=3,A=4;function G(g,U){return g.msg=c[U],U}function L(g){return(g<<1)-(4g.avail_out&&(W=g.avail_out),W!==0&&(i.arraySet(g.output,U.pending_buf,U.pending_out,W,g.next_out),g.next_out+=W,U.pending_out+=W,g.total_out+=W,g.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function B(g,U){a._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,U),g.block_start=g.strstart,z(g.strm)}function te(g,U){g.pending_buf[g.pending++]=U}function X(g,U){g.pending_buf[g.pending++]=U>>>8&255,g.pending_buf[g.pending++]=255&U}function Y(g,U){var W,I,S=g.max_chain_length,F=g.strstart,V=g.prev_length,Z=g.nice_match,M=g.strstart>g.w_size-q?g.strstart-(g.w_size-q):0,Q=g.window,re=g.w_mask,ee=g.prev,se=g.strstart+R,ve=Q[F+V-1],he=Q[F+V];g.prev_length>=g.good_match&&(S>>=2),Z>g.lookahead&&(Z=g.lookahead);do if(Q[(W=U)+V]===he&&Q[W+V-1]===ve&&Q[W]===Q[F]&&Q[++W]===Q[F+1]){F+=2,W++;do;while(Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&FM&&--S!=0);return V<=g.lookahead?V:g.lookahead}function me(g){var U,W,I,S,F,V,Z,M,Q,re,ee=g.w_size;do{if(S=g.window_size-g.lookahead-g.strstart,g.strstart>=ee+(ee-q)){for(i.arraySet(g.window,g.window,ee,ee,0),g.match_start-=ee,g.strstart-=ee,g.block_start-=ee,U=W=g.hash_size;I=g.head[--U],g.head[U]=ee<=I?I-ee:0,--W;);for(U=W=ee;I=g.prev[--U],g.prev[U]=ee<=I?I-ee:0,--W;);S+=ee}if(g.strm.avail_in===0)break;if(V=g.strm,Z=g.window,M=g.strstart+g.lookahead,Q=S,re=void 0,re=V.avail_in,Q=D)for(F=g.strstart-g.insert,g.ins_h=g.window[F],g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D)if(I=a._tr_tally(g,g.strstart-g.match_start,g.match_length-D),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=D){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D&&g.match_length<=g.prev_length){for(S=g.strstart+g.lookahead-D,I=a._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-D),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=S&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(W=g.pending_buf_size-5);;){if(g.lookahead<=1){if(me(g),g.lookahead===0&&U===d)return b;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var I=g.block_start+W;if((g.strstart===0||g.strstart>=I)&&(g.lookahead=g.strstart-I,g.strstart=I,B(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-q&&(B(g,!1),g.strm.avail_out===0))return b}return g.insert=0,U===p?(B(g,!0),g.strm.avail_out===0?$:A):(g.strstart>g.block_start&&(B(g,!1),g.strm.avail_out),b)}),new ue(4,4,8,4,ge),new ue(4,5,16,8,ge),new ue(4,6,32,32,ge),new ue(4,4,16,16,ie),new ue(8,16,32,32,ie),new ue(8,16,128,128,ie),new ue(8,32,128,256,ie),new ue(32,128,258,1024,ie),new ue(32,258,258,4096,ie)],o.deflateInit=function(g,U){return xe(g,U,v,15,8,0)},o.deflateInit2=xe,o.deflateReset=pe,o.deflateResetKeep=ye,o.deflateSetHeader=function(g,U){return g&&g.state?g.state.wrap!==2?w:(g.state.gzhead=U,f):w},o.deflate=function(g,U){var W,I,S,F;if(!g||!g.state||5>8&255),te(I,I.gzhead.time>>16&255),te(I,I.gzhead.time>>24&255),te(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),te(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(te(I,255&I.gzhead.extra.length),te(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(g.adler=u(g.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(te(I,0),te(I,0),te(I,0),te(I,0),te(I,0),te(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),te(I,3),I.status=T);else{var V=v+(I.w_bits-8<<4)<<8;V|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(V|=32),V+=31-V%31,I.status=T,X(I,V),I.strstart!==0&&(X(I,g.adler>>>16),X(I,65535&g.adler)),g.adler=1}if(I.status===69)if(I.gzhead.extra){for(S=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),z(g),S=I.pending,I.pending!==I.pending_buf_size));)te(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){S=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),z(g),S=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexS&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),F===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){S=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),z(g),S=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexS&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),F===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&z(g),I.pending+2<=I.pending_buf_size&&(te(I,255&g.adler),te(I,g.adler>>8&255),g.adler=0,I.status=T)):I.status=T),I.pending!==0){if(z(g),g.avail_out===0)return I.last_flush=-1,f}else if(g.avail_in===0&&L(U)<=L(W)&&U!==p)return G(g,-5);if(I.status===666&&g.avail_in!==0)return G(g,-5);if(g.avail_in!==0||I.lookahead!==0||U!==d&&I.status!==666){var Z=I.strategy===2?function(M,Q){for(var re;;){if(M.lookahead===0&&(me(M),M.lookahead===0)){if(Q===d)return b;break}if(M.match_length=0,re=a._tr_tally(M,0,M.window[M.strstart]),M.lookahead--,M.strstart++,re&&(B(M,!1),M.strm.avail_out===0))return b}return M.insert=0,Q===p?(B(M,!0),M.strm.avail_out===0?$:A):M.last_lit&&(B(M,!1),M.strm.avail_out===0)?b:K}(I,U):I.strategy===3?function(M,Q){for(var re,ee,se,ve,he=M.window;;){if(M.lookahead<=R){if(me(M),M.lookahead<=R&&Q===d)return b;if(M.lookahead===0)break}if(M.match_length=0,M.lookahead>=D&&0M.lookahead&&(M.match_length=M.lookahead)}if(M.match_length>=D?(re=a._tr_tally(M,1,M.match_length-D),M.lookahead-=M.match_length,M.strstart+=M.match_length,M.match_length=0):(re=a._tr_tally(M,0,M.window[M.strstart]),M.lookahead--,M.strstart++),re&&(B(M,!1),M.strm.avail_out===0))return b}return M.insert=0,Q===p?(B(M,!0),M.strm.avail_out===0?$:A):M.last_lit&&(B(M,!1),M.strm.avail_out===0)?b:K}(I,U):s[I.level].func(I,U);if(Z!==$&&Z!==A||(I.status=666),Z===b||Z===$)return g.avail_out===0&&(I.last_flush=-1),f;if(Z===K&&(U===1?a._tr_align(I):U!==5&&(a._tr_stored_block(I,0,0,!1),U===3&&(ne(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),z(g),g.avail_out===0))return I.last_flush=-1,f}return U!==p?f:I.wrap<=0?1:(I.wrap===2?(te(I,255&g.adler),te(I,g.adler>>8&255),te(I,g.adler>>16&255),te(I,g.adler>>24&255),te(I,255&g.total_in),te(I,g.total_in>>8&255),te(I,g.total_in>>16&255),te(I,g.total_in>>24&255)):(X(I,g.adler>>>16),X(I,65535&g.adler)),z(g),0=W.w_size&&(F===0&&(ne(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),V=g.avail_in,Z=g.next_in,M=g.input,g.avail_in=re,g.next_in=0,g.input=U,me(W);W.lookahead>=D;){for(I=W.strstart,S=W.lookahead-(D-1);W.ins_h=(W.ins_h<>>=D=N>>>24,_-=D,(D=N>>>16&255)===0)K[c++]=65535&N;else{if(!(16&D)){if(!(64&D)){N=x[(65535&N)+(v&(1<>>=D,_-=D),_<15&&(v+=b[l++]<<_,_+=8,v+=b[l++]<<_,_+=8),N=k[v&E];n:for(;;){if(v>>>=D=N>>>24,_-=D,!(16&(D=N>>>16&255))){if(!(64&D)){N=k[(65535&N)+(v&(1<>>=D,_-=D,(D=c-d)>3,v&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function v(){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 _(P){var T;return P&&P.state?(T=P.state,P.total_in=P.total_out=T.total=0,P.msg="",T.wrap&&(P.adler=1&T.wrap),T.mode=w,T.last=0,T.havedict=0,T.dmax=32768,T.head=null,T.hold=0,T.bits=0,T.lencode=T.lendyn=new s.Buf32(h),T.distcode=T.distdyn=new s.Buf32(y),T.sane=1,T.back=-1,p):f}function x(P){var T;return P&&P.state?((T=P.state).wsize=0,T.whave=0,T.wnext=0,_(P)):f}function k(P,T){var b,K;return P&&P.state?(K=P.state,T<0?(b=0,T=-T):(b=1+(T>>4),T<48&&(T&=15)),T&&(T<8||15=A.wsize?(s.arraySet(A.window,T,b-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(K<($=A.wsize-A.wnext)&&($=K),s.arraySet(A.window,T,b-K,$,A.wnext),(K-=$)?(s.arraySet(A.window,T,b-K,K,0),A.wnext=K,A.whave=A.wsize):(A.wnext+=$,A.wnext===A.wsize&&(A.wnext=0),A.whave>>8&255,b.check=a(b.check,F,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){P.msg="incorrect header check",b.mode=30;break}if((15&z)!=8){P.msg="unknown compression method",b.mode=30;break}if(B-=4,g=8+(15&(z>>>=4)),b.wbits===0)b.wbits=g;else if(g>b.wbits){P.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(F[0]=255&z,F[1]=z>>>8&255,b.check=a(b.check,F,2,0)),B=z=0,b.mode=3;case 3:for(;B<32;){if(L===0)break e;L--,z+=K[A++]<>>8&255,F[2]=z>>>16&255,F[3]=z>>>24&255,b.check=a(b.check,F,4,0)),B=z=0,b.mode=4;case 4:for(;B<16;){if(L===0)break e;L--,z+=K[A++]<>8),512&b.flags&&(F[0]=255&z,F[1]=z>>>8&255,b.check=a(b.check,F,2,0)),B=z=0,b.mode=5;case 5:if(1024&b.flags){for(;B<16;){if(L===0)break e;L--,z+=K[A++]<>>8&255,b.check=a(b.check,F,2,0)),B=z=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(L<(Y=b.length)&&(Y=L),Y&&(b.head&&(g=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,K,A,Y,g)),512&b.flags&&(b.check=a(b.check,K,Y,A)),L-=Y,A+=Y,b.length-=Y),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(L===0)break e;for(Y=0;g=K[A+Y++],b.head&&g&&b.length<65536&&(b.head.name+=String.fromCharCode(g)),g&&Y>9&1,b.head.done=!0),P.adler=b.check=0,b.mode=12;break;case 10:for(;B<32;){if(L===0)break e;L--,z+=K[A++]<>>=7&B,B-=7&B,b.mode=27;break}for(;B<3;){if(L===0)break e;L--,z+=K[A++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,T!==6)break;z>>>=2,B-=2;break e;case 2:b.mode=17;break;case 3:P.msg="invalid block type",b.mode=30}z>>>=2,B-=2;break;case 14:for(z>>>=7&B,B-=7&B;B<32;){if(L===0)break e;L--,z+=K[A++]<>>16^65535)){P.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&z,B=z=0,b.mode=15,T===6)break e;case 15:b.mode=16;case 16:if(Y=b.length){if(L>>=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[V[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){P.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,be=65535&S,!((ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>>=ie,B-=ie,b.lens[b.have++]=be;else{if(be===16){for(I=ie+2;B>>=ie,B-=ie,b.have===0){P.msg="invalid bit length repeat",b.mode=30;break}g=b.lens[b.have-1],Y=3+(3&z),z>>>=2,B-=2}else if(be===17){for(I=ie+3;B>>=ie)),z>>>=3,B-=3}else{for(I=ie+7;B>>=ie)),z>>>=7,B-=7}if(b.have+Y>b.nlen+b.ndist){P.msg="invalid bit length repeat",b.mode=30;break}for(;Y--;)b.lens[b.have++]=g}}if(b.mode===30)break;if(b.lens[256]===0){P.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){P.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){P.msg="invalid distances set",b.mode=30;break}if(b.mode=20,T===6)break e;case 20:b.mode=21;case 21:if(6<=L&&258<=ne){P.next_out=G,P.avail_out=ne,P.next_in=A,P.avail_in=L,b.hold=z,b.bits=B,l(P,X),G=P.next_out,$=P.output,ne=P.avail_out,A=P.next_in,K=P.input,L=P.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,be=65535&S,!((ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>ye)])>>>16&255,be=65535&S,!(ye+(ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>>=ye,B-=ye,b.back+=ye}if(z>>>=ie,B-=ie,b.back+=ie,b.length=be,ue===0){b.mode=26;break}if(32&ue){b.back=-1,b.mode=12;break}if(64&ue){P.msg="invalid literal/length code",b.mode=30;break}b.extra=15&ue,b.mode=22;case 22:if(b.extra){for(I=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,be=65535&S,!((ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>ye)])>>>16&255,be=65535&S,!(ye+(ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>>=ye,B-=ye,b.back+=ye}if(z>>>=ie,B-=ie,b.back+=ie,64&ue){P.msg="invalid distance code",b.mode=30;break}b.offset=be,b.extra=15&ue,b.mode=24;case 24:if(b.extra){for(I=b.extra;B>>=b.extra,B-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){P.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(ne===0)break e;if(Y=X-ne,b.offset>Y){if((Y=b.offset-Y)>b.whave&&b.sane){P.msg="invalid distance too far back",b.mode=30;break}me=Y>b.wnext?(Y-=b.wnext,b.wsize-Y):b.wnext-Y,Y>b.length&&(Y=b.length),ge=b.window}else ge=$,me=G-b.offset,Y=b.length;for(neE?(D=me[ge+y[T]],B[te+y[T]]):(D=96,0),v=1<>G)+(_-=v)]=N<<24|D<<16|R|0,_!==0;);for(v=1<>=1;if(v!==0?(z&=v-1,z+=v):z=0,T++,--X[P]==0){if(P===K)break;P=d[p+y[T]]}if($>>7)]}function te(S,F){S.pending_buf[S.pending++]=255&F,S.pending_buf[S.pending++]=F>>>8&255}function X(S,F,V){S.bi_valid>m-V?(S.bi_buf|=F<>m-S.bi_valid,S.bi_valid+=V-m):(S.bi_buf|=F<>>=1,V<<=1,0<--F;);return V>>>1}function ge(S,F,V){var Z,M,Q=new Array(y+1),re=0;for(Z=1;Z<=y;Z++)Q[Z]=re=re+V[Z-1]<<1;for(M=0;M<=F;M++){var ee=S[2*M+1];ee!==0&&(S[2*M]=me(Q[ee]++,ee))}}function ie(S){var F;for(F=0;F>1;1<=V;V--)ye(S,Q,V);for(M=se;V=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ye(S,Q,1),Z=S.heap[1],S.heap[--S.heap_max]=V,S.heap[--S.heap_max]=Z,Q[2*M]=Q[2*V]+Q[2*Z],S.depth[M]=(S.depth[V]>=S.depth[Z]?S.depth[V]:S.depth[Z])+1,Q[2*V+1]=Q[2*Z+1]=M,S.heap[1]=M++,ye(S,Q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(he,Ye){var wn,st,bn,je,Yn,oo,ft=Ye.dyn_tree,Ws=Ye.max_code,dl=Ye.stat_desc.static_tree,fl=Ye.stat_desc.has_stree,hl=Ye.stat_desc.extra_bits,Us=Ye.stat_desc.extra_base,_n=Ye.stat_desc.max_length,Jn=0;for(je=0;je<=y;je++)he.bl_count[je]=0;for(ft[2*he.heap[he.heap_max]+1]=0,wn=he.heap_max+1;wn>=7;M>>=1)if(1&ve&&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)<=M&&(M=Q)):M=Q=V+5,V+4<=M&&F!==-1?I(S,F,V,Z):S.strategy===4||Q===M?(X(S,2+(Z?1:0),3),pe(S,q,P)):(X(S,4+(Z?1:0),3),function(ee,se,ve,he){var Ye;for(X(ee,se-257,5),X(ee,ve-1,5),X(ee,he-4,4),Ye=0;Ye>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&F,S.pending_buf[S.l_buf+S.last_lit]=255&V,S.last_lit++,F===0?S.dyn_ltree[2*V]++:(S.matches++,F--,S.dyn_ltree[2*(b[V]+d+1)]++,S.dyn_dtree[2*B(F)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){X(S,2,3),Y(S,_,q),function(F){F.bi_valid===16?(te(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.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,f={},w=!1,h=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){v(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,k=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=k,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){v(x.data)},function(x){c.port2.postMessage(x)}):h&&"onreadystatechange"in h.createElement("script")?(u=h.documentElement,function(x){var k=h.createElement("script");k.onreadystatechange=function(){v(x),k.onreadystatechange=null,u.removeChild(k),k=null},u.appendChild(k)}):function(x){setTimeout(v,0,x)},y.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var k=new Array(arguments.length-1),O=0;O"u"?s===void 0?this:s:self)}).call(this,typeof Xn<"u"?Xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ul);var tp=ul.exports;const np=xa(tp);async function rp(t){let e="",n=t;for(;n!=null;){const r=await(qe==null?void 0:qe.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function Rp(t){if(await(J==null?void 0:J.getSetting("twoWaySync")))return await St.genFilesCountInFolder(t)??0;const n=await(H==null?void 0:H.listAll())??[],r=await(qe==null?void 0:qe.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}const op=async t=>{const e=`ComfyUI workspace workflows ${Yf(Date.now())}`,n=new np,r=await(J==null?void 0:J.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await rp(o.parentFolderID??null).then(async a=>At(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 sp({myWorkflowsDir:t}){return C.jsxs(It,{gap:3,children:[C.jsx(fs,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),C.jsx("p",{children:"Your workflows will be synced to and from path:"}),C.jsx("p",{children:C.jsx("b",{children:t})}),C.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"]}),C.jsxs("p",{children:[C.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."]}),C.jsx(Le,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(H==null?void 0:H.listAll());op(e??[])},children:"👉 Download All My Workflows"})]})}const ap=Pa.lazy(()=>Ft(()=>import("./RecentFilesDrawer-GvndxTNj.js"),__vite__mapDeps([15,1,9,2,14,16,13,5]))),ip=Pa.lazy(()=>Ft(()=>import("./GalleryModal-bkUIdDKq.js"),__vite__mapDeps([17,1,16,13,2,10,9,4])));function lp(){const[t,e]=j.useState(null),[n,r]=j.useState("root"),[o,s]=j.useState(!0),[i,a]=j.useState(null),l=j.useRef(null),[u,c]=j.useState(null),[d,p]=j.useState(!1),f=j.useRef(null),{showDialog:w}=Da(),[h,y]=j.useState(!1);j.useRef(!1);const m=Aa(),[v,_]=ep(null),x=j.useCallback(async($=!1)=>{var G;const A=H==null?void 0:H.curWorkflow;if(A){if(!$&&((G=H==null?void 0:H.curWorkflow)!=null&&G.saveLock)){m({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const L=JSON.stringify(Pe.graph.serialize());await Promise.all([H==null?void 0:H.updateFlow(A.id,{json:L}),Ve==null?void 0:Ve.create({workflowID:A.id,json:L,isAutoSave:!1})]),p(!1)}},[]),k=async()=>{var A,G;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 L=(A=H==null?void 0:H.curWorkflow)==null?void 0:A.id;if(L==null)return;const ne=(G=await(H==null?void 0:H.get(L)))==null?void 0:G.json;ne?(H==null||H.updateCurWorkflow({...H.curWorkflow,json:ne}),await Pe.loadGraphData(JSON.parse(ne)),p(!1)):alert("Error: No last saved version found")}},O=$=>{const A=($==null?void 0:$.id)??null;if(H==null||H.updateCurWorkflow($),l.current=A,a(A),e(($==null?void 0:$.name)??""),A==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(ga()){const G=nl(A);window.location.hash=G,document.title=$.name+" - ComfyUI"}else localStorage.setItem("curFlowID",A),document.title="ComfyUI - "+$.name;$&&(H==null||H.updateLastOpenedTime($.id))},E=async()=>{localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await ah()}catch(L){console.error("error loading db",L)}s(!1);const $=ga();if($!=null&&N($),ke("/workspace/deduplicate_workflow_ids"),ke("/workspace/get_os").then(L=>L.json()).then(L=>{L.os&&(zs.os=L.os)}),!await(J==null?void 0:J.getSetting("twoWaySync"))){if(await ce.workflows.count()==0){await(J==null?void 0:J.upsert({twoWaySync:!0})),await ce.cache.put({id:wa,value:"true"});return}const ne=await(J==null?void 0:J.getSetting("myWorkflowsDir"));w(C.jsx(sp,{myWorkflowsDir:ne??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(J==null?void 0:J.upsert({twoWaySync:!0})),await(J==null?void 0:J.getSetting("twoWaySync"))&&(ce.cache.put({id:wa,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}const G=localStorage.getItem("workspace_manager_shareKey");if(G){const L=Ah(G);L&&c({shareKey:L,username:null})}},N=async($,A)=>{if(Pe.graph==null)return;const G=await(H==null?void 0:H.get($));if(G==null){alert("Error: Workflow not found! id: "+$),O(null);return}const L=A?await(De==null?void 0:De.get(A)):null;Pe.ui.dialog.close(),L?(_(L),O({...G,json:L.json}),Pe.loadGraphData(JSON.parse(L.json))):(O(G),_(null),Pe.loadGraphData(JSON.parse(G.json))),r("root"),d&&p(!1)},D=async($,A,G=!1)=>{var L;if($===null){O(null),Pe.graph.clear();return}if(!d||G||(H==null?void 0:H.curWorkflow)==null||(L=J==null?void 0:J.settings)!=null&&L.disableUnsavedWarning){N($,A);return}R($)},R=async $=>{var G;const A=[$?{label:"Open in new tab",icon:C.jsx(gh,{}),onClick:()=>{Qf($)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await x(),$&&N($)}}];A.push({label:"Discard",colorScheme:"red",onClick:async()=>{$&&N($)}}),w(`Please save or discard your changes to "${(G=H==null?void 0:H.curWorkflow)==null?void 0:G.name}" before leaving, or your changes will be lost.`,A)},q=async $=>{const A=($==null?void 0:$.json)??JSON.stringify(rl),G=await(H==null?void 0:H.createFlow({json:A,name:$==null?void 0:$.name}));G&&await D(G.id),r("root")},P=async($,A=!1)=>{const G=$.split("/").pop()??$;A?x():q({name:G});const L=await fetch(Xf($)),ne=await L.blob(),z=new File([ne],G,{type:L.headers.get("Content-Type")||""});await Pe.handleFile(z),r("root")},T=async($,A)=>{const G=await(H==null?void 0:H.get($));if(G==null)return;const L=await(H==null?void 0:H.createFlow({json:G.json,name:A||G.name,parentFolderID:G.parentFolderID}));L&&await D(L.id)},b=j.useCallback($=>{if(l.current==null)return;let A=$.filename;$.subfolder!=null&&$.subfolder!==""&&(A=$.subfolder+"/"+A),Ht==null||Ht.create({workflowID:l.current,localPath:A})},[]),K=j.useCallback(()=>{r("root")},[]);return j.useEffect(()=>{E(),y(!0);const $=A=>{var G,L,ne,z,B,te;(ne=(L=(G=A.detail)==null?void 0:G.output)==null?void 0:L.images)==null||ne.forEach(X=>{X.type==="output"&&b(X)}),(te=(B=(z=A.detail)==null?void 0:z.output)==null?void 0:B.gifs)==null||te.forEach(X=>{X.type==="output"&&b(X)})};return Ir.addEventListener("executed",$),()=>{window.removeEventListener("executed",$)}},[]),o?null:C.jsx(ot.Provider,{value:{curFlowID:i,onDuplicateWorkflow:T,loadWorkflowID:D,discardUnsavedChanges:k,saveCurWorkflow:x,isDirty:d,setIsDirty:p,loadNewWorkflow:q,loadFilePath:P,setRoute:r,route:n,curVersion:v,setCurVersion:_,setCurFlowIDAndName:O,session:u,updateSession:c},children:C.jsx("div",{ref:f,className:"workspace_manager",children:C.jsxs(Ca,{containerRef:f,children:[C.jsxs(Ot,{style:{position:"absolute",top:0,right:0,left:0},zIndex:eh,draggable:!1,children:[C.jsx(Yh,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&C.jsx(j.Suspense,{children:C.jsx(ap,{onClose:K,onClickNewFlow:()=>{q(),r("root")}})}),n==="gallery"&&C.jsx(j.Suspense,{children:C.jsx(ip,{onclose:()=>r("root")})})]}),C.jsx(Jh,{})]})})})}const Tp=Object.freeze(Object.defineProperty({__proto__:null,default:lp},Symbol.toStringTag,{value:"Module"}));export{il as $,_r as A,Ot as B,_p as C,Dh as D,qf as E,on as F,wh as G,Lt as H,yn as I,qe as J,Gr as K,Yr as L,ci as M,Zr as N,Ch as O,rl as P,Rp as Q,jp as R,hd as S,mt as T,gr as U,Sp as V,ot as W,sh as X,bp as Y,gh as Z,Qf as _,hp as a,ke as a0,Ht as a1,Yf as a2,lt as a3,Pe as a4,Gl as a5,eh as a6,mp as a7,wr as a8,xp as a9,rh as aA,Ip as aB,Ms as aC,ds as aD,Np as aE,Ap as aF,Rh as aG,Th as aH,Fp as aI,Tp as aJ,Ra as aa,nc as ab,Ep as ac,fs as ad,rn as ae,rc as af,Te as ag,Cp as ah,kp as ai,Rl as aj,qn as ak,Cs as al,ce as am,yp as an,Dp as ao,Pp as ap,vp as aq,Ir as ar,gp as as,xc as at,di as au,ui as av,mi as aw,hi as ax,Op as ay,ep as az,dp as b,fp as c,Re as d,Aa as e,It as f,Vt as g,J as h,sp as i,Zd as j,to as k,Nn as l,kc as m,pp as n,wp as o,ko as p,ks as q,Es as r,Nh as s,xt as t,Xr as u,vh as v,H as w,Oh as x,op as y,yh as z}; +\0`,X+=s(z,2),X+=O.magic,X+=s(_,2),X+=s(x,2),X+=s(ne.crc32,4),X+=s(ne.compressedSize,4),X+=s(ne.uncompressedSize,4),X+=s(N.length,2),X+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+X+N+K,dirRecord:d.CENTRAL_FILE_HEADER+s(te,2)+X+s(q.length,2)+"\0\0\0\0"+s(B,4)+s(y,4)+N+K+q}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),c=n("../crc32"),d=n("../signature");function p(f,w,h,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=w,this.zipPlatform=h,this.encodeFileName=y,this.streamFiles=f,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(f){var w=f.meta.percent||0,h=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,l.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:h?(w+100*(h-y-1))/h:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var w=this.streamFiles&&!f.file.dir;if(w){var h=i(f,w,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var w=this.streamFiles&&!f.file.dir,h=i(f,w,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),w)this.push({data:function(y){return d.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)}(f),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,w=0;w=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(w,h){return new c.Promise(function(y,m){var v=[],_=w._internalType,x=w._outputType,k=w._mimeType;w.on("data",function(O,E){v.push(O),h&&h(E)}).on("error",function(O){v=[],m(O)}).on("end",function(){try{var O=function(E,N,D){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),D);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(x,function(E,N){var D,R=0,q=null,P=0;for(D=0;D"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(f){return i.nodebuffer?a.newBufferFrom(f,"utf-8"):function(w){var h,y,m,v,_,x=w.length,k=0;for(v=0;v>>6:(y<65536?h[_++]=224|y>>>12:(h[_++]=240|y>>>18,h[_++]=128|y>>>12&63),h[_++]=128|y>>>6&63),h[_++]=128|63&y);return h}(f)},o.utf8decode=function(f){return i.nodebuffer?s.transformTo("nodebuffer",f).toString("utf-8"):function(w){var h,y,m,v,_=w.length,x=new Array(2*_);for(h=y=0;h<_;)if((m=w[h++])<128)x[y++]=m;else if(4<(v=u[m]))x[y++]=65533,h+=v-1;else{for(m&=v===2?31:v===3?15:7;1>10&1023,x[y++]=56320|1023&m)}return x.length!==y&&(x.subarray?x=x.subarray(0,y):x.length=y),s.applyFromCharCode(x)}(f=s.transformTo(i.uint8array?"uint8array":"array",f))},s.inherits(d,l),d.prototype.processChunk=function(f){var w=s.transformTo(i.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var h=w;(w=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),w.set(h,this.leftOver.length)}else w=this.leftOver.concat(w);this.leftOver=null}var y=function(v,_){var x;for((_=_||v.length)>v.length&&(_=v.length),x=_-1;0<=x&&(192&v[x])==128;)x--;return x<0||x===0?_:x+u[v[x]]>_?x:_}(w),m=w;y!==w.length&&(i.uint8array?(m=w.subarray(0,y),this.leftOver=w.subarray(y,w.length)):(m=w.slice(0,y),this.leftOver=w.slice(y,w.length))),this.push({data:o.utf8decode(m),meta:f.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(f){this.push({data:o.utf8encode(f.data),meta:f.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(h){return h}function c(h,y){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var w,h,y,m=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4>>6:(f<65536?p[y++]=224|f>>>12:(p[y++]=240|f>>>18,p[y++]=128|f>>>12&63),p[y++]=128|f>>>6&63),p[y++]=128|63&f);return p},o.buf2binstring=function(d){return c(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),f=0,w=p.length;f>10&1023,v[w++]=56320|1023&h)}return c(v,w)},o.utf8border=function(d,p){var f;for((p=p||d.length)>d.length&&(p=d.length),f=p-1;0<=f&&(192&d[f])==128;)f--;return f<0||f===0?p:f+l[d[f]]>p?f: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,f=0,w=-2,h=-1,y=4,m=2,v=8,_=9,x=286,k=30,O=19,E=2*x+1,N=15,D=3,R=258,q=R+D+1,P=42,T=113,b=1,K=2,$=3,A=4;function G(g,U){return g.msg=c[U],U}function L(g){return(g<<1)-(4g.avail_out&&(W=g.avail_out),W!==0&&(i.arraySet(g.output,U.pending_buf,U.pending_out,W,g.next_out),g.next_out+=W,U.pending_out+=W,g.total_out+=W,g.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function B(g,U){a._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,U),g.block_start=g.strstart,z(g.strm)}function te(g,U){g.pending_buf[g.pending++]=U}function X(g,U){g.pending_buf[g.pending++]=U>>>8&255,g.pending_buf[g.pending++]=255&U}function Y(g,U){var W,I,S=g.max_chain_length,F=g.strstart,V=g.prev_length,Z=g.nice_match,M=g.strstart>g.w_size-q?g.strstart-(g.w_size-q):0,Q=g.window,re=g.w_mask,ee=g.prev,se=g.strstart+R,ve=Q[F+V-1],he=Q[F+V];g.prev_length>=g.good_match&&(S>>=2),Z>g.lookahead&&(Z=g.lookahead);do if(Q[(W=U)+V]===he&&Q[W+V-1]===ve&&Q[W]===Q[F]&&Q[++W]===Q[F+1]){F+=2,W++;do;while(Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&FM&&--S!=0);return V<=g.lookahead?V:g.lookahead}function me(g){var U,W,I,S,F,V,Z,M,Q,re,ee=g.w_size;do{if(S=g.window_size-g.lookahead-g.strstart,g.strstart>=ee+(ee-q)){for(i.arraySet(g.window,g.window,ee,ee,0),g.match_start-=ee,g.strstart-=ee,g.block_start-=ee,U=W=g.hash_size;I=g.head[--U],g.head[U]=ee<=I?I-ee:0,--W;);for(U=W=ee;I=g.prev[--U],g.prev[U]=ee<=I?I-ee:0,--W;);S+=ee}if(g.strm.avail_in===0)break;if(V=g.strm,Z=g.window,M=g.strstart+g.lookahead,Q=S,re=void 0,re=V.avail_in,Q=D)for(F=g.strstart-g.insert,g.ins_h=g.window[F],g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D)if(I=a._tr_tally(g,g.strstart-g.match_start,g.match_length-D),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=D){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D&&g.match_length<=g.prev_length){for(S=g.strstart+g.lookahead-D,I=a._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-D),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=S&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(W=g.pending_buf_size-5);;){if(g.lookahead<=1){if(me(g),g.lookahead===0&&U===d)return b;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var I=g.block_start+W;if((g.strstart===0||g.strstart>=I)&&(g.lookahead=g.strstart-I,g.strstart=I,B(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-q&&(B(g,!1),g.strm.avail_out===0))return b}return g.insert=0,U===p?(B(g,!0),g.strm.avail_out===0?$:A):(g.strstart>g.block_start&&(B(g,!1),g.strm.avail_out),b)}),new ue(4,4,8,4,ge),new ue(4,5,16,8,ge),new ue(4,6,32,32,ge),new ue(4,4,16,16,ie),new ue(8,16,32,32,ie),new ue(8,16,128,128,ie),new ue(8,32,128,256,ie),new ue(32,128,258,1024,ie),new ue(32,258,258,4096,ie)],o.deflateInit=function(g,U){return xe(g,U,v,15,8,0)},o.deflateInit2=xe,o.deflateReset=pe,o.deflateResetKeep=ye,o.deflateSetHeader=function(g,U){return g&&g.state?g.state.wrap!==2?w:(g.state.gzhead=U,f):w},o.deflate=function(g,U){var W,I,S,F;if(!g||!g.state||5>8&255),te(I,I.gzhead.time>>16&255),te(I,I.gzhead.time>>24&255),te(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),te(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(te(I,255&I.gzhead.extra.length),te(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(g.adler=u(g.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(te(I,0),te(I,0),te(I,0),te(I,0),te(I,0),te(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),te(I,3),I.status=T);else{var V=v+(I.w_bits-8<<4)<<8;V|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(V|=32),V+=31-V%31,I.status=T,X(I,V),I.strstart!==0&&(X(I,g.adler>>>16),X(I,65535&g.adler)),g.adler=1}if(I.status===69)if(I.gzhead.extra){for(S=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),z(g),S=I.pending,I.pending!==I.pending_buf_size));)te(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){S=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),z(g),S=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexS&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),F===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){S=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>S&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),z(g),S=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexS&&(g.adler=u(g.adler,I.pending_buf,I.pending-S,S)),F===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&z(g),I.pending+2<=I.pending_buf_size&&(te(I,255&g.adler),te(I,g.adler>>8&255),g.adler=0,I.status=T)):I.status=T),I.pending!==0){if(z(g),g.avail_out===0)return I.last_flush=-1,f}else if(g.avail_in===0&&L(U)<=L(W)&&U!==p)return G(g,-5);if(I.status===666&&g.avail_in!==0)return G(g,-5);if(g.avail_in!==0||I.lookahead!==0||U!==d&&I.status!==666){var Z=I.strategy===2?function(M,Q){for(var re;;){if(M.lookahead===0&&(me(M),M.lookahead===0)){if(Q===d)return b;break}if(M.match_length=0,re=a._tr_tally(M,0,M.window[M.strstart]),M.lookahead--,M.strstart++,re&&(B(M,!1),M.strm.avail_out===0))return b}return M.insert=0,Q===p?(B(M,!0),M.strm.avail_out===0?$:A):M.last_lit&&(B(M,!1),M.strm.avail_out===0)?b:K}(I,U):I.strategy===3?function(M,Q){for(var re,ee,se,ve,he=M.window;;){if(M.lookahead<=R){if(me(M),M.lookahead<=R&&Q===d)return b;if(M.lookahead===0)break}if(M.match_length=0,M.lookahead>=D&&0M.lookahead&&(M.match_length=M.lookahead)}if(M.match_length>=D?(re=a._tr_tally(M,1,M.match_length-D),M.lookahead-=M.match_length,M.strstart+=M.match_length,M.match_length=0):(re=a._tr_tally(M,0,M.window[M.strstart]),M.lookahead--,M.strstart++),re&&(B(M,!1),M.strm.avail_out===0))return b}return M.insert=0,Q===p?(B(M,!0),M.strm.avail_out===0?$:A):M.last_lit&&(B(M,!1),M.strm.avail_out===0)?b:K}(I,U):s[I.level].func(I,U);if(Z!==$&&Z!==A||(I.status=666),Z===b||Z===$)return g.avail_out===0&&(I.last_flush=-1),f;if(Z===K&&(U===1?a._tr_align(I):U!==5&&(a._tr_stored_block(I,0,0,!1),U===3&&(ne(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),z(g),g.avail_out===0))return I.last_flush=-1,f}return U!==p?f:I.wrap<=0?1:(I.wrap===2?(te(I,255&g.adler),te(I,g.adler>>8&255),te(I,g.adler>>16&255),te(I,g.adler>>24&255),te(I,255&g.total_in),te(I,g.total_in>>8&255),te(I,g.total_in>>16&255),te(I,g.total_in>>24&255)):(X(I,g.adler>>>16),X(I,65535&g.adler)),z(g),0=W.w_size&&(F===0&&(ne(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),V=g.avail_in,Z=g.next_in,M=g.input,g.avail_in=re,g.next_in=0,g.input=U,me(W);W.lookahead>=D;){for(I=W.strstart,S=W.lookahead-(D-1);W.ins_h=(W.ins_h<>>=D=N>>>24,_-=D,(D=N>>>16&255)===0)K[c++]=65535&N;else{if(!(16&D)){if(!(64&D)){N=x[(65535&N)+(v&(1<>>=D,_-=D),_<15&&(v+=b[l++]<<_,_+=8,v+=b[l++]<<_,_+=8),N=k[v&E];n:for(;;){if(v>>>=D=N>>>24,_-=D,!(16&(D=N>>>16&255))){if(!(64&D)){N=k[(65535&N)+(v&(1<>>=D,_-=D,(D=c-d)>3,v&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function v(){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 _(P){var T;return P&&P.state?(T=P.state,P.total_in=P.total_out=T.total=0,P.msg="",T.wrap&&(P.adler=1&T.wrap),T.mode=w,T.last=0,T.havedict=0,T.dmax=32768,T.head=null,T.hold=0,T.bits=0,T.lencode=T.lendyn=new s.Buf32(h),T.distcode=T.distdyn=new s.Buf32(y),T.sane=1,T.back=-1,p):f}function x(P){var T;return P&&P.state?((T=P.state).wsize=0,T.whave=0,T.wnext=0,_(P)):f}function k(P,T){var b,K;return P&&P.state?(K=P.state,T<0?(b=0,T=-T):(b=1+(T>>4),T<48&&(T&=15)),T&&(T<8||15=A.wsize?(s.arraySet(A.window,T,b-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(K<($=A.wsize-A.wnext)&&($=K),s.arraySet(A.window,T,b-K,$,A.wnext),(K-=$)?(s.arraySet(A.window,T,b-K,K,0),A.wnext=K,A.whave=A.wsize):(A.wnext+=$,A.wnext===A.wsize&&(A.wnext=0),A.whave>>8&255,b.check=a(b.check,F,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){P.msg="incorrect header check",b.mode=30;break}if((15&z)!=8){P.msg="unknown compression method",b.mode=30;break}if(B-=4,g=8+(15&(z>>>=4)),b.wbits===0)b.wbits=g;else if(g>b.wbits){P.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(F[0]=255&z,F[1]=z>>>8&255,b.check=a(b.check,F,2,0)),B=z=0,b.mode=3;case 3:for(;B<32;){if(L===0)break e;L--,z+=K[A++]<>>8&255,F[2]=z>>>16&255,F[3]=z>>>24&255,b.check=a(b.check,F,4,0)),B=z=0,b.mode=4;case 4:for(;B<16;){if(L===0)break e;L--,z+=K[A++]<>8),512&b.flags&&(F[0]=255&z,F[1]=z>>>8&255,b.check=a(b.check,F,2,0)),B=z=0,b.mode=5;case 5:if(1024&b.flags){for(;B<16;){if(L===0)break e;L--,z+=K[A++]<>>8&255,b.check=a(b.check,F,2,0)),B=z=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(L<(Y=b.length)&&(Y=L),Y&&(b.head&&(g=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,K,A,Y,g)),512&b.flags&&(b.check=a(b.check,K,Y,A)),L-=Y,A+=Y,b.length-=Y),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(L===0)break e;for(Y=0;g=K[A+Y++],b.head&&g&&b.length<65536&&(b.head.name+=String.fromCharCode(g)),g&&Y>9&1,b.head.done=!0),P.adler=b.check=0,b.mode=12;break;case 10:for(;B<32;){if(L===0)break e;L--,z+=K[A++]<>>=7&B,B-=7&B,b.mode=27;break}for(;B<3;){if(L===0)break e;L--,z+=K[A++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,T!==6)break;z>>>=2,B-=2;break e;case 2:b.mode=17;break;case 3:P.msg="invalid block type",b.mode=30}z>>>=2,B-=2;break;case 14:for(z>>>=7&B,B-=7&B;B<32;){if(L===0)break e;L--,z+=K[A++]<>>16^65535)){P.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&z,B=z=0,b.mode=15,T===6)break e;case 15:b.mode=16;case 16:if(Y=b.length){if(L>>=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[V[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){P.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,be=65535&S,!((ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>>=ie,B-=ie,b.lens[b.have++]=be;else{if(be===16){for(I=ie+2;B>>=ie,B-=ie,b.have===0){P.msg="invalid bit length repeat",b.mode=30;break}g=b.lens[b.have-1],Y=3+(3&z),z>>>=2,B-=2}else if(be===17){for(I=ie+3;B>>=ie)),z>>>=3,B-=3}else{for(I=ie+7;B>>=ie)),z>>>=7,B-=7}if(b.have+Y>b.nlen+b.ndist){P.msg="invalid bit length repeat",b.mode=30;break}for(;Y--;)b.lens[b.have++]=g}}if(b.mode===30)break;if(b.lens[256]===0){P.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){P.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){P.msg="invalid distances set",b.mode=30;break}if(b.mode=20,T===6)break e;case 20:b.mode=21;case 21:if(6<=L&&258<=ne){P.next_out=G,P.avail_out=ne,P.next_in=A,P.avail_in=L,b.hold=z,b.bits=B,l(P,X),G=P.next_out,$=P.output,ne=P.avail_out,A=P.next_in,K=P.input,L=P.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,be=65535&S,!((ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>ye)])>>>16&255,be=65535&S,!(ye+(ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>>=ye,B-=ye,b.back+=ye}if(z>>>=ie,B-=ie,b.back+=ie,b.length=be,ue===0){b.mode=26;break}if(32&ue){b.back=-1,b.mode=12;break}if(64&ue){P.msg="invalid literal/length code",b.mode=30;break}b.extra=15&ue,b.mode=22;case 22:if(b.extra){for(I=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,be=65535&S,!((ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>ye)])>>>16&255,be=65535&S,!(ye+(ie=S>>>24)<=B);){if(L===0)break e;L--,z+=K[A++]<>>=ye,B-=ye,b.back+=ye}if(z>>>=ie,B-=ie,b.back+=ie,64&ue){P.msg="invalid distance code",b.mode=30;break}b.offset=be,b.extra=15&ue,b.mode=24;case 24:if(b.extra){for(I=b.extra;B>>=b.extra,B-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){P.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(ne===0)break e;if(Y=X-ne,b.offset>Y){if((Y=b.offset-Y)>b.whave&&b.sane){P.msg="invalid distance too far back",b.mode=30;break}me=Y>b.wnext?(Y-=b.wnext,b.wsize-Y):b.wnext-Y,Y>b.length&&(Y=b.length),ge=b.window}else ge=$,me=G-b.offset,Y=b.length;for(neE?(D=me[ge+y[T]],B[te+y[T]]):(D=96,0),v=1<>G)+(_-=v)]=N<<24|D<<16|R|0,_!==0;);for(v=1<>=1;if(v!==0?(z&=v-1,z+=v):z=0,T++,--X[P]==0){if(P===K)break;P=d[p+y[T]]}if($>>7)]}function te(S,F){S.pending_buf[S.pending++]=255&F,S.pending_buf[S.pending++]=F>>>8&255}function X(S,F,V){S.bi_valid>m-V?(S.bi_buf|=F<>m-S.bi_valid,S.bi_valid+=V-m):(S.bi_buf|=F<>>=1,V<<=1,0<--F;);return V>>>1}function ge(S,F,V){var Z,M,Q=new Array(y+1),re=0;for(Z=1;Z<=y;Z++)Q[Z]=re=re+V[Z-1]<<1;for(M=0;M<=F;M++){var ee=S[2*M+1];ee!==0&&(S[2*M]=me(Q[ee]++,ee))}}function ie(S){var F;for(F=0;F>1;1<=V;V--)ye(S,Q,V);for(M=se;V=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ye(S,Q,1),Z=S.heap[1],S.heap[--S.heap_max]=V,S.heap[--S.heap_max]=Z,Q[2*M]=Q[2*V]+Q[2*Z],S.depth[M]=(S.depth[V]>=S.depth[Z]?S.depth[V]:S.depth[Z])+1,Q[2*V+1]=Q[2*Z+1]=M,S.heap[1]=M++,ye(S,Q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(he,Ye){var wn,st,bn,je,Yn,oo,ft=Ye.dyn_tree,Us=Ye.max_code,dl=Ye.stat_desc.static_tree,fl=Ye.stat_desc.has_stree,hl=Ye.stat_desc.extra_bits,Ks=Ye.stat_desc.extra_base,_n=Ye.stat_desc.max_length,Jn=0;for(je=0;je<=y;je++)he.bl_count[je]=0;for(ft[2*he.heap[he.heap_max]+1]=0,wn=he.heap_max+1;wn>=7;M>>=1)if(1&ve&&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)<=M&&(M=Q)):M=Q=V+5,V+4<=M&&F!==-1?I(S,F,V,Z):S.strategy===4||Q===M?(X(S,2+(Z?1:0),3),pe(S,q,P)):(X(S,4+(Z?1:0),3),function(ee,se,ve,he){var Ye;for(X(ee,se-257,5),X(ee,ve-1,5),X(ee,he-4,4),Ye=0;Ye>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&F,S.pending_buf[S.l_buf+S.last_lit]=255&V,S.last_lit++,F===0?S.dyn_ltree[2*V]++:(S.matches++,F--,S.dyn_ltree[2*(b[V]+d+1)]++,S.dyn_dtree[2*B(F)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){X(S,2,3),Y(S,_,q),function(F){F.bi_valid===16?(te(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.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,f={},w=!1,h=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){v(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,k=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=k,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){v(x.data)},function(x){c.port2.postMessage(x)}):h&&"onreadystatechange"in h.createElement("script")?(u=h.documentElement,function(x){var k=h.createElement("script");k.onreadystatechange=function(){v(x),k.onreadystatechange=null,u.removeChild(k),k=null},u.appendChild(k)}):function(x){setTimeout(v,0,x)},y.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var k=new Array(arguments.length-1),O=0;O"u"?s===void 0?this:s:self)}).call(this,typeof Xn<"u"?Xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ul);var np=ul.exports;const rp=ka(np);async function op(t){let e="",n=t;for(;n!=null;){const r=await(qe==null?void 0:qe.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function Tp(t){if(await(J==null?void 0:J.getSetting("twoWaySync")))return await St.genFilesCountInFolder(t)??0;const n=await(H==null?void 0:H.listAll())??[],r=await(qe==null?void 0:qe.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}const sp=async t=>{const e=`ComfyUI workspace workflows ${Yf(Date.now())}`,n=new rp,r=await(J==null?void 0:J.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await op(o.parentFolderID??null).then(async a=>At(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 ap({myWorkflowsDir:t}){return C.jsxs(It,{gap:3,children:[C.jsx(hs,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),C.jsx("p",{children:"Your workflows will be synced to and from path:"}),C.jsx("p",{children:C.jsx("b",{children:t})}),C.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"]}),C.jsxs("p",{children:[C.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."]}),C.jsx(Le,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(H==null?void 0:H.listAll());sp(e??[])},children:"👉 Download All My Workflows"})]})}const ip=ja.lazy(()=>Ft(()=>import("./RecentFilesDrawer-efSIwVKr.js"),__vite__mapDeps([15,1,9,2,14,16,13,5]))),lp=ja.lazy(()=>Ft(()=>import("./GalleryModal-DmDbPyXZ.js"),__vite__mapDeps([17,1,16,13,2,10,9,4])));function cp(){const[t,e]=j.useState(null),[n,r]=j.useState("root"),[o,s]=j.useState(!0),[i,a]=j.useState(null),l=j.useRef(null),[u,c]=j.useState(null),[d,p]=j.useState(!1),f=j.useRef(null),{showDialog:w}=Pa(),[h,y]=j.useState(!1);j.useRef(!1);const m=ds(),[v,_]=tp(null),x=j.useCallback(async($=!1)=>{var G;const A=H==null?void 0:H.curWorkflow;if(A){if(!$&&((G=H==null?void 0:H.curWorkflow)!=null&&G.saveLock)){m({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const L=JSON.stringify(Pe.graph.serialize());await Promise.all([H==null?void 0:H.updateFlow(A.id,{json:L}),Ve==null?void 0:Ve.create({workflowID:A.id,json:L,isAutoSave:!1})]),p(!1)}},[]),k=async()=>{var A,G;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 L=(A=H==null?void 0:H.curWorkflow)==null?void 0:A.id;if(L==null)return;const ne=(G=await(H==null?void 0:H.get(L)))==null?void 0:G.json;ne?(H==null||H.updateCurWorkflow({...H.curWorkflow,json:ne}),await Pe.loadGraphData(JSON.parse(ne)),p(!1)):alert("Error: No last saved version found")}},O=$=>{const A=($==null?void 0:$.id)??null;if(H==null||H.updateCurWorkflow($),l.current=A,a(A),e(($==null?void 0:$.name)??""),A==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(wa()){const G=nl(A);window.location.hash=G,document.title=$.name+" - ComfyUI"}else localStorage.setItem("curFlowID",A),document.title="ComfyUI - "+$.name;$&&(H==null||H.updateLastOpenedTime($.id))},E=async()=>{localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await ah()}catch(L){console.error("error loading db",L)}s(!1);const $=wa();if($!=null&&N($),ke("/workspace/deduplicate_workflow_ids"),ke("/workspace/get_os").then(L=>L.json()).then(L=>{L.os&&(Ls.os=L.os)}),!await(J==null?void 0:J.getSetting("twoWaySync"))){if(await ce.workflows.count()==0){await(J==null?void 0:J.upsert({twoWaySync:!0})),await ce.cache.put({id:ba,value:"true"});return}const ne=await(J==null?void 0:J.getSetting("myWorkflowsDir"));w(C.jsx(ap,{myWorkflowsDir:ne??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(J==null?void 0:J.upsert({twoWaySync:!0})),await(J==null?void 0:J.getSetting("twoWaySync"))&&(ce.cache.put({id:ba,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}const G=localStorage.getItem("workspace_manager_shareKey");if(G){const L=Ah(G);L&&c({shareKey:L,username:null})}},N=async($,A)=>{if(Pe.graph==null)return;const G=await(H==null?void 0:H.get($));if(G==null){alert("Error: Workflow not found! id: "+$),O(null);return}const L=A?await(De==null?void 0:De.get(A)):null;Pe.ui.dialog.close(),L?(_(L),O({...G,json:L.json}),Pe.loadGraphData(JSON.parse(L.json))):(O(G),_(null),Pe.loadGraphData(JSON.parse(G.json))),r("root"),d&&p(!1)},D=async($,A,G=!1)=>{var L;if($===null){O(null),Pe.graph.clear();return}if(!d||G||(H==null?void 0:H.curWorkflow)==null||(L=J==null?void 0:J.settings)!=null&&L.disableUnsavedWarning){N($,A);return}R($)},R=async $=>{var G;const A=[$?{label:"Open in new tab",icon:C.jsx(gh,{}),onClick:()=>{Qf($)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await x(),$&&N($)}}];A.push({label:"Discard",colorScheme:"red",onClick:async()=>{$&&N($)}}),w(`Please save or discard your changes to "${(G=H==null?void 0:H.curWorkflow)==null?void 0:G.name}" before leaving, or your changes will be lost.`,A)},q=async $=>{const A=($==null?void 0:$.json)??JSON.stringify(rl),G=await(H==null?void 0:H.createFlow({json:A,name:$==null?void 0:$.name}));G&&await D(G.id),r("root")},P=async($,A=!1)=>{const G=$.split("/").pop()??$;A?x():q({name:G});const L=await fetch(Xf($)),ne=await L.blob(),z=new File([ne],G,{type:L.headers.get("Content-Type")||""});await Pe.handleFile(z),r("root")},T=async($,A)=>{const G=await(H==null?void 0:H.get($));if(G==null)return;const L=await(H==null?void 0:H.createFlow({json:G.json,name:A||G.name,parentFolderID:G.parentFolderID}));L&&await D(L.id)},b=j.useCallback($=>{if(l.current==null)return;let A=$.filename;$.subfolder!=null&&$.subfolder!==""&&(A=$.subfolder+"/"+A),Ht==null||Ht.create({workflowID:l.current,localPath:A})},[]),K=j.useCallback(()=>{r("root")},[]);return j.useEffect(()=>{E(),y(!0);const $=A=>{var G,L,ne,z,B,te;(ne=(L=(G=A.detail)==null?void 0:G.output)==null?void 0:L.images)==null||ne.forEach(X=>{X.type==="output"&&b(X)}),(te=(B=(z=A.detail)==null?void 0:z.output)==null?void 0:B.gifs)==null||te.forEach(X=>{X.type==="output"&&b(X)})};return Ir.addEventListener("executed",$),()=>{window.removeEventListener("executed",$)}},[]),o?null:C.jsx(ot.Provider,{value:{curFlowID:i,onDuplicateWorkflow:T,loadWorkflowID:D,discardUnsavedChanges:k,saveCurWorkflow:x,isDirty:d,setIsDirty:p,loadNewWorkflow:q,loadFilePath:P,setRoute:r,route:n,curVersion:v,setCurVersion:_,setCurFlowIDAndName:O,session:u,updateSession:c},children:C.jsx("div",{ref:f,className:"workspace_manager",children:C.jsxs(Sa,{containerRef:f,children:[C.jsxs(Ot,{style:{position:"absolute",top:0,right:0,left:0},zIndex:eh,draggable:!1,children:[C.jsx(Jh,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&C.jsx(j.Suspense,{children:C.jsx(ip,{onClose:K,onClickNewFlow:()=>{q(),r("root")}})}),n==="gallery"&&C.jsx(j.Suspense,{children:C.jsx(lp,{onclose:()=>r("root")})})]}),C.jsx(Xh,{})]})})})}const Bp=Object.freeze(Object.defineProperty({__proto__:null,default:cp},Symbol.toStringTag,{value:"Module"}));export{il as $,_r as A,Ot as B,xp as C,Dh as D,qf as E,on as F,wh as G,Lt as H,yn as I,qe as J,Gr as K,Yr as L,ci as M,Zr as N,Ch as O,rl as P,Tp as Q,Ap as R,hd as S,mt as T,gr as U,Ip as V,ot as W,sh as X,_p as Y,gh as Z,Qf as _,pp as a,xh as a0,ke as a1,Ht as a2,Yf as a3,lt as a4,Pe as a5,Gl as a6,eh as a7,yp as a8,wr as a9,tp as aA,rh as aB,Op as aC,zs as aD,fs as aE,Bh as aF,Fp as aG,Np as aH,Rh as aI,Th as aJ,Rp as aK,Bp as aL,kp as aa,Ra as ab,nc as ac,Cp as ad,hs as ae,rn as af,rc as ag,Te as ah,Sp as ai,Ep as aj,Rl as ak,qn as al,Ss as am,ce as an,vp as ao,Pp as ap,jp as aq,gp as ar,Ir as as,wp as at,xc as au,di as av,ui as aw,mi as ax,hi as ay,Dp as az,fp as b,hp as c,Re as d,ds as e,It as f,Vt as g,J as h,ap as i,Zd as j,to as k,Nn as l,kc as m,mp as n,bp as o,ko as p,Es as q,Cs as r,Nh as s,xt as t,Xr as u,vh as v,H as w,Oh as x,sp as y,yh as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-g_a6xMAM.js","workspace_web/input.js","workspace_web/chunk-7D6N5TE5-wlKuxWhy.js","workspace_web/civitUtils-T1Lq3reo.js","workspace_web/chunk-VTV6N5LE-qccSGxq6.js","workspace_web/IconCopy-zZpZ6D5h.js","workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-jjabvfOI.js","workspace_web/chunk-JARCRF6W-UTrQeKCZ.js","workspace_web/chunk-3RSXBRAN-oKoElBXY.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-T7ZdSk0R.js","workspace_web/IconSearch-hyGkJAd5.js","workspace_web/chunk-NTCQBYKE-vNLNCBtA.js","workspace_web/RecentFilesDrawer-GvndxTNj.js","workspace_web/MediaPreview-46fgYP_n.js","workspace_web/GalleryModal-bkUIdDKq.js"] + __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-DSSo_bep.js","workspace_web/input.js","workspace_web/chunk-7D6N5TE5-gOmt0HWF.js","workspace_web/civitUtils-TPBejtrP.js","workspace_web/chunk-VTV6N5LE-VcPf7MxV.js","workspace_web/IconCopy-RhFbFhX0.js","workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-d0zTxQle.js","workspace_web/chunk-JARCRF6W-1gGfj837.js","workspace_web/chunk-3RSXBRAN-WBOq6SL0.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-rjI_Y8hu.js","workspace_web/IconSearch-srLS9f0l.js","workspace_web/chunk-NTCQBYKE-ROuYoItA.js","workspace_web/RecentFilesDrawer-efSIwVKr.js","workspace_web/MediaPreview-VRNiVJ5t.js","workspace_web/GalleryModal-DmDbPyXZ.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/dist/workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js b/dist/workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js similarity index 93% rename from dist/workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js rename to dist/workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js index 9e33788..b45ce51 100644 --- a/dist/workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js +++ b/dist/workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js @@ -1 +1 @@ -import{r as l}from"./input.js";import{W as S,a4 as r,ag as w,w as p,E as f,ah as _,ai as C}from"./App-ZTJclgGW.js";import{u as b}from"./useDebounceFn-ld478fd0.js";function R(){const{isDirty:d,setIsDirty:h,setRoute:g,saveCurWorkflow:v,setCurFlowIDAndName:k}=l.useContext(S),E=l.useRef(d);l.useEffect(()=>{E.current=d},[d]),l.useEffect(()=>{const c=e=>{var n;if(document.visibilityState==="hidden")return;const t=C(e);if(t)switch(t===f.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:t}})),t){case f.SAVE:v();break;case f.SAVE_AS:g("saveAsModal");break;case f.openSpotlightSearch:g("spotlightSearch");break}else(n=e.target)!=null&&n.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},u=async()=>{var t,n,a,i;if(!((t=r)!=null&&t.graph)){console.error("🦄 Error in workspace manager! app.graph is not available in restoreCurWorkflow()");return}const e=(a=(n=r.graph.extra)==null?void 0:n[w])==null?void 0:a.id;if(e){const s=await((i=p)==null?void 0:i.get(e));s&&k(s),!(s!=null&&s.saveLock)&&s&&s.json!==JSON.stringify(r.graph.serialize())&&h(!0)}},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,n,a,i;const e=(n=(t=r.graph.extra)==null?void 0:t[w])==null?void 0:n.id;(e==null||e!=((i=(a=p)==null?void 0:a.curWorkflow)==null?void 0:i.id))&&k(null)},500)},document.addEventListener("click",e=>{Object.keys(r.canvas.selected_nodes??{}).length&&(r.canvas.node_over!=null||r.canvas.node_capturing_input!=null||r.canvas.node_widget!=null)&&m()}),document.addEventListener("keydown",c),u(),()=>{document.removeEventListener("keydown",c)}},[]);const y=async()=>{var u,o,e,t;if((o=(u=p)==null?void 0:u.curWorkflow)!=null&&o.saveLock||E.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((t=(e=p)==null?void 0:e.curWorkflow)==null?void 0:t.json)&&h(!0)},[m,D]=b(y,900);return null}export{R as default}; +import{r as l}from"./input.js";import{W as S,a5 as r,ah as w,w as p,E as f,ai as _,aj as C}from"./App-9GIQJeUY.js";import{u as b}from"./useDebounceFn-ld478fd0.js";function R(){const{isDirty:d,setIsDirty:h,setRoute:g,saveCurWorkflow:v,setCurFlowIDAndName:k}=l.useContext(S),E=l.useRef(d);l.useEffect(()=>{E.current=d},[d]),l.useEffect(()=>{const c=e=>{var n;if(document.visibilityState==="hidden")return;const t=C(e);if(t)switch(t===f.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:t}})),t){case f.SAVE:v();break;case f.SAVE_AS:g("saveAsModal");break;case f.openSpotlightSearch:g("spotlightSearch");break}else(n=e.target)!=null&&n.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},u=async()=>{var t,n,a,i;if(!((t=r)!=null&&t.graph)){console.error("🦄 Error in workspace manager! app.graph is not available in restoreCurWorkflow()");return}const e=(a=(n=r.graph.extra)==null?void 0:n[w])==null?void 0:a.id;if(e){const s=await((i=p)==null?void 0:i.get(e));s&&k(s),!(s!=null&&s.saveLock)&&s&&s.json!==JSON.stringify(r.graph.serialize())&&h(!0)}},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,n,a,i;const e=(n=(t=r.graph.extra)==null?void 0:t[w])==null?void 0:n.id;(e==null||e!=((i=(a=p)==null?void 0:a.curWorkflow)==null?void 0:i.id))&&k(null)},500)},document.addEventListener("click",e=>{Object.keys(r.canvas.selected_nodes??{}).length&&(r.canvas.node_over!=null||r.canvas.node_capturing_input!=null||r.canvas.node_widget!=null)&&m()}),document.addEventListener("keydown",c),u(),()=>{document.removeEventListener("keydown",c)}},[]);const y=async()=>{var u,o,e,t;if((o=(u=p)==null?void 0:u.curWorkflow)!=null&&o.saveLock||E.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((t=(e=p)==null?void 0:e.curWorkflow)==null?void 0:t.json)&&h(!0)},[m,D]=b(y,900);return null}export{R as default}; diff --git a/dist/workspace_web/GalleryModal-bkUIdDKq.js b/dist/workspace_web/GalleryModal-DmDbPyXZ.js similarity index 98% rename from dist/workspace_web/GalleryModal-bkUIdDKq.js rename to dist/workspace_web/GalleryModal-DmDbPyXZ.js index adc2f75..70099ad 100644 --- a/dist/workspace_web/GalleryModal-bkUIdDKq.js +++ b/dist/workspace_web/GalleryModal-DmDbPyXZ.js @@ -1 +1 @@ -import{r as d,d as Se,x as Ht,m as be,b as it,f as B,k as Wt,o as ct,E as Kt,j as r,g as O,n as Yt,e as Xt,V as ut,h as dt,M as Zt,T as qt,N as Jt,U as Qt,Q as en,O as tn}from"./input.js";import{aa as nn,ab as sn,d as Re,F as m,ac as rn,l as E,I as on,f as Ee,B as ht,T as K,W as oe,a4 as tt,H as Y,w as W,g as D,v as ft,a2 as xt,O as pt,a1 as R,ad as an,x as ln}from"./App-ZTJclgGW.js";import{c as je,p as cn,r as nt,v as st,I as un,i as dn,b as hn,d as fn,g as xn,N as pn,a as gn,e as mn,f as vn,h as yn,M as gt,u as wn,S as Sn}from"./MediaPreview-46fgYP_n.js";import{I as bn}from"./chunk-7D6N5TE5-wlKuxWhy.js";import{S as jn}from"./chunk-3RSXBRAN-oKoElBXY.js";import{C as Ae,G as kn}from"./chunk-JARCRF6W-UTrQeKCZ.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-qccSGxq6.js";import"./IconSearch-hyGkJAd5.js";const mt=1/60*1e3,Pn=typeof performance<"u"?()=>performance.now():()=>Date.now(),vt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Pn()),mt);function Cn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,g=!1)=>{const f=g&&o,x=f?t:s;return u&&l.add(i),x.indexOf(i)===-1&&(x.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]=Cn(()=>X=!0),e),{}),Tn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||Mn(),s.schedule(n,o,a)),e},{}),En=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(V),e),{});const Nn=e=>ae[e].process(V),yt=e=>{X=!1,V.delta=Me?mt:Math.max(Math.min(e-V.timestamp,In),1),V.timestamp=e,_e=!0,Z.forEach(Nn),_e=!1,X&&(Me=!1,vt(yt))},Mn=()=>{X=!0,Me=!0,_e||vt(yt)},ot=()=>V;var $=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 _n(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var j;const A=(j=n[y])!=null?j:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${A.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${A.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,j)=>ee(y).height>ee(j).height?y:j,te):n.reduce((y,j)=>ee(y).width>ee(j).width?y:j,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,g=[0,o?100-s[0]:s[0]],f=u?g:s;let x=f[0];!u&&o&&(x=100-x);const b=Math.abs(f[f.length-1]-f[0]),N={...i,...Q({orientation:t,vertical:o?{height:`${b}%`,top:`${x}%`}:{height:`${b}%`,bottom:`${x}%`},horizontal:o?{width:`${b}%`,right:`${x}%`}:{width:`${b}%`,left:`${x}%`}})};return{trackStyle:i,innerTrackStyle:N,rootStyle:c,getThumbStyle:a}}function zn(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Dn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Rn(e){const t=Fn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function wt(e){return!!e.touches}function An(e){return wt(e)&&e.touches.length>1}function Fn(e){var t;return(t=e.view)!=null?t:window}function $n(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Vn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function St(e,t="page"){return wt(e)?$n(e,t):Vn(e,t)}function Bn(e){return t=>{const s=Rn(t);(!s||s&&t.button===0)&&e(t)}}function On(e,t=!1){function s(o){e(o,{point:St(o)})}return t?Bn(s):s}function ne(e,t,s,n){return Dn(e,t,On(s,t==="pointerdown"),n)}var Ln=Object.defineProperty,Gn=(e,t,s)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,I=(e,t,s)=>(Gn(e,typeof t!="symbol"?t+"":t,s),s),Un=class{constructor(e,t,s){I(this,"history",[]),I(this,"startEvent",null),I(this,"lastEvent",null),I(this,"lastEventInfo",null),I(this,"handlers",{}),I(this,"removeListeners",()=>{}),I(this,"threshold",3),I(this,"win"),I(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Yn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:g}=ot();this.history.push({...c.point,timestamp:g});const{onStart:f,onMove:x}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,c)}),I(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Tn.update(this.updatePoint,!0)}),I(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:g,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!g||!this.startEvent)&&(g==null||g(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,An(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:St(e)},{timestamp:a}=ot();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Kn(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),En.update(this.updatePoint)}};function at(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:at(e.point,t[t.length-1]),offset:at(e.point,t[0]),velocity:Wn(t,.1)}}var Hn=e=>e*1e3;function Wn(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>Hn(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 Kn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function lt(e){return"x"in e&&"y"in e}function Yn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(lt(e)&<(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function bt(e){const t=d.useRef(null);return t.current=e,t}function Xn(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),g=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,x){u.current=null,o==null||o(f,x)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(g.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function x(b){u.current=new Un(b,g.current,c)}return ne(f,"pointerdown",x)},[e,i,g,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Zn(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 qn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Jn(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 qn(()=>{const l=e(),c=l.map((i,u)=>Zn(i,g=>{n(f=>[...f.slice(0,u),g,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Jn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function es(e){return typeof e=="object"&&e!==null&&"current"in e}function ts(e){const[t]=Qn({observeMutation:!1,getNodes(){return[es(e)?e.current:e]}});return t}function ns(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:g,isDisabled:f,isReadOnly:x,onChangeStart:b,onChangeEnd:N,step:y=1,getAriaValueText:j,"aria-valuetext":A,"aria-label":F,"aria-labelledby":w,name:M,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(b),L=Se(N),Ve=Se(j),C=zn({isReversed:c,direction:i,orientation:u}),[_t,de]=nn({value:a,defaultValue:l??rs(s,n),onChange:o}),[he,Be]=d.useState(!1),[fe,Oe]=d.useState(!1),xe=!(f||x),pe=(n-s)/10,G=y||(n-s)/100,v=je(_t,s,n),zt=n-v+s,Le=st(C?zt:v,s,n),J=u==="vertical",S=bt({min:s,max:n,step:y,isDisabled:f,value:v,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),ge=d.useRef(null),me=d.useRef(null),Ge=d.useRef(null),Dt=d.useId(),Ue=g??Dt,[He,We]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var p,U;if(!ge.current)return;const k=S.current;k.eventSource="pointer";const T=ge.current.getBoundingClientRect(),{clientX:ye,clientY:Lt}=(U=(p=h.touches)==null?void 0:p[0])!=null?U:h,Gt=J?T.bottom-Lt:ye-T.left,Ut=J?T.height:T.width;let we=Gt/Ut;C&&(we=1-we);let H=cn(we,k.min,k.max);return k.step&&(H=parseFloat(nt(H,k.min,k.step))),H=je(H,k.min,k.max),H},[J,C,S]),_=d.useCallback(h=>{const p=S.current;p.isInteractive&&(h=parseFloat(nt(h,p.min,G)),h=je(h,p.min,p.max),de(h))},[G,de,S]),z=d.useMemo(()=>({stepUp(h=G){const p=C?v-h:v+h;_(p)},stepDown(h=G){const p=C?v+h:v-h;_(p)},reset(){_(l||0)},stepTo(h){_(h)}}),[_,C,v,G,l]),Ke=d.useCallback(h=>{const p=S.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(pe),PageDown:()=>z.stepDown(pe),Home:()=>_(p.min),End:()=>_(p.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),p.eventSource="keyboard")},[z,_,pe,S]),Ye=(t=Ve==null?void 0:Ve(v))!=null?t:A,ve=ts(me),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=S.current,p=ve??{width:0,height:0};return _n({isReversed:C,orientation:h.orientation,thumbRects:[p],thumbPercents:[Le]})},[C,ve,Le,S]),Qe=d.useCallback(()=>{S.current.focusThumbOnChange&&setTimeout(()=>{var p;return(p=me.current)==null?void 0:p.focus()})},[S]);Ht(()=>{const h=S.current;Qe(),h.eventSource==="keyboard"&&(L==null||L(h.value))},[v,L]);function et(h){const p=Rt(h);p!=null&&p!==S.current.value&&de(p)}Xn(Ge,{onPanSessionStart(h){const p=S.current;p.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(p.value))},onPanSessionEnd(){const h=S.current;h.isInteractive&&(Be(!1),L==null||L(h.value))},onPan(h){S.current.isInteractive&&et(h)}});const At=d.useCallback((h={},p=null)=>({...h,...Fe,ref:be(p,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":$(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},p=null)=>({...h,ref:be(p,ge),id:We,"data-disabled":$(f),style:{...h.style,...qe}}),[f,We,qe]),$t=d.useCallback((h={},p=null)=>({...h,ref:p,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},p=null)=>({...h,ref:be(p,me),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":$(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":v,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(x),"aria-label":F,"aria-labelledby":F?void 0:w,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,Ke),onFocus:Pe(h.onFocus,()=>Oe(!0)),onBlur:Pe(h.onBlur,()=>Oe(!1))}),[xe,He,he,Ye,s,n,v,u,f,x,F,w,Xe,Ke]),Bt=d.useCallback((h,p=null)=>{const U=!(h.valuen),k=v>=h.value,T=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ss({orientation:u,vertical:{bottom:C?`${100-T}%`:`${T}%`},horizontal:{left:C?`${100-T}%`:`${T}%`}})};return{...h,ref:p,role:"presentation","aria-hidden":!0,"data-disabled":$(f),"data-invalid":$(!U),"data-highlighted":$(k),style:{...h.style,...ye}}},[f,C,n,s,u,v]),Ot=d.useCallback((h={},p=null)=>({...h,ref:p,type:"hidden",value:v,name:M}),[M,v]);return{state:{value:v,isFocused:fe,isDragging:he},actions:z,getRootProps:At,getTrackProps:Ft,getInnerTrackProps:$t,getThumbProps:Vt,getMarkerProps:Bt,getInputProps:Ot}}function ss(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function rs(e,t){return t"}),[as,ie]=it({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),jt=B((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Wt("Slider",n),a=ct(n),{direction:l}=Kt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=ns(a),g=i(),f=c({},t);return r.jsx(os,{value:u,children:r.jsx(as,{value:o,children:r.jsxs(O.div,{...g,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});jt.displayName="Slider";var kt=B((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});kt.displayName="SliderThumb";var Pt=B((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});Pt.displayName="SliderTrack";var Ct=B((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Ct.displayName="SliderFilledTrack";var ls=B((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});ls.displayName="SliderMark";function is(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var cs=["h","minH","height","minHeight"],It=B((e,t)=>{const s=Yt("Textarea",e),{className:n,rows:o,...a}=ct(e),l=sn(a),c=o?is(s,cs):s;return r.jsx(O.textarea,{ref:t,rows:o,...l,className:Xt("chakra-textarea",n),__css:c})});It.displayName="Textarea";var us=Re("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Tt=Re("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"}]]),Et=Re("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 ds=({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(m,{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(bn,{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(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(us,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(un,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null};function hs(e){const t=e.split(".").pop();return fetch(e).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.blob()}).then(async s=>{const n=e.split("/").pop()??"",o=new File([s],n);if(dn(e))return hn(o);if(t==="webp")return fn(o);const a=await xn(o),l=JSON.parse(a==null?void 0:a.prompt),c=JSON.parse(a==null?void 0:a.workflow);return{prompt:l,workflow:c}})}const fs=({inputItem:e})=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(on,{value:e.inputValue,onChange:t=>{}})]}),xs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(pn,{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(gn,{}),r.jsxs(mn,{children:[r.jsx(vn,{}),r.jsx(yn,{})]})]})]}),r.jsx(m,{children:r.jsxs(jt,{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(Pt,{children:r.jsx(Ct,{})}),r.jsx(kt,{})]})})]})},ps=e=>{var s;const{inputItem:t}=e;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(jn,{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}`))})]})},gs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsx(m,{children:t.label??t.inputName}),r.jsx(It,{value:t.inputValue,onChange:s=>{},rows:5})]})};var P=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(P||{});const ms=e=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(m,{children:"No Support"})]}),vs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(Ae,{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(){}}),ys={[P.Input]:fs,[P.InputSlider]:xs,[P.Select]:ps,[P.Textarea]:gs,[P.Checkbox]:vs,NoSupport:ms},ws=LiteGraph.registered_node_types;function Ss(e,t){var o,a,l,c,i;const s=(o=ws[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:P.Textarea}:{type:P.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:P.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:P.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:P.Select}:{type:P.NoSupport}}const ze=({inputItem:e})=>{const t=Ss(e.classType,e.inputName),[s,n]=d.useState(!1),o=ys[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(m,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(E,{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(Tt,{size:14}):r.jsx(Et,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function bs(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(m,{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 js(){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(ks,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(m,{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 ks({title:e,children:t}){return r.jsxs(ht,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(K,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],De=new Set;function Nt(e,t){if(!De.has(e.nodeID))return De.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Nt(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 Ps(e){se=[],De=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))Nt(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 Cs({media:e}){const[t,s]=d.useState([]);d.useContext(oe);const[n,o]=d.useState(),[a,l]=d.useState(!0),[c,i]=d.useState(!0);d.useEffect(()=>{e?hs(`/workspace/view_media?filename=${e.localPath}`).then(x=>{o(x.prompt)}):tt.graphToPrompt(tt.graph).then(x=>{o(x.output)})},[e]),d.useEffect(()=>{if(!n)return;const x=Ps(n);s(x)},[n]);const[u,g]=d.useState([]),f=x=>{if(re(u,{name:x.name,promptKey:x==null?void 0:x.promptKey,classType:(x==null?void 0:x.class_type)??""})){const b=u.filter(N=>N.name!==x.name||N.promptKey!==x.promptKey);g(b)}else{const b=[...u,x];g(b)}};return r.jsx(ce.Provider,{value:{topFields:u,showNodeName:c,calcInputList:t,updateTopField:f},children:r.jsxs(m,{direction:"column",align:"stretch",gap:5,children:[r.jsx(bs,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(rt,{isChecked:a,onChange:x=>l(!a)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:c,onChange:x=>i(!c)})]}),a&&r.jsx(js,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),Is=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ut();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=W)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(m,{flexWrap:"wrap",gap:3,children:[r.jsx(m,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(K,{children:e==null?void 0:e.localPath}),r.jsx(D,{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(E,{size:"sm",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(m,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(K,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{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=R)==null?void 0:u.delete(e.id)),n(g=>g.filter(f=>f.id!==e.id)))}})}),((c=(l=W)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(D,{label:"Set as cover",children:r.jsx(E,{size:"sm",variant:"ghost",icon:t?r.jsx(Tt,{size:19}):r.jsx(Et,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=W)==null?void 0:i.updateMetaInfo(W.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(dt,{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},Ts=({media:e})=>r.jsxs(m,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(Is,{media:e}),r.jsx(Cs,{media:e??null})]}),Te=120;function Es({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(m,{gap:3,h:"100%",children:[r.jsxs(kn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(ds,{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(m,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(ht,{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(gt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=R)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ts,{media:t??void 0})]})}const Ns=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ut();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx(Ae,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(gt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=R)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(D,{label:xt(e.createTime,!0),children:i}),r.jsx(D,{label:e.localPath,children:r.jsx(K,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(dt,{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(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var g;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((g=R)==null?void 0:g.delete(e.id))}})})]})]})},Ms=Ns;function _s({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=R)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=R)==null||i.filter(u=>{var g;return((g=u.workflowJSON)==null?void 0:g.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(Ms,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Gs({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([]),[g,f]=d.useState(),[x,b]=d.useState(""),N=wn(x,300),[y,j]=d.useState(!1),A=async()=>{var M;if(t==null)return;const w=await((M=R)==null?void 0:M.listByWorkflowID(t));u(w??[]),w!=null&&w.length&&f(w[0])};if(d.useEffect(()=>{var w;A(),t&&((w=W)==null||w.get(t).then(M=>{M&&n(M.name)}))},[]),t==null)return null;const F=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:g??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:j},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(an,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(Sn,{searchValue:x,onUpdateSearchValue:w=>{b(w),y||j(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:F,onChange:()=>{a(F?[]:i.map(w=>w.id))},children:"All"}),r.jsxs(K,{fontSize:16,children:[o.length," Selected"]}),r.jsx(E,{size:"sm",icon:r.jsx(ln,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(_s,{searchQuery:N}):r.jsx(Es,{mediaList:i})})]})]})})}export{Gs as default}; +import{r as d,d as Se,x as Ht,m as be,b as it,f as B,k as Wt,o as ct,E as Kt,j as r,g as O,n as Yt,e as Xt,V as ut,h as dt,M as Zt,T as qt,N as Jt,U as Qt,Q as en,O as tn}from"./input.js";import{ab as nn,ac as sn,d as Re,F as m,ad as rn,l as E,I as on,f as Ee,B as ht,T as K,W as oe,a5 as tt,H as Y,w as W,g as D,v as ft,a3 as xt,O as pt,a2 as R,ae as an,x as ln}from"./App-9GIQJeUY.js";import{c as je,p as cn,r as nt,v as st,I as un,i as dn,b as hn,d as fn,g as xn,N as pn,a as gn,e as mn,f as vn,h as yn,M as gt,u as wn,S as Sn}from"./MediaPreview-VRNiVJ5t.js";import{I as bn}from"./chunk-7D6N5TE5-gOmt0HWF.js";import{S as jn}from"./chunk-3RSXBRAN-WBOq6SL0.js";import{C as Ae,G as kn}from"./chunk-JARCRF6W-1gGfj837.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-VcPf7MxV.js";import"./IconSearch-srLS9f0l.js";const mt=1/60*1e3,Pn=typeof performance<"u"?()=>performance.now():()=>Date.now(),vt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Pn()),mt);function Cn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,g=!1)=>{const f=g&&o,x=f?t:s;return u&&l.add(i),x.indexOf(i)===-1&&(x.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]=Cn(()=>X=!0),e),{}),Tn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||Mn(),s.schedule(n,o,a)),e},{}),En=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(V),e),{});const Nn=e=>ae[e].process(V),yt=e=>{X=!1,V.delta=Me?mt:Math.max(Math.min(e-V.timestamp,In),1),V.timestamp=e,_e=!0,Z.forEach(Nn),_e=!1,X&&(Me=!1,vt(yt))},Mn=()=>{X=!0,Me=!0,_e||vt(yt)},ot=()=>V;var $=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 _n(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var j;const A=(j=n[y])!=null?j:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${A.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${A.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,j)=>ee(y).height>ee(j).height?y:j,te):n.reduce((y,j)=>ee(y).width>ee(j).width?y:j,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,g=[0,o?100-s[0]:s[0]],f=u?g:s;let x=f[0];!u&&o&&(x=100-x);const b=Math.abs(f[f.length-1]-f[0]),N={...i,...Q({orientation:t,vertical:o?{height:`${b}%`,top:`${x}%`}:{height:`${b}%`,bottom:`${x}%`},horizontal:o?{width:`${b}%`,right:`${x}%`}:{width:`${b}%`,left:`${x}%`}})};return{trackStyle:i,innerTrackStyle:N,rootStyle:c,getThumbStyle:a}}function zn(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Dn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Rn(e){const t=Fn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function wt(e){return!!e.touches}function An(e){return wt(e)&&e.touches.length>1}function Fn(e){var t;return(t=e.view)!=null?t:window}function $n(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Vn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function St(e,t="page"){return wt(e)?$n(e,t):Vn(e,t)}function Bn(e){return t=>{const s=Rn(t);(!s||s&&t.button===0)&&e(t)}}function On(e,t=!1){function s(o){e(o,{point:St(o)})}return t?Bn(s):s}function ne(e,t,s,n){return Dn(e,t,On(s,t==="pointerdown"),n)}var Ln=Object.defineProperty,Gn=(e,t,s)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,I=(e,t,s)=>(Gn(e,typeof t!="symbol"?t+"":t,s),s),Un=class{constructor(e,t,s){I(this,"history",[]),I(this,"startEvent",null),I(this,"lastEvent",null),I(this,"lastEventInfo",null),I(this,"handlers",{}),I(this,"removeListeners",()=>{}),I(this,"threshold",3),I(this,"win"),I(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Yn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:g}=ot();this.history.push({...c.point,timestamp:g});const{onStart:f,onMove:x}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,c)}),I(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Tn.update(this.updatePoint,!0)}),I(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:g,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!g||!this.startEvent)&&(g==null||g(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,An(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:St(e)},{timestamp:a}=ot();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Kn(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),En.update(this.updatePoint)}};function at(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:at(e.point,t[t.length-1]),offset:at(e.point,t[0]),velocity:Wn(t,.1)}}var Hn=e=>e*1e3;function Wn(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>Hn(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 Kn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function lt(e){return"x"in e&&"y"in e}function Yn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(lt(e)&<(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function bt(e){const t=d.useRef(null);return t.current=e,t}function Xn(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),g=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,x){u.current=null,o==null||o(f,x)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(g.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function x(b){u.current=new Un(b,g.current,c)}return ne(f,"pointerdown",x)},[e,i,g,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Zn(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 qn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Jn(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 qn(()=>{const l=e(),c=l.map((i,u)=>Zn(i,g=>{n(f=>[...f.slice(0,u),g,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Jn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function es(e){return typeof e=="object"&&e!==null&&"current"in e}function ts(e){const[t]=Qn({observeMutation:!1,getNodes(){return[es(e)?e.current:e]}});return t}function ns(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:g,isDisabled:f,isReadOnly:x,onChangeStart:b,onChangeEnd:N,step:y=1,getAriaValueText:j,"aria-valuetext":A,"aria-label":F,"aria-labelledby":w,name:M,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(b),L=Se(N),Ve=Se(j),C=zn({isReversed:c,direction:i,orientation:u}),[_t,de]=nn({value:a,defaultValue:l??rs(s,n),onChange:o}),[he,Be]=d.useState(!1),[fe,Oe]=d.useState(!1),xe=!(f||x),pe=(n-s)/10,G=y||(n-s)/100,v=je(_t,s,n),zt=n-v+s,Le=st(C?zt:v,s,n),J=u==="vertical",S=bt({min:s,max:n,step:y,isDisabled:f,value:v,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),ge=d.useRef(null),me=d.useRef(null),Ge=d.useRef(null),Dt=d.useId(),Ue=g??Dt,[He,We]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var p,U;if(!ge.current)return;const k=S.current;k.eventSource="pointer";const T=ge.current.getBoundingClientRect(),{clientX:ye,clientY:Lt}=(U=(p=h.touches)==null?void 0:p[0])!=null?U:h,Gt=J?T.bottom-Lt:ye-T.left,Ut=J?T.height:T.width;let we=Gt/Ut;C&&(we=1-we);let H=cn(we,k.min,k.max);return k.step&&(H=parseFloat(nt(H,k.min,k.step))),H=je(H,k.min,k.max),H},[J,C,S]),_=d.useCallback(h=>{const p=S.current;p.isInteractive&&(h=parseFloat(nt(h,p.min,G)),h=je(h,p.min,p.max),de(h))},[G,de,S]),z=d.useMemo(()=>({stepUp(h=G){const p=C?v-h:v+h;_(p)},stepDown(h=G){const p=C?v+h:v-h;_(p)},reset(){_(l||0)},stepTo(h){_(h)}}),[_,C,v,G,l]),Ke=d.useCallback(h=>{const p=S.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(pe),PageDown:()=>z.stepDown(pe),Home:()=>_(p.min),End:()=>_(p.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),p.eventSource="keyboard")},[z,_,pe,S]),Ye=(t=Ve==null?void 0:Ve(v))!=null?t:A,ve=ts(me),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=S.current,p=ve??{width:0,height:0};return _n({isReversed:C,orientation:h.orientation,thumbRects:[p],thumbPercents:[Le]})},[C,ve,Le,S]),Qe=d.useCallback(()=>{S.current.focusThumbOnChange&&setTimeout(()=>{var p;return(p=me.current)==null?void 0:p.focus()})},[S]);Ht(()=>{const h=S.current;Qe(),h.eventSource==="keyboard"&&(L==null||L(h.value))},[v,L]);function et(h){const p=Rt(h);p!=null&&p!==S.current.value&&de(p)}Xn(Ge,{onPanSessionStart(h){const p=S.current;p.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(p.value))},onPanSessionEnd(){const h=S.current;h.isInteractive&&(Be(!1),L==null||L(h.value))},onPan(h){S.current.isInteractive&&et(h)}});const At=d.useCallback((h={},p=null)=>({...h,...Fe,ref:be(p,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":$(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},p=null)=>({...h,ref:be(p,ge),id:We,"data-disabled":$(f),style:{...h.style,...qe}}),[f,We,qe]),$t=d.useCallback((h={},p=null)=>({...h,ref:p,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},p=null)=>({...h,ref:be(p,me),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":$(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":v,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(x),"aria-label":F,"aria-labelledby":F?void 0:w,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,Ke),onFocus:Pe(h.onFocus,()=>Oe(!0)),onBlur:Pe(h.onBlur,()=>Oe(!1))}),[xe,He,he,Ye,s,n,v,u,f,x,F,w,Xe,Ke]),Bt=d.useCallback((h,p=null)=>{const U=!(h.valuen),k=v>=h.value,T=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ss({orientation:u,vertical:{bottom:C?`${100-T}%`:`${T}%`},horizontal:{left:C?`${100-T}%`:`${T}%`}})};return{...h,ref:p,role:"presentation","aria-hidden":!0,"data-disabled":$(f),"data-invalid":$(!U),"data-highlighted":$(k),style:{...h.style,...ye}}},[f,C,n,s,u,v]),Ot=d.useCallback((h={},p=null)=>({...h,ref:p,type:"hidden",value:v,name:M}),[M,v]);return{state:{value:v,isFocused:fe,isDragging:he},actions:z,getRootProps:At,getTrackProps:Ft,getInnerTrackProps:$t,getThumbProps:Vt,getMarkerProps:Bt,getInputProps:Ot}}function ss(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function rs(e,t){return t"}),[as,ie]=it({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),jt=B((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Wt("Slider",n),a=ct(n),{direction:l}=Kt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=ns(a),g=i(),f=c({},t);return r.jsx(os,{value:u,children:r.jsx(as,{value:o,children:r.jsxs(O.div,{...g,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});jt.displayName="Slider";var kt=B((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});kt.displayName="SliderThumb";var Pt=B((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});Pt.displayName="SliderTrack";var Ct=B((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Ct.displayName="SliderFilledTrack";var ls=B((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});ls.displayName="SliderMark";function is(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var cs=["h","minH","height","minHeight"],It=B((e,t)=>{const s=Yt("Textarea",e),{className:n,rows:o,...a}=ct(e),l=sn(a),c=o?is(s,cs):s;return r.jsx(O.textarea,{ref:t,rows:o,...l,className:Xt("chakra-textarea",n),__css:c})});It.displayName="Textarea";var us=Re("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Tt=Re("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"}]]),Et=Re("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 ds=({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(m,{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(bn,{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(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(us,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(un,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null};function hs(e){const t=e.split(".").pop();return fetch(e).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.blob()}).then(async s=>{const n=e.split("/").pop()??"",o=new File([s],n);if(dn(e))return hn(o);if(t==="webp")return fn(o);const a=await xn(o),l=JSON.parse(a==null?void 0:a.prompt),c=JSON.parse(a==null?void 0:a.workflow);return{prompt:l,workflow:c}})}const fs=({inputItem:e})=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(on,{value:e.inputValue,onChange:t=>{}})]}),xs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(pn,{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(gn,{}),r.jsxs(mn,{children:[r.jsx(vn,{}),r.jsx(yn,{})]})]})]}),r.jsx(m,{children:r.jsxs(jt,{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(Pt,{children:r.jsx(Ct,{})}),r.jsx(kt,{})]})})]})},ps=e=>{var s;const{inputItem:t}=e;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(jn,{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}`))})]})},gs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsx(m,{children:t.label??t.inputName}),r.jsx(It,{value:t.inputValue,onChange:s=>{},rows:5})]})};var P=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(P||{});const ms=e=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(m,{children:"No Support"})]}),vs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(Ae,{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(){}}),ys={[P.Input]:fs,[P.InputSlider]:xs,[P.Select]:ps,[P.Textarea]:gs,[P.Checkbox]:vs,NoSupport:ms},ws=LiteGraph.registered_node_types;function Ss(e,t){var o,a,l,c,i;const s=(o=ws[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:P.Textarea}:{type:P.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:P.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:P.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:P.Select}:{type:P.NoSupport}}const ze=({inputItem:e})=>{const t=Ss(e.classType,e.inputName),[s,n]=d.useState(!1),o=ys[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(m,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(E,{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(Tt,{size:14}):r.jsx(Et,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function bs(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(m,{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 js(){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(ks,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(m,{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 ks({title:e,children:t}){return r.jsxs(ht,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(K,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],De=new Set;function Nt(e,t){if(!De.has(e.nodeID))return De.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Nt(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 Ps(e){se=[],De=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))Nt(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 Cs({media:e}){const[t,s]=d.useState([]);d.useContext(oe);const[n,o]=d.useState(),[a,l]=d.useState(!0),[c,i]=d.useState(!0);d.useEffect(()=>{e?hs(`/workspace/view_media?filename=${e.localPath}`).then(x=>{o(x.prompt)}):tt.graphToPrompt(tt.graph).then(x=>{o(x.output)})},[e]),d.useEffect(()=>{if(!n)return;const x=Ps(n);s(x)},[n]);const[u,g]=d.useState([]),f=x=>{if(re(u,{name:x.name,promptKey:x==null?void 0:x.promptKey,classType:(x==null?void 0:x.class_type)??""})){const b=u.filter(N=>N.name!==x.name||N.promptKey!==x.promptKey);g(b)}else{const b=[...u,x];g(b)}};return r.jsx(ce.Provider,{value:{topFields:u,showNodeName:c,calcInputList:t,updateTopField:f},children:r.jsxs(m,{direction:"column",align:"stretch",gap:5,children:[r.jsx(bs,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(rt,{isChecked:a,onChange:x=>l(!a)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:c,onChange:x=>i(!c)})]}),a&&r.jsx(js,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),Is=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ut();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=W)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(m,{flexWrap:"wrap",gap:3,children:[r.jsx(m,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(K,{children:e==null?void 0:e.localPath}),r.jsx(D,{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(E,{size:"sm",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(m,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(K,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{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=R)==null?void 0:u.delete(e.id)),n(g=>g.filter(f=>f.id!==e.id)))}})}),((c=(l=W)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(D,{label:"Set as cover",children:r.jsx(E,{size:"sm",variant:"ghost",icon:t?r.jsx(Tt,{size:19}):r.jsx(Et,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=W)==null?void 0:i.updateMetaInfo(W.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(dt,{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},Ts=({media:e})=>r.jsxs(m,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(Is,{media:e}),r.jsx(Cs,{media:e??null})]}),Te=120;function Es({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(m,{gap:3,h:"100%",children:[r.jsxs(kn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(ds,{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(m,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(ht,{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(gt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=R)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ts,{media:t??void 0})]})}const Ns=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ut();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx(Ae,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(gt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=R)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(D,{label:xt(e.createTime,!0),children:i}),r.jsx(D,{label:e.localPath,children:r.jsx(K,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(dt,{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(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var g;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((g=R)==null?void 0:g.delete(e.id))}})})]})]})},Ms=Ns;function _s({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=R)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=R)==null||i.filter(u=>{var g;return((g=u.workflowJSON)==null?void 0:g.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(Ms,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Gs({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([]),[g,f]=d.useState(),[x,b]=d.useState(""),N=wn(x,300),[y,j]=d.useState(!1),A=async()=>{var M;if(t==null)return;const w=await((M=R)==null?void 0:M.listByWorkflowID(t));u(w??[]),w!=null&&w.length&&f(w[0])};if(d.useEffect(()=>{var w;A(),t&&((w=W)==null||w.get(t).then(M=>{M&&n(M.name)}))},[]),t==null)return null;const F=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:g??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:j},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(an,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(Sn,{searchValue:x,onUpdateSearchValue:w=>{b(w),y||j(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:F,onChange:()=>{a(F?[]:i.map(w=>w.id))},children:"All"}),r.jsxs(K,{fontSize:16,children:[o.length," Selected"]}),r.jsx(E,{size:"sm",icon:r.jsx(ln,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(_s,{searchQuery:N}):r.jsx(Es,{mediaList:i})})]})]})})}export{Gs as default}; diff --git a/dist/workspace_web/IconCopy-zZpZ6D5h.js b/dist/workspace_web/IconCopy-RhFbFhX0.js similarity index 83% rename from dist/workspace_web/IconCopy-zZpZ6D5h.js rename to dist/workspace_web/IconCopy-RhFbFhX0.js index 6357199..5791232 100644 --- a/dist/workspace_web/IconCopy-zZpZ6D5h.js +++ b/dist/workspace_web/IconCopy-RhFbFhX0.js @@ -1 +1 @@ -import{d as a}from"./App-ZTJclgGW.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-9GIQJeUY.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-hyGkJAd5.js b/dist/workspace_web/IconSearch-srLS9f0l.js similarity index 67% rename from dist/workspace_web/IconSearch-hyGkJAd5.js rename to dist/workspace_web/IconSearch-srLS9f0l.js index 84d030e..eb0ab2d 100644 --- a/dist/workspace_web/IconSearch-hyGkJAd5.js +++ b/dist/workspace_web/IconSearch-srLS9f0l.js @@ -1 +1 @@ -import{d as a}from"./App-ZTJclgGW.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-9GIQJeUY.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/MediaPreview-46fgYP_n.js b/dist/workspace_web/MediaPreview-VRNiVJ5t.js similarity index 98% rename from dist/workspace_web/MediaPreview-46fgYP_n.js rename to dist/workspace_web/MediaPreview-VRNiVJ5t.js index 3c163f1..abc1439 100644 --- a/dist/workspace_web/MediaPreview-46fgYP_n.js +++ b/dist/workspace_web/MediaPreview-VRNiVJ5t.js @@ -1 +1 @@ -import{d as D,r as l,j as v,I as Ee,x as Te,y as je,m as ae,q as _,p as se,b as Pe,f as T,g as Y,k as Be,o as Ke,e as Ve}from"./input.js";import{ae as Ge,af as We,d as Le,B as qe,l as ze,x as He,I as Xe,ac as $e}from"./App-ZTJclgGW.js";import{I as Ye}from"./IconSearch-hyGkJAd5.js";import{I as Je}from"./chunk-7D6N5TE5-wlKuxWhy.js";function Qe(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function ie(t,e){let r=Qe(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function ue(t){if(!Number.isFinite(t))return 0;let e=1,r=0;for(;Math.round(t*e)/e!==t;)e*=10,r+=1;return r}function Ct(t,e,r){return(t-e)*100/(r-e)}function It(t,e,r){return(r-e)*t+e}function St(t,e,r){const a=Math.round((t-e)/r)*r+e,i=ue(r);return ie(a,i)}function Ze(t,e,r){return t==null?t:(r{var g;return a==null?"":(g=oe(a,s,r))!=null?g:""}),y=typeof i<"u",h=y?i:m,I=Me(P(h),s),S=r??I,A=l.useCallback(g=>{g!==h&&(y||w(g.toString()),c==null||c(g.toString(),P(g)))},[c,y,h]),k=l.useCallback(g=>{let b=g;return f&&(b=Ze(b,u,o)),ie(b,S)},[S,f,o,u]),j=l.useCallback((g=s)=>{let b;h===""?b=P(g):b=P(h)+g,b=k(b),A(b)},[k,s,A,h]),B=l.useCallback((g=s)=>{let b;h===""?b=P(-g):b=P(h)-g,b=k(b),A(b)},[k,s,A,h]),K=l.useCallback(()=>{var g;let b;a==null?b="":b=(g=oe(a,s,r))!=null?g:u,A(b)},[a,r,s,A,u]),Q=l.useCallback(g=>{var b;const ee=(b=oe(g,s,S))!=null?b:u;A(ee)},[S,s,A,u]),V=P(h);return{isOutOfRange:V>o||Vv.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.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=t=>v.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.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 _e(t,e,r,a){l.useEffect(()=>{var i;if(!t.current||!a)return;const s=(i=t.current.ownerDocument.defaultView)!=null?i:window,u=Array.isArray(e)?e:[e],o=new s.MutationObserver(f=>{for(const c of f)c.type==="attributes"&&c.attributeName&&u.includes(c.attributeName)&&r(c)});return o.observe(t.current,{attributes:!0,attributeFilter:u}),()=>o.disconnect()})}function rt(t,e){const r=D(t);l.useEffect(()=>{let a=null;const i=()=>r();return e!==null&&(a=window.setInterval(i,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,ke=300;function st(t,e){const[r,a]=l.useState(!1),[i,s]=l.useState(null),[u,o]=l.useState(!0),f=l.useRef(null),c=()=>clearTimeout(f.current);rt(()=>{i==="increment"&&t(),i==="decrement"&&e()},r?at:null);const m=l.useCallback(()=>{u&&t(),f.current=setTimeout(()=>{o(!1),a(!0),s("increment")},ke)},[t,u]),w=l.useCallback(()=>{u&&e(),f.current=setTimeout(()=>{o(!1),a(!0),s("decrement")},ke)},[e,u]),y=l.useCallback(()=>{o(!0),a(!1),c()},[]);return l.useEffect(()=>()=>c(),[]),{up:m,down:w,stop:y,isSpinning:r}}var ot=/^[Ee0-9+\-.]$/;function ut(t){return ot.test(t)}function it(t,e){if(t.key==null)return!0;const r=t.ctrlKey||t.altKey||t.metaKey;return!(t.key.length===1)||r?!0:e(t.key)}function lt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:i=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER,step:u=1,isReadOnly:o,isDisabled:f,isRequired:c,isInvalid:m,pattern:w="[0-9]*(.[0-9]+)?",inputMode:y="decimal",allowMouseWheel:h,id:I,onChange:S,precision:A,name:k,"aria-describedby":j,"aria-label":B,"aria-labelledby":K,onFocus:Q,onBlur:V,onInvalid:ce,getAriaValueText:fe,isValidCharacter:Z,format:g,parse:b,...ee}=t,te=D(Q),de=D(V),R=D(ce),G=D(Z??ut),ne=D(fe),d=et(t),{update:U,increment:pe,decrement:me}=d,[Fe,re]=l.useState(!1),W=!(o||f),E=l.useRef(null),L=l.useRef(null),be=l.useRef(null),ge=l.useRef(null),q=l.useCallback(n=>n.split("").filter(G).join(""),[G]),z=l.useCallback(n=>{var p;return(p=b==null?void 0:b(n))!=null?p:n},[b]),F=l.useCallback(n=>{var p;return((p=g==null?void 0:g(n))!=null?p:n).toString()},[g]);Te(()=>{(d.valueAsNumber>s||d.valueAsNumber{if(!E.current)return;if(E.current.value!=d.value){const p=z(E.current.value);d.setValue(q(p))}},[z,q]);const H=l.useCallback((n=u)=>{W&&pe(n)},[pe,W,u]),X=l.useCallback((n=u)=>{W&&me(n)},[me,W,u]),N=st(H,X);_e(be,"disabled",N.stop,N.isSpinning),_e(ge,"disabled",N.stop,N.isSpinning);const he=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;const x=z(n.currentTarget.value);U(q(x)),L.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[U,q,z]),ve=l.useCallback(n=>{var p,x,C;te==null||te(n),L.current&&(n.target.selectionStart=(x=L.current.start)!=null?x:(p=n.currentTarget.value)==null?void 0:p.length,n.currentTarget.selectionEnd=(C=L.current.end)!=null?C:n.currentTarget.selectionStart)},[te]),xe=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;it(n,G)||n.preventDefault();const p=we(n)*u,x=n.key,M={ArrowUp:()=>H(p),ArrowDown:()=>X(p),Home:()=>U(i),End:()=>U(s)}[x];M&&(n.preventDefault(),M(n))},[G,u,H,X,U,i,s]),we=n=>{let p=1;return(n.metaKey||n.ctrlKey)&&(p=.1),n.shiftKey&&(p=10),p},ye=l.useMemo(()=>{const n=ne==null?void 0:ne(d.value);if(n!=null)return n;const p=d.value.toString();return p||void 0},[d.value,ne]),Ne=l.useCallback(()=>{let n=d.value;if(d.value==="")return;/^[eE]/.test(d.value.toString())?d.setValue(""):(d.valueAsNumbers&&(n=s),d.cast(n))},[d,s,i]),Ce=l.useCallback(()=>{re(!1),r&&Ne()},[r,re,Ne]),$=l.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=E.current)==null||n.focus()})},[e]),Ie=l.useCallback(n=>{n.preventDefault(),N.up(),$()},[$,N]),Se=l.useCallback(n=>{n.preventDefault(),N.down(),$()},[$,N]);Ge(()=>E.current,"wheel",n=>{var p,x;const M=((x=(p=E.current)==null?void 0:p.ownerDocument)!=null?x:document).activeElement===E.current;if(!h||!M)return;n.preventDefault();const O=we(n)*u,Ae=Math.sign(n.deltaY);Ae===-1?H(O):Ae===1&&X(O)},{passive:!1});const Re=l.useCallback((n={},p=null)=>{const x=f||a&&d.isAtMax;return{...n,ref:ae(p,be),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Ie(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMax,a,Ie,N.stop,f]),Ue=l.useCallback((n={},p=null)=>{const x=f||a&&d.isAtMin;return{...n,ref:ae(p,ge),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Se(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMin,a,Se,N.stop,f]),Oe=l.useCallback((n={},p=null)=>{var x,C,M,O;return{name:k,inputMode:y,type:"text",pattern:w,"aria-labelledby":K,"aria-label":B,"aria-describedby":j,id:I,disabled:f,...n,readOnly:(x=n.readOnly)!=null?x:o,"aria-readonly":(C=n.readOnly)!=null?C:o,"aria-required":(M=n.required)!=null?M:c,required:(O=n.required)!=null?O:c,ref:ae(E,p),value:F(d.value),role:"spinbutton","aria-valuemin":i,"aria-valuemax":s,"aria-valuenow":Number.isNaN(d.valueAsNumber)?void 0:d.valueAsNumber,"aria-invalid":se(m??d.isOutOfRange),"aria-valuetext":ye,autoComplete:"off",autoCorrect:"off",onChange:_(n.onChange,he),onKeyDown:_(n.onKeyDown,xe),onFocus:_(n.onFocus,ve,()=>re(!0)),onBlur:_(n.onBlur,de,Ce)}},[k,y,w,K,B,F,j,I,f,c,o,m,d.value,d.valueAsNumber,d.isOutOfRange,i,s,ye,he,xe,ve,de,Ce]);return{value:F(d.value),valueAsNumber:d.valueAsNumber,isFocused:Fe,isDisabled:f,isReadOnly:o,getIncrementButtonProps:Re,getDecrementButtonProps:Ue,getInputProps:Oe,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[ft,le]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),dt=T(function(e,r){const a=Be("NumberInput",e),i=Ke(e),s=We(i),{htmlProps:u,...o}=lt(s),f=l.useMemo(()=>o,[o]);return v.jsx(ft,{value:f,children:v.jsx(ct,{value:a,children:v.jsx(Y.div,{...u,ref:r,className:Ve("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});dt.displayName="NumberInput";var pt=T(function(e,r){const a=J();return v.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}})});pt.displayName="NumberInputStepper";var mt=T(function(e,r){const{getInputProps:a}=le(),i=a(e,r),s=J();return v.jsx(Y.input,{...i,className:Ve("chakra-numberinput__field",e.className),__css:{width:"100%",...s.field}})});mt.displayName="NumberInputField";var De=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=T(function(e,r){var a;const i=J(),{getDecrementButtonProps:s}=le(),u=s(e,r);return v.jsx(De,{...u,__css:i.stepper,children:(a=e.children)!=null?a:v.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var gt=T(function(e,r){var a;const{getIncrementButtonProps:i}=le(),s=i(e,r),u=J();return v.jsx(De,{...s,__css:u.stepper,children:(a=e.children)!=null?a:v.jsx(nt,{})})});gt.displayName="NumberIncrementStepper";var At=Le("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const _t=(t,e)=>{const[r,a]=l.useState(t);return l.useEffect(()=>{const i=setTimeout(()=>{a(t)},e);return()=>{clearTimeout(i)}},[t,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function kt(t){const{searchValue:e,onUpdateSearchValue:r,style:a}=t,i=e!=="";return v.jsxs(qe,{style:{position:"relative",...a},mb:2,children:[v.jsx(Ye,{style:ht}),i&&v.jsx(ze,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:v.jsx(He,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),v.jsx(Xe,{placeholder:t.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:s})=>r(s.value)})]})}function Et(t){return new Promise((e,r)=>{const a=new FileReader;a.onload=i=>{const s=new Uint8Array(i.target.result),u=new DataView(s.buffer);u.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),r());let o=8;const f={};for(;oString.fromCharCode(S)).join("");f[y]=I}o+=12+c}e(f)},a.readAsArrayBuffer(t)})}function vt(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function r(u,o,f){const c=t.slice(u,u+f);if(f===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,o);if(f===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,o)}const a=r(4,e,4);function i(u){const o=r(u,e,2),f={};for(let c=0;c{const r=new FileReader;r.onload=a=>{var f;const i=new Uint8Array((f=a==null?void 0:a.target)==null?void 0:f.result),s=new DataView(i.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let u=12;const o={};for(;u{const r=new FileReader;r.onload=a=>{const i=new Uint8Array(a.target.result),s=new DataView(i.buffer),u=new TextDecoder;if(s.getUint32(0)==440786851){let o=12;for(;o>8*(4-m)&~(1<<7*m),y=u.decode(i.slice(o+2+m,o+2+m+w)),h=JSON.parse(y);e(h);return}}o+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let o=i.length-4;for(;o>16;){if(s.getUint32(o)==1684108385&&s.getUint32(o-8)==2841865588){s.getUint32(o+4),s.getUint32(o+8);const f=s.getUint32(o-4)-4*4,c=u.decode(i.slice(o+12,o+12+f)),m=JSON.parse(c);e(m);return}o-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},r.readAsArrayBuffer(t)})}function Dt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:i,objectFit:s,onBrokenLink:u}){const[o,f]=l.useState(!0);return l.useEffect(()=>{i&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).status==404){f(!1),u==null||u();return}}catch(m){console.error("Error checking media exists",m)}})()},[]),o?$e(t)?v.jsx(Je,{borderRadius:3,boxSize:`${e}px`,objectFit:s??"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):v.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:v.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:v.jsx("track",{kind:"captions"})})}):null}export{At as I,Dt as M,dt as N,kt as S,mt as a,Mt as b,Ze as c,Pt as d,pt as e,gt as f,Et as g,bt as h,Vt as i,It as p,St as r,_t as u,Ct as v}; +import{d as D,r as l,j as v,I as Ee,x as Te,y as je,m as ae,q as _,p as se,b as Pe,f as T,g as Y,k as Be,o as Ke,e as Ve}from"./input.js";import{af as Ge,ag as We,d as Le,B as qe,l as ze,x as He,I as Xe,ad as $e}from"./App-9GIQJeUY.js";import{I as Ye}from"./IconSearch-srLS9f0l.js";import{I as Je}from"./chunk-7D6N5TE5-gOmt0HWF.js";function Qe(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function ie(t,e){let r=Qe(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function ue(t){if(!Number.isFinite(t))return 0;let e=1,r=0;for(;Math.round(t*e)/e!==t;)e*=10,r+=1;return r}function Ct(t,e,r){return(t-e)*100/(r-e)}function It(t,e,r){return(r-e)*t+e}function St(t,e,r){const a=Math.round((t-e)/r)*r+e,i=ue(r);return ie(a,i)}function Ze(t,e,r){return t==null?t:(r{var g;return a==null?"":(g=oe(a,s,r))!=null?g:""}),y=typeof i<"u",h=y?i:m,I=Me(P(h),s),S=r??I,A=l.useCallback(g=>{g!==h&&(y||w(g.toString()),c==null||c(g.toString(),P(g)))},[c,y,h]),k=l.useCallback(g=>{let b=g;return f&&(b=Ze(b,u,o)),ie(b,S)},[S,f,o,u]),j=l.useCallback((g=s)=>{let b;h===""?b=P(g):b=P(h)+g,b=k(b),A(b)},[k,s,A,h]),B=l.useCallback((g=s)=>{let b;h===""?b=P(-g):b=P(h)-g,b=k(b),A(b)},[k,s,A,h]),K=l.useCallback(()=>{var g;let b;a==null?b="":b=(g=oe(a,s,r))!=null?g:u,A(b)},[a,r,s,A,u]),Q=l.useCallback(g=>{var b;const ee=(b=oe(g,s,S))!=null?b:u;A(ee)},[S,s,A,u]),V=P(h);return{isOutOfRange:V>o||Vv.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.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=t=>v.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.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 _e(t,e,r,a){l.useEffect(()=>{var i;if(!t.current||!a)return;const s=(i=t.current.ownerDocument.defaultView)!=null?i:window,u=Array.isArray(e)?e:[e],o=new s.MutationObserver(f=>{for(const c of f)c.type==="attributes"&&c.attributeName&&u.includes(c.attributeName)&&r(c)});return o.observe(t.current,{attributes:!0,attributeFilter:u}),()=>o.disconnect()})}function rt(t,e){const r=D(t);l.useEffect(()=>{let a=null;const i=()=>r();return e!==null&&(a=window.setInterval(i,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,ke=300;function st(t,e){const[r,a]=l.useState(!1),[i,s]=l.useState(null),[u,o]=l.useState(!0),f=l.useRef(null),c=()=>clearTimeout(f.current);rt(()=>{i==="increment"&&t(),i==="decrement"&&e()},r?at:null);const m=l.useCallback(()=>{u&&t(),f.current=setTimeout(()=>{o(!1),a(!0),s("increment")},ke)},[t,u]),w=l.useCallback(()=>{u&&e(),f.current=setTimeout(()=>{o(!1),a(!0),s("decrement")},ke)},[e,u]),y=l.useCallback(()=>{o(!0),a(!1),c()},[]);return l.useEffect(()=>()=>c(),[]),{up:m,down:w,stop:y,isSpinning:r}}var ot=/^[Ee0-9+\-.]$/;function ut(t){return ot.test(t)}function it(t,e){if(t.key==null)return!0;const r=t.ctrlKey||t.altKey||t.metaKey;return!(t.key.length===1)||r?!0:e(t.key)}function lt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:i=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER,step:u=1,isReadOnly:o,isDisabled:f,isRequired:c,isInvalid:m,pattern:w="[0-9]*(.[0-9]+)?",inputMode:y="decimal",allowMouseWheel:h,id:I,onChange:S,precision:A,name:k,"aria-describedby":j,"aria-label":B,"aria-labelledby":K,onFocus:Q,onBlur:V,onInvalid:ce,getAriaValueText:fe,isValidCharacter:Z,format:g,parse:b,...ee}=t,te=D(Q),de=D(V),R=D(ce),G=D(Z??ut),ne=D(fe),d=et(t),{update:U,increment:pe,decrement:me}=d,[Fe,re]=l.useState(!1),W=!(o||f),E=l.useRef(null),L=l.useRef(null),be=l.useRef(null),ge=l.useRef(null),q=l.useCallback(n=>n.split("").filter(G).join(""),[G]),z=l.useCallback(n=>{var p;return(p=b==null?void 0:b(n))!=null?p:n},[b]),F=l.useCallback(n=>{var p;return((p=g==null?void 0:g(n))!=null?p:n).toString()},[g]);Te(()=>{(d.valueAsNumber>s||d.valueAsNumber{if(!E.current)return;if(E.current.value!=d.value){const p=z(E.current.value);d.setValue(q(p))}},[z,q]);const H=l.useCallback((n=u)=>{W&&pe(n)},[pe,W,u]),X=l.useCallback((n=u)=>{W&&me(n)},[me,W,u]),N=st(H,X);_e(be,"disabled",N.stop,N.isSpinning),_e(ge,"disabled",N.stop,N.isSpinning);const he=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;const x=z(n.currentTarget.value);U(q(x)),L.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[U,q,z]),ve=l.useCallback(n=>{var p,x,C;te==null||te(n),L.current&&(n.target.selectionStart=(x=L.current.start)!=null?x:(p=n.currentTarget.value)==null?void 0:p.length,n.currentTarget.selectionEnd=(C=L.current.end)!=null?C:n.currentTarget.selectionStart)},[te]),xe=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;it(n,G)||n.preventDefault();const p=we(n)*u,x=n.key,M={ArrowUp:()=>H(p),ArrowDown:()=>X(p),Home:()=>U(i),End:()=>U(s)}[x];M&&(n.preventDefault(),M(n))},[G,u,H,X,U,i,s]),we=n=>{let p=1;return(n.metaKey||n.ctrlKey)&&(p=.1),n.shiftKey&&(p=10),p},ye=l.useMemo(()=>{const n=ne==null?void 0:ne(d.value);if(n!=null)return n;const p=d.value.toString();return p||void 0},[d.value,ne]),Ne=l.useCallback(()=>{let n=d.value;if(d.value==="")return;/^[eE]/.test(d.value.toString())?d.setValue(""):(d.valueAsNumbers&&(n=s),d.cast(n))},[d,s,i]),Ce=l.useCallback(()=>{re(!1),r&&Ne()},[r,re,Ne]),$=l.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=E.current)==null||n.focus()})},[e]),Ie=l.useCallback(n=>{n.preventDefault(),N.up(),$()},[$,N]),Se=l.useCallback(n=>{n.preventDefault(),N.down(),$()},[$,N]);Ge(()=>E.current,"wheel",n=>{var p,x;const M=((x=(p=E.current)==null?void 0:p.ownerDocument)!=null?x:document).activeElement===E.current;if(!h||!M)return;n.preventDefault();const O=we(n)*u,Ae=Math.sign(n.deltaY);Ae===-1?H(O):Ae===1&&X(O)},{passive:!1});const Re=l.useCallback((n={},p=null)=>{const x=f||a&&d.isAtMax;return{...n,ref:ae(p,be),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Ie(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMax,a,Ie,N.stop,f]),Ue=l.useCallback((n={},p=null)=>{const x=f||a&&d.isAtMin;return{...n,ref:ae(p,ge),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Se(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMin,a,Se,N.stop,f]),Oe=l.useCallback((n={},p=null)=>{var x,C,M,O;return{name:k,inputMode:y,type:"text",pattern:w,"aria-labelledby":K,"aria-label":B,"aria-describedby":j,id:I,disabled:f,...n,readOnly:(x=n.readOnly)!=null?x:o,"aria-readonly":(C=n.readOnly)!=null?C:o,"aria-required":(M=n.required)!=null?M:c,required:(O=n.required)!=null?O:c,ref:ae(E,p),value:F(d.value),role:"spinbutton","aria-valuemin":i,"aria-valuemax":s,"aria-valuenow":Number.isNaN(d.valueAsNumber)?void 0:d.valueAsNumber,"aria-invalid":se(m??d.isOutOfRange),"aria-valuetext":ye,autoComplete:"off",autoCorrect:"off",onChange:_(n.onChange,he),onKeyDown:_(n.onKeyDown,xe),onFocus:_(n.onFocus,ve,()=>re(!0)),onBlur:_(n.onBlur,de,Ce)}},[k,y,w,K,B,F,j,I,f,c,o,m,d.value,d.valueAsNumber,d.isOutOfRange,i,s,ye,he,xe,ve,de,Ce]);return{value:F(d.value),valueAsNumber:d.valueAsNumber,isFocused:Fe,isDisabled:f,isReadOnly:o,getIncrementButtonProps:Re,getDecrementButtonProps:Ue,getInputProps:Oe,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[ft,le]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),dt=T(function(e,r){const a=Be("NumberInput",e),i=Ke(e),s=We(i),{htmlProps:u,...o}=lt(s),f=l.useMemo(()=>o,[o]);return v.jsx(ft,{value:f,children:v.jsx(ct,{value:a,children:v.jsx(Y.div,{...u,ref:r,className:Ve("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});dt.displayName="NumberInput";var pt=T(function(e,r){const a=J();return v.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}})});pt.displayName="NumberInputStepper";var mt=T(function(e,r){const{getInputProps:a}=le(),i=a(e,r),s=J();return v.jsx(Y.input,{...i,className:Ve("chakra-numberinput__field",e.className),__css:{width:"100%",...s.field}})});mt.displayName="NumberInputField";var De=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=T(function(e,r){var a;const i=J(),{getDecrementButtonProps:s}=le(),u=s(e,r);return v.jsx(De,{...u,__css:i.stepper,children:(a=e.children)!=null?a:v.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var gt=T(function(e,r){var a;const{getIncrementButtonProps:i}=le(),s=i(e,r),u=J();return v.jsx(De,{...s,__css:u.stepper,children:(a=e.children)!=null?a:v.jsx(nt,{})})});gt.displayName="NumberIncrementStepper";var At=Le("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const _t=(t,e)=>{const[r,a]=l.useState(t);return l.useEffect(()=>{const i=setTimeout(()=>{a(t)},e);return()=>{clearTimeout(i)}},[t,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function kt(t){const{searchValue:e,onUpdateSearchValue:r,style:a}=t,i=e!=="";return v.jsxs(qe,{style:{position:"relative",...a},mb:2,children:[v.jsx(Ye,{style:ht}),i&&v.jsx(ze,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:v.jsx(He,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),v.jsx(Xe,{placeholder:t.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:s})=>r(s.value)})]})}function Et(t){return new Promise((e,r)=>{const a=new FileReader;a.onload=i=>{const s=new Uint8Array(i.target.result),u=new DataView(s.buffer);u.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),r());let o=8;const f={};for(;oString.fromCharCode(S)).join("");f[y]=I}o+=12+c}e(f)},a.readAsArrayBuffer(t)})}function vt(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function r(u,o,f){const c=t.slice(u,u+f);if(f===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,o);if(f===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,o)}const a=r(4,e,4);function i(u){const o=r(u,e,2),f={};for(let c=0;c{const r=new FileReader;r.onload=a=>{var f;const i=new Uint8Array((f=a==null?void 0:a.target)==null?void 0:f.result),s=new DataView(i.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let u=12;const o={};for(;u{const r=new FileReader;r.onload=a=>{const i=new Uint8Array(a.target.result),s=new DataView(i.buffer),u=new TextDecoder;if(s.getUint32(0)==440786851){let o=12;for(;o>8*(4-m)&~(1<<7*m),y=u.decode(i.slice(o+2+m,o+2+m+w)),h=JSON.parse(y);e(h);return}}o+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let o=i.length-4;for(;o>16;){if(s.getUint32(o)==1684108385&&s.getUint32(o-8)==2841865588){s.getUint32(o+4),s.getUint32(o+8);const f=s.getUint32(o-4)-4*4,c=u.decode(i.slice(o+12,o+12+f)),m=JSON.parse(c);e(m);return}o-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},r.readAsArrayBuffer(t)})}function Dt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:i,objectFit:s,onBrokenLink:u}){const[o,f]=l.useState(!0);return l.useEffect(()=>{i&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).status==404){f(!1),u==null||u();return}}catch(m){console.error("Error checking media exists",m)}})()},[]),o?$e(t)?v.jsx(Je,{borderRadius:3,boxSize:`${e}px`,objectFit:s??"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):v.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:v.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:v.jsx("track",{kind:"captions"})})}):null}export{At as I,Dt as M,dt as N,kt as S,mt as a,Mt as b,Ze as c,Pt as d,pt as e,gt as f,Et as g,bt as h,Vt as i,It as p,St as r,_t as u,Ct as v}; diff --git a/dist/workspace_web/ModelManagerTopbar-jjabvfOI.js b/dist/workspace_web/ModelManagerTopbar-d0zTxQle.js similarity index 98% rename from dist/workspace_web/ModelManagerTopbar-jjabvfOI.js rename to dist/workspace_web/ModelManagerTopbar-d0zTxQle.js index 78d4d72..34c2b61 100644 --- a/dist/workspace_web/ModelManagerTopbar-jjabvfOI.js +++ b/dist/workspace_web/ModelManagerTopbar-d0zTxQle.js @@ -1 +1 @@ -import{f as V,r as f,j as n,g as B,e as re,$ as J,b as Ve,o as qe,k as Ye,h as A,a0 as ae,P as Qe,a1 as Je,T as ke,a2 as Xe,U as Ie,O as Le,R as Ze,Z as et,M as tt,N as st,Q as nt}from"./input.js";import{aj as ot,m as it,ak as rt,al as at,am as P,B as oe,F as W,T as D,g as ie,W as Ee,an as lt,h as H,a4 as U,a5 as Ae,a6 as ct,ad as Ne,I as X,H as $,ao as De,ap as xe,f as q,v as dt,aq as Te,e as Fe,ar as ye,as as ht,at as Pe,au as ut,av as mt,aw as ft,ax as pt,ay as gt,az as xt,aA as ee,aB as yt,aC as wt}from"./App-ZTJclgGW.js";import{f as le,s as vt,g as jt}from"./civitUtils-T1Lq3reo.js";import{I as Oe}from"./chunk-7D6N5TE5-wlKuxWhy.js";import{G as Mt,C as St}from"./chunk-JARCRF6W-UTrQeKCZ.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-oKoElBXY.js";var ze=V(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:m,...u}=e,g=f.useMemo(()=>m?f.Children.map(a,(p,x)=>n.jsx(de,{children:p},x)):a,[a,m]);return n.jsx(B.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(B.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});ze.displayName="Wrap";var de=V(function(e,s){const{className:o,...r}=e;return n.jsx(B.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...r})});de.displayName="WrapItem";function we(t){return it(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Be=V(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,m=ot({gridArea:o,gridColumn:we(r),gridRow:we(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(B.div,{ref:s,__css:m,...h})});Be.displayName="GridItem";var te=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Re(t){var e;const{bg:s,bgColor:o,backgroundColor:r,shadow:i,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=rt(),h=at(),m=(e=s??o)!=null?e:r,u=i??a;return n.jsx(B.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(B.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",m),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}Re.displayName="PopoverArrow";function _t(t,e,s){return(t-e)*100/(s-e)}J({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});J({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var Ct=J({"0%":{left:"-40%"},"100%":{left:"100%"}}),bt=J({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function kt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=_t(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 i=="function"?i(e,l):r})(),role:c},percent:l,value:e}}var[It,Lt]=Ve({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Et=V((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=kt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Lt().filledTrack};return n.jsx(B.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),We=V((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=qe(t),M=Ye("Progress",t),b=d??((s=M.track)==null?void 0:s.borderRadius),k={animation:`${bt} 1s linear infinite`},T={...!h&&a&&c&&k,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Ct} 1s ease infinite normal none running`}},C={overflow:"hidden",position:"relative",...M.track};return n.jsx(B.div,{ref:e,borderRadius:b,__css:C,...j,children:n.jsxs(It,{value:M,children:[n.jsx(Et,{"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:T,borderRadius:b,title:p,role:x}),l]})})});We.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Ke(t)==="[object Array]"}const At=1/0;function Nt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-At?"-0":s}(t)}function F(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function Dt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ke(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Ke(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Tt=t=>`Missing ${t} property in key`,Ft=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class Pt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Ge(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.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 Ge(t){let e=null,s=null,o=null,r=1,i=null;if(F(t)||K(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Tt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(Ft(a));e=je(a),s=Me(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function je(t){return K(t)?t:t.split(".")}function Me(t){return K(t)?t.join("."):t}var v={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(F(l)||$e(l)||Dt(l)))s.push(Nt(l));else if(K(l)){o=!0;for(let d=0,h=l.length;d{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=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(F(h)&&!se(h)){let m={v:h,i:d,n:this.norm.get(h)};c.push(m)}else K(h)&&h.forEach((m,u)=>{l.push({nestedArrIndex:u,value:m})})}o.$[i]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ue(t,e,{getFn:s=v.getFn,fieldNormWeight:o=v.fieldNormWeight}={}){const r=new he({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Ge)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=v.distance,ignoreLocation:i=v.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function zt(t,e,s,{location:o=v.location,distance:r=v.distance,threshold:i=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,m=t.length,u=Math.max(0,Math.min(o,m));let g=i,p=u;const x=c>1||l,j=x?Array(m):[];let M;for(;(M=t.indexOf(e,p))>-1;){let C=Q(e,{currentLocation:M,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(C,g),p=M+h,x){let I=0;for(;I=z;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(j[S]=+!!_),y[w]=(y[w+1]<<1|1)&_,C&&(y[w]|=(b[w+1]|b[w])<<1|1|b[w+1]),y[w]&Y&&(k=Q(e,{errors:C,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),k<=g)){if(g=k,p=S,p<=u)break;z=Math.max(1,2*u-p)}}if(Q(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;b=y}const T={isMatch:p>=0,score:Math.max(.001,k)};if(x){const C=function(I=[],L=v.minMatchCharLength){let z=[],E=-1,y=-1,w=0;for(let S=I.length;w=L&&z.push([E,y]),E=-1)}return I[w-1]&&w-E>=L&&z.push([E,w-1]),z}(j,c);C.length?l&&(T.indices=C):T.isMatch=!1}return T}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},m=this.pattern.length;if(m>R){let u=0;const g=m%R,p=m-g;for(;u{const{isMatch:M,score:b,indices:k}=zt(e,p,x,{location:r+j,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),m+=b,M&&k&&(h=[...h,...k])});let g={isMatch:u,score:u?m/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const Se=[];function _e(t,e){for(let s=0,o=Se.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function $t(t,e){e.score=t.score}class G{constructor(e,s={},o){if(this.options={...v,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Pt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof he))throw new Error("Incorrect 'index' type");this._myIndex=s||Ue(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;m.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)*(h?1:p))}),m.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),$e(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:m=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return m&&g.push(Wt),u&&g.push($t),d.map(p=>{const{idx:x}=p,j={item:h[x],refIndex:x};return g.length&&g.forEach(M=>{M(p,j)}),j})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=_e(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=_e(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}G.version="7.0.0",G.createIndex=Ue,G.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new he({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},G.config=v;function Kt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(ze,{children:s.map(r=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Gt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Ut({data:t}){const[e,s]=f.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=f.useState(!t.file_hash),[i,a]=f.useState();f.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h;const d=await P.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),!(d!=null&&d.imageUrl)&&t.file_hash!=null)try{const m=await le(t.file_hash),u=m.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:m.modelName??null,civitModelID:m.civitModelID,civitModelVersionID:m.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Gt[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(W,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(Oe,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{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(D,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Ht({list:t}){return n.jsx(Mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Be,{children:n.jsx(Ut,{data:e})},e.model_name+e.date.getTime()))})}function Vt(){const{setRoute:t}=f.useContext(Ee);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const qt=()=>{const[t,e]=f.useState(["checkpoints"]),[s,o]=f.useState([]),[r,i]=f.useState(!0);f.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await lt();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(m=>m.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(m=>({...m,date:new Date(m.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Yt(){const[t,e]=f.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};f.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=H)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),r(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},r=async()=>{const a=await P.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;P.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(St,{isChecked:t,onChange:o,children:"Show NSFW"})}function Qt(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),U.graph.add(i)};return f.useEffect(()=>(U.canvasEl.addEventListener("drop",t),()=>{U.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=f.useState("checkpoints"),[o,r]=f.useState(""),[i,a]=f.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=qt(),[h,m]=f.useState([]),[u,g]=f.useState([]);f.useEffect(()=>{x();async function x(){const j=await P.models.toArray();m(d.map(M=>({...M,db:j.find(b=>b.id===M.model_name+"@"+M.model_type)})))}},[d]),f.useEffect(()=>{let x=[];o.length?x=new G(h,{keys:["model_name","db.modelName"]}).search(o).map(b=>b.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>i==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,i,h]),f.useEffect(()=>(U.canvasEl.addEventListener("click",t),()=>{U.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Qe,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ae,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ct,overflowY:"auto",children:[n.jsxs(W,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Vt,{})]}),n.jsx(W,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(W,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs($,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(Z,{value:i,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(Yt,{})]}),!o.length&&n.jsx(Kt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Ht,{list:u}),c&&n.jsx(W,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(ae,{})})]}),n.jsx(Qt,{})]})})}const Xt=async t=>{try{const s=await(await ce.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 Ce(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function be(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None"||o.nsfwLevel===1);return e&&(s=s??t[0]),s}function Zt(t,e=280,s){var o,r,i,a;if(t){if(t.images)return`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(o=be(t.images,s))==null?void 0:o.url}/width=${e}/`;if(De(t))return(a=be((i=(r=t.modelVersions)==null?void 0:r.at(0))==null?void 0:i.images,s))==null?void 0:a.url}}const ne=280;function es({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=f.useState();f.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));r(Zt(t,ne,x))}},[t]);const i=De(t)?t.modelVersions:t.versions,[a,c]=f.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=f.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),m=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Ae,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Oe,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(q,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(W,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(A,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(A,{leftIcon:n.jsx(dt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs($,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.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})}),m&&n.jsx(ie,{label:Ce(m),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:Ce(m)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(W,{gap:1,alignItems:"center",grow:1,children:[n.jsx(X,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(A,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function ss({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=f.useState(""),[a,c]=f.useState([]),[l,d]=f.useState(""),h=f.useRef(null);f.useEffect(()=>{m()},[]);const m=async()=>{const u=await Te();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(Je,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(ke,{children:n.jsxs(Xe,{children:[n.jsx(Ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Le,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(X,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(D,{children:"Choose model install folder"}),n.jsx(Z,{placeholder:"Select option",value:r,onChange:u=>i(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Ze,{children:[n.jsx(A,{ref:h,onClick:s,children:"Cancel"}),n.jsx(A,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=et(),e=Fe(),[s,o]=f.useState([]);return f.useEffect(()=>{ye.addEventListener("download_progress",r=>{o(r.detail)}),ye.addEventListener("download_error",r=>{e({title:"Download Error",description:r.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(q,{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:r,progress:i})=>n.jsxs($,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(We,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ht(r),children:"Cancel"})]},r))})}function os(){const[t,e]=f.useState(""),{onOpen:s,onClose:o,isOpen:r}=Pe(),i=()=>{vt(t),o()};return n.jsxs(ut,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(mt,{children:n.jsx(A,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(ft,{p:5,children:[n.jsx(Re,{}),n.jsx(pt,{}),n.jsxs(q,{spacing:4,children:[n.jsx(D,{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(X,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function is(t,e){var l;const s={limit:"30",types:t};e&&(s.query=e);const r=`https://civitai.com/api/v1/models?${new URLSearchParams(s).toString()}`,i=await((l=P.cache)==null?void 0:l.get(r));if((i==null?void 0:i.value)!=null)try{const{data:d,timestamp:h}=JSON.parse(i==null?void 0:i.value);if((Date.now()-h)/(1e3*60*60*24){var _;a(!0);const y=await is(c,u);r(y);const w=await Te();w&&Y(w);const S=await((_=H)==null?void 0:_.getSetting("defaultFolders"));S&&C(S),a(!1)},[u,c]),L=(y,w)=>{var me,fe,pe,ge;if(!((me=k.current)!=null&&me.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(fe=k.current)==null?void 0:fe.id}`,_=(pe=k.current)==null?void 0:pe.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&m(He=>[...He,_??""]);const ue=jt();ue&&(S+=`?token=${ue}`),Xt({file_hash:(ge=k.current)==null?void 0:ge.SHA256,filename:_,save_path:y,url:S}),b(void 0),j()},z=async(y,w)=>{const S=T[w.type];b(y),S==null?x():L(S)},E=async(y,w)=>{var _;const S={...T,[y]:w};await((_=H)==null?void 0:_.upsert({defaultFolders:S})),C(S)};return f.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(tt,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(ke,{}),n.jsxs(st,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ie,{pb:1,children:[n.jsxs($,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(ts,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(os,{})]}),n.jsxs($,{gap:2,wrap:"wrap",children:[n.jsx(A,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),yt.map(y=>n.jsx(A,{size:"sm",py:1,isActive:c===y,onClick:()=>{l(y)},children:y},y)),c&&O[ee[c]]&&n.jsxs($,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:T[c],onChange:y=>E(c,y.target.value),children:O[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),i&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(nt,{}),n.jsxs(Le,{overflowY:"auto",children:[n.jsx($,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:z,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:p,onClose:j,selectFolder:(y,w)=>{L(y,k.current?void 0:w)}})]})}function fs(){const{setRoute:t,route:e}=f.useContext(Ee);return f.useEffect(()=>{ce.addEventListener("model_list",async s=>{var i;const o=(i=s.detail)==null?void 0:i.map(async a=>{const c=await P.models.get(a.model_name+"@"+a.model_type);if(c!=null&&c.fileHash)return c;let l={id:a.model_name+"@"+a.model_type,modelName:null,fileHash:a.file_hash??null,fileFolder:a.model_type,fileName:a.model_name+a.model_extension};if(!a.file_hash)return l;const d=await le(a.file_hash);return l={...l,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},l}),r=(await Promise.all(o)).filter(a=>a!=null);await P.models.clear(),await P.models.bulkPut(r.filter(a=>a!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))})},[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(A,{size:"sm",backgroundColor:"#434554",color:"white",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:wt+"px",children:"Models"}),e==="modelList"&&n.jsx(Jt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(rs,{modelType:"Checkpoint",onclose:()=>t("root")})]})}export{fs as default}; +import{f as V,r as f,j as n,g as B,e as re,$ as J,b as Ve,o as qe,k as Ye,h as A,a0 as ae,P as Qe,a1 as Je,T as ke,a2 as Xe,U as Ie,O as Le,R as Ze,Z as et,M as tt,N as st,Q as nt}from"./input.js";import{ak as ot,m as it,al as rt,am as at,an as P,B as oe,F as W,T as D,g as ie,W as Ee,ao as lt,h as H,a5 as U,a6 as Ae,a7 as ct,ae as Ne,I as X,H as $,ap as De,aq as xe,f as q,v as dt,ar as Te,e as Fe,as as ye,at as ht,au as Pe,av as ut,aw as mt,ax as ft,ay as pt,az as gt,aA as xt,aB as ee,aC as yt,aD as wt}from"./App-9GIQJeUY.js";import{f as le,s as vt,g as jt}from"./civitUtils-TPBejtrP.js";import{I as Oe}from"./chunk-7D6N5TE5-gOmt0HWF.js";import{G as Mt,C as St}from"./chunk-JARCRF6W-1gGfj837.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-WBOq6SL0.js";var ze=V(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:m,...u}=e,g=f.useMemo(()=>m?f.Children.map(a,(p,x)=>n.jsx(de,{children:p},x)):a,[a,m]);return n.jsx(B.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(B.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});ze.displayName="Wrap";var de=V(function(e,s){const{className:o,...r}=e;return n.jsx(B.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...r})});de.displayName="WrapItem";function we(t){return it(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Be=V(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,m=ot({gridArea:o,gridColumn:we(r),gridRow:we(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(B.div,{ref:s,__css:m,...h})});Be.displayName="GridItem";var te=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Re(t){var e;const{bg:s,bgColor:o,backgroundColor:r,shadow:i,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=rt(),h=at(),m=(e=s??o)!=null?e:r,u=i??a;return n.jsx(B.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(B.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",m),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}Re.displayName="PopoverArrow";function _t(t,e,s){return(t-e)*100/(s-e)}J({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});J({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var Ct=J({"0%":{left:"-40%"},"100%":{left:"100%"}}),bt=J({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function kt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=_t(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 i=="function"?i(e,l):r})(),role:c},percent:l,value:e}}var[It,Lt]=Ve({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Et=V((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=kt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Lt().filledTrack};return n.jsx(B.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),We=V((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=qe(t),M=Ye("Progress",t),b=d??((s=M.track)==null?void 0:s.borderRadius),k={animation:`${bt} 1s linear infinite`},T={...!h&&a&&c&&k,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Ct} 1s ease infinite normal none running`}},C={overflow:"hidden",position:"relative",...M.track};return n.jsx(B.div,{ref:e,borderRadius:b,__css:C,...j,children:n.jsxs(It,{value:M,children:[n.jsx(Et,{"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:T,borderRadius:b,title:p,role:x}),l]})})});We.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Ke(t)==="[object Array]"}const At=1/0;function Nt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-At?"-0":s}(t)}function F(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function Dt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ke(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Ke(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Tt=t=>`Missing ${t} property in key`,Ft=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class Pt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Ge(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.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 Ge(t){let e=null,s=null,o=null,r=1,i=null;if(F(t)||K(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Tt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(Ft(a));e=je(a),s=Me(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function je(t){return K(t)?t:t.split(".")}function Me(t){return K(t)?t.join("."):t}var v={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(F(l)||$e(l)||Dt(l)))s.push(Nt(l));else if(K(l)){o=!0;for(let d=0,h=l.length;d{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=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(F(h)&&!se(h)){let m={v:h,i:d,n:this.norm.get(h)};c.push(m)}else K(h)&&h.forEach((m,u)=>{l.push({nestedArrIndex:u,value:m})})}o.$[i]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ue(t,e,{getFn:s=v.getFn,fieldNormWeight:o=v.fieldNormWeight}={}){const r=new he({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Ge)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=v.distance,ignoreLocation:i=v.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function zt(t,e,s,{location:o=v.location,distance:r=v.distance,threshold:i=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,m=t.length,u=Math.max(0,Math.min(o,m));let g=i,p=u;const x=c>1||l,j=x?Array(m):[];let M;for(;(M=t.indexOf(e,p))>-1;){let C=Q(e,{currentLocation:M,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(C,g),p=M+h,x){let I=0;for(;I=z;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(j[S]=+!!_),y[w]=(y[w+1]<<1|1)&_,C&&(y[w]|=(b[w+1]|b[w])<<1|1|b[w+1]),y[w]&Y&&(k=Q(e,{errors:C,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),k<=g)){if(g=k,p=S,p<=u)break;z=Math.max(1,2*u-p)}}if(Q(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;b=y}const T={isMatch:p>=0,score:Math.max(.001,k)};if(x){const C=function(I=[],L=v.minMatchCharLength){let z=[],E=-1,y=-1,w=0;for(let S=I.length;w=L&&z.push([E,y]),E=-1)}return I[w-1]&&w-E>=L&&z.push([E,w-1]),z}(j,c);C.length?l&&(T.indices=C):T.isMatch=!1}return T}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},m=this.pattern.length;if(m>R){let u=0;const g=m%R,p=m-g;for(;u{const{isMatch:M,score:b,indices:k}=zt(e,p,x,{location:r+j,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),m+=b,M&&k&&(h=[...h,...k])});let g={isMatch:u,score:u?m/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const Se=[];function _e(t,e){for(let s=0,o=Se.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function $t(t,e){e.score=t.score}class G{constructor(e,s={},o){if(this.options={...v,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Pt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof he))throw new Error("Incorrect 'index' type");this._myIndex=s||Ue(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;m.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)*(h?1:p))}),m.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),$e(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:m=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return m&&g.push(Wt),u&&g.push($t),d.map(p=>{const{idx:x}=p,j={item:h[x],refIndex:x};return g.length&&g.forEach(M=>{M(p,j)}),j})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=_e(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=_e(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}G.version="7.0.0",G.createIndex=Ue,G.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new he({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},G.config=v;function Kt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(ze,{children:s.map(r=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Gt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Ut({data:t}){const[e,s]=f.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=f.useState(!t.file_hash),[i,a]=f.useState();f.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h;const d=await P.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),!(d!=null&&d.imageUrl)&&t.file_hash!=null)try{const m=await le(t.file_hash),u=m.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:m.modelName??null,civitModelID:m.civitModelID,civitModelVersionID:m.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Gt[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(W,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(Oe,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{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(D,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Ht({list:t}){return n.jsx(Mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Be,{children:n.jsx(Ut,{data:e})},e.model_name+e.date.getTime()))})}function Vt(){const{setRoute:t}=f.useContext(Ee);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const qt=()=>{const[t,e]=f.useState(["checkpoints"]),[s,o]=f.useState([]),[r,i]=f.useState(!0);f.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await lt();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(m=>m.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(m=>({...m,date:new Date(m.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Yt(){const[t,e]=f.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};f.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=H)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),r(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},r=async()=>{const a=await P.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;P.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(St,{isChecked:t,onChange:o,children:"Show NSFW"})}function Qt(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),U.graph.add(i)};return f.useEffect(()=>(U.canvasEl.addEventListener("drop",t),()=>{U.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=f.useState("checkpoints"),[o,r]=f.useState(""),[i,a]=f.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=qt(),[h,m]=f.useState([]),[u,g]=f.useState([]);f.useEffect(()=>{x();async function x(){const j=await P.models.toArray();m(d.map(M=>({...M,db:j.find(b=>b.id===M.model_name+"@"+M.model_type)})))}},[d]),f.useEffect(()=>{let x=[];o.length?x=new G(h,{keys:["model_name","db.modelName"]}).search(o).map(b=>b.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>i==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,i,h]),f.useEffect(()=>(U.canvasEl.addEventListener("click",t),()=>{U.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Qe,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ae,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ct,overflowY:"auto",children:[n.jsxs(W,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Vt,{})]}),n.jsx(W,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(W,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs($,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(Z,{value:i,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(Yt,{})]}),!o.length&&n.jsx(Kt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Ht,{list:u}),c&&n.jsx(W,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(ae,{})})]}),n.jsx(Qt,{})]})})}const Xt=async t=>{try{const s=await(await ce.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 Ce(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function be(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None"||o.nsfwLevel===1);return e&&(s=s??t[0]),s}function Zt(t,e=280,s){var o,r,i,a;if(t){if(t.images)return`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(o=be(t.images,s))==null?void 0:o.url}/width=${e}/`;if(De(t))return(a=be((i=(r=t.modelVersions)==null?void 0:r.at(0))==null?void 0:i.images,s))==null?void 0:a.url}}const ne=280;function es({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=f.useState();f.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));r(Zt(t,ne,x))}},[t]);const i=De(t)?t.modelVersions:t.versions,[a,c]=f.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=f.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),m=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Ae,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Oe,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(q,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(W,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(A,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(A,{leftIcon:n.jsx(dt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs($,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.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})}),m&&n.jsx(ie,{label:Ce(m),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:Ce(m)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(W,{gap:1,alignItems:"center",grow:1,children:[n.jsx(X,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(A,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function ss({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=f.useState(""),[a,c]=f.useState([]),[l,d]=f.useState(""),h=f.useRef(null);f.useEffect(()=>{m()},[]);const m=async()=>{const u=await Te();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(Je,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(ke,{children:n.jsxs(Xe,{children:[n.jsx(Ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Le,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(X,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(D,{children:"Choose model install folder"}),n.jsx(Z,{placeholder:"Select option",value:r,onChange:u=>i(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Ze,{children:[n.jsx(A,{ref:h,onClick:s,children:"Cancel"}),n.jsx(A,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=et(),e=Fe(),[s,o]=f.useState([]);return f.useEffect(()=>{ye.addEventListener("download_progress",r=>{o(r.detail)}),ye.addEventListener("download_error",r=>{e({title:"Download Error",description:r.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(q,{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:r,progress:i})=>n.jsxs($,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(We,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ht(r),children:"Cancel"})]},r))})}function os(){const[t,e]=f.useState(""),{onOpen:s,onClose:o,isOpen:r}=Pe(),i=()=>{vt(t),o()};return n.jsxs(ut,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(mt,{children:n.jsx(A,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(ft,{p:5,children:[n.jsx(Re,{}),n.jsx(pt,{}),n.jsxs(q,{spacing:4,children:[n.jsx(D,{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(X,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function is(t,e){var l;const s={limit:"30",types:t};e&&(s.query=e);const r=`https://civitai.com/api/v1/models?${new URLSearchParams(s).toString()}`,i=await((l=P.cache)==null?void 0:l.get(r));if((i==null?void 0:i.value)!=null)try{const{data:d,timestamp:h}=JSON.parse(i==null?void 0:i.value);if((Date.now()-h)/(1e3*60*60*24){var _;a(!0);const y=await is(c,u);r(y);const w=await Te();w&&Y(w);const S=await((_=H)==null?void 0:_.getSetting("defaultFolders"));S&&C(S),a(!1)},[u,c]),L=(y,w)=>{var me,fe,pe,ge;if(!((me=k.current)!=null&&me.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(fe=k.current)==null?void 0:fe.id}`,_=(pe=k.current)==null?void 0:pe.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&m(He=>[...He,_??""]);const ue=jt();ue&&(S+=`?token=${ue}`),Xt({file_hash:(ge=k.current)==null?void 0:ge.SHA256,filename:_,save_path:y,url:S}),b(void 0),j()},z=async(y,w)=>{const S=T[w.type];b(y),S==null?x():L(S)},E=async(y,w)=>{var _;const S={...T,[y]:w};await((_=H)==null?void 0:_.upsert({defaultFolders:S})),C(S)};return f.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(tt,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(ke,{}),n.jsxs(st,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ie,{pb:1,children:[n.jsxs($,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(ts,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(os,{})]}),n.jsxs($,{gap:2,wrap:"wrap",children:[n.jsx(A,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),yt.map(y=>n.jsx(A,{size:"sm",py:1,isActive:c===y,onClick:()=>{l(y)},children:y},y)),c&&O[ee[c]]&&n.jsxs($,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:T[c],onChange:y=>E(c,y.target.value),children:O[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),i&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(nt,{}),n.jsxs(Le,{overflowY:"auto",children:[n.jsx($,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:z,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:p,onClose:j,selectFolder:(y,w)=>{L(y,k.current?void 0:w)}})]})}function fs(){const{setRoute:t,route:e}=f.useContext(Ee);return f.useEffect(()=>{ce.addEventListener("model_list",async s=>{var i;const o=(i=s.detail)==null?void 0:i.map(async a=>{const c=await P.models.get(a.model_name+"@"+a.model_type);if(c!=null&&c.fileHash)return c;let l={id:a.model_name+"@"+a.model_type,modelName:null,fileHash:a.file_hash??null,fileFolder:a.model_type,fileName:a.model_name+a.model_extension};if(!a.file_hash)return l;const d=await le(a.file_hash);return l={...l,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},l}),r=(await Promise.all(o)).filter(a=>a!=null);await P.models.clear(),await P.models.bulkPut(r.filter(a=>a!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))})},[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(A,{size:"sm",backgroundColor:"#434554",color:"white",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:wt+"px",children:"Models"}),e==="modelList"&&n.jsx(Jt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(rs,{modelType:"Checkpoint",onclose:()=>t("root")})]})}export{fs as default}; diff --git a/dist/workspace_web/RecentFilesDrawer-GvndxTNj.js b/dist/workspace_web/RecentFilesDrawer-GvndxTNj.js deleted file mode 100644 index b8fd654..0000000 --- a/dist/workspace_web/RecentFilesDrawer-GvndxTNj.js +++ /dev/null @@ -1,5 +0,0 @@ -import{f as J,E as Ze,j as e,Y as Ye,e as re,g as pe,r,V as ge,h as W,M as me,T as fe,N as xe,U as ye,Q as je,O as we,Z as ve,R as Xe}from"./input.js";import{m as Te,u as We,a as qe,b as Je,c as Qe,S as et,M as tt,d as T,e as Y,E as de,f as B,T as L,H as N,g as R,I as Q,h as C,R as G,i as st,j as be,B as _,F as U,k as nt,l as A,n as Ie,o as at,W as le,s as ot,p as it,q as ee,r as te,t as P,v as rt,D as Ne,w as O,x as Pe,y as lt,z as ke,A as ct,C as dt,G as Ae,J as $,K as ut,L as ht,N as pt,O as gt,P as mt,Q as ft,U as xt,V as De,X as Z,Y as he,Z as yt,_ as jt,$ as Re,a0 as wt,a1 as vt,a2 as kt,a3 as q,a4 as ie,a5 as St,a6 as Ct,a7 as bt,a8 as ue,a9 as It}from"./App-ZTJclgGW.js";import{G as Dt,C as se}from"./chunk-JARCRF6W-UTrQeKCZ.js";import{V as _e}from"./chunk-NTCQBYKE-vNLNCBtA.js";import{N as Ft,a as Mt,g as Et,I as Ot,M as zt,u as Lt,S as Tt}from"./MediaPreview-46fgYP_n.js";import{I as Wt}from"./IconCopy-zZpZ6D5h.js";import"./chunk-7D6N5TE5-wlKuxWhy.js";import"./IconSearch-hyGkJAd5.js";var Be=J(function(t,i){const{columns:l,spacingX:c,spacingY:n,spacing:d,minChildWidth:p,...s}=t,h=Ze(),u=p?Pt(p,h):At(l);return e.jsx(Dt,{ref:i,gap:d,columnGap:c,rowGap:n,templateColumns:u,...s})});Be.displayName="SimpleGrid";function Nt(o){return typeof o=="number"?`${o}px`:o}function Pt(o,t){return Te(o,i=>{const l=Ye("sizes",i,Nt(i))(t);return i===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function At(o){return Te(o,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ke=J((o,t)=>{const{title:i,children:l,className:c,...n}=o,d=re("chakra-menu__group__title",c),p=We();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[i&&e.jsx(pe.p,{className:d,...n,__css:p.groupTitle,children:i}),l]})});Ke.displayName="MenuGroup";var He=o=>{const{className:t,title:i,...l}=o,c=qe(l);return e.jsx(Ke,{title:i,className:re("chakra-menu__option-group",t),...c})};He.displayName="MenuOptionGroup";var Rt=J((o,t)=>{const i=We();return e.jsx(pe.button,{ref:t,...o,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...i.button}})}),ne=J((o,t)=>{const{children:i,as:l,...c}=o,n=Je(c,t),d=l||Rt;return e.jsx(d,{...n,className:re("chakra-menu__menu-button",o.className),children:e.jsx(pe.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:o.children})})});ne.displayName="MenuButton";var _t=o=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...o,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"})}),Se=J((o,t)=>{const{icon:i,iconSpacing:l="0.75rem",...c}=o,n=Qe(c,t);return e.jsxs(et,{...n,className:re("chakra-menu__menuitem-option",c.className),children:[i!==null&&e.jsx(tt,{fontSize:"0.8em",marginEnd:l,opacity:o.isChecked?1:0,children:i||e.jsx(_t,{})}),e.jsx("span",{style:{flex:1},children:n.children})]})});Se.id="MenuItemOption";Se.displayName="MenuItemOption";var Bt=T("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Kt=T("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"}]]),Ht=T("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"}]]),Fe=T("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"}]]),$t=T("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"}]]),$e=T("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=T("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=T("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=T("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"}]]),Zt=T("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"}]]),Yt=T("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"}]]),Ge=T("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Xt=T("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"}]]),qt=T("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"}]]),Jt=T("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 Qt(){const o=Y(),t=r.useRef([{title:"Save current workflow",key:de.SAVE},{title:"Save as current workflow",key:de.SAVE_AS},{title:"Open spotlight search",key:de.openSpotlightSearch}]),[i,l]=r.useState({save:"",saveAs:"",openSpotlightSearch:""}),[c,n]=r.useState(),d=async(s,h)=>{var g;s.preventDefault();let u="";if(s.ctrlKey&&(u+="Control+"),s.metaKey&&(u+="Command+"),s.shiftKey&&(u+="Shift+"),s.altKey&&(u+="Alt+"),u.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){u+=s.key.toUpperCase();const m={...i};delete m[h],Object.values(m).includes(u)?o({title:"Shortcut key conflict",description:`The shortcut key 「${u}」 is already used, please - modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=C)==null?void 0:g.upsert({shortcuts:{...i,[h]:u}})),p())}},p=()=>{var s;(s=C)==null||s.getSetting("shortcuts").then(h=>{var g;const u=h??((g=C)==null?void 0:g.defaultSettings.shortcuts);l({...i,...u})})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(N,{children:[e.jsx(L,{fontSize:"sm",w:170,children:s.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:c===s.key,children:e.jsx(Q,{value:i[s.key],onKeyDown:h=>{d(h,s.key)},onFocus:()=>{n(s.key)},onBlur:()=>{n(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function es(){const{setRefreshFolderStamp:o}=r.useContext(G),[t,i]=r.useState(!1),l=()=>{var n;(n=C)==null||n.getSetting("foldersOnTop").then(d=>{i(!!d)})},c=n=>{var p;const d=n.target.checked;(p=C)==null||p.upsert({foldersOnTop:d}).then(()=>{l(),o(Date.now())})};return r.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:t,onChange:c,children:"Folders always on top"})})}function ts(){const[o,t]=r.useState(!1),[i,l]=r.useState(""),{showDialog:c}=ge(),n=()=>{var p,s;(p=C)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(s=C)==null||s.getSetting("twoWaySync").then(h=>{t(h??!1)})};r.useEffect(()=>{n()},[]);const d=async p=>{var h,u;if(!p.target.checked){await((h=C)==null?void 0:h.upsert({twoWaySync:p.target.checked})),n();return}const s=await((u=C)==null?void 0:u.getSetting("myWorkflowsDir"));c(e.jsx(st,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=C)==null?void 0:g.upsert({twoWaySync:!0})),n()},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]"}),e.jsx(se,{isChecked:o,onChange:d,children:"Enable two way sync"})]})}function Me({settingKey:o,text:t,defaultChecked:i=!1}){const[l,c]=r.useState(i),n=Y(),d=()=>{var p;(p=C)==null||p.getSetting(o).then(s=>{c(!!s)})};return r.useEffect(()=>{d()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:l,onChange:async p=>{var s;await((s=C)==null?void 0:s.upsert({[o]:p.target.checked})),d(),n({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ss(){const[o,t]=r.useState(!1),[i,l]=r.useState(!1),[c,n]=r.useState([]),[d,p]=r.useState(""),[s,h]=r.useState([]),[u,g]=r.useState(!1),[m,a]=r.useState(!1),[f,v]=r.useState(!1),S=r.useRef(null),w=Y();ge();const b=f?"\\":"/";r.useEffect(()=>{var y;be().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=C)==null||y.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async y=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Ie(y??"");return V.includes("Operation not permitted")?(a(!0),z(),{isError:!0}):{dirList:E,dirPath:k}},j=async()=>{const{isError:y=!1,dirList:k=[]}=await F(d);y||(n(k),l(!0),h(d&&d.split(b).filter(E=>!!E)||[]))},z=()=>{l(!1),t(!1),h([])},K=async(y,k=!1,E=!1)=>{var x,I;if(k){const{path:D}=await be();D&&await at(D,y)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:y}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&a(!1),z()},H=async y=>{if(y){const{error:E=""}=await Ie(y);if(E.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?"":b}${s.join(b)}`;K(k,!1,!!y)},X=async()=>{const{dirPath:y,dirList:k}=await F("");h(y.split(b).filter(E=>!!E)),n(k)},ae=async(y,k)=>{var I;let E="";y===-1&&k?E=`${f?"":b}${s.concat([k]).join(b)}`:E=`${f?"":b}${s.slice(0,y+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(n(x),h(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},oe=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(Q,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(W,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var y,k;(y=S==null?void 0:S.current)!=null&&y.value&&H((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ce=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(_,{mb:4,children:[e.jsx(L,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),i?o?oe:e.jsxs(_e,{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&&b,e.jsx(W,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ae(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Be,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((y,k)=>e.jsx(W,{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:()=>{ae(-1,y)},children:y},`${y}-${k}`))}),e.jsxs(_,{w:"100%",textAlign:"end",children:[e.jsx(W,{colorScheme:"teal",size:"sm",onClick:()=>{H()},children:"Save"}),e.jsx(W,{size:"sm",onClick:X,mr:2,ml:2,children:"Reset"}),e.jsx(W,{size:"sm",onClick:z,children:"Cancel"})]})]}):e.jsxs(U,{children:[e.jsx(nt,{overflowWrap:"anywhere",children:d}),e.jsx(R,{label:u?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(A,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!u,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:j})}),e.jsx(R,{label:u?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(A,{isDisabled:!u,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx(Ht,{size:19}),onClick:ce,variant:"ghost"})})]})]}),e.jsxs(me,{isOpen:m,onClose:()=>a(!1),size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Kind tips"}),e.jsx(je,{}),e.jsx(we,{children:e.jsxs(_,{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(W,{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."}),oe]})})]})]})]})}function ns({label:o,settingKey:t}){const[i,l]=r.useState(200),c=Y(),n=s=>{if(!s.length){l(0);return}l(parseInt(s))},d=async()=>{var s;i<0&&l(0),await((s=C)==null?void 0:s.upsert({[t]:Number(i)})),c({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=C)==null||s.getSetting(t).then(h=>{l(h)})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:o}),e.jsx(Ft,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:i,onChange:s=>n(s),onBlur:()=>{d()},onKeyUp:s=>{s.key==="Enter"&&d()},children:e.jsx(Mt,{})})]})}function as(){const o=Y(),[t,i]=r.useState(""),l=()=>{var n;(n=C)==null||n.getSetting("cloudHost").then(d=>{i(d??"")})};r.useEffect(()=>{l()},[]);const c=async n=>{var d;n=n.trim(),n.endsWith("/")&&(n=n.slice(0,-1)),await((d=C)==null?void 0:d.upsert({cloudHost:n})),l(),o({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{children:[e.jsx(L,{children:"For enterprise paid user only. Hosting site of the shared workflow."}),e.jsxs(U,{gap:2,alignItems:"center",children:[e.jsx(Q,{value:t,onChange:n=>i(n.target.value),onBlur:()=>c(t),onKeyDown:n=>{n.key==="Enter"&&c(t)}}),e.jsx(W,{size:"sm",onClick:()=>{var d;const n=(d=C)==null?void 0:d.defaultSettings.cloudHost;i(n),c(n)},children:"Reset"})]})]})}function os(){var p,s,h,u,g,m;const o=Y(),{session:t,updateSession:i}=r.useContext(le),[l,c]=r.useState(""),n=new URL((s=(p=C)==null?void 0:p.settings)==null?void 0:s.cloudHost).hostname;r.useEffect(()=>{c((t==null?void 0:t.shareKey)??"")},[t]);const d=async a=>{ot(a),i({username:(t==null?void 0:t.username)??null,shareKey:a}),o({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{gap:3,children:[e.jsx("p",{style:{fontWeight:"bold"},children:"Cloud Backup [Beta]"}),e.jsxs("p",{children:[e.jsx("a",{href:((u=(h=C)==null?void 0:h.settings)==null?void 0:u.cloudHost)+"/auth/shareKey",target:"_blank",style:{textDecoration:"underline"},children:e.jsx(W,{size:"sm",children:"👉Copy your share key from here"})})," ","and paste it below to start saving workflow versions to cloud at"," ",e.jsx("a",{href:(m=(g=C)==null?void 0:g.settings)==null?void 0:m.cloudHost,target:"_blank",children:n})]}),e.jsx(U,{alignItems:"center",children:e.jsx(Q,{value:l,placeholder:"Paste your share key here",onChange:a=>c(a.target.value),onBlur:()=>d(l),onKeyDown:a=>{a.key==="Enter"&&d(l)}})})]})}function is({onClose:o}){return e.jsx(e.Fragment,{children:e.jsxs(me,{isOpen:!0,onClose:o,size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Settings"}),e.jsx(je,{}),e.jsx(we,{pb:14,children:e.jsx(N,{children:e.jsxs(_e,{divider:e.jsx(it,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ss,{}),e.jsx(Qt,{}),e.jsx(ts,{}),e.jsx(os,{}),e.jsx(es,{}),e.jsx(ns,{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(Me,{settingKey:"disableUnsavedWarning",text:'Disable the "Save or Discard" warning when closing a workflow with unsaved changes. ⛔️Be careful, if you disable this reminder and forget to save your workflow, you will lose your changes.'}),e.jsx(Me,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"}),e.jsx(as,{})]})})})]})]})})}const Ee=16;function rs({}){const[o,t]=r.useState(!1),{colorMode:i,toggleColorMode:l}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(ne,{as:A,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(P,{onClick:()=>t(!0),icon:e.jsx(Xt,{size:16}),fontSize:16,children:"Settings"}),e.jsxs(P,{onClick:l,icon:i==="light"?e.jsx(Zt,{size:Ee}):e.jsx(qt,{size:Ee}),fontSize:16,children:[i==="light"?"Dark":"Light"," Mode"]})]})]}),o&&e.jsx(is,{onClose:()=>t(!1)})]})}function ls(o){const{multipleState:t,changeMultipleState:i,selectedKeys:l,isSelectedAll:c,batchOperationCallback:n}=o,d=async()=>{var h;const s=await((h=O)==null?void 0:h.batchQuery(l))??[];lt(s)},p=l.length===0;return e.jsx(N,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(se,{isChecked:c,onChange:s=>{n("selectAll",s.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(A,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(rt,{size:21}),onClick:d})}),e.jsx(R,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Ne,{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=O)==null?void 0:s.batchDeleteFlow(l)),n("batchDelete")}})}),l.length>0&&e.jsx(L,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(R,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(A,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{i(!1)}})})]}):e.jsx(R,{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:()=>{i(!0)}})})})}const Oe=6;function cs({setSelectedTag:o,selectedTag:t}){const[i,l]=r.useState(!1),[c,n]=r.useState([]);return r.useEffect(()=>{var d;(d=ct)==null||d.listAll().then(p=>{n(p)})},[]),e.jsxs(N,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(A,{"aria-label":"Close",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{o(void 0)}}),c.slice(0,i?void 0:Oe).map(d=>e.jsx(W,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{o(d.name)},isActive:t===d.name,children:d.name},d.name)),(c.length??0)>Oe&&e.jsx(A,{"aria-label":"Show-all-tags",size:"sm",icon:i?e.jsx(Bt,{}):e.jsx(ke,{}),onClick:()=>l(!i)})]})}function Ve({parentFolderID:o,onlyImportFile:t=!1}){const{onRefreshFilesList:i}=r.useContext(G),[l,c]=r.useState("file"),n=r.useRef(null),d=u=>{var g;c(u),u==="folder"?n.current.setAttribute("webkitdirectory",""):n.current.removeAttribute("webkitdirectory"),(g=n.current)==null||g.click()},p=async u=>{var g;if(u.type==="image/png"){const m=await Et(u),a=m==null?void 0:m.workflow;if(a)return{json:a,name:u.name.replace(".png","")}}else if(u.type==="application/json"||(g=u.name)!=null&&g.endsWith(".json"))return await new Promise((m,a)=>{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:u.name.replace(".json","")}):a(new Error("File content is not a string"))}catch(w){a(w)}},f.onerror=a,f.readAsText(u)});return null},s=async u=>{var m,a;const g=[u];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=$)==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((a=O)==null?void 0:a.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}i==null||i()},h=async u=>{var m;const g=u.target.files;if(g)if(l==="folder"){const a={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=a.children??[];for(let w=1;wj.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const j=await p(f);j&&(F.file=j)}S.push(F)}F&&!F.isFile&&(S=F.children)}}s(a)}else{const a=[];for(const f of g){const v=await p(f);v&&a.push(v)}a.length&&(await((m=O)==null?void 0:m.batchCreateFlows(a,void 0,o)),i&&i())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(P,{onClick:u=>{u.stopPropagation(),d("file")},icon:e.jsx(Fe,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,leftIcon:e.jsx(Fe,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:dt.map((u,g)=>e.jsx(P,{onClick:()=>{d(u.type)},iconSpacing:2,icon:u.type==="folder"?e.jsx(Ae,{size:18}):e.jsx($t,{size:18}),children:u.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:n,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:u=>{u.stopPropagation()}})]})}function ds({folder:o,onclose:t}){const[i,l]=r.useState(o.name),[c,n]=r.useState(""),{onRefreshFilesList:d}=r.useContext(G),p=h=>{l(h.target.value),c&&n("")},s=async()=>{var g,m;const h=i.trim();if(l(h),h===o.name)return t();await((g=$)==null?void 0:g.generateUniqueName(h,o.parentFolderID??""))!==h?n("The name is duplicated, please modify it and submit again."):(await((m=$)==null?void 0:m.update(o.id,{name:h})),d&&d(),t())};return e.jsxs(me,{isOpen:!0,onClose:t,children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Edit folder name"}),e.jsx(je,{}),e.jsx(we,{children:e.jsxs(ut,{isInvalid:!!c,children:[e.jsx(ht,{children:"Folder name"}),e.jsx(Q,{value:i,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!c&&i&&s()}}),c&&e.jsx(pt,{children:c})]})}),e.jsxs(Xe,{children:[e.jsx(W,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!i||!!c,children:"Save"}),e.jsx(W,{onClick:t,children:"Cancel"})]})]})]})}function us({menuPosition:o,isopen:t,folder:i,onClose:l}){const[c,n]=r.useState(!1),{onRefreshFilesList:d}=r.useContext(G),{showDialog:p}=ge(),s=async m=>{var a;m.stopPropagation(),await((a=$)==null?void 0:a.create({name:"New Folder",parentFolderID:i.id})),d&&d()},h=async m=>{var a;m.stopPropagation(),await((a=O)==null?void 0:a.createFlow({json:JSON.stringify(mt),parentFolderID:i.id})),d&&d()},u=async m=>{m.stopPropagation();const a=await ft(i.id);p(`Do you want to delete the ${a} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(xt.DELETE)}}])},g=async m=>{var a;await((a=$)==null?void 0:a.deleteFolder(i.id,m)),l(),d&&d()};return e.jsxs(e.Fragment,{children:[e.jsx(_,{position:"absolute",top:o.y,left:o.x,children:e.jsx(ee,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(te,{children:[e.jsx(P,{icon:e.jsx(Yt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),n(!0)},children:"Rename"}),e.jsx(P,{icon:e.jsx(gt,{size:19}),onClick:u,children:"Delete"}),e.jsx(P,{onClick:s,icon:e.jsx($e,{size:19}),children:"New folder"}),e.jsx(P,{onClick:h,icon:e.jsx(Ge,{size:19}),children:"New file"}),e.jsx(Ve,{parentFolderID:i.id,onlyImportFile:!0})]})})}),c&&e.jsx(ds,{folder:i,onclose:()=>n(!1)})]})}const ze=r.memo(function({folder:t}){const[i,l]=r.useState(!1),[c,n]=r.useState(t.isCollapse??!0),[d,p]=r.useState([]),[s,h]=r.useState({x:0,y:0}),[u,g]=r.useState(!1),{colorMode:m}=ve(),{draggingFile:a,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=r.useContext(G),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};r.useEffect(()=>{var j;c||(j=O)==null||j.listFolderContent(t.id,window.localStorage.getItem(he)).then(z=>{p(z)})},[t.id,v,c]);const b=j=>{j.preventDefault(),h({x:j.clientX,y:j.clientY}),g(!0)},F=async j=>{var z,K;if(j.preventDefault(),j.stopPropagation(),!a)return l(!1);if(Z(a)){if(a.id===t.id)return l(!1);await((z=$)==null?void 0:z.update(a.id,{parentFolderID:t.id}))}else Z(a)||await((K=O)==null?void 0:K.updateFolder(a.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return r.useEffect(()=>{var j;!!t.isCollapse!==c&&((j=$)==null||j.update(t.id,{isCollapse:c}))},[c]),r.useEffect(()=>{var X;const j=(X=O)==null?void 0:X.curWorkflow,z=(j==null?void 0:j.parentFolderID)+De(),K=t.id+De();z.startsWith(K)&&n(!1)},[]),e.jsxs(B,{children:[e.jsxs(N,{w:"100%",as:"button",py:1,onClick:()=>{n(!c)},onContextMenu:b,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:F,_hover:w,style:i||u?w:void 0,className:"droppable",children:[e.jsxs(N,{gap:1,children:[c?e.jsx(Ot,{size:20}):e.jsx(ke,{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(us,{isopen:u,menuPosition:s,onClose:()=>g(!1),folder:t}),!c&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Ue,{items:d})})]})});function hs({workflow:o}){const t=r.useRef(null),i=Y(),{onDuplicateWorkflow:l}=r.useContext(le),[c,n]=r.useState(o.saveLock??!1),d=async()=>{var h;const s=!c;n(s),await((h=O)==null?void 0:h.updateMetaInfo(o.id,{saveLock:s})),i({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const h=s.target.files;if(!h)return;const u=new FormData;Array.from(h).forEach((g,m)=>{u.append(`images[${m}]`,g,g.name)}),u.append("subfolder","workspace_manager"),await wt("/workspace/images/save",{method:"POST",body:u}),Array.from(h).forEach(async g=>{var a,f;const m=`workspace_manager/${g.name}`;(a=vt)==null||a.create({workflowID:o.id,localPath:m}),(f=O)==null||f.updateMetaInfo(o.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(ne,{border:0,as:A,"aria-label":"Options",icon:e.jsx(Kt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(P,{icon:e.jsx(Wt,{}),onClick:()=>l&&l(o.id),children:"Duplicate"}),e.jsx(P,{icon:e.jsx(yt,{size:20}),onClick:()=>jt(o.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:c?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(P,{icon:c?e.jsx(Re,{}):e.jsx(Vt,{}),onClick:d,children:c?"Unlock":"Lock"})}),e.jsx(P,{icon:e.jsx(Jt,{}),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 ps({workflow:o}){const{onDeleteFlow:t}=r.useContext(G);return e.jsxs(U,{justifyContent:"flex-end",children:[e.jsx(Ne,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(o.id)}}),e.jsx(hs,{workflow:o})]})}const Le=r.memo(function({workflow:t}){var v,S,w,b;const{colorMode:i}=ve(),{setDraggingFile:l,isMultiSelecting:c,onMultiSelectFlow:n,multiSelectedFlowsID:d}=r.useContext(G),p=d&&d.length>0&&d.includes(t.id),{curFlowID:s,loadWorkflowID:h}=r.useContext(le),u=s===t.id,g=i==="light"?"gray.200":"#4A5568",[m,a]=r.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:u?"teal.200":void 0,color:u&&!c?"#333":void 0,draggable:!c,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!c&&h(t.id)},_hover:{bg:g},children:e.jsxs(N,{flexGrow:1,children:[!((S=(v=C)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((b=t.latestImage)==null?void 0:b.length))&&e.jsx(zt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(_,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(U,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx(Re,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(N,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:i=="dark"?"gray.700":"gray.200",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:c?e.jsx(se,{isChecked:p,spacing:4,onChange:F=>{n&&n(t.id,F.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx(_,{width:"fit-content",children:m?e.jsx(ps,{workflow:t}):e.jsx(L,{color:"GrayText",fontSize:"sm",children:kt(t.updateTime,!1,!1,"/")})})]})})});function Ue({items:o}){var m;const[t,i]=r.useState(!1),l=o.filter(Z),c=o.filter(a=>!Z(a)),n=(m=c[0])==null?void 0:m.parentFolderID,[d,p]=r.useState(!1),{onRefreshFilesList:s,draggingFile:h,refreshFolderStamp:u}=r.useContext(G),g=async a=>{var f,v;if(a.preventDefault(),a.stopPropagation(),!h)return p(!1);if(Z(h)){if(h.id===n)return p(!1);await((f=$)==null?void 0:f.update(h.id,{parentFolderID:n}))}else await((v=O)==null?void 0:v.updateFolder(h.id,{parentFolderID:n}));await(s==null?void 0:s()),p(!1)};return r.useEffect(()=>{var a;(a=C)==null||a.getSetting("foldersOnTop").then(f=>{i(f??!1)})},[u]),e.jsxs(e.Fragment,{children:[t&&l.map(a=>e.jsx(ze,{folder:a},a.id)),e.jsx(_,{border:d?"2px dashed #718096":"2px dashed transparent",onDragOver:a=>{a.preventDefault(),a.stopPropagation(),p(!0)},onDragLeave:a=>{a.preventDefault(),a.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?c.map(a=>e.jsx(Le,{workflow:a},a.id)):o.map(a=>Z(a)?e.jsx(ze,{folder:a},a.id):e.jsx(Le,{workflow:a},a.id))})]})}function ks({onClose:o,onClickNewFlow:t}){const[i,l]=r.useState([]),c=r.useRef([]),{loadWorkflowID:n,curFlowID:d}=r.useContext(le),[p,s]=r.useState(),[h,u]=r.useState(!1),[g,m]=r.useState([]),[a,f]=r.useState(0),[v,S]=r.useState(""),w=Lt(v,400),b=r.useRef(null),[F,j]=r.useState(null),z=r.useRef(window.localStorage.getItem(he)??q.RECENTLY_MODIFIED),K=!!p||!!w.length,H=async()=>{var I,D;const x=await((I=O)==null?void 0:I.listFolderContent())??[];l(ue(x,z.current)),f(Date.now()),c.current=await((D=O)==null?void 0:D.listAll())??[]},X=()=>{const x=c.current.filter(I=>{var Ce;let D=!0,M=!0;return p&&(D=!!((Ce=I.tags)!=null&&Ce.includes(p))),w&&(M=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),D&&M});l(ue(x,z.current))},ae=x=>{l(ue(i,x)),z.current=x,window.localStorage.setItem(he,x),!K&&f(Date.now())};r.useEffect(()=>{K?X():H()},[w,p]);const oe=r.useCallback(async x=>{var I,D,M;await((I=O)==null?void 0:I.deleteFlow(x)),((M=(D=O)==null?void 0:D.curWorkflow)==null?void 0:M.id)===x&&await(n==null?void 0:n(null)),await H()},[p,w]);r.useEffect(()=>{const x=async I=>{var D;if(b.current){const M=await((D=O)==null?void 0:D.get(b.current));M&&M.json&&It(M.json,[I.canvasX,I.canvasY])}};return ie.canvasEl.addEventListener("drop",x),ie.canvasEl.addEventListener("click",o),()=>{ie.canvasEl.removeEventListener("drop",x),ie.canvasEl.removeEventListener("click",o)}},[]);const ce=r.useCallback((x,I)=>{m(D=>{const M=[...D];return I?M.push(x):M.splice(M.indexOf(x),1),M})},[]),y=(x,I)=>{var D;switch(x){case"batchDelete":d&&((D=O)==null||D.get(d).then(M=>{M||n==null||n(null)})),H(),u(!1),m([]);return;case"selectAll":m(I?c.current.map(M=>M.id):[]);return}},k=x=>{j(x),Z(x)||(b.current=x.id)},E=x=>{S(x)},V=450;return e.jsx(G.Provider,{value:{onRefreshFilesList:H,draggingFile:F??void 0,setDraggingFile:k,isMultiSelecting:h,onMultiSelectFlow:ce,multiSelectedFlowsID:g,onDeleteFlow:oe,refreshFolderStamp:a,setRefreshFolderStamp:f},children:e.jsx(_,{style:{width:V},children:e.jsxs(St,{width:V,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Ct,children:[e.jsxs(U,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(N,{gap:4,children:[e.jsx(N,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ve,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(A,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(Ae,{}),variant:"outline",colorScheme:"teal",onClick:()=>bt()})}),e.jsx(R,{label:"New workflow",children:e.jsx(A,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Ge,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(N,{alignItems:"center",children:e.jsx(rs,{})})]}),e.jsxs(U,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(cs,{selectedTag:p,setSelectedTag:s}),e.jsxs(N,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(N,{children:[e.jsx(ls,{multipleState:h,changeMultipleState:x=>{u(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===c.current.length,batchOperationCallback:y}),!h&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(A,{size:"sm",variant:"outline",icon:e.jsx($e,{size:21}),onClick:async()=>{var x;await((x=$)==null?void 0:x.create({name:"New Folder"})),H()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(ke,{size:"16"}),children:e.jsxs(N,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:z.current})]})}),e.jsx(te,{children:e.jsx(He,{value:z.current,type:"radio",onChange:x=>ae(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,I)=>e.jsx(Se,{value:x,children:x},I))})})]})]}),e.jsx(Tt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(U,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(Ue,{items:i})})]})]})})})}export{ks as default}; diff --git a/dist/workspace_web/RecentFilesDrawer-efSIwVKr.js b/dist/workspace_web/RecentFilesDrawer-efSIwVKr.js new file mode 100644 index 0000000..09e4c23 --- /dev/null +++ b/dist/workspace_web/RecentFilesDrawer-efSIwVKr.js @@ -0,0 +1,5 @@ +import{f as J,E as Ze,j as e,Y as Ye,e as re,g as pe,r,V as ge,h as W,M as me,T as fe,N as xe,U as ye,Q as je,O as we,Z as ve,R as Xe}from"./input.js";import{m as Te,u as We,a as qe,b as Je,c as Qe,S as et,M as tt,d as T,e as Y,E as de,f as B,T as z,H as N,g as R,I as Q,h as C,R as G,i as st,j as be,B as _,F as U,k as nt,l as A,n as Ie,o as at,W as le,s as ot,p as it,q as ee,r as te,t as P,v as rt,D as Ne,w as O,x as Pe,y as lt,z as ke,A as ct,C as dt,G as Ae,J as $,K as ut,L as ht,N as pt,O as gt,P as mt,Q as ft,U as xt,V as De,X as Z,Y as he,Z as yt,_ as jt,$ as Re,a0 as wt,a1 as vt,a2 as kt,a3 as St,a4 as q,a5 as ie,a6 as Ct,a7 as bt,a8 as It,a9 as ue,aa as Dt}from"./App-9GIQJeUY.js";import{G as Ft,C as se}from"./chunk-JARCRF6W-1gGfj837.js";import{V as _e}from"./chunk-NTCQBYKE-ROuYoItA.js";import{N as Mt,a as Et,g as Ot,I as Lt,M as zt,u as Tt,S as Wt}from"./MediaPreview-VRNiVJ5t.js";import{I as Nt}from"./IconCopy-RhFbFhX0.js";import"./chunk-7D6N5TE5-gOmt0HWF.js";import"./IconSearch-srLS9f0l.js";var Be=J(function(t,o){const{columns:l,spacingX:c,spacingY:n,spacing:d,minChildWidth:p,...s}=t,u=Ze(),h=p?At(p,u):Rt(l);return e.jsx(Ft,{ref:o,gap:d,columnGap:c,rowGap:n,templateColumns:h,...s})});Be.displayName="SimpleGrid";function Pt(a){return typeof a=="number"?`${a}px`:a}function At(a,t){return Te(a,o=>{const l=Ye("sizes",o,Pt(o))(t);return o===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function Rt(a){return Te(a,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ke=J((a,t)=>{const{title:o,children:l,className:c,...n}=a,d=re("chakra-menu__group__title",c),p=We();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[o&&e.jsx(pe.p,{className:d,...n,__css:p.groupTitle,children:o}),l]})});Ke.displayName="MenuGroup";var He=a=>{const{className:t,title:o,...l}=a,c=qe(l);return e.jsx(Ke,{title:o,className:re("chakra-menu__option-group",t),...c})};He.displayName="MenuOptionGroup";var _t=J((a,t)=>{const o=We();return e.jsx(pe.button,{ref:t,...a,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...o.button}})}),ne=J((a,t)=>{const{children:o,as:l,...c}=a,n=Je(c,t),d=l||_t;return e.jsx(d,{...n,className:re("chakra-menu__menu-button",a.className),children:e.jsx(pe.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:a.children})})});ne.displayName="MenuButton";var Bt=a=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...a,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"})}),Se=J((a,t)=>{const{icon:o,iconSpacing:l="0.75rem",...c}=a,n=Qe(c,t);return e.jsxs(et,{...n,className:re("chakra-menu__menuitem-option",c.className),children:[o!==null&&e.jsx(tt,{fontSize:"0.8em",marginEnd:l,opacity:a.isChecked?1:0,children:o||e.jsx(Bt,{})}),e.jsx("span",{style:{flex:1},children:n.children})]})});Se.id="MenuItemOption";Se.displayName="MenuItemOption";var Kt=T("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Ht=T("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=T("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"}]]),Fe=T("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"}]]),Gt=T("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"}]]),$e=T("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=T("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"}]]),Ut=T("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"}]]),Zt=T("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"}]]),Yt=T("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"}]]),Xt=T("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"}]]),Ge=T("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),qt=T("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"}]]),Jt=T("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"}]]),Qt=T("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 es(){const a=Y(),t=r.useRef([{title:"Save current workflow",key:de.SAVE},{title:"Save as current workflow",key:de.SAVE_AS},{title:"Open spotlight search",key:de.openSpotlightSearch}]),[o,l]=r.useState({save:"",saveAs:"",openSpotlightSearch:""}),[c,n]=r.useState(),d=async(s,u)=>{var g;s.preventDefault();let h="";if(s.ctrlKey&&(h+="Control+"),s.metaKey&&(h+="Command+"),s.shiftKey&&(h+="Shift+"),s.altKey&&(h+="Alt+"),h.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){h+=s.key.toUpperCase();const m={...o};delete m[u],Object.values(m).includes(h)?a({title:"Shortcut key conflict",description:`The shortcut key 「${h}」 is already used, please + modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=C)==null?void 0:g.upsert({shortcuts:{...o,[u]:h}})),p())}},p=()=>{var s;(s=C)==null||s.getSetting("shortcuts").then(u=>{var g;const h=u??((g=C)==null?void 0:g.defaultSettings.shortcuts);l({...o,...h})})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(z,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(N,{children:[e.jsx(z,{fontSize:"sm",w:170,children:s.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:c===s.key,children:e.jsx(Q,{value:o[s.key],onKeyDown:u=>{d(u,s.key)},onFocus:()=>{n(s.key)},onBlur:()=>{n(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function ts(){const{setRefreshFolderStamp:a}=r.useContext(G),[t,o]=r.useState(!1),l=()=>{var n;(n=C)==null||n.getSetting("foldersOnTop").then(d=>{o(!!d)})},c=n=>{var p;const d=n.target.checked;(p=C)==null||p.upsert({foldersOnTop:d}).then(()=>{l(),a(Date.now())})};return r.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:t,onChange:c,children:"Folders always on top"})})}function ss(){const[a,t]=r.useState(!1),[o,l]=r.useState(""),{showDialog:c}=ge(),n=()=>{var p,s;(p=C)==null||p.getSetting("myWorkflowsDir").then(u=>{l(u??"undefined")}),(s=C)==null||s.getSetting("twoWaySync").then(u=>{t(u??!1)})};r.useEffect(()=>{n()},[]);const d=async p=>{var u,h;if(!p.target.checked){await((u=C)==null?void 0:u.upsert({twoWaySync:p.target.checked})),n();return}const s=await((h=C)==null?void 0:h.getSetting("myWorkflowsDir"));c(e.jsx(st,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=C)==null?void 0:g.upsert({twoWaySync:!0})),n()},colorScheme:"red"}])};return e.jsxs(B,{children:[e.jsx(z,{children:"Only for legacy two way sync users to get back their data. [DO NOT DISABLE]"}),e.jsx(se,{isChecked:a,onChange:d,children:"Enable two way sync"})]})}function Me({settingKey:a,text:t,defaultChecked:o=!1}){const[l,c]=r.useState(o),n=Y(),d=()=>{var p;(p=C)==null||p.getSetting(a).then(s=>{c(!!s)})};return r.useEffect(()=>{d()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:l,onChange:async p=>{var s;await((s=C)==null?void 0:s.upsert({[a]:p.target.checked})),d(),n({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ns(){const[a,t]=r.useState(!1),[o,l]=r.useState(!1),[c,n]=r.useState([]),[d,p]=r.useState(""),[s,u]=r.useState([]),[h,g]=r.useState(!1),[m,i]=r.useState(!1),[f,v]=r.useState(!1),S=r.useRef(null),w=Y();ge();const b=f?"\\":"/";r.useEffect(()=>{var y;be().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=C)==null||y.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async y=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Ie(y??"");return V.includes("Operation not permitted")?(i(!0),L(),{isError:!0}):{dirList:E,dirPath:k}},j=async()=>{const{isError:y=!1,dirList:k=[]}=await F(d);y||(n(k),l(!0),u(d&&d.split(b).filter(E=>!!E)||[]))},L=()=>{l(!1),t(!1),u([])},K=async(y,k=!1,E=!1)=>{var x,I;if(k){const{path:D}=await be();D&&await at(D,y)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:y}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&i(!1),L()},H=async y=>{if(y){const{error:E=""}=await Ie(y);if(E.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?"":b}${s.join(b)}`;K(k,!1,!!y)},X=async()=>{const{dirPath:y,dirList:k}=await F("");u(y.split(b).filter(E=>!!E)),n(k)},ae=async(y,k)=>{var I;let E="";y===-1&&k?E=`${f?"":b}${s.concat([k]).join(b)}`:E=`${f?"":b}${s.slice(0,y+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(n(x),u(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},oe=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(Q,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(W,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var y,k;(y=S==null?void 0:S.current)!=null&&y.value&&H((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ce=()=>{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"}),o?a?oe:e.jsxs(_e,{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&&b,e.jsx(W,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ae(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Be,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((y,k)=>e.jsx(W,{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:()=>{ae(-1,y)},children:y},`${y}-${k}`))}),e.jsxs(_,{w:"100%",textAlign:"end",children:[e.jsx(W,{colorScheme:"teal",size:"sm",onClick:()=>{H()},children:"Save"}),e.jsx(W,{size:"sm",onClick:X,mr:2,ml:2,children:"Reset"}),e.jsx(W,{size:"sm",onClick:L,children:"Cancel"})]})]}):e.jsxs(U,{children:[e.jsx(nt,{overflowWrap:"anywhere",children:d}),e.jsx(R,{label:h?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(A,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!h,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:j})}),e.jsx(R,{label:h?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(A,{isDisabled:!h,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:ce,variant:"ghost"})})]})]}),e.jsxs(me,{isOpen:m,onClose:()=>i(!1),size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Kind tips"}),e.jsx(je,{}),e.jsx(we,{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(W,{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."}),oe]})})]})]})]})}function as({label:a,settingKey:t}){const[o,l]=r.useState(200),c=Y(),n=s=>{if(!s.length){l(0);return}l(parseInt(s))},d=async()=>{var s;o<0&&l(0),await((s=C)==null?void 0:s.upsert({[t]:Number(o)})),c({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=C)==null||s.getSetting(t).then(u=>{l(u)})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(z,{children:a}),e.jsx(Mt,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:o,onChange:s=>n(s),onBlur:()=>{d()},onKeyUp:s=>{s.key==="Enter"&&d()},children:e.jsx(Et,{})})]})}function os(){const a=Y(),[t,o]=r.useState(""),l=()=>{var n;(n=C)==null||n.getSetting("cloudHost").then(d=>{o(d??"")})};r.useEffect(()=>{l()},[]);const c=async n=>{var d;n=n.trim(),n.endsWith("/")&&(n=n.slice(0,-1)),await((d=C)==null?void 0:d.upsert({cloudHost:n})),l(),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{children:[e.jsx(z,{children:"For enterprise paid user only. Hosting site of the shared workflow."}),e.jsxs(U,{gap:2,alignItems:"center",children:[e.jsx(Q,{value:t,onChange:n=>o(n.target.value),onBlur:()=>c(t),onKeyDown:n=>{n.key==="Enter"&&c(t)}}),e.jsx(W,{size:"sm",onClick:()=>{var d;const n=(d=C)==null?void 0:d.defaultSettings.cloudHost;o(n),c(n)},children:"Reset"})]})]})}function is(){var p,s,u,h,g,m;const a=Y(),{session:t,updateSession:o}=r.useContext(le),[l,c]=r.useState(""),n=new URL((s=(p=C)==null?void 0:p.settings)==null?void 0:s.cloudHost).hostname;r.useEffect(()=>{c((t==null?void 0:t.shareKey)??"")},[t]);const d=async i=>{ot(i),o({username:(t==null?void 0:t.username)??null,shareKey:i}),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{gap:3,children:[e.jsx("p",{style:{fontWeight:"bold"},children:"Cloud Backup [Beta]"}),e.jsxs("p",{children:[e.jsx("a",{href:((h=(u=C)==null?void 0:u.settings)==null?void 0:h.cloudHost)+"/auth/shareKey",target:"_blank",style:{textDecoration:"underline"},children:e.jsx(W,{size:"sm",children:"👉Copy your share key from here"})})," ","and paste it below to start saving workflow versions to cloud at"," ",e.jsx("a",{href:(m=(g=C)==null?void 0:g.settings)==null?void 0:m.cloudHost,target:"_blank",children:n})]}),e.jsx(U,{alignItems:"center",children:e.jsx(Q,{value:l,placeholder:"Paste your share key here",onChange:i=>c(i.target.value),onBlur:()=>d(l),onKeyDown:i=>{i.key==="Enter"&&d(l)}})})]})}function rs({onClose:a}){return e.jsx(e.Fragment,{children:e.jsxs(me,{isOpen:!0,onClose:a,size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Settings"}),e.jsx(je,{}),e.jsx(we,{pb:14,children:e.jsx(N,{children:e.jsxs(_e,{divider:e.jsx(it,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ns,{}),e.jsx(es,{}),e.jsx(ss,{}),e.jsx(is,{}),e.jsx(ts,{}),e.jsx(as,{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(Me,{settingKey:"disableUnsavedWarning",text:'Disable the "Save or Discard" warning when closing a workflow with unsaved changes. ⛔️Be careful, if you disable this reminder and forget to save your workflow, you will lose your changes.'}),e.jsx(Me,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"}),e.jsx(os,{})]})})})]})]})})}const Ee=16;function ls({}){const[a,t]=r.useState(!1),{colorMode:o,toggleColorMode:l}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(ne,{as:A,"aria-label":"Options",icon:e.jsx(Zt,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(P,{onClick:()=>t(!0),icon:e.jsx(qt,{size:16}),fontSize:16,children:"Settings"}),e.jsxs(P,{onClick:l,icon:o==="light"?e.jsx(Yt,{size:Ee}):e.jsx(Jt,{size:Ee}),fontSize:16,children:[o==="light"?"Dark":"Light"," Mode"]})]})]}),a&&e.jsx(rs,{onClose:()=>t(!1)})]})}function cs(a){const{multipleState:t,changeMultipleState:o,selectedKeys:l,isSelectedAll:c,batchOperationCallback:n}=a,d=async()=>{var u;const s=await((u=O)==null?void 0:u.batchQuery(l))??[];lt(s)},p=l.length===0;return e.jsx(N,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(se,{isChecked:c,onChange:s=>{n("selectAll",s.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(A,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(rt,{size:21}),onClick:d})}),e.jsx(R,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Ne,{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=O)==null?void 0:s.batchDeleteFlow(l)),n("batchDelete")}})}),l.length>0&&e.jsx(z,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(R,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(A,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{o(!1)}})})]}):e.jsx(R,{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(Vt,{size:21}),onClick:()=>{o(!0)}})})})}const Oe=6;function ds({setSelectedTag:a,selectedTag:t}){const[o,l]=r.useState(!1),[c,n]=r.useState([]);return r.useEffect(()=>{var d;(d=ct)==null||d.listAll().then(p=>{n(p)})},[]),e.jsxs(N,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(A,{"aria-label":"Close",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{a(void 0)}}),c.slice(0,o?void 0:Oe).map(d=>e.jsx(W,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{a(d.name)},isActive:t===d.name,children:d.name},d.name)),(c.length??0)>Oe&&e.jsx(A,{"aria-label":"Show-all-tags",size:"sm",icon:o?e.jsx(Kt,{}):e.jsx(ke,{}),onClick:()=>l(!o)})]})}function Ve({parentFolderID:a,onlyImportFile:t=!1}){const{onRefreshFilesList:o}=r.useContext(G),[l,c]=r.useState("file"),n=r.useRef(null),d=h=>{var g;c(h),h==="folder"?n.current.setAttribute("webkitdirectory",""):n.current.removeAttribute("webkitdirectory"),(g=n.current)==null||g.click()},p=async h=>{var g;if(h.type==="image/png"){const m=await Ot(h),i=m==null?void 0:m.workflow;if(i)return{json:i,name:h.name.replace(".png","")}}else if(h.type==="application/json"||(g=h.name)!=null&&g.endsWith(".json"))return await new Promise((m,i)=>{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:h.name.replace(".json","")}):i(new Error("File content is not a string"))}catch(w){i(w)}},f.onerror=i,f.readAsText(h)});return null},s=async h=>{var m,i;const g=[h];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=$)==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((i=O)==null?void 0:i.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}o==null||o()},u=async h=>{var m;const g=h.target.files;if(g)if(l==="folder"){const i={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=i.children??[];for(let w=1;wj.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const j=await p(f);j&&(F.file=j)}S.push(F)}F&&!F.isFile&&(S=F.children)}}s(i)}else{const i=[];for(const f of g){const v=await p(f);v&&i.push(v)}i.length&&(await((m=O)==null?void 0:m.batchCreateFlows(i,void 0,a)),o&&o())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(P,{onClick:h=>{h.stopPropagation(),d("file")},icon:e.jsx(Fe,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,leftIcon:e.jsx(Fe,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:dt.map((h,g)=>e.jsx(P,{onClick:()=>{d(h.type)},iconSpacing:2,icon:h.type==="folder"?e.jsx(Ae,{size:18}):e.jsx(Gt,{size:18}),children:h.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:n,type:"file",accept:".json,image/png",multiple:!0,onChange:u,onClick:h=>{h.stopPropagation()}})]})}function us({folder:a,onclose:t}){const[o,l]=r.useState(a.name),[c,n]=r.useState(""),{onRefreshFilesList:d}=r.useContext(G),p=u=>{l(u.target.value),c&&n("")},s=async()=>{var g,m;const u=o.trim();if(l(u),u===a.name)return t();await((g=$)==null?void 0:g.generateUniqueName(u,a.parentFolderID??""))!==u?n("The name is duplicated, please modify it and submit again."):(await((m=$)==null?void 0:m.update(a.id,{name:u})),d&&d(),t())};return e.jsxs(me,{isOpen:!0,onClose:t,children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Edit folder name"}),e.jsx(je,{}),e.jsx(we,{children:e.jsxs(ut,{isInvalid:!!c,children:[e.jsx(ht,{children:"Folder name"}),e.jsx(Q,{value:o,onChange:p,autoFocus:!0,onKeyUp:u=>{u.code==="Enter"&&!c&&o&&s()}}),c&&e.jsx(pt,{children:c})]})}),e.jsxs(Xe,{children:[e.jsx(W,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!o||!!c,children:"Save"}),e.jsx(W,{onClick:t,children:"Cancel"})]})]})]})}function hs({menuPosition:a,isopen:t,folder:o,onClose:l}){const[c,n]=r.useState(!1),{onRefreshFilesList:d}=r.useContext(G),{showDialog:p}=ge(),s=async m=>{var i;m.stopPropagation(),await((i=$)==null?void 0:i.create({name:"New Folder",parentFolderID:o.id})),d&&d()},u=async m=>{var i;m.stopPropagation(),await((i=O)==null?void 0:i.createFlow({json:JSON.stringify(mt),parentFolderID:o.id})),d&&d()},h=async m=>{m.stopPropagation();const i=await ft(o.id);p(`Do you want to delete the ${i} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(xt.DELETE)}}])},g=async m=>{var i;await((i=$)==null?void 0:i.deleteFolder(o.id,m)),l(),d&&d()};return e.jsxs(e.Fragment,{children:[e.jsx(_,{position:"absolute",top:a.y,left:a.x,children:e.jsx(ee,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(te,{children:[e.jsx(P,{icon:e.jsx(Xt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),n(!0)},children:"Rename"}),e.jsx(P,{icon:e.jsx(gt,{size:19}),onClick:h,children:"Delete"}),e.jsx(P,{onClick:s,icon:e.jsx($e,{size:19}),children:"New folder"}),e.jsx(P,{onClick:u,icon:e.jsx(Ge,{size:19}),children:"New file"}),e.jsx(Ve,{parentFolderID:o.id,onlyImportFile:!0})]})})}),c&&e.jsx(us,{folder:o,onclose:()=>n(!1)})]})}const Le=r.memo(function({folder:t}){const[o,l]=r.useState(!1),[c,n]=r.useState(t.isCollapse??!0),[d,p]=r.useState([]),[s,u]=r.useState({x:0,y:0}),[h,g]=r.useState(!1),{colorMode:m}=ve(),{draggingFile:i,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=r.useContext(G),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};r.useEffect(()=>{var j;c||(j=O)==null||j.listFolderContent(t.id,window.localStorage.getItem(he)).then(L=>{p(L)})},[t.id,v,c]);const b=j=>{j.preventDefault(),u({x:j.clientX,y:j.clientY}),g(!0)},F=async j=>{var L,K;if(j.preventDefault(),j.stopPropagation(),!i)return l(!1);if(Z(i)){if(i.id===t.id)return l(!1);await((L=$)==null?void 0:L.update(i.id,{parentFolderID:t.id}))}else Z(i)||await((K=O)==null?void 0:K.updateFolder(i.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return r.useEffect(()=>{var j;!!t.isCollapse!==c&&((j=$)==null||j.update(t.id,{isCollapse:c}))},[c]),r.useEffect(()=>{var X;const j=(X=O)==null?void 0:X.curWorkflow,L=(j==null?void 0:j.parentFolderID)+De(),K=t.id+De();L.startsWith(K)&&n(!1)},[]),e.jsxs(B,{children:[e.jsxs(N,{w:"100%",as:"button",py:1,onClick:()=>{n(!c)},onContextMenu:b,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:F,_hover:w,style:o||h?w:void 0,className:"droppable",children:[e.jsxs(N,{gap:1,children:[c?e.jsx(Lt,{size:20}):e.jsx(ke,{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(hs,{isopen:h,menuPosition:s,onClose:()=>g(!1),folder:t}),!c&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Ue,{items:d})})]})});function ps({workflow:a}){const t=r.useRef(null),o=Y(),{onDuplicateWorkflow:l}=r.useContext(le),[c,n]=r.useState(a.saveLock??!1),d=async()=>{var u;const s=!c;n(s),await((u=O)==null?void 0:u.updateMetaInfo(a.id,{saveLock:s})),o({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const u=s.target.files;if(!u)return;const h=new FormData;Array.from(u).forEach((g,m)=>{h.append(`images[${m}]`,g,g.name)}),h.append("subfolder","workspace_manager"),await vt("/workspace/images/save",{method:"POST",body:h}),Array.from(u).forEach(async g=>{var i,f;const m=`workspace_manager/${g.name}`;(i=kt)==null||i.create({workflowID:a.id,localPath:m}),(f=O)==null||f.updateMetaInfo(a.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(ne,{border:0,as:A,"aria-label":"Options",icon:e.jsx(Ht,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(P,{icon:e.jsx(Nt,{}),onClick:()=>l&&l(a.id),children:"Duplicate"}),e.jsx(P,{icon:e.jsx(yt,{size:20}),onClick:()=>jt(a.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:c?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(P,{icon:c?e.jsx(Re,{}):e.jsx(Ut,{}),onClick:d,children:c?"Unlock":"Lock"})}),a.cloudID&&e.jsx(P,{icon:e.jsx(wt,{}),onClick:()=>{var s,u;navigator.clipboard.writeText(`${(u=(s=C)==null?void 0:s.settings)==null?void 0:u.cloudHost}/workflow/${a.cloudID}`),o({title:"Cloud link copied",status:"success",duration:3e3})},children:"Copy cloud share link"}),e.jsx(P,{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 gs({workflow:a}){const{onDeleteFlow:t}=r.useContext(G);return e.jsxs(U,{justifyContent:"flex-end",children:[e.jsx(Ne,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(a.id)}}),e.jsx(ps,{workflow:a})]})}const ze=r.memo(function({workflow:t}){var v,S,w,b;const{colorMode:o}=ve(),{setDraggingFile:l,isMultiSelecting:c,onMultiSelectFlow:n,multiSelectedFlowsID:d}=r.useContext(G),p=d&&d.length>0&&d.includes(t.id),{curFlowID:s,loadWorkflowID:u}=r.useContext(le),h=s===t.id,g=o==="light"?"gray.200":"#4A5568",[m,i]=r.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:h?"teal.200":void 0,color:h&&!c?"#333":void 0,draggable:!c,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!c&&u(t.id)},_hover:{bg:g},children:e.jsxs(N,{flexGrow:1,children:[!((S=(v=C)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((b=t.latestImage)==null?void 0:b.length))&&e.jsx(zt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(_,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(U,{alignItems:"center",children:[e.jsx(z,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx(Re,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(N,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:o=="dark"?"gray.700":"gray.200",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:c?e.jsx(se,{isChecked:p,spacing:4,onChange:F=>{n&&n(t.id,F.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx(_,{width:"fit-content",children:m?e.jsx(gs,{workflow:t}):e.jsx(z,{color:"GrayText",fontSize:"sm",children:St(t.updateTime,!1,!1,"/")})})]})})});function Ue({items:a}){var m;const[t,o]=r.useState(!1),l=a.filter(Z),c=a.filter(i=>!Z(i)),n=(m=c[0])==null?void 0:m.parentFolderID,[d,p]=r.useState(!1),{onRefreshFilesList:s,draggingFile:u,refreshFolderStamp:h}=r.useContext(G),g=async i=>{var f,v;if(i.preventDefault(),i.stopPropagation(),!u)return p(!1);if(Z(u)){if(u.id===n)return p(!1);await((f=$)==null?void 0:f.update(u.id,{parentFolderID:n}))}else await((v=O)==null?void 0:v.updateFolder(u.id,{parentFolderID:n}));await(s==null?void 0:s()),p(!1)};return r.useEffect(()=>{var i;(i=C)==null||i.getSetting("foldersOnTop").then(f=>{o(f??!1)})},[h]),e.jsxs(e.Fragment,{children:[t&&l.map(i=>e.jsx(Le,{folder:i},i.id)),e.jsx(_,{border:d?"2px dashed #718096":"2px dashed transparent",onDragOver:i=>{i.preventDefault(),i.stopPropagation(),p(!0)},onDragLeave:i=>{i.preventDefault(),i.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?c.map(i=>e.jsx(ze,{workflow:i},i.id)):a.map(i=>Z(i)?e.jsx(Le,{folder:i},i.id):e.jsx(ze,{workflow:i},i.id))})]})}function Ss({onClose:a,onClickNewFlow:t}){const[o,l]=r.useState([]),c=r.useRef([]),{loadWorkflowID:n,curFlowID:d}=r.useContext(le),[p,s]=r.useState(),[u,h]=r.useState(!1),[g,m]=r.useState([]),[i,f]=r.useState(0),[v,S]=r.useState(""),w=Tt(v,400),b=r.useRef(null),[F,j]=r.useState(null),L=r.useRef(window.localStorage.getItem(he)??q.RECENTLY_MODIFIED),K=!!p||!!w.length,H=async()=>{var I,D;const x=await((I=O)==null?void 0:I.listFolderContent())??[];l(ue(x,L.current)),f(Date.now()),c.current=await((D=O)==null?void 0:D.listAll())??[]},X=()=>{const x=c.current.filter(I=>{var Ce;let D=!0,M=!0;return p&&(D=!!((Ce=I.tags)!=null&&Ce.includes(p))),w&&(M=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),D&&M});l(ue(x,L.current))},ae=x=>{l(ue(o,x)),L.current=x,window.localStorage.setItem(he,x),!K&&f(Date.now())};r.useEffect(()=>{K?X():H()},[w,p]);const oe=r.useCallback(async x=>{var I,D,M;await((I=O)==null?void 0:I.deleteFlow(x)),((M=(D=O)==null?void 0:D.curWorkflow)==null?void 0:M.id)===x&&await(n==null?void 0:n(null)),await H()},[p,w]);r.useEffect(()=>{const x=async I=>{var D;if(b.current){const M=await((D=O)==null?void 0:D.get(b.current));M&&M.json&&Dt(M.json,[I.canvasX,I.canvasY])}};return ie.canvasEl.addEventListener("drop",x),ie.canvasEl.addEventListener("click",a),()=>{ie.canvasEl.removeEventListener("drop",x),ie.canvasEl.removeEventListener("click",a)}},[]);const ce=r.useCallback((x,I)=>{m(D=>{const M=[...D];return I?M.push(x):M.splice(M.indexOf(x),1),M})},[]),y=(x,I)=>{var D;switch(x){case"batchDelete":d&&((D=O)==null||D.get(d).then(M=>{M||n==null||n(null)})),H(),h(!1),m([]);return;case"selectAll":m(I?c.current.map(M=>M.id):[]);return}},k=x=>{j(x),Z(x)||(b.current=x.id)},E=x=>{S(x)},V=450;return e.jsx(G.Provider,{value:{onRefreshFilesList:H,draggingFile:F??void 0,setDraggingFile:k,isMultiSelecting:u,onMultiSelectFlow:ce,multiSelectedFlowsID:g,onDeleteFlow:oe,refreshFolderStamp:i,setRefreshFolderStamp:f},children:e.jsx(_,{style:{width:V},children:e.jsxs(Ct,{width:V,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:bt,children:[e.jsxs(U,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(N,{gap:4,children:[e.jsx(N,{gap:2,children:e.jsx(z,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ve,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(A,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(Ae,{}),variant:"outline",colorScheme:"teal",onClick:()=>It()})}),e.jsx(R,{label:"New workflow",children:e.jsx(A,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Ge,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(N,{alignItems:"center",children:e.jsx(ls,{})})]}),e.jsxs(U,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(ds,{selectedTag:p,setSelectedTag:s}),e.jsxs(N,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(N,{children:[e.jsx(cs,{multipleState:u,changeMultipleState:x=>{h(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===c.current.length,batchOperationCallback:y}),!u&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(A,{size:"sm",variant:"outline",icon:e.jsx($e,{size:21}),onClick:async()=>{var x;await((x=$)==null?void 0:x.create({name:"New Folder"})),H()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(ke,{size:"16"}),children:e.jsxs(N,{children:[e.jsx(z,{children:"Sort by:"}),e.jsx(z,{display:"inline-block",children:L.current})]})}),e.jsx(te,{children:e.jsx(He,{value:L.current,type:"radio",onChange:x=>ae(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,I)=>e.jsx(Se,{value:x,children:x},I))})})]})]}),e.jsx(Wt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(U,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(Ue,{items:o})})]})]})})})}export{Ss as default}; diff --git a/dist/workspace_web/ShareDialog-DSSo_bep.js b/dist/workspace_web/ShareDialog-DSSo_bep.js new file mode 100644 index 0000000..3f108ee --- /dev/null +++ b/dist/workspace_web/ShareDialog-DSSo_bep.js @@ -0,0 +1 @@ +import{f as te,n as me,o as ge,j as e,g as ae,e as ne,r as u,m as xe,w as Q,b as we,h as M,a0 as X,M as je,T as ve,N as be,U as ye,O as ke}from"./input.js";import{B as Ce,z as Se,a6 as Ie,f as P,H as A,ae as Re,a5 as D,ah as F,an as Ee,aA as ee,aF as De,W as Ne,e as Pe,F as se,aG as Te,I as We,h as oe,w as O,a1 as Oe,aH as _e,aI as Fe,aJ as Me,T as ze,k as Le,aK as Ae,Z as Ge}from"./App-9GIQJeUY.js";import{I as He}from"./chunk-7D6N5TE5-gOmt0HWF.js";import{a as Ue}from"./civitUtils-TPBejtrP.js";import{S as Be,L as Ve}from"./chunk-VTV6N5LE-VcPf7MxV.js";import{I as Ke}from"./IconCopy-RhFbFhX0.js";var re=te(function(i,l){const r=me("Badge",i),{className:o,...s}=ge(i);return e.jsx(ae.span,{ref:l,className:ne("chakra-badge",i.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});re.displayName="Badge";function $e(n){return n&&Q(n)&&Q(n.target)}function Je(n={}){const{onChange:i,value:l,defaultValue:r,name:o,isDisabled:s,isFocusable:f,isNative:b,...d}=n,[y,v]=u.useState(r||""),h=typeof l<"u",x=h?l:y,w=u.useRef(null),t=u.useCallback(()=>{const m=w.current;if(!m)return;let g="input:not(:disabled):checked";const T=m.querySelector(g);if(T){T.focus();return}g="input:not(:disabled)";const N=m.querySelector(g);N==null||N.focus()},[]),j=`radio-${u.useId()}`,p=o||j,I=u.useCallback(m=>{const g=$e(m)?m.target.value:m;h||v(g),i==null||i(String(g))},[i,h]),k=u.useCallback((m={},g=null)=>({...m,ref:xe(g,w),role:"radiogroup"}),[]),z=u.useCallback((m={},g=null)=>({...m,ref:g,name:p,[b?"checked":"isChecked"]:x!=null?m.value===x:void 0,onChange(N){I(N)},"data-radiogroup":!0}),[b,p,I,x]);return{getRootProps:k,getRadioProps:z,name:p,ref:w,focus:t,setValue:v,value:x,onChange:I,isDisabled:s,isFocusable:f,htmlProps:d}}var[qe,rs]=we({name:"RadioGroupContext",strict:!1}),ie=te((n,i)=>{const{colorScheme:l,size:r,variant:o,children:s,className:f,isDisabled:b,isFocusable:d,...y}=n,{value:v,onChange:h,getRootProps:x,name:w,htmlProps:t}=Je(y),E=u.useMemo(()=>({name:w,size:r,onChange:h,colorScheme:l,value:v,variant:o,isDisabled:b,isFocusable:d}),[w,r,h,l,v,o,b,d]);return e.jsx(qe,{value:E,children:e.jsx(ae.div,{...x(t,i),className:ne("chakra-radio-group",f),children:s})})});ie.displayName="RadioGroup";function Ye({options:n,value:i,onChange:l}){const[r,o]=u.useState(!1),s=u.useRef(null),f=n.find(d=>d.value===i);u.useEffect(()=>{const d=y=>{s.current&&!s.current.contains(y.target)&&o(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[s]);const b=()=>o(!r);return e.jsxs(Ce,{position:"relative",children:[e.jsx(M,{onClick:b,rightIcon:e.jsx(Se,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),r&&e.jsx(Ie,{gap:4,ref:s,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:n.map(d=>e.jsx(M,{onClick:()=>{o(!1),l(d.value)},leftIcon:d.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:d.label},d.label))})]})}function Ze({deps:n,uploadingImage:i}){const l=Object.values((n==null?void 0:n.images)??{});return n?e.jsx(P,{gap:5,children:l.length>0&&e.jsxs(P,{children:[e.jsxs(A,{children:[e.jsxs(Re,{size:"sm",children:["Images (",l.length,")"]}),e.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),i&&e.jsxs("span",{children:[e.jsx(X,{size:"md",color:"teal.400"})," Uploading"]}),l.map(r=>e.jsxs(P,{children:[e.jsx("p",{children:r.filename}),e.jsx(He,{width:250,src:`/workspace/view_media?filename=${r.filename}&isPreview=true&isInput=true`})]},r.filename))]})}):e.jsx(X,{size:"md",color:"teal.400"})}async function Qe(n,i,l){const r=await Ee.models.where("fileName").equals(n).toArray()??[],o=r.at(0);return{name:n,nodeType:i,hash:(o==null?void 0:o.fileHash)??null,folder:(o==null?void 0:o.fileFolder)??null,url:o!=null&&o.civitModelVersionID?Ue(o.civitModelVersionID):(o==null?void 0:o.downloadUrl)??null,inputName:l,length:r.length}}async function Xe(n){var x,w;let i=[],l={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],o=[".jpeg",".jpg",".png",".gif",".webp"],s=(w=(x=D.graph.extra)==null?void 0:x[F])==null?void 0:w.deps,f=await D.graphToPrompt();Object.values(f.output).forEach(t=>{t.inputs&&Object.keys(t.inputs).forEach(E=>{var p,I;const j=(p=t.inputs)==null?void 0:p[E];typeof j=="string"&&(r.some(k=>j.endsWith(k))&&i.push(Qe(j,t.class_type,E)),o.some(k=>j.endsWith(k))&&(l[j]=((I=s==null?void 0:s.images)==null?void 0:I[j])??{filename:j,nodeType:t.class_type}))})});const d=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:n.map(t=>t.type)})}).then(t=>t.ok?t.json():[]).catch(t=>(console.error("Error fetching node repos",t),[])),y=await Promise.all(i),v={};y.forEach(t=>{v[t.name]=t});const h={};return Object.values(d).forEach(t=>{h[t.gitRepo]=t}),{models:v,images:l,nodeRepos:Object.values(h)}}function is({onClose:n}){var G,H,U,B,V;const[i,l,r]=ee("v"+De()),{saveCurWorkflow:o}=u.useContext(Ne),[s,f]=u.useState(),[b,d]=u.useState(!1),[y,v]=u.useState(!1),h=(H=(G=oe)==null?void 0:G.settings)==null?void 0:H.cloudHost,[x,w,t]=ee("PRIVATE"),[E,j]=u.useState("new_version"),p=(U=O)==null?void 0:U.curWorkflow,I=Pe(),[k,z]=u.useState(!0),m=async a=>{var C;const c=a.data;if(c.type!=="share_workflow_success"||!p)return;const S=c.version.id,R=c.version.workflowID;R&&await((C=O)==null?void 0:C.updateMetaInfo(p.id,{cloudID:R})),g(),window.open(h+"/workflow/"+R+"/"+S,"_blank"),v(!1)};u.useEffect(()=>{g();const a=D.graph.serialize();return Xe(a.nodes??[]).then(c=>{f(c)}),window.addEventListener("message",m),()=>{window.removeEventListener("message",m)}},[]);const g=async()=>{p!=null&&p.cloudID&&p.cloudOrigin&&Me(p).then(a=>{w(a)})},T=a=>{navigator.clipboard.writeText(a).then(()=>{I({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},N=async a=>{var J,q,Y;const c=D.graph.serialize();(J=c.extra||(c.extra={}))[q=F]||(J[q]={}),c.extra[F].deps={models:(s==null?void 0:s.models)??{},images:a??{},nodeRepos:(s==null?void 0:s.nodeRepos)??[]},await o(),await D.graphToPrompt(D.graph).then(W=>(c.extra[F].apiPrompt=W.output,W.output));const S=JSON.stringify(c);v(!0);const R=_e(32),C=await((Y=oe)==null?void 0:Y.getSetting("cloudHost"));let K;K=Fe(),r.current,S??JSON.stringify(D.graph.serialize());const ce=window.location.protocol,de=window.location.host,ue=`${ce}//${de}`,he=C+`/share_workflow_confirm/${R}?redirectUrl=${ue}`,pe=window.open(he,"Share Workflow","width=800,height=800"),$=W=>{var Z;if(W.origin===C&&W.data==="child_ready"){const L=(Z=O)==null?void 0:Z.curWorkflow;if(!L)return;const fe={workflow:{name:L.name,cloudID:L.cloudID},version:{name:r.current,json:S},nodeDefs:K,privacy:t.current};pe.postMessage(fe,C),window.removeEventListener("message",$)}};window.addEventListener("message",$)},le=async()=>{const a=(s==null?void 0:s.images)??{};if(k){d(!0);const c=Object.values((s==null?void 0:s.images)??{}).map(S=>S.filename);if(c.length)try{const R=await(await Oe("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:c})})).json();Object.keys(R).forEach(C=>{a!=null&&a[C]&&(a[C].url=R[C])})}catch(S){console.error("Error uploading images:",S)}d(!1)}N(a)},_=(V=(B=O)==null?void 0:B.curWorkflow)==null?void 0:V.cloudID;return e.jsxs(je,{isOpen:!0,onClose:n,size:"lg",children:[e.jsx(ve,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:[e.jsxs(se,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',p==null?void 0:p.name,'"']}),e.jsx(M,{colorScheme:"teal",onClick:le,size:"sm",isDisabled:y,children:y?"Sharing":"Share"})]}),h&&e.jsxs(ze,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(h).host]})]}),e.jsx(ke,{pb:10,children:e.jsxs(P,{gap:5,children:[_==null?e.jsx(Ye,{options:Te,value:x,onChange:a=>{w(a)}}):e.jsx(Le,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ae,{privacy:x,showEmoji:!0})}),_&&e.jsxs(A,{spacing:2,color:"teal.400",children:[e.jsxs(Ve,{wordBreak:"break-all",href:h+"/workflow/"+_,isExternal:!0,children:[h+"/workflow/"+_," ",e.jsx(Ge,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(M,{size:"sm",leftIcon:e.jsx(Ke,{size:18}),onClick:()=>{var a,c;T(h+"/workflow/"+((c=(a=O)==null?void 0:a.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(ie,{gap:4,onChange:a=>{j(a)},value:E,children:e.jsx(P,{children:e.jsxs(A,{mb:5,alignItems:"center",children:[e.jsx(We,{value:i,width:"60%",onFocus:()=>{j("new_version")},onChange:a=>{l(a.target.value)}}),e.jsx(se,{color:"green",children:e.jsx(re,{colorScheme:"purple",children:"Version Name"})})]})})}),Object.keys((s==null?void 0:s.images)??{}).length>0&&e.jsxs(P,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Be,{isChecked:k,onChange:()=>z(!k),fontWeight:"600",children:"Share input images"}),e.jsxs("span",{style:{color:"GrayText"},children:["If enabled your input images will be uploaded and shared to"," ",h]}),k&&e.jsx(Ze,{deps:s??null,setDeps:f,uploadingImage:b})]})]})})]})]})}export{is as default}; diff --git a/dist/workspace_web/ShareDialog-g_a6xMAM.js b/dist/workspace_web/ShareDialog-g_a6xMAM.js deleted file mode 100644 index 6c1285e..0000000 --- a/dist/workspace_web/ShareDialog-g_a6xMAM.js +++ /dev/null @@ -1 +0,0 @@ -import{f as te,n as fe,o as ge,j as e,g as ae,e as ne,r as u,m as we,w as Q,b as xe,h as M,a0 as X,M as je,T as ve,N as ye,U as be,O as ke}from"./input.js";import{B as Se,z as Ce,a5 as Ie,f as P,H as A,ad as Re,a4 as E,ag as F,am as De,az as ee,W as Ee,e as Ne,F as se,aE as Pe,I as Te,h as oe,w as O,a0 as We,aF as Oe,aG as _e,aH as Fe,T as Me,k as ze,aI as Le,Z as Ae}from"./App-ZTJclgGW.js";import{I as Ge}from"./chunk-7D6N5TE5-wlKuxWhy.js";import{a as He}from"./civitUtils-T1Lq3reo.js";import{S as Ue,L as Be}from"./chunk-VTV6N5LE-qccSGxq6.js";import{I as Ve}from"./IconCopy-zZpZ6D5h.js";var re=te(function(i,l){const r=fe("Badge",i),{className:t,...s}=ge(i);return e.jsx(ae.span,{ref:l,className:ne("chakra-badge",i.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});re.displayName="Badge";function $e(o){return o&&Q(o)&&Q(o.target)}function Ke(o={}){const{onChange:i,value:l,defaultValue:r,name:t,isDisabled:s,isFocusable:m,isNative:y,...d}=o,[b,v]=u.useState(r||""),h=typeof l<"u",w=h?l:b,x=u.useRef(null),a=u.useCallback(()=>{const f=x.current;if(!f)return;let g="input:not(:disabled):checked";const T=f.querySelector(g);if(T){T.focus();return}g="input:not(:disabled)";const N=f.querySelector(g);N==null||N.focus()},[]),j=`radio-${u.useId()}`,p=t||j,I=u.useCallback(f=>{const g=$e(f)?f.target.value:f;h||v(g),i==null||i(String(g))},[i,h]),k=u.useCallback((f={},g=null)=>({...f,ref:we(g,x),role:"radiogroup"}),[]),z=u.useCallback((f={},g=null)=>({...f,ref:g,name:p,[y?"checked":"isChecked"]:w!=null?f.value===w:void 0,onChange(N){I(N)},"data-radiogroup":!0}),[y,p,I,w]);return{getRootProps:k,getRadioProps:z,name:p,ref:x,focus:a,setValue:v,value:w,onChange:I,isDisabled:s,isFocusable:m,htmlProps:d}}var[qe,rs]=xe({name:"RadioGroupContext",strict:!1}),ie=te((o,i)=>{const{colorScheme:l,size:r,variant:t,children:s,className:m,isDisabled:y,isFocusable:d,...b}=o,{value:v,onChange:h,getRootProps:w,name:x,htmlProps:a}=Ke(b),D=u.useMemo(()=>({name:x,size:r,onChange:h,colorScheme:l,value:v,variant:t,isDisabled:y,isFocusable:d}),[x,r,h,l,v,t,y,d]);return e.jsx(qe,{value:D,children:e.jsx(ae.div,{...w(a,i),className:ne("chakra-radio-group",m),children:s})})});ie.displayName="RadioGroup";function Je({options:o,value:i,onChange:l}){const[r,t]=u.useState(!1),s=u.useRef(null),m=o.find(d=>d.value===i);u.useEffect(()=>{const d=b=>{s.current&&!s.current.contains(b.target)&&t(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[s]);const y=()=>t(!r);return e.jsxs(Se,{position:"relative",children:[e.jsx(M,{onClick:y,rightIcon:e.jsx(Ce,{}),leftIcon:m==null?void 0:m.icon,children:m==null?void 0:m.label}),r&&e.jsx(Ie,{gap:4,ref:s,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:o.map(d=>e.jsx(M,{onClick:()=>{t(!1),l(d.value)},leftIcon:d.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:d.label},d.label))})]})}function Ye({deps:o,uploadingImage:i}){const l=Object.values((o==null?void 0:o.images)??{});return o?e.jsx(P,{gap:5,children:l.length>0&&e.jsxs(P,{children:[e.jsxs(A,{children:[e.jsxs(Re,{size:"sm",children:["Images (",l.length,")"]}),e.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),i&&e.jsxs("span",{children:[e.jsx(X,{size:"md",color:"teal.400"})," Uploading"]}),l.map(r=>e.jsxs(P,{children:[e.jsx("p",{children:r.filename}),e.jsx(Ge,{width:250,src:`/workspace/view_media?filename=${r.filename}&isPreview=true&isInput=true`})]},r.filename))]})}):e.jsx(X,{size:"md",color:"teal.400"})}async function Ze(o,i,l){const r=await De.models.where("fileName").equals(o).toArray()??[],t=r.at(0);return{name:o,nodeType:i,hash:(t==null?void 0:t.fileHash)??null,folder:(t==null?void 0:t.fileFolder)??null,url:t!=null&&t.civitModelVersionID?He(t.civitModelVersionID):(t==null?void 0:t.downloadUrl)??null,inputName:l,length:r.length}}async function Qe(o){var w,x;let i=[],l={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],t=[".jpeg",".jpg",".png",".gif",".webp"],s=(x=(w=E.graph.extra)==null?void 0:w[F])==null?void 0:x.deps,m=await E.graphToPrompt();Object.values(m.output).forEach(a=>{a.inputs&&Object.keys(a.inputs).forEach(D=>{var p,I;const j=(p=a.inputs)==null?void 0:p[D];typeof j=="string"&&(r.some(k=>j.endsWith(k))&&i.push(Ze(j,a.class_type,D)),t.some(k=>j.endsWith(k))&&(l[j]=((I=s==null?void 0:s.images)==null?void 0:I[j])??{filename:j,nodeType:a.class_type}))})});const d=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:o.map(a=>a.type)})}).then(a=>a.ok?a.json():[]).catch(a=>(console.error("Error fetching node repos",a),[])),b=await Promise.all(i),v={};b.forEach(a=>{v[a.name]=a});const h={};return Object.values(d).forEach(a=>{h[a.gitRepo]=a}),{models:v,images:l,nodeRepos:Object.values(h)}}function is({onClose:o}){var G,H,U,B,V;const[i,l,r]=ee("v"+Xe()),{saveCurWorkflow:t}=u.useContext(Ee),[s,m]=u.useState(),[y,d]=u.useState(!1),[b,v]=u.useState(!1),h=(H=(G=oe)==null?void 0:G.settings)==null?void 0:H.cloudHost,[w,x,a]=ee("PRIVATE"),[D,j]=u.useState("new_version"),p=(U=O)==null?void 0:U.curWorkflow,I=Ne(),[k,z]=u.useState(!0),f=async n=>{var S;const c=n.data;if(c.type!=="share_workflow_success"||!p)return;const C=c.version.id,R=c.version.workflowID;R&&await((S=O)==null?void 0:S.updateMetaInfo(p.id,{cloudID:R})),g(),window.open(h+"/workflow/"+R+"/"+C,"_blank"),v(!1)};u.useEffect(()=>{g();const n=E.graph.serialize();return Qe(n.nodes??[]).then(c=>{m(c)}),window.addEventListener("message",f),()=>{window.removeEventListener("message",f)}},[]);const g=async()=>{p!=null&&p.cloudID&&p.cloudOrigin&&Fe(p).then(n=>{x(n)})},T=n=>{navigator.clipboard.writeText(n).then(()=>{I({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},N=async n=>{var q,J,Y;const c=E.graph.serialize();(q=c.extra||(c.extra={}))[J=F]||(q[J]={}),c.extra[F].deps={models:(s==null?void 0:s.models)??{},images:n??{},nodeRepos:(s==null?void 0:s.nodeRepos)??[]},await t(),await E.graphToPrompt(E.graph).then(W=>(c.extra[F].apiPrompt=W.output,W.output));const C=JSON.stringify(c);v(!0);const R=Oe(32),S=await((Y=oe)==null?void 0:Y.getSetting("cloudHost"));let $;$=_e(),r.current,C??JSON.stringify(E.graph.serialize());const ce=window.location.protocol,de=window.location.host,ue=`${ce}//${de}`,he=S+`/share_workflow_confirm/${R}?redirectUrl=${ue}`,pe=window.open(he,"Share Workflow","width=800,height=800"),K=W=>{var Z;if(W.origin===S&&W.data==="child_ready"){const L=(Z=O)==null?void 0:Z.curWorkflow;if(!L)return;const me={workflow:{name:L.name,cloudID:L.cloudID},version:{name:r.current,json:C},nodeDefs:$,privacy:a.current};pe.postMessage(me,S),window.removeEventListener("message",K)}};window.addEventListener("message",K)},le=async()=>{const n=(s==null?void 0:s.images)??{};if(k){d(!0);const c=Object.values((s==null?void 0:s.images)??{}).map(C=>C.filename);if(c.length)try{const R=await(await We("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:c})})).json();Object.keys(R).forEach(S=>{n!=null&&n[S]&&(n[S].url=R[S])})}catch(C){console.error("Error uploading images:",C)}d(!1)}N(n)},_=(V=(B=O)==null?void 0:B.curWorkflow)==null?void 0:V.cloudID;return e.jsxs(je,{isOpen:!0,onClose:o,size:"lg",children:[e.jsx(ve,{}),e.jsxs(ye,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(be,{children:[e.jsxs(se,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',p==null?void 0:p.name,'"']}),e.jsx(M,{colorScheme:"teal",onClick:le,size:"sm",isDisabled:b,children:b?"Sharing":"Share"})]}),h&&e.jsxs(Me,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(h).host]})]}),e.jsx(ke,{pb:10,children:e.jsxs(P,{gap:5,children:[_==null?e.jsx(Je,{options:Pe,value:w,onChange:n=>{x(n)}}):e.jsx(ze,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Le,{privacy:w,showEmoji:!0})}),_&&e.jsxs(A,{spacing:2,color:"teal.400",children:[e.jsxs(Be,{wordBreak:"break-all",href:h+"/workflow/"+_,isExternal:!0,children:[h+"/workflow/"+_," ",e.jsx(Ae,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(M,{size:"sm",leftIcon:e.jsx(Ve,{size:18}),onClick:()=>{var n,c;T(h+"/workflow/"+((c=(n=O)==null?void 0:n.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(ie,{gap:4,onChange:n=>{j(n)},value:D,children:e.jsx(P,{children:e.jsxs(A,{mb:5,alignItems:"center",children:[e.jsx(Te,{value:i,width:"60%",onFocus:()=>{j("new_version")},onChange:n=>{l(n.target.value)}}),e.jsx(se,{color:"green",children:e.jsx(re,{colorScheme:"purple",children:"Version Name"})})]})})}),Object.keys((s==null?void 0:s.images)??{}).length>0&&e.jsxs(P,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Ue,{isChecked:k,onChange:()=>z(!k),fontWeight:"600",children:"Share input images"}),e.jsxs("span",{style:{color:"GrayText"},children:["If enabled your input images will be uploaded and shared to"," ",h]}),k&&e.jsx(Ye,{deps:s??null,setDeps:m,uploadingImage:y})]})]})})]})]})}function Xe(){const o=new Date,i=o.getFullYear(),l=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0");return`${i}-${l}-${r}`}export{is as default}; diff --git a/dist/workspace_web/SpotlightSearch-T7ZdSk0R.js b/dist/workspace_web/SpotlightSearch-rjI_Y8hu.js similarity index 89% rename from dist/workspace_web/SpotlightSearch-T7ZdSk0R.js rename to dist/workspace_web/SpotlightSearch-rjI_Y8hu.js index b1debb5..2c06af3 100644 --- a/dist/workspace_web/SpotlightSearch-T7ZdSk0R.js +++ b/dist/workspace_web/SpotlightSearch-rjI_Y8hu.js @@ -1 +1 @@ -import{b as Z,f as j,k as $,o as q,e as w,r as g,j as n,g as A,Z as J,M as Q,N as X,a0 as ee,h as te}from"./input.js";import{aD as ne,aj as se,W as re,az as T,ah as D,H as ae,I as oe,T as G,a2 as ie,w as ce,a3 as le,E as ue,h as O}from"./App-ZTJclgGW.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-hyGkJAd5.js";import{V as he}from"./chunk-NTCQBYKE-vNLNCBtA.js";var[me,ge]=Z({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=$("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 Ie(){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:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},W=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,U]=pe(W,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),U(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(G,{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(G,{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=O)==null||k.getSetting("shortcuts").then(h=>{var F;const L=(h.openSpotlightSearch??((F=O)==null?void 0:F.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(D,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(D,d)}},[]),n.jsx(Q,{isOpen:!0,onClose:z,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{Ie as default}; +import{b as Z,f as j,k as $,o as q,e as w,r as g,j as n,g as A,Z as J,M as Q,N as X,a0 as ee,h as te}from"./input.js";import{aE as ne,ak as se,W as re,aA as T,ai as G,H as ae,I as oe,T as D,a3 as ie,w as ce,a4 as le,E as ue,h as O}from"./App-9GIQJeUY.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-srLS9f0l.js";import{V as he}from"./chunk-NTCQBYKE-ROuYoItA.js";var[me,ge]=Z({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=$("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 Ie(){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:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},W=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,U]=pe(W,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),U(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(D,{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(D,{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=O)==null||k.getSetting("shortcuts").then(h=>{var F;const L=(h.openSpotlightSearch??((F=O)==null?void 0:F.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:z,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{Ie as default}; diff --git a/dist/workspace_web/chunk-3RSXBRAN-oKoElBXY.js b/dist/workspace_web/chunk-3RSXBRAN-WBOq6SL0.js similarity index 81% rename from dist/workspace_web/chunk-3RSXBRAN-oKoElBXY.js rename to dist/workspace_web/chunk-3RSXBRAN-WBOq6SL0.js index 7a15973..2d3b87e 100644 --- a/dist/workspace_web/chunk-3RSXBRAN-oKoElBXY.js +++ b/dist/workspace_web/chunk-3RSXBRAN-WBOq6SL0.js @@ -1 +1 @@ -import{f as x,j as l,g as i,e as w,k as C,o as E,l as I,r as f,a3 as P}from"./input.js";import{ab as z}from"./App-ZTJclgGW.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:w("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},b={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:b,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,e as b,k as C,o as E,l as I,r as f,a3 as P}from"./input.js";import{ac as z}from"./App-9GIQJeUY.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-7D6N5TE5-wlKuxWhy.js b/dist/workspace_web/chunk-7D6N5TE5-gOmt0HWF.js similarity index 98% rename from dist/workspace_web/chunk-7D6N5TE5-wlKuxWhy.js rename to dist/workspace_web/chunk-7D6N5TE5-gOmt0HWF.js index 227271f..c537918 100644 --- a/dist/workspace_web/chunk-7D6N5TE5-wlKuxWhy.js +++ b/dist/workspace_web/chunk-7D6N5TE5-gOmt0HWF.js @@ -1 +1 @@ -import{f as ce,j as W,r as i,y as A,g as oe,d as T,x as ye,l as r,q as m,m as re}from"./input.js";import{af as pe}from"./App-ZTJclgGW.js";var z=ce(function(n,t){const{htmlWidth:o,htmlHeight:d,alt:l,...v}=n;return W.jsx("img",{width:o,height:d,ref:t,alt:l,...v})});z.displayName="NativeImage";function Ee(e){const{loading:n,src:t,srcSet:o,onLoad:d,onError:l,crossOrigin:v,sizes:w,ignoreFallback:L}=e,[h,k]=i.useState("pending");i.useEffect(()=>{k(t?"loading":"pending")},[t]);const f=i.useRef(),I=i.useCallback(()=>{if(!t)return;y();const s=new Image;s.src=t,v&&(s.crossOrigin=v),o&&(s.srcset=o),w&&(s.sizes=w),n&&(s.loading=n),s.onload=p=>{y(),k("loaded"),d==null||d(p)},s.onerror=p=>{y(),k("failed"),l==null||l(p)},f.current=s},[t,v,o,w,d,l,n]),y=()=>{f.current&&(f.current.onload=null,f.current.onerror=null,f.current=null)};return A(()=>{if(!L)return h==="loading"&&I(),()=>{y()}},[h,I,L]),L?"loaded":h}var we=(e,n)=>e!=="loaded"&&n==="beforeLoadOrError"||e==="failed"&&n==="onError";function Le(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}var Ce=ce(function(n,t){const{fallbackSrc:o,fallback:d,src:l,srcSet:v,align:w,fit:L,loading:h,ignoreFallback:k,crossOrigin:f,fallbackStrategy:I="beforeLoadOrError",referrerPolicy:y,...s}=n,p=o!==void 0||d!==void 0,P=h!=null||k||!p,B=Ee({...n,crossOrigin:f,ignoreFallback:P}),K=we(B,I),D={ref:t,objectFit:L,objectPosition:w,...P?s:Le(s,["onError","onLoad"])};return K?d||W.jsx(oe.img,{as:z,className:"chakra-image__placeholder",src:o,...D}):W.jsx(oe.img,{as:z,src:l,srcSet:v,crossOrigin:f,loading:h,referrerPolicy:y,className:"chakra-image",...D})});Ce.displayName="Image";var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Fe=()=>typeof document<"u",se=!1,M=null,C=!1,$=!1,G=new Set;function J(e,n){G.forEach(t=>t(e,n))}var Se=typeof window<"u"&&window.navigator!=null?/^Mac/.test(window.navigator.platform):!1;function Pe(e){return!(e.metaKey||!Se&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function ie(e){C=!0,Pe(e)&&(M="keyboard",J("keyboard",e))}function S(e){if(M="pointer",e.type==="mousedown"||e.type==="pointerdown"){C=!0;const n=e.composedPath?e.composedPath()[0]:e.target;let t=!1;try{t=n.matches(":focus-visible")}catch{}if(t)return;J("pointer",e)}}function De(e){return e.mozInputSource===0&&e.isTrusted?!0:e.detail===0&&!e.pointerType}function Re(e){De(e)&&(C=!0,M="virtual")}function xe(e){e.target===window||e.target===document||(!C&&!$&&(M="virtual",J("virtual",e)),C=!1,$=!1)}function Me(){C=!1,$=!0}function le(){return M!=="pointer"}function Be(){if(!Fe()||se)return;const{focus:e}=HTMLElement.prototype;HTMLElement.prototype.focus=function(...t){C=!0,e.apply(this,t)},document.addEventListener("keydown",ie,!0),document.addEventListener("keyup",ie,!0),document.addEventListener("click",Re,!0),window.addEventListener("focus",xe,!0),window.addEventListener("blur",Me,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",S,!0),document.addEventListener("pointermove",S,!0),document.addEventListener("pointerup",S,!0)):(document.addEventListener("mousedown",S,!0),document.addEventListener("mousemove",S,!0),document.addEventListener("mouseup",S,!0)),se=!0}function Ke(e){Be(),e(le());const n=()=>e(le());return G.add(n),()=>{G.delete(n)}}function Oe(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}function Ue(e={}){const n=pe(e),{isDisabled:t,isReadOnly:o,isRequired:d,isInvalid:l,id:v,onBlur:w,onFocus:L,"aria-describedby":h}=n,{defaultChecked:k,isChecked:f,isFocusable:I,onChange:y,isIndeterminate:s,name:p,value:P,tabIndex:B=void 0,"aria-label":K,"aria-labelledby":D,"aria-invalid":U,...de}=e,V=Oe(de,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),q=T(y),Q=T(w),X=T(L),[O,ue]=i.useState(!1),[E,j]=i.useState(!1),[R,Y]=i.useState(!1),[x,F]=i.useState(!1);i.useEffect(()=>Ke(ue),[]);const b=i.useRef(null),[Z,fe]=i.useState(!0),[me,N]=i.useState(!!k),_=f!==void 0,c=_?f:me,ee=i.useCallback(a=>{if(o||t){a.preventDefault();return}_||N(c?a.target.checked:s?!0:a.target.checked),q==null||q(a)},[o,t,c,_,s,q]);A(()=>{b.current&&(b.current.indeterminate=!!s)},[s]),ye(()=>{t&&j(!1)},[t,j]),A(()=>{const a=b.current;if(!(a!=null&&a.form))return;const u=()=>{N(!!k)};return a.form.addEventListener("reset",u),()=>{var g;return(g=a.form)==null?void 0:g.removeEventListener("reset",u)}},[]);const te=t&&!I,ae=i.useCallback(a=>{a.key===" "&&F(!0)},[F]),ne=i.useCallback(a=>{a.key===" "&&F(!1)},[F]);A(()=>{if(!b.current)return;b.current.checked!==c&&N(b.current.checked)},[b.current]);const ve=i.useCallback((a={},u=null)=>{const g=H=>{E&&H.preventDefault(),F(!0)};return{...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o),"aria-hidden":!0,onMouseDown:m(a.onMouseDown,g),onMouseUp:m(a.onMouseUp,()=>F(!1)),onMouseEnter:m(a.onMouseEnter,()=>Y(!0)),onMouseLeave:m(a.onMouseLeave,()=>Y(!1))}},[x,c,t,E,O,R,s,l,o]),be=i.useCallback((a={},u=null)=>({...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o)}),[x,c,t,E,O,R,s,l,o]),ge=i.useCallback((a={},u=null)=>({...V,...a,ref:re(u,g=>{g&&fe(g.tagName==="LABEL")}),onClick:m(a.onClick,()=>{var g;Z||((g=b.current)==null||g.click(),requestAnimationFrame(()=>{var H;(H=b.current)==null||H.focus({preventScroll:!0})}))}),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[V,t,c,l,Z]),he=i.useCallback((a={},u=null)=>({...a,ref:re(b,u),type:"checkbox",name:p,value:P,id:v,tabIndex:B,onChange:m(a.onChange,ee),onBlur:m(a.onBlur,Q,()=>j(!1)),onFocus:m(a.onFocus,X,()=>j(!0)),onKeyDown:m(a.onKeyDown,ae),onKeyUp:m(a.onKeyUp,ne),required:d,checked:c,disabled:te,readOnly:o,"aria-label":K,"aria-labelledby":D,"aria-invalid":U?!!U:l,"aria-describedby":h,"aria-disabled":t,style:Ie}),[p,P,v,ee,Q,X,ae,ne,d,c,te,o,K,D,U,l,h,t,B]),ke=i.useCallback((a={},u=null)=>({...a,ref:u,onMouseDown:m(a.onMouseDown,je),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[c,t,l]);return{state:{isInvalid:l,isFocused:E,isChecked:c,isActive:x,isHovered:R,isIndeterminate:s,isDisabled:t,isReadOnly:o,isRequired:d},getRootProps:ge,getCheckboxProps:ve,getIndicatorProps:be,getInputProps:he,getLabelProps:ke,htmlProps:V}}function je(e){e.preventDefault(),e.stopPropagation()}export{Ce as I,Ue as u}; +import{f as ce,j as W,r as i,y as A,g as oe,d as T,x as ye,l as r,q as m,m as re}from"./input.js";import{ag as pe}from"./App-9GIQJeUY.js";var z=ce(function(n,t){const{htmlWidth:o,htmlHeight:d,alt:l,...v}=n;return W.jsx("img",{width:o,height:d,ref:t,alt:l,...v})});z.displayName="NativeImage";function Ee(e){const{loading:n,src:t,srcSet:o,onLoad:d,onError:l,crossOrigin:v,sizes:w,ignoreFallback:L}=e,[h,k]=i.useState("pending");i.useEffect(()=>{k(t?"loading":"pending")},[t]);const f=i.useRef(),I=i.useCallback(()=>{if(!t)return;y();const s=new Image;s.src=t,v&&(s.crossOrigin=v),o&&(s.srcset=o),w&&(s.sizes=w),n&&(s.loading=n),s.onload=p=>{y(),k("loaded"),d==null||d(p)},s.onerror=p=>{y(),k("failed"),l==null||l(p)},f.current=s},[t,v,o,w,d,l,n]),y=()=>{f.current&&(f.current.onload=null,f.current.onerror=null,f.current=null)};return A(()=>{if(!L)return h==="loading"&&I(),()=>{y()}},[h,I,L]),L?"loaded":h}var we=(e,n)=>e!=="loaded"&&n==="beforeLoadOrError"||e==="failed"&&n==="onError";function Le(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}var Ce=ce(function(n,t){const{fallbackSrc:o,fallback:d,src:l,srcSet:v,align:w,fit:L,loading:h,ignoreFallback:k,crossOrigin:f,fallbackStrategy:I="beforeLoadOrError",referrerPolicy:y,...s}=n,p=o!==void 0||d!==void 0,P=h!=null||k||!p,B=Ee({...n,crossOrigin:f,ignoreFallback:P}),K=we(B,I),D={ref:t,objectFit:L,objectPosition:w,...P?s:Le(s,["onError","onLoad"])};return K?d||W.jsx(oe.img,{as:z,className:"chakra-image__placeholder",src:o,...D}):W.jsx(oe.img,{as:z,src:l,srcSet:v,crossOrigin:f,loading:h,referrerPolicy:y,className:"chakra-image",...D})});Ce.displayName="Image";var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Fe=()=>typeof document<"u",se=!1,M=null,C=!1,$=!1,G=new Set;function J(e,n){G.forEach(t=>t(e,n))}var Se=typeof window<"u"&&window.navigator!=null?/^Mac/.test(window.navigator.platform):!1;function Pe(e){return!(e.metaKey||!Se&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function ie(e){C=!0,Pe(e)&&(M="keyboard",J("keyboard",e))}function S(e){if(M="pointer",e.type==="mousedown"||e.type==="pointerdown"){C=!0;const n=e.composedPath?e.composedPath()[0]:e.target;let t=!1;try{t=n.matches(":focus-visible")}catch{}if(t)return;J("pointer",e)}}function De(e){return e.mozInputSource===0&&e.isTrusted?!0:e.detail===0&&!e.pointerType}function Re(e){De(e)&&(C=!0,M="virtual")}function xe(e){e.target===window||e.target===document||(!C&&!$&&(M="virtual",J("virtual",e)),C=!1,$=!1)}function Me(){C=!1,$=!0}function le(){return M!=="pointer"}function Be(){if(!Fe()||se)return;const{focus:e}=HTMLElement.prototype;HTMLElement.prototype.focus=function(...t){C=!0,e.apply(this,t)},document.addEventListener("keydown",ie,!0),document.addEventListener("keyup",ie,!0),document.addEventListener("click",Re,!0),window.addEventListener("focus",xe,!0),window.addEventListener("blur",Me,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",S,!0),document.addEventListener("pointermove",S,!0),document.addEventListener("pointerup",S,!0)):(document.addEventListener("mousedown",S,!0),document.addEventListener("mousemove",S,!0),document.addEventListener("mouseup",S,!0)),se=!0}function Ke(e){Be(),e(le());const n=()=>e(le());return G.add(n),()=>{G.delete(n)}}function Oe(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}function Ue(e={}){const n=pe(e),{isDisabled:t,isReadOnly:o,isRequired:d,isInvalid:l,id:v,onBlur:w,onFocus:L,"aria-describedby":h}=n,{defaultChecked:k,isChecked:f,isFocusable:I,onChange:y,isIndeterminate:s,name:p,value:P,tabIndex:B=void 0,"aria-label":K,"aria-labelledby":D,"aria-invalid":U,...de}=e,V=Oe(de,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),q=T(y),Q=T(w),X=T(L),[O,ue]=i.useState(!1),[E,j]=i.useState(!1),[R,Y]=i.useState(!1),[x,F]=i.useState(!1);i.useEffect(()=>Ke(ue),[]);const b=i.useRef(null),[Z,fe]=i.useState(!0),[me,N]=i.useState(!!k),_=f!==void 0,c=_?f:me,ee=i.useCallback(a=>{if(o||t){a.preventDefault();return}_||N(c?a.target.checked:s?!0:a.target.checked),q==null||q(a)},[o,t,c,_,s,q]);A(()=>{b.current&&(b.current.indeterminate=!!s)},[s]),ye(()=>{t&&j(!1)},[t,j]),A(()=>{const a=b.current;if(!(a!=null&&a.form))return;const u=()=>{N(!!k)};return a.form.addEventListener("reset",u),()=>{var g;return(g=a.form)==null?void 0:g.removeEventListener("reset",u)}},[]);const te=t&&!I,ae=i.useCallback(a=>{a.key===" "&&F(!0)},[F]),ne=i.useCallback(a=>{a.key===" "&&F(!1)},[F]);A(()=>{if(!b.current)return;b.current.checked!==c&&N(b.current.checked)},[b.current]);const ve=i.useCallback((a={},u=null)=>{const g=H=>{E&&H.preventDefault(),F(!0)};return{...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o),"aria-hidden":!0,onMouseDown:m(a.onMouseDown,g),onMouseUp:m(a.onMouseUp,()=>F(!1)),onMouseEnter:m(a.onMouseEnter,()=>Y(!0)),onMouseLeave:m(a.onMouseLeave,()=>Y(!1))}},[x,c,t,E,O,R,s,l,o]),be=i.useCallback((a={},u=null)=>({...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o)}),[x,c,t,E,O,R,s,l,o]),ge=i.useCallback((a={},u=null)=>({...V,...a,ref:re(u,g=>{g&&fe(g.tagName==="LABEL")}),onClick:m(a.onClick,()=>{var g;Z||((g=b.current)==null||g.click(),requestAnimationFrame(()=>{var H;(H=b.current)==null||H.focus({preventScroll:!0})}))}),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[V,t,c,l,Z]),he=i.useCallback((a={},u=null)=>({...a,ref:re(b,u),type:"checkbox",name:p,value:P,id:v,tabIndex:B,onChange:m(a.onChange,ee),onBlur:m(a.onBlur,Q,()=>j(!1)),onFocus:m(a.onFocus,X,()=>j(!0)),onKeyDown:m(a.onKeyDown,ae),onKeyUp:m(a.onKeyUp,ne),required:d,checked:c,disabled:te,readOnly:o,"aria-label":K,"aria-labelledby":D,"aria-invalid":U?!!U:l,"aria-describedby":h,"aria-disabled":t,style:Ie}),[p,P,v,ee,Q,X,ae,ne,d,c,te,o,K,D,U,l,h,t,B]),ke=i.useCallback((a={},u=null)=>({...a,ref:u,onMouseDown:m(a.onMouseDown,je),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[c,t,l]);return{state:{isInvalid:l,isFocused:E,isChecked:c,isActive:x,isHovered:R,isIndeterminate:s,isDisabled:t,isReadOnly:o,isRequired:d},getRootProps:ge,getCheckboxProps:ve,getIndicatorProps:be,getInputProps:he,getLabelProps:ke,htmlProps:V}}function je(e){e.preventDefault(),e.stopPropagation()}export{Ce as I,Ue as u}; diff --git a/dist/workspace_web/chunk-JARCRF6W-UTrQeKCZ.js b/dist/workspace_web/chunk-JARCRF6W-1gGfj837.js similarity index 97% rename from dist/workspace_web/chunk-JARCRF6W-UTrQeKCZ.js rename to dist/workspace_web/chunk-JARCRF6W-1gGfj837.js index bd927a7..8c2614f 100644 --- a/dist/workspace_web/chunk-JARCRF6W-UTrQeKCZ.js +++ b/dist/workspace_web/chunk-JARCRF6W-1gGfj837.js @@ -1 +1 @@ -import{b as D,r as h,j as t,g as i,$ as v,f as j,k as T,o as $,H as B,e as E}from"./input.js";import{u as z}from"./chunk-7D6N5TE5-wlKuxWhy.js";var[Z,F]=D({name:"CheckboxGroupContext",strict:!1});function M(o){const[s,n]=h.useState(o),[e,r]=h.useState(!1);return o!==s&&(r(!0),n(o)),e}function W(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:t.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function X(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:t.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function H(o){const{isIndeterminate:s,isChecked:n,...e}=o,r=s?X:W;return n||s?t.jsx(i.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(r,{...e})}):null}var L={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},O={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},q=v({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),J=v({from:{opacity:0},to:{opacity:1}}),K=v({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Q=j(function(s,n){const e=F(),r={...e,...s},a=T("Checkbox",r),c=$(s),{spacing:x="0.5rem",className:C,children:m,iconColor:u,iconSize:d,icon:k=t.jsx(H,{}),isChecked:f,isDisabled:g=e==null?void 0:e.isDisabled,onChange:p,inputProps:w,..._}=c;let y=f;e!=null&&e.value&&c.value&&(y=e.value.includes(c.value));let b=p;e!=null&&e.onChange&&c.value&&(b=B(e.onChange,p));const{state:l,getInputProps:A,getCheckboxProps:S,getLabelProps:G,getRootProps:P}=z({..._,isDisabled:g,isChecked:y,onChange:b}),I=M(l.isChecked),R=h.useMemo(()=>({animation:I?l.isIndeterminate?`${J} 20ms linear, ${K} 200ms linear`:`${q} 200ms linear`:void 0,fontSize:d,color:u,...a.icon}),[u,d,I,l.isIndeterminate,a.icon]),N=h.cloneElement(k,{__css:R,isIndeterminate:l.isIndeterminate,isChecked:l.isChecked});return t.jsxs(i.label,{__css:{...O,...a.container},className:E("chakra-checkbox",C),...P(),children:[t.jsx("input",{className:"chakra-checkbox__input",...A(w,n)}),t.jsx(i.span,{__css:{...L,...a.control},className:"chakra-checkbox__control",...S(),children:N}),m&&t.jsx(i.span,{className:"chakra-checkbox__label",...G(),__css:{marginStart:x,...a.label},children:m})]})});Q.displayName="Checkbox";var U=j(function(s,n){const{templateAreas:e,gap:r,rowGap:a,columnGap:c,column:x,row:C,autoFlow:m,autoRows:u,templateRows:d,autoColumns:k,templateColumns:f,...g}=s,p={display:"grid",gridTemplateAreas:e,gridGap:r,gridRowGap:a,gridColumnGap:c,gridAutoColumns:k,gridColumn:x,gridRow:C,gridAutoFlow:m,gridAutoRows:u,gridTemplateRows:d,gridTemplateColumns:f};return t.jsx(i.div,{ref:n,__css:p,...g})});U.displayName="Grid";export{Q as C,U as G}; +import{b as D,r as h,j as t,g as i,$ as v,f as j,k as T,o as $,H as B,e as E}from"./input.js";import{u as z}from"./chunk-7D6N5TE5-gOmt0HWF.js";var[Z,F]=D({name:"CheckboxGroupContext",strict:!1});function M(o){const[s,n]=h.useState(o),[e,r]=h.useState(!1);return o!==s&&(r(!0),n(o)),e}function W(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:t.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function X(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:t.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function H(o){const{isIndeterminate:s,isChecked:n,...e}=o,r=s?X:W;return n||s?t.jsx(i.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(r,{...e})}):null}var L={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},O={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},q=v({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),J=v({from:{opacity:0},to:{opacity:1}}),K=v({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Q=j(function(s,n){const e=F(),r={...e,...s},a=T("Checkbox",r),c=$(s),{spacing:x="0.5rem",className:C,children:m,iconColor:u,iconSize:d,icon:k=t.jsx(H,{}),isChecked:f,isDisabled:g=e==null?void 0:e.isDisabled,onChange:p,inputProps:w,..._}=c;let y=f;e!=null&&e.value&&c.value&&(y=e.value.includes(c.value));let b=p;e!=null&&e.onChange&&c.value&&(b=B(e.onChange,p));const{state:l,getInputProps:A,getCheckboxProps:S,getLabelProps:G,getRootProps:P}=z({..._,isDisabled:g,isChecked:y,onChange:b}),I=M(l.isChecked),R=h.useMemo(()=>({animation:I?l.isIndeterminate?`${J} 20ms linear, ${K} 200ms linear`:`${q} 200ms linear`:void 0,fontSize:d,color:u,...a.icon}),[u,d,I,l.isIndeterminate,a.icon]),N=h.cloneElement(k,{__css:R,isIndeterminate:l.isIndeterminate,isChecked:l.isChecked});return t.jsxs(i.label,{__css:{...O,...a.container},className:E("chakra-checkbox",C),...P(),children:[t.jsx("input",{className:"chakra-checkbox__input",...A(w,n)}),t.jsx(i.span,{__css:{...L,...a.control},className:"chakra-checkbox__control",...S(),children:N}),m&&t.jsx(i.span,{className:"chakra-checkbox__label",...G(),__css:{marginStart:x,...a.label},children:m})]})});Q.displayName="Checkbox";var U=j(function(s,n){const{templateAreas:e,gap:r,rowGap:a,columnGap:c,column:x,row:C,autoFlow:m,autoRows:u,templateRows:d,autoColumns:k,templateColumns:f,...g}=s,p={display:"grid",gridTemplateAreas:e,gridGap:r,gridRowGap:a,gridColumnGap:c,gridAutoColumns:k,gridColumn:x,gridRow:C,gridAutoFlow:m,gridAutoRows:u,gridTemplateRows:d,gridTemplateColumns:f};return t.jsx(i.div,{ref:n,__css:p,...g})});U.displayName="Grid";export{Q as C,U as G}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-vNLNCBtA.js b/dist/workspace_web/chunk-NTCQBYKE-ROuYoItA.js similarity index 65% rename from dist/workspace_web/chunk-NTCQBYKE-vNLNCBtA.js rename to dist/workspace_web/chunk-NTCQBYKE-ROuYoItA.js index 714c943..703d4bb 100644 --- a/dist/workspace_web/chunk-NTCQBYKE-vNLNCBtA.js +++ b/dist/workspace_web/chunk-NTCQBYKE-ROuYoItA.js @@ -1 +1 @@ -import{f as t}from"./App-ZTJclgGW.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{f as t}from"./App-9GIQJeUY.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/chunk-VTV6N5LE-qccSGxq6.js b/dist/workspace_web/chunk-VTV6N5LE-VcPf7MxV.js similarity index 95% rename from dist/workspace_web/chunk-VTV6N5LE-qccSGxq6.js rename to dist/workspace_web/chunk-VTV6N5LE-VcPf7MxV.js index 3b00f4c..fa896a2 100644 --- a/dist/workspace_web/chunk-VTV6N5LE-qccSGxq6.js +++ b/dist/workspace_web/chunk-VTV6N5LE-VcPf7MxV.js @@ -1 +1 @@ -import{f as l,n as f,o as h,j as e,g as n,e as m,k as y,r as o}from"./input.js";import{u as w}from"./chunk-7D6N5TE5-wlKuxWhy.js";var N=l(function(a,i){const s=f("Link",a),{className:c,isExternal:t,...r}=h(a);return e.jsx(n.a,{target:t?"_blank":void 0,rel:t?"noopener":void 0,ref:i,className:m("chakra-link",c),...r,__css:s})});N.displayName="Link";var j=l(function(a,i){const s=y("Switch",a),{spacing:c="0.5rem",children:t,...r}=h(a),{getIndicatorProps:u,getInputProps:p,getCheckboxProps:x,getRootProps:_,getLabelProps:g}=w(r),b=o.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...s.container}),[s.container]),S=o.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...s.track}),[s.track]),d=o.useMemo(()=>({userSelect:"none",marginStart:c,...s.label}),[c,s.label]);return e.jsxs(n.label,{..._(),className:m("chakra-switch",a.className),__css:b,children:[e.jsx("input",{className:"chakra-switch__input",...p({},i)}),e.jsx(n.span,{...x(),className:"chakra-switch__track",__css:S,children:e.jsx(n.span,{__css:s.thumb,className:"chakra-switch__thumb",...u()})}),t&&e.jsx(n.span,{className:"chakra-switch__label",...g(),__css:d,children:t})]})});j.displayName="Switch";export{N as L,j as S}; +import{f as l,n as f,o as h,j as e,g as n,e as m,k as y,r as o}from"./input.js";import{u as w}from"./chunk-7D6N5TE5-gOmt0HWF.js";var N=l(function(a,i){const s=f("Link",a),{className:c,isExternal:t,...r}=h(a);return e.jsx(n.a,{target:t?"_blank":void 0,rel:t?"noopener":void 0,ref:i,className:m("chakra-link",c),...r,__css:s})});N.displayName="Link";var j=l(function(a,i){const s=y("Switch",a),{spacing:c="0.5rem",children:t,...r}=h(a),{getIndicatorProps:u,getInputProps:p,getCheckboxProps:x,getRootProps:_,getLabelProps:g}=w(r),b=o.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...s.container}),[s.container]),S=o.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...s.track}),[s.track]),d=o.useMemo(()=>({userSelect:"none",marginStart:c,...s.label}),[c,s.label]);return e.jsxs(n.label,{..._(),className:m("chakra-switch",a.className),__css:b,children:[e.jsx("input",{className:"chakra-switch__input",...p({},i)}),e.jsx(n.span,{...x(),className:"chakra-switch__track",__css:S,children:e.jsx(n.span,{__css:s.thumb,className:"chakra-switch__thumb",...u()})}),t&&e.jsx(n.span,{className:"chakra-switch__label",...g(),__css:d,children:t})]})});j.displayName="Switch";export{N as L,j as S}; diff --git a/dist/workspace_web/civitUtils-T1Lq3reo.js b/dist/workspace_web/civitUtils-TPBejtrP.js similarity index 91% rename from dist/workspace_web/civitUtils-T1Lq3reo.js rename to dist/workspace_web/civitUtils-TPBejtrP.js index 2fecbbe..9b58a99 100644 --- a/dist/workspace_web/civitUtils-T1Lq3reo.js +++ b/dist/workspace_web/civitUtils-TPBejtrP.js @@ -1 +1 @@ -import{h as m}from"./App-ZTJclgGW.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function h(){return localStorage.getItem(r)}function g(e){localStorage.setItem(r,e)}function v(e){return`https://civitai.com/api/download/models/${e}`}async function w(e){var s,a,n;try{const l=`https://civitai.com/api/v1/model-versions/by-hash/${e}`,t=await(await fetch(l)).json();let i;if(await((s=m)==null?void 0:s.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(a=t==null?void 0:t.images)==null?void 0:a[0])==null?void 0:n.url;else if(!t.model.nsfw){const o=t.images.find(c=>c.nsfwLevel==1);i=o==null?void 0:o.url}return{modelName:t.model.name,civitModelID:String(t.modelId),civitModelVersionID:String(t.id),imageUrl:i??void 0}}catch{return{}}}export{v as a,w as f,h as g,g as s}; +import{h as m}from"./App-9GIQJeUY.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function h(){return localStorage.getItem(r)}function g(e){localStorage.setItem(r,e)}function v(e){return`https://civitai.com/api/download/models/${e}`}async function w(e){var s,a,n;try{const l=`https://civitai.com/api/v1/model-versions/by-hash/${e}`,t=await(await fetch(l)).json();let i;if(await((s=m)==null?void 0:s.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(a=t==null?void 0:t.images)==null?void 0:a[0])==null?void 0:n.url;else if(!t.model.nsfw){const o=t.images.find(c=>c.nsfwLevel==1);i=o==null?void 0:o.url}return{modelName:t.model.name,civitModelID:String(t.modelId),civitModelVersionID:String(t.id),imageUrl:i??void 0}}catch{return{}}}export{v as a,w as f,h as g,g as s}; diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js index a497b3d..cd44f8e 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-ZTJclgGW.js").then(e=>e.aJ),__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({config:{initialColorMode:"dark",useSystemColorMode:!1},zIndices:uB,components:{Card:{baseStyle:e=>({container:{backgroundColor:e.colorMode==="dark"?"#171B21":"#F6F8FA"}})}}});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{vP 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,_w as N,$w as O,ja as P,Aw as Q,Pw as R,xb as S,Ew as T,Tw as U,EB as V,os as W,Ar as X,pB as Y,Qh as Z,Xk as _,kB as a,Tp as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Be as e,pt as f,_e as g,Mx as h,SB as i,E as j,Xb as k,_v as l,If as m,Bu as n,Iu as o,mB as p,Ei as q,S as r,Gf as s,uw as t,IP as u,bB as v,Kt as w,yg as x,Bl as y,uO as z}; + `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-9GIQJeUY.js").then(e=>e.aL),__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({config:{initialColorMode:"dark",useSystemColorMode:!1},zIndices:uB,components:{Card:{baseStyle:e=>({container:{backgroundColor:e.colorMode==="dark"?"#171B21":"#F6F8FA"}})}}});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{vP 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,_w as N,$w as O,ja as P,Aw as Q,Pw as R,xb as S,Ew as T,Tw as U,EB as V,os as W,Ar as X,pB as Y,Qh as Z,Xk as _,kB as a,Tp as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Be as e,pt as f,_e as g,Mx as h,SB as i,E as j,Xb as k,_v as l,If as m,Bu as n,Iu as o,mB as p,Ei as q,S as r,Gf as s,uw as t,IP as u,bB as v,Kt as w,yg as x,Bl as y,uO as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/App-ZTJclgGW.js","workspace_web/assets/App-JXePnJiV.css"] + __vite__mapDeps.viteFileDeps = ["workspace_web/App-9GIQJeUY.js","workspace_web/assets/App-JXePnJiV.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file