@shiftengineering/folio 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(F,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(F=typeof globalThis<"u"?globalThis:F||self,_(F.FolioEmbedComponent={},F.React))})(this,function(F,_){"use strict";var bs=F=>{throw TypeError(F)};var Or=(F,_,H)=>_.has(F)||bs("Cannot "+H);var a=(F,_,H)=>(Or(F,_,"read from private field"),H?H.call(F):_.get(F)),w=(F,_,H)=>_.has(F)?bs("Cannot add the same private member more than once"):_ instanceof WeakSet?_.add(F):_.set(F,H),b=(F,_,H,U)=>(Or(F,_,"write to private field"),U?U.call(F,H):_.set(F,H),H),S=(F,_,H)=>(Or(F,_,"access private method"),H);var Vt=(F,_,H,U)=>({set _(ht){b(F,_,ht,H)},get _(){return a(F,_,U)}});var je,ve,Xe,In,Ze,we,et,kn,qe,jn,tt,rt,ne,Me,W,St,Ue,oe,me,qn,ce,Mn,le,B,Ne,fe,De,Un,he,ae,Ct,Nn,L,Ee,Oe,nt,st,Pe,it,ot,Ln,X,x,Tt,G,Le,at,Re,de,At,ut,ct,Qe,$e,Se,lt,I,Dt,Pr,Rr,Sr,Cr,Tr,Ar,xr,vs,Qn,Ce,Te,Z,ye,pe,zt,Fr,$n,Kn,Vn,zn,Hn,Wn,Bn;function H(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const U=H(_);var ht={exports:{}},yt={};/**
1
+ (function(A,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(A=typeof globalThis<"u"?globalThis:A||self,_(A.FolioEmbedComponent={},A.React))})(this,function(A,_){"use strict";var bs=A=>{throw TypeError(A)};var Pr=(A,_,H)=>_.has(A)||bs("Cannot "+H);var a=(A,_,H)=>(Pr(A,_,"read from private field"),H?H.call(A):_.get(A)),w=(A,_,H)=>_.has(A)?bs("Cannot add the same private member more than once"):_ instanceof WeakSet?_.add(A):_.set(A,H),b=(A,_,H,U)=>(Pr(A,_,"write to private field"),U?U.call(A,H):_.set(A,H),H),S=(A,_,H)=>(Pr(A,_,"access private method"),H);var Vt=(A,_,H,U)=>({set _(yt){b(A,_,yt,H)},get _(){return a(A,_,U)}});var qe,ve,Ze,In,et,we,tt,kn,Me,jn,rt,nt,ne,Ue,W,St,Ne,oe,me,qn,ce,Mn,le,B,Le,fe,De,Un,he,ae,Ct,Nn,L,Ee,Oe,st,it,Pe,ot,at,Ln,X,x,Tt,G,Qe,ut,Re,de,At,ct,lt,$e,Ke,Se,ft,I,Dt,Rr,Sr,Cr,Tr,Ar,Fr,xr,vs,Qn,Ce,Te,Z,ye,pe,Ht,Dr,$n,Kn,zn,Vn,Hn,Wn,Bn;function H(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const U=H(_);var yt={exports:{}},pt={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Dr;function ws(){if(Dr)return yt;Dr=1;var t=_,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function u(l,c,h){var f,d={},y=null,p=null;h!==void 0&&(y=""+h),c.key!==void 0&&(y=""+c.key),c.ref!==void 0&&(p=c.ref);for(f in c)n.call(c,f)&&!i.hasOwnProperty(f)&&(d[f]=c[f]);if(l&&l.defaultProps)for(f in c=l.defaultProps,c)d[f]===void 0&&(d[f]=c[f]);return{$$typeof:e,type:l,key:y,ref:p,props:d,_owner:s.current}}return yt.Fragment=r,yt.jsx=u,yt.jsxs=u,yt}var pt={};/**
9
+ */var _r;function ws(){if(_r)return pt;_r=1;var t=_,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function u(l,c,h){var f,d={},y=null,p=null;h!==void 0&&(y=""+h),c.key!==void 0&&(y=""+c.key),c.ref!==void 0&&(p=c.ref);for(f in c)n.call(c,f)&&!i.hasOwnProperty(f)&&(d[f]=c[f]);if(l&&l.defaultProps)for(f in c=l.defaultProps,c)d[f]===void 0&&(d[f]=c[f]);return{$$typeof:e,type:l,key:y,ref:p,props:d,_owner:s.current}}return pt.Fragment=r,pt.jsx=u,pt.jsxs=u,pt}var mt={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,21 +14,21 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var _r;function Es(){return _r||(_r=1,process.env.NODE_ENV!=="production"&&function(){var t=_,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),E=Symbol.iterator,g="@@iterator";function O(o){if(o===null||typeof o!="object")return null;var m=E&&o[E]||o[g];return typeof m=="function"?m:null}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(o){{for(var m=arguments.length,v=new Array(m>1?m-1:0),P=1;P<m;P++)v[P-1]=arguments[P];j("error",o,v)}}function j(o,m,v){{var P=C.ReactDebugCurrentFrame,k=P.getStackAddendum();k!==""&&(m+="%s",v=v.concat([k]));var q=v.map(function(D){return String(D)});q.unshift("Warning: "+m),Function.prototype.apply.call(console[o],console,q)}}var V=!1,Y=!1,te=!1,z=!1,N=!1,M;M=Symbol.for("react.module.reference");function Ae(o){return!!(typeof o=="string"||typeof o=="function"||o===n||o===i||N||o===s||o===h||o===f||z||o===p||V||Y||te||typeof o=="object"&&o!==null&&(o.$$typeof===y||o.$$typeof===d||o.$$typeof===u||o.$$typeof===l||o.$$typeof===c||o.$$typeof===M||o.getModuleId!==void 0))}function xe(o,m,v){var P=o.displayName;if(P)return P;var k=m.displayName||m.name||"";return k!==""?v+"("+k+")":v}function Ke(o){return o.displayName||"Context"}function Fe(o){if(o==null)return null;if(typeof o.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case n:return"Fragment";case r:return"Portal";case i:return"Profiler";case s:return"StrictMode";case h:return"Suspense";case f:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case l:var m=o;return Ke(m)+".Consumer";case u:var v=o;return Ke(v._context)+".Provider";case c:return xe(o,o.render,"ForwardRef");case d:var P=o.displayName||null;return P!==null?P:Fe(o.type)||"Memo";case y:{var k=o,q=k._payload,D=k._init;try{return Fe(D(q))}catch{return null}}}return null}var Ve=Object.assign,xt=0,Gn,Yn,Jn,Xn,Zn,es,ts;function rs(){}rs.__reactDisabledLog=!0;function To(){{if(xt===0){Gn=console.log,Yn=console.info,Jn=console.warn,Xn=console.error,Zn=console.group,es=console.groupCollapsed,ts=console.groupEnd;var o={configurable:!0,enumerable:!0,value:rs,writable:!0};Object.defineProperties(console,{info:o,log:o,warn:o,error:o,group:o,groupCollapsed:o,groupEnd:o})}xt++}}function Ao(){{if(xt--,xt===0){var o={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ve({},o,{value:Gn}),info:Ve({},o,{value:Yn}),warn:Ve({},o,{value:Jn}),error:Ve({},o,{value:Xn}),group:Ve({},o,{value:Zn}),groupCollapsed:Ve({},o,{value:es}),groupEnd:Ve({},o,{value:ts})})}xt<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var yr=C.ReactCurrentDispatcher,pr;function Lt(o,m,v){{if(pr===void 0)try{throw Error()}catch(k){var P=k.stack.trim().match(/\n( *(at )?)/);pr=P&&P[1]||""}return`
18
- `+pr+o}}var mr=!1,Qt;{var xo=typeof WeakMap=="function"?WeakMap:Map;Qt=new xo}function ns(o,m){if(!o||mr)return"";{var v=Qt.get(o);if(v!==void 0)return v}var P;mr=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var q;q=yr.current,yr.current=null,To();try{if(m){var D=function(){throw Error()};if(Object.defineProperty(D.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(D,[])}catch(ee){P=ee}Reflect.construct(o,[],D)}else{try{D.call()}catch(ee){P=ee}o.call(D.prototype)}}else{try{throw Error()}catch(ee){P=ee}o()}}catch(ee){if(ee&&P&&typeof ee.stack=="string"){for(var T=ee.stack.split(`
17
+ */var Ir;function Es(){return Ir||(Ir=1,process.env.NODE_ENV!=="production"&&function(){var t=_,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),E=Symbol.iterator,g="@@iterator";function O(o){if(o===null||typeof o!="object")return null;var m=E&&o[E]||o[g];return typeof m=="function"?m:null}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(o){{for(var m=arguments.length,v=new Array(m>1?m-1:0),P=1;P<m;P++)v[P-1]=arguments[P];j("error",o,v)}}function j(o,m,v){{var P=C.ReactDebugCurrentFrame,k=P.getStackAddendum();k!==""&&(m+="%s",v=v.concat([k]));var q=v.map(function(D){return String(D)});q.unshift("Warning: "+m),Function.prototype.apply.call(console[o],console,q)}}var z=!1,Y=!1,te=!1,V=!1,N=!1,M;M=Symbol.for("react.module.reference");function Ae(o){return!!(typeof o=="string"||typeof o=="function"||o===n||o===i||N||o===s||o===h||o===f||V||o===p||z||Y||te||typeof o=="object"&&o!==null&&(o.$$typeof===y||o.$$typeof===d||o.$$typeof===u||o.$$typeof===l||o.$$typeof===c||o.$$typeof===M||o.getModuleId!==void 0))}function Fe(o,m,v){var P=o.displayName;if(P)return P;var k=m.displayName||m.name||"";return k!==""?v+"("+k+")":v}function ze(o){return o.displayName||"Context"}function xe(o){if(o==null)return null;if(typeof o.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case n:return"Fragment";case r:return"Portal";case i:return"Profiler";case s:return"StrictMode";case h:return"Suspense";case f:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case l:var m=o;return ze(m)+".Consumer";case u:var v=o;return ze(v._context)+".Provider";case c:return Fe(o,o.render,"ForwardRef");case d:var P=o.displayName||null;return P!==null?P:xe(o.type)||"Memo";case y:{var k=o,q=k._payload,D=k._init;try{return xe(D(q))}catch{return null}}}return null}var Ve=Object.assign,Ft=0,Gn,Yn,Jn,Xn,Zn,es,ts;function rs(){}rs.__reactDisabledLog=!0;function Ao(){{if(Ft===0){Gn=console.log,Yn=console.info,Jn=console.warn,Xn=console.error,Zn=console.group,es=console.groupCollapsed,ts=console.groupEnd;var o={configurable:!0,enumerable:!0,value:rs,writable:!0};Object.defineProperties(console,{info:o,log:o,warn:o,error:o,group:o,groupCollapsed:o,groupEnd:o})}Ft++}}function Fo(){{if(Ft--,Ft===0){var o={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ve({},o,{value:Gn}),info:Ve({},o,{value:Yn}),warn:Ve({},o,{value:Jn}),error:Ve({},o,{value:Xn}),group:Ve({},o,{value:Zn}),groupCollapsed:Ve({},o,{value:es}),groupEnd:Ve({},o,{value:ts})})}Ft<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pr=C.ReactCurrentDispatcher,mr;function Qt(o,m,v){{if(mr===void 0)try{throw Error()}catch(k){var P=k.stack.trim().match(/\n( *(at )?)/);mr=P&&P[1]||""}return`
18
+ `+mr+o}}var gr=!1,$t;{var xo=typeof WeakMap=="function"?WeakMap:Map;$t=new xo}function ns(o,m){if(!o||gr)return"";{var v=$t.get(o);if(v!==void 0)return v}var P;gr=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var q;q=pr.current,pr.current=null,Ao();try{if(m){var D=function(){throw Error()};if(Object.defineProperty(D.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(D,[])}catch(ee){P=ee}Reflect.construct(o,[],D)}else{try{D.call()}catch(ee){P=ee}o.call(D.prototype)}}else{try{throw Error()}catch(ee){P=ee}o()}}catch(ee){if(ee&&P&&typeof ee.stack=="string"){for(var T=ee.stack.split(`
19
19
  `),J=P.stack.split(`
20
20
  `),Q=T.length-1,$=J.length-1;Q>=1&&$>=0&&T[Q]!==J[$];)$--;for(;Q>=1&&$>=0;Q--,$--)if(T[Q]!==J[$]){if(Q!==1||$!==1)do if(Q--,$--,$<0||T[Q]!==J[$]){var se=`
21
- `+T[Q].replace(" at new "," at ");return o.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",o.displayName)),typeof o=="function"&&Qt.set(o,se),se}while(Q>=1&&$>=0);break}}}finally{mr=!1,yr.current=q,Ao(),Error.prepareStackTrace=k}var dt=o?o.displayName||o.name:"",ze=dt?Lt(dt):"";return typeof o=="function"&&Qt.set(o,ze),ze}function Fo(o,m,v){return ns(o,!1)}function Do(o){var m=o.prototype;return!!(m&&m.isReactComponent)}function $t(o,m,v){if(o==null)return"";if(typeof o=="function")return ns(o,Do(o));if(typeof o=="string")return Lt(o);switch(o){case h:return Lt("Suspense");case f:return Lt("SuspenseList")}if(typeof o=="object")switch(o.$$typeof){case c:return Fo(o.render);case d:return $t(o.type,m,v);case y:{var P=o,k=P._payload,q=P._init;try{return $t(q(k),m,v)}catch{}}}return""}var Ft=Object.prototype.hasOwnProperty,ss={},is=C.ReactDebugCurrentFrame;function Kt(o){if(o){var m=o._owner,v=$t(o.type,o._source,m?m.type:null);is.setExtraStackFrame(v)}else is.setExtraStackFrame(null)}function _o(o,m,v,P,k){{var q=Function.call.bind(Ft);for(var D in o)if(q(o,D)){var T=void 0;try{if(typeof o[D]!="function"){var J=Error((P||"React class")+": "+v+" type `"+D+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[D]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw J.name="Invariant Violation",J}T=o[D](m,D,P,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Q){T=Q}T&&!(T instanceof Error)&&(Kt(k),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",P||"React class",v,D,typeof T),Kt(null)),T instanceof Error&&!(T.message in ss)&&(ss[T.message]=!0,Kt(k),R("Failed %s type: %s",v,T.message),Kt(null))}}}var Io=Array.isArray;function gr(o){return Io(o)}function ko(o){{var m=typeof Symbol=="function"&&Symbol.toStringTag,v=m&&o[Symbol.toStringTag]||o.constructor.name||"Object";return v}}function jo(o){try{return os(o),!1}catch{return!0}}function os(o){return""+o}function as(o){if(jo(o))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ko(o)),os(o)}var us=C.ReactCurrentOwner,qo={key:!0,ref:!0,__self:!0,__source:!0},cs,ls;function Mo(o){if(Ft.call(o,"ref")){var m=Object.getOwnPropertyDescriptor(o,"ref").get;if(m&&m.isReactWarning)return!1}return o.ref!==void 0}function Uo(o){if(Ft.call(o,"key")){var m=Object.getOwnPropertyDescriptor(o,"key").get;if(m&&m.isReactWarning)return!1}return o.key!==void 0}function No(o,m){typeof o.ref=="string"&&us.current}function Lo(o,m){{var v=function(){cs||(cs=!0,R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",m))};v.isReactWarning=!0,Object.defineProperty(o,"key",{get:v,configurable:!0})}}function Qo(o,m){{var v=function(){ls||(ls=!0,R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",m))};v.isReactWarning=!0,Object.defineProperty(o,"ref",{get:v,configurable:!0})}}var $o=function(o,m,v,P,k,q,D){var T={$$typeof:e,type:o,key:m,ref:v,props:D,_owner:q};return T._store={},Object.defineProperty(T._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(T,"_self",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.defineProperty(T,"_source",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.freeze&&(Object.freeze(T.props),Object.freeze(T)),T};function Ko(o,m,v,P,k){{var q,D={},T=null,J=null;v!==void 0&&(as(v),T=""+v),Uo(m)&&(as(m.key),T=""+m.key),Mo(m)&&(J=m.ref,No(m,k));for(q in m)Ft.call(m,q)&&!qo.hasOwnProperty(q)&&(D[q]=m[q]);if(o&&o.defaultProps){var Q=o.defaultProps;for(q in Q)D[q]===void 0&&(D[q]=Q[q])}if(T||J){var $=typeof o=="function"?o.displayName||o.name||"Unknown":o;T&&Lo(D,$),J&&Qo(D,$)}return $o(o,T,J,k,P,us.current,D)}}var br=C.ReactCurrentOwner,fs=C.ReactDebugCurrentFrame;function ft(o){if(o){var m=o._owner,v=$t(o.type,o._source,m?m.type:null);fs.setExtraStackFrame(v)}else fs.setExtraStackFrame(null)}var vr;vr=!1;function wr(o){return typeof o=="object"&&o!==null&&o.$$typeof===e}function ds(){{if(br.current){var o=Fe(br.current.type);if(o)return`
21
+ `+T[Q].replace(" at new "," at ");return o.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",o.displayName)),typeof o=="function"&&$t.set(o,se),se}while(Q>=1&&$>=0);break}}}finally{gr=!1,pr.current=q,Fo(),Error.prepareStackTrace=k}var ht=o?o.displayName||o.name:"",He=ht?Qt(ht):"";return typeof o=="function"&&$t.set(o,He),He}function Do(o,m,v){return ns(o,!1)}function _o(o){var m=o.prototype;return!!(m&&m.isReactComponent)}function Kt(o,m,v){if(o==null)return"";if(typeof o=="function")return ns(o,_o(o));if(typeof o=="string")return Qt(o);switch(o){case h:return Qt("Suspense");case f:return Qt("SuspenseList")}if(typeof o=="object")switch(o.$$typeof){case c:return Do(o.render);case d:return Kt(o.type,m,v);case y:{var P=o,k=P._payload,q=P._init;try{return Kt(q(k),m,v)}catch{}}}return""}var xt=Object.prototype.hasOwnProperty,ss={},is=C.ReactDebugCurrentFrame;function zt(o){if(o){var m=o._owner,v=Kt(o.type,o._source,m?m.type:null);is.setExtraStackFrame(v)}else is.setExtraStackFrame(null)}function Io(o,m,v,P,k){{var q=Function.call.bind(xt);for(var D in o)if(q(o,D)){var T=void 0;try{if(typeof o[D]!="function"){var J=Error((P||"React class")+": "+v+" type `"+D+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[D]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw J.name="Invariant Violation",J}T=o[D](m,D,P,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Q){T=Q}T&&!(T instanceof Error)&&(zt(k),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",P||"React class",v,D,typeof T),zt(null)),T instanceof Error&&!(T.message in ss)&&(ss[T.message]=!0,zt(k),R("Failed %s type: %s",v,T.message),zt(null))}}}var ko=Array.isArray;function br(o){return ko(o)}function jo(o){{var m=typeof Symbol=="function"&&Symbol.toStringTag,v=m&&o[Symbol.toStringTag]||o.constructor.name||"Object";return v}}function qo(o){try{return os(o),!1}catch{return!0}}function os(o){return""+o}function as(o){if(qo(o))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",jo(o)),os(o)}var us=C.ReactCurrentOwner,Mo={key:!0,ref:!0,__self:!0,__source:!0},cs,ls;function Uo(o){if(xt.call(o,"ref")){var m=Object.getOwnPropertyDescriptor(o,"ref").get;if(m&&m.isReactWarning)return!1}return o.ref!==void 0}function No(o){if(xt.call(o,"key")){var m=Object.getOwnPropertyDescriptor(o,"key").get;if(m&&m.isReactWarning)return!1}return o.key!==void 0}function Lo(o,m){typeof o.ref=="string"&&us.current}function Qo(o,m){{var v=function(){cs||(cs=!0,R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",m))};v.isReactWarning=!0,Object.defineProperty(o,"key",{get:v,configurable:!0})}}function $o(o,m){{var v=function(){ls||(ls=!0,R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",m))};v.isReactWarning=!0,Object.defineProperty(o,"ref",{get:v,configurable:!0})}}var Ko=function(o,m,v,P,k,q,D){var T={$$typeof:e,type:o,key:m,ref:v,props:D,_owner:q};return T._store={},Object.defineProperty(T._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(T,"_self",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.defineProperty(T,"_source",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.freeze&&(Object.freeze(T.props),Object.freeze(T)),T};function zo(o,m,v,P,k){{var q,D={},T=null,J=null;v!==void 0&&(as(v),T=""+v),No(m)&&(as(m.key),T=""+m.key),Uo(m)&&(J=m.ref,Lo(m,k));for(q in m)xt.call(m,q)&&!Mo.hasOwnProperty(q)&&(D[q]=m[q]);if(o&&o.defaultProps){var Q=o.defaultProps;for(q in Q)D[q]===void 0&&(D[q]=Q[q])}if(T||J){var $=typeof o=="function"?o.displayName||o.name||"Unknown":o;T&&Qo(D,$),J&&$o(D,$)}return Ko(o,T,J,k,P,us.current,D)}}var vr=C.ReactCurrentOwner,fs=C.ReactDebugCurrentFrame;function dt(o){if(o){var m=o._owner,v=Kt(o.type,o._source,m?m.type:null);fs.setExtraStackFrame(v)}else fs.setExtraStackFrame(null)}var wr;wr=!1;function Er(o){return typeof o=="object"&&o!==null&&o.$$typeof===e}function ds(){{if(vr.current){var o=xe(vr.current.type);if(o)return`
22
22
 
23
- Check the render method of \``+o+"`."}return""}}function Vo(o){return""}var hs={};function zo(o){{var m=ds();if(!m){var v=typeof o=="string"?o:o.displayName||o.name;v&&(m=`
23
+ Check the render method of \``+o+"`."}return""}}function Vo(o){return""}var hs={};function Ho(o){{var m=ds();if(!m){var v=typeof o=="string"?o:o.displayName||o.name;v&&(m=`
24
24
 
25
- Check the top-level render call using <`+v+">.")}return m}}function ys(o,m){{if(!o._store||o._store.validated||o.key!=null)return;o._store.validated=!0;var v=zo(m);if(hs[v])return;hs[v]=!0;var P="";o&&o._owner&&o._owner!==br.current&&(P=" It was passed a child from "+Fe(o._owner.type)+"."),ft(o),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,P),ft(null)}}function ps(o,m){{if(typeof o!="object")return;if(gr(o))for(var v=0;v<o.length;v++){var P=o[v];wr(P)&&ys(P,m)}else if(wr(o))o._store&&(o._store.validated=!0);else if(o){var k=O(o);if(typeof k=="function"&&k!==o.entries)for(var q=k.call(o),D;!(D=q.next()).done;)wr(D.value)&&ys(D.value,m)}}}function Ho(o){{var m=o.type;if(m==null||typeof m=="string")return;var v;if(typeof m=="function")v=m.propTypes;else if(typeof m=="object"&&(m.$$typeof===c||m.$$typeof===d))v=m.propTypes;else return;if(v){var P=Fe(m);_o(v,o.props,"prop",P,o)}else if(m.PropTypes!==void 0&&!vr){vr=!0;var k=Fe(m);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof m.getDefaultProps=="function"&&!m.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Wo(o){{for(var m=Object.keys(o.props),v=0;v<m.length;v++){var P=m[v];if(P!=="children"&&P!=="key"){ft(o),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",P),ft(null);break}}o.ref!==null&&(ft(o),R("Invalid attribute `ref` supplied to `React.Fragment`."),ft(null))}}var ms={};function gs(o,m,v,P,k,q){{var D=Ae(o);if(!D){var T="";(o===void 0||typeof o=="object"&&o!==null&&Object.keys(o).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var J=Vo();J?T+=J:T+=ds();var Q;o===null?Q="null":gr(o)?Q="array":o!==void 0&&o.$$typeof===e?(Q="<"+(Fe(o.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):Q=typeof o,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Q,T)}var $=Ko(o,m,v,k,q);if($==null)return $;if(D){var se=m.children;if(se!==void 0)if(P)if(gr(se)){for(var dt=0;dt<se.length;dt++)ps(se[dt],o);Object.freeze&&Object.freeze(se)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ps(se,o)}if(Ft.call(m,"key")){var ze=Fe(o),ee=Object.keys(m).filter(function(Zo){return Zo!=="key"}),Er=ee.length>0?"{key: someKey, "+ee.join(": ..., ")+": ...}":"{key: someKey}";if(!ms[ze+Er]){var Xo=ee.length>0?"{"+ee.join(": ..., ")+": ...}":"{}";R(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+v+">.")}return m}}function ys(o,m){{if(!o._store||o._store.validated||o.key!=null)return;o._store.validated=!0;var v=Ho(m);if(hs[v])return;hs[v]=!0;var P="";o&&o._owner&&o._owner!==vr.current&&(P=" It was passed a child from "+xe(o._owner.type)+"."),dt(o),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,P),dt(null)}}function ps(o,m){{if(typeof o!="object")return;if(br(o))for(var v=0;v<o.length;v++){var P=o[v];Er(P)&&ys(P,m)}else if(Er(o))o._store&&(o._store.validated=!0);else if(o){var k=O(o);if(typeof k=="function"&&k!==o.entries)for(var q=k.call(o),D;!(D=q.next()).done;)Er(D.value)&&ys(D.value,m)}}}function Wo(o){{var m=o.type;if(m==null||typeof m=="string")return;var v;if(typeof m=="function")v=m.propTypes;else if(typeof m=="object"&&(m.$$typeof===c||m.$$typeof===d))v=m.propTypes;else return;if(v){var P=xe(m);Io(v,o.props,"prop",P,o)}else if(m.PropTypes!==void 0&&!wr){wr=!0;var k=xe(m);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof m.getDefaultProps=="function"&&!m.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Bo(o){{for(var m=Object.keys(o.props),v=0;v<m.length;v++){var P=m[v];if(P!=="children"&&P!=="key"){dt(o),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",P),dt(null);break}}o.ref!==null&&(dt(o),R("Invalid attribute `ref` supplied to `React.Fragment`."),dt(null))}}var ms={};function gs(o,m,v,P,k,q){{var D=Ae(o);if(!D){var T="";(o===void 0||typeof o=="object"&&o!==null&&Object.keys(o).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var J=Vo();J?T+=J:T+=ds();var Q;o===null?Q="null":br(o)?Q="array":o!==void 0&&o.$$typeof===e?(Q="<"+(xe(o.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):Q=typeof o,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Q,T)}var $=zo(o,m,v,k,q);if($==null)return $;if(D){var se=m.children;if(se!==void 0)if(P)if(br(se)){for(var ht=0;ht<se.length;ht++)ps(se[ht],o);Object.freeze&&Object.freeze(se)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ps(se,o)}if(xt.call(m,"key")){var He=xe(o),ee=Object.keys(m).filter(function(ea){return ea!=="key"}),Or=ee.length>0?"{key: someKey, "+ee.join(": ..., ")+": ...}":"{key: someKey}";if(!ms[He+Or]){var Zo=ee.length>0?"{"+ee.join(": ..., ")+": ...}":"{}";R(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Er,ze,Xo,ze),ms[ze+Er]=!0}}return o===n?Wo($):Ho($),$}}function Bo(o,m,v){return gs(o,m,v,!0)}function Go(o,m,v){return gs(o,m,v,!1)}var Yo=Go,Jo=Bo;pt.Fragment=n,pt.jsx=Yo,pt.jsxs=Jo}()),pt}process.env.NODE_ENV==="production"?ht.exports=ws():ht.exports=Es();var mt=ht.exports,Ht=(t=>(t.NOT_CHUNKED="NOT_CHUNKED",t.PROCESSING="PROCESSING",t.CHUNKED="CHUNKED",t.ERROR_CHUNKING="ERROR_CHUNKING",t))(Ht||{}),Wt=(t=>(t.PDF="application/pdf",t.TXT="text/plain",t.CSV="text/csv",t.DIRECTORY="inode/directory",t.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",t))(Wt||{});const gt=4e3*1024*1024,Ir={"application/pdf":{extensions:[".pdf"],maxSize:gt},"text/plain":{extensions:[".txt",".json",".py",".ts",".tsx"],maxSize:gt},"text/csv":{extensions:[".csv"],maxSize:gt},"inode/directory":{extensions:[],maxSize:gt},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{extensions:[".docx"],maxSize:gt}};Object.entries(Ir).reduce((t,[e,r])=>({...t,[e]:r.extensions}),{});const Os=new Set(Object.values(Wt));var He=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_e=typeof window>"u"||"Deno"in globalThis;function re(){}function Ps(t,e){return typeof t=="function"?t(e):t}function Bt(t){return typeof t=="number"&&t>=0&&t!==1/0}function kr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function We(t,e){return typeof t=="function"?t(e):t}function ie(t,e){return typeof t=="function"?t(e):t}function jr(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:i,queryKey:u,stale:l}=t;if(u){if(n){if(e.queryHash!==Gt(u,e.options))return!1}else if(!bt(e.queryKey,u))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||s&&s!==e.state.fetchStatus||i&&!i(e))}function qr(t,e){const{exact:r,status:n,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(Ie(e.options.mutationKey)!==Ie(i))return!1}else if(!bt(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Gt(t,e){return((e==null?void 0:e.queryKeyHashFn)||Ie)(t)}function Ie(t){return JSON.stringify(t,(e,r)=>Jt(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function bt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(r=>!bt(t[r],e[r])):!1}function Yt(t,e){if(t===e)return t;const r=Mr(t)&&Mr(e);if(r||Jt(t)&&Jt(e)){const n=r?t:Object.keys(t),s=n.length,i=r?e:Object.keys(e),u=i.length,l=r?[]:{};let c=0;for(let h=0;h<u;h++){const f=r?h:i[h];(!r&&n.includes(f)||r)&&t[f]===void 0&&e[f]===void 0?(l[f]=void 0,c++):(l[f]=Yt(t[f],e[f]),l[f]===t[f]&&t[f]!==void 0&&c++)}return s===u&&c===s?t:l}return e}function _t(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function Mr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Jt(t){if(!Ur(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!Ur(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Ur(t){return Object.prototype.toString.call(t)==="[object Object]"}function Rs(t){return new Promise(e=>{setTimeout(e,t)})}function Xt(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Yt(t,e)}catch(n){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`)}return Yt(t,e)}return e}function Ss(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function Cs(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var It=Symbol();function Nr(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===It&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===It?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Ts=(In=class extends He{constructor(){super();w(this,je);w(this,ve);w(this,Xe);b(this,Xe,e=>{if(!_e&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){a(this,ve)||this.setEventListener(a(this,Xe))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,ve))==null||e.call(this),b(this,ve,void 0))}setEventListener(e){var r;b(this,Xe,e),(r=a(this,ve))==null||r.call(this),b(this,ve,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){a(this,je)!==e&&(b(this,je,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof a(this,je)=="boolean"?a(this,je):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},je=new WeakMap,ve=new WeakMap,Xe=new WeakMap,In),Zt=new Ts,As=(kn=class extends He{constructor(){super();w(this,Ze,!0);w(this,we);w(this,et);b(this,et,e=>{if(!_e&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){a(this,we)||this.setEventListener(a(this,et))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,we))==null||e.call(this),b(this,we,void 0))}setEventListener(e){var r;b(this,et,e),(r=a(this,we))==null||r.call(this),b(this,we,e(this.setOnline.bind(this)))}setOnline(e){a(this,Ze)!==e&&(b(this,Ze,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return a(this,Ze)}},Ze=new WeakMap,we=new WeakMap,et=new WeakMap,kn),kt=new As;function er(){let t,e;const r=new Promise((s,i)=>{t=s,e=i});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function xs(t){return Math.min(1e3*2**t,3e4)}function Lr(t){return(t??"online")==="online"?kt.isOnline():!0}var Qr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function tr(t){return t instanceof Qr}function $r(t){let e=!1,r=0,n=!1,s;const i=er(),u=g=>{var O;n||(y(new Qr(g)),(O=t.abort)==null||O.call(t))},l=()=>{e=!0},c=()=>{e=!1},h=()=>Zt.isFocused()&&(t.networkMode==="always"||kt.isOnline())&&t.canRun(),f=()=>Lr(t.networkMode)&&t.canRun(),d=g=>{var O;n||(n=!0,(O=t.onSuccess)==null||O.call(t,g),s==null||s(),i.resolve(g))},y=g=>{var O;n||(n=!0,(O=t.onError)==null||O.call(t,g),s==null||s(),i.reject(g))},p=()=>new Promise(g=>{var O;s=C=>{(n||h())&&g(C)},(O=t.onPause)==null||O.call(t)}).then(()=>{var g;s=void 0,n||(g=t.onContinue)==null||g.call(t)}),E=()=>{if(n)return;let g;const O=r===0?t.initialPromise:void 0;try{g=O??t.fn()}catch(C){g=Promise.reject(C)}Promise.resolve(g).then(d).catch(C=>{var te;if(n)return;const R=t.retry??(_e?0:3),j=t.retryDelay??xs,V=typeof j=="function"?j(r,C):j,Y=R===!0||typeof R=="number"&&r<R||typeof R=="function"&&R(r,C);if(e||!Y){y(C);return}r++,(te=t.onFail)==null||te.call(t,r,C),Rs(V).then(()=>h()?void 0:p()).then(()=>{e?y(C):E()})})};return{promise:i,cancel:u,continue:()=>(s==null||s(),i),cancelRetry:l,continueRetry:c,canStart:f,start:()=>(f()?E():p().then(E),i)}}function Fs(){let t=[],e=0,r=l=>{l()},n=l=>{l()},s=l=>setTimeout(l,0);const i=l=>{e?t.push(l):s(()=>{r(l)})},u=()=>{const l=t;t=[],l.length&&s(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||u()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{s=l}}}var K=Fs(),Kr=(jn=class{constructor(){w(this,qe)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bt(this.gcTime)&&b(this,qe,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(_e?1/0:5*60*1e3))}clearGcTimeout(){a(this,qe)&&(clearTimeout(a(this,qe)),b(this,qe,void 0))}},qe=new WeakMap,jn),Ds=(qn=class extends Kr{constructor(e){super();w(this,oe);w(this,tt);w(this,rt);w(this,ne);w(this,Me);w(this,W);w(this,St);w(this,Ue);b(this,Ue,!1),b(this,St,e.defaultOptions),this.setOptions(e.options),this.observers=[],b(this,Me,e.client),b(this,ne,a(this,Me).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,b(this,tt,_s(this.options)),this.state=e.state??a(this,tt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=a(this,W))==null?void 0:e.promise}setOptions(e){this.options={...a(this,St),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&a(this,ne).remove(this)}setData(e,r){const n=Xt(this.state.data,e,this.options);return S(this,oe,me).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){S(this,oe,me).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=a(this,W))==null?void 0:n.promise;return(s=a(this,W))==null||s.cancel(e),r?r.then(re).catch(re):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,tt))}isActive(){return this.observers.some(e=>ie(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===It||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!kr(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,W))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,W))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),a(this,ne).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(a(this,W)&&(a(this,Ue)?a(this,W).cancel({revert:!0}):a(this,W).cancelRetry()),this.scheduleGc()),a(this,ne).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||S(this,oe,me).call(this,{type:"invalidate"})}fetch(e,r){var c,h,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(a(this,W))return a(this,W).continueRetry(),a(this,W).promise}if(e&&this.setOptions(e),!this.options.queryFn){const d=this.observers.find(y=>y.options.queryFn);d&&this.setOptions(d.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,s=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(b(this,Ue,!0),n.signal)})},i=()=>{const d=Nr(this.options,r),y={client:a(this,Me),queryKey:this.queryKey,meta:this.meta};return s(y),b(this,Ue,!1),this.options.persister?this.options.persister(d,y,this):d(y)},u={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:a(this,Me),state:this.state,fetchFn:i};s(u),(c=this.options.behavior)==null||c.onFetch(u,this),b(this,rt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=u.fetchOptions)==null?void 0:h.meta))&&S(this,oe,me).call(this,{type:"fetch",meta:(f=u.fetchOptions)==null?void 0:f.meta});const l=d=>{var y,p,E,g;tr(d)&&d.silent||S(this,oe,me).call(this,{type:"error",error:d}),tr(d)||((p=(y=a(this,ne).config).onError)==null||p.call(y,d,this),(g=(E=a(this,ne).config).onSettled)==null||g.call(E,this.state.data,d,this)),this.scheduleGc()};return b(this,W,$r({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:d=>{var y,p,E,g;if(d===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(d)}catch(O){l(O);return}(p=(y=a(this,ne).config).onSuccess)==null||p.call(y,d,this),(g=(E=a(this,ne).config).onSettled)==null||g.call(E,d,this.state.error,this),this.scheduleGc()},onError:l,onFail:(d,y)=>{S(this,oe,me).call(this,{type:"failed",failureCount:d,error:y})},onPause:()=>{S(this,oe,me).call(this,{type:"pause"})},onContinue:()=>{S(this,oe,me).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0})),a(this,W).start()}},tt=new WeakMap,rt=new WeakMap,ne=new WeakMap,Me=new WeakMap,W=new WeakMap,St=new WeakMap,Ue=new WeakMap,oe=new WeakSet,me=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Vr(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return tr(s)&&s.revert&&a(this,rt)?{...a(this,rt),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),K.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),a(this,ne).notify({query:this,type:"updated",action:e})})},qn);function Vr(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Lr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function _s(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Is=(Mn=class extends He{constructor(e={}){super();w(this,ce);this.config=e,b(this,ce,new Map)}build(e,r,n){const s=r.queryKey,i=r.queryHash??Gt(s,r);let u=this.get(i);return u||(u=new Ds({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(u)),u}add(e){a(this,ce).has(e.queryHash)||(a(this,ce).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=a(this,ce).get(e.queryHash);r&&(e.destroy(),r===e&&a(this,ce).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){K.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return a(this,ce).get(e)}getAll(){return[...a(this,ce).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>jr(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>jr(e,n)):r}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){K.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){K.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ce=new WeakMap,Mn),ks=(Un=class extends Kr{constructor(e){super();w(this,fe);w(this,le);w(this,B);w(this,Ne);this.mutationId=e.mutationId,b(this,B,e.mutationCache),b(this,le,[]),this.state=e.state||zr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){a(this,le).includes(e)||(a(this,le).push(e),this.clearGcTimeout(),a(this,B).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){b(this,le,a(this,le).filter(r=>r!==e)),this.scheduleGc(),a(this,B).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){a(this,le).length||(this.state.status==="pending"?this.scheduleGc():a(this,B).remove(this))}continue(){var e;return((e=a(this,Ne))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var s,i,u,l,c,h,f,d,y,p,E,g,O,C,R,j,V,Y,te,z;b(this,Ne,$r({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(N,M)=>{S(this,fe,De).call(this,{type:"failed",failureCount:N,error:M})},onPause:()=>{S(this,fe,De).call(this,{type:"pause"})},onContinue:()=>{S(this,fe,De).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>a(this,B).canRun(this)}));const r=this.state.status==="pending",n=!a(this,Ne).canStart();try{if(!r){S(this,fe,De).call(this,{type:"pending",variables:e,isPaused:n}),await((i=(s=a(this,B).config).onMutate)==null?void 0:i.call(s,e,this));const M=await((l=(u=this.options).onMutate)==null?void 0:l.call(u,e));M!==this.state.context&&S(this,fe,De).call(this,{type:"pending",context:M,variables:e,isPaused:n})}const N=await a(this,Ne).start();return await((h=(c=a(this,B).config).onSuccess)==null?void 0:h.call(c,N,e,this.state.context,this)),await((d=(f=this.options).onSuccess)==null?void 0:d.call(f,N,e,this.state.context)),await((p=(y=a(this,B).config).onSettled)==null?void 0:p.call(y,N,null,this.state.variables,this.state.context,this)),await((g=(E=this.options).onSettled)==null?void 0:g.call(E,N,null,e,this.state.context)),S(this,fe,De).call(this,{type:"success",data:N}),N}catch(N){try{throw await((C=(O=a(this,B).config).onError)==null?void 0:C.call(O,N,e,this.state.context,this)),await((j=(R=this.options).onError)==null?void 0:j.call(R,N,e,this.state.context)),await((Y=(V=a(this,B).config).onSettled)==null?void 0:Y.call(V,void 0,N,this.state.variables,this.state.context,this)),await((z=(te=this.options).onSettled)==null?void 0:z.call(te,void 0,N,e,this.state.context)),N}finally{S(this,fe,De).call(this,{type:"error",error:N})}}finally{a(this,B).runNext(this)}}},le=new WeakMap,B=new WeakMap,Ne=new WeakMap,fe=new WeakSet,De=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),K.batch(()=>{a(this,le).forEach(n=>{n.onMutationUpdate(e)}),a(this,B).notify({mutation:this,type:"updated",action:e})})},Un);function zr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var js=(Nn=class extends He{constructor(e={}){super();w(this,he);w(this,ae);w(this,Ct);this.config=e,b(this,he,new Set),b(this,ae,new Map),b(this,Ct,0)}build(e,r,n){const s=new ks({mutationCache:this,mutationId:++Vt(this,Ct)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){a(this,he).add(e);const r=jt(e);if(typeof r=="string"){const n=a(this,ae).get(r);n?n.push(e):a(this,ae).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(a(this,he).delete(e)){const r=jt(e);if(typeof r=="string"){const n=a(this,ae).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&a(this,ae).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=jt(e);if(typeof r=="string"){const n=a(this,ae).get(r),s=n==null?void 0:n.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=jt(e);if(typeof r=="string"){const s=(n=a(this,ae).get(r))==null?void 0:n.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){K.batch(()=>{a(this,he).forEach(e=>{this.notify({type:"removed",mutation:e})}),a(this,he).clear(),a(this,ae).clear()})}getAll(){return Array.from(a(this,he))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>qr(r,n))}findAll(e={}){return this.getAll().filter(r=>qr(e,r))}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return K.batch(()=>Promise.all(e.map(r=>r.continue().catch(re))))}},he=new WeakMap,ae=new WeakMap,Ct=new WeakMap,Nn);function jt(t){var e;return(e=t.options.scope)==null?void 0:e.id}function Hr(t){return{onFetch:(e,r)=>{var f,d,y,p,E;const n=e.options,s=(y=(d=(f=e.fetchOptions)==null?void 0:f.meta)==null?void 0:d.fetchMore)==null?void 0:y.direction,i=((p=e.state.data)==null?void 0:p.pages)||[],u=((E=e.state.data)==null?void 0:E.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const h=async()=>{let g=!1;const O=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(e.signal.aborted?g=!0:e.signal.addEventListener("abort",()=>{g=!0}),e.signal)})},C=Nr(e.options,e.fetchOptions),R=async(j,V,Y)=>{if(g)return Promise.reject();if(V==null&&j.pages.length)return Promise.resolve(j);const te={client:e.client,queryKey:e.queryKey,pageParam:V,direction:Y?"backward":"forward",meta:e.options.meta};O(te);const z=await C(te),{maxPages:N}=e.options,M=Y?Cs:Ss;return{pages:M(j.pages,z,N),pageParams:M(j.pageParams,V,N)}};if(s&&i.length){const j=s==="backward",V=j?qs:Wr,Y={pages:i,pageParams:u},te=V(n,Y);l=await R(Y,te,j)}else{const j=t??i.length;do{const V=c===0?u[0]??n.initialPageParam:Wr(n,l);if(c>0&&V==null)break;l=await R(l,V),c++}while(c<j)}return l};e.options.persister?e.fetchFn=()=>{var g,O;return(O=(g=e.options).persister)==null?void 0:O.call(g,h,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=h}}}function Wr(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function qs(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var Ms=(Ln=class{constructor(t={}){w(this,L);w(this,Ee);w(this,Oe);w(this,nt);w(this,st);w(this,Pe);w(this,it);w(this,ot);b(this,L,t.queryCache||new Is),b(this,Ee,t.mutationCache||new js),b(this,Oe,t.defaultOptions||{}),b(this,nt,new Map),b(this,st,new Map),b(this,Pe,0)}mount(){Vt(this,Pe)._++,a(this,Pe)===1&&(b(this,it,Zt.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,L).onFocus())})),b(this,ot,kt.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,L).onOnline())})))}unmount(){var t,e;Vt(this,Pe)._--,a(this,Pe)===0&&((t=a(this,it))==null||t.call(this),b(this,it,void 0),(e=a(this,ot))==null||e.call(this),b(this,ot,void 0))}isFetching(t){return a(this,L).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return a(this,Ee).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,L).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=a(this,L).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(We(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return a(this,L).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=a(this,L).get(n.queryHash),i=s==null?void 0:s.state.data,u=Ps(e,i);if(u!==void 0)return a(this,L).build(this,n).setData(u,{...r,manual:!0})}setQueriesData(t,e,r){return K.batch(()=>a(this,L).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,L).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=a(this,L);K.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=a(this,L);return K.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=K.batch(()=>a(this,L).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(re).catch(re)}invalidateQueries(t,e={}){return K.batch(()=>(a(this,L).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=K.batch(()=>a(this,L).findAll(t).filter(s=>!s.isDisabled()).map(s=>{let i=s.fetch(void 0,r);return r.throwOnError||(i=i.catch(re)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(re)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=a(this,L).build(this,e);return r.isStaleByTime(We(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(re).catch(re)}fetchInfiniteQuery(t){return t.behavior=Hr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(re).catch(re)}ensureInfiniteQueryData(t){return t.behavior=Hr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return kt.isOnline()?a(this,Ee).resumePausedMutations():Promise.resolve()}getQueryCache(){return a(this,L)}getMutationCache(){return a(this,Ee)}getDefaultOptions(){return a(this,Oe)}setDefaultOptions(t){b(this,Oe,t)}setQueryDefaults(t,e){a(this,nt).set(Ie(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...a(this,nt).values()],r={};return e.forEach(n=>{bt(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){a(this,st).set(Ie(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...a(this,st).values()],r={};return e.forEach(n=>{bt(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...a(this,Oe).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Gt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===It&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...a(this,Oe).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){a(this,L).clear(),a(this,Ee).clear()}},L=new WeakMap,Ee=new WeakMap,Oe=new WeakMap,nt=new WeakMap,st=new WeakMap,Pe=new WeakMap,it=new WeakMap,ot=new WeakMap,Ln),Us=(Qn=class extends He{constructor(e,r){super();w(this,I);w(this,X);w(this,x);w(this,Tt);w(this,G);w(this,Le);w(this,at);w(this,Re);w(this,de);w(this,At);w(this,ut);w(this,ct);w(this,Qe);w(this,$e);w(this,Se);w(this,lt,new Set);this.options=r,b(this,X,e),b(this,de,null),b(this,Re,er()),this.options.experimental_prefetchInRender||a(this,Re).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,x).addObserver(this),Br(a(this,x),this.options)?S(this,I,Dt).call(this):this.updateResult(),S(this,I,Cr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rr(a(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rr(a(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,S(this,I,Tr).call(this),S(this,I,Ar).call(this),a(this,x).removeObserver(this)}setOptions(e,r){const n=this.options,s=a(this,x);if(this.options=a(this,X).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ie(this.options.enabled,a(this,x))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");S(this,I,xr).call(this),a(this,x).setOptions(this.options),n._defaulted&&!_t(this.options,n)&&a(this,X).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,x),observer:this});const i=this.hasListeners();i&&Gr(a(this,x),s,this.options,n)&&S(this,I,Dt).call(this),this.updateResult(r),i&&(a(this,x)!==s||ie(this.options.enabled,a(this,x))!==ie(n.enabled,a(this,x))||We(this.options.staleTime,a(this,x))!==We(n.staleTime,a(this,x)))&&S(this,I,Pr).call(this);const u=S(this,I,Rr).call(this);i&&(a(this,x)!==s||ie(this.options.enabled,a(this,x))!==ie(n.enabled,a(this,x))||u!==a(this,Se))&&S(this,I,Sr).call(this,u)}getOptimisticResult(e){const r=a(this,X).getQueryCache().build(a(this,X),e),n=this.createResult(r,e);return Ls(this,n)&&(b(this,G,n),b(this,at,this.options),b(this,Le,a(this,x).state)),n}getCurrentResult(){return a(this,G)}trackResult(e,r){const n={};return Object.keys(e).forEach(s=>{Object.defineProperty(n,s,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(s),r==null||r(s),e[s])})}),n}trackProp(e){a(this,lt).add(e)}getCurrentQuery(){return a(this,x)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=a(this,X).defaultQueryOptions(e),n=a(this,X).getQueryCache().build(a(this,X),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return S(this,I,Dt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,G)))}createResult(e,r){var N;const n=a(this,x),s=this.options,i=a(this,G),u=a(this,Le),l=a(this,at),h=e!==n?e.state:a(this,Tt),{state:f}=e;let d={...f},y=!1,p;if(r._optimisticResults){const M=this.hasListeners(),Ae=!M&&Br(e,r),xe=M&&Gr(e,n,r,s);(Ae||xe)&&(d={...d,...Vr(f.data,e.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:E,errorUpdatedAt:g,status:O}=d;if(r.select&&d.data!==void 0)if(i&&d.data===(u==null?void 0:u.data)&&r.select===a(this,At))p=a(this,ut);else try{b(this,At,r.select),p=r.select(d.data),p=Xt(i==null?void 0:i.data,p,r),b(this,ut,p),b(this,de,null)}catch(M){b(this,de,M)}else p=d.data;if(r.placeholderData!==void 0&&p===void 0&&O==="pending"){let M;if(i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData))M=i.data;else if(M=typeof r.placeholderData=="function"?r.placeholderData((N=a(this,ct))==null?void 0:N.state.data,a(this,ct)):r.placeholderData,r.select&&M!==void 0)try{M=r.select(M),b(this,de,null)}catch(Ae){b(this,de,Ae)}M!==void 0&&(O="success",p=Xt(i==null?void 0:i.data,M,r),y=!0)}a(this,de)&&(E=a(this,de),p=a(this,ut),g=Date.now(),O="error");const C=d.fetchStatus==="fetching",R=O==="pending",j=O==="error",V=R&&C,Y=p!==void 0,z={status:O,fetchStatus:d.fetchStatus,isPending:R,isSuccess:O==="success",isError:j,isInitialLoading:V,isLoading:V,data:p,dataUpdatedAt:d.dataUpdatedAt,error:E,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>h.dataUpdateCount||d.errorUpdateCount>h.errorUpdateCount,isFetching:C,isRefetching:C&&!R,isLoadingError:j&&!Y,isPaused:d.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:j&&Y,isStale:nr(e,r),refetch:this.refetch,promise:a(this,Re)};if(this.options.experimental_prefetchInRender){const M=Ke=>{z.status==="error"?Ke.reject(z.error):z.data!==void 0&&Ke.resolve(z.data)},Ae=()=>{const Ke=b(this,Re,z.promise=er());M(Ke)},xe=a(this,Re);switch(xe.status){case"pending":e.queryHash===n.queryHash&&M(xe);break;case"fulfilled":(z.status==="error"||z.data!==xe.value)&&Ae();break;case"rejected":(z.status!=="error"||z.error!==xe.reason)&&Ae();break}}return z}updateResult(e){const r=a(this,G),n=this.createResult(a(this,x),this.options);if(b(this,Le,a(this,x).state),b(this,at,this.options),a(this,Le).data!==void 0&&b(this,ct,a(this,x)),_t(n,r))return;b(this,G,n);const s={},i=()=>{if(!r)return!0;const{notifyOnChangeProps:u}=this.options,l=typeof u=="function"?u():u;if(l==="all"||!l&&!a(this,lt).size)return!0;const c=new Set(l??a(this,lt));return this.options.throwOnError&&c.add("error"),Object.keys(a(this,G)).some(h=>{const f=h;return a(this,G)[f]!==r[f]&&c.has(f)})};(e==null?void 0:e.listeners)!==!1&&i()&&(s.listeners=!0),S(this,I,vs).call(this,{...s,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&S(this,I,Cr).call(this)}},X=new WeakMap,x=new WeakMap,Tt=new WeakMap,G=new WeakMap,Le=new WeakMap,at=new WeakMap,Re=new WeakMap,de=new WeakMap,At=new WeakMap,ut=new WeakMap,ct=new WeakMap,Qe=new WeakMap,$e=new WeakMap,Se=new WeakMap,lt=new WeakMap,I=new WeakSet,Dt=function(e){S(this,I,xr).call(this);let r=a(this,x).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(re)),r},Pr=function(){S(this,I,Tr).call(this);const e=We(this.options.staleTime,a(this,x));if(_e||a(this,G).isStale||!Bt(e))return;const n=kr(a(this,G).dataUpdatedAt,e)+1;b(this,Qe,setTimeout(()=>{a(this,G).isStale||this.updateResult()},n))},Rr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,x)):this.options.refetchInterval)??!1},Sr=function(e){S(this,I,Ar).call(this),b(this,Se,e),!(_e||ie(this.options.enabled,a(this,x))===!1||!Bt(a(this,Se))||a(this,Se)===0)&&b(this,$e,setInterval(()=>{(this.options.refetchIntervalInBackground||Zt.isFocused())&&S(this,I,Dt).call(this)},a(this,Se)))},Cr=function(){S(this,I,Pr).call(this),S(this,I,Sr).call(this,S(this,I,Rr).call(this))},Tr=function(){a(this,Qe)&&(clearTimeout(a(this,Qe)),b(this,Qe,void 0))},Ar=function(){a(this,$e)&&(clearInterval(a(this,$e)),b(this,$e,void 0))},xr=function(){const e=a(this,X).getQueryCache().build(a(this,X),this.options);if(e===a(this,x))return;const r=a(this,x);b(this,x,e),b(this,Tt,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},vs=function(e){K.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(a(this,G))}),a(this,X).getQueryCache().notify({query:a(this,x),type:"observerResultsUpdated"})})},Qn);function Ns(t,e){return ie(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Br(t,e){return Ns(t,e)||t.state.data!==void 0&&rr(t,e,e.refetchOnMount)}function rr(t,e,r){if(ie(e.enabled,t)!==!1){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&nr(t,e)}return!1}function Gr(t,e,r,n){return(t!==e||ie(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&nr(t,r)}function nr(t,e){return ie(e.enabled,t)!==!1&&t.isStaleByTime(We(e.staleTime,t))}function Ls(t,e){return!_t(t.getCurrentResult(),e)}var Qs=($n=class extends He{constructor(e,r){super();w(this,pe);w(this,Ce);w(this,Te);w(this,Z);w(this,ye);b(this,Ce,e),this.setOptions(r),this.bindMethods(),S(this,pe,zt).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var n;const r=this.options;this.options=a(this,Ce).defaultMutationOptions(e),_t(this.options,r)||a(this,Ce).getMutationCache().notify({type:"observerOptionsUpdated",mutation:a(this,Z),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Ie(r.mutationKey)!==Ie(this.options.mutationKey)?this.reset():((n=a(this,Z))==null?void 0:n.state.status)==="pending"&&a(this,Z).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||(e=a(this,Z))==null||e.removeObserver(this)}onMutationUpdate(e){S(this,pe,zt).call(this),S(this,pe,Fr).call(this,e)}getCurrentResult(){return a(this,Te)}reset(){var e;(e=a(this,Z))==null||e.removeObserver(this),b(this,Z,void 0),S(this,pe,zt).call(this),S(this,pe,Fr).call(this)}mutate(e,r){var n;return b(this,ye,r),(n=a(this,Z))==null||n.removeObserver(this),b(this,Z,a(this,Ce).getMutationCache().build(a(this,Ce),this.options)),a(this,Z).addObserver(this),a(this,Z).execute(e)}},Ce=new WeakMap,Te=new WeakMap,Z=new WeakMap,ye=new WeakMap,pe=new WeakSet,zt=function(){var r;const e=((r=a(this,Z))==null?void 0:r.state)??zr();b(this,Te,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Fr=function(e){K.batch(()=>{var r,n,s,i,u,l,c,h;if(a(this,ye)&&this.hasListeners()){const f=a(this,Te).variables,d=a(this,Te).context;(e==null?void 0:e.type)==="success"?((n=(r=a(this,ye)).onSuccess)==null||n.call(r,e.data,f,d),(i=(s=a(this,ye)).onSettled)==null||i.call(s,e.data,null,f,d)):(e==null?void 0:e.type)==="error"&&((l=(u=a(this,ye)).onError)==null||l.call(u,e.error,f,d),(h=(c=a(this,ye)).onSettled)==null||h.call(c,void 0,e.error,f,d))}this.listeners.forEach(f=>{f(a(this,Te))})})},$n),Yr=U.createContext(void 0),vt=t=>{const e=U.useContext(Yr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},$s=({client:t,children:e})=>(U.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),mt.jsx(Yr.Provider,{value:t,children:e})),Jr=U.createContext(!1),Ks=()=>U.useContext(Jr);Jr.Provider;function Vs(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var zs=U.createContext(Vs()),Hs=()=>U.useContext(zs);function Xr(t,e){return typeof t=="function"?t(...e):!!t}function sr(){}var Ws=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Bs=t=>{U.useEffect(()=>{t.clearReset()},[t])},Gs=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Xr(r,[t.error,n])),Ys=t=>{const e=t.staleTime;t.suspense&&(t.staleTime=typeof e=="function"?(...r)=>Math.max(e(...r),1e3):Math.max(e??1e3,1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},Js=(t,e)=>t.isLoading&&t.isFetching&&!e,Xs=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Zr=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Zs(t,e,r){var d,y,p,E,g;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=vt(),s=Ks(),i=Hs(),u=n.defaultQueryOptions(t);(y=(d=n.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||y.call(d,u),process.env.NODE_ENV!=="production"&&(u.queryFn||console.error(`[${u.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),u._optimisticResults=s?"isRestoring":"optimistic",Ys(u),Ws(u,i),Bs(i);const l=!n.getQueryCache().get(u.queryHash),[c]=U.useState(()=>new e(n,u)),h=c.getOptimisticResult(u),f=!s&&t.subscribed!==!1;if(U.useSyncExternalStore(U.useCallback(O=>{const C=f?c.subscribe(K.batchCalls(O)):sr;return c.updateResult(),C},[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),U.useEffect(()=>{c.setOptions(u,{listeners:!1})},[u,c]),Xs(u,h))throw Zr(u,c,i);if(Gs({result:h,errorResetBoundary:i,throwOnError:u.throwOnError,query:n.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw h.error;if((E=(p=n.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||E.call(p,u,h),u.experimental_prefetchInRender&&!_e&&Js(h,s)){const O=l?Zr(u,c,i):(g=n.getQueryCache().get(u.queryHash))==null?void 0:g.promise;O==null||O.catch(sr).finally(()=>{c.updateResult()})}return u.notifyOnChangeProps?h:c.trackResult(h)}function en(t,e){return Zs(t,Us)}function ir(t,e){const r=vt(),[n]=U.useState(()=>new Qs(r,t));U.useEffect(()=>{n.setOptions(t)},[n,t]);const s=U.useSyncExternalStore(U.useCallback(u=>n.subscribe(K.batchCalls(u)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=U.useCallback((u,l)=>{n.mutate(u,l).catch(sr)},[n]);if(s.error&&Xr(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}function Be(t){const e={subscribe(r){let n=null,s=!1,i=!1,u=!1;function l(){if(n===null){u=!0;return}i||(i=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){var h;s||(h=r.next)==null||h.call(r,c)},error(c){var h;s||(s=!0,(h=r.error)==null||h.call(r,c),l())},complete(){var c;s||(s=!0,(c=r.complete)==null||c.call(r),l())}}),u&&l(),{unsubscribe:l}},pipe(...r){return r.reduce(ei,e)}};return e}function ei(t,e){return e(t)}function ti(t){const e=new AbortController;return new Promise((n,s)=>{let i=!1;function u(){i||(i=!0,l.unsubscribe())}e.signal.addEventListener("abort",()=>{s(e.signal.reason)});const l=t.subscribe({next(c){i=!0,n(c),u()},error(c){s(c)},complete(){e.abort(),u()}})})}function ri(t){return e=>{let r=0,n=null;const s=[];function i(){n||(n=e.subscribe({next(l){var c;for(const h of s)(c=h.next)==null||c.call(h,l)},error(l){var c;for(const h of s)(c=h.error)==null||c.call(h,l)},complete(){var l;for(const c of s)(l=c.complete)==null||l.call(c)}}))}function u(){if(r===0&&n){const l=n;n=null,l.unsubscribe()}}return Be(l=>(r++,s.push(l),i(),{unsubscribe(){r--,u();const c=s.findIndex(h=>h===l);c>-1&&s.splice(c,1)}}))}}function ni(t){return e=>Be(r=>e.subscribe({next(n){var s;(s=t.next)==null||s.call(t,n),r.next(n)},error(n){var s;(s=t.error)==null||s.call(t,n),r.error(n)},complete(){var n;(n=t.complete)==null||n.call(t),r.complete()}}))}function si(t){let e=t;const r=[],n=u=>{e!==void 0&&u.next(e),r.push(u)},s=u=>{r.splice(r.indexOf(u),1)},i=Be(u=>(n(u),()=>{s(u)}));return i.next=u=>{if(e!==u){e=u;for(const l of r)l.next(u)}},i.get=()=>e,i}function ii(t){return Be(e=>{function r(s=0,i=t.op){const u=t.links[s];if(!u)throw new Error("No more links to execute - did you forget to add an ending link?");return u({op:i,next(c){return r(s+1,c)}})}return r().subscribe(e)})}const tn=()=>{},rn=t=>{Object.freeze&&Object.freeze(t)};function nn(t,e,r){var n,s;const i=e.join(".");return(n=r)[s=i]??(n[s]=new Proxy(tn,{get(u,l){if(!(typeof l!="string"||l==="then"))return nn(t,[...e,l],r)},apply(u,l,c){const h=e[e.length-1];let f={args:c,path:e};return h==="call"?f={args:c.length>=2?[c[1]]:[],path:e.slice(0,-1)}:h==="apply"&&(f={args:c.length>=2?c[1]:[],path:e.slice(0,-1)}),rn(f.args),rn(f.path),t(f)}})),r[i]}const oi=t=>nn(t,[],Object.create(null)),ai=t=>new Proxy(tn,{get(e,r){if(r!=="then")return t(r)}});function wt(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function ui(t,e){if("error"in t){const n=e.deserialize(t.error);return{ok:!1,error:{...t,error:n}}}return{ok:!0,result:{...t.result,...(!t.result.type||t.result.type==="data")&&{type:"data",data:e.deserialize(t.result.data)}}}}class or extends Error{constructor(){super("Unable to transform response from server")}}function ci(t,e){let r;try{r=ui(t,e)}catch{throw new or}if(!r.ok&&(!wt(r.error.error)||typeof r.error.error.code!="number"))throw new or;if(r.ok&&!wt(r.result))throw new or;return r}var sn,on;(sn=Symbol).dispose??(sn.dispose=Symbol()),(on=Symbol).asyncDispose??(on.asyncDispose=Symbol()),typeof window>"u"||"Deno"in window||((Vn=(Kn=globalThis.process)==null?void 0:Kn.env)==null?void 0:Vn.NODE_ENV)==="test"||(Hn=(zn=globalThis.process)==null?void 0:zn.env)!=null&&Hn.JEST_WORKER_ID||(Bn=(Wn=globalThis.process)==null?void 0:Wn.env)!=null&&Bn.VITEST_WORKER_ID;function qt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function li(t){return t instanceof ge||t instanceof Error&&t.name==="TRPCClientError"}function fi(t){return wt(t)&&wt(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function di(t,e){return typeof t=="string"?t:wt(t)&&typeof t.message=="string"?t.message:e}class ge extends Error{static from(e,r={}){const n=e;return li(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):fi(n)?new ge(n.error.message,{...r,result:n}):new ge(di(n,"Unknown error"),{...r,cause:n})}constructor(e,r){var s,i;const n=r==null?void 0:r.cause;super(e,{cause:n}),qt(this,"cause",void 0),qt(this,"shape",void 0),qt(this,"data",void 0),qt(this,"meta",void 0),this.meta=r==null?void 0:r.meta,this.cause=n,this.shape=(s=r==null?void 0:r.result)==null?void 0:s.error,this.data=(i=r==null?void 0:r.result)==null?void 0:i.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,ge.prototype)}}function ar(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class hi{$request(e){return ii({links:this.links,op:{...e,context:e.context??{},id:++this.requestId}}).pipe(ri())}async requestAsPromise(e){try{const r=this.$request(e);return(await ti(r)).result.data}catch(r){throw ge.from(r)}}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n.context,signal:n.signal}).subscribe({next(i){var u,l,c,h;switch(i.result.type){case"state":{(u=n.onConnectionStateChange)==null||u.call(n,i.result);break}case"started":{(l=n.onStarted)==null||l.call(n,{context:i.context});break}case"stopped":{(c=n.onStopped)==null||c.call(n);break}case"data":case void 0:{(h=n.onData)==null||h.call(n,i.result.data);break}}},error(i){var u;(u=n.onError)==null||u.call(n,i)},complete(){var i;(i=n.onComplete)==null||i.call(n)}})}constructor(e){ar(this,"links",void 0),ar(this,"runtime",void 0),ar(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(r=>r(this.runtime))}}const yi=Symbol.for("trpc_untypedClient"),pi={query:"query",mutate:"mutation",subscribe:"subscription"},mi=t=>pi[t];function gi(t){const e=oi(({path:r,args:n})=>{const s=[...r],i=mi(s.pop()),u=s.join(".");return t[i](u,...n)});return ai(r=>r===yi?t:e[r])}function bi(t){const e=new hi(t);return gi(e)}const an=t=>typeof t=="function";function vi(t){if(t)return t;if(typeof window<"u"&&an(window.fetch))return window.fetch;if(typeof globalThis<"u"&&an(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}const un=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function cn(t){let e=null,r=null;const n=()=>{clearTimeout(r),r=null,e=null};function s(l){var f,d;const c=[[]];let h=0;for(;;){const y=l[h];if(!y)break;const p=c[c.length-1];if(y.aborted){(f=y.reject)==null||f.call(y,new Error("Aborted")),h++;continue}if(t.validate(p.concat(y).map(g=>g.key))){p.push(y),h++;continue}if(p.length===0){(d=y.reject)==null||d.call(y,new Error("Input is too big for a single dispatch")),h++;continue}c.push([])}return c}function i(){const l=s(e);n();for(const c of l){if(!c.length)continue;const h={items:c};for(const d of c)d.batch=h;t.fetch(h.items.map(d=>d.key)).then(async d=>{var y;await Promise.all(d.map(async(p,E)=>{var O,C;const g=h.items[E];try{const R=await Promise.resolve(p);(O=g.resolve)==null||O.call(g,R)}catch(R){(C=g.reject)==null||C.call(g,R)}g.batch=null,g.reject=null,g.resolve=null}));for(const p of h.items)(y=p.reject)==null||y.call(p,new Error("Missing result")),p.batch=null}).catch(d=>{var y;for(const p of h.items)(y=p.reject)==null||y.call(p,d),p.batch=null})}}function u(l){const c={aborted:!1,key:l,batch:null,resolve:un,reject:un},h=new Promise((f,d)=>{c.reject=d,c.resolve=f,e||(e=[]),e.push(c)});return r||(r=setTimeout(i)),h}return{load:u}}function wi(...t){const e=new AbortController,r=t.length;let n=0;const s=()=>{++n===r&&e.abort()};for(const i of t)i!=null&&i.aborted?s():i==null||i.addEventListener("abort",s,{once:!0});return e.signal}function Ei(t){const e=t;return e?"input"in e?e:{input:e,output:e}:{input:{serialize:r=>r,deserialize:r=>r},output:{serialize:r=>r,deserialize:r=>r}}}function Oi(t){return{url:t.url.toString(),fetch:t.fetch,transformer:Ei(t.transformer),methodOverride:t.methodOverride}}function Pi(t){const e={};for(let r=0;r<t.length;r++){const n=t[r];e[r]=n}return e}const Ri={query:"GET",mutation:"POST",subscription:"PATCH"};function ln(t){return"input"in t?t.transformer.input.serialize(t.input):Pi(t.inputs.map(e=>t.transformer.input.serialize(e)))}const fn=t=>{const e=t.url.split("?");let n=e[0].replace(/\/$/,"")+"/"+t.path;const s=[];if(e[1]&&s.push(e[1]),"inputs"in t&&s.push("batch=1"),t.type==="query"||t.type==="subscription"){const i=ln(t);i!==void 0&&t.methodOverride!=="POST"&&s.push(`input=${encodeURIComponent(JSON.stringify(i))}`)}return s.length&&(n+="?"+s.join("&")),n},Si=t=>{if(t.type==="query"&&t.methodOverride!=="POST")return;const e=ln(t);return e!==void 0?JSON.stringify(e):void 0},Ci=t=>Fi({...t,contentTypeHeader:"application/json",getUrl:fn,getBody:Si});class Ti extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}}const Ai=t=>{var e;if(t!=null&&t.aborted)throw(e=t.throwIfAborted)==null||e.call(t),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new Ti};async function xi(t){Ai(t.signal);const e=t.getUrl(t),r=t.getBody(t),{type:n}=t,s=await(async()=>{const u=await t.headers();return Symbol.iterator in u?Object.fromEntries(u):u})(),i={...t.contentTypeHeader?{"content-type":t.contentTypeHeader}:{},...t.trpcAcceptHeader?{"trpc-accept":t.trpcAcceptHeader}:void 0,...s};return vi(t.fetch)(e,{method:t.methodOverride??Ri[n],signal:t.signal,body:r,headers:i})}async function Fi(t){const e={},r=await xi(t);e.response=r;const n=await r.json();return e.responseJSON=n,{json:n,meta:e}}function Di(t){const e=Oi(t),r=t.maxURLLength??1/0;return()=>{const n=l=>({validate(c){if(r===1/0)return!0;const h=c.map(y=>y.path).join(","),f=c.map(y=>y.input);return fn({...e,type:l,path:h,inputs:f,signal:null}).length<=r},async fetch(c){const h=c.map(g=>g.path).join(","),f=c.map(g=>g.input),d=wi(...c.map(g=>g.signal)),y=await Ci({...e,path:h,inputs:f,type:l,headers(){return t.headers?typeof t.headers=="function"?t.headers({opList:c}):t.headers:{}},signal:d});return(Array.isArray(y.json)?y.json:c.map(()=>y.json)).map(g=>({meta:y.meta,json:g}))}}),s=cn(n("query")),i=cn(n("mutation")),u={query:s,mutation:i};return({op:l})=>Be(c=>{/* istanbul ignore if -- @preserve */if(l.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const f=u[l.type].load(l);let d;return f.then(y=>{d=y;const p=ci(y.json,e.transformer.output);if(!p.ok){c.error(ge.from(p.error,{meta:y.meta}));return}c.next({context:y.meta,result:p.result}),c.complete()}).catch(y=>{c.error(ge.from(y,{meta:d==null?void 0:d.meta}))}),()=>{}})}}function _i(t){return typeof FormData>"u"?!1:t instanceof FormData}const ur={css:{query:["72e3ff","3fb0d8"],mutation:["c5a3fc","904dfc"],subscription:["ff49e1","d83fbe"]},ansi:{regular:{query:["\x1B[30;46m","\x1B[97;46m"],mutation:["\x1B[30;45m","\x1B[97;45m"],subscription:["\x1B[30;42m","\x1B[97;42m"]},bold:{query:["\x1B[1;30;46m","\x1B[1;97;46m"],mutation:["\x1B[1;30;45m","\x1B[1;97;45m"],subscription:["\x1B[1;30;42m","\x1B[1;97;42m"]}}};function Ii(t){const{direction:e,type:r,withContext:n,path:s,id:i,input:u}=t,l=[],c=[];if(t.colorMode==="none")l.push(e==="up"?">>":"<<",r,`#${i}`,s);else if(t.colorMode==="ansi"){const[h,f]=ur.ansi.regular[r],[d,y]=ur.ansi.bold[r];l.push(e==="up"?h:f,e==="up"?">>":"<<",r,e==="up"?d:y,`#${i}`,s,"\x1B[0m")}else{const[h,f]=ur.css[r],d=`
30
+ <%s key={someKey} {...props} />`,Or,He,Zo,He),ms[He+Or]=!0}}return o===n?Bo($):Wo($),$}}function Go(o,m,v){return gs(o,m,v,!0)}function Yo(o,m,v){return gs(o,m,v,!1)}var Jo=Yo,Xo=Go;mt.Fragment=n,mt.jsx=Jo,mt.jsxs=Xo}()),mt}process.env.NODE_ENV==="production"?yt.exports=ws():yt.exports=Es();var gt=yt.exports,Wt=(t=>(t.NOT_CHUNKED="NOT_CHUNKED",t.PROCESSING="PROCESSING",t.CHUNKED="CHUNKED",t.ERROR_CHUNKING="ERROR_CHUNKING",t))(Wt||{}),Bt=(t=>(t.PDF="application/pdf",t.TXT="text/plain",t.CSV="text/csv",t.DIRECTORY="inode/directory",t.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",t))(Bt||{});const bt=4e3*1024*1024,kr={"application/pdf":{extensions:[".pdf"],maxSize:bt},"text/plain":{extensions:[".txt",".json",".py",".ts",".tsx"],maxSize:bt},"text/csv":{extensions:[".csv"],maxSize:bt},"inode/directory":{extensions:[],maxSize:bt},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{extensions:[".docx"],maxSize:bt}};Object.entries(kr).reduce((t,[e,r])=>({...t,[e]:r.extensions}),{});const Os=new Set(Object.values(Bt));var We=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_e=typeof window>"u"||"Deno"in globalThis;function re(){}function Ps(t,e){return typeof t=="function"?t(e):t}function Gt(t){return typeof t=="number"&&t>=0&&t!==1/0}function jr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Be(t,e){return typeof t=="function"?t(e):t}function ie(t,e){return typeof t=="function"?t(e):t}function qr(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:i,queryKey:u,stale:l}=t;if(u){if(n){if(e.queryHash!==Yt(u,e.options))return!1}else if(!vt(e.queryKey,u))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||s&&s!==e.state.fetchStatus||i&&!i(e))}function Mr(t,e){const{exact:r,status:n,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(Ie(e.options.mutationKey)!==Ie(i))return!1}else if(!vt(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Yt(t,e){return((e==null?void 0:e.queryKeyHashFn)||Ie)(t)}function Ie(t){return JSON.stringify(t,(e,r)=>Xt(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function vt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(r=>!vt(t[r],e[r])):!1}function Jt(t,e){if(t===e)return t;const r=Ur(t)&&Ur(e);if(r||Xt(t)&&Xt(e)){const n=r?t:Object.keys(t),s=n.length,i=r?e:Object.keys(e),u=i.length,l=r?[]:{};let c=0;for(let h=0;h<u;h++){const f=r?h:i[h];(!r&&n.includes(f)||r)&&t[f]===void 0&&e[f]===void 0?(l[f]=void 0,c++):(l[f]=Jt(t[f],e[f]),l[f]===t[f]&&t[f]!==void 0&&c++)}return s===u&&c===s?t:l}return e}function _t(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function Ur(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Xt(t){if(!Nr(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!Nr(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Nr(t){return Object.prototype.toString.call(t)==="[object Object]"}function Rs(t){return new Promise(e=>{setTimeout(e,t)})}function Zt(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Jt(t,e)}catch(n){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`)}return Jt(t,e)}return e}function Ss(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function Cs(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var It=Symbol();function Lr(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===It&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===It?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Ts=(In=class extends We{constructor(){super();w(this,qe);w(this,ve);w(this,Ze);b(this,Ze,e=>{if(!_e&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){a(this,ve)||this.setEventListener(a(this,Ze))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,ve))==null||e.call(this),b(this,ve,void 0))}setEventListener(e){var r;b(this,Ze,e),(r=a(this,ve))==null||r.call(this),b(this,ve,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){a(this,qe)!==e&&(b(this,qe,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof a(this,qe)=="boolean"?a(this,qe):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},qe=new WeakMap,ve=new WeakMap,Ze=new WeakMap,In),er=new Ts,As=(kn=class extends We{constructor(){super();w(this,et,!0);w(this,we);w(this,tt);b(this,tt,e=>{if(!_e&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){a(this,we)||this.setEventListener(a(this,tt))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,we))==null||e.call(this),b(this,we,void 0))}setEventListener(e){var r;b(this,tt,e),(r=a(this,we))==null||r.call(this),b(this,we,e(this.setOnline.bind(this)))}setOnline(e){a(this,et)!==e&&(b(this,et,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return a(this,et)}},et=new WeakMap,we=new WeakMap,tt=new WeakMap,kn),kt=new As;function tr(){let t,e;const r=new Promise((s,i)=>{t=s,e=i});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function Fs(t){return Math.min(1e3*2**t,3e4)}function Qr(t){return(t??"online")==="online"?kt.isOnline():!0}var $r=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function rr(t){return t instanceof $r}function Kr(t){let e=!1,r=0,n=!1,s;const i=tr(),u=g=>{var O;n||(y(new $r(g)),(O=t.abort)==null||O.call(t))},l=()=>{e=!0},c=()=>{e=!1},h=()=>er.isFocused()&&(t.networkMode==="always"||kt.isOnline())&&t.canRun(),f=()=>Qr(t.networkMode)&&t.canRun(),d=g=>{var O;n||(n=!0,(O=t.onSuccess)==null||O.call(t,g),s==null||s(),i.resolve(g))},y=g=>{var O;n||(n=!0,(O=t.onError)==null||O.call(t,g),s==null||s(),i.reject(g))},p=()=>new Promise(g=>{var O;s=C=>{(n||h())&&g(C)},(O=t.onPause)==null||O.call(t)}).then(()=>{var g;s=void 0,n||(g=t.onContinue)==null||g.call(t)}),E=()=>{if(n)return;let g;const O=r===0?t.initialPromise:void 0;try{g=O??t.fn()}catch(C){g=Promise.reject(C)}Promise.resolve(g).then(d).catch(C=>{var te;if(n)return;const R=t.retry??(_e?0:3),j=t.retryDelay??Fs,z=typeof j=="function"?j(r,C):j,Y=R===!0||typeof R=="number"&&r<R||typeof R=="function"&&R(r,C);if(e||!Y){y(C);return}r++,(te=t.onFail)==null||te.call(t,r,C),Rs(z).then(()=>h()?void 0:p()).then(()=>{e?y(C):E()})})};return{promise:i,cancel:u,continue:()=>(s==null||s(),i),cancelRetry:l,continueRetry:c,canStart:f,start:()=>(f()?E():p().then(E),i)}}function xs(){let t=[],e=0,r=l=>{l()},n=l=>{l()},s=l=>setTimeout(l,0);const i=l=>{e?t.push(l):s(()=>{r(l)})},u=()=>{const l=t;t=[],l.length&&s(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||u()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{s=l}}}var K=xs(),zr=(jn=class{constructor(){w(this,Me)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Gt(this.gcTime)&&b(this,Me,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(_e?1/0:5*60*1e3))}clearGcTimeout(){a(this,Me)&&(clearTimeout(a(this,Me)),b(this,Me,void 0))}},Me=new WeakMap,jn),Ds=(qn=class extends zr{constructor(e){super();w(this,oe);w(this,rt);w(this,nt);w(this,ne);w(this,Ue);w(this,W);w(this,St);w(this,Ne);b(this,Ne,!1),b(this,St,e.defaultOptions),this.setOptions(e.options),this.observers=[],b(this,Ue,e.client),b(this,ne,a(this,Ue).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,b(this,rt,_s(this.options)),this.state=e.state??a(this,rt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=a(this,W))==null?void 0:e.promise}setOptions(e){this.options={...a(this,St),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&a(this,ne).remove(this)}setData(e,r){const n=Zt(this.state.data,e,this.options);return S(this,oe,me).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){S(this,oe,me).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=a(this,W))==null?void 0:n.promise;return(s=a(this,W))==null||s.cancel(e),r?r.then(re).catch(re):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,rt))}isActive(){return this.observers.some(e=>ie(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===It||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!jr(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,W))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,W))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),a(this,ne).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(a(this,W)&&(a(this,Ne)?a(this,W).cancel({revert:!0}):a(this,W).cancelRetry()),this.scheduleGc()),a(this,ne).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||S(this,oe,me).call(this,{type:"invalidate"})}fetch(e,r){var c,h,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(a(this,W))return a(this,W).continueRetry(),a(this,W).promise}if(e&&this.setOptions(e),!this.options.queryFn){const d=this.observers.find(y=>y.options.queryFn);d&&this.setOptions(d.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,s=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(b(this,Ne,!0),n.signal)})},i=()=>{const d=Lr(this.options,r),y={client:a(this,Ue),queryKey:this.queryKey,meta:this.meta};return s(y),b(this,Ne,!1),this.options.persister?this.options.persister(d,y,this):d(y)},u={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:a(this,Ue),state:this.state,fetchFn:i};s(u),(c=this.options.behavior)==null||c.onFetch(u,this),b(this,nt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=u.fetchOptions)==null?void 0:h.meta))&&S(this,oe,me).call(this,{type:"fetch",meta:(f=u.fetchOptions)==null?void 0:f.meta});const l=d=>{var y,p,E,g;rr(d)&&d.silent||S(this,oe,me).call(this,{type:"error",error:d}),rr(d)||((p=(y=a(this,ne).config).onError)==null||p.call(y,d,this),(g=(E=a(this,ne).config).onSettled)==null||g.call(E,this.state.data,d,this)),this.scheduleGc()};return b(this,W,Kr({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:d=>{var y,p,E,g;if(d===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(d)}catch(O){l(O);return}(p=(y=a(this,ne).config).onSuccess)==null||p.call(y,d,this),(g=(E=a(this,ne).config).onSettled)==null||g.call(E,d,this.state.error,this),this.scheduleGc()},onError:l,onFail:(d,y)=>{S(this,oe,me).call(this,{type:"failed",failureCount:d,error:y})},onPause:()=>{S(this,oe,me).call(this,{type:"pause"})},onContinue:()=>{S(this,oe,me).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0})),a(this,W).start()}},rt=new WeakMap,nt=new WeakMap,ne=new WeakMap,Ue=new WeakMap,W=new WeakMap,St=new WeakMap,Ne=new WeakMap,oe=new WeakSet,me=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Vr(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return rr(s)&&s.revert&&a(this,nt)?{...a(this,nt),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),K.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),a(this,ne).notify({query:this,type:"updated",action:e})})},qn);function Vr(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Qr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function _s(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Is=(Mn=class extends We{constructor(e={}){super();w(this,ce);this.config=e,b(this,ce,new Map)}build(e,r,n){const s=r.queryKey,i=r.queryHash??Yt(s,r);let u=this.get(i);return u||(u=new Ds({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(u)),u}add(e){a(this,ce).has(e.queryHash)||(a(this,ce).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=a(this,ce).get(e.queryHash);r&&(e.destroy(),r===e&&a(this,ce).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){K.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return a(this,ce).get(e)}getAll(){return[...a(this,ce).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>qr(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>qr(e,n)):r}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){K.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){K.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ce=new WeakMap,Mn),ks=(Un=class extends zr{constructor(e){super();w(this,fe);w(this,le);w(this,B);w(this,Le);this.mutationId=e.mutationId,b(this,B,e.mutationCache),b(this,le,[]),this.state=e.state||Hr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){a(this,le).includes(e)||(a(this,le).push(e),this.clearGcTimeout(),a(this,B).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){b(this,le,a(this,le).filter(r=>r!==e)),this.scheduleGc(),a(this,B).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){a(this,le).length||(this.state.status==="pending"?this.scheduleGc():a(this,B).remove(this))}continue(){var e;return((e=a(this,Le))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var s,i,u,l,c,h,f,d,y,p,E,g,O,C,R,j,z,Y,te,V;b(this,Le,Kr({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(N,M)=>{S(this,fe,De).call(this,{type:"failed",failureCount:N,error:M})},onPause:()=>{S(this,fe,De).call(this,{type:"pause"})},onContinue:()=>{S(this,fe,De).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>a(this,B).canRun(this)}));const r=this.state.status==="pending",n=!a(this,Le).canStart();try{if(!r){S(this,fe,De).call(this,{type:"pending",variables:e,isPaused:n}),await((i=(s=a(this,B).config).onMutate)==null?void 0:i.call(s,e,this));const M=await((l=(u=this.options).onMutate)==null?void 0:l.call(u,e));M!==this.state.context&&S(this,fe,De).call(this,{type:"pending",context:M,variables:e,isPaused:n})}const N=await a(this,Le).start();return await((h=(c=a(this,B).config).onSuccess)==null?void 0:h.call(c,N,e,this.state.context,this)),await((d=(f=this.options).onSuccess)==null?void 0:d.call(f,N,e,this.state.context)),await((p=(y=a(this,B).config).onSettled)==null?void 0:p.call(y,N,null,this.state.variables,this.state.context,this)),await((g=(E=this.options).onSettled)==null?void 0:g.call(E,N,null,e,this.state.context)),S(this,fe,De).call(this,{type:"success",data:N}),N}catch(N){try{throw await((C=(O=a(this,B).config).onError)==null?void 0:C.call(O,N,e,this.state.context,this)),await((j=(R=this.options).onError)==null?void 0:j.call(R,N,e,this.state.context)),await((Y=(z=a(this,B).config).onSettled)==null?void 0:Y.call(z,void 0,N,this.state.variables,this.state.context,this)),await((V=(te=this.options).onSettled)==null?void 0:V.call(te,void 0,N,e,this.state.context)),N}finally{S(this,fe,De).call(this,{type:"error",error:N})}}finally{a(this,B).runNext(this)}}},le=new WeakMap,B=new WeakMap,Le=new WeakMap,fe=new WeakSet,De=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),K.batch(()=>{a(this,le).forEach(n=>{n.onMutationUpdate(e)}),a(this,B).notify({mutation:this,type:"updated",action:e})})},Un);function Hr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var js=(Nn=class extends We{constructor(e={}){super();w(this,he);w(this,ae);w(this,Ct);this.config=e,b(this,he,new Set),b(this,ae,new Map),b(this,Ct,0)}build(e,r,n){const s=new ks({mutationCache:this,mutationId:++Vt(this,Ct)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){a(this,he).add(e);const r=jt(e);if(typeof r=="string"){const n=a(this,ae).get(r);n?n.push(e):a(this,ae).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(a(this,he).delete(e)){const r=jt(e);if(typeof r=="string"){const n=a(this,ae).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&a(this,ae).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=jt(e);if(typeof r=="string"){const n=a(this,ae).get(r),s=n==null?void 0:n.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=jt(e);if(typeof r=="string"){const s=(n=a(this,ae).get(r))==null?void 0:n.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){K.batch(()=>{a(this,he).forEach(e=>{this.notify({type:"removed",mutation:e})}),a(this,he).clear(),a(this,ae).clear()})}getAll(){return Array.from(a(this,he))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Mr(r,n))}findAll(e={}){return this.getAll().filter(r=>Mr(e,r))}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return K.batch(()=>Promise.all(e.map(r=>r.continue().catch(re))))}},he=new WeakMap,ae=new WeakMap,Ct=new WeakMap,Nn);function jt(t){var e;return(e=t.options.scope)==null?void 0:e.id}function Wr(t){return{onFetch:(e,r)=>{var f,d,y,p,E;const n=e.options,s=(y=(d=(f=e.fetchOptions)==null?void 0:f.meta)==null?void 0:d.fetchMore)==null?void 0:y.direction,i=((p=e.state.data)==null?void 0:p.pages)||[],u=((E=e.state.data)==null?void 0:E.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const h=async()=>{let g=!1;const O=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(e.signal.aborted?g=!0:e.signal.addEventListener("abort",()=>{g=!0}),e.signal)})},C=Lr(e.options,e.fetchOptions),R=async(j,z,Y)=>{if(g)return Promise.reject();if(z==null&&j.pages.length)return Promise.resolve(j);const te={client:e.client,queryKey:e.queryKey,pageParam:z,direction:Y?"backward":"forward",meta:e.options.meta};O(te);const V=await C(te),{maxPages:N}=e.options,M=Y?Cs:Ss;return{pages:M(j.pages,V,N),pageParams:M(j.pageParams,z,N)}};if(s&&i.length){const j=s==="backward",z=j?qs:Br,Y={pages:i,pageParams:u},te=z(n,Y);l=await R(Y,te,j)}else{const j=t??i.length;do{const z=c===0?u[0]??n.initialPageParam:Br(n,l);if(c>0&&z==null)break;l=await R(l,z),c++}while(c<j)}return l};e.options.persister?e.fetchFn=()=>{var g,O;return(O=(g=e.options).persister)==null?void 0:O.call(g,h,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=h}}}function Br(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function qs(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var Ms=(Ln=class{constructor(t={}){w(this,L);w(this,Ee);w(this,Oe);w(this,st);w(this,it);w(this,Pe);w(this,ot);w(this,at);b(this,L,t.queryCache||new Is),b(this,Ee,t.mutationCache||new js),b(this,Oe,t.defaultOptions||{}),b(this,st,new Map),b(this,it,new Map),b(this,Pe,0)}mount(){Vt(this,Pe)._++,a(this,Pe)===1&&(b(this,ot,er.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,L).onFocus())})),b(this,at,kt.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,L).onOnline())})))}unmount(){var t,e;Vt(this,Pe)._--,a(this,Pe)===0&&((t=a(this,ot))==null||t.call(this),b(this,ot,void 0),(e=a(this,at))==null||e.call(this),b(this,at,void 0))}isFetching(t){return a(this,L).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return a(this,Ee).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,L).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=a(this,L).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Be(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return a(this,L).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=a(this,L).get(n.queryHash),i=s==null?void 0:s.state.data,u=Ps(e,i);if(u!==void 0)return a(this,L).build(this,n).setData(u,{...r,manual:!0})}setQueriesData(t,e,r){return K.batch(()=>a(this,L).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,L).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=a(this,L);K.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=a(this,L);return K.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=K.batch(()=>a(this,L).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(re).catch(re)}invalidateQueries(t,e={}){return K.batch(()=>(a(this,L).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=K.batch(()=>a(this,L).findAll(t).filter(s=>!s.isDisabled()).map(s=>{let i=s.fetch(void 0,r);return r.throwOnError||(i=i.catch(re)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(re)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=a(this,L).build(this,e);return r.isStaleByTime(Be(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(re).catch(re)}fetchInfiniteQuery(t){return t.behavior=Wr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(re).catch(re)}ensureInfiniteQueryData(t){return t.behavior=Wr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return kt.isOnline()?a(this,Ee).resumePausedMutations():Promise.resolve()}getQueryCache(){return a(this,L)}getMutationCache(){return a(this,Ee)}getDefaultOptions(){return a(this,Oe)}setDefaultOptions(t){b(this,Oe,t)}setQueryDefaults(t,e){a(this,st).set(Ie(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...a(this,st).values()],r={};return e.forEach(n=>{vt(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){a(this,it).set(Ie(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...a(this,it).values()],r={};return e.forEach(n=>{vt(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...a(this,Oe).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Yt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===It&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...a(this,Oe).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){a(this,L).clear(),a(this,Ee).clear()}},L=new WeakMap,Ee=new WeakMap,Oe=new WeakMap,st=new WeakMap,it=new WeakMap,Pe=new WeakMap,ot=new WeakMap,at=new WeakMap,Ln),Us=(Qn=class extends We{constructor(e,r){super();w(this,I);w(this,X);w(this,x);w(this,Tt);w(this,G);w(this,Qe);w(this,ut);w(this,Re);w(this,de);w(this,At);w(this,ct);w(this,lt);w(this,$e);w(this,Ke);w(this,Se);w(this,ft,new Set);this.options=r,b(this,X,e),b(this,de,null),b(this,Re,tr()),this.options.experimental_prefetchInRender||a(this,Re).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,x).addObserver(this),Gr(a(this,x),this.options)?S(this,I,Dt).call(this):this.updateResult(),S(this,I,Tr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nr(a(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nr(a(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,S(this,I,Ar).call(this),S(this,I,Fr).call(this),a(this,x).removeObserver(this)}setOptions(e,r){const n=this.options,s=a(this,x);if(this.options=a(this,X).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ie(this.options.enabled,a(this,x))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");S(this,I,xr).call(this),a(this,x).setOptions(this.options),n._defaulted&&!_t(this.options,n)&&a(this,X).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,x),observer:this});const i=this.hasListeners();i&&Yr(a(this,x),s,this.options,n)&&S(this,I,Dt).call(this),this.updateResult(r),i&&(a(this,x)!==s||ie(this.options.enabled,a(this,x))!==ie(n.enabled,a(this,x))||Be(this.options.staleTime,a(this,x))!==Be(n.staleTime,a(this,x)))&&S(this,I,Rr).call(this);const u=S(this,I,Sr).call(this);i&&(a(this,x)!==s||ie(this.options.enabled,a(this,x))!==ie(n.enabled,a(this,x))||u!==a(this,Se))&&S(this,I,Cr).call(this,u)}getOptimisticResult(e){const r=a(this,X).getQueryCache().build(a(this,X),e),n=this.createResult(r,e);return Ls(this,n)&&(b(this,G,n),b(this,ut,this.options),b(this,Qe,a(this,x).state)),n}getCurrentResult(){return a(this,G)}trackResult(e,r){const n={};return Object.keys(e).forEach(s=>{Object.defineProperty(n,s,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(s),r==null||r(s),e[s])})}),n}trackProp(e){a(this,ft).add(e)}getCurrentQuery(){return a(this,x)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=a(this,X).defaultQueryOptions(e),n=a(this,X).getQueryCache().build(a(this,X),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return S(this,I,Dt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,G)))}createResult(e,r){var N;const n=a(this,x),s=this.options,i=a(this,G),u=a(this,Qe),l=a(this,ut),h=e!==n?e.state:a(this,Tt),{state:f}=e;let d={...f},y=!1,p;if(r._optimisticResults){const M=this.hasListeners(),Ae=!M&&Gr(e,r),Fe=M&&Yr(e,n,r,s);(Ae||Fe)&&(d={...d,...Vr(f.data,e.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:E,errorUpdatedAt:g,status:O}=d;if(r.select&&d.data!==void 0)if(i&&d.data===(u==null?void 0:u.data)&&r.select===a(this,At))p=a(this,ct);else try{b(this,At,r.select),p=r.select(d.data),p=Zt(i==null?void 0:i.data,p,r),b(this,ct,p),b(this,de,null)}catch(M){b(this,de,M)}else p=d.data;if(r.placeholderData!==void 0&&p===void 0&&O==="pending"){let M;if(i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData))M=i.data;else if(M=typeof r.placeholderData=="function"?r.placeholderData((N=a(this,lt))==null?void 0:N.state.data,a(this,lt)):r.placeholderData,r.select&&M!==void 0)try{M=r.select(M),b(this,de,null)}catch(Ae){b(this,de,Ae)}M!==void 0&&(O="success",p=Zt(i==null?void 0:i.data,M,r),y=!0)}a(this,de)&&(E=a(this,de),p=a(this,ct),g=Date.now(),O="error");const C=d.fetchStatus==="fetching",R=O==="pending",j=O==="error",z=R&&C,Y=p!==void 0,V={status:O,fetchStatus:d.fetchStatus,isPending:R,isSuccess:O==="success",isError:j,isInitialLoading:z,isLoading:z,data:p,dataUpdatedAt:d.dataUpdatedAt,error:E,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>h.dataUpdateCount||d.errorUpdateCount>h.errorUpdateCount,isFetching:C,isRefetching:C&&!R,isLoadingError:j&&!Y,isPaused:d.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:j&&Y,isStale:sr(e,r),refetch:this.refetch,promise:a(this,Re)};if(this.options.experimental_prefetchInRender){const M=ze=>{V.status==="error"?ze.reject(V.error):V.data!==void 0&&ze.resolve(V.data)},Ae=()=>{const ze=b(this,Re,V.promise=tr());M(ze)},Fe=a(this,Re);switch(Fe.status){case"pending":e.queryHash===n.queryHash&&M(Fe);break;case"fulfilled":(V.status==="error"||V.data!==Fe.value)&&Ae();break;case"rejected":(V.status!=="error"||V.error!==Fe.reason)&&Ae();break}}return V}updateResult(e){const r=a(this,G),n=this.createResult(a(this,x),this.options);if(b(this,Qe,a(this,x).state),b(this,ut,this.options),a(this,Qe).data!==void 0&&b(this,lt,a(this,x)),_t(n,r))return;b(this,G,n);const s={},i=()=>{if(!r)return!0;const{notifyOnChangeProps:u}=this.options,l=typeof u=="function"?u():u;if(l==="all"||!l&&!a(this,ft).size)return!0;const c=new Set(l??a(this,ft));return this.options.throwOnError&&c.add("error"),Object.keys(a(this,G)).some(h=>{const f=h;return a(this,G)[f]!==r[f]&&c.has(f)})};(e==null?void 0:e.listeners)!==!1&&i()&&(s.listeners=!0),S(this,I,vs).call(this,{...s,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&S(this,I,Tr).call(this)}},X=new WeakMap,x=new WeakMap,Tt=new WeakMap,G=new WeakMap,Qe=new WeakMap,ut=new WeakMap,Re=new WeakMap,de=new WeakMap,At=new WeakMap,ct=new WeakMap,lt=new WeakMap,$e=new WeakMap,Ke=new WeakMap,Se=new WeakMap,ft=new WeakMap,I=new WeakSet,Dt=function(e){S(this,I,xr).call(this);let r=a(this,x).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(re)),r},Rr=function(){S(this,I,Ar).call(this);const e=Be(this.options.staleTime,a(this,x));if(_e||a(this,G).isStale||!Gt(e))return;const n=jr(a(this,G).dataUpdatedAt,e)+1;b(this,$e,setTimeout(()=>{a(this,G).isStale||this.updateResult()},n))},Sr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,x)):this.options.refetchInterval)??!1},Cr=function(e){S(this,I,Fr).call(this),b(this,Se,e),!(_e||ie(this.options.enabled,a(this,x))===!1||!Gt(a(this,Se))||a(this,Se)===0)&&b(this,Ke,setInterval(()=>{(this.options.refetchIntervalInBackground||er.isFocused())&&S(this,I,Dt).call(this)},a(this,Se)))},Tr=function(){S(this,I,Rr).call(this),S(this,I,Cr).call(this,S(this,I,Sr).call(this))},Ar=function(){a(this,$e)&&(clearTimeout(a(this,$e)),b(this,$e,void 0))},Fr=function(){a(this,Ke)&&(clearInterval(a(this,Ke)),b(this,Ke,void 0))},xr=function(){const e=a(this,X).getQueryCache().build(a(this,X),this.options);if(e===a(this,x))return;const r=a(this,x);b(this,x,e),b(this,Tt,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},vs=function(e){K.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(a(this,G))}),a(this,X).getQueryCache().notify({query:a(this,x),type:"observerResultsUpdated"})})},Qn);function Ns(t,e){return ie(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Gr(t,e){return Ns(t,e)||t.state.data!==void 0&&nr(t,e,e.refetchOnMount)}function nr(t,e,r){if(ie(e.enabled,t)!==!1){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&sr(t,e)}return!1}function Yr(t,e,r,n){return(t!==e||ie(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&sr(t,r)}function sr(t,e){return ie(e.enabled,t)!==!1&&t.isStaleByTime(Be(e.staleTime,t))}function Ls(t,e){return!_t(t.getCurrentResult(),e)}var Qs=($n=class extends We{constructor(e,r){super();w(this,pe);w(this,Ce);w(this,Te);w(this,Z);w(this,ye);b(this,Ce,e),this.setOptions(r),this.bindMethods(),S(this,pe,Ht).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var n;const r=this.options;this.options=a(this,Ce).defaultMutationOptions(e),_t(this.options,r)||a(this,Ce).getMutationCache().notify({type:"observerOptionsUpdated",mutation:a(this,Z),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Ie(r.mutationKey)!==Ie(this.options.mutationKey)?this.reset():((n=a(this,Z))==null?void 0:n.state.status)==="pending"&&a(this,Z).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||(e=a(this,Z))==null||e.removeObserver(this)}onMutationUpdate(e){S(this,pe,Ht).call(this),S(this,pe,Dr).call(this,e)}getCurrentResult(){return a(this,Te)}reset(){var e;(e=a(this,Z))==null||e.removeObserver(this),b(this,Z,void 0),S(this,pe,Ht).call(this),S(this,pe,Dr).call(this)}mutate(e,r){var n;return b(this,ye,r),(n=a(this,Z))==null||n.removeObserver(this),b(this,Z,a(this,Ce).getMutationCache().build(a(this,Ce),this.options)),a(this,Z).addObserver(this),a(this,Z).execute(e)}},Ce=new WeakMap,Te=new WeakMap,Z=new WeakMap,ye=new WeakMap,pe=new WeakSet,Ht=function(){var r;const e=((r=a(this,Z))==null?void 0:r.state)??Hr();b(this,Te,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Dr=function(e){K.batch(()=>{var r,n,s,i,u,l,c,h;if(a(this,ye)&&this.hasListeners()){const f=a(this,Te).variables,d=a(this,Te).context;(e==null?void 0:e.type)==="success"?((n=(r=a(this,ye)).onSuccess)==null||n.call(r,e.data,f,d),(i=(s=a(this,ye)).onSettled)==null||i.call(s,e.data,null,f,d)):(e==null?void 0:e.type)==="error"&&((l=(u=a(this,ye)).onError)==null||l.call(u,e.error,f,d),(h=(c=a(this,ye)).onSettled)==null||h.call(c,void 0,e.error,f,d))}this.listeners.forEach(f=>{f(a(this,Te))})})},$n),Jr=U.createContext(void 0),Ge=t=>{const e=U.useContext(Jr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},$s=({client:t,children:e})=>(U.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),gt.jsx(Jr.Provider,{value:t,children:e})),Xr=U.createContext(!1),Ks=()=>U.useContext(Xr);Xr.Provider;function zs(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Vs=U.createContext(zs()),Hs=()=>U.useContext(Vs);function Zr(t,e){return typeof t=="function"?t(...e):!!t}function ir(){}var Ws=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Bs=t=>{U.useEffect(()=>{t.clearReset()},[t])},Gs=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Zr(r,[t.error,n])),Ys=t=>{const e=t.staleTime;t.suspense&&(t.staleTime=typeof e=="function"?(...r)=>Math.max(e(...r),1e3):Math.max(e??1e3,1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},Js=(t,e)=>t.isLoading&&t.isFetching&&!e,Xs=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,en=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Zs(t,e,r){var d,y,p,E,g;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=Ge(),s=Ks(),i=Hs(),u=n.defaultQueryOptions(t);(y=(d=n.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||y.call(d,u),process.env.NODE_ENV!=="production"&&(u.queryFn||console.error(`[${u.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),u._optimisticResults=s?"isRestoring":"optimistic",Ys(u),Ws(u,i),Bs(i);const l=!n.getQueryCache().get(u.queryHash),[c]=U.useState(()=>new e(n,u)),h=c.getOptimisticResult(u),f=!s&&t.subscribed!==!1;if(U.useSyncExternalStore(U.useCallback(O=>{const C=f?c.subscribe(K.batchCalls(O)):ir;return c.updateResult(),C},[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),U.useEffect(()=>{c.setOptions(u,{listeners:!1})},[u,c]),Xs(u,h))throw en(u,c,i);if(Gs({result:h,errorResetBoundary:i,throwOnError:u.throwOnError,query:n.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw h.error;if((E=(p=n.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||E.call(p,u,h),u.experimental_prefetchInRender&&!_e&&Js(h,s)){const O=l?en(u,c,i):(g=n.getQueryCache().get(u.queryHash))==null?void 0:g.promise;O==null||O.catch(ir).finally(()=>{c.updateResult()})}return u.notifyOnChangeProps?h:c.trackResult(h)}function or(t,e){return Zs(t,Us)}function qt(t,e){const r=Ge(),[n]=U.useState(()=>new Qs(r,t));U.useEffect(()=>{n.setOptions(t)},[n,t]);const s=U.useSyncExternalStore(U.useCallback(u=>n.subscribe(K.batchCalls(u)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=U.useCallback((u,l)=>{n.mutate(u,l).catch(ir)},[n]);if(s.error&&Zr(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}function Ye(t){const e={subscribe(r){let n=null,s=!1,i=!1,u=!1;function l(){if(n===null){u=!0;return}i||(i=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){var h;s||(h=r.next)==null||h.call(r,c)},error(c){var h;s||(s=!0,(h=r.error)==null||h.call(r,c),l())},complete(){var c;s||(s=!0,(c=r.complete)==null||c.call(r),l())}}),u&&l(),{unsubscribe:l}},pipe(...r){return r.reduce(ei,e)}};return e}function ei(t,e){return e(t)}function ti(t){const e=new AbortController;return new Promise((n,s)=>{let i=!1;function u(){i||(i=!0,l.unsubscribe())}e.signal.addEventListener("abort",()=>{s(e.signal.reason)});const l=t.subscribe({next(c){i=!0,n(c),u()},error(c){s(c)},complete(){e.abort(),u()}})})}function ri(t){return e=>{let r=0,n=null;const s=[];function i(){n||(n=e.subscribe({next(l){var c;for(const h of s)(c=h.next)==null||c.call(h,l)},error(l){var c;for(const h of s)(c=h.error)==null||c.call(h,l)},complete(){var l;for(const c of s)(l=c.complete)==null||l.call(c)}}))}function u(){if(r===0&&n){const l=n;n=null,l.unsubscribe()}}return Ye(l=>(r++,s.push(l),i(),{unsubscribe(){r--,u();const c=s.findIndex(h=>h===l);c>-1&&s.splice(c,1)}}))}}function ni(t){return e=>Ye(r=>e.subscribe({next(n){var s;(s=t.next)==null||s.call(t,n),r.next(n)},error(n){var s;(s=t.error)==null||s.call(t,n),r.error(n)},complete(){var n;(n=t.complete)==null||n.call(t),r.complete()}}))}function si(t){let e=t;const r=[],n=u=>{e!==void 0&&u.next(e),r.push(u)},s=u=>{r.splice(r.indexOf(u),1)},i=Ye(u=>(n(u),()=>{s(u)}));return i.next=u=>{if(e!==u){e=u;for(const l of r)l.next(u)}},i.get=()=>e,i}function ii(t){return Ye(e=>{function r(s=0,i=t.op){const u=t.links[s];if(!u)throw new Error("No more links to execute - did you forget to add an ending link?");return u({op:i,next(c){return r(s+1,c)}})}return r().subscribe(e)})}const tn=()=>{},rn=t=>{Object.freeze&&Object.freeze(t)};function nn(t,e,r){var n,s;const i=e.join(".");return(n=r)[s=i]??(n[s]=new Proxy(tn,{get(u,l){if(!(typeof l!="string"||l==="then"))return nn(t,[...e,l],r)},apply(u,l,c){const h=e[e.length-1];let f={args:c,path:e};return h==="call"?f={args:c.length>=2?[c[1]]:[],path:e.slice(0,-1)}:h==="apply"&&(f={args:c.length>=2?c[1]:[],path:e.slice(0,-1)}),rn(f.args),rn(f.path),t(f)}})),r[i]}const oi=t=>nn(t,[],Object.create(null)),ai=t=>new Proxy(tn,{get(e,r){if(r!=="then")return t(r)}});function wt(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function ui(t,e){if("error"in t){const n=e.deserialize(t.error);return{ok:!1,error:{...t,error:n}}}return{ok:!0,result:{...t.result,...(!t.result.type||t.result.type==="data")&&{type:"data",data:e.deserialize(t.result.data)}}}}class ar extends Error{constructor(){super("Unable to transform response from server")}}function ci(t,e){let r;try{r=ui(t,e)}catch{throw new ar}if(!r.ok&&(!wt(r.error.error)||typeof r.error.error.code!="number"))throw new ar;if(r.ok&&!wt(r.result))throw new ar;return r}var sn,on;(sn=Symbol).dispose??(sn.dispose=Symbol()),(on=Symbol).asyncDispose??(on.asyncDispose=Symbol()),typeof window>"u"||"Deno"in window||((zn=(Kn=globalThis.process)==null?void 0:Kn.env)==null?void 0:zn.NODE_ENV)==="test"||(Hn=(Vn=globalThis.process)==null?void 0:Vn.env)!=null&&Hn.JEST_WORKER_ID||(Bn=(Wn=globalThis.process)==null?void 0:Wn.env)!=null&&Bn.VITEST_WORKER_ID;function Mt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function li(t){return t instanceof ge||t instanceof Error&&t.name==="TRPCClientError"}function fi(t){return wt(t)&&wt(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function di(t,e){return typeof t=="string"?t:wt(t)&&typeof t.message=="string"?t.message:e}class ge extends Error{static from(e,r={}){const n=e;return li(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):fi(n)?new ge(n.error.message,{...r,result:n}):new ge(di(n,"Unknown error"),{...r,cause:n})}constructor(e,r){var s,i;const n=r==null?void 0:r.cause;super(e,{cause:n}),Mt(this,"cause",void 0),Mt(this,"shape",void 0),Mt(this,"data",void 0),Mt(this,"meta",void 0),this.meta=r==null?void 0:r.meta,this.cause=n,this.shape=(s=r==null?void 0:r.result)==null?void 0:s.error,this.data=(i=r==null?void 0:r.result)==null?void 0:i.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,ge.prototype)}}function ur(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class hi{$request(e){return ii({links:this.links,op:{...e,context:e.context??{},id:++this.requestId}}).pipe(ri())}async requestAsPromise(e){try{const r=this.$request(e);return(await ti(r)).result.data}catch(r){throw ge.from(r)}}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n.context,signal:n.signal}).subscribe({next(i){var u,l,c,h;switch(i.result.type){case"state":{(u=n.onConnectionStateChange)==null||u.call(n,i.result);break}case"started":{(l=n.onStarted)==null||l.call(n,{context:i.context});break}case"stopped":{(c=n.onStopped)==null||c.call(n);break}case"data":case void 0:{(h=n.onData)==null||h.call(n,i.result.data);break}}},error(i){var u;(u=n.onError)==null||u.call(n,i)},complete(){var i;(i=n.onComplete)==null||i.call(n)}})}constructor(e){ur(this,"links",void 0),ur(this,"runtime",void 0),ur(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(r=>r(this.runtime))}}const yi=Symbol.for("trpc_untypedClient"),pi={query:"query",mutate:"mutation",subscribe:"subscription"},mi=t=>pi[t];function gi(t){const e=oi(({path:r,args:n})=>{const s=[...r],i=mi(s.pop()),u=s.join(".");return t[i](u,...n)});return ai(r=>r===yi?t:e[r])}function bi(t){const e=new hi(t);return gi(e)}const an=t=>typeof t=="function";function vi(t){if(t)return t;if(typeof window<"u"&&an(window.fetch))return window.fetch;if(typeof globalThis<"u"&&an(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}const un=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function cn(t){let e=null,r=null;const n=()=>{clearTimeout(r),r=null,e=null};function s(l){var f,d;const c=[[]];let h=0;for(;;){const y=l[h];if(!y)break;const p=c[c.length-1];if(y.aborted){(f=y.reject)==null||f.call(y,new Error("Aborted")),h++;continue}if(t.validate(p.concat(y).map(g=>g.key))){p.push(y),h++;continue}if(p.length===0){(d=y.reject)==null||d.call(y,new Error("Input is too big for a single dispatch")),h++;continue}c.push([])}return c}function i(){const l=s(e);n();for(const c of l){if(!c.length)continue;const h={items:c};for(const d of c)d.batch=h;t.fetch(h.items.map(d=>d.key)).then(async d=>{var y;await Promise.all(d.map(async(p,E)=>{var O,C;const g=h.items[E];try{const R=await Promise.resolve(p);(O=g.resolve)==null||O.call(g,R)}catch(R){(C=g.reject)==null||C.call(g,R)}g.batch=null,g.reject=null,g.resolve=null}));for(const p of h.items)(y=p.reject)==null||y.call(p,new Error("Missing result")),p.batch=null}).catch(d=>{var y;for(const p of h.items)(y=p.reject)==null||y.call(p,d),p.batch=null})}}function u(l){const c={aborted:!1,key:l,batch:null,resolve:un,reject:un},h=new Promise((f,d)=>{c.reject=d,c.resolve=f,e||(e=[]),e.push(c)});return r||(r=setTimeout(i)),h}return{load:u}}function wi(...t){const e=new AbortController,r=t.length;let n=0;const s=()=>{++n===r&&e.abort()};for(const i of t)i!=null&&i.aborted?s():i==null||i.addEventListener("abort",s,{once:!0});return e.signal}function Ei(t){const e=t;return e?"input"in e?e:{input:e,output:e}:{input:{serialize:r=>r,deserialize:r=>r},output:{serialize:r=>r,deserialize:r=>r}}}function Oi(t){return{url:t.url.toString(),fetch:t.fetch,transformer:Ei(t.transformer),methodOverride:t.methodOverride}}function Pi(t){const e={};for(let r=0;r<t.length;r++){const n=t[r];e[r]=n}return e}const Ri={query:"GET",mutation:"POST",subscription:"PATCH"};function ln(t){return"input"in t?t.transformer.input.serialize(t.input):Pi(t.inputs.map(e=>t.transformer.input.serialize(e)))}const fn=t=>{const e=t.url.split("?");let n=e[0].replace(/\/$/,"")+"/"+t.path;const s=[];if(e[1]&&s.push(e[1]),"inputs"in t&&s.push("batch=1"),t.type==="query"||t.type==="subscription"){const i=ln(t);i!==void 0&&t.methodOverride!=="POST"&&s.push(`input=${encodeURIComponent(JSON.stringify(i))}`)}return s.length&&(n+="?"+s.join("&")),n},Si=t=>{if(t.type==="query"&&t.methodOverride!=="POST")return;const e=ln(t);return e!==void 0?JSON.stringify(e):void 0},Ci=t=>xi({...t,contentTypeHeader:"application/json",getUrl:fn,getBody:Si});class Ti extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}}const Ai=t=>{var e;if(t!=null&&t.aborted)throw(e=t.throwIfAborted)==null||e.call(t),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new Ti};async function Fi(t){Ai(t.signal);const e=t.getUrl(t),r=t.getBody(t),{type:n}=t,s=await(async()=>{const u=await t.headers();return Symbol.iterator in u?Object.fromEntries(u):u})(),i={...t.contentTypeHeader?{"content-type":t.contentTypeHeader}:{},...t.trpcAcceptHeader?{"trpc-accept":t.trpcAcceptHeader}:void 0,...s};return vi(t.fetch)(e,{method:t.methodOverride??Ri[n],signal:t.signal,body:r,headers:i})}async function xi(t){const e={},r=await Fi(t);e.response=r;const n=await r.json();return e.responseJSON=n,{json:n,meta:e}}function Di(t){const e=Oi(t),r=t.maxURLLength??1/0;return()=>{const n=l=>({validate(c){if(r===1/0)return!0;const h=c.map(y=>y.path).join(","),f=c.map(y=>y.input);return fn({...e,type:l,path:h,inputs:f,signal:null}).length<=r},async fetch(c){const h=c.map(g=>g.path).join(","),f=c.map(g=>g.input),d=wi(...c.map(g=>g.signal)),y=await Ci({...e,path:h,inputs:f,type:l,headers(){return t.headers?typeof t.headers=="function"?t.headers({opList:c}):t.headers:{}},signal:d});return(Array.isArray(y.json)?y.json:c.map(()=>y.json)).map(g=>({meta:y.meta,json:g}))}}),s=cn(n("query")),i=cn(n("mutation")),u={query:s,mutation:i};return({op:l})=>Ye(c=>{/* istanbul ignore if -- @preserve */if(l.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const f=u[l.type].load(l);let d;return f.then(y=>{d=y;const p=ci(y.json,e.transformer.output);if(!p.ok){c.error(ge.from(p.error,{meta:y.meta}));return}c.next({context:y.meta,result:p.result}),c.complete()}).catch(y=>{c.error(ge.from(y,{meta:d==null?void 0:d.meta}))}),()=>{}})}}function _i(t){return typeof FormData>"u"?!1:t instanceof FormData}const cr={css:{query:["72e3ff","3fb0d8"],mutation:["c5a3fc","904dfc"],subscription:["ff49e1","d83fbe"]},ansi:{regular:{query:["\x1B[30;46m","\x1B[97;46m"],mutation:["\x1B[30;45m","\x1B[97;45m"],subscription:["\x1B[30;42m","\x1B[97;42m"]},bold:{query:["\x1B[1;30;46m","\x1B[1;97;46m"],mutation:["\x1B[1;30;45m","\x1B[1;97;45m"],subscription:["\x1B[1;30;42m","\x1B[1;97;42m"]}}};function Ii(t){const{direction:e,type:r,withContext:n,path:s,id:i,input:u}=t,l=[],c=[];if(t.colorMode==="none")l.push(e==="up"?">>":"<<",r,`#${i}`,s);else if(t.colorMode==="ansi"){const[h,f]=cr.ansi.regular[r],[d,y]=cr.ansi.bold[r];l.push(e==="up"?h:f,e==="up"?">>":"<<",r,e==="up"?d:y,`#${i}`,s,"\x1B[0m")}else{const[h,f]=cr.css[r],d=`
31
31
  background-color: #${e==="up"?h:f};
32
32
  color: ${e==="up"?"black":"white"};
33
33
  padding: 2px;
34
- `;l.push("%c",e==="up"?">>":"<<",r,`#${i}`,`%c${s}%c`,"%O"),c.push(d,`${d}; font-weight: bold;`,`${d}; font-weight: normal;`)}return e==="up"?c.push(n?{input:u,context:t.context}:{input:u}):c.push({input:u,result:t.result,elapsedMs:t.elapsedMs,...n&&{context:t.context}}),{parts:l,args:c}}const ki=({c:t=console,colorMode:e="css",withContext:r})=>n=>{const s=n.input,i=_i(s)?Object.fromEntries(s):s,{parts:u,args:l}=Ii({...n,colorMode:e,input:i,withContext:r}),c=n.direction==="down"&&n.result&&(n.result instanceof Error||"error"in n.result.result&&n.result.result.error)?"error":"log";t[c].apply(null,[u.join(" ")].concat(l))};function ji(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),n=t.withContext??r==="css",{logger:s=ki({c:t.console,colorMode:r,withContext:n})}=t;return()=>({op:i,next:u})=>Be(l=>{e({...i,direction:"up"})&&s({...i,direction:"up"});const c=Date.now();function h(f){const d=Date.now()-c;e({...i,direction:"down",result:f})&&s({...i,direction:"down",elapsedMs:d,result:f})}return u(i).pipe(ni({next(f){h(f)},error(f){h(f)}})).subscribe(l)})}const qi=(t,...e)=>typeof t=="function"?t(...e):t;function Mi(){let t,e;return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}async function Ui(t){const e=await qi(t.url);if(!t.connectionParams)return e;const n=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+n}function ke(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ni(t){const{promise:e,resolve:r,reject:n}=Mi();return t.addEventListener("open",()=>{t.removeEventListener("error",n),r()}),t.addEventListener("error",n),e}function Li(t,{intervalMs:e,pongTimeoutMs:r}){let n,s;function i(){n=setTimeout(()=>{t.send("PING"),s=setTimeout(()=>{t.close()},r)},e)}function u(){clearTimeout(n),i()}function l(){clearTimeout(s),u()}t.addEventListener("open",i),t.addEventListener("message",({data:c})=>{clearTimeout(n),i(),c==="PONG"&&l()}),t.addEventListener("close",()=>{clearTimeout(n),clearTimeout(s)})}class Mt{get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){if(this.openPromise)return this.openPromise;this.id=++Mt.connectCount;const e=Ui(this.urlOptions).then(r=>new this.WebSocketPonyfill(r));this.openPromise=e.then(Ni),this.ws=await e,this.ws.addEventListener("message",function({data:r}){r==="PING"&&this.send("PONG")}),this.keepAliveOpts.enabled&&Li(this.ws,this.keepAliveOpts),this.ws.addEventListener("close",()=>{this.ws=null});try{await this.openPromise}finally{this.openPromise=null}}async close(){var e;try{await this.openPromise}finally{(e=this.ws)==null||e.close()}}constructor(e){if(ke(this,"id",++Mt.connectCount),ke(this,"WebSocketPonyfill",void 0),ke(this,"urlOptions",void 0),ke(this,"keepAliveOpts",void 0),ke(this,"wsObservable",si(null)),ke(this,"openPromise",null),this.WebSocketPonyfill=e.WebSocketPonyfill??WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=e.urlOptions,this.keepAliveOpts=e.keepAlive}}ke(Mt,"connectCount",0);class Qi{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,r){this.keyToValue.set(e,r),this.valueToKey.set(r,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class dn{constructor(e){this.generateIdentifier=e,this.kv=new Qi}register(e,r){this.kv.getByValue(e)||(r||(r=this.generateIdentifier(e)),this.kv.set(r,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}}class $i extends dn{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,r){typeof r=="object"?(r.allowProps&&this.classToAllowedProps.set(e,r.allowProps),super.register(e,r.identifier)):super.register(e,r)}getAllowedProps(e){return this.classToAllowedProps.get(e)}}function Ki(t){if("values"in Object)return Object.values(t);const e=[];for(const r in t)t.hasOwnProperty(r)&&e.push(t[r]);return e}function Vi(t,e){const r=Ki(t);if("find"in r)return r.find(e);const n=r;for(let s=0;s<n.length;s++){const i=n[s];if(e(i))return i}}function Ge(t,e){Object.entries(t).forEach(([r,n])=>e(n,r))}function Ut(t,e){return t.indexOf(e)!==-1}function hn(t,e){for(let r=0;r<t.length;r++){const n=t[r];if(e(n))return n}}class zi{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Vi(this.transfomers,r=>r.isApplicable(e))}findByName(e){return this.transfomers[e]}}const Hi=t=>Object.prototype.toString.call(t).slice(8,-1),yn=t=>typeof t>"u",Wi=t=>t===null,Et=t=>typeof t!="object"||t===null||t===Object.prototype?!1:Object.getPrototypeOf(t)===null?!0:Object.getPrototypeOf(t)===Object.prototype,cr=t=>Et(t)&&Object.keys(t).length===0,be=t=>Array.isArray(t),Bi=t=>typeof t=="string",Gi=t=>typeof t=="number"&&!isNaN(t),Yi=t=>typeof t=="boolean",Ji=t=>t instanceof RegExp,Ot=t=>t instanceof Map,Pt=t=>t instanceof Set,pn=t=>Hi(t)==="Symbol",Xi=t=>t instanceof Date&&!isNaN(t.valueOf()),Zi=t=>t instanceof Error,mn=t=>typeof t=="number"&&isNaN(t),eo=t=>Yi(t)||Wi(t)||yn(t)||Gi(t)||Bi(t)||pn(t),to=t=>typeof t=="bigint",ro=t=>t===1/0||t===-1/0,no=t=>ArrayBuffer.isView(t)&&!(t instanceof DataView),so=t=>t instanceof URL,gn=t=>t.replace(/\./g,"\\."),lr=t=>t.map(String).map(gn).join("."),Rt=t=>{const e=[];let r="";for(let s=0;s<t.length;s++){let i=t.charAt(s);if(i==="\\"&&t.charAt(s+1)==="."){r+=".",s++;continue}if(i==="."){e.push(r),r="";continue}r+=i}const n=r;return e.push(n),e};function ue(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const bn=[ue(yn,"undefined",()=>null,()=>{}),ue(to,"bigint",t=>t.toString(),t=>typeof BigInt<"u"?BigInt(t):(console.error("Please add a BigInt polyfill."),t)),ue(Xi,"Date",t=>t.toISOString(),t=>new Date(t)),ue(Zi,"Error",(t,e)=>{const r={name:t.name,message:t.message};return e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r},(t,e)=>{const r=new Error(t.message);return r.name=t.name,r.stack=t.stack,e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r}),ue(Ji,"regexp",t=>""+t,t=>{const e=t.slice(1,t.lastIndexOf("/")),r=t.slice(t.lastIndexOf("/")+1);return new RegExp(e,r)}),ue(Pt,"set",t=>[...t.values()],t=>new Set(t)),ue(Ot,"map",t=>[...t.entries()],t=>new Map(t)),ue(t=>mn(t)||ro(t),"number",t=>mn(t)?"NaN":t>0?"Infinity":"-Infinity",Number),ue(t=>t===0&&1/t===-1/0,"number",()=>"-0",Number),ue(so,"URL",t=>t.toString(),t=>new URL(t))];function Nt(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const vn=Nt((t,e)=>pn(t)?!!e.symbolRegistry.getIdentifier(t):!1,(t,e)=>["symbol",e.symbolRegistry.getIdentifier(t)],t=>t.description,(t,e,r)=>{const n=r.symbolRegistry.getValue(e[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),io=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((t,e)=>(t[e.name]=e,t),{}),wn=Nt(no,t=>["typed-array",t.constructor.name],t=>[...t],(t,e)=>{const r=io[e[1]];if(!r)throw new Error("Trying to deserialize unknown typed array");return new r(t)});function En(t,e){return t!=null&&t.constructor?!!e.classRegistry.getIdentifier(t.constructor):!1}const On=Nt(En,(t,e)=>["class",e.classRegistry.getIdentifier(t.constructor)],(t,e)=>{const r=e.classRegistry.getAllowedProps(t.constructor);if(!r)return{...t};const n={};return r.forEach(s=>{n[s]=t[s]}),n},(t,e,r)=>{const n=r.classRegistry.getValue(e[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${e[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),t)}),Pn=Nt((t,e)=>!!e.customTransformerRegistry.findApplicable(t),(t,e)=>["custom",e.customTransformerRegistry.findApplicable(t).name],(t,e)=>e.customTransformerRegistry.findApplicable(t).serialize(t),(t,e,r)=>{const n=r.customTransformerRegistry.findByName(e[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(t)}),oo=[On,vn,Pn,wn],Rn=(t,e)=>{const r=hn(oo,s=>s.isApplicable(t,e));if(r)return{value:r.transform(t,e),type:r.annotation(t,e)};const n=hn(bn,s=>s.isApplicable(t,e));if(n)return{value:n.transform(t,e),type:n.annotation}},Sn={};bn.forEach(t=>{Sn[t.annotation]=t});const ao=(t,e,r)=>{if(be(e))switch(e[0]){case"symbol":return vn.untransform(t,e,r);case"class":return On.untransform(t,e,r);case"custom":return Pn.untransform(t,e,r);case"typed-array":return wn.untransform(t,e,r);default:throw new Error("Unknown transformation: "+e)}else{const n=Sn[e];if(!n)throw new Error("Unknown transformation: "+e);return n.untransform(t,r)}},Ye=(t,e)=>{if(e>t.size)throw new Error("index out of bounds");const r=t.keys();for(;e>0;)r.next(),e--;return r.next().value};function Cn(t){if(Ut(t,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Ut(t,"prototype"))throw new Error("prototype is not allowed as a property");if(Ut(t,"constructor"))throw new Error("constructor is not allowed as a property")}const uo=(t,e)=>{Cn(e);for(let r=0;r<e.length;r++){const n=e[r];if(Pt(t))t=Ye(t,+n);else if(Ot(t)){const s=+n,i=+e[++r]==0?"key":"value",u=Ye(t,s);switch(i){case"key":t=u;break;case"value":t=t.get(u);break}}else t=t[n]}return t},fr=(t,e,r)=>{if(Cn(e),e.length===0)return r(t);let n=t;for(let i=0;i<e.length-1;i++){const u=e[i];if(be(n)){const l=+u;n=n[l]}else if(Et(n))n=n[u];else if(Pt(n)){const l=+u;n=Ye(n,l)}else if(Ot(n)){if(i===e.length-2)break;const c=+u,h=+e[++i]==0?"key":"value",f=Ye(n,c);switch(h){case"key":n=f;break;case"value":n=n.get(f);break}}}const s=e[e.length-1];if(be(n)?n[+s]=r(n[+s]):Et(n)&&(n[s]=r(n[s])),Pt(n)){const i=Ye(n,+s),u=r(i);i!==u&&(n.delete(i),n.add(u))}if(Ot(n)){const i=+e[e.length-2],u=Ye(n,i);switch(+s==0?"key":"value"){case"key":{const c=r(u);n.set(c,n.get(u)),c!==u&&n.delete(u);break}case"value":{n.set(u,r(n.get(u)));break}}}return t};function dr(t,e,r=[]){if(!t)return;if(!be(t)){Ge(t,(i,u)=>dr(i,e,[...r,...Rt(u)]));return}const[n,s]=t;s&&Ge(s,(i,u)=>{dr(i,e,[...r,...Rt(u)])}),e(n,r)}function co(t,e,r){return dr(e,(n,s)=>{t=fr(t,s,i=>ao(i,n,r))}),t}function lo(t,e){function r(n,s){const i=uo(t,Rt(s));n.map(Rt).forEach(u=>{t=fr(t,u,()=>i)})}if(be(e)){const[n,s]=e;n.forEach(i=>{t=fr(t,Rt(i),()=>t)}),s&&Ge(s,r)}else Ge(e,r);return t}const fo=(t,e)=>Et(t)||be(t)||Ot(t)||Pt(t)||En(t,e);function ho(t,e,r){const n=r.get(t);n?n.push(e):r.set(t,[e])}function yo(t,e){const r={};let n;return t.forEach(s=>{if(s.length<=1)return;e||(s=s.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[i,...u]=s;i.length===0?n=u.map(lr):r[lr(i)]=u.map(lr)}),n?cr(r)?[n]:[n,r]:cr(r)?void 0:r}const Tn=(t,e,r,n,s=[],i=[],u=new Map)=>{const l=eo(t);if(!l){ho(t,s,e);const p=u.get(t);if(p)return n?{transformedValue:null}:p}if(!fo(t,r)){const p=Rn(t,r),E=p?{transformedValue:p.value,annotations:[p.type]}:{transformedValue:t};return l||u.set(t,E),E}if(Ut(i,t))return{transformedValue:null};const c=Rn(t,r),h=(c==null?void 0:c.value)??t,f=be(h)?[]:{},d={};Ge(h,(p,E)=>{if(E==="__proto__"||E==="constructor"||E==="prototype")throw new Error(`Detected property ${E}. This is a prototype pollution risk, please remove it from your object.`);const g=Tn(p,e,r,n,[...s,E],[...i,t],u);f[E]=g.transformedValue,be(g.annotations)?d[E]=g.annotations:Et(g.annotations)&&Ge(g.annotations,(O,C)=>{d[gn(E)+"."+C]=O})});const y=cr(d)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,d]:d};return l||u.set(t,y),y};function An(t){return Object.prototype.toString.call(t).slice(8,-1)}function xn(t){return An(t)==="Array"}function po(t){if(An(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return!!e&&e.constructor===Object&&e===Object.prototype}function mo(t,e,r,n,s){const i={}.propertyIsEnumerable.call(n,e)?"enumerable":"nonenumerable";i==="enumerable"&&(t[e]=r),s&&i==="nonenumerable"&&Object.defineProperty(t,e,{value:r,enumerable:!1,writable:!0,configurable:!0})}function hr(t,e={}){if(xn(t))return t.map(s=>hr(s,e));if(!po(t))return t;const r=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return[...r,...n].reduce((s,i)=>{if(xn(e.props)&&!e.props.includes(i))return s;const u=t[i],l=hr(u,e);return mo(s,i,l,t,e.nonenumerable),s},{})}class A{constructor({dedupe:e=!1}={}){this.classRegistry=new $i,this.symbolRegistry=new dn(r=>r.description??""),this.customTransformerRegistry=new zi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const r=new Map,n=Tn(e,r,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const i=yo(r,this.dedupe);return i&&(s.meta={...s.meta,referentialEqualities:i}),s}deserialize(e){const{json:r,meta:n}=e;let s=hr(r);return n!=null&&n.values&&(s=co(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=lo(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,r){this.classRegistry.register(e,r)}registerSymbol(e,r){this.symbolRegistry.register(e,r)}registerCustom(e,r){this.customTransformerRegistry.register({name:r,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}}A.defaultInstance=new A,A.serialize=A.defaultInstance.serialize.bind(A.defaultInstance),A.deserialize=A.defaultInstance.deserialize.bind(A.defaultInstance),A.stringify=A.defaultInstance.stringify.bind(A.defaultInstance),A.parse=A.defaultInstance.parse.bind(A.defaultInstance),A.registerClass=A.defaultInstance.registerClass.bind(A.defaultInstance),A.registerSymbol=A.defaultInstance.registerSymbol.bind(A.defaultInstance),A.registerCustom=A.defaultInstance.registerCustom.bind(A.defaultInstance),A.allowErrorProps=A.defaultInstance.allowErrorProps.bind(A.defaultInstance),A.serialize,A.deserialize,A.stringify,A.parse,A.registerClass,A.registerCustom,A.registerSymbol,A.allowErrorProps;const Fn=_.createContext(null);function go(t,e){const r=bi({links:[ji({enabled:s=>process.env.NODE_ENV==="development"&&typeof window<"u"||s.direction==="down"&&s.result instanceof Error}),Di({url:`${t}/trpc`,headers:()=>({Authorization:`Bearer ${e}`}),transformer:A})]}),n=async(s,i,u=null)=>{const l=Object.entries(Ir).reduce((y,[p,E])=>(E.extensions.forEach(g=>{y.set(g,p)}),y),new Map),c=i.map(y=>{const p=y.name.toLowerCase(),E=p.includes(".")?p.substring(p.lastIndexOf(".")):"",g=E.startsWith(".")?E:`.${E}`,O=l.get(g)||null;return{...y,mimeType:O}}).filter(y=>y.mimeType!==null&&Os.has(y.mimeType));if(c.length===0)return{filesToCreate:[]};const h=await r.fileRouter.getFilesByProject.query({projectId:s}),f=c.filter(y=>u===null?!h.some(p=>p.path===y.blobUrl):!h.some(p=>p.path===y.blobUrl&&p.parentId===u));return f.length===0?{filesToCreate:[]}:{filesToCreate:f.map(y=>({projectId:s,mimeType:y.mimeType,path:y.blobUrl,name:y.name,size:0,metadata:null,isArtifact:!1,summary:null,chunkingStatus:Ht.NOT_CHUNKED,isDirectory:!1,parentId:u}))}};return{getProjectsForUser:async()=>{const s=await r.projectRouter.getAllProjects.query();if(s.length===0){const i=await r.projectRouter.createProject.mutate({name:"Default Project"});return[{name:i.name,id:i.id,updatedAt:i.updatedAt,createdAt:i.createdAt}]}return s.map(i=>({name:i.name,id:i.id,updatedAt:i.updatedAt,createdAt:i.createdAt}))},addProjectForUser:async s=>{const i=await r.projectRouter.createProject.mutate({name:s});return{name:i.name,id:i.id,updatedAt:i.updatedAt,createdAt:i.createdAt}},addFilesToProject:async(s,i)=>{const{filesToCreate:u}=await n(s,i);return u.length===0?[]:(await r.fileRouter.createFiles.mutate({files:u})).map(c=>({blobUrl:c.path,name:c.name,id:c.id,parentId:c.parentId,isDirectory:c.isDirectory,createdAt:c.createdAt,updatedAt:c.updatedAt}))},getFilesForProject:async s=>(await r.fileRouter.getFilesByProject.query({projectId:s})).map(u=>({blobUrl:u.path,name:u.name,id:u.id,parentId:u.parentId,isDirectory:u.isDirectory,createdAt:u.createdAt,updatedAt:u.updatedAt})),addDirectoryWithFilesToProject:async(s,i,u,l)=>{if((await r.fileRouter.getFilesByProject.query({projectId:s})).some(p=>p.name===i&&p.isDirectory===!0&&p.parentId===null))return console.warn(`A directory named "${i}" already exists at the root level. Skipping creation.`),{directory:null,files:[]};const f=await r.fileRouter.createFile.mutate({file:{projectId:s,mimeType:Wt.DIRECTORY,path:"",name:i,size:0,metadata:u,isArtifact:!1,isDirectory:!0,parentId:null,summary:null,chunkingStatus:Ht.NOT_CHUNKED}});if(l.length===0)return{directory:{blobUrl:f.path,name:f.name,id:f.id,parentId:f.parentId,isDirectory:f.isDirectory,createdAt:f.createdAt,updatedAt:f.updatedAt},files:[]};const{filesToCreate:d}=await n(s,l,f.id);if(d.length===0)return{directory:{blobUrl:f.path,name:f.name,id:f.id,parentId:f.parentId,isDirectory:f.isDirectory,createdAt:f.createdAt,updatedAt:f.updatedAt},files:[]};const y=await r.fileRouter.createFiles.mutate({files:d});return{directory:f?{blobUrl:f.path,name:f.name,id:f.id,parentId:f.parentId,isDirectory:f.isDirectory,createdAt:f.createdAt,updatedAt:f.updatedAt}:null,files:y.map(p=>({blobUrl:p.path,name:p.name,id:p.id,parentId:p.parentId,isDirectory:p.isDirectory,createdAt:p.createdAt,updatedAt:p.updatedAt}))}},updateUserMetadata:async s=>{await r.userRouter.updateUserMetadata.mutate({metadata:s})},getUserMetadata:async()=>await r.userRouter.getUserMetadata.query()}}function bo({children:t,host:e="http://localhost",port:r=5174,token:n,userMetadata:s,onAnalyticsEvent:i,passTokenInQueryParam:u=!1}){const[l,c]=_.useState(null),h=_.useMemo(()=>new Ms({defaultOptions:{queries:{staleTime:30*1e3,refetchOnWindowFocus:!1}}}),[]);return _.useEffect(()=>{const f=`${e}:${r}`,d=go(f,n);c(d)},[e,r,n]),_.useEffect(()=>{if(!l||!s)return;const f=JSON.stringify(s);l.updateUserMetadata(f).catch(d=>{console.error("Failed to update user metadata:",d)})},[l,s]),_.useEffect(()=>{if(!i)return;const f=y=>{i(y.detail)},d=y=>{var p;((p=y.data)==null?void 0:p.type)==="folio-analytics"&&y.data.event&&i(y.data.event)};return window.addEventListener("folio-analytics",f),window.addEventListener("message",d),()=>{window.removeEventListener("folio-analytics",f),window.removeEventListener("message",d)}},[i]),mt.jsx($s,{client:h,children:mt.jsx(Fn.Provider,{value:{host:e,port:r,client:l,token:n,passTokenInQueryParam:u},children:t})})}function Je(){const t=_.useContext(Fn);if(!t)throw new Error("useFolioContext must be used within a FolioProvider");return t}const Dn="folio-token",{useEffect:_n,useRef:vo,useState:wo}=U;function Eo({width:t="100%",height:e="100vh",allow:r="camera; microphone; clipboard-read; clipboard-write; fullscreen",style:n,className:s="",iframeProps:i={},passTokenInQueryParam:u}){const{host:l,port:c,token:h,passTokenInQueryParam:f}=Je(),d=vo(null),[y,p]=wo(),E=`${l}:${c}`,g=u!==void 0?u:f;_n(()=>{(()=>{let R=E;g&&(R=`${E}?jwt=${encodeURIComponent(h)}`),p(R)})()},[l,c,h,E,g]),_n(()=>{if(g||!d.current)return;const C=R=>{var j;if(((j=R.data)==null?void 0:j.type)==="folio-request-token"&&!(!R.source||typeof R.source.postMessage!="function"))try{R.source.postMessage({type:Dn,token:h},"*")}catch{}};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[h,g]);const O=()=>{var C;if(!(g||!((C=d.current)!=null&&C.contentWindow)))try{d.current.contentWindow.postMessage({type:Dn,token:h},"*")}catch{}};return y?mt.jsx("div",{className:`folio-embed-container ${s}`,style:{width:t,height:e,overflow:"hidden",...n},children:mt.jsx("iframe",{ref:d,src:y,width:"100%",height:"100%",style:{border:"none",width:"100%",height:"100%",overflow:"auto"},allow:r,allowFullScreen:!0,onLoad:O,...i})}):null}function Oo(){const{client:t}=Je(),e=en({queryKey:["folioProjects"],queryFn:async()=>{if(!t)throw new Error("Folio client not initialized");return t.getProjectsForUser()},enabled:!!t});return{projects:e.data||[],isLoading:e.isLoading,isError:e.isError,error:e.error,refetch:e.refetch}}function Po(t){const{client:e}=Je(),r=en({queryKey:["folioFiles",t],queryFn:async()=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.getFilesForProject(t)},enabled:!!e&&!!t});return{files:r.data||[],isLoading:r.isLoading,isError:r.isError,error:r.error,refetch:r.refetch}}function Ro(){const{client:t}=Je(),e=vt(),r=ir({mutationFn:async n=>{if(!t)throw new Error("Folio client not initialized");return t.addProjectForUser(n)},onSuccess:()=>{e.invalidateQueries({queryKey:["folioProjects"]})}});return{addProject:r.mutate,addProjectAsync:r.mutateAsync,isAdding:r.isPending,isError:r.isError,error:r.error,newProject:r.data}}function So(t){const{client:e}=Je(),r=vt(),n=ir({mutationFn:async s=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.addFilesToProject(t,s)},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addFiles:n.mutate,addFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,newFiles:n.data}}function Co(t){const{client:e}=Je(),r=vt(),n=ir({mutationFn:async s=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");const i=Array.isArray(s)?s:[s],u=[];for(const l of i){const c=JSON.stringify(l.directoryMetadata),h=await e.addDirectoryWithFilesToProject(t,l.directoryName,c,l.files);u.push(h)}return Array.isArray(s)?u:u[0]},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addDirectoriesWithFiles:n.mutate,addDirectoriesWithFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,result:n.data}}F.FolioEmbed=Eo,F.FolioProvider=bo,F.useAddFolioDirectoriesWithFiles=Co,F.useAddFolioFiles=So,F.useAddFolioProject=Ro,F.useFolioFiles=Po,F.useFolioProjects=Oo,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
34
+ `;l.push("%c",e==="up"?">>":"<<",r,`#${i}`,`%c${s}%c`,"%O"),c.push(d,`${d}; font-weight: bold;`,`${d}; font-weight: normal;`)}return e==="up"?c.push(n?{input:u,context:t.context}:{input:u}):c.push({input:u,result:t.result,elapsedMs:t.elapsedMs,...n&&{context:t.context}}),{parts:l,args:c}}const ki=({c:t=console,colorMode:e="css",withContext:r})=>n=>{const s=n.input,i=_i(s)?Object.fromEntries(s):s,{parts:u,args:l}=Ii({...n,colorMode:e,input:i,withContext:r}),c=n.direction==="down"&&n.result&&(n.result instanceof Error||"error"in n.result.result&&n.result.result.error)?"error":"log";t[c].apply(null,[u.join(" ")].concat(l))};function ji(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),n=t.withContext??r==="css",{logger:s=ki({c:t.console,colorMode:r,withContext:n})}=t;return()=>({op:i,next:u})=>Ye(l=>{e({...i,direction:"up"})&&s({...i,direction:"up"});const c=Date.now();function h(f){const d=Date.now()-c;e({...i,direction:"down",result:f})&&s({...i,direction:"down",elapsedMs:d,result:f})}return u(i).pipe(ni({next(f){h(f)},error(f){h(f)}})).subscribe(l)})}const qi=(t,...e)=>typeof t=="function"?t(...e):t;function Mi(){let t,e;return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}async function Ui(t){const e=await qi(t.url);if(!t.connectionParams)return e;const n=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+n}function ke(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ni(t){const{promise:e,resolve:r,reject:n}=Mi();return t.addEventListener("open",()=>{t.removeEventListener("error",n),r()}),t.addEventListener("error",n),e}function Li(t,{intervalMs:e,pongTimeoutMs:r}){let n,s;function i(){n=setTimeout(()=>{t.send("PING"),s=setTimeout(()=>{t.close()},r)},e)}function u(){clearTimeout(n),i()}function l(){clearTimeout(s),u()}t.addEventListener("open",i),t.addEventListener("message",({data:c})=>{clearTimeout(n),i(),c==="PONG"&&l()}),t.addEventListener("close",()=>{clearTimeout(n),clearTimeout(s)})}class Ut{get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){if(this.openPromise)return this.openPromise;this.id=++Ut.connectCount;const e=Ui(this.urlOptions).then(r=>new this.WebSocketPonyfill(r));this.openPromise=e.then(Ni),this.ws=await e,this.ws.addEventListener("message",function({data:r}){r==="PING"&&this.send("PONG")}),this.keepAliveOpts.enabled&&Li(this.ws,this.keepAliveOpts),this.ws.addEventListener("close",()=>{this.ws=null});try{await this.openPromise}finally{this.openPromise=null}}async close(){var e;try{await this.openPromise}finally{(e=this.ws)==null||e.close()}}constructor(e){if(ke(this,"id",++Ut.connectCount),ke(this,"WebSocketPonyfill",void 0),ke(this,"urlOptions",void 0),ke(this,"keepAliveOpts",void 0),ke(this,"wsObservable",si(null)),ke(this,"openPromise",null),this.WebSocketPonyfill=e.WebSocketPonyfill??WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=e.urlOptions,this.keepAliveOpts=e.keepAlive}}ke(Ut,"connectCount",0);class Qi{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,r){this.keyToValue.set(e,r),this.valueToKey.set(r,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class dn{constructor(e){this.generateIdentifier=e,this.kv=new Qi}register(e,r){this.kv.getByValue(e)||(r||(r=this.generateIdentifier(e)),this.kv.set(r,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}}class $i extends dn{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,r){typeof r=="object"?(r.allowProps&&this.classToAllowedProps.set(e,r.allowProps),super.register(e,r.identifier)):super.register(e,r)}getAllowedProps(e){return this.classToAllowedProps.get(e)}}function Ki(t){if("values"in Object)return Object.values(t);const e=[];for(const r in t)t.hasOwnProperty(r)&&e.push(t[r]);return e}function zi(t,e){const r=Ki(t);if("find"in r)return r.find(e);const n=r;for(let s=0;s<n.length;s++){const i=n[s];if(e(i))return i}}function Je(t,e){Object.entries(t).forEach(([r,n])=>e(n,r))}function Nt(t,e){return t.indexOf(e)!==-1}function hn(t,e){for(let r=0;r<t.length;r++){const n=t[r];if(e(n))return n}}class Vi{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return zi(this.transfomers,r=>r.isApplicable(e))}findByName(e){return this.transfomers[e]}}const Hi=t=>Object.prototype.toString.call(t).slice(8,-1),yn=t=>typeof t>"u",Wi=t=>t===null,Et=t=>typeof t!="object"||t===null||t===Object.prototype?!1:Object.getPrototypeOf(t)===null?!0:Object.getPrototypeOf(t)===Object.prototype,lr=t=>Et(t)&&Object.keys(t).length===0,be=t=>Array.isArray(t),Bi=t=>typeof t=="string",Gi=t=>typeof t=="number"&&!isNaN(t),Yi=t=>typeof t=="boolean",Ji=t=>t instanceof RegExp,Ot=t=>t instanceof Map,Pt=t=>t instanceof Set,pn=t=>Hi(t)==="Symbol",Xi=t=>t instanceof Date&&!isNaN(t.valueOf()),Zi=t=>t instanceof Error,mn=t=>typeof t=="number"&&isNaN(t),eo=t=>Yi(t)||Wi(t)||yn(t)||Gi(t)||Bi(t)||pn(t),to=t=>typeof t=="bigint",ro=t=>t===1/0||t===-1/0,no=t=>ArrayBuffer.isView(t)&&!(t instanceof DataView),so=t=>t instanceof URL,gn=t=>t.replace(/\./g,"\\."),fr=t=>t.map(String).map(gn).join("."),Rt=t=>{const e=[];let r="";for(let s=0;s<t.length;s++){let i=t.charAt(s);if(i==="\\"&&t.charAt(s+1)==="."){r+=".",s++;continue}if(i==="."){e.push(r),r="";continue}r+=i}const n=r;return e.push(n),e};function ue(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const bn=[ue(yn,"undefined",()=>null,()=>{}),ue(to,"bigint",t=>t.toString(),t=>typeof BigInt<"u"?BigInt(t):(console.error("Please add a BigInt polyfill."),t)),ue(Xi,"Date",t=>t.toISOString(),t=>new Date(t)),ue(Zi,"Error",(t,e)=>{const r={name:t.name,message:t.message};return e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r},(t,e)=>{const r=new Error(t.message);return r.name=t.name,r.stack=t.stack,e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r}),ue(Ji,"regexp",t=>""+t,t=>{const e=t.slice(1,t.lastIndexOf("/")),r=t.slice(t.lastIndexOf("/")+1);return new RegExp(e,r)}),ue(Pt,"set",t=>[...t.values()],t=>new Set(t)),ue(Ot,"map",t=>[...t.entries()],t=>new Map(t)),ue(t=>mn(t)||ro(t),"number",t=>mn(t)?"NaN":t>0?"Infinity":"-Infinity",Number),ue(t=>t===0&&1/t===-1/0,"number",()=>"-0",Number),ue(so,"URL",t=>t.toString(),t=>new URL(t))];function Lt(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const vn=Lt((t,e)=>pn(t)?!!e.symbolRegistry.getIdentifier(t):!1,(t,e)=>["symbol",e.symbolRegistry.getIdentifier(t)],t=>t.description,(t,e,r)=>{const n=r.symbolRegistry.getValue(e[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),io=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((t,e)=>(t[e.name]=e,t),{}),wn=Lt(no,t=>["typed-array",t.constructor.name],t=>[...t],(t,e)=>{const r=io[e[1]];if(!r)throw new Error("Trying to deserialize unknown typed array");return new r(t)});function En(t,e){return t!=null&&t.constructor?!!e.classRegistry.getIdentifier(t.constructor):!1}const On=Lt(En,(t,e)=>["class",e.classRegistry.getIdentifier(t.constructor)],(t,e)=>{const r=e.classRegistry.getAllowedProps(t.constructor);if(!r)return{...t};const n={};return r.forEach(s=>{n[s]=t[s]}),n},(t,e,r)=>{const n=r.classRegistry.getValue(e[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${e[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),t)}),Pn=Lt((t,e)=>!!e.customTransformerRegistry.findApplicable(t),(t,e)=>["custom",e.customTransformerRegistry.findApplicable(t).name],(t,e)=>e.customTransformerRegistry.findApplicable(t).serialize(t),(t,e,r)=>{const n=r.customTransformerRegistry.findByName(e[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(t)}),oo=[On,vn,Pn,wn],Rn=(t,e)=>{const r=hn(oo,s=>s.isApplicable(t,e));if(r)return{value:r.transform(t,e),type:r.annotation(t,e)};const n=hn(bn,s=>s.isApplicable(t,e));if(n)return{value:n.transform(t,e),type:n.annotation}},Sn={};bn.forEach(t=>{Sn[t.annotation]=t});const ao=(t,e,r)=>{if(be(e))switch(e[0]){case"symbol":return vn.untransform(t,e,r);case"class":return On.untransform(t,e,r);case"custom":return Pn.untransform(t,e,r);case"typed-array":return wn.untransform(t,e,r);default:throw new Error("Unknown transformation: "+e)}else{const n=Sn[e];if(!n)throw new Error("Unknown transformation: "+e);return n.untransform(t,r)}},Xe=(t,e)=>{if(e>t.size)throw new Error("index out of bounds");const r=t.keys();for(;e>0;)r.next(),e--;return r.next().value};function Cn(t){if(Nt(t,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Nt(t,"prototype"))throw new Error("prototype is not allowed as a property");if(Nt(t,"constructor"))throw new Error("constructor is not allowed as a property")}const uo=(t,e)=>{Cn(e);for(let r=0;r<e.length;r++){const n=e[r];if(Pt(t))t=Xe(t,+n);else if(Ot(t)){const s=+n,i=+e[++r]==0?"key":"value",u=Xe(t,s);switch(i){case"key":t=u;break;case"value":t=t.get(u);break}}else t=t[n]}return t},dr=(t,e,r)=>{if(Cn(e),e.length===0)return r(t);let n=t;for(let i=0;i<e.length-1;i++){const u=e[i];if(be(n)){const l=+u;n=n[l]}else if(Et(n))n=n[u];else if(Pt(n)){const l=+u;n=Xe(n,l)}else if(Ot(n)){if(i===e.length-2)break;const c=+u,h=+e[++i]==0?"key":"value",f=Xe(n,c);switch(h){case"key":n=f;break;case"value":n=n.get(f);break}}}const s=e[e.length-1];if(be(n)?n[+s]=r(n[+s]):Et(n)&&(n[s]=r(n[s])),Pt(n)){const i=Xe(n,+s),u=r(i);i!==u&&(n.delete(i),n.add(u))}if(Ot(n)){const i=+e[e.length-2],u=Xe(n,i);switch(+s==0?"key":"value"){case"key":{const c=r(u);n.set(c,n.get(u)),c!==u&&n.delete(u);break}case"value":{n.set(u,r(n.get(u)));break}}}return t};function hr(t,e,r=[]){if(!t)return;if(!be(t)){Je(t,(i,u)=>hr(i,e,[...r,...Rt(u)]));return}const[n,s]=t;s&&Je(s,(i,u)=>{hr(i,e,[...r,...Rt(u)])}),e(n,r)}function co(t,e,r){return hr(e,(n,s)=>{t=dr(t,s,i=>ao(i,n,r))}),t}function lo(t,e){function r(n,s){const i=uo(t,Rt(s));n.map(Rt).forEach(u=>{t=dr(t,u,()=>i)})}if(be(e)){const[n,s]=e;n.forEach(i=>{t=dr(t,Rt(i),()=>t)}),s&&Je(s,r)}else Je(e,r);return t}const fo=(t,e)=>Et(t)||be(t)||Ot(t)||Pt(t)||En(t,e);function ho(t,e,r){const n=r.get(t);n?n.push(e):r.set(t,[e])}function yo(t,e){const r={};let n;return t.forEach(s=>{if(s.length<=1)return;e||(s=s.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[i,...u]=s;i.length===0?n=u.map(fr):r[fr(i)]=u.map(fr)}),n?lr(r)?[n]:[n,r]:lr(r)?void 0:r}const Tn=(t,e,r,n,s=[],i=[],u=new Map)=>{const l=eo(t);if(!l){ho(t,s,e);const p=u.get(t);if(p)return n?{transformedValue:null}:p}if(!fo(t,r)){const p=Rn(t,r),E=p?{transformedValue:p.value,annotations:[p.type]}:{transformedValue:t};return l||u.set(t,E),E}if(Nt(i,t))return{transformedValue:null};const c=Rn(t,r),h=(c==null?void 0:c.value)??t,f=be(h)?[]:{},d={};Je(h,(p,E)=>{if(E==="__proto__"||E==="constructor"||E==="prototype")throw new Error(`Detected property ${E}. This is a prototype pollution risk, please remove it from your object.`);const g=Tn(p,e,r,n,[...s,E],[...i,t],u);f[E]=g.transformedValue,be(g.annotations)?d[E]=g.annotations:Et(g.annotations)&&Je(g.annotations,(O,C)=>{d[gn(E)+"."+C]=O})});const y=lr(d)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,d]:d};return l||u.set(t,y),y};function An(t){return Object.prototype.toString.call(t).slice(8,-1)}function Fn(t){return An(t)==="Array"}function po(t){if(An(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return!!e&&e.constructor===Object&&e===Object.prototype}function mo(t,e,r,n,s){const i={}.propertyIsEnumerable.call(n,e)?"enumerable":"nonenumerable";i==="enumerable"&&(t[e]=r),s&&i==="nonenumerable"&&Object.defineProperty(t,e,{value:r,enumerable:!1,writable:!0,configurable:!0})}function yr(t,e={}){if(Fn(t))return t.map(s=>yr(s,e));if(!po(t))return t;const r=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return[...r,...n].reduce((s,i)=>{if(Fn(e.props)&&!e.props.includes(i))return s;const u=t[i],l=yr(u,e);return mo(s,i,l,t,e.nonenumerable),s},{})}class F{constructor({dedupe:e=!1}={}){this.classRegistry=new $i,this.symbolRegistry=new dn(r=>r.description??""),this.customTransformerRegistry=new Vi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const r=new Map,n=Tn(e,r,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const i=yo(r,this.dedupe);return i&&(s.meta={...s.meta,referentialEqualities:i}),s}deserialize(e){const{json:r,meta:n}=e;let s=yr(r);return n!=null&&n.values&&(s=co(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=lo(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,r){this.classRegistry.register(e,r)}registerSymbol(e,r){this.symbolRegistry.register(e,r)}registerCustom(e,r){this.customTransformerRegistry.register({name:r,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}}F.defaultInstance=new F,F.serialize=F.defaultInstance.serialize.bind(F.defaultInstance),F.deserialize=F.defaultInstance.deserialize.bind(F.defaultInstance),F.stringify=F.defaultInstance.stringify.bind(F.defaultInstance),F.parse=F.defaultInstance.parse.bind(F.defaultInstance),F.registerClass=F.defaultInstance.registerClass.bind(F.defaultInstance),F.registerSymbol=F.defaultInstance.registerSymbol.bind(F.defaultInstance),F.registerCustom=F.defaultInstance.registerCustom.bind(F.defaultInstance),F.allowErrorProps=F.defaultInstance.allowErrorProps.bind(F.defaultInstance),F.serialize,F.deserialize,F.stringify,F.parse,F.registerClass,F.registerCustom,F.registerSymbol,F.allowErrorProps;const xn=_.createContext(null);function go(t,e){const r=bi({links:[ji({enabled:s=>process.env.NODE_ENV==="development"&&typeof window<"u"||s.direction==="down"&&s.result instanceof Error}),Di({url:`${t}/trpc`,headers:()=>({Authorization:`Bearer ${e}`}),transformer:F})]}),n=async(s,i,u=null)=>{const l=Object.entries(kr).reduce((y,[p,E])=>(E.extensions.forEach(g=>{y.set(g,p)}),y),new Map),c=i.map(y=>{const p=y.name.toLowerCase(),E=p.includes(".")?p.substring(p.lastIndexOf(".")):"",g=E.startsWith(".")?E:`.${E}`,O=l.get(g)||null;return{...y,mimeType:O}}).filter(y=>y.mimeType!==null&&Os.has(y.mimeType));if(c.length===0)return{filesToCreate:[]};const h=await r.fileRouter.getFilesByProject.query({projectId:s}),f=c.filter(y=>u===null?!h.some(p=>p.path===y.blobUrl):!h.some(p=>p.path===y.blobUrl&&p.parentId===u));return f.length===0?{filesToCreate:[]}:{filesToCreate:f.map(y=>({projectId:s,mimeType:y.mimeType,path:y.blobUrl,name:y.name,size:0,metadata:null,isArtifact:!1,summary:null,chunkingStatus:Wt.NOT_CHUNKED,isDirectory:!1,parentId:u}))}};return{getProjectsForUser:async()=>{const s=await r.projectRouter.getAllProjects.query();if(s.length===0){const i=await r.projectRouter.createProject.mutate({name:"Default Project"});return[{name:i.name,id:i.id,updatedAt:i.updatedAt,createdAt:i.createdAt}]}return s.map(i=>({name:i.name,id:i.id,updatedAt:i.updatedAt,createdAt:i.createdAt}))},addProjectForUser:async s=>{const i=await r.projectRouter.createProject.mutate({name:s});return{name:i.name,id:i.id,updatedAt:i.updatedAt,createdAt:i.createdAt}},addFilesToProject:async(s,i)=>{const{filesToCreate:u}=await n(s,i);return u.length===0?[]:(await r.fileRouter.createFiles.mutate({files:u})).map(c=>({blobUrl:c.path,name:c.name,id:c.id,parentId:c.parentId,isDirectory:c.isDirectory,createdAt:c.createdAt,updatedAt:c.updatedAt}))},getFilesForProject:async s=>(await r.fileRouter.getFilesByProject.query({projectId:s})).map(u=>({blobUrl:u.path,name:u.name,id:u.id,parentId:u.parentId,isDirectory:u.isDirectory,createdAt:u.createdAt,updatedAt:u.updatedAt})),addDirectoryWithFilesToProject:async(s,i,u,l)=>{if((await r.fileRouter.getFilesByProject.query({projectId:s})).some(p=>p.name===i&&p.isDirectory===!0&&p.parentId===null))return console.warn(`A directory named "${i}" already exists at the root level. Skipping creation.`),{directory:null,files:[]};const f=await r.fileRouter.createFile.mutate({file:{projectId:s,mimeType:Bt.DIRECTORY,path:"",name:i,size:0,metadata:u,isArtifact:!1,isDirectory:!0,parentId:null,summary:null,chunkingStatus:Wt.NOT_CHUNKED}});if(l.length===0)return{directory:{blobUrl:f.path,name:f.name,id:f.id,parentId:f.parentId,isDirectory:f.isDirectory,createdAt:f.createdAt,updatedAt:f.updatedAt},files:[]};const{filesToCreate:d}=await n(s,l,f.id);if(d.length===0)return{directory:{blobUrl:f.path,name:f.name,id:f.id,parentId:f.parentId,isDirectory:f.isDirectory,createdAt:f.createdAt,updatedAt:f.updatedAt},files:[]};const y=await r.fileRouter.createFiles.mutate({files:d});return{directory:f?{blobUrl:f.path,name:f.name,id:f.id,parentId:f.parentId,isDirectory:f.isDirectory,createdAt:f.createdAt,updatedAt:f.updatedAt}:null,files:y.map(p=>({blobUrl:p.path,name:p.name,id:p.id,parentId:p.parentId,isDirectory:p.isDirectory,createdAt:p.createdAt,updatedAt:p.updatedAt}))}},updateUserMetadata:async s=>{await r.userRouter.updateUserMetadata.mutate({metadata:s})},getUserMetadata:async()=>await r.userRouter.getUserMetadata.query()}}function bo({children:t,host:e="http://localhost",port:r=5174,token:n,userMetadata:s,onAnalyticsEvent:i,passTokenInQueryParam:u=!1}){const[l,c]=_.useState(null),h=_.useMemo(()=>new Ms({defaultOptions:{queries:{staleTime:30*1e3,refetchOnWindowFocus:!1}}}),[]);return _.useEffect(()=>{const f=`${e}:${r}`,d=go(f,n);c(d)},[e,r,n]),_.useEffect(()=>{if(!l||!s)return;const f=JSON.stringify(s);l.updateUserMetadata(f).catch(d=>{console.error("Failed to update user metadata:",d)})},[l,s]),_.useEffect(()=>{if(!i)return;const f=y=>{i(y.detail)},d=y=>{var p;((p=y.data)==null?void 0:p.type)==="folio-analytics"&&y.data.event&&i(y.data.event)};return window.addEventListener("folio-analytics",f),window.addEventListener("message",d),()=>{window.removeEventListener("folio-analytics",f),window.removeEventListener("message",d)}},[i]),gt.jsx($s,{client:h,children:gt.jsx(xn.Provider,{value:{host:e,port:r,client:l,token:n,passTokenInQueryParam:u},children:t})})}function je(){const t=_.useContext(xn);if(!t)throw new Error("useFolioContext must be used within a FolioProvider");return t}const Dn="folio-token",{useEffect:_n,useRef:vo,useState:wo}=U;function Eo({width:t="100%",height:e="100vh",allow:r="camera; microphone; clipboard-read; clipboard-write; fullscreen",style:n,className:s="",iframeProps:i={},passTokenInQueryParam:u}){const{host:l,port:c,token:h,passTokenInQueryParam:f}=je(),d=vo(null),[y,p]=wo(),E=`${l}:${c}`,g=u!==void 0?u:f;_n(()=>{(()=>{let R=E;g&&(R=`${E}?jwt=${encodeURIComponent(h)}`),p(R)})()},[l,c,h,E,g]),_n(()=>{if(g||!d.current)return;const C=R=>{var j;if(((j=R.data)==null?void 0:j.type)==="folio-request-token"&&!(!R.source||typeof R.source.postMessage!="function"))try{R.source.postMessage({type:Dn,token:h},"*")}catch{}};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[h,g]);const O=()=>{var C;if(!(g||!((C=d.current)!=null&&C.contentWindow)))try{d.current.contentWindow.postMessage({type:Dn,token:h},"*")}catch{}};return y?gt.jsx("div",{className:`folio-embed-container ${s}`,style:{width:t,height:e,overflow:"hidden",...n},children:gt.jsx("iframe",{ref:d,src:y,width:"100%",height:"100%",style:{border:"none",width:"100%",height:"100%",overflow:"auto"},allow:r,allowFullScreen:!0,onLoad:O,...i})}):null}function Oo(){const{client:t}=je(),e=or({queryKey:["folioProjects"],queryFn:async()=>{if(!t)throw new Error("Folio client not initialized");return t.getProjectsForUser()},enabled:!!t});return{projects:e.data||[],isLoading:e.isLoading,isError:e.isError,error:e.error,refetch:e.refetch}}function Po(){const{client:t}=je(),e=Ge(),r=or({queryKey:["folioUserMetadata"],queryFn:async()=>{if(!t)throw new Error("Folio client not initialized");return t.getUserMetadata()},enabled:!!t}),n=qt({mutationFn:async s=>{if(!t)throw new Error("Folio client not initialized");const i=JSON.stringify(s);return t.updateUserMetadata(i)},onSuccess:()=>{e.invalidateQueries({queryKey:["folioUserMetadata"]})}});return{metadata:r.data,isLoading:r.isLoading,isError:r.isError,error:r.error,updateMetadata:n.mutate,updateMetadataAsync:n.mutateAsync,isUpdating:n.isPending,refetch:r.refetch}}function Ro(t){const{client:e}=je(),r=or({queryKey:["folioFiles",t],queryFn:async()=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.getFilesForProject(t)},enabled:!!e&&!!t});return{files:r.data||[],isLoading:r.isLoading,isError:r.isError,error:r.error,refetch:r.refetch}}function So(){const{client:t}=je(),e=Ge(),r=qt({mutationFn:async n=>{if(!t)throw new Error("Folio client not initialized");return t.addProjectForUser(n)},onSuccess:()=>{e.invalidateQueries({queryKey:["folioProjects"]})}});return{addProject:r.mutate,addProjectAsync:r.mutateAsync,isAdding:r.isPending,isError:r.isError,error:r.error,newProject:r.data}}function Co(t){const{client:e}=je(),r=Ge(),n=qt({mutationFn:async s=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.addFilesToProject(t,s)},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addFiles:n.mutate,addFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,newFiles:n.data}}function To(t){const{client:e}=je(),r=Ge(),n=qt({mutationFn:async s=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");const i=Array.isArray(s)?s:[s],u=[];for(const l of i){const c=JSON.stringify(l.directoryMetadata),h=await e.addDirectoryWithFilesToProject(t,l.directoryName,c,l.files);u.push(h)}return Array.isArray(s)?u:u[0]},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addDirectoriesWithFiles:n.mutate,addDirectoriesWithFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,result:n.data}}A.FolioEmbed=Eo,A.FolioProvider=bo,A.useAddFolioDirectoriesWithFiles=To,A.useAddFolioFiles=Co,A.useAddFolioProject=So,A.useFolioFiles=Ro,A.useFolioProjects=Oo,A.useFolioUserMetadata=Po,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
@@ -169,7 +169,7 @@ export declare interface FolioProviderProps {
169
169
  /**
170
170
  * Type definition for metadata values that can be nested
171
171
  */
172
- declare type MetadataValue = string | number | boolean | null | {
172
+ export declare type MetadataValue = string | number | boolean | null | {
173
173
  [key: string]: MetadataValue;
174
174
  } | MetadataValue[];
175
175
 
@@ -279,6 +279,21 @@ export declare function useFolioProjects(): {
279
279
  refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<FolioProject[], Error>>;
280
280
  };
281
281
 
282
+ /**
283
+ * Hook for retrieving and updating the current user's metadata
284
+ * @returns User metadata with loading and error states
285
+ */
286
+ export declare function useFolioUserMetadata(): {
287
+ metadata: string | null | undefined;
288
+ isLoading: boolean;
289
+ isError: boolean;
290
+ error: Error | null;
291
+ updateMetadata: UseMutateFunction<void, Error, Record<string, MetadataValue_2>, unknown>;
292
+ updateMetadataAsync: UseMutateAsyncFunction<void, Error, Record<string, MetadataValue_2>, unknown>;
293
+ isUpdating: boolean;
294
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<string | null, Error>>;
295
+ };
296
+
282
297
  export { }
283
298
 
284
299
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shiftengineering/folio",
3
3
  "private": false,
4
- "version": "0.1.19",
4
+ "version": "0.1.21",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ShiftEngineering/folio.git"