diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..96b839a --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,20 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-explicit-any': 'warn', + }, +} \ No newline at end of file diff --git a/dist/assets/index-RpkfYM5z.js b/dist/assets/index-D3cSeV7q.js similarity index 86% rename from dist/assets/index-RpkfYM5z.js rename to dist/assets/index-D3cSeV7q.js index 66e4fe2..96bb1ba 100644 --- a/dist/assets/index-RpkfYM5z.js +++ b/dist/assets/index-D3cSeV7q.js @@ -1,4 +1,4 @@ -var Bc=t=>{throw TypeError(t)};var ja=(t,e,r)=>e.has(t)||Bc("Cannot "+r);var y=(t,e,r)=>(ja(t,e,"read from private field"),r?r.call(t):e.get(t)),U=(t,e,r)=>e.has(t)?Bc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),I=(t,e,r,n)=>(ja(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),W=(t,e,r)=>(ja(t,e,"access private method"),r);var Ai=(t,e,r,n)=>({set _(s){I(t,e,s,r)},get _(){return y(t,e,n)}});function cg(t,e){for(var r=0;rn[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function r(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();var mt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function dg(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var Qh={exports:{}},Jo={},Kh={exports:{}},K={};/** +var Bc=t=>{throw TypeError(t)};var ja=(t,e,r)=>e.has(t)||Bc("Cannot "+r);var y=(t,e,r)=>(ja(t,e,"read from private field"),r?r.call(t):e.get(t)),U=(t,e,r)=>e.has(t)?Bc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),I=(t,e,r,n)=>(ja(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),W=(t,e,r)=>(ja(t,e,"access private method"),r);var Ai=(t,e,r,n)=>({set _(s){I(t,e,s,r)},get _(){return y(t,e,n)}});function cg(t,e){for(var r=0;rn[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function r(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();var mt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function dg(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var Qh={exports:{}},Jo={},Kh={exports:{}},V={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var Bc=t=>{throw TypeError(t)};var ja=(t,e,r)=>e.has(t)||Bc("Cannot "+r);var y=( * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ei=Symbol.for("react.element"),hg=Symbol.for("react.portal"),fg=Symbol.for("react.fragment"),pg=Symbol.for("react.strict_mode"),mg=Symbol.for("react.profiler"),gg=Symbol.for("react.provider"),vg=Symbol.for("react.context"),yg=Symbol.for("react.forward_ref"),wg=Symbol.for("react.suspense"),xg=Symbol.for("react.memo"),_g=Symbol.for("react.lazy"),Wc=Symbol.iterator;function bg(t){return t===null||typeof t!="object"?null:(t=Wc&&t[Wc]||t["@@iterator"],typeof t=="function"?t:null)}var Vh={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Gh=Object.assign,Jh={};function xs(t,e,r){this.props=t,this.context=e,this.refs=Jh,this.updater=r||Vh}xs.prototype.isReactComponent={};xs.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};xs.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Yh(){}Yh.prototype=xs.prototype;function Tu(t,e,r){this.props=t,this.context=e,this.refs=Jh,this.updater=r||Vh}var Ou=Tu.prototype=new Yh;Ou.constructor=Tu;Gh(Ou,xs.prototype);Ou.isPureReactComponent=!0;var Hc=Array.isArray,Xh=Object.prototype.hasOwnProperty,Ru={current:null},Zh={key:!0,ref:!0,__self:!0,__source:!0};function ef(t,e,r){var n,s={},i=null,o=null;if(e!=null)for(n in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(i=""+e.key),e)Xh.call(e,n)&&!Zh.hasOwnProperty(n)&&(s[n]=e[n]);var a=arguments.length-2;if(a===1)s.children=r;else if(1{throw TypeError(t)};var ja=(t,e,r)=>e.has(t)||Bc("Cannot "+r);var y=( * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(t){function e(L,R){var D=L.length;L.push(R);e:for(;0>>1,M=L[ie];if(0>>1;ies(ke,D))qes(re,ke)?(L[ie]=re,L[qe]=D,ie=qe):(L[ie]=ke,L[Y]=D,ie=Y);else if(qes(re,D))L[ie]=re,L[qe]=D,ie=qe;else break e}}return R}function s(L,R){var D=L.sortIndex-R.sortIndex;return D!==0?D:L.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],u=[],c=1,d=null,m=3,f=!1,_=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(L){for(var R=r(u);R!==null;){if(R.callback===null)n(u);else if(R.startTime<=L)n(u),R.sortIndex=R.expirationTime,e(l,R);else break;R=r(u)}}function w(L){if(x=!1,p(L),!_)if(r(l)!==null)_=!0,$e(k);else{var R=r(u);R!==null&&Pe(w,R.startTime-L)}}function k(L,R){_=!1,x&&(x=!1,v(T),T=-1),f=!0;var D=m;try{for(p(R),d=r(l);d!==null&&(!(d.expirationTime>R)||L&&!F());){var ie=d.callback;if(typeof ie=="function"){d.callback=null,m=d.priorityLevel;var M=ie(d.expirationTime<=R);R=t.unstable_now(),typeof M=="function"?d.callback=M:d===r(l)&&n(l),p(R)}else n(l);d=r(l)}if(d!==null)var X=!0;else{var Y=r(u);Y!==null&&Pe(w,Y.startTime-R),X=!1}return X}finally{d=null,m=D,f=!1}}var S=!1,j=null,T=-1,P=5,E=-1;function F(){return!(t.unstable_now()-EL||125ie?(L.sortIndex=D,e(u,L),r(l)===null&&L===r(u)&&(x?(v(T),T=-1):x=!0,Pe(w,D-ie))):(L.sortIndex=M,e(l,L),_||f||(_=!0,$e(k))),L},t.unstable_shouldYield=F,t.unstable_wrapCallback=function(L){var R=m;return function(){var D=m;m=R;try{return L.apply(this,arguments)}finally{m=D}}}})(of);sf.exports=of;var Lg=sf.exports;/** + */(function(t){function e(L,R){var D=L.length;L.push(R);e:for(;0>>1,F=L[ie];if(0>>1;ies(ke,D))qes(re,ke)?(L[ie]=re,L[qe]=D,ie=qe):(L[ie]=ke,L[Y]=D,ie=Y);else if(qes(re,D))L[ie]=re,L[qe]=D,ie=qe;else break e}}return R}function s(L,R){var D=L.sortIndex-R.sortIndex;return D!==0?D:L.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],u=[],c=1,d=null,m=3,f=!1,_=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(L){for(var R=r(u);R!==null;){if(R.callback===null)n(u);else if(R.startTime<=L)n(u),R.sortIndex=R.expirationTime,e(l,R);else break;R=r(u)}}function w(L){if(x=!1,p(L),!_)if(r(l)!==null)_=!0,$e(k);else{var R=r(u);R!==null&&Pe(w,R.startTime-L)}}function k(L,R){_=!1,x&&(x=!1,v(T),T=-1),f=!0;var D=m;try{for(p(R),d=r(l);d!==null&&(!(d.expirationTime>R)||L&&!M());){var ie=d.callback;if(typeof ie=="function"){d.callback=null,m=d.priorityLevel;var F=ie(d.expirationTime<=R);R=t.unstable_now(),typeof F=="function"?d.callback=F:d===r(l)&&n(l),p(R)}else n(l);d=r(l)}if(d!==null)var X=!0;else{var Y=r(u);Y!==null&&Pe(w,Y.startTime-R),X=!1}return X}finally{d=null,m=D,f=!1}}var S=!1,j=null,T=-1,P=5,E=-1;function M(){return!(t.unstable_now()-EL||125ie?(L.sortIndex=D,e(u,L),r(l)===null&&L===r(u)&&(x?(v(T),T=-1):x=!0,Pe(w,D-ie))):(L.sortIndex=F,e(l,L),_||f||(_=!0,$e(k))),L},t.unstable_shouldYield=M,t.unstable_wrapCallback=function(L){var R=m;return function(){var D=m;m=R;try{return L.apply(this,arguments)}finally{m=D}}}})(of);sf.exports=of;var Lg=sf.exports;/** * @license React * react-dom.production.min.js * @@ -35,9 +35,9 @@ var Bc=t=>{throw TypeError(t)};var ja=(t,e,r)=>e.has(t)||Bc("Cannot "+r);var y=( `),i=n.stack.split(` `),o=s.length-1,a=i.length-1;1<=o&&0<=a&&s[o]!==i[a];)a--;for(;1<=o&&0<=a;o--,a--)if(s[o]!==i[a]){if(o!==1||a!==1)do if(o--,a--,0>a||s[o]!==i[a]){var l=` `+s[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ta=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?Ds(t):""}function Fg(t){switch(t.tag){case 5:return Ds(t.type);case 16:return Ds("Lazy");case 13:return Ds("Suspense");case 19:return Ds("SuspenseList");case 0:case 2:case 15:return t=Oa(t.type,!1),t;case 11:return t=Oa(t.type.render,!1),t;case 1:return t=Oa(t.type,!0),t;default:return""}}function pl(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Ln:return"Fragment";case In:return"Portal";case dl:return"Profiler";case Uu:return"StrictMode";case hl:return"Suspense";case fl:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case uf:return(t.displayName||"Context")+".Consumer";case lf:return(t._context.displayName||"Context")+".Provider";case Du:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Mu:return e=t.displayName||null,e!==null?e:pl(t.type)||"Memo";case hr:e=t._payload,t=t._init;try{return pl(t(e))}catch{}}return null}function zg(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pl(e);case 8:return e===Uu?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Dr(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function df(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Bg(t){var e=df(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var s=r.get,i=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){n=""+o,i.call(this,o)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Di(t){t._valueTracker||(t._valueTracker=Bg(t))}function hf(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=df(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function xo(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function ml(t,e){var r=e.checked;return he({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function Gc(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=Dr(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function ff(t,e){e=e.checked,e!=null&&$u(t,"checked",e,!1)}function gl(t,e){ff(t,e);var r=Dr(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?vl(t,e.type,r):e.hasOwnProperty("defaultValue")&&vl(t,e.type,Dr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Jc(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function vl(t,e,r){(e!=="number"||xo(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Ms=Array.isArray;function qn(t,e,r,n){if(t=t.options,e){e={};for(var s=0;s"+e.valueOf().toString()+"",e=Mi.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function ni(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var Hs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Wg=["Webkit","ms","Moz","O"];Object.keys(Hs).forEach(function(t){Wg.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Hs[e]=Hs[t]})});function vf(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||Hs.hasOwnProperty(t)&&Hs[t]?(""+e).trim():e+"px"}function yf(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=vf(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var Hg=he({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function xl(t,e){if(e){if(Hg[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(N(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(N(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(N(61))}if(e.style!=null&&typeof e.style!="object")throw Error(N(62))}}function _l(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var bl=null;function Fu(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Sl=null,Qn=null,Kn=null;function Zc(t){if(t=Pi(t)){if(typeof Sl!="function")throw Error(N(280));var e=t.stateNode;e&&(e=ta(e),Sl(t.stateNode,t.type,e))}}function wf(t){Qn?Kn?Kn.push(t):Kn=[t]:Qn=t}function xf(){if(Qn){var t=Qn,e=Kn;if(Kn=Qn=null,Zc(t),e)for(t=0;t>>=0,t===0?32:31-(tv(t)/rv|0)|0}var Fi=64,zi=4194304;function Fs(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ko(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,s=t.suspendedLanes,i=t.pingedLanes,o=r&268435455;if(o!==0){var a=o&~s;a!==0?n=Fs(a):(i&=o,i!==0&&(n=Fs(i)))}else o=r&~s,o!==0?n=Fs(o):i!==0&&(n=Fs(i));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0r;r++)e.push(t);return e}function Ci(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Tt(e),t[e]=r}function ov(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=Qs),ld=" ",ud=!1;function Ff(t,e){switch(t){case"keyup":return Lv.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zf(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var An=!1;function $v(t,e){switch(t){case"compositionend":return zf(e);case"keypress":return e.which!==32?null:(ud=!0,ld);case"textInput":return t=e.data,t===ld&&ud?null:t;default:return null}}function Uv(t,e){if(An)return t==="compositionend"||!Vu&&Ff(t,e)?(t=Df(),lo=qu=Cr=null,An=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=fd(r)}}function qf(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?qf(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Qf(){for(var t=window,e=xo();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=xo(t.document)}return e}function Gu(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Qv(t){var e=Qf(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&qf(r.ownerDocument.documentElement,r)){if(n!==null&&Gu(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=r.textContent.length,i=Math.min(n.start,s);n=n.end===void 0?i:Math.min(n.end,s),!t.extend&&i>n&&(s=n,n=i,i=s),s=pd(r,i);var o=pd(r,n);s&&o&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),i>n?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,$n=null,Nl=null,Vs=null,Tl=!1;function md(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Tl||$n==null||$n!==xo(n)||(n=$n,"selectionStart"in n&&Gu(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),Vs&&ui(Vs,n)||(Vs=n,n=jo(Nl,"onSelect"),0Mn||(t.current=$l[Mn],$l[Mn]=null,Mn--)}function se(t,e){Mn++,$l[Mn]=t.current,t.current=e}var Mr={},Ae=zr(Mr),Xe=zr(!1),hn=Mr;function fs(t,e){var r=t.type.contextTypes;if(!r)return Mr;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in r)s[i]=e[i];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function Ze(t){return t=t.childContextTypes,t!=null}function No(){ae(Xe),ae(Ae)}function bd(t,e,r){if(Ae.current!==Mr)throw Error(N(168));se(Ae,e),se(Xe,r)}function tp(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(N(108,zg(t)||"Unknown",s));return he({},r,n)}function To(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Mr,hn=Ae.current,se(Ae,t),se(Xe,Xe.current),!0}function Sd(t,e,r){var n=t.stateNode;if(!n)throw Error(N(169));r?(t=tp(t,e,hn),n.__reactInternalMemoizedMergedChildContext=t,ae(Xe),ae(Ae),se(Ae,t)):ae(Xe),se(Xe,r)}var Qt=null,ra=!1,qa=!1;function rp(t){Qt===null?Qt=[t]:Qt.push(t)}function sy(t){ra=!0,rp(t)}function Br(){if(!qa&&Qt!==null){qa=!0;var t=0,e=ee;try{var r=Qt;for(ee=1;t>=o,s-=o,Jt=1<<32-Tt(e)+s|r<T?(P=j,j=null):P=j.sibling;var E=m(v,j,p[T],w);if(E===null){j===null&&(j=P);break}t&&j&&E.alternate===null&&e(v,j),g=i(E,g,T),S===null?k=E:S.sibling=E,S=E,j=P}if(T===p.length)return r(v,j),ue&&Vr(v,T),k;if(j===null){for(;TT?(P=j,j=null):P=j.sibling;var F=m(v,j,E.value,w);if(F===null){j===null&&(j=P);break}t&&j&&F.alternate===null&&e(v,j),g=i(F,g,T),S===null?k=F:S.sibling=F,S=F,j=P}if(E.done)return r(v,j),ue&&Vr(v,T),k;if(j===null){for(;!E.done;T++,E=p.next())E=d(v,E.value,w),E!==null&&(g=i(E,g,T),S===null?k=E:S.sibling=E,S=E);return ue&&Vr(v,T),k}for(j=n(v,j);!E.done;T++,E=p.next())E=f(j,v,T,E.value,w),E!==null&&(t&&E.alternate!==null&&j.delete(E.key===null?T:E.key),g=i(E,g,T),S===null?k=E:S.sibling=E,S=E);return t&&j.forEach(function(J){return e(v,J)}),ue&&Vr(v,T),k}function b(v,g,p,w){if(typeof p=="object"&&p!==null&&p.type===Ln&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case Ui:e:{for(var k=p.key,S=g;S!==null;){if(S.key===k){if(k=p.type,k===Ln){if(S.tag===7){r(v,S.sibling),g=s(S,p.props.children),g.return=v,v=g;break e}}else if(S.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===hr&&Cd(k)===S.type){r(v,S.sibling),g=s(S,p.props),g.ref=Ls(v,S,p),g.return=v,v=g;break e}r(v,S);break}else e(v,S);S=S.sibling}p.type===Ln?(g=dn(p.props.children,v.mode,w,p.key),g.return=v,v=g):(w=vo(p.type,p.key,p.props,null,v.mode,w),w.ref=Ls(v,g,p),w.return=v,v=w)}return o(v);case In:e:{for(S=p.key;g!==null;){if(g.key===S)if(g.tag===4&&g.stateNode.containerInfo===p.containerInfo&&g.stateNode.implementation===p.implementation){r(v,g.sibling),g=s(g,p.children||[]),g.return=v,v=g;break e}else{r(v,g);break}else e(v,g);g=g.sibling}g=Za(p,v.mode,w),g.return=v,v=g}return o(v);case hr:return S=p._init,b(v,g,S(p._payload),w)}if(Ms(p))return _(v,g,p,w);if(Ns(p))return x(v,g,p,w);Vi(v,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,g!==null&&g.tag===6?(r(v,g.sibling),g=s(g,p),g.return=v,v=g):(r(v,g),g=Xa(p,v.mode,w),g.return=v,v=g),o(v)):r(v,g)}return b}var ms=op(!0),ap=op(!1),Io=zr(null),Lo=null,Bn=null,Zu=null;function ec(){Zu=Bn=Lo=null}function tc(t){var e=Io.current;ae(Io),t._currentValue=e}function Ml(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function Gn(t,e){Lo=t,Zu=Bn=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Ye=!0),t.firstContext=null)}function gt(t){var e=t._currentValue;if(Zu!==t)if(t={context:t,memoizedValue:e,next:null},Bn===null){if(Lo===null)throw Error(N(308));Bn=t,Lo.dependencies={lanes:0,firstContext:t}}else Bn=Bn.next=t;return e}var Zr=null;function rc(t){Zr===null?Zr=[t]:Zr.push(t)}function lp(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,rc(e)):(r.next=s.next,s.next=r),e.interleaved=r,rr(t,n)}function rr(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var fr=!1;function nc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function up(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Xt(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Ir(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,G&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,rr(t,r)}return s=n.interleaved,s===null?(e.next=e,rc(n)):(e.next=s.next,s.next=e),n.interleaved=e,rr(t,r)}function co(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Bu(t,r)}}function jd(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?s=i=o:i=i.next=o,r=r.next}while(r!==null);i===null?s=i=e:i=i.next=e}else s=i=e;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function Ao(t,e,r,n){var s=t.updateQueue;fr=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?i=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(i!==null){var d=s.baseState;o=0,c=u=l=null,a=i;do{var m=a.lane,f=a.eventTime;if((n&m)===m){c!==null&&(c=c.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var _=t,x=a;switch(m=e,f=r,x.tag){case 1:if(_=x.payload,typeof _=="function"){d=_.call(f,d,m);break e}d=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=x.payload,m=typeof _=="function"?_.call(f,d,m):_,m==null)break e;d=he({},d,m);break e;case 2:fr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,m=s.effects,m===null?s.effects=[a]:m.push(a))}else f={eventTime:f,lane:m,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=f,l=d):c=c.next=f,o|=m;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;m=a,a=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(c===null&&(l=d),s.baseState=l,s.firstBaseUpdate=u,s.lastBaseUpdate=c,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);mn|=o,t.lanes=o,t.memoizedState=d}}function Pd(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;er?r:4,t(!0);var n=Ka.transition;Ka.transition={};try{t(!1),e()}finally{ee=r,Ka.transition=n}}function Cp(){return vt().memoizedState}function ly(t,e,r){var n=Ar(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},jp(t))Pp(e,r);else if(r=lp(t,e,r,n),r!==null){var s=Be();Ot(r,t,n,s),Np(r,e,n)}}function uy(t,e,r){var n=Ar(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(jp(t))Pp(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,a=i(o,r);if(s.hasEagerState=!0,s.eagerState=a,Rt(a,o)){var l=e.interleaved;l===null?(s.next=s,rc(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}r=lp(t,e,s,n),r!==null&&(s=Be(),Ot(r,t,n,s),Np(r,e,n))}}function jp(t){var e=t.alternate;return t===de||e!==null&&e===de}function Pp(t,e){Gs=Uo=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function Np(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Bu(t,r)}}var Do={readContext:gt,useCallback:Re,useContext:Re,useEffect:Re,useImperativeHandle:Re,useInsertionEffect:Re,useLayoutEffect:Re,useMemo:Re,useReducer:Re,useRef:Re,useState:Re,useDebugValue:Re,useDeferredValue:Re,useTransition:Re,useMutableSource:Re,useSyncExternalStore:Re,useId:Re,unstable_isNewReconciler:!1},cy={readContext:gt,useCallback:function(t,e){return Lt().memoizedState=[t,e===void 0?null:e],t},useContext:gt,useEffect:Td,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,fo(4194308,4,_p.bind(null,e,t),r)},useLayoutEffect:function(t,e){return fo(4194308,4,t,e)},useInsertionEffect:function(t,e){return fo(4,2,t,e)},useMemo:function(t,e){var r=Lt();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=Lt();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=ly.bind(null,de,t),[n.memoizedState,t]},useRef:function(t){var e=Lt();return t={current:t},e.memoizedState=t},useState:Nd,useDebugValue:dc,useDeferredValue:function(t){return Lt().memoizedState=t},useTransition:function(){var t=Nd(!1),e=t[0];return t=ay.bind(null,t[1]),Lt().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=de,s=Lt();if(ue){if(r===void 0)throw Error(N(407));r=r()}else{if(r=e(),je===null)throw Error(N(349));pn&30||fp(n,e,r)}s.memoizedState=r;var i={value:r,getSnapshot:e};return s.queue=i,Td(mp.bind(null,n,i,t),[t]),n.flags|=2048,vi(9,pp.bind(null,n,i,r,e),void 0,null),r},useId:function(){var t=Lt(),e=je.identifierPrefix;if(ue){var r=Yt,n=Jt;r=(n&~(1<<32-Tt(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=mi++,0Mn||(t.current=$l[Mn],$l[Mn]=null,Mn--)}function se(t,e){Mn++,$l[Mn]=t.current,t.current=e}var Mr={},Ae=zr(Mr),Xe=zr(!1),hn=Mr;function fs(t,e){var r=t.type.contextTypes;if(!r)return Mr;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in r)s[i]=e[i];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function Ze(t){return t=t.childContextTypes,t!=null}function No(){ae(Xe),ae(Ae)}function bd(t,e,r){if(Ae.current!==Mr)throw Error(N(168));se(Ae,e),se(Xe,r)}function tp(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(N(108,zg(t)||"Unknown",s));return he({},r,n)}function To(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Mr,hn=Ae.current,se(Ae,t),se(Xe,Xe.current),!0}function Sd(t,e,r){var n=t.stateNode;if(!n)throw Error(N(169));r?(t=tp(t,e,hn),n.__reactInternalMemoizedMergedChildContext=t,ae(Xe),ae(Ae),se(Ae,t)):ae(Xe),se(Xe,r)}var Qt=null,ra=!1,qa=!1;function rp(t){Qt===null?Qt=[t]:Qt.push(t)}function sy(t){ra=!0,rp(t)}function Br(){if(!qa&&Qt!==null){qa=!0;var t=0,e=ee;try{var r=Qt;for(ee=1;t>=o,s-=o,Jt=1<<32-Tt(e)+s|r<T?(P=j,j=null):P=j.sibling;var E=m(v,j,p[T],w);if(E===null){j===null&&(j=P);break}t&&j&&E.alternate===null&&e(v,j),g=i(E,g,T),S===null?k=E:S.sibling=E,S=E,j=P}if(T===p.length)return r(v,j),ue&&Vr(v,T),k;if(j===null){for(;TT?(P=j,j=null):P=j.sibling;var M=m(v,j,E.value,w);if(M===null){j===null&&(j=P);break}t&&j&&M.alternate===null&&e(v,j),g=i(M,g,T),S===null?k=M:S.sibling=M,S=M,j=P}if(E.done)return r(v,j),ue&&Vr(v,T),k;if(j===null){for(;!E.done;T++,E=p.next())E=d(v,E.value,w),E!==null&&(g=i(E,g,T),S===null?k=E:S.sibling=E,S=E);return ue&&Vr(v,T),k}for(j=n(v,j);!E.done;T++,E=p.next())E=f(j,v,T,E.value,w),E!==null&&(t&&E.alternate!==null&&j.delete(E.key===null?T:E.key),g=i(E,g,T),S===null?k=E:S.sibling=E,S=E);return t&&j.forEach(function(q){return e(v,q)}),ue&&Vr(v,T),k}function b(v,g,p,w){if(typeof p=="object"&&p!==null&&p.type===Ln&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case Ui:e:{for(var k=p.key,S=g;S!==null;){if(S.key===k){if(k=p.type,k===Ln){if(S.tag===7){r(v,S.sibling),g=s(S,p.props.children),g.return=v,v=g;break e}}else if(S.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===hr&&Cd(k)===S.type){r(v,S.sibling),g=s(S,p.props),g.ref=Ls(v,S,p),g.return=v,v=g;break e}r(v,S);break}else e(v,S);S=S.sibling}p.type===Ln?(g=dn(p.props.children,v.mode,w,p.key),g.return=v,v=g):(w=vo(p.type,p.key,p.props,null,v.mode,w),w.ref=Ls(v,g,p),w.return=v,v=w)}return o(v);case In:e:{for(S=p.key;g!==null;){if(g.key===S)if(g.tag===4&&g.stateNode.containerInfo===p.containerInfo&&g.stateNode.implementation===p.implementation){r(v,g.sibling),g=s(g,p.children||[]),g.return=v,v=g;break e}else{r(v,g);break}else e(v,g);g=g.sibling}g=Za(p,v.mode,w),g.return=v,v=g}return o(v);case hr:return S=p._init,b(v,g,S(p._payload),w)}if(Ms(p))return _(v,g,p,w);if(Ns(p))return x(v,g,p,w);Vi(v,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,g!==null&&g.tag===6?(r(v,g.sibling),g=s(g,p),g.return=v,v=g):(r(v,g),g=Xa(p,v.mode,w),g.return=v,v=g),o(v)):r(v,g)}return b}var ms=op(!0),ap=op(!1),Io=zr(null),Lo=null,Bn=null,Zu=null;function ec(){Zu=Bn=Lo=null}function tc(t){var e=Io.current;ae(Io),t._currentValue=e}function Ml(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function Gn(t,e){Lo=t,Zu=Bn=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Ye=!0),t.firstContext=null)}function gt(t){var e=t._currentValue;if(Zu!==t)if(t={context:t,memoizedValue:e,next:null},Bn===null){if(Lo===null)throw Error(N(308));Bn=t,Lo.dependencies={lanes:0,firstContext:t}}else Bn=Bn.next=t;return e}var Zr=null;function rc(t){Zr===null?Zr=[t]:Zr.push(t)}function lp(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,rc(e)):(r.next=s.next,s.next=r),e.interleaved=r,rr(t,n)}function rr(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var fr=!1;function nc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function up(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Xt(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Ir(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,J&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,rr(t,r)}return s=n.interleaved,s===null?(e.next=e,rc(n)):(e.next=s.next,s.next=e),n.interleaved=e,rr(t,r)}function co(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Bu(t,r)}}function jd(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?s=i=o:i=i.next=o,r=r.next}while(r!==null);i===null?s=i=e:i=i.next=e}else s=i=e;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function Ao(t,e,r,n){var s=t.updateQueue;fr=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?i=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(i!==null){var d=s.baseState;o=0,c=u=l=null,a=i;do{var m=a.lane,f=a.eventTime;if((n&m)===m){c!==null&&(c=c.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var _=t,x=a;switch(m=e,f=r,x.tag){case 1:if(_=x.payload,typeof _=="function"){d=_.call(f,d,m);break e}d=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=x.payload,m=typeof _=="function"?_.call(f,d,m):_,m==null)break e;d=he({},d,m);break e;case 2:fr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,m=s.effects,m===null?s.effects=[a]:m.push(a))}else f={eventTime:f,lane:m,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=f,l=d):c=c.next=f,o|=m;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;m=a,a=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(c===null&&(l=d),s.baseState=l,s.firstBaseUpdate=u,s.lastBaseUpdate=c,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);mn|=o,t.lanes=o,t.memoizedState=d}}function Pd(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;er?r:4,t(!0);var n=Ka.transition;Ka.transition={};try{t(!1),e()}finally{ee=r,Ka.transition=n}}function Cp(){return vt().memoizedState}function ly(t,e,r){var n=Ar(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},jp(t))Pp(e,r);else if(r=lp(t,e,r,n),r!==null){var s=Be();Ot(r,t,n,s),Np(r,e,n)}}function uy(t,e,r){var n=Ar(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(jp(t))Pp(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,a=i(o,r);if(s.hasEagerState=!0,s.eagerState=a,Rt(a,o)){var l=e.interleaved;l===null?(s.next=s,rc(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}r=lp(t,e,s,n),r!==null&&(s=Be(),Ot(r,t,n,s),Np(r,e,n))}}function jp(t){var e=t.alternate;return t===de||e!==null&&e===de}function Pp(t,e){Gs=Uo=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function Np(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Bu(t,r)}}var Do={readContext:gt,useCallback:Re,useContext:Re,useEffect:Re,useImperativeHandle:Re,useInsertionEffect:Re,useLayoutEffect:Re,useMemo:Re,useReducer:Re,useRef:Re,useState:Re,useDebugValue:Re,useDeferredValue:Re,useTransition:Re,useMutableSource:Re,useSyncExternalStore:Re,useId:Re,unstable_isNewReconciler:!1},cy={readContext:gt,useCallback:function(t,e){return Lt().memoizedState=[t,e===void 0?null:e],t},useContext:gt,useEffect:Td,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,fo(4194308,4,_p.bind(null,e,t),r)},useLayoutEffect:function(t,e){return fo(4194308,4,t,e)},useInsertionEffect:function(t,e){return fo(4,2,t,e)},useMemo:function(t,e){var r=Lt();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=Lt();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=ly.bind(null,de,t),[n.memoizedState,t]},useRef:function(t){var e=Lt();return t={current:t},e.memoizedState=t},useState:Nd,useDebugValue:dc,useDeferredValue:function(t){return Lt().memoizedState=t},useTransition:function(){var t=Nd(!1),e=t[0];return t=ay.bind(null,t[1]),Lt().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=de,s=Lt();if(ue){if(r===void 0)throw Error(N(407));r=r()}else{if(r=e(),je===null)throw Error(N(349));pn&30||fp(n,e,r)}s.memoizedState=r;var i={value:r,getSnapshot:e};return s.queue=i,Td(mp.bind(null,n,i,t),[t]),n.flags|=2048,vi(9,pp.bind(null,n,i,r,e),void 0,null),r},useId:function(){var t=Lt(),e=je.identifierPrefix;if(ue){var r=Yt,n=Jt;r=(n&~(1<<32-Tt(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=mi++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=o.createElement(r,{is:n.is}):(t=o.createElement(r),r==="select"&&(o=t,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):t=o.createElementNS(t,r),t[Mt]=e,t[hi]=n,Mp(t,e,!1,!1),e.stateNode=t;e:{switch(o=_l(r,n),r){case"dialog":oe("cancel",t),oe("close",t),s=n;break;case"iframe":case"object":case"embed":oe("load",t),s=n;break;case"video":case"audio":for(s=0;sys&&(e.flags|=128,n=!0,As(i,!1),e.lanes=4194304)}else{if(!n)if(t=$o(o),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),As(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!ue)return Ie(e),null}else 2*ve()-i.renderingStartTime>ys&&r!==1073741824&&(e.flags|=128,n=!0,As(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(r=i.last,r!==null?r.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=ve(),e.sibling=null,r=ce.current,se(ce,n?r&1|2:r&1),e):(Ie(e),null);case 22:case 23:return vc(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?rt&1073741824&&(Ie(e),e.subtreeFlags&6&&(e.flags|=8192)):Ie(e),null;case 24:return null;case 25:return null}throw Error(N(156,e.tag))}function yy(t,e){switch(Yu(e),e.tag){case 1:return Ze(e.type)&&No(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return gs(),ae(Xe),ae(Ae),oc(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return ic(e),null;case 13:if(ae(ce),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(N(340));ps()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return ae(ce),null;case 4:return gs(),null;case 10:return tc(e.type._context),null;case 22:case 23:return vc(),null;case 24:return null;default:return null}}var Ji=!1,Le=!1,wy=typeof WeakSet=="function"?WeakSet:Set,A=null;function Wn(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){me(t,e,n)}else r.current=null}function Vl(t,e,r){try{r()}catch(n){me(t,e,n)}}var zd=!1;function xy(t,e){if(Ol=Eo,t=Qf(),Gu(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var s=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,m=null;t:for(;;){for(var f;d!==r||s!==0&&d.nodeType!==3||(a=o+s),d!==i||n!==0&&d.nodeType!==3||(l=o+n),d.nodeType===3&&(o+=d.nodeValue.length),(f=d.firstChild)!==null;)m=d,d=f;for(;;){if(d===t)break t;if(m===r&&++u===s&&(a=o),m===i&&++c===n&&(l=o),(f=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=f}r=a===-1||l===-1?null:{start:a,end:l}}else r=null}r=r||{start:0,end:0}}else r=null;for(Rl={focusedElem:t,selectionRange:r},Eo=!1,A=e;A!==null;)if(e=A,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,A=t;else for(;A!==null;){e=A;try{var _=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var x=_.memoizedProps,b=_.memoizedState,v=e.stateNode,g=v.getSnapshotBeforeUpdate(e.elementType===e.type?x:kt(e.type,x),b);v.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var p=e.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(w){me(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,A=t;break}A=e.return}return _=zd,zd=!1,_}function Js(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&Vl(e,r,i)}s=s.next}while(s!==n)}}function ia(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function Gl(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function Bp(t){var e=t.alternate;e!==null&&(t.alternate=null,Bp(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Mt],delete e[hi],delete e[Al],delete e[ry],delete e[ny])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Wp(t){return t.tag===5||t.tag===3||t.tag===4}function Bd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Wp(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Jl(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=Po));else if(n!==4&&(t=t.child,t!==null))for(Jl(t,e,r),t=t.sibling;t!==null;)Jl(t,e,r),t=t.sibling}function Yl(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(Yl(t,e,r),t=t.sibling;t!==null;)Yl(t,e,r),t=t.sibling}var Ne=null,jt=!1;function lr(t,e,r){for(r=r.child;r!==null;)Hp(t,e,r),r=r.sibling}function Hp(t,e,r){if(Ft&&typeof Ft.onCommitFiberUnmount=="function")try{Ft.onCommitFiberUnmount(Yo,r)}catch{}switch(r.tag){case 5:Le||Wn(r,e);case 6:var n=Ne,s=jt;Ne=null,lr(t,e,r),Ne=n,jt=s,Ne!==null&&(jt?(t=Ne,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Ne.removeChild(r.stateNode));break;case 18:Ne!==null&&(jt?(t=Ne,r=r.stateNode,t.nodeType===8?Ha(t.parentNode,r):t.nodeType===1&&Ha(t,r),ai(t)):Ha(Ne,r.stateNode));break;case 4:n=Ne,s=jt,Ne=r.stateNode.containerInfo,jt=!0,lr(t,e,r),Ne=n,jt=s;break;case 0:case 11:case 14:case 15:if(!Le&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Vl(r,e,o),s=s.next}while(s!==n)}lr(t,e,r);break;case 1:if(!Le&&(Wn(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(a){me(r,e,a)}lr(t,e,r);break;case 21:lr(t,e,r);break;case 22:r.mode&1?(Le=(n=Le)||r.memoizedState!==null,lr(t,e,r),Le=n):lr(t,e,r);break;default:lr(t,e,r)}}function Wd(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new wy),e.forEach(function(n){var s=Ny.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function _t(t,e){var r=e.deletions;if(r!==null)for(var n=0;ns&&(s=o),n&=~i}if(n=s,n=ve()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*by(n/1960))-n,10t?16:t,jr===null)var n=!1;else{if(t=jr,jr=null,zo=0,G&6)throw Error(N(331));var s=G;for(G|=4,A=t.current;A!==null;){var i=A,o=i.child;if(A.flags&16){var a=i.deletions;if(a!==null){for(var l=0;lve()-mc?cn(t,0):pc|=r),et(t,e)}function Xp(t,e){e===0&&(t.mode&1?(e=zi,zi<<=1,!(zi&130023424)&&(zi=4194304)):e=1);var r=Be();t=rr(t,e),t!==null&&(Ci(t,e,r),et(t,r))}function Py(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),Xp(t,r)}function Ny(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,s=t.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(N(314))}n!==null&&n.delete(e),Xp(t,r)}var Zp;Zp=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Xe.current)Ye=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return Ye=!1,gy(t,e,r);Ye=!!(t.flags&131072)}else Ye=!1,ue&&e.flags&1048576&&np(e,Ro,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;po(t,e),t=e.pendingProps;var s=fs(e,Ae.current);Gn(e,r),s=lc(null,e,n,t,s,r);var i=uc();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ze(n)?(i=!0,To(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,nc(e),s.updater=sa,e.stateNode=s,s._reactInternals=e,zl(e,n,t,r),e=Hl(null,e,n,!0,i,r)):(e.tag=0,ue&&i&&Ju(e),Fe(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(po(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=Oy(n),t=kt(n,t),s){case 0:e=Wl(null,e,n,t,r);break e;case 1:e=Dd(null,e,n,t,r);break e;case 11:e=$d(null,e,n,t,r);break e;case 14:e=Ud(null,e,n,kt(n.type,t),r);break e}throw Error(N(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),Wl(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),Dd(t,e,n,s,r);case 3:e:{if($p(e),t===null)throw Error(N(387));n=e.pendingProps,i=e.memoizedState,s=i.element,up(t,e),Ao(e,n,null,r);var o=e.memoizedState;if(n=o.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=vs(Error(N(423)),e),e=Md(t,e,n,r,s);break e}else if(n!==s){s=vs(Error(N(424)),e),e=Md(t,e,n,r,s);break e}else for(nt=Rr(e.stateNode.containerInfo.firstChild),st=e,ue=!0,Nt=null,r=ap(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(ps(),n===s){e=nr(t,e,r);break e}Fe(t,e,n,r)}e=e.child}return e;case 5:return cp(e),t===null&&Dl(e),n=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,o=s.children,Il(n,s)?o=null:i!==null&&Il(n,i)&&(e.flags|=32),Ap(t,e),Fe(t,e,o,r),e.child;case 6:return t===null&&Dl(e),null;case 13:return Up(t,e,r);case 4:return sc(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=ms(e,null,n,r):Fe(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),$d(t,e,n,s,r);case 7:return Fe(t,e,e.pendingProps,r),e.child;case 8:return Fe(t,e,e.pendingProps.children,r),e.child;case 12:return Fe(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,se(Io,n._currentValue),n._currentValue=o,i!==null)if(Rt(i.value,o)){if(i.children===s.children&&!Xe.current){e=nr(t,e,r);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===n){if(i.tag===1){l=Xt(-1,r&-r),l.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?l.next=l:(l.next=c.next,c.next=l),u.pending=l}}i.lanes|=r,l=i.alternate,l!==null&&(l.lanes|=r),Ml(i.return,r,e),a.lanes|=r;break}l=l.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(N(341));o.lanes|=r,a=o.alternate,a!==null&&(a.lanes|=r),Ml(o,r,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Fe(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,Gn(e,r),s=gt(s),n=n(s),e.flags|=1,Fe(t,e,n,r),e.child;case 14:return n=e.type,s=kt(n,e.pendingProps),s=kt(n.type,s),Ud(t,e,n,s,r);case 15:return Ip(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),po(t,e),e.tag=1,Ze(n)?(t=!0,To(e)):t=!1,Gn(e,r),Tp(e,n,s),zl(e,n,s,r),Hl(null,e,n,!0,t,r);case 19:return Dp(t,e,r);case 22:return Lp(t,e,r)}throw Error(N(156,e.tag))};function em(t,e){return jf(t,e)}function Ty(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ft(t,e,r,n){return new Ty(t,e,r,n)}function wc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Oy(t){if(typeof t=="function")return wc(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Du)return 11;if(t===Mu)return 14}return 2}function $r(t,e){var r=t.alternate;return r===null?(r=ft(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function vo(t,e,r,n,s,i){var o=2;if(n=t,typeof t=="function")wc(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Ln:return dn(r.children,s,i,e);case Uu:o=8,s|=8;break;case dl:return t=ft(12,r,e,s|2),t.elementType=dl,t.lanes=i,t;case hl:return t=ft(13,r,e,s),t.elementType=hl,t.lanes=i,t;case fl:return t=ft(19,r,e,s),t.elementType=fl,t.lanes=i,t;case cf:return aa(r,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case lf:o=10;break e;case uf:o=9;break e;case Du:o=11;break e;case Mu:o=14;break e;case hr:o=16,n=null;break e}throw Error(N(130,t==null?t:typeof t,""))}return e=ft(o,r,e,s),e.elementType=t,e.type=n,e.lanes=i,e}function dn(t,e,r,n){return t=ft(7,t,n,e),t.lanes=r,t}function aa(t,e,r,n){return t=ft(22,t,n,e),t.elementType=cf,t.lanes=r,t.stateNode={isHidden:!1},t}function Xa(t,e,r){return t=ft(6,t,null,e),t.lanes=r,t}function Za(t,e,r){return e=ft(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Ry(t,e,r,n,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ia(0),this.expirationTimes=Ia(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ia(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function xc(t,e,r,n,s,i,o,a,l){return t=new Ry(t,e,r,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=ft(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},nc(i),t}function Iy(t,e,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sm)}catch(t){console.error(t)}}sm(),nf.exports=ot;var im=nf.exports;const Dy=qh(im);var Yd=im;ul.createRoot=Yd.createRoot,ul.hydrateRoot=Yd.hydrateRoot;/** +`+i.stack}return{value:t,source:e,stack:s,digest:null}}function Ja(t,e,r){return{value:t,source:null,stack:r??null,digest:e??null}}function Bl(t,e){try{console.error(e.value)}catch(r){setTimeout(function(){throw r})}}var fy=typeof WeakMap=="function"?WeakMap:Map;function Op(t,e,r){r=Xt(-1,r),r.tag=3,r.payload={element:null};var n=e.value;return r.callback=function(){Fo||(Fo=!0,Xl=n),Bl(t,e)},r}function Rp(t,e,r){r=Xt(-1,r),r.tag=3;var n=t.type.getDerivedStateFromError;if(typeof n=="function"){var s=e.value;r.payload=function(){return n(s)},r.callback=function(){Bl(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){Bl(t,e),typeof n!="function"&&(Lr===null?Lr=new Set([this]):Lr.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),r}function Id(t,e,r){var n=t.pingCache;if(n===null){n=t.pingCache=new fy;var s=new Set;n.set(e,s)}else s=n.get(e),s===void 0&&(s=new Set,n.set(e,s));s.has(r)||(s.add(r),t=jy.bind(null,t,e,r),e.then(t,t))}function Ld(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function Ad(t,e,r,n,s){return t.mode&1?(t.flags|=65536,t.lanes=s,t):(t===e?t.flags|=65536:(t.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(e=Xt(-1,1),e.tag=2,Ir(r,e,1))),r.lanes|=1),t)}var py=sr.ReactCurrentOwner,Ye=!1;function Fe(t,e,r,n){e.child=t===null?ap(e,null,r,n):ms(e,t.child,r,n)}function $d(t,e,r,n,s){r=r.render;var i=e.ref;return Gn(e,s),n=lc(t,e,r,n,i,s),r=uc(),t!==null&&!Ye?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,nr(t,e,s)):(ue&&r&&Ju(e),e.flags|=1,Fe(t,e,n,s),e.child)}function Ud(t,e,r,n,s){if(t===null){var i=r.type;return typeof i=="function"&&!wc(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(e.tag=15,e.type=i,Ip(t,e,i,n,s)):(t=vo(r.type,null,n,e,e.mode,s),t.ref=e.ref,t.return=e,e.child=t)}if(i=t.child,!(t.lanes&s)){var o=i.memoizedProps;if(r=r.compare,r=r!==null?r:ui,r(o,n)&&t.ref===e.ref)return nr(t,e,s)}return e.flags|=1,t=$r(i,n),t.ref=e.ref,t.return=e,e.child=t}function Ip(t,e,r,n,s){if(t!==null){var i=t.memoizedProps;if(ui(i,n)&&t.ref===e.ref)if(Ye=!1,e.pendingProps=n=i,(t.lanes&s)!==0)t.flags&131072&&(Ye=!0);else return e.lanes=t.lanes,nr(t,e,s)}return Wl(t,e,r,n,s)}function Lp(t,e,r){var n=e.pendingProps,s=n.children,i=t!==null?t.memoizedState:null;if(n.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},se(Hn,rt),rt|=r;else{if(!(r&1073741824))return t=i!==null?i.baseLanes|r:r,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,se(Hn,rt),rt|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,se(Hn,rt),rt|=n}else i!==null?(n=i.baseLanes|r,e.memoizedState=null):n=r,se(Hn,rt),rt|=n;return Fe(t,e,s,r),e.child}function Ap(t,e){var r=e.ref;(t===null&&r!==null||t!==null&&t.ref!==r)&&(e.flags|=512,e.flags|=2097152)}function Wl(t,e,r,n,s){var i=Ze(r)?hn:Ae.current;return i=fs(e,i),Gn(e,s),r=lc(t,e,r,n,i,s),n=uc(),t!==null&&!Ye?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,nr(t,e,s)):(ue&&n&&Ju(e),e.flags|=1,Fe(t,e,r,s),e.child)}function Dd(t,e,r,n,s){if(Ze(r)){var i=!0;To(e)}else i=!1;if(Gn(e,s),e.stateNode===null)po(t,e),Tp(e,r,n),zl(e,r,n,s),n=!0;else if(t===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,u=r.contextType;typeof u=="object"&&u!==null?u=gt(u):(u=Ze(r)?hn:Ae.current,u=fs(e,u));var c=r.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==u)&&Rd(e,o,n,u),fr=!1;var m=e.memoizedState;o.state=m,Ao(e,n,o,s),l=e.memoizedState,a!==n||m!==l||Xe.current||fr?(typeof c=="function"&&(Fl(e,r,c,n),l=e.memoizedState),(a=fr||Od(e,r,a,n,m,l,u))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=n,e.memoizedState=l),o.props=n,o.state=l,o.context=u,n=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{o=e.stateNode,up(t,e),a=e.memoizedProps,u=e.type===e.elementType?a:kt(e.type,a),o.props=u,d=e.pendingProps,m=o.context,l=r.contextType,typeof l=="object"&&l!==null?l=gt(l):(l=Ze(r)?hn:Ae.current,l=fs(e,l));var f=r.getDerivedStateFromProps;(c=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||m!==l)&&Rd(e,o,n,l),fr=!1,m=e.memoizedState,o.state=m,Ao(e,n,o,s);var _=e.memoizedState;a!==d||m!==_||Xe.current||fr?(typeof f=="function"&&(Fl(e,r,f,n),_=e.memoizedState),(u=fr||Od(e,r,u,n,m,_,l)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,_,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,_,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&m===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&m===t.memoizedState||(e.flags|=1024),e.memoizedProps=n,e.memoizedState=_),o.props=n,o.state=_,o.context=l,n=u):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&m===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&m===t.memoizedState||(e.flags|=1024),n=!1)}return Hl(t,e,r,n,i,s)}function Hl(t,e,r,n,s,i){Ap(t,e);var o=(e.flags&128)!==0;if(!n&&!o)return s&&Sd(e,r,!1),nr(t,e,i);n=e.stateNode,py.current=e;var a=o&&typeof r.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,t!==null&&o?(e.child=ms(e,t.child,null,i),e.child=ms(e,null,a,i)):Fe(t,e,a,i),e.memoizedState=n.state,s&&Sd(e,r,!0),e.child}function $p(t){var e=t.stateNode;e.pendingContext?bd(t,e.pendingContext,e.pendingContext!==e.context):e.context&&bd(t,e.context,!1),sc(t,e.containerInfo)}function Md(t,e,r,n,s){return ps(),Xu(s),e.flags|=256,Fe(t,e,r,n),e.child}var ql={dehydrated:null,treeContext:null,retryLane:0};function Ql(t){return{baseLanes:t,cachePool:null,transitions:null}}function Up(t,e,r){var n=e.pendingProps,s=ce.current,i=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(s&2)!==0),a?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),se(ce,s&1),t===null)return Dl(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=n.children,t=n.fallback,i?(n=e.mode,i=e.child,o={mode:"hidden",children:o},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=aa(o,n,0,null),t=dn(t,n,r,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=Ql(r),e.memoizedState=ql,t):hc(e,o));if(s=t.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return my(t,e,o,n,a,s,r);if(i){i=n.fallback,o=e.mode,s=t.child,a=s.sibling;var l={mode:"hidden",children:n.children};return!(o&1)&&e.child!==s?(n=e.child,n.childLanes=0,n.pendingProps=l,e.deletions=null):(n=$r(s,l),n.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=$r(a,i):(i=dn(i,o,r,null),i.flags|=2),i.return=e,n.return=e,n.sibling=i,e.child=n,n=i,i=e.child,o=t.child.memoizedState,o=o===null?Ql(r):{baseLanes:o.baseLanes|r,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=t.childLanes&~r,e.memoizedState=ql,n}return i=t.child,t=i.sibling,n=$r(i,{mode:"visible",children:n.children}),!(e.mode&1)&&(n.lanes=r),n.return=e,n.sibling=null,t!==null&&(r=e.deletions,r===null?(e.deletions=[t],e.flags|=16):r.push(t)),e.child=n,e.memoizedState=null,n}function hc(t,e){return e=aa({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Gi(t,e,r,n){return n!==null&&Xu(n),ms(e,t.child,null,r),t=hc(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function my(t,e,r,n,s,i,o){if(r)return e.flags&256?(e.flags&=-257,n=Ja(Error(N(422))),Gi(t,e,o,n)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=n.fallback,s=e.mode,n=aa({mode:"visible",children:n.children},s,0,null),i=dn(i,s,o,null),i.flags|=2,n.return=e,i.return=e,n.sibling=i,e.child=n,e.mode&1&&ms(e,t.child,null,o),e.child.memoizedState=Ql(o),e.memoizedState=ql,i);if(!(e.mode&1))return Gi(t,e,o,null);if(s.data==="$!"){if(n=s.nextSibling&&s.nextSibling.dataset,n)var a=n.dgst;return n=a,i=Error(N(419)),n=Ja(i,n,void 0),Gi(t,e,o,n)}if(a=(o&t.childLanes)!==0,Ye||a){if(n=je,n!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(n.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,rr(t,s),Ot(n,t,s,-1))}return yc(),n=Ja(Error(N(421))),Gi(t,e,o,n)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=Py.bind(null,t),s._reactRetry=e,null):(t=i.treeContext,nt=Rr(s.nextSibling),st=e,ue=!0,Nt=null,t!==null&&(dt[ht++]=Jt,dt[ht++]=Yt,dt[ht++]=fn,Jt=t.id,Yt=t.overflow,fn=e),e=hc(e,n.children),e.flags|=4096,e)}function Fd(t,e,r){t.lanes|=e;var n=t.alternate;n!==null&&(n.lanes|=e),Ml(t.return,e,r)}function Ya(t,e,r,n,s){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=r,i.tailMode=s)}function Dp(t,e,r){var n=e.pendingProps,s=n.revealOrder,i=n.tail;if(Fe(t,e,n.children,r),n=ce.current,n&2)n=n&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Fd(t,r,e);else if(t.tag===19)Fd(t,r,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}n&=1}if(se(ce,n),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(r=e.child,s=null;r!==null;)t=r.alternate,t!==null&&$o(t)===null&&(s=r),r=r.sibling;r=s,r===null?(s=e.child,e.child=null):(s=r.sibling,r.sibling=null),Ya(e,!1,s,r,i);break;case"backwards":for(r=null,s=e.child,e.child=null;s!==null;){if(t=s.alternate,t!==null&&$o(t)===null){e.child=s;break}t=s.sibling,s.sibling=r,r=s,s=t}Ya(e,!0,r,null,i);break;case"together":Ya(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function po(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function nr(t,e,r){if(t!==null&&(e.dependencies=t.dependencies),mn|=e.lanes,!(r&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(N(153));if(e.child!==null){for(t=e.child,r=$r(t,t.pendingProps),e.child=r,r.return=e;t.sibling!==null;)t=t.sibling,r=r.sibling=$r(t,t.pendingProps),r.return=e;r.sibling=null}return e.child}function gy(t,e,r){switch(e.tag){case 3:$p(e),ps();break;case 5:cp(e);break;case 1:Ze(e.type)&&To(e);break;case 4:sc(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,s=e.memoizedProps.value;se(Io,n._currentValue),n._currentValue=s;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(se(ce,ce.current&1),e.flags|=128,null):r&e.child.childLanes?Up(t,e,r):(se(ce,ce.current&1),t=nr(t,e,r),t!==null?t.sibling:null);se(ce,ce.current&1);break;case 19:if(n=(r&e.childLanes)!==0,t.flags&128){if(n)return Dp(t,e,r);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),se(ce,ce.current),n)break;return null;case 22:case 23:return e.lanes=0,Lp(t,e,r)}return nr(t,e,r)}var Mp,Kl,Fp,zp;Mp=function(t,e){for(var r=e.child;r!==null;){if(r.tag===5||r.tag===6)t.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};Kl=function(){};Fp=function(t,e,r,n){var s=t.memoizedProps;if(s!==n){t=e.stateNode,en(zt.current);var i=null;switch(r){case"input":s=ml(t,s),n=ml(t,n),i=[];break;case"select":s=he({},s,{value:void 0}),n=he({},n,{value:void 0}),i=[];break;case"textarea":s=yl(t,s),n=yl(t,n),i=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(t.onclick=Po)}xl(r,n);var o;r=null;for(u in s)if(!n.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var a=s[u];for(o in a)a.hasOwnProperty(o)&&(r||(r={}),r[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(ri.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in n){var l=n[u];if(a=s!=null?s[u]:void 0,n.hasOwnProperty(u)&&l!==a&&(l!=null||a!=null))if(u==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(r||(r={}),r[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(r||(r={}),r[o]=l[o])}else r||(i||(i=[]),i.push(u,r)),r=l;else u==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(i=i||[]).push(u,l)):u==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(u,""+l):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(ri.hasOwnProperty(u)?(l!=null&&u==="onScroll"&&oe("scroll",t),i||a===l||(i=[])):(i=i||[]).push(u,l))}r&&(i=i||[]).push("style",r);var u=i;(e.updateQueue=u)&&(e.flags|=4)}};zp=function(t,e,r,n){r!==n&&(e.flags|=4)};function As(t,e){if(!ue)switch(t.tailMode){case"hidden":e=t.tail;for(var r=null;e!==null;)e.alternate!==null&&(r=e),e=e.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:n.sibling=null}}function Ie(t){var e=t.alternate!==null&&t.alternate.child===t.child,r=0,n=0;if(e)for(var s=t.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags&14680064,n|=s.flags&14680064,s.return=t,s=s.sibling;else for(s=t.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=t,s=s.sibling;return t.subtreeFlags|=n,t.childLanes=r,e}function vy(t,e,r){var n=e.pendingProps;switch(Yu(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ie(e),null;case 1:return Ze(e.type)&&No(),Ie(e),null;case 3:return n=e.stateNode,gs(),ae(Xe),ae(Ae),oc(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(t===null||t.child===null)&&(Ki(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Nt!==null&&(tu(Nt),Nt=null))),Kl(t,e),Ie(e),null;case 5:ic(e);var s=en(pi.current);if(r=e.type,t!==null&&e.stateNode!=null)Fp(t,e,r,n,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(N(166));return Ie(e),null}if(t=en(zt.current),Ki(e)){n=e.stateNode,r=e.type;var i=e.memoizedProps;switch(n[Mt]=e,n[hi]=i,t=(e.mode&1)!==0,r){case"dialog":oe("cancel",n),oe("close",n);break;case"iframe":case"object":case"embed":oe("load",n);break;case"video":case"audio":for(s=0;s<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=o.createElement(r,{is:n.is}):(t=o.createElement(r),r==="select"&&(o=t,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):t=o.createElementNS(t,r),t[Mt]=e,t[hi]=n,Mp(t,e,!1,!1),e.stateNode=t;e:{switch(o=_l(r,n),r){case"dialog":oe("cancel",t),oe("close",t),s=n;break;case"iframe":case"object":case"embed":oe("load",t),s=n;break;case"video":case"audio":for(s=0;sys&&(e.flags|=128,n=!0,As(i,!1),e.lanes=4194304)}else{if(!n)if(t=$o(o),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),As(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!ue)return Ie(e),null}else 2*ve()-i.renderingStartTime>ys&&r!==1073741824&&(e.flags|=128,n=!0,As(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(r=i.last,r!==null?r.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=ve(),e.sibling=null,r=ce.current,se(ce,n?r&1|2:r&1),e):(Ie(e),null);case 22:case 23:return vc(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?rt&1073741824&&(Ie(e),e.subtreeFlags&6&&(e.flags|=8192)):Ie(e),null;case 24:return null;case 25:return null}throw Error(N(156,e.tag))}function yy(t,e){switch(Yu(e),e.tag){case 1:return Ze(e.type)&&No(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return gs(),ae(Xe),ae(Ae),oc(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return ic(e),null;case 13:if(ae(ce),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(N(340));ps()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return ae(ce),null;case 4:return gs(),null;case 10:return tc(e.type._context),null;case 22:case 23:return vc(),null;case 24:return null;default:return null}}var Ji=!1,Le=!1,wy=typeof WeakSet=="function"?WeakSet:Set,A=null;function Wn(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){me(t,e,n)}else r.current=null}function Vl(t,e,r){try{r()}catch(n){me(t,e,n)}}var zd=!1;function xy(t,e){if(Ol=Eo,t=Qf(),Gu(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var s=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,m=null;t:for(;;){for(var f;d!==r||s!==0&&d.nodeType!==3||(a=o+s),d!==i||n!==0&&d.nodeType!==3||(l=o+n),d.nodeType===3&&(o+=d.nodeValue.length),(f=d.firstChild)!==null;)m=d,d=f;for(;;){if(d===t)break t;if(m===r&&++u===s&&(a=o),m===i&&++c===n&&(l=o),(f=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=f}r=a===-1||l===-1?null:{start:a,end:l}}else r=null}r=r||{start:0,end:0}}else r=null;for(Rl={focusedElem:t,selectionRange:r},Eo=!1,A=e;A!==null;)if(e=A,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,A=t;else for(;A!==null;){e=A;try{var _=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var x=_.memoizedProps,b=_.memoizedState,v=e.stateNode,g=v.getSnapshotBeforeUpdate(e.elementType===e.type?x:kt(e.type,x),b);v.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var p=e.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(w){me(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,A=t;break}A=e.return}return _=zd,zd=!1,_}function Js(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&Vl(e,r,i)}s=s.next}while(s!==n)}}function ia(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function Gl(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function Bp(t){var e=t.alternate;e!==null&&(t.alternate=null,Bp(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Mt],delete e[hi],delete e[Al],delete e[ry],delete e[ny])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Wp(t){return t.tag===5||t.tag===3||t.tag===4}function Bd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Wp(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Jl(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=Po));else if(n!==4&&(t=t.child,t!==null))for(Jl(t,e,r),t=t.sibling;t!==null;)Jl(t,e,r),t=t.sibling}function Yl(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(Yl(t,e,r),t=t.sibling;t!==null;)Yl(t,e,r),t=t.sibling}var Ne=null,jt=!1;function lr(t,e,r){for(r=r.child;r!==null;)Hp(t,e,r),r=r.sibling}function Hp(t,e,r){if(Ft&&typeof Ft.onCommitFiberUnmount=="function")try{Ft.onCommitFiberUnmount(Yo,r)}catch{}switch(r.tag){case 5:Le||Wn(r,e);case 6:var n=Ne,s=jt;Ne=null,lr(t,e,r),Ne=n,jt=s,Ne!==null&&(jt?(t=Ne,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Ne.removeChild(r.stateNode));break;case 18:Ne!==null&&(jt?(t=Ne,r=r.stateNode,t.nodeType===8?Ha(t.parentNode,r):t.nodeType===1&&Ha(t,r),ai(t)):Ha(Ne,r.stateNode));break;case 4:n=Ne,s=jt,Ne=r.stateNode.containerInfo,jt=!0,lr(t,e,r),Ne=n,jt=s;break;case 0:case 11:case 14:case 15:if(!Le&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Vl(r,e,o),s=s.next}while(s!==n)}lr(t,e,r);break;case 1:if(!Le&&(Wn(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(a){me(r,e,a)}lr(t,e,r);break;case 21:lr(t,e,r);break;case 22:r.mode&1?(Le=(n=Le)||r.memoizedState!==null,lr(t,e,r),Le=n):lr(t,e,r);break;default:lr(t,e,r)}}function Wd(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new wy),e.forEach(function(n){var s=Ny.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function _t(t,e){var r=e.deletions;if(r!==null)for(var n=0;ns&&(s=o),n&=~i}if(n=s,n=ve()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*by(n/1960))-n,10t?16:t,jr===null)var n=!1;else{if(t=jr,jr=null,zo=0,J&6)throw Error(N(331));var s=J;for(J|=4,A=t.current;A!==null;){var i=A,o=i.child;if(A.flags&16){var a=i.deletions;if(a!==null){for(var l=0;lve()-mc?cn(t,0):pc|=r),et(t,e)}function Xp(t,e){e===0&&(t.mode&1?(e=zi,zi<<=1,!(zi&130023424)&&(zi=4194304)):e=1);var r=Be();t=rr(t,e),t!==null&&(Ci(t,e,r),et(t,r))}function Py(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),Xp(t,r)}function Ny(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,s=t.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(N(314))}n!==null&&n.delete(e),Xp(t,r)}var Zp;Zp=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Xe.current)Ye=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return Ye=!1,gy(t,e,r);Ye=!!(t.flags&131072)}else Ye=!1,ue&&e.flags&1048576&&np(e,Ro,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;po(t,e),t=e.pendingProps;var s=fs(e,Ae.current);Gn(e,r),s=lc(null,e,n,t,s,r);var i=uc();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ze(n)?(i=!0,To(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,nc(e),s.updater=sa,e.stateNode=s,s._reactInternals=e,zl(e,n,t,r),e=Hl(null,e,n,!0,i,r)):(e.tag=0,ue&&i&&Ju(e),Fe(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(po(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=Oy(n),t=kt(n,t),s){case 0:e=Wl(null,e,n,t,r);break e;case 1:e=Dd(null,e,n,t,r);break e;case 11:e=$d(null,e,n,t,r);break e;case 14:e=Ud(null,e,n,kt(n.type,t),r);break e}throw Error(N(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),Wl(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),Dd(t,e,n,s,r);case 3:e:{if($p(e),t===null)throw Error(N(387));n=e.pendingProps,i=e.memoizedState,s=i.element,up(t,e),Ao(e,n,null,r);var o=e.memoizedState;if(n=o.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=vs(Error(N(423)),e),e=Md(t,e,n,r,s);break e}else if(n!==s){s=vs(Error(N(424)),e),e=Md(t,e,n,r,s);break e}else for(nt=Rr(e.stateNode.containerInfo.firstChild),st=e,ue=!0,Nt=null,r=ap(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(ps(),n===s){e=nr(t,e,r);break e}Fe(t,e,n,r)}e=e.child}return e;case 5:return cp(e),t===null&&Dl(e),n=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,o=s.children,Il(n,s)?o=null:i!==null&&Il(n,i)&&(e.flags|=32),Ap(t,e),Fe(t,e,o,r),e.child;case 6:return t===null&&Dl(e),null;case 13:return Up(t,e,r);case 4:return sc(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=ms(e,null,n,r):Fe(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),$d(t,e,n,s,r);case 7:return Fe(t,e,e.pendingProps,r),e.child;case 8:return Fe(t,e,e.pendingProps.children,r),e.child;case 12:return Fe(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,se(Io,n._currentValue),n._currentValue=o,i!==null)if(Rt(i.value,o)){if(i.children===s.children&&!Xe.current){e=nr(t,e,r);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===n){if(i.tag===1){l=Xt(-1,r&-r),l.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?l.next=l:(l.next=c.next,c.next=l),u.pending=l}}i.lanes|=r,l=i.alternate,l!==null&&(l.lanes|=r),Ml(i.return,r,e),a.lanes|=r;break}l=l.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(N(341));o.lanes|=r,a=o.alternate,a!==null&&(a.lanes|=r),Ml(o,r,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Fe(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,Gn(e,r),s=gt(s),n=n(s),e.flags|=1,Fe(t,e,n,r),e.child;case 14:return n=e.type,s=kt(n,e.pendingProps),s=kt(n.type,s),Ud(t,e,n,s,r);case 15:return Ip(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:kt(n,s),po(t,e),e.tag=1,Ze(n)?(t=!0,To(e)):t=!1,Gn(e,r),Tp(e,n,s),zl(e,n,s,r),Hl(null,e,n,!0,t,r);case 19:return Dp(t,e,r);case 22:return Lp(t,e,r)}throw Error(N(156,e.tag))};function em(t,e){return jf(t,e)}function Ty(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ft(t,e,r,n){return new Ty(t,e,r,n)}function wc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Oy(t){if(typeof t=="function")return wc(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Du)return 11;if(t===Mu)return 14}return 2}function $r(t,e){var r=t.alternate;return r===null?(r=ft(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function vo(t,e,r,n,s,i){var o=2;if(n=t,typeof t=="function")wc(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Ln:return dn(r.children,s,i,e);case Uu:o=8,s|=8;break;case dl:return t=ft(12,r,e,s|2),t.elementType=dl,t.lanes=i,t;case hl:return t=ft(13,r,e,s),t.elementType=hl,t.lanes=i,t;case fl:return t=ft(19,r,e,s),t.elementType=fl,t.lanes=i,t;case cf:return aa(r,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case lf:o=10;break e;case uf:o=9;break e;case Du:o=11;break e;case Mu:o=14;break e;case hr:o=16,n=null;break e}throw Error(N(130,t==null?t:typeof t,""))}return e=ft(o,r,e,s),e.elementType=t,e.type=n,e.lanes=i,e}function dn(t,e,r,n){return t=ft(7,t,n,e),t.lanes=r,t}function aa(t,e,r,n){return t=ft(22,t,n,e),t.elementType=cf,t.lanes=r,t.stateNode={isHidden:!1},t}function Xa(t,e,r){return t=ft(6,t,null,e),t.lanes=r,t}function Za(t,e,r){return e=ft(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Ry(t,e,r,n,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ia(0),this.expirationTimes=Ia(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ia(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function xc(t,e,r,n,s,i,o,a,l){return t=new Ry(t,e,r,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=ft(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},nc(i),t}function Iy(t,e,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sm)}catch(t){console.error(t)}}sm(),nf.exports=ot;var im=nf.exports;const Dy=qh(im);var Yd=im;ul.createRoot=Yd.createRoot,ul.hydrateRoot=Yd.hydrateRoot;/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. @@ -64,8 +64,8 @@ Error generating stack: `+i.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */const k0="6";try{window.__reactRouterVersion=k0}catch{}const E0="startTransition",nh=jg[E0];function C0(t){let{basename:e,children:r,future:n,window:s}=t,i=C.useRef();i.current==null&&(i.current=My({window:s,v5Compat:!0}));let o=i.current,[a,l]=C.useState({action:o.action,location:o.location}),{v7_startTransition:u}=n||{},c=C.useCallback(d=>{u&&nh?nh(()=>l(d)):l(d)},[l,u]);return C.useLayoutEffect(()=>o.listen(c),[o,c]),C.useEffect(()=>_0(n),[n]),C.createElement(b0,{basename:e,children:r,location:a.location,navigationType:a.action,navigator:o,future:n})}var sh;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(sh||(sh={}));var ih;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(ih||(ih={}));var Ss=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},vn=typeof window>"u"||"Deno"in globalThis;function ze(){}function j0(t,e){return typeof t=="function"?t(e):t}function su(t){return typeof t=="number"&&t>=0&&t!==1/0}function mm(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Ur(t,e){return typeof t=="function"?t(e):t}function ct(t,e){return typeof t=="function"?t(e):t}function oh(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:i,queryKey:o,stale:a}=t;if(o){if(n){if(e.queryHash!==Ec(o,e.options))return!1}else if(!wi(e.queryKey,o))return!1}if(r!=="all"){const l=e.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||s&&s!==e.state.fetchStatus||i&&!i(e))}function ah(t,e){const{exact:r,status:n,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(yn(e.options.mutationKey)!==yn(i))return!1}else if(!wi(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Ec(t,e){return((e==null?void 0:e.queryKeyHashFn)||yn)(t)}function yn(t){return JSON.stringify(t,(e,r)=>iu(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function wi(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>wi(t[r],e[r])):!1}function gm(t,e){if(t===e)return t;const r=lh(t)&&lh(e);if(r||iu(t)&&iu(e)){const n=r?t:Object.keys(t),s=n.length,i=r?e:Object.keys(e),o=i.length,a=r?[]:{},l=new Set(n);let u=0;for(let c=0;c{setTimeout(e,t)})}function ou(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?gm(t,e):e}function N0(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function T0(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var Cc=Symbol();function vm(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===Cc?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function ym(t,e){return typeof t=="function"?t(...e):!!t}var tn,vr,Zn,Ah,O0=(Ah=class extends Ss{constructor(){super();U(this,tn);U(this,vr);U(this,Zn);I(this,Zn,e=>{if(!vn&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){y(this,vr)||this.setEventListener(y(this,Zn))}onUnsubscribe(){var e;this.hasListeners()||((e=y(this,vr))==null||e.call(this),I(this,vr,void 0))}setEventListener(e){var r;I(this,Zn,e),(r=y(this,vr))==null||r.call(this),I(this,vr,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){y(this,tn)!==e&&(I(this,tn,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof y(this,tn)=="boolean"?y(this,tn):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},tn=new WeakMap,vr=new WeakMap,Zn=new WeakMap,Ah),jc=new O0,es,yr,ts,$h,R0=($h=class extends Ss{constructor(){super();U(this,es,!0);U(this,yr);U(this,ts);I(this,ts,e=>{if(!vn&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){y(this,yr)||this.setEventListener(y(this,ts))}onUnsubscribe(){var e;this.hasListeners()||((e=y(this,yr))==null||e.call(this),I(this,yr,void 0))}setEventListener(e){var r;I(this,ts,e),(r=y(this,yr))==null||r.call(this),I(this,yr,e(this.setOnline.bind(this)))}setOnline(e){y(this,es)!==e&&(I(this,es,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return y(this,es)}},es=new WeakMap,yr=new WeakMap,ts=new WeakMap,$h),Ko=new R0;function au(){let t,e;const r=new Promise((s,i)=>{t=s,e=i});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function I0(t){return Math.min(1e3*2**t,3e4)}function wm(t){return(t??"online")==="online"?Ko.isOnline():!0}var xm=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function _m(t){let e=!1,r=0,n;const s=au(),i=()=>s.status!=="pending",o=x=>{var b;i()||(m(new xm(x)),(b=t.abort)==null||b.call(t))},a=()=>{e=!0},l=()=>{e=!1},u=()=>jc.isFocused()&&(t.networkMode==="always"||Ko.isOnline())&&t.canRun(),c=()=>wm(t.networkMode)&&t.canRun(),d=x=>{i()||(n==null||n(),s.resolve(x))},m=x=>{i()||(n==null||n(),s.reject(x))},f=()=>new Promise(x=>{var b;n=v=>{(i()||u())&&x(v)},(b=t.onPause)==null||b.call(t)}).then(()=>{var x;n=void 0,i()||(x=t.onContinue)==null||x.call(t)}),_=()=>{if(i())return;let x;const b=r===0?t.initialPromise:void 0;try{x=b??t.fn()}catch(v){x=Promise.reject(v)}Promise.resolve(x).then(d).catch(v=>{var S;if(i())return;const g=t.retry??(vn?0:3),p=t.retryDelay??I0,w=typeof p=="function"?p(r,v):p,k=g===!0||typeof g=="number"&&ru()?void 0:f()).then(()=>{e?m(v):_()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:a,continueRetry:l,canStart:c,start:()=>(c()?_():f().then(_),s)}}var L0=t=>setTimeout(t,0);function A0(){let t=[],e=0,r=a=>{a()},n=a=>{a()},s=L0;const i=a=>{e?t.push(a):s(()=>{r(a)})},o=()=>{const a=t;t=[],a.length&&s(()=>{n(()=>{a.forEach(l=>{r(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||o()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{r=a},setBatchNotifyFunction:a=>{n=a},setScheduler:a=>{s=a}}}var be=A0(),rn,Uh,bm=(Uh=class{constructor(){U(this,rn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),su(this.gcTime)&&I(this,rn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(vn?1/0:5*60*1e3))}clearGcTimeout(){y(this,rn)&&(clearTimeout(y(this,rn)),I(this,rn,void 0))}},rn=new WeakMap,Uh),rs,ns,ut,nn,Ee,_i,sn,Et,Bt,Dh,$0=(Dh=class extends bm{constructor(e){super();U(this,Et);U(this,rs);U(this,ns);U(this,ut);U(this,nn);U(this,Ee);U(this,_i);U(this,sn);I(this,sn,!1),I(this,_i,e.defaultOptions),this.setOptions(e.options),this.observers=[],I(this,nn,e.client),I(this,ut,y(this,nn).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,I(this,rs,U0(this.options)),this.state=e.state??y(this,rs),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=y(this,Ee))==null?void 0:e.promise}setOptions(e){this.options={...y(this,_i),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,ut).remove(this)}setData(e,r){const n=ou(this.state.data,e,this.options);return W(this,Et,Bt).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){W(this,Et,Bt).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=y(this,Ee))==null?void 0:n.promise;return(s=y(this,Ee))==null||s.cancel(e),r?r.then(ze).catch(ze):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,rs))}isActive(){return this.observers.some(e=>ct(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Cc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Ur(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!mm(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=y(this,Ee))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=y(this,Ee))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),y(this,ut).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(y(this,Ee)&&(y(this,sn)?y(this,Ee).cancel({revert:!0}):y(this,Ee).cancelRetry()),this.scheduleGc()),y(this,ut).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,Et,Bt).call(this,{type:"invalidate"})}async fetch(e,r){var l,u,c,d,m,f,_,x,b,v,g,p;if(this.state.fetchStatus!=="idle"&&((l=y(this,Ee))==null?void 0:l.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ee))return y(this,Ee).continueRetry(),y(this,Ee).promise}if(e&&this.setOptions(e),!this.options.queryFn){const w=this.observers.find(k=>k.options.queryFn);w&&this.setOptions(w.options)}const n=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(I(this,sn,!0),n.signal)})},i=()=>{const w=vm(this.options,r),S=(()=>{const j={client:y(this,nn),queryKey:this.queryKey,meta:this.meta};return s(j),j})();return I(this,sn,!1),this.options.persister?this.options.persister(w,S,this):w(S)},a=(()=>{const w={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:y(this,nn),state:this.state,fetchFn:i};return s(w),w})();(u=this.options.behavior)==null||u.onFetch(a,this),I(this,ns,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((c=a.fetchOptions)==null?void 0:c.meta))&&W(this,Et,Bt).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),I(this,Ee,_m({initialPromise:r==null?void 0:r.initialPromise,fn:a.fetchFn,abort:n.abort.bind(n),onFail:(w,k)=>{W(this,Et,Bt).call(this,{type:"failed",failureCount:w,error:k})},onPause:()=>{W(this,Et,Bt).call(this,{type:"pause"})},onContinue:()=>{W(this,Et,Bt).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ee).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(f=(m=y(this,ut).config).onSuccess)==null||f.call(m,w,this),(x=(_=y(this,ut).config).onSettled)==null||x.call(_,w,this.state.error,this),w}catch(w){if(w instanceof xm){if(w.silent)return y(this,Ee).promise;if(w.revert){if(this.setState({...y(this,ns),fetchStatus:"idle"}),this.state.data===void 0)throw w;return this.state.data}}throw W(this,Et,Bt).call(this,{type:"error",error:w}),(v=(b=y(this,ut).config).onError)==null||v.call(b,w,this),(p=(g=y(this,ut).config).onSettled)==null||p.call(g,this.state.data,w,this),w}finally{this.scheduleGc()}}},rs=new WeakMap,ns=new WeakMap,ut=new WeakMap,nn=new WeakMap,Ee=new WeakMap,_i=new WeakMap,sn=new WeakMap,Et=new WeakSet,Bt=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Sm(n.data,this.options),fetchMeta:e.meta??null};case"success":const s={...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return I(this,ns,e.manual?s:void 0),s;case"error":const i=e.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),be.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),y(this,ut).notify({query:this,type:"updated",action:e})})},Dh);function Sm(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:wm(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function U0(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var $t,Mh,D0=(Mh=class extends Ss{constructor(e={}){super();U(this,$t);this.config=e,I(this,$t,new Map)}build(e,r,n){const s=r.queryKey,i=r.queryHash??Ec(s,r);let o=this.get(i);return o||(o=new $0({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(o)),o}add(e){y(this,$t).has(e.queryHash)||(y(this,$t).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=y(this,$t).get(e.queryHash);r&&(e.destroy(),r===e&&y(this,$t).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){be.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return y(this,$t).get(e)}getAll(){return[...y(this,$t).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>oh(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>oh(e,n)):r}notify(e){be.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){be.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$t=new WeakMap,Mh),Ut,De,on,Dt,cr,Fh,M0=(Fh=class extends bm{constructor(e){super();U(this,Dt);U(this,Ut);U(this,De);U(this,on);this.mutationId=e.mutationId,I(this,De,e.mutationCache),I(this,Ut,[]),this.state=e.state||km(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){y(this,Ut).includes(e)||(y(this,Ut).push(e),this.clearGcTimeout(),y(this,De).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){I(this,Ut,y(this,Ut).filter(r=>r!==e)),this.scheduleGc(),y(this,De).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){y(this,Ut).length||(this.state.status==="pending"?this.scheduleGc():y(this,De).remove(this))}continue(){var e;return((e=y(this,on))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var i,o,a,l,u,c,d,m,f,_,x,b,v,g,p,w,k,S,j,T;const r=()=>{W(this,Dt,cr).call(this,{type:"continue"})};I(this,on,_m({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(P,E)=>{W(this,Dt,cr).call(this,{type:"failed",failureCount:P,error:E})},onPause:()=>{W(this,Dt,cr).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,De).canRun(this)}));const n=this.state.status==="pending",s=!y(this,on).canStart();try{if(n)r();else{W(this,Dt,cr).call(this,{type:"pending",variables:e,isPaused:s}),await((o=(i=y(this,De).config).onMutate)==null?void 0:o.call(i,e,this));const E=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,e));E!==this.state.context&&W(this,Dt,cr).call(this,{type:"pending",context:E,variables:e,isPaused:s})}const P=await y(this,on).start();return await((c=(u=y(this,De).config).onSuccess)==null?void 0:c.call(u,P,e,this.state.context,this)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,P,e,this.state.context)),await((_=(f=y(this,De).config).onSettled)==null?void 0:_.call(f,P,null,this.state.variables,this.state.context,this)),await((b=(x=this.options).onSettled)==null?void 0:b.call(x,P,null,e,this.state.context)),W(this,Dt,cr).call(this,{type:"success",data:P}),P}catch(P){try{throw await((g=(v=y(this,De).config).onError)==null?void 0:g.call(v,P,e,this.state.context,this)),await((w=(p=this.options).onError)==null?void 0:w.call(p,P,e,this.state.context)),await((S=(k=y(this,De).config).onSettled)==null?void 0:S.call(k,void 0,P,this.state.variables,this.state.context,this)),await((T=(j=this.options).onSettled)==null?void 0:T.call(j,void 0,P,e,this.state.context)),P}finally{W(this,Dt,cr).call(this,{type:"error",error:P})}}finally{y(this,De).runNext(this)}}},Ut=new WeakMap,De=new WeakMap,on=new WeakMap,Dt=new WeakSet,cr=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),be.batch(()=>{y(this,Ut).forEach(n=>{n.onMutationUpdate(e)}),y(this,De).notify({mutation:this,type:"updated",action:e})})},Fh);function km(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Kt,Ct,bi,zh,F0=(zh=class extends Ss{constructor(e={}){super();U(this,Kt);U(this,Ct);U(this,bi);this.config=e,I(this,Kt,new Set),I(this,Ct,new Map),I(this,bi,0)}build(e,r,n){const s=new M0({mutationCache:this,mutationId:++Ai(this,bi)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){y(this,Kt).add(e);const r=Zi(e);if(typeof r=="string"){const n=y(this,Ct).get(r);n?n.push(e):y(this,Ct).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(y(this,Kt).delete(e)){const r=Zi(e);if(typeof r=="string"){const n=y(this,Ct).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&y(this,Ct).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=Zi(e);if(typeof r=="string"){const n=y(this,Ct).get(r),s=n==null?void 0:n.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=Zi(e);if(typeof r=="string"){const s=(n=y(this,Ct).get(r))==null?void 0:n.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{y(this,Kt).forEach(e=>{this.notify({type:"removed",mutation:e})}),y(this,Kt).clear(),y(this,Ct).clear()})}getAll(){return Array.from(y(this,Kt))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>ah(r,n))}findAll(e={}){return this.getAll().filter(r=>ah(e,r))}notify(e){be.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return be.batch(()=>Promise.all(e.map(r=>r.continue().catch(ze))))}},Kt=new WeakMap,Ct=new WeakMap,bi=new WeakMap,zh);function Zi(t){var e;return(e=t.options.scope)==null?void 0:e.id}function ch(t){return{onFetch:(e,r)=>{var c,d,m,f,_;const n=e.options,s=(m=(d=(c=e.fetchOptions)==null?void 0:c.meta)==null?void 0:d.fetchMore)==null?void 0:m.direction,i=((f=e.state.data)==null?void 0:f.pages)||[],o=((_=e.state.data)==null?void 0:_.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const u=async()=>{let x=!1;const b=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(e.signal.aborted?x=!0:e.signal.addEventListener("abort",()=>{x=!0}),e.signal)})},v=vm(e.options,e.fetchOptions),g=async(p,w,k)=>{if(x)return Promise.reject();if(w==null&&p.pages.length)return Promise.resolve(p);const j=(()=>{const F={client:e.client,queryKey:e.queryKey,pageParam:w,direction:k?"backward":"forward",meta:e.options.meta};return b(F),F})(),T=await v(j),{maxPages:P}=e.options,E=k?T0:N0;return{pages:E(p.pages,T,P),pageParams:E(p.pageParams,w,P)}};if(s&&i.length){const p=s==="backward",w=p?z0:dh,k={pages:i,pageParams:o},S=w(n,k);a=await g(k,S,p)}else{const p=t??i.length;do{const w=l===0?o[0]??n.initialPageParam:dh(n,a);if(l>0&&w==null)break;a=await g(a,w),l++}while(l{var x,b;return(b=(x=e.options).persister)==null?void 0:b.call(x,u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=u}}}function dh(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function z0(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var pe,wr,xr,ss,is,_r,os,as,Bh,B0=(Bh=class{constructor(t={}){U(this,pe);U(this,wr);U(this,xr);U(this,ss);U(this,is);U(this,_r);U(this,os);U(this,as);I(this,pe,t.queryCache||new D0),I(this,wr,t.mutationCache||new F0),I(this,xr,t.defaultOptions||{}),I(this,ss,new Map),I(this,is,new Map),I(this,_r,0)}mount(){Ai(this,_r)._++,y(this,_r)===1&&(I(this,os,jc.subscribe(async t=>{t&&(await this.resumePausedMutations(),y(this,pe).onFocus())})),I(this,as,Ko.subscribe(async t=>{t&&(await this.resumePausedMutations(),y(this,pe).onOnline())})))}unmount(){var t,e;Ai(this,_r)._--,y(this,_r)===0&&((t=y(this,os))==null||t.call(this),I(this,os,void 0),(e=y(this,as))==null||e.call(this),I(this,as,void 0))}isFetching(t){return y(this,pe).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return y(this,wr).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=y(this,pe).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=y(this,pe).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Ur(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return y(this,pe).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=y(this,pe).get(n.queryHash),i=s==null?void 0:s.state.data,o=j0(e,i);if(o!==void 0)return y(this,pe).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return be.batch(()=>y(this,pe).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=y(this,pe).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=y(this,pe);be.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=y(this,pe);return be.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=be.batch(()=>y(this,pe).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(ze).catch(ze)}invalidateQueries(t,e={}){return be.batch(()=>(y(this,pe).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=be.batch(()=>y(this,pe).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,r);return r.throwOnError||(i=i.catch(ze)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(ze)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=y(this,pe).build(this,e);return r.isStaleByTime(Ur(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ze).catch(ze)}fetchInfiniteQuery(t){return t.behavior=ch(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ze).catch(ze)}ensureInfiniteQueryData(t){return t.behavior=ch(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Ko.isOnline()?y(this,wr).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,pe)}getMutationCache(){return y(this,wr)}getDefaultOptions(){return y(this,xr)}setDefaultOptions(t){I(this,xr,t)}setQueryDefaults(t,e){y(this,ss).set(yn(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...y(this,ss).values()],r={};return e.forEach(n=>{wi(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){y(this,is).set(yn(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...y(this,is).values()],r={};return e.forEach(n=>{wi(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...y(this,xr).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Ec(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Cc&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...y(this,xr).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){y(this,pe).clear(),y(this,wr).clear()}},pe=new WeakMap,wr=new WeakMap,xr=new WeakMap,ss=new WeakMap,is=new WeakMap,_r=new WeakMap,os=new WeakMap,as=new WeakMap,Bh),Qe,V,Si,Me,an,ls,Vt,br,ki,us,cs,ln,un,Sr,ds,Z,Bs,lu,uu,cu,du,hu,fu,pu,Em,Wh,W0=(Wh=class extends Ss{constructor(e,r){super();U(this,Z);U(this,Qe);U(this,V);U(this,Si);U(this,Me);U(this,an);U(this,ls);U(this,Vt);U(this,br);U(this,ki);U(this,us);U(this,cs);U(this,ln);U(this,un);U(this,Sr);U(this,ds,new Set);this.options=r,I(this,Qe,e),I(this,br,null),I(this,Vt,au()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,V).addObserver(this),hh(y(this,V),this.options)?W(this,Z,Bs).call(this):this.updateResult(),W(this,Z,du).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return mu(y(this,V),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return mu(y(this,V),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,Z,hu).call(this),W(this,Z,fu).call(this),y(this,V).removeObserver(this)}setOptions(e){const r=this.options,n=y(this,V);if(this.options=y(this,Qe).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ct(this.options.enabled,y(this,V))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,Z,pu).call(this),y(this,V).setOptions(this.options),r._defaulted&&!Qo(this.options,r)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,V),observer:this});const s=this.hasListeners();s&&fh(y(this,V),n,this.options,r)&&W(this,Z,Bs).call(this),this.updateResult(),s&&(y(this,V)!==n||ct(this.options.enabled,y(this,V))!==ct(r.enabled,y(this,V))||Ur(this.options.staleTime,y(this,V))!==Ur(r.staleTime,y(this,V)))&&W(this,Z,lu).call(this);const i=W(this,Z,uu).call(this);s&&(y(this,V)!==n||ct(this.options.enabled,y(this,V))!==ct(r.enabled,y(this,V))||i!==y(this,Sr))&&W(this,Z,cu).call(this,i)}getOptimisticResult(e){const r=y(this,Qe).getQueryCache().build(y(this,Qe),e),n=this.createResult(r,e);return q0(this,n)&&(I(this,Me,n),I(this,ls,this.options),I(this,an,y(this,V).state)),n}getCurrentResult(){return y(this,Me)}trackResult(e,r){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),r==null||r(s),s==="promise"&&!this.options.experimental_prefetchInRender&&y(this,Vt).status==="pending"&&y(this,Vt).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(n,s))})}trackProp(e){y(this,ds).add(e)}getCurrentQuery(){return y(this,V)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=y(this,Qe).defaultQueryOptions(e),n=y(this,Qe).getQueryCache().build(y(this,Qe),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return W(this,Z,Bs).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Me)))}createResult(e,r){var P;const n=y(this,V),s=this.options,i=y(this,Me),o=y(this,an),a=y(this,ls),u=e!==n?e.state:y(this,Si),{state:c}=e;let d={...c},m=!1,f;if(r._optimisticResults){const E=this.hasListeners(),F=!E&&hh(e,r),J=E&&fh(e,n,r,s);(F||J)&&(d={...d,...Sm(c.data,e.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:_,errorUpdatedAt:x,status:b}=d;f=d.data;let v=!1;if(r.placeholderData!==void 0&&f===void 0&&b==="pending"){let E;i!=null&&i.isPlaceholderData&&r.placeholderData===(a==null?void 0:a.placeholderData)?(E=i.data,v=!0):E=typeof r.placeholderData=="function"?r.placeholderData((P=y(this,cs))==null?void 0:P.state.data,y(this,cs)):r.placeholderData,E!==void 0&&(b="success",f=ou(i==null?void 0:i.data,E,r),m=!0)}if(r.select&&f!==void 0&&!v)if(i&&f===(o==null?void 0:o.data)&&r.select===y(this,ki))f=y(this,us);else try{I(this,ki,r.select),f=r.select(f),f=ou(i==null?void 0:i.data,f,r),I(this,us,f),I(this,br,null)}catch(E){I(this,br,E)}y(this,br)&&(_=y(this,br),f=y(this,us),x=Date.now(),b="error");const g=d.fetchStatus==="fetching",p=b==="pending",w=b==="error",k=p&&g,S=f!==void 0,T={status:b,fetchStatus:d.fetchStatus,isPending:p,isSuccess:b==="success",isError:w,isInitialLoading:k,isLoading:k,data:f,dataUpdatedAt:d.dataUpdatedAt,error:_,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&!p,isLoadingError:w&&!S,isPaused:d.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:w&&S,isStale:Pc(e,r),refetch:this.refetch,promise:y(this,Vt),isEnabled:ct(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const E=$=>{T.status==="error"?$.reject(T.error):T.data!==void 0&&$.resolve(T.data)},F=()=>{const $=I(this,Vt,T.promise=au());E($)},J=y(this,Vt);switch(J.status){case"pending":e.queryHash===n.queryHash&&E(J);break;case"fulfilled":(T.status==="error"||T.data!==J.value)&&F();break;case"rejected":(T.status!=="error"||T.error!==J.reason)&&F();break}}return T}updateResult(){const e=y(this,Me),r=this.createResult(y(this,V),this.options);if(I(this,an,y(this,V).state),I(this,ls,this.options),y(this,an).data!==void 0&&I(this,cs,y(this,V)),Qo(r,e))return;I(this,Me,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,ds).size)return!0;const o=new Set(i??y(this,ds));return this.options.throwOnError&&o.add("error"),Object.keys(y(this,Me)).some(a=>{const l=a;return y(this,Me)[l]!==e[l]&&o.has(l)})};W(this,Z,Em).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,Z,du).call(this)}},Qe=new WeakMap,V=new WeakMap,Si=new WeakMap,Me=new WeakMap,an=new WeakMap,ls=new WeakMap,Vt=new WeakMap,br=new WeakMap,ki=new WeakMap,us=new WeakMap,cs=new WeakMap,ln=new WeakMap,un=new WeakMap,Sr=new WeakMap,ds=new WeakMap,Z=new WeakSet,Bs=function(e){W(this,Z,pu).call(this);let r=y(this,V).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(ze)),r},lu=function(){W(this,Z,hu).call(this);const e=Ur(this.options.staleTime,y(this,V));if(vn||y(this,Me).isStale||!su(e))return;const n=mm(y(this,Me).dataUpdatedAt,e)+1;I(this,ln,setTimeout(()=>{y(this,Me).isStale||this.updateResult()},n))},uu=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,V)):this.options.refetchInterval)??!1},cu=function(e){W(this,Z,fu).call(this),I(this,Sr,e),!(vn||ct(this.options.enabled,y(this,V))===!1||!su(y(this,Sr))||y(this,Sr)===0)&&I(this,un,setInterval(()=>{(this.options.refetchIntervalInBackground||jc.isFocused())&&W(this,Z,Bs).call(this)},y(this,Sr)))},du=function(){W(this,Z,lu).call(this),W(this,Z,cu).call(this,W(this,Z,uu).call(this))},hu=function(){y(this,ln)&&(clearTimeout(y(this,ln)),I(this,ln,void 0))},fu=function(){y(this,un)&&(clearInterval(y(this,un)),I(this,un,void 0))},pu=function(){const e=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(e===y(this,V))return;const r=y(this,V);I(this,V,e),I(this,Si,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Em=function(e){be.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(y(this,Me))}),y(this,Qe).getQueryCache().notify({query:y(this,V),type:"observerResultsUpdated"})})},Wh);function H0(t,e){return ct(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function hh(t,e){return H0(t,e)||t.state.data!==void 0&&mu(t,e,e.refetchOnMount)}function mu(t,e,r){if(ct(e.enabled,t)!==!1&&Ur(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&Pc(t,e)}return!1}function fh(t,e,r,n){return(t!==e||ct(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Pc(t,r)}function Pc(t,e){return ct(e.enabled,t)!==!1&&t.isStaleByTime(Ur(e.staleTime,t))}function q0(t,e){return!Qo(t.getCurrentResult(),e)}var kr,Er,Ke,Gt,Zt,wo,gu,Hh,Q0=(Hh=class extends Ss{constructor(r,n){super();U(this,Zt);U(this,kr);U(this,Er);U(this,Ke);U(this,Gt);I(this,kr,r),this.setOptions(n),this.bindMethods(),W(this,Zt,wo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var s;const n=this.options;this.options=y(this,kr).defaultMutationOptions(r),Qo(this.options,n)||y(this,kr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ke),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&yn(n.mutationKey)!==yn(this.options.mutationKey)?this.reset():((s=y(this,Ke))==null?void 0:s.state.status)==="pending"&&y(this,Ke).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=y(this,Ke))==null||r.removeObserver(this)}onMutationUpdate(r){W(this,Zt,wo).call(this),W(this,Zt,gu).call(this,r)}getCurrentResult(){return y(this,Er)}reset(){var r;(r=y(this,Ke))==null||r.removeObserver(this),I(this,Ke,void 0),W(this,Zt,wo).call(this),W(this,Zt,gu).call(this)}mutate(r,n){var s;return I(this,Gt,n),(s=y(this,Ke))==null||s.removeObserver(this),I(this,Ke,y(this,kr).getMutationCache().build(y(this,kr),this.options)),y(this,Ke).addObserver(this),y(this,Ke).execute(r)}},kr=new WeakMap,Er=new WeakMap,Ke=new WeakMap,Gt=new WeakMap,Zt=new WeakSet,wo=function(){var n;const r=((n=y(this,Ke))==null?void 0:n.state)??km();I(this,Er,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},gu=function(r){be.batch(()=>{var n,s,i,o,a,l,u,c;if(y(this,Gt)&&this.hasListeners()){const d=y(this,Er).variables,m=y(this,Er).context;(r==null?void 0:r.type)==="success"?((s=(n=y(this,Gt)).onSuccess)==null||s.call(n,r.data,d,m),(o=(i=y(this,Gt)).onSettled)==null||o.call(i,r.data,null,d,m)):(r==null?void 0:r.type)==="error"&&((l=(a=y(this,Gt)).onError)==null||l.call(a,r.error,d,m),(c=(u=y(this,Gt)).onSettled)==null||c.call(u,void 0,r.error,d,m))}this.listeners.forEach(d=>{d(y(this,Er))})})},Hh),Cm=C.createContext(void 0),ma=t=>{const e=C.useContext(Cm);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},K0=({client:t,children:e})=>(C.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),h.jsx(Cm.Provider,{value:t,children:e})),jm=C.createContext(!1),V0=()=>C.useContext(jm);jm.Provider;function G0(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var J0=C.createContext(G0()),Y0=()=>C.useContext(J0),X0=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Z0=t=>{C.useEffect(()=>{t.clearReset()},[t])},ew=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||ym(r,[t.error,n])),tw=t=>{if(t.suspense){const e=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>e(r(...n)):e(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},rw=(t,e)=>t.isLoading&&t.isFetching&&!e,nw=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ph=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function sw(t,e,r){var d,m,f,_,x;const n=V0(),s=Y0(),i=ma(),o=i.defaultQueryOptions(t);(m=(d=i.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||m.call(d,o),o._optimisticResults=n?"isRestoring":"optimistic",tw(o),X0(o,s),Z0(s);const a=!i.getQueryCache().get(o.queryHash),[l]=C.useState(()=>new e(i,o)),u=l.getOptimisticResult(o),c=!n&&t.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(b=>{const v=c?l.subscribe(be.batchCalls(b)):ze;return l.updateResult(),v},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),C.useEffect(()=>{l.setOptions(o)},[o,l]),nw(o,u))throw ph(o,l,s);if(ew({result:u,errorResetBoundary:s,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;if((_=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||_.call(f,o,u),o.experimental_prefetchInRender&&!vn&&rw(u,n)){const b=a?ph(o,l,s):(x=i.getQueryCache().get(o.queryHash))==null?void 0:x.promise;b==null||b.catch(ze).finally(()=>{l.updateResult()})}return o.notifyOnChangeProps?u:l.trackResult(u)}function vu(t,e){return sw(t,W0)}function Xn(t,e){const r=ma(),[n]=C.useState(()=>new Q0(r,t));C.useEffect(()=>{n.setOptions(t)},[n,t]);const s=C.useSyncExternalStore(C.useCallback(o=>n.subscribe(be.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=C.useCallback((o,a)=>{n.mutate(o,a).catch(ze)},[n]);if(s.error&&ym(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}var iw=t=>{switch(t){case"success":return lw;case"info":return cw;case"warning":return uw;case"error":return dw;default:return null}},ow=Array(12).fill(0),aw=({visible:t,className:e})=>O.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},O.createElement("div",{className:"sonner-spinner"},ow.map((r,n)=>O.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),lw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),uw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),cw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),dw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),hw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},O.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),O.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),fw=()=>{let[t,e]=O.useState(document.hidden);return O.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},yu=1,pw=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...n}=t,s=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:yu++,i=this.toasts.find(a=>a.id===s),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(a=>a.id===s?(this.publish({...a,...t,id:s,title:r}),{...a,...t,id:s,dismissible:o,title:r}):a):this.addToast({title:r,...n,dismissible:o,id:s}),s},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let n=t instanceof Promise?t:t(),s=r!==void 0,i,o=n.then(async l=>{if(i=["resolve",l],O.isValidElement(l))s=!1,this.create({id:r,type:"default",message:l});else if(gw(l)&&!l.ok){s=!1;let u=typeof e.error=="function"?await e.error(`HTTP error! status: ${l.status}`):e.error,c=typeof e.description=="function"?await e.description(`HTTP error! status: ${l.status}`):e.description;this.create({id:r,type:"error",message:u,description:c})}else if(e.success!==void 0){s=!1;let u=typeof e.success=="function"?await e.success(l):e.success,c=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"success",message:u,description:c})}}).catch(async l=>{if(i=["reject",l],e.error!==void 0){s=!1;let u=typeof e.error=="function"?await e.error(l):e.error,c=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"error",message:u,description:c})}}).finally(()=>{var l;s&&(this.dismiss(r),r=void 0),(l=e.finally)==null||l.call(e)}),a=()=>new Promise((l,u)=>o.then(()=>i[0]==="reject"?u(i[1]):l(i[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:a}:Object.assign(r,{unwrap:a})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||yu++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ve=new pw,mw=(t,e)=>{let r=(e==null?void 0:e.id)||yu++;return Ve.addToast({title:t,...e,id:r}),r},gw=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",vw=mw,yw=()=>Ve.toasts,ww=()=>Ve.getActiveToasts(),H=Object.assign(vw,{success:Ve.success,info:Ve.info,warning:Ve.warning,error:Ve.error,custom:Ve.custom,message:Ve.message,promise:Ve.promise,dismiss:Ve.dismiss,loading:Ve.loading},{getHistory:yw,getToasts:ww});function xw(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}xw(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} -`);function eo(t){return t.label!==void 0}var _w=3,bw="32px",Sw="16px",mh=4e3,kw=356,Ew=14,Cw=20,jw=200;function bt(...t){return t.filter(Boolean).join(" ")}function Pw(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var Nw=t=>{var e,r,n,s,i,o,a,l,u,c,d;let{invert:m,toast:f,unstyled:_,interacting:x,setHeights:b,visibleToasts:v,heights:g,index:p,toasts:w,expanded:k,removeToast:S,defaultRichColors:j,closeButton:T,style:P,cancelButtonStyle:E,actionButtonStyle:F,className:J="",descriptionClassName:$="",duration:fe,position:ge,gap:$e,loadingIcon:Pe,expandByDefault:L,classNames:R,icons:D,closeButtonAriaLabel:ie="Close toast",pauseWhenPageIsHidden:M}=t,[X,Y]=O.useState(null),[ke,qe]=O.useState(null),[re,ba]=O.useState(!1),[Cs,Ii]=O.useState(!1),[js,Sa]=O.useState(!1),[Lc,Ym]=O.useState(!1),[Xm,Ac]=O.useState(!1),[Zm,ka]=O.useState(0),[eg,$c]=O.useState(0),Ps=O.useRef(f.duration||fe||mh),Uc=O.useRef(null),Hr=O.useRef(null),tg=p===0,rg=p+1<=v,lt=f.type,bn=f.dismissible!==!1,ng=f.className||"",sg=f.descriptionClassName||"",Li=O.useMemo(()=>g.findIndex(z=>z.toastId===f.id)||0,[g,f.id]),ig=O.useMemo(()=>{var z;return(z=f.closeButton)!=null?z:T},[f.closeButton,T]),Dc=O.useMemo(()=>f.duration||fe||mh,[f.duration,fe]),Ea=O.useRef(0),Sn=O.useRef(0),Mc=O.useRef(0),kn=O.useRef(null),[og,ag]=ge.split("-"),Fc=O.useMemo(()=>g.reduce((z,te,le)=>le>=Li?z:z+te.height,0),[g,Li]),zc=fw(),lg=f.invert||m,Ca=lt==="loading";Sn.current=O.useMemo(()=>Li*$e+Fc,[Li,Fc]),O.useEffect(()=>{Ps.current=Dc},[Dc]),O.useEffect(()=>{ba(!0)},[]),O.useEffect(()=>{let z=Hr.current;if(z){let te=z.getBoundingClientRect().height;return $c(te),b(le=>[{toastId:f.id,height:te,position:f.position},...le]),()=>b(le=>le.filter(yt=>yt.toastId!==f.id))}},[b,f.id]),O.useLayoutEffect(()=>{if(!re)return;let z=Hr.current,te=z.style.height;z.style.height="auto";let le=z.getBoundingClientRect().height;z.style.height=te,$c(le),b(yt=>yt.find(wt=>wt.toastId===f.id)?yt.map(wt=>wt.toastId===f.id?{...wt,height:le}:wt):[{toastId:f.id,height:le,position:f.position},...yt])},[re,f.title,f.description,b,f.id]);let ir=O.useCallback(()=>{Ii(!0),ka(Sn.current),b(z=>z.filter(te=>te.toastId!==f.id)),setTimeout(()=>{S(f)},jw)},[f,S,b,Sn]);O.useEffect(()=>{if(f.promise&<==="loading"||f.duration===1/0||f.type==="loading")return;let z;return k||x||M&&zc?(()=>{if(Mc.current{var te;(te=f.onAutoClose)==null||te.call(f,f),ir()},Ps.current)),()=>clearTimeout(z)},[k,x,f,lt,M,zc,ir]),O.useEffect(()=>{f.delete&&ir()},[ir,f.delete]);function ug(){var z,te,le;return D!=null&&D.loading?O.createElement("div",{className:bt(R==null?void 0:R.loader,(z=f==null?void 0:f.classNames)==null?void 0:z.loader,"sonner-loader"),"data-visible":lt==="loading"},D.loading):Pe?O.createElement("div",{className:bt(R==null?void 0:R.loader,(te=f==null?void 0:f.classNames)==null?void 0:te.loader,"sonner-loader"),"data-visible":lt==="loading"},Pe):O.createElement(aw,{className:bt(R==null?void 0:R.loader,(le=f==null?void 0:f.classNames)==null?void 0:le.loader),visible:lt==="loading"})}return O.createElement("li",{tabIndex:0,ref:Hr,className:bt(J,ng,R==null?void 0:R.toast,(e=f==null?void 0:f.classNames)==null?void 0:e.toast,R==null?void 0:R.default,R==null?void 0:R[lt],(r=f==null?void 0:f.classNames)==null?void 0:r[lt]),"data-sonner-toast":"","data-rich-colors":(n=f.richColors)!=null?n:j,"data-styled":!(f.jsx||f.unstyled||_),"data-mounted":re,"data-promise":!!f.promise,"data-swiped":Xm,"data-removed":Cs,"data-visible":rg,"data-y-position":og,"data-x-position":ag,"data-index":p,"data-front":tg,"data-swiping":js,"data-dismissible":bn,"data-type":lt,"data-invert":lg,"data-swipe-out":Lc,"data-swipe-direction":ke,"data-expanded":!!(k||L&&re),style:{"--index":p,"--toasts-before":p,"--z-index":w.length-p,"--offset":`${Cs?Zm:Sn.current}px`,"--initial-height":L?"auto":`${eg}px`,...P,...f.style},onDragEnd:()=>{Sa(!1),Y(null),kn.current=null},onPointerDown:z=>{Ca||!bn||(Uc.current=new Date,ka(Sn.current),z.target.setPointerCapture(z.pointerId),z.target.tagName!=="BUTTON"&&(Sa(!0),kn.current={x:z.clientX,y:z.clientY}))},onPointerUp:()=>{var z,te,le,yt;if(Lc||!bn)return;kn.current=null;let wt=Number(((z=Hr.current)==null?void 0:z.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),or=Number(((te=Hr.current)==null?void 0:te.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),qr=new Date().getTime()-((le=Uc.current)==null?void 0:le.getTime()),xt=X==="x"?wt:or,ar=Math.abs(xt)/qr;if(Math.abs(xt)>=Cw||ar>.11){ka(Sn.current),(yt=f.onDismiss)==null||yt.call(f,f),qe(X==="x"?wt>0?"right":"left":or>0?"down":"up"),ir(),Ym(!0),Ac(!1);return}Sa(!1),Y(null)},onPointerMove:z=>{var te,le,yt,wt;if(!kn.current||!bn||((te=window.getSelection())==null?void 0:te.toString().length)>0)return;let or=z.clientY-kn.current.y,qr=z.clientX-kn.current.x,xt=(le=t.swipeDirections)!=null?le:Pw(ge);!X&&(Math.abs(qr)>1||Math.abs(or)>1)&&Y(Math.abs(qr)>Math.abs(or)?"x":"y");let ar={x:0,y:0};X==="y"?(xt.includes("top")||xt.includes("bottom"))&&(xt.includes("top")&&or<0||xt.includes("bottom")&&or>0)&&(ar.y=or):X==="x"&&(xt.includes("left")||xt.includes("right"))&&(xt.includes("left")&&qr<0||xt.includes("right")&&qr>0)&&(ar.x=qr),(Math.abs(ar.x)>0||Math.abs(ar.y)>0)&&Ac(!0),(yt=Hr.current)==null||yt.style.setProperty("--swipe-amount-x",`${ar.x}px`),(wt=Hr.current)==null||wt.style.setProperty("--swipe-amount-y",`${ar.y}px`)}},ig&&!f.jsx?O.createElement("button",{"aria-label":ie,"data-disabled":Ca,"data-close-button":!0,onClick:Ca||!bn?()=>{}:()=>{var z;ir(),(z=f.onDismiss)==null||z.call(f,f)},className:bt(R==null?void 0:R.closeButton,(s=f==null?void 0:f.classNames)==null?void 0:s.closeButton)},(i=D==null?void 0:D.close)!=null?i:hw):null,f.jsx||C.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:O.createElement(O.Fragment,null,lt||f.icon||f.promise?O.createElement("div",{"data-icon":"",className:bt(R==null?void 0:R.icon,(o=f==null?void 0:f.classNames)==null?void 0:o.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||ug():null,f.type!=="loading"?f.icon||(D==null?void 0:D[lt])||iw(lt):null):null,O.createElement("div",{"data-content":"",className:bt(R==null?void 0:R.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},O.createElement("div",{"data-title":"",className:bt(R==null?void 0:R.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?O.createElement("div",{"data-description":"",className:bt($,sg,R==null?void 0:R.description,(u=f==null?void 0:f.classNames)==null?void 0:u.description)},typeof f.description=="function"?f.description():f.description):null),C.isValidElement(f.cancel)?f.cancel:f.cancel&&eo(f.cancel)?O.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||E,onClick:z=>{var te,le;eo(f.cancel)&&bn&&((le=(te=f.cancel).onClick)==null||le.call(te,z),ir())},className:bt(R==null?void 0:R.cancelButton,(c=f==null?void 0:f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,C.isValidElement(f.action)?f.action:f.action&&eo(f.action)?O.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||F,onClick:z=>{var te,le;eo(f.action)&&((le=(te=f.action).onClick)==null||le.call(te,z),!z.defaultPrevented&&ir())},className:bt(R==null?void 0:R.actionButton,(d=f==null?void 0:f.classNames)==null?void 0:d.actionButton)},f.action.label):null))};function gh(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function Tw(t,e){let r={};return[t,e].forEach((n,s)=>{let i=s===1,o=i?"--mobile-offset":"--offset",a=i?Sw:bw;function l(u){["top","right","bottom","left"].forEach(c=>{r[`${o}-${c}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?l(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${o}-${u}`]=a:r[`${o}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):l(a)}),r}var Ow=C.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:o,className:a,offset:l,mobileOffset:u,theme:c="light",richColors:d,duration:m,style:f,visibleToasts:_=_w,toastOptions:x,dir:b=gh(),gap:v=Ew,loadingIcon:g,icons:p,containerAriaLabel:w="Notifications",pauseWhenPageIsHidden:k}=t,[S,j]=O.useState([]),T=O.useMemo(()=>Array.from(new Set([n].concat(S.filter(M=>M.position).map(M=>M.position)))),[S,n]),[P,E]=O.useState([]),[F,J]=O.useState(!1),[$,fe]=O.useState(!1),[ge,$e]=O.useState(c!=="system"?c:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Pe=O.useRef(null),L=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),R=O.useRef(null),D=O.useRef(!1),ie=O.useCallback(M=>{j(X=>{var Y;return(Y=X.find(ke=>ke.id===M.id))!=null&&Y.delete||Ve.dismiss(M.id),X.filter(({id:ke})=>ke!==M.id)})},[]);return O.useEffect(()=>Ve.subscribe(M=>{if(M.dismiss){j(X=>X.map(Y=>Y.id===M.id?{...Y,delete:!0}:Y));return}setTimeout(()=>{Dy.flushSync(()=>{j(X=>{let Y=X.findIndex(ke=>ke.id===M.id);return Y!==-1?[...X.slice(0,Y),{...X[Y],...M},...X.slice(Y+1)]:[M,...X]})})})}),[]),O.useEffect(()=>{if(c!=="system"){$e(c);return}if(c==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$e("dark"):$e("light")),typeof window>"u")return;let M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:X})=>{$e(X?"dark":"light")})}catch{M.addListener(({matches:Y})=>{try{$e(Y?"dark":"light")}catch(ke){console.error(ke)}})}},[c]),O.useEffect(()=>{S.length<=1&&J(!1)},[S]),O.useEffect(()=>{let M=X=>{var Y,ke;s.every(qe=>X[qe]||X.code===qe)&&(J(!0),(Y=Pe.current)==null||Y.focus()),X.code==="Escape"&&(document.activeElement===Pe.current||(ke=Pe.current)!=null&&ke.contains(document.activeElement))&&J(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[s]),O.useEffect(()=>{if(Pe.current)return()=>{R.current&&(R.current.focus({preventScroll:!0}),R.current=null,D.current=!1)}},[Pe.current]),O.createElement("section",{ref:e,"aria-label":`${w} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},T.map((M,X)=>{var Y;let[ke,qe]=M.split("-");return S.length?O.createElement("ol",{key:M,dir:b==="auto"?gh():b,tabIndex:-1,ref:Pe,className:a,"data-sonner-toaster":!0,"data-theme":ge,"data-y-position":ke,"data-lifted":F&&S.length>1&&!i,"data-x-position":qe,style:{"--front-toast-height":`${((Y=P[0])==null?void 0:Y.height)||0}px`,"--width":`${kw}px`,"--gap":`${v}px`,...f,...Tw(l,u)},onBlur:re=>{D.current&&!re.currentTarget.contains(re.relatedTarget)&&(D.current=!1,R.current&&(R.current.focus({preventScroll:!0}),R.current=null))},onFocus:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||D.current||(D.current=!0,R.current=re.relatedTarget)},onMouseEnter:()=>J(!0),onMouseMove:()=>J(!0),onMouseLeave:()=>{$||J(!1)},onDragEnd:()=>J(!1),onPointerDown:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||fe(!0)},onPointerUp:()=>fe(!1)},S.filter(re=>!re.position&&X===0||re.position===M).map((re,ba)=>{var Cs,Ii;return O.createElement(Nw,{key:re.id,icons:p,index:ba,toast:re,defaultRichColors:d,duration:(Cs=x==null?void 0:x.duration)!=null?Cs:m,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:r,visibleToasts:_,closeButton:(Ii=x==null?void 0:x.closeButton)!=null?Ii:o,interacting:$,position:M,style:x==null?void 0:x.style,unstyled:x==null?void 0:x.unstyled,classNames:x==null?void 0:x.classNames,cancelButtonStyle:x==null?void 0:x.cancelButtonStyle,actionButtonStyle:x==null?void 0:x.actionButtonStyle,removeToast:ie,toasts:S.filter(js=>js.position==re.position),heights:P.filter(js=>js.position==re.position),setHeights:E,expandByDefault:i,gap:v,loadingIcon:g,expanded:F,pauseWhenPageIsHidden:k,swipeDirections:t.swipeDirections})})):null}))});const Rw="modulepreload",Iw=function(t){return"/"+t},vh={},Ti=function(e,r,n){let s=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(r.map(l=>{if(l=Iw(l),l in vh)return;vh[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Rw,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((m,f)=>{d.addEventListener("load",m),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})},Lw=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Ti(async()=>{const{default:n}=await Promise.resolve().then(()=>ks);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};class Nc extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}}class Aw extends Nc{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class yh extends Nc{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class wh extends Nc{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var wu;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(wu||(wu={}));var $w=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};class Uw{constructor(e,{headers:r={},customFetch:n,region:s=wu.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=Lw(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return $w(this,void 0,void 0,function*(){try{const{headers:s,method:i,body:o}=r;let a={},{region:l}=r;l||(l=this.region);const u=new URL(`${this.url}/${e}`);l&&l!=="any"&&(a["x-region"]=l,u.searchParams.set("forceFunctionRegion",l));let c;o&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",c=o):typeof o=="string"?(a["Content-Type"]="text/plain",c=o):typeof FormData<"u"&&o instanceof FormData?c=o:(a["Content-Type"]="application/json",c=JSON.stringify(o)));const d=yield this.fetch(u.toString(),{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),s),body:c}).catch(x=>{throw new Aw(x)}),m=d.headers.get("x-relay-error");if(m&&m==="true")throw new yh(d);if(!d.ok)throw new wh(d);let f=((n=d.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),_;return f==="application/json"?_=yield d.json():f==="application/octet-stream"?_=yield d.blob():f==="text/event-stream"?_=d:f==="multipart/form-data"?_=yield d.formData():_=yield d.text(),{data:_,error:null,response:d}}catch(s){return{data:null,error:s,response:s instanceof wh||s instanceof yh?s.context:void 0}}})}}var Je={},Tc={},ga={},Oi={},va={},ya={},Dw=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},ws=Dw();const Mw=ws.fetch,Pm=ws.fetch.bind(ws),Nm=ws.Headers,Fw=ws.Request,zw=ws.Response,ks=Object.freeze(Object.defineProperty({__proto__:null,Headers:Nm,Request:Fw,Response:zw,default:Pm,fetch:Mw},Symbol.toStringTag,{value:"Module"})),Bw=dg(ks);var wa={};Object.defineProperty(wa,"__esModule",{value:!0});let Ww=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};wa.default=Ww;var Tm=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ya,"__esModule",{value:!0});const Hw=Tm(Bw),qw=Tm(wa);let Qw=class{constructor(e){var r,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(r=e.shouldThrowOnError)!==null&&r!==void 0?r:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=Hw.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,r){return this.headers=new Headers(this.headers),this.headers.set(e,r),this}then(e,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const n=this.fetch;let s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,l,u;let c=null,d=null,m=null,f=i.status,_=i.statusText;if(i.ok){if(this.method!=="HEAD"){const g=await i.text();g===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=g:d=JSON.parse(g))}const b=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),v=(l=i.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");b&&v&&v.length>1&&(m=parseInt(v[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(c={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,f=406,_="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{const b=await i.text();try{c=JSON.parse(b),Array.isArray(c)&&i.status===404&&(d=[],c=null,f=200,_="OK")}catch{i.status===404&&b===""?(f=204,_="No Content"):c={message:b}}if(c&&this.isMaybeSingle&&(!((u=c==null?void 0:c.details)===null||u===void 0)&&u.includes("0 rows"))&&(c=null,f=200,_="OK"),c&&this.shouldThrowOnError)throw new qw.default(c)}return{error:c,data:d,count:m,status:f,statusText:_}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,l;return{error:{message:`${(o=i==null?void 0:i.name)!==null&&o!==void 0?o:"FetchError"}: ${i==null?void 0:i.message}`,details:`${(a=i==null?void 0:i.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(l=i==null?void 0:i.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,r)}returns(){return this}overrideTypes(){return this}};ya.default=Qw;var Kw=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(va,"__esModule",{value:!0});const Vw=Kw(ya);let Gw=class extends Vw.default{select(e){let r=!1;const n=(e??"*").split("").map(s=>/\s/.test(s)&&!r?"":(s==='"'&&(r=!r),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:r=!0,nullsFirst:n,foreignTable:s,referencedTable:i=s}={}){const o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:r,referencedTable:n=r}={}){const s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,r,{foreignTable:n,referencedTable:s=n}={}){const i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${r-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:r=!1,settings:n=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;const l=[e?"analyze":null,r?"verbose":null,n?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),u=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${u}"; options=${l};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};va.default=Gw;var Jw=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Oi,"__esModule",{value:!0});const Yw=Jw(va);let Xw=class extends Yw.default{eq(e,r){return this.url.searchParams.append(e,`eq.${r}`),this}neq(e,r){return this.url.searchParams.append(e,`neq.${r}`),this}gt(e,r){return this.url.searchParams.append(e,`gt.${r}`),this}gte(e,r){return this.url.searchParams.append(e,`gte.${r}`),this}lt(e,r){return this.url.searchParams.append(e,`lt.${r}`),this}lte(e,r){return this.url.searchParams.append(e,`lte.${r}`),this}like(e,r){return this.url.searchParams.append(e,`like.${r}`),this}likeAllOf(e,r){return this.url.searchParams.append(e,`like(all).{${r.join(",")}}`),this}likeAnyOf(e,r){return this.url.searchParams.append(e,`like(any).{${r.join(",")}}`),this}ilike(e,r){return this.url.searchParams.append(e,`ilike.${r}`),this}ilikeAllOf(e,r){return this.url.searchParams.append(e,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(e,r){return this.url.searchParams.append(e,`ilike(any).{${r.join(",")}}`),this}is(e,r){return this.url.searchParams.append(e,`is.${r}`),this}in(e,r){const n=Array.from(new Set(r)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cs.{${r.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(r)}`),this}containedBy(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cd.{${r.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(r)}`),this}rangeGt(e,r){return this.url.searchParams.append(e,`sr.${r}`),this}rangeGte(e,r){return this.url.searchParams.append(e,`nxl.${r}`),this}rangeLt(e,r){return this.url.searchParams.append(e,`sl.${r}`),this}rangeLte(e,r){return this.url.searchParams.append(e,`nxr.${r}`),this}rangeAdjacent(e,r){return this.url.searchParams.append(e,`adj.${r}`),this}overlaps(e,r){return typeof r=="string"?this.url.searchParams.append(e,`ov.${r}`):this.url.searchParams.append(e,`ov.{${r.join(",")}}`),this}textSearch(e,r,{config:n,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const o=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${i}fts${o}.${r}`),this}match(e){return Object.entries(e).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(e,r,n){return this.url.searchParams.append(e,`not.${r}.${n}`),this}or(e,{foreignTable:r,referencedTable:n=r}={}){const s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,r,n){return this.url.searchParams.append(e,`${r}.${n}`),this}};Oi.default=Xw;var Zw=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ga,"__esModule",{value:!0});const Us=Zw(Oi);let ex=class{constructor(e,{headers:r={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(r),this.schema=n,this.fetch=s}select(e,{head:r=!1,count:n}={}){const s=r?"HEAD":"GET";let i=!1;const o=(e??"*").split("").map(a=>/\s/.test(a)&&!i?"":(a==='"'&&(i=!i),a)).join("");return this.url.searchParams.set("select",o),n&&this.headers.append("Prefer",`count=${n}`),new Us.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:r,defaultToNull:n=!0}={}){var s;const i="POST";if(r&&this.headers.append("Prefer",`count=${r}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){const o=e.reduce((a,l)=>a.concat(Object.keys(l)),[]);if(o.length>0){const a=[...new Set(o)].map(l=>`"${l}"`);this.url.searchParams.set("columns",a.join(","))}}return new Us.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:r,ignoreDuplicates:n=!1,count:s,defaultToNull:i=!0}={}){var o;const a="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),r!==void 0&&this.url.searchParams.set("on_conflict",r),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){const l=e.reduce((u,c)=>u.concat(Object.keys(c)),[]);if(l.length>0){const u=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",u.join(","))}}return new Us.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:r}={}){var n;const s="PATCH";return r&&this.headers.append("Prefer",`count=${r}`),new Us.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var r;const n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new Us.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}};ga.default=ex;var Om=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Tc,"__esModule",{value:!0});const tx=Om(ga),rx=Om(Oi);let nx=class Rm{constructor(e,{headers:r={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(r),this.schemaName=n,this.fetch=s}from(e){const r=new URL(`${this.url}/${e}`);return new tx.default(r,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new Rm(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:s=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let u;n||s?(a=n?"HEAD":"GET",Object.entries(r).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{l.searchParams.append(d,m)})):(a="POST",u=r);const c=new Headers(this.headers);return i&&c.set("Prefer",`count=${i}`),new rx.default({method:a,url:l,headers:c,schema:this.schemaName,body:u,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};Tc.default=nx;var Es=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Je,"__esModule",{value:!0});Je.PostgrestError=Je.PostgrestBuilder=Je.PostgrestTransformBuilder=Je.PostgrestFilterBuilder=Je.PostgrestQueryBuilder=Je.PostgrestClient=void 0;const Im=Es(Tc);Je.PostgrestClient=Im.default;const Lm=Es(ga);Je.PostgrestQueryBuilder=Lm.default;const Am=Es(Oi);Je.PostgrestFilterBuilder=Am.default;const $m=Es(va);Je.PostgrestTransformBuilder=$m.default;const Um=Es(ya);Je.PostgrestBuilder=Um.default;const Dm=Es(wa);Je.PostgrestError=Dm.default;var sx=Je.default={PostgrestClient:Im.default,PostgrestQueryBuilder:Lm.default,PostgrestFilterBuilder:Am.default,PostgrestTransformBuilder:$m.default,PostgrestBuilder:Um.default,PostgrestError:Dm.default};const{PostgrestClient:ix,PostgrestQueryBuilder:d1,PostgrestFilterBuilder:h1,PostgrestTransformBuilder:f1,PostgrestBuilder:p1,PostgrestError:m1}=sx;class ox{static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"&&process.versions&&process.versions.node){const r=parseInt(process.versions.node.split(".")[0]);return r>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${r} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${r} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: + */const k0="6";try{window.__reactRouterVersion=k0}catch{}const E0="startTransition",nh=jg[E0];function C0(t){let{basename:e,children:r,future:n,window:s}=t,i=C.useRef();i.current==null&&(i.current=My({window:s,v5Compat:!0}));let o=i.current,[a,l]=C.useState({action:o.action,location:o.location}),{v7_startTransition:u}=n||{},c=C.useCallback(d=>{u&&nh?nh(()=>l(d)):l(d)},[l,u]);return C.useLayoutEffect(()=>o.listen(c),[o,c]),C.useEffect(()=>_0(n),[n]),C.createElement(b0,{basename:e,children:r,location:a.location,navigationType:a.action,navigator:o,future:n})}var sh;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(sh||(sh={}));var ih;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(ih||(ih={}));var Ss=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},vn=typeof window>"u"||"Deno"in globalThis;function ze(){}function j0(t,e){return typeof t=="function"?t(e):t}function su(t){return typeof t=="number"&&t>=0&&t!==1/0}function mm(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Ur(t,e){return typeof t=="function"?t(e):t}function ct(t,e){return typeof t=="function"?t(e):t}function oh(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:i,queryKey:o,stale:a}=t;if(o){if(n){if(e.queryHash!==Ec(o,e.options))return!1}else if(!wi(e.queryKey,o))return!1}if(r!=="all"){const l=e.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||s&&s!==e.state.fetchStatus||i&&!i(e))}function ah(t,e){const{exact:r,status:n,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(yn(e.options.mutationKey)!==yn(i))return!1}else if(!wi(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Ec(t,e){return((e==null?void 0:e.queryKeyHashFn)||yn)(t)}function yn(t){return JSON.stringify(t,(e,r)=>iu(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function wi(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>wi(t[r],e[r])):!1}function gm(t,e){if(t===e)return t;const r=lh(t)&&lh(e);if(r||iu(t)&&iu(e)){const n=r?t:Object.keys(t),s=n.length,i=r?e:Object.keys(e),o=i.length,a=r?[]:{},l=new Set(n);let u=0;for(let c=0;c{setTimeout(e,t)})}function ou(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?gm(t,e):e}function N0(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function T0(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var Cc=Symbol();function vm(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===Cc?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function ym(t,e){return typeof t=="function"?t(...e):!!t}var tn,vr,Zn,Ah,O0=(Ah=class extends Ss{constructor(){super();U(this,tn);U(this,vr);U(this,Zn);I(this,Zn,e=>{if(!vn&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){y(this,vr)||this.setEventListener(y(this,Zn))}onUnsubscribe(){var e;this.hasListeners()||((e=y(this,vr))==null||e.call(this),I(this,vr,void 0))}setEventListener(e){var r;I(this,Zn,e),(r=y(this,vr))==null||r.call(this),I(this,vr,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){y(this,tn)!==e&&(I(this,tn,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof y(this,tn)=="boolean"?y(this,tn):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},tn=new WeakMap,vr=new WeakMap,Zn=new WeakMap,Ah),jc=new O0,es,yr,ts,$h,R0=($h=class extends Ss{constructor(){super();U(this,es,!0);U(this,yr);U(this,ts);I(this,ts,e=>{if(!vn&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){y(this,yr)||this.setEventListener(y(this,ts))}onUnsubscribe(){var e;this.hasListeners()||((e=y(this,yr))==null||e.call(this),I(this,yr,void 0))}setEventListener(e){var r;I(this,ts,e),(r=y(this,yr))==null||r.call(this),I(this,yr,e(this.setOnline.bind(this)))}setOnline(e){y(this,es)!==e&&(I(this,es,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return y(this,es)}},es=new WeakMap,yr=new WeakMap,ts=new WeakMap,$h),Ko=new R0;function au(){let t,e;const r=new Promise((s,i)=>{t=s,e=i});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function I0(t){return Math.min(1e3*2**t,3e4)}function wm(t){return(t??"online")==="online"?Ko.isOnline():!0}var xm=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function _m(t){let e=!1,r=0,n;const s=au(),i=()=>s.status!=="pending",o=x=>{var b;i()||(m(new xm(x)),(b=t.abort)==null||b.call(t))},a=()=>{e=!0},l=()=>{e=!1},u=()=>jc.isFocused()&&(t.networkMode==="always"||Ko.isOnline())&&t.canRun(),c=()=>wm(t.networkMode)&&t.canRun(),d=x=>{i()||(n==null||n(),s.resolve(x))},m=x=>{i()||(n==null||n(),s.reject(x))},f=()=>new Promise(x=>{var b;n=v=>{(i()||u())&&x(v)},(b=t.onPause)==null||b.call(t)}).then(()=>{var x;n=void 0,i()||(x=t.onContinue)==null||x.call(t)}),_=()=>{if(i())return;let x;const b=r===0?t.initialPromise:void 0;try{x=b??t.fn()}catch(v){x=Promise.reject(v)}Promise.resolve(x).then(d).catch(v=>{var S;if(i())return;const g=t.retry??(vn?0:3),p=t.retryDelay??I0,w=typeof p=="function"?p(r,v):p,k=g===!0||typeof g=="number"&&ru()?void 0:f()).then(()=>{e?m(v):_()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:a,continueRetry:l,canStart:c,start:()=>(c()?_():f().then(_),s)}}var L0=t=>setTimeout(t,0);function A0(){let t=[],e=0,r=a=>{a()},n=a=>{a()},s=L0;const i=a=>{e?t.push(a):s(()=>{r(a)})},o=()=>{const a=t;t=[],a.length&&s(()=>{n(()=>{a.forEach(l=>{r(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||o()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{r=a},setBatchNotifyFunction:a=>{n=a},setScheduler:a=>{s=a}}}var be=A0(),rn,Uh,bm=(Uh=class{constructor(){U(this,rn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),su(this.gcTime)&&I(this,rn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(vn?1/0:5*60*1e3))}clearGcTimeout(){y(this,rn)&&(clearTimeout(y(this,rn)),I(this,rn,void 0))}},rn=new WeakMap,Uh),rs,ns,ut,nn,Ee,_i,sn,Et,Bt,Dh,$0=(Dh=class extends bm{constructor(e){super();U(this,Et);U(this,rs);U(this,ns);U(this,ut);U(this,nn);U(this,Ee);U(this,_i);U(this,sn);I(this,sn,!1),I(this,_i,e.defaultOptions),this.setOptions(e.options),this.observers=[],I(this,nn,e.client),I(this,ut,y(this,nn).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,I(this,rs,U0(this.options)),this.state=e.state??y(this,rs),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=y(this,Ee))==null?void 0:e.promise}setOptions(e){this.options={...y(this,_i),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,ut).remove(this)}setData(e,r){const n=ou(this.state.data,e,this.options);return W(this,Et,Bt).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){W(this,Et,Bt).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=y(this,Ee))==null?void 0:n.promise;return(s=y(this,Ee))==null||s.cancel(e),r?r.then(ze).catch(ze):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,rs))}isActive(){return this.observers.some(e=>ct(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Cc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Ur(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!mm(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=y(this,Ee))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=y(this,Ee))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),y(this,ut).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(y(this,Ee)&&(y(this,sn)?y(this,Ee).cancel({revert:!0}):y(this,Ee).cancelRetry()),this.scheduleGc()),y(this,ut).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,Et,Bt).call(this,{type:"invalidate"})}async fetch(e,r){var l,u,c,d,m,f,_,x,b,v,g,p;if(this.state.fetchStatus!=="idle"&&((l=y(this,Ee))==null?void 0:l.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ee))return y(this,Ee).continueRetry(),y(this,Ee).promise}if(e&&this.setOptions(e),!this.options.queryFn){const w=this.observers.find(k=>k.options.queryFn);w&&this.setOptions(w.options)}const n=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(I(this,sn,!0),n.signal)})},i=()=>{const w=vm(this.options,r),S=(()=>{const j={client:y(this,nn),queryKey:this.queryKey,meta:this.meta};return s(j),j})();return I(this,sn,!1),this.options.persister?this.options.persister(w,S,this):w(S)},a=(()=>{const w={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:y(this,nn),state:this.state,fetchFn:i};return s(w),w})();(u=this.options.behavior)==null||u.onFetch(a,this),I(this,ns,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((c=a.fetchOptions)==null?void 0:c.meta))&&W(this,Et,Bt).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),I(this,Ee,_m({initialPromise:r==null?void 0:r.initialPromise,fn:a.fetchFn,abort:n.abort.bind(n),onFail:(w,k)=>{W(this,Et,Bt).call(this,{type:"failed",failureCount:w,error:k})},onPause:()=>{W(this,Et,Bt).call(this,{type:"pause"})},onContinue:()=>{W(this,Et,Bt).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ee).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(f=(m=y(this,ut).config).onSuccess)==null||f.call(m,w,this),(x=(_=y(this,ut).config).onSettled)==null||x.call(_,w,this.state.error,this),w}catch(w){if(w instanceof xm){if(w.silent)return y(this,Ee).promise;if(w.revert){if(this.setState({...y(this,ns),fetchStatus:"idle"}),this.state.data===void 0)throw w;return this.state.data}}throw W(this,Et,Bt).call(this,{type:"error",error:w}),(v=(b=y(this,ut).config).onError)==null||v.call(b,w,this),(p=(g=y(this,ut).config).onSettled)==null||p.call(g,this.state.data,w,this),w}finally{this.scheduleGc()}}},rs=new WeakMap,ns=new WeakMap,ut=new WeakMap,nn=new WeakMap,Ee=new WeakMap,_i=new WeakMap,sn=new WeakMap,Et=new WeakSet,Bt=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Sm(n.data,this.options),fetchMeta:e.meta??null};case"success":const s={...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return I(this,ns,e.manual?s:void 0),s;case"error":const i=e.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),be.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),y(this,ut).notify({query:this,type:"updated",action:e})})},Dh);function Sm(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:wm(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function U0(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var $t,Mh,D0=(Mh=class extends Ss{constructor(e={}){super();U(this,$t);this.config=e,I(this,$t,new Map)}build(e,r,n){const s=r.queryKey,i=r.queryHash??Ec(s,r);let o=this.get(i);return o||(o=new $0({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(o)),o}add(e){y(this,$t).has(e.queryHash)||(y(this,$t).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=y(this,$t).get(e.queryHash);r&&(e.destroy(),r===e&&y(this,$t).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){be.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return y(this,$t).get(e)}getAll(){return[...y(this,$t).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>oh(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>oh(e,n)):r}notify(e){be.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){be.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$t=new WeakMap,Mh),Ut,De,on,Dt,cr,Fh,M0=(Fh=class extends bm{constructor(e){super();U(this,Dt);U(this,Ut);U(this,De);U(this,on);this.mutationId=e.mutationId,I(this,De,e.mutationCache),I(this,Ut,[]),this.state=e.state||km(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){y(this,Ut).includes(e)||(y(this,Ut).push(e),this.clearGcTimeout(),y(this,De).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){I(this,Ut,y(this,Ut).filter(r=>r!==e)),this.scheduleGc(),y(this,De).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){y(this,Ut).length||(this.state.status==="pending"?this.scheduleGc():y(this,De).remove(this))}continue(){var e;return((e=y(this,on))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var i,o,a,l,u,c,d,m,f,_,x,b,v,g,p,w,k,S,j,T;const r=()=>{W(this,Dt,cr).call(this,{type:"continue"})};I(this,on,_m({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(P,E)=>{W(this,Dt,cr).call(this,{type:"failed",failureCount:P,error:E})},onPause:()=>{W(this,Dt,cr).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,De).canRun(this)}));const n=this.state.status==="pending",s=!y(this,on).canStart();try{if(n)r();else{W(this,Dt,cr).call(this,{type:"pending",variables:e,isPaused:s}),await((o=(i=y(this,De).config).onMutate)==null?void 0:o.call(i,e,this));const E=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,e));E!==this.state.context&&W(this,Dt,cr).call(this,{type:"pending",context:E,variables:e,isPaused:s})}const P=await y(this,on).start();return await((c=(u=y(this,De).config).onSuccess)==null?void 0:c.call(u,P,e,this.state.context,this)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,P,e,this.state.context)),await((_=(f=y(this,De).config).onSettled)==null?void 0:_.call(f,P,null,this.state.variables,this.state.context,this)),await((b=(x=this.options).onSettled)==null?void 0:b.call(x,P,null,e,this.state.context)),W(this,Dt,cr).call(this,{type:"success",data:P}),P}catch(P){try{throw await((g=(v=y(this,De).config).onError)==null?void 0:g.call(v,P,e,this.state.context,this)),await((w=(p=this.options).onError)==null?void 0:w.call(p,P,e,this.state.context)),await((S=(k=y(this,De).config).onSettled)==null?void 0:S.call(k,void 0,P,this.state.variables,this.state.context,this)),await((T=(j=this.options).onSettled)==null?void 0:T.call(j,void 0,P,e,this.state.context)),P}finally{W(this,Dt,cr).call(this,{type:"error",error:P})}}finally{y(this,De).runNext(this)}}},Ut=new WeakMap,De=new WeakMap,on=new WeakMap,Dt=new WeakSet,cr=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),be.batch(()=>{y(this,Ut).forEach(n=>{n.onMutationUpdate(e)}),y(this,De).notify({mutation:this,type:"updated",action:e})})},Fh);function km(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Kt,Ct,bi,zh,F0=(zh=class extends Ss{constructor(e={}){super();U(this,Kt);U(this,Ct);U(this,bi);this.config=e,I(this,Kt,new Set),I(this,Ct,new Map),I(this,bi,0)}build(e,r,n){const s=new M0({mutationCache:this,mutationId:++Ai(this,bi)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){y(this,Kt).add(e);const r=Zi(e);if(typeof r=="string"){const n=y(this,Ct).get(r);n?n.push(e):y(this,Ct).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(y(this,Kt).delete(e)){const r=Zi(e);if(typeof r=="string"){const n=y(this,Ct).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&y(this,Ct).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=Zi(e);if(typeof r=="string"){const n=y(this,Ct).get(r),s=n==null?void 0:n.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=Zi(e);if(typeof r=="string"){const s=(n=y(this,Ct).get(r))==null?void 0:n.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{y(this,Kt).forEach(e=>{this.notify({type:"removed",mutation:e})}),y(this,Kt).clear(),y(this,Ct).clear()})}getAll(){return Array.from(y(this,Kt))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>ah(r,n))}findAll(e={}){return this.getAll().filter(r=>ah(e,r))}notify(e){be.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return be.batch(()=>Promise.all(e.map(r=>r.continue().catch(ze))))}},Kt=new WeakMap,Ct=new WeakMap,bi=new WeakMap,zh);function Zi(t){var e;return(e=t.options.scope)==null?void 0:e.id}function ch(t){return{onFetch:(e,r)=>{var c,d,m,f,_;const n=e.options,s=(m=(d=(c=e.fetchOptions)==null?void 0:c.meta)==null?void 0:d.fetchMore)==null?void 0:m.direction,i=((f=e.state.data)==null?void 0:f.pages)||[],o=((_=e.state.data)==null?void 0:_.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const u=async()=>{let x=!1;const b=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(e.signal.aborted?x=!0:e.signal.addEventListener("abort",()=>{x=!0}),e.signal)})},v=vm(e.options,e.fetchOptions),g=async(p,w,k)=>{if(x)return Promise.reject();if(w==null&&p.pages.length)return Promise.resolve(p);const j=(()=>{const M={client:e.client,queryKey:e.queryKey,pageParam:w,direction:k?"backward":"forward",meta:e.options.meta};return b(M),M})(),T=await v(j),{maxPages:P}=e.options,E=k?T0:N0;return{pages:E(p.pages,T,P),pageParams:E(p.pageParams,w,P)}};if(s&&i.length){const p=s==="backward",w=p?z0:dh,k={pages:i,pageParams:o},S=w(n,k);a=await g(k,S,p)}else{const p=t??i.length;do{const w=l===0?o[0]??n.initialPageParam:dh(n,a);if(l>0&&w==null)break;a=await g(a,w),l++}while(l{var x,b;return(b=(x=e.options).persister)==null?void 0:b.call(x,u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=u}}}function dh(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function z0(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var pe,wr,xr,ss,is,_r,os,as,Bh,B0=(Bh=class{constructor(t={}){U(this,pe);U(this,wr);U(this,xr);U(this,ss);U(this,is);U(this,_r);U(this,os);U(this,as);I(this,pe,t.queryCache||new D0),I(this,wr,t.mutationCache||new F0),I(this,xr,t.defaultOptions||{}),I(this,ss,new Map),I(this,is,new Map),I(this,_r,0)}mount(){Ai(this,_r)._++,y(this,_r)===1&&(I(this,os,jc.subscribe(async t=>{t&&(await this.resumePausedMutations(),y(this,pe).onFocus())})),I(this,as,Ko.subscribe(async t=>{t&&(await this.resumePausedMutations(),y(this,pe).onOnline())})))}unmount(){var t,e;Ai(this,_r)._--,y(this,_r)===0&&((t=y(this,os))==null||t.call(this),I(this,os,void 0),(e=y(this,as))==null||e.call(this),I(this,as,void 0))}isFetching(t){return y(this,pe).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return y(this,wr).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=y(this,pe).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=y(this,pe).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Ur(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return y(this,pe).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=y(this,pe).get(n.queryHash),i=s==null?void 0:s.state.data,o=j0(e,i);if(o!==void 0)return y(this,pe).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return be.batch(()=>y(this,pe).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=y(this,pe).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=y(this,pe);be.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=y(this,pe);return be.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=be.batch(()=>y(this,pe).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(ze).catch(ze)}invalidateQueries(t,e={}){return be.batch(()=>(y(this,pe).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=be.batch(()=>y(this,pe).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,r);return r.throwOnError||(i=i.catch(ze)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(ze)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=y(this,pe).build(this,e);return r.isStaleByTime(Ur(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ze).catch(ze)}fetchInfiniteQuery(t){return t.behavior=ch(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ze).catch(ze)}ensureInfiniteQueryData(t){return t.behavior=ch(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Ko.isOnline()?y(this,wr).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,pe)}getMutationCache(){return y(this,wr)}getDefaultOptions(){return y(this,xr)}setDefaultOptions(t){I(this,xr,t)}setQueryDefaults(t,e){y(this,ss).set(yn(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...y(this,ss).values()],r={};return e.forEach(n=>{wi(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){y(this,is).set(yn(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...y(this,is).values()],r={};return e.forEach(n=>{wi(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...y(this,xr).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Ec(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Cc&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...y(this,xr).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){y(this,pe).clear(),y(this,wr).clear()}},pe=new WeakMap,wr=new WeakMap,xr=new WeakMap,ss=new WeakMap,is=new WeakMap,_r=new WeakMap,os=new WeakMap,as=new WeakMap,Bh),Qe,G,Si,Me,an,ls,Vt,br,ki,us,cs,ln,un,Sr,ds,Z,Bs,lu,uu,cu,du,hu,fu,pu,Em,Wh,W0=(Wh=class extends Ss{constructor(e,r){super();U(this,Z);U(this,Qe);U(this,G);U(this,Si);U(this,Me);U(this,an);U(this,ls);U(this,Vt);U(this,br);U(this,ki);U(this,us);U(this,cs);U(this,ln);U(this,un);U(this,Sr);U(this,ds,new Set);this.options=r,I(this,Qe,e),I(this,br,null),I(this,Vt,au()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,G).addObserver(this),hh(y(this,G),this.options)?W(this,Z,Bs).call(this):this.updateResult(),W(this,Z,du).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return mu(y(this,G),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return mu(y(this,G),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,Z,hu).call(this),W(this,Z,fu).call(this),y(this,G).removeObserver(this)}setOptions(e){const r=this.options,n=y(this,G);if(this.options=y(this,Qe).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ct(this.options.enabled,y(this,G))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,Z,pu).call(this),y(this,G).setOptions(this.options),r._defaulted&&!Qo(this.options,r)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,G),observer:this});const s=this.hasListeners();s&&fh(y(this,G),n,this.options,r)&&W(this,Z,Bs).call(this),this.updateResult(),s&&(y(this,G)!==n||ct(this.options.enabled,y(this,G))!==ct(r.enabled,y(this,G))||Ur(this.options.staleTime,y(this,G))!==Ur(r.staleTime,y(this,G)))&&W(this,Z,lu).call(this);const i=W(this,Z,uu).call(this);s&&(y(this,G)!==n||ct(this.options.enabled,y(this,G))!==ct(r.enabled,y(this,G))||i!==y(this,Sr))&&W(this,Z,cu).call(this,i)}getOptimisticResult(e){const r=y(this,Qe).getQueryCache().build(y(this,Qe),e),n=this.createResult(r,e);return q0(this,n)&&(I(this,Me,n),I(this,ls,this.options),I(this,an,y(this,G).state)),n}getCurrentResult(){return y(this,Me)}trackResult(e,r){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),r==null||r(s),s==="promise"&&!this.options.experimental_prefetchInRender&&y(this,Vt).status==="pending"&&y(this,Vt).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(n,s))})}trackProp(e){y(this,ds).add(e)}getCurrentQuery(){return y(this,G)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=y(this,Qe).defaultQueryOptions(e),n=y(this,Qe).getQueryCache().build(y(this,Qe),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return W(this,Z,Bs).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Me)))}createResult(e,r){var P;const n=y(this,G),s=this.options,i=y(this,Me),o=y(this,an),a=y(this,ls),u=e!==n?e.state:y(this,Si),{state:c}=e;let d={...c},m=!1,f;if(r._optimisticResults){const E=this.hasListeners(),M=!E&&hh(e,r),q=E&&fh(e,n,r,s);(M||q)&&(d={...d,...Sm(c.data,e.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:_,errorUpdatedAt:x,status:b}=d;f=d.data;let v=!1;if(r.placeholderData!==void 0&&f===void 0&&b==="pending"){let E;i!=null&&i.isPlaceholderData&&r.placeholderData===(a==null?void 0:a.placeholderData)?(E=i.data,v=!0):E=typeof r.placeholderData=="function"?r.placeholderData((P=y(this,cs))==null?void 0:P.state.data,y(this,cs)):r.placeholderData,E!==void 0&&(b="success",f=ou(i==null?void 0:i.data,E,r),m=!0)}if(r.select&&f!==void 0&&!v)if(i&&f===(o==null?void 0:o.data)&&r.select===y(this,ki))f=y(this,us);else try{I(this,ki,r.select),f=r.select(f),f=ou(i==null?void 0:i.data,f,r),I(this,us,f),I(this,br,null)}catch(E){I(this,br,E)}y(this,br)&&(_=y(this,br),f=y(this,us),x=Date.now(),b="error");const g=d.fetchStatus==="fetching",p=b==="pending",w=b==="error",k=p&&g,S=f!==void 0,T={status:b,fetchStatus:d.fetchStatus,isPending:p,isSuccess:b==="success",isError:w,isInitialLoading:k,isLoading:k,data:f,dataUpdatedAt:d.dataUpdatedAt,error:_,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&!p,isLoadingError:w&&!S,isPaused:d.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:w&&S,isStale:Pc(e,r),refetch:this.refetch,promise:y(this,Vt),isEnabled:ct(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const E=$=>{T.status==="error"?$.reject(T.error):T.data!==void 0&&$.resolve(T.data)},M=()=>{const $=I(this,Vt,T.promise=au());E($)},q=y(this,Vt);switch(q.status){case"pending":e.queryHash===n.queryHash&&E(q);break;case"fulfilled":(T.status==="error"||T.data!==q.value)&&M();break;case"rejected":(T.status!=="error"||T.error!==q.reason)&&M();break}}return T}updateResult(){const e=y(this,Me),r=this.createResult(y(this,G),this.options);if(I(this,an,y(this,G).state),I(this,ls,this.options),y(this,an).data!==void 0&&I(this,cs,y(this,G)),Qo(r,e))return;I(this,Me,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,ds).size)return!0;const o=new Set(i??y(this,ds));return this.options.throwOnError&&o.add("error"),Object.keys(y(this,Me)).some(a=>{const l=a;return y(this,Me)[l]!==e[l]&&o.has(l)})};W(this,Z,Em).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,Z,du).call(this)}},Qe=new WeakMap,G=new WeakMap,Si=new WeakMap,Me=new WeakMap,an=new WeakMap,ls=new WeakMap,Vt=new WeakMap,br=new WeakMap,ki=new WeakMap,us=new WeakMap,cs=new WeakMap,ln=new WeakMap,un=new WeakMap,Sr=new WeakMap,ds=new WeakMap,Z=new WeakSet,Bs=function(e){W(this,Z,pu).call(this);let r=y(this,G).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(ze)),r},lu=function(){W(this,Z,hu).call(this);const e=Ur(this.options.staleTime,y(this,G));if(vn||y(this,Me).isStale||!su(e))return;const n=mm(y(this,Me).dataUpdatedAt,e)+1;I(this,ln,setTimeout(()=>{y(this,Me).isStale||this.updateResult()},n))},uu=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,G)):this.options.refetchInterval)??!1},cu=function(e){W(this,Z,fu).call(this),I(this,Sr,e),!(vn||ct(this.options.enabled,y(this,G))===!1||!su(y(this,Sr))||y(this,Sr)===0)&&I(this,un,setInterval(()=>{(this.options.refetchIntervalInBackground||jc.isFocused())&&W(this,Z,Bs).call(this)},y(this,Sr)))},du=function(){W(this,Z,lu).call(this),W(this,Z,cu).call(this,W(this,Z,uu).call(this))},hu=function(){y(this,ln)&&(clearTimeout(y(this,ln)),I(this,ln,void 0))},fu=function(){y(this,un)&&(clearInterval(y(this,un)),I(this,un,void 0))},pu=function(){const e=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(e===y(this,G))return;const r=y(this,G);I(this,G,e),I(this,Si,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Em=function(e){be.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(y(this,Me))}),y(this,Qe).getQueryCache().notify({query:y(this,G),type:"observerResultsUpdated"})})},Wh);function H0(t,e){return ct(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function hh(t,e){return H0(t,e)||t.state.data!==void 0&&mu(t,e,e.refetchOnMount)}function mu(t,e,r){if(ct(e.enabled,t)!==!1&&Ur(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&Pc(t,e)}return!1}function fh(t,e,r,n){return(t!==e||ct(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Pc(t,r)}function Pc(t,e){return ct(e.enabled,t)!==!1&&t.isStaleByTime(Ur(e.staleTime,t))}function q0(t,e){return!Qo(t.getCurrentResult(),e)}var kr,Er,Ke,Gt,Zt,wo,gu,Hh,Q0=(Hh=class extends Ss{constructor(r,n){super();U(this,Zt);U(this,kr);U(this,Er);U(this,Ke);U(this,Gt);I(this,kr,r),this.setOptions(n),this.bindMethods(),W(this,Zt,wo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var s;const n=this.options;this.options=y(this,kr).defaultMutationOptions(r),Qo(this.options,n)||y(this,kr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ke),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&yn(n.mutationKey)!==yn(this.options.mutationKey)?this.reset():((s=y(this,Ke))==null?void 0:s.state.status)==="pending"&&y(this,Ke).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=y(this,Ke))==null||r.removeObserver(this)}onMutationUpdate(r){W(this,Zt,wo).call(this),W(this,Zt,gu).call(this,r)}getCurrentResult(){return y(this,Er)}reset(){var r;(r=y(this,Ke))==null||r.removeObserver(this),I(this,Ke,void 0),W(this,Zt,wo).call(this),W(this,Zt,gu).call(this)}mutate(r,n){var s;return I(this,Gt,n),(s=y(this,Ke))==null||s.removeObserver(this),I(this,Ke,y(this,kr).getMutationCache().build(y(this,kr),this.options)),y(this,Ke).addObserver(this),y(this,Ke).execute(r)}},kr=new WeakMap,Er=new WeakMap,Ke=new WeakMap,Gt=new WeakMap,Zt=new WeakSet,wo=function(){var n;const r=((n=y(this,Ke))==null?void 0:n.state)??km();I(this,Er,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},gu=function(r){be.batch(()=>{var n,s,i,o,a,l,u,c;if(y(this,Gt)&&this.hasListeners()){const d=y(this,Er).variables,m=y(this,Er).context;(r==null?void 0:r.type)==="success"?((s=(n=y(this,Gt)).onSuccess)==null||s.call(n,r.data,d,m),(o=(i=y(this,Gt)).onSettled)==null||o.call(i,r.data,null,d,m)):(r==null?void 0:r.type)==="error"&&((l=(a=y(this,Gt)).onError)==null||l.call(a,r.error,d,m),(c=(u=y(this,Gt)).onSettled)==null||c.call(u,void 0,r.error,d,m))}this.listeners.forEach(d=>{d(y(this,Er))})})},Hh),Cm=C.createContext(void 0),ma=t=>{const e=C.useContext(Cm);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},K0=({client:t,children:e})=>(C.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),h.jsx(Cm.Provider,{value:t,children:e})),jm=C.createContext(!1),V0=()=>C.useContext(jm);jm.Provider;function G0(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var J0=C.createContext(G0()),Y0=()=>C.useContext(J0),X0=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Z0=t=>{C.useEffect(()=>{t.clearReset()},[t])},ew=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||ym(r,[t.error,n])),tw=t=>{if(t.suspense){const e=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>e(r(...n)):e(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},rw=(t,e)=>t.isLoading&&t.isFetching&&!e,nw=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ph=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function sw(t,e,r){var d,m,f,_,x;const n=V0(),s=Y0(),i=ma(),o=i.defaultQueryOptions(t);(m=(d=i.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||m.call(d,o),o._optimisticResults=n?"isRestoring":"optimistic",tw(o),X0(o,s),Z0(s);const a=!i.getQueryCache().get(o.queryHash),[l]=C.useState(()=>new e(i,o)),u=l.getOptimisticResult(o),c=!n&&t.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(b=>{const v=c?l.subscribe(be.batchCalls(b)):ze;return l.updateResult(),v},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),C.useEffect(()=>{l.setOptions(o)},[o,l]),nw(o,u))throw ph(o,l,s);if(ew({result:u,errorResetBoundary:s,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;if((_=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||_.call(f,o,u),o.experimental_prefetchInRender&&!vn&&rw(u,n)){const b=a?ph(o,l,s):(x=i.getQueryCache().get(o.queryHash))==null?void 0:x.promise;b==null||b.catch(ze).finally(()=>{l.updateResult()})}return o.notifyOnChangeProps?u:l.trackResult(u)}function vu(t,e){return sw(t,W0)}function Xn(t,e){const r=ma(),[n]=C.useState(()=>new Q0(r,t));C.useEffect(()=>{n.setOptions(t)},[n,t]);const s=C.useSyncExternalStore(C.useCallback(o=>n.subscribe(be.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=C.useCallback((o,a)=>{n.mutate(o,a).catch(ze)},[n]);if(s.error&&ym(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}var iw=t=>{switch(t){case"success":return lw;case"info":return cw;case"warning":return uw;case"error":return dw;default:return null}},ow=Array(12).fill(0),aw=({visible:t,className:e})=>O.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},O.createElement("div",{className:"sonner-spinner"},ow.map((r,n)=>O.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),lw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),uw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),cw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),dw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),hw=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},O.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),O.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),fw=()=>{let[t,e]=O.useState(document.hidden);return O.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},yu=1,pw=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...n}=t,s=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:yu++,i=this.toasts.find(a=>a.id===s),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(a=>a.id===s?(this.publish({...a,...t,id:s,title:r}),{...a,...t,id:s,dismissible:o,title:r}):a):this.addToast({title:r,...n,dismissible:o,id:s}),s},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let n=t instanceof Promise?t:t(),s=r!==void 0,i,o=n.then(async l=>{if(i=["resolve",l],O.isValidElement(l))s=!1,this.create({id:r,type:"default",message:l});else if(gw(l)&&!l.ok){s=!1;let u=typeof e.error=="function"?await e.error(`HTTP error! status: ${l.status}`):e.error,c=typeof e.description=="function"?await e.description(`HTTP error! status: ${l.status}`):e.description;this.create({id:r,type:"error",message:u,description:c})}else if(e.success!==void 0){s=!1;let u=typeof e.success=="function"?await e.success(l):e.success,c=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"success",message:u,description:c})}}).catch(async l=>{if(i=["reject",l],e.error!==void 0){s=!1;let u=typeof e.error=="function"?await e.error(l):e.error,c=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"error",message:u,description:c})}}).finally(()=>{var l;s&&(this.dismiss(r),r=void 0),(l=e.finally)==null||l.call(e)}),a=()=>new Promise((l,u)=>o.then(()=>i[0]==="reject"?u(i[1]):l(i[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:a}:Object.assign(r,{unwrap:a})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||yu++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ve=new pw,mw=(t,e)=>{let r=(e==null?void 0:e.id)||yu++;return Ve.addToast({title:t,...e,id:r}),r},gw=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",vw=mw,yw=()=>Ve.toasts,ww=()=>Ve.getActiveToasts(),H=Object.assign(vw,{success:Ve.success,info:Ve.info,warning:Ve.warning,error:Ve.error,custom:Ve.custom,message:Ve.message,promise:Ve.promise,dismiss:Ve.dismiss,loading:Ve.loading},{getHistory:yw,getToasts:ww});function xw(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}xw(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} +`);function eo(t){return t.label!==void 0}var _w=3,bw="32px",Sw="16px",mh=4e3,kw=356,Ew=14,Cw=20,jw=200;function bt(...t){return t.filter(Boolean).join(" ")}function Pw(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var Nw=t=>{var e,r,n,s,i,o,a,l,u,c,d;let{invert:m,toast:f,unstyled:_,interacting:x,setHeights:b,visibleToasts:v,heights:g,index:p,toasts:w,expanded:k,removeToast:S,defaultRichColors:j,closeButton:T,style:P,cancelButtonStyle:E,actionButtonStyle:M,className:q="",descriptionClassName:$="",duration:fe,position:ge,gap:$e,loadingIcon:Pe,expandByDefault:L,classNames:R,icons:D,closeButtonAriaLabel:ie="Close toast",pauseWhenPageIsHidden:F}=t,[X,Y]=O.useState(null),[ke,qe]=O.useState(null),[re,ba]=O.useState(!1),[Cs,Ii]=O.useState(!1),[js,Sa]=O.useState(!1),[Lc,Ym]=O.useState(!1),[Xm,Ac]=O.useState(!1),[Zm,ka]=O.useState(0),[eg,$c]=O.useState(0),Ps=O.useRef(f.duration||fe||mh),Uc=O.useRef(null),Hr=O.useRef(null),tg=p===0,rg=p+1<=v,lt=f.type,bn=f.dismissible!==!1,ng=f.className||"",sg=f.descriptionClassName||"",Li=O.useMemo(()=>g.findIndex(z=>z.toastId===f.id)||0,[g,f.id]),ig=O.useMemo(()=>{var z;return(z=f.closeButton)!=null?z:T},[f.closeButton,T]),Dc=O.useMemo(()=>f.duration||fe||mh,[f.duration,fe]),Ea=O.useRef(0),Sn=O.useRef(0),Mc=O.useRef(0),kn=O.useRef(null),[og,ag]=ge.split("-"),Fc=O.useMemo(()=>g.reduce((z,te,le)=>le>=Li?z:z+te.height,0),[g,Li]),zc=fw(),lg=f.invert||m,Ca=lt==="loading";Sn.current=O.useMemo(()=>Li*$e+Fc,[Li,Fc]),O.useEffect(()=>{Ps.current=Dc},[Dc]),O.useEffect(()=>{ba(!0)},[]),O.useEffect(()=>{let z=Hr.current;if(z){let te=z.getBoundingClientRect().height;return $c(te),b(le=>[{toastId:f.id,height:te,position:f.position},...le]),()=>b(le=>le.filter(yt=>yt.toastId!==f.id))}},[b,f.id]),O.useLayoutEffect(()=>{if(!re)return;let z=Hr.current,te=z.style.height;z.style.height="auto";let le=z.getBoundingClientRect().height;z.style.height=te,$c(le),b(yt=>yt.find(wt=>wt.toastId===f.id)?yt.map(wt=>wt.toastId===f.id?{...wt,height:le}:wt):[{toastId:f.id,height:le,position:f.position},...yt])},[re,f.title,f.description,b,f.id]);let ir=O.useCallback(()=>{Ii(!0),ka(Sn.current),b(z=>z.filter(te=>te.toastId!==f.id)),setTimeout(()=>{S(f)},jw)},[f,S,b,Sn]);O.useEffect(()=>{if(f.promise&<==="loading"||f.duration===1/0||f.type==="loading")return;let z;return k||x||F&&zc?(()=>{if(Mc.current{var te;(te=f.onAutoClose)==null||te.call(f,f),ir()},Ps.current)),()=>clearTimeout(z)},[k,x,f,lt,F,zc,ir]),O.useEffect(()=>{f.delete&&ir()},[ir,f.delete]);function ug(){var z,te,le;return D!=null&&D.loading?O.createElement("div",{className:bt(R==null?void 0:R.loader,(z=f==null?void 0:f.classNames)==null?void 0:z.loader,"sonner-loader"),"data-visible":lt==="loading"},D.loading):Pe?O.createElement("div",{className:bt(R==null?void 0:R.loader,(te=f==null?void 0:f.classNames)==null?void 0:te.loader,"sonner-loader"),"data-visible":lt==="loading"},Pe):O.createElement(aw,{className:bt(R==null?void 0:R.loader,(le=f==null?void 0:f.classNames)==null?void 0:le.loader),visible:lt==="loading"})}return O.createElement("li",{tabIndex:0,ref:Hr,className:bt(q,ng,R==null?void 0:R.toast,(e=f==null?void 0:f.classNames)==null?void 0:e.toast,R==null?void 0:R.default,R==null?void 0:R[lt],(r=f==null?void 0:f.classNames)==null?void 0:r[lt]),"data-sonner-toast":"","data-rich-colors":(n=f.richColors)!=null?n:j,"data-styled":!(f.jsx||f.unstyled||_),"data-mounted":re,"data-promise":!!f.promise,"data-swiped":Xm,"data-removed":Cs,"data-visible":rg,"data-y-position":og,"data-x-position":ag,"data-index":p,"data-front":tg,"data-swiping":js,"data-dismissible":bn,"data-type":lt,"data-invert":lg,"data-swipe-out":Lc,"data-swipe-direction":ke,"data-expanded":!!(k||L&&re),style:{"--index":p,"--toasts-before":p,"--z-index":w.length-p,"--offset":`${Cs?Zm:Sn.current}px`,"--initial-height":L?"auto":`${eg}px`,...P,...f.style},onDragEnd:()=>{Sa(!1),Y(null),kn.current=null},onPointerDown:z=>{Ca||!bn||(Uc.current=new Date,ka(Sn.current),z.target.setPointerCapture(z.pointerId),z.target.tagName!=="BUTTON"&&(Sa(!0),kn.current={x:z.clientX,y:z.clientY}))},onPointerUp:()=>{var z,te,le,yt;if(Lc||!bn)return;kn.current=null;let wt=Number(((z=Hr.current)==null?void 0:z.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),or=Number(((te=Hr.current)==null?void 0:te.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),qr=new Date().getTime()-((le=Uc.current)==null?void 0:le.getTime()),xt=X==="x"?wt:or,ar=Math.abs(xt)/qr;if(Math.abs(xt)>=Cw||ar>.11){ka(Sn.current),(yt=f.onDismiss)==null||yt.call(f,f),qe(X==="x"?wt>0?"right":"left":or>0?"down":"up"),ir(),Ym(!0),Ac(!1);return}Sa(!1),Y(null)},onPointerMove:z=>{var te,le,yt,wt;if(!kn.current||!bn||((te=window.getSelection())==null?void 0:te.toString().length)>0)return;let or=z.clientY-kn.current.y,qr=z.clientX-kn.current.x,xt=(le=t.swipeDirections)!=null?le:Pw(ge);!X&&(Math.abs(qr)>1||Math.abs(or)>1)&&Y(Math.abs(qr)>Math.abs(or)?"x":"y");let ar={x:0,y:0};X==="y"?(xt.includes("top")||xt.includes("bottom"))&&(xt.includes("top")&&or<0||xt.includes("bottom")&&or>0)&&(ar.y=or):X==="x"&&(xt.includes("left")||xt.includes("right"))&&(xt.includes("left")&&qr<0||xt.includes("right")&&qr>0)&&(ar.x=qr),(Math.abs(ar.x)>0||Math.abs(ar.y)>0)&&Ac(!0),(yt=Hr.current)==null||yt.style.setProperty("--swipe-amount-x",`${ar.x}px`),(wt=Hr.current)==null||wt.style.setProperty("--swipe-amount-y",`${ar.y}px`)}},ig&&!f.jsx?O.createElement("button",{"aria-label":ie,"data-disabled":Ca,"data-close-button":!0,onClick:Ca||!bn?()=>{}:()=>{var z;ir(),(z=f.onDismiss)==null||z.call(f,f)},className:bt(R==null?void 0:R.closeButton,(s=f==null?void 0:f.classNames)==null?void 0:s.closeButton)},(i=D==null?void 0:D.close)!=null?i:hw):null,f.jsx||C.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:O.createElement(O.Fragment,null,lt||f.icon||f.promise?O.createElement("div",{"data-icon":"",className:bt(R==null?void 0:R.icon,(o=f==null?void 0:f.classNames)==null?void 0:o.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||ug():null,f.type!=="loading"?f.icon||(D==null?void 0:D[lt])||iw(lt):null):null,O.createElement("div",{"data-content":"",className:bt(R==null?void 0:R.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},O.createElement("div",{"data-title":"",className:bt(R==null?void 0:R.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?O.createElement("div",{"data-description":"",className:bt($,sg,R==null?void 0:R.description,(u=f==null?void 0:f.classNames)==null?void 0:u.description)},typeof f.description=="function"?f.description():f.description):null),C.isValidElement(f.cancel)?f.cancel:f.cancel&&eo(f.cancel)?O.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||E,onClick:z=>{var te,le;eo(f.cancel)&&bn&&((le=(te=f.cancel).onClick)==null||le.call(te,z),ir())},className:bt(R==null?void 0:R.cancelButton,(c=f==null?void 0:f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,C.isValidElement(f.action)?f.action:f.action&&eo(f.action)?O.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||M,onClick:z=>{var te,le;eo(f.action)&&((le=(te=f.action).onClick)==null||le.call(te,z),!z.defaultPrevented&&ir())},className:bt(R==null?void 0:R.actionButton,(d=f==null?void 0:f.classNames)==null?void 0:d.actionButton)},f.action.label):null))};function gh(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function Tw(t,e){let r={};return[t,e].forEach((n,s)=>{let i=s===1,o=i?"--mobile-offset":"--offset",a=i?Sw:bw;function l(u){["top","right","bottom","left"].forEach(c=>{r[`${o}-${c}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?l(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${o}-${u}`]=a:r[`${o}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):l(a)}),r}var Ow=C.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:o,className:a,offset:l,mobileOffset:u,theme:c="light",richColors:d,duration:m,style:f,visibleToasts:_=_w,toastOptions:x,dir:b=gh(),gap:v=Ew,loadingIcon:g,icons:p,containerAriaLabel:w="Notifications",pauseWhenPageIsHidden:k}=t,[S,j]=O.useState([]),T=O.useMemo(()=>Array.from(new Set([n].concat(S.filter(F=>F.position).map(F=>F.position)))),[S,n]),[P,E]=O.useState([]),[M,q]=O.useState(!1),[$,fe]=O.useState(!1),[ge,$e]=O.useState(c!=="system"?c:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Pe=O.useRef(null),L=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),R=O.useRef(null),D=O.useRef(!1),ie=O.useCallback(F=>{j(X=>{var Y;return(Y=X.find(ke=>ke.id===F.id))!=null&&Y.delete||Ve.dismiss(F.id),X.filter(({id:ke})=>ke!==F.id)})},[]);return O.useEffect(()=>Ve.subscribe(F=>{if(F.dismiss){j(X=>X.map(Y=>Y.id===F.id?{...Y,delete:!0}:Y));return}setTimeout(()=>{Dy.flushSync(()=>{j(X=>{let Y=X.findIndex(ke=>ke.id===F.id);return Y!==-1?[...X.slice(0,Y),{...X[Y],...F},...X.slice(Y+1)]:[F,...X]})})})}),[]),O.useEffect(()=>{if(c!=="system"){$e(c);return}if(c==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$e("dark"):$e("light")),typeof window>"u")return;let F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:X})=>{$e(X?"dark":"light")})}catch{F.addListener(({matches:Y})=>{try{$e(Y?"dark":"light")}catch(ke){console.error(ke)}})}},[c]),O.useEffect(()=>{S.length<=1&&q(!1)},[S]),O.useEffect(()=>{let F=X=>{var Y,ke;s.every(qe=>X[qe]||X.code===qe)&&(q(!0),(Y=Pe.current)==null||Y.focus()),X.code==="Escape"&&(document.activeElement===Pe.current||(ke=Pe.current)!=null&&ke.contains(document.activeElement))&&q(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[s]),O.useEffect(()=>{if(Pe.current)return()=>{R.current&&(R.current.focus({preventScroll:!0}),R.current=null,D.current=!1)}},[Pe.current]),O.createElement("section",{ref:e,"aria-label":`${w} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},T.map((F,X)=>{var Y;let[ke,qe]=F.split("-");return S.length?O.createElement("ol",{key:F,dir:b==="auto"?gh():b,tabIndex:-1,ref:Pe,className:a,"data-sonner-toaster":!0,"data-theme":ge,"data-y-position":ke,"data-lifted":M&&S.length>1&&!i,"data-x-position":qe,style:{"--front-toast-height":`${((Y=P[0])==null?void 0:Y.height)||0}px`,"--width":`${kw}px`,"--gap":`${v}px`,...f,...Tw(l,u)},onBlur:re=>{D.current&&!re.currentTarget.contains(re.relatedTarget)&&(D.current=!1,R.current&&(R.current.focus({preventScroll:!0}),R.current=null))},onFocus:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||D.current||(D.current=!0,R.current=re.relatedTarget)},onMouseEnter:()=>q(!0),onMouseMove:()=>q(!0),onMouseLeave:()=>{$||q(!1)},onDragEnd:()=>q(!1),onPointerDown:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||fe(!0)},onPointerUp:()=>fe(!1)},S.filter(re=>!re.position&&X===0||re.position===F).map((re,ba)=>{var Cs,Ii;return O.createElement(Nw,{key:re.id,icons:p,index:ba,toast:re,defaultRichColors:d,duration:(Cs=x==null?void 0:x.duration)!=null?Cs:m,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:r,visibleToasts:_,closeButton:(Ii=x==null?void 0:x.closeButton)!=null?Ii:o,interacting:$,position:F,style:x==null?void 0:x.style,unstyled:x==null?void 0:x.unstyled,classNames:x==null?void 0:x.classNames,cancelButtonStyle:x==null?void 0:x.cancelButtonStyle,actionButtonStyle:x==null?void 0:x.actionButtonStyle,removeToast:ie,toasts:S.filter(js=>js.position==re.position),heights:P.filter(js=>js.position==re.position),setHeights:E,expandByDefault:i,gap:v,loadingIcon:g,expanded:M,pauseWhenPageIsHidden:k,swipeDirections:t.swipeDirections})})):null}))});const Rw="modulepreload",Iw=function(t){return"/"+t},vh={},Ti=function(e,r,n){let s=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(r.map(l=>{if(l=Iw(l),l in vh)return;vh[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Rw,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((m,f)=>{d.addEventListener("load",m),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})},Lw=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Ti(async()=>{const{default:n}=await Promise.resolve().then(()=>ks);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};class Nc extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}}class Aw extends Nc{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class yh extends Nc{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class wh extends Nc{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var wu;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(wu||(wu={}));var $w=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};class Uw{constructor(e,{headers:r={},customFetch:n,region:s=wu.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=Lw(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return $w(this,void 0,void 0,function*(){try{const{headers:s,method:i,body:o}=r;let a={},{region:l}=r;l||(l=this.region);const u=new URL(`${this.url}/${e}`);l&&l!=="any"&&(a["x-region"]=l,u.searchParams.set("forceFunctionRegion",l));let c;o&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",c=o):typeof o=="string"?(a["Content-Type"]="text/plain",c=o):typeof FormData<"u"&&o instanceof FormData?c=o:(a["Content-Type"]="application/json",c=JSON.stringify(o)));const d=yield this.fetch(u.toString(),{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),s),body:c}).catch(x=>{throw new Aw(x)}),m=d.headers.get("x-relay-error");if(m&&m==="true")throw new yh(d);if(!d.ok)throw new wh(d);let f=((n=d.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),_;return f==="application/json"?_=yield d.json():f==="application/octet-stream"?_=yield d.blob():f==="text/event-stream"?_=d:f==="multipart/form-data"?_=yield d.formData():_=yield d.text(),{data:_,error:null,response:d}}catch(s){return{data:null,error:s,response:s instanceof wh||s instanceof yh?s.context:void 0}}})}}var Je={},Tc={},ga={},Oi={},va={},ya={},Dw=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},ws=Dw();const Mw=ws.fetch,Pm=ws.fetch.bind(ws),Nm=ws.Headers,Fw=ws.Request,zw=ws.Response,ks=Object.freeze(Object.defineProperty({__proto__:null,Headers:Nm,Request:Fw,Response:zw,default:Pm,fetch:Mw},Symbol.toStringTag,{value:"Module"})),Bw=dg(ks);var wa={};Object.defineProperty(wa,"__esModule",{value:!0});let Ww=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};wa.default=Ww;var Tm=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ya,"__esModule",{value:!0});const Hw=Tm(Bw),qw=Tm(wa);let Qw=class{constructor(e){var r,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(r=e.shouldThrowOnError)!==null&&r!==void 0?r:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=Hw.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,r){return this.headers=new Headers(this.headers),this.headers.set(e,r),this}then(e,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const n=this.fetch;let s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,l,u;let c=null,d=null,m=null,f=i.status,_=i.statusText;if(i.ok){if(this.method!=="HEAD"){const g=await i.text();g===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=g:d=JSON.parse(g))}const b=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),v=(l=i.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");b&&v&&v.length>1&&(m=parseInt(v[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(c={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,f=406,_="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{const b=await i.text();try{c=JSON.parse(b),Array.isArray(c)&&i.status===404&&(d=[],c=null,f=200,_="OK")}catch{i.status===404&&b===""?(f=204,_="No Content"):c={message:b}}if(c&&this.isMaybeSingle&&(!((u=c==null?void 0:c.details)===null||u===void 0)&&u.includes("0 rows"))&&(c=null,f=200,_="OK"),c&&this.shouldThrowOnError)throw new qw.default(c)}return{error:c,data:d,count:m,status:f,statusText:_}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,l;return{error:{message:`${(o=i==null?void 0:i.name)!==null&&o!==void 0?o:"FetchError"}: ${i==null?void 0:i.message}`,details:`${(a=i==null?void 0:i.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(l=i==null?void 0:i.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,r)}returns(){return this}overrideTypes(){return this}};ya.default=Qw;var Kw=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(va,"__esModule",{value:!0});const Vw=Kw(ya);let Gw=class extends Vw.default{select(e){let r=!1;const n=(e??"*").split("").map(s=>/\s/.test(s)&&!r?"":(s==='"'&&(r=!r),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:r=!0,nullsFirst:n,foreignTable:s,referencedTable:i=s}={}){const o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:r,referencedTable:n=r}={}){const s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,r,{foreignTable:n,referencedTable:s=n}={}){const i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${r-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:r=!1,settings:n=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;const l=[e?"analyze":null,r?"verbose":null,n?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),u=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${u}"; options=${l};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};va.default=Gw;var Jw=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Oi,"__esModule",{value:!0});const Yw=Jw(va);let Xw=class extends Yw.default{eq(e,r){return this.url.searchParams.append(e,`eq.${r}`),this}neq(e,r){return this.url.searchParams.append(e,`neq.${r}`),this}gt(e,r){return this.url.searchParams.append(e,`gt.${r}`),this}gte(e,r){return this.url.searchParams.append(e,`gte.${r}`),this}lt(e,r){return this.url.searchParams.append(e,`lt.${r}`),this}lte(e,r){return this.url.searchParams.append(e,`lte.${r}`),this}like(e,r){return this.url.searchParams.append(e,`like.${r}`),this}likeAllOf(e,r){return this.url.searchParams.append(e,`like(all).{${r.join(",")}}`),this}likeAnyOf(e,r){return this.url.searchParams.append(e,`like(any).{${r.join(",")}}`),this}ilike(e,r){return this.url.searchParams.append(e,`ilike.${r}`),this}ilikeAllOf(e,r){return this.url.searchParams.append(e,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(e,r){return this.url.searchParams.append(e,`ilike(any).{${r.join(",")}}`),this}is(e,r){return this.url.searchParams.append(e,`is.${r}`),this}in(e,r){const n=Array.from(new Set(r)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cs.{${r.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(r)}`),this}containedBy(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cd.{${r.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(r)}`),this}rangeGt(e,r){return this.url.searchParams.append(e,`sr.${r}`),this}rangeGte(e,r){return this.url.searchParams.append(e,`nxl.${r}`),this}rangeLt(e,r){return this.url.searchParams.append(e,`sl.${r}`),this}rangeLte(e,r){return this.url.searchParams.append(e,`nxr.${r}`),this}rangeAdjacent(e,r){return this.url.searchParams.append(e,`adj.${r}`),this}overlaps(e,r){return typeof r=="string"?this.url.searchParams.append(e,`ov.${r}`):this.url.searchParams.append(e,`ov.{${r.join(",")}}`),this}textSearch(e,r,{config:n,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const o=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${i}fts${o}.${r}`),this}match(e){return Object.entries(e).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(e,r,n){return this.url.searchParams.append(e,`not.${r}.${n}`),this}or(e,{foreignTable:r,referencedTable:n=r}={}){const s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,r,n){return this.url.searchParams.append(e,`${r}.${n}`),this}};Oi.default=Xw;var Zw=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ga,"__esModule",{value:!0});const Us=Zw(Oi);let ex=class{constructor(e,{headers:r={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(r),this.schema=n,this.fetch=s}select(e,{head:r=!1,count:n}={}){const s=r?"HEAD":"GET";let i=!1;const o=(e??"*").split("").map(a=>/\s/.test(a)&&!i?"":(a==='"'&&(i=!i),a)).join("");return this.url.searchParams.set("select",o),n&&this.headers.append("Prefer",`count=${n}`),new Us.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:r,defaultToNull:n=!0}={}){var s;const i="POST";if(r&&this.headers.append("Prefer",`count=${r}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){const o=e.reduce((a,l)=>a.concat(Object.keys(l)),[]);if(o.length>0){const a=[...new Set(o)].map(l=>`"${l}"`);this.url.searchParams.set("columns",a.join(","))}}return new Us.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:r,ignoreDuplicates:n=!1,count:s,defaultToNull:i=!0}={}){var o;const a="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),r!==void 0&&this.url.searchParams.set("on_conflict",r),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){const l=e.reduce((u,c)=>u.concat(Object.keys(c)),[]);if(l.length>0){const u=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",u.join(","))}}return new Us.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:r}={}){var n;const s="PATCH";return r&&this.headers.append("Prefer",`count=${r}`),new Us.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var r;const n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new Us.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}};ga.default=ex;var Om=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Tc,"__esModule",{value:!0});const tx=Om(ga),rx=Om(Oi);let nx=class Rm{constructor(e,{headers:r={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(r),this.schemaName=n,this.fetch=s}from(e){const r=new URL(`${this.url}/${e}`);return new tx.default(r,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new Rm(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:s=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let u;n||s?(a=n?"HEAD":"GET",Object.entries(r).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{l.searchParams.append(d,m)})):(a="POST",u=r);const c=new Headers(this.headers);return i&&c.set("Prefer",`count=${i}`),new rx.default({method:a,url:l,headers:c,schema:this.schemaName,body:u,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};Tc.default=nx;var Es=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Je,"__esModule",{value:!0});Je.PostgrestError=Je.PostgrestBuilder=Je.PostgrestTransformBuilder=Je.PostgrestFilterBuilder=Je.PostgrestQueryBuilder=Je.PostgrestClient=void 0;const Im=Es(Tc);Je.PostgrestClient=Im.default;const Lm=Es(ga);Je.PostgrestQueryBuilder=Lm.default;const Am=Es(Oi);Je.PostgrestFilterBuilder=Am.default;const $m=Es(va);Je.PostgrestTransformBuilder=$m.default;const Um=Es(ya);Je.PostgrestBuilder=Um.default;const Dm=Es(wa);Je.PostgrestError=Dm.default;var sx=Je.default={PostgrestClient:Im.default,PostgrestQueryBuilder:Lm.default,PostgrestFilterBuilder:Am.default,PostgrestTransformBuilder:$m.default,PostgrestBuilder:Um.default,PostgrestError:Dm.default};const{PostgrestClient:ix,PostgrestQueryBuilder:d1,PostgrestFilterBuilder:h1,PostgrestTransformBuilder:f1,PostgrestBuilder:p1,PostgrestError:m1}=sx;class ox{static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"&&process.versions&&process.versions.node){const r=parseInt(process.versions.node.split(".")[0]);return r>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${r} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${r} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=` @@ -88,17 +88,17 @@ Option 2: Install and provide the "ws" package: ...options, transport: ws })`):new Error(`WebSocket not available: ${r}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:ux}))}disconnect(e,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),this._setConnectionState("disconnected")},e?this.conn.close(e,r??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const e=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,r,n){this.logger(e,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case Zs.connecting:return Yr.Connecting;case Zs.open:return Yr.Open;case Zs.closing:return Yr.Closing;default:return Yr.Closed}}isConnected(){return this.connectionState()===Yr.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,r={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(i=>i.topic===n);if(s)return s;{const i=new Oc(`realtime:${e}`,r,this);return this.channels.push(i),i}}push(e){const{topic:r,event:n,payload:s,ref:i}=e,o=()=>{this.encode(e,a=>{var l;(l=this.conn)===null||l===void 0||l.send(a)})};this.log("push",`${r} ${n} (${i})`,s),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){this.heartbeatCallback("disconnected");return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(cx,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},to.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let r=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${e}"`),r.unsubscribe())}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,r=>{r.topic==="phoenix"&&r.event==="phx_reply"&&this.heartbeatCallback(r.payload.status==="ok"?"ok":"error"),r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:s,payload:i,ref:o}=r,a=o?`(${o})`:"",l=i.status||"";this.log("receive",`${l} ${n} ${s} ${a}`.trim(),i),this.channels.filter(u=>u._isMember(n)).forEach(u=>u._trigger(s,i,o)),this._triggerStateCallbacks("message",r)})}_clearTimer(e){var r;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var r;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(Pt.error))}_appendParams(e,r){if(Object.keys(r).length===0)return e;const n=e.match(/\?/)?"&":"?",s=new URLSearchParams(r);return`${e}${n}${s}`}_workerObjectUrl(e){let r;if(e)r=e;else{const n=new Blob([_x],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_setConnectionState(e,r=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(e=null){let r;e?r=e:this.accessToken?r=await this.accessToken():r=this.accessTokenValue,this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const s={access_token:r,version:lx};r&&n.updateJoinPayload(s),n.joinedOnce&&n._isJoined()&&n._push(Pt.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${e}`,r)})}_triggerStateCallbacks(e,r){try{this.stateChangeCallbacks[e].forEach(n=>{try{n(r)}catch(s){this.log("error",`error in ${e} callback`,s)}})}catch(n){this.log("error",`error triggering ${e} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new Mm(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},to.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var r,n,s,i,o,a,l,u;if(this.transport=(r=e==null?void 0:e.transport)!==null&&r!==void 0?r:null,this.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:xu,this.heartbeatIntervalMs=(s=e==null?void 0:e.heartbeatIntervalMs)!==null&&s!==void 0?s:to.HEARTBEAT_INTERVAL,this.worker=(i=e==null?void 0:e.worker)!==null&&i!==void 0?i:!1,this.accessToken=(o=e==null?void 0:e.accessToken)!==null&&o!==void 0?o:null,e!=null&&e.params&&(this.params=e.params),e!=null&&e.logger&&(this.logger=e.logger),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(a=e==null?void 0:e.reconnectAfterMs)!==null&&a!==void 0?a:c=>wx[c-1]||xx,this.encode=(l=e==null?void 0:e.encode)!==null&&l!==void 0?l:(c,d)=>d(JSON.stringify(c)),this.decode=(u=e==null?void 0:e.decode)!==null&&u!==void 0?u:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl}}}class Rc extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function xe(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class Sx extends Rc{constructor(e,r,n){super(e),this.name="StorageApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class Su extends Rc{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}}var kx=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Bm=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Ti(async()=>{const{default:n}=await Promise.resolve().then(()=>ks);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},Ex=()=>kx(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Ti(()=>Promise.resolve().then(()=>ks),void 0)).Response:Response}),ku=t=>{if(Array.isArray(t))return t.map(r=>ku(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,n])=>{const s=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[s]=ku(n)}),e},Cx=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};var _n=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const tl=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),jx=(t,e,r)=>_n(void 0,void 0,void 0,function*(){const n=yield Ex();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(s=>{const i=t.status||500,o=(s==null?void 0:s.statusCode)||i+"";e(new Sx(tl(s),i,o))}).catch(s=>{e(new Su(tl(s),s))}):e(new Su(tl(t),t))}),Px=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"||!n?s:(Cx(n)?(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(n)):s.body=n,e!=null&&e.duplex&&(s.duplex=e.duplex),Object.assign(Object.assign({},s),r))};function Ri(t,e,r,n,s,i){return _n(this,void 0,void 0,function*(){return new Promise((o,a)=>{t(r,Px(e,n,s,i)).then(l=>{if(!l.ok)throw l;return n!=null&&n.noResolveJson?l:l.json()}).then(l=>o(l)).catch(l=>jx(l,a,n))})})}function Vo(t,e,r,n){return _n(this,void 0,void 0,function*(){return Ri(t,"GET",e,r,n)})}function At(t,e,r,n,s){return _n(this,void 0,void 0,function*(){return Ri(t,"POST",e,n,s,r)})}function Eu(t,e,r,n,s){return _n(this,void 0,void 0,function*(){return Ri(t,"PUT",e,n,s,r)})}function Nx(t,e,r,n){return _n(this,void 0,void 0,function*(){return Ri(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function Wm(t,e,r,n,s){return _n(this,void 0,void 0,function*(){return Ri(t,"DELETE",e,n,s,r)})}var Ue=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Tx={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},kh={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Ox{constructor(e,r={},n,s){this.url=e,this.headers=r,this.bucketId=n,this.fetch=Bm(s)}uploadOrUpdate(e,r,n,s){return Ue(this,void 0,void 0,function*(){try{let i;const o=Object.assign(Object.assign({},kh),s);let a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});const l=o.metadata;typeof Blob<"u"&&n instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",this.encodeMetadata(l)),i.append("",n)):typeof FormData<"u"&&n instanceof FormData?(i=n,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",this.encodeMetadata(l))):(i=n,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(l)))),s!=null&&s.headers&&(a=Object.assign(Object.assign({},a),s.headers));const u=this._removeEmptyFolders(r),c=this._getFinalPath(u),d=yield(e=="PUT"?Eu:At)(this.fetch,`${this.url}/object/${c}`,i,Object.assign({headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{data:{path:u,id:d.Id,fullPath:d.Key},error:null}}catch(i){if(xe(i))return{data:null,error:i};throw i}})}upload(e,r,n){return Ue(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,s){return Ue(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),o=this._getFinalPath(i),a=new URL(this.url+`/object/upload/sign/${o}`);a.searchParams.set("token",r);try{let l;const u=Object.assign({upsert:kh.upsert},s),c=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(l=new FormData,l.append("cacheControl",u.cacheControl),l.append("",n)):typeof FormData<"u"&&n instanceof FormData?(l=n,l.append("cacheControl",u.cacheControl)):(l=n,c["cache-control"]=`max-age=${u.cacheControl}`,c["content-type"]=u.contentType);const d=yield Eu(this.fetch,a.toString(),l,{headers:c});return{data:{path:i,fullPath:d.Key},error:null}}catch(l){if(xe(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e,r){return Ue(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e);const s=Object.assign({},this.headers);r!=null&&r.upsert&&(s["x-upsert"]="true");const i=yield At(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),o=new URL(this.url+i.url),a=o.searchParams.get("token");if(!a)throw new Rc("No token returned by API");return{data:{signedUrl:o.toString(),path:e,token:a},error:null}}catch(n){if(xe(n))return{data:null,error:n};throw n}})}update(e,r,n){return Ue(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return Ue(this,void 0,void 0,function*(){try{return{data:yield At(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(xe(s))return{data:null,error:s};throw s}})}copy(e,r,n){return Ue(this,void 0,void 0,function*(){try{return{data:{path:(yield At(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(xe(s))return{data:null,error:s};throw s}})}createSignedUrl(e,r,n){return Ue(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield At(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const o=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${o}`)},{data:i,error:null}}catch(s){if(xe(s))return{data:null,error:s};throw s}})}createSignedUrls(e,r,n){return Ue(this,void 0,void 0,function*(){try{const s=yield At(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:e},{headers:this.headers}),i=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:s.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${i}`):null})),error:null}}catch(s){if(xe(s))return{data:null,error:s};throw s}})}download(e,r){return Ue(this,void 0,void 0,function*(){const s=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),o=i?`?${i}`:"";try{const a=this._getFinalPath(e);return{data:yield(yield Vo(this.fetch,`${this.url}/${s}/${a}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(xe(a))return{data:null,error:a};throw a}})}info(e){return Ue(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{const n=yield Vo(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:ku(n),error:null}}catch(n){if(xe(n))return{data:null,error:n};throw n}})}exists(e){return Ue(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{return yield Nx(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(xe(n)&&n instanceof Su){const s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,r){const n=this._getFinalPath(e),s=[],i=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";i!==""&&s.push(i);const a=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",l=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});l!==""&&s.push(l);let u=s.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${n}${u}`)}}}remove(e){return Ue(this,void 0,void 0,function*(){try{return{data:yield Wm(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if(xe(r))return{data:null,error:r};throw r}})}list(e,r,n){return Ue(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},Tx),r),{prefix:e||""});return{data:yield At(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(xe(s))return{data:null,error:s};throw s}})}listV2(e,r){return Ue(this,void 0,void 0,function*(){try{const n=Object.assign({},e);return{data:yield At(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(xe(n))return{data:null,error:n};throw n}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const r=[];return e.width&&r.push(`width=${e.width}`),e.height&&r.push(`height=${e.height}`),e.resize&&r.push(`resize=${e.resize}`),e.format&&r.push(`format=${e.format}`),e.quality&&r.push(`quality=${e.quality}`),r.join("&")}}const Rx="2.11.0",Ix={"X-Client-Info":`storage-js/${Rx}`};var Cn=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};class Lx{constructor(e,r={},n,s){const i=new URL(e);s!=null&&s.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href,this.headers=Object.assign(Object.assign({},Ix),r),this.fetch=Bm(n)}listBuckets(){return Cn(this,void 0,void 0,function*(){try{return{data:yield Vo(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(xe(e))return{data:null,error:e};throw e}})}getBucket(e){return Cn(this,void 0,void 0,function*(){try{return{data:yield Vo(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if(xe(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return Cn(this,void 0,void 0,function*(){try{return{data:yield At(this.fetch,`${this.url}/bucket`,{id:e,name:e,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(xe(n))return{data:null,error:n};throw n}})}updateBucket(e,r){return Cn(this,void 0,void 0,function*(){try{return{data:yield Eu(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(xe(n))return{data:null,error:n};throw n}})}emptyBucket(e){return Cn(this,void 0,void 0,function*(){try{return{data:yield At(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(xe(r))return{data:null,error:r};throw r}})}deleteBucket(e){return Cn(this,void 0,void 0,function*(){try{return{data:yield Wm(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(xe(r))return{data:null,error:r};throw r}})}}class Ax extends Lx{constructor(e,r={},n,s){super(e,r,n,s)}from(e){return new Ox(this.url,this.headers,e,this.fetch)}}const $x="2.56.0";let Ws="";typeof Deno<"u"?Ws="deno":typeof document<"u"?Ws="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Ws="react-native":Ws="node";const Ux={"X-Client-Info":`supabase-js-${Ws}/${$x}`},Dx={headers:Ux},Mx={schema:"public"},Fx={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},zx={};var Bx=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Wx=t=>{let e;return t?e=t:typeof fetch>"u"?e=Pm:e=fetch,(...r)=>e(...r)},Hx=()=>typeof Headers>"u"?Nm:Headers,qx=(t,e,r)=>{const n=Wx(r),s=Hx();return(i,o)=>Bx(void 0,void 0,void 0,function*(){var a;const l=(a=yield e())!==null&&a!==void 0?a:t;let u=new s(o==null?void 0:o.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${l}`),n(i,Object.assign(Object.assign({},o),{headers:u}))})};var Qx=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};function Kx(t){return t.endsWith("/")?t:t+"/"}function Vx(t,e){var r,n;const{db:s,auth:i,realtime:o,global:a}=t,{db:l,auth:u,realtime:c,global:d}=e,m={db:Object.assign(Object.assign({},l),s),auth:Object.assign(Object.assign({},u),i),realtime:Object.assign(Object.assign({},c),o),storage:{},global:Object.assign(Object.assign(Object.assign({},d),a),{headers:Object.assign(Object.assign({},(r=d==null?void 0:d.headers)!==null&&r!==void 0?r:{}),(n=a==null?void 0:a.headers)!==null&&n!==void 0?n:{})}),accessToken:()=>Qx(this,void 0,void 0,function*(){return""})};return t.accessToken?m.accessToken=t.accessToken:delete m.accessToken,m}const Hm="2.71.1",On=30*1e3,Cu=3,rl=Cu*On,Gx="http://localhost:9999",Jx="supabase.auth.token",Yx={"X-Client-Info":`gotrue-js/${Hm}`},ju="X-Supabase-Api-Version",qm={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Xx=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Zx=10*60*1e3;class Ic extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function B(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class e_ extends Ic{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function t_(t){return B(t)&&t.name==="AuthApiError"}class Qm extends Ic{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class Wr extends Ic{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}}class dr extends Wr{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function r_(t){return B(t)&&t.name==="AuthSessionMissingError"}class ro extends Wr{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class no extends Wr{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class so extends Wr{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function n_(t){return B(t)&&t.name==="AuthImplicitGrantRedirectError"}class Eh extends Wr{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Pu extends Wr{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function nl(t){return B(t)&&t.name==="AuthRetryableFetchError"}class Ch extends Wr{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class Nu extends Wr{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Go="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),jh=` -\r=`.split(""),s_=(()=>{const t=new Array(128);for(let e=0;e=6;){const n=e.queue>>e.queuedBits-6&63;r(Go[n]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(Go[n]),e.queuedBits-=6}}function Km(t,e,r){const n=s_[t];if(n>-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Nh(t){const e=[],r=o=>{e.push(String.fromCodePoint(o))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=o=>{a_(o,n,r)};for(let o=0;o>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function o_(t,e){for(let r=0;r55295&&n<=56319){const s=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|s)+65536,r+=1}i_(n,e)}}function a_(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function l_(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;se.push(r)),new Uint8Array(e)}function c_(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};return t.forEach(s=>Ph(s,r,n)),Ph(null,r,n),e.join("")}function d_(t){return Math.round(Date.now()/1e3)+t}function h_(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}const St=()=>typeof window<"u"&&typeof document<"u",Qr={tested:!1,writable:!1},Vm=()=>{if(!St())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Qr.tested)return Qr.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Qr.tested=!0,Qr.writable=!0}catch{Qr.tested=!0,Qr.writable=!1}return Qr.writable};function f_(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,i)=>{e[i]=s})}catch{}return r.searchParams.forEach((n,s)=>{e[s]=n}),e}const Gm=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Ti(async()=>{const{default:n}=await Promise.resolve().then(()=>ks);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},p_=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Rn=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},Kr=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},ur=async(t,e)=>{await t.removeItem(e)};class xa{constructor(){this.promise=new xa.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}xa.promiseConstructor=Promise;function sl(t){const e=t.split(".");if(e.length!==3)throw new Nu("Invalid JWT structure");for(let n=0;n{setTimeout(()=>e(null),t)})}function g_(t,e){return new Promise((n,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!e(i,null,o)){n(o);return}}catch(o){if(!e(i,o)){s(o);return}}})()})}function v_(t){return("0"+t.toString(16)).substr(-2)}function y_(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let s="";for(let i=0;i<56;i++)s+=r.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,v_).join("")}async function w_(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(n);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function x_(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await w_(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function jn(t,e,r=!1){const n=y_();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await Rn(t,`${e}-code-verifier`,s);const i=await x_(n);return[i,n===i?"plain":"s256"]}const __=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function b_(t){const e=t.headers.get(ju);if(!e||!e.match(__))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function S_(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function k_(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const E_=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Pn(t){if(!E_.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function il(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function Th(t){return JSON.parse(JSON.stringify(t))}var C_=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);st.msg||t.message||t.error_description||t.error||JSON.stringify(t),j_=[502,503,504];async function Oh(t){var e;if(!p_(t))throw new Pu(Jr(t),0);if(j_.includes(t.status))throw new Pu(Jr(t),t.status);let r;try{r=await t.json()}catch(i){throw new Qm(Jr(i),i)}let n;const s=b_(t);if(s&&s.getTime()>=qm["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new Ch(Jr(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new dr}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new Ch(Jr(r),t.status,r.weak_password.reasons);throw new e_(Jr(r),t.status||500,n)}const P_=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function Q(t,e,r,n){var s;const i=Object.assign({},n==null?void 0:n.headers);i[ju]||(i[ju]=qm["2024-01-01"].name),n!=null&&n.jwt&&(i.Authorization=`Bearer ${n.jwt}`);const o=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(o.redirect_to=n.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await N_(t,e,r+a,{headers:i,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(l):{data:Object.assign({},l),error:null}}async function N_(t,e,r,n,s,i){const o=P_(e,n,s,i);let a;try{a=await t(r,Object.assign({},o))}catch(l){throw console.error(l),new Pu(Jr(l),0)}if(a.ok||await Oh(a),n!=null&&n.noResolveJson)return a;try{return await a.json()}catch(l){await Oh(l)}}function Wt(t){var e;let r=null;I_(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=d_(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function Rh(t){const e=Wt(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function gr(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function T_(t){return{data:t,error:null}}function O_(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i}=t,o=C_(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function R_(t){return t}function I_(t){return t.access_token&&t.refresh_token&&t.expires_in}const ol=["global","local","others"];var L_=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s0&&(f.forEach(_=>{const x=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),b=JSON.parse(_.split(";")[1].split("=")[1]);u[`${b}Page`]=x}),u.total=parseInt(m)),{data:Object.assign(Object.assign({},d),u),error:null}}catch(u){if(B(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){Pn(e);try{return await Q(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:gr})}catch(r){if(B(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){Pn(e);try{return await Q(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:gr})}catch(n){if(B(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){Pn(e);try{return await Q(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:gr})}catch(n){if(B(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){Pn(e.userId);try{const{data:r,error:n}=await Q(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:n}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _deleteFactor(e){Pn(e.userId),Pn(e.id);try{return{data:await Q(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}}function Ih(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}function $_(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const Nn={debug:!!(globalThis&&Vm()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Jm extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class U_ extends Jm{}async function D_(t,e,r){Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new U_(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Nn.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}$_();const M_={url:Gx,storageKey:Jx,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Yx,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function Lh(t,e,r){return await r()}const Tn={};class xi{constructor(e){var r,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=xi.nextInstanceID,xi.nextInstanceID+=1,this.instanceID>0&&St()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const s=Object.assign(Object.assign({},M_),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new A_({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=Gm(s.fetch),this.lock=s.lock||Lh,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:St()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=D_:this.lock=Lh,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?(s.storage?this.storage=s.storage:Vm()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Ih(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=Ih(this.memoryStorage)),St()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}get jwks(){var e,r;return(r=(e=Tn[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Tn[this.storageKey]=Object.assign(Object.assign({},Tn[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Tn[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Tn[this.storageKey]=Object.assign(Object.assign({},Tn[this.storageKey]),{cachedAt:e})}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${Hm}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{const r=f_(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),St()&&this.detectSessionInUrl&&n!=="none"){const{data:s,error:i}=await this._getSessionFromURL(r,n);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),n_(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:o,redirectType:a}=s;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return B(r)?{error:r}:{error:new Qm("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const i=await Q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Wt}),{data:o,error:a}=i;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(B(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(e){var r,n,s;try{let i;if("email"in e){const{email:c,password:d,options:m}=e;let f=null,_=null;this.flowType==="pkce"&&([f,_]=await jn(this.storage,this.storageKey)),i=await Q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:m==null?void 0:m.emailRedirectTo,body:{email:c,password:d,data:(r=m==null?void 0:m.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken},code_challenge:f,code_challenge_method:_},xform:Wt})}else if("phone"in e){const{phone:c,password:d,options:m}=e;i=await Q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:c,password:d,data:(n=m==null?void 0:m.data)!==null&&n!==void 0?n:{},channel:(s=m==null?void 0:m.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken}},xform:Wt})}else throw new no("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(B(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:i,password:o,options:a}=e;r=await Q(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Rh})}else if("phone"in e){const{phone:i,password:o,options:a}=e;r=await Q(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Rh})}else throw new no("You must provide either an email or phone number and a password");const{data:n,error:s}=r;return s?{data:{user:null,session:null},error:s}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new ro}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(e){var r,n,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:r}=e;if(r==="solana")return await this.signInWithSolana(e);throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}async signInWithSolana(e){var r,n,s,i,o,a,l,u,c,d,m,f;let _,x;if("message"in e)_=e.message,x=e.signature;else{const{chain:b,wallet:v,statement:g,options:p}=e;let w;if(St())if(typeof v=="object")w=v;else{const S=window;if("solana"in S&&typeof S.solana=="object"&&("signIn"in S.solana&&typeof S.solana.signIn=="function"||"signMessage"in S.solana&&typeof S.solana.signMessage=="function"))w=S.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!(p!=null&&p.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");w=v}const k=new URL((r=p==null?void 0:p.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in w&&w.signIn){const S=await w.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},p==null?void 0:p.signInWithSolana),{version:"1",domain:k.host,uri:k.href}),g?{statement:g}:null));let j;if(Array.isArray(S)&&S[0]&&typeof S[0]=="object")j=S[0];else if(S&&typeof S=="object"&&"signedMessage"in S&&"signature"in S)j=S;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in j&&"signature"in j&&(typeof j.signedMessage=="string"||j.signedMessage instanceof Uint8Array)&&j.signature instanceof Uint8Array)_=typeof j.signedMessage=="string"?j.signedMessage:new TextDecoder().decode(j.signedMessage),x=j.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in w)||typeof w.signMessage!="function"||!("publicKey"in w)||typeof w!="object"||!w.publicKey||!("toBase58"in w.publicKey)||typeof w.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${k.host} wants you to sign in with your Solana account:`,w.publicKey.toBase58(),...g?["",g,""]:[""],"Version: 1",`URI: ${k.href}`,`Issued At: ${(s=(n=p==null?void 0:p.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=p==null?void 0:p.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${p.signInWithSolana.notBefore}`]:[],...!((o=p==null?void 0:p.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${p.signInWithSolana.expirationTime}`]:[],...!((a=p==null?void 0:p.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${p.signInWithSolana.chainId}`]:[],...!((l=p==null?void 0:p.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${p.signInWithSolana.nonce}`]:[],...!((u=p==null?void 0:p.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${p.signInWithSolana.requestId}`]:[],...!((d=(c=p==null?void 0:p.signInWithSolana)===null||c===void 0?void 0:c.resources)===null||d===void 0)&&d.length?["Resources",...p.signInWithSolana.resources.map(j=>`- ${j}`)]:[]].join(` -`);const S=await w.signMessage(new TextEncoder().encode(_),"utf8");if(!S||!(S instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");x=S}}try{const{data:b,error:v}=await Q(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:c_(x)},!((m=e.options)===null||m===void 0)&&m.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:Wt});if(v)throw v;return!b||!b.session||!b.user?{data:{user:null,session:null},error:new ro}:(b.session&&(await this._saveSession(b.session),await this._notifyAllSubscribers("SIGNED_IN",b.session)),{data:Object.assign({},b),error:v})}catch(b){if(B(b))return{data:{user:null,session:null},error:b};throw b}}async _exchangeCodeForSession(e){const r=await Kr(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{const{data:i,error:o}=await Q(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Wt});if(await ur(this.storage,`${this.storageKey}-code-verifier`),o)throw o;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new ro}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:o})}catch(i){if(B(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(e){try{const{options:r,provider:n,token:s,access_token:i,nonce:o}=e,a=await Q(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Wt}),{data:l,error:u}=a;return u?{data:{user:null,session:null},error:u}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new ro}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:u})}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(e){var r,n,s,i,o;try{if("email"in e){const{email:a,options:l}=e;let u=null,c=null;this.flowType==="pkce"&&([u,c]=await jn(this.storage,this.storageKey));const{error:d}=await Q(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=l==null?void 0:l.data)!==null&&r!==void 0?r:{},create_user:(n=l==null?void 0:l.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:u,code_challenge_method:c},redirectTo:l==null?void 0:l.emailRedirectTo});return{data:{user:null,session:null},error:d}}if("phone"in e){const{phone:a,options:l}=e,{data:u,error:c}=await Q(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=l==null?void 0:l.data)!==null&&s!==void 0?s:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:c}}throw new no("You must provide either an email or phone number.")}catch(a){if(B(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var r,n;try{let s,i;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:o,error:a}=await Q(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:Wt});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,u=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(s){if(B(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var r,n,s;try{let i=null,o=null;return this.flowType==="pkce"&&([i,o]=await jn(this.storage,this.storageKey)),await Q(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:o}),headers:this.headers,xform:T_})}catch(i){if(B(i))return{data:null,error:i};throw i}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new dr;const{error:s}=await Q(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(B(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:s,options:i}=e,{error:o}=await Q(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:n,type:s,options:i}=e,{data:o,error:a}=await Q(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a}}throw new no("You must provide either an email or phone number and a type")}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Kr(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()(!o&&u==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),o=!0,this.suppressGetSessionWarning=!0),Reflect.get(l,u,c))})}return{data:{session:e},error:null}}const{session:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await Q(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:gr}):await this._useSession(async r=>{var n,s,i;const{data:o,error:a}=r;if(a)throw a;return!(!((n=o.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new dr}:await Q(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=o.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:gr})})}catch(r){if(B(r))return r_(r)&&(await this._removeSession(),await ur(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:s,error:i}=n;if(i)throw i;if(!s.session)throw new dr;const o=s.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await jn(this.storage,this.storageKey));const{data:u,error:c}=await Q(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:gr});if(c)throw c;return o.user=u.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(n){if(B(n))return{data:{user:null},error:n};throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new dr;const r=Date.now()/1e3;let n=r,s=!0,i=null;const{payload:o}=sl(e.access_token);if(o.exp&&(n=o.exp,s=n<=r),s){const{session:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)throw l;i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(r){if(B(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:o,error:a}=r;if(a)throw a;e=(n=o.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new dr;const{session:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e,r){try{if(!St())throw new so("No browser detected.");if(e.error||e.error_description||e.error_code)throw new so(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new Eh("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new so("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Eh("No code detected.");const{data:g,error:p}=await this._exchangeCodeForSession(e.code);if(p)throw p;const w=new URL(window.location.href);return w.searchParams.delete("code"),window.history.replaceState(window.history.state,"",w.toString()),{data:{session:g.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:s,access_token:i,refresh_token:o,expires_in:a,expires_at:l,token_type:u}=e;if(!i||!a||!o||!u)throw new so("No session defined in URL");const c=Math.round(Date.now()/1e3),d=parseInt(a);let m=c+d;l&&(m=parseInt(l));const f=m-c;f*1e3<=On&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${d}s`);const _=m-d;c-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,m,c):c-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,m,c);const{data:x,error:b}=await this._getUser(i);if(b)throw b;const v={provider_token:n,provider_refresh_token:s,access_token:i,expires_in:d,expires_at:m,refresh_token:o,token_type:u,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:v,redirectType:e.type},error:null}}catch(n){if(B(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await Kr(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return{error:i};const o=(n=s.session)===null||n===void 0?void 0:n.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(t_(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await ur(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const r=h_(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,s;try{const{data:{session:i},error:o}=r;if(o)throw o;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),console.error(i)}})}async resetPasswordForEmail(e,r={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await jn(this.storage,this.storageKey,!0));try{return await Q(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(B(i))return{data:null,error:i};throw i}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async linkIdentity(e){var r;try{const{data:n,error:s}=await this._useSession(async i=>{var o,a,l,u,c;const{data:d,error:m}=i;if(m)throw m;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await Q(this.fetch,"GET",f,{headers:this.headers,jwt:(c=(u=d.session)===null||u===void 0?void 0:u.access_token)!==null&&c!==void 0?c:void 0})});if(s)throw s;return St()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:e.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(B(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:o}=r;if(o)throw o;return await Q(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await g_(async s=>(s>0&&await m_(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await Q(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Wt})),(s,i)=>{const o=200*Math.pow(2,s);return i&&nl(i)&&Date.now()+o-n{try{await a.callback(e,r)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;athis._autoRefreshTokenTick(),On);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((n.expires_at*1e3-e)/On);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${On}ms, refresh threshold is ${Cu} ticks`),s<=Cu&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Jm)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!St()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const s=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[i,o]=await jn(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});s.push(a.toString())}if(n!=null&&n.queryParams){const i=new URLSearchParams(n.queryParams);s.push(i.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?{data:null,error:i}:await Q(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:o}=r;if(o)return{data:null,error:o};const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:l,error:u}=await Q(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token});return u?{data:null,error:u}:(e.factorType==="totp"&&(!((s=l==null?void 0:l.totp)===null||s===void 0)&&s.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),{data:l,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return{data:null,error:i};const{data:o,error:a}=await Q(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:a})})}catch(r){if(B(r))return{data:null,error:r};throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?{data:null,error:i}:await Q(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(B(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){const{data:{user:e},error:r}=await this.getUser();if(r)return{data:null,error:r};const n=(e==null?void 0:e.factors)||[],s=n.filter(o=>o.factor_type==="totp"&&o.status==="verified"),i=n.filter(o=>o.factor_type==="phone"&&o.status==="verified");return{data:{all:n,totp:s,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var r,n;const{data:{session:s},error:i}=e;if(i)return{data:null,error:i};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=sl(s.access_token);let a=null;o.aal&&(a=o.aal);let l=a;((n=(r=s.user.factors)===null||r===void 0?void 0:r.filter(d=>d.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(l="aal2");const c=o.amr||[];return{data:{currentLevel:a,nextLevel:l,currentAuthenticationMethods:c},error:null}}))}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(a=>a.kid===e);if(n)return n;const s=Date.now();if(n=this.jwks.keys.find(a=>a.kid===e),n&&this.jwks_cached_at+Zx>s)return n;const{data:i,error:o}=await Q(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,n=i.keys.find(a=>a.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:f,error:_}=await this.getSession();if(_||!f.session)return{data:null,error:_};n=f.session.access_token}const{header:s,payload:i,signature:o,raw:{header:a,payload:l}}=sl(n);r!=null&&r.allowExpired||S_(i.exp);const u=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!u){const{error:f}=await this.getUser(n);if(f)throw f;return{data:{claims:i,header:s,signature:o},error:null}}const c=k_(s.alg),d=await crypto.subtle.importKey("jwk",u,c,!0,["verify"]);if(!await crypto.subtle.verify(c,d,o,u_(`${a}.${l}`)))throw new Nu("Invalid JWT signature");return{data:{claims:i,header:s,signature:o},error:null}}catch(n){if(B(n))return{data:null,error:n};throw n}}}xi.nextInstanceID=0;const F_=xi;class z_ extends F_{constructor(e){super(e)}}var B_=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};class W_{constructor(e,r,n){var s,i,o;if(this.supabaseUrl=e,this.supabaseKey=r,!e)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const a=Kx(e),l=new URL(a);this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const u=`sb-${l.hostname.split(".")[0]}-auth-token`,c={db:Mx,realtime:zx,auth:Object.assign(Object.assign({},Fx),{storageKey:u}),global:Dx},d=Vx(n??{},c);this.storageKey=(s=d.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(i=d.global.headers)!==null&&i!==void 0?i:{},d.accessToken?(this.accessToken=d.accessToken,this.auth=new Proxy({},{get:(m,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((o=d.auth)!==null&&o!==void 0?o:{},this.headers,d.global.fetch),this.fetch=qx(r,this._getAccessToken.bind(this),d.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},d.realtime)),this.rest=new ix(new URL("rest/v1",l).href,{headers:this.headers,schema:d.db.schema,fetch:this.fetch}),this.storage=new Ax(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),d.accessToken||this._listenForAuthEvents()}get functions(){return new Uw(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},n={}){return this.rest.rpc(e,r,n)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,r;return B_(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return(r=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,storageKey:i,flowType:o,lock:a,debug:l},u,c){const d={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new z_({url:this.authUrl.href,headers:Object.assign(Object.assign({},d),u),storageKey:i,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,flowType:o,lock:a,debug:l,fetch:c,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new bx(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,r,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:e==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const H_=(t,e,r)=>new W_(t,e,r);function q_(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}q_()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const Q_="https://tjlvullrsgepsoqyeali.supabase.co",K_="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InRqbHZ1bGxyc2dlcHNvcXllYWxpIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTYxMzkyNzgsImV4cCI6MjA3MTcxNTI3OH0.3znjDsjFP93YOJOEkn-XpalCK17yPHXUxFSfbu22ZrA",q=H_(Q_,K_,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0}});function _a(){const[t,e]=C.useState(null),[r,n]=C.useState(!0);C.useEffect(()=>{console.log("Setting up auth listener..."),q.auth.getSession().then(({data:{session:u}})=>{var c;console.log("Initial session:",(c=u==null?void 0:u.user)==null?void 0:c.email),u!=null&&u.user&&s(u.user),n(!1)});const{data:{subscription:l}}=q.auth.onAuthStateChange(async(u,c)=>{var d,m;console.log("Auth state change:",{event:u,userId:(d=c==null?void 0:c.user)==null?void 0:d.id,email:(m=c==null?void 0:c.user)==null?void 0:m.email}),u==="SIGNED_IN"&&(c!=null&&c.user)?await s(c.user):u==="SIGNED_OUT"&&e(null),n(!1)});return()=>l.unsubscribe()},[]);const s=async l=>{var u,c,d,m,f,_,x,b,v;console.log("Loading user data for:",l.email);try{const{data:g,error:p}=await q.from("profiles").select("*").eq("id",l.id).single();if(console.log("Profile query result:",{profile:g,error:p}),g&&!p){console.log("Using existing profile:",g.username),e({id:g.id,email:l.email||"",username:g.username,display_name:g.display_name||g.username,avatar_url:g.avatar_url,status:g.status,created_at:g.created_at});return}console.log("Profile not found, creating one...");const k=(((u=l.email)==null?void 0:u.split("@")[0])||"user").replace(/[^a-zA-Z0-9_]/g,"").toLowerCase(),{data:S,error:j}=await q.from("profiles").insert({id:l.id,username:k,email:l.email||"",display_name:((c=l.user_metadata)==null?void 0:c.full_name)||k,avatar_url:((d=l.user_metadata)==null?void 0:d.avatar_url)||null,status:"online"}).select().single();S&&!j?e({id:S.id,email:l.email||"",username:S.username,display_name:S.display_name||S.username,avatar_url:S.avatar_url,status:S.status,created_at:S.created_at}):(console.warn("Failed to create profile, using auth data:",j),e({id:l.id,email:l.email||"",username:k,display_name:((m=l.user_metadata)==null?void 0:m.full_name)||k,avatar_url:((f=l.user_metadata)==null?void 0:f.avatar_url)||null,status:"online",created_at:l.created_at}))}catch(g){console.error("Error loading user data:",g),e({id:l.id,email:l.email||"",username:((_=l.email)==null?void 0:_.split("@")[0])||"user",display_name:((x=l.user_metadata)==null?void 0:x.full_name)||((b=l.email)==null?void 0:b.split("@")[0])||"user",avatar_url:((v=l.user_metadata)==null?void 0:v.avatar_url)||null,status:"online",created_at:l.created_at})}};return{user:t,loading:r,signUp:async(l,u)=>{try{const{data:c,error:d}=await q.auth.signUp({email:l,password:u});if(d)throw d;return{success:!0,data:c}}catch(c){return{success:!1,error:c.message}}},signIn:async(l,u)=>{try{const{data:c,error:d}=await q.auth.signInWithPassword({email:l,password:u});if(d)throw d;return{success:!0,data:c}}catch(c){return{success:!1,error:c.message}}},signOut:async()=>{try{const{error:l}=await q.auth.signOut();if(l)throw l;return e(null),{success:!0}}catch(l){return{success:!1,error:l.message}}},isAuthenticated:!!t}}function al(){const[t,e]=C.useState(!1),[r,n]=C.useState(""),[s,i]=C.useState(""),[o,a]=C.useState(!1),{signIn:l,signUp:u}=_a(),c=async d=>{if(d.preventDefault(),!r||!s){H.error("Please fill in all fields");return}a(!0);try{const m=t?await u(r,s):await l(r,s);m.success?t&&H.success("Account created! Please check your email to verify your account."):H.error(m.error)}catch(m){H.error(m.message)}finally{a(!1)}};return h.jsx("div",{className:"min-h-screen bg-discord-bg flex items-center justify-center p-4",children:h.jsx("div",{className:"w-full max-w-md",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg p-8 shadow-xl",children:[h.jsxs("div",{className:"text-center mb-8",children:[h.jsx("h1",{className:"text-3xl font-bold text-discord-text mb-2",children:"CrestChat"}),h.jsx("p",{className:"text-discord-muted",children:"Your Discord-like chat application"})]}),h.jsxs("form",{onSubmit:c,className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-discord-text mb-2",children:"Email"}),h.jsx("input",{id:"email",type:"email",value:r,onChange:d=>n(d.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter your email",required:!0})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-discord-text mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:s,onChange:d=>i(d.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter your password",required:!0})]}),h.jsx("button",{type:"submit",disabled:o,className:"w-full bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:o?"Loading...":t?"Create Account":"Sign In"})]}),h.jsx("div",{className:"mt-6 text-center",children:h.jsx("button",{onClick:()=>e(!t),className:"text-discord-muted hover:text-discord-text transition-colors duration-200",children:t?"Already have an account? Sign In":"Don't have an account? Sign Up"})})]})})})}function V_(){const t=ma(),{data:e=[],isLoading:r}=vu({queryKey:["user-servers"],queryFn:async()=>{const{data:c,error:d}=await q.from("server_members").select(` +\r=`.split(""),s_=(()=>{const t=new Array(128);for(let e=0;e=6;){const n=e.queue>>e.queuedBits-6&63;r(Go[n]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(Go[n]),e.queuedBits-=6}}function Km(t,e,r){const n=s_[t];if(n>-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Nh(t){const e=[],r=o=>{e.push(String.fromCodePoint(o))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=o=>{a_(o,n,r)};for(let o=0;o>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function o_(t,e){for(let r=0;r55295&&n<=56319){const s=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|s)+65536,r+=1}i_(n,e)}}function a_(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function l_(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;se.push(r)),new Uint8Array(e)}function c_(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};return t.forEach(s=>Ph(s,r,n)),Ph(null,r,n),e.join("")}function d_(t){return Math.round(Date.now()/1e3)+t}function h_(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}const St=()=>typeof window<"u"&&typeof document<"u",Qr={tested:!1,writable:!1},Vm=()=>{if(!St())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Qr.tested)return Qr.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Qr.tested=!0,Qr.writable=!0}catch{Qr.tested=!0,Qr.writable=!1}return Qr.writable};function f_(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,i)=>{e[i]=s})}catch{}return r.searchParams.forEach((n,s)=>{e[s]=n}),e}const Gm=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Ti(async()=>{const{default:n}=await Promise.resolve().then(()=>ks);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},p_=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Rn=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},Kr=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},ur=async(t,e)=>{await t.removeItem(e)};class xa{constructor(){this.promise=new xa.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}xa.promiseConstructor=Promise;function sl(t){const e=t.split(".");if(e.length!==3)throw new Nu("Invalid JWT structure");for(let n=0;n{setTimeout(()=>e(null),t)})}function g_(t,e){return new Promise((n,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!e(i,null,o)){n(o);return}}catch(o){if(!e(i,o)){s(o);return}}})()})}function v_(t){return("0"+t.toString(16)).substr(-2)}function y_(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let s="";for(let i=0;i<56;i++)s+=r.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,v_).join("")}async function w_(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(n);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function x_(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await w_(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function jn(t,e,r=!1){const n=y_();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await Rn(t,`${e}-code-verifier`,s);const i=await x_(n);return[i,n===i?"plain":"s256"]}const __=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function b_(t){const e=t.headers.get(ju);if(!e||!e.match(__))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function S_(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function k_(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const E_=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Pn(t){if(!E_.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function il(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function Th(t){return JSON.parse(JSON.stringify(t))}var C_=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);st.msg||t.message||t.error_description||t.error||JSON.stringify(t),j_=[502,503,504];async function Oh(t){var e;if(!p_(t))throw new Pu(Jr(t),0);if(j_.includes(t.status))throw new Pu(Jr(t),t.status);let r;try{r=await t.json()}catch(i){throw new Qm(Jr(i),i)}let n;const s=b_(t);if(s&&s.getTime()>=qm["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new Ch(Jr(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new dr}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new Ch(Jr(r),t.status,r.weak_password.reasons);throw new e_(Jr(r),t.status||500,n)}const P_=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function K(t,e,r,n){var s;const i=Object.assign({},n==null?void 0:n.headers);i[ju]||(i[ju]=qm["2024-01-01"].name),n!=null&&n.jwt&&(i.Authorization=`Bearer ${n.jwt}`);const o=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(o.redirect_to=n.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await N_(t,e,r+a,{headers:i,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(l):{data:Object.assign({},l),error:null}}async function N_(t,e,r,n,s,i){const o=P_(e,n,s,i);let a;try{a=await t(r,Object.assign({},o))}catch(l){throw console.error(l),new Pu(Jr(l),0)}if(a.ok||await Oh(a),n!=null&&n.noResolveJson)return a;try{return await a.json()}catch(l){await Oh(l)}}function Wt(t){var e;let r=null;I_(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=d_(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function Rh(t){const e=Wt(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function gr(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function T_(t){return{data:t,error:null}}function O_(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i}=t,o=C_(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function R_(t){return t}function I_(t){return t.access_token&&t.refresh_token&&t.expires_in}const ol=["global","local","others"];var L_=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s0&&(f.forEach(_=>{const x=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),b=JSON.parse(_.split(";")[1].split("=")[1]);u[`${b}Page`]=x}),u.total=parseInt(m)),{data:Object.assign(Object.assign({},d),u),error:null}}catch(u){if(B(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){Pn(e);try{return await K(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:gr})}catch(r){if(B(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){Pn(e);try{return await K(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:gr})}catch(n){if(B(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){Pn(e);try{return await K(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:gr})}catch(n){if(B(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){Pn(e.userId);try{const{data:r,error:n}=await K(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:n}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _deleteFactor(e){Pn(e.userId),Pn(e.id);try{return{data:await K(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}}function Ih(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}function $_(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const Nn={debug:!!(globalThis&&Vm()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Jm extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class U_ extends Jm{}async function D_(t,e,r){Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Nn.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new U_(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Nn.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}$_();const M_={url:Gx,storageKey:Jx,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Yx,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function Lh(t,e,r){return await r()}const Tn={};class xi{constructor(e){var r,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=xi.nextInstanceID,xi.nextInstanceID+=1,this.instanceID>0&&St()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const s=Object.assign(Object.assign({},M_),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new A_({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=Gm(s.fetch),this.lock=s.lock||Lh,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:St()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=D_:this.lock=Lh,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?(s.storage?this.storage=s.storage:Vm()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Ih(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=Ih(this.memoryStorage)),St()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}get jwks(){var e,r;return(r=(e=Tn[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Tn[this.storageKey]=Object.assign(Object.assign({},Tn[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Tn[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Tn[this.storageKey]=Object.assign(Object.assign({},Tn[this.storageKey]),{cachedAt:e})}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${Hm}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{const r=f_(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),St()&&this.detectSessionInUrl&&n!=="none"){const{data:s,error:i}=await this._getSessionFromURL(r,n);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),n_(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:o,redirectType:a}=s;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return B(r)?{error:r}:{error:new Qm("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const i=await K(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Wt}),{data:o,error:a}=i;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(B(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(e){var r,n,s;try{let i;if("email"in e){const{email:c,password:d,options:m}=e;let f=null,_=null;this.flowType==="pkce"&&([f,_]=await jn(this.storage,this.storageKey)),i=await K(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:m==null?void 0:m.emailRedirectTo,body:{email:c,password:d,data:(r=m==null?void 0:m.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken},code_challenge:f,code_challenge_method:_},xform:Wt})}else if("phone"in e){const{phone:c,password:d,options:m}=e;i=await K(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:c,password:d,data:(n=m==null?void 0:m.data)!==null&&n!==void 0?n:{},channel:(s=m==null?void 0:m.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken}},xform:Wt})}else throw new no("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(B(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:i,password:o,options:a}=e;r=await K(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Rh})}else if("phone"in e){const{phone:i,password:o,options:a}=e;r=await K(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Rh})}else throw new no("You must provide either an email or phone number and a password");const{data:n,error:s}=r;return s?{data:{user:null,session:null},error:s}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new ro}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(e){var r,n,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:r}=e;if(r==="solana")return await this.signInWithSolana(e);throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}async signInWithSolana(e){var r,n,s,i,o,a,l,u,c,d,m,f;let _,x;if("message"in e)_=e.message,x=e.signature;else{const{chain:b,wallet:v,statement:g,options:p}=e;let w;if(St())if(typeof v=="object")w=v;else{const S=window;if("solana"in S&&typeof S.solana=="object"&&("signIn"in S.solana&&typeof S.solana.signIn=="function"||"signMessage"in S.solana&&typeof S.solana.signMessage=="function"))w=S.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!(p!=null&&p.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");w=v}const k=new URL((r=p==null?void 0:p.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in w&&w.signIn){const S=await w.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},p==null?void 0:p.signInWithSolana),{version:"1",domain:k.host,uri:k.href}),g?{statement:g}:null));let j;if(Array.isArray(S)&&S[0]&&typeof S[0]=="object")j=S[0];else if(S&&typeof S=="object"&&"signedMessage"in S&&"signature"in S)j=S;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in j&&"signature"in j&&(typeof j.signedMessage=="string"||j.signedMessage instanceof Uint8Array)&&j.signature instanceof Uint8Array)_=typeof j.signedMessage=="string"?j.signedMessage:new TextDecoder().decode(j.signedMessage),x=j.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in w)||typeof w.signMessage!="function"||!("publicKey"in w)||typeof w!="object"||!w.publicKey||!("toBase58"in w.publicKey)||typeof w.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${k.host} wants you to sign in with your Solana account:`,w.publicKey.toBase58(),...g?["",g,""]:[""],"Version: 1",`URI: ${k.href}`,`Issued At: ${(s=(n=p==null?void 0:p.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=p==null?void 0:p.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${p.signInWithSolana.notBefore}`]:[],...!((o=p==null?void 0:p.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${p.signInWithSolana.expirationTime}`]:[],...!((a=p==null?void 0:p.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${p.signInWithSolana.chainId}`]:[],...!((l=p==null?void 0:p.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${p.signInWithSolana.nonce}`]:[],...!((u=p==null?void 0:p.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${p.signInWithSolana.requestId}`]:[],...!((d=(c=p==null?void 0:p.signInWithSolana)===null||c===void 0?void 0:c.resources)===null||d===void 0)&&d.length?["Resources",...p.signInWithSolana.resources.map(j=>`- ${j}`)]:[]].join(` +`);const S=await w.signMessage(new TextEncoder().encode(_),"utf8");if(!S||!(S instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");x=S}}try{const{data:b,error:v}=await K(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:c_(x)},!((m=e.options)===null||m===void 0)&&m.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:Wt});if(v)throw v;return!b||!b.session||!b.user?{data:{user:null,session:null},error:new ro}:(b.session&&(await this._saveSession(b.session),await this._notifyAllSubscribers("SIGNED_IN",b.session)),{data:Object.assign({},b),error:v})}catch(b){if(B(b))return{data:{user:null,session:null},error:b};throw b}}async _exchangeCodeForSession(e){const r=await Kr(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{const{data:i,error:o}=await K(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Wt});if(await ur(this.storage,`${this.storageKey}-code-verifier`),o)throw o;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new ro}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:o})}catch(i){if(B(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(e){try{const{options:r,provider:n,token:s,access_token:i,nonce:o}=e,a=await K(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Wt}),{data:l,error:u}=a;return u?{data:{user:null,session:null},error:u}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new ro}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:u})}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(e){var r,n,s,i,o;try{if("email"in e){const{email:a,options:l}=e;let u=null,c=null;this.flowType==="pkce"&&([u,c]=await jn(this.storage,this.storageKey));const{error:d}=await K(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=l==null?void 0:l.data)!==null&&r!==void 0?r:{},create_user:(n=l==null?void 0:l.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:u,code_challenge_method:c},redirectTo:l==null?void 0:l.emailRedirectTo});return{data:{user:null,session:null},error:d}}if("phone"in e){const{phone:a,options:l}=e,{data:u,error:c}=await K(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=l==null?void 0:l.data)!==null&&s!==void 0?s:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:c}}throw new no("You must provide either an email or phone number.")}catch(a){if(B(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var r,n;try{let s,i;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:o,error:a}=await K(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:Wt});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,u=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(s){if(B(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var r,n,s;try{let i=null,o=null;return this.flowType==="pkce"&&([i,o]=await jn(this.storage,this.storageKey)),await K(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:o}),headers:this.headers,xform:T_})}catch(i){if(B(i))return{data:null,error:i};throw i}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new dr;const{error:s}=await K(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(B(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:s,options:i}=e,{error:o}=await K(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:n,type:s,options:i}=e,{data:o,error:a}=await K(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a}}throw new no("You must provide either an email or phone number and a type")}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Kr(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()(!o&&u==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),o=!0,this.suppressGetSessionWarning=!0),Reflect.get(l,u,c))})}return{data:{session:e},error:null}}const{session:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await K(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:gr}):await this._useSession(async r=>{var n,s,i;const{data:o,error:a}=r;if(a)throw a;return!(!((n=o.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new dr}:await K(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=o.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:gr})})}catch(r){if(B(r))return r_(r)&&(await this._removeSession(),await ur(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:s,error:i}=n;if(i)throw i;if(!s.session)throw new dr;const o=s.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await jn(this.storage,this.storageKey));const{data:u,error:c}=await K(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:gr});if(c)throw c;return o.user=u.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(n){if(B(n))return{data:{user:null},error:n};throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new dr;const r=Date.now()/1e3;let n=r,s=!0,i=null;const{payload:o}=sl(e.access_token);if(o.exp&&(n=o.exp,s=n<=r),s){const{session:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)throw l;i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(r){if(B(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:o,error:a}=r;if(a)throw a;e=(n=o.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new dr;const{session:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(B(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e,r){try{if(!St())throw new so("No browser detected.");if(e.error||e.error_description||e.error_code)throw new so(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new Eh("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new so("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Eh("No code detected.");const{data:g,error:p}=await this._exchangeCodeForSession(e.code);if(p)throw p;const w=new URL(window.location.href);return w.searchParams.delete("code"),window.history.replaceState(window.history.state,"",w.toString()),{data:{session:g.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:s,access_token:i,refresh_token:o,expires_in:a,expires_at:l,token_type:u}=e;if(!i||!a||!o||!u)throw new so("No session defined in URL");const c=Math.round(Date.now()/1e3),d=parseInt(a);let m=c+d;l&&(m=parseInt(l));const f=m-c;f*1e3<=On&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${d}s`);const _=m-d;c-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,m,c):c-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,m,c);const{data:x,error:b}=await this._getUser(i);if(b)throw b;const v={provider_token:n,provider_refresh_token:s,access_token:i,expires_in:d,expires_at:m,refresh_token:o,token_type:u,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:v,redirectType:e.type},error:null}}catch(n){if(B(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await Kr(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return{error:i};const o=(n=s.session)===null||n===void 0?void 0:n.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(t_(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await ur(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const r=h_(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,s;try{const{data:{session:i},error:o}=r;if(o)throw o;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),console.error(i)}})}async resetPasswordForEmail(e,r={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await jn(this.storage,this.storageKey,!0));try{return await K(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(B(i))return{data:null,error:i};throw i}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async linkIdentity(e){var r;try{const{data:n,error:s}=await this._useSession(async i=>{var o,a,l,u,c;const{data:d,error:m}=i;if(m)throw m;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await K(this.fetch,"GET",f,{headers:this.headers,jwt:(c=(u=d.session)===null||u===void 0?void 0:u.access_token)!==null&&c!==void 0?c:void 0})});if(s)throw s;return St()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:e.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(B(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:o}=r;if(o)throw o;return await K(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await g_(async s=>(s>0&&await m_(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await K(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Wt})),(s,i)=>{const o=200*Math.pow(2,s);return i&&nl(i)&&Date.now()+o-n{try{await a.callback(e,r)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;athis._autoRefreshTokenTick(),On);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((n.expires_at*1e3-e)/On);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${On}ms, refresh threshold is ${Cu} ticks`),s<=Cu&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Jm)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!St()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const s=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[i,o]=await jn(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});s.push(a.toString())}if(n!=null&&n.queryParams){const i=new URLSearchParams(n.queryParams);s.push(i.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?{data:null,error:i}:await K(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:o}=r;if(o)return{data:null,error:o};const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:l,error:u}=await K(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token});return u?{data:null,error:u}:(e.factorType==="totp"&&(!((s=l==null?void 0:l.totp)===null||s===void 0)&&s.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),{data:l,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return{data:null,error:i};const{data:o,error:a}=await K(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:a})})}catch(r){if(B(r))return{data:null,error:r};throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?{data:null,error:i}:await K(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(B(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){const{data:{user:e},error:r}=await this.getUser();if(r)return{data:null,error:r};const n=(e==null?void 0:e.factors)||[],s=n.filter(o=>o.factor_type==="totp"&&o.status==="verified"),i=n.filter(o=>o.factor_type==="phone"&&o.status==="verified");return{data:{all:n,totp:s,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var r,n;const{data:{session:s},error:i}=e;if(i)return{data:null,error:i};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=sl(s.access_token);let a=null;o.aal&&(a=o.aal);let l=a;((n=(r=s.user.factors)===null||r===void 0?void 0:r.filter(d=>d.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(l="aal2");const c=o.amr||[];return{data:{currentLevel:a,nextLevel:l,currentAuthenticationMethods:c},error:null}}))}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(a=>a.kid===e);if(n)return n;const s=Date.now();if(n=this.jwks.keys.find(a=>a.kid===e),n&&this.jwks_cached_at+Zx>s)return n;const{data:i,error:o}=await K(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,n=i.keys.find(a=>a.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:f,error:_}=await this.getSession();if(_||!f.session)return{data:null,error:_};n=f.session.access_token}const{header:s,payload:i,signature:o,raw:{header:a,payload:l}}=sl(n);r!=null&&r.allowExpired||S_(i.exp);const u=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!u){const{error:f}=await this.getUser(n);if(f)throw f;return{data:{claims:i,header:s,signature:o},error:null}}const c=k_(s.alg),d=await crypto.subtle.importKey("jwk",u,c,!0,["verify"]);if(!await crypto.subtle.verify(c,d,o,u_(`${a}.${l}`)))throw new Nu("Invalid JWT signature");return{data:{claims:i,header:s,signature:o},error:null}}catch(n){if(B(n))return{data:null,error:n};throw n}}}xi.nextInstanceID=0;const F_=xi;class z_ extends F_{constructor(e){super(e)}}var B_=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):s(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};class W_{constructor(e,r,n){var s,i,o;if(this.supabaseUrl=e,this.supabaseKey=r,!e)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const a=Kx(e),l=new URL(a);this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const u=`sb-${l.hostname.split(".")[0]}-auth-token`,c={db:Mx,realtime:zx,auth:Object.assign(Object.assign({},Fx),{storageKey:u}),global:Dx},d=Vx(n??{},c);this.storageKey=(s=d.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(i=d.global.headers)!==null&&i!==void 0?i:{},d.accessToken?(this.accessToken=d.accessToken,this.auth=new Proxy({},{get:(m,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((o=d.auth)!==null&&o!==void 0?o:{},this.headers,d.global.fetch),this.fetch=qx(r,this._getAccessToken.bind(this),d.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},d.realtime)),this.rest=new ix(new URL("rest/v1",l).href,{headers:this.headers,schema:d.db.schema,fetch:this.fetch}),this.storage=new Ax(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),d.accessToken||this._listenForAuthEvents()}get functions(){return new Uw(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},n={}){return this.rest.rpc(e,r,n)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,r;return B_(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return(r=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,storageKey:i,flowType:o,lock:a,debug:l},u,c){const d={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new z_({url:this.authUrl.href,headers:Object.assign(Object.assign({},d),u),storageKey:i,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,flowType:o,lock:a,debug:l,fetch:c,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new bx(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,r,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:e==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const H_=(t,e,r)=>new W_(t,e,r);function q_(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}q_()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const Q_="https://tjlvullrsgepsoqyeali.supabase.co",K_="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InRqbHZ1bGxyc2dlcHNvcXllYWxpIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTYxMzkyNzgsImV4cCI6MjA3MTcxNTI3OH0.3znjDsjFP93YOJOEkn-XpalCK17yPHXUxFSfbu22ZrA",Q=H_(Q_,K_,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0}});function _a(){const[t,e]=C.useState(null),[r,n]=C.useState(!0);C.useEffect(()=>{console.log("Setting up auth listener..."),Q.auth.getSession().then(({data:{session:u}})=>{var c;console.log("Initial session:",(c=u==null?void 0:u.user)==null?void 0:c.email),u!=null&&u.user&&s(u.user),n(!1)});const{data:{subscription:l}}=Q.auth.onAuthStateChange(async(u,c)=>{var d,m;console.log("Auth state change:",{event:u,userId:(d=c==null?void 0:c.user)==null?void 0:d.id,email:(m=c==null?void 0:c.user)==null?void 0:m.email}),u==="SIGNED_IN"&&(c!=null&&c.user)?await s(c.user):u==="SIGNED_OUT"&&e(null),n(!1)});return()=>l.unsubscribe()},[]);const s=async l=>{var u,c,d,m,f,_,x,b,v;console.log("Loading user data for:",l.email);try{const{data:g,error:p}=await Q.from("profiles").select("*").eq("id",l.id).single();if(console.log("Profile query result:",{profile:g,error:p}),g&&!p){console.log("Using existing profile:",g.username),e({id:g.id,email:l.email||"",username:g.username,display_name:g.display_name||g.username,avatar_url:g.avatar_url,status:g.status,created_at:g.created_at});return}console.log("Profile not found, creating one...");const k=(((u=l.email)==null?void 0:u.split("@")[0])||"user").replace(/[^a-zA-Z0-9_]/g,"").toLowerCase(),{data:S,error:j}=await Q.from("profiles").insert({id:l.id,username:k,email:l.email||"",display_name:((c=l.user_metadata)==null?void 0:c.full_name)||k,avatar_url:((d=l.user_metadata)==null?void 0:d.avatar_url)||null,status:"online"}).select().single();S&&!j?e({id:S.id,email:l.email||"",username:S.username,display_name:S.display_name||S.username,avatar_url:S.avatar_url,status:S.status,created_at:S.created_at}):(console.warn("Failed to create profile, using auth data:",j),e({id:l.id,email:l.email||"",username:k,display_name:((m=l.user_metadata)==null?void 0:m.full_name)||k,avatar_url:((f=l.user_metadata)==null?void 0:f.avatar_url)||null,status:"online",created_at:l.created_at}))}catch(g){console.error("Error loading user data:",g),e({id:l.id,email:l.email||"",username:((_=l.email)==null?void 0:_.split("@")[0])||"user",display_name:((x=l.user_metadata)==null?void 0:x.full_name)||((b=l.email)==null?void 0:b.split("@")[0])||"user",avatar_url:((v=l.user_metadata)==null?void 0:v.avatar_url)||null,status:"online",created_at:l.created_at})}};return{user:t,loading:r,signUp:async(l,u)=>{try{const{data:c,error:d}=await Q.auth.signUp({email:l,password:u});if(d)throw d;return{success:!0,data:c}}catch(c){return{success:!1,error:c instanceof Error?c.message:"Unknown error"}}},signIn:async(l,u)=>{try{const{data:c,error:d}=await Q.auth.signInWithPassword({email:l,password:u});if(d)throw d;return{success:!0,data:c}}catch(c){return{success:!1,error:c instanceof Error?c.message:"Unknown error"}}},signOut:async()=>{try{const{error:l}=await Q.auth.signOut();if(l)throw l;return e(null),{success:!0}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Unknown error"}}},isAuthenticated:!!t}}function al(){const[t,e]=C.useState(!1),[r,n]=C.useState(""),[s,i]=C.useState(""),[o,a]=C.useState(!1),{signIn:l,signUp:u}=_a(),c=async d=>{if(d.preventDefault(),!r||!s){H.error("Please fill in all fields");return}a(!0);try{const m=t?await u(r,s):await l(r,s);m.success?t&&H.success("Account created! Please check your email to verify your account."):H.error(m.error)}catch(m){H.error(m instanceof Error?m.message:"Unknown error")}finally{a(!1)}};return h.jsx("div",{className:"min-h-screen bg-discord-bg flex items-center justify-center p-4",children:h.jsx("div",{className:"w-full max-w-md",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg p-8 shadow-xl",children:[h.jsxs("div",{className:"text-center mb-8",children:[h.jsx("h1",{className:"text-3xl font-bold text-discord-text mb-2",children:"CrestChat"}),h.jsx("p",{className:"text-discord-muted",children:"Your Discord-like chat application"})]}),h.jsxs("form",{onSubmit:c,className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-discord-text mb-2",children:"Email"}),h.jsx("input",{id:"email",type:"email",value:r,onChange:d=>n(d.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter your email",required:!0})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-discord-text mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:s,onChange:d=>i(d.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter your password",required:!0})]}),h.jsx("button",{type:"submit",disabled:o,className:"w-full bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:o?"Loading...":t?"Create Account":"Sign In"})]}),h.jsx("div",{className:"mt-6 text-center",children:h.jsx("button",{onClick:()=>e(!t),className:"text-discord-muted hover:text-discord-text transition-colors duration-200",children:t?"Already have an account? Sign In":"Don't have an account? Sign Up"})})]})})})}function V_(){const t=ma(),{data:e=[],isLoading:r}=vu({queryKey:["user-servers"],queryFn:async()=>{const{data:c,error:d}=await Q.from("server_members").select(` server_id, servers ( *, channels (*) ) - `);return d?(console.error("Error fetching user servers:",d),[]):(c==null?void 0:c.map(m=>({...m.servers,channels:m.servers.channels||[]})))||[]}}),{data:n=[],isLoading:s}=vu({queryKey:["public-servers"],queryFn:async()=>{const{data:c,error:d}=await q.from("servers").select(` + `);return d?(console.error("Error fetching user servers:",d),[]):(c==null?void 0:c.map(m=>({...m.servers,channels:m.servers.channels||[]})))||[]}}),{data:n=[],isLoading:s}=vu({queryKey:["public-servers"],queryFn:async()=>{const{data:c,error:d}=await Q.from("servers").select(` *, channels (*) - `).eq("privacy_level","public");return d?(console.error("Error fetching public servers:",d),[]):c||[]}}),i=[...e.map(c=>({...c,isMember:!0})),...n.filter(c=>!e.find(d=>d.id===c.id)).map(c=>({...c,isMember:!1}))],o=Xn({mutationFn:async({name:c,description:d,privacyLevel:m})=>{var g,p;const{data:f,error:_}=await q.from("servers").insert({name:c,description:d,privacy_level:m,owner_id:(g=(await q.auth.getUser()).data.user)==null?void 0:g.id}).select().single();if(_)throw _;const{data:x,error:b}=await q.from("channels").insert({name:"general",server_id:f.id,type:"text"}).select().single();if(b)throw b;const{error:v}=await q.from("server_members").insert({server_id:f.id,user_id:(p=(await q.auth.getUser()).data.user)==null?void 0:p.id});if(v)throw v;return{...f,channels:[x]}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]}),H.success("Server created successfully!")},onError:c=>{H.error(`Failed to create server: ${c.message}`)}}),a=Xn({mutationFn:async({name:c,serverId:d,type:m="text"})=>{const{data:f,error:_}=await q.from("channels").insert({name:c,server_id:d,type:m}).select().single();if(_)throw _;return f},onSuccess:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]}),H.success("Channel created successfully!")},onError:c=>{H.error(`Failed to create channel: ${c.message}`)}}),l=Xn({mutationFn:async c=>{var m;const{error:d}=await q.from("server_members").insert({server_id:c,user_id:(m=(await q.auth.getUser()).data.user)==null?void 0:m.id});if(d)throw d;return{success:!0}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]}),H.success("Joined server successfully!")},onError:c=>{H.error(`Failed to join server: ${c.message}`)}});return{servers:i,userServers:e,publicServers:n,isLoading:r||s,createServer:o,createChannel:a,joinServer:l,refreshServers:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]})}}}function G_({servers:t,currentServer:e,currentChannel:r,onServerSelect:n,onChannelSelect:s,user:i}){var J;const[o,a]=C.useState(!1),[l,u]=C.useState(!1),[c,d]=C.useState(!1),[m,f]=C.useState(""),[_,x]=C.useState(""),[b,v]=C.useState("public"),[g,p]=C.useState(""),[w,k]=C.useState(""),[S,j]=C.useState(!1),T=async()=>{if(!m.trim()){H.error("Please enter a server name");return}j(!0);try{const $=Math.random().toString(36).substring(2,8).toUpperCase(),{data:fe,error:ge}=await q.from("servers").insert({name:m.trim(),description:_.trim()||null,owner_id:i.id,privacy_level:b,invite_code:$}).select().single();if(ge)throw console.error("Server creation error:",ge),ge;console.log("Server created:",fe);const{error:$e}=await q.from("channels").insert({name:"general",server_id:fe.id,type:"text"});if($e)throw console.error("Channel creation error:",$e),$e;console.log("Default channel created");const{error:Pe}=await q.from("server_members").insert({server_id:fe.id,user_id:i.id});if(Pe)throw console.error("Member creation error:",Pe),Pe;console.log("Owner added as member"),H.success("Server created successfully!"),a(!1),f(""),x(""),v("public"),window.location.reload()}catch($){console.error("Full error:",$),H.error(`Failed to create server: ${$.message}`)}finally{j(!1)}},P=async()=>{if(!e||!g.trim()){H.error("Please enter a channel name");return}j(!0);try{const{error:$}=await q.from("channels").insert({name:g.trim(),server_id:e.id,type:"text"});if($)throw $;H.success("Channel created successfully!"),u(!1),p(""),window.location.reload()}catch($){H.error(`Failed to create channel: ${$.message}`)}finally{j(!1)}},E=async()=>{if(!w.trim()){H.error("Please enter an invite code");return}j(!0);try{const{error:$}=await q.rpc("join_server_by_invite",{invite_code_param:w.trim().toUpperCase()});if($)throw $;H.success("Joined server successfully!"),d(!1),k(""),window.location.reload()}catch($){H.error(`Failed to join server: ${$.message}`)}finally{j(!1)}},F=$=>{switch($){case"text":return"#";case"voice":return"🔊";case"announcement":return"📢";default:return"#"}};return h.jsxs("div",{className:"w-64 bg-discord-sidebar flex flex-col h-full",children:[h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-2",children:[h.jsx("button",{onClick:()=>n(null),className:`w-full p-3 rounded-lg transition-colors ${e?"bg-discord-channel hover:bg-discord-channel/80 text-discord-text":"bg-discord-primary text-white"}`,children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})}),h.jsx("span",{className:"font-medium",children:"Home"})]})}),h.jsx("div",{className:"border-t border-gray-700 my-4"}),t.map($=>{var fe;return h.jsxs("div",{className:"space-y-2",children:[h.jsx("button",{onClick:()=>n($),className:`w-full p-3 rounded-lg transition-colors ${(e==null?void 0:e.id)===$.id?"bg-discord-primary text-white":"bg-discord-channel hover:bg-discord-channel/80 text-discord-text"}`,children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center font-medium",children:$.name.charAt(0).toUpperCase()}),h.jsxs("div",{className:"flex-1 text-left",children:[h.jsx("p",{className:"font-medium truncate",children:$.name}),h.jsxs("p",{className:"text-xs opacity-75 truncate",children:[((fe=$.channels)==null?void 0:fe.length)||0," channels"]})]})]})}),(e==null?void 0:e.id)===$.id&&$.channels&&h.jsx("div",{className:"ml-4 space-y-1",children:$.channels.map(ge=>h.jsx("button",{onClick:()=>s(ge),className:`w-full p-2 rounded transition-colors text-left ${(r==null?void 0:r.id)===ge.id?"bg-discord-primary text-white":"text-discord-muted hover:text-discord-text hover:bg-discord-channel/50"}`,children:h.jsxs("div",{className:"flex items-center space-x-2",children:[h.jsx("span",{className:"text-sm",children:F(ge.type)}),h.jsx("span",{className:"text-sm truncate",children:ge.name})]})},ge.id))})]},$.id)}),h.jsx("button",{onClick:()=>a(!0),className:"w-full p-3 rounded-lg bg-discord-channel hover:bg-discord-channel/80 text-discord-text transition-colors",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),h.jsx("span",{className:"font-medium",children:"Create Server"})]})}),h.jsx("button",{onClick:()=>d(!0),className:"w-full p-3 rounded-lg bg-discord-channel hover:bg-discord-channel/80 text-discord-text transition-colors",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),h.jsx("span",{className:"font-medium",children:"Join Server"})]})}),e&&h.jsx("button",{onClick:()=>u(!0),className:"w-full p-3 rounded-lg bg-discord-channel hover:bg-discord-channel/80 text-discord-text transition-colors",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),h.jsx("span",{className:"font-medium",children:"Create Channel"})]})})]}),h.jsx("div",{className:"p-4 border-t border-gray-700",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((J=i.username)==null?void 0:J.charAt(0).toUpperCase())||"U"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text truncate",children:i.display_name||i.username}),h.jsx("p",{className:"text-xs text-discord-muted truncate",children:i.email})]}),h.jsx("div",{className:"w-4 h-4"})]})}),o&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md p-6",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text mb-4",children:"Create Server"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Server Name"}),h.jsx("input",{type:"text",value:m,onChange:$=>f($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter server name"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Description (Optional)"}),h.jsx("textarea",{value:_,onChange:$=>x($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",rows:3,placeholder:"Describe your server..."})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Privacy Level"}),h.jsxs("select",{value:b,onChange:$=>v($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",children:[h.jsx("option",{value:"public",children:"Public - Anyone can join"}),h.jsx("option",{value:"private",children:"Private - Invite only"}),h.jsx("option",{value:"invite_only",children:"Invite Only - Requires invite link"})]})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>a(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:T,disabled:S||!m.trim(),className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:S?"Creating...":"Create Server"})]})]})]})}),l&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md p-6",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text mb-4",children:"Create Channel"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Channel Name"}),h.jsx("input",{type:"text",value:g,onChange:$=>p($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter channel name"})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>u(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:P,disabled:S||!g.trim(),className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:S?"Creating...":"Create Channel"})]})]})]})}),c&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md p-6",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text mb-4",children:"Join Server"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Invite Code"}),h.jsx("input",{type:"text",value:w,onChange:$=>k($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter invite code"})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>d(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:E,disabled:S||!w.trim(),className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:S?"Joining...":"Join Server"})]})]})]})})]})}function J_(t){const e=ma(),{data:r=[],isLoading:n}=vu({queryKey:["messages",t],queryFn:async()=>{if(!t)return[];const{data:a,error:l}=await q.from("messages").select(` + `).eq("privacy_level","public");return d?(console.error("Error fetching public servers:",d),[]):c||[]}}),i=[...e.map(c=>({...c,isMember:!0})),...n.filter(c=>!e.find(d=>d.id===c.id)).map(c=>({...c,isMember:!1}))],o=Xn({mutationFn:async({name:c,description:d,privacyLevel:m})=>{var g,p;const{data:f,error:_}=await Q.from("servers").insert({name:c,description:d,privacy_level:m,owner_id:(g=(await Q.auth.getUser()).data.user)==null?void 0:g.id}).select().single();if(_)throw _;const{data:x,error:b}=await Q.from("channels").insert({name:"general",server_id:f.id,type:"text"}).select().single();if(b)throw b;const{error:v}=await Q.from("server_members").insert({server_id:f.id,user_id:(p=(await Q.auth.getUser()).data.user)==null?void 0:p.id});if(v)throw v;return{...f,channels:[x]}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]}),H.success("Server created successfully!")},onError:c=>{H.error(`Failed to create server: ${c instanceof Error?c.message:"Unknown error"}`)}}),a=Xn({mutationFn:async({name:c,serverId:d,type:m="text"})=>{const{data:f,error:_}=await Q.from("channels").insert({name:c,server_id:d,type:m}).select().single();if(_)throw _;return f},onSuccess:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]}),H.success("Channel created successfully!")},onError:c=>{H.error(`Failed to create channel: ${c instanceof Error?c.message:"Unknown error"}`)}}),l=Xn({mutationFn:async c=>{var m;const{error:d}=await Q.from("server_members").insert({server_id:c,user_id:(m=(await Q.auth.getUser()).data.user)==null?void 0:m.id});if(d)throw d;return{success:!0}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]}),H.success("Joined server successfully!")},onError:c=>{H.error(`Failed to join server: ${c instanceof Error?c.message:"Unknown error"}`)}});return{servers:i,userServers:e,publicServers:n,isLoading:r||s,createServer:o,createChannel:a,joinServer:l,refreshServers:()=>{t.invalidateQueries({queryKey:["user-servers"]}),t.invalidateQueries({queryKey:["public-servers"]})}}}function G_({servers:t,currentServer:e,currentChannel:r,onServerSelect:n,onChannelSelect:s,user:i}){var q;const[o,a]=C.useState(!1),[l,u]=C.useState(!1),[c,d]=C.useState(!1),[m,f]=C.useState(""),[_,x]=C.useState(""),[b,v]=C.useState("public"),[g,p]=C.useState(""),[w,k]=C.useState(""),[S,j]=C.useState(!1),T=async()=>{if(!m.trim()){H.error("Please enter a server name");return}j(!0);try{const $=Math.random().toString(36).substring(2,8).toUpperCase(),{data:fe,error:ge}=await Q.from("servers").insert({name:m.trim(),description:_.trim()||null,owner_id:i.id,privacy_level:b,invite_code:$}).select().single();if(ge)throw console.error("Server creation error:",ge),ge;console.log("Server created:",fe);const{error:$e}=await Q.from("channels").insert({name:"general",server_id:fe.id,type:"text"});if($e)throw console.error("Channel creation error:",$e),$e;console.log("Default channel created");const{error:Pe}=await Q.from("server_members").insert({server_id:fe.id,user_id:i.id});if(Pe)throw console.error("Member creation error:",Pe),Pe;console.log("Owner added as member"),H.success("Server created successfully!"),a(!1),f(""),x(""),v("public"),window.location.reload()}catch($){console.error("Full error:",$),H.error(`Failed to create server: ${$ instanceof Error?$.message:"Unknown error"}`)}finally{j(!1)}},P=async()=>{if(!e||!g.trim()){H.error("Please enter a channel name");return}j(!0);try{const{error:$}=await Q.from("channels").insert({name:g.trim(),server_id:e.id,type:"text"});if($)throw $;H.success("Channel created successfully!"),u(!1),p(""),window.location.reload()}catch($){H.error(`Failed to create channel: ${$ instanceof Error?$.message:"Unknown error"}`)}finally{j(!1)}},E=async()=>{if(!w.trim()){H.error("Please enter an invite code");return}j(!0);try{const{error:$}=await Q.rpc("join_server_by_invite",{invite_code_param:w.trim().toUpperCase()});if($)throw $;H.success("Joined server successfully!"),d(!1),k(""),window.location.reload()}catch($){H.error(`Failed to join server: ${$ instanceof Error?$.message:"Unknown error"}`)}finally{j(!1)}},M=$=>{switch($){case"text":return"#";case"voice":return"🔊";case"announcement":return"📢";default:return"#"}};return h.jsxs("div",{className:"w-64 bg-discord-sidebar flex flex-col h-full",children:[h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-2",children:[h.jsx("button",{onClick:()=>n(null),className:`w-full p-3 rounded-lg transition-colors ${e?"bg-discord-channel hover:bg-discord-channel/80 text-discord-text":"bg-discord-primary text-white"}`,children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})}),h.jsx("span",{className:"font-medium",children:"Home"})]})}),h.jsx("div",{className:"border-t border-gray-700 my-4"}),t.map($=>{var fe;return h.jsxs("div",{className:"space-y-2",children:[h.jsx("button",{onClick:()=>n($),className:`w-full p-3 rounded-lg transition-colors ${(e==null?void 0:e.id)===$.id?"bg-discord-primary text-white":"bg-discord-channel hover:bg-discord-channel/80 text-discord-text"}`,children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center font-medium",children:$.name.charAt(0).toUpperCase()}),h.jsxs("div",{className:"flex-1 text-left",children:[h.jsx("p",{className:"font-medium truncate",children:$.name}),h.jsxs("p",{className:"text-xs opacity-75 truncate",children:[((fe=$.channels)==null?void 0:fe.length)||0," channels"]})]})]})}),(e==null?void 0:e.id)===$.id&&$.channels&&h.jsx("div",{className:"ml-4 space-y-1",children:$.channels.map(ge=>h.jsx("button",{onClick:()=>s(ge),className:`w-full p-2 rounded transition-colors text-left ${(r==null?void 0:r.id)===ge.id?"bg-discord-primary text-white":"text-discord-muted hover:text-discord-text hover:bg-discord-channel/50"}`,children:h.jsxs("div",{className:"flex items-center space-x-2",children:[h.jsx("span",{className:"text-sm",children:M(ge.type)}),h.jsx("span",{className:"text-sm truncate",children:ge.name})]})},ge.id))})]},$.id)}),h.jsx("button",{onClick:()=>a(!0),className:"w-full p-3 rounded-lg bg-discord-channel hover:bg-discord-channel/80 text-discord-text transition-colors",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),h.jsx("span",{className:"font-medium",children:"Create Server"})]})}),h.jsx("button",{onClick:()=>d(!0),className:"w-full p-3 rounded-lg bg-discord-channel hover:bg-discord-channel/80 text-discord-text transition-colors",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),h.jsx("span",{className:"font-medium",children:"Join Server"})]})}),e&&h.jsx("button",{onClick:()=>u(!0),className:"w-full p-3 rounded-lg bg-discord-channel hover:bg-discord-channel/80 text-discord-text transition-colors",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),h.jsx("span",{className:"font-medium",children:"Create Channel"})]})})]}),h.jsx("div",{className:"p-4 border-t border-gray-700",children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((q=i.username)==null?void 0:q.charAt(0).toUpperCase())||"U"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text truncate",children:i.display_name||i.username}),h.jsx("p",{className:"text-xs text-discord-muted truncate",children:i.email})]}),h.jsx("div",{className:"w-4 h-4"})]})}),o&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md p-6",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text mb-4",children:"Create Server"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Server Name"}),h.jsx("input",{type:"text",value:m,onChange:$=>f($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter server name"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Description (Optional)"}),h.jsx("textarea",{value:_,onChange:$=>x($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",rows:3,placeholder:"Describe your server..."})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Privacy Level"}),h.jsxs("select",{value:b,onChange:$=>v($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",children:[h.jsx("option",{value:"public",children:"Public - Anyone can join"}),h.jsx("option",{value:"private",children:"Private - Invite only"}),h.jsx("option",{value:"invite_only",children:"Invite Only - Requires invite link"})]})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>a(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:T,disabled:S||!m.trim(),className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:S?"Creating...":"Create Server"})]})]})]})}),l&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md p-6",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text mb-4",children:"Create Channel"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Channel Name"}),h.jsx("input",{type:"text",value:g,onChange:$=>p($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter channel name"})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>u(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:P,disabled:S||!g.trim(),className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:S?"Creating...":"Create Channel"})]})]})]})}),c&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md p-6",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text mb-4",children:"Join Server"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Invite Code"}),h.jsx("input",{type:"text",value:w,onChange:$=>k($.target.value),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter invite code"})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>d(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:E,disabled:S||!w.trim(),className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:S?"Joining...":"Join Server"})]})]})]})})]})}function J_(t){const e=ma(),{data:r=[],isLoading:n}=vu({queryKey:["messages",t],queryFn:async()=>{if(!t)return[];const{data:a,error:l}=await Q.from("messages").select(` *, author:profiles!messages_author_id_fkey ( id, @@ -107,7 +107,7 @@ Option 2: Install and provide the "ws" package: avatar_url, status ) - `).eq("channel_id",t).eq("is_deleted",!1).order("created_at",{ascending:!0}).limit(100);return l?(console.error("Error fetching messages:",l),[]):a||[]},enabled:!!t}),s=Xn({mutationFn:async a=>{var c;if(!t)throw new Error("No channel selected");const{data:l,error:u}=await q.from("messages").insert({channel_id:t,author_id:(c=(await q.auth.getUser()).data.user)==null?void 0:c.id,content:a,type:"default",is_pinned:!1,is_edited:!1,is_deleted:!1,mentions_everyone:!1,mention_roles:[],mention_users:[],embeds:null,attachments:null,reactions:null,flags:0}).select(` + `).eq("channel_id",t).eq("is_deleted",!1).order("created_at",{ascending:!0}).limit(100);return l?(console.error("Error fetching messages:",l),[]):a||[]},enabled:!!t}),s=Xn({mutationFn:async a=>{var c;if(!t)throw new Error("No channel selected");const{data:l,error:u}=await Q.from("messages").insert({channel_id:t,author_id:(c=(await Q.auth.getUser()).data.user)==null?void 0:c.id,content:a,type:"default",is_pinned:!1,is_edited:!1,is_deleted:!1,mentions_everyone:!1,mention_roles:[],mention_users:[],embeds:null,attachments:null,reactions:null,flags:0}).select(` *, author:profiles!messages_author_id_fkey ( id, @@ -116,9 +116,9 @@ Option 2: Install and provide the "ws" package: avatar_url, status ) - `).single();if(u)throw u;return l},onSuccess:()=>{e.invalidateQueries({queryKey:["messages",t]})},onError:a=>{H.error(`Failed to send message: ${a.message}`)}}),i=Xn({mutationFn:async({messageId:a,content:l})=>{const{data:u,error:c}=await q.from("messages").update({content:l,is_edited:!0,updated_at:new Date().toISOString()}).eq("id",a).select().single();if(c)throw c;return u},onSuccess:()=>{e.invalidateQueries({queryKey:["messages",t]}),H.success("Message edited successfully!")},onError:a=>{H.error(`Failed to edit message: ${a.message}`)}}),o=Xn({mutationFn:async a=>{const{error:l}=await q.from("messages").update({is_deleted:!0,updated_at:new Date().toISOString()}).eq("id",a);if(l)throw l;return{success:!0}},onSuccess:()=>{e.invalidateQueries({queryKey:["messages",t]}),H.success("Message deleted successfully!")},onError:a=>{H.error(`Failed to delete message: ${a.message}`)}});return{messages:r,messagesLoading:n,sendMessage:s,editMessage:i,deleteMessage:o}}function Y_({channel:t,server:e,onOpenServerSettings:r}){const{messages:n,messagesLoading:s,sendMessage:i,editMessage:o,deleteMessage:a}=J_(t.id),[l,u]=C.useState(""),[c,d]=C.useState(null),[m,f]=C.useState(""),[_,x]=C.useState(!1),b=C.useRef(null),v=C.useRef(null);C.useEffect(()=>{var E;(E=b.current)==null||E.scrollIntoView({behavior:"smooth"})},[n]),C.useEffect(()=>{var E;(E=v.current)==null||E.focus(),d(null),f("")},[t.id]);const g=E=>{const F=new Date(E),$=(new Date().getTime()-F.getTime())/(1e3*60*60);return $<24?F.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$<168?F.toLocaleDateString([],{weekday:"short"}):F.toLocaleDateString([],{month:"short",day:"numeric"})},p=async()=>{if(l.trim())try{await i.mutateAsync(l.trim()),u("")}catch{}},w=async()=>{if(!(!c||!m.trim()))try{await o.mutateAsync({messageId:c,content:m.trim()}),d(null),f("")}catch{}},k=async E=>{if(confirm("Are you sure you want to delete this message?"))try{await a.mutateAsync(E)}catch{}},S=E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),c?w():p())},j=E=>{d(E.id),f(E.content)},T=()=>{d(null),f("")},P=(E,F)=>{H.info("Reactions coming soon!")};return h.jsxs("div",{className:"flex flex-col h-full bg-discord-bg",children:[h.jsx("div",{className:"bg-discord-channel border-b border-gray-700 px-6 py-4",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("span",{className:"text-discord-muted text-2xl",children:"#"}),h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text",children:t.name}),h.jsx("p",{className:"text-sm text-discord-muted",children:t.description||"No description"})]})]}),e&&r&&h.jsx("button",{onClick:r,className:"p-2 hover:bg-discord-channel/80 rounded-md transition-colors",title:"Server Settings",children:h.jsxs("svg",{className:"w-5 h-5 text-discord-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s?h.jsx("div",{className:"flex items-center justify-center h-full",children:h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-discord-primary"})}):n.length===0?h.jsx("div",{className:"flex items-center justify-center h-full",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"text-6xl mb-4",children:"👋"}),h.jsxs("h3",{className:"text-xl font-bold text-discord-text mb-2",children:["Welcome to #",t.name,"!"]}),h.jsxs("p",{className:"text-discord-muted",children:["This is the beginning of the #",t.name," channel."]})]})}):n.map(E=>{var F,J,$,fe;return h.jsx("div",{className:"group hover:bg-discord-channel/30 rounded-md p-2 transition-colors",children:c===E.id?h.jsxs("div",{className:"space-y-2",children:[h.jsx("textarea",{value:m,onChange:ge=>f(ge.target.value),onKeyPress:S,className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent resize-none",rows:Math.max(1,m.split(` -`).length),autoFocus:!0}),h.jsxs("div",{className:"flex items-center space-x-2 text-xs text-discord-muted",children:[h.jsx("span",{children:"Press ESC to cancel • Enter to save"}),h.jsx("button",{onClick:T,className:"text-discord-danger hover:text-discord-danger/80 transition-colors",children:"Cancel"})]})]}):h.jsxs("div",{className:"flex space-x-3",children:[h.jsx("div",{className:"flex-shrink-0",children:h.jsx("div",{className:"w-10 h-10 rounded-full bg-discord-primary flex items-center justify-center text-white font-medium",children:((J=(F=E.author)==null?void 0:F.username)==null?void 0:J.charAt(0).toUpperCase())||"U"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[h.jsx("span",{className:"font-medium text-sm text-discord-text",children:(($=E.author)==null?void 0:$.display_name)||((fe=E.author)==null?void 0:fe.username)||"Unknown User"}),h.jsx("span",{className:"text-xs text-discord-muted",children:g(E.created_at)}),E.is_edited&&h.jsx("span",{className:"text-xs text-discord-muted",children:"(edited)"})]}),h.jsx("div",{className:"text-discord-text text-sm whitespace-pre-wrap break-words",children:E.content}),h.jsxs("div",{className:"flex items-center space-x-1 mt-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{onClick:()=>P(E.id),className:"p-1 hover:bg-discord-channel rounded text-discord-muted hover:text-discord-text transition-colors",title:"Add reaction",children:"😊"}),h.jsx("button",{onClick:()=>j(E),className:"p-1 hover:bg-discord-channel rounded text-discord-muted hover:text-discord-text transition-colors",title:"Edit message",children:h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),h.jsx("button",{onClick:()=>k(E.id),className:"p-1 hover:bg-discord-channel rounded text-discord-muted hover:text-discord-danger transition-colors",title:"Delete message",children:h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})},E.id)}),h.jsx("div",{ref:b})]}),h.jsxs("div",{className:"p-4 border-t border-gray-700",children:[h.jsxs("div",{className:"flex items-end space-x-3",children:[h.jsxs("div",{className:"flex-1 relative",children:[h.jsx("textarea",{ref:v,value:l,onChange:E=>u(E.target.value),onKeyPress:S,placeholder:`Message #${t.name}`,className:"w-full px-4 py-3 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent resize-none",rows:Math.max(1,Math.min(4,l.split(` -`).length))}),h.jsx("button",{onClick:()=>x(!_),className:"absolute right-3 bottom-3 p-1 hover:bg-discord-channel/80 rounded text-discord-muted hover:text-discord-text transition-colors",title:"Add emoji",children:"😊"})]}),h.jsx("button",{onClick:p,disabled:!l.trim()||i.isPending,className:"px-4 py-3 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 disabled:cursor-not-allowed text-white font-medium rounded-md transition-colors",children:i.isPending?h.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}):h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),h.jsxs("div",{className:"flex items-center justify-between mt-2 text-xs text-discord-muted",children:[h.jsx("span",{children:"Press Enter to send, Shift+Enter for new line"}),h.jsxs("span",{children:[l.length,"/2000"]})]})]})]})}function X_({server:t}){const[e,r]=C.useState([]),[n,s]=C.useState(!1);C.useEffect(()=>{t&&i()},[t]);const i=async()=>{if(t){s(!0);try{const{data:l,error:u}=await q.from("server_members").select(` + `).single();if(u)throw u;return l},onSuccess:()=>{e.invalidateQueries({queryKey:["messages",t]})},onError:a=>{H.error(`Failed to send message: ${a instanceof Error?a.message:"Unknown error"}`)}}),i=Xn({mutationFn:async({messageId:a,content:l})=>{const{data:u,error:c}=await Q.from("messages").update({content:l,is_edited:!0,updated_at:new Date().toISOString()}).eq("id",a).select().single();if(c)throw c;return u},onSuccess:()=>{e.invalidateQueries({queryKey:["messages",t]}),H.success("Message edited successfully!")},onError:a=>{H.error(`Failed to edit message: ${a instanceof Error?a.message:"Unknown error"}`)}}),o=Xn({mutationFn:async a=>{const{error:l}=await Q.from("messages").update({is_deleted:!0,updated_at:new Date().toISOString()}).eq("id",a);if(l)throw l;return{success:!0}},onSuccess:()=>{e.invalidateQueries({queryKey:["messages",t]}),H.success("Message deleted successfully!")},onError:a=>{H.error(`Failed to delete message: ${a instanceof Error?a.message:"Unknown error"}`)}});return{messages:r,messagesLoading:n,sendMessage:s,editMessage:i,deleteMessage:o}}function Y_({channel:t,server:e,onOpenServerSettings:r}){const{messages:n,messagesLoading:s,sendMessage:i,editMessage:o,deleteMessage:a}=J_(t.id),[l,u]=C.useState(""),[c,d]=C.useState(null),[m,f]=C.useState(""),[_,x]=C.useState(!1),b=C.useRef(null),v=C.useRef(null);C.useEffect(()=>{var E;(E=b.current)==null||E.scrollIntoView({behavior:"smooth"})},[n]),C.useEffect(()=>{var E;(E=v.current)==null||E.focus(),d(null),f("")},[t.id]);const g=E=>{const M=new Date(E),$=(new Date().getTime()-M.getTime())/(1e3*60*60);return $<24?M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$<168?M.toLocaleDateString([],{weekday:"short"}):M.toLocaleDateString([],{month:"short",day:"numeric"})},p=async()=>{if(l.trim())try{await i.mutateAsync(l.trim()),u("")}catch{}},w=async()=>{if(!(!c||!m.trim()))try{await o.mutateAsync({messageId:c,content:m.trim()}),d(null),f("")}catch{}},k=async E=>{if(confirm("Are you sure you want to delete this message?"))try{await a.mutateAsync(E)}catch{}},S=E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),c?w():p())},j=E=>{d(E.id),f(E.content)},T=()=>{d(null),f("")},P=(E,M)=>{H.info("Reactions coming soon!")};return h.jsxs("div",{className:"flex flex-col h-full bg-discord-bg",children:[h.jsx("div",{className:"bg-discord-channel border-b border-gray-700 px-6 py-4",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("span",{className:"text-discord-muted text-2xl",children:"#"}),h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text",children:t.name}),h.jsx("p",{className:"text-sm text-discord-muted",children:t.description||"No description"})]})]}),e&&r&&h.jsx("button",{onClick:r,className:"p-2 hover:bg-discord-channel/80 rounded-md transition-colors",title:"Server Settings",children:h.jsxs("svg",{className:"w-5 h-5 text-discord-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s?h.jsx("div",{className:"flex items-center justify-center h-full",children:h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-discord-primary"})}):n.length===0?h.jsx("div",{className:"flex items-center justify-center h-full",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"text-6xl mb-4",children:"👋"}),h.jsxs("h3",{className:"text-xl font-bold text-discord-text mb-2",children:["Welcome to #",t.name,"!"]}),h.jsxs("p",{className:"text-discord-muted",children:["This is the beginning of the #",t.name," channel."]})]})}):n.map(E=>{var M,q,$,fe;return h.jsx("div",{className:"group hover:bg-discord-channel/30 rounded-md p-2 transition-colors",children:c===E.id?h.jsxs("div",{className:"space-y-2",children:[h.jsx("textarea",{value:m,onChange:ge=>f(ge.target.value),onKeyPress:S,className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent resize-none",rows:Math.max(1,m.split(` +`).length),autoFocus:!0}),h.jsxs("div",{className:"flex items-center space-x-2 text-xs text-discord-muted",children:[h.jsx("span",{children:"Press ESC to cancel • Enter to save"}),h.jsx("button",{onClick:T,className:"text-discord-danger hover:text-discord-danger/80 transition-colors",children:"Cancel"})]})]}):h.jsxs("div",{className:"flex space-x-3",children:[h.jsx("div",{className:"flex-shrink-0",children:h.jsx("div",{className:"w-10 h-10 rounded-full bg-discord-primary flex items-center justify-center text-white font-medium",children:((q=(M=E.author)==null?void 0:M.username)==null?void 0:q.charAt(0).toUpperCase())||"U"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[h.jsx("span",{className:"font-medium text-sm text-discord-text",children:(($=E.author)==null?void 0:$.display_name)||((fe=E.author)==null?void 0:fe.username)||"Unknown User"}),h.jsx("span",{className:"text-xs text-discord-muted",children:g(E.created_at)}),E.is_edited&&h.jsx("span",{className:"text-xs text-discord-muted",children:"(edited)"})]}),h.jsx("div",{className:"text-discord-text text-sm whitespace-pre-wrap break-words",children:E.content}),h.jsxs("div",{className:"flex items-center space-x-1 mt-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{onClick:()=>P(E.id),className:"p-1 hover:bg-discord-channel rounded text-discord-muted hover:text-discord-text transition-colors",title:"Add reaction",children:"😊"}),h.jsx("button",{onClick:()=>j(E),className:"p-1 hover:bg-discord-channel rounded text-discord-muted hover:text-discord-text transition-colors",title:"Edit message",children:h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),h.jsx("button",{onClick:()=>k(E.id),className:"p-1 hover:bg-discord-channel rounded text-discord-muted hover:text-discord-danger transition-colors",title:"Delete message",children:h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})},E.id)}),h.jsx("div",{ref:b})]}),h.jsxs("div",{className:"p-4 border-t border-gray-700",children:[h.jsxs("div",{className:"flex items-end space-x-3",children:[h.jsxs("div",{className:"flex-1 relative",children:[h.jsx("textarea",{ref:v,value:l,onChange:E=>u(E.target.value),onKeyPress:S,placeholder:`Message #${t.name}`,className:"w-full px-4 py-3 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent resize-none",rows:Math.max(1,Math.min(4,l.split(` +`).length))}),h.jsx("button",{onClick:()=>x(!_),className:"absolute right-3 bottom-3 p-1 hover:bg-discord-channel/80 rounded text-discord-muted hover:text-discord-text transition-colors",title:"Add emoji",children:"😊"})]}),h.jsx("button",{onClick:p,disabled:!l.trim()||i.isPending,className:"px-4 py-3 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 disabled:cursor-not-allowed text-white font-medium rounded-md transition-colors",children:i.isPending?h.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}):h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),h.jsxs("div",{className:"flex items-center justify-between mt-2 text-xs text-discord-muted",children:[h.jsx("span",{children:"Press Enter to send, Shift+Enter for new line"}),h.jsxs("span",{children:[l.length,"/2000"]})]})]})]})}function X_({server:t}){const[e,r]=C.useState([]),[n,s]=C.useState(!1),i=C.useCallback(async()=>{if(t){s(!0);try{const{data:l,error:u}=await Q.from("server_members").select(` user_id, user:profiles!server_members_user_id_fkey ( id, @@ -127,7 +127,7 @@ Option 2: Install and provide the "ws" package: status, avatar_url ) - `).eq("server_id",t.id);if(u)throw u;const c=(l==null?void 0:l.map(d=>d.user).filter(d=>d&&d.status!=="offline").sort((d,m)=>{const f={online:0,idle:1,dnd:2,invisible:3};return f[d.status]-f[m.status]}))||[];r(c)}catch(l){console.error("Error loading online users:",l)}finally{s(!1)}}},o=l=>{switch(l){case"online":return"bg-green-500";case"idle":return"bg-yellow-500";case"dnd":return"bg-red-500";case"invisible":return"bg-gray-500";default:return"bg-gray-500"}},a=l=>{switch(l){case"online":return"Online";case"idle":return"Idle";case"dnd":return"Do Not Disturb";case"invisible":return"Invisible";default:return"Offline"}};return t?h.jsxs("div",{className:"space-y-4",children:[h.jsxs("h3",{className:"text-sm font-semibold text-discord-text uppercase tracking-wide",children:["Online — ",e.length]}),n?h.jsxs("div",{className:"text-center py-4",children:[h.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-discord-primary mx-auto mb-2"}),h.jsx("p",{className:"text-xs text-discord-muted",children:"Loading..."})]}):h.jsxs("div",{className:"space-y-2",children:[e.map(l=>{var u;return h.jsxs("div",{className:"flex items-center space-x-3 p-2 hover:bg-discord-channel/50 rounded-md transition-colors",children:[h.jsxs("div",{className:"relative",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((u=l.username)==null?void 0:u.charAt(0).toUpperCase())||"U"}),h.jsx("div",{className:`absolute -bottom-1 -right-1 w-3 h-3 ${o(l.status)} rounded-full border-2 border-discord-channel`})]}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text truncate",children:l.display_name||l.username}),h.jsx("p",{className:"text-xs text-discord-muted truncate",children:a(l.status)})]})]},l.id)}),e.length===0&&h.jsx("p",{className:"text-xs text-discord-muted text-center py-4",children:"No one is online"})]})]}):null}function Z_({server:t}){var g;const{user:e,signOut:r}=_a(),[n,s]=C.useState(!1),[i,o]=C.useState(!1),[a,l]=C.useState(!1),[u,c]=C.useState({status:"online",display_name:"",bio:"",theme:"dark",notifications:!0}),[d,m]=C.useState(!1);C.useEffect(()=>{e&&f()},[e]);const f=async()=>{if(e)try{const{data:p,error:w}=await q.from("user_settings").select("*").eq("user_id",e.id).single();if(w&&w.code!=="PGRST116")throw w;p?c({status:p.status||"online",display_name:p.display_name||e.display_name||"",bio:p.bio||"",theme:p.theme||"dark",notifications:p.notifications!==!1}):await q.from("user_settings").insert({user_id:e.id,status:"online",display_name:e.display_name||e.username,bio:"",theme:"dark",notifications:!0})}catch(p){console.error("Error loading user settings:",p)}},_=async p=>{if(e){m(!0);try{const{error:w}=await q.from("user_settings").upsert({user_id:e.id,status:p,display_name:u.display_name,bio:u.bio,theme:u.theme,notifications:u.notifications});if(w)throw w;c(k=>({...k,status:p})),l(!1),H.success("Status updated successfully!")}catch(w){H.error(`Failed to update status: ${w.message}`)}finally{m(!1)}}},x=async()=>{if(e){m(!0);try{const{error:p}=await q.from("user_settings").upsert({user_id:e.id,status:u.status,display_name:u.display_name,bio:u.bio,theme:u.theme,notifications:u.notifications});if(p)throw p;o(!1),H.success("Settings saved successfully!")}catch(p){H.error(`Failed to save settings: ${p.message}`)}finally{m(!1)}}},b=p=>{switch(p){case"online":return"bg-green-500";case"idle":return"bg-yellow-500";case"dnd":return"bg-red-500";case"invisible":return"bg-gray-500";default:return"bg-green-500"}},v=p=>{switch(p){case"online":return"Online";case"idle":return"Idle";case"dnd":return"Do Not Disturb";case"invisible":return"Invisible";default:return"Online"}};return e?h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsx("div",{className:"flex-1 overflow-y-auto",children:h.jsx(X_,{server:t})}),h.jsxs("div",{className:"mt-4 relative",children:[h.jsx("div",{className:"bg-discord-channel hover:bg-discord-channel/80 p-3 rounded-md cursor-pointer transition-colors",onClick:()=>s(!n),children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsxs("div",{className:"relative",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((g=e.username)==null?void 0:g.charAt(0).toUpperCase())||"U"}),h.jsx("div",{className:`absolute -bottom-1 -right-1 w-3 h-3 ${b(u.status)} rounded-full border-2 border-discord-channel`})]}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text truncate",children:u.display_name||e.display_name||e.username}),h.jsx("p",{className:"text-xs text-discord-muted truncate",children:v(u.status)})]}),h.jsx("svg",{className:`w-4 h-4 text-discord-muted transition-transform ${n?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})}),n&&h.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 bg-discord-sidebar border border-gray-700 rounded-md shadow-lg z-50",children:[h.jsxs("div",{className:"p-3 border-b border-gray-700",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text",children:u.display_name||e.display_name||e.username}),h.jsx("p",{className:"text-xs text-discord-muted",children:e.email})]}),h.jsxs("div",{className:"py-1",children:[h.jsxs("div",{className:"relative",children:[h.jsxs("button",{onClick:()=>l(!a),className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors flex items-center justify-between",children:[h.jsx("span",{children:"Set Status"}),h.jsx("div",{className:`w-3 h-3 ${b(u.status)} rounded-full`})]}),a&&h.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-48 bg-discord-sidebar border border-gray-700 rounded-md shadow-lg",children:[{status:"online",label:"Online",color:"bg-green-500"},{status:"idle",label:"Idle",color:"bg-yellow-500"},{status:"dnd",label:"Do Not Disturb",color:"bg-red-500"},{status:"invisible",label:"Invisible",color:"bg-gray-500"}].map(p=>h.jsxs("button",{onClick:()=>_(p.status),disabled:d,className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors flex items-center space-x-2",children:[h.jsx("div",{className:`w-3 h-3 ${p.color} rounded-full`}),h.jsx("span",{children:p.label})]},p.status))})]}),h.jsx("button",{onClick:()=>{s(!1),o(!0)},className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors",children:"User Settings"}),h.jsx("button",{onClick:()=>{s(!1)},className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors",children:"Privacy & Safety"}),h.jsx("button",{onClick:()=>{s(!1)},className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors",children:"Activity Status"})]}),h.jsx("div",{className:"border-t border-gray-700 py-1",children:h.jsx("button",{onClick:()=>{s(!1),r()},className:"w-full px-3 py-2 text-left text-sm text-discord-danger hover:bg-discord-channel transition-colors",children:"Sign Out"})})]})]}),i&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md max-h-[90vh] overflow-hidden",children:[h.jsx("div",{className:"p-6 border-b border-gray-700",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text",children:"User Settings"}),h.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-discord-channel rounded-md transition-colors",children:h.jsx("svg",{className:"w-5 h-5 text-discord-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),h.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Display Name"}),h.jsx("input",{type:"text",value:u.display_name,onChange:p=>c({...u,display_name:p.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter display name"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Bio"}),h.jsx("textarea",{value:u.bio,onChange:p=>c({...u,bio:p.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",rows:3,placeholder:"Tell us about yourself..."})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Theme"}),h.jsxs("select",{value:u.theme,onChange:p=>c({...u,theme:p.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",children:[h.jsx("option",{value:"dark",children:"Dark"}),h.jsx("option",{value:"light",children:"Light"}),h.jsx("option",{value:"auto",children:"Auto"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-discord-text",children:"Notifications"}),h.jsx("p",{className:"text-xs text-discord-muted",children:"Receive notifications for mentions and messages"})]}),h.jsx("button",{onClick:()=>c({...u,notifications:!u.notifications}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${u.notifications?"bg-discord-primary":"bg-gray-600"}`,children:h.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${u.notifications?"translate-x-6":"translate-x-1"}`})})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>o(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:x,disabled:d,className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:d?"Saving...":"Save Changes"})]})]})]})})]}):null}function e1({server:t,isOpen:e,onClose:r,onServerUpdate:n,onChannelUpdate:s}){const[i,o]=C.useState("overview"),[a,l]=C.useState(!1),[u,c]=C.useState([]),[d,m]=C.useState([]),[f,_]=C.useState(!1),[x,b]=C.useState({name:"",description:"",privacyLevel:"public"}),[v,g]=C.useState("");C.useEffect(()=>{t&&e&&(b({name:t.name,description:t.description||"",privacyLevel:t.privacy_level}),p(),w())},[t,e]);const p=async()=>{if(t)try{const{data:P,error:E}=await q.from("channels").select("*").eq("server_id",t.id).order("position",{ascending:!0});if(E)throw E;c(P||[])}catch(P){console.error("Error loading channels:",P),H.error("Failed to load channels")}},w=async()=>{if(t){_(!0);try{console.log("Loading members for server:",t.id);const{data:P,error:E}=await q.from("server_members").select(` + `).eq("server_id",t.id);if(u)throw u;const c=(l==null?void 0:l.map(d=>d.user).flat().filter(d=>d&&d.status!=="offline").sort((d,m)=>{const f={online:0,idle:1,dnd:2,invisible:3};return f[d.status]-f[m.status]}))||[];r(c)}catch(l){console.error("Error loading online users:",l)}finally{s(!1)}}},[t]);C.useEffect(()=>{t&&i()},[t,i]);const o=l=>{switch(l){case"online":return"bg-green-500";case"idle":return"bg-yellow-500";case"dnd":return"bg-red-500";case"invisible":return"bg-gray-500";default:return"bg-gray-500"}},a=l=>{switch(l){case"online":return"Online";case"idle":return"Idle";case"dnd":return"Do Not Disturb";case"invisible":return"Invisible";default:return"Offline"}};return t?h.jsxs("div",{className:"space-y-4",children:[h.jsxs("h3",{className:"text-sm font-semibold text-discord-text uppercase tracking-wide",children:["Online — ",e.length]}),n?h.jsxs("div",{className:"text-center py-4",children:[h.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-discord-primary mx-auto mb-2"}),h.jsx("p",{className:"text-xs text-discord-muted",children:"Loading..."})]}):h.jsxs("div",{className:"space-y-2",children:[e.map(l=>{var u;return h.jsxs("div",{className:"flex items-center space-x-3 p-2 hover:bg-discord-channel/50 rounded-md transition-colors",children:[h.jsxs("div",{className:"relative",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((u=l.username)==null?void 0:u.charAt(0).toUpperCase())||"U"}),h.jsx("div",{className:`absolute -bottom-1 -right-1 w-3 h-3 ${o(l.status)} rounded-full border-2 border-discord-channel`})]}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text truncate",children:l.display_name||l.username}),h.jsx("p",{className:"text-xs text-discord-muted truncate",children:a(l.status)})]})]},l.id)}),e.length===0&&h.jsx("p",{className:"text-xs text-discord-muted text-center py-4",children:"No one is online"})]})]}):null}function Z_({server:t}){var g;const{user:e,signOut:r}=_a(),[n,s]=C.useState(!1),[i,o]=C.useState(!1),[a,l]=C.useState(!1),[u,c]=C.useState({status:"online",display_name:"",bio:"",theme:"dark",notifications:!0}),[d,m]=C.useState(!1),f=C.useCallback(async()=>{if(e)try{const{data:p,error:w}=await Q.from("user_settings").select("*").eq("user_id",e.id).single();if(w&&w.code!=="PGRST116")throw w;p?c({status:p.status||"online",display_name:p.display_name||e.display_name||"",bio:p.bio||"",theme:p.theme||"dark",notifications:p.notifications!==!1}):await Q.from("user_settings").insert({user_id:e.id,status:"online",display_name:e.display_name||e.username,bio:"",theme:"dark",notifications:!0})}catch(p){console.error("Error loading user settings:",p)}},[e]);C.useEffect(()=>{e&&f()},[e,f]);const _=async p=>{if(e){m(!0);try{const{error:w}=await Q.from("user_settings").upsert({user_id:e.id,status:p,display_name:u.display_name,bio:u.bio,theme:u.theme,notifications:u.notifications});if(w)throw w;c(k=>({...k,status:p})),l(!1),H.success("Status updated successfully!")}catch(w){H.error(`Failed to update status: ${w instanceof Error?w.message:"Unknown error"}`)}finally{m(!1)}}},x=async()=>{if(e){m(!0);try{const{error:p}=await Q.from("user_settings").upsert({user_id:e.id,status:u.status,display_name:u.display_name,bio:u.bio,theme:u.theme,notifications:u.notifications});if(p)throw p;o(!1),H.success("Settings saved successfully!")}catch(p){H.error(`Failed to save settings: ${p instanceof Error?p.message:"Unknown error"}`)}finally{m(!1)}}},b=p=>{switch(p){case"online":return"bg-green-500";case"idle":return"bg-yellow-500";case"dnd":return"bg-red-500";case"invisible":return"bg-gray-500";default:return"bg-green-500"}},v=p=>{switch(p){case"online":return"Online";case"idle":return"Idle";case"dnd":return"Do Not Disturb";case"invisible":return"Invisible";default:return"Online"}};return e?h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsx("div",{className:"flex-1 overflow-y-auto",children:h.jsx(X_,{server:t||null})}),h.jsxs("div",{className:"mt-4 relative",children:[h.jsx("div",{className:"bg-discord-channel hover:bg-discord-channel/80 p-3 rounded-md cursor-pointer transition-colors",onClick:()=>s(!n),children:h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsxs("div",{className:"relative",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((g=e.username)==null?void 0:g.charAt(0).toUpperCase())||"U"}),h.jsx("div",{className:`absolute -bottom-1 -right-1 w-3 h-3 ${b(u.status)} rounded-full border-2 border-discord-channel`})]}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text truncate",children:u.display_name||e.display_name||e.username}),h.jsx("p",{className:"text-xs text-discord-muted truncate",children:v(u.status)})]}),h.jsx("svg",{className:`w-4 h-4 text-discord-muted transition-transform ${n?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})}),n&&h.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 bg-discord-sidebar border border-gray-700 rounded-md shadow-lg z-50",children:[h.jsxs("div",{className:"p-3 border-b border-gray-700",children:[h.jsx("p",{className:"text-sm font-medium text-discord-text",children:u.display_name||e.display_name||e.username}),h.jsx("p",{className:"text-xs text-discord-muted",children:e.email})]}),h.jsxs("div",{className:"py-1",children:[h.jsxs("div",{className:"relative",children:[h.jsxs("button",{onClick:()=>l(!a),className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors flex items-center justify-between",children:[h.jsx("span",{children:"Set Status"}),h.jsx("div",{className:`w-3 h-3 ${b(u.status)} rounded-full`})]}),a&&h.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-48 bg-discord-sidebar border border-gray-700 rounded-md shadow-lg",children:[{status:"online",label:"Online",color:"bg-green-500"},{status:"idle",label:"Idle",color:"bg-yellow-500"},{status:"dnd",label:"Do Not Disturb",color:"bg-red-500"},{status:"invisible",label:"Invisible",color:"bg-gray-500"}].map(p=>h.jsxs("button",{onClick:()=>_(p.status),disabled:d,className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors flex items-center space-x-2",children:[h.jsx("div",{className:`w-3 h-3 ${p.color} rounded-full`}),h.jsx("span",{children:p.label})]},p.status))})]}),h.jsx("button",{onClick:()=>{s(!1),o(!0)},className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors",children:"User Settings"}),h.jsx("button",{onClick:()=>{s(!1)},className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors",children:"Privacy & Safety"}),h.jsx("button",{onClick:()=>{s(!1)},className:"w-full px-3 py-2 text-left text-sm text-discord-text hover:bg-discord-channel transition-colors",children:"Activity Status"})]}),h.jsx("div",{className:"border-t border-gray-700 py-1",children:h.jsx("button",{onClick:()=>{s(!1),r()},className:"w-full px-3 py-2 text-left text-sm text-discord-danger hover:bg-discord-channel transition-colors",children:"Sign Out"})})]})]}),i&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-md max-h-[90vh] overflow-hidden",children:[h.jsx("div",{className:"p-6 border-b border-gray-700",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text",children:"User Settings"}),h.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-discord-channel rounded-md transition-colors",children:h.jsx("svg",{className:"w-5 h-5 text-discord-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),h.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Display Name"}),h.jsx("input",{type:"text",value:u.display_name,onChange:p=>c({...u,display_name:p.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",placeholder:"Enter display name"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Bio"}),h.jsx("textarea",{value:u.bio,onChange:p=>c({...u,bio:p.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",rows:3,placeholder:"Tell us about yourself..."})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Theme"}),h.jsxs("select",{value:u.theme,onChange:p=>c({...u,theme:p.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",children:[h.jsx("option",{value:"dark",children:"Dark"}),h.jsx("option",{value:"light",children:"Light"}),h.jsx("option",{value:"auto",children:"Auto"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-discord-text",children:"Notifications"}),h.jsx("p",{className:"text-xs text-discord-muted",children:"Receive notifications for mentions and messages"})]}),h.jsx("button",{onClick:()=>c({...u,notifications:!u.notifications}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${u.notifications?"bg-discord-primary":"bg-gray-600"}`,children:h.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${u.notifications?"translate-x-6":"translate-x-1"}`})})]}),h.jsxs("div",{className:"flex space-x-3 pt-4",children:[h.jsx("button",{onClick:()=>o(!1),className:"flex-1 px-4 py-2 bg-discord-channel hover:bg-discord-channel/80 text-discord-text font-medium rounded-md transition-colors",children:"Cancel"}),h.jsx("button",{onClick:x,disabled:d,className:"flex-1 px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors",children:d?"Saving...":"Save Changes"})]})]})]})})]}):null}function e1({server:t,isOpen:e,onClose:r,onServerUpdate:n,onChannelUpdate:s}){const[i,o]=C.useState("overview"),[a,l]=C.useState(!1),[u,c]=C.useState([]),[d,m]=C.useState([]),[f,_]=C.useState(!1),[x,b]=C.useState({name:"",description:"",privacyLevel:"public"}),[v,g]=C.useState(""),p=C.useCallback(async()=>{if(t)try{const{data:P,error:E}=await Q.from("channels").select("*").eq("server_id",t.id).order("position",{ascending:!0});if(E)throw E;c(P||[])}catch(P){console.error("Error loading channels:",P),H.error("Failed to load channels")}},[t]),w=C.useCallback(async()=>{if(t){_(!0);try{console.log("Loading members for server:",t.id);const{data:P,error:E}=await Q.from("server_members").select(` user_id, user:profiles!server_members_user_id_fkey ( id, @@ -136,4 +136,4 @@ Option 2: Install and provide the "ws" package: avatar_url, status ) - `).eq("server_id",t.id);if(E)throw console.error("Supabase error loading members:",E),E;console.log("Members loaded successfully:",P),m(P||[])}catch(P){console.error("Error loading members:",P),H.error("Failed to load members")}finally{_(!1)}}},k=async()=>{if(t){l(!0);try{const{error:P}=await q.from("servers").update({name:x.name,description:x.description,privacy_level:x.privacyLevel}).eq("id",t.id);if(P)throw P;H.success("Server updated successfully!"),n()}catch(P){H.error(`Failed to update server: ${P.message}`)}finally{l(!1)}}},S=async()=>{if(!(!t||!v.trim()))try{const{error:P}=await q.from("channels").insert({name:v.trim(),server_id:t.id,type:"text"});if(P)throw P;H.success("Channel created successfully!"),g(""),p(),s()}catch(P){H.error(`Failed to create channel: ${P.message}`)}},j=async P=>{if(confirm("Are you sure you want to delete this channel?"))try{const{error:E}=await q.from("channels").delete().eq("id",P);if(E)throw E;H.success("Channel deleted successfully!"),p(),s()}catch(E){H.error(`Failed to delete channel: ${E.message}`)}},T=async(P,E)=>{if(!(!t||!confirm(`Are you sure you want to remove ${E} from this server?`)))try{const{error:F}=await q.from("server_members").delete().eq("server_id",t.id).eq("user_id",P);if(F)throw F;H.success("Member removed successfully!"),w()}catch(F){H.error(`Failed to remove member: ${F.message}`)}};return!e||!t?null:h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[h.jsx("div",{className:"p-6 border-b border-gray-700",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text",children:"Server Settings"}),h.jsx("button",{onClick:r,className:"p-2 hover:bg-discord-channel rounded-md transition-colors",children:h.jsx("svg",{className:"w-5 h-5 text-discord-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),h.jsxs("div",{className:"flex h-[calc(90vh-120px)]",children:[h.jsx("div",{className:"w-48 bg-discord-channel p-4",children:h.jsx("nav",{className:"space-y-1",children:[{id:"overview",label:"Overview"},{id:"channels",label:"Channels"},{id:"members",label:"Members"},{id:"roles",label:"Roles"},{id:"safety",label:"Safety"}].map(P=>h.jsx("button",{onClick:()=>o(P.id),className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${i===P.id?"bg-discord-primary text-white":"text-discord-muted hover:text-discord-text hover:bg-discord-channel/50"}`,children:P.label},P.id))})}),h.jsxs("div",{className:"flex-1 p-6 overflow-y-auto",children:[i==="overview"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Server Overview"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Server Name"}),h.jsx("input",{type:"text",value:x.name,onChange:P=>b({...x,name:P.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Description"}),h.jsx("textarea",{value:x.description,onChange:P=>b({...x,description:P.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",rows:3})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Privacy Level"}),h.jsxs("select",{value:x.privacyLevel,onChange:P=>b({...x,privacyLevel:P.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",children:[h.jsx("option",{value:"public",children:"Public"}),h.jsx("option",{value:"private",children:"Private"}),h.jsx("option",{value:"invite_only",children:"Invite Only"})]})]}),h.jsx("button",{onClick:k,disabled:a,className:"px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors duration-200",children:a?"Saving...":"Save Changes"})]})]}),i==="channels"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Channels"}),h.jsxs("div",{className:"space-y-4",children:[h.jsx("h4",{className:"text-md font-medium text-discord-text",children:"Create Channel"}),h.jsxs("div",{className:"flex space-x-3",children:[h.jsx("input",{type:"text",value:v,onChange:P=>g(P.target.value),placeholder:"Enter channel name",className:"flex-1 px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent"}),h.jsx("button",{onClick:S,disabled:!v.trim(),className:"px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors duration-200",children:"Create"})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("h4",{className:"text-md font-medium text-discord-text",children:"Existing Channels"}),u.map(P=>h.jsxs("div",{className:"flex items-center justify-between p-3 bg-discord-channel rounded-md",children:[h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("span",{className:"text-discord-muted",children:"#"}),h.jsx("span",{className:"text-discord-text",children:P.name})]}),h.jsx("button",{onClick:()=>j(P.id),className:"px-3 py-1 bg-discord-danger hover:bg-discord-danger/90 text-white text-sm rounded transition-colors",children:"Delete"})]},P.id))]})]}),i==="members"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Members"}),f?h.jsxs("div",{className:"text-center py-8",children:[h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-discord-primary mx-auto mb-2"}),h.jsx("p",{className:"text-discord-muted",children:"Loading members..."})]}):h.jsx("div",{className:"space-y-2",children:d.map(P=>{var E,F,J,$,fe;return h.jsxs("div",{className:"flex items-center justify-between p-3 bg-discord-channel rounded-md",children:[h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((F=(E=P.user)==null?void 0:E.username)==null?void 0:F.charAt(0).toUpperCase())||"U"}),h.jsxs("div",{children:[h.jsx("p",{className:"text-discord-text font-medium",children:((J=P.user)==null?void 0:J.display_name)||(($=P.user)==null?void 0:$.username)||"Unknown User"}),h.jsx("p",{className:"text-discord-muted text-sm",children:(fe=P.user)==null?void 0:fe.username})]})]}),h.jsx("button",{onClick:()=>{var ge;return T(P.user_id,((ge=P.user)==null?void 0:ge.username)||"User")},className:"px-3 py-1 bg-discord-danger hover:bg-discord-danger/90 text-white text-sm rounded transition-colors",children:"Remove"})]},P.user_id)})})]}),i==="roles"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Roles"}),h.jsx("p",{className:"text-discord-muted",children:"Role management coming soon..."})]}),i==="safety"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Safety"}),h.jsx("p",{className:"text-discord-muted",children:"Safety settings coming soon..."})]})]})]})]})})}function ll(){const{user:t}=_a(),{servers:e,isLoading:r}=V_(),[n,s]=C.useState(null),[i,o]=C.useState(null),[a,l]=C.useState(!1),u=m=>{s(m),m.channels&&m.channels.length>0?o(m.channels[0]):o(null)},c=m=>{o(m)},d=()=>{l(!0)};return r?h.jsx("div",{className:"min-h-screen bg-discord-bg flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-b-2 border-discord-primary mx-auto mb-4"}),h.jsx("p",{className:"text-discord-text text-lg",children:"Loading servers..."})]})}):h.jsxs("div",{className:"flex h-screen bg-discord-bg",children:[h.jsx(G_,{servers:e,currentServer:n,currentChannel:i,onServerSelect:u,onChannelSelect:c,user:t}),h.jsx("div",{className:"flex-1 flex flex-col",children:n&&i?h.jsx(Y_,{channel:i,server:n,onServerUpdate:()=>{window.location.reload()},onChannelUpdate:()=>{window.location.reload()},onOpenServerSettings:d}):h.jsx("div",{className:"flex-1 flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("h2",{className:"text-2xl font-bold text-discord-text mb-2",children:"Welcome to CrestChat!"}),h.jsx("p",{className:"text-discord-muted",children:n?"Select a channel to start chatting":"Select a server to get started"})]})})}),h.jsx("div",{className:"w-64 bg-discord-sidebar border-l border-gray-700 p-4",children:h.jsx(Z_,{server:n})}),h.jsx(e1,{server:n,isOpen:a,onClose:()=>l(!1),onServerUpdate:()=>{window.location.reload()},onChannelUpdate:()=>{window.location.reload()}})]})}function t1(){return h.jsx("div",{className:"min-h-screen bg-discord-bg flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-b-2 border-discord-primary mx-auto mb-4"}),h.jsx("p",{className:"text-discord-text text-lg",children:"Loading CrestChat..."})]})})}function r1(){const{user:t,loading:e}=_a();return e?h.jsx(t1,{}):h.jsx("div",{className:"min-h-screen bg-discord-bg",children:h.jsxs(S0,{children:[h.jsx(yo,{path:"/",element:t?h.jsx(ll,{}):h.jsx(al,{})}),h.jsx(yo,{path:"/auth",element:t?h.jsx(ll,{}):h.jsx(al,{})}),h.jsx(yo,{path:"*",element:t?h.jsx(ll,{}):h.jsx(al,{})})]})})}const n1=new B0({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}});ul.createRoot(document.getElementById("root")).render(h.jsx(O.StrictMode,{children:h.jsx(K0,{client:n1,children:h.jsxs(C0,{children:[h.jsx(r1,{}),h.jsx(Ow,{position:"top-right"})]})})})); + `).eq("server_id",t.id);if(E)throw console.error("Supabase error loading members:",E),E;console.log("Members loaded successfully:",P);const M=(P||[]).map(q=>({id:q.user_id,server_id:t.id,user_id:q.user_id,role:"member",joined_at:new Date().toISOString(),user:Array.isArray(q.user)?q.user[0]:q.user}));m(M)}catch(P){console.error("Error loading members:",P),H.error("Failed to load members")}finally{_(!1)}}},[t]);C.useEffect(()=>{t&&e&&(b({name:t.name,description:t.description||"",privacyLevel:t.privacy_level}),p(),w())},[t,e,p,w]);const k=async()=>{if(t){l(!0);try{const{error:P}=await Q.from("servers").update({name:x.name,description:x.description,privacy_level:x.privacyLevel}).eq("id",t.id);if(P)throw P;H.success("Server updated successfully!"),n()}catch(P){H.error(`Failed to update server: ${P instanceof Error?P.message:"Unknown error"}`)}finally{l(!1)}}},S=async()=>{if(!(!t||!v.trim()))try{const{error:P}=await Q.from("channels").insert({name:v.trim(),server_id:t.id,type:"text"});if(P)throw P;H.success("Channel created successfully!"),g(""),p(),s()}catch(P){H.error(`Failed to create channel: ${P instanceof Error?P.message:"Unknown error"}`)}},j=async P=>{if(confirm("Are you sure you want to delete this channel?"))try{const{error:E}=await Q.from("channels").delete().eq("id",P);if(E)throw E;H.success("Channel deleted successfully!"),p(),s()}catch(E){H.error(`Failed to delete channel: ${E instanceof Error?E.message:"Unknown error"}`)}},T=async(P,E)=>{if(!(!t||!confirm(`Are you sure you want to remove ${E} from this server?`)))try{const{error:M}=await Q.from("server_members").delete().eq("server_id",t.id).eq("user_id",P);if(M)throw M;H.success("Member removed successfully!"),w()}catch(M){H.error(`Failed to remove member: ${M instanceof Error?M.message:"Unknown error"}`)}};return!e||!t?null:h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-discord-sidebar rounded-lg w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[h.jsx("div",{className:"p-6 border-b border-gray-700",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-bold text-discord-text",children:"Server Settings"}),h.jsx("button",{onClick:r,className:"p-2 hover:bg-discord-channel rounded-md transition-colors",children:h.jsx("svg",{className:"w-5 h-5 text-discord-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),h.jsxs("div",{className:"flex h-[calc(90vh-120px)]",children:[h.jsx("div",{className:"w-48 bg-discord-channel p-4",children:h.jsx("nav",{className:"space-y-1",children:[{id:"overview",label:"Overview"},{id:"channels",label:"Channels"},{id:"members",label:"Members"},{id:"roles",label:"Roles"},{id:"safety",label:"Safety"}].map(P=>h.jsx("button",{onClick:()=>o(P.id),className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${i===P.id?"bg-discord-primary text-white":"text-discord-muted hover:text-discord-text hover:bg-discord-channel/50"}`,children:P.label},P.id))})}),h.jsxs("div",{className:"flex-1 p-6 overflow-y-auto",children:[i==="overview"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Server Overview"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Server Name"}),h.jsx("input",{type:"text",value:x.name,onChange:P=>b({...x,name:P.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Description"}),h.jsx("textarea",{value:x.description,onChange:P=>b({...x,description:P.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",rows:3})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-discord-text mb-2",children:"Privacy Level"}),h.jsxs("select",{value:x.privacyLevel,onChange:P=>b({...x,privacyLevel:P.target.value}),className:"w-full px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent",children:[h.jsx("option",{value:"public",children:"Public"}),h.jsx("option",{value:"private",children:"Private"}),h.jsx("option",{value:"invite_only",children:"Invite Only"})]})]}),h.jsx("button",{onClick:k,disabled:a,className:"px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors duration-200",children:a?"Saving...":"Save Changes"})]})]}),i==="channels"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Channels"}),h.jsxs("div",{className:"space-y-4",children:[h.jsx("h4",{className:"text-md font-medium text-discord-text",children:"Create Channel"}),h.jsxs("div",{className:"flex space-x-3",children:[h.jsx("input",{type:"text",value:v,onChange:P=>g(P.target.value),placeholder:"Enter channel name",className:"flex-1 px-3 py-2 bg-discord-channel border border-gray-600 rounded-md text-discord-text placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-discord-primary focus:border-transparent"}),h.jsx("button",{onClick:S,disabled:!v.trim(),className:"px-4 py-2 bg-discord-primary hover:bg-discord-primary/90 disabled:opacity-50 text-white font-medium rounded-md transition-colors duration-200",children:"Create"})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("h4",{className:"text-md font-medium text-discord-text",children:"Existing Channels"}),u.map(P=>h.jsxs("div",{className:"flex items-center justify-between p-3 bg-discord-channel rounded-md",children:[h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("span",{className:"text-discord-muted",children:"#"}),h.jsx("span",{className:"text-discord-text",children:P.name})]}),h.jsx("button",{onClick:()=>j(P.id),className:"px-3 py-1 bg-discord-danger hover:bg-discord-danger/90 text-white text-sm rounded transition-colors",children:"Delete"})]},P.id))]})]}),i==="members"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Members"}),f?h.jsxs("div",{className:"text-center py-8",children:[h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-discord-primary mx-auto mb-2"}),h.jsx("p",{className:"text-discord-muted",children:"Loading members..."})]}):h.jsx("div",{className:"space-y-2",children:d.map(P=>{var E,M,q,$,fe;return h.jsxs("div",{className:"flex items-center justify-between p-3 bg-discord-channel rounded-md",children:[h.jsxs("div",{className:"flex items-center space-x-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-discord-primary flex items-center justify-center text-white text-sm font-medium",children:((M=(E=P.user)==null?void 0:E.username)==null?void 0:M.charAt(0).toUpperCase())||"U"}),h.jsxs("div",{children:[h.jsx("p",{className:"text-discord-text font-medium",children:((q=P.user)==null?void 0:q.display_name)||(($=P.user)==null?void 0:$.username)||"Unknown User"}),h.jsx("p",{className:"text-discord-muted text-sm",children:(fe=P.user)==null?void 0:fe.username})]})]}),h.jsx("button",{onClick:()=>{var ge;return T(P.user_id,((ge=P.user)==null?void 0:ge.username)||"User")},className:"px-3 py-1 bg-discord-danger hover:bg-discord-danger/90 text-white text-sm rounded transition-colors",children:"Remove"})]},P.user_id)})})]}),i==="roles"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Roles"}),h.jsx("p",{className:"text-discord-muted",children:"Role management coming soon..."})]}),i==="safety"&&h.jsxs("div",{className:"space-y-6",children:[h.jsx("h3",{className:"text-lg font-semibold text-discord-text",children:"Safety"}),h.jsx("p",{className:"text-discord-muted",children:"Safety settings coming soon..."})]})]})]})]})})}function ll(){const{user:t}=_a(),{servers:e,isLoading:r}=V_(),[n,s]=C.useState(null),[i,o]=C.useState(null),[a,l]=C.useState(!1),u=m=>{s(m),m.channels&&m.channels.length>0?o(m.channels[0]):o(null)},c=m=>{o(m)},d=()=>{l(!0)};return r?h.jsx("div",{className:"min-h-screen bg-discord-bg flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-b-2 border-discord-primary mx-auto mb-4"}),h.jsx("p",{className:"text-discord-text text-lg",children:"Loading servers..."})]})}):h.jsxs("div",{className:"flex h-screen bg-discord-bg",children:[h.jsx(G_,{servers:e,currentServer:n,currentChannel:i,onServerSelect:u,onChannelSelect:c,user:t}),h.jsx("div",{className:"flex-1 flex flex-col",children:n&&i?h.jsx(Y_,{channel:i,server:n,onServerUpdate:()=>{window.location.reload()},onChannelUpdate:()=>{window.location.reload()},onOpenServerSettings:d}):h.jsx("div",{className:"flex-1 flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("h2",{className:"text-2xl font-bold text-discord-text mb-2",children:"Welcome to CrestChat!"}),h.jsx("p",{className:"text-discord-muted",children:n?"Select a channel to start chatting":"Select a server to get started"})]})})}),h.jsx("div",{className:"w-64 bg-discord-sidebar border-l border-gray-700 p-4",children:h.jsx(Z_,{server:n||void 0})}),h.jsx(e1,{server:n,isOpen:a,onClose:()=>l(!1),onServerUpdate:()=>{window.location.reload()},onChannelUpdate:()=>{window.location.reload()}})]})}function t1(){return h.jsx("div",{className:"min-h-screen bg-discord-bg flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-b-2 border-discord-primary mx-auto mb-4"}),h.jsx("p",{className:"text-discord-text text-lg",children:"Loading CrestChat..."})]})})}function r1(){const{user:t,loading:e}=_a();return e?h.jsx(t1,{}):h.jsx("div",{className:"min-h-screen bg-discord-bg",children:h.jsxs(S0,{children:[h.jsx(yo,{path:"/",element:t?h.jsx(ll,{}):h.jsx(al,{})}),h.jsx(yo,{path:"/auth",element:t?h.jsx(ll,{}):h.jsx(al,{})}),h.jsx(yo,{path:"*",element:t?h.jsx(ll,{}):h.jsx(al,{})})]})})}const n1=new B0({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}});ul.createRoot(document.getElementById("root")).render(h.jsx(O.StrictMode,{children:h.jsx(K0,{client:n1,children:h.jsxs(C0,{children:[h.jsx(r1,{}),h.jsx(Ow,{position:"top-right"})]})})})); diff --git a/dist/index.html b/dist/index.html index 30540f0..93ac4b0 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ CrestChat - Discord Clone - + diff --git a/src/components/ChatArea.tsx b/src/components/ChatArea.tsx index de54984..2c0e0b1 100644 --- a/src/components/ChatArea.tsx +++ b/src/components/ChatArea.tsx @@ -1,11 +1,11 @@ import { useState, useRef, useEffect } from 'react' import { useMessages } from '../hooks/useMessages' -import { Channel } from '../integrations/supabase/types' +import { Channel, Server, Message } from '../integrations/supabase/types' import { toast } from 'sonner' interface ChatAreaProps { channel: Channel - server?: any + server?: Server onServerUpdate: () => void onChannelUpdate: () => void onOpenServerSettings?: () => void @@ -90,7 +90,7 @@ export default function ChatArea({ channel, server, onOpenServerSettings }: Chat } } - const startEditing = (message: any) => { + const startEditing = (message: Message) => { setEditingMessageId(message.id) setEditContent(message.content) } diff --git a/src/components/OnlineUsers.tsx b/src/components/OnlineUsers.tsx index 26c5459..e3a285a 100644 --- a/src/components/OnlineUsers.tsx +++ b/src/components/OnlineUsers.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react' +import { useState, useEffect, useCallback } from 'react' import { supabase } from '../integrations/supabase/client' import { Server } from '../integrations/supabase/types' @@ -18,13 +18,7 @@ export default function OnlineUsers({ server }: OnlineUsersProps) { const [onlineUsers, setOnlineUsers] = useState([]) const [loading, setLoading] = useState(false) - useEffect(() => { - if (server) { - loadOnlineUsers() - } - }, [server]) - - const loadOnlineUsers = async () => { + const loadOnlineUsers = useCallback(async () => { if (!server) return setLoading(true) try { @@ -46,8 +40,9 @@ export default function OnlineUsers({ server }: OnlineUsersProps) { const users = data ?.map(item => item.user) - .filter((user: any) => user && user.status !== 'offline') - .sort((a: any, b: any) => { + .flat() + .filter((user) => user && user.status !== 'offline') + .sort((a, b) => { // Sort by status priority: online > idle > dnd > invisible const statusOrder = { online: 0, idle: 1, dnd: 2, invisible: 3 } return statusOrder[a.status as keyof typeof statusOrder] - statusOrder[b.status as keyof typeof statusOrder] @@ -59,7 +54,13 @@ export default function OnlineUsers({ server }: OnlineUsersProps) { } finally { setLoading(false) } - } + }, [server]) + + useEffect(() => { + if (server) { + loadOnlineUsers() + } + }, [server, loadOnlineUsers]) const getStatusColor = (status: string) => { switch (status) { diff --git a/src/components/ServerSettingsModal.tsx b/src/components/ServerSettingsModal.tsx index d1f3cf1..d17bc2d 100644 --- a/src/components/ServerSettingsModal.tsx +++ b/src/components/ServerSettingsModal.tsx @@ -1,6 +1,6 @@ -import { useState, useEffect } from 'react' +import { useState, useEffect, useCallback } from 'react' import { supabase } from '../integrations/supabase/client' -import { Server, Channel } from '../integrations/supabase/types' +import { Server, Channel, ServerMember } from '../integrations/supabase/types' import { toast } from 'sonner' interface ServerSettingsModalProps { @@ -21,7 +21,7 @@ export default function ServerSettingsModal({ const [activeTab, setActiveTab] = useState('overview') const [loading, setLoading] = useState(false) const [channels, setChannels] = useState([]) - const [members, setMembers] = useState([]) + const [members, setMembers] = useState([]) const [loadingMembers, setLoadingMembers] = useState(false) const [serverForm, setServerForm] = useState({ name: '', @@ -30,19 +30,7 @@ export default function ServerSettingsModal({ }) const [newChannelName, setNewChannelName] = useState('') - useEffect(() => { - if (server && isOpen) { - setServerForm({ - name: server.name, - description: server.description || '', - privacyLevel: server.privacy_level - }) - loadChannels() - loadMembers() - } - }, [server, isOpen]) - - const loadChannels = async () => { + const loadChannels = useCallback(async () => { if (!server) return try { const { data, error } = await supabase @@ -57,9 +45,9 @@ export default function ServerSettingsModal({ console.error('Error loading channels:', error) toast.error('Failed to load channels') } - } + }, [server]) - const loadMembers = async () => { + const loadMembers = useCallback(async () => { if (!server) return setLoadingMembers(true) try { @@ -85,14 +73,34 @@ export default function ServerSettingsModal({ } console.log('Members loaded successfully:', data) - setMembers(data || []) + const formattedMembers: ServerMember[] = (data || []).map((item: any) => ({ + id: item.user_id, + server_id: server.id, + user_id: item.user_id, + role: 'member', + joined_at: new Date().toISOString(), + user: Array.isArray(item.user) ? item.user[0] : item.user + })) + setMembers(formattedMembers) } catch (error) { console.error('Error loading members:', error) toast.error('Failed to load members') } finally { setLoadingMembers(false) } - } + }, [server]) + + useEffect(() => { + if (server && isOpen) { + setServerForm({ + name: server.name, + description: server.description || '', + privacyLevel: server.privacy_level + }) + loadChannels() + loadMembers() + } + }, [server, isOpen, loadChannels, loadMembers]) const handleSaveServer = async () => { if (!server) return @@ -110,8 +118,8 @@ export default function ServerSettingsModal({ if (error) throw error toast.success('Server updated successfully!') onServerUpdate() - } catch (error: any) { - toast.error(`Failed to update server: ${error.message}`) + } catch (error) { + toast.error(`Failed to update server: ${error instanceof Error ? error.message : 'Unknown error'}`) } finally { setLoading(false) } @@ -133,8 +141,8 @@ export default function ServerSettingsModal({ setNewChannelName('') loadChannels() onChannelUpdate() - } catch (error: any) { - toast.error(`Failed to create channel: ${error.message}`) + } catch (error) { + toast.error(`Failed to create channel: ${error instanceof Error ? error.message : 'Unknown error'}`) } } @@ -150,8 +158,8 @@ export default function ServerSettingsModal({ toast.success('Channel deleted successfully!') loadChannels() onChannelUpdate() - } catch (error: any) { - toast.error(`Failed to delete channel: ${error.message}`) + } catch (error) { + toast.error(`Failed to delete channel: ${error instanceof Error ? error.message : 'Unknown error'}`) } } @@ -167,8 +175,8 @@ export default function ServerSettingsModal({ if (error) throw error toast.success('Member removed successfully!') loadMembers() - } catch (error: any) { - toast.error(`Failed to remove member: ${error.message}`) + } catch (error) { + toast.error(`Failed to remove member: ${error instanceof Error ? error.message : 'Unknown error'}`) } } diff --git a/src/components/ServerSidebar.tsx b/src/components/ServerSidebar.tsx index 769f4e8..b390e00 100644 --- a/src/components/ServerSidebar.tsx +++ b/src/components/ServerSidebar.tsx @@ -3,13 +3,23 @@ import { Server, Channel } from '../integrations/supabase/types' import { supabase } from '../integrations/supabase/client' import { toast } from 'sonner' +interface AuthUser { + id: string + email: string + username: string + display_name: string + avatar_url?: string + status: string + created_at: string +} + interface ServerSidebarProps { servers: Server[] currentServer: Server | null currentChannel: Channel | null onServerSelect: (server: Server) => void onChannelSelect: (channel: Channel) => void - user: any + user: AuthUser } export default function ServerSidebar({ @@ -100,9 +110,9 @@ export default function ServerSidebar({ // Refresh the page to show new server window.location.reload() - } catch (error: any) { + } catch (error) { console.error('Full error:', error) - toast.error(`Failed to create server: ${error.message}`) + toast.error(`Failed to create server: ${error instanceof Error ? error.message : 'Unknown error'}`) } finally { setLoading(false) } @@ -132,8 +142,8 @@ export default function ServerSidebar({ // Refresh the page to show new channel window.location.reload() - } catch (error: any) { - toast.error(`Failed to create channel: ${error.message}`) + } catch (error) { + toast.error(`Failed to create channel: ${error instanceof Error ? error.message : 'Unknown error'}`) } finally { setLoading(false) } @@ -159,8 +169,8 @@ export default function ServerSidebar({ // Refresh the page to show new server window.location.reload() - } catch (error: any) { - toast.error(`Failed to join server: ${error.message}`) + } catch (error) { + toast.error(`Failed to join server: ${error instanceof Error ? error.message : 'Unknown error'}`) } finally { setLoading(false) } @@ -181,7 +191,7 @@ export default function ServerSidebar({
{/* Home Button */}