heyio 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))r(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function s(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(n){if(n.ep)return;n.ep=!0;const i=s(n);fetch(n.href,i)}})();/**
2
+ * @vue/shared v3.5.34
3
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
+ * @license MIT
5
+ **/function Ti(t){const e=Object.create(null);for(const s of t.split(","))e[s]=1;return s=>s in e}const ve={},Os=[],Rt=()=>{},Ta=()=>!1,un=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),hn=t=>t.startsWith("onUpdate:"),He=Object.assign,Ai=(t,e)=>{const s=t.indexOf(e);s>-1&&t.splice(s,1)},Tc=Object.prototype.hasOwnProperty,fe=(t,e)=>Tc.call(t,e),ee=Array.isArray,Cs=t=>kr(t)==="[object Map]",dn=t=>kr(t)==="[object Set]",Qi=t=>kr(t)==="[object Date]",ae=t=>typeof t=="function",Ee=t=>typeof t=="string",ct=t=>typeof t=="symbol",ge=t=>t!==null&&typeof t=="object",Aa=t=>(ge(t)||ae(t))&&ae(t.then)&&ae(t.catch),Ra=Object.prototype.toString,kr=t=>Ra.call(t),Ac=t=>kr(t).slice(8,-1),Oa=t=>kr(t)==="[object Object]",fn=t=>Ee(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Xs=Ti(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),pn=t=>{const e=Object.create(null);return s=>e[s]||(e[s]=t(s))},Rc=/-\w/g,ft=pn(t=>t.replace(Rc,e=>e.slice(1).toUpperCase())),Oc=/\B([A-Z])/g,ps=pn(t=>t.replace(Oc,"-$1").toLowerCase()),Ca=pn(t=>t.charAt(0).toUpperCase()+t.slice(1)),Pn=pn(t=>t?`on${Ca(t)}`:""),At=(t,e)=>!Object.is(t,e),qr=(t,...e)=>{for(let s=0;s<t.length;s++)t[s](...e)},Pa=(t,e,s,r=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:r,value:s})},Ri=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Zi;const gn=()=>Zi||(Zi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Oi(t){if(ee(t)){const e={};for(let s=0;s<t.length;s++){const r=t[s],n=Ee(r)?jc(r):Oi(r);if(n)for(const i in n)e[i]=n[i]}return e}else if(Ee(t)||ge(t))return t}const Cc=/;(?![^(]*\))/g,Pc=/:([^]+)/,Ic=/\/\*[^]*?\*\//g;function jc(t){const e={};return t.replace(Ic,"").split(Cc).forEach(s=>{if(s){const r=s.split(Pc);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function Ne(t){let e="";if(Ee(t))e=t;else if(ee(t))for(let s=0;s<t.length;s++){const r=Ne(t[s]);r&&(e+=r+" ")}else if(ge(t))for(const s in t)t[s]&&(e+=s+" ");return e.trim()}const $c="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",Nc=Ti($c);function Ia(t){return!!t||t===""}function Lc(t,e){if(t.length!==e.length)return!1;let s=!0;for(let r=0;s&&r<t.length;r++)s=Er(t[r],e[r]);return s}function Er(t,e){if(t===e)return!0;let s=Qi(t),r=Qi(e);if(s||r)return s&&r?t.getTime()===e.getTime():!1;if(s=ct(t),r=ct(e),s||r)return t===e;if(s=ee(t),r=ee(e),s||r)return s&&r?Lc(t,e):!1;if(s=ge(t),r=ge(e),s||r){if(!s||!r)return!1;const n=Object.keys(t).length,i=Object.keys(e).length;if(n!==i)return!1;for(const o in t){const a=t.hasOwnProperty(o),l=e.hasOwnProperty(o);if(a&&!l||!a&&l||!Er(t[o],e[o]))return!1}}return String(t)===String(e)}function ja(t,e){return t.findIndex(s=>Er(s,e))}const $a=t=>!!(t&&t.__v_isRef===!0),F=t=>Ee(t)?t:t==null?"":ee(t)||ge(t)&&(t.toString===Ra||!ae(t.toString))?$a(t)?F(t.value):JSON.stringify(t,Na,2):String(t),Na=(t,e)=>$a(e)?Na(t,e.value):Cs(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((s,[r,n],i)=>(s[In(r,i)+" =>"]=n,s),{})}:dn(e)?{[`Set(${e.size})`]:[...e.values()].map(s=>In(s))}:ct(e)?In(e):ge(e)&&!ee(e)&&!Oa(e)?String(e):e,In=(t,e="")=>{var s;return ct(t)?`Symbol(${(s=t.description)!=null?s:e})`:t};/**
6
+ * @vue/reactivity v3.5.34
7
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
8
+ * @license MIT
9
+ **/let Pe;class La{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&Pe&&(Pe.active?(this.parent=Pe,this.index=(Pe.scopes||(Pe.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,s;if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].pause();for(e=0,s=this.effects.length;e<s;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,s;if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].resume();for(e=0,s=this.effects.length;e<s;e++)this.effects[e].resume()}}run(e){if(this._active){const s=Pe;try{return Pe=this,e()}finally{Pe=s}}}on(){++this._on===1&&(this.prevScope=Pe,Pe=this)}off(){if(this._on>0&&--this._on===0){if(Pe===this)Pe=this.prevScope;else{let e=Pe;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let s,r;for(s=0,r=this.effects.length;s<r;s++)this.effects[s].stop();for(this.effects.length=0,s=0,r=this.cleanups.length;s<r;s++)this.cleanups[s]();if(this.cleanups.length=0,this.scopes){for(s=0,r=this.scopes.length;s<r;s++)this.scopes[s].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const n=this.parent.scopes.pop();n&&n!==this&&(this.parent.scopes[this.index]=n,n.index=this.index)}this.parent=void 0}}}function Ua(t){return new La(t)}function Da(){return Pe}function Uc(t,e=!1){Pe&&Pe.cleanups.push(t)}let we;const jn=new WeakSet;class Ba{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Pe&&(Pe.active?Pe.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,jn.has(this)&&(jn.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Ha(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,eo(this),Fa(this);const e=we,s=pt;we=this,pt=!0;try{return this.fn()}finally{qa(this),we=e,pt=s,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Ii(e);this.deps=this.depsTail=void 0,eo(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?jn.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Xn(this)&&this.run()}get dirty(){return Xn(this)}}let Ma=0,Qs,Zs;function Ha(t,e=!1){if(t.flags|=8,e){t.next=Zs,Zs=t;return}t.next=Qs,Qs=t}function Ci(){Ma++}function Pi(){if(--Ma>0)return;if(Zs){let e=Zs;for(Zs=void 0;e;){const s=e.next;e.next=void 0,e.flags&=-9,e=s}}let t;for(;Qs;){let e=Qs;for(Qs=void 0;e;){const s=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(r){t||(t=r)}e=s}}if(t)throw t}function Fa(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function qa(t){let e,s=t.depsTail,r=s;for(;r;){const n=r.prevDep;r.version===-1?(r===s&&(s=n),Ii(r),Dc(r)):e=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=n}t.deps=e,t.depsTail=s}function Xn(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Va(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Va(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===cr)||(t.globalVersion=cr,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Xn(t))))return;t.flags|=2;const e=t.dep,s=we,r=pt;we=t,pt=!0;try{Fa(t);const n=t.fn(t._value);(e.version===0||At(n,t._value))&&(t.flags|=128,t._value=n,e.version++)}catch(n){throw e.version++,n}finally{we=s,pt=r,qa(t),t.flags&=-3}}function Ii(t,e=!1){const{dep:s,prevSub:r,nextSub:n}=t;if(r&&(r.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=r,t.nextSub=void 0),s.subs===t&&(s.subs=r,!r&&s.computed)){s.computed.flags&=-5;for(let i=s.computed.deps;i;i=i.nextDep)Ii(i,!0)}!e&&!--s.sc&&s.map&&s.map.delete(s.key)}function Dc(t){const{prevDep:e,nextDep:s}=t;e&&(e.nextDep=s,t.prevDep=void 0),s&&(s.prevDep=e,t.nextDep=void 0)}let pt=!0;const Ka=[];function Ht(){Ka.push(pt),pt=!1}function Ft(){const t=Ka.pop();pt=t===void 0?!0:t}function eo(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const s=we;we=void 0;try{e()}finally{we=s}}}let cr=0;class Bc{constructor(e,s){this.sub=e,this.dep=s,this.version=s.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class ji{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!we||!pt||we===this.computed)return;let s=this.activeLink;if(s===void 0||s.sub!==we)s=this.activeLink=new Bc(we,this),we.deps?(s.prevDep=we.depsTail,we.depsTail.nextDep=s,we.depsTail=s):we.deps=we.depsTail=s,Wa(s);else if(s.version===-1&&(s.version=this.version,s.nextDep)){const r=s.nextDep;r.prevDep=s.prevDep,s.prevDep&&(s.prevDep.nextDep=r),s.prevDep=we.depsTail,s.nextDep=void 0,we.depsTail.nextDep=s,we.depsTail=s,we.deps===s&&(we.deps=r)}return s}trigger(e){this.version++,cr++,this.notify(e)}notify(e){Ci();try{for(let s=this.subs;s;s=s.prevSub)s.sub.notify()&&s.sub.dep.notify()}finally{Pi()}}}function Wa(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let r=e.deps;r;r=r.nextDep)Wa(r)}const s=t.dep.subs;s!==t&&(t.prevSub=s,s&&(s.nextSub=t)),t.dep.subs=t}}const Gr=new WeakMap,hs=Symbol(""),Qn=Symbol(""),ur=Symbol("");function Fe(t,e,s){if(pt&&we){let r=Gr.get(t);r||Gr.set(t,r=new Map);let n=r.get(s);n||(r.set(s,n=new ji),n.map=r,n.key=s),n.track()}}function Ut(t,e,s,r,n,i){const o=Gr.get(t);if(!o){cr++;return}const a=l=>{l&&l.trigger()};if(Ci(),e==="clear")o.forEach(a);else{const l=ee(t),c=l&&fn(s);if(l&&s==="length"){const u=Number(r);o.forEach((h,d)=>{(d==="length"||d===ur||!ct(d)&&d>=u)&&a(h)})}else switch((s!==void 0||o.has(void 0))&&a(o.get(s)),c&&a(o.get(ur)),e){case"add":l?c&&a(o.get("length")):(a(o.get(hs)),Cs(t)&&a(o.get(Qn)));break;case"delete":l||(a(o.get(hs)),Cs(t)&&a(o.get(Qn)));break;case"set":Cs(t)&&a(o.get(hs));break}}Pi()}function Mc(t,e){const s=Gr.get(t);return s&&s.get(e)}function gs(t){const e=ue(t);return e===t?e:(Fe(e,"iterate",ur),nt(t)?e:e.map(gt))}function yn(t){return Fe(t=ue(t),"iterate",ur),t}function Et(t,e){return qt(t)?Ns(Mt(t)?gt(e):e):gt(e)}const Hc={__proto__:null,[Symbol.iterator](){return $n(this,Symbol.iterator,t=>Et(this,t))},concat(...t){return gs(this).concat(...t.map(e=>ee(e)?gs(e):e))},entries(){return $n(this,"entries",t=>(t[1]=Et(this,t[1]),t))},every(t,e){return Ct(this,"every",t,e,void 0,arguments)},filter(t,e){return Ct(this,"filter",t,e,s=>s.map(r=>Et(this,r)),arguments)},find(t,e){return Ct(this,"find",t,e,s=>Et(this,s),arguments)},findIndex(t,e){return Ct(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Ct(this,"findLast",t,e,s=>Et(this,s),arguments)},findLastIndex(t,e){return Ct(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Ct(this,"forEach",t,e,void 0,arguments)},includes(...t){return Nn(this,"includes",t)},indexOf(...t){return Nn(this,"indexOf",t)},join(t){return gs(this).join(t)},lastIndexOf(...t){return Nn(this,"lastIndexOf",t)},map(t,e){return Ct(this,"map",t,e,void 0,arguments)},pop(){return Hs(this,"pop")},push(...t){return Hs(this,"push",t)},reduce(t,...e){return to(this,"reduce",t,e)},reduceRight(t,...e){return to(this,"reduceRight",t,e)},shift(){return Hs(this,"shift")},some(t,e){return Ct(this,"some",t,e,void 0,arguments)},splice(...t){return Hs(this,"splice",t)},toReversed(){return gs(this).toReversed()},toSorted(t){return gs(this).toSorted(t)},toSpliced(...t){return gs(this).toSpliced(...t)},unshift(...t){return Hs(this,"unshift",t)},values(){return $n(this,"values",t=>Et(this,t))}};function $n(t,e,s){const r=yn(t),n=r[e]();return r!==t&&!nt(t)&&(n._next=n.next,n.next=()=>{const i=n._next();return i.done||(i.value=s(i.value)),i}),n}const Fc=Array.prototype;function Ct(t,e,s,r,n,i){const o=yn(t),a=o!==t&&!nt(t),l=o[e];if(l!==Fc[e]){const h=l.apply(t,i);return a?gt(h):h}let c=s;o!==t&&(a?c=function(h,d){return s.call(this,Et(t,h),d,t)}:s.length>2&&(c=function(h,d){return s.call(this,h,d,t)}));const u=l.call(o,c,r);return a&&n?n(u):u}function to(t,e,s,r){const n=yn(t),i=n!==t&&!nt(t);let o=s,a=!1;n!==t&&(i?(a=r.length===0,o=function(c,u,h){return a&&(a=!1,c=Et(t,c)),s.call(this,c,Et(t,u),h,t)}):s.length>3&&(o=function(c,u,h){return s.call(this,c,u,h,t)}));const l=n[e](o,...r);return a?Et(t,l):l}function Nn(t,e,s){const r=ue(t);Fe(r,"iterate",ur);const n=r[e](...s);return(n===-1||n===!1)&&mn(s[0])?(s[0]=ue(s[0]),r[e](...s)):n}function Hs(t,e,s=[]){Ht(),Ci();const r=ue(t)[e].apply(t,s);return Pi(),Ft(),r}const qc=Ti("__proto__,__v_isRef,__isVue"),Ga=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(ct));function Vc(t){ct(t)||(t=String(t));const e=ue(this);return Fe(e,"has",t),e.hasOwnProperty(t)}class Ja{constructor(e=!1,s=!1){this._isReadonly=e,this._isShallow=s}get(e,s,r){if(s==="__v_skip")return e.__v_skip;const n=this._isReadonly,i=this._isShallow;if(s==="__v_isReactive")return!n;if(s==="__v_isReadonly")return n;if(s==="__v_isShallow")return i;if(s==="__v_raw")return r===(n?i?eu:Qa:i?Xa:Ya).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(r)?e:void 0;const o=ee(e);if(!n){let l;if(o&&(l=Hc[s]))return l;if(s==="hasOwnProperty")return Vc}const a=Reflect.get(e,s,xe(e)?e:r);if((ct(s)?Ga.has(s):qc(s))||(n||Fe(e,"get",s),i))return a;if(xe(a)){const l=o&&fn(s)?a:a.value;return n&&ge(l)?ei(l):l}return ge(a)?n?ei(a):Bt(a):a}}class za extends Ja{constructor(e=!1){super(!1,e)}set(e,s,r,n){let i=e[s];const o=ee(e)&&fn(s);if(!this._isShallow){const c=qt(i);if(!nt(r)&&!qt(r)&&(i=ue(i),r=ue(r)),!o&&xe(i)&&!xe(r))return c||(i.value=r),!0}const a=o?Number(s)<e.length:fe(e,s),l=Reflect.set(e,s,r,xe(e)?e:n);return e===ue(n)&&(a?At(r,i)&&Ut(e,"set",s,r):Ut(e,"add",s,r)),l}deleteProperty(e,s){const r=fe(e,s);e[s];const n=Reflect.deleteProperty(e,s);return n&&r&&Ut(e,"delete",s,void 0),n}has(e,s){const r=Reflect.has(e,s);return(!ct(s)||!Ga.has(s))&&Fe(e,"has",s),r}ownKeys(e){return Fe(e,"iterate",ee(e)?"length":hs),Reflect.ownKeys(e)}}class Kc extends Ja{constructor(e=!1){super(!0,e)}set(e,s){return!0}deleteProperty(e,s){return!0}}const Wc=new za,Gc=new Kc,Jc=new za(!0);const Zn=t=>t,Cr=t=>Reflect.getPrototypeOf(t);function zc(t,e,s){return function(...r){const n=this.__v_raw,i=ue(n),o=Cs(i),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=n[t](...r),u=s?Zn:e?Ns:gt;return!e&&Fe(i,"iterate",l?Qn:hs),He(Object.create(c),{next(){const{value:h,done:d}=c.next();return d?{value:h,done:d}:{value:a?[u(h[0]),u(h[1])]:u(h),done:d}}})}}function Pr(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Yc(t,e){const s={get(n){const i=this.__v_raw,o=ue(i),a=ue(n);t||(At(n,a)&&Fe(o,"get",n),Fe(o,"get",a));const{has:l}=Cr(o),c=e?Zn:t?Ns:gt;if(l.call(o,n))return c(i.get(n));if(l.call(o,a))return c(i.get(a));i!==o&&i.get(n)},get size(){const n=this.__v_raw;return!t&&Fe(ue(n),"iterate",hs),n.size},has(n){const i=this.__v_raw,o=ue(i),a=ue(n);return t||(At(n,a)&&Fe(o,"has",n),Fe(o,"has",a)),n===a?i.has(n):i.has(n)||i.has(a)},forEach(n,i){const o=this,a=o.__v_raw,l=ue(a),c=e?Zn:t?Ns:gt;return!t&&Fe(l,"iterate",hs),a.forEach((u,h)=>n.call(i,c(u),c(h),o))}};return He(s,t?{add:Pr("add"),set:Pr("set"),delete:Pr("delete"),clear:Pr("clear")}:{add(n){const i=ue(this),o=Cr(i),a=ue(n),l=!e&&!nt(n)&&!qt(n)?a:n;return o.has.call(i,l)||At(n,l)&&o.has.call(i,n)||At(a,l)&&o.has.call(i,a)||(i.add(l),Ut(i,"add",l,l)),this},set(n,i){!e&&!nt(i)&&!qt(i)&&(i=ue(i));const o=ue(this),{has:a,get:l}=Cr(o);let c=a.call(o,n);c||(n=ue(n),c=a.call(o,n));const u=l.call(o,n);return o.set(n,i),c?At(i,u)&&Ut(o,"set",n,i):Ut(o,"add",n,i),this},delete(n){const i=ue(this),{has:o,get:a}=Cr(i);let l=o.call(i,n);l||(n=ue(n),l=o.call(i,n)),a&&a.call(i,n);const c=i.delete(n);return l&&Ut(i,"delete",n,void 0),c},clear(){const n=ue(this),i=n.size!==0,o=n.clear();return i&&Ut(n,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(n=>{s[n]=zc(n,t,e)}),s}function $i(t,e){const s=Yc(t,e);return(r,n,i)=>n==="__v_isReactive"?!t:n==="__v_isReadonly"?t:n==="__v_raw"?r:Reflect.get(fe(s,n)&&n in r?s:r,n,i)}const Xc={get:$i(!1,!1)},Qc={get:$i(!1,!0)},Zc={get:$i(!0,!1)};const Ya=new WeakMap,Xa=new WeakMap,Qa=new WeakMap,eu=new WeakMap;function tu(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function su(t){return t.__v_skip||!Object.isExtensible(t)?0:tu(Ac(t))}function Bt(t){return qt(t)?t:Ni(t,!1,Wc,Xc,Ya)}function Za(t){return Ni(t,!1,Jc,Qc,Xa)}function ei(t){return Ni(t,!0,Gc,Zc,Qa)}function Ni(t,e,s,r,n){if(!ge(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const i=su(t);if(i===0)return t;const o=n.get(t);if(o)return o;const a=new Proxy(t,i===2?r:s);return n.set(t,a),a}function Mt(t){return qt(t)?Mt(t.__v_raw):!!(t&&t.__v_isReactive)}function qt(t){return!!(t&&t.__v_isReadonly)}function nt(t){return!!(t&&t.__v_isShallow)}function mn(t){return t?!!t.__v_raw:!1}function ue(t){const e=t&&t.__v_raw;return e?ue(e):t}function Li(t){return!fe(t,"__v_skip")&&Object.isExtensible(t)&&Pa(t,"__v_skip",!0),t}const gt=t=>ge(t)?Bt(t):t,Ns=t=>ge(t)?ei(t):t;function xe(t){return t?t.__v_isRef===!0:!1}function ie(t){return el(t,!1)}function ru(t){return el(t,!0)}function el(t,e){return xe(t)?t:new nu(t,e)}class nu{constructor(e,s){this.dep=new ji,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=s?e:ue(e),this._value=s?e:gt(e),this.__v_isShallow=s}get value(){return this.dep.track(),this._value}set value(e){const s=this._rawValue,r=this.__v_isShallow||nt(e)||qt(e);e=r?e:ue(e),At(e,s)&&(this._rawValue=e,this._value=r?e:gt(e),this.dep.trigger())}}function me(t){return xe(t)?t.value:t}const iu={get:(t,e,s)=>e==="__v_raw"?t:me(Reflect.get(t,e,s)),set:(t,e,s,r)=>{const n=t[e];return xe(n)&&!xe(s)?(n.value=s,!0):Reflect.set(t,e,s,r)}};function tl(t){return Mt(t)?t:new Proxy(t,iu)}function ou(t){const e=ee(t)?new Array(t.length):{};for(const s in t)e[s]=lu(t,s);return e}class au{constructor(e,s,r){this._object=e,this._defaultValue=r,this.__v_isRef=!0,this._value=void 0,this._key=ct(s)?s:String(s),this._raw=ue(e);let n=!0,i=e;if(!ee(e)||ct(this._key)||!fn(this._key))do n=!mn(i)||nt(i);while(n&&(i=i.__v_raw));this._shallow=n}get value(){let e=this._object[this._key];return this._shallow&&(e=me(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&xe(this._raw[this._key])){const s=this._object[this._key];if(xe(s)){s.value=e;return}}this._object[this._key]=e}get dep(){return Mc(this._raw,this._key)}}function lu(t,e,s){return new au(t,e,s)}class cu{constructor(e,s,r){this.fn=e,this.setter=s,this._value=void 0,this.dep=new ji(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=cr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!s,this.isSSR=r}notify(){if(this.flags|=16,!(this.flags&8)&&we!==this)return Ha(this,!0),!0}get value(){const e=this.dep.track();return Va(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function uu(t,e,s=!1){let r,n;return ae(t)?r=t:(r=t.get,n=t.set),new cu(r,n,s)}const Ir={},Jr=new WeakMap;let os;function hu(t,e=!1,s=os){if(s){let r=Jr.get(s);r||Jr.set(s,r=[]),r.push(t)}}function du(t,e,s=ve){const{immediate:r,deep:n,once:i,scheduler:o,augmentJob:a,call:l}=s,c=C=>n?C:nt(C)||n===!1||n===0?Dt(C,1):Dt(C);let u,h,d,f,y=!1,v=!1;if(xe(t)?(h=()=>t.value,y=nt(t)):Mt(t)?(h=()=>c(t),y=!0):ee(t)?(v=!0,y=t.some(C=>Mt(C)||nt(C)),h=()=>t.map(C=>{if(xe(C))return C.value;if(Mt(C))return c(C);if(ae(C))return l?l(C,2):C()})):ae(t)?e?h=l?()=>l(t,2):t:h=()=>{if(d){Ht();try{d()}finally{Ft()}}const C=os;os=u;try{return l?l(t,3,[f]):t(f)}finally{os=C}}:h=Rt,e&&n){const C=h,W=n===!0?1/0:n;h=()=>Dt(C(),W)}const T=Da(),A=()=>{u.stop(),T&&T.active&&Ai(T.effects,u)};if(i&&e){const C=e;e=(...W)=>{C(...W),A()}}let _=v?new Array(t.length).fill(Ir):Ir;const w=C=>{if(!(!(u.flags&1)||!u.dirty&&!C))if(e){const W=u.run();if(n||y||(v?W.some((re,Y)=>At(re,_[Y])):At(W,_))){d&&d();const re=os;os=u;try{const Y=[W,_===Ir?void 0:v&&_[0]===Ir?[]:_,f];_=W,l?l(e,3,Y):e(...Y)}finally{os=re}}}else u.run()};return a&&a(w),u=new Ba(h),u.scheduler=o?()=>o(w,!1):w,f=C=>hu(C,!1,u),d=u.onStop=()=>{const C=Jr.get(u);if(C){if(l)l(C,4);else for(const W of C)W();Jr.delete(u)}},e?r?w(!0):_=u.run():o?o(w.bind(null,!0),!0):u.run(),A.pause=u.pause.bind(u),A.resume=u.resume.bind(u),A.stop=A,A}function Dt(t,e=1/0,s){if(e<=0||!ge(t)||t.__v_skip||(s=s||new Map,(s.get(t)||0)>=e))return t;if(s.set(t,e),e--,xe(t))Dt(t.value,e,s);else if(ee(t))for(let r=0;r<t.length;r++)Dt(t[r],e,s);else if(dn(t)||Cs(t))t.forEach(r=>{Dt(r,e,s)});else if(Oa(t)){for(const r in t)Dt(t[r],e,s);for(const r of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,r)&&Dt(t[r],e,s)}return t}/**
10
+ * @vue/runtime-core v3.5.34
11
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
12
+ * @license MIT
13
+ **/function xr(t,e,s,r){try{return r?t(...r):t()}catch(n){vn(n,e,s)}}function Ot(t,e,s,r){if(ae(t)){const n=xr(t,e,s,r);return n&&Aa(n)&&n.catch(i=>{vn(i,e,s)}),n}if(ee(t)){const n=[];for(let i=0;i<t.length;i++)n.push(Ot(t[i],e,s,r));return n}}function vn(t,e,s,r=!0){const n=e?e.vnode:null,{errorHandler:i,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||ve;if(e){let a=e.parent;const l=e.proxy,c=`https://vuejs.org/error-reference/#runtime-${s}`;for(;a;){const u=a.ec;if(u){for(let h=0;h<u.length;h++)if(u[h](t,l,c)===!1)return}a=a.parent}if(i){Ht(),xr(i,null,10,[t,l,c]),Ft();return}}fu(t,s,n,r,o)}function fu(t,e,s,r=!0,n=!1){if(n)throw t;console.error(t)}const Ke=[];let St=-1;const Ps=[];let zt=null,Ss=0;const sl=Promise.resolve();let zr=null;function Tr(t){const e=zr||sl;return t?e.then(this?t.bind(this):t):e}function pu(t){let e=St+1,s=Ke.length;for(;e<s;){const r=e+s>>>1,n=Ke[r],i=hr(n);i<t||i===t&&n.flags&2?e=r+1:s=r}return e}function Ui(t){if(!(t.flags&1)){const e=hr(t),s=Ke[Ke.length-1];!s||!(t.flags&2)&&e>=hr(s)?Ke.push(t):Ke.splice(pu(e),0,t),t.flags|=1,rl()}}function rl(){zr||(zr=sl.then(il))}function gu(t){ee(t)?Ps.push(...t):zt&&t.id===-1?zt.splice(Ss+1,0,t):t.flags&1||(Ps.push(t),t.flags|=1),rl()}function so(t,e,s=St+1){for(;s<Ke.length;s++){const r=Ke[s];if(r&&r.flags&2){if(t&&r.id!==t.uid)continue;Ke.splice(s,1),s--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function nl(t){if(Ps.length){const e=[...new Set(Ps)].sort((s,r)=>hr(s)-hr(r));if(Ps.length=0,zt){zt.push(...e);return}for(zt=e,Ss=0;Ss<zt.length;Ss++){const s=zt[Ss];s.flags&4&&(s.flags&=-2),s.flags&8||s(),s.flags&=-2}zt=null,Ss=0}}const hr=t=>t.id==null?t.flags&2?-1:1/0:t.id;function il(t){try{for(St=0;St<Ke.length;St++){const e=Ke[St];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),xr(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;St<Ke.length;St++){const e=Ke[St];e&&(e.flags&=-2)}St=-1,Ke.length=0,nl(),zr=null,(Ke.length||Ps.length)&&il()}}let at=null,ol=null;function Yr(t){const e=at;return at=t,ol=t&&t.type.__scopeId||null,e}function Ks(t,e=at,s){if(!e||t._n)return t;const r=(...n)=>{r._d&&Zr(-1);const i=Yr(e);let o;try{o=t(...n)}finally{Yr(i),r._d&&Zr(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function ds(t,e){if(at===null)return t;const s=kn(at),r=t.dirs||(t.dirs=[]);for(let n=0;n<e.length;n++){let[i,o,a,l=ve]=e[n];i&&(ae(i)&&(i={mounted:i,updated:i}),i.deep&&Dt(o),r.push({dir:i,instance:s,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function ss(t,e,s,r){const n=t.dirs,i=e&&e.dirs;for(let o=0;o<n.length;o++){const a=n[o];i&&(a.oldValue=i[o].value);let l=a.dir[r];l&&(Ht(),Ot(l,s,8,[t.el,a,t,e]),Ft())}}function Vr(t,e){if(We){let s=We.provides;const r=We.parent&&We.parent.provides;r===s&&(s=We.provides=Object.create(r)),s[t]=e}}function lt(t,e,s=!1){const r=Il();if(r||fs){let n=fs?fs._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(n&&t in n)return n[t];if(arguments.length>1)return s&&ae(e)?e.call(r&&r.proxy):e}}function yu(){return!!(Il()||fs)}const mu=Symbol.for("v-scx"),vu=()=>lt(mu);function Zt(t,e,s){return al(t,e,s)}function al(t,e,s=ve){const{immediate:r,deep:n,flush:i,once:o}=s,a=He({},s),l=e&&r||!e&&i!=="post";let c;if(fr){if(i==="sync"){const f=vu();c=f.__watcherHandles||(f.__watcherHandles=[])}else if(!l){const f=()=>{};return f.stop=Rt,f.resume=Rt,f.pause=Rt,f}}const u=We;a.call=(f,y,v)=>Ot(f,u,y,v);let h=!1;i==="post"?a.scheduler=f=>{Ye(f,u&&u.suspense)}:i!=="sync"&&(h=!0,a.scheduler=(f,y)=>{y?f():Ui(f)}),a.augmentJob=f=>{e&&(f.flags|=4),h&&(f.flags|=2,u&&(f.id=u.uid,f.i=u))};const d=du(t,e,a);return fr&&(c?c.push(d):l&&d()),d}function bu(t,e,s){const r=this.proxy,n=Ee(t)?t.includes(".")?ll(r,t):()=>r[t]:t.bind(r,r);let i;ae(e)?i=e:(i=e.handler,s=e);const o=Ar(this),a=al(n,i.bind(r),s);return o(),a}function ll(t,e){const s=e.split(".");return()=>{let r=t;for(let n=0;n<s.length&&r;n++)r=r[s[n]];return r}}const _u=Symbol("_vte"),wu=t=>t.__isTeleport,Su=Symbol("_leaveCb");function Di(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Di(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function Vt(t,e){return ae(t)?He({name:t.name},e,{setup:t}):t}function cl(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function ro(t,e){let s;return!!((s=Object.getOwnPropertyDescriptor(t,e))&&!s.configurable)}const Xr=new WeakMap;function er(t,e,s,r,n=!1){if(ee(t)){t.forEach((v,T)=>er(v,e&&(ee(e)?e[T]:e),s,r,n));return}if(tr(r)&&!n){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&er(t,e,s,r.component.subTree);return}const i=r.shapeFlag&4?kn(r.component):r.el,o=n?null:i,{i:a,r:l}=t,c=e&&e.r,u=a.refs===ve?a.refs={}:a.refs,h=a.setupState,d=ue(h),f=h===ve?Ta:v=>ro(u,v)?!1:fe(d,v),y=(v,T)=>!(T&&ro(u,T));if(c!=null&&c!==l){if(no(e),Ee(c))u[c]=null,f(c)&&(h[c]=null);else if(xe(c)){const v=e;y(c,v.k)&&(c.value=null),v.k&&(u[v.k]=null)}}if(ae(l))xr(l,a,12,[o,u]);else{const v=Ee(l),T=xe(l);if(v||T){const A=()=>{if(t.f){const _=v?f(l)?h[l]:u[l]:y()||!t.k?l.value:u[t.k];if(n)ee(_)&&Ai(_,i);else if(ee(_))_.includes(i)||_.push(i);else if(v)u[l]=[i],f(l)&&(h[l]=u[l]);else{const w=[i];y(l,t.k)&&(l.value=w),t.k&&(u[t.k]=w)}}else v?(u[l]=o,f(l)&&(h[l]=o)):T&&(y(l,t.k)&&(l.value=o),t.k&&(u[t.k]=o))};if(o){const _=()=>{A(),Xr.delete(t)};_.id=-1,Xr.set(t,_),Ye(_,s)}else no(t),A()}}}function no(t){const e=Xr.get(t);e&&(e.flags|=8,Xr.delete(t))}gn().requestIdleCallback;gn().cancelIdleCallback;const tr=t=>!!t.type.__asyncLoader,ul=t=>t.type.__isKeepAlive;function ku(t,e){hl(t,"a",e)}function Eu(t,e){hl(t,"da",e)}function hl(t,e,s=We){const r=t.__wdc||(t.__wdc=()=>{let n=s;for(;n;){if(n.isDeactivated)return;n=n.parent}return t()});if(bn(e,r,s),s){let n=s.parent;for(;n&&n.parent;)ul(n.parent.vnode)&&xu(r,e,s,n),n=n.parent}}function xu(t,e,s,r){const n=bn(e,t,r,!0);Bi(()=>{Ai(r[e],n)},s)}function bn(t,e,s=We,r=!1){if(s){const n=s[t]||(s[t]=[]),i=e.__weh||(e.__weh=(...o)=>{Ht();const a=Ar(s),l=Ot(e,s,t,o);return a(),Ft(),l});return r?n.unshift(i):n.push(i),i}}const Kt=t=>(e,s=We)=>{(!fr||t==="sp")&&bn(t,(...r)=>e(...r),s)},Tu=Kt("bm"),_n=Kt("m"),Au=Kt("bu"),Ru=Kt("u"),dl=Kt("bum"),Bi=Kt("um"),Ou=Kt("sp"),Cu=Kt("rtg"),Pu=Kt("rtc");function Iu(t,e=We){bn("ec",t,e)}const ju=Symbol.for("v-ndc");function es(t,e,s,r){let n;const i=s,o=ee(t);if(o||Ee(t)){const a=o&&Mt(t);let l=!1,c=!1;a&&(l=!nt(t),c=qt(t),t=yn(t)),n=new Array(t.length);for(let u=0,h=t.length;u<h;u++)n[u]=e(l?c?Ns(gt(t[u])):gt(t[u]):t[u],u,void 0,i)}else if(typeof t=="number"){n=new Array(t);for(let a=0;a<t;a++)n[a]=e(a+1,a,void 0,i)}else if(ge(t))if(t[Symbol.iterator])n=Array.from(t,(a,l)=>e(a,l,void 0,i));else{const a=Object.keys(t);n=new Array(a.length);for(let l=0,c=a.length;l<c;l++){const u=a[l];n[l]=e(t[u],u,l,i)}}else n=[];return n}const ti=t=>t?jl(t)?kn(t):ti(t.parent):null,sr=He(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>ti(t.parent),$root:t=>ti(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>pl(t),$forceUpdate:t=>t.f||(t.f=()=>{Ui(t.update)}),$nextTick:t=>t.n||(t.n=Tr.bind(t.proxy)),$watch:t=>bu.bind(t)}),Ln=(t,e)=>t!==ve&&!t.__isScriptSetup&&fe(t,e),$u={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:s,setupState:r,data:n,props:i,accessCache:o,type:a,appContext:l}=t;if(e[0]!=="$"){const d=o[e];if(d!==void 0)switch(d){case 1:return r[e];case 2:return n[e];case 4:return s[e];case 3:return i[e]}else{if(Ln(r,e))return o[e]=1,r[e];if(n!==ve&&fe(n,e))return o[e]=2,n[e];if(fe(i,e))return o[e]=3,i[e];if(s!==ve&&fe(s,e))return o[e]=4,s[e];si&&(o[e]=0)}}const c=sr[e];let u,h;if(c)return e==="$attrs"&&Fe(t.attrs,"get",""),c(t);if((u=a.__cssModules)&&(u=u[e]))return u;if(s!==ve&&fe(s,e))return o[e]=4,s[e];if(h=l.config.globalProperties,fe(h,e))return h[e]},set({_:t},e,s){const{data:r,setupState:n,ctx:i}=t;return Ln(n,e)?(n[e]=s,!0):r!==ve&&fe(r,e)?(r[e]=s,!0):fe(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(i[e]=s,!0)},has({_:{data:t,setupState:e,accessCache:s,ctx:r,appContext:n,props:i,type:o}},a){let l;return!!(s[a]||t!==ve&&a[0]!=="$"&&fe(t,a)||Ln(e,a)||fe(i,a)||fe(r,a)||fe(sr,a)||fe(n.config.globalProperties,a)||(l=o.__cssModules)&&l[a])},defineProperty(t,e,s){return s.get!=null?t._.accessCache[e]=0:fe(s,"value")&&this.set(t,e,s.value,null),Reflect.defineProperty(t,e,s)}};function io(t){return ee(t)?t.reduce((e,s)=>(e[s]=null,e),{}):t}let si=!0;function Nu(t){const e=pl(t),s=t.proxy,r=t.ctx;si=!1,e.beforeCreate&&oo(e.beforeCreate,t,"bc");const{data:n,computed:i,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:h,mounted:d,beforeUpdate:f,updated:y,activated:v,deactivated:T,beforeDestroy:A,beforeUnmount:_,destroyed:w,unmounted:C,render:W,renderTracked:re,renderTriggered:Y,errorCaptured:te,serverPrefetch:X,expose:oe,inheritAttrs:Oe,components:Le,directives:Te,filters:Qe}=e;if(c&&Lu(c,r,null),o)for(const se in o){const I=o[se];ae(I)&&(r[se]=I.bind(s))}if(n){const se=n.call(s,s);ge(se)&&(t.data=Bt(se))}if(si=!0,i)for(const se in i){const I=i[se],G=ae(I)?I.bind(s,s):ae(I.get)?I.get.bind(s,s):Rt,q=!ae(I)&&ae(I.set)?I.set.bind(s):Rt,x=Ge({get:G,set:q});Object.defineProperty(r,se,{enumerable:!0,configurable:!0,get:()=>x.value,set:P=>x.value=P})}if(a)for(const se in a)fl(a[se],r,s,se);if(l){const se=ae(l)?l.call(s):l;Reflect.ownKeys(se).forEach(I=>{Vr(I,se[I])})}u&&oo(u,t,"c");function pe(se,I){ee(I)?I.forEach(G=>se(G.bind(s))):I&&se(I.bind(s))}if(pe(Tu,h),pe(_n,d),pe(Au,f),pe(Ru,y),pe(ku,v),pe(Eu,T),pe(Iu,te),pe(Pu,re),pe(Cu,Y),pe(dl,_),pe(Bi,C),pe(Ou,X),ee(oe))if(oe.length){const se=t.exposed||(t.exposed={});oe.forEach(I=>{Object.defineProperty(se,I,{get:()=>s[I],set:G=>s[I]=G,enumerable:!0})})}else t.exposed||(t.exposed={});W&&t.render===Rt&&(t.render=W),Oe!=null&&(t.inheritAttrs=Oe),Le&&(t.components=Le),Te&&(t.directives=Te),X&&cl(t)}function Lu(t,e,s=Rt){ee(t)&&(t=ri(t));for(const r in t){const n=t[r];let i;ge(n)?"default"in n?i=lt(n.from||r,n.default,!0):i=lt(n.from||r):i=lt(n),xe(i)?Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):e[r]=i}}function oo(t,e,s){Ot(ee(t)?t.map(r=>r.bind(e.proxy)):t.bind(e.proxy),e,s)}function fl(t,e,s,r){let n=r.includes(".")?ll(s,r):()=>s[r];if(Ee(t)){const i=e[t];ae(i)&&Zt(n,i)}else if(ae(t))Zt(n,t.bind(s));else if(ge(t))if(ee(t))t.forEach(i=>fl(i,e,s,r));else{const i=ae(t.handler)?t.handler.bind(s):e[t.handler];ae(i)&&Zt(n,i,t)}}function pl(t){const e=t.type,{mixins:s,extends:r}=e,{mixins:n,optionsCache:i,config:{optionMergeStrategies:o}}=t.appContext,a=i.get(e);let l;return a?l=a:!n.length&&!s&&!r?l=e:(l={},n.length&&n.forEach(c=>Qr(l,c,o,!0)),Qr(l,e,o)),ge(e)&&i.set(e,l),l}function Qr(t,e,s,r=!1){const{mixins:n,extends:i}=e;i&&Qr(t,i,s,!0),n&&n.forEach(o=>Qr(t,o,s,!0));for(const o in e)if(!(r&&o==="expose")){const a=Uu[o]||s&&s[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const Uu={data:ao,props:lo,emits:lo,methods:Ws,computed:Ws,beforeCreate:qe,created:qe,beforeMount:qe,mounted:qe,beforeUpdate:qe,updated:qe,beforeDestroy:qe,beforeUnmount:qe,destroyed:qe,unmounted:qe,activated:qe,deactivated:qe,errorCaptured:qe,serverPrefetch:qe,components:Ws,directives:Ws,watch:Bu,provide:ao,inject:Du};function ao(t,e){return e?t?function(){return He(ae(t)?t.call(this,this):t,ae(e)?e.call(this,this):e)}:e:t}function Du(t,e){return Ws(ri(t),ri(e))}function ri(t){if(ee(t)){const e={};for(let s=0;s<t.length;s++)e[t[s]]=t[s];return e}return t}function qe(t,e){return t?[...new Set([].concat(t,e))]:e}function Ws(t,e){return t?He(Object.create(null),t,e):e}function lo(t,e){return t?ee(t)&&ee(e)?[...new Set([...t,...e])]:He(Object.create(null),io(t),io(e??{})):e}function Bu(t,e){if(!t)return e;if(!e)return t;const s=He(Object.create(null),t);for(const r in e)s[r]=qe(t[r],e[r]);return s}function gl(){return{app:null,config:{isNativeTag:Ta,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Mu=0;function Hu(t,e){return function(r,n=null){ae(r)||(r=He({},r)),n!=null&&!ge(n)&&(n=null);const i=gl(),o=new WeakSet,a=[];let l=!1;const c=i.app={_uid:Mu++,_component:r,_props:n,_container:null,_context:i,_instance:null,version:bh,get config(){return i.config},set config(u){},use(u,...h){return o.has(u)||(u&&ae(u.install)?(o.add(u),u.install(c,...h)):ae(u)&&(o.add(u),u(c,...h))),c},mixin(u){return i.mixins.includes(u)||i.mixins.push(u),c},component(u,h){return h?(i.components[u]=h,c):i.components[u]},directive(u,h){return h?(i.directives[u]=h,c):i.directives[u]},mount(u,h,d){if(!l){const f=c._ceVNode||Ie(r,n);return f.appContext=i,d===!0?d="svg":d===!1&&(d=void 0),t(f,u,d),l=!0,c._container=u,u.__vue_app__=c,kn(f.component)}},onUnmount(u){a.push(u)},unmount(){l&&(Ot(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,h){return i.provides[u]=h,c},runWithContext(u){const h=fs;fs=c;try{return u()}finally{fs=h}}};return c}}let fs=null;const Fu=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${ft(e)}Modifiers`]||t[`${ps(e)}Modifiers`];function qu(t,e,...s){if(t.isUnmounted)return;const r=t.vnode.props||ve;let n=s;const i=e.startsWith("update:"),o=i&&Fu(r,e.slice(7));o&&(o.trim&&(n=s.map(u=>Ee(u)?u.trim():u)),o.number&&(n=s.map(Ri)));let a,l=r[a=Pn(e)]||r[a=Pn(ft(e))];!l&&i&&(l=r[a=Pn(ps(e))]),l&&Ot(l,t,6,n);const c=r[a+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,Ot(c,t,6,n)}}const Vu=new WeakMap;function yl(t,e,s=!1){const r=s?Vu:e.emitsCache,n=r.get(t);if(n!==void 0)return n;const i=t.emits;let o={},a=!1;if(!ae(t)){const l=c=>{const u=yl(c,e,!0);u&&(a=!0,He(o,u))};!s&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!i&&!a?(ge(t)&&r.set(t,null),null):(ee(i)?i.forEach(l=>o[l]=null):He(o,i),ge(t)&&r.set(t,o),o)}function wn(t,e){return!t||!un(e)?!1:(e=e.slice(2).replace(/Once$/,""),fe(t,e[0].toLowerCase()+e.slice(1))||fe(t,ps(e))||fe(t,e))}function co(t){const{type:e,vnode:s,proxy:r,withProxy:n,propsOptions:[i],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:h,data:d,setupState:f,ctx:y,inheritAttrs:v}=t,T=Yr(t);let A,_;try{if(s.shapeFlag&4){const C=n||r,W=C;A=xt(c.call(W,C,u,h,f,d,y)),_=a}else{const C=e;A=xt(C.length>1?C(h,{attrs:a,slots:o,emit:l}):C(h,null)),_=e.props?a:Ku(a)}}catch(C){rr.length=0,vn(C,t,1),A=Ie(ts)}let w=A;if(_&&v!==!1){const C=Object.keys(_),{shapeFlag:W}=w;C.length&&W&7&&(i&&C.some(hn)&&(_=Wu(_,i)),w=Ls(w,_,!1,!0))}return s.dirs&&(w=Ls(w,null,!1,!0),w.dirs=w.dirs?w.dirs.concat(s.dirs):s.dirs),s.transition&&Di(w,s.transition),A=w,Yr(T),A}const Ku=t=>{let e;for(const s in t)(s==="class"||s==="style"||un(s))&&((e||(e={}))[s]=t[s]);return e},Wu=(t,e)=>{const s={};for(const r in t)(!hn(r)||!(r.slice(9)in e))&&(s[r]=t[r]);return s};function Gu(t,e,s){const{props:r,children:n,component:i}=t,{props:o,children:a,patchFlag:l}=e,c=i.emitsOptions;if(e.dirs||e.transition)return!0;if(s&&l>=0){if(l&1024)return!0;if(l&16)return r?uo(r,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let h=0;h<u.length;h++){const d=u[h];if(ml(o,r,d)&&!wn(c,d))return!0}}}else return(n||a)&&(!a||!a.$stable)?!0:r===o?!1:r?o?uo(r,o,c):!0:!!o;return!1}function uo(t,e,s){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!0;for(let n=0;n<r.length;n++){const i=r[n];if(ml(e,t,i)&&!wn(s,i))return!0}return!1}function ml(t,e,s){const r=t[s],n=e[s];return s==="style"&&ge(r)&&ge(n)?!Er(r,n):r!==n}function Ju({vnode:t,parent:e,suspense:s},r){for(;e;){const n=e.subTree;if(n.suspense&&n.suspense.activeBranch===t&&(n.suspense.vnode.el=n.el=r,t=n),n===t)(t=e.vnode).el=r,e=e.parent;else break}s&&s.activeBranch===t&&(s.vnode.el=r)}const vl={},bl=()=>Object.create(vl),_l=t=>Object.getPrototypeOf(t)===vl;function zu(t,e,s,r=!1){const n={},i=bl();t.propsDefaults=Object.create(null),wl(t,e,n,i);for(const o in t.propsOptions[0])o in n||(n[o]=void 0);s?t.props=r?n:Za(n):t.type.props?t.props=n:t.props=i,t.attrs=i}function Yu(t,e,s,r){const{props:n,attrs:i,vnode:{patchFlag:o}}=t,a=ue(n),[l]=t.propsOptions;let c=!1;if((r||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let h=0;h<u.length;h++){let d=u[h];if(wn(t.emitsOptions,d))continue;const f=e[d];if(l)if(fe(i,d))f!==i[d]&&(i[d]=f,c=!0);else{const y=ft(d);n[y]=ni(l,a,y,f,t,!1)}else f!==i[d]&&(i[d]=f,c=!0)}}}else{wl(t,e,n,i)&&(c=!0);let u;for(const h in a)(!e||!fe(e,h)&&((u=ps(h))===h||!fe(e,u)))&&(l?s&&(s[h]!==void 0||s[u]!==void 0)&&(n[h]=ni(l,a,h,void 0,t,!0)):delete n[h]);if(i!==a)for(const h in i)(!e||!fe(e,h))&&(delete i[h],c=!0)}c&&Ut(t.attrs,"set","")}function wl(t,e,s,r){const[n,i]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(Xs(l))continue;const c=e[l];let u;n&&fe(n,u=ft(l))?!i||!i.includes(u)?s[u]=c:(a||(a={}))[u]=c:wn(t.emitsOptions,l)||(!(l in r)||c!==r[l])&&(r[l]=c,o=!0)}if(i){const l=ue(s),c=a||ve;for(let u=0;u<i.length;u++){const h=i[u];s[h]=ni(n,l,h,c[h],t,!fe(c,h))}}return o}function ni(t,e,s,r,n,i){const o=t[s];if(o!=null){const a=fe(o,"default");if(a&&r===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&ae(l)){const{propsDefaults:c}=n;if(s in c)r=c[s];else{const u=Ar(n);r=c[s]=l.call(null,e),u()}}else r=l;n.ce&&n.ce._setProp(s,r)}o[0]&&(i&&!a?r=!1:o[1]&&(r===""||r===ps(s))&&(r=!0))}return r}const Xu=new WeakMap;function Sl(t,e,s=!1){const r=s?Xu:e.propsCache,n=r.get(t);if(n)return n;const i=t.props,o={},a=[];let l=!1;if(!ae(t)){const u=h=>{l=!0;const[d,f]=Sl(h,e,!0);He(o,d),f&&a.push(...f)};!s&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!i&&!l)return ge(t)&&r.set(t,Os),Os;if(ee(i))for(let u=0;u<i.length;u++){const h=ft(i[u]);ho(h)&&(o[h]=ve)}else if(i)for(const u in i){const h=ft(u);if(ho(h)){const d=i[u],f=o[h]=ee(d)||ae(d)?{type:d}:He({},d),y=f.type;let v=!1,T=!0;if(ee(y))for(let A=0;A<y.length;++A){const _=y[A],w=ae(_)&&_.name;if(w==="Boolean"){v=!0;break}else w==="String"&&(T=!1)}else v=ae(y)&&y.name==="Boolean";f[0]=v,f[1]=T,(v||fe(f,"default"))&&a.push(h)}}const c=[o,a];return ge(t)&&r.set(t,c),c}function ho(t){return t[0]!=="$"&&!Xs(t)}const Mi=t=>t==="_"||t==="_ctx"||t==="$stable",Hi=t=>ee(t)?t.map(xt):[xt(t)],Qu=(t,e,s)=>{if(e._n)return e;const r=Ks((...n)=>Hi(e(...n)),s);return r._c=!1,r},kl=(t,e,s)=>{const r=t._ctx;for(const n in t){if(Mi(n))continue;const i=t[n];if(ae(i))e[n]=Qu(n,i,r);else if(i!=null){const o=Hi(i);e[n]=()=>o}}},El=(t,e)=>{const s=Hi(e);t.slots.default=()=>s},xl=(t,e,s)=>{for(const r in e)(s||!Mi(r))&&(t[r]=e[r])},Zu=(t,e,s)=>{const r=t.slots=bl();if(t.vnode.shapeFlag&32){const n=e._;n?(xl(r,e,s),s&&Pa(r,"_",n,!0)):kl(e,r)}else e&&El(t,e)},eh=(t,e,s)=>{const{vnode:r,slots:n}=t;let i=!0,o=ve;if(r.shapeFlag&32){const a=e._;a?s&&a===1?i=!1:xl(n,e,s):(i=!e.$stable,kl(e,n)),o=e}else e&&(El(t,e),o={default:1});if(i)for(const a in n)!Mi(a)&&o[a]==null&&delete n[a]},Ye=ih;function th(t){return sh(t)}function sh(t,e){const s=gn();s.__VUE__=!0;const{insert:r,remove:n,patchProp:i,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:h,nextSibling:d,setScopeId:f=Rt,insertStaticContent:y}=t,v=(p,g,m,S=null,R=null,E=null,D=void 0,L=null,N=!!g.dynamicChildren)=>{if(p===g)return;p&&!Fs(p,g)&&(S=k(p),P(p,R,E,!0),p=null),g.patchFlag===-2&&(N=!1,g.dynamicChildren=null);const{type:O,ref:Q,shapeFlag:M}=g;switch(O){case Sn:T(p,g,m,S);break;case ts:A(p,g,m,S);break;case Dn:p==null&&_(g,m,S,D);break;case $e:Le(p,g,m,S,R,E,D,L,N);break;default:M&1?W(p,g,m,S,R,E,D,L,N):M&6?Te(p,g,m,S,R,E,D,L,N):(M&64||M&128)&&O.process(p,g,m,S,R,E,D,L,N,J)}Q!=null&&R?er(Q,p&&p.ref,E,g||p,!g):Q==null&&p&&p.ref!=null&&er(p.ref,null,E,p,!0)},T=(p,g,m,S)=>{if(p==null)r(g.el=a(g.children),m,S);else{const R=g.el=p.el;g.children!==p.children&&c(R,g.children)}},A=(p,g,m,S)=>{p==null?r(g.el=l(g.children||""),m,S):g.el=p.el},_=(p,g,m,S)=>{[p.el,p.anchor]=y(p.children,g,m,S,p.el,p.anchor)},w=({el:p,anchor:g},m,S)=>{let R;for(;p&&p!==g;)R=d(p),r(p,m,S),p=R;r(g,m,S)},C=({el:p,anchor:g})=>{let m;for(;p&&p!==g;)m=d(p),n(p),p=m;n(g)},W=(p,g,m,S,R,E,D,L,N)=>{if(g.type==="svg"?D="svg":g.type==="math"&&(D="mathml"),p==null)re(g,m,S,R,E,D,L,N);else{const O=p.el&&p.el._isVueCE?p.el:null;try{O&&O._beginPatch(),X(p,g,R,E,D,L,N)}finally{O&&O._endPatch()}}},re=(p,g,m,S,R,E,D,L)=>{let N,O;const{props:Q,shapeFlag:M,transition:z,dirs:ne}=p;if(N=p.el=o(p.type,E,Q&&Q.is,Q),M&8?u(N,p.children):M&16&&te(p.children,N,null,S,R,Un(p,E),D,L),ne&&ss(p,null,S,"created"),Y(N,p,p.scopeId,D,S),Q){for(const ye in Q)ye!=="value"&&!Xs(ye)&&i(N,ye,null,Q[ye],E,S);"value"in Q&&i(N,"value",null,Q.value,E),(O=Q.onVnodeBeforeMount)&&_t(O,S,p)}ne&&ss(p,null,S,"beforeMount");const ce=rh(R,z);ce&&z.beforeEnter(N),r(N,g,m),((O=Q&&Q.onVnodeMounted)||ce||ne)&&Ye(()=>{try{O&&_t(O,S,p),ce&&z.enter(N),ne&&ss(p,null,S,"mounted")}finally{}},R)},Y=(p,g,m,S,R)=>{if(m&&f(p,m),S)for(let E=0;E<S.length;E++)f(p,S[E]);if(R){let E=R.subTree;if(g===E||Ol(E.type)&&(E.ssContent===g||E.ssFallback===g)){const D=R.vnode;Y(p,D,D.scopeId,D.slotScopeIds,R.parent)}}},te=(p,g,m,S,R,E,D,L,N=0)=>{for(let O=N;O<p.length;O++){const Q=p[O]=L?Lt(p[O]):xt(p[O]);v(null,Q,g,m,S,R,E,D,L)}},X=(p,g,m,S,R,E,D)=>{const L=g.el=p.el;let{patchFlag:N,dynamicChildren:O,dirs:Q}=g;N|=p.patchFlag&16;const M=p.props||ve,z=g.props||ve;let ne;if(m&&rs(m,!1),(ne=z.onVnodeBeforeUpdate)&&_t(ne,m,g,p),Q&&ss(g,p,m,"beforeUpdate"),m&&rs(m,!0),(M.innerHTML&&z.innerHTML==null||M.textContent&&z.textContent==null)&&u(L,""),O?oe(p.dynamicChildren,O,L,m,S,Un(g,R),E):D||I(p,g,L,null,m,S,Un(g,R),E,!1),N>0){if(N&16)Oe(L,M,z,m,R);else if(N&2&&M.class!==z.class&&i(L,"class",null,z.class,R),N&4&&i(L,"style",M.style,z.style,R),N&8){const ce=g.dynamicProps;for(let ye=0;ye<ce.length;ye++){const be=ce[ye],Ae=M[be],De=z[be];(De!==Ae||be==="value")&&i(L,be,Ae,De,R,m)}}N&1&&p.children!==g.children&&u(L,g.children)}else!D&&O==null&&Oe(L,M,z,m,R);((ne=z.onVnodeUpdated)||Q)&&Ye(()=>{ne&&_t(ne,m,g,p),Q&&ss(g,p,m,"updated")},S)},oe=(p,g,m,S,R,E,D)=>{for(let L=0;L<g.length;L++){const N=p[L],O=g[L],Q=N.el&&(N.type===$e||!Fs(N,O)||N.shapeFlag&198)?h(N.el):m;v(N,O,Q,null,S,R,E,D,!0)}},Oe=(p,g,m,S,R)=>{if(g!==m){if(g!==ve)for(const E in g)!Xs(E)&&!(E in m)&&i(p,E,g[E],null,R,S);for(const E in m){if(Xs(E))continue;const D=m[E],L=g[E];D!==L&&E!=="value"&&i(p,E,L,D,R,S)}"value"in m&&i(p,"value",g.value,m.value,R)}},Le=(p,g,m,S,R,E,D,L,N)=>{const O=g.el=p?p.el:a(""),Q=g.anchor=p?p.anchor:a("");let{patchFlag:M,dynamicChildren:z,slotScopeIds:ne}=g;ne&&(L=L?L.concat(ne):ne),p==null?(r(O,m,S),r(Q,m,S),te(g.children||[],m,Q,R,E,D,L,N)):M>0&&M&64&&z&&p.dynamicChildren&&p.dynamicChildren.length===z.length?(oe(p.dynamicChildren,z,m,R,E,D,L),(g.key!=null||R&&g===R.subTree)&&Tl(p,g,!0)):I(p,g,m,Q,R,E,D,L,N)},Te=(p,g,m,S,R,E,D,L,N)=>{g.slotScopeIds=L,p==null?g.shapeFlag&512?R.ctx.activate(g,m,S,D,N):Qe(g,m,S,R,E,D,N):Ze(p,g,N)},Qe=(p,g,m,S,R,E,D)=>{const L=p.component=fh(p,S,R);if(ul(p)&&(L.ctx.renderer=J),ph(L,!1,D),L.asyncDep){if(R&&R.registerDep(L,pe,D),!p.el){const N=L.subTree=Ie(ts);A(null,N,g,m),p.placeholder=N.el}}else pe(L,p,g,m,R,E,D)},Ze=(p,g,m)=>{const S=g.component=p.component;if(Gu(p,g,m))if(S.asyncDep&&!S.asyncResolved){se(S,g,m);return}else S.next=g,S.update();else g.el=p.el,S.vnode=g},pe=(p,g,m,S,R,E,D)=>{const L=()=>{if(p.isMounted){let{next:M,bu:z,u:ne,parent:ce,vnode:ye}=p;{const vt=Al(p);if(vt){M&&(M.el=ye.el,se(p,M,D)),vt.asyncDep.then(()=>{Ye(()=>{p.isUnmounted||O()},R)});return}}let be=M,Ae;rs(p,!1),M?(M.el=ye.el,se(p,M,D)):M=ye,z&&qr(z),(Ae=M.props&&M.props.onVnodeBeforeUpdate)&&_t(Ae,ce,M,ye),rs(p,!0);const De=co(p),mt=p.subTree;p.subTree=De,v(mt,De,h(mt.el),k(mt),p,R,E),M.el=De.el,be===null&&Ju(p,De.el),ne&&Ye(ne,R),(Ae=M.props&&M.props.onVnodeUpdated)&&Ye(()=>_t(Ae,ce,M,ye),R)}else{let M;const{el:z,props:ne}=g,{bm:ce,m:ye,parent:be,root:Ae,type:De}=p,mt=tr(g);rs(p,!1),ce&&qr(ce),!mt&&(M=ne&&ne.onVnodeBeforeMount)&&_t(M,be,g),rs(p,!0);{Ae.ce&&Ae.ce._hasShadowRoot()&&Ae.ce._injectChildStyle(De,p.parent?p.parent.type:void 0);const vt=p.subTree=co(p);v(null,vt,m,S,p,R,E),g.el=vt.el}if(ye&&Ye(ye,R),!mt&&(M=ne&&ne.onVnodeMounted)){const vt=g;Ye(()=>_t(M,be,vt),R)}(g.shapeFlag&256||be&&tr(be.vnode)&&be.vnode.shapeFlag&256)&&p.a&&Ye(p.a,R),p.isMounted=!0,g=m=S=null}};p.scope.on();const N=p.effect=new Ba(L);p.scope.off();const O=p.update=N.run.bind(N),Q=p.job=N.runIfDirty.bind(N);Q.i=p,Q.id=p.uid,N.scheduler=()=>Ui(Q),rs(p,!0),O()},se=(p,g,m)=>{g.component=p;const S=p.vnode.props;p.vnode=g,p.next=null,Yu(p,g.props,S,m),eh(p,g.children,m),Ht(),so(p),Ft()},I=(p,g,m,S,R,E,D,L,N=!1)=>{const O=p&&p.children,Q=p?p.shapeFlag:0,M=g.children,{patchFlag:z,shapeFlag:ne}=g;if(z>0){if(z&128){q(O,M,m,S,R,E,D,L,N);return}else if(z&256){G(O,M,m,S,R,E,D,L,N);return}}ne&8?(Q&16&&Je(O,R,E),M!==O&&u(m,M)):Q&16?ne&16?q(O,M,m,S,R,E,D,L,N):Je(O,R,E,!0):(Q&8&&u(m,""),ne&16&&te(M,m,S,R,E,D,L,N))},G=(p,g,m,S,R,E,D,L,N)=>{p=p||Os,g=g||Os;const O=p.length,Q=g.length,M=Math.min(O,Q);let z;for(z=0;z<M;z++){const ne=g[z]=N?Lt(g[z]):xt(g[z]);v(p[z],ne,m,null,R,E,D,L,N)}O>Q?Je(p,R,E,!0,!1,M):te(g,m,S,R,E,D,L,N,M)},q=(p,g,m,S,R,E,D,L,N)=>{let O=0;const Q=g.length;let M=p.length-1,z=Q-1;for(;O<=M&&O<=z;){const ne=p[O],ce=g[O]=N?Lt(g[O]):xt(g[O]);if(Fs(ne,ce))v(ne,ce,m,null,R,E,D,L,N);else break;O++}for(;O<=M&&O<=z;){const ne=p[M],ce=g[z]=N?Lt(g[z]):xt(g[z]);if(Fs(ne,ce))v(ne,ce,m,null,R,E,D,L,N);else break;M--,z--}if(O>M){if(O<=z){const ne=z+1,ce=ne<Q?g[ne].el:S;for(;O<=z;)v(null,g[O]=N?Lt(g[O]):xt(g[O]),m,ce,R,E,D,L,N),O++}}else if(O>z)for(;O<=M;)P(p[O],R,E,!0),O++;else{const ne=O,ce=O,ye=new Map;for(O=ce;O<=z;O++){const tt=g[O]=N?Lt(g[O]):xt(g[O]);tt.key!=null&&ye.set(tt.key,O)}let be,Ae=0;const De=z-ce+1;let mt=!1,vt=0;const Ms=new Array(De);for(O=0;O<De;O++)Ms[O]=0;for(O=ne;O<=M;O++){const tt=p[O];if(Ae>=De){P(tt,R,E,!0);continue}let bt;if(tt.key!=null)bt=ye.get(tt.key);else for(be=ce;be<=z;be++)if(Ms[be-ce]===0&&Fs(tt,g[be])){bt=be;break}bt===void 0?P(tt,R,E,!0):(Ms[bt-ce]=O+1,bt>=vt?vt=bt:mt=!0,v(tt,g[bt],m,null,R,E,D,L,N),Ae++)}const zi=mt?nh(Ms):Os;for(be=zi.length-1,O=De-1;O>=0;O--){const tt=ce+O,bt=g[tt],Yi=g[tt+1],Xi=tt+1<Q?Yi.el||Rl(Yi):S;Ms[O]===0?v(null,bt,m,Xi,R,E,D,L,N):mt&&(be<0||O!==zi[be]?x(bt,m,Xi,2):be--)}}},x=(p,g,m,S,R=null)=>{const{el:E,type:D,transition:L,children:N,shapeFlag:O}=p;if(O&6){x(p.component.subTree,g,m,S);return}if(O&128){p.suspense.move(g,m,S);return}if(O&64){D.move(p,g,m,J);return}if(D===$e){r(E,g,m);for(let M=0;M<N.length;M++)x(N[M],g,m,S);r(p.anchor,g,m);return}if(D===Dn){w(p,g,m);return}if(S!==2&&O&1&&L)if(S===0)L.beforeEnter(E),r(E,g,m),Ye(()=>L.enter(E),R);else{const{leave:M,delayLeave:z,afterLeave:ne}=L,ce=()=>{p.ctx.isUnmounted?n(E):r(E,g,m)},ye=()=>{E._isLeaving&&E[Su](!0),M(E,()=>{ce(),ne&&ne()})};z?z(E,ce,ye):ye()}else r(E,g,m)},P=(p,g,m,S=!1,R=!1)=>{const{type:E,props:D,ref:L,children:N,dynamicChildren:O,shapeFlag:Q,patchFlag:M,dirs:z,cacheIndex:ne,memo:ce}=p;if(M===-2&&(R=!1),L!=null&&(Ht(),er(L,null,m,p,!0),Ft()),ne!=null&&(g.renderCache[ne]=void 0),Q&256){g.ctx.deactivate(p);return}const ye=Q&1&&z,be=!tr(p);let Ae;if(be&&(Ae=D&&D.onVnodeBeforeUnmount)&&_t(Ae,g,p),Q&6)et(p.component,m,S);else{if(Q&128){p.suspense.unmount(m,S);return}ye&&ss(p,null,g,"beforeUnmount"),Q&64?p.type.remove(p,g,m,J,S):O&&!O.hasOnce&&(E!==$e||M>0&&M&64)?Je(O,g,m,!1,!0):(E===$e&&M&384||!R&&Q&16)&&Je(N,g,m),S&&H(p)}const De=ce!=null&&ne==null;(be&&(Ae=D&&D.onVnodeUnmounted)||ye||De)&&Ye(()=>{Ae&&_t(Ae,g,p),ye&&ss(p,null,g,"unmounted"),De&&(p.el=null)},m)},H=p=>{const{type:g,el:m,anchor:S,transition:R}=p;if(g===$e){Ue(m,S);return}if(g===Dn){C(p);return}const E=()=>{n(m),R&&!R.persisted&&R.afterLeave&&R.afterLeave()};if(p.shapeFlag&1&&R&&!R.persisted){const{leave:D,delayLeave:L}=R,N=()=>D(m,E);L?L(p.el,E,N):N()}else E()},Ue=(p,g)=>{let m;for(;p!==g;)m=d(p),n(p),p=m;n(g)},et=(p,g,m)=>{const{bum:S,scope:R,job:E,subTree:D,um:L,m:N,a:O}=p;fo(N),fo(O),S&&qr(S),R.stop(),E&&(E.flags|=8,P(D,p,g,m)),L&&Ye(L,g),Ye(()=>{p.isUnmounted=!0},g)},Je=(p,g,m,S=!1,R=!1,E=0)=>{for(let D=E;D<p.length;D++)P(p[D],g,m,S,R)},k=p=>{if(p.shapeFlag&6)return k(p.component.subTree);if(p.shapeFlag&128)return p.suspense.next();const g=d(p.anchor||p.el),m=g&&g[_u];return m?d(m):g};let V=!1;const B=(p,g,m)=>{let S;p==null?g._vnode&&(P(g._vnode,null,null,!0),S=g._vnode.component):v(g._vnode||null,p,g,null,null,null,m),g._vnode=p,V||(V=!0,so(S),nl(),V=!1)},J={p:v,um:P,m:x,r:H,mt:Qe,mc:te,pc:I,pbc:oe,n:k,o:t};return{render:B,hydrate:void 0,createApp:Hu(B)}}function Un({type:t,props:e},s){return s==="svg"&&t==="foreignObject"||s==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:s}function rs({effect:t,job:e},s){s?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function rh(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Tl(t,e,s=!1){const r=t.children,n=e.children;if(ee(r)&&ee(n))for(let i=0;i<r.length;i++){const o=r[i];let a=n[i];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=n[i]=Lt(n[i]),a.el=o.el),!s&&a.patchFlag!==-2&&Tl(o,a)),a.type===Sn&&(a.patchFlag===-1&&(a=n[i]=Lt(a)),a.el=o.el),a.type===ts&&!a.el&&(a.el=o.el)}}function nh(t){const e=t.slice(),s=[0];let r,n,i,o,a;const l=t.length;for(r=0;r<l;r++){const c=t[r];if(c!==0){if(n=s[s.length-1],t[n]<c){e[r]=n,s.push(r);continue}for(i=0,o=s.length-1;i<o;)a=i+o>>1,t[s[a]]<c?i=a+1:o=a;c<t[s[i]]&&(i>0&&(e[r]=s[i-1]),s[i]=r)}}for(i=s.length,o=s[i-1];i-- >0;)s[i]=o,o=e[o];return s}function Al(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Al(e)}function fo(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function Rl(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?Rl(e.subTree):null}const Ol=t=>t.__isSuspense;function ih(t,e){e&&e.pendingBranch?ee(t)?e.effects.push(...t):e.effects.push(t):gu(t)}const $e=Symbol.for("v-fgt"),Sn=Symbol.for("v-txt"),ts=Symbol.for("v-cmt"),Dn=Symbol.for("v-stc"),rr=[];let rt=null;function j(t=!1){rr.push(rt=t?null:[])}function oh(){rr.pop(),rt=rr[rr.length-1]||null}let dr=1;function Zr(t,e=!1){dr+=t,t<0&&rt&&e&&(rt.hasOnce=!0)}function Cl(t){return t.dynamicChildren=dr>0?rt||Os:null,oh(),dr>0&&rt&&rt.push(t),t}function $(t,e,s,r,n,i){return Cl(b(t,e,s,r,n,i,!0))}function ah(t,e,s,r,n){return Cl(Ie(t,e,s,r,n,!0))}function en(t){return t?t.__v_isVNode===!0:!1}function Fs(t,e){return t.type===e.type&&t.key===e.key}const Pl=({key:t})=>t??null,Kr=({ref:t,ref_key:e,ref_for:s})=>(typeof t=="number"&&(t=""+t),t!=null?Ee(t)||xe(t)||ae(t)?{i:at,r:t,k:e,f:!!s}:t:null);function b(t,e=null,s=null,r=0,n=null,i=t===$e?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Pl(e),ref:e&&Kr(e),scopeId:ol,slotScopeIds:null,children:s,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:r,dynamicProps:n,dynamicChildren:null,appContext:null,ctx:at};return a?(Fi(l,s),i&128&&t.normalize(l)):s&&(l.shapeFlag|=Ee(s)?8:16),dr>0&&!o&&rt&&(l.patchFlag>0||i&6)&&l.patchFlag!==32&&rt.push(l),l}const Ie=lh;function lh(t,e=null,s=null,r=0,n=null,i=!1){if((!t||t===ju)&&(t=ts),en(t)){const a=Ls(t,e,!0);return s&&Fi(a,s),dr>0&&!i&&rt&&(a.shapeFlag&6?rt[rt.indexOf(t)]=a:rt.push(a)),a.patchFlag=-2,a}if(vh(t)&&(t=t.__vccOpts),e){e=ch(e);let{class:a,style:l}=e;a&&!Ee(a)&&(e.class=Ne(a)),ge(l)&&(mn(l)&&!ee(l)&&(l=He({},l)),e.style=Oi(l))}const o=Ee(t)?1:Ol(t)?128:wu(t)?64:ge(t)?4:ae(t)?2:0;return b(t,e,s,r,n,o,i,!0)}function ch(t){return t?mn(t)||_l(t)?He({},t):t:null}function Ls(t,e,s=!1,r=!1){const{props:n,ref:i,patchFlag:o,children:a,transition:l}=t,c=e?uh(n||{},e):n,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Pl(c),ref:e&&e.ref?s&&i?ee(i)?i.concat(Kr(e)):[i,Kr(e)]:Kr(e):i,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:a,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==$e?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Ls(t.ssContent),ssFallback:t.ssFallback&&Ls(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&r&&Di(u,l.clone(u)),u}function Xe(t=" ",e=0){return Ie(Sn,null,t,e)}function de(t="",e=!1){return e?(j(),ah(ts,null,t)):Ie(ts,null,t)}function xt(t){return t==null||typeof t=="boolean"?Ie(ts):ee(t)?Ie($e,null,t.slice()):en(t)?Lt(t):Ie(Sn,null,String(t))}function Lt(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Ls(t)}function Fi(t,e){let s=0;const{shapeFlag:r}=t;if(e==null)e=null;else if(ee(e))s=16;else if(typeof e=="object")if(r&65){const n=e.default;n&&(n._c&&(n._d=!1),Fi(t,n()),n._c&&(n._d=!0));return}else{s=32;const n=e._;!n&&!_l(e)?e._ctx=at:n===3&&at&&(at.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else ae(e)?(e={default:e,_ctx:at},s=32):(e=String(e),r&64?(s=16,e=[Xe(e)]):s=8);t.children=e,t.shapeFlag|=s}function uh(...t){const e={};for(let s=0;s<t.length;s++){const r=t[s];for(const n in r)if(n==="class")e.class!==r.class&&(e.class=Ne([e.class,r.class]));else if(n==="style")e.style=Oi([e.style,r.style]);else if(un(n)){const i=e[n],o=r[n];o&&i!==o&&!(ee(i)&&i.includes(o))?e[n]=i?[].concat(i,o):o:o==null&&i==null&&!hn(n)&&(e[n]=o)}else n!==""&&(e[n]=r[n])}return e}function _t(t,e,s,r=null){Ot(t,e,7,[s,r])}const hh=gl();let dh=0;function fh(t,e,s){const r=t.type,n=(e?e.appContext:t.appContext)||hh,i={uid:dh++,vnode:t,type:r,parent:e,appContext:n,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new La(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(n.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Sl(r,n),emitsOptions:yl(r,n),emit:null,emitted:null,propsDefaults:ve,inheritAttrs:r.inheritAttrs,ctx:ve,data:ve,props:ve,attrs:ve,slots:ve,refs:ve,setupState:ve,setupContext:null,suspense:s,suspenseId:s?s.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return i.ctx={_:i},i.root=e?e.root:i,i.emit=qu.bind(null,i),t.ce&&t.ce(i),i}let We=null;const Il=()=>We||at;let tn,ii;{const t=gn(),e=(s,r)=>{let n;return(n=t[s])||(n=t[s]=[]),n.push(r),i=>{n.length>1?n.forEach(o=>o(i)):n[0](i)}};tn=e("__VUE_INSTANCE_SETTERS__",s=>We=s),ii=e("__VUE_SSR_SETTERS__",s=>fr=s)}const Ar=t=>{const e=We;return tn(t),t.scope.on(),()=>{t.scope.off(),tn(e)}},po=()=>{We&&We.scope.off(),tn(null)};function jl(t){return t.vnode.shapeFlag&4}let fr=!1;function ph(t,e=!1,s=!1){e&&ii(e);const{props:r,children:n}=t.vnode,i=jl(t);zu(t,r,i,e),Zu(t,n,s||e);const o=i?gh(t,e):void 0;return e&&ii(!1),o}function gh(t,e){const s=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,$u);const{setup:r}=s;if(r){Ht();const n=t.setupContext=r.length>1?mh(t):null,i=Ar(t),o=xr(r,t,0,[t.props,n]),a=Aa(o);if(Ft(),i(),(a||t.sp)&&!tr(t)&&cl(t),a){if(o.then(po,po),e)return o.then(l=>{go(t,l)}).catch(l=>{vn(l,t,0)});t.asyncDep=o}else go(t,o)}else $l(t)}function go(t,e,s){ae(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ge(e)&&(t.setupState=tl(e)),$l(t)}function $l(t,e,s){const r=t.type;t.render||(t.render=r.render||Rt);{const n=Ar(t);Ht();try{Nu(t)}finally{Ft(),n()}}}const yh={get(t,e){return Fe(t,"get",""),t[e]}};function mh(t){const e=s=>{t.exposed=s||{}};return{attrs:new Proxy(t.attrs,yh),slots:t.slots,emit:t.emit,expose:e}}function kn(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(tl(Li(t.exposed)),{get(e,s){if(s in e)return e[s];if(s in sr)return sr[s](t)},has(e,s){return s in e||s in sr}})):t.proxy}function vh(t){return ae(t)&&"__vccOpts"in t}const Ge=(t,e)=>uu(t,e,fr);function Nl(t,e,s){try{Zr(-1);const r=arguments.length;return r===2?ge(e)&&!ee(e)?en(e)?Ie(t,null,[e]):Ie(t,e):Ie(t,null,e):(r>3?s=Array.prototype.slice.call(arguments,2):r===3&&en(s)&&(s=[s]),Ie(t,e,s))}finally{Zr(1)}}const bh="3.5.34";/**
14
+ * @vue/runtime-dom v3.5.34
15
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
16
+ * @license MIT
17
+ **/let oi;const yo=typeof window<"u"&&window.trustedTypes;if(yo)try{oi=yo.createPolicy("vue",{createHTML:t=>t})}catch{}const Ll=oi?t=>oi.createHTML(t):t=>t,_h="http://www.w3.org/2000/svg",wh="http://www.w3.org/1998/Math/MathML",jt=typeof document<"u"?document:null,mo=jt&&jt.createElement("template"),Sh={insert:(t,e,s)=>{e.insertBefore(t,s||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,s,r)=>{const n=e==="svg"?jt.createElementNS(_h,t):e==="mathml"?jt.createElementNS(wh,t):s?jt.createElement(t,{is:s}):jt.createElement(t);return t==="select"&&r&&r.multiple!=null&&n.setAttribute("multiple",r.multiple),n},createText:t=>jt.createTextNode(t),createComment:t=>jt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>jt.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,s,r,n,i){const o=s?s.previousSibling:e.lastChild;if(n&&(n===i||n.nextSibling))for(;e.insertBefore(n.cloneNode(!0),s),!(n===i||!(n=n.nextSibling)););else{mo.innerHTML=Ll(r==="svg"?`<svg>${t}</svg>`:r==="mathml"?`<math>${t}</math>`:t);const a=mo.content;if(r==="svg"||r==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}e.insertBefore(a,s)}return[o?o.nextSibling:e.firstChild,s?s.previousSibling:e.lastChild]}},kh=Symbol("_vtc");function Eh(t,e,s){const r=t[kh];r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?t.removeAttribute("class"):s?t.setAttribute("class",e):t.className=e}const vo=Symbol("_vod"),xh=Symbol("_vsh"),Th=Symbol(""),Ah=/(?:^|;)\s*display\s*:/;function Rh(t,e,s){const r=t.style,n=Ee(s);let i=!1;if(s&&!n){if(e)if(Ee(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();s[a]==null&&Gs(r,a,"")}else for(const o in e)s[o]==null&&Gs(r,o,"");for(const o in s){o==="display"&&(i=!0);const a=s[o];a!=null?Ch(t,o,!Ee(e)&&e?e[o]:void 0,a)||Gs(r,o,a):Gs(r,o,"")}}else if(n){if(e!==s){const o=r[Th];o&&(s+=";"+o),r.cssText=s,i=Ah.test(s)}}else e&&t.removeAttribute("style");vo in t&&(t[vo]=i?r.display:"",t[xh]&&(r.display="none"))}const bo=/\s*!important$/;function Gs(t,e,s){if(ee(s))s.forEach(r=>Gs(t,e,r));else if(s==null&&(s=""),e.startsWith("--"))t.setProperty(e,s);else{const r=Oh(t,e);bo.test(s)?t.setProperty(ps(r),s.replace(bo,""),"important"):t[r]=s}}const _o=["Webkit","Moz","ms"],Bn={};function Oh(t,e){const s=Bn[e];if(s)return s;let r=ft(e);if(r!=="filter"&&r in t)return Bn[e]=r;r=Ca(r);for(let n=0;n<_o.length;n++){const i=_o[n]+r;if(i in t)return Bn[e]=i}return e}function Ch(t,e,s,r){return t.tagName==="TEXTAREA"&&(e==="width"||e==="height")&&Ee(r)&&s===r}const wo="http://www.w3.org/1999/xlink";function So(t,e,s,r,n,i=Nc(e)){r&&e.startsWith("xlink:")?s==null?t.removeAttributeNS(wo,e.slice(6,e.length)):t.setAttributeNS(wo,e,s):s==null||i&&!Ia(s)?t.removeAttribute(e):t.setAttribute(e,i?"":ct(s)?String(s):s)}function ko(t,e,s,r,n){if(e==="innerHTML"||e==="textContent"){s!=null&&(t[e]=e==="innerHTML"?Ll(s):s);return}const i=t.tagName;if(e==="value"&&i!=="PROGRESS"&&!i.includes("-")){const a=i==="OPTION"?t.getAttribute("value")||"":t.value,l=s==null?t.type==="checkbox"?"on":"":String(s);(a!==l||!("_value"in t))&&(t.value=l),s==null&&t.removeAttribute(e),t._value=s;return}let o=!1;if(s===""||s==null){const a=typeof t[e];a==="boolean"?s=Ia(s):s==null&&a==="string"?(s="",o=!0):a==="number"&&(s=0,o=!0)}try{t[e]=s}catch{}o&&t.removeAttribute(n||e)}function ls(t,e,s,r){t.addEventListener(e,s,r)}function Ph(t,e,s,r){t.removeEventListener(e,s,r)}const Eo=Symbol("_vei");function Ih(t,e,s,r,n=null){const i=t[Eo]||(t[Eo]={}),o=i[e];if(r&&o)o.value=r;else{const[a,l]=jh(e);if(r){const c=i[e]=Lh(r,n);ls(t,a,c,l)}else o&&(Ph(t,a,o,l),i[e]=void 0)}}const xo=/(?:Once|Passive|Capture)$/;function jh(t){let e;if(xo.test(t)){e={};let r;for(;r=t.match(xo);)t=t.slice(0,t.length-r[0].length),e[r[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):ps(t.slice(2)),e]}let Mn=0;const $h=Promise.resolve(),Nh=()=>Mn||($h.then(()=>Mn=0),Mn=Date.now());function Lh(t,e){const s=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=s.attached)return;Ot(Uh(r,s.value),e,5,[r])};return s.value=t,s.attached=Nh(),s}function Uh(t,e){if(ee(e)){const s=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{s.call(t),t._stopped=!0},e.map(r=>n=>!n._stopped&&r&&r(n))}else return e}const To=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Dh=(t,e,s,r,n,i)=>{const o=n==="svg";e==="class"?Eh(t,r,o):e==="style"?Rh(t,s,r):un(e)?hn(e)||Ih(t,e,s,r,i):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Bh(t,e,r,o))?(ko(t,e,r),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&So(t,e,r,o,i,e!=="value")):t._isVueCE&&(Mh(t,e)||t._def.__asyncLoader&&(/[A-Z]/.test(e)||!Ee(r)))?ko(t,ft(e),r,i,e):(e==="true-value"?t._trueValue=r:e==="false-value"&&(t._falseValue=r),So(t,e,r,o))};function Bh(t,e,s,r){if(r)return!!(e==="innerHTML"||e==="textContent"||e in t&&To(e)&&ae(s));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const n=t.tagName;if(n==="IMG"||n==="VIDEO"||n==="CANVAS"||n==="SOURCE")return!1}return To(e)&&Ee(s)?!1:e in t}function Mh(t,e){const s=t._def.props;if(!s)return!1;const r=ft(e);return Array.isArray(s)?s.some(n=>ft(n)===r):Object.keys(s).some(n=>ft(n)===r)}const sn=t=>{const e=t.props["onUpdate:modelValue"]||!1;return ee(e)?s=>qr(e,s):e};function Hh(t){t.target.composing=!0}function Ao(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Is=Symbol("_assign");function Ro(t,e,s){return e&&(t=t.trim()),s&&(t=Ri(t)),t}const js={created(t,{modifiers:{lazy:e,trim:s,number:r}},n){t[Is]=sn(n);const i=r||n.props&&n.props.type==="number";ls(t,e?"change":"input",o=>{o.target.composing||t[Is](Ro(t.value,s,i))}),(s||i)&&ls(t,"change",()=>{t.value=Ro(t.value,s,i)}),e||(ls(t,"compositionstart",Hh),ls(t,"compositionend",Ao),ls(t,"change",Ao))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:s,modifiers:{lazy:r,trim:n,number:i}},o){if(t[Is]=sn(o),t.composing)return;const a=(i||t.type==="number")&&!/^0\d/.test(t.value)?Ri(t.value):t.value,l=e??"";if(a===l)return;const c=t.getRootNode();(c instanceof Document||c instanceof ShadowRoot)&&c.activeElement===t&&t.type!=="range"&&(r&&e===s||n&&t.value.trim()===l)||(t.value=l)}},Fh={deep:!0,created(t,e,s){t[Is]=sn(s),ls(t,"change",()=>{const r=t._modelValue,n=qh(t),i=t.checked,o=t[Is];if(ee(r)){const a=ja(r,n),l=a!==-1;if(i&&!l)o(r.concat(n));else if(!i&&l){const c=[...r];c.splice(a,1),o(c)}}else if(dn(r)){const a=new Set(r);i?a.add(n):a.delete(n),o(a)}else o(Ul(t,i))})},mounted:Oo,beforeUpdate(t,e,s){t[Is]=sn(s),Oo(t,e,s)}};function Oo(t,{value:e,oldValue:s},r){t._modelValue=e;let n;if(ee(e))n=ja(e,r.props.value)>-1;else if(dn(e))n=e.has(r.props.value);else{if(e===s)return;n=Er(e,Ul(t,!0))}t.checked!==n&&(t.checked=n)}function qh(t){return"_value"in t?t._value:t.value}function Ul(t,e){const s=e?"_trueValue":"_falseValue";return s in t?t[s]:e}const Vh=["ctrl","shift","alt","meta"],Kh={stop:t=>t.stopPropagation(),prevent:t=>t.preventDefault(),self:t=>t.target!==t.currentTarget,ctrl:t=>!t.ctrlKey,shift:t=>!t.shiftKey,alt:t=>!t.altKey,meta:t=>!t.metaKey,left:t=>"button"in t&&t.button!==0,middle:t=>"button"in t&&t.button!==1,right:t=>"button"in t&&t.button!==2,exact:(t,e)=>Vh.some(s=>t[`${s}Key`]&&!e.includes(s))},pr=(t,e)=>{if(!t)return t;const s=t._withMods||(t._withMods={}),r=e.join(".");return s[r]||(s[r]=(n,...i)=>{for(let o=0;o<e.length;o++){const a=Kh[e[o]];if(a&&a(n,e))return}return t(n,...i)})},Wh=He({patchProp:Dh},Sh);let Co;function Gh(){return Co||(Co=th(Wh))}const Jh=(...t)=>{const e=Gh().createApp(...t),{mount:s}=e;return e.mount=r=>{const n=Yh(r);if(!n)return;const i=e._component;!ae(i)&&!i.render&&!i.template&&(i.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const o=s(n,!1,zh(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),o},e};function zh(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function Yh(t){return Ee(t)?document.querySelector(t):t}/*!
18
+ * pinia v2.3.1
19
+ * (c) 2025 Eduardo San Martin Morote
20
+ * @license MIT
21
+ */let Dl;const En=t=>Dl=t,Bl=Symbol();function ai(t){return t&&typeof t=="object"&&Object.prototype.toString.call(t)==="[object Object]"&&typeof t.toJSON!="function"}var nr;(function(t){t.direct="direct",t.patchObject="patch object",t.patchFunction="patch function"})(nr||(nr={}));function Xh(){const t=Ua(!0),e=t.run(()=>ie({}));let s=[],r=[];const n=Li({install(i){En(n),n._a=i,i.provide(Bl,n),i.config.globalProperties.$pinia=n,r.forEach(o=>s.push(o)),r=[]},use(i){return this._a?s.push(i):r.push(i),this},_p:s,_a:null,_e:t,_s:new Map,state:e});return n}const Ml=()=>{};function Po(t,e,s,r=Ml){t.push(e);const n=()=>{const i=t.indexOf(e);i>-1&&(t.splice(i,1),r())};return!s&&Da()&&Uc(n),n}function ys(t,...e){t.slice().forEach(s=>{s(...e)})}const Qh=t=>t(),Io=Symbol(),Hn=Symbol();function li(t,e){t instanceof Map&&e instanceof Map?e.forEach((s,r)=>t.set(r,s)):t instanceof Set&&e instanceof Set&&e.forEach(t.add,t);for(const s in e){if(!e.hasOwnProperty(s))continue;const r=e[s],n=t[s];ai(n)&&ai(r)&&t.hasOwnProperty(s)&&!xe(r)&&!Mt(r)?t[s]=li(n,r):t[s]=r}return t}const Zh=Symbol();function ed(t){return!ai(t)||!t.hasOwnProperty(Zh)}const{assign:Jt}=Object;function td(t){return!!(xe(t)&&t.effect)}function sd(t,e,s,r){const{state:n,actions:i,getters:o}=e,a=s.state.value[t];let l;function c(){a||(s.state.value[t]=n?n():{});const u=ou(s.state.value[t]);return Jt(u,i,Object.keys(o||{}).reduce((h,d)=>(h[d]=Li(Ge(()=>{En(s);const f=s._s.get(t);return o[d].call(f,f)})),h),{}))}return l=Hl(t,c,e,s,r,!0),l}function Hl(t,e,s={},r,n,i){let o;const a=Jt({actions:{}},s),l={deep:!0};let c,u,h=[],d=[],f;const y=r.state.value[t];!i&&!y&&(r.state.value[t]={});let v;function T(te){let X;c=u=!1,typeof te=="function"?(te(r.state.value[t]),X={type:nr.patchFunction,storeId:t,events:f}):(li(r.state.value[t],te),X={type:nr.patchObject,payload:te,storeId:t,events:f});const oe=v=Symbol();Tr().then(()=>{v===oe&&(c=!0)}),u=!0,ys(h,X,r.state.value[t])}const A=i?function(){const{state:X}=s,oe=X?X():{};this.$patch(Oe=>{Jt(Oe,oe)})}:Ml;function _(){o.stop(),h=[],d=[],r._s.delete(t)}const w=(te,X="")=>{if(Io in te)return te[Hn]=X,te;const oe=function(){En(r);const Oe=Array.from(arguments),Le=[],Te=[];function Qe(se){Le.push(se)}function Ze(se){Te.push(se)}ys(d,{args:Oe,name:oe[Hn],store:W,after:Qe,onError:Ze});let pe;try{pe=te.apply(this&&this.$id===t?this:W,Oe)}catch(se){throw ys(Te,se),se}return pe instanceof Promise?pe.then(se=>(ys(Le,se),se)).catch(se=>(ys(Te,se),Promise.reject(se))):(ys(Le,pe),pe)};return oe[Io]=!0,oe[Hn]=X,oe},C={_p:r,$id:t,$onAction:Po.bind(null,d),$patch:T,$reset:A,$subscribe(te,X={}){const oe=Po(h,te,X.detached,()=>Oe()),Oe=o.run(()=>Zt(()=>r.state.value[t],Le=>{(X.flush==="sync"?u:c)&&te({storeId:t,type:nr.direct,events:f},Le)},Jt({},l,X)));return oe},$dispose:_},W=Bt(C);r._s.set(t,W);const Y=(r._a&&r._a.runWithContext||Qh)(()=>r._e.run(()=>(o=Ua()).run(()=>e({action:w}))));for(const te in Y){const X=Y[te];if(xe(X)&&!td(X)||Mt(X))i||(y&&ed(X)&&(xe(X)?X.value=y[te]:li(X,y[te])),r.state.value[t][te]=X);else if(typeof X=="function"){const oe=w(X,te);Y[te]=oe,a.actions[te]=X}}return Jt(W,Y),Jt(ue(W),Y),Object.defineProperty(W,"$state",{get:()=>r.state.value[t],set:te=>{T(X=>{Jt(X,te)})}}),r._p.forEach(te=>{Jt(W,o.run(()=>te({store:W,app:r._a,pinia:r,options:a})))}),y&&i&&s.hydrate&&s.hydrate(W.$state,y),c=!0,u=!0,W}/*! #__NO_SIDE_EFFECTS__ */function Fl(t,e,s){let r,n;const i=typeof e=="function";typeof t=="string"?(r=t,n=i?s:e):(n=t,r=t.id);function o(a,l){const c=yu();return a=a||(c?lt(Bl,null):null),a&&En(a),a=Dl,a._s.has(r)||(i?Hl(r,e,n,a):sd(r,n,a)),a._s.get(r)}return o.$id=r,o}/*!
22
+ * vue-router v4.6.4
23
+ * (c) 2025 Eduardo San Martin Morote
24
+ * @license MIT
25
+ */const ks=typeof document<"u";function ql(t){return typeof t=="object"||"displayName"in t||"props"in t||"__vccOpts"in t}function rd(t){return t.__esModule||t[Symbol.toStringTag]==="Module"||t.default&&ql(t.default)}const he=Object.assign;function Fn(t,e){const s={};for(const r in e){const n=e[r];s[r]=yt(n)?n.map(t):t(n)}return s}const ir=()=>{},yt=Array.isArray;function jo(t,e){const s={};for(const r in t)s[r]=r in e?e[r]:t[r];return s}const Vl=/#/g,nd=/&/g,id=/\//g,od=/=/g,ad=/\?/g,Kl=/\+/g,ld=/%5B/g,cd=/%5D/g,Wl=/%5E/g,ud=/%60/g,Gl=/%7B/g,hd=/%7C/g,Jl=/%7D/g,dd=/%20/g;function qi(t){return t==null?"":encodeURI(""+t).replace(hd,"|").replace(ld,"[").replace(cd,"]")}function fd(t){return qi(t).replace(Gl,"{").replace(Jl,"}").replace(Wl,"^")}function ci(t){return qi(t).replace(Kl,"%2B").replace(dd,"+").replace(Vl,"%23").replace(nd,"%26").replace(ud,"`").replace(Gl,"{").replace(Jl,"}").replace(Wl,"^")}function pd(t){return ci(t).replace(od,"%3D")}function gd(t){return qi(t).replace(Vl,"%23").replace(ad,"%3F")}function yd(t){return gd(t).replace(id,"%2F")}function gr(t){if(t==null)return null;try{return decodeURIComponent(""+t)}catch{}return""+t}const md=/\/$/,vd=t=>t.replace(md,"");function qn(t,e,s="/"){let r,n={},i="",o="";const a=e.indexOf("#");let l=e.indexOf("?");return l=a>=0&&l>a?-1:l,l>=0&&(r=e.slice(0,l),i=e.slice(l,a>0?a:e.length),n=t(i.slice(1))),a>=0&&(r=r||e.slice(0,a),o=e.slice(a,e.length)),r=Sd(r??e,s),{fullPath:r+i+o,path:r,query:n,hash:gr(o)}}function bd(t,e){const s=e.query?t(e.query):"";return e.path+(s&&"?")+s+(e.hash||"")}function $o(t,e){return!e||!t.toLowerCase().startsWith(e.toLowerCase())?t:t.slice(e.length)||"/"}function _d(t,e,s){const r=e.matched.length-1,n=s.matched.length-1;return r>-1&&r===n&&Us(e.matched[r],s.matched[n])&&zl(e.params,s.params)&&t(e.query)===t(s.query)&&e.hash===s.hash}function Us(t,e){return(t.aliasOf||t)===(e.aliasOf||e)}function zl(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(var s in t)if(!wd(t[s],e[s]))return!1;return!0}function wd(t,e){return yt(t)?No(t,e):yt(e)?No(e,t):(t==null?void 0:t.valueOf())===(e==null?void 0:e.valueOf())}function No(t,e){return yt(e)?t.length===e.length&&t.every((s,r)=>s===e[r]):t.length===1&&t[0]===e}function Sd(t,e){if(t.startsWith("/"))return t;if(!t)return e;const s=e.split("/"),r=t.split("/"),n=r[r.length-1];(n===".."||n===".")&&r.push("");let i=s.length-1,o,a;for(o=0;o<r.length;o++)if(a=r[o],a!==".")if(a==="..")i>1&&i--;else break;return s.slice(0,i).join("/")+"/"+r.slice(o).join("/")}const Gt={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};let ui=function(t){return t.pop="pop",t.push="push",t}({}),Vn=function(t){return t.back="back",t.forward="forward",t.unknown="",t}({});function kd(t){if(!t)if(ks){const e=document.querySelector("base");t=e&&e.getAttribute("href")||"/",t=t.replace(/^\w+:\/\/[^\/]+/,"")}else t="/";return t[0]!=="/"&&t[0]!=="#"&&(t="/"+t),vd(t)}const Ed=/^[^#]+#/;function xd(t,e){return t.replace(Ed,"#")+e}function Td(t,e){const s=document.documentElement.getBoundingClientRect(),r=t.getBoundingClientRect();return{behavior:e.behavior,left:r.left-s.left-(e.left||0),top:r.top-s.top-(e.top||0)}}const xn=()=>({left:window.scrollX,top:window.scrollY});function Ad(t){let e;if("el"in t){const s=t.el,r=typeof s=="string"&&s.startsWith("#"),n=typeof s=="string"?r?document.getElementById(s.slice(1)):document.querySelector(s):s;if(!n)return;e=Td(n,t)}else e=t;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(e.left!=null?e.left:window.scrollX,e.top!=null?e.top:window.scrollY)}function Lo(t,e){return(history.state?history.state.position-e:-1)+t}const hi=new Map;function Rd(t,e){hi.set(t,e)}function Od(t){const e=hi.get(t);return hi.delete(t),e}function Cd(t){return typeof t=="string"||t&&typeof t=="object"}function Yl(t){return typeof t=="string"||typeof t=="symbol"}let Se=function(t){return t[t.MATCHER_NOT_FOUND=1]="MATCHER_NOT_FOUND",t[t.NAVIGATION_GUARD_REDIRECT=2]="NAVIGATION_GUARD_REDIRECT",t[t.NAVIGATION_ABORTED=4]="NAVIGATION_ABORTED",t[t.NAVIGATION_CANCELLED=8]="NAVIGATION_CANCELLED",t[t.NAVIGATION_DUPLICATED=16]="NAVIGATION_DUPLICATED",t}({});const Xl=Symbol("");Se.MATCHER_NOT_FOUND+"",Se.NAVIGATION_GUARD_REDIRECT+"",Se.NAVIGATION_ABORTED+"",Se.NAVIGATION_CANCELLED+"",Se.NAVIGATION_DUPLICATED+"";function Ds(t,e){return he(new Error,{type:t,[Xl]:!0},e)}function Pt(t,e){return t instanceof Error&&Xl in t&&(e==null||!!(t.type&e))}const Pd=["params","query","hash"];function Id(t){if(typeof t=="string")return t;if(t.path!=null)return t.path;const e={};for(const s of Pd)s in t&&(e[s]=t[s]);return JSON.stringify(e,null,2)}function jd(t){const e={};if(t===""||t==="?")return e;const s=(t[0]==="?"?t.slice(1):t).split("&");for(let r=0;r<s.length;++r){const n=s[r].replace(Kl," "),i=n.indexOf("="),o=gr(i<0?n:n.slice(0,i)),a=i<0?null:gr(n.slice(i+1));if(o in e){let l=e[o];yt(l)||(l=e[o]=[l]),l.push(a)}else e[o]=a}return e}function Uo(t){let e="";for(let s in t){const r=t[s];if(s=pd(s),r==null){r!==void 0&&(e+=(e.length?"&":"")+s);continue}(yt(r)?r.map(n=>n&&ci(n)):[r&&ci(r)]).forEach(n=>{n!==void 0&&(e+=(e.length?"&":"")+s,n!=null&&(e+="="+n))})}return e}function $d(t){const e={};for(const s in t){const r=t[s];r!==void 0&&(e[s]=yt(r)?r.map(n=>n==null?null:""+n):r==null?r:""+r)}return e}const Nd=Symbol(""),Do=Symbol(""),Tn=Symbol(""),Vi=Symbol(""),di=Symbol("");function qs(){let t=[];function e(r){return t.push(r),()=>{const n=t.indexOf(r);n>-1&&t.splice(n,1)}}function s(){t=[]}return{add:e,list:()=>t.slice(),reset:s}}function Yt(t,e,s,r,n,i=o=>o()){const o=r&&(r.enterCallbacks[n]=r.enterCallbacks[n]||[]);return()=>new Promise((a,l)=>{const c=d=>{d===!1?l(Ds(Se.NAVIGATION_ABORTED,{from:s,to:e})):d instanceof Error?l(d):Cd(d)?l(Ds(Se.NAVIGATION_GUARD_REDIRECT,{from:e,to:d})):(o&&r.enterCallbacks[n]===o&&typeof d=="function"&&o.push(d),a())},u=i(()=>t.call(r&&r.instances[n],e,s,c));let h=Promise.resolve(u);t.length<3&&(h=h.then(c)),h.catch(d=>l(d))})}function Kn(t,e,s,r,n=i=>i()){const i=[];for(const o of t)for(const a in o.components){let l=o.components[a];if(!(e!=="beforeRouteEnter"&&!o.instances[a]))if(ql(l)){const c=(l.__vccOpts||l)[e];c&&i.push(Yt(c,s,r,o,a,n))}else{let c=l();i.push(()=>c.then(u=>{if(!u)throw new Error(`Couldn't resolve component "${a}" at "${o.path}"`);const h=rd(u)?u.default:u;o.mods[a]=u,o.components[a]=h;const d=(h.__vccOpts||h)[e];return d&&Yt(d,s,r,o,a,n)()}))}}return i}function Ld(t,e){const s=[],r=[],n=[],i=Math.max(e.matched.length,t.matched.length);for(let o=0;o<i;o++){const a=e.matched[o];a&&(t.matched.find(c=>Us(c,a))?r.push(a):s.push(a));const l=t.matched[o];l&&(e.matched.find(c=>Us(c,l))||n.push(l))}return[s,r,n]}/*!
26
+ * vue-router v4.6.4
27
+ * (c) 2025 Eduardo San Martin Morote
28
+ * @license MIT
29
+ */let Ud=()=>location.protocol+"//"+location.host;function Ql(t,e){const{pathname:s,search:r,hash:n}=e,i=t.indexOf("#");if(i>-1){let o=n.includes(t.slice(i))?t.slice(i).length:1,a=n.slice(o);return a[0]!=="/"&&(a="/"+a),$o(a,"")}return $o(s,t)+r+n}function Dd(t,e,s,r){let n=[],i=[],o=null;const a=({state:d})=>{const f=Ql(t,location),y=s.value,v=e.value;let T=0;if(d){if(s.value=f,e.value=d,o&&o===y){o=null;return}T=v?d.position-v.position:0}else r(f);n.forEach(A=>{A(s.value,y,{delta:T,type:ui.pop,direction:T?T>0?Vn.forward:Vn.back:Vn.unknown})})};function l(){o=s.value}function c(d){n.push(d);const f=()=>{const y=n.indexOf(d);y>-1&&n.splice(y,1)};return i.push(f),f}function u(){if(document.visibilityState==="hidden"){const{history:d}=window;if(!d.state)return;d.replaceState(he({},d.state,{scroll:xn()}),"")}}function h(){for(const d of i)d();i=[],window.removeEventListener("popstate",a),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",a),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:l,listen:c,destroy:h}}function Bo(t,e,s,r=!1,n=!1){return{back:t,current:e,forward:s,replaced:r,position:window.history.length,scroll:n?xn():null}}function Bd(t){const{history:e,location:s}=window,r={value:Ql(t,s)},n={value:e.state};n.value||i(r.value,{back:null,current:r.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function i(l,c,u){const h=t.indexOf("#"),d=h>-1?(s.host&&document.querySelector("base")?t:t.slice(h))+l:Ud()+t+l;try{e[u?"replaceState":"pushState"](c,"",d),n.value=c}catch(f){console.error(f),s[u?"replace":"assign"](d)}}function o(l,c){i(l,he({},e.state,Bo(n.value.back,l,n.value.forward,!0),c,{position:n.value.position}),!0),r.value=l}function a(l,c){const u=he({},n.value,e.state,{forward:l,scroll:xn()});i(u.current,u,!0),i(l,he({},Bo(r.value,l,null),{position:u.position+1},c),!1),r.value=l}return{location:r,state:n,push:a,replace:o}}function Md(t){t=kd(t);const e=Bd(t),s=Dd(t,e.state,e.location,e.replace);function r(i,o=!0){o||s.pauseListeners(),history.go(i)}const n=he({location:"",base:t,go:r,createHref:xd.bind(null,t)},e,s);return Object.defineProperty(n,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(n,"state",{enumerable:!0,get:()=>e.state.value}),n}let cs=function(t){return t[t.Static=0]="Static",t[t.Param=1]="Param",t[t.Group=2]="Group",t}({});var Ce=function(t){return t[t.Static=0]="Static",t[t.Param=1]="Param",t[t.ParamRegExp=2]="ParamRegExp",t[t.ParamRegExpEnd=3]="ParamRegExpEnd",t[t.EscapeNext=4]="EscapeNext",t}(Ce||{});const Hd={type:cs.Static,value:""},Fd=/[a-zA-Z0-9_]/;function qd(t){if(!t)return[[]];if(t==="/")return[[Hd]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(f){throw new Error(`ERR (${s})/"${c}": ${f}`)}let s=Ce.Static,r=s;const n=[];let i;function o(){i&&n.push(i),i=[]}let a=0,l,c="",u="";function h(){c&&(s===Ce.Static?i.push({type:cs.Static,value:c}):s===Ce.Param||s===Ce.ParamRegExp||s===Ce.ParamRegExpEnd?(i.length>1&&(l==="*"||l==="+")&&e(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),i.push({type:cs.Param,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):e("Invalid state to consume buffer"),c="")}function d(){c+=l}for(;a<t.length;){if(l=t[a++],l==="\\"&&s!==Ce.ParamRegExp){r=s,s=Ce.EscapeNext;continue}switch(s){case Ce.Static:l==="/"?(c&&h(),o()):l===":"?(h(),s=Ce.Param):d();break;case Ce.EscapeNext:d(),s=r;break;case Ce.Param:l==="("?s=Ce.ParamRegExp:Fd.test(l)?d():(h(),s=Ce.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--);break;case Ce.ParamRegExp:l===")"?u[u.length-1]=="\\"?u=u.slice(0,-1)+l:s=Ce.ParamRegExpEnd:u+=l;break;case Ce.ParamRegExpEnd:h(),s=Ce.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--,u="";break;default:e("Unknown state");break}}return s===Ce.ParamRegExp&&e(`Unfinished custom RegExp for param "${c}"`),h(),o(),n}const Mo="[^/]+?",Vd={sensitive:!1,strict:!1,start:!0,end:!0};var Ve=function(t){return t[t._multiplier=10]="_multiplier",t[t.Root=90]="Root",t[t.Segment=40]="Segment",t[t.SubSegment=30]="SubSegment",t[t.Static=40]="Static",t[t.Dynamic=20]="Dynamic",t[t.BonusCustomRegExp=10]="BonusCustomRegExp",t[t.BonusWildcard=-50]="BonusWildcard",t[t.BonusRepeatable=-20]="BonusRepeatable",t[t.BonusOptional=-8]="BonusOptional",t[t.BonusStrict=.7000000000000001]="BonusStrict",t[t.BonusCaseSensitive=.25]="BonusCaseSensitive",t}(Ve||{});const Kd=/[.+*?^${}()[\]/\\]/g;function Wd(t,e){const s=he({},Vd,e),r=[];let n=s.start?"^":"";const i=[];for(const c of t){const u=c.length?[]:[Ve.Root];s.strict&&!c.length&&(n+="/");for(let h=0;h<c.length;h++){const d=c[h];let f=Ve.Segment+(s.sensitive?Ve.BonusCaseSensitive:0);if(d.type===cs.Static)h||(n+="/"),n+=d.value.replace(Kd,"\\$&"),f+=Ve.Static;else if(d.type===cs.Param){const{value:y,repeatable:v,optional:T,regexp:A}=d;i.push({name:y,repeatable:v,optional:T});const _=A||Mo;if(_!==Mo){f+=Ve.BonusCustomRegExp;try{`${_}`}catch(C){throw new Error(`Invalid custom RegExp for param "${y}" (${_}): `+C.message)}}let w=v?`((?:${_})(?:/(?:${_}))*)`:`(${_})`;h||(w=T&&c.length<2?`(?:/${w})`:"/"+w),T&&(w+="?"),n+=w,f+=Ve.Dynamic,T&&(f+=Ve.BonusOptional),v&&(f+=Ve.BonusRepeatable),_===".*"&&(f+=Ve.BonusWildcard)}u.push(f)}r.push(u)}if(s.strict&&s.end){const c=r.length-1;r[c][r[c].length-1]+=Ve.BonusStrict}s.strict||(n+="/?"),s.end?n+="$":s.strict&&!n.endsWith("/")&&(n+="(?:/|$)");const o=new RegExp(n,s.sensitive?"":"i");function a(c){const u=c.match(o),h={};if(!u)return null;for(let d=1;d<u.length;d++){const f=u[d]||"",y=i[d-1];h[y.name]=f&&y.repeatable?f.split("/"):f}return h}function l(c){let u="",h=!1;for(const d of t){(!h||!u.endsWith("/"))&&(u+="/"),h=!1;for(const f of d)if(f.type===cs.Static)u+=f.value;else if(f.type===cs.Param){const{value:y,repeatable:v,optional:T}=f,A=y in c?c[y]:"";if(yt(A)&&!v)throw new Error(`Provided param "${y}" is an array but it is not repeatable (* or + modifiers)`);const _=yt(A)?A.join("/"):A;if(!_)if(T)d.length<2&&(u.endsWith("/")?u=u.slice(0,-1):h=!0);else throw new Error(`Missing required param "${y}"`);u+=_}}return u||"/"}return{re:o,score:r,keys:i,parse:a,stringify:l}}function Gd(t,e){let s=0;for(;s<t.length&&s<e.length;){const r=e[s]-t[s];if(r)return r;s++}return t.length<e.length?t.length===1&&t[0]===Ve.Static+Ve.Segment?-1:1:t.length>e.length?e.length===1&&e[0]===Ve.Static+Ve.Segment?1:-1:0}function Zl(t,e){let s=0;const r=t.score,n=e.score;for(;s<r.length&&s<n.length;){const i=Gd(r[s],n[s]);if(i)return i;s++}if(Math.abs(n.length-r.length)===1){if(Ho(r))return 1;if(Ho(n))return-1}return n.length-r.length}function Ho(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const Jd={strict:!1,end:!0,sensitive:!1};function zd(t,e,s){const r=Wd(qd(t.path),s),n=he(r,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function Yd(t,e){const s=[],r=new Map;e=jo(Jd,e);function n(h){return r.get(h)}function i(h,d,f){const y=!f,v=qo(h);v.aliasOf=f&&f.record;const T=jo(e,h),A=[v];if("alias"in h){const C=typeof h.alias=="string"?[h.alias]:h.alias;for(const W of C)A.push(qo(he({},v,{components:f?f.record.components:v.components,path:W,aliasOf:f?f.record:v})))}let _,w;for(const C of A){const{path:W}=C;if(d&&W[0]!=="/"){const re=d.record.path,Y=re[re.length-1]==="/"?"":"/";C.path=d.record.path+(W&&Y+W)}if(_=zd(C,d,T),f?f.alias.push(_):(w=w||_,w!==_&&w.alias.push(_),y&&h.name&&!Vo(_)&&o(h.name)),ec(_)&&l(_),v.children){const re=v.children;for(let Y=0;Y<re.length;Y++)i(re[Y],_,f&&f.children[Y])}f=f||_}return w?()=>{o(w)}:ir}function o(h){if(Yl(h)){const d=r.get(h);d&&(r.delete(h),s.splice(s.indexOf(d),1),d.children.forEach(o),d.alias.forEach(o))}else{const d=s.indexOf(h);d>-1&&(s.splice(d,1),h.record.name&&r.delete(h.record.name),h.children.forEach(o),h.alias.forEach(o))}}function a(){return s}function l(h){const d=Zd(h,s);s.splice(d,0,h),h.record.name&&!Vo(h)&&r.set(h.record.name,h)}function c(h,d){let f,y={},v,T;if("name"in h&&h.name){if(f=r.get(h.name),!f)throw Ds(Se.MATCHER_NOT_FOUND,{location:h});T=f.record.name,y=he(Fo(d.params,f.keys.filter(w=>!w.optional).concat(f.parent?f.parent.keys.filter(w=>w.optional):[]).map(w=>w.name)),h.params&&Fo(h.params,f.keys.map(w=>w.name))),v=f.stringify(y)}else if(h.path!=null)v=h.path,f=s.find(w=>w.re.test(v)),f&&(y=f.parse(v),T=f.record.name);else{if(f=d.name?r.get(d.name):s.find(w=>w.re.test(d.path)),!f)throw Ds(Se.MATCHER_NOT_FOUND,{location:h,currentLocation:d});T=f.record.name,y=he({},d.params,h.params),v=f.stringify(y)}const A=[];let _=f;for(;_;)A.unshift(_.record),_=_.parent;return{name:T,path:v,params:y,matched:A,meta:Qd(A)}}t.forEach(h=>i(h));function u(){s.length=0,r.clear()}return{addRoute:i,resolve:c,removeRoute:o,clearRoutes:u,getRoutes:a,getRecordMatcher:n}}function Fo(t,e){const s={};for(const r of e)r in t&&(s[r]=t[r]);return s}function qo(t){const e={path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:t.aliasOf,beforeEnter:t.beforeEnter,props:Xd(t),children:t.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in t?t.components||null:t.component&&{default:t.component}};return Object.defineProperty(e,"mods",{value:{}}),e}function Xd(t){const e={},s=t.props||!1;if("component"in t)e.default=s;else for(const r in t.components)e[r]=typeof s=="object"?s[r]:s;return e}function Vo(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function Qd(t){return t.reduce((e,s)=>he(e,s.meta),{})}function Zd(t,e){let s=0,r=e.length;for(;s!==r;){const i=s+r>>1;Zl(t,e[i])<0?r=i:s=i+1}const n=ef(t);return n&&(r=e.lastIndexOf(n,r-1)),r}function ef(t){let e=t;for(;e=e.parent;)if(ec(e)&&Zl(t,e)===0)return e}function ec({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function Ko(t){const e=lt(Tn),s=lt(Vi),r=Ge(()=>{const l=me(t.to);return e.resolve(l)}),n=Ge(()=>{const{matched:l}=r.value,{length:c}=l,u=l[c-1],h=s.matched;if(!u||!h.length)return-1;const d=h.findIndex(Us.bind(null,u));if(d>-1)return d;const f=Wo(l[c-2]);return c>1&&Wo(u)===f&&h[h.length-1].path!==f?h.findIndex(Us.bind(null,l[c-2])):d}),i=Ge(()=>n.value>-1&&nf(s.params,r.value.params)),o=Ge(()=>n.value>-1&&n.value===s.matched.length-1&&zl(s.params,r.value.params));function a(l={}){if(rf(l)){const c=e[me(t.replace)?"replace":"push"](me(t.to)).catch(ir);return t.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:r,href:Ge(()=>r.value.href),isActive:i,isExactActive:o,navigate:a}}function tf(t){return t.length===1?t[0]:t}const sf=Vt({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:Ko,setup(t,{slots:e}){const s=Bt(Ko(t)),{options:r}=lt(Tn),n=Ge(()=>({[Go(t.activeClass,r.linkActiveClass,"router-link-active")]:s.isActive,[Go(t.exactActiveClass,r.linkExactActiveClass,"router-link-exact-active")]:s.isExactActive}));return()=>{const i=e.default&&tf(e.default(s));return t.custom?i:Nl("a",{"aria-current":s.isExactActive?t.ariaCurrentValue:null,href:s.href,onClick:s.navigate,class:n.value},i)}}}),Js=sf;function rf(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function nf(t,e){for(const s in e){const r=e[s],n=t[s];if(typeof r=="string"){if(r!==n)return!1}else if(!yt(n)||n.length!==r.length||r.some((i,o)=>i.valueOf()!==n[o].valueOf()))return!1}return!0}function Wo(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const Go=(t,e,s)=>t??e??s,of=Vt({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:s}){const r=lt(di),n=Ge(()=>t.route||r.value),i=lt(Do,0),o=Ge(()=>{let c=me(i);const{matched:u}=n.value;let h;for(;(h=u[c])&&!h.components;)c++;return c}),a=Ge(()=>n.value.matched[o.value]);Vr(Do,Ge(()=>o.value+1)),Vr(Nd,a),Vr(di,n);const l=ie();return Zt(()=>[l.value,a.value,t.name],([c,u,h],[d,f,y])=>{u&&(u.instances[h]=c,f&&f!==u&&c&&c===d&&(u.leaveGuards.size||(u.leaveGuards=f.leaveGuards),u.updateGuards.size||(u.updateGuards=f.updateGuards))),c&&u&&(!f||!Us(u,f)||!d)&&(u.enterCallbacks[h]||[]).forEach(v=>v(c))},{flush:"post"}),()=>{const c=n.value,u=t.name,h=a.value,d=h&&h.components[u];if(!d)return Jo(s.default,{Component:d,route:c});const f=h.props[u],y=f?f===!0?c.params:typeof f=="function"?f(c):f:null,T=Nl(d,he({},y,e,{onVnodeUnmounted:A=>{A.component.isUnmounted&&(h.instances[u]=null)},ref:l}));return Jo(s.default,{Component:T,route:c})||T}}});function Jo(t,e){if(!t)return null;const s=t(e);return s.length===1?s[0]:s}const tc=of;function af(t){const e=Yd(t.routes,t),s=t.parseQuery||jd,r=t.stringifyQuery||Uo,n=t.history,i=qs(),o=qs(),a=qs(),l=ru(Gt);let c=Gt;ks&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Fn.bind(null,k=>""+k),h=Fn.bind(null,yd),d=Fn.bind(null,gr);function f(k,V){let B,J;return Yl(k)?(B=e.getRecordMatcher(k),J=V):J=k,e.addRoute(J,B)}function y(k){const V=e.getRecordMatcher(k);V&&e.removeRoute(V)}function v(){return e.getRoutes().map(k=>k.record)}function T(k){return!!e.getRecordMatcher(k)}function A(k,V){if(V=he({},V||l.value),typeof k=="string"){const m=qn(s,k,V.path),S=e.resolve({path:m.path},V),R=n.createHref(m.fullPath);return he(m,S,{params:d(S.params),hash:gr(m.hash),redirectedFrom:void 0,href:R})}let B;if(k.path!=null)B=he({},k,{path:qn(s,k.path,V.path).path});else{const m=he({},k.params);for(const S in m)m[S]==null&&delete m[S];B=he({},k,{params:h(m)}),V.params=h(V.params)}const J=e.resolve(B,V),le=k.hash||"";J.params=u(d(J.params));const p=bd(r,he({},k,{hash:fd(le),path:J.path})),g=n.createHref(p);return he({fullPath:p,hash:le,query:r===Uo?$d(k.query):k.query||{}},J,{redirectedFrom:void 0,href:g})}function _(k){return typeof k=="string"?qn(s,k,l.value.path):he({},k)}function w(k,V){if(c!==k)return Ds(Se.NAVIGATION_CANCELLED,{from:V,to:k})}function C(k){return Y(k)}function W(k){return C(he(_(k),{replace:!0}))}function re(k,V){const B=k.matched[k.matched.length-1];if(B&&B.redirect){const{redirect:J}=B;let le=typeof J=="function"?J(k,V):J;return typeof le=="string"&&(le=le.includes("?")||le.includes("#")?le=_(le):{path:le},le.params={}),he({query:k.query,hash:k.hash,params:le.path!=null?{}:k.params},le)}}function Y(k,V){const B=c=A(k),J=l.value,le=k.state,p=k.force,g=k.replace===!0,m=re(B,J);if(m)return Y(he(_(m),{state:typeof m=="object"?he({},le,m.state):le,force:p,replace:g}),V||B);const S=B;S.redirectedFrom=V;let R;return!p&&_d(r,J,B)&&(R=Ds(Se.NAVIGATION_DUPLICATED,{to:S,from:J}),x(J,J,!0,!1)),(R?Promise.resolve(R):oe(S,J)).catch(E=>Pt(E)?Pt(E,Se.NAVIGATION_GUARD_REDIRECT)?E:q(E):I(E,S,J)).then(E=>{if(E){if(Pt(E,Se.NAVIGATION_GUARD_REDIRECT))return Y(he({replace:g},_(E.to),{state:typeof E.to=="object"?he({},le,E.to.state):le,force:p}),V||S)}else E=Le(S,J,!0,g,le);return Oe(S,J,E),E})}function te(k,V){const B=w(k,V);return B?Promise.reject(B):Promise.resolve()}function X(k){const V=Ue.values().next().value;return V&&typeof V.runWithContext=="function"?V.runWithContext(k):k()}function oe(k,V){let B;const[J,le,p]=Ld(k,V);B=Kn(J.reverse(),"beforeRouteLeave",k,V);for(const m of J)m.leaveGuards.forEach(S=>{B.push(Yt(S,k,V))});const g=te.bind(null,k,V);return B.push(g),Je(B).then(()=>{B=[];for(const m of i.list())B.push(Yt(m,k,V));return B.push(g),Je(B)}).then(()=>{B=Kn(le,"beforeRouteUpdate",k,V);for(const m of le)m.updateGuards.forEach(S=>{B.push(Yt(S,k,V))});return B.push(g),Je(B)}).then(()=>{B=[];for(const m of p)if(m.beforeEnter)if(yt(m.beforeEnter))for(const S of m.beforeEnter)B.push(Yt(S,k,V));else B.push(Yt(m.beforeEnter,k,V));return B.push(g),Je(B)}).then(()=>(k.matched.forEach(m=>m.enterCallbacks={}),B=Kn(p,"beforeRouteEnter",k,V,X),B.push(g),Je(B))).then(()=>{B=[];for(const m of o.list())B.push(Yt(m,k,V));return B.push(g),Je(B)}).catch(m=>Pt(m,Se.NAVIGATION_CANCELLED)?m:Promise.reject(m))}function Oe(k,V,B){a.list().forEach(J=>X(()=>J(k,V,B)))}function Le(k,V,B,J,le){const p=w(k,V);if(p)return p;const g=V===Gt,m=ks?history.state:{};B&&(J||g?n.replace(k.fullPath,he({scroll:g&&m&&m.scroll},le)):n.push(k.fullPath,le)),l.value=k,x(k,V,B,g),q()}let Te;function Qe(){Te||(Te=n.listen((k,V,B)=>{if(!et.listening)return;const J=A(k),le=re(J,et.currentRoute.value);if(le){Y(he(le,{replace:!0,force:!0}),J).catch(ir);return}c=J;const p=l.value;ks&&Rd(Lo(p.fullPath,B.delta),xn()),oe(J,p).catch(g=>Pt(g,Se.NAVIGATION_ABORTED|Se.NAVIGATION_CANCELLED)?g:Pt(g,Se.NAVIGATION_GUARD_REDIRECT)?(Y(he(_(g.to),{force:!0}),J).then(m=>{Pt(m,Se.NAVIGATION_ABORTED|Se.NAVIGATION_DUPLICATED)&&!B.delta&&B.type===ui.pop&&n.go(-1,!1)}).catch(ir),Promise.reject()):(B.delta&&n.go(-B.delta,!1),I(g,J,p))).then(g=>{g=g||Le(J,p,!1),g&&(B.delta&&!Pt(g,Se.NAVIGATION_CANCELLED)?n.go(-B.delta,!1):B.type===ui.pop&&Pt(g,Se.NAVIGATION_ABORTED|Se.NAVIGATION_DUPLICATED)&&n.go(-1,!1)),Oe(J,p,g)}).catch(ir)}))}let Ze=qs(),pe=qs(),se;function I(k,V,B){q(k);const J=pe.list();return J.length?J.forEach(le=>le(k,V,B)):console.error(k),Promise.reject(k)}function G(){return se&&l.value!==Gt?Promise.resolve():new Promise((k,V)=>{Ze.add([k,V])})}function q(k){return se||(se=!k,Qe(),Ze.list().forEach(([V,B])=>k?B(k):V()),Ze.reset()),k}function x(k,V,B,J){const{scrollBehavior:le}=t;if(!ks||!le)return Promise.resolve();const p=!B&&Od(Lo(k.fullPath,0))||(J||!B)&&history.state&&history.state.scroll||null;return Tr().then(()=>le(k,V,p)).then(g=>g&&Ad(g)).catch(g=>I(g,k,V))}const P=k=>n.go(k);let H;const Ue=new Set,et={currentRoute:l,listening:!0,addRoute:f,removeRoute:y,clearRoutes:e.clearRoutes,hasRoute:T,getRoutes:v,resolve:A,options:t,push:C,replace:W,go:P,back:()=>P(-1),forward:()=>P(1),beforeEach:i.add,beforeResolve:o.add,afterEach:a.add,onError:pe.add,isReady:G,install(k){k.component("RouterLink",Js),k.component("RouterView",tc),k.config.globalProperties.$router=et,Object.defineProperty(k.config.globalProperties,"$route",{enumerable:!0,get:()=>me(l)}),ks&&!H&&l.value===Gt&&(H=!0,C(n.location).catch(J=>{}));const V={};for(const J in Gt)Object.defineProperty(V,J,{get:()=>l.value[J],enumerable:!0});k.provide(Tn,et),k.provide(Vi,Za(V)),k.provide(di,l);const B=k.unmount;Ue.add(k),k.unmount=function(){Ue.delete(k),Ue.size<1&&(c=Gt,Te&&Te(),Te=null,l.value=Gt,H=!1,se=!1),B()}}};function Je(k){return k.reduce((V,B)=>V.then(()=>X(B)),Promise.resolve())}return et}function sc(){return lt(Tn)}function lf(t){return lt(Vi)}function An(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(s[r[n]]=t[r[n]]);return s}function cf(t,e,s,r){function n(i){return i instanceof s?i:new s(function(o){o(i)})}return new(s||(s=Promise))(function(i,o){function a(u){try{c(r.next(u))}catch(h){o(h)}}function l(u){try{c(r.throw(u))}catch(h){o(h)}}function c(u){u.done?i(u.value):n(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}const uf=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Ki extends Error{constructor(e,s="FunctionsError",r){super(e),this.name=s,this.context=r}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class hf extends Ki{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class zo extends Ki{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class Yo extends Ki{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var fi;(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"})(fi||(fi={}));class df{constructor(e,{headers:s={},customFetch:r,region:n=fi.Any}={}){this.url=e,this.headers=s,this.region=n,this.fetch=uf(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return cf(this,arguments,void 0,function*(s,r={}){var n;let i,o;try{const{headers:a,method:l,body:c,signal:u,timeout:h}=r;let d={},{region:f}=r;f||(f=this.region);const y=new URL(`${this.url}/${s}`);f&&f!=="any"&&(d["x-region"]=f,y.searchParams.set("forceFunctionRegion",f));let v;c&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(d["Content-Type"]="application/octet-stream",v=c):typeof c=="string"?(d["Content-Type"]="text/plain",v=c):typeof FormData<"u"&&c instanceof FormData?v=c:(d["Content-Type"]="application/json",v=JSON.stringify(c)):c&&typeof c!="string"&&!(typeof Blob<"u"&&c instanceof Blob)&&!(c instanceof ArrayBuffer)&&!(typeof FormData<"u"&&c instanceof FormData)?v=JSON.stringify(c):v=c;let T=u;h&&(o=new AbortController,i=setTimeout(()=>o.abort(),h),u?(T=o.signal,u.addEventListener("abort",()=>o.abort())):T=o.signal);const A=yield this.fetch(y.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},d),this.headers),a),body:v,signal:T}).catch(W=>{throw new hf(W)}),_=A.headers.get("x-relay-error");if(_&&_==="true")throw new zo(A);if(!A.ok)throw new Yo(A);let w=((n=A.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),C;return w==="application/json"?C=yield A.json():w==="application/octet-stream"||w==="application/pdf"?C=yield A.blob():w==="text/event-stream"?C=A:w==="multipart/form-data"?C=yield A.formData():C=yield A.text(),{data:C,error:null,response:A}}catch(a){return{data:null,error:a,response:a instanceof Yo||a instanceof zo?a.context:void 0}}finally{i&&clearTimeout(i)}})}}const rc=3,Xo=t=>Math.min(1e3*2**t,3e4),ff=[520,503],nc=["GET","HEAD","OPTIONS"];var pf=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function Qo(t,e){return new Promise(s=>{if(e!=null&&e.aborted){s();return}const r=setTimeout(()=>{e==null||e.removeEventListener("abort",n),s()},t);function n(){clearTimeout(r),s()}e==null||e.addEventListener("abort",n)})}function gf(t,e,s,r){return!(!r||s>=rc||!nc.includes(t)||!ff.includes(e))}var yf=class{constructor(t){var e,s,r,n,i;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,this.shouldStripNulls=(r=t.shouldStripNulls)!==null&&r!==void 0?r:!1,this.urlLengthLimit=(n=t.urlLengthLimit)!==null&&n!==void 0?n:8e3,this.retryEnabled=(i=t.retry)!==null&&i!==void 0?i:!0,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}retry(t){return this.retryEnabled=t,this}then(t,e){var s=this;if(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"),this.shouldStripNulls){const o=this.headers.get("Accept");o==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!o||o==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const r=this.fetch;let i=(async()=>{let o=0;for(;;){const c=new Headers(s.headers);o>0&&c.set("X-Retry-Count",String(o));let u;try{u=await r(s.url.toString(),{method:s.method,headers:c,body:JSON.stringify(s.body,(h,d)=>typeof d=="bigint"?d.toString():d),signal:s.signal})}catch(h){if((h==null?void 0:h.name)==="AbortError"||(h==null?void 0:h.code)==="ABORT_ERR"||!nc.includes(s.method))throw h;if(s.retryEnabled&&o<rc){const d=Xo(o);o++,await Qo(d,s.signal);continue}throw h}if(gf(s.method,u.status,o,s.retryEnabled)){var a,l;const h=(a=(l=u.headers)===null||l===void 0?void 0:l.get("Retry-After"))!==null&&a!==void 0?a:null,d=h!==null?Math.max(0,parseInt(h,10)||0)*1e3:Xo(o);await u.text(),o++,await Qo(d,s.signal);continue}return await s.processResponse(u)}})();return this.shouldThrowOnError||(i=i.catch(o=>{var a;let l="",c="",u="";const h=o==null?void 0:o.cause;if(h){var d,f,y,v;const _=(d=h==null?void 0:h.message)!==null&&d!==void 0?d:"",w=(f=h==null?void 0:h.code)!==null&&f!==void 0?f:"";l=`${(y=o==null?void 0:o.name)!==null&&y!==void 0?y:"FetchError"}: ${o==null?void 0:o.message}`,l+=`
30
+
31
+ Caused by: ${(v=h==null?void 0:h.name)!==null&&v!==void 0?v:"Error"}: ${_}`,w&&(l+=` (${w})`),h!=null&&h.stack&&(l+=`
32
+ ${h.stack}`)}else{var T;l=(T=o==null?void 0:o.stack)!==null&&T!==void 0?T:""}const A=this.url.toString().length;return(o==null?void 0:o.name)==="AbortError"||(o==null?void 0:o.code)==="ABORT_ERR"?(u="",c="Request was aborted (timeout or manual cancellation)",A>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${A} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((h==null?void 0:h.name)==="HeadersOverflowError"||(h==null?void 0:h.code)==="UND_ERR_HEADERS_OVERFLOW")&&(u="",c="HTTP headers exceeded server limits (typically 16KB)",A>this.urlLengthLimit&&(c+=`. Your request URL is ${A} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(a=o==null?void 0:o.name)!==null&&a!==void 0?a:"FetchError"}: ${o==null?void 0:o.message}`,details:l,hint:c,code:u},data:null,count:null,status:0,statusText:""}})),i.then(t,e)}async processResponse(t){var e=this;let s=null,r=null,n=null,i=t.status,o=t.statusText;if(t.ok){var a,l;if(e.method!=="HEAD"){var c;const d=await t.text();d===""||(e.headers.get("Accept")==="text/csv"||e.headers.get("Accept")&&(!((c=e.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text"))?r=d:r=JSON.parse(d))}const u=(a=e.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),h=(l=t.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");u&&h&&h.length>1&&(n=parseInt(h[1])),e.isMaybeSingle&&Array.isArray(r)&&(r.length>1?(s={code:"PGRST116",details:`Results contain ${r.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},r=null,n=null,i=406,o="Not Acceptable"):r.length===1?r=r[0]:r=null)}else{const u=await t.text();try{s=JSON.parse(u),Array.isArray(s)&&t.status===404&&(r=[],s=null,i=200,o="OK")}catch{t.status===404&&u===""?(i=204,o="No Content"):s={message:u}}if(s&&e.shouldThrowOnError)throw new pf(s)}return{success:s===null,error:s,data:r,count:n,status:i,statusText:o}}returns(){return this}overrideTypes(){return this}},mf=class extends yf{select(t){let e=!1;const s=(t??"*").split("").map(r=>/\s/.test(r)&&!e?"":(r==='"'&&(e=!e),r)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:r,referencedTable:n=r}={}){const i=n?`${n}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){const r=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:r=s}={}){const n=typeof r>"u"?"offset":`${r}.offset`,i=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(i,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return 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:t=!1,verbose:e=!1,settings:s=!1,buffers:r=!1,wal:n=!1,format:i="text"}={}){var o;const a=[t?"analyze":null,e?"verbose":null,s?"settings":null,r?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${a};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const Zo=new RegExp("[,()]");var Es=class extends mf{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&Zo.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&Zo.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:s,type:r}={}){let n="";r==="plain"?n="pl":r==="phrase"?n="ph":r==="websearch"&&(n="w");const i=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${n}fts${i}.${e}`),this}match(t){return Object.entries(t).filter(([e,s])=>s!==void 0).forEach(([e,s])=>{this.url.searchParams.append(e,`eq.${s}`)}),this}not(t,e,s){return this.url.searchParams.append(t,`not.${e}.${s}`),this}or(t,{foreignTable:e,referencedTable:s=e}={}){const r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},vf=class{constructor(t,{headers:e={},schema:s,fetch:r,urlLengthLimit:n=8e3,retry:i}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=r,this.urlLengthLimit=n,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:s=!1,count:r}=e??{},n=s?"HEAD":"GET";let i=!1;const o=(t??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join(""),{url:a,headers:l}=this.cloneRequestState();return a.searchParams.set("select",o),r&&l.append("Prefer",`count=${r}`),new Es({method:n,url:a,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:s=!0}={}){var r;const n="POST",{url:i,headers:o}=this.cloneRequestState();if(e&&o.append("Prefer",`count=${e}`),s||o.append("Prefer","missing=default"),Array.isArray(t)){const a=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(a.length>0){const l=[...new Set(a)].map(c=>`"${c}"`);i.searchParams.set("columns",l.join(","))}}return new Es({method:n,url:i,headers:o,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:r,defaultToNull:n=!0}={}){var i;const o="POST",{url:a,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&a.searchParams.set("on_conflict",e),r&&l.append("Prefer",`count=${r}`),n||l.append("Prefer","missing=default"),Array.isArray(t)){const c=t.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(c.length>0){const u=[...new Set(c)].map(h=>`"${h}"`);a.searchParams.set("columns",u.join(","))}}return new Es({method:o,url:a,headers:l,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var s;const r="PATCH",{url:n,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new Es({method:r,url:n,headers:i,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var e;const s="DELETE",{url:r,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new Es({method:s,url:r,headers:n,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function yr(t){"@babel/helpers - typeof";return yr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yr(t)}function bf(t,e){if(yr(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(yr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function _f(t){var e=bf(t,"string");return yr(e)=="symbol"?e:e+""}function wf(t,e,s){return(e=_f(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function ea(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,r)}return s}function jr(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?ea(Object(s),!0).forEach(function(r){wf(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ea(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var Sf=class ic{constructor(e,{headers:s={},schema:r,fetch:n,timeout:i,urlLengthLimit:o=8e3,retry:a}={}){this.url=e,this.headers=new Headers(s),this.schemaName=r,this.urlLengthLimit=o;const l=n??globalThis.fetch;i!==void 0&&i>0?this.fetch=(c,u)=>{const h=new AbortController,d=setTimeout(()=>h.abort(),i),f=u==null?void 0:u.signal;if(f){if(f.aborted)return clearTimeout(d),l(c,u);const y=()=>{clearTimeout(d),h.abort()};return f.addEventListener("abort",y,{once:!0}),l(c,jr(jr({},u),{},{signal:h.signal})).finally(()=>{clearTimeout(d),f.removeEventListener("abort",y)})}return l(c,jr(jr({},u),{},{signal:h.signal})).finally(()=>clearTimeout(d))}:this.fetch=l,this.retry=a}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new vf(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(e){return new ic(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,s={},{head:r=!1,get:n=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let c;const u=f=>f!==null&&typeof f=="object"&&(!Array.isArray(f)||f.some(u)),h=r&&Object.values(s).some(u);h?(a="POST",c=s):r||n?(a=r?"HEAD":"GET",Object.entries(s).filter(([f,y])=>y!==void 0).map(([f,y])=>[f,Array.isArray(y)?`{${y.join(",")}}`:`${y}`]).forEach(([f,y])=>{l.searchParams.append(f,y)})):(a="POST",c=s);const d=new Headers(this.headers);return h?d.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&d.set("Prefer",`count=${i}`),new Es({method:a,url:l,headers:d,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class kf{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const s=globalThis;if(typeof globalThis<"u"&&typeof s.WebSocket<"u")return{type:"native",wsConstructor:s.WebSocket};const r=typeof global<"u"?global:void 0;if(r&&typeof r.WebSocket<"u")return{type:"native",wsConstructor:r.WebSocket};if(typeof globalThis<"u"&&typeof s.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"&&s.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."};const n=globalThis.process;if(n){const i=n.versions;if(i&&i.node){const o=i.node,a=parseInt(o.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
33
+ import ws from "ws"
34
+ 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.wsConstructor)return e.wsConstructor;let s=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(s+=`
35
+
36
+ Suggested solution: ${e.workaround}`),new Error(s)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const Ef="2.105.4",xf=`realtime-js/${Ef}`,Tf="1.0.0",oc="2.0.0",Af=oc,Rf=1e4,Of=100,Xt={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ac={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},pi={connecting:"connecting",closing:"closing",closed:"closed"};class Cf{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,s){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return s(this._binaryEncodeUserBroadcastPush(e));let r=[e.join_ref,e.ref,e.topic,e.event,e.payload];return s(JSON.stringify(r))}_binaryEncodeUserBroadcastPush(e){var s;return this._isArrayBuffer((s=e.payload)===null||s===void 0?void 0:s.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var s,r;const n=(r=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&r!==void 0?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var s,r;const n=(r=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&r!==void 0?r:{},o=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,o)}_encodeUserBroadcastPush(e,s,r){var n,i;const o=e.topic,a=(n=e.ref)!==null&&n!==void 0?n:"",l=(i=e.join_ref)!==null&&i!==void 0?i:"",c=e.payload.event,u=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=Object.keys(u).length===0?"":JSON.stringify(u);if(l.length>255)throw new Error(`joinRef length ${l.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`ref length ${a.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`topic length ${o.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`userEvent length ${c.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`metadata length ${h.length} exceeds maximum of 255`);const d=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+a.length+o.length+c.length+h.length,f=new ArrayBuffer(this.HEADER_LENGTH+d);let y=new DataView(f),v=0;y.setUint8(v++,this.KINDS.userBroadcastPush),y.setUint8(v++,l.length),y.setUint8(v++,a.length),y.setUint8(v++,o.length),y.setUint8(v++,c.length),y.setUint8(v++,h.length),y.setUint8(v++,s),Array.from(l,A=>y.setUint8(v++,A.charCodeAt(0))),Array.from(a,A=>y.setUint8(v++,A.charCodeAt(0))),Array.from(o,A=>y.setUint8(v++,A.charCodeAt(0))),Array.from(c,A=>y.setUint8(v++,A.charCodeAt(0))),Array.from(h,A=>y.setUint8(v++,A.charCodeAt(0)));var T=new Uint8Array(f.byteLength+r.byteLength);return T.set(new Uint8Array(f),0),T.set(new Uint8Array(r),f.byteLength),T.buffer}decode(e,s){if(this._isArrayBuffer(e)){let r=this._binaryDecode(e);return s(r)}if(typeof e=="string"){const r=JSON.parse(e),[n,i,o,a,l]=r;return s({join_ref:n,ref:i,topic:o,event:a,payload:l})}return s({})}_binaryDecode(e){const s=new DataView(e),r=s.getUint8(0),n=new TextDecoder;switch(r){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,s,n)}}_decodeUserBroadcast(e,s,r){const n=s.getUint8(1),i=s.getUint8(2),o=s.getUint8(3),a=s.getUint8(4);let l=this.HEADER_LENGTH+4;const c=r.decode(e.slice(l,l+n));l=l+n;const u=r.decode(e.slice(l,l+i));l=l+i;const h=r.decode(e.slice(l,l+o));l=l+o;const d=e.slice(l,e.byteLength),f=a===this.JSON_ENCODING?JSON.parse(r.decode(d)):d,y={type:this.BROADCAST_EVENT,event:u,payload:f};return o>0&&(y.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:y}}_isArrayBuffer(e){var s;return e instanceof ArrayBuffer||((s=e==null?void 0:e.constructor)===null||s===void 0?void 0:s.name)==="ArrayBuffer"}_pick(e,s){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([r])=>s.includes(r)))}}var _e;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(_e||(_e={}));const ta=(t,e,s={})=>{var r;const n=(r=s.skipTypes)!==null&&r!==void 0?r:[];return e?Object.keys(e).reduce((i,o)=>(i[o]=Pf(o,t,e,n),i),{}):{}},Pf=(t,e,s,r)=>{const n=e.find(a=>a.name===t),i=n==null?void 0:n.type,o=s[t];return i&&!r.includes(i)?lc(i,o):gi(o)},lc=(t,e)=>{if(t.charAt(0)==="_"){const s=t.slice(1,t.length);return Nf(e,s)}switch(t){case _e.bool:return If(e);case _e.float4:case _e.float8:case _e.int2:case _e.int4:case _e.int8:case _e.numeric:case _e.oid:return jf(e);case _e.json:case _e.jsonb:return $f(e);case _e.timestamp:return Lf(e);case _e.abstime:case _e.date:case _e.daterange:case _e.int4range:case _e.int8range:case _e.money:case _e.reltime:case _e.text:case _e.time:case _e.timestamptz:case _e.timetz:case _e.tsrange:case _e.tstzrange:return gi(e);default:return gi(e)}},gi=t=>t,If=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},jf=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},$f=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},Nf=(t,e)=>{if(typeof t!="string")return t;const s=t.length-1,r=t[s];if(t[0]==="{"&&r==="}"){let i;const o=t.slice(1,s);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>lc(e,a))}return t},Lf=t=>typeof t=="string"?t.replace(" ","T"):t,cc=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};var or=t=>typeof t=="function"?t:function(){return t},Uf=typeof self<"u"?self:null,xs=typeof window<"u"?window:null,kt=Uf||xs||globalThis,Df="2.0.0",Bf=1e4,Mf=1e3,Tt={connecting:0,open:1,closing:2,closed:3},ze={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},$t={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},yi={longpoll:"longpoll",websocket:"websocket"},Hf={complete:4},mi="base64url.bearer.phx.",$r=class{constructor(t,e,s,r){this.channel=t,this.event=e,this.payload=s||function(){return{}},this.receivedResp=null,this.timeout=r,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:s}){this.recHooks.filter(r=>r.status===t).forEach(r=>r.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},uc=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Ff=class{constructor(t,e,s){this.state=ze.closed,this.topic=t,this.params=or(e||{}),this.socket=s,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new $r(this,$t.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new uc(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=ze.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(r=>r.send()),this.pushBuffer=[]}),this.joinPush.receive("error",r=>{this.state=ze.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,r),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=ze.closed,this.socket.remove(this)}),this.onError(r=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,r),this.isJoining()&&this.joinPush.reset(),this.state=ze.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new $r(this,$t.leave,or({}),this.timeout).send(),this.state=ze.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on($t.reply,(r,n)=>{this.trigger(this.replyEventName(n),r)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=ze.closed,this.bindings=[]}onClose(t){this.on($t.close,t)}onError(t){return this.on($t.error,e=>t(e))}on(t,e){let s=this.bindingRef++;return this.bindings.push({event:t,ref:s,callback:e}),s}off(t,e){this.bindings=this.bindings.filter(s=>!(s.event===t&&(typeof e>"u"||e===s.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,s=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let r=new $r(this,t,function(){return e},s);return this.canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=ze.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger($t.close,"leave")},s=new $r(this,$t.leave,or({}),t);return s.receive("ok",()=>e()).receive("timeout",()=>e()),s.send(),this.canPush()||s.trigger("ok",{}),s}onMessage(t,e,s){return e}filterBindings(t,e,s){return!0}isMember(t,e,s,r){return this.topic!==t?!1:r&&r!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:s,joinRef:r}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=ze.joining,this.joinPush.resend(t))}trigger(t,e,s,r){let n=this.onMessage(t,e,s,r);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===t&&this.filterBindings(o,e,s));for(let o=0;o<i.length;o++)i[o].callback(n,s,r||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===ze.closed}isErrored(){return this.state===ze.errored}isJoined(){return this.state===ze.joined}isJoining(){return this.state===ze.joining}isLeaving(){return this.state===ze.leaving}},rn=class{static request(t,e,s,r,n,i,o){if(kt.XDomainRequest){let a=new kt.XDomainRequest;return this.xdomainRequest(a,t,e,r,n,i,o)}else if(kt.XMLHttpRequest){let a=new kt.XMLHttpRequest;return this.xhrRequest(a,t,e,s,r,n,i,o)}else{if(kt.fetch&&kt.AbortController)return this.fetchRequest(t,e,s,r,n,i,o);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,s,r,n,i,o){let a={method:t,headers:s,body:r},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),a.signal=l.signal),kt.fetch(e,a).then(c=>c.text()).then(c=>this.parseJSON(c)).then(c=>o&&o(c)).catch(c=>{c.name==="AbortError"&&i?i():o&&o(null)}),l}static xdomainRequest(t,e,s,r,n,i,o){return t.timeout=n,t.open(e,s),t.onload=()=>{let a=this.parseJSON(t.responseText);o&&o(a)},i&&(t.ontimeout=i),t.onprogress=()=>{},t.send(r),t}static xhrRequest(t,e,s,r,n,i,o,a){t.open(e,s,!0),t.timeout=i;for(let[l,c]of Object.entries(r))t.setRequestHeader(l,c);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===Hf.complete&&a){let l=this.parseJSON(t.responseText);a(l)}},o&&(t.ontimeout=o),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let s=[];for(var r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let n=e?`${e}[${r}]`:r,i=t[r];typeof i=="object"?s.push(this.serialize(i,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}return s.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let s=t.match(/\?/)?"&":"?";return`${t}${s}${this.serialize(e)}`}},qf=t=>{let e="",s=new Uint8Array(t),r=s.byteLength;for(let n=0;n<r;n++)e+=String.fromCharCode(s[n]);return btoa(e)},ms=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(mi)&&(this.authToken=atob(e[1].slice(mi.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=Tt.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+yi.websocket),"$1/"+yi.longpoll)}endpointURL(){return rn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,s){this.close(t,e,s),this.readyState=Tt.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Tt.open||this.readyState===Tt.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:s,token:r,messages:n}=e;if(s===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=r}else s=0;switch(s){case 200:n.forEach(i=>{setTimeout(()=>this.onmessage({data:i}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Tt.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${s}`)}})}send(t){typeof t!="string"&&(t=qf(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},t.join(`
37
+ `),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,s){for(let n of this.reqs)n.abort();this.readyState=Tt.closed;let r=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:s});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",r)):this.onclose(r)}ajax(t,e,s,r,n){let i,o=()=>{this.reqs.delete(i),r()};i=rn.request(t,this.endpointURL(),e,s,this.timeout,o,a=>{this.reqs.delete(i),this.isActive()&&n(a)}),this.reqs.add(i)}},Vf=class zs{constructor(e,s={}){let r=s.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(r.state,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel.joinRef(),this.state=zs.syncState(this.state,n,i,o),this.pendingDiffs.forEach(l=>{this.state=zs.syncDiff(this.state,l,i,o)}),this.pendingDiffs=[],a()}),this.channel.on(r.diff,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=zs.syncDiff(this.state,n,i,o),a())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return zs.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,s,r,n){let i=this.clone(e),o={},a={};return this.map(i,(l,c)=>{s[l]||(a[l]=c)}),this.map(s,(l,c)=>{let u=i[l];if(u){let h=c.metas.map(v=>v.phx_ref),d=u.metas.map(v=>v.phx_ref),f=c.metas.filter(v=>d.indexOf(v.phx_ref)<0),y=u.metas.filter(v=>h.indexOf(v.phx_ref)<0);f.length>0&&(o[l]=c,o[l].metas=f),y.length>0&&(a[l]=this.clone(u),a[l].metas=y)}else o[l]=c}),this.syncDiff(i,{joins:o,leaves:a},r,n)}static syncDiff(e,s,r,n){let{joins:i,leaves:o}=this.clone(s);return r||(r=function(){}),n||(n=function(){}),this.map(i,(a,l)=>{let c=e[a];if(e[a]=this.clone(l),c){let u=e[a].metas.map(d=>d.phx_ref),h=c.metas.filter(d=>u.indexOf(d.phx_ref)<0);e[a].metas.unshift(...h)}r(a,c,l)}),this.map(o,(a,l)=>{let c=e[a];if(!c)return;let u=l.metas.map(h=>h.phx_ref);c.metas=c.metas.filter(h=>u.indexOf(h.phx_ref)<0),n(a,c,l),c.metas.length===0&&delete e[a]}),e}static list(e,s){return s||(s=function(r,n){return n}),this.map(e,(r,n)=>s(r,n))}static map(e,s){return Object.getOwnPropertyNames(e).map(r=>s(r,e[r]))}static clone(e){return JSON.parse(JSON.stringify(e))}},Nr={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let s=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(s))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[s,r,n,i,o]=JSON.parse(t);return e({join_ref:s,ref:r,topic:n,event:i,payload:o})}},binaryEncode(t){let{join_ref:e,ref:s,event:r,topic:n,payload:i}=t,o=this.META_LENGTH+e.length+s.length+n.length+r.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,e.length),l.setUint8(c++,s.length),l.setUint8(c++,n.length),l.setUint8(c++,r.length),Array.from(e,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(s,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(n,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(r,h=>l.setUint8(c++,h.charCodeAt(0)));var u=new Uint8Array(a.byteLength+i.byteLength);return u.set(new Uint8Array(a),0),u.set(new Uint8Array(i),a.byteLength),u.buffer},binaryDecode(t){let e=new DataView(t),s=e.getUint8(0),r=new TextDecoder;switch(s){case this.KINDS.push:return this.decodePush(t,e,r);case this.KINDS.reply:return this.decodeReply(t,e,r);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,r)}},decodePush(t,e,s){let r=e.getUint8(1),n=e.getUint8(2),i=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=s.decode(t.slice(o,o+r));o=o+r;let l=s.decode(t.slice(o,o+n));o=o+n;let c=s.decode(t.slice(o,o+i));o=o+i;let u=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:l,event:c,payload:u}},decodeReply(t,e,s){let r=e.getUint8(1),n=e.getUint8(2),i=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=s.decode(t.slice(a,a+r));a=a+r;let c=s.decode(t.slice(a,a+n));a=a+n;let u=s.decode(t.slice(a,a+i));a=a+i;let h=s.decode(t.slice(a,a+o));a=a+o;let d=t.slice(a,t.byteLength),f={status:h,response:d};return{join_ref:l,ref:c,topic:u,event:$t.reply,payload:f}},decodeBroadcast(t,e,s){let r=e.getUint8(1),n=e.getUint8(2),i=this.HEADER_LENGTH+2,o=s.decode(t.slice(i,i+r));i=i+r;let a=s.decode(t.slice(i,i+n));i=i+n;let l=t.slice(i,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},Kf=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||Bf,this.transport=e.transport||kt.WebSocket||ms,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null;let s=null;try{s=kt&&kt.sessionStorage}catch{}this.sessionStore=e.sessionStorage||s,this.establishedConnections=0,this.defaultEncoder=Nr.encode.bind(Nr),this.defaultDecoder=Nr.decode.bind(Nr),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==ms?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let r=null;xs&&xs.addEventListener&&(xs.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),r=this.connectClock)}),xs.addEventListener("pageshow",n=>{r===this.connectClock&&(r=null,this.connect())}),xs.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=e.autoSendHeartbeat??!0,this.heartbeatCallback=e.heartbeatCallback??(()=>{}),this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(n,i,o)=>{console.log(`${n}: ${i}`,o)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=or(e.params||{}),this.endPoint=`${t}/${yi.websocket}`,this.vsn=e.vsn||Df,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new uc(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{e.beforeReconnect&&await e.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=e.authToken}getLongPollTransport(){return ms}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=rn.appendParams(rn.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,s){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,s)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=or(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==ms?this.connectWithFallback(ms,this.longPollFallbackMs):this.transportConnect())}log(t,e,s){this.logger&&this.logger(t,e,s)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),s=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let r=this.onMessage(n=>{n.ref===e&&(this.off([r]),t(Date.now()-s))});return!0}transportName(t){switch(t){case ms:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${mi}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,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)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let s=!1,r=!0,n,i,o=this.transportName(t),a=l=>{this.log("transport",`falling back to ${o}...`,l),this.off([n,i]),r=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return a("memorized");this.fallbackTimer=setTimeout(a,e),i=this.onError(l=>{this.log("transport","error",l),r&&!s&&(clearTimeout(this.fallbackTimer),a(l))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(s=!0,!r){let l=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${l}`,"true"),this.log("transport",`established ${l} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(a,e),this.ping(l=>{this.log("transport","connected to primary after",l),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Mf,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,s){if(!this.conn)return t&&t();const r=this.conn;this.waitForBufferDone(r,()=>{e?r.close(e,s||""):r.close(),this.waitForSocketClosed(r,()=>{this.conn===r&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,s=1){if(s===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,s+1)},150*s)}waitForSocketClosed(t,e,s=1){if(s===5||t.readyState===Tt.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,s+1)},150*s)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(t),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport","error",t);let e=this.transport,s=this.establishedConnections;this.triggerStateCallbacks("error",t,e,s),(e===this.transport||s>0)&&this.triggerChanError(t)}triggerChanError(t){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger($t.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case Tt.connecting:return"connecting";case Tt.open:return"open";case Tt.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([s])=>t.indexOf(s)===-1)}channel(t,e={}){let s=new Ff(t,e,this);return this.channels.push(s),s}push(t){if(this.hasLogger()){let{topic:e,event:s,payload:r,ref:n,join_ref:i}=t;this.log("push",`${e} ${s} (${i}, ${n})`,r)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:s,event:r,payload:n,ref:i,join_ref:o}=e;if(i&&i===this.pendingHeartbeatRef){const a=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(n.status==="ok"?"ok":"error",a)}catch(l){this.log("error","error in heartbeat callback",l)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${s} ${r} ${i&&"("+i+")"||""}`.trim(),n);for(let a=0;a<this.channels.length;a++){const l=this.channels[a];l.isMember(s,r,n,o)&&l.trigger(r,n,i,o)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(t,...e){try{this.stateChangeCallbacks[t].forEach(([s,r])=>{try{r(...e)}catch(n){this.log("error",`error in ${t} callback`,n)}})}catch(s){this.log("error",`error triggering ${t} callbacks`,s)}}leaveOpenTopic(t){let e=this.channels.find(s=>s.topic===t&&(s.isJoined()||s.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};class ar{constructor(e,s){const r=Gf(s);this.presence=new Vf(e.getChannel(),r),this.presence.onJoin((n,i,o)=>{const a=ar.onJoinPayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onLeave((n,i,o)=>{const a=ar.onLeavePayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return ar.transformState(this.presence.state)}static transformState(e){return e=Wf(e),Object.getOwnPropertyNames(e).reduce((s,r)=>{const n=e[r];return s[r]=Wr(n),s},{})}static onJoinPayload(e,s,r){const n=sa(s),i=Wr(r);return{event:"join",key:e,currentPresences:n,newPresences:i}}static onLeavePayload(e,s,r){const n=sa(s),i=Wr(r);return{event:"leave",key:e,currentPresences:n,leftPresences:i}}}function Wr(t){return t.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function Wf(t){return JSON.parse(JSON.stringify(t))}function Gf(t){return(t==null?void 0:t.events)&&{events:t.events}}function sa(t){return t!=null&&t.metas?Wr(t):[]}var ra;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(ra||(ra={}));class Jf{get state(){return this.presenceAdapter.state}constructor(e,s){this.channel=e,this.presenceAdapter=new ar(this.channel.channelAdapter,s)}}function zf(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t&&typeof t=="object"){const e=t;if(typeof e.code=="number"){const s=typeof e.reason=="string"&&e.reason?` (${e.reason})`:"";return new Error(`socket closed: ${e.code}${s}`,{cause:t})}return new Error("channel error: transport failure",{cause:t})}return new Error("channel error: connection lost")}class Yf{constructor(e,s,r){const n=Xf(r);this.channel=e.getSocket().channel(s,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,s){return this.channel.on(e,s)}off(e,s){this.channel.off(e,s)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,s,r){let n;try{n=this.channel.push(e,s,r)}catch{throw new Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>Of){const i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${i.event}`,i.payload())}return n}updateJoinPayload(e){const s=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},s),e)}canPush(){return this.socket.isConnected()&&this.state===Xt.joined}isJoined(){return this.state===Xt.joined}isJoining(){return this.state===Xt.joining}isClosed(){return this.state===Xt.closed}isLeaving(){return this.state===Xt.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function Xf(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}var na;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(na||(na={}));var Rs;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Rs||(Rs={}));var Nt;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Nt||(Nt={}));class lr{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,s={config:{}},r){var n,i;if(this.topic=e,this.params=s,this.socket=r,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},s.config),this.channelAdapter=new Yf(this.socket.socketAdapter,e,this.params),this.presence=new Jf(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=cc(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((i=(n=this.params.config)===null||n===void 0?void 0:n.broadcast)===null||i===void 0)&&i.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,s=this.timeout){var r,n,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:o,presence:a,private:l}}=this.params,c=(n=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(f=>f.filter))!==null&&n!==void 0?n:[],u=!!this.bindings[Rs.PRESENCE]&&this.bindings[Rs.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},d={broadcast:o,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(f=>{e==null||e(Nt.CHANNEL_ERROR,zf(f))}),this._onClose(()=>e==null?void 0:e(Nt.CLOSED)),this.updateJoinPayload(Object.assign({config:d},h)),this._updateFilterMessage(),this.channelAdapter.subscribe(s).receive("ok",async({postgres_changes:f})=>{if(this.socket._isManualToken()||this.socket.setAuth(),f===void 0){e==null||e(Nt.SUBSCRIBED);return}this._updatePostgresBindings(f,e)}).receive("error",f=>{this.state=Xt.errored;const y=Object.values(f).join(", ")||"error";e==null||e(Nt.CHANNEL_ERROR,new Error(y,{cause:f}))}).receive("timeout",()=>{e==null||e(Nt.TIMED_OUT)})}return this}_updatePostgresBindings(e,s){var r;const n=this.bindings.postgres_changes,i=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0,o=[];for(let a=0;a<i;a++){const l=n[a],{filter:{event:c,schema:u,table:h,filter:d}}=l,f=e&&e[a];if(f&&f.event===c&&lr.isFilterValueEqual(f.schema,u)&&lr.isFilterValueEqual(f.table,h)&&lr.isFilterValueEqual(f.filter,d))o.push(Object.assign(Object.assign({},l),{id:f.id}));else{this.unsubscribe(),this.state=Xt.errored,s==null||s(Nt.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=o,this.state!=Xt.errored&&s&&s(Nt.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,s={}){return await this.send({type:"presence",event:"track",payload:e},s.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,s,r){const n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),i=e===Rs.PRESENCE||e===Rs.POSTGRES_CHANGES;if(n&&i)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,s,r)}async httpSend(e,s,r={}){var n;if(s==null)return Promise.reject(new Error("Payload is required for httpSend()"));const i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const o={method:"POST",headers:i,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:s,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,o,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);if(a.status===202)return{success:!0};let l=a.statusText;try{const c=await a.json();l=c.error||c.message||l}catch{}return Promise.reject(new Error(l))}async send(e,s={}){var r,n;if(!this.channelAdapter.canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:o}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);const l={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(r=s.timeout)!==null&&r!==void 0?r:this.timeout);return await((n=c.body)===null||n===void 0?void 0:n.cancel()),c.ok?"ok":"error"}catch(c){return c instanceof Error&&c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,a,l;const c=this.channelAdapter.push(e.type,e,s.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(o=this.params)===null||o===void 0?void 0:o.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(s=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>s("ok")).receive("timeout",()=>s("timed out")).receive("error",()=>s("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,s,r){const n=new AbortController,i=setTimeout(()=>n.abort(),r),o=await this.socket.fetch(e,Object.assign(Object.assign({},s),{signal:n.signal}));return clearTimeout(i),o}_on(e,s,r){const n=e.toLocaleLowerCase(),i=this.channelAdapter.on(e,r),o={type:n,filter:s,callback:r,ref:i};return this.bindings[n]?this.bindings[n].push(o):this.bindings[n]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,s,r)=>{var n,i,o,a,l,c,u;const h=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(h,r))return!1;const d=(n=this.bindings[h])===null||n===void 0?void 0:n.find(f=>f.ref===e.ref);if(!d)return!0;if(["broadcast","presence","postgres_changes"].includes(h))if("id"in d){const f=d.id,y=(i=d.filter)===null||i===void 0?void 0:i.event;return f&&((o=s.ids)===null||o===void 0?void 0:o.includes(f))&&(y==="*"||(y==null?void 0:y.toLocaleLowerCase())===((a=s.data)===null||a===void 0?void 0:a.type.toLocaleLowerCase()))}else{const f=(c=(l=d==null?void 0:d.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return f==="*"||f===((u=s==null?void 0:s.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return d.type.toLocaleLowerCase()===h})}_notThisChannelEvent(e,s){const{close:r,error:n,leave:i,join:o}=ac;return s&&[r,n,i,o].includes(e)&&s!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,s,r)=>{if(typeof s=="object"&&"ids"in s){const n=s.data,{schema:i,table:o,commit_timestamp:a,type:l,errors:c}=n;return Object.assign(Object.assign({},{schema:i,table:o,commit_timestamp:a,eventType:l,new:{},old:{},errors:c}),this._getPayloadRecords(n))}return s})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const s in e.bindings)for(const r of e.bindings[s])this._on(r.type,r.filter,r.callback)}static isFilterValueEqual(e,s){return(e??void 0)===(s??void 0)}_getPayloadRecords(e){const s={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(s.new=ta(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(s.old=ta(e.columns,e.old_record)),s}}class Qf{constructor(e,s){this.socket=new Kf(e,s)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,s,r,n=1e4){return new Promise(i=>{setTimeout(()=>i("timeout"),n),this.socket.disconnect(()=>{e(),i("ok")},s,r)})}push(e){this.socket.push(e)}log(e,s,r){this.socket.log(e,s,r)}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==pi.connecting}isDisconnecting(){return this.socket.connectionState()==pi.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const ia={HEARTBEAT_INTERVAL:25e3},Zf=[1e3,2e3,5e3,1e4],ep=1e4;function tp(){const t=new Map;return{get length(){return t.size},clear(){t.clear()},getItem(e){return t.has(e)?t.get(e):null},key(e){var s;return(s=Array.from(t.keys())[e])!==null&&s!==void 0?s:null},removeItem(e){t.delete(e)},setItem(e,s){t.set(e,String(s))}}}function sp(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return tp()}const rp=`
38
+ addEventListener("message", (e) => {
39
+ if (e.data.event === "start") {
40
+ setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
41
+ }
42
+ });`;class np{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,s){var r;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new Cf,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=i=>i?(...o)=>i(...o):(...o)=>fetch(...o),!(!((r=s==null?void 0:s.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=s.params.apikey;const n=this._initializeOptions(s);this.socketAdapter=new Qf(e,n),this.httpEndpoint=cc(e),this.fetch=this._resolveFetch(s==null?void 0:s.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){const s=e.message;throw s.includes("Node.js")?new Error(`${s}
43
+
44
+ To use Realtime in Node.js, you need to provide a WebSocket implementation:
45
+
46
+ Option 1: Use Node.js 22+ which has native WebSocket support
47
+ Option 2: Install and provide the "ws" package:
48
+
49
+ npm install ws
50
+
51
+ import ws from "ws"
52
+ const client = new RealtimeClient(url, {
53
+ ...options,
54
+ transport: ws
55
+ })`):new Error(`WebSocket not available: ${s}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,s){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,s)}getChannels(){return this.channels}async removeChannel(e){const s=await e.unsubscribe();return s==="ok"&&e.teardown(),s}async removeAllChannels(){const e=this.channels.map(async r=>{const n=await r.unsubscribe();return r.teardown(),n}),s=await Promise.all(e);return await this.disconnect(),s}log(e,s,r){this.socketAdapter.log(e,s,r)}connectionState(){return this.socketAdapter.connectionState()||pi.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,s={config:{}}){const r=`realtime:${e}`,n=this.getChannels().find(i=>i.topic===r);if(n)return n;{const i=new lr(`realtime:${e}`,s,this);return this._cancelPendingDisconnect(),this.channels.push(i),i}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(s=>s.topic!==e.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e=null){let s,r=!1;if(e)s=e,r=!0;else if(this.accessToken)try{s=await this.accessToken()}catch(n){this.log("error","Error fetching access token from callback",n),s=this.accessTokenValue}else s=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=s&&(this.accessTokenValue=s,this.channels.forEach(n=>{const i={access_token:s,version:xf};s&&n.updateJoinPayload(i),n.joinedOnce&&n.channelAdapter.isJoined()&&n.channelAdapter.push(ac.access_token,{access_token:s})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(s=>{this.log("error",`Error setting auth in ${e}`,s)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(s=>{this.log("error","error waiting for auth on connect",s)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(s,r)=>{s=="sent"&&this._setAuthSafely(),e&&e(s,r)}}_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=s=>{this.log("worker","worker error",s.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=s=>{s.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let s;if(e)s=e;else{const r=new Blob([rp],{type:"application/javascript"});s=URL.createObjectURL(r)}return s}_initializeOptions(e){var s,r,n,i,o,a,l,c,u,h,d,f;this.worker=(s=e==null?void 0:e.worker)!==null&&s!==void 0?s:!1,this.accessToken=(r=e==null?void 0:e.accessToken)!==null&&r!==void 0?r:null;const y={};y.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:Rf,y.heartbeatIntervalMs=(i=e==null?void 0:e.heartbeatIntervalMs)!==null&&i!==void 0?i:ia.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(o=e==null?void 0:e.disconnectOnEmptyChannelsAfterMs)!==null&&o!==void 0?o:2*((a=e==null?void 0:e.heartbeatIntervalMs)!==null&&a!==void 0?a:ia.HEARTBEAT_INTERVAL),y.transport=(l=e==null?void 0:e.transport)!==null&&l!==void 0?l:kf.getWebSocketConstructor(),y.params=e==null?void 0:e.params,y.logger=e==null?void 0:e.logger,y.heartbeatCallback=this._wrapHeartbeatCallback(e==null?void 0:e.heartbeatCallback),y.sessionStorage=(c=e==null?void 0:e.sessionStorage)!==null&&c!==void 0?c:sp(),y.reconnectAfterMs=(u=e==null?void 0:e.reconnectAfterMs)!==null&&u!==void 0?u:_=>Zf[_-1]||ep;let v,T;const A=(h=e==null?void 0:e.vsn)!==null&&h!==void 0?h:Af;switch(A){case Tf:v=(_,w)=>w(JSON.stringify(_)),T=(_,w)=>w(JSON.parse(_));break;case oc:v=this.serializer.encode.bind(this.serializer),T=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${y.vsn}`)}if(y.vsn=A,y.encode=(d=e==null?void 0:e.encode)!==null&&d!==void 0?d:v,y.decode=(f=e==null?void 0:e.decode)!==null&&f!==void 0?f:T,y.beforeReconnect=this._reconnectAuth.bind(this),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,y.params=Object.assign(Object.assign({},y.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl,y.autoSendHeartbeat=!this.worker}return y}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var mr=class extends Error{constructor(t,e){var s;super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&((s=e.icebergType)==null?void 0:s.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function ip(t,e,s){const r=new URL(e,t);if(s)for(const[n,i]of Object.entries(s))i!==void 0&&r.searchParams.set(n,i);return r.toString()}async function op(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function ap(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:s,path:r,query:n,body:i,headers:o}){const a=ip(t.baseUrl,r,n),l=await op(t.auth),c=await e(a,{method:s,headers:{...i?{"Content-Type":"application/json"}:{},...l,...o},body:i?JSON.stringify(i):void 0}),u=await c.text(),h=(c.headers.get("content-type")||"").includes("application/json"),d=h&&u?JSON.parse(u):u;if(!c.ok){const f=h?d:void 0,y=f==null?void 0:f.error;throw new mr((y==null?void 0:y.message)??`Request failed with status ${c.status}`,{status:c.status,icebergType:y==null?void 0:y.type,icebergCode:y==null?void 0:y.code,details:f})}return{status:c.status,headers:c.headers,data:d}}}}function Lr(t){return t.join("")}var lp=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Lr(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(r=>({namespace:r}))}async createNamespace(t,e){const s={namespace:t.namespace,properties:e==null?void 0:e.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:s})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Lr(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Lr(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Lr(t.namespace)}`}),!0}catch(e){if(e instanceof mr&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(s){if(s instanceof mr&&s.status===409)return;throw s}}};function vs(t){return t.join("")}var cp=class{constructor(t,e="",s){this.client=t,this.prefix=e,this.accessDelegation=s}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${vs(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const s={};return this.accessDelegation&&(s["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${vs(t.namespace)}/tables`,body:e,headers:s})).data.metadata}async updateTable(t,e){const s=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${vs(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":s.data["metadata-location"],metadata:s.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${vs(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((e==null?void 0:e.purge)??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${vs(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${vs(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(s){if(s instanceof mr&&s.status===404)return!1;throw s}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(s){if(s instanceof mr&&s.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw s}}},up=class{constructor(t){var r;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const s=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=ap({baseUrl:s,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(r=t.accessDelegation)==null?void 0:r.join(","),this.namespaceOps=new lp(this.client,e),this.tableOps=new cp(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}};function vr(t){"@babel/helpers - typeof";return vr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vr(t)}function hp(t,e){if(vr(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(vr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dp(t){var e=hp(t,"string");return vr(e)=="symbol"?e:e+""}function fp(t,e,s){return(e=dp(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function oa(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,r)}return s}function Z(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?oa(Object(s),!0).forEach(function(r){fp(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):oa(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var Rn=class extends Error{constructor(t,e="storage",s,r){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=s,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function On(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var vi=class extends Rn{constructor(t,e,s,r="storage"){super(t,r,e,s),this.name=r==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=s}toJSON(){return Z({},super.toJSON())}},hc=class extends Rn{constructor(t,e,s="storage"){super(t,s),this.name=s==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};function nn(t,e,s){const r=Z({},t),n=e.toLowerCase();for(const i of Object.keys(r))i.toLowerCase()===n&&delete r[i];return r[n]=s,r}function pp(t){const e={};for(const[s,r]of Object.entries(t))e[s.toLowerCase()]=r;return e}const gp=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),yp=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)},bi=t=>{if(Array.isArray(t))return t.map(s=>bi(s));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([s,r])=>{const n=s.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[n]=bi(r)}),e},mp=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),aa=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error;if(typeof e.error=="object"&&e.error!==null){const s=e.error;if(typeof s.message=="string")return s.message}}return JSON.stringify(t)},vp=async(t,e,s,r)=>{if(t!==null&&typeof t=="object"&&"json"in t&&typeof t.json=="function"){const n=t;let i=parseInt(String(n.status),10);Number.isFinite(i)||(i=500),n.json().then(o=>{const a=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||i+"";e(new vi(aa(o),i,a,r))}).catch(()=>{const o=i+"";e(new vi(n.statusText||`HTTP ${i} error`,i,o,r))})}else e(new hc(aa(t),t,r))},bp=(t,e,s,r)=>{const n={method:t,headers:(e==null?void 0:e.headers)||{}};if(t==="GET"||t==="HEAD"||!r)return Z(Z({},n),s);if(yp(r)){var i;const o=(e==null?void 0:e.headers)||{};let a;for(const[l,c]of Object.entries(o))l.toLowerCase()==="content-type"&&(a=c);n.headers=nn(o,"Content-Type",(i=a)!==null&&i!==void 0?i:"application/json"),n.body=JSON.stringify(r)}else n.body=r;return e!=null&&e.duplex&&(n.duplex=e.duplex),Z(Z({},n),s)};async function Vs(t,e,s,r,n,i,o){return new Promise((a,l)=>{t(s,bp(e,r,n,i)).then(c=>{if(!c.ok)throw c;if(r!=null&&r.noResolveJson)return c;if(o==="vectors"){const u=c.headers.get("content-type");if(c.headers.get("content-length")==="0"||c.status===204)return{};if(!u||!u.includes("application/json"))return{}}return c.json()}).then(c=>a(c)).catch(c=>vp(c,l,r,o))})}function dc(t="storage"){return{get:async(e,s,r,n)=>Vs(e,"GET",s,r,n,void 0,t),post:async(e,s,r,n,i)=>Vs(e,"POST",s,n,i,r,t),put:async(e,s,r,n,i)=>Vs(e,"PUT",s,n,i,r,t),head:async(e,s,r,n)=>Vs(e,"HEAD",s,Z(Z({},r),{},{noResolveJson:!0}),n,void 0,t),remove:async(e,s,r,n,i)=>Vs(e,"DELETE",s,n,i,r,t)}}const _p=dc("storage"),{get:br,post:ht,put:_i,head:wp,remove:Wi}=_p,st=dc("vectors");var Bs=class{constructor(t,e={},s,r="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=pp(e),this.fetch=gp(s),this.namespace=r}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=nn(this.headers,t,e),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(On(s))return{data:null,error:s};throw s}}},Sp=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e}then(t,e){return this.execute().then(t,e)}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(On(e))return{data:null,error:e};throw e}}};let fc;fc=Symbol.toStringTag;var kp=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[fc]="BlobDownloadBuilder",this.promise=null}asStream(){return new Sp(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(On(e))return{data:null,error:e};throw e}}};const Ep={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},la={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var xp=class extends Bs{constructor(t,e={},s,r){super(t,e,r,"storage"),this.bucketId=s}async uploadOrUpdate(t,e,s,r){var n=this;return n.handleOperation(async()=>{let i;const o=Z(Z({},la),r);let a=Z(Z({},n.headers),t==="POST"&&{"x-upsert":String(o.upsert)});const l=o.metadata;if(typeof Blob<"u"&&s instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",n.encodeMetadata(l)),i.append("",s)):typeof FormData<"u"&&s instanceof FormData?(i=s,i.has("cacheControl")||i.append("cacheControl",o.cacheControl),l&&!i.has("metadata")&&i.append("metadata",n.encodeMetadata(l))):(i=s,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=n.toBase64(n.encodeMetadata(l))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!o.duplex&&(o.duplex="half")),r!=null&&r.headers)for(const[d,f]of Object.entries(r.headers))a=nn(a,d,f);const c=n._removeEmptyFolders(e),u=n._getFinalPath(c),h=await(t=="PUT"?_i:ht)(n.fetch,`${n.url}/object/${u}`,i,Z({headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{path:c,id:h.Id,fullPath:h.Key}})}async upload(t,e,s){return this.uploadOrUpdate("POST",t,e,s)}async uploadToSignedUrl(t,e,s,r){var n=this;const i=n._removeEmptyFolders(t),o=n._getFinalPath(i),a=new URL(n.url+`/object/upload/sign/${o}`);return a.searchParams.set("token",e),n.handleOperation(async()=>{let l;const c=Z(Z({},la),r);let u=Z(Z({},n.headers),{"x-upsert":String(c.upsert)});const h=c.metadata;if(typeof Blob<"u"&&s instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),h&&l.append("metadata",n.encodeMetadata(h)),l.append("",s)):typeof FormData<"u"&&s instanceof FormData?(l=s,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),h&&!l.has("metadata")&&l.append("metadata",n.encodeMetadata(h))):(l=s,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType,h&&(u["x-metadata"]=n.toBase64(n.encodeMetadata(h))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),r!=null&&r.headers)for(const[d,f]of Object.entries(r.headers))u=nn(u,d,f);return{path:i,fullPath:(await _i(n.fetch,a.toString(),l,Z({headers:u},c!=null&&c.duplex?{duplex:c.duplex}:{}))).Key}})}async createSignedUploadUrl(t,e){var s=this;return s.handleOperation(async()=>{let r=s._getFinalPath(t);const n=Z({},s.headers);e!=null&&e.upsert&&(n["x-upsert"]="true");const i=await ht(s.fetch,`${s.url}/object/upload/sign/${r}`,{},{headers:n}),o=new URL(s.url+i.url),a=o.searchParams.get("token");if(!a)throw new Rn("No token returned by API");return{signedUrl:o.toString(),path:t,token:a}})}async update(t,e,s){return this.uploadOrUpdate("PUT",t,e,s)}async move(t,e,s){var r=this;return r.handleOperation(async()=>await ht(r.fetch,`${r.url}/object/move`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s==null?void 0:s.destinationBucket},{headers:r.headers}))}async copy(t,e,s){var r=this;return r.handleOperation(async()=>({path:(await ht(r.fetch,`${r.url}/object/copy`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:s==null?void 0:s.destinationBucket},{headers:r.headers})).Key}))}async createSignedUrl(t,e,s){var r=this;return r.handleOperation(async()=>{let n=r._getFinalPath(t);const i=typeof(s==null?void 0:s.transform)=="object"&&s.transform!==null&&Object.keys(s.transform).length>0;let o=await ht(r.fetch,`${r.url}/object/sign/${n}`,Z({expiresIn:e},i?{transform:s.transform}:{}),{headers:r.headers});const a=new URLSearchParams;s!=null&&s.download&&a.set("download",s.download===!0?"":s.download),(s==null?void 0:s.cacheNonce)!=null&&a.set("cacheNonce",String(s.cacheNonce));const l=a.toString();return{signedUrl:encodeURI(`${r.url}${o.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(t,e,s){var r=this;return r.handleOperation(async()=>{const n=await ht(r.fetch,`${r.url}/object/sign/${r.bucketId}`,{expiresIn:e,paths:t},{headers:r.headers}),i=new URLSearchParams;s!=null&&s.download&&i.set("download",s.download===!0?"":s.download),(s==null?void 0:s.cacheNonce)!=null&&i.set("cacheNonce",String(s.cacheNonce));const o=i.toString();return n.map(a=>Z(Z({},a),{},{signedUrl:a.signedURL?encodeURI(`${r.url}${a.signedURL}${o?`&${o}`:""}`):null}))})}download(t,e,s){const r=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;e!=null&&e.transform&&this.applyTransformOptsToQuery(n,e.transform),(e==null?void 0:e.cacheNonce)!=null&&n.set("cacheNonce",String(e.cacheNonce));const i=n.toString(),o=this._getFinalPath(t),a=()=>br(this.fetch,`${this.url}/${r}/${o}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},s);return new kp(a,this.shouldThrowOnError)}async info(t){var e=this;const s=e._getFinalPath(t);return e.handleOperation(async()=>bi(await br(e.fetch,`${e.url}/object/info/${s}`,{headers:e.headers})))}async exists(t){var e=this;const s=e._getFinalPath(t);try{return await wp(e.fetch,`${e.url}/object/${s}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(On(n)){var r;const i=n instanceof vi?n.status:n instanceof hc?(r=n.originalError)===null||r===void 0?void 0:r.status:void 0;if(i!==void 0&&[400,404].includes(i))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const s=this._getFinalPath(t),r=new URLSearchParams;e!=null&&e.download&&r.set("download",e.download===!0?"":e.download),e!=null&&e.transform&&this.applyTransformOptsToQuery(r,e.transform),(e==null?void 0:e.cacheNonce)!=null&&r.set("cacheNonce",String(e.cacheNonce));const n=r.toString(),i=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${s}`)+(n?`?${n}`:"")}}}async remove(t){var e=this;return e.handleOperation(async()=>await Wi(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,s){var r=this;return r.handleOperation(async()=>{const n=Z(Z(Z({},Ep),e),{},{prefix:t||""});return await ht(r.fetch,`${r.url}/object/list/${r.bucketId}`,n,{headers:r.headers},s)})}async listV2(t,e){var s=this;return s.handleOperation(async()=>{const r=Z({},t);return await ht(s.fetch,`${s.url}/object/list-v2/${s.bucketId}`,r,{headers:s.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(t,e){return e.width&&t.set("width",e.width.toString()),e.height&&t.set("height",e.height.toString()),e.resize&&t.set("resize",e.resize),e.format&&t.set("format",e.format),e.quality&&t.set("quality",e.quality.toString()),t}};const Tp="2.105.4",Rr={"X-Client-Info":`storage-js/${Tp}`};var Ap=class extends Bs{constructor(t,e={},s,r){const n=new URL(t);r!=null&&r.useNewHostname&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase."));const i=n.href.replace(/\/$/,""),o=Z(Z({},Rr),e);super(i,o,s,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const s=e.listBucketOptionsToQueryString(t);return await br(e.fetch,`${e.url}/bucket${s}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await br(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var s=this;return s.handleOperation(async()=>await ht(s.fetch,`${s.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:s.headers}))}async updateBucket(t,e){var s=this;return s.handleOperation(async()=>await _i(s.fetch,`${s.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:s.headers}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await ht(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Wi(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},Rp=class extends Bs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=Z(Z({},Rr),e);super(r,n,s,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await ht(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const s=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&s.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&s.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&s.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&s.set("sortOrder",t.sortOrder),t!=null&&t.search&&s.set("search",t.search);const r=s.toString(),n=r?`${e.url}/bucket?${r}`:`${e.url}/bucket`;return await br(e.fetch,n,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Wi(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!mp(t))throw new Rn("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const s=new up({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),r=this.shouldThrowOnError;return new Proxy(s,{get(n,i){const o=n[i];return typeof o!="function"?o:async(...a)=>{try{return{data:await o.apply(n,a),error:null}}catch(l){if(r)throw l;return{data:null,error:l}}}}})}},Op=class extends Bs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=Z(Z({},Rr),{},{"Content-Type":"application/json"},e);super(r,n,s,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var s=this;return s.handleOperation(async()=>await st.post(s.fetch,`${s.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var s=this;return s.handleOperation(async()=>await st.post(s.fetch,`${s.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers})||{})}},Cp=class extends Bs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=Z(Z({},Rr),{},{"Content-Type":"application/json"},e);super(r,n,s,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},Pp=class extends Bs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=Z(Z({},Rr),{},{"Content-Type":"application/json"},e);super(r,n,s,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await st.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},Ip=class extends Pp{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new jp(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,s=this;return e().call(s,t)}async getBucket(t){var e=()=>super.getBucket,s=this;return e().call(s,t)}async listBuckets(t={}){var e=()=>super.listBuckets,s=this;return e().call(s,t)}async deleteBucket(t){var e=()=>super.deleteBucket,s=this;return e().call(s,t)}},jp=class extends Op{constructor(t,e,s,r){super(t,e,r),this.vectorBucketName=s}async createIndex(t){var e=()=>super.createIndex,s=this;return e().call(s,Z(Z({},t),{},{vectorBucketName:s.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,s=this;return e().call(s,Z(Z({},t),{},{vectorBucketName:s.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,s=this;return e().call(s,s.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,s=this;return e().call(s,s.vectorBucketName,t)}index(t){return new $p(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},$p=class extends Cp{constructor(t,e,s,r,n){super(t,e,n),this.vectorBucketName=s,this.indexName=r}async putVectors(t){var e=()=>super.putVectors,s=this;return e().call(s,Z(Z({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async getVectors(t){var e=()=>super.getVectors,s=this;return e().call(s,Z(Z({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,s=this;return e().call(s,Z(Z({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,s=this;return e().call(s,Z(Z({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,s=this;return e().call(s,Z(Z({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}},Np=class extends Ap{constructor(t,e={},s,r){super(t,e,s,r)}from(t){return new xp(this.url,this.headers,t,this.fetch)}get vectors(){return new Ip(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Rp(this.url+"/iceberg",this.headers,this.fetch)}};const pc="2.105.4",Ts=30*1e3,wi=3,Wn=wi*Ts,Lp="http://localhost:9999",Up="supabase.auth.token",Dp={"X-Client-Info":`gotrue-js/${pc}`},Si="X-Supabase-Api-Version",gc={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Bp=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Mp=10*60*1e3;class _r extends Error{constructor(e,s,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=s,this.code=r}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function U(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Hp extends _r{constructor(e,s,r){super(e,s,r),this.name="AuthApiError",this.status=s,this.code=r}}function Fp(t){return U(t)&&t.name==="AuthApiError"}class dt extends _r{constructor(e,s){super(e),this.name="AuthUnknownError",this.originalError=s}}class Wt extends _r{constructor(e,s,r,n){super(e,r,n),this.name=s,this.status=r}}class je extends Wt{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Ur(t){return U(t)&&t.name==="AuthSessionMissingError"}class bs extends Wt{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Dr extends Wt{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Br extends Wt{constructor(e,s=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function qp(t){return U(t)&&t.name==="AuthImplicitGrantRedirectError"}class ca extends Wt{constructor(e,s=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class Vp extends Wt{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class ki extends Wt{constructor(e,s){super(e,"AuthRetryableFetchError",s,void 0)}}function Gn(t){return U(t)&&t.name==="AuthRetryableFetchError"}class ua extends Wt{constructor(e,s,r){super(e,"AuthWeakPasswordError",s,"weak_password"),this.reasons=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class Ei extends Wt{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const on="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ha=`
56
+ \r=`.split(""),Kp=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<ha.length;e+=1)t[ha[e].charCodeAt(0)]=-2;for(let e=0;e<on.length;e+=1)t[on[e].charCodeAt(0)]=e;return t})();function da(t,e,s){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;s(on[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;s(on[r]),e.queuedBits-=6}}function yc(t,e,s){const r=Kp[t];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)s(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function fa(t){const e=[],s=o=>{e.push(String.fromCodePoint(o))},r={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=o=>{Jp(o,r,s)};for(let o=0;o<t.length;o+=1)yc(t.charCodeAt(o),n,i);return e.join("")}function Wp(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>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 Gp(t,e){for(let s=0;s<t.length;s+=1){let r=t.charCodeAt(s);if(r>55295&&r<=56319){const n=(r-55296)*1024&65535;r=(t.charCodeAt(s+1)-56320&65535|n)+65536,s+=1}Wp(r,e)}}function Jp(t,e,s){if(e.utf8seq===0){if(t<=127){s(t);return}for(let r=1;r<6;r+=1)if(!(t>>7-r&1)){e.utf8seq=r;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&&s(e.codepoint)}}function $s(t){const e=[],s={queue:0,queuedBits:0},r=n=>{e.push(n)};for(let n=0;n<t.length;n+=1)yc(t.charCodeAt(n),s,r);return new Uint8Array(e)}function zp(t){const e=[];return Gp(t,s=>e.push(s)),new Uint8Array(e)}function us(t){const e=[],s={queue:0,queuedBits:0},r=n=>{e.push(n)};return t.forEach(n=>da(n,s,r)),da(null,s,r),e.join("")}function Yp(t){return Math.round(Date.now()/1e3)+t}function Xp(){return Symbol("auth-callback")}const Me=()=>typeof window<"u"&&typeof document<"u",ns={tested:!1,writable:!1},mc=()=>{if(!Me())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(ns.tested)return ns.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),ns.tested=!0,ns.writable=!0}catch{ns.tested=!0,ns.writable=!1}return ns.writable};function Qp(t){const e={},s=new URL(t);if(s.hash&&s.hash[0]==="#")try{new URLSearchParams(s.hash.substring(1)).forEach((n,i)=>{e[i]=n})}catch{}return s.searchParams.forEach((r,n)=>{e[n]=r}),e}const vc=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Zp=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",As=async(t,e,s)=>{await t.setItem(e,JSON.stringify(s))},is=async(t,e)=>{const s=await t.getItem(e);if(!s)return null;try{return JSON.parse(s)}catch{return null}},Be=async(t,e)=>{await t.removeItem(e)};class Cn{constructor(){this.promise=new Cn.promiseConstructor((e,s)=>{this.resolve=e,this.reject=s})}}Cn.promiseConstructor=Promise;function Mr(t){const e=t.split(".");if(e.length!==3)throw new Ei("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!Bp.test(e[r]))throw new Ei("JWT not in base64url format");return{header:JSON.parse(fa(e[0])),payload:JSON.parse(fa(e[1])),signature:$s(e[2]),raw:{header:e[0],payload:e[1]}}}async function eg(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function tg(t,e){return new Promise((r,n)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!e(i,null,o)){r(o);return}}catch(o){if(!e(i,o)){n(o);return}}})()})}function sg(t){return("0"+t.toString(16)).substr(-2)}function rg(){const e=new Uint32Array(56);if(typeof crypto>"u"){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=s.length;let n="";for(let i=0;i<56;i++)n+=s.charAt(Math.floor(Math.random()*r));return n}return crypto.getRandomValues(e),Array.from(e,sg).join("")}async function ng(t){const s=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",s),n=new Uint8Array(r);return Array.from(n).map(i=>String.fromCharCode(i)).join("")}async function ig(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 s=await ng(t);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function _s(t,e,s=!1){const r=rg();let n=r;s&&(n+="/recovery"),await As(t,`${e}-code-verifier`,n);const i=await ig(r);return[i,r===i?"plain":"s256"]}const og=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function ag(t){const e=t.headers.get(Si);if(!e||!e.match(og))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function lg(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 cg(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 ug=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function It(t){if(!ug.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function ut(t){if(!t.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function Jn(){const t={};return new Proxy(t,{get:(e,s)=>{if(s==="__isUserNotAvailableProxy")return!0;if(typeof s=="symbol"){const r=s.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="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 "${s}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function hg(t,e){return new Proxy(t,{get:(s,r,n)=>{if(r==="__isInsecureUserWarningProxy")return!0;if(typeof r=="symbol"){const i=r.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(s,r,n)}return!e.value&&typeof r=="string"&&(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."),e.value=!0),Reflect.get(s,r,n)}})}function pa(t){return JSON.parse(JSON.stringify(t))}const as=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error}return JSON.stringify(t)},dg=[502,503,504,520,521,522,523,524,530];async function ga(t){var e;if(!Zp(t))throw new ki(as(t),0);if(dg.includes(t.status))throw new ki(as(t),t.status);let s;try{s=await t.json()}catch(i){throw new dt(as(i),i)}let r;const n=ag(t);if(n&&n.getTime()>=gc["2024-01-01"].timestamp&&typeof s=="object"&&s&&typeof s.code=="string"?r=s.code:typeof s=="object"&&s&&typeof s.error_code=="string"&&(r=s.error_code),r){if(r==="weak_password")throw new ua(as(s),t.status,((e=s.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new je}else if(typeof s=="object"&&s&&typeof s.weak_password=="object"&&s.weak_password&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new ua(as(s),t.status,s.weak_password.reasons);throw new Hp(as(s),t.status||500,r)}const fg=(t,e,s,r)=>{const n={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),n.body=JSON.stringify(r),Object.assign(Object.assign({},n),s))};async function K(t,e,s,r){var n;const i=Object.assign({},r==null?void 0:r.headers);i[Si]||(i[Si]=gc["2024-01-01"].name),r!=null&&r.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const o=(n=r==null?void 0:r.query)!==null&&n!==void 0?n:{};r!=null&&r.redirectTo&&(o.redirect_to=r.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await pg(t,e,s+a,{headers:i,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(l):{data:Object.assign({},l),error:null}}async function pg(t,e,s,r,n,i){const o=fg(e,r,n,i);let a;try{a=await t(s,Object.assign({},o))}catch(l){throw console.error(l),new ki(as(l),0)}if(a.ok||await ga(a),r!=null&&r.noResolveJson)return a;try{return await a.json()}catch(l){await ga(l)}}function it(t){var e;let s=null;mg(t)&&(s=Object.assign({},t),t.expires_at||(s.expires_at=Yp(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:s,user:r},error:null}}function ya(t){const e=it(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((s,r)=>s&&typeof r=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Qt(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function gg(t){return{data:t,error:null}}function yg(t){const{action_link:e,email_otp:s,hashed_token:r,redirect_to:n,verification_type:i}=t,o=An(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:s,hashed_token:r,redirect_to:n,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function ma(t){return t}function mg(t){return!!t.access_token&&!!t.refresh_token&&!!t.expires_in}const zn=["global","local","others"];class vg{constructor({url:e="",headers:s={},fetch:r,experimental:n}){this.url=e,this.headers=s,this.fetch=vc(r),this.experimental=n??{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,s=zn[0]){if(zn.indexOf(s)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${zn.join(", ")}`);try{return await K(this.fetch,"POST",`${this.url}/logout?scope=${s}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(U(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,s={}){try{return await K(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:s.data},headers:this.headers,redirectTo:s.redirectTo,xform:Qt})}catch(r){if(U(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:s}=e,r=An(e,["options"]),n=Object.assign(Object.assign({},r),s);return"newEmail"in r&&(n.new_email=r==null?void 0:r.newEmail,delete n.newEmail),await K(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:yg,redirectTo:s==null?void 0:s.redirectTo})}catch(s){if(U(s))return{data:{properties:null,user:null},error:s};throw s}}async createUser(e){try{return await K(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Qt})}catch(s){if(U(s))return{data:{user:null},error:s};throw s}}async listUsers(e){var s,r,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await K(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(s=e==null?void 0:e.page)===null||s===void 0?void 0:s.toString())!==null&&r!==void 0?r:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:ma});if(u.error)throw u.error;const h=await u.json(),d=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(y=>{const v=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),T=JSON.parse(y.split(";")[1].split("=")[1]);c[`${T}Page`]=v}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(U(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){It(e);try{return await K(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Qt})}catch(s){if(U(s))return{data:{user:null},error:s};throw s}}async updateUserById(e,s){It(e);try{return await K(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:s,headers:this.headers,xform:Qt})}catch(r){if(U(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,s=!1){It(e);try{return await K(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:s},xform:Qt})}catch(r){if(U(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){It(e.userId);try{const{data:s,error:r}=await K(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:s,error:r}}catch(s){if(U(s))return{data:null,error:s};throw s}}async _deleteFactor(e){It(e.userId),It(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(s){if(U(s))return{data:null,error:s};throw s}}async _listOAuthClients(e){var s,r,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await K(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(s=e==null?void 0:e.page)===null||s===void 0?void 0:s.toString())!==null&&r!==void 0?r:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:ma});if(u.error)throw u.error;const h=await u.json(),d=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(y=>{const v=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),T=JSON.parse(y.split(";")[1].split("=")[1]);c[`${T}Page`]=v}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(U(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await K(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(U(s))return{data:null,error:s};throw s}}async _getOAuthClient(e){try{return await K(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(U(s))return{data:null,error:s};throw s}}async _updateOAuthClient(e,s){try{return await K(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(U(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(e){try{return await K(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(U(s))return{data:null,error:s};throw s}}async _regenerateOAuthClientSecret(e){try{return await K(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(U(s))return{data:null,error:s};throw s}}async _listCustomProviders(e){try{const s={};return e!=null&&e.type&&(s.type=e.type),await K(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:s,xform:r=>{var n;return{data:{providers:(n=r==null?void 0:r.providers)!==null&&n!==void 0?n:[]},error:null}}})}catch(s){if(U(s))return{data:{providers:[]},error:s};throw s}}async _createCustomProvider(e){try{return await K(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(U(s))return{data:null,error:s};throw s}}async _getCustomProvider(e){try{return await K(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(U(s))return{data:null,error:s};throw s}}async _updateCustomProvider(e,s){try{return await K(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(U(r))return{data:null,error:r};throw r}}async _deleteCustomProvider(e){try{return await K(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(U(s))return{data:null,error:s};throw s}}async _adminListPasskeys(e){ut(this.experimental),It(e.userId);try{return await K(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(U(s))return{data:null,error:s};throw s}}async _adminDeletePasskey(e){ut(this.experimental),It(e.userId),It(e.passkeyId);try{return await K(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(U(s))return{data:null,error:s};throw s}}}function va(t={}){return{getItem:e=>t[e]||null,setItem:(e,s)=>{t[e]=s},removeItem:e=>{delete t[e]}}}const wt={debug:!!(globalThis&&mc()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class bc extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class ba extends bc{}async function bg(t,e,s){wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;let n;e>0&&(n=setTimeout(()=>{r.abort(),wt.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e)),await Promise.resolve();try{return await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async i=>{if(i){clearTimeout(n),wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await s()}finally{wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new ba(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(wt.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}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"),clearTimeout(n),await s()}})}catch(i){if(e>0&&clearTimeout(n),i!==null&&typeof i=="object"&&"name"in i&&i.name==="AbortError"&&e>0){if(r.signal.aborted)return wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",t),console.warn(`@supabase/gotrue-js: Lock "${t}" was not released within ${e}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,{mode:"exclusive",steal:!0},async o=>{if(o){wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",t,o.name);try{return await s()}finally{wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",t,o.name)}}else return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await s()}));throw wt.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",t),new ba(`Lock "${t}" was released because another request stole it`)}throw i}}function _g(){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)}}function _c(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function wg(t){return parseInt(t,16)}function Sg(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function kg(t){var e;const{chainId:s,domain:r,expirationTime:n,issuedAt:i=new Date,nonce:o,notBefore:a,requestId:l,resources:c,scheme:u,uri:h,version:d}=t;{if(!Number.isInteger(s))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${s}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(d!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
57
+ `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const f=_c(t.address),y=u?`${u}://${r}`:r,v=t.statement?`${t.statement}
58
+ `:"",T=`${y} wants you to sign in with your Ethereum account:
59
+ ${f}
60
+
61
+ ${v}`;let A=`URI: ${h}
62
+ Version: ${d}
63
+ Chain ID: ${s}${o?`
64
+ Nonce: ${o}`:""}
65
+ Issued At: ${i.toISOString()}`;if(n&&(A+=`
66
+ Expiration Time: ${n.toISOString()}`),a&&(A+=`
67
+ Not Before: ${a.toISOString()}`),l&&(A+=`
68
+ Request ID: ${l}`),c){let _=`
69
+ Resources:`;for(const w of c){if(!w||typeof w!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${w}`);_+=`
70
+ - ${w}`}A+=_}return`${T}
71
+ ${A}`}class Re extends Error{constructor({message:e,code:s,cause:r,name:n}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(i=n??(r instanceof Error?r.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=s}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class an extends Re{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function Eg({error:t,options:e}){var s,r,n;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Re({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new Re({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new Re({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new Re({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Re({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Re({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new Re({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Re({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const o=window.location.hostname;if(wc(o)){if(i.rp.id!==o)return new Re({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Re({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new Re({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Re({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Re({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function xg({error:t,options:e}){const{publicKey:s}=e;if(!s)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Re({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Re({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(wc(r)){if(s.rpId!==r)return new Re({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Re({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Re({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Re({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Tg{createNewAbortSignal(){if(this.controller){const s=new Error("Cancelling existing WebAuthn API call for new one");s.name="AbortError",this.controller.abort(s)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const xi=new Tg;function _a(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:s,excludeCredentials:r}=t,n=An(t,["challenge","user","excludeCredentials"]),i=$s(e).buffer,o=Object.assign(Object.assign({},s),{id:$s(s.id).buffer}),a=Object.assign(Object.assign({},n),{challenge:i,user:o});if(r&&r.length>0){a.excludeCredentials=new Array(r.length);for(let l=0;l<r.length;l++){const c=r[l];a.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:$s(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return a}function wa(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:s}=t,r=An(t,["challenge","allowCredentials"]),n=$s(e).buffer,i=Object.assign(Object.assign({},r),{challenge:n});if(s&&s.length>0){i.allowCredentials=new Array(s.length);for(let o=0;o<s.length;o++){const a=s[o];i.allowCredentials[o]=Object.assign(Object.assign({},a),{id:$s(a.id).buffer,type:a.type||"public-key",transports:a.transports})}}return i}function Sa(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t;return{id:t.id,rawId:t.id,response:{attestationObject:us(new Uint8Array(t.response.attestationObject)),clientDataJSON:us(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function ka(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t,r=t.getClientExtensionResults(),n=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:us(new Uint8Array(n.authenticatorData)),clientDataJSON:us(new Uint8Array(n.clientDataJSON)),signature:us(new Uint8Array(n.signature)),userHandle:n.userHandle?us(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function wc(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function ln(){var t,e;return!!(Me()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Sc(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new an("Browser returned unexpected credential type",e)}:{data:null,error:new an("Empty credential response",e)}}catch(e){return{data:null,error:Eg({error:e,options:t})}}}async function kc(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new an("Browser returned unexpected credential type",e)}:{data:null,error:new an("Empty credential response",e)}}catch(e){return{data:null,error:xg({error:e,options:t})}}}const Ag={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},Rg={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function cn(...t){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),s=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),r={};for(const n of t)if(n)for(const i in n){const o=n[i];if(o!==void 0)if(Array.isArray(o))r[i]=o;else if(s(o))r[i]=o;else if(e(o)){const a=r[i];e(a)?r[i]=cn(a,o):r[i]=cn(o)}else r[i]=o}return r}function Og(t,e){return cn(Ag,t,e||{})}function Cg(t,e){return cn(Rg,t,e||{})}class Pg{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:s,friendlyName:r,signal:n},i){var o;try{const{data:a,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:s});if(!a)return{data:null,error:l};const c=n??xi.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:u}=a.webauthn.credential_options.publicKey;if(!u.name){const h=r;if(h)u.name=`${u.id}:${h}`;else{const f=(await this.client.getUser()).data.user,y=((o=f==null?void 0:f.user_metadata)===null||o===void 0?void 0:o.name)||(f==null?void 0:f.email)||(f==null?void 0:f.id)||"User";u.name=`${u.id}:${y}`}}u.displayName||(u.displayName=u.name)}switch(a.webauthn.type){case"create":{const u=Og(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:h,error:d}=await Sc({publicKey:u,signal:c});return h?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:h}},error:null}:{data:null,error:d}}case"request":{const u=Cg(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:h,error:d}=await kc(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:u,signal:c}));return h?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:h}},error:null}:{data:null,error:d}}}}catch(a){return U(a)?{data:null,error:a}:{data:null,error:new dt("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:s,webauthn:r}){return this.client.mfa.verify({factorId:s,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!s)return{data:null,error:new _r("rpId is required for WebAuthn authentication")};try{if(!ln())return{data:null,error:new dt("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this.challenge({factorId:e,webauthn:{rpId:s,rpOrigins:r},signal:n},{request:i});if(!o)return{data:null,error:a};const{webauthn:l}=o;return this._verify({factorId:e,challengeId:o.challengeId,webauthn:{type:l.type,rpId:s,rpOrigins:r,credential_response:l.credential_response}})}catch(o){return U(o)?{data:null,error:o}:{data:null,error:new dt("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!s)return{data:null,error:new _r("rpId is required for WebAuthn registration")};try{if(!ln())return{data:null,error:new dt("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this._enroll({friendlyName:e});if(!o)return await this.client.mfa.listFactors().then(u=>{var h;return(h=u.data)===null||h===void 0?void 0:h.all.find(d=>d.factor_type==="webauthn"&&d.friendly_name===e&&d.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u==null?void 0:u.id}):void 0),{data:null,error:a};const{data:l,error:c}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:s,rpOrigins:r},signal:n},{create:i});return l?this._verify({factorId:o.id,challengeId:l.challengeId,webauthn:{rpId:s,rpOrigins:r,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(o){return U(o)?{data:null,error:o}:{data:null,error:new dt("Unexpected error in register",o)}}}}_g();const Ig={url:Lp,storageKey:Up,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Dp,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function Ea(t,e,s){return await s()}const ws={};class wr{get jwks(){var e,s;return(s=(e=ws[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(e){ws[this.storageKey]=Object.assign(Object.assign({},ws[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,s;return(s=(e=ws[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){ws[this.storageKey]=Object.assign(Object.assign({},ws[this.storageKey]),{cachedAt:e})}constructor(e){var s,r,n,i;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=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;const o=Object.assign(Object.assign({},Ig),e);if(this.storageKey=o.storageKey,this.instanceID=(s=wr.nextInstanceID[this.storageKey])!==null&&s!==void 0?s:0,wr.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!o.debug,typeof o.debug=="function"&&(this.logger=o.debug),this.instanceID>0&&Me()){const a=`${this._logPrefix()} 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.`;console.warn(a),this.logDebugMessages&&console.trace(a)}if(this.persistSession=o.persistSession,this.autoRefreshToken=o.autoRefreshToken,this.experimental=(r=o.experimental)!==null&&r!==void 0?r:{},this.admin=new vg({url:o.url,headers:o.headers,fetch:o.fetch,experimental:this.experimental}),this.url=o.url,this.headers=o.headers,this.fetch=vc(o.fetch),this.lock=o.lock||Ea,this.detectSessionInUrl=o.detectSessionInUrl,this.flowType=o.flowType,this.hasCustomAuthorizationHeader=o.hasCustomAuthorizationHeader,this.throwOnError=o.throwOnError,this.lockAcquireTimeout=o.lockAcquireTimeout,o.lock?this.lock=o.lock:this.persistSession&&Me()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=bg:this.lock=Ea,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),webauthn:new Pg(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(o.storage?this.storage=o.storage:mc()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=va(this.memoryStorage)),o.userStorage&&(this.userStorage=o.userStorage)):(this.memoryStorage={},this.storage=va(this.memoryStorage)),Me()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(i=this.broadcastChannel)===null||i===void 0||i.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a);try{await this._notifyAllSubscribers(a.data.event,a.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}o.skipAutoInitialize||this.initialize().catch(a=>{this._debug("#initialize()","error",a)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${pc}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let s={},r="none";if(Me()&&(s=Qp(window.location.href),this._isImplicitGrantCallback(s)?r="implicit":await this._isPKCECallback(s)&&(r="pkce")),Me()&&this.detectSessionInUrl&&r!=="none"){const{data:n,error:i}=await this._getSessionFromURL(s,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),qp(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{error:i}}const{session:o,redirectType:a}=n;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(s){return U(s)?this._returnResult({error:s}):this._returnResult({error:new dt("Unexpected error during initialization",s)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var s,r,n;try{const i=await K(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.captchaToken}},xform:it}),{data:o,error:a}=i;if(a||!o)return this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(U(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var s,r,n;try{let i;if("email"in e){const{email:u,password:h,options:d}=e;let f=null,y=null;this.flowType==="pkce"&&([f,y]=await _s(this.storage,this.storageKey)),i=await K(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:d==null?void 0:d.emailRedirectTo,body:{email:u,password:h,data:(s=d==null?void 0:d.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:f,code_challenge_method:y},xform:it})}else if("phone"in e){const{phone:u,password:h,options:d}=e;i=await K(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:h,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},channel:(n=d==null?void 0:d.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:it})}else throw new Dr("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return await Be(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(await Be(this.storage,`${this.storageKey}-code-verifier`),U(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let s;if("email"in e){const{email:i,password:o,options:a}=e;s=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:ya})}else if("phone"in e){const{phone:i,password:o,options:a}=e;s=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:ya})}else throw new Dr("You must provide either an email or phone number and a password");const{data:r,error:n}=s;if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!r||!r.session||!r.user){const i=new bs;return this._returnResult({data:{user:null,session:null},error:i})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:n})}catch(s){if(U(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOAuth(e){var s,r,n,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:s}=e;switch(s){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${s}"`)}}async signInWithEthereum(e){var s,r,n,i,o,a,l,c,u,h,d;let f,y;if("message"in e)f=e.message,y=e.signature;else{const{chain:v,wallet:T,statement:A,options:_}=e;let w;if(Me())if(typeof T=="object")w=T;else{const X=window;if("ethereum"in X&&typeof X.ethereum=="object"&&"request"in X.ethereum&&typeof X.ethereum.request=="function")w=X.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) 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: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof T!="object"||!(_!=null&&_.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");w=T}const C=new URL((s=_==null?void 0:_.url)!==null&&s!==void 0?s:window.location.href),W=await w.request({method:"eth_requestAccounts"}).then(X=>X).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!W||W.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const re=_c(W[0]);let Y=(r=_==null?void 0:_.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!Y){const X=await w.request({method:"eth_chainId"});Y=wg(X)}const te={domain:C.host,address:re,statement:A,uri:C.href,version:"1",chainId:Y,nonce:(n=_==null?void 0:_.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(o=(i=_==null?void 0:_.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=_==null?void 0:_.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=_==null?void 0:_.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=_==null?void 0:_.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=_==null?void 0:_.signInWithEthereum)===null||u===void 0?void 0:u.resources};f=kg(te),y=await w.request({method:"personal_sign",params:[Sg(f),re]})}try{const{data:v,error:T}=await K(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:y},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(d=e.options)===null||d===void 0?void 0:d.captchaToken}}:null),xform:it});if(T)throw T;if(!v||!v.session||!v.user){const A=new bs;return this._returnResult({data:{user:null,session:null},error:A})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:T})}catch(v){if(U(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async signInWithSolana(e){var s,r,n,i,o,a,l,c,u,h,d,f;let y,v;if("message"in e)y=e.message,v=e.signature;else{const{chain:T,wallet:A,statement:_,options:w}=e;let C;if(Me())if(typeof A=="object")C=A;else{const re=window;if("solana"in re&&typeof re.solana=="object"&&("signIn"in re.solana&&typeof re.solana.signIn=="function"||"signMessage"in re.solana&&typeof re.solana.signMessage=="function"))C=re.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 A!="object"||!(w!=null&&w.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");C=A}const W=new URL((s=w==null?void 0:w.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in C&&C.signIn){const re=await C.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},w==null?void 0:w.signInWithSolana),{version:"1",domain:W.host,uri:W.href}),_?{statement:_}:null));let Y;if(Array.isArray(re)&&re[0]&&typeof re[0]=="object")Y=re[0];else if(re&&typeof re=="object"&&"signedMessage"in re&&"signature"in re)Y=re;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in Y&&"signature"in Y&&(typeof Y.signedMessage=="string"||Y.signedMessage instanceof Uint8Array)&&Y.signature instanceof Uint8Array)y=typeof Y.signedMessage=="string"?Y.signedMessage:new TextDecoder().decode(Y.signedMessage),v=Y.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in C)||typeof C.signMessage!="function"||!("publicKey"in C)||typeof C!="object"||!C.publicKey||!("toBase58"in C.publicKey)||typeof C.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");y=[`${W.host} wants you to sign in with your Solana account:`,C.publicKey.toBase58(),..._?["",_,""]:[""],"Version: 1",`URI: ${W.href}`,`Issued At: ${(n=(r=w==null?void 0:w.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((i=w==null?void 0:w.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${w.signInWithSolana.notBefore}`]:[],...!((o=w==null?void 0:w.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${w.signInWithSolana.expirationTime}`]:[],...!((a=w==null?void 0:w.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${w.signInWithSolana.chainId}`]:[],...!((l=w==null?void 0:w.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${w.signInWithSolana.nonce}`]:[],...!((c=w==null?void 0:w.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${w.signInWithSolana.requestId}`]:[],...!((h=(u=w==null?void 0:w.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||h===void 0)&&h.length?["Resources",...w.signInWithSolana.resources.map(Y=>`- ${Y}`)]:[]].join(`
72
+ `);const re=await C.signMessage(new TextEncoder().encode(y),"utf8");if(!re||!(re instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");v=re}}try{const{data:T,error:A}=await K(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:y,signature:us(v)},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:it});if(A)throw A;if(!T||!T.session||!T.user){const _=new bs;return this._returnResult({data:{user:null,session:null},error:_})}return T.session&&(await this._saveSession(T.session),await this._notifyAllSubscribers("SIGNED_IN",T.session)),this._returnResult({data:Object.assign({},T),error:A})}catch(T){if(U(T))return this._returnResult({data:{user:null,session:null},error:T});throw T}}async _exchangeCodeForSession(e){const s=await is(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(s??"").split("/");try{if(!r&&this.flowType==="pkce")throw new Vp;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:r},xform:it});if(await Be(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new bs;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers(n==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:o})}catch(i){if(await Be(this.storage,`${this.storageKey}-code-verifier`),U(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:s,provider:r,token:n,access_token:i,nonce:o}=e,a=await K(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:n,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:it}),{data:l,error:c}=a;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new bs;return this._returnResult({data:{user:null,session:null},error:u})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(s){if(U(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,r,n,i,o;try{if("email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await _s(this.storage,this.storageKey));const{error:h}=await K(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(s=l==null?void 0:l.data)!==null&&s!==void 0?s:{},create_user:(r=l==null?void 0:l.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:h})}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await K(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},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 this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u})}throw new Dr("You must provide either an email or phone number.")}catch(a){if(await Be(this.storage,`${this.storageKey}-code-verifier`),U(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var s,r;try{let n,i;"options"in e&&(n=(s=e.options)===null||s===void 0?void 0:s.redirectTo,i=(r=e.options)===null||r===void 0?void 0:r.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:n,xform:it});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(U(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var s,r,n,i,o;try{let a=null,l=null;this.flowType==="pkce"&&([a,l]=await _s(this.storage,this.storageKey));const c=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:(r=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&r!==void 0?r:void 0}),!((n=e==null?void 0:e.options)===null||n===void 0)&&n.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:l}),headers:this.headers,xform:gg});return!((i=c.data)===null||i===void 0)&&i.url&&Me()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(a){if(await Be(this.storage,`${this.storageKey}-code-verifier`),U(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)throw r;if(!s)throw new je;const{error:n}=await K(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(U(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const s=`${this.url}/resend`;if("email"in e){const{email:r,type:n,options:i}=e,{error:o}=await K(this.fetch,"POST",s,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:r,type:n,options:i}=e,{data:o,error:a}=await K(this.fetch,"POST",s,{headers:this.headers,body:{phone:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a})}throw new Dr("You must provide either an email or phone number and a type")}catch(s){if(U(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await r,await s()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=s();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await r}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 s=await this.__loadSession();return await e(s)}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 s=await is(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?e=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<Wn:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const o=await is(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=Jn()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=hg(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const s=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await K(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Qt}):await this._useSession(async s=>{var r,n,i;const{data:o,error:a}=s;if(a)throw a;return!(!((r=o.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new je}:await K(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:Qt})})}catch(s){if(U(s))return Ur(s)&&(await this._removeSession(),await Be(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:s});throw s}}async updateUser(e,s={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async r=>{const{data:n,error:i}=r;if(i)throw i;if(!n.session)throw new je;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await _s(this.storage,this.storageKey));const{data:c,error:u}=await K(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s==null?void 0:s.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:Qt});if(u)throw u;return o.user=c.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(r){if(await Be(this.storage,`${this.storageKey}-code-verifier`),U(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new je;const s=Date.now()/1e3;let r=s,n=!0,i=null;const{payload:o}=Mr(e.access_token);if(o.exp&&(r=o.exp,n=r<=s),n){const{data:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({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)return this._returnResult({data:{user:null,session:null},error:l});i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-s,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(s){if(U(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var r;if(!e){const{data:o,error:a}=s;if(a)throw a;e=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new je;const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(U(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){var r;try{if(!Me())throw new Br("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Br(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new ca("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Br("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new ca("No code detected.");const{data:w,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const W=new URL(window.location.href);return W.searchParams.delete("code"),window.history.replaceState(window.history.state,"",W.toString()),{data:{session:w.session,redirectType:(r=w.redirectType)!==null&&r!==void 0?r:null},error:null}}const{provider_token:n,provider_refresh_token:i,access_token:o,refresh_token:a,expires_in:l,expires_at:c,token_type:u}=e;if(!o||!l||!a||!u)throw new Br("No session defined in URL");const h=Math.round(Date.now()/1e3),d=parseInt(l);let f=h+d;c&&(f=parseInt(c));const y=f-h;y*1e3<=Ts&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${d}s`);const v=f-d;h-v>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",v,f,h):h-v<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",v,f,h);const{data:T,error:A}=await this._getUser(o);if(A)throw A;const _={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:d,expires_at:f,refresh_token:a,token_type:u,user:T.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:_,redirectType:e.type},error:null})}catch(n){if(U(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const s=await is(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i&&!Ur(i))return this._returnResult({error:i});const o=(r=n.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(Fp(a)&&(a.status===404||a.status===401||a.status===403)||Ur(a)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await Be(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=Xp(),r={id:s,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,r),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async s=>{var r,n;try{const{data:{session:i},error:o}=s;if(o)throw o;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),Ur(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,s={}){let r=null,n=null;this.flowType==="pkce"&&([r,n]=await _s(this.storage,this.storageKey,!0));try{return await K(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:n,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(i){if(await Be(this.storage,`${this.storageKey}-code-verifier`),U(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:s,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var s;try{const{data:r,error:n}=await this._useSession(async i=>{var o,a,l,c,u;const{data:h,error:d}=i;if(d)throw d;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:(u=(c=h.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(n)throw n;return Me()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),this._returnResult({data:{provider:e.provider,url:r==null?void 0:r.url},error:null})}catch(r){if(U(r))return this._returnResult({data:{provider:e.provider,url:null},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var r;try{const{error:n,data:{session:i}}=s;if(n)throw n;const{options:o,provider:a,token:l,access_token:c,nonce:u}=e,h=await K(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=i==null?void 0:i.access_token)!==null&&r!==void 0?r:void 0,body:{provider:a,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:it}),{data:d,error:f}=h;return f?this._returnResult({data:{user:null,session:null},error:f}):!d||!d.session||!d.user?this._returnResult({data:{user:null,session:null},error:new bs}):(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("USER_UPDATED",d.session)),this._returnResult({data:d,error:f}))}catch(n){if(await Be(this.storage,`${this.storageKey}-code-verifier`),U(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var r,n;const{data:i,error:o}=s;if(o)throw o;return await K(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0})})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async _refreshAccessToken(e){const s=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{const r=Date.now();return await tg(async n=>(n>0&&await eg(200*Math.pow(2,n-1)),this._debug(s,"refreshing attempt",n),await K(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:it})),(n,i)=>{const o=200*Math.pow(2,n);return i&&Gn(i)&&Date.now()+o-r<Ts})}catch(r){if(this._debug(s,"error",r),U(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(s,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,s){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:s.redirectTo,scopes:s.scopes,queryParams:s.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",s,"url",r),Me()&&!s.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,s;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const n=await is(this.storage,this.storageKey);if(n&&this.userStorage){let o=await is(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await As(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:Jn()}else if(n&&!n.user&&!n.user){const o=await is(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(n.user=o.user,await Be(this.storage,this.storageKey+"-user"),await As(this.storage,this.storageKey,n)):n.user=Jn()}if(this._debug(r,"session from storage",n),!this._isValidSession(n)){this._debug(r,"session is not valid"),n!==null&&await this._removeSession();return}const i=((s=n.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<Wn;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${Wn}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),Gn(o)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(n.access_token);!a&&(o!=null&&o.user)?(n.user=o.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(r,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(r,"error",n),console.error(n);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var s,r;if(!e)throw new je;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new Cn;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new je;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const a={data:i.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(i){if(this._debug(n,"error",i),U(i)){const o={data:null,error:i};return Gn(i)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(o),o}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(i),i}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,s,r=!0){const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",s,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:s});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,s)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;a<i.length;a+=1)console.error(i[a]);throw i[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Be(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),r=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&s.user&&await As(this.userStorage,this.storageKey+"-user",{user:s.user});const n=Object.assign({},s);delete n.user;const i=pa(n);await As(this.storage,this.storageKey,i)}else{const n=pa(s);await As(this.storage,this.storageKey,n)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Be(this.storage,this.storageKey),await Be(this.storage,this.storageKey+"-code-verifier"),await Be(this.storage,this.storageKey+"-user"),this.userStorage&&await Be(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Me()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(s){console.error("removing visibilitychange callback failed",s)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ts);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const s=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const s=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,s&&clearTimeout(s)}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 s=>{const{data:{session:r}}=s;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((r.expires_at*1e3-e)/Ts);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${Ts}ms, refresh threshold is ${wi} ticks`),n<=wi&&await this._callRefreshToken(r.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof bc)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Me()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"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,s,r){const n=[`provider=${encodeURIComponent(s)}`];if(r!=null&&r.redirectTo&&n.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&n.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,o]=await _s(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});n.push(a.toString())}if(r!=null&&r.queryParams){const i=new URLSearchParams(r.queryParams);n.push(i.toString())}return r!=null&&r.skipBrowserRedirect&&n.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;return i?this._returnResult({data:null,error:i}):await K(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token})})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var r,n;const{data:i,error:o}=s;if(o)return this._returnResult({data:null,error:o});const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await K(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l==null?void 0:l.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Sa(e.webauthn.credential_response):ka(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await K(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:l}))})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=await K(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});if(o.error)return o;const{data:a}=o;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:_a(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:wa(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:r}=await this.getUser();if(r)return{data:null,error:r};const n={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=s==null?void 0:s.factors)!==null&&e!==void 0?e:[])n.all.push(i),i.status==="verified"&&n[i.factor_type].push(i);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var s,r,n,i;if(e)try{const{payload:f}=Mr(e);let y=null;f.aal&&(y=f.aal);let v=y;const{data:{user:T},error:A}=await this.getUser(e);if(A)return this._returnResult({data:null,error:A});((r=(s=T==null?void 0:T.factors)===null||s===void 0?void 0:s.filter(C=>C.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(v="aal2");const w=f.amr||[];return{data:{currentLevel:y,nextLevel:v,currentAuthenticationMethods:w},error:null}}catch(f){if(U(f))return this._returnResult({data:null,error:f});throw f}const{data:{session:o},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=Mr(o.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((i=(n=o.user.factors)===null||n===void 0?void 0:n.filter(f=>f.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(u="aal2");const d=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:d},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;return n?this._returnResult({data:null,error:n}):r?await K(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new je})})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new je});const o=await K(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&Me()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(U(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(e,s){try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new je});const o=await K(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&Me()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(U(r))return this._returnResult({data:null,error:r});throw r}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;return r?this._returnResult({data:null,error:r}):s?await K(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new je})})}catch(e){if(U(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;return n?this._returnResult({data:null,error:n}):r?(await K(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new je})})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let r=s.keys.find(a=>a.kid===e);if(r)return r;const n=Date.now();if(r=this.jwks.keys.find(a=>a.kid===e),r&&this.jwks_cached_at+Mp>n)return r;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=n,r=i.keys.find(a=>a.kid===e),!r)?null:r}async getClaims(e,s={}){try{let r=e;if(!r){const{data:f,error:y}=await this.getSession();if(y||!f.session)return this._returnResult({data:null,error:y});r=f.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=Mr(r);s!=null&&s.allowExpired||lg(i.exp);const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,s!=null&&s.keys?{keys:s.keys}:s==null?void 0:s.jwks);if(!c){const{error:f}=await this.getUser(r);if(f)throw f;return{data:{claims:i,header:n,signature:o},error:null}}const u=cg(n.alg),h=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,o,zp(`${a}.${l}`)))throw new Ei("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(r){if(U(r))return this._returnResult({data:null,error:r});throw r}}async signInWithPasskey(e){var s,r,n;ut(this.experimental);try{if(!ln())return this._returnResult({data:null,error:new dt("Browser does not support WebAuthn",null)});const{data:i,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}});if(o||!i)return this._returnResult({data:null,error:o});const a=wa(i.options),l=(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&n!==void 0?n:xi.createNewAbortSignal(),{data:c,error:u}=await kc({publicKey:a,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new dt("WebAuthn ceremony failed",null)});const h=ka(c);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:h})}catch(i){if(U(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(e){var s,r;ut(this.experimental);try{if(!ln())return this._returnResult({data:null,error:new dt("Browser does not support WebAuthn",null)});const{data:n,error:i}=await this._startPasskeyRegistration();if(i||!n)return this._returnResult({data:null,error:i});const o=_a(n.options),a=(r=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.signal)!==null&&r!==void 0?r:xi.createNewAbortSignal(),{data:l,error:c}=await Sc({publicKey:o,signal:a});if(c||!l)return this._returnResult({data:null,error:c??new dt("WebAuthn ceremony failed",null)});const u=Sa(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:u})}catch(n){if(U(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){ut(this.experimental);try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new je});const{data:n,error:i}=await K(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:s.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(U(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){ut(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new je});const{data:i,error:o}=await K(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async _startPasskeyAuthentication(e){var s;ut(this.experimental);try{const{data:r,error:n}=await K(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:r,error:null})}catch(r){if(U(r))return this._returnResult({data:null,error:r});throw r}}async _verifyPasskeyAuthentication(e){ut(this.experimental);try{const{data:s,error:r}=await K(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:it});return r?this._returnResult({data:null,error:r}):(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:s,error:null}))}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async _listPasskeys(){ut(this.experimental);try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new je});const{data:n,error:i}=await K(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:s.access_token,xform:o=>({data:o,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(U(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){ut(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new je});const{data:i,error:o}=await K(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}async _deletePasskey(e){ut(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new je});const{error:i}=await K(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(s){if(U(s))return this._returnResult({data:null,error:s});throw s}}}wr.nextInstanceID={};const jg=wr,$g="2.105.4";let Ys="";typeof Deno<"u"?Ys="deno":typeof document<"u"?Ys="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Ys="react-native":Ys="node";const Ng={"X-Client-Info":`supabase-js-${Ys}/${$g}`},Lg={headers:Ng},Ug={schema:"public"},Dg={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Bg={};function Sr(t){"@babel/helpers - typeof";return Sr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Sr(t)}function Mg(t,e){if(Sr(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(Sr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Hg(t){var e=Mg(t,"string");return Sr(e)=="symbol"?e:e+""}function Fg(t,e,s){return(e=Hg(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function xa(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,r)}return s}function ke(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?xa(Object(s),!0).forEach(function(r){Fg(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):xa(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}const qg=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Vg=()=>Headers,Kg=(t,e,s)=>{const r=qg(s),n=Vg();return async(i,o)=>{var a;const l=(a=await e())!==null&&a!==void 0?a:t;let c=new n(o==null?void 0:o.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),r(i,ke(ke({},o),{},{headers:c}))}};function Wg(t){return t.endsWith("/")?t:t+"/"}function Gg(t,e){var s,r;const{db:n,auth:i,realtime:o,global:a}=t,{db:l,auth:c,realtime:u,global:h}=e,d={db:ke(ke({},l),n),auth:ke(ke({},c),i),realtime:ke(ke({},u),o),storage:{},global:ke(ke(ke({},h),a),{},{headers:ke(ke({},(s=h==null?void 0:h.headers)!==null&&s!==void 0?s:{}),(r=a==null?void 0:a.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return t.accessToken?d.accessToken=t.accessToken:delete d.accessToken,d}function Jg(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Wg(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var zg=class extends jg{constructor(t){super(t)}},Yg=class{constructor(t,e,s){var r,n;this.supabaseUrl=t,this.supabaseKey=e;const i=Jg(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,a={db:Ug,realtime:Bg,auth:ke(ke({},Dg),{},{storageKey:o}),global:Lg},l=Gg(s??{},a);if(this.storageKey=(r=l.auth.storageKey)!==null&&r!==void 0?r:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=Kg(e,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(ke({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new Sf(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new Np(this.storageUrl.href,this.headers,this.fetch,s==null?void 0:s.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new df(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},s={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,s)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,s;if(t.accessToken)return await t.accessToken();const{data:r}=await t.auth.getSession();return(e=(s=r.session)===null||s===void 0?void 0:s.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:n,storageKey:i,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:h,skipAutoInitialize:d},f,y){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new zg({url:this.authUrl.href,headers:ke(ke({},v),f),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:n,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,fetch:y,lockAcquireTimeout:h,skipAutoInitialize:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(T=>T.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new np(this.realtimeUrl.href,ke(ke({},t),{},{params:ke(ke({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0:e.access_token)})}_handleTokenChanged(t,e,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?(this.changedAccessToken=s,this.realtime.setAuth(s)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const Xg=(t,e,s)=>new Yg(t,e,s);function Qg(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const s=e.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}Qg()&&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");let Hr=null,Fr=null;async function Ec(){return Fr||(Fr=await(await fetch("/api/auth/config")).json(),Fr)}async function Yn(){if(Hr)return Hr;const t=await Ec();return!t.authEnabled||!t.supabaseUrl||!t.supabaseAnonKey?null:(Hr=Xg(t.supabaseUrl,t.supabaseAnonKey),Hr)}const Or=Fl("auth",()=>{const t=ie(null),e=ie(null),s=ie(!1),r=ie(!1),n=ie(!1);async function i(){var d;const c=await Ec();if(n.value=c.authEnabled,!c.authEnabled){r.value=!0;return}const u=await Yn();if(!u){r.value=!0;return}const{data:h}=await u.auth.getSession();e.value=h.session,t.value=((d=h.session)==null?void 0:d.user)??null,u.auth.onAuthStateChange((f,y)=>{e.value=y,t.value=(y==null?void 0:y.user)??null}),r.value=!0}async function o(c,u){const h=await Yn();if(!h)return"Auth not configured";s.value=!0;try{const{error:d}=await h.auth.signInWithPassword({email:c,password:u});return d?d.message:null}finally{s.value=!1}}async function a(){const c=await Yn();c&&await c.auth.signOut(),t.value=null,e.value=null}function l(){var c;return((c=e.value)==null?void 0:c.access_token)??null}return{user:t,session:e,loading:s,initialized:r,authEnabled:n,init:i,signIn:o,signOut:a,getAccessToken:l}}),Zg={key:0,class:"w-64 bg-gray-900 border-r border-gray-800 flex flex-col"},ey={class:"flex-1 py-6"},ty={class:"space-y-2 px-3"},sy={key:0,class:"p-4 border-t border-gray-800"},ry={class:"text-xs text-gray-500 truncate mb-2"},ny=Vt({__name:"AppNav",setup(t){const e=lf(),s=sc(),r=Or();async function n(){await r.signOut(),s.push("/login")}return(i,o)=>me(e).name!=="login"?(j(),$("nav",Zg,[o[4]||(o[4]=b("div",{class:"p-6 border-b border-gray-800"},[b("h1",{class:"text-xl font-bold text-blue-400"},"IO"),b("p",{class:"text-xs text-gray-500"},"Terminal Assistant")],-1)),b("div",ey,[b("ul",ty,[b("li",null,[Ie(me(Js),{to:"/chat",class:Ne(["block px-4 py-2 rounded hover:bg-gray-800 transition-colors",{"bg-blue-900 text-blue-300":me(e).name==="chat"}])},{default:Ks(()=>[...o[0]||(o[0]=[Xe(" 💬 Chat ",-1)])]),_:1},8,["class"])]),b("li",null,[Ie(me(Js),{to:"/skills",class:Ne(["block px-4 py-2 rounded hover:bg-gray-800 transition-colors",{"bg-blue-900 text-blue-300":me(e).name==="skills"}])},{default:Ks(()=>[...o[1]||(o[1]=[Xe(" ⚙️ Skills ",-1)])]),_:1},8,["class"])]),b("li",null,[Ie(me(Js),{to:"/squads",class:Ne(["block px-4 py-2 rounded hover:bg-gray-800 transition-colors",{"bg-blue-900 text-blue-300":me(e).name==="squads"}])},{default:Ks(()=>[...o[2]||(o[2]=[Xe(" 👥 Squads ",-1)])]),_:1},8,["class"])]),b("li",null,[Ie(me(Js),{to:"/activity",class:Ne(["block px-4 py-2 rounded hover:bg-gray-800 transition-colors",{"bg-blue-900 text-blue-300":me(e).name==="activity"}])},{default:Ks(()=>[...o[3]||(o[3]=[Xe(" 📊 Activity ",-1)])]),_:1},8,["class"])])])]),me(r).authEnabled&&me(r).user?(j(),$("div",sy,[b("p",ry,F(me(r).user.email),1),b("button",{onClick:n,class:"w-full px-3 py-1.5 text-sm text-gray-400 hover:text-white hover:bg-gray-800 rounded transition-colors"}," Sign out ")])):de("",!0)])):de("",!0)}}),iy={class:"flex h-screen bg-gray-950"},oy={class:"flex-1 overflow-auto"},ay=Vt({__name:"App",setup(t){return(e,s)=>(j(),$("div",iy,[Ie(ny),b("main",oy,[Ie(me(tc))])]))}}),ly=Fl("chat",()=>{const t=ie([]),e=ie(!1);function s(i){t.value.push(i)}function r(i){const o=t.value[t.value.length-1];o&&o.role==="assistant"&&(o.content+=i)}function n(i){const o=t.value[t.value.length-1];o&&o.role==="assistant"&&(o.streaming=i)}return{messages:t,isLoading:e,addMessage:s,appendToLast:r,setLastStreaming:n}});async function ot(t,e){const s=Or(),r=s.getAccessToken(),n=new Headers(e==null?void 0:e.headers);r&&n.set("Authorization",`Bearer ${r}`);const i=await fetch(t,{...e,headers:n});return i.status===401&&s.authEnabled&&await s.signOut(),i}function Gi(t){const s=Or().getAccessToken();if(!s)return t;const r=t.includes("?")?"&":"?";return`${t}${r}token=${encodeURIComponent(s)}`}const cy={class:"flex flex-col h-full"},uy={key:0,class:"text-gray-600 text-sm text-center mt-12"},hy={key:0,class:"inline-block w-2 h-4 bg-blue-400 ml-1 animate-pulse"},dy={key:1,class:"flex justify-start"},fy={class:"border-t border-gray-800 p-4"},py=["disabled"],gy=["disabled"],yy=["disabled"],my=Vt({__name:"ChatView",setup(t){const e=ly(),s=ie(""),r=ie(!1),n=ie(null);async function i(){if(!r.value){r.value=!0;try{await ot("/api/orchestrator/abort",{method:"POST"})}catch{}finally{r.value=!1}}}const o=Ge(()=>e.messages.some(c=>c.streaming));function a(){Tr(()=>{n.value&&(n.value.scrollTop=n.value.scrollHeight)})}Zt(()=>e.messages.length,a);async function l(){const c=s.value.trim();if(!c||e.isLoading)return;s.value="",e.isLoading=!0,e.addMessage({id:crypto.randomUUID(),role:"user",content:c}),e.addMessage({id:crypto.randomUUID(),role:"assistant",content:"",streaming:!0}),a();const u=new EventSource(Gi("/api/events"));u.onmessage=h=>{try{const d=JSON.parse(h.data);d.type==="delta"?(e.appendToLast(d.text),a()):d.type==="done"&&(e.setLastStreaming(!1),e.isLoading=!1,u.close(),a())}catch{}},u.onerror=()=>{e.setLastStreaming(!1),e.isLoading=!1,u.close()};try{await ot("/api/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:c})})}catch{e.appendToLast(`
73
+
74
+ [Error: failed to reach IO]`),e.setLastStreaming(!1),e.isLoading=!1,u.close()}}return(c,u)=>(j(),$("div",cy,[b("div",{ref_key:"messagesEl",ref:n,class:"flex-1 overflow-y-auto p-6 space-y-4"},[me(e).messages.length===0?(j(),$("div",uy," Send a message to start chatting with IO ")):de("",!0),(j(!0),$($e,null,es(me(e).messages,h=>(j(),$("div",{key:h.id,class:Ne(["flex",h.role==="user"?"justify-end":"justify-start"])},[b("div",{class:Ne(["max-w-[75%] px-4 py-3 rounded-lg text-sm whitespace-pre-wrap",h.role==="user"?"bg-blue-700 text-white":"bg-gray-800 text-gray-100 border border-gray-700"])},[b("span",null,F(h.content),1),h.streaming?(j(),$("span",hy)):de("",!0)],2)],2))),128)),me(e).isLoading&&!o.value?(j(),$("div",dy,[...u[1]||(u[1]=[b("div",{class:"bg-gray-800 border border-gray-700 px-4 py-3 rounded-lg text-sm text-gray-400 flex gap-1"},[b("span",{class:"animate-bounce",style:{"animation-delay":"0ms"}},"·"),b("span",{class:"animate-bounce",style:{"animation-delay":"150ms"}},"·"),b("span",{class:"animate-bounce",style:{"animation-delay":"300ms"}},"·")],-1)])])):de("",!0)],512),b("div",fy,[b("form",{onSubmit:pr(l,["prevent"]),class:"flex gap-3"},[ds(b("input",{"onUpdate:modelValue":u[0]||(u[0]=h=>s.value=h),type:"text",placeholder:"Message IO...",disabled:me(e).isLoading,class:"flex-1 bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50"},null,8,py),[[js,s.value]]),me(e).isLoading?(j(),$("button",{key:0,type:"button",onClick:i,disabled:r.value,class:"bg-red-600 hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed text-white px-4 py-2 rounded-lg text-sm transition-colors flex items-center gap-2",title:"Stop the orchestrator"},[u[2]||(u[2]=b("span",{class:"inline-block w-3 h-3 bg-white rounded-sm"},null,-1)),Xe(" "+F(r.value?"Stopping...":"Stop"),1)],8,gy)):(j(),$("button",{key:1,type:"submit",disabled:!s.value.trim(),class:"bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed text-white px-4 py-2 rounded-lg text-sm transition-colors"}," Send ",8,yy))],32)])]))}}),vy={class:"flex flex-col h-full bg-gray-950"},by={class:"flex-1 overflow-y-auto p-6"},_y={key:0,class:"text-gray-400 text-center py-12"},wy={key:1,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},Sy={key:2,class:"text-gray-400 text-center py-12"},ky={key:3,class:"grid gap-4"},Ey={class:"flex justify-between items-start mb-2"},xy={class:"font-bold text-gray-100"},Ty={class:"text-sm text-gray-500"},Ay={class:"text-sm text-gray-400 mb-3"},Ry={class:"text-xs text-gray-500"},Oy=Vt({__name:"SkillsView",setup(t){const e=ie([]),s=ie(!0),r=ie(null);return _n(async()=>{try{const n=await ot("/api/skills");if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const i=await n.json();e.value=i.skills}catch(n){r.value=n instanceof Error?n.message:"Failed to load skills"}finally{s.value=!1}}),(n,i)=>(j(),$("div",vy,[b("div",by,[i[0]||(i[0]=b("h2",{class:"text-2xl font-bold mb-6"},"Skills",-1)),s.value?(j(),$("div",_y," Loading skills... ")):r.value?(j(),$("div",wy,F(r.value),1)):e.value.length===0?(j(),$("div",Sy," No skills available ")):(j(),$("div",ky,[(j(!0),$($e,null,es(e.value,o=>(j(),$("div",{key:o.slug,class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-blue-500 transition-colors"},[b("div",Ey,[b("div",null,[b("h3",xy,F(o.name),1),b("p",Ty,F(o.slug),1)])]),b("p",Ay,F(o.description),1),b("p",Ry,F(o.path),1)]))),128))]))])]))}}),Cy={class:"flex flex-col h-full bg-gray-950"},Py={class:"flex-1 overflow-y-auto p-6"},Iy={class:"flex justify-between items-center mb-6"},jy={class:"space-y-3"},$y=["disabled"],Ny={key:0,class:"mt-2 text-red-400 text-sm"},Ly={key:1,class:"text-gray-400 text-center py-12"},Uy={key:2,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},Dy={key:3,class:"text-gray-400 text-center py-12"},By={key:4,class:"grid gap-4"},My=["onClick","aria-expanded"],Hy={class:"flex justify-between items-start mb-3"},Fy={class:"flex-1 flex items-center gap-2"},qy={class:"font-bold text-gray-100"},Vy={class:"text-sm text-gray-500"},Ky={class:"flex items-center gap-2"},Wy={key:0,class:"px-2 py-1 rounded text-xs font-medium bg-purple-900 text-purple-100"},Gy={class:"text-sm text-gray-400"},Jy={key:0,class:"mt-4 pt-4 border-t border-gray-700"},zy={class:"flex justify-between items-center text-xs text-gray-500 mb-3"},Yy={key:0},Xy={key:0,class:"text-gray-400 text-sm py-2"},Qy={key:1,class:"text-red-400 text-sm py-2"},Zy={key:2,class:"text-gray-500 text-sm italic py-2"},em={key:3,class:"space-y-2"},tm={class:"flex-1 min-w-0"},sm={class:"text-sm font-medium text-gray-100"},rm={class:"text-xs text-gray-500 ml-2"},nm=["onClick"],im=["onClick","disabled"],om={class:"bg-gray-900 border border-gray-700 rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col shadow-2xl"},am={class:"flex justify-between items-center p-4 border-b border-gray-700"},lm={class:"min-w-0"},cm={class:"text-lg font-bold text-gray-100 truncate"},um={class:"text-sm font-normal text-gray-400"},hm={class:"text-xs text-gray-500 mt-1 flex items-center gap-2"},dm={key:0,class:"bg-red-900 text-red-100 p-3 rounded"},fm={key:1,class:"text-gray-500 italic text-center py-8"},pm={class:"flex justify-between items-center mb-1"},gm={class:"text-blue-400"},ym={class:"text-gray-600 text-[10px]"},mm={class:"text-gray-200 whitespace-pre-wrap break-words"},vm=Vt({__name:"SquadsView",setup(t){const e={"a-team":"The A-Team",transformers:"Transformers",thundercats:"ThunderCats","gi-joe":"G.I. Joe",aliens:"Aliens",ghostbusters:"Ghostbusters"},s=ie([]),r=ie(!0),n=ie(null),i=ie(!1),o=ie(!1),a=ie(null),l=Bt({}),c=Bt({}),u=Bt({}),h=Bt({}),d=ie(new Set),f=ie(null),y=ie([]),v=ie(null),T=ie(!1),A=ie(null);let _=null;const w=Ge(()=>v.value?"Disconnected":T.value?"Live":"Connecting..."),C=I=>{try{return new Date(I).toLocaleTimeString()}catch{return""}},W=I=>{const G=I.data;if(!G||typeof G!="object")return"";if(typeof G.deltaContent=="string")return G.deltaContent;if(typeof G.content=="string")return G.content;if(typeof G.text=="string")return G.text;try{return JSON.stringify(G,null,2)}catch{return String(G)}},re=()=>{Tr(()=>{const I=A.value;I&&(I.scrollTop=I.scrollHeight)})},Y=I=>{if(!I.currentTaskId)return;te(),f.value=I,y.value=[],v.value=null,T.value=!1;const G=Gi(`/api/tasks/${encodeURIComponent(I.currentTaskId)}/events`),q=new EventSource(G);_=q,q.onopen=()=>{T.value=!0},q.onmessage=x=>{try{const P=JSON.parse(x.data);y.value.push(P),re()}catch{}},q.onerror=()=>{T.value=!1,y.value.length===0&&(v.value="Connection error. Retrying...")}},te=()=>{if(_){try{_.close()}catch{}_=null}f.value=null,y.value=[],v.value=null,T.value=!1};dl(()=>{te()});const X=async(I,G)=>{if(!d.value.has(G)){d.value=new Set(d.value).add(G);try{await ot(`/api/tasks/${encodeURIComponent(G)}/cancel`,{method:"POST"}),await Ze(I,!0)}catch(q){h[I]=q instanceof Error?q.message:"Failed to stop task"}finally{const q=new Set(d.value);q.delete(G),d.value=q}}},oe=ie({slug:"",name:"",projectPath:""}),Oe=I=>I?e[I]??I:"",Le=I=>new Date(I).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),Te=I=>!!l[I],Qe=async I=>{l[I]=!l[I],l[I]&&!c[I]&&!u[I]&&await Ze(I)},Ze=async(I,G=!1)=>{if(!(!G&&u[I])){u[I]=!0,h[I]=null;try{const q=await ot(`/api/squads/${encodeURIComponent(I)}/agents`);if(!q.ok)throw new Error(`HTTP error! status: ${q.status}`);const x=await q.json();c[I]=x.agents}catch(q){h[I]=q instanceof Error?q.message:"Failed to load agents"}finally{u[I]=!1}}},pe=async()=>{try{const I=await ot("/api/squads");if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);const G=await I.json();s.value=G.squads}catch(I){n.value=I instanceof Error?I.message:"Failed to load squads"}finally{r.value=!1}},se=async()=>{if(!oe.value.slug||!oe.value.name||!oe.value.projectPath){a.value="All fields are required";return}o.value=!0,a.value=null;try{const I=await ot("/api/squads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:oe.value.slug,name:oe.value.name,projectPath:oe.value.projectPath})});if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);oe.value={slug:"",name:"",projectPath:""},i.value=!1,await pe()}catch(I){a.value=I instanceof Error?I.message:"Failed to create squad"}finally{o.value=!1}};return _n(()=>{pe()}),(I,G)=>(j(),$("div",Cy,[b("div",Py,[b("div",Iy,[G[4]||(G[4]=b("h2",{class:"text-2xl font-bold"},"Squads & Dashboard",-1)),b("button",{onClick:G[0]||(G[0]=q=>i.value=!i.value),class:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm transition-colors"},F(i.value?"Cancel":"New Squad"),1)]),i.value?(j(),$("form",{key:0,onSubmit:pr(se,["prevent"]),class:"bg-gray-800 border border-gray-700 rounded-lg p-4 mb-6"},[G[5]||(G[5]=b("h3",{class:"font-bold text-gray-100 mb-4"},"Create New Squad",-1)),b("div",jy,[ds(b("input",{"onUpdate:modelValue":G[1]||(G[1]=q=>oe.value.slug=q),type:"text",placeholder:"Squad slug (e.g., frontend-team)",class:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500"},null,512),[[js,oe.value.slug]]),ds(b("input",{"onUpdate:modelValue":G[2]||(G[2]=q=>oe.value.name=q),type:"text",placeholder:"Squad name (e.g., Frontend Team)",class:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500"},null,512),[[js,oe.value.name]]),ds(b("input",{"onUpdate:modelValue":G[3]||(G[3]=q=>oe.value.projectPath=q),type:"text",placeholder:"Project path (e.g., /path/to/project)",class:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500"},null,512),[[js,oe.value.projectPath]]),b("button",{type:"submit",disabled:o.value||!oe.value.slug||!oe.value.name||!oe.value.projectPath,class:"w-full bg-green-600 hover:bg-green-700 disabled:bg-gray-700 text-white px-4 py-2 rounded text-sm transition-colors"},F(o.value?"Creating...":"Create Squad"),9,$y)]),a.value?(j(),$("div",Ny,F(a.value),1)):de("",!0)],32)):de("",!0),r.value?(j(),$("div",Ly," Loading squads... ")):n.value?(j(),$("div",Uy,F(n.value),1)):s.value.length===0?(j(),$("div",Dy," No squads created yet ")):(j(),$("div",By,[(j(!0),$($e,null,es(s.value,q=>(j(),$("div",{key:q.id,class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-blue-500 transition-colors"},[b("button",{type:"button",onClick:x=>Qe(q.slug),class:"w-full text-left focus:outline-none","aria-expanded":Te(q.slug)},[b("div",Hy,[b("div",Fy,[b("span",{class:Ne(["inline-block transition-transform text-gray-400",Te(q.slug)?"rotate-90":""])},"▶",2),b("div",null,[b("h3",qy,F(q.name),1),b("p",Vy,F(q.slug),1)])]),b("div",Ky,[q.universe?(j(),$("span",Wy," 🎬 "+F(Oe(q.universe)),1)):de("",!0),b("span",{class:Ne(["px-2 py-1 rounded text-xs font-medium",q.status==="working"?"bg-blue-900 text-blue-100":q.status==="error"?"bg-red-900 text-red-100":"bg-gray-700 text-gray-200"])},F(q.status),3)])]),b("p",Gy,"📁 "+F(q.project_path),1)],8,My),Te(q.slug)?(j(),$("div",Jy,[b("div",zy,[q.model?(j(),$("span",Yy,"Model: "+F(q.model),1)):de("",!0),b("span",null,F(Le(q.created_at)),1)]),G[8]||(G[8]=b("h4",{class:"font-semibold text-gray-200 text-sm mb-2"},"Team Roster",-1)),u[q.slug]?(j(),$("div",Xy," Loading agents... ")):h[q.slug]?(j(),$("div",Qy,F(h[q.slug]),1)):!c[q.slug]||c[q.slug].length===0?(j(),$("div",Zy," No agents assigned yet ")):(j(),$("ul",em,[(j(!0),$($e,null,es(c[q.slug],x=>(j(),$("li",{key:x.id??x.character_name,class:Ne(["flex items-center gap-3 rounded px-3 py-2",x.status==="working"?"bg-blue-950 border border-blue-800":"bg-gray-900 border border-gray-700"])},[b("div",tm,[b("span",sm,F(x.character_name),1),b("span",rm,F(x.role_title),1)]),b("span",{class:Ne(["px-2 py-0.5 rounded text-xs",x.status==="working"?"bg-blue-800 text-blue-200":x.status==="error"?"bg-red-800 text-red-200":"bg-gray-700 text-gray-400"])},F(x.status),3),x.status==="working"&&x.currentTaskId?(j(),$("button",{key:0,type:"button",onClick:P=>Y(x),class:"bg-blue-700 hover:bg-blue-600 text-white text-xs px-2 py-1 rounded transition-colors flex items-center gap-1",title:"Preview this agent's live work"},[...G[6]||(G[6]=[b("span",{"aria-hidden":"true"},"👁",-1),Xe(" Preview ",-1)])],8,nm)):de("",!0),x.status==="working"&&x.currentTaskId?(j(),$("button",{key:1,type:"button",onClick:P=>X(q.slug,x.currentTaskId),disabled:d.value.has(x.currentTaskId),class:"bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white text-xs px-2 py-1 rounded transition-colors flex items-center gap-1",title:"Stop this agent's current task"},[G[7]||(G[7]=b("span",{class:"inline-block w-2 h-2 bg-white rounded-sm"},null,-1)),Xe(" "+F(d.value.has(x.currentTaskId)?"Stopping...":"Stop"),1)],8,im)):de("",!0)],2))),128))]))])):de("",!0)]))),128))]))]),f.value?(j(),$("div",{key:0,class:"fixed inset-0 bg-black/70 flex items-center justify-center p-4 z-50",onClick:pr(te,["self"])},[b("div",om,[b("div",am,[b("div",lm,[b("h3",cm,[Xe(F(f.value.character_name)+" ",1),b("span",um,"— "+F(f.value.role_title),1)]),b("p",hm,[b("span",{class:Ne(["inline-block w-2 h-2 rounded-full",T.value?"bg-green-400 animate-pulse":"bg-gray-500"])},null,2),Xe(" "+F(w.value),1)])]),b("button",{type:"button",onClick:te,class:"text-gray-400 hover:text-gray-100 text-2xl leading-none focus:outline-none","aria-label":"Close"},"×")]),b("div",{ref_key:"previewScrollEl",ref:A,class:"overflow-y-auto p-4 space-y-3 flex-1 font-mono text-xs"},[v.value?(j(),$("div",dm,F(v.value),1)):y.value.length===0?(j(),$("div",fm," Waiting for activity... ")):de("",!0),(j(!0),$($e,null,es(y.value,(q,x)=>(j(),$("div",{key:x,class:"border border-gray-800 rounded p-2 bg-gray-950"},[b("div",pm,[b("span",gm,F(q.type),1),b("span",ym,F(C(q.ts)),1)]),b("pre",mm,F(W(q)),1)]))),128))],512),b("div",{class:"p-3 border-t border-gray-700 flex justify-end"},[b("button",{type:"button",onClick:te,class:"bg-gray-700 hover:bg-gray-600 text-gray-100 text-sm px-4 py-2 rounded transition-colors"}," Close ")])])])):de("",!0)]))}}),bm={class:"flex flex-col h-full bg-gray-950"},_m={class:"flex-1 overflow-y-auto p-6"},wm={class:"flex justify-between items-center mb-6"},Sm=["disabled"],km={key:0,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},Em={class:"mb-8"},xm={key:0,class:"text-gray-400 text-center py-8"},Tm={key:1,class:"text-gray-400 text-center py-8"},Am={key:2,class:"grid gap-4"},Rm={class:"flex justify-between items-start mb-3"},Om={class:"flex-1"},Cm={class:"font-bold text-gray-100"},Pm={class:"flex items-center gap-2 mt-1"},Im={class:"text-sm text-gray-500"},jm={key:0,class:"text-xs bg-gray-700 text-gray-300 px-2 py-0.5 rounded"},$m={key:1,class:"text-xs bg-purple-900 text-purple-200 px-2 py-0.5 rounded"},Nm=["title"],Lm={key:0,class:"inline-block w-2 h-2 bg-blue-400 rounded-full mr-1 animate-pulse"},Um={key:0,class:"bg-gray-700 rounded p-3 mb-2"},Dm={class:"text-sm text-gray-100 break-words"},Bm={class:"flex justify-between items-center"},Mm={class:"text-xs text-gray-500"},Hm=["onClick","disabled"],Fm={key:0,class:"text-gray-400 text-center py-8"},qm={key:1,class:"text-gray-400 text-center py-8"},Vm={key:2,class:"bg-gray-800 border border-gray-700 rounded-lg divide-y divide-gray-700 overflow-hidden"},Km=["onClick"],Wm={class:"flex justify-between items-start gap-3"},Gm={class:"flex-1 min-w-0"},Jm={class:"flex items-center gap-2 mb-1"},zm={class:"text-sm font-medium text-gray-100 truncate"},Ym={key:0,class:"text-xs text-gray-500"},Xm={class:"text-sm text-gray-300 truncate"},Qm={class:"text-xs text-gray-500 mt-1"},Zm={key:0},ev={class:"bg-gray-900 border border-gray-700 rounded-lg w-full max-w-2xl max-h-[85vh] flex flex-col shadow-2xl"},tv={class:"overflow-y-auto p-5 space-y-4"},sv={key:0,class:"text-gray-400 text-center py-8"},rv={key:1,class:"bg-red-900 text-red-100 p-3 rounded text-sm"},nv={class:"flex justify-between items-start gap-3"},iv={class:"text-sm text-gray-100 font-medium"},ov={class:"text-xs text-gray-400 font-mono break-all"},av={key:0},lv={class:"text-sm text-gray-200"},cv={class:"grid grid-cols-2 gap-4"},uv={class:"text-sm text-gray-200"},hv={class:"text-sm text-gray-200"},dv={key:1},fv={class:"text-sm text-gray-200"},pv={class:"text-sm text-gray-100 bg-gray-800 border border-gray-700 rounded p-3 whitespace-pre-wrap break-words font-sans"},gv={class:"flex justify-between items-center mb-2"},yv={class:"flex items-center gap-2 text-xs text-gray-400 cursor-pointer select-none"},mv={key:0,class:"text-sm text-gray-500 italic"},vv={key:1,class:"text-sm text-gray-500 italic"},bv={key:2,class:"bg-gray-800 border border-gray-700 rounded divide-y divide-gray-700 max-h-96 overflow-y-auto"},_v=["onClick"],wv={class:"shrink-0"},Sv={class:"flex-1 break-words"},kv={class:"text-xs text-gray-500 shrink-0"},Ev={key:0,class:"mt-2 pl-6 space-y-1"},xv={key:0,class:"text-xs text-gray-200 bg-gray-900 border border-gray-700 rounded p-2 whitespace-pre-wrap break-words font-mono"},Tv={class:"text-[11px] text-gray-500 bg-gray-900 border border-gray-700 rounded p-2 whitespace-pre-wrap break-words font-mono max-h-48 overflow-y-auto"},Av={class:"text-[10px] text-gray-600 font-mono"},Rv={key:0,class:"text-sm text-gray-100 bg-gray-800 border border-gray-700 rounded p-3 whitespace-pre-wrap break-words font-mono max-h-96 overflow-y-auto"},Ov={key:1,class:"text-sm text-gray-500 italic"},Cv={class:"p-4 border-t border-gray-700 flex justify-between items-center"},Pv=["disabled"],Iv={key:1},jv=Vt({__name:"AgentActivityView",setup(t){const e=ie([]),s=ie([]),r=ie(!0),n=ie(null),i=ie(new Set),o=ie(null),a=ie(null),l=ie(!1),c=ie(null),u=ie([]),h=ie(!1),d=ie(!1),f=ie(new Set);let y=null,v=null,T=null;const A=x=>x.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),_=x=>{if(!x)return"";const P=x.includes("T")?x:x.replace(" ","T")+"Z",H=new Date(P);return Number.isNaN(H.getTime())?x:H.toLocaleString()},w=x=>{switch(x){case"running":return"bg-blue-900 text-blue-100";case"done":return"bg-green-900 text-green-100";case"failed":return"bg-red-900 text-red-100";case"cancelled":return"bg-yellow-900 text-yellow-100";default:return"bg-gray-700 text-gray-200"}},C=Ge(()=>{if(!a.value)return null;const x=a.value.started_at,P=a.value.completed_at;if(!x||!P)return null;const H=new Date(x.includes("T")?x:x.replace(" ","T")+"Z").getTime(),Ue=new Date(P.includes("T")?P:P.replace(" ","T")+"Z").getTime();if(Number.isNaN(H)||Number.isNaN(Ue))return null;const et=Math.max(0,Math.round((Ue-H)/1e3));if(et<60)return`${et}s`;const Je=Math.floor(et/60),k=et%60;return`${Je}m ${k}s`}),W=async x=>{if(!i.value.has(x)){i.value=new Set(i.value).add(x);try{await ot(`/api/tasks/${encodeURIComponent(x)}/cancel`,{method:"POST"}),await te(),o.value===x&&await X(x)}catch(P){n.value=P instanceof Error?P.message:"Failed to stop task"}finally{const P=new Set(i.value);P.delete(x),i.value=P}}},re=async()=>{try{const x=await ot("/api/agents");if(!x.ok)throw new Error(`HTTP error! status: ${x.status}`);const P=await x.json();e.value=P.agents}catch(x){n.value=x instanceof Error?x.message:"Failed to load agents"}},Y=async()=>{try{const x=await ot("/api/tasks?limit=50");if(!x.ok)throw new Error(`HTTP error! status: ${x.status}`);const P=await x.json();s.value=P.tasks}catch(x){n.value=x instanceof Error?x.message:"Failed to load tasks"}},te=async()=>{r.value=!0,n.value=null;try{await Promise.all([re(),Y()])}finally{r.value=!1}},X=async x=>{l.value=!0,c.value=null;try{const P=await ot(`/api/tasks/${encodeURIComponent(x)}`);if(!P.ok)throw new Error(`HTTP error! status: ${P.status}`);const H=await P.json();a.value=H.task}catch(P){c.value=P instanceof Error?P.message:"Failed to load task",a.value=null}finally{l.value=!1}},oe=x=>{if(!x)return"";const P=new Date(x);return Number.isNaN(P.getTime())?"":P.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})},Oe=x=>{try{return JSON.stringify(x,null,2)}catch{return String(x)}},Le=x=>{if(x.status==="success")return"text-green-300";if(x.status==="error")return"text-red-300";if(x.status==="pending")return"text-blue-300";switch(x.kind){case"message":return"text-gray-100";case"reasoning":return"text-purple-300";case"tool":return"text-blue-200";case"outcome":return"text-yellow-200";default:return"text-gray-300"}},Te=x=>{if(d.value)return;const P=new Set(f.value);P.has(x)?P.delete(x):P.add(x),f.value=P},Qe=async(x,P={})=>{P.initial&&(h.value=!0);try{const H=await ot(`/api/tasks/${encodeURIComponent(x)}/activity`);if(!H.ok)return;const Ue=await H.json();u.value=Ue.activity??[]}catch{}finally{P.initial&&(h.value=!1)}},Ze=x=>{v||(v=setTimeout(()=>{v=null,o.value===x&&Qe(x)},250))},pe=x=>{se(),Qe(x,{initial:!0});try{y=new EventSource(Gi(`/api/tasks/${encodeURIComponent(x)}/events`)),y.onmessage=()=>{Ze(x)},y.onerror=()=>{}}catch{y=null}},se=()=>{y&&(y.close(),y=null),v&&(clearTimeout(v),v=null)},I=x=>{o.value=x,a.value=null,u.value=[],f.value=new Set,X(x),pe(x)},G=()=>{o.value=null,a.value=null,c.value=null,u.value=[],f.value=new Set,se()},q=x=>{x.key==="Escape"&&o.value&&G()};return Zt(o,x=>{x?document.addEventListener("keydown",q):document.removeEventListener("keydown",q)}),_n(()=>{te(),T=setInterval(te,5e3)}),Zt(()=>{var x;return(x=a.value)==null?void 0:x.status},x=>{x&&x!=="running"&&(o.value&&Qe(o.value),se())}),Bi(()=>{T&&clearInterval(T),document.removeEventListener("keydown",q),se()}),(x,P)=>(j(),$("div",bm,[b("div",_m,[b("div",wm,[P[2]||(P[2]=b("h2",{class:"text-2xl font-bold"},"Agent Activity",-1)),b("button",{onClick:te,disabled:r.value,class:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-700 text-white px-4 py-2 rounded-lg text-sm transition-colors"},F(r.value?"Refreshing...":"Refresh"),9,Sm)]),n.value?(j(),$("div",km,F(n.value),1)):de("",!0),b("section",Em,[P[5]||(P[5]=b("h3",{class:"text-lg font-semibold text-gray-200 mb-3"},"Active Agents",-1)),r.value&&e.value.length===0?(j(),$("div",xm," Loading agents... ")):e.value.length===0?(j(),$("div",Tm," No active agents ")):(j(),$("div",Am,[(j(!0),$($e,null,es(e.value,H=>(j(),$("div",{key:H.slug+(H.characterName||""),class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-blue-500 transition-colors"},[b("div",Rm,[b("div",Om,[b("h3",Cm,F(H.name),1),b("div",Pm,[b("p",Im,F(H.slug),1),H.roleTitle?(j(),$("span",jm,F(H.roleTitle),1)):de("",!0),H.universe?(j(),$("span",$m," 🎬 "+F(H.universe),1)):de("",!0),H.model&&H.status==="working"?(j(),$("span",{key:2,class:"text-xs bg-emerald-900 text-emerald-200 px-2 py-0.5 rounded",title:`Model: ${H.model}`}," 🧠 "+F(H.model),9,Nm)):de("",!0)])]),b("span",{class:Ne(["px-3 py-1 rounded text-xs font-medium",H.status==="working"?"bg-blue-900 text-blue-100":H.status==="error"?"bg-red-900 text-red-100":"bg-green-900 text-green-100"])},[H.status==="working"?(j(),$("span",Lm)):de("",!0),Xe(" "+F(H.status==="working"?"Working":H.status==="error"?"Error":"Idle"),1)],2)]),H.currentTask?(j(),$("div",Um,[P[3]||(P[3]=b("p",{class:"text-xs text-gray-400 mb-1"},"Current Task:",-1)),b("p",Dm,F(H.currentTask),1)])):de("",!0),b("div",Bm,[b("div",Mm," Last updated: "+F(A(new Date)),1),H.status==="working"&&H.currentTaskId?(j(),$("button",{key:0,type:"button",onClick:Ue=>W(H.currentTaskId),disabled:i.value.has(H.currentTaskId),class:"bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white text-xs px-3 py-1 rounded transition-colors flex items-center gap-1",title:"Stop this agent's current task"},[P[4]||(P[4]=b("span",{class:"inline-block w-2 h-2 bg-white rounded-sm"},null,-1)),Xe(" "+F(i.value.has(H.currentTaskId)?"Stopping...":"Stop"),1)],8,Hm)):de("",!0)])]))),128))]))]),b("section",null,[P[6]||(P[6]=b("h3",{class:"text-lg font-semibold text-gray-200 mb-3"},"Recent Activity",-1)),r.value&&s.value.length===0?(j(),$("div",Fm," Loading activity... ")):s.value.length===0?(j(),$("div",qm," No recent activity yet ")):(j(),$("ul",Vm,[(j(!0),$($e,null,es(s.value,H=>(j(),$("li",{key:H.task_id},[b("button",{type:"button",onClick:Ue=>I(H.task_id),class:"w-full text-left p-4 hover:bg-gray-750 focus:bg-gray-750 focus:outline-none transition-colors"},[b("div",Wm,[b("div",Gm,[b("div",Jm,[b("span",zm,F(H.agent_slug),1),H.origin_channel?(j(),$("span",Ym,"via "+F(H.origin_channel),1)):de("",!0)]),b("p",Xm,F(H.description),1),b("p",Qm,[Xe(" Started "+F(_(H.started_at))+" ",1),H.completed_at?(j(),$("span",Zm," · Completed "+F(_(H.completed_at)),1)):de("",!0)])]),b("span",{class:Ne(["px-2 py-1 rounded text-xs font-medium whitespace-nowrap",w(H.status)])},F(H.status),3)])],8,Km)]))),128))]))])]),o.value?(j(),$("div",{key:0,class:"fixed inset-0 bg-black/70 flex items-center justify-center p-4 z-50",onClick:pr(G,["self"])},[b("div",ev,[b("div",{class:"flex justify-between items-center p-4 border-b border-gray-700"},[P[7]||(P[7]=b("h3",{class:"text-lg font-bold text-gray-100"},"Task Details",-1)),b("button",{type:"button",onClick:G,class:"text-gray-400 hover:text-gray-100 text-2xl leading-none focus:outline-none","aria-label":"Close"},"×")]),b("div",tv,[l.value?(j(),$("div",sv,"Loading task...")):c.value?(j(),$("div",rv,F(c.value),1)):a.value?(j(),$($e,{key:2},[b("div",nv,[b("div",null,[P[8]||(P[8]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Agent",-1)),b("p",iv,F(a.value.agent_slug),1)]),b("span",{class:Ne(["px-3 py-1 rounded text-xs font-medium",w(a.value.status)])},F(a.value.status),3)]),b("div",null,[P[9]||(P[9]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Task ID",-1)),b("p",ov,F(a.value.task_id),1)]),a.value.origin_channel?(j(),$("div",av,[P[10]||(P[10]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Origin",-1)),b("p",lv,F(a.value.origin_channel),1)])):de("",!0),b("div",cv,[b("div",null,[P[11]||(P[11]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Started",-1)),b("p",uv,F(_(a.value.started_at)),1)]),b("div",null,[P[12]||(P[12]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Completed",-1)),b("p",hv,F(a.value.completed_at?_(a.value.completed_at):"—"),1)])]),C.value?(j(),$("div",dv,[P[13]||(P[13]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Duration",-1)),b("p",fv,F(C.value),1)])):de("",!0),b("div",null,[P[14]||(P[14]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Description",-1)),b("pre",pv,F(a.value.description),1)]),b("div",null,[b("div",gv,[P[16]||(P[16]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500"},"Activity",-1)),b("label",yv,[ds(b("input",{type:"checkbox","onUpdate:modelValue":P[0]||(P[0]=H=>d.value=H),class:"rounded bg-gray-700 border-gray-600"},null,512),[[Fh,d.value]]),P[15]||(P[15]=Xe(" Show details ",-1))])]),h.value&&u.value.length===0?(j(),$("div",mv,"Loading activity…")):u.value.length===0?(j(),$("div",vv,"No activity yet")):(j(),$("ul",bv,[(j(!0),$($e,null,es(u.value,(H,Ue)=>(j(),$("li",{key:`${H.ts}-${Ue}-${H.rawType}`,class:"px-3 py-2 text-sm hover:bg-gray-750 cursor-pointer",onClick:et=>Te(Ue)},[b("div",{class:Ne(["flex items-start gap-2",Le(H)])},[b("span",wv,F(H.icon),1),b("span",Sv,F(H.summary),1),b("span",kv,F(oe(H.ts)),1)],2),d.value||f.value.has(Ue)?(j(),$("div",Ev,[H.detail?(j(),$("pre",xv,F(H.detail),1)):de("",!0),b("pre",Tv,F(Oe(H.raw)),1),b("p",Av,F(H.rawType),1)])):de("",!0)],8,_v))),128))]))]),b("div",null,[P[17]||(P[17]=b("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Result",-1)),a.value.result?(j(),$("pre",Rv,F(a.value.result),1)):(j(),$("p",Ov,"No result yet"))])],64)):de("",!0)]),b("div",Cv,[a.value&&a.value.status==="running"?(j(),$("button",{key:0,type:"button",onClick:P[1]||(P[1]=H=>W(a.value.task_id)),disabled:i.value.has(a.value.task_id),class:"bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white text-sm px-3 py-2 rounded transition-colors"},F(i.value.has(a.value.task_id)?"Stopping...":"Stop Task"),9,Pv)):(j(),$("span",Iv)),b("button",{type:"button",onClick:G,class:"bg-gray-700 hover:bg-gray-600 text-gray-100 text-sm px-4 py-2 rounded transition-colors"}," Close ")])])])):de("",!0)]))}}),$v=(t,e)=>{const s=t.__vccOpts||t;for(const[r,n]of e)s[r]=n;return s},Nv=$v(jv,[["__scopeId","data-v-6c7a72da"]]),Lv={class:"flex items-center justify-center h-screen bg-gray-950"},Uv={class:"w-full max-w-sm p-8 bg-gray-900 rounded-xl border border-gray-800"},Dv={key:0,class:"text-red-400 text-sm"},Bv=["disabled"],Mv=Vt({__name:"LoginView",setup(t){const e=Or(),s=sc(),r=ie(""),n=ie(""),i=ie(null);async function o(){i.value=null;const a=await e.signIn(r.value,n.value);a?i.value=a:s.push("/chat")}return(a,l)=>(j(),$("div",Lv,[b("div",Uv,[l[4]||(l[4]=b("h1",{class:"text-2xl font-bold text-white text-center mb-2"},"IO",-1)),l[5]||(l[5]=b("p",{class:"text-gray-400 text-sm text-center mb-8"},"Sign in to continue",-1)),b("form",{onSubmit:pr(o,["prevent"]),class:"space-y-4"},[b("div",null,[l[2]||(l[2]=b("label",{for:"email",class:"block text-sm font-medium text-gray-300 mb-1"},"Email",-1)),ds(b("input",{id:"email","onUpdate:modelValue":l[0]||(l[0]=c=>r.value=c),type:"email",required:"",autocomplete:"email",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent",placeholder:"you@example.com"},null,512),[[js,r.value]])]),b("div",null,[l[3]||(l[3]=b("label",{for:"password",class:"block text-sm font-medium text-gray-300 mb-1"},"Password",-1)),ds(b("input",{id:"password","onUpdate:modelValue":l[1]||(l[1]=c=>n.value=c),type:"password",required:"",autocomplete:"current-password",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent",placeholder:"••••••••"},null,512),[[js,n.value]])]),i.value?(j(),$("div",Dv,F(i.value),1)):de("",!0),b("button",{type:"submit",disabled:me(e).loading,class:"w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors"},F(me(e).loading?"Signing in...":"Sign in"),9,Bv)],32)])]))}}),xc=af({history:Md("/"),routes:[{path:"/",redirect:"/chat"},{path:"/login",name:"login",component:Mv,meta:{public:!0}},{path:"/chat",name:"chat",component:my},{path:"/skills",name:"skills",component:Oy},{path:"/squads",name:"squads",component:vm},{path:"/activity",name:"activity",component:Nv}]});xc.beforeEach(async t=>{const e=Or();return e.initialized||await e.init(),!e.authEnabled||t.meta.public||e.user?!0:{name:"login"}});const Ji=Jh(ay);Ji.use(Xh());Ji.use(xc);Ji.mount("#app");