heyio 0.11.0 → 0.12.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.
- package/dist/api/server.js +46 -5
- package/dist/copilot/agents.js +3 -0
- package/dist/copilot/skills.js +97 -13
- package/dist/copilot/tools.js +3 -2
- package/dist/index.js +5 -2
- package/package.json +1 -1
- package/web-dist/assets/index-C6i8dB9S.css +1 -0
- package/web-dist/assets/index-I-mPEKj7.js +79 -0
- package/web-dist/index.html +2 -2
- package/web-dist/assets/index-Do8uw7iA.css +0 -1
- package/web-dist/assets/index-FoS7-hiM.js +0 -78
|
@@ -0,0 +1,79 @@
|
|
|
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 Oi(t){const e=Object.create(null);for(const s of t.split(","))e[s]=1;return s=>s in e}const we={},Is=[],Pt=()=>{},Oa=()=>!1,hn=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),dn=t=>t.startsWith("onUpdate:"),Fe=Object.assign,$i=(t,e)=>{const s=t.indexOf(e);s>-1&&t.splice(s,1)},jc=Object.prototype.hasOwnProperty,pe=(t,e)=>jc.call(t,e),te=Array.isArray,js=t=>Sr(t)==="[object Map]",fn=t=>Sr(t)==="[object Set]",eo=t=>Sr(t)==="[object Date]",ie=t=>typeof t=="function",Re=t=>typeof t=="string",ht=t=>typeof t=="symbol",ve=t=>t!==null&&typeof t=="object",$a=t=>(ve(t)||ie(t))&&ie(t.then)&&ie(t.catch),Pa=Object.prototype.toString,Sr=t=>Pa.call(t),Nc=t=>Sr(t).slice(8,-1),Ia=t=>Sr(t)==="[object Object]",pn=t=>Re(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Zs=Oi(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),gn=t=>{const e=Object.create(null);return s=>e[s]||(e[s]=t(s))},Lc=/-\w/g,yt=gn(t=>t.replace(Lc,e=>e.slice(1).toUpperCase())),Uc=/\B([A-Z])/g,vs=gn(t=>t.replace(Uc,"-$1").toLowerCase()),ja=gn(t=>t.charAt(0).toUpperCase()+t.slice(1)),jn=gn(t=>t?`on${ja(t)}`:""),$t=(t,e)=>!Object.is(t,e),Vr=(t,...e)=>{for(let s=0;s<t.length;s++)t[s](...e)},Na=(t,e,s,r=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:r,value:s})},Pi=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let to;const yn=()=>to||(to=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Ii(t){if(te(t)){const e={};for(let s=0;s<t.length;s++){const r=t[s],n=Re(r)?Hc(r):Ii(r);if(n)for(const i in n)e[i]=n[i]}return e}else if(Re(t)||ve(t))return t}const Dc=/;(?![^(]*\))/g,Mc=/:([^]+)/,Bc=/\/\*[^]*?\*\//g;function Hc(t){const e={};return t.replace(Bc,"").split(Dc).forEach(s=>{if(s){const r=s.split(Mc);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function ge(t){let e="";if(Re(t))e=t;else if(te(t))for(let s=0;s<t.length;s++){const r=ge(t[s]);r&&(e+=r+" ")}else if(ve(t))for(const s in t)t[s]&&(e+=s+" ");return e.trim()}const Fc="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",qc=Oi(Fc);function La(t){return!!t||t===""}function Vc(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=eo(t),r=eo(e);if(s||r)return s&&r?t.getTime()===e.getTime():!1;if(s=ht(t),r=ht(e),s||r)return t===e;if(s=te(t),r=te(e),s||r)return s&&r?Vc(t,e):!1;if(s=ve(t),r=ve(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 Ua(t,e){return t.findIndex(s=>Er(s,e))}const Da=t=>!!(t&&t.__v_isRef===!0),O=t=>Re(t)?t:t==null?"":te(t)||ve(t)&&(t.toString===Pa||!ie(t.toString))?Da(t)?O(t.value):JSON.stringify(t,Ma,2):String(t),Ma=(t,e)=>Da(e)?Ma(t,e.value):js(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((s,[r,n],i)=>(s[Nn(r,i)+" =>"]=n,s),{})}:fn(e)?{[`Set(${e.size})`]:[...e.values()].map(s=>Nn(s))}:ht(e)?Nn(e):ve(e)&&!te(e)&&!Ia(e)?String(e):e,Nn=(t,e="")=>{var s;return ht(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 je;class Ba{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&&je&&(je.active?(this.parent=je,this.index=(je.scopes||(je.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=je;try{return je=this,e()}finally{je=s}}}on(){++this._on===1&&(this.prevScope=je,je=this)}off(){if(this._on>0&&--this._on===0){if(je===this)je=this.prevScope;else{let e=je;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 Ha(t){return new Ba(t)}function Fa(){return je}function Wc(t,e=!1){je&&je.cleanups.push(t)}let Se;const Ln=new WeakSet;class qa{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,je&&(je.active?je.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Ln.has(this)&&(Ln.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Wa(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,so(this),Ka(this);const e=Se,s=mt;Se=this,mt=!0;try{return this.fn()}finally{Ga(this),Se=e,mt=s,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Li(e);this.deps=this.depsTail=void 0,so(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Ln.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){ti(this)&&this.run()}get dirty(){return ti(this)}}let Va=0,er,tr;function Wa(t,e=!1){if(t.flags|=8,e){t.next=tr,tr=t;return}t.next=er,er=t}function ji(){Va++}function Ni(){if(--Va>0)return;if(tr){let e=tr;for(tr=void 0;e;){const s=e.next;e.next=void 0,e.flags&=-9,e=s}}let t;for(;er;){let e=er;for(er=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 Ka(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Ga(t){let e,s=t.depsTail,r=s;for(;r;){const n=r.prevDep;r.version===-1?(r===s&&(s=n),Li(r),Kc(r)):e=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=n}t.deps=e,t.depsTail=s}function ti(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Ja(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Ja(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===hr)||(t.globalVersion=hr,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!ti(t))))return;t.flags|=2;const e=t.dep,s=Se,r=mt;Se=t,mt=!0;try{Ka(t);const n=t.fn(t._value);(e.version===0||$t(n,t._value))&&(t.flags|=128,t._value=n,e.version++)}catch(n){throw e.version++,n}finally{Se=s,mt=r,Ga(t),t.flags&=-3}}function Li(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)Li(i,!0)}!e&&!--s.sc&&s.map&&s.map.delete(s.key)}function Kc(t){const{prevDep:e,nextDep:s}=t;e&&(e.nextDep=s,t.prevDep=void 0),s&&(s.prevDep=e,t.nextDep=void 0)}let mt=!0;const za=[];function Kt(){za.push(mt),mt=!1}function Gt(){const t=za.pop();mt=t===void 0?!0:t}function so(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const s=Se;Se=void 0;try{e()}finally{Se=s}}}let hr=0;class Gc{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 Ui{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(!Se||!mt||Se===this.computed)return;let s=this.activeLink;if(s===void 0||s.sub!==Se)s=this.activeLink=new Gc(Se,this),Se.deps?(s.prevDep=Se.depsTail,Se.depsTail.nextDep=s,Se.depsTail=s):Se.deps=Se.depsTail=s,Ya(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=Se.depsTail,s.nextDep=void 0,Se.depsTail.nextDep=s,Se.depsTail=s,Se.deps===s&&(Se.deps=r)}return s}trigger(e){this.version++,hr++,this.notify(e)}notify(e){ji();try{for(let s=this.subs;s;s=s.prevSub)s.sub.notify()&&s.sub.dep.notify()}finally{Ni()}}}function Ya(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)Ya(r)}const s=t.dep.subs;s!==t&&(t.prevSub=s,s&&(s.nextSub=t)),t.dep.subs=t}}const Jr=new WeakMap,ys=Symbol(""),si=Symbol(""),dr=Symbol("");function qe(t,e,s){if(mt&&Se){let r=Jr.get(t);r||Jr.set(t,r=new Map);let n=r.get(s);n||(r.set(s,n=new Ui),n.map=r,n.key=s),n.track()}}function Ft(t,e,s,r,n,i){const o=Jr.get(t);if(!o){hr++;return}const a=l=>{l&&l.trigger()};if(ji(),e==="clear")o.forEach(a);else{const l=te(t),c=l&&pn(s);if(l&&s==="length"){const u=Number(r);o.forEach((h,f)=>{(f==="length"||f===dr||!ht(f)&&f>=u)&&a(h)})}else switch((s!==void 0||o.has(void 0))&&a(o.get(s)),c&&a(o.get(dr)),e){case"add":l?c&&a(o.get("length")):(a(o.get(ys)),js(t)&&a(o.get(si)));break;case"delete":l||(a(o.get(ys)),js(t)&&a(o.get(si)));break;case"set":js(t)&&a(o.get(ys));break}}Ni()}function Jc(t,e){const s=Jr.get(t);return s&&s.get(e)}function bs(t){const e=ue(t);return e===t?e:(qe(e,"iterate",dr),it(t)?e:e.map(vt))}function mn(t){return qe(t=ue(t),"iterate",dr),t}function Rt(t,e){return Jt(t)?Ds(Wt(t)?vt(e):e):vt(e)}const zc={__proto__:null,[Symbol.iterator](){return Un(this,Symbol.iterator,t=>Rt(this,t))},concat(...t){return bs(this).concat(...t.map(e=>te(e)?bs(e):e))},entries(){return Un(this,"entries",t=>(t[1]=Rt(this,t[1]),t))},every(t,e){return Nt(this,"every",t,e,void 0,arguments)},filter(t,e){return Nt(this,"filter",t,e,s=>s.map(r=>Rt(this,r)),arguments)},find(t,e){return Nt(this,"find",t,e,s=>Rt(this,s),arguments)},findIndex(t,e){return Nt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Nt(this,"findLast",t,e,s=>Rt(this,s),arguments)},findLastIndex(t,e){return Nt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Nt(this,"forEach",t,e,void 0,arguments)},includes(...t){return Dn(this,"includes",t)},indexOf(...t){return Dn(this,"indexOf",t)},join(t){return bs(this).join(t)},lastIndexOf(...t){return Dn(this,"lastIndexOf",t)},map(t,e){return Nt(this,"map",t,e,void 0,arguments)},pop(){return Ws(this,"pop")},push(...t){return Ws(this,"push",t)},reduce(t,...e){return ro(this,"reduce",t,e)},reduceRight(t,...e){return ro(this,"reduceRight",t,e)},shift(){return Ws(this,"shift")},some(t,e){return Nt(this,"some",t,e,void 0,arguments)},splice(...t){return Ws(this,"splice",t)},toReversed(){return bs(this).toReversed()},toSorted(t){return bs(this).toSorted(t)},toSpliced(...t){return bs(this).toSpliced(...t)},unshift(...t){return Ws(this,"unshift",t)},values(){return Un(this,"values",t=>Rt(this,t))}};function Un(t,e,s){const r=mn(t),n=r[e]();return r!==t&&!it(t)&&(n._next=n.next,n.next=()=>{const i=n._next();return i.done||(i.value=s(i.value)),i}),n}const Yc=Array.prototype;function Nt(t,e,s,r,n,i){const o=mn(t),a=o!==t&&!it(t),l=o[e];if(l!==Yc[e]){const h=l.apply(t,i);return a?vt(h):h}let c=s;o!==t&&(a?c=function(h,f){return s.call(this,Rt(t,h),f,t)}:s.length>2&&(c=function(h,f){return s.call(this,h,f,t)}));const u=l.call(o,c,r);return a&&n?n(u):u}function ro(t,e,s,r){const n=mn(t),i=n!==t&&!it(t);let o=s,a=!1;n!==t&&(i?(a=r.length===0,o=function(c,u,h){return a&&(a=!1,c=Rt(t,c)),s.call(this,c,Rt(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?Rt(t,l):l}function Dn(t,e,s){const r=ue(t);qe(r,"iterate",dr);const n=r[e](...s);return(n===-1||n===!1)&&vn(s[0])?(s[0]=ue(s[0]),r[e](...s)):n}function Ws(t,e,s=[]){Kt(),ji();const r=ue(t)[e].apply(t,s);return Ni(),Gt(),r}const Xc=Oi("__proto__,__v_isRef,__isVue"),Xa=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(ht));function Qc(t){ht(t)||(t=String(t));const e=ue(this);return qe(e,"has",t),e.hasOwnProperty(t)}class Qa{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?lu:sl:i?tl:el).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(r)?e:void 0;const o=te(e);if(!n){let l;if(o&&(l=zc[s]))return l;if(s==="hasOwnProperty")return Qc}const a=Reflect.get(e,s,Ce(e)?e:r);if((ht(s)?Xa.has(s):Xc(s))||(n||qe(e,"get",s),i))return a;if(Ce(a)){const l=o&&pn(s)?a:a.value;return n&&ve(l)?ni(l):l}return ve(a)?n?ni(a):Vt(a):a}}class Za extends Qa{constructor(e=!1){super(!1,e)}set(e,s,r,n){let i=e[s];const o=te(e)&&pn(s);if(!this._isShallow){const c=Jt(i);if(!it(r)&&!Jt(r)&&(i=ue(i),r=ue(r)),!o&&Ce(i)&&!Ce(r))return c||(i.value=r),!0}const a=o?Number(s)<e.length:pe(e,s),l=Reflect.set(e,s,r,Ce(e)?e:n);return e===ue(n)&&(a?$t(r,i)&&Ft(e,"set",s,r):Ft(e,"add",s,r)),l}deleteProperty(e,s){const r=pe(e,s);e[s];const n=Reflect.deleteProperty(e,s);return n&&r&&Ft(e,"delete",s,void 0),n}has(e,s){const r=Reflect.has(e,s);return(!ht(s)||!Xa.has(s))&&qe(e,"has",s),r}ownKeys(e){return qe(e,"iterate",te(e)?"length":ys),Reflect.ownKeys(e)}}class Zc extends Qa{constructor(e=!1){super(!0,e)}set(e,s){return!0}deleteProperty(e,s){return!0}}const eu=new Za,tu=new Zc,su=new Za(!0);const ri=t=>t,$r=t=>Reflect.getPrototypeOf(t);function ru(t,e,s){return function(...r){const n=this.__v_raw,i=ue(n),o=js(i),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=n[t](...r),u=s?ri:e?Ds:vt;return!e&&qe(i,"iterate",l?si:ys),Fe(Object.create(c),{next(){const{value:h,done:f}=c.next();return f?{value:h,done:f}:{value:a?[u(h[0]),u(h[1])]:u(h),done:f}}})}}function Pr(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function nu(t,e){const s={get(n){const i=this.__v_raw,o=ue(i),a=ue(n);t||($t(n,a)&&qe(o,"get",n),qe(o,"get",a));const{has:l}=$r(o),c=e?ri:t?Ds:vt;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&&qe(ue(n),"iterate",ys),n.size},has(n){const i=this.__v_raw,o=ue(i),a=ue(n);return t||($t(n,a)&&qe(o,"has",n),qe(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?ri:t?Ds:vt;return!t&&qe(l,"iterate",ys),a.forEach((u,h)=>n.call(i,c(u),c(h),o))}};return Fe(s,t?{add:Pr("add"),set:Pr("set"),delete:Pr("delete"),clear:Pr("clear")}:{add(n){const i=ue(this),o=$r(i),a=ue(n),l=!e&&!it(n)&&!Jt(n)?a:n;return o.has.call(i,l)||$t(n,l)&&o.has.call(i,n)||$t(a,l)&&o.has.call(i,a)||(i.add(l),Ft(i,"add",l,l)),this},set(n,i){!e&&!it(i)&&!Jt(i)&&(i=ue(i));const o=ue(this),{has:a,get:l}=$r(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?$t(i,u)&&Ft(o,"set",n,i):Ft(o,"add",n,i),this},delete(n){const i=ue(this),{has:o,get:a}=$r(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&&Ft(i,"delete",n,void 0),c},clear(){const n=ue(this),i=n.size!==0,o=n.clear();return i&&Ft(n,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(n=>{s[n]=ru(n,t,e)}),s}function Di(t,e){const s=nu(t,e);return(r,n,i)=>n==="__v_isReactive"?!t:n==="__v_isReadonly"?t:n==="__v_raw"?r:Reflect.get(pe(s,n)&&n in r?s:r,n,i)}const iu={get:Di(!1,!1)},ou={get:Di(!1,!0)},au={get:Di(!0,!1)};const el=new WeakMap,tl=new WeakMap,sl=new WeakMap,lu=new WeakMap;function cu(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function uu(t){return t.__v_skip||!Object.isExtensible(t)?0:cu(Nc(t))}function Vt(t){return Jt(t)?t:Mi(t,!1,eu,iu,el)}function rl(t){return Mi(t,!1,su,ou,tl)}function ni(t){return Mi(t,!0,tu,au,sl)}function Mi(t,e,s,r,n){if(!ve(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const i=uu(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 Wt(t){return Jt(t)?Wt(t.__v_raw):!!(t&&t.__v_isReactive)}function Jt(t){return!!(t&&t.__v_isReadonly)}function it(t){return!!(t&&t.__v_isShallow)}function vn(t){return t?!!t.__v_raw:!1}function ue(t){const e=t&&t.__v_raw;return e?ue(e):t}function Bi(t){return!pe(t,"__v_skip")&&Object.isExtensible(t)&&Na(t,"__v_skip",!0),t}const vt=t=>ve(t)?Vt(t):t,Ds=t=>ve(t)?ni(t):t;function Ce(t){return t?t.__v_isRef===!0:!1}function B(t){return nl(t,!1)}function hu(t){return nl(t,!0)}function nl(t,e){return Ce(t)?t:new du(t,e)}class du{constructor(e,s){this.dep=new Ui,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=s?e:ue(e),this._value=s?e:vt(e),this.__v_isShallow=s}get value(){return this.dep.track(),this._value}set value(e){const s=this._rawValue,r=this.__v_isShallow||it(e)||Jt(e);e=r?e:ue(e),$t(e,s)&&(this._rawValue=e,this._value=r?e:vt(e),this.dep.trigger())}}function Ee(t){return Ce(t)?t.value:t}const fu={get:(t,e,s)=>e==="__v_raw"?t:Ee(Reflect.get(t,e,s)),set:(t,e,s,r)=>{const n=t[e];return Ce(n)&&!Ce(s)?(n.value=s,!0):Reflect.set(t,e,s,r)}};function il(t){return Wt(t)?t:new Proxy(t,fu)}function pu(t){const e=te(t)?new Array(t.length):{};for(const s in t)e[s]=yu(t,s);return e}class gu{constructor(e,s,r){this._object=e,this._defaultValue=r,this.__v_isRef=!0,this._value=void 0,this._key=ht(s)?s:String(s),this._raw=ue(e);let n=!0,i=e;if(!te(e)||ht(this._key)||!pn(this._key))do n=!vn(i)||it(i);while(n&&(i=i.__v_raw));this._shallow=n}get value(){let e=this._object[this._key];return this._shallow&&(e=Ee(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&Ce(this._raw[this._key])){const s=this._object[this._key];if(Ce(s)){s.value=e;return}}this._object[this._key]=e}get dep(){return Jc(this._raw,this._key)}}function yu(t,e,s){return new gu(t,e,s)}class mu{constructor(e,s,r){this.fn=e,this.setter=s,this._value=void 0,this.dep=new Ui(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=hr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!s,this.isSSR=r}notify(){if(this.flags|=16,!(this.flags&8)&&Se!==this)return Wa(this,!0),!0}get value(){const e=this.dep.track();return Ja(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function vu(t,e,s=!1){let r,n;return ie(t)?r=t:(r=t.get,n=t.set),new mu(r,n,s)}const Ir={},zr=new WeakMap;let hs;function bu(t,e=!1,s=hs){if(s){let r=zr.get(s);r||zr.set(s,r=[]),r.push(t)}}function _u(t,e,s=we){const{immediate:r,deep:n,once:i,scheduler:o,augmentJob:a,call:l}=s,c=U=>n?U:it(U)||n===!1||n===0?qt(U,1):qt(U);let u,h,f,d,g=!1,v=!1;if(Ce(t)?(h=()=>t.value,g=it(t)):Wt(t)?(h=()=>c(t),g=!0):te(t)?(v=!0,g=t.some(U=>Wt(U)||it(U)),h=()=>t.map(U=>{if(Ce(U))return U.value;if(Wt(U))return c(U);if(ie(U))return l?l(U,2):U()})):ie(t)?e?h=l?()=>l(t,2):t:h=()=>{if(f){Kt();try{f()}finally{Gt()}}const U=hs;hs=u;try{return l?l(t,3,[d]):t(d)}finally{hs=U}}:h=Pt,e&&n){const U=h,D=n===!0?1/0:n;h=()=>qt(U(),D)}const S=Fa(),C=()=>{u.stop(),S&&S.active&&$i(S.effects,u)};if(i&&e){const U=e;e=(...D)=>{U(...D),C()}}let T=v?new Array(t.length).fill(Ir):Ir;const E=U=>{if(!(!(u.flags&1)||!u.dirty&&!U))if(e){const D=u.run();if(n||g||(v?D.some((j,b)=>$t(j,T[b])):$t(D,T))){f&&f();const j=hs;hs=u;try{const b=[D,T===Ir?void 0:v&&T[0]===Ir?[]:T,d];T=D,l?l(e,3,b):e(...b)}finally{hs=j}}}else u.run()};return a&&a(E),u=new qa(h),u.scheduler=o?()=>o(E,!1):E,d=U=>bu(U,!1,u),f=u.onStop=()=>{const U=zr.get(u);if(U){if(l)l(U,4);else for(const D of U)D();zr.delete(u)}},e?r?E(!0):T=u.run():o?o(E.bind(null,!0),!0):u.run(),C.pause=u.pause.bind(u),C.resume=u.resume.bind(u),C.stop=C,C}function qt(t,e=1/0,s){if(e<=0||!ve(t)||t.__v_skip||(s=s||new Map,(s.get(t)||0)>=e))return t;if(s.set(t,e),e--,Ce(t))qt(t.value,e,s);else if(te(t))for(let r=0;r<t.length;r++)qt(t[r],e,s);else if(fn(t)||js(t))t.forEach(r=>{qt(r,e,s)});else if(Ia(t)){for(const r in t)qt(t[r],e,s);for(const r of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,r)&&qt(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 Tr(t,e,s,r){try{return r?t(...r):t()}catch(n){bn(n,e,s)}}function jt(t,e,s,r){if(ie(t)){const n=Tr(t,e,s,r);return n&&$a(n)&&n.catch(i=>{bn(i,e,s)}),n}if(te(t)){const n=[];for(let i=0;i<t.length;i++)n.push(jt(t[i],e,s,r));return n}}function bn(t,e,s,r=!0){const n=e?e.vnode:null,{errorHandler:i,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||we;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){Kt(),Tr(i,null,10,[t,l,c]),Gt();return}}wu(t,s,n,r,o)}function wu(t,e,s,r=!0,n=!1){if(n)throw t;console.error(t)}const Je=[];let Et=-1;const Ns=[];let Zt=null,Ts=0;const ol=Promise.resolve();let Yr=null;function Ms(t){const e=Yr||ol;return t?e.then(this?t.bind(this):t):e}function xu(t){let e=Et+1,s=Je.length;for(;e<s;){const r=e+s>>>1,n=Je[r],i=fr(n);i<t||i===t&&n.flags&2?e=r+1:s=r}return e}function Hi(t){if(!(t.flags&1)){const e=fr(t),s=Je[Je.length-1];!s||!(t.flags&2)&&e>=fr(s)?Je.push(t):Je.splice(xu(e),0,t),t.flags|=1,al()}}function al(){Yr||(Yr=ol.then(cl))}function ku(t){te(t)?Ns.push(...t):Zt&&t.id===-1?Zt.splice(Ts+1,0,t):t.flags&1||(Ns.push(t),t.flags|=1),al()}function no(t,e,s=Et+1){for(;s<Je.length;s++){const r=Je[s];if(r&&r.flags&2){if(t&&r.id!==t.uid)continue;Je.splice(s,1),s--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function ll(t){if(Ns.length){const e=[...new Set(Ns)].sort((s,r)=>fr(s)-fr(r));if(Ns.length=0,Zt){Zt.push(...e);return}for(Zt=e,Ts=0;Ts<Zt.length;Ts++){const s=Zt[Ts];s.flags&4&&(s.flags&=-2),s.flags&8||s(),s.flags&=-2}Zt=null,Ts=0}}const fr=t=>t.id==null?t.flags&2?-1:1/0:t.id;function cl(t){try{for(Et=0;Et<Je.length;Et++){const e=Je[Et];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Tr(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Et<Je.length;Et++){const e=Je[Et];e&&(e.flags&=-2)}Et=-1,Je.length=0,ll(),Yr=null,(Je.length||Ns.length)&&cl()}}let lt=null,ul=null;function Xr(t){const e=lt;return lt=t,ul=t&&t.type.__scopeId||null,e}function hl(t,e=lt,s){if(!e||t._n)return t;const r=(...n)=>{r._d&&en(-1);const i=Xr(e);let o;try{o=t(...n)}finally{Xr(i),r._d&&en(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function ct(t,e){if(lt===null)return t;const s=Sn(lt),r=t.dirs||(t.dirs=[]);for(let n=0;n<e.length;n++){let[i,o,a,l=we]=e[n];i&&(ie(i)&&(i={mounted:i,updated:i}),i.deep&&qt(o),r.push({dir:i,instance:s,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function as(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&&(Kt(),jt(l,s,8,[t.el,a,t,e]),Gt())}}function Wr(t,e){if(ze){let s=ze.provides;const r=ze.parent&&ze.parent.provides;r===s&&(s=ze.provides=Object.create(r)),s[t]=e}}function ut(t,e,s=!1){const r=Ul();if(r||ms){let n=ms?ms._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&&ie(e)?e.call(r&&r.proxy):e}}function Su(){return!!(Ul()||ms)}const Eu=Symbol.for("v-scx"),Tu=()=>ut(Eu);function rs(t,e,s){return dl(t,e,s)}function dl(t,e,s=we){const{immediate:r,deep:n,flush:i,once:o}=s,a=Fe({},s),l=e&&r||!e&&i!=="post";let c;if(gr){if(i==="sync"){const d=Tu();c=d.__watcherHandles||(d.__watcherHandles=[])}else if(!l){const d=()=>{};return d.stop=Pt,d.resume=Pt,d.pause=Pt,d}}const u=ze;a.call=(d,g,v)=>jt(d,u,g,v);let h=!1;i==="post"?a.scheduler=d=>{Ze(d,u&&u.suspense)}:i!=="sync"&&(h=!0,a.scheduler=(d,g)=>{g?d():Hi(d)}),a.augmentJob=d=>{e&&(d.flags|=4),h&&(d.flags|=2,u&&(d.id=u.uid,d.i=u))};const f=_u(t,e,a);return gr&&(c?c.push(f):l&&f()),f}function Au(t,e,s){const r=this.proxy,n=Re(t)?t.includes(".")?fl(r,t):()=>r[t]:t.bind(r,r);let i;ie(e)?i=e:(i=e.handler,s=e);const o=Ar(this),a=dl(n,i.bind(r),s);return o(),a}function fl(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 Ru=Symbol("_vte"),Cu=t=>t.__isTeleport,Ou=Symbol("_leaveCb");function Fi(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Fi(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 dt(t,e){return ie(t)?Fe({name:t.name},e,{setup:t}):t}function pl(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function io(t,e){let s;return!!((s=Object.getOwnPropertyDescriptor(t,e))&&!s.configurable)}const Qr=new WeakMap;function sr(t,e,s,r,n=!1){if(te(t)){t.forEach((v,S)=>sr(v,e&&(te(e)?e[S]:e),s,r,n));return}if(rr(r)&&!n){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&sr(t,e,s,r.component.subTree);return}const i=r.shapeFlag&4?Sn(r.component):r.el,o=n?null:i,{i:a,r:l}=t,c=e&&e.r,u=a.refs===we?a.refs={}:a.refs,h=a.setupState,f=ue(h),d=h===we?Oa:v=>io(u,v)?!1:pe(f,v),g=(v,S)=>!(S&&io(u,S));if(c!=null&&c!==l){if(oo(e),Re(c))u[c]=null,d(c)&&(h[c]=null);else if(Ce(c)){const v=e;g(c,v.k)&&(c.value=null),v.k&&(u[v.k]=null)}}if(ie(l))Tr(l,a,12,[o,u]);else{const v=Re(l),S=Ce(l);if(v||S){const C=()=>{if(t.f){const T=v?d(l)?h[l]:u[l]:g()||!t.k?l.value:u[t.k];if(n)te(T)&&$i(T,i);else if(te(T))T.includes(i)||T.push(i);else if(v)u[l]=[i],d(l)&&(h[l]=u[l]);else{const E=[i];g(l,t.k)&&(l.value=E),t.k&&(u[t.k]=E)}}else v?(u[l]=o,d(l)&&(h[l]=o)):S&&(g(l,t.k)&&(l.value=o),t.k&&(u[t.k]=o))};if(o){const T=()=>{C(),Qr.delete(t)};T.id=-1,Qr.set(t,T),Ze(T,s)}else oo(t),C()}}}function oo(t){const e=Qr.get(t);e&&(e.flags|=8,Qr.delete(t))}yn().requestIdleCallback;yn().cancelIdleCallback;const rr=t=>!!t.type.__asyncLoader,gl=t=>t.type.__isKeepAlive;function $u(t,e){yl(t,"a",e)}function Pu(t,e){yl(t,"da",e)}function yl(t,e,s=ze){const r=t.__wdc||(t.__wdc=()=>{let n=s;for(;n;){if(n.isDeactivated)return;n=n.parent}return t()});if(_n(e,r,s),s){let n=s.parent;for(;n&&n.parent;)gl(n.parent.vnode)&&Iu(r,e,s,n),n=n.parent}}function Iu(t,e,s,r){const n=_n(e,t,r,!0);wn(()=>{$i(r[e],n)},s)}function _n(t,e,s=ze,r=!1){if(s){const n=s[t]||(s[t]=[]),i=e.__weh||(e.__weh=(...o)=>{Kt();const a=Ar(s),l=jt(e,s,t,o);return a(),Gt(),l});return r?n.unshift(i):n.push(i),i}}const zt=t=>(e,s=ze)=>{(!gr||t==="sp")&&_n(t,(...r)=>e(...r),s)},ju=zt("bm"),os=zt("m"),Nu=zt("bu"),Lu=zt("u"),ml=zt("bum"),wn=zt("um"),Uu=zt("sp"),Du=zt("rtg"),Mu=zt("rtc");function Bu(t,e=ze){_n("ec",t,e)}const Hu=Symbol.for("v-ndc");function Ve(t,e,s,r){let n;const i=s,o=te(t);if(o||Re(t)){const a=o&&Wt(t);let l=!1,c=!1;a&&(l=!it(t),c=Jt(t),t=mn(t)),n=new Array(t.length);for(let u=0,h=t.length;u<h;u++)n[u]=e(l?c?Ds(vt(t[u])):vt(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(ve(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 ii=t=>t?Dl(t)?Sn(t):ii(t.parent):null,nr=Fe(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=>ii(t.parent),$root:t=>ii(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>bl(t),$forceUpdate:t=>t.f||(t.f=()=>{Hi(t.update)}),$nextTick:t=>t.n||(t.n=Ms.bind(t.proxy)),$watch:t=>Au.bind(t)}),Mn=(t,e)=>t!==we&&!t.__isScriptSetup&&pe(t,e),Fu={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 f=o[e];if(f!==void 0)switch(f){case 1:return r[e];case 2:return n[e];case 4:return s[e];case 3:return i[e]}else{if(Mn(r,e))return o[e]=1,r[e];if(n!==we&&pe(n,e))return o[e]=2,n[e];if(pe(i,e))return o[e]=3,i[e];if(s!==we&&pe(s,e))return o[e]=4,s[e];oi&&(o[e]=0)}}const c=nr[e];let u,h;if(c)return e==="$attrs"&&qe(t.attrs,"get",""),c(t);if((u=a.__cssModules)&&(u=u[e]))return u;if(s!==we&&pe(s,e))return o[e]=4,s[e];if(h=l.config.globalProperties,pe(h,e))return h[e]},set({_:t},e,s){const{data:r,setupState:n,ctx:i}=t;return Mn(n,e)?(n[e]=s,!0):r!==we&&pe(r,e)?(r[e]=s,!0):pe(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!==we&&a[0]!=="$"&&pe(t,a)||Mn(e,a)||pe(i,a)||pe(r,a)||pe(nr,a)||pe(n.config.globalProperties,a)||(l=o.__cssModules)&&l[a])},defineProperty(t,e,s){return s.get!=null?t._.accessCache[e]=0:pe(s,"value")&&this.set(t,e,s.value,null),Reflect.defineProperty(t,e,s)}};function ao(t){return te(t)?t.reduce((e,s)=>(e[s]=null,e),{}):t}let oi=!0;function qu(t){const e=bl(t),s=t.proxy,r=t.ctx;oi=!1,e.beforeCreate&&lo(e.beforeCreate,t,"bc");const{data:n,computed:i,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:h,mounted:f,beforeUpdate:d,updated:g,activated:v,deactivated:S,beforeDestroy:C,beforeUnmount:T,destroyed:E,unmounted:U,render:D,renderTracked:j,renderTriggered:b,errorCaptured:N,serverPrefetch:Y,expose:he,inheritAttrs:me,components:Pe,directives:oe,filters:et}=e;if(c&&Vu(c,r,null),o)for(const se in o){const ae=o[se];ie(ae)&&(r[se]=ae.bind(s))}if(n){const se=n.call(s,s);ve(se)&&(t.data=Vt(se))}if(oi=!0,i)for(const se in i){const ae=i[se],Ue=ie(ae)?ae.bind(s,s):ie(ae.get)?ae.get.bind(s,s):Pt,Ye=!ie(ae)&&ie(ae.set)?ae.set.bind(s):Pt,k=Ne({get:Ue,set:Ye});Object.defineProperty(r,se,{enumerable:!0,configurable:!0,get:()=>k.value,set:A=>k.value=A})}if(a)for(const se in a)vl(a[se],r,s,se);if(l){const se=ie(l)?l.call(s):l;Reflect.ownKeys(se).forEach(ae=>{Wr(ae,se[ae])})}u&&lo(u,t,"c");function de(se,ae){te(ae)?ae.forEach(Ue=>se(Ue.bind(s))):ae&&se(ae.bind(s))}if(de(ju,h),de(os,f),de(Nu,d),de(Lu,g),de($u,v),de(Pu,S),de(Bu,N),de(Mu,j),de(Du,b),de(ml,T),de(wn,U),de(Uu,Y),te(he))if(he.length){const se=t.exposed||(t.exposed={});he.forEach(ae=>{Object.defineProperty(se,ae,{get:()=>s[ae],set:Ue=>s[ae]=Ue,enumerable:!0})})}else t.exposed||(t.exposed={});D&&t.render===Pt&&(t.render=D),me!=null&&(t.inheritAttrs=me),Pe&&(t.components=Pe),oe&&(t.directives=oe),Y&&pl(t)}function Vu(t,e,s=Pt){te(t)&&(t=ai(t));for(const r in t){const n=t[r];let i;ve(n)?"default"in n?i=ut(n.from||r,n.default,!0):i=ut(n.from||r):i=ut(n),Ce(i)?Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):e[r]=i}}function lo(t,e,s){jt(te(t)?t.map(r=>r.bind(e.proxy)):t.bind(e.proxy),e,s)}function vl(t,e,s,r){let n=r.includes(".")?fl(s,r):()=>s[r];if(Re(t)){const i=e[t];ie(i)&&rs(n,i)}else if(ie(t))rs(n,t.bind(s));else if(ve(t))if(te(t))t.forEach(i=>vl(i,e,s,r));else{const i=ie(t.handler)?t.handler.bind(s):e[t.handler];ie(i)&&rs(n,i,t)}}function bl(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=>Zr(l,c,o,!0)),Zr(l,e,o)),ve(e)&&i.set(e,l),l}function Zr(t,e,s,r=!1){const{mixins:n,extends:i}=e;i&&Zr(t,i,s,!0),n&&n.forEach(o=>Zr(t,o,s,!0));for(const o in e)if(!(r&&o==="expose")){const a=Wu[o]||s&&s[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const Wu={data:co,props:uo,emits:uo,methods:zs,computed:zs,beforeCreate:Ke,created:Ke,beforeMount:Ke,mounted:Ke,beforeUpdate:Ke,updated:Ke,beforeDestroy:Ke,beforeUnmount:Ke,destroyed:Ke,unmounted:Ke,activated:Ke,deactivated:Ke,errorCaptured:Ke,serverPrefetch:Ke,components:zs,directives:zs,watch:Gu,provide:co,inject:Ku};function co(t,e){return e?t?function(){return Fe(ie(t)?t.call(this,this):t,ie(e)?e.call(this,this):e)}:e:t}function Ku(t,e){return zs(ai(t),ai(e))}function ai(t){if(te(t)){const e={};for(let s=0;s<t.length;s++)e[t[s]]=t[s];return e}return t}function Ke(t,e){return t?[...new Set([].concat(t,e))]:e}function zs(t,e){return t?Fe(Object.create(null),t,e):e}function uo(t,e){return t?te(t)&&te(e)?[...new Set([...t,...e])]:Fe(Object.create(null),ao(t),ao(e??{})):e}function Gu(t,e){if(!t)return e;if(!e)return t;const s=Fe(Object.create(null),t);for(const r in e)s[r]=Ke(t[r],e[r]);return s}function _l(){return{app:null,config:{isNativeTag:Oa,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 Ju=0;function zu(t,e){return function(r,n=null){ie(r)||(r=Fe({},r)),n!=null&&!ve(n)&&(n=null);const i=_l(),o=new WeakSet,a=[];let l=!1;const c=i.app={_uid:Ju++,_component:r,_props:n,_container:null,_context:i,_instance:null,version:Ah,get config(){return i.config},set config(u){},use(u,...h){return o.has(u)||(u&&ie(u.install)?(o.add(u),u.install(c,...h)):ie(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,f){if(!l){const d=c._ceVNode||We(r,n);return d.appContext=i,f===!0?f="svg":f===!1&&(f=void 0),t(d,u,f),l=!0,c._container=u,u.__vue_app__=c,Sn(d.component)}},onUnmount(u){a.push(u)},unmount(){l&&(jt(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=ms;ms=c;try{return u()}finally{ms=h}}};return c}}let ms=null;const Yu=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${yt(e)}Modifiers`]||t[`${vs(e)}Modifiers`];function Xu(t,e,...s){if(t.isUnmounted)return;const r=t.vnode.props||we;let n=s;const i=e.startsWith("update:"),o=i&&Yu(r,e.slice(7));o&&(o.trim&&(n=s.map(u=>Re(u)?u.trim():u)),o.number&&(n=s.map(Pi)));let a,l=r[a=jn(e)]||r[a=jn(yt(e))];!l&&i&&(l=r[a=jn(vs(e))]),l&&jt(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,jt(c,t,6,n)}}const Qu=new WeakMap;function wl(t,e,s=!1){const r=s?Qu:e.emitsCache,n=r.get(t);if(n!==void 0)return n;const i=t.emits;let o={},a=!1;if(!ie(t)){const l=c=>{const u=wl(c,e,!0);u&&(a=!0,Fe(o,u))};!s&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!i&&!a?(ve(t)&&r.set(t,null),null):(te(i)?i.forEach(l=>o[l]=null):Fe(o,i),ve(t)&&r.set(t,o),o)}function xn(t,e){return!t||!hn(e)?!1:(e=e.slice(2).replace(/Once$/,""),pe(t,e[0].toLowerCase()+e.slice(1))||pe(t,vs(e))||pe(t,e))}function ho(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:f,setupState:d,ctx:g,inheritAttrs:v}=t,S=Xr(t);let C,T;try{if(s.shapeFlag&4){const U=n||r,D=U;C=Ct(c.call(D,U,u,h,d,f,g)),T=a}else{const U=e;C=Ct(U.length>1?U(h,{attrs:a,slots:o,emit:l}):U(h,null)),T=e.props?a:Zu(a)}}catch(U){ir.length=0,bn(U,t,1),C=We(ns)}let E=C;if(T&&v!==!1){const U=Object.keys(T),{shapeFlag:D}=E;U.length&&D&7&&(i&&U.some(dn)&&(T=eh(T,i)),E=Bs(E,T,!1,!0))}return s.dirs&&(E=Bs(E,null,!1,!0),E.dirs=E.dirs?E.dirs.concat(s.dirs):s.dirs),s.transition&&Fi(E,s.transition),C=E,Xr(S),C}const Zu=t=>{let e;for(const s in t)(s==="class"||s==="style"||hn(s))&&((e||(e={}))[s]=t[s]);return e},eh=(t,e)=>{const s={};for(const r in t)(!dn(r)||!(r.slice(9)in e))&&(s[r]=t[r]);return s};function th(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?fo(r,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let h=0;h<u.length;h++){const f=u[h];if(xl(o,r,f)&&!xn(c,f))return!0}}}else return(n||a)&&(!a||!a.$stable)?!0:r===o?!1:r?o?fo(r,o,c):!0:!!o;return!1}function fo(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(xl(e,t,i)&&!xn(s,i))return!0}return!1}function xl(t,e,s){const r=t[s],n=e[s];return s==="style"&&ve(r)&&ve(n)?!Er(r,n):r!==n}function sh({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 kl={},Sl=()=>Object.create(kl),El=t=>Object.getPrototypeOf(t)===kl;function rh(t,e,s,r=!1){const n={},i=Sl();t.propsDefaults=Object.create(null),Tl(t,e,n,i);for(const o in t.propsOptions[0])o in n||(n[o]=void 0);s?t.props=r?n:rl(n):t.type.props?t.props=n:t.props=i,t.attrs=i}function nh(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 f=u[h];if(xn(t.emitsOptions,f))continue;const d=e[f];if(l)if(pe(i,f))d!==i[f]&&(i[f]=d,c=!0);else{const g=yt(f);n[g]=li(l,a,g,d,t,!1)}else d!==i[f]&&(i[f]=d,c=!0)}}}else{Tl(t,e,n,i)&&(c=!0);let u;for(const h in a)(!e||!pe(e,h)&&((u=vs(h))===h||!pe(e,u)))&&(l?s&&(s[h]!==void 0||s[u]!==void 0)&&(n[h]=li(l,a,h,void 0,t,!0)):delete n[h]);if(i!==a)for(const h in i)(!e||!pe(e,h))&&(delete i[h],c=!0)}c&&Ft(t.attrs,"set","")}function Tl(t,e,s,r){const[n,i]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(Zs(l))continue;const c=e[l];let u;n&&pe(n,u=yt(l))?!i||!i.includes(u)?s[u]=c:(a||(a={}))[u]=c:xn(t.emitsOptions,l)||(!(l in r)||c!==r[l])&&(r[l]=c,o=!0)}if(i){const l=ue(s),c=a||we;for(let u=0;u<i.length;u++){const h=i[u];s[h]=li(n,l,h,c[h],t,!pe(c,h))}}return o}function li(t,e,s,r,n,i){const o=t[s];if(o!=null){const a=pe(o,"default");if(a&&r===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&ie(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===vs(s))&&(r=!0))}return r}const ih=new WeakMap;function Al(t,e,s=!1){const r=s?ih:e.propsCache,n=r.get(t);if(n)return n;const i=t.props,o={},a=[];let l=!1;if(!ie(t)){const u=h=>{l=!0;const[f,d]=Al(h,e,!0);Fe(o,f),d&&a.push(...d)};!s&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!i&&!l)return ve(t)&&r.set(t,Is),Is;if(te(i))for(let u=0;u<i.length;u++){const h=yt(i[u]);po(h)&&(o[h]=we)}else if(i)for(const u in i){const h=yt(u);if(po(h)){const f=i[u],d=o[h]=te(f)||ie(f)?{type:f}:Fe({},f),g=d.type;let v=!1,S=!0;if(te(g))for(let C=0;C<g.length;++C){const T=g[C],E=ie(T)&&T.name;if(E==="Boolean"){v=!0;break}else E==="String"&&(S=!1)}else v=ie(g)&&g.name==="Boolean";d[0]=v,d[1]=S,(v||pe(d,"default"))&&a.push(h)}}const c=[o,a];return ve(t)&&r.set(t,c),c}function po(t){return t[0]!=="$"&&!Zs(t)}const qi=t=>t==="_"||t==="_ctx"||t==="$stable",Vi=t=>te(t)?t.map(Ct):[Ct(t)],oh=(t,e,s)=>{if(e._n)return e;const r=hl((...n)=>Vi(e(...n)),s);return r._c=!1,r},Rl=(t,e,s)=>{const r=t._ctx;for(const n in t){if(qi(n))continue;const i=t[n];if(ie(i))e[n]=oh(n,i,r);else if(i!=null){const o=Vi(i);e[n]=()=>o}}},Cl=(t,e)=>{const s=Vi(e);t.slots.default=()=>s},Ol=(t,e,s)=>{for(const r in e)(s||!qi(r))&&(t[r]=e[r])},ah=(t,e,s)=>{const r=t.slots=Sl();if(t.vnode.shapeFlag&32){const n=e._;n?(Ol(r,e,s),s&&Na(r,"_",n,!0)):Rl(e,r)}else e&&Cl(t,e)},lh=(t,e,s)=>{const{vnode:r,slots:n}=t;let i=!0,o=we;if(r.shapeFlag&32){const a=e._;a?s&&a===1?i=!1:Ol(n,e,s):(i=!e.$stable,Rl(e,n)),o=e}else e&&(Cl(t,e),o={default:1});if(i)for(const a in n)!qi(a)&&o[a]==null&&delete n[a]},Ze=fh;function ch(t){return uh(t)}function uh(t,e){const s=yn();s.__VUE__=!0;const{insert:r,remove:n,patchProp:i,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:h,nextSibling:f,setScopeId:d=Pt,insertStaticContent:g}=t,v=(y,m,x,$=null,L=null,I=null,V=void 0,F=null,H=!!m.dynamicChildren)=>{if(y===m)return;y&&!Ks(y,m)&&($=P(y),A(y,L,I,!0),y=null),m.patchFlag===-2&&(H=!1,m.dynamicChildren=null);const{type:M,ref:Z,shapeFlag:K}=m;switch(M){case kn:S(y,m,x,$);break;case ns:C(y,m,x,$);break;case Hn:y==null&&T(m,x,$,V);break;case ye:Pe(y,m,x,$,L,I,V,F,H);break;default:K&1?D(y,m,x,$,L,I,V,F,H):K&6?oe(y,m,x,$,L,I,V,F,H):(K&64||K&128)&&M.process(y,m,x,$,L,I,V,F,H,X)}Z!=null&&L?sr(Z,y&&y.ref,I,m||y,!m):Z==null&&y&&y.ref!=null&&sr(y.ref,null,I,y,!0)},S=(y,m,x,$)=>{if(y==null)r(m.el=a(m.children),x,$);else{const L=m.el=y.el;m.children!==y.children&&c(L,m.children)}},C=(y,m,x,$)=>{y==null?r(m.el=l(m.children||""),x,$):m.el=y.el},T=(y,m,x,$)=>{[y.el,y.anchor]=g(y.children,m,x,$,y.el,y.anchor)},E=({el:y,anchor:m},x,$)=>{let L;for(;y&&y!==m;)L=f(y),r(y,x,$),y=L;r(m,x,$)},U=({el:y,anchor:m})=>{let x;for(;y&&y!==m;)x=f(y),n(y),y=x;n(m)},D=(y,m,x,$,L,I,V,F,H)=>{if(m.type==="svg"?V="svg":m.type==="math"&&(V="mathml"),y==null)j(m,x,$,L,I,V,F,H);else{const M=y.el&&y.el._isVueCE?y.el:null;try{M&&M._beginPatch(),Y(y,m,L,I,V,F,H)}finally{M&&M._endPatch()}}},j=(y,m,x,$,L,I,V,F)=>{let H,M;const{props:Z,shapeFlag:K,transition:Q,dirs:re}=y;if(H=y.el=o(y.type,I,Z&&Z.is,Z),K&8?u(H,y.children):K&16&&N(y.children,H,null,$,L,Bn(y,I),V,F),re&&as(y,null,$,"created"),b(H,y,y.scopeId,V,$),Z){for(const _e in Z)_e!=="value"&&!Zs(_e)&&i(H,_e,null,Z[_e],I,$);"value"in Z&&i(H,"value",null,Z.value,I),(M=Z.onVnodeBeforeMount)&&kt(M,$,y)}re&&as(y,null,$,"beforeMount");const ce=hh(L,Q);ce&&Q.beforeEnter(H),r(H,m,x),((M=Z&&Z.onVnodeMounted)||ce||re)&&Ze(()=>{try{M&&kt(M,$,y),ce&&Q.enter(H),re&&as(y,null,$,"mounted")}finally{}},L)},b=(y,m,x,$,L)=>{if(x&&d(y,x),$)for(let I=0;I<$.length;I++)d(y,$[I]);if(L){let I=L.subTree;if(m===I||jl(I.type)&&(I.ssContent===m||I.ssFallback===m)){const V=L.vnode;b(y,V,V.scopeId,V.slotScopeIds,L.parent)}}},N=(y,m,x,$,L,I,V,F,H=0)=>{for(let M=H;M<y.length;M++){const Z=y[M]=F?Ht(y[M]):Ct(y[M]);v(null,Z,m,x,$,L,I,V,F)}},Y=(y,m,x,$,L,I,V)=>{const F=m.el=y.el;let{patchFlag:H,dynamicChildren:M,dirs:Z}=m;H|=y.patchFlag&16;const K=y.props||we,Q=m.props||we;let re;if(x&&ls(x,!1),(re=Q.onVnodeBeforeUpdate)&&kt(re,x,m,y),Z&&as(m,y,x,"beforeUpdate"),x&&ls(x,!0),(K.innerHTML&&Q.innerHTML==null||K.textContent&&Q.textContent==null)&&u(F,""),M?he(y.dynamicChildren,M,F,x,$,Bn(m,L),I):V||ae(y,m,F,null,x,$,Bn(m,L),I,!1),H>0){if(H&16)me(F,K,Q,x,L);else if(H&2&&K.class!==Q.class&&i(F,"class",null,Q.class,L),H&4&&i(F,"style",K.style,Q.style,L),H&8){const ce=m.dynamicProps;for(let _e=0;_e<ce.length;_e++){const xe=ce[_e],Oe=K[xe],Me=Q[xe];(Me!==Oe||xe==="value")&&i(F,xe,Oe,Me,L,x)}}H&1&&y.children!==m.children&&u(F,m.children)}else!V&&M==null&&me(F,K,Q,x,L);((re=Q.onVnodeUpdated)||Z)&&Ze(()=>{re&&kt(re,x,m,y),Z&&as(m,y,x,"updated")},$)},he=(y,m,x,$,L,I,V)=>{for(let F=0;F<m.length;F++){const H=y[F],M=m[F],Z=H.el&&(H.type===ye||!Ks(H,M)||H.shapeFlag&198)?h(H.el):x;v(H,M,Z,null,$,L,I,V,!0)}},me=(y,m,x,$,L)=>{if(m!==x){if(m!==we)for(const I in m)!Zs(I)&&!(I in x)&&i(y,I,m[I],null,L,$);for(const I in x){if(Zs(I))continue;const V=x[I],F=m[I];V!==F&&I!=="value"&&i(y,I,F,V,L,$)}"value"in x&&i(y,"value",m.value,x.value,L)}},Pe=(y,m,x,$,L,I,V,F,H)=>{const M=m.el=y?y.el:a(""),Z=m.anchor=y?y.anchor:a("");let{patchFlag:K,dynamicChildren:Q,slotScopeIds:re}=m;re&&(F=F?F.concat(re):re),y==null?(r(M,x,$),r(Z,x,$),N(m.children||[],x,Z,L,I,V,F,H)):K>0&&K&64&&Q&&y.dynamicChildren&&y.dynamicChildren.length===Q.length?(he(y.dynamicChildren,Q,x,L,I,V,F),(m.key!=null||L&&m===L.subTree)&&$l(y,m,!0)):ae(y,m,x,Z,L,I,V,F,H)},oe=(y,m,x,$,L,I,V,F,H)=>{m.slotScopeIds=F,y==null?m.shapeFlag&512?L.ctx.activate(m,x,$,V,H):et(m,x,$,L,I,V,H):ot(y,m,H)},et=(y,m,x,$,L,I,V)=>{const F=y.component=wh(y,$,L);if(gl(y)&&(F.ctx.renderer=X),xh(F,!1,V),F.asyncDep){if(L&&L.registerDep(F,de,V),!y.el){const H=F.subTree=We(ns);C(null,H,m,x),y.placeholder=H.el}}else de(F,y,m,x,L,I,V)},ot=(y,m,x)=>{const $=m.component=y.component;if(th(y,m,x))if($.asyncDep&&!$.asyncResolved){se($,m,x);return}else $.next=m,$.update();else m.el=y.el,$.vnode=m},de=(y,m,x,$,L,I,V)=>{const F=()=>{if(y.isMounted){let{next:K,bu:Q,u:re,parent:ce,vnode:_e}=y;{const wt=Pl(y);if(wt){K&&(K.el=_e.el,se(y,K,V)),wt.asyncDep.then(()=>{Ze(()=>{y.isUnmounted||M()},L)});return}}let xe=K,Oe;ls(y,!1),K?(K.el=_e.el,se(y,K,V)):K=_e,Q&&Vr(Q),(Oe=K.props&&K.props.onVnodeBeforeUpdate)&&kt(Oe,ce,K,_e),ls(y,!0);const Me=ho(y),_t=y.subTree;y.subTree=Me,v(_t,Me,h(_t.el),P(_t),y,L,I),K.el=Me.el,xe===null&&sh(y,Me.el),re&&Ze(re,L),(Oe=K.props&&K.props.onVnodeUpdated)&&Ze(()=>kt(Oe,ce,K,_e),L)}else{let K;const{el:Q,props:re}=m,{bm:ce,m:_e,parent:xe,root:Oe,type:Me}=y,_t=rr(m);ls(y,!1),ce&&Vr(ce),!_t&&(K=re&&re.onVnodeBeforeMount)&&kt(K,xe,m),ls(y,!0);{Oe.ce&&Oe.ce._hasShadowRoot()&&Oe.ce._injectChildStyle(Me,y.parent?y.parent.type:void 0);const wt=y.subTree=ho(y);v(null,wt,x,$,y,L,I),m.el=wt.el}if(_e&&Ze(_e,L),!_t&&(K=re&&re.onVnodeMounted)){const wt=m;Ze(()=>kt(K,xe,wt),L)}(m.shapeFlag&256||xe&&rr(xe.vnode)&&xe.vnode.shapeFlag&256)&&y.a&&Ze(y.a,L),y.isMounted=!0,m=x=$=null}};y.scope.on();const H=y.effect=new qa(F);y.scope.off();const M=y.update=H.run.bind(H),Z=y.job=H.runIfDirty.bind(H);Z.i=y,Z.id=y.uid,H.scheduler=()=>Hi(Z),ls(y,!0),M()},se=(y,m,x)=>{m.component=y;const $=y.vnode.props;y.vnode=m,y.next=null,nh(y,m.props,$,x),lh(y,m.children,x),Kt(),no(y),Gt()},ae=(y,m,x,$,L,I,V,F,H=!1)=>{const M=y&&y.children,Z=y?y.shapeFlag:0,K=m.children,{patchFlag:Q,shapeFlag:re}=m;if(Q>0){if(Q&128){Ye(M,K,x,$,L,I,V,F,H);return}else if(Q&256){Ue(M,K,x,$,L,I,V,F,H);return}}re&8?(Z&16&&Xe(M,L,I),K!==M&&u(x,K)):Z&16?re&16?Ye(M,K,x,$,L,I,V,F,H):Xe(M,L,I,!0):(Z&8&&u(x,""),re&16&&N(K,x,$,L,I,V,F,H))},Ue=(y,m,x,$,L,I,V,F,H)=>{y=y||Is,m=m||Is;const M=y.length,Z=m.length,K=Math.min(M,Z);let Q;for(Q=0;Q<K;Q++){const re=m[Q]=H?Ht(m[Q]):Ct(m[Q]);v(y[Q],re,x,null,L,I,V,F,H)}M>Z?Xe(y,L,I,!0,!1,K):N(m,x,$,L,I,V,F,H,K)},Ye=(y,m,x,$,L,I,V,F,H)=>{let M=0;const Z=m.length;let K=y.length-1,Q=Z-1;for(;M<=K&&M<=Q;){const re=y[M],ce=m[M]=H?Ht(m[M]):Ct(m[M]);if(Ks(re,ce))v(re,ce,x,null,L,I,V,F,H);else break;M++}for(;M<=K&&M<=Q;){const re=y[K],ce=m[Q]=H?Ht(m[Q]):Ct(m[Q]);if(Ks(re,ce))v(re,ce,x,null,L,I,V,F,H);else break;K--,Q--}if(M>K){if(M<=Q){const re=Q+1,ce=re<Z?m[re].el:$;for(;M<=Q;)v(null,m[M]=H?Ht(m[M]):Ct(m[M]),x,ce,L,I,V,F,H),M++}}else if(M>Q)for(;M<=K;)A(y[M],L,I,!0),M++;else{const re=M,ce=M,_e=new Map;for(M=ce;M<=Q;M++){const tt=m[M]=H?Ht(m[M]):Ct(m[M]);tt.key!=null&&_e.set(tt.key,M)}let xe,Oe=0;const Me=Q-ce+1;let _t=!1,wt=0;const Vs=new Array(Me);for(M=0;M<Me;M++)Vs[M]=0;for(M=re;M<=K;M++){const tt=y[M];if(Oe>=Me){A(tt,L,I,!0);continue}let xt;if(tt.key!=null)xt=_e.get(tt.key);else for(xe=ce;xe<=Q;xe++)if(Vs[xe-ce]===0&&Ks(tt,m[xe])){xt=xe;break}xt===void 0?A(tt,L,I,!0):(Vs[xt-ce]=M+1,xt>=wt?wt=xt:_t=!0,v(tt,m[xt],x,null,L,I,V,F,H),Oe++)}const Xi=_t?dh(Vs):Is;for(xe=Xi.length-1,M=Me-1;M>=0;M--){const tt=ce+M,xt=m[tt],Qi=m[tt+1],Zi=tt+1<Z?Qi.el||Il(Qi):$;Vs[M]===0?v(null,xt,x,Zi,L,I,V,F,H):_t&&(xe<0||M!==Xi[xe]?k(xt,x,Zi,2):xe--)}}},k=(y,m,x,$,L=null)=>{const{el:I,type:V,transition:F,children:H,shapeFlag:M}=y;if(M&6){k(y.component.subTree,m,x,$);return}if(M&128){y.suspense.move(m,x,$);return}if(M&64){V.move(y,m,x,X);return}if(V===ye){r(I,m,x);for(let K=0;K<H.length;K++)k(H[K],m,x,$);r(y.anchor,m,x);return}if(V===Hn){E(y,m,x);return}if($!==2&&M&1&&F)if($===0)F.beforeEnter(I),r(I,m,x),Ze(()=>F.enter(I),L);else{const{leave:K,delayLeave:Q,afterLeave:re}=F,ce=()=>{y.ctx.isUnmounted?n(I):r(I,m,x)},_e=()=>{I._isLeaving&&I[Ou](!0),K(I,()=>{ce(),re&&re()})};Q?Q(I,ce,_e):_e()}else r(I,m,x)},A=(y,m,x,$=!1,L=!1)=>{const{type:I,props:V,ref:F,children:H,dynamicChildren:M,shapeFlag:Z,patchFlag:K,dirs:Q,cacheIndex:re,memo:ce}=y;if(K===-2&&(L=!1),F!=null&&(Kt(),sr(F,null,x,y,!0),Gt()),re!=null&&(m.renderCache[re]=void 0),Z&256){m.ctx.deactivate(y);return}const _e=Z&1&&Q,xe=!rr(y);let Oe;if(xe&&(Oe=V&&V.onVnodeBeforeUnmount)&&kt(Oe,m,y),Z&6)De(y.component,x,$);else{if(Z&128){y.suspense.unmount(x,$);return}_e&&as(y,null,m,"beforeUnmount"),Z&64?y.type.remove(y,m,x,X,$):M&&!M.hasOnce&&(I!==ye||K>0&&K&64)?Xe(M,m,x,!1,!0):(I===ye&&K&384||!L&&Z&16)&&Xe(H,m,x),$&&R(y)}const Me=ce!=null&&re==null;(xe&&(Oe=V&&V.onVnodeUnmounted)||_e||Me)&&Ze(()=>{Oe&&kt(Oe,m,y),_e&&as(y,null,m,"unmounted"),Me&&(y.el=null)},x)},R=y=>{const{type:m,el:x,anchor:$,transition:L}=y;if(m===ye){ne(x,$);return}if(m===Hn){U(y);return}const I=()=>{n(x),L&&!L.persisted&&L.afterLeave&&L.afterLeave()};if(y.shapeFlag&1&&L&&!L.persisted){const{leave:V,delayLeave:F}=L,H=()=>V(x,I);F?F(y.el,I,H):H()}else I()},ne=(y,m)=>{let x;for(;y!==m;)x=f(y),n(y),y=x;n(m)},De=(y,m,x)=>{const{bum:$,scope:L,job:I,subTree:V,um:F,m:H,a:M}=y;go(H),go(M),$&&Vr($),L.stop(),I&&(I.flags|=8,A(V,y,m,x)),F&&Ze(F,m),Ze(()=>{y.isUnmounted=!0},m)},Xe=(y,m,x,$=!1,L=!1,I=0)=>{for(let V=I;V<y.length;V++)A(y[V],m,x,$,L)},P=y=>{if(y.shapeFlag&6)return P(y.component.subTree);if(y.shapeFlag&128)return y.suspense.next();const m=f(y.anchor||y.el),x=m&&m[Ru];return x?f(x):m};let G=!1;const W=(y,m,x)=>{let $;y==null?m._vnode&&(A(m._vnode,null,null,!0),$=m._vnode.component):v(m._vnode||null,y,m,null,null,null,x),m._vnode=y,G||(G=!0,no($),ll(),G=!1)},X={p:v,um:A,m:k,r:R,mt:et,mc:N,pc:ae,pbc:he,n:P,o:t};return{render:W,hydrate:void 0,createApp:zu(W)}}function Bn({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 ls({effect:t,job:e},s){s?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function hh(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function $l(t,e,s=!1){const r=t.children,n=e.children;if(te(r)&&te(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]=Ht(n[i]),a.el=o.el),!s&&a.patchFlag!==-2&&$l(o,a)),a.type===kn&&(a.patchFlag===-1&&(a=n[i]=Ht(a)),a.el=o.el),a.type===ns&&!a.el&&(a.el=o.el)}}function dh(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 Pl(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Pl(e)}function go(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function Il(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?Il(e.subTree):null}const jl=t=>t.__isSuspense;function fh(t,e){e&&e.pendingBranch?te(t)?e.effects.push(...t):e.effects.push(t):ku(t)}const ye=Symbol.for("v-fgt"),kn=Symbol.for("v-txt"),ns=Symbol.for("v-cmt"),Hn=Symbol.for("v-stc"),ir=[];let nt=null;function _(t=!1){ir.push(nt=t?null:[])}function ph(){ir.pop(),nt=ir[ir.length-1]||null}let pr=1;function en(t,e=!1){pr+=t,t<0&&nt&&e&&(nt.hasOnce=!0)}function Nl(t){return t.dynamicChildren=pr>0?nt||Is:null,ph(),pr>0&&nt&&nt.push(t),t}function w(t,e,s,r,n,i){return Nl(p(t,e,s,r,n,i,!0))}function gh(t,e,s,r,n){return Nl(We(t,e,s,r,n,!0))}function tn(t){return t?t.__v_isVNode===!0:!1}function Ks(t,e){return t.type===e.type&&t.key===e.key}const Ll=({key:t})=>t??null,Kr=({ref:t,ref_key:e,ref_for:s})=>(typeof t=="number"&&(t=""+t),t!=null?Re(t)||Ce(t)||ie(t)?{i:lt,r:t,k:e,f:!!s}:t:null);function p(t,e=null,s=null,r=0,n=null,i=t===ye?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Ll(e),ref:e&&Kr(e),scopeId:ul,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:lt};return a?(Wi(l,s),i&128&&t.normalize(l)):s&&(l.shapeFlag|=Re(s)?8:16),pr>0&&!o&&nt&&(l.patchFlag>0||i&6)&&l.patchFlag!==32&&nt.push(l),l}const We=yh;function yh(t,e=null,s=null,r=0,n=null,i=!1){if((!t||t===Hu)&&(t=ns),tn(t)){const a=Bs(t,e,!0);return s&&Wi(a,s),pr>0&&!i&&nt&&(a.shapeFlag&6?nt[nt.indexOf(t)]=a:nt.push(a)),a.patchFlag=-2,a}if(Th(t)&&(t=t.__vccOpts),e){e=mh(e);let{class:a,style:l}=e;a&&!Re(a)&&(e.class=ge(a)),ve(l)&&(vn(l)&&!te(l)&&(l=Fe({},l)),e.style=Ii(l))}const o=Re(t)?1:jl(t)?128:Cu(t)?64:ve(t)?4:ie(t)?2:0;return p(t,e,s,r,n,o,i,!0)}function mh(t){return t?vn(t)||El(t)?Fe({},t):t:null}function Bs(t,e,s=!1,r=!1){const{props:n,ref:i,patchFlag:o,children:a,transition:l}=t,c=e?vh(n||{},e):n,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Ll(c),ref:e&&e.ref?s&&i?te(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!==ye?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&&Bs(t.ssContent),ssFallback:t.ssFallback&&Bs(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&r&&Fi(u,l.clone(u)),u}function st(t=" ",e=0){return We(kn,null,t,e)}function z(t="",e=!1){return e?(_(),gh(ns,null,t)):We(ns,null,t)}function Ct(t){return t==null||typeof t=="boolean"?We(ns):te(t)?We(ye,null,t.slice()):tn(t)?Ht(t):We(kn,null,String(t))}function Ht(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Bs(t)}function Wi(t,e){let s=0;const{shapeFlag:r}=t;if(e==null)e=null;else if(te(e))s=16;else if(typeof e=="object")if(r&65){const n=e.default;n&&(n._c&&(n._d=!1),Wi(t,n()),n._c&&(n._d=!0));return}else{s=32;const n=e._;!n&&!El(e)?e._ctx=lt:n===3&<&&(lt.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else ie(e)?(e={default:e,_ctx:lt},s=32):(e=String(e),r&64?(s=16,e=[st(e)]):s=8);t.children=e,t.shapeFlag|=s}function vh(...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=ge([e.class,r.class]));else if(n==="style")e.style=Ii([e.style,r.style]);else if(hn(n)){const i=e[n],o=r[n];o&&i!==o&&!(te(i)&&i.includes(o))?e[n]=i?[].concat(i,o):o:o==null&&i==null&&!dn(n)&&(e[n]=o)}else n!==""&&(e[n]=r[n])}return e}function kt(t,e,s,r=null){jt(t,e,7,[s,r])}const bh=_l();let _h=0;function wh(t,e,s){const r=t.type,n=(e?e.appContext:t.appContext)||bh,i={uid:_h++,vnode:t,type:r,parent:e,appContext:n,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Ba(!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:Al(r,n),emitsOptions:wl(r,n),emit:null,emitted:null,propsDefaults:we,inheritAttrs:r.inheritAttrs,ctx:we,data:we,props:we,attrs:we,slots:we,refs:we,setupState:we,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=Xu.bind(null,i),t.ce&&t.ce(i),i}let ze=null;const Ul=()=>ze||lt;let sn,ci;{const t=yn(),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)}};sn=e("__VUE_INSTANCE_SETTERS__",s=>ze=s),ci=e("__VUE_SSR_SETTERS__",s=>gr=s)}const Ar=t=>{const e=ze;return sn(t),t.scope.on(),()=>{t.scope.off(),sn(e)}},yo=()=>{ze&&ze.scope.off(),sn(null)};function Dl(t){return t.vnode.shapeFlag&4}let gr=!1;function xh(t,e=!1,s=!1){e&&ci(e);const{props:r,children:n}=t.vnode,i=Dl(t);rh(t,r,i,e),ah(t,n,s||e);const o=i?kh(t,e):void 0;return e&&ci(!1),o}function kh(t,e){const s=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,Fu);const{setup:r}=s;if(r){Kt();const n=t.setupContext=r.length>1?Eh(t):null,i=Ar(t),o=Tr(r,t,0,[t.props,n]),a=$a(o);if(Gt(),i(),(a||t.sp)&&!rr(t)&&pl(t),a){if(o.then(yo,yo),e)return o.then(l=>{mo(t,l)}).catch(l=>{bn(l,t,0)});t.asyncDep=o}else mo(t,o)}else Ml(t)}function mo(t,e,s){ie(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ve(e)&&(t.setupState=il(e)),Ml(t)}function Ml(t,e,s){const r=t.type;t.render||(t.render=r.render||Pt);{const n=Ar(t);Kt();try{qu(t)}finally{Gt(),n()}}}const Sh={get(t,e){return qe(t,"get",""),t[e]}};function Eh(t){const e=s=>{t.exposed=s||{}};return{attrs:new Proxy(t.attrs,Sh),slots:t.slots,emit:t.emit,expose:e}}function Sn(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(il(Bi(t.exposed)),{get(e,s){if(s in e)return e[s];if(s in nr)return nr[s](t)},has(e,s){return s in e||s in nr}})):t.proxy}function Th(t){return ie(t)&&"__vccOpts"in t}const Ne=(t,e)=>vu(t,e,gr);function Bl(t,e,s){try{en(-1);const r=arguments.length;return r===2?ve(e)&&!te(e)?tn(e)?We(t,null,[e]):We(t,e):We(t,null,e):(r>3?s=Array.prototype.slice.call(arguments,2):r===3&&tn(s)&&(s=[s]),We(t,e,s))}finally{en(1)}}const Ah="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 ui;const vo=typeof window<"u"&&window.trustedTypes;if(vo)try{ui=vo.createPolicy("vue",{createHTML:t=>t})}catch{}const Hl=ui?t=>ui.createHTML(t):t=>t,Rh="http://www.w3.org/2000/svg",Ch="http://www.w3.org/1998/Math/MathML",Dt=typeof document<"u"?document:null,bo=Dt&&Dt.createElement("template"),Oh={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"?Dt.createElementNS(Rh,t):e==="mathml"?Dt.createElementNS(Ch,t):s?Dt.createElement(t,{is:s}):Dt.createElement(t);return t==="select"&&r&&r.multiple!=null&&n.setAttribute("multiple",r.multiple),n},createText:t=>Dt.createTextNode(t),createComment:t=>Dt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Dt.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{bo.innerHTML=Hl(r==="svg"?`<svg>${t}</svg>`:r==="mathml"?`<math>${t}</math>`:t);const a=bo.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]}},$h=Symbol("_vtc");function Ph(t,e,s){const r=t[$h];r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?t.removeAttribute("class"):s?t.setAttribute("class",e):t.className=e}const _o=Symbol("_vod"),Ih=Symbol("_vsh"),jh=Symbol(""),Nh=/(?:^|;)\s*display\s*:/;function Lh(t,e,s){const r=t.style,n=Re(s);let i=!1;if(s&&!n){if(e)if(Re(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();s[a]==null&&Ys(r,a,"")}else for(const o in e)s[o]==null&&Ys(r,o,"");for(const o in s){o==="display"&&(i=!0);const a=s[o];a!=null?Dh(t,o,!Re(e)&&e?e[o]:void 0,a)||Ys(r,o,a):Ys(r,o,"")}}else if(n){if(e!==s){const o=r[jh];o&&(s+=";"+o),r.cssText=s,i=Nh.test(s)}}else e&&t.removeAttribute("style");_o in t&&(t[_o]=i?r.display:"",t[Ih]&&(r.display="none"))}const wo=/\s*!important$/;function Ys(t,e,s){if(te(s))s.forEach(r=>Ys(t,e,r));else if(s==null&&(s=""),e.startsWith("--"))t.setProperty(e,s);else{const r=Uh(t,e);wo.test(s)?t.setProperty(vs(r),s.replace(wo,""),"important"):t[r]=s}}const xo=["Webkit","Moz","ms"],Fn={};function Uh(t,e){const s=Fn[e];if(s)return s;let r=yt(e);if(r!=="filter"&&r in t)return Fn[e]=r;r=ja(r);for(let n=0;n<xo.length;n++){const i=xo[n]+r;if(i in t)return Fn[e]=i}return e}function Dh(t,e,s,r){return t.tagName==="TEXTAREA"&&(e==="width"||e==="height")&&Re(r)&&s===r}const ko="http://www.w3.org/1999/xlink";function So(t,e,s,r,n,i=qc(e)){r&&e.startsWith("xlink:")?s==null?t.removeAttributeNS(ko,e.slice(6,e.length)):t.setAttributeNS(ko,e,s):s==null||i&&!La(s)?t.removeAttribute(e):t.setAttribute(e,i?"":ht(s)?String(s):s)}function Eo(t,e,s,r,n){if(e==="innerHTML"||e==="textContent"){s!=null&&(t[e]=e==="innerHTML"?Hl(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=La(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 fs(t,e,s,r){t.addEventListener(e,s,r)}function Mh(t,e,s,r){t.removeEventListener(e,s,r)}const To=Symbol("_vei");function Bh(t,e,s,r,n=null){const i=t[To]||(t[To]={}),o=i[e];if(r&&o)o.value=r;else{const[a,l]=Hh(e);if(r){const c=i[e]=Vh(r,n);fs(t,a,c,l)}else o&&(Mh(t,a,o,l),i[e]=void 0)}}const Ao=/(?:Once|Passive|Capture)$/;function Hh(t){let e;if(Ao.test(t)){e={};let r;for(;r=t.match(Ao);)t=t.slice(0,t.length-r[0].length),e[r[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):vs(t.slice(2)),e]}let qn=0;const Fh=Promise.resolve(),qh=()=>qn||(Fh.then(()=>qn=0),qn=Date.now());function Vh(t,e){const s=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=s.attached)return;jt(Wh(r,s.value),e,5,[r])};return s.value=t,s.attached=qh(),s}function Wh(t,e){if(te(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 Ro=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Kh=(t,e,s,r,n,i)=>{const o=n==="svg";e==="class"?Ph(t,r,o):e==="style"?Lh(t,s,r):hn(e)?dn(e)||Bh(t,e,s,r,i):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Gh(t,e,r,o))?(Eo(t,e,r),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&So(t,e,r,o,i,e!=="value")):t._isVueCE&&(Jh(t,e)||t._def.__asyncLoader&&(/[A-Z]/.test(e)||!Re(r)))?Eo(t,yt(e),r,i,e):(e==="true-value"?t._trueValue=r:e==="false-value"&&(t._falseValue=r),So(t,e,r,o))};function Gh(t,e,s,r){if(r)return!!(e==="innerHTML"||e==="textContent"||e in t&&Ro(e)&&ie(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 Ro(e)&&Re(s)?!1:e in t}function Jh(t,e){const s=t._def.props;if(!s)return!1;const r=yt(e);return Array.isArray(s)?s.some(n=>yt(n)===r):Object.keys(s).some(n=>yt(n)===r)}const rn=t=>{const e=t.props["onUpdate:modelValue"]||!1;return te(e)?s=>Vr(e,s):e};function zh(t){t.target.composing=!0}function Co(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Ls=Symbol("_assign");function Oo(t,e,s){return e&&(t=t.trim()),s&&(t=Pi(t)),t}const It={created(t,{modifiers:{lazy:e,trim:s,number:r}},n){t[Ls]=rn(n);const i=r||n.props&&n.props.type==="number";fs(t,e?"change":"input",o=>{o.target.composing||t[Ls](Oo(t.value,s,i))}),(s||i)&&fs(t,"change",()=>{t.value=Oo(t.value,s,i)}),e||(fs(t,"compositionstart",zh),fs(t,"compositionend",Co),fs(t,"change",Co))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:s,modifiers:{lazy:r,trim:n,number:i}},o){if(t[Ls]=rn(o),t.composing)return;const a=(i||t.type==="number")&&!/^0\d/.test(t.value)?Pi(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)}},Fl={deep:!0,created(t,e,s){t[Ls]=rn(s),fs(t,"change",()=>{const r=t._modelValue,n=Yh(t),i=t.checked,o=t[Ls];if(te(r)){const a=Ua(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(fn(r)){const a=new Set(r);i?a.add(n):a.delete(n),o(a)}else o(ql(t,i))})},mounted:$o,beforeUpdate(t,e,s){t[Ls]=rn(s),$o(t,e,s)}};function $o(t,{value:e,oldValue:s},r){t._modelValue=e;let n;if(te(e))n=Ua(e,r.props.value)>-1;else if(fn(e))n=e.has(r.props.value);else{if(e===s)return;n=Er(e,ql(t,!0))}t.checked!==n&&(t.checked=n)}function Yh(t){return"_value"in t?t._value:t.value}function ql(t,e){const s=e?"_trueValue":"_falseValue";return s in t?t[s]:e}const Xh=["ctrl","shift","alt","meta"],Qh={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)=>Xh.some(s=>t[`${s}Key`]&&!e.includes(s))},is=(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=Qh[e[o]];if(a&&a(n,e))return}return t(n,...i)})},Zh=Fe({patchProp:Kh},Oh);let Po;function ed(){return Po||(Po=ch(Zh))}const td=(...t)=>{const e=ed().createApp(...t),{mount:s}=e;return e.mount=r=>{const n=rd(r);if(!n)return;const i=e._component;!ie(i)&&!i.render&&!i.template&&(i.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const o=s(n,!1,sd(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),o},e};function sd(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function rd(t){return Re(t)?document.querySelector(t):t}/*!
|
|
18
|
+
* pinia v2.3.1
|
|
19
|
+
* (c) 2025 Eduardo San Martin Morote
|
|
20
|
+
* @license MIT
|
|
21
|
+
*/let Vl;const En=t=>Vl=t,Wl=Symbol();function hi(t){return t&&typeof t=="object"&&Object.prototype.toString.call(t)==="[object Object]"&&typeof t.toJSON!="function"}var or;(function(t){t.direct="direct",t.patchObject="patch object",t.patchFunction="patch function"})(or||(or={}));function nd(){const t=Ha(!0),e=t.run(()=>B({}));let s=[],r=[];const n=Bi({install(i){En(n),n._a=i,i.provide(Wl,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 Kl=()=>{};function Io(t,e,s,r=Kl){t.push(e);const n=()=>{const i=t.indexOf(e);i>-1&&(t.splice(i,1),r())};return!s&&Fa()&&Wc(n),n}function _s(t,...e){t.slice().forEach(s=>{s(...e)})}const id=t=>t(),jo=Symbol(),Vn=Symbol();function di(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];hi(n)&&hi(r)&&t.hasOwnProperty(s)&&!Ce(r)&&!Wt(r)?t[s]=di(n,r):t[s]=r}return t}const od=Symbol();function ad(t){return!hi(t)||!t.hasOwnProperty(od)}const{assign:Qt}=Object;function ld(t){return!!(Ce(t)&&t.effect)}function cd(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=pu(s.state.value[t]);return Qt(u,i,Object.keys(o||{}).reduce((h,f)=>(h[f]=Bi(Ne(()=>{En(s);const d=s._s.get(t);return o[f].call(d,d)})),h),{}))}return l=Gl(t,c,e,s,r,!0),l}function Gl(t,e,s={},r,n,i){let o;const a=Qt({actions:{}},s),l={deep:!0};let c,u,h=[],f=[],d;const g=r.state.value[t];!i&&!g&&(r.state.value[t]={});let v;function S(N){let Y;c=u=!1,typeof N=="function"?(N(r.state.value[t]),Y={type:or.patchFunction,storeId:t,events:d}):(di(r.state.value[t],N),Y={type:or.patchObject,payload:N,storeId:t,events:d});const he=v=Symbol();Ms().then(()=>{v===he&&(c=!0)}),u=!0,_s(h,Y,r.state.value[t])}const C=i?function(){const{state:Y}=s,he=Y?Y():{};this.$patch(me=>{Qt(me,he)})}:Kl;function T(){o.stop(),h=[],f=[],r._s.delete(t)}const E=(N,Y="")=>{if(jo in N)return N[Vn]=Y,N;const he=function(){En(r);const me=Array.from(arguments),Pe=[],oe=[];function et(se){Pe.push(se)}function ot(se){oe.push(se)}_s(f,{args:me,name:he[Vn],store:D,after:et,onError:ot});let de;try{de=N.apply(this&&this.$id===t?this:D,me)}catch(se){throw _s(oe,se),se}return de instanceof Promise?de.then(se=>(_s(Pe,se),se)).catch(se=>(_s(oe,se),Promise.reject(se))):(_s(Pe,de),de)};return he[jo]=!0,he[Vn]=Y,he},U={_p:r,$id:t,$onAction:Io.bind(null,f),$patch:S,$reset:C,$subscribe(N,Y={}){const he=Io(h,N,Y.detached,()=>me()),me=o.run(()=>rs(()=>r.state.value[t],Pe=>{(Y.flush==="sync"?u:c)&&N({storeId:t,type:or.direct,events:d},Pe)},Qt({},l,Y)));return he},$dispose:T},D=Vt(U);r._s.set(t,D);const b=(r._a&&r._a.runWithContext||id)(()=>r._e.run(()=>(o=Ha()).run(()=>e({action:E}))));for(const N in b){const Y=b[N];if(Ce(Y)&&!ld(Y)||Wt(Y))i||(g&&ad(Y)&&(Ce(Y)?Y.value=g[N]:di(Y,g[N])),r.state.value[t][N]=Y);else if(typeof Y=="function"){const he=E(Y,N);b[N]=he,a.actions[N]=Y}}return Qt(D,b),Qt(ue(D),b),Object.defineProperty(D,"$state",{get:()=>r.state.value[t],set:N=>{S(Y=>{Qt(Y,N)})}}),r._p.forEach(N=>{Qt(D,o.run(()=>N({store:D,app:r._a,pinia:r,options:a})))}),g&&i&&s.hydrate&&s.hydrate(D.$state,g),c=!0,u=!0,D}/*! #__NO_SIDE_EFFECTS__ */function Jl(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=Su();return a=a||(c?ut(Wl,null):null),a&&En(a),a=Vl,a._s.has(r)||(i?Gl(r,e,n,a):cd(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 As=typeof document<"u";function zl(t){return typeof t=="object"||"displayName"in t||"props"in t||"__vccOpts"in t}function ud(t){return t.__esModule||t[Symbol.toStringTag]==="Module"||t.default&&zl(t.default)}const fe=Object.assign;function Wn(t,e){const s={};for(const r in e){const n=e[r];s[r]=bt(n)?n.map(t):t(n)}return s}const ar=()=>{},bt=Array.isArray;function No(t,e){const s={};for(const r in t)s[r]=r in e?e[r]:t[r];return s}const Yl=/#/g,hd=/&/g,dd=/\//g,fd=/=/g,pd=/\?/g,Xl=/\+/g,gd=/%5B/g,yd=/%5D/g,Ql=/%5E/g,md=/%60/g,Zl=/%7B/g,vd=/%7C/g,ec=/%7D/g,bd=/%20/g;function Ki(t){return t==null?"":encodeURI(""+t).replace(vd,"|").replace(gd,"[").replace(yd,"]")}function _d(t){return Ki(t).replace(Zl,"{").replace(ec,"}").replace(Ql,"^")}function fi(t){return Ki(t).replace(Xl,"%2B").replace(bd,"+").replace(Yl,"%23").replace(hd,"%26").replace(md,"`").replace(Zl,"{").replace(ec,"}").replace(Ql,"^")}function wd(t){return fi(t).replace(fd,"%3D")}function xd(t){return Ki(t).replace(Yl,"%23").replace(pd,"%3F")}function kd(t){return xd(t).replace(dd,"%2F")}function yr(t){if(t==null)return null;try{return decodeURIComponent(""+t)}catch{}return""+t}const Sd=/\/$/,Ed=t=>t.replace(Sd,"");function Kn(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=Cd(r??e,s),{fullPath:r+i+o,path:r,query:n,hash:yr(o)}}function Td(t,e){const s=e.query?t(e.query):"";return e.path+(s&&"?")+s+(e.hash||"")}function Lo(t,e){return!e||!t.toLowerCase().startsWith(e.toLowerCase())?t:t.slice(e.length)||"/"}function Ad(t,e,s){const r=e.matched.length-1,n=s.matched.length-1;return r>-1&&r===n&&Hs(e.matched[r],s.matched[n])&&tc(e.params,s.params)&&t(e.query)===t(s.query)&&e.hash===s.hash}function Hs(t,e){return(t.aliasOf||t)===(e.aliasOf||e)}function tc(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(var s in t)if(!Rd(t[s],e[s]))return!1;return!0}function Rd(t,e){return bt(t)?Uo(t,e):bt(e)?Uo(e,t):(t==null?void 0:t.valueOf())===(e==null?void 0:e.valueOf())}function Uo(t,e){return bt(e)?t.length===e.length&&t.every((s,r)=>s===e[r]):t.length===1&&t[0]===e}function Cd(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 Xt={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};let pi=function(t){return t.pop="pop",t.push="push",t}({}),Gn=function(t){return t.back="back",t.forward="forward",t.unknown="",t}({});function Od(t){if(!t)if(As){const e=document.querySelector("base");t=e&&e.getAttribute("href")||"/",t=t.replace(/^\w+:\/\/[^\/]+/,"")}else t="/";return t[0]!=="/"&&t[0]!=="#"&&(t="/"+t),Ed(t)}const $d=/^[^#]+#/;function Pd(t,e){return t.replace($d,"#")+e}function Id(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 Tn=()=>({left:window.scrollX,top:window.scrollY});function jd(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=Id(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 Do(t,e){return(history.state?history.state.position-e:-1)+t}const gi=new Map;function Nd(t,e){gi.set(t,e)}function Ld(t){const e=gi.get(t);return gi.delete(t),e}function Ud(t){return typeof t=="string"||t&&typeof t=="object"}function sc(t){return typeof t=="string"||typeof t=="symbol"}let Te=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 rc=Symbol("");Te.MATCHER_NOT_FOUND+"",Te.NAVIGATION_GUARD_REDIRECT+"",Te.NAVIGATION_ABORTED+"",Te.NAVIGATION_CANCELLED+"",Te.NAVIGATION_DUPLICATED+"";function Fs(t,e){return fe(new Error,{type:t,[rc]:!0},e)}function Lt(t,e){return t instanceof Error&&rc in t&&(e==null||!!(t.type&e))}const Dd=["params","query","hash"];function Md(t){if(typeof t=="string")return t;if(t.path!=null)return t.path;const e={};for(const s of Dd)s in t&&(e[s]=t[s]);return JSON.stringify(e,null,2)}function Bd(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(Xl," "),i=n.indexOf("="),o=yr(i<0?n:n.slice(0,i)),a=i<0?null:yr(n.slice(i+1));if(o in e){let l=e[o];bt(l)||(l=e[o]=[l]),l.push(a)}else e[o]=a}return e}function Mo(t){let e="";for(let s in t){const r=t[s];if(s=wd(s),r==null){r!==void 0&&(e+=(e.length?"&":"")+s);continue}(bt(r)?r.map(n=>n&&fi(n)):[r&&fi(r)]).forEach(n=>{n!==void 0&&(e+=(e.length?"&":"")+s,n!=null&&(e+="="+n))})}return e}function Hd(t){const e={};for(const s in t){const r=t[s];r!==void 0&&(e[s]=bt(r)?r.map(n=>n==null?null:""+n):r==null?r:""+r)}return e}const Fd=Symbol(""),Bo=Symbol(""),An=Symbol(""),Gi=Symbol(""),yi=Symbol("");function Gs(){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 es(t,e,s,r,n,i=o=>o()){const o=r&&(r.enterCallbacks[n]=r.enterCallbacks[n]||[]);return()=>new Promise((a,l)=>{const c=f=>{f===!1?l(Fs(Te.NAVIGATION_ABORTED,{from:s,to:e})):f instanceof Error?l(f):Ud(f)?l(Fs(Te.NAVIGATION_GUARD_REDIRECT,{from:e,to:f})):(o&&r.enterCallbacks[n]===o&&typeof f=="function"&&o.push(f),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(f=>l(f))})}function Jn(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(zl(l)){const c=(l.__vccOpts||l)[e];c&&i.push(es(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=ud(u)?u.default:u;o.mods[a]=u,o.components[a]=h;const f=(h.__vccOpts||h)[e];return f&&es(f,s,r,o,a,n)()}))}}return i}function qd(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=>Hs(c,a))?r.push(a):s.push(a));const l=t.matched[o];l&&(e.matched.find(c=>Hs(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 Vd=()=>location.protocol+"//"+location.host;function nc(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),Lo(a,"")}return Lo(s,t)+r+n}function Wd(t,e,s,r){let n=[],i=[],o=null;const a=({state:f})=>{const d=nc(t,location),g=s.value,v=e.value;let S=0;if(f){if(s.value=d,e.value=f,o&&o===g){o=null;return}S=v?f.position-v.position:0}else r(d);n.forEach(C=>{C(s.value,g,{delta:S,type:pi.pop,direction:S?S>0?Gn.forward:Gn.back:Gn.unknown})})};function l(){o=s.value}function c(f){n.push(f);const d=()=>{const g=n.indexOf(f);g>-1&&n.splice(g,1)};return i.push(d),d}function u(){if(document.visibilityState==="hidden"){const{history:f}=window;if(!f.state)return;f.replaceState(fe({},f.state,{scroll:Tn()}),"")}}function h(){for(const f of i)f();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 Ho(t,e,s,r=!1,n=!1){return{back:t,current:e,forward:s,replaced:r,position:window.history.length,scroll:n?Tn():null}}function Kd(t){const{history:e,location:s}=window,r={value:nc(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("#"),f=h>-1?(s.host&&document.querySelector("base")?t:t.slice(h))+l:Vd()+t+l;try{e[u?"replaceState":"pushState"](c,"",f),n.value=c}catch(d){console.error(d),s[u?"replace":"assign"](f)}}function o(l,c){i(l,fe({},e.state,Ho(n.value.back,l,n.value.forward,!0),c,{position:n.value.position}),!0),r.value=l}function a(l,c){const u=fe({},n.value,e.state,{forward:l,scroll:Tn()});i(u.current,u,!0),i(l,fe({},Ho(r.value,l,null),{position:u.position+1},c),!1),r.value=l}return{location:r,state:n,push:a,replace:o}}function Gd(t){t=Od(t);const e=Kd(t),s=Wd(t,e.state,e.location,e.replace);function r(i,o=!0){o||s.pauseListeners(),history.go(i)}const n=fe({location:"",base:t,go:r,createHref:Pd.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 ps=function(t){return t[t.Static=0]="Static",t[t.Param=1]="Param",t[t.Group=2]="Group",t}({});var Ie=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}(Ie||{});const Jd={type:ps.Static,value:""},zd=/[a-zA-Z0-9_]/;function Yd(t){if(!t)return[[]];if(t==="/")return[[Jd]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(d){throw new Error(`ERR (${s})/"${c}": ${d}`)}let s=Ie.Static,r=s;const n=[];let i;function o(){i&&n.push(i),i=[]}let a=0,l,c="",u="";function h(){c&&(s===Ie.Static?i.push({type:ps.Static,value:c}):s===Ie.Param||s===Ie.ParamRegExp||s===Ie.ParamRegExpEnd?(i.length>1&&(l==="*"||l==="+")&&e(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),i.push({type:ps.Param,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):e("Invalid state to consume buffer"),c="")}function f(){c+=l}for(;a<t.length;){if(l=t[a++],l==="\\"&&s!==Ie.ParamRegExp){r=s,s=Ie.EscapeNext;continue}switch(s){case Ie.Static:l==="/"?(c&&h(),o()):l===":"?(h(),s=Ie.Param):f();break;case Ie.EscapeNext:f(),s=r;break;case Ie.Param:l==="("?s=Ie.ParamRegExp:zd.test(l)?f():(h(),s=Ie.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--);break;case Ie.ParamRegExp:l===")"?u[u.length-1]=="\\"?u=u.slice(0,-1)+l:s=Ie.ParamRegExpEnd:u+=l;break;case Ie.ParamRegExpEnd:h(),s=Ie.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--,u="";break;default:e("Unknown state");break}}return s===Ie.ParamRegExp&&e(`Unfinished custom RegExp for param "${c}"`),h(),o(),n}const Fo="[^/]+?",Xd={sensitive:!1,strict:!1,start:!0,end:!0};var Ge=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}(Ge||{});const Qd=/[.+*?^${}()[\]/\\]/g;function Zd(t,e){const s=fe({},Xd,e),r=[];let n=s.start?"^":"";const i=[];for(const c of t){const u=c.length?[]:[Ge.Root];s.strict&&!c.length&&(n+="/");for(let h=0;h<c.length;h++){const f=c[h];let d=Ge.Segment+(s.sensitive?Ge.BonusCaseSensitive:0);if(f.type===ps.Static)h||(n+="/"),n+=f.value.replace(Qd,"\\$&"),d+=Ge.Static;else if(f.type===ps.Param){const{value:g,repeatable:v,optional:S,regexp:C}=f;i.push({name:g,repeatable:v,optional:S});const T=C||Fo;if(T!==Fo){d+=Ge.BonusCustomRegExp;try{`${T}`}catch(U){throw new Error(`Invalid custom RegExp for param "${g}" (${T}): `+U.message)}}let E=v?`((?:${T})(?:/(?:${T}))*)`:`(${T})`;h||(E=S&&c.length<2?`(?:/${E})`:"/"+E),S&&(E+="?"),n+=E,d+=Ge.Dynamic,S&&(d+=Ge.BonusOptional),v&&(d+=Ge.BonusRepeatable),T===".*"&&(d+=Ge.BonusWildcard)}u.push(d)}r.push(u)}if(s.strict&&s.end){const c=r.length-1;r[c][r[c].length-1]+=Ge.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 f=1;f<u.length;f++){const d=u[f]||"",g=i[f-1];h[g.name]=d&&g.repeatable?d.split("/"):d}return h}function l(c){let u="",h=!1;for(const f of t){(!h||!u.endsWith("/"))&&(u+="/"),h=!1;for(const d of f)if(d.type===ps.Static)u+=d.value;else if(d.type===ps.Param){const{value:g,repeatable:v,optional:S}=d,C=g in c?c[g]:"";if(bt(C)&&!v)throw new Error(`Provided param "${g}" is an array but it is not repeatable (* or + modifiers)`);const T=bt(C)?C.join("/"):C;if(!T)if(S)f.length<2&&(u.endsWith("/")?u=u.slice(0,-1):h=!0);else throw new Error(`Missing required param "${g}"`);u+=T}}return u||"/"}return{re:o,score:r,keys:i,parse:a,stringify:l}}function ef(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]===Ge.Static+Ge.Segment?-1:1:t.length>e.length?e.length===1&&e[0]===Ge.Static+Ge.Segment?1:-1:0}function ic(t,e){let s=0;const r=t.score,n=e.score;for(;s<r.length&&s<n.length;){const i=ef(r[s],n[s]);if(i)return i;s++}if(Math.abs(n.length-r.length)===1){if(qo(r))return 1;if(qo(n))return-1}return n.length-r.length}function qo(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const tf={strict:!1,end:!0,sensitive:!1};function sf(t,e,s){const r=Zd(Yd(t.path),s),n=fe(r,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function rf(t,e){const s=[],r=new Map;e=No(tf,e);function n(h){return r.get(h)}function i(h,f,d){const g=!d,v=Wo(h);v.aliasOf=d&&d.record;const S=No(e,h),C=[v];if("alias"in h){const U=typeof h.alias=="string"?[h.alias]:h.alias;for(const D of U)C.push(Wo(fe({},v,{components:d?d.record.components:v.components,path:D,aliasOf:d?d.record:v})))}let T,E;for(const U of C){const{path:D}=U;if(f&&D[0]!=="/"){const j=f.record.path,b=j[j.length-1]==="/"?"":"/";U.path=f.record.path+(D&&b+D)}if(T=sf(U,f,S),d?d.alias.push(T):(E=E||T,E!==T&&E.alias.push(T),g&&h.name&&!Ko(T)&&o(h.name)),oc(T)&&l(T),v.children){const j=v.children;for(let b=0;b<j.length;b++)i(j[b],T,d&&d.children[b])}d=d||T}return E?()=>{o(E)}:ar}function o(h){if(sc(h)){const f=r.get(h);f&&(r.delete(h),s.splice(s.indexOf(f),1),f.children.forEach(o),f.alias.forEach(o))}else{const f=s.indexOf(h);f>-1&&(s.splice(f,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 f=af(h,s);s.splice(f,0,h),h.record.name&&!Ko(h)&&r.set(h.record.name,h)}function c(h,f){let d,g={},v,S;if("name"in h&&h.name){if(d=r.get(h.name),!d)throw Fs(Te.MATCHER_NOT_FOUND,{location:h});S=d.record.name,g=fe(Vo(f.params,d.keys.filter(E=>!E.optional).concat(d.parent?d.parent.keys.filter(E=>E.optional):[]).map(E=>E.name)),h.params&&Vo(h.params,d.keys.map(E=>E.name))),v=d.stringify(g)}else if(h.path!=null)v=h.path,d=s.find(E=>E.re.test(v)),d&&(g=d.parse(v),S=d.record.name);else{if(d=f.name?r.get(f.name):s.find(E=>E.re.test(f.path)),!d)throw Fs(Te.MATCHER_NOT_FOUND,{location:h,currentLocation:f});S=d.record.name,g=fe({},f.params,h.params),v=d.stringify(g)}const C=[];let T=d;for(;T;)C.unshift(T.record),T=T.parent;return{name:S,path:v,params:g,matched:C,meta:of(C)}}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 Vo(t,e){const s={};for(const r of e)r in t&&(s[r]=t[r]);return s}function Wo(t){const e={path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:t.aliasOf,beforeEnter:t.beforeEnter,props:nf(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 nf(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 Ko(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function of(t){return t.reduce((e,s)=>fe(e,s.meta),{})}function af(t,e){let s=0,r=e.length;for(;s!==r;){const i=s+r>>1;ic(t,e[i])<0?r=i:s=i+1}const n=lf(t);return n&&(r=e.lastIndexOf(n,r-1)),r}function lf(t){let e=t;for(;e=e.parent;)if(oc(e)&&ic(t,e)===0)return e}function oc({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function Go(t){const e=ut(An),s=ut(Gi),r=Ne(()=>{const l=Ee(t.to);return e.resolve(l)}),n=Ne(()=>{const{matched:l}=r.value,{length:c}=l,u=l[c-1],h=s.matched;if(!u||!h.length)return-1;const f=h.findIndex(Hs.bind(null,u));if(f>-1)return f;const d=Jo(l[c-2]);return c>1&&Jo(u)===d&&h[h.length-1].path!==d?h.findIndex(Hs.bind(null,l[c-2])):f}),i=Ne(()=>n.value>-1&&df(s.params,r.value.params)),o=Ne(()=>n.value>-1&&n.value===s.matched.length-1&&tc(s.params,r.value.params));function a(l={}){if(hf(l)){const c=e[Ee(t.replace)?"replace":"push"](Ee(t.to)).catch(ar);return t.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:r,href:Ne(()=>r.value.href),isActive:i,isExactActive:o,navigate:a}}function cf(t){return t.length===1?t[0]:t}const uf=dt({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:Go,setup(t,{slots:e}){const s=Vt(Go(t)),{options:r}=ut(An),n=Ne(()=>({[zo(t.activeClass,r.linkActiveClass,"router-link-active")]:s.isActive,[zo(t.exactActiveClass,r.linkExactActiveClass,"router-link-exact-active")]:s.isExactActive}));return()=>{const i=e.default&&cf(e.default(s));return t.custom?i:Bl("a",{"aria-current":s.isExactActive?t.ariaCurrentValue:null,href:s.href,onClick:s.navigate,class:n.value},i)}}}),ac=uf;function hf(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 df(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(!bt(n)||n.length!==r.length||r.some((i,o)=>i.valueOf()!==n[o].valueOf()))return!1}return!0}function Jo(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const zo=(t,e,s)=>t??e??s,ff=dt({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:s}){const r=ut(yi),n=Ne(()=>t.route||r.value),i=ut(Bo,0),o=Ne(()=>{let c=Ee(i);const{matched:u}=n.value;let h;for(;(h=u[c])&&!h.components;)c++;return c}),a=Ne(()=>n.value.matched[o.value]);Wr(Bo,Ne(()=>o.value+1)),Wr(Fd,a),Wr(yi,n);const l=B();return rs(()=>[l.value,a.value,t.name],([c,u,h],[f,d,g])=>{u&&(u.instances[h]=c,d&&d!==u&&c&&c===f&&(u.leaveGuards.size||(u.leaveGuards=d.leaveGuards),u.updateGuards.size||(u.updateGuards=d.updateGuards))),c&&u&&(!d||!Hs(u,d)||!f)&&(u.enterCallbacks[h]||[]).forEach(v=>v(c))},{flush:"post"}),()=>{const c=n.value,u=t.name,h=a.value,f=h&&h.components[u];if(!f)return Yo(s.default,{Component:f,route:c});const d=h.props[u],g=d?d===!0?c.params:typeof d=="function"?d(c):d:null,S=Bl(f,fe({},g,e,{onVnodeUnmounted:C=>{C.component.isUnmounted&&(h.instances[u]=null)},ref:l}));return Yo(s.default,{Component:S,route:c})||S}}});function Yo(t,e){if(!t)return null;const s=t(e);return s.length===1?s[0]:s}const lc=ff;function pf(t){const e=rf(t.routes,t),s=t.parseQuery||Bd,r=t.stringifyQuery||Mo,n=t.history,i=Gs(),o=Gs(),a=Gs(),l=hu(Xt);let c=Xt;As&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Wn.bind(null,P=>""+P),h=Wn.bind(null,kd),f=Wn.bind(null,yr);function d(P,G){let W,X;return sc(P)?(W=e.getRecordMatcher(P),X=G):X=P,e.addRoute(X,W)}function g(P){const G=e.getRecordMatcher(P);G&&e.removeRoute(G)}function v(){return e.getRoutes().map(P=>P.record)}function S(P){return!!e.getRecordMatcher(P)}function C(P,G){if(G=fe({},G||l.value),typeof P=="string"){const x=Kn(s,P,G.path),$=e.resolve({path:x.path},G),L=n.createHref(x.fullPath);return fe(x,$,{params:f($.params),hash:yr(x.hash),redirectedFrom:void 0,href:L})}let W;if(P.path!=null)W=fe({},P,{path:Kn(s,P.path,G.path).path});else{const x=fe({},P.params);for(const $ in x)x[$]==null&&delete x[$];W=fe({},P,{params:h(x)}),G.params=h(G.params)}const X=e.resolve(W,G),le=P.hash||"";X.params=u(f(X.params));const y=Td(r,fe({},P,{hash:_d(le),path:X.path})),m=n.createHref(y);return fe({fullPath:y,hash:le,query:r===Mo?Hd(P.query):P.query||{}},X,{redirectedFrom:void 0,href:m})}function T(P){return typeof P=="string"?Kn(s,P,l.value.path):fe({},P)}function E(P,G){if(c!==P)return Fs(Te.NAVIGATION_CANCELLED,{from:G,to:P})}function U(P){return b(P)}function D(P){return U(fe(T(P),{replace:!0}))}function j(P,G){const W=P.matched[P.matched.length-1];if(W&&W.redirect){const{redirect:X}=W;let le=typeof X=="function"?X(P,G):X;return typeof le=="string"&&(le=le.includes("?")||le.includes("#")?le=T(le):{path:le},le.params={}),fe({query:P.query,hash:P.hash,params:le.path!=null?{}:P.params},le)}}function b(P,G){const W=c=C(P),X=l.value,le=P.state,y=P.force,m=P.replace===!0,x=j(W,X);if(x)return b(fe(T(x),{state:typeof x=="object"?fe({},le,x.state):le,force:y,replace:m}),G||W);const $=W;$.redirectedFrom=G;let L;return!y&&Ad(r,X,W)&&(L=Fs(Te.NAVIGATION_DUPLICATED,{to:$,from:X}),k(X,X,!0,!1)),(L?Promise.resolve(L):he($,X)).catch(I=>Lt(I)?Lt(I,Te.NAVIGATION_GUARD_REDIRECT)?I:Ye(I):ae(I,$,X)).then(I=>{if(I){if(Lt(I,Te.NAVIGATION_GUARD_REDIRECT))return b(fe({replace:m},T(I.to),{state:typeof I.to=="object"?fe({},le,I.to.state):le,force:y}),G||$)}else I=Pe($,X,!0,m,le);return me($,X,I),I})}function N(P,G){const W=E(P,G);return W?Promise.reject(W):Promise.resolve()}function Y(P){const G=ne.values().next().value;return G&&typeof G.runWithContext=="function"?G.runWithContext(P):P()}function he(P,G){let W;const[X,le,y]=qd(P,G);W=Jn(X.reverse(),"beforeRouteLeave",P,G);for(const x of X)x.leaveGuards.forEach($=>{W.push(es($,P,G))});const m=N.bind(null,P,G);return W.push(m),Xe(W).then(()=>{W=[];for(const x of i.list())W.push(es(x,P,G));return W.push(m),Xe(W)}).then(()=>{W=Jn(le,"beforeRouteUpdate",P,G);for(const x of le)x.updateGuards.forEach($=>{W.push(es($,P,G))});return W.push(m),Xe(W)}).then(()=>{W=[];for(const x of y)if(x.beforeEnter)if(bt(x.beforeEnter))for(const $ of x.beforeEnter)W.push(es($,P,G));else W.push(es(x.beforeEnter,P,G));return W.push(m),Xe(W)}).then(()=>(P.matched.forEach(x=>x.enterCallbacks={}),W=Jn(y,"beforeRouteEnter",P,G,Y),W.push(m),Xe(W))).then(()=>{W=[];for(const x of o.list())W.push(es(x,P,G));return W.push(m),Xe(W)}).catch(x=>Lt(x,Te.NAVIGATION_CANCELLED)?x:Promise.reject(x))}function me(P,G,W){a.list().forEach(X=>Y(()=>X(P,G,W)))}function Pe(P,G,W,X,le){const y=E(P,G);if(y)return y;const m=G===Xt,x=As?history.state:{};W&&(X||m?n.replace(P.fullPath,fe({scroll:m&&x&&x.scroll},le)):n.push(P.fullPath,le)),l.value=P,k(P,G,W,m),Ye()}let oe;function et(){oe||(oe=n.listen((P,G,W)=>{if(!De.listening)return;const X=C(P),le=j(X,De.currentRoute.value);if(le){b(fe(le,{replace:!0,force:!0}),X).catch(ar);return}c=X;const y=l.value;As&&Nd(Do(y.fullPath,W.delta),Tn()),he(X,y).catch(m=>Lt(m,Te.NAVIGATION_ABORTED|Te.NAVIGATION_CANCELLED)?m:Lt(m,Te.NAVIGATION_GUARD_REDIRECT)?(b(fe(T(m.to),{force:!0}),X).then(x=>{Lt(x,Te.NAVIGATION_ABORTED|Te.NAVIGATION_DUPLICATED)&&!W.delta&&W.type===pi.pop&&n.go(-1,!1)}).catch(ar),Promise.reject()):(W.delta&&n.go(-W.delta,!1),ae(m,X,y))).then(m=>{m=m||Pe(X,y,!1),m&&(W.delta&&!Lt(m,Te.NAVIGATION_CANCELLED)?n.go(-W.delta,!1):W.type===pi.pop&&Lt(m,Te.NAVIGATION_ABORTED|Te.NAVIGATION_DUPLICATED)&&n.go(-1,!1)),me(X,y,m)}).catch(ar)}))}let ot=Gs(),de=Gs(),se;function ae(P,G,W){Ye(P);const X=de.list();return X.length?X.forEach(le=>le(P,G,W)):console.error(P),Promise.reject(P)}function Ue(){return se&&l.value!==Xt?Promise.resolve():new Promise((P,G)=>{ot.add([P,G])})}function Ye(P){return se||(se=!P,et(),ot.list().forEach(([G,W])=>P?W(P):G()),ot.reset()),P}function k(P,G,W,X){const{scrollBehavior:le}=t;if(!As||!le)return Promise.resolve();const y=!W&&Ld(Do(P.fullPath,0))||(X||!W)&&history.state&&history.state.scroll||null;return Ms().then(()=>le(P,G,y)).then(m=>m&&jd(m)).catch(m=>ae(m,P,G))}const A=P=>n.go(P);let R;const ne=new Set,De={currentRoute:l,listening:!0,addRoute:d,removeRoute:g,clearRoutes:e.clearRoutes,hasRoute:S,getRoutes:v,resolve:C,options:t,push:U,replace:D,go:A,back:()=>A(-1),forward:()=>A(1),beforeEach:i.add,beforeResolve:o.add,afterEach:a.add,onError:de.add,isReady:Ue,install(P){P.component("RouterLink",ac),P.component("RouterView",lc),P.config.globalProperties.$router=De,Object.defineProperty(P.config.globalProperties,"$route",{enumerable:!0,get:()=>Ee(l)}),As&&!R&&l.value===Xt&&(R=!0,U(n.location).catch(X=>{}));const G={};for(const X in Xt)Object.defineProperty(G,X,{get:()=>l.value[X],enumerable:!0});P.provide(An,De),P.provide(Gi,rl(G)),P.provide(yi,l);const W=P.unmount;ne.add(P),P.unmount=function(){ne.delete(P),ne.size<1&&(c=Xt,oe&&oe(),oe=null,l.value=Xt,R=!1,se=!1),W()}}};function Xe(P){return P.reduce((G,W)=>G.then(()=>Y(W)),Promise.resolve())}return De}function cc(){return ut(An)}function gf(t){return ut(Gi)}function Rn(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 yf(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 mf=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Ji 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 vf extends Ji{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Xo extends Ji{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class Qo extends Ji{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var mi;(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"})(mi||(mi={}));class bf{constructor(e,{headers:s={},customFetch:r,region:n=mi.Any}={}){this.url=e,this.headers=s,this.region=n,this.fetch=mf(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return yf(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 f={},{region:d}=r;d||(d=this.region);const g=new URL(`${this.url}/${s}`);d&&d!=="any"&&(f["x-region"]=d,g.searchParams.set("forceFunctionRegion",d));let v;c&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(f["Content-Type"]="application/octet-stream",v=c):typeof c=="string"?(f["Content-Type"]="text/plain",v=c):typeof FormData<"u"&&c instanceof FormData?v=c:(f["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 S=u;h&&(o=new AbortController,i=setTimeout(()=>o.abort(),h),u?(S=o.signal,u.addEventListener("abort",()=>o.abort())):S=o.signal);const C=yield this.fetch(g.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},f),this.headers),a),body:v,signal:S}).catch(D=>{throw new vf(D)}),T=C.headers.get("x-relay-error");if(T&&T==="true")throw new Xo(C);if(!C.ok)throw new Qo(C);let E=((n=C.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),U;return E==="application/json"?U=yield C.json():E==="application/octet-stream"||E==="application/pdf"?U=yield C.blob():E==="text/event-stream"?U=C:E==="multipart/form-data"?U=yield C.formData():U=yield C.text(),{data:U,error:null,response:C}}catch(a){return{data:null,error:a,response:a instanceof Qo||a instanceof Xo?a.context:void 0}}finally{i&&clearTimeout(i)}})}}const uc=3,Zo=t=>Math.min(1e3*2**t,3e4),_f=[520,503],hc=["GET","HEAD","OPTIONS"];var wf=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 ea(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 xf(t,e,s,r){return!(!r||s>=uc||!hc.includes(t)||!_f.includes(e))}var kf=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,f)=>typeof f=="bigint"?f.toString():f),signal:s.signal})}catch(h){if((h==null?void 0:h.name)==="AbortError"||(h==null?void 0:h.code)==="ABORT_ERR"||!hc.includes(s.method))throw h;if(s.retryEnabled&&o<uc){const f=Zo(o);o++,await ea(f,s.signal);continue}throw h}if(xf(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,f=h!==null?Math.max(0,parseInt(h,10)||0)*1e3:Zo(o);await u.text(),o++,await ea(f,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 f,d,g,v;const T=(f=h==null?void 0:h.message)!==null&&f!==void 0?f:"",E=(d=h==null?void 0:h.code)!==null&&d!==void 0?d:"";l=`${(g=o==null?void 0:o.name)!==null&&g!==void 0?g:"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"}: ${T}`,E&&(l+=` (${E})`),h!=null&&h.stack&&(l+=`
|
|
32
|
+
${h.stack}`)}else{var S;l=(S=o==null?void 0:o.stack)!==null&&S!==void 0?S:""}const C=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)",C>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${C} 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)",C>this.urlLengthLimit&&(c+=`. Your request URL is ${C} 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 f=await t.text();f===""||(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=f:r=JSON.parse(f))}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 wf(s)}return{success:s===null,error:s,data:r,count:n,status:i,statusText:o}}returns(){return this}overrideTypes(){return this}},Sf=class extends kf{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 ta=new RegExp("[,()]");var Rs=class extends Sf{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"&&ta.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"&&ta.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}},Ef=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 Rs({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 Rs({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 Rs({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 Rs({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 Rs({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 mr(t){"@babel/helpers - typeof";return mr=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},mr(t)}function Tf(t,e){if(mr(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(mr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Af(t){var e=Tf(t,"string");return mr(e)=="symbol"?e:e+""}function Rf(t,e,s){return(e=Af(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function sa(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?sa(Object(s),!0).forEach(function(r){Rf(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):sa(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var Cf=class dc{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,f=setTimeout(()=>h.abort(),i),d=u==null?void 0:u.signal;if(d){if(d.aborted)return clearTimeout(f),l(c,u);const g=()=>{clearTimeout(f),h.abort()};return d.addEventListener("abort",g,{once:!0}),l(c,jr(jr({},u),{},{signal:h.signal})).finally(()=>{clearTimeout(f),d.removeEventListener("abort",g)})}return l(c,jr(jr({},u),{},{signal:h.signal})).finally(()=>clearTimeout(f))}: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 Ef(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 dc(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=d=>d!==null&&typeof d=="object"&&(!Array.isArray(d)||d.some(u)),h=r&&Object.values(s).some(u);h?(a="POST",c=s):r||n?(a=r?"HEAD":"GET",Object.entries(s).filter(([d,g])=>g!==void 0).map(([d,g])=>[d,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([d,g])=>{l.searchParams.append(d,g)})):(a="POST",c=s);const f=new Headers(this.headers);return h?f.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&f.set("Prefer",`count=${i}`),new Rs({method:a,url:l,headers:f,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class Of{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 $f="2.105.4",Pf=`realtime-js/${$f}`,If="1.0.0",fc="2.0.0",jf=fc,Nf=1e4,Lf=100,ts={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},pc={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},vi={connecting:"connecting",closing:"closing",closed:"closed"};class Uf{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 f=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+a.length+o.length+c.length+h.length,d=new ArrayBuffer(this.HEADER_LENGTH+f);let g=new DataView(d),v=0;g.setUint8(v++,this.KINDS.userBroadcastPush),g.setUint8(v++,l.length),g.setUint8(v++,a.length),g.setUint8(v++,o.length),g.setUint8(v++,c.length),g.setUint8(v++,h.length),g.setUint8(v++,s),Array.from(l,C=>g.setUint8(v++,C.charCodeAt(0))),Array.from(a,C=>g.setUint8(v++,C.charCodeAt(0))),Array.from(o,C=>g.setUint8(v++,C.charCodeAt(0))),Array.from(c,C=>g.setUint8(v++,C.charCodeAt(0))),Array.from(h,C=>g.setUint8(v++,C.charCodeAt(0)));var S=new Uint8Array(d.byteLength+r.byteLength);return S.set(new Uint8Array(d),0),S.set(new Uint8Array(r),d.byteLength),S.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 f=e.slice(l,e.byteLength),d=a===this.JSON_ENCODING?JSON.parse(r.decode(f)):f,g={type:this.BROADCAST_EVENT,event:u,payload:d};return o>0&&(g.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:g}}_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 ke;(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"})(ke||(ke={}));const ra=(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]=Df(o,t,e,n),i),{}):{}},Df=(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)?gc(i,o):bi(o)},gc=(t,e)=>{if(t.charAt(0)==="_"){const s=t.slice(1,t.length);return Ff(e,s)}switch(t){case ke.bool:return Mf(e);case ke.float4:case ke.float8:case ke.int2:case ke.int4:case ke.int8:case ke.numeric:case ke.oid:return Bf(e);case ke.json:case ke.jsonb:return Hf(e);case ke.timestamp:return qf(e);case ke.abstime:case ke.date:case ke.daterange:case ke.int4range:case ke.int8range:case ke.money:case ke.reltime:case ke.text:case ke.time:case ke.timestamptz:case ke.timetz:case ke.tsrange:case ke.tstzrange:return bi(e);default:return bi(e)}},bi=t=>t,Mf=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Bf=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},Hf=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},Ff=(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=>gc(e,a))}return t},qf=t=>typeof t=="string"?t.replace(" ","T"):t,yc=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 lr=t=>typeof t=="function"?t:function(){return t},Vf=typeof self<"u"?self:null,Cs=typeof window<"u"?window:null,Tt=Vf||Cs||globalThis,Wf="2.0.0",Kf=1e4,Gf=1e3,Ot={connecting:0,open:1,closing:2,closed:3},Qe={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},Mt={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},_i={longpoll:"longpoll",websocket:"websocket"},Jf={complete:4},wi="base64url.bearer.phx.",Nr=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})}},mc=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))}},zf=class{constructor(t,e,s){this.state=Qe.closed,this.topic=t,this.params=lr(e||{}),this.socket=s,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Nr(this,Mt.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new mc(()=>{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=Qe.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(r=>r.send()),this.pushBuffer=[]}),this.joinPush.receive("error",r=>{this.state=Qe.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=Qe.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=Qe.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 Nr(this,Mt.leave,lr({}),this.timeout).send(),this.state=Qe.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(Mt.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=Qe.closed,this.bindings=[]}onClose(t){this.on(Mt.close,t)}onError(t){return this.on(Mt.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 Nr(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=Qe.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(Mt.close,"leave")},s=new Nr(this,Mt.leave,lr({}),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=Qe.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===Qe.closed}isErrored(){return this.state===Qe.errored}isJoined(){return this.state===Qe.joined}isJoining(){return this.state===Qe.joining}isLeaving(){return this.state===Qe.leaving}},nn=class{static request(t,e,s,r,n,i,o){if(Tt.XDomainRequest){let a=new Tt.XDomainRequest;return this.xdomainRequest(a,t,e,r,n,i,o)}else if(Tt.XMLHttpRequest){let a=new Tt.XMLHttpRequest;return this.xhrRequest(a,t,e,s,r,n,i,o)}else{if(Tt.fetch&&Tt.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),Tt.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===Jf.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)}`}},Yf=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)},ws=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(wi)&&(this.authToken=atob(e[1].slice(wi.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=Ot.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+_i.websocket),"$1/"+_i.longpoll)}endpointURL(){return nn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,s){this.close(t,e,s),this.readyState=Ot.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Ot.open||this.readyState===Ot.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=Ot.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=Yf(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=Ot.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=nn.request(t,this.endpointURL(),e,s,this.timeout,o,a=>{this.reqs.delete(i),this.isActive()&&n(a)}),this.reqs.add(i)}},Xf=class Xs{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=Xs.syncState(this.state,n,i,o),this.pendingDiffs.forEach(l=>{this.state=Xs.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=Xs.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 Xs.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),f=u.metas.map(v=>v.phx_ref),d=c.metas.filter(v=>f.indexOf(v.phx_ref)<0),g=u.metas.filter(v=>h.indexOf(v.phx_ref)<0);d.length>0&&(o[l]=c,o[l].metas=d),g.length>0&&(a[l]=this.clone(u),a[l].metas=g)}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(f=>f.phx_ref),h=c.metas.filter(f=>u.indexOf(f.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))}},Lr={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 f=t.slice(a,t.byteLength),d={status:h,response:f};return{join_ref:l,ref:c,topic:u,event:Mt.reply,payload:d}},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}}},Qf=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||Kf,this.transport=e.transport||Tt.WebSocket||ws,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null;let s=null;try{s=Tt&&Tt.sessionStorage}catch{}this.sessionStore=e.sessionStorage||s,this.establishedConnections=0,this.defaultEncoder=Lr.encode.bind(Lr),this.defaultDecoder=Lr.decode.bind(Lr),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!==ws?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let r=null;Cs&&Cs.addEventListener&&(Cs.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),r=this.connectClock)}),Cs.addEventListener("pageshow",n=>{r===this.connectClock&&(r=null,this.connect())}),Cs.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=lr(e.params||{}),this.endPoint=`${t}/${_i.websocket}`,this.vsn=e.vsn||Wf,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new mc(()=>{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 ws}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=nn.appendParams(nn.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=lr(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==ws?this.connectWithFallback(ws,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 ws:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${wi}${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(),Gf,"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===Ot.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(Mt.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case Ot.connecting:return"connecting";case Ot.open:return"open";case Ot.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 zf(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 cr{constructor(e,s){const r=ep(s);this.presence=new Xf(e.getChannel(),r),this.presence.onJoin((n,i,o)=>{const a=cr.onJoinPayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onLeave((n,i,o)=>{const a=cr.onLeavePayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return cr.transformState(this.presence.state)}static transformState(e){return e=Zf(e),Object.getOwnPropertyNames(e).reduce((s,r)=>{const n=e[r];return s[r]=Gr(n),s},{})}static onJoinPayload(e,s,r){const n=na(s),i=Gr(r);return{event:"join",key:e,currentPresences:n,newPresences:i}}static onLeavePayload(e,s,r){const n=na(s),i=Gr(r);return{event:"leave",key:e,currentPresences:n,leftPresences:i}}}function Gr(t){return t.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function Zf(t){return JSON.parse(JSON.stringify(t))}function ep(t){return(t==null?void 0:t.events)&&{events:t.events}}function na(t){return t!=null&&t.metas?Gr(t):[]}var ia;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(ia||(ia={}));class tp{get state(){return this.presenceAdapter.state}constructor(e,s){this.channel=e,this.presenceAdapter=new cr(this.channel.channelAdapter,s)}}function sp(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 rp{constructor(e,s,r){const n=np(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>Lf){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===ts.joined}isJoined(){return this.state===ts.joined}isJoining(){return this.state===ts.joining}isClosed(){return this.state===ts.closed}isLeaving(){return this.state===ts.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function np(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}var oa;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(oa||(oa={}));var Ps;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Ps||(Ps={}));var Bt;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Bt||(Bt={}));class ur{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 rp(this.socket.socketAdapter,e,this.params),this.presence=new tp(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=yc(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(d=>d.filter))!==null&&n!==void 0?n:[],u=!!this.bindings[Ps.PRESENCE]&&this.bindings[Ps.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},f={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(d=>{e==null||e(Bt.CHANNEL_ERROR,sp(d))}),this._onClose(()=>e==null?void 0:e(Bt.CLOSED)),this.updateJoinPayload(Object.assign({config:f},h)),this._updateFilterMessage(),this.channelAdapter.subscribe(s).receive("ok",async({postgres_changes:d})=>{if(this.socket._isManualToken()||this.socket.setAuth(),d===void 0){e==null||e(Bt.SUBSCRIBED);return}this._updatePostgresBindings(d,e)}).receive("error",d=>{this.state=ts.errored;const g=Object.values(d).join(", ")||"error";e==null||e(Bt.CHANNEL_ERROR,new Error(g,{cause:d}))}).receive("timeout",()=>{e==null||e(Bt.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:f}}=l,d=e&&e[a];if(d&&d.event===c&&ur.isFilterValueEqual(d.schema,u)&&ur.isFilterValueEqual(d.table,h)&&ur.isFilterValueEqual(d.filter,f))o.push(Object.assign(Object.assign({},l),{id:d.id}));else{this.unsubscribe(),this.state=ts.errored,s==null||s(Bt.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=o,this.state!=ts.errored&&s&&s(Bt.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===Ps.PRESENCE||e===Ps.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 f=(n=this.bindings[h])===null||n===void 0?void 0:n.find(d=>d.ref===e.ref);if(!f)return!0;if(["broadcast","presence","postgres_changes"].includes(h))if("id"in f){const d=f.id,g=(i=f.filter)===null||i===void 0?void 0:i.event;return d&&((o=s.ids)===null||o===void 0?void 0:o.includes(d))&&(g==="*"||(g==null?void 0:g.toLocaleLowerCase())===((a=s.data)===null||a===void 0?void 0:a.type.toLocaleLowerCase()))}else{const d=(c=(l=f==null?void 0:f.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return d==="*"||d===((u=s==null?void 0:s.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===h})}_notThisChannelEvent(e,s){const{close:r,error:n,leave:i,join:o}=pc;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=ra(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(s.old=ra(e.columns,e.old_record)),s}}class ip{constructor(e,s){this.socket=new Qf(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()==vi.connecting}isDisconnecting(){return this.socket.connectionState()==vi.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const aa={HEARTBEAT_INTERVAL:25e3},op=[1e3,2e3,5e3,1e4],ap=1e4;function lp(){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 cp(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return lp()}const up=`
|
|
38
|
+
addEventListener("message", (e) => {
|
|
39
|
+
if (e.data.event === "start") {
|
|
40
|
+
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
|
41
|
+
}
|
|
42
|
+
});`;class hp{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 Uf,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 ip(e,n),this.httpEndpoint=yc(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()||vi.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 ur(`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:Pf};s&&n.updateJoinPayload(i),n.joinedOnce&&n.channelAdapter.isJoined()&&n.channelAdapter.push(pc.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([up],{type:"application/javascript"});s=URL.createObjectURL(r)}return s}_initializeOptions(e){var s,r,n,i,o,a,l,c,u,h,f,d;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 g={};g.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:Nf,g.heartbeatIntervalMs=(i=e==null?void 0:e.heartbeatIntervalMs)!==null&&i!==void 0?i:aa.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:aa.HEARTBEAT_INTERVAL),g.transport=(l=e==null?void 0:e.transport)!==null&&l!==void 0?l:Of.getWebSocketConstructor(),g.params=e==null?void 0:e.params,g.logger=e==null?void 0:e.logger,g.heartbeatCallback=this._wrapHeartbeatCallback(e==null?void 0:e.heartbeatCallback),g.sessionStorage=(c=e==null?void 0:e.sessionStorage)!==null&&c!==void 0?c:cp(),g.reconnectAfterMs=(u=e==null?void 0:e.reconnectAfterMs)!==null&&u!==void 0?u:T=>op[T-1]||ap;let v,S;const C=(h=e==null?void 0:e.vsn)!==null&&h!==void 0?h:jf;switch(C){case If:v=(T,E)=>E(JSON.stringify(T)),S=(T,E)=>E(JSON.parse(T));break;case fc:v=this.serializer.encode.bind(this.serializer),S=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${g.vsn}`)}if(g.vsn=C,g.encode=(f=e==null?void 0:e.encode)!==null&&f!==void 0?f:v,g.decode=(d=e==null?void 0:e.decode)!==null&&d!==void 0?d:S,g.beforeReconnect=this._reconnectAuth.bind(this),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,g.params=Object.assign(Object.assign({},g.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,g.autoSendHeartbeat=!this.worker}return g}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var vr=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 dp(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 fp(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 pp(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:s,path:r,query:n,body:i,headers:o}){const a=dp(t.baseUrl,r,n),l=await fp(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"),f=h&&u?JSON.parse(u):u;if(!c.ok){const d=h?f:void 0,g=d==null?void 0:d.error;throw new vr((g==null?void 0:g.message)??`Request failed with status ${c.status}`,{status:c.status,icebergType:g==null?void 0:g.type,icebergCode:g==null?void 0:g.code,details:d})}return{status:c.status,headers:c.headers,data:f}}}}function Ur(t){return t.join("")}var gp=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Ur(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/${Ur(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ur(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ur(t.namespace)}`}),!0}catch(e){if(e instanceof vr&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(s){if(s instanceof vr&&s.status===409)return;throw s}}};function xs(t){return t.join("")}var yp=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/${xs(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/${xs(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/${xs(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/${xs(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/${xs(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/${xs(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(s){if(s instanceof vr&&s.status===404)return!1;throw s}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(s){if(s instanceof vr&&s.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw s}}},mp=class{constructor(t){var r;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const s=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=pp({baseUrl:s,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(r=t.accessDelegation)==null?void 0:r.join(","),this.namespaceOps=new gp(this.client,e),this.tableOps=new yp(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 br(t){"@babel/helpers - typeof";return br=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},br(t)}function vp(t,e){if(br(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(br(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function bp(t){var e=vp(t,"string");return br(e)=="symbol"?e:e+""}function _p(t,e,s){return(e=bp(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function la(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 ee(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?la(Object(s),!0).forEach(function(r){_p(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):la(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var Cn=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 xi=class extends Cn{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 ee({},super.toJSON())}},vc=class extends Cn{constructor(t,e,s="storage"){super(t,s),this.name=s==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};function on(t,e,s){const r=ee({},t),n=e.toLowerCase();for(const i of Object.keys(r))i.toLowerCase()===n&&delete r[i];return r[n]=s,r}function wp(t){const e={};for(const[s,r]of Object.entries(t))e[s.toLowerCase()]=r;return e}const xp=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),kp=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)},ki=t=>{if(Array.isArray(t))return t.map(s=>ki(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]=ki(r)}),e},Sp=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),ca=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)},Ep=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 xi(ca(o),i,a,r))}).catch(()=>{const o=i+"";e(new xi(n.statusText||`HTTP ${i} error`,i,o,r))})}else e(new vc(ca(t),t,r))},Tp=(t,e,s,r)=>{const n={method:t,headers:(e==null?void 0:e.headers)||{}};if(t==="GET"||t==="HEAD"||!r)return ee(ee({},n),s);if(kp(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=on(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),ee(ee({},n),s)};async function Js(t,e,s,r,n,i,o){return new Promise((a,l)=>{t(s,Tp(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=>Ep(c,l,r,o))})}function bc(t="storage"){return{get:async(e,s,r,n)=>Js(e,"GET",s,r,n,void 0,t),post:async(e,s,r,n,i)=>Js(e,"POST",s,n,i,r,t),put:async(e,s,r,n,i)=>Js(e,"PUT",s,n,i,r,t),head:async(e,s,r,n)=>Js(e,"HEAD",s,ee(ee({},r),{},{noResolveJson:!0}),n,void 0,t),remove:async(e,s,r,n,i)=>Js(e,"DELETE",s,n,i,r,t)}}const Ap=bc("storage"),{get:_r,post:pt,put:Si,head:Rp,remove:zi}=Ap,rt=bc("vectors");var qs=class{constructor(t,e={},s,r="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=wp(e),this.fetch=xp(s),this.namespace=r}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=on(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}}},Cp=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 _c;_c=Symbol.toStringTag;var Op=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[_c]="BlobDownloadBuilder",this.promise=null}asStream(){return new Cp(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 $p={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},ua={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var Pp=class extends qs{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=ee(ee({},ua),r);let a=ee(ee({},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[f,d]of Object.entries(r.headers))a=on(a,f,d);const c=n._removeEmptyFolders(e),u=n._getFinalPath(c),h=await(t=="PUT"?Si:pt)(n.fetch,`${n.url}/object/${u}`,i,ee({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=ee(ee({},ua),r);let u=ee(ee({},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[f,d]of Object.entries(r.headers))u=on(u,f,d);return{path:i,fullPath:(await Si(n.fetch,a.toString(),l,ee({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=ee({},s.headers);e!=null&&e.upsert&&(n["x-upsert"]="true");const i=await pt(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 Cn("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 pt(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 pt(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 pt(r.fetch,`${r.url}/object/sign/${n}`,ee({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 pt(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=>ee(ee({},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=()=>_r(this.fetch,`${this.url}/${r}/${o}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},s);return new Op(a,this.shouldThrowOnError)}async info(t){var e=this;const s=e._getFinalPath(t);return e.handleOperation(async()=>ki(await _r(e.fetch,`${e.url}/object/info/${s}`,{headers:e.headers})))}async exists(t){var e=this;const s=e._getFinalPath(t);try{return await Rp(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 xi?n.status:n instanceof vc?(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 zi(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=ee(ee(ee({},$p),e),{},{prefix:t||""});return await pt(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=ee({},t);return await pt(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 Ip="2.105.4",Rr={"X-Client-Info":`storage-js/${Ip}`};var jp=class extends qs{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=ee(ee({},Rr),e);super(i,o,s,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const s=e.listBucketOptionsToQueryString(t);return await _r(e.fetch,`${e.url}/bucket${s}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await _r(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var s=this;return s.handleOperation(async()=>await pt(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 Si(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 pt(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await zi(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():""}},Np=class extends qs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=ee(ee({},Rr),e);super(r,n,s,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await pt(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 _r(e.fetch,n,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await zi(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!Sp(t))throw new Cn("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 mp({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}}}}})}},Lp=class extends qs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=ee(ee({},Rr),{},{"Content-Type":"application/json"},e);super(r,n,s,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await rt.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var s=this;return s.handleOperation(async()=>await rt.post(s.fetch,`${s.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await rt.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var s=this;return s.handleOperation(async()=>await rt.post(s.fetch,`${s.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:s.headers})||{})}},Up=class extends qs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=ee(ee({},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 rt.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await rt.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 rt.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await rt.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 rt.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},Dp=class extends qs{constructor(t,e={},s){const r=t.replace(/\/$/,""),n=ee(ee({},Rr),{},{"Content-Type":"application/json"},e);super(r,n,s,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await rt.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await rt.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await rt.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await rt.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},Mp=class extends Dp{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new Bp(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)}},Bp=class extends Lp{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,ee(ee({},t),{},{vectorBucketName:s.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,s=this;return e().call(s,ee(ee({},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 Hp(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},Hp=class extends Up{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,ee(ee({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async getVectors(t){var e=()=>super.getVectors,s=this;return e().call(s,ee(ee({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,s=this;return e().call(s,ee(ee({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,s=this;return e().call(s,ee(ee({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,s=this;return e().call(s,ee(ee({},t),{},{vectorBucketName:s.vectorBucketName,indexName:s.indexName}))}},Fp=class extends jp{constructor(t,e={},s,r){super(t,e,s,r)}from(t){return new Pp(this.url,this.headers,t,this.fetch)}get vectors(){return new Mp(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Np(this.url+"/iceberg",this.headers,this.fetch)}};const wc="2.105.4",Os=30*1e3,Ei=3,zn=Ei*Os,qp="http://localhost:9999",Vp="supabase.auth.token",Wp={"X-Client-Info":`gotrue-js/${wc}`},Ti="X-Supabase-Api-Version",xc={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Kp=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Gp=10*60*1e3;class wr 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 q(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Jp extends wr{constructor(e,s,r){super(e,s,r),this.name="AuthApiError",this.status=s,this.code=r}}function zp(t){return q(t)&&t.name==="AuthApiError"}class gt extends wr{constructor(e,s){super(e),this.name="AuthUnknownError",this.originalError=s}}class Yt extends wr{constructor(e,s,r,n){super(e,r,n),this.name=s,this.status=r}}class Le extends Yt{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Dr(t){return q(t)&&t.name==="AuthSessionMissingError"}class ks extends Yt{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Mr extends Yt{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Br extends Yt{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 Yp(t){return q(t)&&t.name==="AuthImplicitGrantRedirectError"}class ha extends Yt{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 Xp extends Yt{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 Ai extends Yt{constructor(e,s){super(e,"AuthRetryableFetchError",s,void 0)}}function Yn(t){return q(t)&&t.name==="AuthRetryableFetchError"}class da extends Yt{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 Ri extends Yt{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const an="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),fa=`
|
|
56
|
+
\r=`.split(""),Qp=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<fa.length;e+=1)t[fa[e].charCodeAt(0)]=-2;for(let e=0;e<an.length;e+=1)t[an[e].charCodeAt(0)]=e;return t})();function pa(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(an[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(an[r]),e.queuedBits-=6}}function kc(t,e,s){const r=Qp[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 ga(t){const e=[],s=o=>{e.push(String.fromCodePoint(o))},r={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=o=>{tg(o,r,s)};for(let o=0;o<t.length;o+=1)kc(t.charCodeAt(o),n,i);return e.join("")}function Zp(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 eg(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}Zp(r,e)}}function tg(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 Us(t){const e=[],s={queue:0,queuedBits:0},r=n=>{e.push(n)};for(let n=0;n<t.length;n+=1)kc(t.charCodeAt(n),s,r);return new Uint8Array(e)}function sg(t){const e=[];return eg(t,s=>e.push(s)),new Uint8Array(e)}function gs(t){const e=[],s={queue:0,queuedBits:0},r=n=>{e.push(n)};return t.forEach(n=>pa(n,s,r)),pa(null,s,r),e.join("")}function rg(t){return Math.round(Date.now()/1e3)+t}function ng(){return Symbol("auth-callback")}const He=()=>typeof window<"u"&&typeof document<"u",cs={tested:!1,writable:!1},Sc=()=>{if(!He())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(cs.tested)return cs.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),cs.tested=!0,cs.writable=!0}catch{cs.tested=!0,cs.writable=!1}return cs.writable};function ig(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 Ec=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),og=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",$s=async(t,e,s)=>{await t.setItem(e,JSON.stringify(s))},us=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 $n{constructor(){this.promise=new $n.promiseConstructor((e,s)=>{this.resolve=e,this.reject=s})}}$n.promiseConstructor=Promise;function Hr(t){const e=t.split(".");if(e.length!==3)throw new Ri("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!Kp.test(e[r]))throw new Ri("JWT not in base64url format");return{header:JSON.parse(ga(e[0])),payload:JSON.parse(ga(e[1])),signature:Us(e[2]),raw:{header:e[0],payload:e[1]}}}async function ag(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function lg(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 cg(t){return("0"+t.toString(16)).substr(-2)}function ug(){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,cg).join("")}async function hg(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 dg(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 hg(t);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Ss(t,e,s=!1){const r=ug();let n=r;s&&(n+="/recovery"),await $s(t,`${e}-code-verifier`,n);const i=await dg(r);return[i,r===i?"plain":"s256"]}const fg=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function pg(t){const e=t.headers.get(Ti);if(!e||!e.match(fg))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function gg(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 yg(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 mg=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Ut(t){if(!mg.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function ft(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 Xn(){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 vg(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 ya(t){return JSON.parse(JSON.stringify(t))}const ds=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)},bg=[502,503,504,520,521,522,523,524,530];async function ma(t){var e;if(!og(t))throw new Ai(ds(t),0);if(bg.includes(t.status))throw new Ai(ds(t),t.status);let s;try{s=await t.json()}catch(i){throw new gt(ds(i),i)}let r;const n=pg(t);if(n&&n.getTime()>=xc["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 da(ds(s),t.status,((e=s.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new Le}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 da(ds(s),t.status,s.weak_password.reasons);throw new Jp(ds(s),t.status||500,r)}const _g=(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 J(t,e,s,r){var n;const i=Object.assign({},r==null?void 0:r.headers);i[Ti]||(i[Ti]=xc["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 wg(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 wg(t,e,s,r,n,i){const o=_g(e,r,n,i);let a;try{a=await t(s,Object.assign({},o))}catch(l){throw console.error(l),new Ai(ds(l),0)}if(a.ok||await ma(a),r!=null&&r.noResolveJson)return a;try{return await a.json()}catch(l){await ma(l)}}function at(t){var e;let s=null;Sg(t)&&(s=Object.assign({},t),t.expires_at||(s.expires_at=rg(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:s,user:r},error:null}}function va(t){const e=at(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 ss(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function xg(t){return{data:t,error:null}}function kg(t){const{action_link:e,email_otp:s,hashed_token:r,redirect_to:n,verification_type:i}=t,o=Rn(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 ba(t){return t}function Sg(t){return!!t.access_token&&!!t.refresh_token&&!!t.expires_in}const Qn=["global","local","others"];class Eg{constructor({url:e="",headers:s={},fetch:r,experimental:n}){this.url=e,this.headers=s,this.fetch=Ec(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=Qn[0]){if(Qn.indexOf(s)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Qn.join(", ")}`);try{return await J(this.fetch,"POST",`${this.url}/logout?scope=${s}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(q(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,s={}){try{return await J(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:s.data},headers:this.headers,redirectTo:s.redirectTo,xform:ss})}catch(r){if(q(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:s}=e,r=Rn(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 J(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:kg,redirectTo:s==null?void 0:s.redirectTo})}catch(s){if(q(s))return{data:{properties:null,user:null},error:s};throw s}}async createUser(e){try{return await J(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:ss})}catch(s){if(q(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 J(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:ba});if(u.error)throw u.error;const h=await u.json(),f=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,d=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return d.length>0&&(d.forEach(g=>{const v=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),S=JSON.parse(g.split(";")[1].split("=")[1]);c[`${S}Page`]=v}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(q(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){Ut(e);try{return await J(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:ss})}catch(s){if(q(s))return{data:{user:null},error:s};throw s}}async updateUserById(e,s){Ut(e);try{return await J(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:s,headers:this.headers,xform:ss})}catch(r){if(q(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,s=!1){Ut(e);try{return await J(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:s},xform:ss})}catch(r){if(q(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){Ut(e.userId);try{const{data:s,error:r}=await J(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(q(s))return{data:null,error:s};throw s}}async _deleteFactor(e){Ut(e.userId),Ut(e.id);try{return{data:await J(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(s){if(q(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 J(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:ba});if(u.error)throw u.error;const h=await u.json(),f=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,d=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return d.length>0&&(d.forEach(g=>{const v=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),S=JSON.parse(g.split(";")[1].split("=")[1]);c[`${S}Page`]=v}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(q(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await J(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(q(s))return{data:null,error:s};throw s}}async _getOAuthClient(e){try{return await J(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(q(s))return{data:null,error:s};throw s}}async _updateOAuthClient(e,s){try{return await J(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(q(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(e){try{return await J(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(q(s))return{data:null,error:s};throw s}}async _regenerateOAuthClientSecret(e){try{return await J(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(q(s))return{data:null,error:s};throw s}}async _listCustomProviders(e){try{const s={};return e!=null&&e.type&&(s.type=e.type),await J(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(q(s))return{data:{providers:[]},error:s};throw s}}async _createCustomProvider(e){try{return await J(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(q(s))return{data:null,error:s};throw s}}async _getCustomProvider(e){try{return await J(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(q(s))return{data:null,error:s};throw s}}async _updateCustomProvider(e,s){try{return await J(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(q(r))return{data:null,error:r};throw r}}async _deleteCustomProvider(e){try{return await J(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(q(s))return{data:null,error:s};throw s}}async _adminListPasskeys(e){ft(this.experimental),Ut(e.userId);try{return await J(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(q(s))return{data:null,error:s};throw s}}async _adminDeletePasskey(e){ft(this.experimental),Ut(e.userId),Ut(e.passkeyId);try{return await J(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(q(s))return{data:null,error:s};throw s}}}function _a(t={}){return{getItem:e=>t[e]||null,setItem:(e,s)=>{t[e]=s},removeItem:e=>{delete t[e]}}}const St={debug:!!(globalThis&&Sc()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Tc extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class wa extends Tc{}async function Tg(t,e,s){St.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;let n;e>0&&(n=setTimeout(()=>{r.abort(),St.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),St.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await s()}finally{St.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw St.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new wa(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(St.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 St.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){St.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",t,o.name);try{return await s()}finally{St.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 St.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",t),new wa(`Lock "${t}" was released because another request stole it`)}throw i}}function Ag(){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 Ac(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Rg(t){return parseInt(t,16)}function Cg(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function Og(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:f}=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(f!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${f}`);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 d=Ac(t.address),g=u?`${u}://${r}`:r,v=t.statement?`${t.statement}
|
|
58
|
+
`:"",S=`${g} wants you to sign in with your Ethereum account:
|
|
59
|
+
${d}
|
|
60
|
+
|
|
61
|
+
${v}`;let C=`URI: ${h}
|
|
62
|
+
Version: ${f}
|
|
63
|
+
Chain ID: ${s}${o?`
|
|
64
|
+
Nonce: ${o}`:""}
|
|
65
|
+
Issued At: ${i.toISOString()}`;if(n&&(C+=`
|
|
66
|
+
Expiration Time: ${n.toISOString()}`),a&&(C+=`
|
|
67
|
+
Not Before: ${a.toISOString()}`),l&&(C+=`
|
|
68
|
+
Request ID: ${l}`),c){let T=`
|
|
69
|
+
Resources:`;for(const E of c){if(!E||typeof E!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${E}`);T+=`
|
|
70
|
+
- ${E}`}C+=T}return`${S}
|
|
71
|
+
${C}`}class $e 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 ln extends $e{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function $g({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 $e({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 $e({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 $e({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 $e({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 $e({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new $e({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 $e({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new $e({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(Rc(o)){if(i.rp.id!==o)return new $e({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new $e({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 $e({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 $e({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 $e({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Pg({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 $e({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new $e({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(Rc(r)){if(s.rpId!==r)return new $e({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new $e({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new $e({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 $e({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Ig{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 Ci=new Ig;function xa(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=Rn(t,["challenge","user","excludeCredentials"]),i=Us(e).buffer,o=Object.assign(Object.assign({},s),{id:Us(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:Us(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return a}function ka(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=Rn(t,["challenge","allowCredentials"]),n=Us(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:Us(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:gs(new Uint8Array(t.response.attestationObject)),clientDataJSON:gs(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Ea(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:gs(new Uint8Array(n.authenticatorData)),clientDataJSON:gs(new Uint8Array(n.clientDataJSON)),signature:gs(new Uint8Array(n.signature)),userHandle:n.userHandle?gs(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Rc(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function cn(){var t,e;return!!(He()&&"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 Cc(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new ln("Browser returned unexpected credential type",e)}:{data:null,error:new ln("Empty credential response",e)}}catch(e){return{data:null,error:$g({error:e,options:t})}}}async function Oc(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new ln("Browser returned unexpected credential type",e)}:{data:null,error:new ln("Empty credential response",e)}}catch(e){return{data:null,error:Pg({error:e,options:t})}}}const jg={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},Ng={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function un(...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]=un(a,o):r[i]=un(o)}else r[i]=o}return r}function Lg(t,e){return un(jg,t,e||{})}function Ug(t,e){return un(Ng,t,e||{})}class Dg{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??Ci.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 d=(await this.client.getUser()).data.user,g=((o=d==null?void 0:d.user_metadata)===null||o===void 0?void 0:o.name)||(d==null?void 0:d.email)||(d==null?void 0:d.id)||"User";u.name=`${u.id}:${g}`}}u.displayName||(u.displayName=u.name)}switch(a.webauthn.type){case"create":{const u=Lg(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:h,error:f}=await Cc({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:f}}case"request":{const u=Ug(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:h,error:f}=await Oc(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:f}}}}catch(a){return q(a)?{data:null,error:a}:{data:null,error:new gt("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 wr("rpId is required for WebAuthn authentication")};try{if(!cn())return{data:null,error:new gt("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 q(o)?{data:null,error:o}:{data:null,error:new gt("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 wr("rpId is required for WebAuthn registration")};try{if(!cn())return{data:null,error:new gt("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(f=>f.factor_type==="webauthn"&&f.friendly_name===e&&f.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 q(o)?{data:null,error:o}:{data:null,error:new gt("Unexpected error in register",o)}}}}Ag();const Mg={url:qp,storageKey:Vp,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Wp,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function Ta(t,e,s){return await s()}const Es={};class xr{get jwks(){var e,s;return(s=(e=Es[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(e){Es[this.storageKey]=Object.assign(Object.assign({},Es[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,s;return(s=(e=Es[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Es[this.storageKey]=Object.assign(Object.assign({},Es[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({},Mg),e);if(this.storageKey=o.storageKey,this.instanceID=(s=xr.nextInstanceID[this.storageKey])!==null&&s!==void 0?s:0,xr.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!o.debug,typeof o.debug=="function"&&(this.logger=o.debug),this.instanceID>0&&He()){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 Eg({url:o.url,headers:o.headers,fetch:o.fetch,experimental:this.experimental}),this.url=o.url,this.headers=o.headers,this.fetch=Ec(o.fetch),this.lock=o.lock||Ta,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&&He()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=Tg:this.lock=Ta,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 Dg(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:Sc()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=_a(this.memoryStorage)),o.userStorage&&(this.userStorage=o.userStorage)):(this.memoryStorage={},this.storage=_a(this.memoryStorage)),He()&&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} (${wc}) ${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(He()&&(s=ig(window.location.href),this._isImplicitGrantCallback(s)?r="implicit":await this._isPKCECallback(s)&&(r="pkce")),He()&&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),Yp(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 q(s)?this._returnResult({error:s}):this._returnResult({error:new gt("Unexpected error during initialization",s)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var s,r,n;try{const i=await J(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:at}),{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(q(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:f}=e;let d=null,g=null;this.flowType==="pkce"&&([d,g]=await Ss(this.storage,this.storageKey)),i=await J(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:u,password:h,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:d,code_challenge_method:g},xform:at})}else if("phone"in e){const{phone:u,password:h,options:f}=e;i=await J(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:h,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},channel:(n=f==null?void 0:f.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:at})}else throw new Mr("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`),q(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 J(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:va})}else if("phone"in e){const{phone:i,password:o,options:a}=e;s=await J(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:va})}else throw new Mr("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 ks;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(q(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,f;let d,g;if("message"in e)d=e.message,g=e.signature;else{const{chain:v,wallet:S,statement:C,options:T}=e;let E;if(He())if(typeof S=="object")E=S;else{const Y=window;if("ethereum"in Y&&typeof Y.ethereum=="object"&&"request"in Y.ethereum&&typeof Y.ethereum.request=="function")E=Y.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 S!="object"||!(T!=null&&T.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");E=S}const U=new URL((s=T==null?void 0:T.url)!==null&&s!==void 0?s:window.location.href),D=await E.request({method:"eth_requestAccounts"}).then(Y=>Y).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!D||D.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const j=Ac(D[0]);let b=(r=T==null?void 0:T.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!b){const Y=await E.request({method:"eth_chainId"});b=Rg(Y)}const N={domain:U.host,address:j,statement:C,uri:U.href,version:"1",chainId:b,nonce:(n=T==null?void 0:T.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(o=(i=T==null?void 0:T.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=T==null?void 0:T.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=T==null?void 0:T.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=T==null?void 0:T.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=T==null?void 0:T.signInWithEthereum)===null||u===void 0?void 0:u.resources};d=Og(N),g=await E.request({method:"personal_sign",params:[Cg(d),j]})}try{const{data:v,error:S}=await J(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:d,signature:g},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:at});if(S)throw S;if(!v||!v.session||!v.user){const C=new ks;return this._returnResult({data:{user:null,session:null},error:C})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:S})}catch(v){if(q(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,f,d;let g,v;if("message"in e)g=e.message,v=e.signature;else{const{chain:S,wallet:C,statement:T,options:E}=e;let U;if(He())if(typeof C=="object")U=C;else{const j=window;if("solana"in j&&typeof j.solana=="object"&&("signIn"in j.solana&&typeof j.solana.signIn=="function"||"signMessage"in j.solana&&typeof j.solana.signMessage=="function"))U=j.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 C!="object"||!(E!=null&&E.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");U=C}const D=new URL((s=E==null?void 0:E.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in U&&U.signIn){const j=await U.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},E==null?void 0:E.signInWithSolana),{version:"1",domain:D.host,uri:D.href}),T?{statement:T}:null));let b;if(Array.isArray(j)&&j[0]&&typeof j[0]=="object")b=j[0];else if(j&&typeof j=="object"&&"signedMessage"in j&&"signature"in j)b=j;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in b&&"signature"in b&&(typeof b.signedMessage=="string"||b.signedMessage instanceof Uint8Array)&&b.signature instanceof Uint8Array)g=typeof b.signedMessage=="string"?b.signedMessage:new TextDecoder().decode(b.signedMessage),v=b.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in U)||typeof U.signMessage!="function"||!("publicKey"in U)||typeof U!="object"||!U.publicKey||!("toBase58"in U.publicKey)||typeof U.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");g=[`${D.host} wants you to sign in with your Solana account:`,U.publicKey.toBase58(),...T?["",T,""]:[""],"Version: 1",`URI: ${D.href}`,`Issued At: ${(n=(r=E==null?void 0:E.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((i=E==null?void 0:E.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${E.signInWithSolana.notBefore}`]:[],...!((o=E==null?void 0:E.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${E.signInWithSolana.expirationTime}`]:[],...!((a=E==null?void 0:E.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${E.signInWithSolana.chainId}`]:[],...!((l=E==null?void 0:E.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${E.signInWithSolana.nonce}`]:[],...!((c=E==null?void 0:E.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${E.signInWithSolana.requestId}`]:[],...!((h=(u=E==null?void 0:E.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||h===void 0)&&h.length?["Resources",...E.signInWithSolana.resources.map(b=>`- ${b}`)]:[]].join(`
|
|
72
|
+
`);const j=await U.signMessage(new TextEncoder().encode(g),"utf8");if(!j||!(j instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");v=j}}try{const{data:S,error:C}=await J(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:g,signature:gs(v)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(d=e.options)===null||d===void 0?void 0:d.captchaToken}}:null),xform:at});if(C)throw C;if(!S||!S.session||!S.user){const T=new ks;return this._returnResult({data:{user:null,session:null},error:T})}return S.session&&(await this._saveSession(S.session),await this._notifyAllSubscribers("SIGNED_IN",S.session)),this._returnResult({data:Object.assign({},S),error:C})}catch(S){if(q(S))return this._returnResult({data:{user:null,session:null},error:S});throw S}}async _exchangeCodeForSession(e){const s=await us(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(s??"").split("/");try{if(!r&&this.flowType==="pkce")throw new Xp;const{data:i,error:o}=await J(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:at});if(await Be(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new ks;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`),q(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 J(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:at}),{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 ks;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(q(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 Ss(this.storage,this.storageKey));const{error:h}=await J(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 J(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 Mr("You must provide either an email or phone number.")}catch(a){if(await Be(this.storage,`${this.storageKey}-code-verifier`),q(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 J(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:at});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(q(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 Ss(this.storage,this.storageKey));const c=await J(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:xg});return!((i=c.data)===null||i===void 0)&&i.url&&He()&&!(!((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`),q(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 Le;const{error:n}=await J(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(q(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 J(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 J(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 Mr("You must provide either an email or phone number and a type")}catch(s){if(q(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 us(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()<zn:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const o=await us(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=Xn()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=vg(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 J(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ss}):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 Le}:await J(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:ss})})}catch(s){if(q(s))return Dr(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 Le;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await Ss(this.storage,this.storageKey));const{data:c,error:u}=await J(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:ss});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`),q(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 Le;const s=Date.now()/1e3;let r=s,n=!0,i=null;const{payload:o}=Hr(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(q(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 Le;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(q(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){var r;try{if(!He())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 ha("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 ha("No code detected.");const{data:E,error:U}=await this._exchangeCodeForSession(e.code);if(U)throw U;const D=new URL(window.location.href);return D.searchParams.delete("code"),window.history.replaceState(window.history.state,"",D.toString()),{data:{session:E.session,redirectType:(r=E.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),f=parseInt(l);let d=h+f;c&&(d=parseInt(c));const g=d-h;g*1e3<=Os&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${g}s, should have been closer to ${f}s`);const v=d-f;h-v>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",v,d,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,d,h);const{data:S,error:C}=await this._getUser(o);if(C)throw C;const T={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:f,expires_at:d,refresh_token:a,token_type:u,user:S.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:T,redirectType:e.type},error:null})}catch(n){if(q(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 us(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&&!Dr(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&&!(zp(a)&&(a.status===404||a.status===401||a.status===403)||Dr(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=ng(),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),Dr(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,s={}){let r=null,n=null;this.flowType==="pkce"&&([r,n]=await Ss(this.storage,this.storageKey,!0));try{return await J(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`),q(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(q(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:f}=i;if(f)throw f;const d=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 J(this.fetch,"GET",d,{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 He()&&!(!((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(q(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 J(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:at}),{data:f,error:d}=h;return d?this._returnResult({data:{user:null,session:null},error:d}):!f||!f.session||!f.user?this._returnResult({data:{user:null,session:null},error:new ks}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:d}))}catch(n){if(await Be(this.storage,`${this.storageKey}-code-verifier`),q(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 J(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(q(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 lg(async n=>(n>0&&await ag(200*Math.pow(2,n-1)),this._debug(s,"refreshing attempt",n),await J(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:at})),(n,i)=>{const o=200*Math.pow(2,n);return i&&Yn(i)&&Date.now()+o-r<Os})}catch(r){if(this._debug(s,"error",r),q(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),He()&&!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 us(this.storage,this.storageKey);if(n&&this.userStorage){let o=await us(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await $s(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:Xn()}else if(n&&!n.user&&!n.user){const o=await us(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(n.user=o.user,await Be(this.storage,this.storageKey+"-user"),await $s(this.storage,this.storageKey,n)):n.user=Xn()}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()<zn;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${zn}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),Yn(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 Le;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new $n;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new Le;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),q(i)){const o={data:null,error:i};return Yn(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 $s(this.userStorage,this.storageKey+"-user",{user:s.user});const n=Object.assign({},s);delete n.user;const i=ya(n);await $s(this.storage,this.storageKey,i)}else{const n=ya(s);await $s(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&&He()&&(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(),Os);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)/Os);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${Os}ms, refresh threshold is ${Ei} ticks`),n<=Ei&&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 Tc)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!He()||!(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 Ss(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 J(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(q(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 J(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(q(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):Ea(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await J(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(q(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 J(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:xa(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:ka(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(q(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:d}=Hr(e);let g=null;d.aal&&(g=d.aal);let v=g;const{data:{user:S},error:C}=await this.getUser(e);if(C)return this._returnResult({data:null,error:C});((r=(s=S==null?void 0:S.factors)===null||s===void 0?void 0:s.filter(U=>U.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(v="aal2");const E=d.amr||[];return{data:{currentLevel:g,nextLevel:v,currentAuthenticationMethods:E},error:null}}catch(d){if(q(d))return this._returnResult({data:null,error:d});throw d}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}=Hr(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(d=>d.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(u="aal2");const f=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:f},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 J(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 Le})})}catch(s){if(q(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 Le});const o=await J(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&&He()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(q(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 Le});const o=await J(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&&He()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(q(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 J(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 Le})})}catch(e){if(q(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 J(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 Le})})}catch(s){if(q(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+Gp>n)return r;const{data:i,error:o}=await J(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:d,error:g}=await this.getSession();if(g||!d.session)return this._returnResult({data:null,error:g});r=d.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=Hr(r);s!=null&&s.allowExpired||gg(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:d}=await this.getUser(r);if(d)throw d;return{data:{claims:i,header:n,signature:o},error:null}}const u=yg(n.alg),h=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,o,sg(`${a}.${l}`)))throw new Ri("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(r){if(q(r))return this._returnResult({data:null,error:r});throw r}}async signInWithPasskey(e){var s,r,n;ft(this.experimental);try{if(!cn())return this._returnResult({data:null,error:new gt("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=ka(i.options),l=(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&n!==void 0?n:Ci.createNewAbortSignal(),{data:c,error:u}=await Oc({publicKey:a,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new gt("WebAuthn ceremony failed",null)});const h=Ea(c);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:h})}catch(i){if(q(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(e){var s,r;ft(this.experimental);try{if(!cn())return this._returnResult({data:null,error:new gt("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=xa(n.options),a=(r=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.signal)!==null&&r!==void 0?r:Ci.createNewAbortSignal(),{data:l,error:c}=await Cc({publicKey:o,signal:a});if(c||!l)return this._returnResult({data:null,error:c??new gt("WebAuthn ceremony failed",null)});const u=Sa(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:u})}catch(n){if(q(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){ft(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 Le});const{data:n,error:i}=await J(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(q(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){ft(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 Le});const{data:i,error:o}=await J(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(q(s))return this._returnResult({data:null,error:s});throw s}}async _startPasskeyAuthentication(e){var s;ft(this.experimental);try{const{data:r,error:n}=await J(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(q(r))return this._returnResult({data:null,error:r});throw r}}async _verifyPasskeyAuthentication(e){ft(this.experimental);try{const{data:s,error:r}=await J(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:at});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(q(s))return this._returnResult({data:null,error:s});throw s}}async _listPasskeys(){ft(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 Le});const{data:n,error:i}=await J(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(q(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){ft(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 Le});const{data:i,error:o}=await J(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(q(s))return this._returnResult({data:null,error:s});throw s}}async _deletePasskey(e){ft(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 Le});const{error:i}=await J(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(q(s))return this._returnResult({data:null,error:s});throw s}}}xr.nextInstanceID={};const Bg=xr,Hg="2.105.4";let Qs="";typeof Deno<"u"?Qs="deno":typeof document<"u"?Qs="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Qs="react-native":Qs="node";const Fg={"X-Client-Info":`supabase-js-${Qs}/${Hg}`},qg={headers:Fg},Vg={schema:"public"},Wg={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Kg={};function kr(t){"@babel/helpers - typeof";return kr=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},kr(t)}function Gg(t,e){if(kr(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(kr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Jg(t){var e=Gg(t,"string");return kr(e)=="symbol"?e:e+""}function zg(t,e,s){return(e=Jg(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function Aa(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 Ae(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Aa(Object(s),!0).forEach(function(r){zg(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Aa(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}const Yg=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Xg=()=>Headers,Qg=(t,e,s)=>{const r=Yg(s),n=Xg();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,Ae(Ae({},o),{},{headers:c}))}};function Zg(t){return t.endsWith("/")?t:t+"/"}function ey(t,e){var s,r;const{db:n,auth:i,realtime:o,global:a}=t,{db:l,auth:c,realtime:u,global:h}=e,f={db:Ae(Ae({},l),n),auth:Ae(Ae({},c),i),realtime:Ae(Ae({},u),o),storage:{},global:Ae(Ae(Ae({},h),a),{},{headers:Ae(Ae({},(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?f.accessToken=t.accessToken:delete f.accessToken,f}function ty(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(Zg(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var sy=class extends Bg{constructor(t){super(t)}},ry=class{constructor(t,e,s){var r,n;this.supabaseUrl=t,this.supabaseKey=e;const i=ty(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:Vg,realtime:Kg,auth:Ae(Ae({},Wg),{},{storageKey:o}),global:qg},l=ey(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=Qg(e,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(Ae({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 Cf(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 Fp(this.storageUrl.href,this.headers,this.fetch,s==null?void 0:s.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new bf(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:f},d,g){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new sy({url:this.authUrl.href,headers:Ae(Ae({},v),d),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:n,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,fetch:g,lockAcquireTimeout:h,skipAutoInitialize:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(S=>S.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new hp(this.realtimeUrl.href,Ae(Ae({},t),{},{params:Ae(Ae({},{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 ny=(t,e,s)=>new ry(t,e,s);function iy(){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}iy()&&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 Fr=null,qr=null;async function $c(){return qr||(qr=await(await fetch("/api/auth/config")).json(),qr)}async function Zn(){if(Fr)return Fr;const t=await $c();return!t.authEnabled||!t.supabaseUrl||!t.supabaseAnonKey?null:(Fr=ny(t.supabaseUrl,t.supabaseAnonKey),Fr)}const Cr=Jl("auth",()=>{const t=B(null),e=B(null),s=B(!1),r=B(!1),n=B(!1);let i=null;async function o(){const h=await $c();if(n.value=h.authEnabled,!h.authEnabled){r.value=!0;return}const f=await Zn();if(!f){r.value=!0;return}await new Promise(d=>{f.auth.onAuthStateChange((g,v)=>{e.value=v,t.value=(v==null?void 0:v.user)??null,g==="INITIAL_SESSION"&&d()})}),r.value=!0}async function a(){if(!r.value)return i||(i=o()),i}async function l(h,f){const d=await Zn();if(!d)return"Auth not configured";s.value=!0;try{const{error:g}=await d.auth.signInWithPassword({email:h,password:f});return g?g.message:null}finally{s.value=!1}}async function c(){const h=await Zn();h&&await h.auth.signOut(),t.value=null,e.value=null}function u(){var h;return((h=e.value)==null?void 0:h.access_token)??null}return{user:t,session:e,loading:s,initialized:r,authEnabled:n,init:a,signIn:l,signOut:c,getAccessToken:u}});async function be(t,e){const s=Cr(),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 Pn(t){const s=Cr().getAccessToken();if(!s)return t;const r=t.includes("?")?"&":"?";return`${t}${r}token=${encodeURIComponent(s)}`}const oy={key:0,class:"min-w-0"},ay={key:1,class:"text-xl font-bold text-blue-400"},ly=["title"],cy={class:"text-sm font-mono select-none"},uy={class:"flex-1 py-4 overflow-hidden"},hy={class:"space-y-1 px-2"},dy={class:"text-base leading-none shrink-0"},fy={key:0,class:"text-sm truncate"},py={class:"p-3 border-t border-gray-800"},gy={class:"flex items-center justify-between mb-2"},yy={class:"text-xs text-gray-500 truncate"},my={class:"flex items-center gap-1 shrink-0 ml-2"},vy={key:0,class:"text-[10px] text-gray-600"},by={key:1,class:"text-[10px] text-gray-600"},_y={key:1,class:"flex items-center gap-1"},wy={key:0,class:"text-[10px] text-gray-600"},xy={key:1,class:"text-[10px] text-gray-600"},ky={key:1,class:"flex flex-col items-center gap-1"},Ra="io-nav-collapsed",Sy=dt({__name:"AppNav",setup(t){const e=gf(),s=cc(),r=Cr(),n=B(""),i=B(0),o=B(!1);let a=null;const l=[{to:"/chat",name:"chat",icon:"💬",label:"Chat"},{to:"/skills",name:"skills",icon:"⚙️",label:"Skills"},{to:"/squads",name:"squads",icon:"👥",label:"Squads"},{to:"/wiki",name:"wiki",icon:"📚",label:"Wiki"},{to:"/schedules",name:"schedules",icon:"📅",label:"Schedules"},{to:"/notifications",name:"notifications",icon:"🔔",label:"Notifications"},{to:"/activity",name:"activity",icon:"📊",label:"Activity"}];function c(){o.value=!o.value;try{localStorage.setItem(Ra,String(o.value))}catch{}}async function u(){await r.signOut(),s.push("/login")}function h(){i.value=0}return os(async()=>{try{const f=localStorage.getItem(Ra);f!==null&&(o.value=f==="true")}catch{}try{const f=await be("/api/status");if(f.ok){const d=await f.json();n.value=d.version??""}}catch{}try{const f=await be("/api/notifications?unread=true&limit=1");if(f.ok){const d=await f.json();i.value=d.unreadCount??0}}catch{}a=new EventSource(Pn("/api/events")),a.onmessage=f=>{try{JSON.parse(f.data).type==="notification"&&e.name!=="notifications"&&i.value++}catch{}}}),wn(()=>{a==null||a.close(),a=null}),(f,d)=>Ee(e).name!=="login"?(_(),w("nav",{key:0,class:ge(["bg-gray-900 border-r border-gray-800 flex flex-col shrink-0 nav-sidebar",o.value?"nav-collapsed":"nav-expanded"])},[p("div",{class:ge(["p-3 border-b border-gray-800 flex items-center",o.value?"justify-center":"justify-between"])},[o.value?(_(),w("span",ay,"IO")):(_(),w("div",oy,[...d[0]||(d[0]=[p("h1",{class:"text-xl font-bold text-blue-400"},"IO",-1),p("p",{class:"text-xs text-gray-500"},"Terminal Assistant",-1)])])),p("button",{onClick:c,class:ge(["text-gray-400 hover:text-gray-200 transition-colors p-1 rounded hover:bg-gray-800 shrink-0",o.value?"":"ml-2"]),title:o.value?"Expand sidebar":"Collapse sidebar"},[p("span",cy,O(o.value?"»":"«"),1)],10,ly)],2),p("div",uy,[p("ul",hy,[(_(),w(ye,null,Ve(l,g=>p("li",{key:g.to},[We(Ee(ac),{to:g.to,class:ge(["flex items-center rounded hover:bg-gray-800 transition-colors relative",[o.value?"justify-center px-2 py-2":"px-3 py-2 gap-2",Ee(e).name===g.name?"bg-blue-900 text-blue-300":""]]),title:o.value?g.label:void 0,onClick:v=>g.name==="notifications"?h():void 0},{default:hl(()=>[p("span",dy,O(g.icon),1),o.value?z("",!0):(_(),w("span",fy,O(g.label),1)),g.name==="notifications"&&i.value>0?(_(),w("span",{key:1,class:ge(["absolute bg-red-500 text-white text-[9px] font-bold rounded-full min-w-[16px] h-[16px] flex items-center justify-center px-0.5",o.value?"top-0.5 right-0.5":"top-1 right-1.5"])},O(i.value>99?"99+":i.value),3)):z("",!0)]),_:2},1032,["to","class","title","onClick"])])),64))])]),p("div",py,[o.value?(_(),w("div",ky,[d[4]||(d[4]=p("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"text-gray-600 hover:text-gray-400 transition-colors",title:"GitHub"},[p("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor"},[p("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.489.5.092.682-.217.682-.482 0-.237-.009-.868-.013-1.703-2.782.604-3.369-1.342-3.369-1.342-.454-1.154-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0112 6.836a9.59 9.59 0 012.504.337c1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.741 0 .267.18.578.688.48C19.138 20.163 22 16.418 22 12c0-5.523-4.477-10-10-10z"})])],-1)),Ee(r).authEnabled&&Ee(r).user?(_(),w("button",{key:0,onClick:u,class:"flex justify-center p-1 text-gray-500 hover:text-white hover:bg-gray-800 rounded transition-colors",title:"Sign out"},[...d[3]||(d[3]=[p("span",{class:"text-sm"},"↩",-1)])])):z("",!0)])):(_(),w(ye,{key:0},[Ee(r).authEnabled&&Ee(r).user?(_(),w(ye,{key:0},[p("div",gy,[p("p",yy,O(Ee(r).user.email),1),p("span",my,[n.value?(_(),w("span",vy,"v"+O(n.value),1)):z("",!0),n.value?(_(),w("span",by,"·")):z("",!0),d[1]||(d[1]=p("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"text-[10px] text-gray-600 hover:text-gray-400 transition-colors"},"GitHub",-1))])]),p("button",{onClick:u,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 ")],64)):(_(),w("span",_y,[n.value?(_(),w("span",wy,"v"+O(n.value),1)):z("",!0),n.value?(_(),w("span",xy,"·")):z("",!0),d[2]||(d[2]=p("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"text-[10px] text-gray-600 hover:text-gray-400 transition-colors"},"GitHub",-1))]))],64))])],2)):z("",!0)}}),Or=(t,e)=>{const s=t.__vccOpts||t;for(const[r,n]of e)s[r]=n;return s},Ey=Or(Sy,[["__scopeId","data-v-d1740758"]]),Ty={class:"flex h-screen bg-gray-950"},Ay={class:"flex-1 overflow-auto"},Ry=dt({__name:"App",setup(t){return(e,s)=>(_(),w("div",Ty,[We(Ey),p("main",Ay,[We(Ee(lc))])]))}}),Cy=Jl("chat",()=>{const t=B([]),e=B(!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}});function At(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\*\*\*(.*?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`([^`]+)`/g,'<code class="bg-gray-800 px-1 rounded text-blue-300 font-mono text-xs">$1</code>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,s,r)=>`<a href="${/^https?:\/\//i.test(r)||r.startsWith("/")||r.startsWith("#")?r:"#"}" target="_blank" rel="noopener" class="text-blue-400 hover:underline">${s}</a>`)}function Pc(t){const e=t.trim();return e.startsWith("|")&&e.endsWith("|")&&e.length>2}function Ca(t){return Pc(t)&&/^\|[\s|:\-]+\|$/.test(t.trim())}function ei(t){return t.trim().slice(1,-1).split("|").map(e=>e.trim())}function Oy(t){const e=t.trim();return e.startsWith(":")&&e.endsWith(":")?"text-center":e.endsWith(":")?"text-right":"text-left"}function $y(t){if(t.length<2)return t.map(a=>`<p class="my-1">${At(a)}</p>`).join(`
|
|
73
|
+
`);const e=ei(t[0]),s=t[1],r=Ca(s)?ei(s).map(Oy):e.map(()=>"text-left"),n=Ca(s)?t.slice(2):t.slice(1),i=e.map((a,l)=>`<th class="px-3 py-1.5 font-medium text-gray-300 ${r[l]??"text-left"}">${At(a)}</th>`).join(""),o=n.map(a=>{const l=ei(a);return`<tr class="border-b border-gray-800">${e.map((u,h)=>`<td class="px-3 py-1.5 text-gray-400 ${r[h]??"text-left"}">${At(l[h]??"")}</td>`).join("")}</tr>`}).join("");return`<div class="overflow-x-auto my-2"><table class="border-collapse w-full text-sm"><thead><tr class="border-b border-gray-700">${i}</tr></thead><tbody>${o}</tbody></table></div>`}function In(t){if(!t)return"";const e=t.split(`
|
|
74
|
+
`),s=[];let r=!1,n=!1,i=!1,o=[],a=[];function l(){n&&(s.push("</ul>"),n=!1)}function c(){i&&(s.push($y(a)),a=[],i=!1)}for(const u of e){if(u.startsWith("```")){if(l(),c(),!r)r=!0,o=[];else{const C=o.join(`
|
|
75
|
+
`).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");s.push(`<pre class="bg-gray-900 border border-gray-800 rounded p-3 my-2 overflow-x-auto"><code class="font-mono text-xs text-green-300">${C}</code></pre>`),r=!1,o=[]}continue}if(r){o.push(u);continue}if(Pc(u)){l(),i=!0,a.push(u);continue}i&&c();const h=u.match(/^####\s+(.+)/),f=u.match(/^###\s+(.+)/),d=u.match(/^##\s+(.+)/),g=u.match(/^#\s+(.+)/);if(h){l(),s.push(`<h4 class="text-sm font-semibold text-gray-200 mt-4 mb-1">${At(h[1])}</h4>`);continue}if(f){l(),s.push(`<h3 class="text-base font-semibold text-gray-100 mt-5 mb-2">${At(f[1])}</h3>`);continue}if(d){l(),s.push(`<h2 class="text-lg font-bold text-gray-100 mt-6 mb-2 pb-1 border-b border-gray-800">${At(d[1])}</h2>`);continue}if(g){l(),s.push(`<h1 class="text-xl font-bold text-gray-100 mt-6 mb-3">${At(g[1])}</h1>`);continue}if(/^---+$/.test(u.trim())){l(),s.push('<hr class="border-gray-800 my-4" />');continue}const v=u.match(/^[-*+]\s+(.+)/);if(v){n||(s.push('<ul class="list-disc list-inside my-2 space-y-1 pl-2">'),n=!0),s.push(`<li>${At(v[1])}</li>`);continue}const S=u.match(/^\d+\.\s+(.+)/);if(S){n||(s.push('<ol class="list-decimal list-inside my-2 space-y-1 pl-2">'),n=!0),s.push(`<li>${At(S[1])}</li>`);continue}if(u.trim()===""){l(),s.push('<div class="my-2"></div>');continue}l(),s.push(`<p class="my-1">${At(u)}</p>`)}if(r&&o.length){const u=o.join(`
|
|
76
|
+
`).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");s.push(`<pre class="bg-gray-900 border border-gray-800 rounded p-3 my-2 overflow-x-auto"><code class="font-mono text-xs text-green-300">${u}</code></pre>`)}return c(),l(),s.join(`
|
|
77
|
+
`)}const Py={class:"flex flex-col h-full relative"},Iy={key:0,class:"text-gray-600 text-sm text-center mt-12"},jy={key:0,class:"max-w-[75%] px-4 py-3 rounded-lg text-sm whitespace-pre-wrap bg-blue-700 text-white"},Ny=["innerHTML"],Ly={key:1,class:"flex justify-start"},Uy={class:"border-t border-gray-800 p-4"},Dy=["disabled"],My=["disabled"],By=["disabled"],Hy=dt({__name:"ChatView",setup(t){const e=Cy(),s=B(""),r=B(!1),n=B(null),i=B(!1),o=B(null);async function a(){if(!r.value){r.value=!0;try{await be("/api/orchestrator/abort",{method:"POST"})}catch{}finally{r.value=!1}}}const l=Ne(()=>e.messages.some(g=>g.streaming));function c(){const g=n.value;g&&(i.value=g.scrollTop+g.clientHeight<g.scrollHeight-100)}function u(){Ms(()=>{n.value&&(n.value.scrollTop=n.value.scrollHeight)})}rs(()=>e.messages.length,()=>{i.value||u()});function h(g){g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),d())}function f(){const g=o.value;g&&(g.style.height="auto",g.style.height=Math.min(g.scrollHeight,200)+"px")}async function d(){const g=s.value.trim();if(!g||e.isLoading)return;s.value="",Ms(()=>{o.value&&(o.value.style.height="auto")}),e.isLoading=!0,e.addMessage({id:crypto.randomUUID(),role:"user",content:g}),e.addMessage({id:crypto.randomUUID(),role:"assistant",content:"",streaming:!0}),u();const v=new EventSource(Pn("/api/events"));v.onmessage=S=>{try{const C=JSON.parse(S.data);C.type==="delta"?(e.appendToLast(C.text),u()):C.type==="done"&&(e.setLastStreaming(!1),e.isLoading=!1,v.close(),u())}catch{}},v.onerror=()=>{e.setLastStreaming(!1),e.isLoading=!1,v.close()};try{await be("/api/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:g})})}catch{e.appendToLast(`
|
|
78
|
+
|
|
79
|
+
[Error: failed to reach IO]`),e.setLastStreaming(!1),e.isLoading=!1,v.close()}}return(g,v)=>(_(),w("div",Py,[p("div",{ref_key:"messagesEl",ref:n,class:"flex-1 overflow-y-auto p-6 space-y-4",onScroll:c},[Ee(e).messages.length===0?(_(),w("div",Iy," Send a message to start chatting with IO ")):z("",!0),(_(!0),w(ye,null,Ve(Ee(e).messages,S=>(_(),w("div",{key:S.id,class:ge(["flex",S.role==="user"?"justify-end":"justify-start"])},[S.role==="user"?(_(),w("div",jy,O(S.content),1)):(_(),w("div",{key:1,class:"chat-md max-w-[75%] px-4 py-3 rounded-lg text-sm bg-gray-800 text-gray-100 border border-gray-700",innerHTML:Ee(In)(S.content)+(S.streaming?'<span class="inline-block w-2 h-4 bg-blue-400 ml-1 animate-pulse align-middle"></span>':"")},null,8,Ny))],2))),128)),Ee(e).isLoading&&!l.value?(_(),w("div",Ly,[...v[1]||(v[1]=[p("div",{class:"bg-gray-800 border border-gray-700 px-4 py-3 rounded-lg flex items-center gap-1.5"},[p("span",{class:"dot-pulse",style:{"animation-delay":"0s"}}),p("span",{class:"dot-pulse",style:{"animation-delay":"0.2s"}}),p("span",{class:"dot-pulse",style:{"animation-delay":"0.4s"}})],-1)])])):z("",!0)],544),i.value?(_(),w("button",{key:0,onClick:u,class:"absolute bottom-20 right-8 bg-gray-700 hover:bg-gray-600 text-gray-200 rounded-full p-2 shadow-lg transition-all z-10",title:"Scroll to bottom"},[...v[2]||(v[2]=[p("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},[p("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])])):z("",!0),p("div",Uy,[p("form",{onSubmit:is(d,["prevent"]),class:"flex gap-3 items-end"},[ct(p("textarea",{ref_key:"inputEl",ref:o,"onUpdate:modelValue":v[0]||(v[0]=S=>s.value=S),placeholder:"Message IO...",disabled:Ee(e).isLoading,rows:"1",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 resize-none overflow-hidden",onKeydown:h,onInput:f},null,40,Dy),[[It,s.value]]),Ee(e).isLoading?(_(),w("button",{key:0,type:"button",onClick:a,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"},[v[3]||(v[3]=p("span",{class:"inline-block w-3 h-3 bg-white rounded-sm"},null,-1)),st(" "+O(r.value?"Stopping...":"Stop"),1)],8,My)):(_(),w("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,By))],32)])]))}}),Fy=Or(Hy,[["__scopeId","data-v-ef4cff2c"]]),qy={class:"flex flex-col h-full bg-gray-950"},Vy={key:0,class:"flex flex-col h-full overflow-hidden"},Wy={class:"flex items-center gap-3 px-6 py-4 border-b border-gray-800 shrink-0"},Ky={class:"text-lg font-bold text-gray-100 truncate"},Gy={class:"text-xs text-gray-500 font-mono shrink-0"},Jy={key:0,class:"flex-1 flex items-center justify-center"},zy={key:1,class:"flex-1 p-6"},Yy={class:"text-sm text-red-400"},Xy=["innerHTML"],Qy={key:1,class:"flex-1 overflow-y-auto p-6"},Zy={class:"mb-6 max-w-2xl"},em={class:"flex gap-1 mb-3 border-b border-gray-800"},tm={class:"flex gap-2"},sm=["disabled"],rm=["disabled"],nm={class:"flex flex-col gap-2"},im=["disabled"],om=["disabled"],am=["disabled"],lm={key:0,class:"bg-green-900 text-green-100 p-4 rounded-lg mb-4"},cm={key:1,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},um={key:2,class:"text-gray-400 text-center py-12"},hm={key:3,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},dm={key:4,class:"text-gray-400 text-center py-12"},fm={key:5,class:"grid gap-4"},pm=["onClick"],gm={class:"flex justify-between items-start mb-2"},ym={class:"font-bold text-gray-100"},mm={class:"text-sm text-gray-500"},vm={class:"text-sm text-gray-400 mb-3"},bm={class:"text-xs text-gray-500"},_m=dt({__name:"SkillsView",setup(t){const e=B([]),s=B(!0),r=B(null),n=B(""),i=B(!1),o=B(null),a=B(null),l=B("url"),c=B(""),u=B(""),h=B(!1),f=B(null),d=B(""),g=B(!1),v=B(null),S=Ne(()=>In(d.value));async function C(j){f.value=j,d.value="",v.value=null,g.value=!0;try{const b=await be(`/api/skills/${encodeURIComponent(j.slug)}`);if(b.status===404)v.value="Skill not found";else if(!b.ok)v.value=`Failed to load skill (HTTP ${b.status})`;else{const N=await b.json();d.value=N.content??""}}catch(b){v.value=b instanceof Error?b.message:"Failed to load skill"}finally{g.value=!1}}function T(){f.value=null,d.value="",v.value=null}async function E(){try{const j=await be("/api/skills");if(!j.ok)throw new Error(`HTTP error! status: ${j.status}`);const b=await j.json();e.value=b.skills}catch(j){r.value=j instanceof Error?j.message:"Failed to load skills"}finally{s.value=!1}}async function U(){if(!(i.value||n.value.trim()==="")){i.value=!0,o.value=null,a.value=null;try{const j=await be("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repoUrl:n.value.trim()})});if(j.ok){const b=await j.json();e.value=[b.skill,...e.value],n.value="",a.value=`✓ Installed: ${b.skill.name}`,setTimeout(()=>{a.value=null},4e3),E()}else{let b="Install failed";try{b=(await j.json()).error??j.statusText??b}catch{b=j.statusText||b}o.value=b}}catch(j){o.value=j instanceof Error?j.message:"Install failed"}finally{i.value=!1}}}async function D(){if(!(h.value||c.value.trim()===""||u.value.trim()==="")){h.value=!0,o.value=null,a.value=null;try{const j=await be("/api/skills/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u.value.trim(),slug:c.value.trim()})});if(j.ok){const b=await j.json();e.value=[b.skill,...e.value],c.value="",u.value="",a.value=`✓ Installed: ${b.skill.name}`,setTimeout(()=>{a.value=null},4e3),E()}else{let b="Install failed";try{b=(await j.json()).error??j.statusText??b}catch{b=j.statusText||b}o.value=b}}catch(j){o.value=j instanceof Error?j.message:"Install failed"}finally{h.value=!1}}}return os(E),(j,b)=>(_(),w("div",qy,[f.value?(_(),w("div",Vy,[p("div",Wy,[p("button",{onClick:T,class:"text-gray-400 hover:text-gray-200 transition-colors flex items-center gap-1.5 text-sm"}," ← Back "),p("h2",Ky,O(f.value.name),1),p("span",Gy,O(f.value.slug),1)]),g.value?(_(),w("div",Jy,[...b[5]||(b[5]=[p("span",{class:"text-sm text-gray-500"},"Loading…",-1)])])):v.value?(_(),w("div",zy,[p("p",Yy,O(v.value),1)])):(_(),w("div",{key:2,class:"flex-1 overflow-y-auto p-6 skill-content text-sm text-gray-300 leading-relaxed",innerHTML:S.value},null,8,Xy))])):(_(),w("div",Qy,[b[7]||(b[7]=p("h2",{class:"text-2xl font-bold mb-6"},"Skills",-1)),p("div",Zy,[p("div",em,[p("button",{type:"button",onClick:b[0]||(b[0]=N=>l.value="url"),class:ge(["px-3 py-1.5 text-sm rounded-t transition-colors",l.value==="url"?"bg-gray-800 text-gray-100 border-b-2 border-blue-500":"text-gray-500 hover:text-gray-300"])}," From URL ",2),p("button",{type:"button",onClick:b[1]||(b[1]=N=>l.value="paste"),class:ge(["px-3 py-1.5 text-sm rounded-t transition-colors",l.value==="paste"?"bg-gray-800 text-gray-100 border-b-2 border-blue-500":"text-gray-500 hover:text-gray-300"])}," Paste SKILL.md ",2)]),l.value==="url"?(_(),w("form",{key:0,onSubmit:is(U,["prevent"])},[p("div",tm,[ct(p("input",{"onUpdate:modelValue":b[2]||(b[2]=N=>n.value=N),type:"url",placeholder:"https://github.com/owner/repo.git","aria-label":"Git repository URL",disabled:i.value,class:"flex-1 bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50"},null,8,sm),[[It,n.value]]),p("button",{type:"submit",disabled:i.value||n.value.trim()==="",class:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-700 disabled:opacity-50 text-white px-4 py-2 rounded text-sm transition-colors whitespace-nowrap"},O(i.value?"Installing…":"Install"),9,rm)])],32)):(_(),w("form",{key:1,onSubmit:is(D,["prevent"])},[p("div",nm,[p("div",null,[ct(p("input",{"onUpdate:modelValue":b[3]||(b[3]=N=>c.value=N),type:"text",placeholder:"my-skill","aria-label":"Skill slug",disabled:h.value,class:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50"},null,8,im),[[It,c.value]]),b[6]||(b[6]=p("p",{class:"text-xs text-gray-600 mt-1"},"Unique identifier for this skill (lowercase, hyphens ok)",-1))]),ct(p("textarea",{"onUpdate:modelValue":b[4]||(b[4]=N=>u.value=N),placeholder:"Paste SKILL.md content here…","aria-label":"SKILL.md content",disabled:h.value,rows:"8",class:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 font-mono resize-y"},null,8,om),[[It,u.value]]),p("button",{type:"submit",disabled:h.value||c.value.trim()===""||u.value.trim()==="",class:"self-end bg-blue-600 hover:bg-blue-700 disabled:bg-gray-700 disabled:opacity-50 text-white px-4 py-2 rounded text-sm transition-colors"},O(h.value?"Installing…":"Install"),9,am)])],32))]),a.value?(_(),w("div",lm,O(a.value),1)):z("",!0),o.value?(_(),w("div",cm,O(o.value),1)):z("",!0),s.value?(_(),w("div",um," Loading skills... ")):r.value?(_(),w("div",hm,O(r.value),1)):e.value.length===0?(_(),w("div",dm," No skills available ")):(_(),w("div",fm,[(_(!0),w(ye,null,Ve(e.value,N=>(_(),w("div",{key:N.slug,onClick:Y=>C(N),class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-blue-500 transition-colors cursor-pointer"},[p("div",gm,[p("div",null,[p("h3",ym,O(N.name),1),p("p",mm,O(N.slug),1)])]),p("p",vm,O(N.description),1),p("p",bm,O(N.path),1)],8,pm))),128))]))]))]))}}),wm=Or(_m,[["__scopeId","data-v-422f7a1e"]]),xm={class:"flex flex-col h-full bg-gray-950"},km={class:"flex-1 overflow-y-auto p-6"},Sm={class:"flex justify-between items-center mb-6"},Em={class:"space-y-3"},Tm=["disabled"],Am={key:0,class:"mt-2 text-red-400 text-sm"},Rm={key:1,class:"text-gray-400 text-center py-12"},Cm={key:2,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},Om={key:3,class:"text-gray-400 text-center py-12"},$m={key:4,class:"grid gap-4"},Pm=["onClick","aria-expanded"],Im={class:"flex justify-between items-start mb-3"},jm={class:"flex-1 flex items-center gap-2"},Nm={class:"font-bold text-gray-100"},Lm={class:"text-sm text-gray-500"},Um={class:"flex items-center gap-2"},Dm={key:0,class:"px-2 py-1 rounded text-xs font-medium bg-purple-900 text-purple-100"},Mm={class:"text-sm text-gray-400"},Bm={key:0,class:"mt-4 pt-4 border-t border-gray-700"},Hm={class:"flex justify-between items-center text-xs text-gray-500 mb-3"},Fm={key:0},qm={key:0,class:"text-gray-400 text-sm py-2"},Vm={key:1,class:"text-red-400 text-sm py-2"},Wm={key:2,class:"text-gray-500 text-sm italic py-2"},Km={key:3,class:"space-y-2"},Gm={class:"flex-1 min-w-0"},Jm={class:"text-sm font-medium text-gray-100"},zm={key:0,title:"Team Lead",class:"text-xs"},Ym={key:1,title:"QA / Veto Power",class:"text-xs"},Xm={class:"text-xs text-gray-500 ml-2"},Qm=["onClick"],Zm=["onClick","disabled"],ev={class:"bg-gray-900 border border-gray-700 rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col shadow-2xl"},tv={class:"flex justify-between items-center p-4 border-b border-gray-700"},sv={class:"min-w-0"},rv={class:"text-lg font-bold text-gray-100 truncate"},nv={class:"text-sm font-normal text-gray-400"},iv={class:"text-xs text-gray-500 mt-1 flex items-center gap-2"},ov={class:"flex items-center gap-3"},av={class:"flex items-center gap-1.5 text-xs text-gray-400 cursor-pointer select-none"},lv={key:0,class:"bg-red-900 text-red-100 p-3 rounded"},cv={key:1,class:"text-gray-500 italic text-center py-8"},uv={class:"shrink-0"},hv={class:"flex-1 min-w-0"},dv={class:"text-gray-200 break-words"},fv={class:"text-gray-600 text-[10px] ml-2"},pv={key:0,class:"text-gray-500 italic text-center py-4"},gv={class:"flex justify-between items-center mb-1"},yv={class:"text-blue-400"},mv={class:"text-gray-600 text-[10px]"},vv={class:"text-gray-200 whitespace-pre-wrap break-words"},bv=dt({__name:"SquadsView",setup(t){const e=new Set(["system"]),s={"a-team":"The A-Team",transformers:"Transformers",thundercats:"ThunderCats","gi-joe":"G.I. Joe",aliens:"Aliens",ghostbusters:"Ghostbusters"},r=B([]),n=B(!0),i=B(null),o=B(!1),a=B(!1),l=B(null),c=Vt({}),u=Vt({}),h=Vt({}),f=Vt({}),d=B(new Set),g=B(null),v=B([]),S=B(null),C=B(!1),T=B(!0),E=B(null);let U=null;const D=Ne(()=>S.value?"Disconnected":C.value?"Live":"Connecting..."),j=Ne(()=>v.value.filter(k=>!(!k.summary||e.has(k.summary.kind)||k.type==="assistant.message_delta"))),b=k=>{try{return new Date(k).toLocaleTimeString()}catch{return""}},N=k=>{const A=k.data;if(!A||typeof A!="object")return"";if(typeof A.deltaContent=="string")return A.deltaContent;if(typeof A.content=="string")return A.content;if(typeof A.text=="string")return A.text;try{return JSON.stringify(A,null,2)}catch{return String(A)}},Y=()=>{Ms(()=>{const k=E.value;k&&(k.scrollTop=k.scrollHeight)})},he=k=>{if(!k.currentTaskId)return;me(),g.value=k,v.value=[],S.value=null,C.value=!1,T.value=!0;const A=Pn(`/api/tasks/${encodeURIComponent(k.currentTaskId)}/events`),R=new EventSource(A);U=R,R.onopen=()=>{C.value=!0},R.onmessage=ne=>{try{const De=JSON.parse(ne.data);v.value.push(De),Y()}catch{}},R.onerror=()=>{C.value=!1,v.value.length===0&&(S.value="Connection error. Retrying...")}},me=()=>{if(U){try{U.close()}catch{}U=null}g.value=null,v.value=[],S.value=null,C.value=!1};ml(()=>{me()});const Pe=async(k,A)=>{if(!d.value.has(A)){d.value=new Set(d.value).add(A);try{await be(`/api/tasks/${encodeURIComponent(A)}/cancel`,{method:"POST"}),await ae(k,!0)}catch(R){f[k]=R instanceof Error?R.message:"Failed to stop task"}finally{const R=new Set(d.value);R.delete(A),d.value=R}}},oe=B({slug:"",name:"",projectPath:""}),et=k=>k?s[k]??k:"",ot=k=>new Date(k).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),de=k=>!!c[k],se=async k=>{c[k]=!c[k],c[k]&&!u[k]&&!h[k]&&await ae(k)},ae=async(k,A=!1)=>{if(!(!A&&h[k])){h[k]=!0,f[k]=null;try{const R=await be(`/api/squads/${encodeURIComponent(k)}/agents`);if(!R.ok)throw new Error(`HTTP error! status: ${R.status}`);const ne=await R.json();u[k]=ne.agents}catch(R){f[k]=R instanceof Error?R.message:"Failed to load agents"}finally{h[k]=!1}}},Ue=async()=>{try{const k=await be("/api/squads");if(!k.ok)throw new Error(`HTTP error! status: ${k.status}`);const A=await k.json();r.value=A.squads}catch(k){i.value=k instanceof Error?k.message:"Failed to load squads"}finally{n.value=!1}},Ye=async()=>{if(!oe.value.slug||!oe.value.name||!oe.value.projectPath){l.value="All fields are required";return}a.value=!0,l.value=null;try{const k=await be("/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(!k.ok)throw new Error(`HTTP error! status: ${k.status}`);oe.value={slug:"",name:"",projectPath:""},o.value=!1,await Ue()}catch(k){l.value=k instanceof Error?k.message:"Failed to create squad"}finally{a.value=!1}};return os(()=>{Ue()}),(k,A)=>(_(),w("div",xm,[p("div",km,[p("div",Sm,[A[5]||(A[5]=p("h2",{class:"text-2xl font-bold"},"Squads & Dashboard",-1)),p("button",{onClick:A[0]||(A[0]=R=>o.value=!o.value),class:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm transition-colors"},O(o.value?"Cancel":"New Squad"),1)]),o.value?(_(),w("form",{key:0,onSubmit:is(Ye,["prevent"]),class:"bg-gray-800 border border-gray-700 rounded-lg p-4 mb-6"},[A[6]||(A[6]=p("h3",{class:"font-bold text-gray-100 mb-4"},"Create New Squad",-1)),p("div",Em,[ct(p("input",{"onUpdate:modelValue":A[1]||(A[1]=R=>oe.value.slug=R),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),[[It,oe.value.slug]]),ct(p("input",{"onUpdate:modelValue":A[2]||(A[2]=R=>oe.value.name=R),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),[[It,oe.value.name]]),ct(p("input",{"onUpdate:modelValue":A[3]||(A[3]=R=>oe.value.projectPath=R),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),[[It,oe.value.projectPath]]),p("button",{type:"submit",disabled:a.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"},O(a.value?"Creating...":"Create Squad"),9,Tm)]),l.value?(_(),w("div",Am,O(l.value),1)):z("",!0)],32)):z("",!0),n.value?(_(),w("div",Rm," Loading squads... ")):i.value?(_(),w("div",Cm,O(i.value),1)):r.value.length===0?(_(),w("div",Om," No squads created yet ")):(_(),w("div",$m,[(_(!0),w(ye,null,Ve(r.value,R=>(_(),w("div",{key:R.id,class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-blue-500 transition-colors"},[p("button",{type:"button",onClick:ne=>se(R.slug),class:"w-full text-left focus:outline-none","aria-expanded":de(R.slug)},[p("div",Im,[p("div",jm,[p("span",{class:ge(["inline-block transition-transform text-gray-400",de(R.slug)?"rotate-90":""])},"▶",2),p("div",null,[p("h3",Nm,O(R.name),1),p("p",Lm,O(R.slug),1)])]),p("div",Um,[R.universe?(_(),w("span",Dm," 🎬 "+O(et(R.universe)),1)):z("",!0),p("span",{class:ge(["px-2 py-1 rounded text-xs font-medium",R.status==="working"?"bg-blue-900 text-blue-100":R.status==="error"?"bg-red-900 text-red-100":"bg-gray-700 text-gray-200"])},O(R.status),3)])]),p("p",Mm,"📁 "+O(R.project_path),1)],8,Pm),de(R.slug)?(_(),w("div",Bm,[p("div",Hm,[R.model?(_(),w("span",Fm,"Model: "+O(R.model),1)):z("",!0),p("span",null,O(ot(R.created_at)),1)]),A[9]||(A[9]=p("h4",{class:"font-semibold text-gray-200 text-sm mb-2"},"Team Roster",-1)),h[R.slug]?(_(),w("div",qm," Loading agents... ")):f[R.slug]?(_(),w("div",Vm,O(f[R.slug]),1)):!u[R.slug]||u[R.slug].length===0?(_(),w("div",Wm," No agents assigned yet ")):(_(),w("ul",Km,[(_(!0),w(ye,null,Ve(u[R.slug],ne=>(_(),w("li",{key:ne.id??ne.character_name,class:ge(["flex items-center gap-3 rounded px-3 py-2",ne.status==="working"?"bg-blue-950 border border-blue-800":"bg-gray-900 border border-gray-700"])},[p("div",Gm,[p("span",Jm,O(ne.character_name),1),ne.is_lead?(_(),w("span",zm,"👑")):z("",!0),ne.is_qa?(_(),w("span",Ym,"🛡️")):z("",!0),p("span",Xm,O(ne.role_title),1)]),p("span",{class:ge(["px-2 py-0.5 rounded text-xs",ne.status==="working"?"bg-blue-800 text-blue-200":ne.status==="error"?"bg-red-800 text-red-200":"bg-gray-700 text-gray-400"])},O(ne.status),3),ne.status==="working"&&ne.currentTaskId?(_(),w("button",{key:0,type:"button",onClick:De=>he(ne),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"},[...A[7]||(A[7]=[p("span",{"aria-hidden":"true"},"👁",-1),st(" Preview ",-1)])],8,Qm)):z("",!0),ne.status==="working"&&ne.currentTaskId?(_(),w("button",{key:1,type:"button",onClick:De=>Pe(R.slug,ne.currentTaskId),disabled:d.value.has(ne.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"},[A[8]||(A[8]=p("span",{class:"inline-block w-2 h-2 bg-white rounded-sm"},null,-1)),st(" "+O(d.value.has(ne.currentTaskId)?"Stopping...":"Stop"),1)],8,Zm)):z("",!0)],2))),128))]))])):z("",!0)]))),128))]))]),g.value?(_(),w("div",{key:0,class:"fixed inset-0 bg-black/70 flex items-center justify-center p-4 z-50",onClick:is(me,["self"])},[p("div",ev,[p("div",tv,[p("div",sv,[p("h3",rv,[st(O(g.value.character_name)+" ",1),p("span",nv,"— "+O(g.value.role_title),1)]),p("p",iv,[p("span",{class:ge(["inline-block w-2 h-2 rounded-full",C.value?"bg-green-400 animate-pulse":"bg-gray-500"])},null,2),st(" "+O(D.value),1)])]),p("div",ov,[p("label",av,[ct(p("input",{type:"checkbox","onUpdate:modelValue":A[4]||(A[4]=R=>T.value=R),class:"rounded bg-gray-700 border-gray-600"},null,512),[[Fl,T.value]]),A[10]||(A[10]=st(" Summary ",-1))]),p("button",{type:"button",onClick:me,class:"text-gray-400 hover:text-gray-100 text-2xl leading-none focus:outline-none","aria-label":"Close"},"×")])]),p("div",{ref_key:"previewScrollEl",ref:E,class:"overflow-y-auto p-4 space-y-3 flex-1 font-mono text-xs"},[S.value?(_(),w("div",lv,O(S.value),1)):v.value.length===0?(_(),w("div",cv," Waiting for activity... ")):T.value?(_(),w(ye,{key:2},[(_(!0),w(ye,null,Ve(j.value,(R,ne)=>(_(),w("div",{key:ne,class:"flex items-start gap-2 py-1.5"},[p("span",uv,O(R.summary.icon),1),p("div",hv,[p("span",dv,O(R.summary.summary),1),p("span",fv,O(b(R.ts)),1)])]))),128)),j.value.length===0?(_(),w("div",pv," Processing… ")):z("",!0)],64)):(_(!0),w(ye,{key:3},Ve(v.value,(R,ne)=>(_(),w("div",{key:ne,class:"border border-gray-800 rounded p-2 bg-gray-950"},[p("div",gv,[p("span",yv,O(R.type),1),p("span",mv,O(b(R.ts)),1)]),p("pre",vv,O(N(R)),1)]))),128))],512),p("div",{class:"p-3 border-t border-gray-700 flex justify-end"},[p("button",{type:"button",onClick:me,class:"bg-gray-700 hover:bg-gray-600 text-gray-100 text-sm px-4 py-2 rounded transition-colors"}," Close ")])])])):z("",!0)]))}}),_v={class:"flex flex-col h-full bg-gray-950"},wv={class:"flex-1 overflow-y-auto p-6"},xv={class:"flex justify-between items-center mb-6"},kv=["disabled"],Sv={key:0,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},Ev={class:"mb-8"},Tv={key:0,class:"text-gray-400 text-center py-8"},Av={key:1,class:"text-gray-400 text-center py-8"},Rv={key:2,class:"grid gap-4"},Cv={class:"flex justify-between items-start mb-3"},Ov={class:"flex-1"},$v={class:"font-bold text-gray-100"},Pv={class:"flex items-center gap-2 mt-1"},Iv={class:"text-sm text-gray-500"},jv={key:0,class:"text-xs bg-gray-700 text-gray-300 px-2 py-0.5 rounded"},Nv={key:1,class:"text-xs bg-purple-900 text-purple-200 px-2 py-0.5 rounded"},Lv=["title"],Uv={key:0,class:"inline-block w-2 h-2 bg-blue-400 rounded-full mr-1 animate-pulse"},Dv={key:0,class:"bg-gray-700 rounded p-3 mb-2"},Mv={class:"text-sm text-gray-100 break-words"},Bv={class:"flex justify-between items-center"},Hv={class:"text-xs text-gray-500"},Fv=["onClick","disabled"],qv={key:0,class:"text-gray-400 text-center py-8"},Vv={key:1,class:"text-gray-400 text-center py-8"},Wv={key:2,class:"bg-gray-800 border border-gray-700 rounded-lg divide-y divide-gray-700 overflow-hidden"},Kv=["onClick"],Gv={class:"flex justify-between items-start gap-3"},Jv={class:"flex-1 min-w-0"},zv={class:"flex items-center gap-2 mb-1"},Yv={class:"text-sm font-medium text-gray-100 truncate"},Xv={key:0,class:"text-xs text-gray-500"},Qv={class:"text-sm text-gray-300 truncate"},Zv={class:"text-xs text-gray-500 mt-1"},e0={key:0},t0={class:"bg-gray-900 border border-gray-700 rounded-lg w-full max-w-2xl max-h-[85vh] flex flex-col shadow-2xl"},s0={class:"overflow-y-auto p-5 space-y-4"},r0={key:0,class:"text-gray-400 text-center py-8"},n0={key:1,class:"bg-red-900 text-red-100 p-3 rounded text-sm"},i0={class:"flex justify-between items-start gap-3"},o0={class:"text-sm text-gray-100 font-medium"},a0={class:"text-xs text-gray-400 font-mono break-all"},l0={key:0},c0={class:"text-sm text-gray-200"},u0={class:"grid grid-cols-2 gap-4"},h0={class:"text-sm text-gray-200"},d0={class:"text-sm text-gray-200"},f0={key:1},p0={class:"text-sm text-gray-200"},g0={class:"text-sm text-gray-100 bg-gray-800 border border-gray-700 rounded p-3 whitespace-pre-wrap break-words font-sans"},y0={class:"flex justify-between items-center mb-2"},m0={class:"flex items-center gap-2 text-xs text-gray-400 cursor-pointer select-none"},v0={key:0,class:"text-sm text-gray-500 italic"},b0={key:1,class:"text-sm text-gray-500 italic"},_0={key:2,class:"bg-gray-800 border border-gray-700 rounded divide-y divide-gray-700 max-h-96 overflow-y-auto"},w0=["onClick"],x0={class:"shrink-0"},k0={class:"flex-1 break-words"},S0={class:"text-xs text-gray-500 shrink-0"},E0={key:0,class:"mt-2 pl-6 space-y-1"},T0={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"},A0={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"},R0={class:"text-[10px] text-gray-600 font-mono"},C0={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"},O0={key:1,class:"text-sm text-gray-500 italic"},$0={class:"p-4 border-t border-gray-700 flex justify-between items-center"},P0=["disabled"],I0={key:1},j0=dt({__name:"AgentActivityView",setup(t){const e=B([]),s=B([]),r=B(!0),n=B(null),i=B(new Set),o=B(null),a=B(null),l=B(!1),c=B(null),u=B([]),h=B(!1),f=B(!1),d=B(new Set);let g=null,v=null,S=null;const C=k=>k.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),T=k=>{if(!k)return"";const A=k.includes("T")?k:k.replace(" ","T")+"Z",R=new Date(A);return Number.isNaN(R.getTime())?k:R.toLocaleString()},E=k=>{switch(k){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"}},U=Ne(()=>{if(!a.value)return null;const k=a.value.started_at,A=a.value.completed_at;if(!k||!A)return null;const R=new Date(k.includes("T")?k:k.replace(" ","T")+"Z").getTime(),ne=new Date(A.includes("T")?A:A.replace(" ","T")+"Z").getTime();if(Number.isNaN(R)||Number.isNaN(ne))return null;const De=Math.max(0,Math.round((ne-R)/1e3));if(De<60)return`${De}s`;const Xe=Math.floor(De/60),P=De%60;return`${Xe}m ${P}s`}),D=async k=>{if(!i.value.has(k)){i.value=new Set(i.value).add(k);try{await be(`/api/tasks/${encodeURIComponent(k)}/cancel`,{method:"POST"}),await N(),o.value===k&&await Y(k)}catch(A){n.value=A instanceof Error?A.message:"Failed to stop task"}finally{const A=new Set(i.value);A.delete(k),i.value=A}}},j=async()=>{try{const k=await be("/api/agents");if(!k.ok)throw new Error(`HTTP error! status: ${k.status}`);const A=await k.json();e.value=A.agents}catch(k){n.value=k instanceof Error?k.message:"Failed to load agents"}},b=async()=>{try{const k=await be("/api/tasks?limit=50");if(!k.ok)throw new Error(`HTTP error! status: ${k.status}`);const A=await k.json();s.value=A.tasks}catch(k){n.value=k instanceof Error?k.message:"Failed to load tasks"}},N=async()=>{r.value=!0,n.value=null;try{await Promise.all([j(),b()])}finally{r.value=!1}},Y=async k=>{l.value=!0,c.value=null;try{const A=await be(`/api/tasks/${encodeURIComponent(k)}`);if(!A.ok)throw new Error(`HTTP error! status: ${A.status}`);const R=await A.json();a.value=R.task}catch(A){c.value=A instanceof Error?A.message:"Failed to load task",a.value=null}finally{l.value=!1}},he=k=>{if(!k)return"";const A=new Date(k);return Number.isNaN(A.getTime())?"":A.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})},me=k=>{try{return JSON.stringify(k,null,2)}catch{return String(k)}},Pe=k=>{if(k.status==="success")return"text-green-300";if(k.status==="error")return"text-red-300";if(k.status==="pending")return"text-blue-300";switch(k.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"}},oe=k=>{if(f.value)return;const A=new Set(d.value);A.has(k)?A.delete(k):A.add(k),d.value=A},et=async(k,A={})=>{A.initial&&(h.value=!0);try{const R=await be(`/api/tasks/${encodeURIComponent(k)}/activity`);if(!R.ok)return;const ne=await R.json();u.value=ne.activity??[]}catch{}finally{A.initial&&(h.value=!1)}},ot=k=>{v||(v=setTimeout(()=>{v=null,o.value===k&&et(k)},250))},de=k=>{se(),et(k,{initial:!0});try{g=new EventSource(Pn(`/api/tasks/${encodeURIComponent(k)}/events`)),g.onmessage=()=>{ot(k)},g.onerror=()=>{}}catch{g=null}},se=()=>{g&&(g.close(),g=null),v&&(clearTimeout(v),v=null)},ae=k=>{o.value=k,a.value=null,u.value=[],d.value=new Set,Y(k),de(k)},Ue=()=>{o.value=null,a.value=null,c.value=null,u.value=[],d.value=new Set,se()},Ye=k=>{k.key==="Escape"&&o.value&&Ue()};return rs(o,k=>{k?document.addEventListener("keydown",Ye):document.removeEventListener("keydown",Ye)}),os(()=>{N(),S=setInterval(N,5e3)}),rs(()=>{var k;return(k=a.value)==null?void 0:k.status},k=>{k&&k!=="running"&&(o.value&&et(o.value),se())}),wn(()=>{S&&clearInterval(S),document.removeEventListener("keydown",Ye),se()}),(k,A)=>(_(),w("div",_v,[p("div",wv,[p("div",xv,[A[2]||(A[2]=p("h2",{class:"text-2xl font-bold"},"Agent Activity",-1)),p("button",{onClick:N,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"},O(r.value?"Refreshing...":"Refresh"),9,kv)]),n.value?(_(),w("div",Sv,O(n.value),1)):z("",!0),p("section",Ev,[A[5]||(A[5]=p("h3",{class:"text-lg font-semibold text-gray-200 mb-3"},"Active Agents",-1)),r.value&&e.value.length===0?(_(),w("div",Tv," Loading agents... ")):e.value.length===0?(_(),w("div",Av," No active agents ")):(_(),w("div",Rv,[(_(!0),w(ye,null,Ve(e.value,R=>(_(),w("div",{key:R.slug+(R.characterName||""),class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-blue-500 transition-colors"},[p("div",Cv,[p("div",Ov,[p("h3",$v,O(R.name),1),p("div",Pv,[p("p",Iv,O(R.slug),1),R.roleTitle?(_(),w("span",jv,O(R.roleTitle),1)):z("",!0),R.universe?(_(),w("span",Nv," 🎬 "+O(R.universe),1)):z("",!0),R.model&&R.status==="working"?(_(),w("span",{key:2,class:"text-xs bg-emerald-900 text-emerald-200 px-2 py-0.5 rounded",title:`Model: ${R.model}`}," 🧠 "+O(R.model),9,Lv)):z("",!0)])]),p("span",{class:ge(["px-3 py-1 rounded text-xs font-medium",R.status==="working"?"bg-blue-900 text-blue-100":R.status==="error"?"bg-red-900 text-red-100":"bg-green-900 text-green-100"])},[R.status==="working"?(_(),w("span",Uv)):z("",!0),st(" "+O(R.status==="working"?"Working":R.status==="error"?"Error":"Idle"),1)],2)]),R.currentTask?(_(),w("div",Dv,[A[3]||(A[3]=p("p",{class:"text-xs text-gray-400 mb-1"},"Current Task:",-1)),p("p",Mv,O(R.currentTask),1)])):z("",!0),p("div",Bv,[p("div",Hv," Last updated: "+O(C(new Date)),1),R.status==="working"&&R.currentTaskId?(_(),w("button",{key:0,type:"button",onClick:ne=>D(R.currentTaskId),disabled:i.value.has(R.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"},[A[4]||(A[4]=p("span",{class:"inline-block w-2 h-2 bg-white rounded-sm"},null,-1)),st(" "+O(i.value.has(R.currentTaskId)?"Stopping...":"Stop"),1)],8,Fv)):z("",!0)])]))),128))]))]),p("section",null,[A[6]||(A[6]=p("h3",{class:"text-lg font-semibold text-gray-200 mb-3"},"Recent Activity",-1)),r.value&&s.value.length===0?(_(),w("div",qv," Loading activity... ")):s.value.length===0?(_(),w("div",Vv," No recent activity yet ")):(_(),w("ul",Wv,[(_(!0),w(ye,null,Ve(s.value,R=>(_(),w("li",{key:R.task_id},[p("button",{type:"button",onClick:ne=>ae(R.task_id),class:"w-full text-left p-4 hover:bg-gray-750 focus:bg-gray-750 focus:outline-none transition-colors"},[p("div",Gv,[p("div",Jv,[p("div",zv,[p("span",Yv,O(R.agent_slug),1),R.origin_channel?(_(),w("span",Xv,"via "+O(R.origin_channel),1)):z("",!0)]),p("p",Qv,O(R.description),1),p("p",Zv,[st(" Started "+O(T(R.started_at))+" ",1),R.completed_at?(_(),w("span",e0," · Completed "+O(T(R.completed_at)),1)):z("",!0)])]),p("span",{class:ge(["px-2 py-1 rounded text-xs font-medium whitespace-nowrap",E(R.status)])},O(R.status),3)])],8,Kv)]))),128))]))])]),o.value?(_(),w("div",{key:0,class:"fixed inset-0 bg-black/70 flex items-center justify-center p-4 z-50",onClick:is(Ue,["self"])},[p("div",t0,[p("div",{class:"flex justify-between items-center p-4 border-b border-gray-700"},[A[7]||(A[7]=p("h3",{class:"text-lg font-bold text-gray-100"},"Task Details",-1)),p("button",{type:"button",onClick:Ue,class:"text-gray-400 hover:text-gray-100 text-2xl leading-none focus:outline-none","aria-label":"Close"},"×")]),p("div",s0,[l.value?(_(),w("div",r0,"Loading task...")):c.value?(_(),w("div",n0,O(c.value),1)):a.value?(_(),w(ye,{key:2},[p("div",i0,[p("div",null,[A[8]||(A[8]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Agent",-1)),p("p",o0,O(a.value.agent_slug),1)]),p("span",{class:ge(["px-3 py-1 rounded text-xs font-medium",E(a.value.status)])},O(a.value.status),3)]),p("div",null,[A[9]||(A[9]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Task ID",-1)),p("p",a0,O(a.value.task_id),1)]),a.value.origin_channel?(_(),w("div",l0,[A[10]||(A[10]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Origin",-1)),p("p",c0,O(a.value.origin_channel),1)])):z("",!0),p("div",u0,[p("div",null,[A[11]||(A[11]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Started",-1)),p("p",h0,O(T(a.value.started_at)),1)]),p("div",null,[A[12]||(A[12]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Completed",-1)),p("p",d0,O(a.value.completed_at?T(a.value.completed_at):"—"),1)])]),U.value?(_(),w("div",f0,[A[13]||(A[13]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Duration",-1)),p("p",p0,O(U.value),1)])):z("",!0),p("div",null,[A[14]||(A[14]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Description",-1)),p("pre",g0,O(a.value.description),1)]),p("div",null,[p("div",y0,[A[16]||(A[16]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500"},"Activity",-1)),p("label",m0,[ct(p("input",{type:"checkbox","onUpdate:modelValue":A[0]||(A[0]=R=>f.value=R),class:"rounded bg-gray-700 border-gray-600"},null,512),[[Fl,f.value]]),A[15]||(A[15]=st(" Show details ",-1))])]),h.value&&u.value.length===0?(_(),w("div",v0,"Loading activity…")):u.value.length===0?(_(),w("div",b0,"No activity yet")):(_(),w("ul",_0,[(_(!0),w(ye,null,Ve(u.value,(R,ne)=>(_(),w("li",{key:`${R.ts}-${ne}-${R.rawType}`,class:"px-3 py-2 text-sm hover:bg-gray-750 cursor-pointer",onClick:De=>oe(ne)},[p("div",{class:ge(["flex items-start gap-2",Pe(R)])},[p("span",x0,O(R.icon),1),p("span",k0,O(R.summary),1),p("span",S0,O(he(R.ts)),1)],2),f.value||d.value.has(ne)?(_(),w("div",E0,[R.detail?(_(),w("pre",T0,O(R.detail),1)):z("",!0),p("pre",A0,O(me(R.raw)),1),p("p",R0,O(R.rawType),1)])):z("",!0)],8,w0))),128))]))]),p("div",null,[A[17]||(A[17]=p("p",{class:"text-xs uppercase tracking-wider text-gray-500 mb-1"},"Result",-1)),a.value.result?(_(),w("pre",C0,O(a.value.result),1)):(_(),w("p",O0,"No result yet"))])],64)):z("",!0)]),p("div",$0,[a.value&&a.value.status==="running"?(_(),w("button",{key:0,type:"button",onClick:A[1]||(A[1]=R=>D(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"},O(i.value.has(a.value.task_id)?"Stopping...":"Stop Task"),9,P0)):(_(),w("span",I0)),p("button",{type:"button",onClick:Ue,class:"bg-gray-700 hover:bg-gray-600 text-gray-100 text-sm px-4 py-2 rounded transition-colors"}," Close ")])])])):z("",!0)]))}}),N0=Or(j0,[["__scopeId","data-v-6c7a72da"]]),L0={class:"flex flex-col h-full bg-gray-950"},U0={class:"flex-1 overflow-y-auto p-6"},D0={class:"flex justify-between items-center mb-6"},M0=["disabled"],B0={key:0,class:"text-gray-400 text-center py-12"},H0={key:1,class:"bg-red-900 text-red-100 p-4 rounded-lg mb-4"},F0={open:"",class:"mb-6"},q0={class:"cursor-pointer select-none flex items-center gap-2 text-lg font-semibold text-gray-100 mb-4 py-2 border-b border-gray-700"},V0={class:"ml-2 text-xs font-normal text-gray-500 bg-gray-800 px-2 py-0.5 rounded-full"},W0={key:0,class:"text-gray-500 italic text-sm py-4 text-center"},K0={key:1,class:"grid gap-3"},G0={class:"flex flex-wrap items-start gap-3"},J0={class:"flex-1 min-w-0"},z0={class:"flex flex-wrap items-center gap-2 mb-1"},Y0={class:"font-bold text-gray-100 break-words min-w-0"},X0={class:"flex flex-wrap gap-3 text-sm text-gray-400 mt-1"},Q0={class:"font-mono text-xs bg-gray-900 px-2 py-0.5 rounded break-all"},Z0={title:"Next run",class:"shrink-0"},eb={title:"Last run",class:"shrink-0"},tb={key:0,class:"text-xs text-gray-500 mt-1 break-words"},sb={class:"flex flex-wrap items-center gap-2"},rb=["onClick","disabled"],nb=["onClick","disabled"],ib=["onClick","disabled"],ob=["onClick"],ab=["onClick","disabled"],lb={key:0,class:"mt-3"},cb=["onClick"],ub={key:1,class:"mt-4 pt-4 border-t border-gray-700"},hb={class:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-3"},db={key:0,class:"text-gray-500 text-xs py-2 text-center"},fb={key:1,class:"text-gray-500 italic text-xs py-2 text-center"},pb={key:2,class:"space-y-2"},gb={class:"shrink-0 mt-0.5"},yb={class:"flex-1 min-w-0"},mb={class:"flex flex-wrap items-center gap-2"},vb={class:"text-gray-300"},bb={key:0,class:"text-gray-500 mt-0.5"},_b={key:1,class:"text-red-400 mt-1 break-words"},wb={open:""},xb={class:"cursor-pointer select-none flex items-center gap-2 text-lg font-semibold text-gray-100 mb-4 py-2 border-b border-gray-700"},kb={class:"ml-2 text-xs font-normal text-gray-500 bg-gray-800 px-2 py-0.5 rounded-full"},Sb={key:0,class:"text-gray-500 italic text-sm py-4 text-center"},Eb={key:1,class:"grid gap-3"},Tb={class:"flex flex-wrap items-start gap-3"},Ab={class:"flex-1 min-w-0"},Rb={class:"flex flex-wrap items-center gap-2 mb-1"},Cb={class:"font-bold text-gray-100 break-words min-w-0"},Ob={class:"text-xs text-gray-500 bg-gray-900 px-2 py-0.5 rounded shrink-0"},$b={class:"flex flex-wrap gap-3 text-sm text-gray-400 mt-1"},Pb={class:"font-mono text-xs bg-gray-900 px-2 py-0.5 rounded break-all"},Ib={title:"Next run",class:"shrink-0"},jb={title:"Last run",class:"shrink-0"},Nb={key:0,class:"text-xs text-gray-500 mt-1 break-words"},Lb={class:"flex flex-wrap items-center gap-2"},Ub=["onClick","disabled"],Db=["onClick","disabled"],Mb=["onClick","disabled"],Bb=["onClick"],Hb=["onClick","disabled"],Fb={key:0,class:"mt-3"},qb=["onClick"],Vb={key:1,class:"mt-4 pt-4 border-t border-gray-700"},Wb={class:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-3"},Kb={key:0,class:"text-gray-500 text-xs py-2 text-center"},Gb={key:1,class:"text-gray-500 italic text-xs py-2 text-center"},Jb={key:2,class:"space-y-2"},zb={class:"shrink-0 mt-0.5"},Yb={class:"flex-1 min-w-0"},Xb={class:"flex flex-wrap items-center gap-2"},Qb={class:"text-gray-300"},Zb={key:0,class:"text-gray-500 mt-0.5"},e_={key:1,class:"text-red-400 mt-1 break-words"},t_=dt({__name:"SchedulesView",setup(t){const e=B([]),s=B([]),r=B(!0),n=B(null),i=B(new Set),o=B(new Map),a=B(new Map),l=B(new Set),c=B(new Set);function u(D){const j=D.includes("T")||D.endsWith("Z")?D:D.replace(" ","T")+"Z";return new Date(j).toLocaleString()}function h(D){return D==="done"?"✅":D==="failed"?"❌":"⏳"}function f(D){return D==="done"?"bg-green-900 text-green-200":D==="failed"?"bg-red-900 text-red-200":"bg-gray-700 text-gray-300"}function d(D,j){const b=`${D}-${j}`,N=new Set(c.value);N.has(b)?N.delete(b):N.add(b),c.value=N}async function g(D,j){const b=`${D}-${j}`,N=o.value.get(b)??!1,Y=new Map(o.value);if(Y.set(b,!N),o.value=Y,!N&&!a.value.has(b)){const he=new Set(l.value);he.add(b),l.value=he;try{const me=await be(`/api/schedules/${D}/${j}/runs?limit=25`);if(me.ok){const Pe=await me.json(),oe=new Map(a.value);oe.set(b,Pe.runs??[]),a.value=oe}}catch{}finally{const me=new Set(l.value);me.delete(b),l.value=me}}}async function v(){r.value=!0,n.value=null,a.value=new Map;try{const D=await be("/api/schedules");if(!D.ok)throw new Error(`HTTP ${D.status}`);const j=await D.json();e.value=j.io,s.value=j.squads}catch(D){n.value=D instanceof Error?D.message:"Failed to load schedules"}finally{r.value=!1}}async function S(D,j){if(!i.value.has(D)){i.value=new Set(i.value).add(D);try{await j(),await v()}catch(b){n.value=b instanceof Error?b.message:"Action failed"}finally{const b=new Set(i.value);b.delete(D),i.value=b}}}async function C(D,j){await S(`${D}-${j}`,async()=>{const b=await be(`/api/schedules/${D}/${j}/pause`,{method:"POST"});if(!b.ok)throw new Error(`HTTP ${b.status}`)})}async function T(D,j){await S(`${D}-${j}`,async()=>{const b=await be(`/api/schedules/${D}/${j}/resume`,{method:"POST"});if(!b.ok)throw new Error(`HTTP ${b.status}`)})}async function E(D,j){await S(`${D}-${j}`,async()=>{const b=await be(`/api/schedules/${D}/${j}/run-now`,{method:"POST"});if(!b.ok)throw new Error(`HTTP ${b.status}`)})}async function U(D,j,b){window.confirm(`Delete schedule '${b}'?`)&&await S(`${D}-${j}`,async()=>{const N=await be(`/api/schedules/${D}/${j}`,{method:"DELETE"});if(!N.ok)throw new Error(`HTTP ${N.status}`)})}return os(v),(D,j)=>(_(),w("div",L0,[p("div",U0,[p("div",D0,[j[0]||(j[0]=p("h2",{class:"text-2xl font-bold"},"Schedules",-1)),p("button",{onClick:v,disabled:r.value,class:"bg-gray-700 hover:bg-gray-600 disabled:opacity-50 text-white px-4 py-2 rounded-lg text-sm transition-colors"}," ↻ Refresh ",8,M0)]),r.value?(_(),w("div",B0," Loading schedules... ")):n.value?(_(),w("div",H0,O(n.value),1)):(_(),w(ye,{key:2},[p("details",F0,[p("summary",q0,[j[1]||(j[1]=p("span",{class:"text-gray-400 text-sm"},"▶",-1)),j[2]||(j[2]=st(" 🤖 IO Schedules ",-1)),p("span",V0,O(e.value.length),1)]),e.value.length===0?(_(),w("div",W0," No IO schedules configured. ")):(_(),w("div",K0,[(_(!0),w(ye,null,Ve(e.value,b=>(_(),w("div",{key:b.id,class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-gray-600 transition-colors overflow-hidden"},[p("div",G0,[p("div",J0,[p("div",z0,[p("span",Y0,O(b.name),1),p("span",{class:ge(["px-2 py-0.5 rounded text-xs font-medium shrink-0",b.enabled?"bg-green-900 text-green-200":"bg-gray-700 text-gray-400"])},O(b.enabled?"Active":"Paused"),3)]),p("div",X0,[p("span",Q0,O(b.cron_expr),1),p("span",Z0,"⏭ "+O(b.next_run_at?u(b.next_run_at):"—"),1),p("span",eb,"🕐 "+O(b.last_run_at?u(b.last_run_at):"—"),1)]),b.notes?(_(),w("p",tb,O(b.notes),1)):z("",!0)]),p("div",sb,[b.enabled?(_(),w("button",{key:0,onClick:N=>C("io",b.id),disabled:i.value.has(`io-${b.id}`),class:"bg-gray-700 hover:bg-gray-600 disabled:opacity-50 text-gray-200 text-xs px-3 py-1.5 rounded transition-colors",title:"Pause"},"⏸ Pause",8,rb)):(_(),w("button",{key:1,onClick:N=>T("io",b.id),disabled:i.value.has(`io-${b.id}`),class:"bg-gray-700 hover:bg-gray-600 disabled:opacity-50 text-gray-200 text-xs px-3 py-1.5 rounded transition-colors",title:"Resume"},"▶ Resume",8,nb)),p("button",{onClick:N=>E("io",b.id),disabled:i.value.has(`io-${b.id}`),class:"bg-blue-700 hover:bg-blue-600 disabled:opacity-50 text-white text-xs px-3 py-1.5 rounded transition-colors",title:"Run now"},"▶ Run now",8,ib),p("button",{onClick:N=>g("io",b.id),class:ge(["text-xs px-3 py-1.5 rounded transition-colors",o.value.get(`io-${b.id}`)?"bg-blue-800 text-blue-200":"bg-gray-700 hover:bg-gray-600 text-gray-200"]),title:"Toggle run history"},"📋 History",10,ob),p("button",{onClick:N=>U("io",b.id,b.name),disabled:i.value.has(`io-${b.id}`),class:"bg-red-900 hover:bg-red-800 disabled:opacity-50 text-red-200 text-xs px-3 py-1.5 rounded transition-colors",title:"Delete"},"🗑",8,ab)])]),b.prompt?(_(),w("div",lb,[p("p",{class:ge(["text-xs text-gray-400 break-words",c.value.has(`io-${b.id}`)?"":"line-clamp-2"])},O(b.prompt),3),b.prompt.length>120?(_(),w("button",{key:0,onClick:N=>d("io",b.id),class:"text-[10px] text-blue-400 hover:text-blue-300 mt-1 transition-colors"},O(c.value.has(`io-${b.id}`)?"Show less ▲":"Show more ▼"),9,cb)):z("",!0)])):z("",!0),o.value.get(`io-${b.id}`)?(_(),w("div",ub,[p("h4",hb," Run history — "+O(b.name),1),l.value.has(`io-${b.id}`)?(_(),w("div",db," Loading… ")):!a.value.get(`io-${b.id}`)||a.value.get(`io-${b.id}`).length===0?(_(),w("div",fb," No history yet ")):(_(),w("ul",pb,[(_(!0),w(ye,null,Ve(a.value.get(`io-${b.id}`),N=>(_(),w("li",{key:N.id,class:"flex items-start gap-2 text-xs bg-gray-900 rounded p-2"},[p("span",gb,O(h(N.status)),1),p("div",yb,[p("div",mb,[p("span",vb,O(u(N.started_at)),1),p("span",{class:ge(["px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0",f(N.status)])},O(N.status),3)]),N.completed_at?(_(),w("div",bb," Completed: "+O(u(N.completed_at)),1)):z("",!0),N.error_text?(_(),w("div",_b,O(N.error_text),1)):z("",!0)])]))),128))]))])):z("",!0)]))),128))]))]),p("details",wb,[p("summary",xb,[j[3]||(j[3]=p("span",{class:"text-gray-400 text-sm"},"▶",-1)),j[4]||(j[4]=st(" 👥 Squad Schedules ",-1)),p("span",kb,O(s.value.length),1)]),s.value.length===0?(_(),w("div",Sb," No squad schedules configured. ")):(_(),w("div",Eb,[(_(!0),w(ye,null,Ve(s.value,b=>(_(),w("div",{key:b.id,class:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:border-gray-600 transition-colors overflow-hidden"},[p("div",Tb,[p("div",Ab,[p("div",Rb,[p("span",Cb,O(b.name),1),p("span",Ob,O(b.squad_slug),1),p("span",{class:ge(["px-2 py-0.5 rounded text-xs font-medium shrink-0",b.enabled?"bg-green-900 text-green-200":"bg-gray-700 text-gray-400"])},O(b.enabled?"Active":"Paused"),3)]),p("div",$b,[p("span",Pb,O(b.cron_expr),1),p("span",Ib,"⏭ "+O(b.next_run_at?u(b.next_run_at):"—"),1),p("span",jb,"🕐 "+O(b.last_run_at?u(b.last_run_at):"—"),1)]),b.notes?(_(),w("p",Nb,O(b.notes),1)):z("",!0)]),p("div",Lb,[b.enabled?(_(),w("button",{key:0,onClick:N=>C("squads",b.id),disabled:i.value.has(`squads-${b.id}`),class:"bg-gray-700 hover:bg-gray-600 disabled:opacity-50 text-gray-200 text-xs px-3 py-1.5 rounded transition-colors",title:"Pause"},"⏸ Pause",8,Ub)):(_(),w("button",{key:1,onClick:N=>T("squads",b.id),disabled:i.value.has(`squads-${b.id}`),class:"bg-gray-700 hover:bg-gray-600 disabled:opacity-50 text-gray-200 text-xs px-3 py-1.5 rounded transition-colors",title:"Resume"},"▶ Resume",8,Db)),p("button",{onClick:N=>E("squads",b.id),disabled:i.value.has(`squads-${b.id}`),class:"bg-blue-700 hover:bg-blue-600 disabled:opacity-50 text-white text-xs px-3 py-1.5 rounded transition-colors",title:"Run now"},"▶ Run now",8,Mb),p("button",{onClick:N=>g("squads",b.id),class:ge(["text-xs px-3 py-1.5 rounded transition-colors",o.value.get(`squads-${b.id}`)?"bg-blue-800 text-blue-200":"bg-gray-700 hover:bg-gray-600 text-gray-200"]),title:"Toggle run history"},"📋 History",10,Bb),p("button",{onClick:N=>U("squads",b.id,b.name),disabled:i.value.has(`squads-${b.id}`),class:"bg-red-900 hover:bg-red-800 disabled:opacity-50 text-red-200 text-xs px-3 py-1.5 rounded transition-colors",title:"Delete"},"🗑",8,Hb)])]),b.prompt?(_(),w("div",Fb,[p("p",{class:ge(["text-xs text-gray-400 break-words",c.value.has(`squads-${b.id}`)?"":"line-clamp-2"])},O(b.prompt),3),b.prompt.length>120?(_(),w("button",{key:0,onClick:N=>d("squads",b.id),class:"text-[10px] text-blue-400 hover:text-blue-300 mt-1 transition-colors"},O(c.value.has(`squads-${b.id}`)?"Show less ▲":"Show more ▼"),9,qb)):z("",!0)])):z("",!0),o.value.get(`squads-${b.id}`)?(_(),w("div",Vb,[p("h4",Wb," Run history — "+O(b.name),1),l.value.has(`squads-${b.id}`)?(_(),w("div",Kb," Loading… ")):!a.value.get(`squads-${b.id}`)||a.value.get(`squads-${b.id}`).length===0?(_(),w("div",Gb," No history yet ")):(_(),w("ul",Jb,[(_(!0),w(ye,null,Ve(a.value.get(`squads-${b.id}`),N=>(_(),w("li",{key:N.id,class:"flex items-start gap-2 text-xs bg-gray-900 rounded p-2"},[p("span",zb,O(h(N.status)),1),p("div",Yb,[p("div",Xb,[p("span",Qb,O(u(N.started_at)),1),p("span",{class:ge(["px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0",f(N.status)])},O(N.status),3)]),N.completed_at?(_(),w("div",Zb," Completed: "+O(u(N.completed_at)),1)):z("",!0),N.error_text?(_(),w("div",e_,O(N.error_text),1)):z("",!0)])]))),128))]))])):z("",!0)]))),128))]))])],64))])]))}}),s_={class:"flex flex-col h-full p-6"},r_={class:"flex justify-between items-center mb-4"},n_={key:0,class:"text-gray-400 text-center py-8"},i_={key:1,class:"text-gray-500 text-center py-8"},o_={key:2,class:"space-y-2 overflow-y-auto flex-1"},a_=["onClick"],l_={class:"flex justify-between items-start gap-2"},c_={class:"flex-1 min-w-0"},u_={class:"flex items-center gap-2 mb-1"},h_={key:0,class:"w-2 h-2 bg-blue-400 rounded-full shrink-0"},d_={class:"text-sm font-medium text-gray-100 truncate"},f_={class:"text-xs text-gray-500"},p_={class:"text-xs text-gray-500"},g_=["onClick"],y_=["innerHTML"],m_=dt({__name:"NotificationsView",setup(t){const e=B([]),s=B(!0),r=B(new Set);function n(c){try{const u=c.includes("T")||c.endsWith("Z")?c:c.replace(" ","T")+"Z";return new Date(u).toLocaleString()}catch{return c}}function i(c){const u=new Set(r.value);u.has(c)?u.delete(c):u.add(c),r.value=u}async function o(){try{const c=await be("/api/notifications?limit=100");if(c.ok){const u=await c.json();e.value=u.notifications??[]}}catch{}s.value=!1}async function a(c){try{await be(`/api/notifications/${c}/read`,{method:"POST"});const u=e.value.find(h=>h.id===c);u&&(u.read_at=new Date().toISOString())}catch{}}async function l(){try{await be("/api/notifications/read-all",{method:"POST"});for(const c of e.value)c.read_at||(c.read_at=new Date().toISOString())}catch{}}return os(o),(c,u)=>(_(),w("div",s_,[p("div",r_,[u[0]||(u[0]=p("h2",{class:"text-xl font-bold text-gray-100"},"Notifications",-1)),e.value.length>0?(_(),w("button",{key:0,onClick:l,class:"text-sm text-blue-400 hover:text-blue-300 transition-colors"}," Mark all as read ")):z("",!0)]),s.value?(_(),w("div",n_,"Loading...")):e.value.length===0?(_(),w("div",i_," No notifications yet ")):(_(),w("ul",o_,[(_(!0),w(ye,null,Ve(e.value,h=>{var f;return _(),w("li",{key:h.id,class:ge(["bg-gray-800 border rounded-lg p-4 cursor-pointer transition-colors",h.read_at?"border-gray-700 opacity-60":"border-blue-700"]),onClick:d=>i(h.id)},[p("div",l_,[p("div",c_,[p("div",u_,[h.read_at?z("",!0):(_(),w("span",h_)),p("span",d_,O(h.title),1),p("span",f_,O((f=h.source)==null?void 0:f.type),1)]),p("p",p_,O(n(h.created_at)),1)]),h.read_at?z("",!0):(_(),w("button",{key:0,onClick:is(d=>a(h.id),["stop"]),class:"text-xs text-gray-400 hover:text-white shrink-0",title:"Mark as read"}," ✓ ",8,g_))]),r.value.has(h.id)?(_(),w("div",{key:0,class:"mt-3 text-sm text-gray-300 bg-gray-900 rounded p-3 border border-gray-700 wiki-content",innerHTML:Ee(In)(h.text)},null,8,y_)):z("",!0)],10,a_)}),128))]))]))}}),v_={class:"flex h-full overflow-hidden"},b_={class:"w-72 shrink-0 bg-gray-900 border-r border-gray-800 flex flex-col"},__={class:"p-4 border-b border-gray-800"},w_={class:"flex items-center justify-between mb-3"},x_={class:"text-xs text-gray-500"},k_={key:0,class:"flex-1 flex items-center justify-center"},S_={key:1,class:"flex-1 p-4"},E_={class:"text-sm text-red-400"},T_={key:2,class:"flex-1 overflow-y-auto py-2"},A_={key:0,class:"px-4 py-3 text-sm text-gray-500"},R_=["onClick"],C_={class:"flex-1 min-w-0 flex flex-col bg-gray-950 overflow-hidden"},O_={key:0,class:"flex-1 flex items-center justify-center"},$_={key:1,class:"flex-1 flex items-center justify-center"},P_={key:2,class:"flex-1 p-6"},I_={class:"text-sm text-red-400"},j_={key:3,class:"flex-1 overflow-y-auto p-6"},N_={class:"text-xl font-bold text-gray-100 mb-4 pb-3 border-b border-gray-800"},L_=["innerHTML"],U_=dt({__name:"WikiView",setup(t){const e=B([]),s=B(null),r=B(""),n=B(""),i=B(!1),o=B(!1),a=B(""),l=B(""),c=Ne(()=>{const d=n.value.trim().toLowerCase();return d?e.value.filter(g=>g.title.toLowerCase().includes(d)):e.value}),u=Ne(()=>In(r.value));async function h(){i.value=!0,a.value="";try{const d=await be("/api/wiki");if(!d.ok)throw new Error(`HTTP ${d.status}`);const g=await d.json();e.value=g.pages??[]}catch(d){a.value=d instanceof Error?d.message:"Failed to load pages"}finally{i.value=!1}}async function f(d){var g;if(((g=s.value)==null?void 0:g.path)!==d.path){s.value=d,r.value="",o.value=!0,l.value="";try{const v=await be(`/api/wiki/${encodeURIComponent(d.path)}`);if(!v.ok)throw new Error(`HTTP ${v.status}`);const S=await v.json();r.value=S.content??""}catch(v){l.value=v instanceof Error?v.message:"Failed to load page"}finally{o.value=!1}}}return os(h),(d,g)=>(_(),w("div",v_,[p("div",b_,[p("div",__,[p("div",w_,[g[1]||(g[1]=p("h2",{class:"text-sm font-semibold text-gray-300"},"📚 Wiki",-1)),p("span",x_,O(c.value.length)+" pages",1)]),ct(p("input",{"onUpdate:modelValue":g[0]||(g[0]=v=>n.value=v),type:"text",placeholder:"Filter pages…",class:"w-full px-3 py-1.5 text-sm bg-gray-800 border border-gray-700 rounded text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500"},null,512),[[It,n.value]])]),i.value?(_(),w("div",k_,[...g[2]||(g[2]=[p("span",{class:"text-sm text-gray-500"},"Loading…",-1)])])):a.value?(_(),w("div",S_,[p("p",E_,O(a.value),1)])):(_(),w("ul",T_,[c.value.length===0?(_(),w("li",A_," No pages found. ")):z("",!0),(_(!0),w(ye,null,Ve(c.value,v=>{var S;return _(),w("li",{key:v.path,onClick:C=>f(v),class:ge(["px-4 py-2 cursor-pointer text-sm transition-colors hover:bg-gray-800",((S=s.value)==null?void 0:S.path)===v.path?"bg-blue-900 text-blue-300 font-medium":"text-gray-300"])},O(v.title),11,R_)}),128))]))]),p("div",C_,[s.value?o.value?(_(),w("div",$_,[...g[4]||(g[4]=[p("span",{class:"text-sm text-gray-500"},"Loading…",-1)])])):l.value?(_(),w("div",P_,[p("p",I_,O(l.value),1)])):(_(),w("div",j_,[p("h1",N_,O(s.value.title),1),p("div",{class:"wiki-content text-gray-300 text-sm leading-relaxed",innerHTML:u.value},null,8,L_)])):(_(),w("div",O_,[...g[3]||(g[3]=[p("p",{class:"text-gray-600 text-sm"},"Select a page to view",-1)])]))])]))}}),D_=Or(U_,[["__scopeId","data-v-bc46a605"]]),M_={class:"flex items-center justify-center h-screen bg-gray-950"},B_={class:"w-full max-w-sm p-8 bg-gray-900 rounded-xl border border-gray-800"},H_={key:0,class:"text-red-400 text-sm"},F_=["disabled"],q_=dt({__name:"LoginView",setup(t){const e=Cr(),s=cc(),r=B(""),n=B(""),i=B(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)=>(_(),w("div",M_,[p("div",B_,[l[4]||(l[4]=p("h1",{class:"text-2xl font-bold text-white text-center mb-2"},"IO",-1)),l[5]||(l[5]=p("p",{class:"text-gray-400 text-sm text-center mb-8"},"Sign in to continue",-1)),p("form",{onSubmit:is(o,["prevent"]),class:"space-y-4"},[p("div",null,[l[2]||(l[2]=p("label",{for:"email",class:"block text-sm font-medium text-gray-300 mb-1"},"Email",-1)),ct(p("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),[[It,r.value]])]),p("div",null,[l[3]||(l[3]=p("label",{for:"password",class:"block text-sm font-medium text-gray-300 mb-1"},"Password",-1)),ct(p("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),[[It,n.value]])]),i.value?(_(),w("div",H_,O(i.value),1)):z("",!0),p("button",{type:"submit",disabled:Ee(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"},O(Ee(e).loading?"Signing in...":"Sign in"),9,F_)],32)])]))}}),Ic=pf({history:Gd("/"),routes:[{path:"/",redirect:"/chat"},{path:"/login",name:"login",component:q_,meta:{public:!0}},{path:"/chat",name:"chat",component:Fy},{path:"/skills",name:"skills",component:wm},{path:"/squads",name:"squads",component:bv},{path:"/activity",name:"activity",component:N0},{path:"/wiki",name:"wiki",component:D_},{path:"/schedules",name:"schedules",component:t_},{path:"/notifications",name:"notifications",component:m_}]});Ic.beforeEach(async t=>{const e=Cr();return e.initialized||await e.init(),!e.authEnabled||t.meta.public||e.user?!0:{name:"login"}});const Yi=td(Ry);Yi.use(nd());Yi.use(Ic);Yi.mount("#app");
|