@qratilabs/qrati-connect 2.23.0-beta.11 → 2.23.0-beta.12

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.
Files changed (55) hide show
  1. package/element/{CGiGAVqL.js → 4tMgCiYw.js} +3 -3
  2. package/element/{C4370mP22.js → 6hoD5_Vl2.js} +1 -1
  3. package/element/{nAMI7pCS2.js → B70v8cGQ2.js} +1 -1
  4. package/element/{C08PJA0j2.js → B9-WkJUt2.js} +1 -1
  5. package/element/{Dscm4xyu.js → BE-haWnd.js} +1 -1
  6. package/element/{C-E67-yG.js → BFvmiMbV.js} +2 -2
  7. package/element/{DtRVUwJ92.js → BGSX-HAY2.js} +10 -10
  8. package/element/{MRMgnSUK2.js → BSHuoVMu2.js} +8 -8
  9. package/element/{CreKudlo.js → BWFsg0bG.js} +1 -1
  10. package/element/{B7MADUG82.js → Bd-4kf1_2.js} +50 -50
  11. package/element/{Cwd5KWes.js → BezKyBw8.js} +1 -1
  12. package/element/{C_RRTK0-2.js → BkPCorGR2.js} +4 -4
  13. package/element/BsD01BsS2.js +3 -0
  14. package/element/{BkvtmX4K.js → BsYbcfkG.js} +1 -1
  15. package/element/{CjEOOwEO.js → BtZjRMK0.js} +1 -1
  16. package/element/{t0ZObetV.js → BxAGmFjz.js} +1 -1
  17. package/element/{BtjAZJ-32.js → C1HCUyOY2.js} +1 -1
  18. package/element/{BI-Mhsz-2.js → C7hsHpwE2.js} +1 -1
  19. package/element/{DIYUC8M3.js → CAETItHr.js} +1 -1
  20. package/element/{D0vGK2Zn2.js → CDFn498b2.js} +3 -3
  21. package/element/{Byk0pccK.js → CFnGGYmq.js} +1 -1
  22. package/element/{B9stbVC1.js → CI6iTXM5.js} +5 -5
  23. package/element/{qWx6O8vp2.js → CWRQEdBR2.js} +9 -9
  24. package/element/{r78o73pY.js → CWmhhcUq.js} +2 -2
  25. package/element/{B14kCOq8.js → CZ9iaxjO.js} +1 -1
  26. package/element/{CVMDCRWz2.js → CZqlO3zh2.js} +1 -1
  27. package/element/{CDaUEYt62.js → CoT7nGQp2.js} +2 -2
  28. package/element/{jxn6d20U.js → CqKs7cYK.js} +1 -1
  29. package/element/{YCFE6Xtd.js → CtbuoQ7J.js} +1 -1
  30. package/element/{CaHiQix32.js → D1PqO8Bd2.js} +1 -1
  31. package/element/{_ty2jtjs.js → D35mTuTT.js} +1 -1
  32. package/element/{zJ8qjhhA2.js → D5TKEdBd2.js} +1 -1
  33. package/element/{Cz97-05w.js → DG8EMwNQ.js} +1 -1
  34. package/element/{DvTRhlvs.js → DGGc10Cy.js} +1 -1
  35. package/element/{Dm37OGNw.js → DIQ9mtoC.js} +1 -1
  36. package/element/{CMvk3x_Q.js → DX3xkbbX.js} +1 -1
  37. package/element/{BGXWCZ2-.js → Da2eagiO.js} +1 -1
  38. package/element/{CwmhT3N32.js → Dik2a7Gm2.js} +1 -1
  39. package/element/{gk4TX_a62.js → DlRUi0u42.js} +1 -1
  40. package/element/{DElj3bqm.js → Dog5Nkhv.js} +1 -1
  41. package/element/{CZA9tJZU2.js → DrlwFVJe2.js} +1 -1
  42. package/element/DrrpB4Om.js +1 -0
  43. package/element/{BVdi0hGz.js → DxS0MPY6.js} +1 -1
  44. package/element/{DNG5BSHx2.js → N4HKgEC52.js} +1 -1
  45. package/element/Rcen6i0h.js +80 -0
  46. package/element/{C_8sJC3q.js → U2g1x1CI.js} +3 -3
  47. package/element/{C77vfObS.js → WW2XnkWC2.js} +1 -1
  48. package/element/{C4nDNsRk.js → Z1XNQctT.js} +1 -1
  49. package/element/{Btd0y9Xt2.js → ZvXeEmeW2.js} +1 -1
  50. package/element/sEG-IEXG2.js +35 -0
  51. package/element/web.es.js +26 -105
  52. package/package.json +1 -1
  53. package/element/0P3j0_yy2.js +0 -3
  54. package/element/BJCkWokM2.js +0 -37
  55. package/element/C3uDEVBt.js +0 -1
