import{r as e}from"./chunk-DECur_0Z.js";import{t}from"./react-CO2uhaBc.js";import{$d as n,Bd as r,Cf as i,Df as a,Ef as o,Fd as s,Gd as c,Hd as l,Id as u,Jd as d,Kd as f,Ld as p,Md as m,Nd as h,Pd as g,Qd as _,Rd as v,Sf as y,Tf as b,Ud as x,Vd as ee,Wd as S,Xd as C,Yd as w,Zd as te,_f as T,af as ne,bf as E,cf as re,df as D,ef as O,ff as k,gf as A,hf as ie,if as j,lf as ae,mf as oe,nf as se,of as ce,pf as le,qd as ue,rf as de,sf as fe,tf as pe,tm as me,uf as he,vf as ge,wf as _e,xf as ve,yf as ye,zd as be}from"./messages-BOatyqUm.js";import{t as xe}from"./with-selector-DBfssCrY.js";import{n as Se,r as Ce,t as we}from"./cookies-BzZOQYPw.js";import{n as Te}from"./dist-JOUh6qvR.js";var M=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ee=new class extends M{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},De={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},N=new class{#e=De;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Oe(e){setTimeout(e,0)}var ke=typeof window>`u`||`Deno`in globalThis;function P(){}function Ae(e,t){return typeof e==`function`?e(t):e}function je(e){return typeof e==`number`&&e>=0&&e!==1/0}function Me(e,t){return Math.max(e+(t||0)-Date.now(),0)}function F(e,t){return typeof e==`function`?e(t):e}function I(e,t){return typeof e==`function`?e(t):e}function Ne(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Fe(o,t.options))return!1}else if(!Ie(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Pe(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(L(t.options.mutationKey)!==L(a))return!1}else if(!Ie(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Fe(e,t){return(t?.queryKeyHashFn||L)(e)}function L(e){return JSON.stringify(e,(e,t)=>Be(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Ie(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Ie(e[n],t[n])):!1}var Le=Object.prototype.hasOwnProperty;function Re(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ze(e)&&ze(t);if(!r&&!(Be(e)&&Be(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l{N.setTimeout(t,e)})}function Ue(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Re(e,t)}function We(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ge(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ke=Symbol();function qe(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ke?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Je(e,t){return typeof e==`function`?e(...t):!!e}function Ye(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var z=(()=>{let e=()=>ke;return{isServer(){return e()},setIsServer(t){e=t}}})();function Xe(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Ze=Oe;function Qe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Ze,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var B=Qe(),$e=new class extends M{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function et(e){return Math.min(1e3*2**e,3e4)}function tt(e){return(e??`online`)===`online`?$e.isOnline():!0}var nt=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function rt(e){let t=!1,n=0,r,i=Xe(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new nt(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Ee.isFocused()&&(e.networkMode===`always`||$e.isOnline())&&e.canRun(),u=()=>tt(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(z.isServer()?0:3),o=e.retryDelay??et,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&nl()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var it=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),je(this.gcTime)&&(this.#e=N.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(z.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(N.clearTimeout(this.#e),this.#e=void 0)}},at=class extends it{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=ct(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=ct(this.options);e.data!==void 0&&(this.setState(st(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=Ue(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(P).catch(P):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>I(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ke||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>F(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Me(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=qe(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=rt({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof nt&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof nt){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...ot(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...st(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),B.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function ot(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:tt(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function st(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function ct(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var lt=class extends M{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Xe(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),dt(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ft(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ft(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof I(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!R(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&pt(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||F(this.options.staleTime,this.#t)!==F(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ht(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(P)),t}#g(){this.#b();let e=F(this.options.staleTime,this.#t);if(z.isServer()||this.#r.isStale||!je(e))return;let t=Me(this.#r.dataUpdatedAt,e)+1;this.#d=N.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(z.isServer()||I(this.options.enabled,this.#t)===!1||!je(this.#p)||this.#p===0)&&(this.#f=N.setInterval(()=>{(this.options.refetchIntervalInBackground||Ee.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(N.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(N.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&dt(e,t),o=i&&pt(e,n,t,r);(a||o)&&(l={...l,...ot(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Ue(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Ue(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:mt(e,t),refetch:this.refetch,promise:this.#o,isEnabled:I(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Xe())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!R(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){B.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ut(e,t){return I(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function dt(e,t){return ut(e,t)||e.state.data!==void 0&&ft(e,t,t.refetchOnMount)}function ft(e,t,n){if(I(t.enabled,e)!==!1&&F(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&mt(e,t)}return!1}function pt(e,t,n,r){return(e!==t||I(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&mt(e,n)}function mt(e,t){return I(t.enabled,e)!==!1&&e.isStaleByTime(F(t.staleTime,e))}function ht(e,t){return!R(e.getCurrentResult(),t)}function gt(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Ye(e,()=>t.signal,()=>n=!0)},u=qe(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?Ge:We;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?vt:_t,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:_t(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(ct.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function _t(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function vt(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function yt(e,t){return t?_t(e,t)!=null:!1}function bt(e,t){return!t||!e.getPreviousPageParam?!1:vt(e,t)!=null}var xt=class extends lt{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:gt()})}getOptimisticResult(e){return e.behavior=gt(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:yt(t,n.data),hasPreviousPage:bt(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},St=class extends it{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ct(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=rt({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,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{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),B.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ct(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var wt=class extends M{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),R(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&L(t.mutationKey)!==L(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ct();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){B.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},V=e(t(),1),Tt=me(),Et=V.createContext(void 0),Dt=e=>{let t=V.useContext(Et);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Ot=({client:e,children:t})=>(V.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Tt.jsx)(Et.Provider,{value:e,children:t})),kt=V.createContext(!1),At=()=>V.useContext(kt);kt.Provider;function jt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Mt=V.createContext(jt()),Nt=()=>V.useContext(Mt),Pt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Je(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ft=e=>{V.useEffect(()=>{e.clearReset()},[e])},It=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Je(n,[e.error,r])),Lt=(e,t)=>t.state.data===void 0,Rt=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},zt=(e,t)=>e.isLoading&&e.isFetching&&!t,Bt=(e,t)=>e?.suspense&&t.isPending,Vt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ht(e,t,n){let r=At(),i=Nt(),a=Dt(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Rt(o),Pt(o,i,s),Ft(i);let c=!a.getQueryCache().get(o.queryHash),[l]=V.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(V.useSyncExternalStore(V.useCallback(e=>{let t=d?l.subscribe(B.batchCalls(e)):P;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),V.useEffect(()=>{l.setOptions(o)},[o,l]),Bt(o,u))throw Vt(o,l,i);if(It({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!z.isServer()&&zt(u,r)&&(c?Vt(o,l,i):s?.promise)?.catch(P).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function Ut(e,t){return Ht(e,lt,t)}function Wt(e,t){return Ht({...e,enabled:!0,suspense:!0,throwOnError:Lt,placeholderData:void 0},lt,t)}function Gt(e,t){let n=Dt(t),[r]=V.useState(()=>new wt(n,e));V.useEffect(()=>{r.setOptions(e)},[r,e]);let i=V.useSyncExternalStore(V.useCallback(e=>r.subscribe(B.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=V.useCallback((e,t)=>{r.mutate(e,t).catch(P)},[r]);if(i.error&&Je(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Kt(e,t){return Ht(e,xt,t)}var qt=xe();function Jt(e,t){return e===t}function Yt(e,t,n=Jt){let r=(0,V.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,V.useCallback)(()=>e?.get(),[e]);return(0,qt.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var H=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function Xt({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&(H.RecursedCheck|H.Recursed|H.Dirty|H.Pending)?a&(H.RecursedCheck|H.Recursed)?a&H.RecursedCheck?!(a&(H.Dirty|H.Pending))&&c(e,i)?(i.flags=a|(H.Recursed|H.Pending),a&=H.Mutable):a=H.None:i.flags=a&~H.Recursed|H.Pending:a=H.None:i.flags=a|H.Pending,a&H.Watching&&t(i),a&H.Mutable){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&H.Dirty)a=!0;else if((c&(H.Mutable|H.Dirty))===(H.Mutable|H.Dirty)){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&(H.Mutable|H.Pending))===(H.Mutable|H.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=~H.Pending;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&(H.Pending|H.Dirty))===H.Pending&&(n.flags=r|H.Dirty,(r&(H.Watching|H.RecursedCheck))===H.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Zt(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var Qt=[],U=0,{link:$t,unlink:en,propagate:tn,checkDirty:nn,shallowPropagate:rn}=Xt({update(e){return e._update()},notify(e){Qt[an++]=e,e.flags&=~H.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=H.Mutable|H.Dirty,K(e))}}),W=0,an=0,G,on=0;function K(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=en(n,e)}function sn(){if(!(on>0)){for(;W{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=G,o=t?.compare??Object.is;if(n)G=i,++U,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=H.Mutable|H.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{G=a,n&&(i.flags&=~H.RecursedCheck),K(i)}}};return n?(i.flags=H.Mutable|H.Dirty,i.get=function(){let e=i.flags;if(e&H.Dirty||e&H.Pending&&nn(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&rn(e)}}else e&H.Pending&&(i.flags=e&~H.Pending);return G!==void 0&&$t(i,G,U),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(tn(e),rn(e),sn())}},i}function ln(e){let t=()=>{let t=G;G=n,++U,n.depsTail=void 0,n.flags=H.Watching|H.RecursedCheck;try{return e()}finally{G=t,n.flags&=~H.RecursedCheck,K(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:H.Watching|H.RecursedCheck,notify(){let e=this.flags;e&H.Dirty||e&H.Pending&&nn(this.deps,this)?t():this.flags=H.Watching},stop(){this.flags=H.None,this.depsTail=void 0,K(this)}};return t(),n}var un=class{constructor(e){this.atom=cn(e)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(Zt(e))}},q=`access_token`,dn=`auth_user`,fn=`sidebar_state`,pn=3600*24*7,mn=/\{[^{}]+\}/g,hn=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function gn(){return Math.random().toString(36).slice(2,11)}function _n(e){let{baseUrl:t=``,Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:a,pathSerializer:o,headers:s,requestInitExt:c=void 0,...l}={...e};c=hn()?c:void 0,t=Tn(t);let u=[];async function d(e,d){let{baseUrl:f,fetch:p=r,Request:m=n,headers:h,params:g={},parseAs:_=`json`,querySerializer:v,bodySerializer:y=a??Sn,pathSerializer:b,body:x,middleware:ee=[],...S}=d||{},C=t;f&&(C=Tn(f)??t);let w=typeof i==`function`?i:bn(i);v&&(w=typeof v==`function`?v:bn({...typeof i==`object`?i:{},...v}));let te=b||o||xn,T=x===void 0?void 0:y(x,wn(s,h,g.header)),ne=wn(T===void 0||T instanceof FormData?{}:{"Content-Type":`application/json`},s,h,g.header),E=[...u,...ee],re={redirect:`follow`,...l,...S,body:T,headers:ne},D,O,k=new m(Cn(e,{baseUrl:C,params:g,querySerializer:w,pathSerializer:te}),re),A;for(let e in S)e in k||(k[e]=S[e]);if(E.length){D=gn(),O=Object.freeze({baseUrl:C,fetch:p,parseAs:_,querySerializer:w,bodySerializer:y,pathSerializer:te});for(let t of E)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:k,schemaPath:e,params:g,options:O,id:D});if(n)if(n instanceof m)k=n;else if(n instanceof Response){A=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}if(!A){try{A=await p(k,c)}catch(t){let n=t;if(E.length)for(let t=E.length-1;t>=0;t--){let r=E[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:k,error:n,schemaPath:e,params:g,options:O,id:D});if(t){if(t instanceof Response){n=void 0,A=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(E.length)for(let t=E.length-1;t>=0;t--){let n=E[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:k,response:A,schemaPath:e,params:g,options:O,id:D});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);A=t}}}}let ie=A.headers.get(`Content-Length`);if(A.status===204||k.method===`HEAD`||ie===`0`&&!A.headers.get(`Transfer-Encoding`)?.includes(`chunked`))return A.ok?{data:void 0,response:A}:{error:void 0,response:A};if(A.ok)return{data:await(async()=>{if(_===`stream`)return A.body;if(_===`json`&&!ie){let e=await A.text();return e?JSON.parse(e):void 0}return await A[_]()})(),response:A};let j=await A.text();try{j=JSON.parse(j)}catch{}return{error:j,response:A}}return{request(e,t,n){return d(t,{...n,method:e.toUpperCase()})},GET(e,t){return d(e,{...t,method:`GET`})},PUT(e,t){return d(e,{...t,method:`PUT`})},POST(e,t){return d(e,{...t,method:`POST`})},DELETE(e,t){return d(e,{...t,method:`DELETE`})},OPTIONS(e,t){return d(e,{...t,method:`OPTIONS`})},HEAD(e,t){return d(e,{...t,method:`HEAD`})},PATCH(e,t){return d(e,{...t,method:`PATCH`})},TRACE(e,t){return d(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(t)}},eject(...e){for(let t of e){let e=u.indexOf(t);e!==-1&&u.splice(e,1)}}}}function J(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function vn(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(J(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function yn(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(J(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function bn(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(yn(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof i==`object`){n.push(vn(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(J(r,i,e))}}return n.join(`&`)}}function xn(e,t){let n=e;for(let r of e.match(mn)??[]){let e=r.substring(1,r.length-1),i=!1,a=`simple`;if(e.endsWith(`*`)&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!t||t[e]===void 0||t[e]===null)continue;let o=t[e];if(Array.isArray(o)){n=n.replace(r,yn(e,o,{style:a,explode:i}));continue}if(typeof o==`object`){n=n.replace(r,vn(e,o,{style:a,explode:i}));continue}if(a===`matrix`){n=n.replace(r,`;${J(e,o)}`);continue}n=n.replace(r,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return n}function Sn(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function Cn(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function wn(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function Tn(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}function En(e){let t=async({queryKey:[t,n,r],signal:i})=>{let a=e[t.toUpperCase()],{data:o,error:s,response:c}=await a(n,{signal:i,...r});if(s)throw s;return c.status===204||c.headers.get(`Content-Length`)===`0`?o??null:o},n=(e,n,...[r,i])=>({queryKey:r===void 0?[e,n]:[e,n,r],queryFn:t,...i});return{queryOptions:n,useQuery:(e,t,...[r,i,a])=>Ut(n(e,t,r,i),a),useSuspenseQuery:(e,t,...[r,i,a])=>Wt(n(e,t,r,i),a),useInfiniteQuery:(t,r,i,a,o)=>{let{pageParamName:s=`cursor`,...c}=a,{queryKey:l}=n(t,r,i);return Kt({queryKey:l,queryFn:async({queryKey:[t,n,r],pageParam:i=0,signal:a})=>{let o=e[t.toUpperCase()],{data:c,error:l}=await o(n,{...r,signal:a,params:{...r?.params||{},query:{...r?.params?.query,[s]:i}}});if(l)throw l;return c},...c},o)},useMutation:(t,n,r,i)=>Gt({mutationKey:[t,n],mutationFn:async r=>{let i=e[t.toUpperCase()],{data:a,error:o}=await i(n,r);if(o)throw o;return a},...r},i)}}var Dn={0:h,400:a,401:o,500:m,10001:b,10002:_e,10003:i,10004:y,10005:ve,10006:E,10007:ye,10008:ge,10009:T,10010:A,10011:ie,10012:oe,10013:le,10014:k,10015:D,10016:he,10017:ae,10018:re,10019:fe,10020:ce,10021:ne,10022:j,10023:de,10024:se,10025:pe,10026:O,10027:n,10028:_,10029:te,10030:C,10031:w,10032:d,10033:ue,10034:f,10035:c,10036:S,10037:x,10038:l,10039:ee,10040:r,10041:be,10042:v,10043:p,10044:u,10045:s,10046:g};function Y(e){return Dn[e]?.()??Dn[0]()}var On={onRequest({request:e}){let t=we(q);if(t)try{let n=JSON.parse(t);n&&e.headers.set(`Authorization`,`Bearer ${n}`)}catch{}return e},async onResponse({response:e}){if(e.status===401){Rn();let t=encodeURIComponent(window.location.pathname+window.location.search);return window.location.replace(`/sign-in?redirect=${t}`),e}if(e.status===400)try{let t=await e.clone().json(),n=t.status_code&&Y(t.status_code)||t.message||Y(0);Te.error(n)}catch{Te.error(Y(0))}return e.status>=500&&Te.error(Y(500)),e}},X=_n({baseUrl:`/`});X.use(On);var kn=En(X);function An(e,t){try{return JSON.parse(e)}catch{return t}}function jn(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Mn(e){return jn()?.getItem(e)??void 0}function Nn(e,t){jn()?.setItem(e,t)}function Pn(e){jn()?.removeItem(e)}var Z={getToken:()=>An(we(`access_token`)||``,``),getUser:()=>An(Mn(`auth_user`)||``,null),setToken:e=>e?Ce(q,JSON.stringify(e)):Se(q),setUser:e=>e?Nn(dn,JSON.stringify(e)):Pn(dn),clear:()=>{Se(q),Pn(dn)}},Fn=Z.getToken(),Q=new un({accessToken:Fn,user:Fn?Z.getUser():null}),$=null;function In(e){Z.setUser(e),Q.setState(t=>({...t,user:e}))}function Ln(e){let t=Q.state.accessToken;Z.setToken(e);let n=t!==e;n&&(Z.setUser(null),$=null),Q.setState(t=>({...t,accessToken:e,user:n?null:t.user})),e&&zn()}function Rn(){Z.clear(),$=null,Q.setState(()=>({accessToken:``,user:null}))}function zn(){let{user:e,accessToken:t}=Q.state;return e?Promise.resolve(e):t?$||($=X.GET(`/admin/api/v1/auth/me`).then(({data:e})=>{let t=e?.data??null;return t&&In(t),t}).catch(()=>(Rn(),null)).finally(()=>{$=null}),$):Promise.resolve(null)}function Bn(){return Yt(Q,e=>e)}export{M as A,Pe as C,F as D,Ie as E,Ke as O,Fe as S,P as T,at as _,kn as a,Ae as b,q as c,un as d,Yt as f,gt as g,St as h,Bn as i,Ee as k,pn as l,Ot as m,Rn as n,Y as o,Ut as p,Ln as r,X as s,Q as t,fn as u,$e as v,Ne as w,L as x,B as y};