@@ -1,4 +1,4 @@
1
- import{E as e,b as t,h as r,p as s,r as o,s as n,t as i,v as a,y as c}from"./C3uDEVBt.js";var u={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},l=new class{#e=u;#t=!1;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)}},h="undefined"==typeof window||"Deno"in globalThis;function d(){}function f(e,t){return"function"==typeof e?e(t):e}function p(e){return"number"==typeof e&&e>=0&&e!==1/0}function m(e,t){return Math.max(e+(t||0)-Date.now(),0)}function y(e,t){return"function"==typeof e?e(t):e}function g(e,t){return"function"==typeof e?e(t):e}function w(e,t){const{type:r="all",exact:s,fetchStatus:o,predicate:n,queryKey:i,stale:a}=e;if(i)if(s){if(t.queryHash!==v(i,t.options))return!1}else if(!E(t.queryKey,i))return!1;if("all"!==r){const e=t.isActive();if("active"===r&&!e)return!1;if("inactive"===r&&e)return!1}return!("boolean"==typeof a&&t.isStale()!==a||o&&o!==t.state.fetchStatus||n&&!n(t))}function b(e,t){const{exact:r,status:s,predicate:o,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(r){if(R(t.options.mutationKey)!==R(n))return!1}else if(!E(t.options.mutationKey,n))return!1}return!(s&&t.state.status!==s||o&&!o(t))}function v(e,t){return(t?.queryKeyHashFn||R)(e)}function R(e){return JSON.stringify(e,(e,t)=>I(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function E(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(r=>E(e[r],t[r]))}var T=Object.prototype.hasOwnProperty;function S(e,t,r=0){if(e===t)return e;if(r>500)return t;const s=A(e)&&A(t);if(!(s||I(e)&&I(t)))return t;const o=(s?e:Object.keys(e)).length,n=s?t:Object.keys(t),i=n.length,a=s?new Array(i):{};let c=0;for(let u=0;u<i;u++){const i=s?u:n[u],l=e[i],h=t[i];if(l===h){a[i]=l,(s?u<o:T.call(e,i))&&c++;continue}if(null===l||null===h||"object"!=typeof l||"object"!=typeof h){a[i]=h;continue}const d=S(l,h,r+1);a[i]=d,d===l&&c++}return o===i&&c===o?e:a}function O(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function A(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function I(e){if(!C(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!C(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function C(e){return"[object Object]"===Object.prototype.toString.call(e)}function P(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?S(e,t):t}function D(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function N(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var q=/* @__PURE__ */Symbol();function _(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==q?e.queryFn:()=>Promise.reject(/* @__PURE__ */new Error(`Missing queryFn: '${e.queryHash}'`))}function L(e,t){return"function"==typeof e?e(...t):!!e}var x=/* @__PURE__ */(()=>{let e=()=>h;return{isServer:()=>e(),setIsServer(t){e=t}}})(),k=class{constructor(){this.listeners=/* @__PURE__ */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(){}},F=new class extends k{#r;#s;#o;constructor(){super(),this.#o=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#s||this.setEventListener(this.#o)}onUnsubscribe(){this.hasListeners()||(this.#s?.(),this.#s=void 0)}setEventListener(e){this.#o=e,this.#s?.(),this.#s=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#r!==e&&(this.#r=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#r?this.#r:"hidden"!==globalThis.document?.visibilityState}},U=function(e){setTimeout(e,0)},M=function(){let e=[],t=0,r=e=>{e()},s=e=>{e()},o=U;const n=s=>{t?e.push(s):o(()=>{r(s)})};return{batch:n=>{let i;t++;try{i=n()}finally{t--,t||(()=>{const t=e;e=[],t.length&&o(()=>{s(()=>{t.forEach(e=>{r(e)})})})})()}return i},batchCalls:e=>(...t)=>{n(()=>{e(...t)})},schedule:n,setNotifyFunction:e=>{r=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{o=e}}}(),$=new class extends k{#n=!0;#s;#o;constructor(){super(),this.#o=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#s||this.setEventListener(this.#o)}onUnsubscribe(){this.hasListeners()||(this.#s?.(),this.#s=void 0)}setEventListener(e){this.#o=e,this.#s?.(),this.#s=e(this.setOnline.bind(this))}setOnline(e){this.#n!==e&&(this.#n=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#n}};function j(){let e,t;const r=new Promise((r,s)=>{e=r,t=s});function s(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{s({status:"fulfilled",value:t}),e(t)},r.reject=e=>{s({status:"rejected",reason:e}),t(e)},r}function H(e){return Math.min(1e3*2**e,3e4)}function G(e){return"online"!==(e??"online")||$.isOnline()}var V=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Q(e){let t,r=!1,s=0;const o=j(),n=()=>"pending"!==o.status,i=()=>F.isFocused()&&("always"===e.networkMode||$.isOnline())&&e.canRun(),a=()=>G(e.networkMode)&&e.canRun(),c=e=>{n()||(t?.(),o.resolve(e))},u=e=>{n()||(t?.(),o.reject(e))},h=()=>new Promise(r=>{t=e=>{(n()||i())&&r(e)},e.onPause?.()}).then(()=>{t=void 0,n()||e.onContinue?.()}),d=()=>{if(n())return;let t;const o=0===s?e.initialPromise:void 0;try{t=o??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{if(n())return;const o=e.retry??(x.isServer()?0:3),a=e.retryDelay??H,c="function"==typeof a?a(s,t):a,f=!0===o||"number"==typeof o&&s<o||"function"==typeof o&&o(s,t);var p;!r&&f?(s++,e.onFail?.(s,t),(p=c,new Promise(e=>{l.setTimeout(e,p)})).then(()=>i()?void 0:h()).then(()=>{r?u(t):d()})):u(t)})};return{promise:o,status:()=>o.status,cancel:t=>{if(!n()){const r=new V(t);u(r),e.onCancel?.(r)}},continue:()=>(t?.(),o),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?d():h().then(d),o)}}var B=class{#i;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),p(this.gcTime)&&(this.#i=l.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(x.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#i&&(l.clearTimeout(this.#i),this.#i=void 0)}};function z(e){return{onFetch:(t,r)=>{const s=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,n=t.state.data?.pages||[],i=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let r=!1;const u=e=>{!function(e,r,s){let o,n=!1;Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??=t.signal,n||(n=!0,o.aborted?s():o.addEventListener("abort",s,{once:!0})),o)})}(e,0,()=>r=!0)},l=_(t.options,t.fetchOptions),h=async(e,s,o)=>{if(r)return Promise.reject(t.signal.reason);if(null==s&&e.pages.length)return Promise.resolve(e);const n=await l((()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:s,direction:o?"backward":"forward",meta:t.options.meta};return u(e),e})()),{maxPages:i}=t.options,a=o?N:D;return{pages:a(e.pages,n,i),pageParams:a(e.pageParams,s,i)}};if(o&&n.length){const e="backward"===o,t=e?Z:W,r={pages:n,pageParams:i};a=await h(r,t(s,r),e)}else{const t=e??n.length;do{const e=0===c?i[0]??s.initialPageParam:W(s,a);if(c>0&&null==e)break;a=await h(a,e),c++}while(c<t)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u}}}function W(e,{pages:t,pageParams:r}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,r[s],r):void 0}function Z(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}function K(e,t){return!!t&&null!=W(e,t)}function J(e,t){return!(!t||!e.getPreviousPageParam)&&null!=Z(e,t)}var Y=class extends B{#a;#c;#u;#l;#h;#d;#f;#p;constructor(e){super(),this.#p=!1,this.#f=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#h=e.client,this.#l=this.#h.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#c=te(this.options),this.state=e.state??this.#c,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#a}get promise(){return this.#d?.promise}setOptions(e){if(this.options={...this.#f,...e},e?._type&&(this.#a=e._type),this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=te(this.options);void 0!==e.data&&(this.setState(ee(e.data,e.dataUpdatedAt)),this.#c=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#l.remove(this)}setData(e,t){const r=P(this.state.data,e,this.options);return this.#m({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e){this.#m({type:"setState",state:e})}cancel(e){const t=this.#d?.promise;return this.#d?.cancel(e),t?t.then(d).catch(d):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#c}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>!1!==g(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===q||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===y(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!m(this.state.dataUpdatedAt,e))}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#d?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#d?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#l.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.#d&&(this.#p||this.#y()?this.#d.cancel({revert:!0}):this.#d.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#y(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#m({type:"invalidate"})}async fetch(e,t){if("idle"!==this.state.fetchStatus&&"rejected"!==this.#d?.status())if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#d)return this.#d.continueRetry(),this.#d.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const r=new AbortController,s=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,r.signal)})},o=()=>{const e=_(this.options,t),r=(()=>{const e={client:this.#h,queryKey:this.queryKey,meta:this.meta};return s(e),e})();return this.#p=!1,this.options.persister?this.options.persister(e,r,this):e(r)},n=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#h,state:this.state,fetchFn:o};return s(e),e})();("infinite"===this.#a?z(this.options.pages):this.options.behavior)?.onFetch(n,this),this.#u=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===n.fetchOptions?.meta||this.#m({type:"fetch",meta:n.fetchOptions?.meta}),this.#d=Q({initialPromise:t?.initialPromise,fn:n.fetchFn,onCancel:e=>{e instanceof V&&e.revert&&this.setState({...this.#u,fetchStatus:"idle"}),r.abort()},onFail:(e,t)=>{this.#m({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#m({type:"pause"})},onContinue:()=>{this.#m({type:"continue"})},retry:n.options.retry,retryDelay:n.options.retryDelay,networkMode:n.options.networkMode,canRun:()=>!0});try{const e=await this.#d.start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#l.config.onSuccess?.(e,this),this.#l.config.onSettled?.(e,this.state.error,this),e}catch(i){if(i instanceof V){if(i.silent)return this.#d.promise;if(i.revert){if(void 0===this.state.data)throw i;return this.state.data}}throw this.#m({type:"error",error:i}),this.#l.config.onError?.(i,this),this.#l.config.onSettled?.(this.state.data,i,this),i}finally{this.scheduleGc()}}#m(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,...X(t.data,this.options),fetchMeta:e.meta??null};case"success":const r={...t,...ee(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#u=e.manual?r:void 0,r;case"error":const s=e.error;return{...t,error:s,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),M.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:e})})}};function X(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:G(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function ee(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function te(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,s=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var re=class extends k{constructor(e,t){super(),this.options=t,this.#h=e,this.#g=null,this.#w=j(),this.bindMethods(),this.setOptions(t)}#h;#b=void 0;#v=void 0;#R=void 0;#E;#T;#w;#g;#S;#O;#A;#I;#C;#P;#D=/* @__PURE__ */new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#b.addObserver(this),se(this.#b,this.options)?this.#N():this.updateResult(),this.#q())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return oe(this.#b,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return oe(this.#b,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=/* @__PURE__ */new Set,this.#_(),this.#L(),this.#b.removeObserver(this)}setOptions(e){const t=this.options,r=this.#b;if(this.options=this.#h.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof g(this.options.enabled,this.#b))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#b.setOptions(this.options),t._defaulted&&!O(this.options,t)&&this.#h.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#b,observer:this});const s=this.hasListeners();s&&ne(this.#b,r,this.options,t)&&this.#N(),this.updateResult(),!s||this.#b===r&&g(this.options.enabled,this.#b)===g(t.enabled,this.#b)&&y(this.options.staleTime,this.#b)===y(t.staleTime,this.#b)||this.#k();const o=this.#F();!s||this.#b===r&&g(this.options.enabled,this.#b)===g(t.enabled,this.#b)&&o===this.#P||this.#U(o)}getOptimisticResult(e){const t=this.#h.getQueryCache().build(this.#h,e),r=this.createResult(t,e);var s;return s=r,O(this.getCurrentResult(),s)||(this.#R=r,this.#T=this.options,this.#E=this.#b.state),r}getCurrentResult(){return this.#R}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#w.status||this.#w.reject(/* @__PURE__ */new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#D.add(e)}getCurrentQuery(){return this.#b}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#h.defaultQueryOptions(e),r=this.#h.getQueryCache().build(this.#h,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#N({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#R))}#N(e){this.#x();let t=this.#b.fetch(this.options,e);return e?.throwOnError||(t=t.catch(d)),t}#k(){this.#_();const e=y(this.options.staleTime,this.#b);if(x.isServer()||this.#R.isStale||!p(e))return;const t=m(this.#R.dataUpdatedAt,e)+1;this.#I=l.setTimeout(()=>{this.#R.isStale||this.updateResult()},t)}#F(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#b):this.options.refetchInterval)??!1}#U(e){this.#L(),this.#P=e,!x.isServer()&&!1!==g(this.options.enabled,this.#b)&&p(this.#P)&&0!==this.#P&&(this.#C=l.setInterval(()=>{(this.options.refetchIntervalInBackground||F.isFocused())&&this.#N()},this.#P))}#q(){this.#k(),this.#U(this.#F())}#_(){void 0!==this.#I&&(l.clearTimeout(this.#I),this.#I=void 0)}#L(){void 0!==this.#C&&(l.clearInterval(this.#C),this.#C=void 0)}createResult(e,t){const r=this.#b,s=this.options,o=this.#R,n=this.#E,i=this.#T,a=e!==r?e.state:this.#v,{state:c}=e;let u,l={...c},h=!1;if(t._optimisticResults){const o=this.hasListeners(),n=!o&&se(e,t),i=o&&ne(e,r,t,s);(n||i)&&(l={...l,...X(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(l.fetchStatus="idle")}let{error:d,errorUpdatedAt:f,status:p}=l;u=l.data;let m=!1;if(void 0!==t.placeholderData&&void 0===u&&"pending"===p){let e;o?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(e=o.data,m=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#A?.state.data,this.#A):t.placeholderData,void 0!==e&&(p="success",u=P(o?.data,e,t),h=!0)}if(t.select&&void 0!==u&&!m)if(o&&u===n?.data&&t.select===this.#S)u=this.#O;else try{this.#S=t.select,u=t.select(u),u=P(o?.data,u,t),this.#O=u,this.#g=null}catch(T){this.#g=T}this.#g&&(d=this.#g,u=this.#O,f=Date.now(),p="error");const y="fetching"===l.fetchStatus,w="pending"===p,b="error"===p,v=w&&y,R=void 0!==u,E={status:p,fetchStatus:l.fetchStatus,isPending:w,isSuccess:"success"===p,isError:b,isInitialLoading:v,isLoading:v,data:u,dataUpdatedAt:l.dataUpdatedAt,error:d,errorUpdatedAt:f,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>a.dataUpdateCount||l.errorUpdateCount>a.errorUpdateCount,isFetching:y,isRefetching:y&&!w,isLoadingError:b&&!R,isPaused:"paused"===l.fetchStatus,isPlaceholderData:h,isRefetchError:b&&R,isStale:ie(e,t),refetch:this.refetch,promise:this.#w,isEnabled:!1!==g(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=void 0!==E.data,s="error"===E.status&&!t,o=e=>{s?e.reject(E.error):t&&e.resolve(E.data)},n=()=>{o(this.#w=E.promise=j())},i=this.#w;switch(i.status){case"pending":e.queryHash===r.queryHash&&o(i);break;case"fulfilled":(s||E.data!==i.value)&&n();break;case"rejected":s&&E.error===i.reason||n()}}return E}updateResult(){const e=this.#R,t=this.createResult(this.#b,this.options);this.#E=this.#b.state,this.#T=this.options,void 0!==this.#E.data&&(this.#A=this.#b),O(t,e)||(this.#R=t,this.#M({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#D.size)return!0;const s=new Set(r??this.#D);return this.options.throwOnError&&s.add("error"),Object.keys(this.#R).some(t=>{const r=t;return this.#R[r]!==e[r]&&s.has(r)})})()}))}#x(){const e=this.#h.getQueryCache().build(this.#h,this.options);if(e===this.#b)return;const t=this.#b;this.#b=e,this.#v=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#q()}#M(e){M.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#R)}),this.#h.getQueryCache().notify({query:this.#b,type:"observerResultsUpdated"})})}};function se(e,t){return function(e,t){return!1!==g(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===g(t.retryOnMount,e))}(e,t)||void 0!==e.state.data&&oe(e,t,t.refetchOnMount)}function oe(e,t,r){if(!1!==g(t.enabled,e)&&"static"!==y(t.staleTime,e)){const s="function"==typeof r?r(e):r;return"always"===s||!1!==s&&ie(e,t)}return!1}function ne(e,t,r,s){return(e!==t||!1===g(s.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&ie(e,r)}function ie(e,t){return!1!==g(t.enabled,e)&&e.isStaleByTime(y(t.staleTime,e))}var ae=e(void 0),ce=e=>{const t=c(ae);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ue=({client:e,children:r})=>(t(()=>(e.mount(),()=>{e.unmount()}),[e]),/* @__PURE__ */i(ae.Provider,{value:e,children:r})),le=e(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),he=e(!1),de=(he.Provider,(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()}));function fe(e,s,n){const i=c(he),u=c(le),l=ce(n),h=l.defaultQueryOptions(e);l.getDefaultOptions().queries?._experimental_beforeQuery?.(h);const f=l.getQueryCache().get(h.queryHash),p=!1!==e.subscribed;h._optimisticResults=i?"isRestoring":p?"optimistic":void 0,(e=>{if(e.suspense){const t=1e3,r=e=>"static"===e?e:Math.max(e??t,t),s=e.staleTime;e.staleTime="function"==typeof s?(...e)=>r(s(...e)):r(s),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(h),((e,t,r)=>{const s=r?.state.error&&"function"==typeof e.throwOnError?L(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))})(h,u,f),(e=>{t(()=>{e.clearReset()},[e])})(u);const m=!l.getQueryCache().get(h.queryHash),[y]=r(()=>new s(l,h)),g=y.getOptimisticResult(h),w=!i&&p;if(o(a(e=>{const t=w?y.subscribe(M.batchCalls(e)):d;return y.updateResult(),t},[y,w]),()=>y.getCurrentResult(),()=>y.getCurrentResult()),t(()=>{y.setOptions(h)},[h,y]),((e,t)=>e?.suspense&&t.isPending)(h,g))throw de(h,y,u);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(o&&void 0===e.data||L(r,[e.error,s])))({result:g,errorResetBoundary:u,throwOnError:h.throwOnError,query:f,suspense:h.suspense}))throw g.error;return l.getDefaultOptions().queries?._experimental_afterQuery?.(h,g),h.experimental_prefetchInRender&&!x.isServer()&&((e,t)=>e.isLoading&&e.isFetching&&!t)(g,i)&&(m?de(h,y,u):f?.promise)?.catch(d).finally(()=>{y.updateResult()}),h.notifyOnChangeProps?g:y.trackResult(g)}function pe(e,t){return fe(e,re,t)}var me=class extends Error{name="KyError";get isKyError(){return!0}},ye=class extends me{name="HTTPError";response;request;options;data;constructor(e,t,r){const s=`${e.status||0===e.status?e.status:""} ${e.statusText??""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${t.method} ${t.url}`),this.response=e,this.request=t,this.options=r}},ge=class extends me{name="NetworkError";request;constructor(e,t){super(`Request failed due to a network error: ${e.method} ${e.url}`,t),this.request=e}},we=class extends Error{name="NonError";value;constructor(e){let t="Non-error value was thrown";try{"string"==typeof e?t=e:e&&"object"==typeof e&&"message"in e&&"string"==typeof e.message&&(t=e.message)}catch{}super(t),this.value=e}},be=class extends me{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const t=e?.cause?e.cause instanceof Error?e.cause:new we(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},ve=class extends Error{name="SchemaValidationError";issues;constructor(e){super("Response schema validation failed"),this.issues=e}},Re=class extends me{name="TimeoutError";request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.request=e}},Ee=(()=>{let e=!1,t=!1;const r="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(r&&s)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(o){if(o instanceof Error&&"unsupported BodyInit type"===o.message)return!1;throw o}return e&&!t})(),Te="function"==typeof globalThis.AbortController,Se="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Oe="function"==typeof globalThis.ReadableStream,Ae="function"==typeof globalThis.FormData,Ie=["get","post","put","patch","head","delete"],Ce={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Pe=Symbol("stop"),De=class{options;constructor(e){this.options=e}},Ne=e=>new De(e),qe={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,baseUrl:!0,prefix:!0,retry:!0,timeout:!0,totalTimeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},_e={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Le=new TextEncoder,xe=(e,t,r)=>{let s,o=0;return e.pipeThrough(new TransformStream({transform(e,n){if(n.enqueue(e),s){o+=s.byteLength;let e=0===t?0:o/t;e>=1&&(e=1-Number.EPSILON),r?.({percent:e,totalBytes:Math.max(t,o),transferredBytes:o},s)}s=e},flush(){s&&(o+=s.byteLength,r?.({percent:1,totalBytes:Math.max(t,o),transferredBytes:o},s))}}))},ke=e=>null!==e&&"object"==typeof e,Fe=Symbol("replaceOption"),Ue=e=>ke(e)&&!0===e[Fe]?{isReplace:!0,value:e.value}:{isReplace:!1,value:e},Me=(...e)=>{for(const t of e)if((!ke(t)||Array.isArray(t))&&void 0!==t)throw new TypeError("The `options` argument must be an object");return We({},...e)},$e=(e={},t={})=>{const r=new globalThis.Headers(e),s=t instanceof globalThis.Headers,o=new globalThis.Headers(t);for(const[n,i]of o.entries())s&&"undefined"===i||void 0===i?r.delete(n):r.set(n,i);return r},je=e=>{if(!ke(e)||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t},He=e=>{if(e instanceof URLSearchParams){const t=new URLSearchParams(e),r=e[Be];return r&&(t[Be]=new Set(r)),t}return e instanceof globalThis.Headers?new globalThis.Headers(e):Array.isArray(e)?[...e]:je(e)?{...e}:e},Ge=(e,t)=>{return je(e)&&je(t)?(r={...e,...t},Object.fromEntries(Object.entries(r).filter(e=>void 0!==e[1]))):$e(e,t);var r};function Ve(e,t,r){return Object.hasOwn(t,r)&&void 0===t[r]?[]:We(e[r]??[],t[r]??[])}var Qe=(e={},t={})=>({init:Ve(e,t,"init"),beforeRequest:Ve(e,t,"beforeRequest"),beforeRetry:Ve(e,t,"beforeRetry"),beforeError:Ve(e,t,"beforeError"),afterResponse:Ve(e,t,"afterResponse")}),Be=Symbol("deletedParameters"),ze=(e,t)=>{const r=new URLSearchParams,s=/* @__PURE__ */new Set;for(const o of[e,t])if(void 0!==o)if(o instanceof URLSearchParams){for(const[t,n]of o.entries())r.append(t,n),s.delete(t);const e=o[Be];if(e)for(const t of e)r.delete(t),s.add(t)}else if(Array.isArray(o))for(const e of o){if(!Array.isArray(e)||2!==e.length)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(e[0]),String(e[1])),s.delete(String(e[0]))}else if(ke(o))for(const[e,t]of Object.entries(o))void 0===t?(r.delete(e),s.add(e)):(r.append(e,String(t)),s.delete(e));else{const e=new URLSearchParams(o);for(const[t,o]of e.entries())r.append(t,o),s.delete(t)}return s.size>0&&(r[Be]=s),r},We=(...e)=>{let t,r={},s={},o={};const n=[];for(const i of e)if(Array.isArray(i))Array.isArray(r)||(r=[]),r=[...r,...i];else if(ke(i)){for(let[e,s]of Object.entries(i)){if("signal"===e&&s instanceof globalThis.AbortSignal){n.push(s);continue}const o=Ue(s),{isReplace:i}=o;if(s=o.value,"context"!==e)"searchParams"!==e?(ke(s)&&!i&&e in r&&(s=We(r[e],s)),r={...r,[e]:s}):t=null==s?void 0:i||void 0===t?s:ze(t,s);else{if(null!=s&&(!ke(s)||Array.isArray(s)))throw new TypeError("The `context` option must be an object");r={...r,context:null==s?{}:i?{...s}:{...r.context,...s}}}}if(ke(i.hooks)){const{value:e,isReplace:t}=Ue(i.hooks);o=Qe(t?{}:o,e),r.hooks=o}if(ke(i.headers)){const{value:e,isReplace:t}=Ue(i.headers);s=t?He(e):Ge(s,e),r.headers=s}}return void 0!==t&&(r.searchParams=t),n.length>0&&(1===n.length?r.signal=n[0]:r.signal=Se?AbortSignal.any(n):n.at(-1)),r},Ze=e=>Ie.includes(e)?e.toUpperCase():e,Ke={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},Je=(e={})=>{if("number"==typeof e)return{...Ke,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");const t=Object.fromEntries(Object.entries({...e,methods:e.methods?.map(e=>e.toLowerCase())}).filter(([,e])=>void 0!==e));return{...Ke,...t}};async function Ye(e,{signal:t}){return new Promise((r,s)=>{function o(){clearTimeout(n),s(t.reason)}t&&(t.throwIfAborted(),t.addEventListener("abort",o,{once:!0}));const n=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e)})}var Xe=Object.prototype.toString,et=/* @__PURE__ */new Set(["network error","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);var tt=(e,t)=>e instanceof t||e?.name===t.name,rt=Symbol("timedOutResponseData"),st="The `schema` argument must follow the Standard Schema specification",ot=Object.prototype.toString,nt=e=>e instanceof globalThis.Request||"[object Request]"===ot.call(e),it=e=>e instanceof globalThis.Response||"[object Response]"===ot.call(e),at=async(e,t)=>{if("object"!=typeof t&&"function"!=typeof t||null===t)throw new TypeError(st);const r=t["~standard"];if("object"!=typeof r||null===r||"function"!=typeof r.validate)throw new TypeError(st);const s=await r.validate(e);if(s.issues)throw new ve(s.issues);return s.value},ct=class e{static create(t,r){const s=r.hooks?.init??[],o=s.length>0?function(e){const t={...e,json:He(e.json),context:He(e.context),headers:He(e.headers),searchParams:(r=e.searchParams,Array.isArray(r)?r.map(e=>[...e]):He(r))};var r;return void 0!==e.retry&&(t.retry=(e=>"object"!=typeof e?e:{...e,...e.methods&&{methods:[...e.methods]},...e.statusCodes&&{statusCodes:[...e.statusCodes]},...e.afterStatusCodes&&{afterStatusCodes:[...e.afterStatusCodes]}})(e.retry)),t}(r):r;for(const e of s)e(o);const n=new e(t,o),i=(async()=>{try{return await(async()=>{if("number"==typeof n.#$.timeout&&n.#$.timeout>2147483647)throw new RangeError("The `timeout` option cannot be greater than 2147483647");if("number"==typeof n.#$.totalTimeout&&n.#$.totalTimeout>2147483647)throw new RangeError("The `totalTimeout` option cannot be greater than 2147483647");await Promise.resolve();const e=await n.#j();let t=e??await n.#H(async()=>n.#G()),r=void 0!==e||n.#V();for(;;){if(void 0===t)return t;if(it(t))try{t=await n.#Q(t)}catch(s){if(!(s instanceof be))throw s;const e=await n.#B(s,async()=>n.#G());if(void 0===e)return e;t=e,r=n.#V();continue}const e=t;if(!e.ok&&"opaque"!==e.type&&("function"==typeof n.#$.throwHttpErrors?n.#$.throwHttpErrors(e.status):n.#$.throwHttpErrors)){const s=new ye(e,n.#z(e),n.#W()),o=s;if(s.data=await n.#Z(e),r)throw o;const i=await n.#B(s,async()=>n.#G());if(void 0===i)return i;t=i,r=n.#V();continue}break}if(!it(t))return t;if(n.#K(t),n.#$.onDownloadProgress){if("function"!=typeof n.#$.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Oe)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const e=t.clone();return n.#J(t),((e,t)=>{if(!e.body)return e;const r={status:e.status,statusText:e.statusText,headers:e.headers};if(204===e.status)return new Response(null,r);const s=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(xe(e.body,s,t),r)})(e,n.#$.onDownloadProgress)}return t})()}catch(e){if(!(e instanceof Error))throw e;if(n.#Y.has(e))throw e;let t=e;for(const r of n.#$.hooks.beforeError){const e=await r({request:n.request,options:n.#W(),error:t,retryCount:n.#X});e instanceof Error&&(t=e)}throw t}finally{const e=n.#ee;n.#te(e?.body??void 0),n.request!==e&&n.#te(n.request.body??void 0)}})();for(const[e,a]of Object.entries(Ce))"bytes"===e&&"function"!=typeof globalThis.Response?.prototype?.bytes||(i[e]=async t=>{n.request.headers.set("accept",n.request.headers.get("accept")||a);const r=await i;if("json"!==e)return r[e]();const s=await r.text();if(""===s)return void 0!==t?at(void 0,t):JSON.parse(s);const c=o.parseJson?await o.parseJson(s,{request:n.#z(r),response:r}):JSON.parse(s);return void 0===t?c:at(c,t)});return i}static#re(e){return!e||"object"!=typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}request;#se;#X=0;#oe;#$;#ee;#ne;#Y=/* @__PURE__ */new WeakSet;#ie;#ae;#ce=!1;#ue=/* @__PURE__ */new WeakMap;constructor(t,r={}){if(this.#oe=t,Object.hasOwn(r,"prefixUrl"))throw new Error("The `prefixUrl` option has been renamed `prefix` in v2 and enhanced to allow slashes in input. See also the new `baseUrl` option for improved flexibility with standard URL resolution: https://github.com/sindresorhus/ky#baseurl");if(this.#$={...r,headers:$e(this.#oe.headers,r.headers),hooks:Qe({},r.hooks),method:Ze(r.method??this.#oe.method??"GET"),prefix:String(r.prefix||""),retry:Je(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,totalTimeout:r.totalTimeout??!1,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},"string"!=typeof this.#oe&&!(this.#oe instanceof URL||this.#oe instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if("string"==typeof this.#oe){if(this.#$.prefix){const e=this.#$.prefix.replace(/\/+$/,""),t=this.#oe.replace(/^\/+/,"");this.#oe=`${e}/${t}`}if(this.#$.baseUrl){let e;try{e=new URL(this.#oe)}catch{}e||(this.#oe=new URL(this.#oe,new Request(this.#$.baseUrl).url))}}Te&&Se&&(this.#ne=this.#$.signal??this.#oe.signal,this.#se=new globalThis.AbortController,this.#$.signal=this.#le()),Ee&&(this.#$.duplex="half"),void 0!==this.#$.json&&(this.#$.body=this.#$.stringifyJson?.(this.#$.json)??JSON.stringify(this.#$.json),this.#$.headers.set("content-type",this.#$.headers.get("content-type")??"application/json"));const s=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#oe instanceof globalThis.Request&&(Ae&&this.#$.body instanceof globalThis.FormData||this.#$.body instanceof URLSearchParams)&&!s&&this.#$.headers.delete("content-type"),this.request=new globalThis.Request(this.#oe,this.#$),void 0!==(o=this.#$.searchParams)&&(Array.isArray(o)?o.length>0:o instanceof URLSearchParams?o.size>0||Boolean(o[Be]?.size):"object"==typeof o?Object.keys(o).length>0:"string"==typeof o?o.trim().length>0:Boolean(o))){const t=new URL(this.request.url),r=this.#$.searchParams?.[Be];if(r)for(const e of r)t.searchParams.delete(e);if("string"==typeof this.#$.searchParams){const e=this.#$.searchParams.replace(/^\?/,"");""!==e&&(t.search=t.search?`${t.search}&${e}`:`?${e}`)}else{const r=new URLSearchParams(e.#re(this.#$.searchParams));for(const[e,s]of r.entries())t.searchParams.append(e,s)}if(this.#$.searchParams&&"object"==typeof this.#$.searchParams&&!Array.isArray(this.#$.searchParams)&&!(this.#$.searchParams instanceof URLSearchParams))for(const[e,s]of Object.entries(this.#$.searchParams))void 0===s&&t.searchParams.delete(e);this.request=new globalThis.Request(t,this.#$)}var o;if(this.#$.onUploadProgress&&"function"!=typeof this.#$.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");this.#ae="number"==typeof this.#$.totalTimeout?this.#he():void 0}#de(){const e=this.#$.retry.delay(this.#X+1);let t=e;return!0===this.#$.retry.jitter?t=Math.random()*e:"function"==typeof this.#$.retry.jitter&&(t=this.#$.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e)),Math.min(this.#$.retry.backoffLimit,t)}async#fe(e){if(this.#X>=this.#$.retry.limit)throw e;const t=e instanceof Error?e:new we(e);if(t instanceof be)return t.customDelay??this.#de();if(!this.#$.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(void 0!==this.#$.retry.shouldRetry){const r=await this.#$.retry.shouldRetry({error:t,retryCount:this.#X+1});if(!1===r)throw e;if(!0===r)return this.#de()}if(function(e){return tt(e,Re)}(e)){if(!this.#$.retry.retryOnTimeout)throw e;return this.#de()}if(function(e){return tt(e,ye)}(e)){if(!this.#$.retry.statusCodes.includes(e.response.status))throw e;const t=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(t&&this.#$.retry.afterStatusCodes.includes(e.response.status)){let e=1e3*Number(t);return Number.isNaN(e)?e=Date.parse(t)-Date.now():e>=Date.parse("2024-01-01")&&(e-=Date.now()),Number.isFinite(e)?(e=Math.max(0,e),Math.min(this.#$.retry.maxRetryAfter,e)):Math.min(this.#$.retry.maxRetryAfter,this.#de())}if(413===e.response.status)throw e;return this.#de()}if(!function(e){return tt(e,ge)}(e))throw e;return this.#de()}#K(e){const t=this.#z(e);return this.#$.parseJson&&(e.json=async()=>{const r=await e.text();return""===r?JSON.parse(r):this.#$.parseJson(r,{request:t,response:e})}),e}async#Z(e){const t=await this.#pe(e,this.#me());if(t===rt)return void this.#ye();if(!t)return;if(!this.#ge(e.headers.get("content-type")??""))return t;const r=await this.#we(t,e,this.#me(),this.#z(e));if(r!==rt)return r;this.#ye()}#me(){const e=!1===this.#$.timeout?1e4:this.#$.timeout,t=this.#be();if(void 0===t)return e;if(t<=0)throw new Re(this.request);return Math.min(e,t)}#ge(e){const t=(e.split(";",1)[0]??"").trim().toLowerCase();return/\/(?:.*[.+-])?json$/.test(t)}async#pe(e,t){const{body:r}=e;if(!r)try{return await e.text()}catch{return}let s;try{s=r.getReader()}catch{return}const o=(e=>{const t=/;\s*charset\s*=\s*(?:"([^"]+)"|([^;,\s]+))/i.exec(e),r=t?.[1]??t?.[2];if(r)try{return new TextDecoder(r)}catch{}return new TextDecoder})(e.headers.get("content-type")??""),n=[];let i=0;const a=(async()=>{try{for(;;){const{done:e,value:t}=await s.read();if(e)break;if(i+=t.byteLength,i>10485760)return void s.cancel().catch(()=>{});n.push(o.decode(t,{stream:!0}))}}catch{return}return n.push(o.decode()),n.join("")})(),c=new Promise(e=>{const r=setTimeout(()=>{e(rt)},t);a.finally(()=>{clearTimeout(r)})}),u=await Promise.race([a,c]);return u===rt&&s.cancel().catch(()=>{}),u}async#we(e,t,r,s){let o;try{return await Promise.race([Promise.resolve().then(()=>this.#$.parseJson?this.#$.parseJson(e,{request:s,response:t}):JSON.parse(e)),new Promise(e=>{o=setTimeout(()=>{e(rt)},r)})])}catch{return}finally{clearTimeout(o)}}#te(e){e&&e.cancel().catch(()=>{})}#J(e){this.#te(e.body??void 0)}#le(){return this.#ne?AbortSignal.any([this.#ne,this.#se.signal]):this.#se.signal}#ye(){const e=this.#be();if(void 0!==e&&e<=0)throw new Re(this.request)}async#j(){for(const e of this.#$.hooks.beforeRequest){const t=await e({request:this.request,options:this.#W(),retryCount:0});if(nt(t))this.#ve(t);else if(it(t))return t}}async#Q(e){const t=this.#z(e);for(const s of this.#$.hooks.afterResponse){const o=this.#Re(e.clone(),t);let n;this.#K(o);try{n=await s({request:this.request,options:this.#W(),response:o,retryCount:this.#X})}catch(r){throw o!==e&&this.#J(o),this.#J(e),r}if(n instanceof De)throw o!==e&&this.#J(o),this.#J(e),new be(n.options);const i=it(n)?this.#Re(n,t):e;o!==e&&o!==i&&o.body!==i.body&&this.#J(o),e!==i&&e.body!==i.body&&this.#J(e),e=i}return e}async#H(e){try{return await e()}catch(t){return this.#B(t,e)}}async#B(e,t){this.#ce=!1;const r=Math.min(await this.#fe(e),2147483647),s={signal:this.#ne},o=this.#be();if(void 0!==o){if(o<=0)throw new Re(this.request);if(r>=o)throw await Ye(o,s),new Re(this.request)}if(await Ye(r,s),this.#ye(),e instanceof be&&e.customRequest){const t=new globalThis.Request(e.customRequest,this.#$.signal?{signal:this.#$.signal}:void 0);this.#ve(t)}for(const i of this.#$.hooks.beforeRetry){let t;try{t=await i({request:this.request,options:this.#W(),error:e,retryCount:this.#X+1})}catch(n){throw n instanceof Error&&n!==e&&this.#Y.add(n),n}if(nt(t)){this.#ve(t);break}if(it(t))return this.#ce=!0,this.#X++,t;if(t===Pe)return}return this.#ye(),this.#X++,this.#H(t)}#V(){const e=this.#ce;return this.#ce=!1,e}async#G(){this.#se?.signal.aborted&&(this.#se=new globalThis.AbortController,this.#$.signal=this.#le(),this.request=new globalThis.Request(this.request,{signal:this.#$.signal}));const e=(e=>{const t={};for(const r in e)Object.hasOwn(e,r)&&(r in _e||r in qe||(t[r]=e[r]));return t})(this.#$),t=this.#$.retry.limit>0?this.request.clone():void 0,r=this.#Ee(this.request,this.#$.body??void 0);this.#ee=r,t&&(this.request=t);try{const t=this.#be();if(void 0!==t&&t<=0)throw new Re(this.request);const s=!1===this.#$.timeout?t:void 0===t?this.#$.timeout:Math.min(this.#$.timeout,t),o=void 0===s?await this.#$.fetch(r,e):await async function(e,t,r,s){return new Promise((o,n)=>{const i=setTimeout(()=>{r&&r.abort(),n(new Re(e))},s.timeout);s.fetch(e,t).then(o).catch(n).then(()=>{clearTimeout(i)})})}(r,e,this.#se,{timeout:s,fetch:this.#$.fetch});return this.#Re(o,r)}catch(s){if(function(e){if(!e||(t=e,"[object Error]"!==Xe.call(t))||"TypeError"!==e.name||"string"!=typeof e.message)return!1;var t;const{message:r,stack:s}=e;return"Load failed"===r?void 0===s||"__sentry_captured__"in e:!!r.startsWith("error sending request for url")||!!("Failed to fetch"===r||r.startsWith("Failed to fetch (")&&r.endsWith(")"))||et.has(r)}(s))throw new ge(this.request,{cause:s});throw s}}#be(){if(void 0===this.#ae)return;const e=this.#he()-this.#ae;return Math.max(0,this.#$.totalTimeout-e)}#he(){return globalThis.performance?.now()??Date.now()}#W(){if(!this.#ie){const{hooks:e,json:t,parseJson:r,stringifyJson:s,searchParams:o,timeout:n,totalTimeout:i,throwHttpErrors:a,fetch:c,...u}=this.#$;this.#ie=Object.freeze(u)}return this.#ie}#ve(e){this.#ie=void 0,this.request=e}#z(e){return this.#ue.get(e)??this.request}#Re(e,t){return this.#ue.set(e,t),e}#Ee(e,t){return this.#$.onUploadProgress&&e.body&&Ee?((e,t,r)=>{if(!e.body)return e;const s=(e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,s]of e)t+=40,t+=Le.encode(`Content-Disposition: form-data; name="${r}"`).byteLength,t+="string"==typeof s?Le.encode(s).byteLength:s.size;return t}return e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:"string"==typeof e?Le.encode(e).byteLength:e instanceof URLSearchParams?Le.encode(e.toString()).byteLength:0})(r??e.body);return new Request(e,{duplex:"half",body:xe(e.body,s,t)})})(e,this.#$.onUploadProgress,t??this.#$.body??void 0):e}},ut=e=>{const t=(t,r)=>ct.create(t,Me(e,r));for(const r of Ie)t[r]=(t,s)=>ct.create(t,Me(e,s,{method:r}));return t.create=e=>ut(Me(e)),t.extend=t=>("function"==typeof t&&(t=t(e??{})),ut(Me(e,t))),t.stop=Pe,t.retry=Ne,t},lt=ut(),ht={PUBLIC_EVENTS:"/",FOLDER_EVENTS:e=>`/${e}`,LOGIN:"/auth/login",REGISTER:"/auth/register",FORGOT_PASSWORD:"/auth/forgot-password",RESET_PASSWORD:"/auth/reset-password",VERIFY_EMAIL:"/auth/verify-email",GALLERY:e=>`/event/${e}`,UPLOAD:e=>`/event/${e}/upload`,CURATE:e=>`/event/${e}/curate`,LEADERBOARD:e=>`/event/${e}/leaderboard`,MY_UPLOADS:"/my-uploads"},dt={ORGANIZATION_SETTINGS:e=>`https://beta.qratilabs.com/org/${e}/settings`,ORGANIZATION_SETTINGS_INTEGRATION:e=>`https://beta.qratilabs.com/org/${e}/settings/integration`,ORGANIZATION_DASHBOARD:e=>`https://beta.qratilabs.com/org/${e}/dashboard`,ORGANIZATION_ADMINS:e=>`https://beta.qratilabs.com/org/${e}/admins`,EVENT_SETTINGS_BASIC_DETAILS:e=>`https://beta.qratilabs.com/event/${e}/settings`,EVENT_REVIEW_CONTENTS:e=>`https://beta.qratilabs.com/event/${e}/review-contents`,EVENT_DEEP_SEARCH:e=>`https://beta.qratilabs.com/event/${e}/deep-search`,EVENT_GENERATE_ARTICLE:e=>`https://beta.qratilabs.com/event/${e}/generate-article`,EVENT_ACCESS_REQUESTS:e=>`https://beta.qratilabs.com/event/${e}/access-requests`,EVENT_SHOT_INSPECTOR:e=>`https://beta.qratilabs.com/event/${e}/shot-inspector`,EVENT_CURATION_DETAILS:e=>`https://beta.qratilabs.com/event/${e}/curation-details`},ft={PUBLIC:"PUBLIC",PRIVATE:"PRIVATE",SECRET:"SECRET"},pt="https://beta.qratilabs.com/api/connect",mt={INITIALIZE_SESSION:`${pt}/session/initialize`,REGISTER:`${pt}/auth/register`,LOGIN:`${pt}/auth/login`,LOGOUT:`${pt}/auth/logout`,UPDATE_SESSION:`${pt}/session/update`,ACCEPT_TERMS:`${pt}/auth/accept-terms`,EXTERNAL_LOGIN:`${pt}/auth/external-login`,PUBLIC_EVENTS:`${pt}/event/public-events`,SEARCH_EVENTS:`${pt}/event/search`,FOLDER_DETAILS:`${pt}/folder/details`,NESTED_FOLDERS:`${pt}/folder/nested-folders`,GET_EVENT_POINTS:`${pt}/event/points`,ELIGIBLE_TO_CURATE:`${pt}/content/curation-eligibility`,CONTENT_FOR_CURATION:`${pt}/content/for-curation`,CURATE_CONTENT:`${pt}/content/curate`,GET_LEADERBOARD:`${pt}/event/leaderboard`,GET_UPLOAD_COUNT:`${pt}/event/upload-count`,UPLOAD_CREATE:`${pt}/content/upload/create`,UPLOAD_COMPLETE:`${pt}/content/upload/complete`,UPLOAD_FAIL:`${pt}/content/upload/fail`,UPLOAD_ABORT:`${pt}/content/upload/abort`,UPDATE_REACTION:`${pt}/content/update-reaction`,EVENT_DATA:`${pt}/event/details-with-ads-parameters`,UPDATE_EVENT_LAYOUT:`${pt}/event/update-layout`,GET_EVENT_STATISTICS:`${pt}/event/statistics`,GET_CONTENTS:`${pt}/content/for-gallery`,SEARCH_CONTENTS:`${pt}/content/search`,GET_CONTENTS_COUNT:`${pt}/content/count`,UPDATE_AD_ANALYTICS:`${pt}/event/update-ad-analytics`,UPDATE_GAM_ANALYTICS:`${pt}/event/update-gam-analytics`,INCREMENT_EVENT_VIEW:`${pt}/event/increment-view`,SEND_PASSWORD_RESET_CODE:`${pt}/auth/send-password-reset-code`,VERIFY_PASSWORD_RESET_CODE:`${pt}/auth/verify-password-reset-code`,RESET_PASSWORD:`${pt}/auth/reset-password`,REPORT_ERROR:`${pt}/session/report-error`,GET_POST_PROCESSING_SETTINGS:`${pt}/event/post-processing-settings`,MY_UPLOADS:`${pt}/content/my-uploads`,DELETE_CONTENT:`${pt}/content/delete`},yt={OWNER:"owner",ADMIN:"admin",MODERATOR:"moderator"},gt={IMAGE:"IMAGE",VIDEO:"VIDEO",AD:"AD",GAM_AD:"GAM_AD"},wt={GAM_IMPRESSION:"gam_impression",GAM_VIEWABLE:"gam_viewable",GAM_CLICK:"gam_click"},bt={ROW:"ROW",COLUMN:"COLUMN",MASONRY:"MASONRY"},vt={IN_REVIEW:"IN_REVIEW",APPROVED:"APPROVED",REJECTED:"REJECTED"},Rt=26214400,Et=262144e3,Tt={CLOSED:"CLOSED",OPEN:"OPEN",UPCOMING:"UPCOMING"},St={TEXT:"text",IMAGE:"image",LOTTIE:"lottie"},Ot={CONTEST:"CONTEST",REACTION:"REACTION"},At={GRID:"grid",SINGLE:"single"},It={POPULAR:"popular",UPLOAD_TIME:"upload",CAPTURE_TIME:"capture"},Ct={[It.POPULAR]:{label:"Popular",sortField:"score"},[It.UPLOAD_TIME]:{label:"Uploaded",sortField:"createdAt"},[It.CAPTURE_TIME]:{label:"Captured",sortField:"capturedAt"}},Pt="map-view-state",Dt=It.UPLOAD_TIME,Nt={ASC:"asc",DESC:"desc"},qt={[Nt.ASC]:{label:"Ascending",sortOrder:""},[Nt.DESC]:{label:"Descending",sortOrder:"-"}},_t=Nt.DESC,Lt={OWN:"own",CURATED:"curated",ELIGIBLE:"eligible"},xt={NONE:null,LINK:"LINK",EMAIL:"EMAIL",PHONE:"PHONE",SMS:"SMS",WHATSAPP:"WHATSAPP",MESSENGER:"MESSENGER"},kt={AD_IMPRESSION:"impression",AD_ENGAGEMENT:"engagement",AD_CLICK:"click"},Ft={QRATI_CONNECT_SESSION:"qrati-connect-session",EVENT_IN_REVIEW_COUNT:e=>`in-review-count-${e}`,CONTENTS_BY_EVENT:e=>`contents-by-event-${e}`,USER_UPLOADS:"user-uploads"};function Ut({title:e,children:t}){/* @__PURE__ */
1
+ import{E as e,_ as t,h as r,p as s,r as o,s as n,t as i,v as a,y as c}from"./DrrpB4Om.js";var u={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},l=new class{#e=u;#t=!1;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)}},h="undefined"==typeof window||"Deno"in globalThis;function d(){}function f(e,t){return"function"==typeof e?e(t):e}function p(e){return"number"==typeof e&&e>=0&&e!==1/0}function m(e,t){return Math.max(e+(t||0)-Date.now(),0)}function y(e,t){return"function"==typeof e?e(t):e}function g(e,t){return"function"==typeof e?e(t):e}function w(e,t){const{type:r="all",exact:s,fetchStatus:o,predicate:n,queryKey:i,stale:a}=e;if(i)if(s){if(t.queryHash!==v(i,t.options))return!1}else if(!E(t.queryKey,i))return!1;if("all"!==r){const e=t.isActive();if("active"===r&&!e)return!1;if("inactive"===r&&e)return!1}return!("boolean"==typeof a&&t.isStale()!==a||o&&o!==t.state.fetchStatus||n&&!n(t))}function b(e,t){const{exact:r,status:s,predicate:o,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(r){if(R(t.options.mutationKey)!==R(n))return!1}else if(!E(t.options.mutationKey,n))return!1}return!(s&&t.state.status!==s||o&&!o(t))}function v(e,t){return(t?.queryKeyHashFn||R)(e)}function R(e){return JSON.stringify(e,(e,t)=>I(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function E(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(r=>E(e[r],t[r]))}var T=Object.prototype.hasOwnProperty;function S(e,t,r=0){if(e===t)return e;if(r>500)return t;const s=A(e)&&A(t);if(!(s||I(e)&&I(t)))return t;const o=(s?e:Object.keys(e)).length,n=s?t:Object.keys(t),i=n.length,a=s?new Array(i):{};let c=0;for(let u=0;u<i;u++){const i=s?u:n[u],l=e[i],h=t[i];if(l===h){a[i]=l,(s?u<o:T.call(e,i))&&c++;continue}if(null===l||null===h||"object"!=typeof l||"object"!=typeof h){a[i]=h;continue}const d=S(l,h,r+1);a[i]=d,d===l&&c++}return o===i&&c===o?e:a}function O(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function A(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function I(e){if(!C(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!C(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function C(e){return"[object Object]"===Object.prototype.toString.call(e)}function P(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?S(e,t):t}function N(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function D(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var q=/* @__PURE__ */Symbol();function _(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==q?e.queryFn:()=>Promise.reject(/* @__PURE__ */new Error(`Missing queryFn: '${e.queryHash}'`))}function L(e,t){return"function"==typeof e?e(...t):!!e}var x=/* @__PURE__ */(()=>{let e=()=>h;return{isServer:()=>e(),setIsServer(t){e=t}}})(),k=class{constructor(){this.listeners=/* @__PURE__ */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(){}},F=new class extends k{#r;#s;#o;constructor(){super(),this.#o=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#s||this.setEventListener(this.#o)}onUnsubscribe(){this.hasListeners()||(this.#s?.(),this.#s=void 0)}setEventListener(e){this.#o=e,this.#s?.(),this.#s=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#r!==e&&(this.#r=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#r?this.#r:"hidden"!==globalThis.document?.visibilityState}},U=function(e){setTimeout(e,0)},M=function(){let e=[],t=0,r=e=>{e()},s=e=>{e()},o=U;const n=s=>{t?e.push(s):o(()=>{r(s)})};return{batch:n=>{let i;t++;try{i=n()}finally{t--,t||(()=>{const t=e;e=[],t.length&&o(()=>{s(()=>{t.forEach(e=>{r(e)})})})})()}return i},batchCalls:e=>(...t)=>{n(()=>{e(...t)})},schedule:n,setNotifyFunction:e=>{r=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{o=e}}}(),$=new class extends k{#n=!0;#s;#o;constructor(){super(),this.#o=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#s||this.setEventListener(this.#o)}onUnsubscribe(){this.hasListeners()||(this.#s?.(),this.#s=void 0)}setEventListener(e){this.#o=e,this.#s?.(),this.#s=e(this.setOnline.bind(this))}setOnline(e){this.#n!==e&&(this.#n=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#n}};function j(){let e,t;const r=new Promise((r,s)=>{e=r,t=s});function s(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{s({status:"fulfilled",value:t}),e(t)},r.reject=e=>{s({status:"rejected",reason:e}),t(e)},r}function H(e){return Math.min(1e3*2**e,3e4)}function G(e){return"online"!==(e??"online")||$.isOnline()}var Q=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function V(e){let t,r=!1,s=0;const o=j(),n=()=>"pending"!==o.status,i=()=>F.isFocused()&&("always"===e.networkMode||$.isOnline())&&e.canRun(),a=()=>G(e.networkMode)&&e.canRun(),c=e=>{n()||(t?.(),o.resolve(e))},u=e=>{n()||(t?.(),o.reject(e))},h=()=>new Promise(r=>{t=e=>{(n()||i())&&r(e)},e.onPause?.()}).then(()=>{t=void 0,n()||e.onContinue?.()}),d=()=>{if(n())return;let t;const o=0===s?e.initialPromise:void 0;try{t=o??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{if(n())return;const o=e.retry??(x.isServer()?0:3),a=e.retryDelay??H,c="function"==typeof a?a(s,t):a,f=!0===o||"number"==typeof o&&s<o||"function"==typeof o&&o(s,t);var p;!r&&f?(s++,e.onFail?.(s,t),(p=c,new Promise(e=>{l.setTimeout(e,p)})).then(()=>i()?void 0:h()).then(()=>{r?u(t):d()})):u(t)})};return{promise:o,status:()=>o.status,cancel:t=>{if(!n()){const r=new Q(t);u(r),e.onCancel?.(r)}},continue:()=>(t?.(),o),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?d():h().then(d),o)}}var B=class{#i;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),p(this.gcTime)&&(this.#i=l.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(x.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#i&&(l.clearTimeout(this.#i),this.#i=void 0)}};function z(e){return{onFetch:(t,r)=>{const s=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,n=t.state.data?.pages||[],i=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let r=!1;const u=e=>{!function(e,r,s){let o,n=!1;Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??=t.signal,n||(n=!0,o.aborted?s():o.addEventListener("abort",s,{once:!0})),o)})}(e,0,()=>r=!0)},l=_(t.options,t.fetchOptions),h=async(e,s,o)=>{if(r)return Promise.reject(t.signal.reason);if(null==s&&e.pages.length)return Promise.resolve(e);const n=await l((()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:s,direction:o?"backward":"forward",meta:t.options.meta};return u(e),e})()),{maxPages:i}=t.options,a=o?D:N;return{pages:a(e.pages,n,i),pageParams:a(e.pageParams,s,i)}};if(o&&n.length){const e="backward"===o,t=e?Z:W,r={pages:n,pageParams:i};a=await h(r,t(s,r),e)}else{const t=e??n.length;do{const e=0===c?i[0]??s.initialPageParam:W(s,a);if(c>0&&null==e)break;a=await h(a,e),c++}while(c<t)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u}}}function W(e,{pages:t,pageParams:r}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,r[s],r):void 0}function Z(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}function K(e,t){return!!t&&null!=W(e,t)}function J(e,t){return!(!t||!e.getPreviousPageParam)&&null!=Z(e,t)}var Y=class extends B{#a;#c;#u;#l;#h;#d;#f;#p;constructor(e){super(),this.#p=!1,this.#f=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#h=e.client,this.#l=this.#h.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#c=te(this.options),this.state=e.state??this.#c,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#a}get promise(){return this.#d?.promise}setOptions(e){if(this.options={...this.#f,...e},e?._type&&(this.#a=e._type),this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=te(this.options);void 0!==e.data&&(this.setState(ee(e.data,e.dataUpdatedAt)),this.#c=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#l.remove(this)}setData(e,t){const r=P(this.state.data,e,this.options);return this.#m({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e){this.#m({type:"setState",state:e})}cancel(e){const t=this.#d?.promise;return this.#d?.cancel(e),t?t.then(d).catch(d):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#c}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>!1!==g(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===q||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===y(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!m(this.state.dataUpdatedAt,e))}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#d?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#d?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#l.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.#d&&(this.#p||this.#y()?this.#d.cancel({revert:!0}):this.#d.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#y(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#m({type:"invalidate"})}async fetch(e,t){if("idle"!==this.state.fetchStatus&&"rejected"!==this.#d?.status())if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#d)return this.#d.continueRetry(),this.#d.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const r=new AbortController,s=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,r.signal)})},o=()=>{const e=_(this.options,t),r=(()=>{const e={client:this.#h,queryKey:this.queryKey,meta:this.meta};return s(e),e})();return this.#p=!1,this.options.persister?this.options.persister(e,r,this):e(r)},n=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#h,state:this.state,fetchFn:o};return s(e),e})();("infinite"===this.#a?z(this.options.pages):this.options.behavior)?.onFetch(n,this),this.#u=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===n.fetchOptions?.meta||this.#m({type:"fetch",meta:n.fetchOptions?.meta}),this.#d=V({initialPromise:t?.initialPromise,fn:n.fetchFn,onCancel:e=>{e instanceof Q&&e.revert&&this.setState({...this.#u,fetchStatus:"idle"}),r.abort()},onFail:(e,t)=>{this.#m({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#m({type:"pause"})},onContinue:()=>{this.#m({type:"continue"})},retry:n.options.retry,retryDelay:n.options.retryDelay,networkMode:n.options.networkMode,canRun:()=>!0});try{const e=await this.#d.start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#l.config.onSuccess?.(e,this),this.#l.config.onSettled?.(e,this.state.error,this),e}catch(i){if(i instanceof Q){if(i.silent)return this.#d.promise;if(i.revert){if(void 0===this.state.data)throw i;return this.state.data}}throw this.#m({type:"error",error:i}),this.#l.config.onError?.(i,this),this.#l.config.onSettled?.(this.state.data,i,this),i}finally{this.scheduleGc()}}#m(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,...X(t.data,this.options),fetchMeta:e.meta??null};case"success":const r={...t,...ee(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#u=e.manual?r:void 0,r;case"error":const s=e.error;return{...t,error:s,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),M.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:e})})}};function X(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:G(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function ee(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function te(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,s=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var re=class extends k{constructor(e,t){super(),this.options=t,this.#h=e,this.#g=null,this.#w=j(),this.bindMethods(),this.setOptions(t)}#h;#b=void 0;#v=void 0;#R=void 0;#E;#T;#w;#g;#S;#O;#A;#I;#C;#P;#N=/* @__PURE__ */new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#b.addObserver(this),se(this.#b,this.options)?this.#D():this.updateResult(),this.#q())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return oe(this.#b,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return oe(this.#b,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=/* @__PURE__ */new Set,this.#_(),this.#L(),this.#b.removeObserver(this)}setOptions(e){const t=this.options,r=this.#b;if(this.options=this.#h.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof g(this.options.enabled,this.#b))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#b.setOptions(this.options),t._defaulted&&!O(this.options,t)&&this.#h.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#b,observer:this});const s=this.hasListeners();s&&ne(this.#b,r,this.options,t)&&this.#D(),this.updateResult(),!s||this.#b===r&&g(this.options.enabled,this.#b)===g(t.enabled,this.#b)&&y(this.options.staleTime,this.#b)===y(t.staleTime,this.#b)||this.#k();const o=this.#F();!s||this.#b===r&&g(this.options.enabled,this.#b)===g(t.enabled,this.#b)&&o===this.#P||this.#U(o)}getOptimisticResult(e){const t=this.#h.getQueryCache().build(this.#h,e),r=this.createResult(t,e);var s;return s=r,O(this.getCurrentResult(),s)||(this.#R=r,this.#T=this.options,this.#E=this.#b.state),r}getCurrentResult(){return this.#R}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#w.status||this.#w.reject(/* @__PURE__ */new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#N.add(e)}getCurrentQuery(){return this.#b}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#h.defaultQueryOptions(e),r=this.#h.getQueryCache().build(this.#h,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#D({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#R))}#D(e){this.#x();let t=this.#b.fetch(this.options,e);return e?.throwOnError||(t=t.catch(d)),t}#k(){this.#_();const e=y(this.options.staleTime,this.#b);if(x.isServer()||this.#R.isStale||!p(e))return;const t=m(this.#R.dataUpdatedAt,e)+1;this.#I=l.setTimeout(()=>{this.#R.isStale||this.updateResult()},t)}#F(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#b):this.options.refetchInterval)??!1}#U(e){this.#L(),this.#P=e,!x.isServer()&&!1!==g(this.options.enabled,this.#b)&&p(this.#P)&&0!==this.#P&&(this.#C=l.setInterval(()=>{(this.options.refetchIntervalInBackground||F.isFocused())&&this.#D()},this.#P))}#q(){this.#k(),this.#U(this.#F())}#_(){void 0!==this.#I&&(l.clearTimeout(this.#I),this.#I=void 0)}#L(){void 0!==this.#C&&(l.clearInterval(this.#C),this.#C=void 0)}createResult(e,t){const r=this.#b,s=this.options,o=this.#R,n=this.#E,i=this.#T,a=e!==r?e.state:this.#v,{state:c}=e;let u,l={...c},h=!1;if(t._optimisticResults){const o=this.hasListeners(),n=!o&&se(e,t),i=o&&ne(e,r,t,s);(n||i)&&(l={...l,...X(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(l.fetchStatus="idle")}let{error:d,errorUpdatedAt:f,status:p}=l;u=l.data;let m=!1;if(void 0!==t.placeholderData&&void 0===u&&"pending"===p){let e;o?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(e=o.data,m=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#A?.state.data,this.#A):t.placeholderData,void 0!==e&&(p="success",u=P(o?.data,e,t),h=!0)}if(t.select&&void 0!==u&&!m)if(o&&u===n?.data&&t.select===this.#S)u=this.#O;else try{this.#S=t.select,u=t.select(u),u=P(o?.data,u,t),this.#O=u,this.#g=null}catch(T){this.#g=T}this.#g&&(d=this.#g,u=this.#O,f=Date.now(),p="error");const y="fetching"===l.fetchStatus,w="pending"===p,b="error"===p,v=w&&y,R=void 0!==u,E={status:p,fetchStatus:l.fetchStatus,isPending:w,isSuccess:"success"===p,isError:b,isInitialLoading:v,isLoading:v,data:u,dataUpdatedAt:l.dataUpdatedAt,error:d,errorUpdatedAt:f,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>a.dataUpdateCount||l.errorUpdateCount>a.errorUpdateCount,isFetching:y,isRefetching:y&&!w,isLoadingError:b&&!R,isPaused:"paused"===l.fetchStatus,isPlaceholderData:h,isRefetchError:b&&R,isStale:ie(e,t),refetch:this.refetch,promise:this.#w,isEnabled:!1!==g(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=void 0!==E.data,s="error"===E.status&&!t,o=e=>{s?e.reject(E.error):t&&e.resolve(E.data)},n=()=>{o(this.#w=E.promise=j())},i=this.#w;switch(i.status){case"pending":e.queryHash===r.queryHash&&o(i);break;case"fulfilled":(s||E.data!==i.value)&&n();break;case"rejected":s&&E.error===i.reason||n()}}return E}updateResult(){const e=this.#R,t=this.createResult(this.#b,this.options);this.#E=this.#b.state,this.#T=this.options,void 0!==this.#E.data&&(this.#A=this.#b),O(t,e)||(this.#R=t,this.#M({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#N.size)return!0;const s=new Set(r??this.#N);return this.options.throwOnError&&s.add("error"),Object.keys(this.#R).some(t=>{const r=t;return this.#R[r]!==e[r]&&s.has(r)})})()}))}#x(){const e=this.#h.getQueryCache().build(this.#h,this.options);if(e===this.#b)return;const t=this.#b;this.#b=e,this.#v=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#q()}#M(e){M.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#R)}),this.#h.getQueryCache().notify({query:this.#b,type:"observerResultsUpdated"})})}};function se(e,t){return function(e,t){return!1!==g(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===g(t.retryOnMount,e))}(e,t)||void 0!==e.state.data&&oe(e,t,t.refetchOnMount)}function oe(e,t,r){if(!1!==g(t.enabled,e)&&"static"!==y(t.staleTime,e)){const s="function"==typeof r?r(e):r;return"always"===s||!1!==s&&ie(e,t)}return!1}function ne(e,t,r,s){return(e!==t||!1===g(s.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&ie(e,r)}function ie(e,t){return!1!==g(t.enabled,e)&&e.isStaleByTime(y(t.staleTime,e))}var ae=e(void 0),ce=e=>{const t=c(ae);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ue=({client:e,children:r})=>(t(()=>(e.mount(),()=>{e.unmount()}),[e]),/* @__PURE__ */i(ae.Provider,{value:e,children:r})),le=e(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),he=e(!1),de=(he.Provider,(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()}));function fe(e,s,n){const i=c(he),u=c(le),l=ce(n),h=l.defaultQueryOptions(e);l.getDefaultOptions().queries?._experimental_beforeQuery?.(h);const f=l.getQueryCache().get(h.queryHash),p=!1!==e.subscribed;h._optimisticResults=i?"isRestoring":p?"optimistic":void 0,(e=>{if(e.suspense){const t=1e3,r=e=>"static"===e?e:Math.max(e??t,t),s=e.staleTime;e.staleTime="function"==typeof s?(...e)=>r(s(...e)):r(s),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(h),((e,t,r)=>{const s=r?.state.error&&"function"==typeof e.throwOnError?L(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))})(h,u,f),(e=>{t(()=>{e.clearReset()},[e])})(u);const m=!l.getQueryCache().get(h.queryHash),[y]=r(()=>new s(l,h)),g=y.getOptimisticResult(h),w=!i&&p;if(o(a(e=>{const t=w?y.subscribe(M.batchCalls(e)):d;return y.updateResult(),t},[y,w]),()=>y.getCurrentResult(),()=>y.getCurrentResult()),t(()=>{y.setOptions(h)},[h,y]),((e,t)=>e?.suspense&&t.isPending)(h,g))throw de(h,y,u);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(o&&void 0===e.data||L(r,[e.error,s])))({result:g,errorResetBoundary:u,throwOnError:h.throwOnError,query:f,suspense:h.suspense}))throw g.error;return l.getDefaultOptions().queries?._experimental_afterQuery?.(h,g),h.experimental_prefetchInRender&&!x.isServer()&&((e,t)=>e.isLoading&&e.isFetching&&!t)(g,i)&&(m?de(h,y,u):f?.promise)?.catch(d).finally(()=>{y.updateResult()}),h.notifyOnChangeProps?g:y.trackResult(g)}function pe(e,t){return fe(e,re,t)}var me=class extends Error{name="KyError";get isKyError(){return!0}},ye=class extends me{name="HTTPError";response;request;options;data;constructor(e,t,r){const s=`${e.status||0===e.status?e.status:""} ${e.statusText??""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${t.method} ${t.url}`),this.response=e,this.request=t,this.options=r}},ge=class extends me{name="NetworkError";request;constructor(e,t){super(`Request failed due to a network error: ${e.method} ${e.url}`,t),this.request=e}},we=class extends Error{name="NonError";value;constructor(e){let t="Non-error value was thrown";try{"string"==typeof e?t=e:e&&"object"==typeof e&&"message"in e&&"string"==typeof e.message&&(t=e.message)}catch{}super(t),this.value=e}},be=class extends me{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const t=e?.cause?e.cause instanceof Error?e.cause:new we(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},ve=class extends Error{name="SchemaValidationError";issues;constructor(e){super("Response schema validation failed"),this.issues=e}},Re=class extends me{name="TimeoutError";request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.request=e}},Ee=(()=>{let e=!1,t=!1;const r="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(r&&s)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(o){if(o instanceof Error&&"unsupported BodyInit type"===o.message)return!1;throw o}return e&&!t})(),Te="function"==typeof globalThis.AbortController,Se="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Oe="function"==typeof globalThis.ReadableStream,Ae="function"==typeof globalThis.FormData,Ie=["get","post","put","patch","head","delete"],Ce={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Pe=Symbol("stop"),Ne=class{options;constructor(e){this.options=e}},De=e=>new Ne(e),qe={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,baseUrl:!0,prefix:!0,retry:!0,timeout:!0,totalTimeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},_e={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Le=new TextEncoder,xe=(e,t,r)=>{let s,o=0;return e.pipeThrough(new TransformStream({transform(e,n){if(n.enqueue(e),s){o+=s.byteLength;let e=0===t?0:o/t;e>=1&&(e=1-Number.EPSILON),r?.({percent:e,totalBytes:Math.max(t,o),transferredBytes:o},s)}s=e},flush(){s&&(o+=s.byteLength,r?.({percent:1,totalBytes:Math.max(t,o),transferredBytes:o},s))}}))},ke=e=>null!==e&&"object"==typeof e,Fe=Symbol("replaceOption"),Ue=e=>ke(e)&&!0===e[Fe]?{isReplace:!0,value:e.value}:{isReplace:!1,value:e},Me=(...e)=>{for(const t of e)if((!ke(t)||Array.isArray(t))&&void 0!==t)throw new TypeError("The `options` argument must be an object");return We({},...e)},$e=(e={},t={})=>{const r=new globalThis.Headers(e),s=t instanceof globalThis.Headers,o=new globalThis.Headers(t);for(const[n,i]of o.entries())s&&"undefined"===i||void 0===i?r.delete(n):r.set(n,i);return r},je=e=>{if(!ke(e)||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t},He=e=>{if(e instanceof URLSearchParams){const t=new URLSearchParams(e),r=e[Be];return r&&(t[Be]=new Set(r)),t}return e instanceof globalThis.Headers?new globalThis.Headers(e):Array.isArray(e)?[...e]:je(e)?{...e}:e},Ge=(e,t)=>{return je(e)&&je(t)?(r={...e,...t},Object.fromEntries(Object.entries(r).filter(e=>void 0!==e[1]))):$e(e,t);var r};function Qe(e,t,r){return Object.hasOwn(t,r)&&void 0===t[r]?[]:We(e[r]??[],t[r]??[])}var Ve=(e={},t={})=>({init:Qe(e,t,"init"),beforeRequest:Qe(e,t,"beforeRequest"),beforeRetry:Qe(e,t,"beforeRetry"),beforeError:Qe(e,t,"beforeError"),afterResponse:Qe(e,t,"afterResponse")}),Be=Symbol("deletedParameters"),ze=(e,t)=>{const r=new URLSearchParams,s=/* @__PURE__ */new Set;for(const o of[e,t])if(void 0!==o)if(o instanceof URLSearchParams){for(const[t,n]of o.entries())r.append(t,n),s.delete(t);const e=o[Be];if(e)for(const t of e)r.delete(t),s.add(t)}else if(Array.isArray(o))for(const e of o){if(!Array.isArray(e)||2!==e.length)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(e[0]),String(e[1])),s.delete(String(e[0]))}else if(ke(o))for(const[e,t]of Object.entries(o))void 0===t?(r.delete(e),s.add(e)):(r.append(e,String(t)),s.delete(e));else{const e=new URLSearchParams(o);for(const[t,o]of e.entries())r.append(t,o),s.delete(t)}return s.size>0&&(r[Be]=s),r},We=(...e)=>{let t,r={},s={},o={};const n=[];for(const i of e)if(Array.isArray(i))Array.isArray(r)||(r=[]),r=[...r,...i];else if(ke(i)){for(let[e,s]of Object.entries(i)){if("signal"===e&&s instanceof globalThis.AbortSignal){n.push(s);continue}const o=Ue(s),{isReplace:i}=o;if(s=o.value,"context"!==e)"searchParams"!==e?(ke(s)&&!i&&e in r&&(s=We(r[e],s)),r={...r,[e]:s}):t=null==s?void 0:i||void 0===t?s:ze(t,s);else{if(null!=s&&(!ke(s)||Array.isArray(s)))throw new TypeError("The `context` option must be an object");r={...r,context:null==s?{}:i?{...s}:{...r.context,...s}}}}if(ke(i.hooks)){const{value:e,isReplace:t}=Ue(i.hooks);o=Ve(t?{}:o,e),r.hooks=o}if(ke(i.headers)){const{value:e,isReplace:t}=Ue(i.headers);s=t?He(e):Ge(s,e),r.headers=s}}return void 0!==t&&(r.searchParams=t),n.length>0&&(1===n.length?r.signal=n[0]:r.signal=Se?AbortSignal.any(n):n.at(-1)),r},Ze=e=>Ie.includes(e)?e.toUpperCase():e,Ke={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},Je=(e={})=>{if("number"==typeof e)return{...Ke,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");const t=Object.fromEntries(Object.entries({...e,methods:e.methods?.map(e=>e.toLowerCase())}).filter(([,e])=>void 0!==e));return{...Ke,...t}};async function Ye(e,{signal:t}){return new Promise((r,s)=>{function o(){clearTimeout(n),s(t.reason)}t&&(t.throwIfAborted(),t.addEventListener("abort",o,{once:!0}));const n=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e)})}var Xe=Object.prototype.toString,et=/* @__PURE__ */new Set(["network error","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);var tt=(e,t)=>e instanceof t||e?.name===t.name,rt=Symbol("timedOutResponseData"),st="The `schema` argument must follow the Standard Schema specification",ot=Object.prototype.toString,nt=e=>e instanceof globalThis.Request||"[object Request]"===ot.call(e),it=e=>e instanceof globalThis.Response||"[object Response]"===ot.call(e),at=async(e,t)=>{if("object"!=typeof t&&"function"!=typeof t||null===t)throw new TypeError(st);const r=t["~standard"];if("object"!=typeof r||null===r||"function"!=typeof r.validate)throw new TypeError(st);const s=await r.validate(e);if(s.issues)throw new ve(s.issues);return s.value},ct=class e{static create(t,r){const s=r.hooks?.init??[],o=s.length>0?function(e){const t={...e,json:He(e.json),context:He(e.context),headers:He(e.headers),searchParams:(r=e.searchParams,Array.isArray(r)?r.map(e=>[...e]):He(r))};var r;return void 0!==e.retry&&(t.retry=(e=>"object"!=typeof e?e:{...e,...e.methods&&{methods:[...e.methods]},...e.statusCodes&&{statusCodes:[...e.statusCodes]},...e.afterStatusCodes&&{afterStatusCodes:[...e.afterStatusCodes]}})(e.retry)),t}(r):r;for(const e of s)e(o);const n=new e(t,o),i=(async()=>{try{return await(async()=>{if("number"==typeof n.#$.timeout&&n.#$.timeout>2147483647)throw new RangeError("The `timeout` option cannot be greater than 2147483647");if("number"==typeof n.#$.totalTimeout&&n.#$.totalTimeout>2147483647)throw new RangeError("The `totalTimeout` option cannot be greater than 2147483647");await Promise.resolve();const e=await n.#j();let t=e??await n.#H(async()=>n.#G()),r=void 0!==e||n.#Q();for(;;){if(void 0===t)return t;if(it(t))try{t=await n.#V(t)}catch(s){if(!(s instanceof be))throw s;const e=await n.#B(s,async()=>n.#G());if(void 0===e)return e;t=e,r=n.#Q();continue}const e=t;if(!e.ok&&"opaque"!==e.type&&("function"==typeof n.#$.throwHttpErrors?n.#$.throwHttpErrors(e.status):n.#$.throwHttpErrors)){const s=new ye(e,n.#z(e),n.#W()),o=s;if(s.data=await n.#Z(e),r)throw o;const i=await n.#B(s,async()=>n.#G());if(void 0===i)return i;t=i,r=n.#Q();continue}break}if(!it(t))return t;if(n.#K(t),n.#$.onDownloadProgress){if("function"!=typeof n.#$.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Oe)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const e=t.clone();return n.#J(t),((e,t)=>{if(!e.body)return e;const r={status:e.status,statusText:e.statusText,headers:e.headers};if(204===e.status)return new Response(null,r);const s=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(xe(e.body,s,t),r)})(e,n.#$.onDownloadProgress)}return t})()}catch(e){if(!(e instanceof Error))throw e;if(n.#Y.has(e))throw e;let t=e;for(const r of n.#$.hooks.beforeError){const e=await r({request:n.request,options:n.#W(),error:t,retryCount:n.#X});e instanceof Error&&(t=e)}throw t}finally{const e=n.#ee;n.#te(e?.body??void 0),n.request!==e&&n.#te(n.request.body??void 0)}})();for(const[e,a]of Object.entries(Ce))"bytes"===e&&"function"!=typeof globalThis.Response?.prototype?.bytes||(i[e]=async t=>{n.request.headers.set("accept",n.request.headers.get("accept")||a);const r=await i;if("json"!==e)return r[e]();const s=await r.text();if(""===s)return void 0!==t?at(void 0,t):JSON.parse(s);const c=o.parseJson?await o.parseJson(s,{request:n.#z(r),response:r}):JSON.parse(s);return void 0===t?c:at(c,t)});return i}static#re(e){return!e||"object"!=typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}request;#se;#X=0;#oe;#$;#ee;#ne;#Y=/* @__PURE__ */new WeakSet;#ie;#ae;#ce=!1;#ue=/* @__PURE__ */new WeakMap;constructor(t,r={}){if(this.#oe=t,Object.hasOwn(r,"prefixUrl"))throw new Error("The `prefixUrl` option has been renamed `prefix` in v2 and enhanced to allow slashes in input. See also the new `baseUrl` option for improved flexibility with standard URL resolution: https://github.com/sindresorhus/ky#baseurl");if(this.#$={...r,headers:$e(this.#oe.headers,r.headers),hooks:Ve({},r.hooks),method:Ze(r.method??this.#oe.method??"GET"),prefix:String(r.prefix||""),retry:Je(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,totalTimeout:r.totalTimeout??!1,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},"string"!=typeof this.#oe&&!(this.#oe instanceof URL||this.#oe instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if("string"==typeof this.#oe){if(this.#$.prefix){const e=this.#$.prefix.replace(/\/+$/,""),t=this.#oe.replace(/^\/+/,"");this.#oe=`${e}/${t}`}if(this.#$.baseUrl){let e;try{e=new URL(this.#oe)}catch{}e||(this.#oe=new URL(this.#oe,new Request(this.#$.baseUrl).url))}}Te&&Se&&(this.#ne=this.#$.signal??this.#oe.signal,this.#se=new globalThis.AbortController,this.#$.signal=this.#le()),Ee&&(this.#$.duplex="half"),void 0!==this.#$.json&&(this.#$.body=this.#$.stringifyJson?.(this.#$.json)??JSON.stringify(this.#$.json),this.#$.headers.set("content-type",this.#$.headers.get("content-type")??"application/json"));const s=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#oe instanceof globalThis.Request&&(Ae&&this.#$.body instanceof globalThis.FormData||this.#$.body instanceof URLSearchParams)&&!s&&this.#$.headers.delete("content-type"),this.request=new globalThis.Request(this.#oe,this.#$),void 0!==(o=this.#$.searchParams)&&(Array.isArray(o)?o.length>0:o instanceof URLSearchParams?o.size>0||Boolean(o[Be]?.size):"object"==typeof o?Object.keys(o).length>0:"string"==typeof o?o.trim().length>0:Boolean(o))){const t=new URL(this.request.url),r=this.#$.searchParams?.[Be];if(r)for(const e of r)t.searchParams.delete(e);if("string"==typeof this.#$.searchParams){const e=this.#$.searchParams.replace(/^\?/,"");""!==e&&(t.search=t.search?`${t.search}&${e}`:`?${e}`)}else{const r=new URLSearchParams(e.#re(this.#$.searchParams));for(const[e,s]of r.entries())t.searchParams.append(e,s)}if(this.#$.searchParams&&"object"==typeof this.#$.searchParams&&!Array.isArray(this.#$.searchParams)&&!(this.#$.searchParams instanceof URLSearchParams))for(const[e,s]of Object.entries(this.#$.searchParams))void 0===s&&t.searchParams.delete(e);this.request=new globalThis.Request(t,this.#$)}var o;if(this.#$.onUploadProgress&&"function"!=typeof this.#$.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");this.#ae="number"==typeof this.#$.totalTimeout?this.#he():void 0}#de(){const e=this.#$.retry.delay(this.#X+1);let t=e;return!0===this.#$.retry.jitter?t=Math.random()*e:"function"==typeof this.#$.retry.jitter&&(t=this.#$.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e)),Math.min(this.#$.retry.backoffLimit,t)}async#fe(e){if(this.#X>=this.#$.retry.limit)throw e;const t=e instanceof Error?e:new we(e);if(t instanceof be)return t.customDelay??this.#de();if(!this.#$.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(void 0!==this.#$.retry.shouldRetry){const r=await this.#$.retry.shouldRetry({error:t,retryCount:this.#X+1});if(!1===r)throw e;if(!0===r)return this.#de()}if(function(e){return tt(e,Re)}(e)){if(!this.#$.retry.retryOnTimeout)throw e;return this.#de()}if(function(e){return tt(e,ye)}(e)){if(!this.#$.retry.statusCodes.includes(e.response.status))throw e;const t=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(t&&this.#$.retry.afterStatusCodes.includes(e.response.status)){let e=1e3*Number(t);return Number.isNaN(e)?e=Date.parse(t)-Date.now():e>=Date.parse("2024-01-01")&&(e-=Date.now()),Number.isFinite(e)?(e=Math.max(0,e),Math.min(this.#$.retry.maxRetryAfter,e)):Math.min(this.#$.retry.maxRetryAfter,this.#de())}if(413===e.response.status)throw e;return this.#de()}if(!function(e){return tt(e,ge)}(e))throw e;return this.#de()}#K(e){const t=this.#z(e);return this.#$.parseJson&&(e.json=async()=>{const r=await e.text();return""===r?JSON.parse(r):this.#$.parseJson(r,{request:t,response:e})}),e}async#Z(e){const t=await this.#pe(e,this.#me());if(t===rt)return void this.#ye();if(!t)return;if(!this.#ge(e.headers.get("content-type")??""))return t;const r=await this.#we(t,e,this.#me(),this.#z(e));if(r!==rt)return r;this.#ye()}#me(){const e=!1===this.#$.timeout?1e4:this.#$.timeout,t=this.#be();if(void 0===t)return e;if(t<=0)throw new Re(this.request);return Math.min(e,t)}#ge(e){const t=(e.split(";",1)[0]??"").trim().toLowerCase();return/\/(?:.*[.+-])?json$/.test(t)}async#pe(e,t){const{body:r}=e;if(!r)try{return await e.text()}catch{return}let s;try{s=r.getReader()}catch{return}const o=(e=>{const t=/;\s*charset\s*=\s*(?:"([^"]+)"|([^;,\s]+))/i.exec(e),r=t?.[1]??t?.[2];if(r)try{return new TextDecoder(r)}catch{}return new TextDecoder})(e.headers.get("content-type")??""),n=[];let i=0;const a=(async()=>{try{for(;;){const{done:e,value:t}=await s.read();if(e)break;if(i+=t.byteLength,i>10485760)return void s.cancel().catch(()=>{});n.push(o.decode(t,{stream:!0}))}}catch{return}return n.push(o.decode()),n.join("")})(),c=new Promise(e=>{const r=setTimeout(()=>{e(rt)},t);a.finally(()=>{clearTimeout(r)})}),u=await Promise.race([a,c]);return u===rt&&s.cancel().catch(()=>{}),u}async#we(e,t,r,s){let o;try{return await Promise.race([Promise.resolve().then(()=>this.#$.parseJson?this.#$.parseJson(e,{request:s,response:t}):JSON.parse(e)),new Promise(e=>{o=setTimeout(()=>{e(rt)},r)})])}catch{return}finally{clearTimeout(o)}}#te(e){e&&e.cancel().catch(()=>{})}#J(e){this.#te(e.body??void 0)}#le(){return this.#ne?AbortSignal.any([this.#ne,this.#se.signal]):this.#se.signal}#ye(){const e=this.#be();if(void 0!==e&&e<=0)throw new Re(this.request)}async#j(){for(const e of this.#$.hooks.beforeRequest){const t=await e({request:this.request,options:this.#W(),retryCount:0});if(nt(t))this.#ve(t);else if(it(t))return t}}async#V(e){const t=this.#z(e);for(const s of this.#$.hooks.afterResponse){const o=this.#Re(e.clone(),t);let n;this.#K(o);try{n=await s({request:this.request,options:this.#W(),response:o,retryCount:this.#X})}catch(r){throw o!==e&&this.#J(o),this.#J(e),r}if(n instanceof Ne)throw o!==e&&this.#J(o),this.#J(e),new be(n.options);const i=it(n)?this.#Re(n,t):e;o!==e&&o!==i&&o.body!==i.body&&this.#J(o),e!==i&&e.body!==i.body&&this.#J(e),e=i}return e}async#H(e){try{return await e()}catch(t){return this.#B(t,e)}}async#B(e,t){this.#ce=!1;const r=Math.min(await this.#fe(e),2147483647),s={signal:this.#ne},o=this.#be();if(void 0!==o){if(o<=0)throw new Re(this.request);if(r>=o)throw await Ye(o,s),new Re(this.request)}if(await Ye(r,s),this.#ye(),e instanceof be&&e.customRequest){const t=new globalThis.Request(e.customRequest,this.#$.signal?{signal:this.#$.signal}:void 0);this.#ve(t)}for(const i of this.#$.hooks.beforeRetry){let t;try{t=await i({request:this.request,options:this.#W(),error:e,retryCount:this.#X+1})}catch(n){throw n instanceof Error&&n!==e&&this.#Y.add(n),n}if(nt(t)){this.#ve(t);break}if(it(t))return this.#ce=!0,this.#X++,t;if(t===Pe)return}return this.#ye(),this.#X++,this.#H(t)}#Q(){const e=this.#ce;return this.#ce=!1,e}async#G(){this.#se?.signal.aborted&&(this.#se=new globalThis.AbortController,this.#$.signal=this.#le(),this.request=new globalThis.Request(this.request,{signal:this.#$.signal}));const e=(e=>{const t={};for(const r in e)Object.hasOwn(e,r)&&(r in _e||r in qe||(t[r]=e[r]));return t})(this.#$),t=this.#$.retry.limit>0?this.request.clone():void 0,r=this.#Ee(this.request,this.#$.body??void 0);this.#ee=r,t&&(this.request=t);try{const t=this.#be();if(void 0!==t&&t<=0)throw new Re(this.request);const s=!1===this.#$.timeout?t:void 0===t?this.#$.timeout:Math.min(this.#$.timeout,t),o=void 0===s?await this.#$.fetch(r,e):await async function(e,t,r,s){return new Promise((o,n)=>{const i=setTimeout(()=>{r&&r.abort(),n(new Re(e))},s.timeout);s.fetch(e,t).then(o).catch(n).then(()=>{clearTimeout(i)})})}(r,e,this.#se,{timeout:s,fetch:this.#$.fetch});return this.#Re(o,r)}catch(s){if(function(e){if(!e||(t=e,"[object Error]"!==Xe.call(t))||"TypeError"!==e.name||"string"!=typeof e.message)return!1;var t;const{message:r,stack:s}=e;return"Load failed"===r?void 0===s||"__sentry_captured__"in e:!!r.startsWith("error sending request for url")||!!("Failed to fetch"===r||r.startsWith("Failed to fetch (")&&r.endsWith(")"))||et.has(r)}(s))throw new ge(this.request,{cause:s});throw s}}#be(){if(void 0===this.#ae)return;const e=this.#he()-this.#ae;return Math.max(0,this.#$.totalTimeout-e)}#he(){return globalThis.performance?.now()??Date.now()}#W(){if(!this.#ie){const{hooks:e,json:t,parseJson:r,stringifyJson:s,searchParams:o,timeout:n,totalTimeout:i,throwHttpErrors:a,fetch:c,...u}=this.#$;this.#ie=Object.freeze(u)}return this.#ie}#ve(e){this.#ie=void 0,this.request=e}#z(e){return this.#ue.get(e)??this.request}#Re(e,t){return this.#ue.set(e,t),e}#Ee(e,t){return this.#$.onUploadProgress&&e.body&&Ee?((e,t,r)=>{if(!e.body)return e;const s=(e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,s]of e)t+=40,t+=Le.encode(`Content-Disposition: form-data; name="${r}"`).byteLength,t+="string"==typeof s?Le.encode(s).byteLength:s.size;return t}return e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:"string"==typeof e?Le.encode(e).byteLength:e instanceof URLSearchParams?Le.encode(e.toString()).byteLength:0})(r??e.body);return new Request(e,{duplex:"half",body:xe(e.body,s,t)})})(e,this.#$.onUploadProgress,t??this.#$.body??void 0):e}},ut=e=>{const t=(t,r)=>ct.create(t,Me(e,r));for(const r of Ie)t[r]=(t,s)=>ct.create(t,Me(e,s,{method:r}));return t.create=e=>ut(Me(e)),t.extend=t=>("function"==typeof t&&(t=t(e??{})),ut(Me(e,t))),t.stop=Pe,t.retry=De,t},lt=ut(),ht={PUBLIC_EVENTS:"/",FOLDER_EVENTS:e=>`/${e}`,LOGIN:"/auth/login",REGISTER:"/auth/register",FORGOT_PASSWORD:"/auth/forgot-password",RESET_PASSWORD:"/auth/reset-password",VERIFY_EMAIL:"/auth/verify-email",GALLERY:e=>`/event/${e}`,UPLOAD:e=>`/event/${e}/upload`,CURATE:e=>`/event/${e}/curate`,LEADERBOARD:e=>`/event/${e}/leaderboard`,MY_UPLOADS:"/my-uploads"},dt={ORGANIZATION_SETTINGS:e=>`https://beta.qratilabs.com/org/${e}/settings`,ORGANIZATION_SETTINGS_INTEGRATION:e=>`https://beta.qratilabs.com/org/${e}/settings/integration`,ORGANIZATION_DASHBOARD:e=>`https://beta.qratilabs.com/org/${e}/dashboard`,ORGANIZATION_ADMINS:e=>`https://beta.qratilabs.com/org/${e}/admins`,EVENT_SETTINGS_BASIC_DETAILS:e=>`https://beta.qratilabs.com/event/${e}/settings`,EVENT_REVIEW_CONTENTS:e=>`https://beta.qratilabs.com/event/${e}/review-contents`,EVENT_DEEP_SEARCH:e=>`https://beta.qratilabs.com/event/${e}/deep-search`,EVENT_GENERATE_ARTICLE:e=>`https://beta.qratilabs.com/event/${e}/generate-article`,EVENT_ACCESS_REQUESTS:e=>`https://beta.qratilabs.com/event/${e}/access-requests`,EVENT_SHOT_INSPECTOR:e=>`https://beta.qratilabs.com/event/${e}/shot-inspector`,EVENT_CURATION_DETAILS:e=>`https://beta.qratilabs.com/event/${e}/curation-details`},ft={PUBLIC:"PUBLIC",PRIVATE:"PRIVATE",SECRET:"SECRET"},pt="https://beta.qratilabs.com/api/connect",mt={INITIALIZE_SESSION:`${pt}/session/initialize`,REGISTER:`${pt}/auth/register`,LOGIN:`${pt}/auth/login`,LOGOUT:`${pt}/auth/logout`,UPDATE_SESSION:`${pt}/session/update`,ACCEPT_TERMS:`${pt}/auth/accept-terms`,EXTERNAL_LOGIN:`${pt}/auth/external-login`,PUBLIC_EVENTS:`${pt}/event/public-events`,SEARCH_EVENTS:`${pt}/event/search`,FOLDER_DETAILS:`${pt}/folder/details`,NESTED_FOLDERS:`${pt}/folder/nested-folders`,GET_EVENT_POINTS:`${pt}/event/points`,ELIGIBLE_TO_CURATE:`${pt}/content/curation-eligibility`,CONTENT_FOR_CURATION:`${pt}/content/for-curation`,CURATE_CONTENT:`${pt}/content/curate`,GET_LEADERBOARD:`${pt}/event/leaderboard`,GET_UPLOAD_COUNT:`${pt}/event/upload-count`,UPLOAD_CREATE:`${pt}/content/upload/create`,UPLOAD_COMPLETE:`${pt}/content/upload/complete`,UPLOAD_FAIL:`${pt}/content/upload/fail`,UPLOAD_ABORT:`${pt}/content/upload/abort`,UPDATE_REACTION:`${pt}/content/update-reaction`,EVENT_DATA:`${pt}/event/details-with-ads-parameters`,UPDATE_EVENT_LAYOUT:`${pt}/event/update-layout`,GET_EVENT_STATISTICS:`${pt}/event/statistics`,GET_CONTENTS:`${pt}/content/for-gallery`,SEARCH_CONTENTS:`${pt}/content/search`,GET_CONTENTS_COUNT:`${pt}/content/count`,UPDATE_AD_ANALYTICS:`${pt}/event/update-ad-analytics`,UPDATE_GAM_ANALYTICS:`${pt}/event/update-gam-analytics`,INCREMENT_EVENT_VIEW:`${pt}/event/increment-view`,SEND_PASSWORD_RESET_CODE:`${pt}/auth/send-password-reset-code`,VERIFY_PASSWORD_RESET_CODE:`${pt}/auth/verify-password-reset-code`,RESET_PASSWORD:`${pt}/auth/reset-password`,REPORT_ERROR:`${pt}/session/report-error`,GET_POST_PROCESSING_SETTINGS:`${pt}/event/post-processing-settings`,MY_UPLOADS:`${pt}/content/my-uploads`,DELETE_CONTENT:`${pt}/content/delete`},yt={OWNER:"owner",ADMIN:"admin",MODERATOR:"moderator"},gt={IMAGE:"IMAGE",VIDEO:"VIDEO",AD:"AD",GAM_AD:"GAM_AD"},wt={GAM_IMPRESSION:"gam_impression",GAM_VIEWABLE:"gam_viewable",GAM_CLICK:"gam_click"},bt={ROW:"ROW",COLUMN:"COLUMN",MASONRY:"MASONRY"},vt={IN_REVIEW:"IN_REVIEW",APPROVED:"APPROVED",REJECTED:"REJECTED"},Rt=26214400,Et=262144e3,Tt={CLOSED:"CLOSED",OPEN:"OPEN",UPCOMING:"UPCOMING"},St={TEXT:"text",IMAGE:"image",LOTTIE:"lottie"},Ot={CONTEST:"CONTEST",REACTION:"REACTION"},At={GRID:"grid",SINGLE:"single"},It={POPULAR:"popular",UPLOAD_TIME:"upload",CAPTURE_TIME:"capture"},Ct={[It.POPULAR]:{label:"Popular",sortField:"score"},[It.UPLOAD_TIME]:{label:"Uploaded",sortField:"createdAt"},[It.CAPTURE_TIME]:{label:"Captured",sortField:"capturedAt"}},Pt="map-view-state",Nt=It.UPLOAD_TIME,Dt={ASC:"asc",DESC:"desc"},qt={[Dt.ASC]:{label:"Ascending",sortOrder:""},[Dt.DESC]:{label:"Descending",sortOrder:"-"}},_t=Dt.DESC,Lt={OWN:"own",CURATED:"curated",ELIGIBLE:"eligible"},xt={NONE:null,LINK:"LINK",EMAIL:"EMAIL",PHONE:"PHONE",SMS:"SMS",WHATSAPP:"WHATSAPP",MESSENGER:"MESSENGER"},kt={AD_IMPRESSION:"impression",AD_ENGAGEMENT:"engagement",AD_CLICK:"click"},Ft={QRATI_CONNECT_SESSION:"qrati-connect-session",EVENT_IN_REVIEW_COUNT:e=>`in-review-count-${e}`,CONTENTS_BY_EVENT:e=>`contents-by-event-${e}`,USER_UPLOADS:"user-uploads"};function Ut({title:e,children:t}){/* @__PURE__ */
2
2
  return i("div",{className:"mx-auto mt-24 w-fit max-w-xl space-y-8",children:[/* @__PURE__ */i("svg",{xmlns:"http://www.w3.org/2000/svg",className:"mx-auto h-64 w-fit text-[#ff4800]",width:"800",height:"469.317",viewBox:"0 0 800 469.317",role:"img","aria-label":"Error illustration",children:/* @__PURE__ */i("g",{transform:"translate(-443.142 -257.876)",children:[
3
3
  /* @__PURE__ */i("path",{d:"M898.247,664.1H371.155a30.276,30.276,0,0,1-30.241-30.241V352.525a30.276,30.276,0,0,1,30.241-30.241H898.247a30.276,30.276,0,0,1,30.241,30.241V633.862A30.276,30.276,0,0,1,898.247,664.1Z",transform:"translate(308.867 25.517)",fill:"#fff"}),
4
4
  /* @__PURE__ */i("path",{d:"M557.334,341.82H30.241A30.276,30.276,0,0,1,0,311.578V30.241A30.276,30.276,0,0,1,30.241,0H557.334a30.276,30.276,0,0,1,30.241,30.241V311.578A30.276,30.276,0,0,1,557.334,341.82ZM30.241,1.833A28.441,28.441,0,0,0,1.833,30.241V311.578a28.441,28.441,0,0,0,28.409,28.409H557.334a28.441,28.441,0,0,0,28.409-28.409V30.241A28.441,28.441,0,0,0,557.334,1.833Z",transform:"matrix(0.999, -0.035, 0.035, 0.999, 643.995, 358.158)",fill:"#d6d6e3"}),
@@ -36,6 +36,6 @@ return i(Ut,"custom-auth-invalid"===t?{title:"Setup needed",children:["Custom au
36
36
  /* @__PURE__ */i(Mt,{organizationId:e})," for details."]}:"page-not-registered"===t?{title:"Page not registered",children:["Add the current page URL in Allowed URLs under"," ",
37
37
  /* @__PURE__ */i("a",{className:"font-medium text-blue-500",href:dt.ORGANIZATION_SETTINGS(e),target:"_blank",rel:"noreferrer",children:"Organization Settings"})," ","⇨ Integration Settings. See our ",
38
38
  /* @__PURE__ */i(Mt,{organizationId:e})," for details."]}:{title:"Heads up",children:["Something needs attention. See our ",
39
- /* @__PURE__ */i(Mt,{organizationId:e})," for details or contact Qrati support."]})}var jt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Ht=e=>e.trim().replace(/\s+/g," "),Gt=e=>e?.replace(/\/+$/,"")||"",Vt=e=>{if(!e)return jt;const t=Ht("string"==typeof e?e:e.fontFamily||""),r="string"==typeof e?void 0:e.customFontName;return t&&"system"!==t?"custom"===t?`"${r||"QratiCustomFont"}", ${jt}`:`"${t}", ${jt}`:"inherit"};function Qt(e){var t,r,s="";if("string"==typeof e||"number"==typeof e)s+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=Qt(e[t]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}function Bt(){for(var e,t,r=0,s="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Qt(e))&&(s&&(s+=" "),s+=t);return s}var zt=(...e)=>Bt(e.filter(Boolean)),Wt=e=>{const t=e.replace(/#/g,"");return(299*parseInt(t.slice(0,2),16)+587*parseInt(t.slice(2,4),16)+114*parseInt(t.slice(4,6),16))/1e3>=128?"#000000":"#FFFFFF"},Zt="px",Kt=(e,t="light")=>{const r=e?.themeSettings?.colors??{},s=e?.themeSettings?.border,o=e?.themeSettings?.shadow,n=e?.integrationSettings,i="dark"===t,a=(e,t,s,o)=>{const n=i?o:s;return r[i?t:e]||n},c=a("primaryLight","primaryDark","#ff4800","#ff4800");return{"--background":a("backgroundLight","backgroundDark","#fafafa","#0a0a0a"),"--foreground":a("foregroundLight","foregroundDark","#252629","#f5f5f5"),"--muted":a("mutedLight","mutedDark","#e5e5e5","#171717"),"--muted-foreground":a("mutedForegroundLight","mutedForegroundDark","#484848","#b5b8bb"),"--border":a("borderLight","borderDark","#dddddd","#353538"),"--input":a("inputLight","inputDark","#f5f5f5","#171717"),"--primary":c,"--primary-foreground":Wt(c),"--popover":a("popoverLight","popoverDark","#f5f5f5","#171717"),"--popover-foreground":a("popoverForegroundLight","popoverForegroundDark","#252629","#fafafa"),"--info":a("infoLight","infoDark","#2563eb","#5b8def"),"--warning":a("warningLight","warningDark","#f59e0b","#fbbf24"),"--success":a("successLight","successDark","#10b981","#34d399"),"--destructive":a("destructiveLight","destructiveDark","#ef4444","#f87171"),"--border-width":`${s?.width??"1"}${s?.unit??"px"}`,"--radius":`${s?.radius??"10"}${s?.unit??"px"}`,"--shadow-outer-horizontal-offset":`${o?.outerHorizontalOffset??"0"}${o?.unit??Zt}`,"--shadow-outer-vertical-offset":`${o?.outerVerticalOffset??"0"}${o?.unit??Zt}`,"--shadow-outer-blur":`${o?.outerBlur??"0"}${o?.unit??Zt}`,"--shadow-outer-spread":`${o?.outerSpread??"0"}${o?.unit??Zt}`,...n?.fontFamily&&"system"!==n.fontFamily?{"--font-family":Vt(n)}:{}}},Jt=async e=>{try{return await e()}catch{return null}},Yt=(e,t=1)=>{const r=(new TextEncoder).encode(e),s=3432918353,o=461845907;let n=t>>>0;const i=Math.floor(r.length/4),a=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let h=0;h<i;h++){let e=a.getUint32(4*h,!0);e=Math.imul(e,s),e=e<<15|e>>>17,e=Math.imul(e,o),n^=e,n=n<<13|n>>>19,n=Math.imul(n,5)+3864292196>>>0}let c=0;const u=4*i,l=3&r.length;return 3===l&&(c^=r[u+2]<<16),l>=2&&(c^=r[u+1]<<8),l>=1&&(c^=r[u],c=Math.imul(c,s),c=c<<15|c>>>17,c=Math.imul(c,o),n^=c),n^=r.length,n^=n>>>16,n=Math.imul(n,2246822507)>>>0,n^=n>>>13,n=Math.imul(n,3266489909)>>>0,n^=n>>>16,n.toString(16).padStart(8,"0")},Xt=e=>{if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Xt).join(",")}]`;const t=Object.keys(e).sort(),r=[];for(const s of t){const t=e[s];void 0!==t&&r.push(`${Xt(s)}:${Xt(t)}`)}return`{${r.join(",")}}`},er=async({debug:e=!1}={})=>{const t=performance.now(),r=await Jt(async()=>window.navigator.userAgentData&&"function"==typeof window.navigator.userAgentData.getHighEntropyValues?Xt(await window.navigator.userAgentData.getHighEntropyValues(["architecture","bitness","platformVersion","model","fullVersionList"])):null),s=await Jt(()=>(()=>{const e=document.createElement("video"),t=["video/webm","video/mp4","video/ogg","audio/mp4","audio/webm","audio/ogg","audio/mpeg"],r={};for(const s of t){const t=e.canPlayType(s);r[s]=""===t?"no":t}return Xt(r)})()),o=await Jt(()=>(()=>{const e=["monospace","serif","sans-serif"],t=["Arial","Helvetica","Verdana","Trebuchet MS","Comic Sans MS","Georgia","Times New Roman","Courier New","Segoe UI","Roboto","Open Sans","Noto Sans","system-ui","-apple-system","BlinkMacSystemFont"],r=document.createElement("span");r.style.fontSize="72px",r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="nowrap",r.textContent="mmmmmmmmmwwwwwww",document.body.appendChild(r);const s={};for(const n of e)r.style.fontFamily=n,s[n]=r.offsetWidth;const o=[];for(const n of t){let t=!1;for(const i of e)if(r.style.fontFamily=`"${n}", ${i}`,r.offsetWidth!==s[i]){o.push(n),t=!0;break}t||(r.style.fontFamily=`"${n}"`,r.offsetWidth!==s.monospace&&r.offsetWidth!==s.serif&&o.push(n))}return document.body.removeChild(r),o.length?o.sort().join(","):null})()),n=await Jt(()=>new Intl.NumberFormat(window.navigator.languages?.[0]||"en").resolvedOptions().numberingSystem),i=window.navigator.languages?Array.from(window.navigator.languages).join(","):window.navigator.language||null,a=Intl.DateTimeFormat().resolvedOptions(),c=a.timeZone,u=/* @__PURE__ */(new Date).getTimezoneOffset(),l=a.calendar||null,h=void 0!==a.hour12?a.hour12?"h12":"h23":a.hourCycle||null,d=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"reduce":"no-preference",f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",p=window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":window.matchMedia("(prefers-contrast: custom)").matches?"custom":"no-preference",m=window.matchMedia("(prefers-reduced-transparency: reduce)").matches?"reduce":"no-preference",y=window.matchMedia("(forced-colors: active)").matches?"active":null,g="number"==typeof window.devicePixelRatio?Math.round(100*window.devicePixelRatio)/100:null,{pixelDepth:w,colorDepth:b}=window.screen,v="ontouchstart"in window||window.navigator.maxTouchPoints>0,R=await Jt(()=>(async e=>{const t=document.createElement("canvas");t.width=280,t.height=100;const r=t.getContext("2d"),s=r.createLinearGradient(0,0,280,100);return s.addColorStop(0,"#f60"),s.addColorStop(.4,"#09f"),s.addColorStop(.7,"#f09"),s.addColorStop(1,"#0f9"),r.fillStyle=s,r.fillRect(0,0,280,100),r.font='18px "Arial","Helvetica","DejaVu Sans",sans-serif',r.fillStyle="#000",r.textBaseline="alphabetic",r.fillText("Fingerprint ¼½¾™©®∆π∑€¶§",12,45),r.font='bold 22px "Georgia","Times New Roman",serif',r.fillStyle="#222",r.fillText("🦊🐱🚀 2026",12,78),r.globalAlpha=.7,r.fillStyle="rgba(255, 80, 0, 0.35)",r.fillRect(180,20,80,60),r.beginPath(),r.arc(220,50,32,0,2*Math.PI),r.strokeStyle="#fff",r.lineWidth=4,r.stroke(),r.beginPath(),r.moveTo(30,85),r.quadraticCurveTo(140,20,240,85),r.strokeStyle="#00f",r.lineWidth=3,r.stroke(),e&&(t.style.border="1px solid #444",document.body.appendChild(t)),Yt(t.toDataURL("image/png"))})(e)),E=await Jt(()=>(async()=>{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl"),r=t.getExtension("WEBGL_debug_renderer_info");return Yt(Xt({vendor:r?t.getParameter(r.UNMASKED_VENDOR_WEBGL):t.getParameter(t.VENDOR),renderer:r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER)}))})()),T=await Jt(()=>(async e=>{const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),r={vendor:t.info?.vendor??"",architecture:t.info?.architecture??"",description:t.info?.description??"",features:Array.from(t.features).sort(),limits:Array.from(t.limits).sort()};if(e){const e=document.createElement("pre");e.style.margin="10px 0",e.style.padding="10px",e.style.border="1px solid #444",e.style.background="#111",e.style.color="#0f8",e.style.fontFamily="monospace",e.textContent=`WebGPU:\n${JSON.stringify(r,null,2)}`,document.body.appendChild(e)}return Yt(Xt(r))})(e)),S=await Jt(()=>(async e=>{const t=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,6e3,44100),r=t.createOscillator();r.type="sawtooth",r.frequency.value=8800;const s=t.createDynamicsCompressor();s.threshold.value=-48,s.knee.value=30,s.ratio.value=14,s.attack.value=0,s.release.value=.3;const o=t.createGain();o.gain.value=.4,r.connect(s),s.connect(o),o.connect(t.destination),r.start(0);const n=(await t.startRendering()).getChannelData(0);let i=0,a=0;for(let u=3e3;u<5800;u+=2){const e=n[u];i=31*i+Math.floor(1e5*(e+1))|0,a=Math.imul(a^Math.floor(98765*e),2246822519)}const c=i>>>0^a>>>0;if(e){const e=document.createElement("canvas");e.width=500,e.height=120,e.style.border="1px solid #444",e.style.margin="10px 0",e.title="Audio buffer snippet (4500–5000 samples)";const t=e.getContext("2d");t.fillStyle="#111",t.fillRect(0,0,e.width,e.height),t.font="14px monospace",t.fillStyle="#0f8",t.textAlign="left",t.fillText("AudioID",10,20),t.strokeStyle="#0f8",t.lineWidth=1.5,t.beginPath();const r=Array.from(n.slice(4500,5e3)),s=e.width/r.length;for(let o=0;o<r.length;o++){const n=o*s,i=(r[o]+1)/2*e.height;0===o?t.moveTo(n,i):t.lineTo(n,i)}t.stroke(),document.body.appendChild(e)}return Yt(c.toString(16))})(e)),O=window.screen.width&&window.screen.height?(window.screen.width/window.screen.height).toFixed(4):null,A=await Jt(()=>window.screen.orientation?.type||null),I=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection,C=I&&I.type||null,P=I?.effectiveType||null,D=!0===I?.saveData,N="boolean"==typeof window.navigator.pdfViewerEnabled?window.navigator.pdfViewerEnabled:null,q="boolean"==typeof window.navigator.webdriver?window.navigator.webdriver:null,_=await Jt(()=>"function"!=typeof Intl.supportedValuesOf?null:Intl.supportedValuesOf("calendar").join(",")),L=await Jt(async()=>{if(!window.navigator.permissions||"function"!=typeof window.navigator.permissions.query)return null;const e=["geolocation","notifications"],t={};for(const r of e)try{t[r]=(await window.navigator.permissions.query({name:r})).state}catch{t[r]="unsupported"}return Xt(t)}),x={vendor:window.navigator.vendor||null,platform:window.navigator.platform||null,userAgentHighEntropy:r||null,mediaCodecs:s||null,fonts:o,numberingSystem:n,languages:i,timezone:c,timezoneOffset:u,intlCalendar:l,hourCycle:h,reducedMotion:d,colorScheme:f,prefersContrast:p,prefersReducedTransparency:m,pdfViewerEnabled:N,webdriver:q,intlSupportedCalendars:_||null,permissionsState:L||null,hardwareConcurrency:window.navigator.hardwareConcurrency||null,deviceMemory:window.navigator.deviceMemory||null,forcedColors:y,devicePixelRatio:g,pixelDepth:w,colorDepth:b,touchSupport:v,screenOrientation:A||null,connectionType:C,effectiveType:P,saveData:D,canvasID:R,webglID:E,webgpuID:T,audioID:S},k={aspectRatio:O,width:window.screen.width,height:window.screen.height,maxTouchPoints:window.navigator.maxTouchPoints};(!0===navigator.userAgentData?.mobile||/Mobi|Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||navigator.maxTouchPoints>0&&matchMedia("(pointer:coarse)").matches&&innerWidth<=1024)&&Object.assign(x,k);const F=Yt(Xt(x)),U=Math.round(performance.now()-t);return{fingerprint:F,...x,elapsedMs:U}};"undefined"!=typeof window&&(window.getBrowserFingerprint=er);var tr=async(e,t)=>{if(e instanceof ye){try{const t=e.data;if(t?.error)return t.error;if(t?.message)return t.message;if("INVALID_EMAIL_OR_PASSWORD"===t?.code)return"Invalid email or password"}catch{return t||e.message}return t||e.message}return e instanceof Error?t||e.message:t||String(e)},rr=e(void 0),sr=({props:e={},children:o})=>{const{organizationId:c,uid:u,fname:l,lname:h,theme:d="light"}=e,[f,p]=r(null),[m,y]=r(()=>{if("undefined"==typeof window)return null;const e=localStorage.getItem("qrati_token");return e?{token:e}:null}),{isLoading:g,data:w,error:b}=pe({queryKey:[Ft.QRATI_CONNECT_SESSION,c,u??null,l??null,h??null],queryFn:async()=>{const e=await(async()=>{const e=await er();return"string"==typeof e?e:e?.fingerprint})();try{return(await lt.post(mt.INITIALIZE_SESSION,{json:{uid:u,fname:l,lname:h,browserFingerprint:e},headers:{"x-org-id":c,...!m?.token||u||l||h?{}:{Authorization:`Bearer ${m.token}`}}}).json()).data}catch(t){if(t instanceof ye)try{const e=t.data;t.apiMessage=e?.message||e?.error}catch{}throw t}},enabled:!!c});t(()=>{const e=w?.authSession?.session?.token??w?.authSession?.token,t=w?.authSession?.user;t&&e?(y(r=>({...r,...t,token:e,tcAccepted:void 0===t.tcAccepted?r?.tcAccepted:t.tcAccepted})),localStorage.setItem("qrati_token",e)):w?.organization?.customAuth&&u&&l&&y(e=>e??{_id:u,uid:u,name:h?`${l} ${h}`:l,fname:l,lname:h})},[w]);const v=s(()=>{const e=w?.organization?.integrationSettings?.fontFamily,t=((e,t)=>{const r=Gt("https://beta.qratilabs.com"),s=t?Ht(t):"";return r&&s?`${r}/api/connect/organization/google-font?family=${encodeURIComponent(s)}`:null})(0,e),r=((e,t)=>{const r=Gt("https://beta.qratilabs.com");return r&&t?`${r}/api/connect/organization/custom-font?organizationId=${encodeURIComponent(t)}`:null})(0,c);return((e,t,r)=>{if(!e?.fontFamily||"system"===e.fontFamily)return"";const s=Ht(e.fontFamily);if("custom"===s&&t){const r=e.customFontName||"QratiCustomFont",s=/\.woff2(\?|$)/i.test(t)?"woff2":/\.ttf(\?|$)/i.test(t)?"truetype":"woff";return`@font-face{font-family:"${o=r,o.replace(/"/g,'\\"')}";src:url("${t}") format("${s}");font-weight:400 700;font-style:normal;font-display:swap;}`}var o;const n=r||(e=>{if(!e)return null;const t=Ht(e);return t&&"system"!==t.toLowerCase()&&"custom"!==t.toLowerCase()?`https://fonts.googleapis.com/css2?family=${t.replace(/\s+/g,"+")}:wght@400;500;600;700&display=swap`:null})(s);return n?`@import url("${n}");`:""})(w?.organization?.integrationSettings,w?.organization?.customFontUrl?r||w.organization.customFontUrl:void 0,t||void 0)},[w?.organization?.integrationSettings,w?.organization?.customFontUrl,c]);t(()=>{const e=`data-qrati-font-${c}`;if(document.head.querySelector(`[${e}]`)?.remove(),v){if(v.startsWith("@import")){const t=v.match(/@import url\("([^"]+)"\)/);if(!t?.[1])return;const r=document.createElement("link");r.rel="stylesheet",r.href=t[1],r.setAttribute(e,""),document.head.appendChild(r)}else{const t=document.createElement("style");t.textContent=v,t.setAttribute(e,""),document.head.appendChild(t)}return()=>{document.head.querySelector(`[${e}]`)?.remove()}}},[v,c]);const R=a(async e=>{y(t=>({...t,...e}))},[]),E=a(async(e,t,r,s)=>{try{const o=await lt.post(mt.REGISTER,{json:{email:e,password:t,fname:r,lname:s},headers:{"x-org-id":c}}).json();return o.error?{error:o.error}:(y({...o.user,token:o.token}),o.token&&localStorage.setItem("qrati_token",o.token),o)}catch(b){return{error:await tr(b,"Registration failed")}}},[c]),T=a(async(e,t)=>{try{const r=await lt.post(mt.LOGIN,{json:{email:e,password:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:(y({...r.user,token:r.token}),r.token&&localStorage.setItem("qrati_token",r.token),r)}catch(b){return{error:await tr(b,"Invalid email or password")}}},[c]),S=a(async e=>{const t=await((e,t,r)=>new Promise((s,o)=>{if(!e)return void o(/* @__PURE__ */new Error("Provider is required"));if(!t)return void o(/* @__PURE__ */new Error("Organization ID is required"));const n=new URL(`${r}/qc-social-auth`);n.searchParams.set("provider",e),n.searchParams.set("organizationId",t),n.searchParams.set("origin",window.location.origin);const i=(window.screen.width-500)/2,a=(window.screen.height-600)/2,c=window.open(n.toString(),"qrati_social_auth",`width=500,height=600,left=${i},top=${a},scrollbars=yes,resizable=yes,status=yes`);if(!c)return void o(/* @__PURE__ */new Error("Failed to open popup window. Please allow popups and try again."));const u=()=>{clearInterval(h),clearTimeout(d),window.removeEventListener("message",l)},l=e=>{try{const t=new URL(r).origin;if(e.origin!==t)return void console.warn("Origin mismatch:",e.origin,"expected:",t)}catch(h){console.warn("Could not parse origin for verification")}const{type:n,data:i,error:a,organizationId:l}=e.data||{};if(l===t)switch(n){case"QRATI_SOCIAL_AUTH_SUCCESS":u(),c.close(),s({user:i.user,session:i.session,token:i.token});break;case"QRATI_SOCIAL_AUTH_ERROR":console.error("Authentication error:",a),u(),c.close(),o(new Error(a||"Social authentication failed"));break;case"QRATI_SOCIAL_AUTH_CANCELLED":u(),c.close(),o(/* @__PURE__ */new Error("Authentication was cancelled"))}else console.warn("Organization ID mismatch:",l,"expected:",t)},h=setInterval(()=>{try{c.closed&&(u(),o(/* @__PURE__ */new Error("Authentication was cancelled")))}catch(e){}},1e3);window.addEventListener("message",l);const d=setTimeout(()=>{u(),c.closed||c.close(),o(/* @__PURE__ */new Error("Authentication timeout. Please try again."))},3e5)}))(e,c??"","https://beta.qratilabs.com");return t?.user&&t?.token&&(y({...t.user,token:t.token}),localStorage.setItem("qrati_token",t.token)),t},[c]),O=a(async()=>S("google"),[S]),A=a(async()=>S("apple"),[S]),I=a(async e=>{try{const t=await lt.post(mt.SEND_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase()},headers:{"x-org-id":c}}).json();return t.error?{error:t.error}:t}catch(b){return{error:await tr(b,"Failed to send password reset code")}}},[c]),C=a(async(e,t)=>{try{const r=await lt.post(mt.VERIFY_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase(),code:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(b){return{error:await tr(b,"Invalid code, please check your email")}}},[c]),P=a(async(e,t)=>{try{const r=await lt.post(mt.RESET_PASSWORD,{json:{passwordResetCodeId:e,newPassword:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(b){return{error:b?.message}}},[c]),D=a(async()=>{try{const e=await lt.post(mt.LOGOUT,{headers:{"x-org-id":c,Authorization:`Bearer ${m?.token}`}}).json();return e.error?{error:e.error}:(y(null),localStorage.removeItem("qrati_token"),e)}catch(b){return{error:b?.message}}},[c,m?.token]),N=s(()=>({props:e,initializing:g,sessionId:w?.sessionId,organization:w?.organization,folders:w?.folders,orgRole:w?.orgRole??null,loadingUser:g,user:m,updateUser:R,registerUsingEmail:E,loginWithGoogle:O,loginWithApple:A,loginUsingEmail:T,sendPasswordResetCode:I,verifyPasswordResetCode:C,resetPassword:P,signout:D,error:b,portalContainer:f}),[e,g,w,m,R,E,O,A,T,I,C,P,D,b,f]);if(b){const e=b,t=401===e?.response?.status?"page-not-registered":e?.response?"generic-error":"service-unavailable";/* @__PURE__ */
39
+ /* @__PURE__ */i(Mt,{organizationId:e})," for details or contact Qrati support."]})}var jt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Ht=e=>e.trim().replace(/\s+/g," "),Gt=e=>e?.replace(/\/+$/,"")||"",Qt=e=>{if(!e)return jt;const t=Ht("string"==typeof e?e:e.fontFamily||""),r="string"==typeof e?void 0:e.customFontName;return t&&"system"!==t?"custom"===t?`"${r||"QratiCustomFont"}", ${jt}`:`"${t}", ${jt}`:"inherit"};function Vt(e){var t,r,s="";if("string"==typeof e||"number"==typeof e)s+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=Vt(e[t]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}function Bt(){for(var e,t,r=0,s="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Vt(e))&&(s&&(s+=" "),s+=t);return s}var zt=(...e)=>Bt(e.filter(Boolean)),Wt=e=>{const t=e.replace(/#/g,"");return(299*parseInt(t.slice(0,2),16)+587*parseInt(t.slice(2,4),16)+114*parseInt(t.slice(4,6),16))/1e3>=128?"#000000":"#FFFFFF"},Zt="px",Kt=(e,t="light")=>{const r=e?.themeSettings?.colors??{},s=e?.themeSettings?.border,o=e?.themeSettings?.shadow,n=e?.integrationSettings,i="dark"===t,a=(e,t,s,o)=>{const n=i?o:s;return r[i?t:e]||n},c=a("primaryLight","primaryDark","#ff4800","#ff4800");return{"--background":a("backgroundLight","backgroundDark","#fafafa","#0a0a0a"),"--foreground":a("foregroundLight","foregroundDark","#252629","#f5f5f5"),"--muted":a("mutedLight","mutedDark","#e5e5e5","#171717"),"--muted-foreground":a("mutedForegroundLight","mutedForegroundDark","#484848","#b5b8bb"),"--border":a("borderLight","borderDark","#dddddd","#353538"),"--input":a("inputLight","inputDark","#f5f5f5","#171717"),"--primary":c,"--primary-foreground":Wt(c),"--popover":a("popoverLight","popoverDark","#f5f5f5","#171717"),"--popover-foreground":a("popoverForegroundLight","popoverForegroundDark","#252629","#fafafa"),"--info":a("infoLight","infoDark","#2563eb","#5b8def"),"--warning":a("warningLight","warningDark","#f59e0b","#fbbf24"),"--success":a("successLight","successDark","#10b981","#34d399"),"--destructive":a("destructiveLight","destructiveDark","#ef4444","#f87171"),"--border-width":`${s?.width??"1"}${s?.unit??"px"}`,"--radius":`${s?.radius??"10"}${s?.unit??"px"}`,"--shadow-outer-horizontal-offset":`${o?.outerHorizontalOffset??"0"}${o?.unit??Zt}`,"--shadow-outer-vertical-offset":`${o?.outerVerticalOffset??"0"}${o?.unit??Zt}`,"--shadow-outer-blur":`${o?.outerBlur??"0"}${o?.unit??Zt}`,"--shadow-outer-spread":`${o?.outerSpread??"0"}${o?.unit??Zt}`,...n?.fontFamily&&"system"!==n.fontFamily?{"--font-family":Qt(n)}:{}}},Jt=async e=>{try{return await e()}catch{return null}},Yt=(e,t=1)=>{const r=(new TextEncoder).encode(e),s=3432918353,o=461845907;let n=t>>>0;const i=Math.floor(r.length/4),a=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let h=0;h<i;h++){let e=a.getUint32(4*h,!0);e=Math.imul(e,s),e=e<<15|e>>>17,e=Math.imul(e,o),n^=e,n=n<<13|n>>>19,n=Math.imul(n,5)+3864292196>>>0}let c=0;const u=4*i,l=3&r.length;return 3===l&&(c^=r[u+2]<<16),l>=2&&(c^=r[u+1]<<8),l>=1&&(c^=r[u],c=Math.imul(c,s),c=c<<15|c>>>17,c=Math.imul(c,o),n^=c),n^=r.length,n^=n>>>16,n=Math.imul(n,2246822507)>>>0,n^=n>>>13,n=Math.imul(n,3266489909)>>>0,n^=n>>>16,n.toString(16).padStart(8,"0")},Xt=e=>{if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Xt).join(",")}]`;const t=Object.keys(e).sort(),r=[];for(const s of t){const t=e[s];void 0!==t&&r.push(`${Xt(s)}:${Xt(t)}`)}return`{${r.join(",")}}`},er=async({debug:e=!1}={})=>{const t=performance.now(),r=await Jt(async()=>window.navigator.userAgentData&&"function"==typeof window.navigator.userAgentData.getHighEntropyValues?Xt(await window.navigator.userAgentData.getHighEntropyValues(["architecture","bitness","platformVersion","model","fullVersionList"])):null),s=await Jt(()=>(()=>{const e=document.createElement("video"),t=["video/webm","video/mp4","video/ogg","audio/mp4","audio/webm","audio/ogg","audio/mpeg"],r={};for(const s of t){const t=e.canPlayType(s);r[s]=""===t?"no":t}return Xt(r)})()),o=await Jt(()=>(()=>{const e=["monospace","serif","sans-serif"],t=["Arial","Helvetica","Verdana","Trebuchet MS","Comic Sans MS","Georgia","Times New Roman","Courier New","Segoe UI","Roboto","Open Sans","Noto Sans","system-ui","-apple-system","BlinkMacSystemFont"],r=document.createElement("span");r.style.fontSize="72px",r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="nowrap",r.textContent="mmmmmmmmmwwwwwww",document.body.appendChild(r);const s={};for(const n of e)r.style.fontFamily=n,s[n]=r.offsetWidth;const o=[];for(const n of t){let t=!1;for(const i of e)if(r.style.fontFamily=`"${n}", ${i}`,r.offsetWidth!==s[i]){o.push(n),t=!0;break}t||(r.style.fontFamily=`"${n}"`,r.offsetWidth!==s.monospace&&r.offsetWidth!==s.serif&&o.push(n))}return document.body.removeChild(r),o.length?o.sort().join(","):null})()),n=await Jt(()=>new Intl.NumberFormat(window.navigator.languages?.[0]||"en").resolvedOptions().numberingSystem),i=window.navigator.languages?Array.from(window.navigator.languages).join(","):window.navigator.language||null,a=Intl.DateTimeFormat().resolvedOptions(),c=a.timeZone,u=/* @__PURE__ */(new Date).getTimezoneOffset(),l=a.calendar||null,h=void 0!==a.hour12?a.hour12?"h12":"h23":a.hourCycle||null,d=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"reduce":"no-preference",f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",p=window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":window.matchMedia("(prefers-contrast: custom)").matches?"custom":"no-preference",m=window.matchMedia("(prefers-reduced-transparency: reduce)").matches?"reduce":"no-preference",y=window.matchMedia("(forced-colors: active)").matches?"active":null,g="number"==typeof window.devicePixelRatio?Math.round(100*window.devicePixelRatio)/100:null,{pixelDepth:w,colorDepth:b}=window.screen,v="ontouchstart"in window||window.navigator.maxTouchPoints>0,R=await Jt(()=>(async e=>{const t=document.createElement("canvas");t.width=280,t.height=100;const r=t.getContext("2d"),s=r.createLinearGradient(0,0,280,100);return s.addColorStop(0,"#f60"),s.addColorStop(.4,"#09f"),s.addColorStop(.7,"#f09"),s.addColorStop(1,"#0f9"),r.fillStyle=s,r.fillRect(0,0,280,100),r.font='18px "Arial","Helvetica","DejaVu Sans",sans-serif',r.fillStyle="#000",r.textBaseline="alphabetic",r.fillText("Fingerprint ¼½¾™©®∆π∑€¶§",12,45),r.font='bold 22px "Georgia","Times New Roman",serif',r.fillStyle="#222",r.fillText("🦊🐱🚀 2026",12,78),r.globalAlpha=.7,r.fillStyle="rgba(255, 80, 0, 0.35)",r.fillRect(180,20,80,60),r.beginPath(),r.arc(220,50,32,0,2*Math.PI),r.strokeStyle="#fff",r.lineWidth=4,r.stroke(),r.beginPath(),r.moveTo(30,85),r.quadraticCurveTo(140,20,240,85),r.strokeStyle="#00f",r.lineWidth=3,r.stroke(),e&&(t.style.border="1px solid #444",document.body.appendChild(t)),Yt(t.toDataURL("image/png"))})(e)),E=await Jt(()=>(async()=>{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl"),r=t.getExtension("WEBGL_debug_renderer_info");return Yt(Xt({vendor:r?t.getParameter(r.UNMASKED_VENDOR_WEBGL):t.getParameter(t.VENDOR),renderer:r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER)}))})()),T=await Jt(()=>(async e=>{const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),r={vendor:t.info?.vendor??"",architecture:t.info?.architecture??"",description:t.info?.description??"",features:Array.from(t.features).sort(),limits:Array.from(t.limits).sort()};if(e){const e=document.createElement("pre");e.style.margin="10px 0",e.style.padding="10px",e.style.border="1px solid #444",e.style.background="#111",e.style.color="#0f8",e.style.fontFamily="monospace",e.textContent=`WebGPU:\n${JSON.stringify(r,null,2)}`,document.body.appendChild(e)}return Yt(Xt(r))})(e)),S=await Jt(()=>(async e=>{const t=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,6e3,44100),r=t.createOscillator();r.type="sawtooth",r.frequency.value=8800;const s=t.createDynamicsCompressor();s.threshold.value=-48,s.knee.value=30,s.ratio.value=14,s.attack.value=0,s.release.value=.3;const o=t.createGain();o.gain.value=.4,r.connect(s),s.connect(o),o.connect(t.destination),r.start(0);const n=(await t.startRendering()).getChannelData(0);let i=0,a=0;for(let u=3e3;u<5800;u+=2){const e=n[u];i=31*i+Math.floor(1e5*(e+1))|0,a=Math.imul(a^Math.floor(98765*e),2246822519)}const c=i>>>0^a>>>0;if(e){const e=document.createElement("canvas");e.width=500,e.height=120,e.style.border="1px solid #444",e.style.margin="10px 0",e.title="Audio buffer snippet (4500–5000 samples)";const t=e.getContext("2d");t.fillStyle="#111",t.fillRect(0,0,e.width,e.height),t.font="14px monospace",t.fillStyle="#0f8",t.textAlign="left",t.fillText("AudioID",10,20),t.strokeStyle="#0f8",t.lineWidth=1.5,t.beginPath();const r=Array.from(n.slice(4500,5e3)),s=e.width/r.length;for(let o=0;o<r.length;o++){const n=o*s,i=(r[o]+1)/2*e.height;0===o?t.moveTo(n,i):t.lineTo(n,i)}t.stroke(),document.body.appendChild(e)}return Yt(c.toString(16))})(e)),O=window.screen.width&&window.screen.height?(window.screen.width/window.screen.height).toFixed(4):null,A=await Jt(()=>window.screen.orientation?.type||null),I=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection,C=I&&I.type||null,P=I?.effectiveType||null,N=!0===I?.saveData,D="boolean"==typeof window.navigator.pdfViewerEnabled?window.navigator.pdfViewerEnabled:null,q="boolean"==typeof window.navigator.webdriver?window.navigator.webdriver:null,_=await Jt(()=>"function"!=typeof Intl.supportedValuesOf?null:Intl.supportedValuesOf("calendar").join(",")),L=await Jt(async()=>{if(!window.navigator.permissions||"function"!=typeof window.navigator.permissions.query)return null;const e=["geolocation","notifications"],t={};for(const r of e)try{t[r]=(await window.navigator.permissions.query({name:r})).state}catch{t[r]="unsupported"}return Xt(t)}),x={vendor:window.navigator.vendor||null,platform:window.navigator.platform||null,userAgentHighEntropy:r||null,mediaCodecs:s||null,fonts:o,numberingSystem:n,languages:i,timezone:c,timezoneOffset:u,intlCalendar:l,hourCycle:h,reducedMotion:d,colorScheme:f,prefersContrast:p,prefersReducedTransparency:m,pdfViewerEnabled:D,webdriver:q,intlSupportedCalendars:_||null,permissionsState:L||null,hardwareConcurrency:window.navigator.hardwareConcurrency||null,deviceMemory:window.navigator.deviceMemory||null,forcedColors:y,devicePixelRatio:g,pixelDepth:w,colorDepth:b,touchSupport:v,screenOrientation:A||null,connectionType:C,effectiveType:P,saveData:N,canvasID:R,webglID:E,webgpuID:T,audioID:S},k={aspectRatio:O,width:window.screen.width,height:window.screen.height,maxTouchPoints:window.navigator.maxTouchPoints};(!0===navigator.userAgentData?.mobile||/Mobi|Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||navigator.maxTouchPoints>0&&matchMedia("(pointer:coarse)").matches&&innerWidth<=1024)&&Object.assign(x,k);const F=Yt(Xt(x)),U=Math.round(performance.now()-t);return{fingerprint:F,...x,elapsedMs:U}};"undefined"!=typeof window&&(window.getBrowserFingerprint=er);var tr=async(e,t)=>{if(e instanceof ye){try{const t=e.data;if(t?.error)return t.error;if(t?.message)return t.message;if("INVALID_EMAIL_OR_PASSWORD"===t?.code)return"Invalid email or password"}catch{return t||e.message}return t||e.message}return e instanceof Error?t||e.message:t||String(e)},rr=e(void 0),sr=({props:e={},children:o})=>{const{organizationId:c,uid:u,fname:l,lname:h,theme:d="light"}=e,f=ce(),[p,m]=r(null),[y,g]=r(()=>{if("undefined"==typeof window)return null;const e=localStorage.getItem("qrati_token");return e?{token:e}:null}),{isLoading:w,data:b,error:v}=pe({queryKey:[Ft.QRATI_CONNECT_SESSION,c,u??null,l??null,h??null],queryFn:async()=>{const e=await(async()=>{const e=await er();return"string"==typeof e?e:e?.fingerprint})();try{return(await lt.post(mt.INITIALIZE_SESSION,{json:{uid:u,fname:l,lname:h,browserFingerprint:e},headers:{"x-org-id":c,...!y?.token||u||l||h?{}:{Authorization:`Bearer ${y.token}`}}}).json()).data}catch(t){if(t instanceof ye)try{const e=t.data;t.apiMessage=e?.message||e?.error}catch{}throw t}},enabled:!!c});t(()=>{const e=b?.authSession?.session?.token??b?.authSession?.token,t=b?.authSession?.user;t&&e?(g(r=>({...r,...t,token:e,tcAccepted:void 0===t.tcAccepted?r?.tcAccepted:t.tcAccepted})),localStorage.setItem("qrati_token",e)):b?.organization?.customAuth&&u&&l&&g(e=>e??{_id:u,uid:u,name:h?`${l} ${h}`:l,fname:l,lname:h})},[b]);const R=s(()=>{const e=b?.organization?.integrationSettings?.fontFamily,t=((e,t)=>{const r=Gt("https://beta.qratilabs.com"),s=t?Ht(t):"";return r&&s?`${r}/api/connect/organization/google-font?family=${encodeURIComponent(s)}`:null})(0,e),r=((e,t)=>{const r=Gt("https://beta.qratilabs.com");return r&&t?`${r}/api/connect/organization/custom-font?organizationId=${encodeURIComponent(t)}`:null})(0,c);return((e,t,r)=>{if(!e?.fontFamily||"system"===e.fontFamily)return"";const s=Ht(e.fontFamily);if("custom"===s&&t){const r=e.customFontName||"QratiCustomFont",s=/\.woff2(\?|$)/i.test(t)?"woff2":/\.ttf(\?|$)/i.test(t)?"truetype":"woff";return`@font-face{font-family:"${o=r,o.replace(/"/g,'\\"')}";src:url("${t}") format("${s}");font-weight:400 700;font-style:normal;font-display:swap;}`}var o;const n=r||(e=>{if(!e)return null;const t=Ht(e);return t&&"system"!==t.toLowerCase()&&"custom"!==t.toLowerCase()?`https://fonts.googleapis.com/css2?family=${t.replace(/\s+/g,"+")}:wght@400;500;600;700&display=swap`:null})(s);return n?`@import url("${n}");`:""})(b?.organization?.integrationSettings,b?.organization?.customFontUrl?r||b.organization.customFontUrl:void 0,t||void 0)},[b?.organization?.integrationSettings,b?.organization?.customFontUrl,c]);t(()=>{const e=`data-qrati-font-${c}`;if(document.head.querySelector(`[${e}]`)?.remove(),R){if(R.startsWith("@import")){const t=R.match(/@import url\("([^"]+)"\)/);if(!t?.[1])return;const r=document.createElement("link");r.rel="stylesheet",r.href=t[1],r.setAttribute(e,""),document.head.appendChild(r)}else{const t=document.createElement("style");t.textContent=R,t.setAttribute(e,""),document.head.appendChild(t)}return()=>{document.head.querySelector(`[${e}]`)?.remove()}}},[R,c]);const E=a(async e=>{g(t=>({...t,...e}))},[]),T=a(async(e,t,r,s)=>{try{const o=await lt.post(mt.REGISTER,{json:{email:e,password:t,fname:r,lname:s},headers:{"x-org-id":c}}).json();return o.error?{error:o.error}:(g({...o.user,token:o.token}),o.token&&localStorage.setItem("qrati_token",o.token),o)}catch(v){return{error:await tr(v,"Registration failed")}}},[c]),S=a(async(e,t)=>{try{const r=await lt.post(mt.LOGIN,{json:{email:e,password:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:(g({...r.user,token:r.token}),r.token&&localStorage.setItem("qrati_token",r.token),r)}catch(v){return{error:await tr(v,"Invalid email or password")}}},[c]),O=a(async e=>{const t=await((e,t,r)=>new Promise((s,o)=>{if(!e)return void o(/* @__PURE__ */new Error("Provider is required"));if(!t)return void o(/* @__PURE__ */new Error("Organization ID is required"));const n=new URL(`${r}/qc-social-auth`);n.searchParams.set("provider",e),n.searchParams.set("organizationId",t),n.searchParams.set("origin",window.location.origin);const i=(window.screen.width-500)/2,a=(window.screen.height-600)/2,c=window.open(n.toString(),"qrati_social_auth",`width=500,height=600,left=${i},top=${a},scrollbars=yes,resizable=yes,status=yes`);if(!c)return void o(/* @__PURE__ */new Error("Failed to open popup window. Please allow popups and try again."));const u=()=>{clearInterval(h),clearTimeout(d),window.removeEventListener("message",l)},l=e=>{try{const t=new URL(r).origin;if(e.origin!==t)return void console.warn("Origin mismatch:",e.origin,"expected:",t)}catch(h){console.warn("Could not parse origin for verification")}const{type:n,data:i,error:a,organizationId:l}=e.data||{};if(l===t)switch(n){case"QRATI_SOCIAL_AUTH_SUCCESS":u(),c.close(),s({user:i.user,session:i.session,token:i.token});break;case"QRATI_SOCIAL_AUTH_ERROR":console.error("Authentication error:",a),u(),c.close(),o(new Error(a||"Social authentication failed"));break;case"QRATI_SOCIAL_AUTH_CANCELLED":u(),c.close(),o(/* @__PURE__ */new Error("Authentication was cancelled"))}else console.warn("Organization ID mismatch:",l,"expected:",t)},h=setInterval(()=>{try{c.closed&&(u(),o(/* @__PURE__ */new Error("Authentication was cancelled")))}catch(e){}},1e3);window.addEventListener("message",l);const d=setTimeout(()=>{u(),c.closed||c.close(),o(/* @__PURE__ */new Error("Authentication timeout. Please try again."))},3e5)}))(e,c??"","https://beta.qratilabs.com");return t?.user&&t?.token&&(g({...t.user,token:t.token}),localStorage.setItem("qrati_token",t.token)),t},[c]),A=a(async()=>O("google"),[O]),I=a(async()=>O("apple"),[O]),C=a(async e=>{try{const t=await lt.post(mt.SEND_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase()},headers:{"x-org-id":c}}).json();return t.error?{error:t.error}:t}catch(v){return{error:await tr(v,"Failed to send password reset code")}}},[c]),P=a(async(e,t)=>{try{const r=await lt.post(mt.VERIFY_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase(),code:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(v){return{error:await tr(v,"Invalid code, please check your email")}}},[c]),N=a(async(e,t)=>{try{const r=await lt.post(mt.RESET_PASSWORD,{json:{passwordResetCodeId:e,newPassword:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(v){return{error:v?.message}}},[c]),D=a(async()=>{try{const e=await lt.post(mt.LOGOUT,{headers:{"x-org-id":c,Authorization:`Bearer ${y?.token}`}}).json();return e.error?{error:e.error}:(g(null),localStorage.removeItem("qrati_token"),await f.invalidateQueries({queryKey:[Ft.QRATI_CONNECT_SESSION]}),e)}catch(v){return{error:v?.message}}},[c,y?.token]),q=s(()=>({props:e,initializing:w,sessionId:b?.sessionId,organization:b?.organization,folders:b?.folders,orgRole:b?.orgRole??null,loadingUser:w,user:y,updateUser:E,registerUsingEmail:T,loginWithGoogle:A,loginWithApple:I,loginUsingEmail:S,sendPasswordResetCode:C,verifyPasswordResetCode:P,resetPassword:N,signout:D,error:v,portalContainer:p}),[e,w,b,y,E,T,A,I,S,C,P,N,D,v,p]);if(v){const e=v,t=401===e?.response?.status?"page-not-registered":e?.response?"generic-error":"service-unavailable";/* @__PURE__ */
40
40
  return i(n,{fallback:null,children:/* @__PURE__ */i($t,{organizationId:c??"",errorType:t,errorMessage:"generic-error"===t?e.apiMessage:void 0})})}/* @__PURE__ */
41
- return i(rr.Provider,{value:N,children:/* @__PURE__ */i("div",{ref:p,id:"qrati-connect-container",style:{...Kt(w?.organization,d),fontFamily:w?.organization?.integrationSettings?.fontFamily&&"system"!==w.organization.integrationSettings.fontFamily?"var(--font-family)":"inherit"},className:zt("bg-background text-foreground relative min-h-[80vh]"),children:o})})},or=()=>{const e=c(rr);if(void 0===e)throw new Error("useSession must be used within SessionProvider");return e};export{d as $,St as A,K as B,wt as C,ht as D,Et as E,fe as F,M as G,B as H,ue as I,f as J,F as K,ce as L,qt as M,lt as N,Ft as O,pe as P,w as Q,re as R,bt as S,Rt as T,Q as U,J as V,$ as W,v as X,R as Y,b as Z,_t as _,Kt as a,ft as b,kt as c,It as d,E as et,Ct as f,Dt as g,At as h,zt as i,q as it,Nt as j,Lt as k,xt as l,gt as m,or as n,O as nt,Bt as o,vt as p,k as q,er as r,L as rt,yt as s,sr as t,y as tt,mt as u,Ot as v,Pt as w,dt as x,Tt as y,Y as z};
41
+ return i(rr.Provider,{value:q,children:/* @__PURE__ */i("div",{ref:m,id:"qrati-connect-container",style:{...Kt(b?.organization,d),fontFamily:b?.organization?.integrationSettings?.fontFamily&&"system"!==b.organization.integrationSettings.fontFamily?"var(--font-family)":"inherit"},className:zt("bg-background text-foreground relative min-h-[80vh]"),children:o})})},or=()=>{const e=c(rr);if(void 0===e)throw new Error("useSession must be used within SessionProvider");return e};export{d as $,St as A,K as B,wt as C,ht as D,Et as E,fe as F,M as G,B as H,ue as I,f as J,F as K,ce as L,qt as M,lt as N,Ft as O,pe as P,w as Q,re as R,bt as S,Rt as T,V as U,J as V,$ as W,v as X,R as Y,b as Z,_t as _,Kt as a,ft as b,kt as c,It as d,E as et,Ct as f,Nt as g,At as h,zt as i,q as it,Dt as j,Lt as k,xt as l,gt as m,or as n,O as nt,Bt as o,vt as p,k as q,er as r,L as rt,yt as s,sr as t,y as tt,mt as u,Ot as v,Pt as w,dt as x,Tt as y,Y as z};