From b07c78df0ed865b3babefef146602283da3c466c Mon Sep 17 00:00:00 2001 From: csae8092 Date: Fri, 1 Mar 2024 09:58:52 +0100 Subject: [PATCH] added legend and test for network view --- dumper/templates/dumper/network.html | 19 ++++++++++++++++++- dumper/tests.py | 5 +++++ dumper/views.py | 19 +++++++++++++++++++ pmb/urls.py | 4 +++- static/src/js/main.js | 2 ++ ...rowser-Co2CjrBv.js => browser-C1tfp1OT.js} | 2 +- .../{main-BgjuSik3.js => main-CE-ujooY.js} | 4 ++-- static/vite/manifest.info | 8 ++++---- 8 files changed, 54 insertions(+), 9 deletions(-) rename static/vite/{browser-Co2CjrBv.js => browser-C1tfp1OT.js} (88%) rename static/vite/{main-BgjuSik3.js => main-CE-ujooY.js} (99%) diff --git a/dumper/templates/dumper/network.html b/dumper/templates/dumper/network.html index 9a11baa..b428538 100644 --- a/dumper/templates/dumper/network.html +++ b/dumper/templates/dumper/network.html @@ -24,7 +24,24 @@

Netzwerk aller Verbindungen

Lade die Netzwerkdaten... +
+
+ +
+
+
-
+
+
+ + {% endblock %} \ No newline at end of file diff --git a/dumper/tests.py b/dumper/tests.py index 49903ad..46f6118 100644 --- a/dumper/tests.py +++ b/dumper/tests.py @@ -72,3 +72,8 @@ def test_09_imprint(self): url = reverse("dumper:export") response = client.get(url) self.assertEqual(response.status_code, 200) + + def test_10_network(self): + url = reverse("dumper:network") + response = client.get(url) + self.assertEqual(response.status_code, 200) diff --git a/dumper/views.py b/dumper/views.py index 91f04c1..6d7e29c 100644 --- a/dumper/views.py +++ b/dumper/views.py @@ -1,3 +1,5 @@ +from typing import Any +from django.apps import apps from django.contrib.auth import authenticate, login, logout from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render @@ -29,6 +31,23 @@ class ExportView(TemplateView): class NetworkView(TemplateView): template_name = "dumper/network.html" + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: + context = super().get_context_data(**kwargs) + MODELS = list(apps.all_models["apis_entities"].values()) + model_list = [] + for x in MODELS: + try: + item = { + "color": x.get_color(), + "icon": x.get_icon(), + "name": x._meta.verbose_name, + } + except AttributeError: + continue + model_list.append(item) + context["model_list"] = model_list + return context + class ImprintView(TemplateView): template_name = "dumper/imprint.html" diff --git a/pmb/urls.py b/pmb/urls.py index c6e3617..f2aab5c 100644 --- a/pmb/urls.py +++ b/pmb/urls.py @@ -23,4 +23,6 @@ ) if settings.DEBUG: - urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file + urlpatterns = urlpatterns + static( + settings.MEDIA_URL, document_root=settings.MEDIA_ROOT + ) diff --git a/static/src/js/main.js b/static/src/js/main.js index 225e667..43bed7e 100644 --- a/static/src/js/main.js +++ b/static/src/js/main.js @@ -7,6 +7,7 @@ const node_csv = "/media/nodes.csv"; const edge_promis = d3.csv(edge_csv); const node_promis = d3.csv(node_csv); const spinnerNode = document.getElementById("spinner"); +const legendNode = document.getElementById("legend"); const canvas = document.createElement("div"); canvas.style.height = "800px" @@ -27,6 +28,7 @@ Promise.all([edge_promis, node_promis]).then(([edge_data, node_data]) => { // remove spinner spinnerNode.style.visibility = "hidden"; + legendNode.style.visibility = "visible"; appNode.appendChild(canvas); const searchContainer = document.createElement('div') appNode.appendChild(searchContainer); diff --git a/static/vite/browser-Co2CjrBv.js b/static/vite/browser-C1tfp1OT.js similarity index 88% rename from static/vite/browser-Co2CjrBv.js rename to static/vite/browser-C1tfp1OT.js index 7426369..bfa8ba3 100644 --- a/static/vite/browser-Co2CjrBv.js +++ b/static/vite/browser-C1tfp1OT.js @@ -1 +1 @@ -import{g as a}from"./main-BgjuSik3.js";function f(t,s){for(var o=0;oe[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var c=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")};const i=a(c),u=f({__proto__:null,default:i},[c]);export{u as b}; +import{g as a}from"./main-CE-ujooY.js";function f(t,s){for(var o=0;oe[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var c=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")};const i=a(c),u=f({__proto__:null,default:i},[c]);export{u as b}; diff --git a/static/vite/main-BgjuSik3.js b/static/vite/main-CE-ujooY.js similarity index 99% rename from static/vite/main-BgjuSik3.js rename to static/vite/main-CE-ujooY.js index 244ad81..5421aeb 100644 --- a/static/vite/main-BgjuSik3.js +++ b/static/vite/main-CE-ujooY.js @@ -939,11 +939,11 @@ uniform sampler2D position;uniform sampler2D trackedIndices;uniform float points
${ot.join("")}
- `}return Oe(String(V),!0)})((C=>{const Q={},V=Object.keys(C),ne=K.accessor(C);if(ne&&(Q[K.label]=ne),!m.ordering||!m.ordering.order&&!m.ordering.include){const Ge=Object.entries(C).findIndex(([tt,ot])=>K.accessor({[tt]:ot}));Ge!==-1&&V.splice(Ge,1);for(const tt of V)Q[tt]=C[tt];return Q}const Ve=m.ordering.order||[];let Re=m.ordering.include?new Set(m.ordering.include):null;if(Re||(Re=new Set(V)),Ve.length>0)for(const Ge of Ve)Ge in C&&(Q[Ge]=C[Ge]);for(const Ge in C)!Object.prototype.hasOwnProperty.call(Q,Ge)&&Re.has(Ge)&&(Q[Ge]=C[Ge]);return Q})(N)),N=>{N.preventDefault()},p,N=>{f==null||f.setOpen(N)},n,a,function(N){Ft[N?"unshift":"push"](()=>{s=N,t(5,s)})},function(N){y=N,t(0,y)},function(N){r=N,t(12,r),t(21,p),t(2,E),t(1,m),t(3,k)},function(N){Ft[N?"unshift":"push"](()=>{l=N,t(6,l)})},function(N){k=N,t(3,k)},function(N){Ft[N?"unshift":"push"](()=>{f=N,t(10,f)})},function(N){Ft[N?"unshift":"push"](()=>{d=N,t(7,d)})}]}class zA extends hr{constructor(e){super(),fr(this,e,MA,NA,Zi,{config:1,data:21,textInput:0,setListState:22},null,[-1,-1])}get setListState(){return this.$$.ctx[22]}}let BA=class{constructor(e,t){this._config={},this._containerNode=e,this._config=La(Ss,t!=null?t:{}),this._search=new zA({target:e,props:{config:this._config}}),this._search.$on(cn.Input,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onSearch)===null||a===void 0?void 0:a.call(n,r)}),this._search.$on(cn.Select,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onSelect)===null||a===void 0?void 0:a.call(n,r)}),this._search.$on(cn.Enter,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onEnter)===null||a===void 0?void 0:a.call(n,r)}),this._search.$on(cn.AccessorSelect,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onAccessorSelect)===null||a===void 0?void 0:a.call(n,r)})}setData(e){this._search.$set({data:e,textInput:""})}setConfig(e){this._config=La(Ss,e!=null?e:{}),this._search.$set({config:this._config,textInput:""})}setListState(e){this._search.setListState(e)}clearInput(){this._search.$set({textInput:""})}getConfig(){return this._config}destroy(){this._containerNode.innerHTML=""}};const UA='',GA="modulepreload",jA=function(i){return"/static/"+i},Qp={},Do=function(e,t,r){let n=Promise.resolve();if(t&&t.length>0){const a=document.getElementsByTagName("link");n=Promise.all(t.map(o=>{if(o=jA(o),o in Qp)return;Qp[o]=!0;const s=o.endsWith(".css"),l=s?'[rel="stylesheet"]':"";if(!!r)for(let u=a.length-1;u>=0;u--){const f=a[u];if(f.href===o&&(!s||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${l}`))return;const c=document.createElement("link");if(c.rel=s?"stylesheet":GA,s||(c.as="script",c.crossOrigin=""),c.href=o,document.head.appendChild(c),s)return new Promise((u,f)=>{c.addEventListener("load",u),c.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${o}`)))})}))}return n.then(()=>e()).catch(a=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a})},VA=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=(...t)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)};class qu extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}}class HA extends qu{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class qA extends qu{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class WA extends qu{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var XA=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};class YA{constructor(e,{headers:t={},customFetch:r}={}){this.url=e,this.headers=t,this.fetch=VA(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r;return XA(this,void 0,void 0,function*(){try{const{headers:n,method:a,body:o}=t;let s={},l;o&&(n&&!Object.prototype.hasOwnProperty.call(n,"Content-Type")||!n)&&(typeof Blob!="undefined"&&o instanceof Blob||o instanceof ArrayBuffer?(s["Content-Type"]="application/octet-stream",l=o):typeof o=="string"?(s["Content-Type"]="text/plain",l=o):typeof FormData!="undefined"&&o instanceof FormData?l=o:(s["Content-Type"]="application/json",l=JSON.stringify(o)));const d=yield this.fetch(`${this.url}/${e}`,{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},s),this.headers),n),body:l}).catch(m=>{throw new HA(m)}),c=d.headers.get("x-relay-error");if(c&&c==="true")throw new qA(d);if(!d.ok)throw new WA(d);let u=((r=d.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),f;return u==="application/json"?f=yield d.json():u==="application/octet-stream"?f=yield d.blob():u==="multipart/form-data"?f=yield d.formData():f=yield d.text(),{data:f,error:null}}catch(n){return{data:null,error:n}}})}}var ZA=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("unable to locate global object")},Mo=ZA();const KA=Mo.fetch,Wu=Mo.fetch.bind(Mo),Y0=Mo.Headers,JA=Mo.Request,QA=Mo.Response,Bs=Object.freeze(Object.defineProperty({__proto__:null,Headers:Y0,Request:JA,Response:QA,default:Wu,fetch:KA},Symbol.toStringTag,{value:"Module"}));class e4 extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}class t4{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch=="undefined"?this.fetch=Wu:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const r=this.fetch;let n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(a=>fe(this,null,function*(){var o,s,l;let d=null,c=null,u=null,f=a.status,m=a.statusText;if(a.ok){if(this.method!=="HEAD"){const E=yield a.text();E===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?c=E:c=JSON.parse(E))}const y=(o=this.headers.Prefer)===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),x=(s=a.headers.get("content-range"))===null||s===void 0?void 0:s.split("/");y&&x&&x.length>1&&(u=parseInt(x[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(c)&&(c.length>1?(d={code:"PGRST116",details:`Results contain ${c.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},c=null,u=null,f=406,m="Not Acceptable"):c.length===1?c=c[0]:c=null)}else{const y=yield a.text();try{d=JSON.parse(y),Array.isArray(d)&&a.status===404&&(c=[],d=null,f=200,m="OK")}catch(x){a.status===404&&y===""?(f=204,m="No Content"):d={message:y}}if(d&&this.isMaybeSingle&&(!((l=d==null?void 0:d.details)===null||l===void 0)&&l.includes("0 rows"))&&(d=null,f=200,m="OK"),d&&this.shouldThrowOnError)throw new e4(d)}return{error:d,data:c,count:u,status:f,statusText:m}}));return this.shouldThrowOnError||(n=n.catch(a=>{var o,s,l;return{error:{message:`${(o=a==null?void 0:a.name)!==null&&o!==void 0?o:"FetchError"}: ${a==null?void 0:a.message}`,details:`${(s=a==null?void 0:a.stack)!==null&&s!==void 0?s:""}`,hint:"",code:`${(l=a==null?void 0:a.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}}class i4 extends t4{select(e){let t=!1;const r=(e!=null?e:"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:a=n}={}){const o=a?`${a}.order`:"order",s=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${s?`${s},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){const n=typeof r=="undefined"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){const a=typeof n=="undefined"?"offset":`${n}.offset`,o=typeof n=="undefined"?"limit":`${n}.limit`;return this.url.searchParams.set(a,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:a=!1,format:o="text"}={}){var s;const l=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,a?"wal":null].filter(Boolean).join("|"),d=(s=this.headers.Accept)!==null&&s!==void 0?s:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${d}"; options=${l};`,o==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class vo extends i4{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=t.map(n=>typeof n=="string"&&new RegExp("[,()]").test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let a="";n==="plain"?a="pl":n==="phrase"?a="ph":n==="websearch"&&(a="w");const o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${a}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){const n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}}class r4{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=t,this.schema=r,this.fetch=n}select(e,{head:t=!1,count:r}={}){const n=t?"HEAD":"GET";let a=!1;const o=(e!=null?e:"*").split("").map(s=>/\s/.test(s)&&!a?"":(s==='"'&&(a=!a),s)).join("");return this.url.searchParams.set("select",o),r&&(this.headers.Prefer=`count=${r}`),new vo({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:r=!0}={}){const n="POST",a=[];if(this.headers.Prefer&&a.push(this.headers.Prefer),t&&a.push(`count=${t}`),r||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){const o=e.reduce((s,l)=>s.concat(Object.keys(l)),[]);if(o.length>0){const s=[...new Set(o)].map(l=>`"${l}"`);this.url.searchParams.set("columns",s.join(","))}}return new vo({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:a=!0}={}){const o="POST",s=[`resolution=${r?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&s.push(this.headers.Prefer),n&&s.push(`count=${n}`),a||s.push("missing=default"),this.headers.Prefer=s.join(","),Array.isArray(e)){const l=e.reduce((d,c)=>d.concat(Object.keys(c)),[]);if(l.length>0){const d=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",d.join(","))}}return new vo({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const r="PATCH",n=[];return this.headers.Prefer&&n.push(this.headers.Prefer),t&&n.push(`count=${t}`),this.headers.Prefer=n.join(","),new vo({method:r,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t="DELETE",r=[];return e&&r.push(`count=${e}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new vo({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const n4="1.9.2",a4={"X-Client-Info":`postgrest-js/${n4}`};class Xu{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=Object.assign(Object.assign({},a4),t),this.schemaName=r,this.fetch=n}from(e){const t=new URL(`${this.url}/${e}`);return new r4(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new Xu(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:n}={}){let a;const o=new URL(`${this.url}/rpc/${e}`);let s;r?(a="HEAD",Object.entries(t).forEach(([d,c])=>{o.searchParams.append(d,`${c}`)})):(a="POST",s=t);const l=Object.assign({},this.headers);return n&&(l.Prefer=`count=${n}`),new vo({method:a,url:o,headers:l,schema:this.schemaName,body:s,fetch:this.fetch,allowEmpty:!1})}}const o4="2.9.3",s4={"X-Client-Info":`realtime-js/${o4}`},l4="1.0.0",Z0=1e4,d4=1e3;var Io;(function(i){i[i.connecting=0]="connecting",i[i.open=1]="open",i[i.closing=2]="closing",i[i.closed=3]="closed"})(Io||(Io={}));var Fr;(function(i){i.closed="closed",i.errored="errored",i.joined="joined",i.joining="joining",i.leaving="leaving"})(Fr||(Fr={}));var Wr;(function(i){i.close="phx_close",i.error="phx_error",i.join="phx_join",i.reply="phx_reply",i.leave="phx_leave",i.access_token="access_token"})(Wr||(Wr={}));var bu;(function(i){i.websocket="websocket"})(bu||(bu={}));var wa;(function(i){i.Connecting="connecting",i.Open="open",i.Closing="closing",i.Closed="closed"})(wa||(wa={}));class K0{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}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))}}class c4{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const n=t.getUint8(1),a=t.getUint8(2);let o=this.HEADER_LENGTH+2;const s=r.decode(e.slice(o,o+n));o=o+n;const l=r.decode(e.slice(o,o+a));o=o+a;const d=JSON.parse(r.decode(e.slice(o,e.byteLength)));return{ref:null,topic:s,event:l,payload:d}}}class Bc{constructor(e,t,r={},n=Z0){this.channel=e,this.event=t,this.payload=r,this.timeout=n,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,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()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var eg;(function(i){i.SYNC="sync",i.JOIN="join",i.LEAVE="leave"})(eg||(eg={}));class Ts{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},n=>{const{onJoin:a,onLeave:o,onSync:s}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Ts.syncState(this.state,n,a,o),this.pendingDiffs.forEach(l=>{this.state=Ts.syncDiff(this.state,l,a,o)}),this.pendingDiffs=[],s()}),this.channel._on(r.diff,{},n=>{const{onJoin:a,onLeave:o,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=Ts.syncDiff(this.state,n,a,o),s())}),this.onJoin((n,a,o)=>{this.channel._trigger("presence",{event:"join",key:n,currentPresences:a,newPresences:o})}),this.onLeave((n,a,o)=>{this.channel._trigger("presence",{event:"leave",key:n,currentPresences:a,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,n){const a=this.cloneDeep(e),o=this.transformState(t),s={},l={};return this.map(a,(d,c)=>{o[d]||(l[d]=c)}),this.map(o,(d,c)=>{const u=a[d];if(u){const f=c.map(x=>x.presence_ref),m=u.map(x=>x.presence_ref),p=c.filter(x=>m.indexOf(x.presence_ref)<0),y=u.filter(x=>f.indexOf(x.presence_ref)<0);p.length>0&&(s[d]=p),y.length>0&&(l[d]=y)}else s[d]=c}),this.syncDiff(a,{joins:s,leaves:l},r,n)}static syncDiff(e,t,r,n){const{joins:a,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),n||(n=()=>{}),this.map(a,(s,l)=>{var d;const c=(d=e[s])!==null&&d!==void 0?d:[];if(e[s]=this.cloneDeep(l),c.length>0){const u=e[s].map(m=>m.presence_ref),f=c.filter(m=>u.indexOf(m.presence_ref)<0);e[s].unshift(...f)}r(s,c,l)}),this.map(o,(s,l)=>{let d=e[s];if(!d)return;const c=l.map(u=>u.presence_ref);d=d.filter(u=>c.indexOf(u.presence_ref)<0),e[s]=d,n(s,d,l),d.length===0&&delete e[s]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,r)=>{const n=e[r];return"metas"in n?t[r]=n.metas.map(a=>(a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a)):t[r]=n,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var gi;(function(i){i.abstime="abstime",i.bool="bool",i.date="date",i.daterange="daterange",i.float4="float4",i.float8="float8",i.int2="int2",i.int4="int4",i.int4range="int4range",i.int8="int8",i.int8range="int8range",i.json="json",i.jsonb="jsonb",i.money="money",i.numeric="numeric",i.oid="oid",i.reltime="reltime",i.text="text",i.time="time",i.timestamp="timestamp",i.timestamptz="timestamptz",i.timetz="timetz",i.tsrange="tsrange",i.tstzrange="tstzrange"})(gi||(gi={}));const tg=(i,e,t={})=>{var r;const n=(r=t.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((a,o)=>(a[o]=u4(o,i,e,n),a),{})},u4=(i,e,t,r)=>{const n=e.find(s=>s.name===i),a=n==null?void 0:n.type,o=t[i];return a&&!r.includes(a)?J0(a,o):_u(o)},J0=(i,e)=>{if(i.charAt(0)==="_"){const t=i.slice(1,i.length);return p4(e,t)}switch(i){case gi.bool:return f4(e);case gi.float4:case gi.float8:case gi.int2:case gi.int4:case gi.int8:case gi.numeric:case gi.oid:return h4(e);case gi.json:case gi.jsonb:return m4(e);case gi.timestamp:return g4(e);case gi.abstime:case gi.date:case gi.daterange:case gi.int4range:case gi.int8range:case gi.money:case gi.reltime:case gi.text:case gi.time:case gi.timestamptz:case gi.timetz:case gi.tsrange:case gi.tstzrange:return _u(e);default:return _u(e)}},_u=i=>i,f4=i=>{switch(i){case"t":return!0;case"f":return!1;default:return i}},h4=i=>{if(typeof i=="string"){const e=parseFloat(i);if(!Number.isNaN(e))return e}return i},m4=i=>{if(typeof i=="string")try{return JSON.parse(i)}catch(e){return console.log(`JSON parse error: ${e}`),i}return i},p4=(i,e)=>{if(typeof i!="string")return i;const t=i.length-1,r=i[t];if(i[0]==="{"&&r==="}"){let a;const o=i.slice(1,t);try{a=JSON.parse("["+o+"]")}catch(s){a=o?o.split(","):[]}return a.map(s=>J0(e,s))}return i},g4=i=>typeof i=="string"?i.replace(" ","T"):i;var ig;(function(i){i.ALL="*",i.INSERT="INSERT",i.UPDATE="UPDATE",i.DELETE="DELETE"})(ig||(ig={}));var rg;(function(i){i.BROADCAST="broadcast",i.PRESENCE="presence",i.POSTGRES_CHANGES="postgres_changes"})(rg||(rg={}));var ng;(function(i){i.SUBSCRIBED="SUBSCRIBED",i.TIMED_OUT="TIMED_OUT",i.CLOSED="CLOSED",i.CHANNEL_ERROR="CHANNEL_ERROR"})(ng||(ng={}));class Yu{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=Fr.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new Bc(this,Wr.join,this.params,this.timeout),this.rejoinTimer=new K0(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Fr.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(n=>n.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Fr.closed,this.socket._remove(this)}),this._onError(n=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,n),this.state=Fr.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Fr.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Wr.reply,{},(n,a)=>{this._trigger(this._replyEventName(a),n)}),this.presence=new Ts(this),this.broadcastEndpointURL=this._broadcastEndpointURL()}subscribe(e,t=this.timeout){var r,n;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:a,presence:o}}=this.params;this._onError(d=>e&&e("CHANNEL_ERROR",d)),this._onClose(()=>e&&e("CLOSED"));const s={},l={broadcast:a,presence:o,postgres_changes:(n=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(d=>d.filter))!==null&&n!==void 0?n:[]};this.socket.accessToken&&(s.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:l},s)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",({postgres_changes:d})=>{var c;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),d===void 0){e&&e("SUBSCRIBED");return}else{const u=this.bindings.postgres_changes,f=(c=u==null?void 0:u.length)!==null&&c!==void 0?c:0,m=[];for(let p=0;p{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(d).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}track(r){return fe(this,arguments,function*(e,t={}){return yield this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)})}untrack(){return fe(this,arguments,function*(e={}){return yield this.send({type:"presence",event:"untrack"},e)})}on(e,t,r){return this._on(e,t,r)}send(r){return fe(this,arguments,function*(e,t={}){var n,a;if(!this._canPush()&&e.type==="broadcast"){const{event:o,payload:s}=e,l={method:"POST",headers:{apikey:(n=this.socket.apiKey)!==null&&n!==void 0?n:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:s}]})};try{return(yield this._fetchWithTimeout(this.broadcastEndpointURL,l,(a=t.timeout)!==null&&a!==void 0?a:this.timeout)).ok?"ok":"error"}catch(d){return d.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var s,l,d;const c=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((d=(l=(s=this.params)===null||s===void 0?void 0:s.config)===null||l===void 0?void 0:l.broadcast)===null||d===void 0)&&d.ack)&&o("ok"),c.receive("ok",()=>o("ok")),c.receive("timeout",()=>o("timed out"))})})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Fr.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Wr.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{const n=new Bc(this,Wr.leave,{},e);n.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),n.send(),this._canPush()||n.trigger("ok",{})})}_broadcastEndpointURL(){let e=this.socket.endPoint;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"}_fetchWithTimeout(e,t,r){return fe(this,null,function*(){const n=new AbortController,a=setTimeout(()=>n.abort(),r),o=yield this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}));return clearTimeout(a),o})}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let n=new Bc(this,e,t,r);return this._canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var n,a;const o=e.toLocaleLowerCase(),{close:s,error:l,leave:d,join:c}=Wr;if(r&&[s,l,d,c].indexOf(o)>=0&&r!==this._joinRef())return;let f=this._onMessage(o,t,r);if(t&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(n=this.bindings.postgres_changes)===null||n===void 0||n.filter(m=>{var p,y,x;return((p=m.filter)===null||p===void 0?void 0:p.event)==="*"||((x=(y=m.filter)===null||y===void 0?void 0:y.event)===null||x===void 0?void 0:x.toLocaleLowerCase())===o}).map(m=>m.callback(f,r)):(a=this.bindings[o])===null||a===void 0||a.filter(m=>{var p,y,x,E,k,I;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in m){const v=m.id,M=(p=m.filter)===null||p===void 0?void 0:p.event;return v&&((y=t.ids)===null||y===void 0?void 0:y.includes(v))&&(M==="*"||(M==null?void 0:M.toLocaleLowerCase())===((x=t.data)===null||x===void 0?void 0:x.type.toLocaleLowerCase()))}else{const v=(k=(E=m==null?void 0:m.filter)===null||E===void 0?void 0:E.event)===null||k===void 0?void 0:k.toLocaleLowerCase();return v==="*"||v===((I=t==null?void 0:t.event)===null||I===void 0?void 0:I.toLocaleLowerCase())}else return m.type.toLocaleLowerCase()===o}).map(m=>{if(typeof f=="object"&&"ids"in f){const p=f.data,{schema:y,table:x,commit_timestamp:E,type:k,errors:I}=p;f=Object.assign(Object.assign({},{schema:y,table:x,commit_timestamp:E,eventType:k,new:{},old:{},errors:I}),this._getPayloadRecords(p))}m.callback(f,r)})}_isClosed(){return this.state===Fr.closed}_isJoined(){return this.state===Fr.joined}_isJoining(){return this.state===Fr.joining}_isLeaving(){return this.state===Fr.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){const n=e.toLocaleLowerCase(),a={type:n,filter:t,callback:r};return this.bindings[n]?this.bindings[n].push(a):this.bindings[n]=[a],this}_off(e,t){const r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(n=>{var a;return!(((a=n.type)===null||a===void 0?void 0:a.toLocaleLowerCase())===r&&Yu.isEqual(n.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(Wr.close,{},e)}_onError(e){this._on(Wr.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Fr.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=tg(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=tg(e.columns,e.old_record)),t}}const v4=()=>{},b4=typeof WebSocket!="undefined";class _4{constructor(e,t){var r;this.accessToken=null,this.apiKey=null,this.channels=[],this.endPoint="",this.headers=s4,this.params={},this.timeout=Z0,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=v4,this.conn=null,this.sendBuffer=[],this.serializer=new c4,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this._resolveFetch=a=>{let o;return a?o=a:typeof fetch=="undefined"?o=(...s)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:l})=>l(...s)):o=fetch,(...s)=>o(...s)},this.endPoint=`${e}/${bu.websocket}`,t!=null&&t.transport?this.transport=t.transport:this.transport=null,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const n=(r=t==null?void 0:t.params)===null||r===void 0?void 0:r.apikey;n&&(this.accessToken=n,this.apiKey=n),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:a=>[1e3,2e3,5e3,1e4][a-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(a,o)=>o(JSON.stringify(a)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new K0(()=>fe(this,null,function*(){this.disconnect(),this.connect()}),this.reconnectAfterMs),this.fetch=this._resolveFetch(t==null?void 0:t.fetch)}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this._endPointURL(),void 0,{headers:this.headers});return}if(b4){this.conn=new WebSocket(this._endPointURL()),this.setupConnection();return}this.conn=new y4(this._endPointURL(),void 0,{close:()=>{this.conn=null}}),Do(()=>import("./browser-Co2CjrBv.js").then(e=>e.b),__vite__mapDeps([])).then(({default:e})=>{this.conn=new e(this._endPointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t!=null?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}removeChannel(e){return fe(this,null,function*(){const t=yield e.unsubscribe();return this.channels.length===0&&this.disconnect(),t})}removeAllChannels(){return fe(this,null,function*(){const e=yield Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e})}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case Io.connecting:return wa.Connecting;case Io.open:return wa.Open;case Io.closing:return wa.Closing;default:return wa.Closed}}isConnected(){return this.connectionState()===wa.Open}channel(e,t={config:{}}){const r=new Yu(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){const{topic:t,event:r,payload:n,ref:a}=e,o=()=>{this.encode(e,s=>{var l;(l=this.conn)===null||l===void 0||l.send(s)})};this.log("push",`${t} ${r} (${a})`,n),this.isConnected()?o():this.sendBuffer.push(o)}setAuth(e){this.accessToken=e,this.channels.forEach(t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(Wr.access_token,{access_token:e})})}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:l4}))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:r,event:n,payload:a,ref:o}=t;(o&&o===this.pendingHeartbeatRef||n===(a==null?void 0:a.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${a.status||""} ${r} ${n} ${o&&"("+o+")"||""}`,a),this.channels.filter(s=>s._isMember(r)).forEach(s=>s._trigger(n,a,o)),this.stateChangeCallbacks.message.forEach(s=>s(t))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(Wr.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;const r=e.match(/\?/)?"&":"?",n=new URLSearchParams(t);return`${e}${r}${n}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(d4,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}class y4{constructor(e,t,r){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=Io.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=r.close}}class Zu extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function pr(i){return typeof i=="object"&&i!==null&&"__isStorageError"in i}class x4 extends Zu{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class ag extends Zu{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var w4=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const Q0=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=(...t)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},S4=()=>w4(void 0,void 0,void 0,function*(){return typeof Response=="undefined"?(yield Do(()=>Promise.resolve().then(()=>Bs),void 0)).Response:Response});var zo=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const Uc=i=>i.msg||i.message||i.error_description||i.error||JSON.stringify(i),E4=(i,e)=>zo(void 0,void 0,void 0,function*(){const t=yield S4();i instanceof t?i.json().then(r=>{e(new x4(Uc(r),i.status||500))}).catch(r=>{e(new ag(Uc(r),r))}):e(new ag(Uc(i),i))}),T4=(i,e,t,r)=>{const n={method:i,headers:(e==null?void 0:e.headers)||{}};return i==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),n.body=JSON.stringify(r),Object.assign(Object.assign({},n),t))};function Sd(i,e,t,r,n,a){return zo(this,void 0,void 0,function*(){return new Promise((o,s)=>{i(t,T4(e,r,n,a)).then(l=>{if(!l.ok)throw l;return r!=null&&r.noResolveJson?l:l.json()}).then(l=>o(l)).catch(l=>E4(l,s))})})}function yu(i,e,t,r){return zo(this,void 0,void 0,function*(){return Sd(i,"GET",e,t,r)})}function Wn(i,e,t,r,n){return zo(this,void 0,void 0,function*(){return Sd(i,"POST",e,r,n,t)})}function I4(i,e,t,r,n){return zo(this,void 0,void 0,function*(){return Sd(i,"PUT",e,r,n,t)})}function ev(i,e,t,r,n){return zo(this,void 0,void 0,function*(){return Sd(i,"DELETE",e,r,n,t)})}var zr=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const A4={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},og={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class C4{constructor(e,t={},r,n){this.url=e,this.headers=t,this.bucketId=r,this.fetch=Q0(n)}uploadOrUpdate(e,t,r,n){return zr(this,void 0,void 0,function*(){try{let a;const o=Object.assign(Object.assign({},og),n),s=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});typeof Blob!="undefined"&&r instanceof Blob?(a=new FormData,a.append("cacheControl",o.cacheControl),a.append("",r)):typeof FormData!="undefined"&&r instanceof FormData?(a=r,a.append("cacheControl",o.cacheControl)):(a=r,s["cache-control"]=`max-age=${o.cacheControl}`,s["content-type"]=o.contentType);const l=this._removeEmptyFolders(t),d=this._getFinalPath(l),c=yield this.fetch(`${this.url}/object/${d}`,Object.assign({method:e,body:a,headers:s},o!=null&&o.duplex?{duplex:o.duplex}:{})),u=yield c.json();return c.ok?{data:{path:l,id:u.Id,fullPath:u.Key},error:null}:{data:null,error:u}}catch(a){if(pr(a))return{data:null,error:a};throw a}})}upload(e,t,r){return zr(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,n){return zr(this,void 0,void 0,function*(){const a=this._removeEmptyFolders(e),o=this._getFinalPath(a),s=new URL(this.url+`/object/upload/sign/${o}`);s.searchParams.set("token",t);try{let l;const d=Object.assign({upsert:og.upsert},n),c=Object.assign(Object.assign({},this.headers),{"x-upsert":String(d.upsert)});typeof Blob!="undefined"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",d.cacheControl),l.append("",r)):typeof FormData!="undefined"&&r instanceof FormData?(l=r,l.append("cacheControl",d.cacheControl)):(l=r,c["cache-control"]=`max-age=${d.cacheControl}`,c["content-type"]=d.contentType);const u=yield this.fetch(s.toString(),{method:"PUT",body:l,headers:c}),f=yield u.json();return u.ok?{data:{path:a,fullPath:f.Key},error:null}:{data:null,error:f}}catch(l){if(pr(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e){return zr(this,void 0,void 0,function*(){try{let t=this._getFinalPath(e);const r=yield Wn(this.fetch,`${this.url}/object/upload/sign/${t}`,{},{headers:this.headers}),n=new URL(this.url+r.url),a=n.searchParams.get("token");if(!a)throw new Zu("No token returned by API");return{data:{signedUrl:n.toString(),path:e,token:a},error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}update(e,t,r){return zr(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t){return zr(this,void 0,void 0,function*(){try{return{data:yield Wn(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}copy(e,t){return zr(this,void 0,void 0,function*(){try{return{data:{path:(yield Wn(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers})).Key},error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}createSignedUrl(e,t,r){return zr(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),a=yield Wn(this.fetch,`${this.url}/object/sign/${n}`,Object.assign({expiresIn:t},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers});const o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return a={signedUrl:encodeURI(`${this.url}${a.signedURL}${o}`)},{data:a,error:null}}catch(n){if(pr(n))return{data:null,error:n};throw n}})}createSignedUrls(e,t,r){return zr(this,void 0,void 0,function*(){try{const n=yield Wn(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),a=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:n.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${a}`):null})),error:null}}catch(n){if(pr(n))return{data:null,error:n};throw n}})}download(e,t){return zr(this,void 0,void 0,function*(){const n=typeof(t==null?void 0:t.transform)!="undefined"?"render/image/authenticated":"object",a=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),o=a?`?${a}`:"";try{const s=this._getFinalPath(e);return{data:yield(yield yu(this.fetch,`${this.url}/${n}/${s}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(s){if(pr(s))return{data:null,error:s};throw s}})}getPublicUrl(e,t){const r=this._getFinalPath(e),n=[],a=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";a!==""&&n.push(a);const s=typeof(t==null?void 0:t.transform)!="undefined"?"render/image":"object",l=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});l!==""&&n.push(l);let d=n.join("&");return d!==""&&(d=`?${d}`),{data:{publicUrl:encodeURI(`${this.url}/${s}/public/${r}${d}`)}}}remove(e){return zr(this,void 0,void 0,function*(){try{return{data:yield ev(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}list(e,t,r){return zr(this,void 0,void 0,function*(){try{const n=Object.assign(Object.assign(Object.assign({},A4),t),{prefix:e||""});return{data:yield Wn(this.fetch,`${this.url}/object/list/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(pr(n))return{data:null,error:n};throw n}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const k4="2.5.5",$4={"X-Client-Info":`storage-js/${k4}`};var co=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};class L4{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},$4),t),this.fetch=Q0(r)}listBuckets(){return co(this,void 0,void 0,function*(){try{return{data:yield yu(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(pr(e))return{data:null,error:e};throw e}})}getBucket(e){return co(this,void 0,void 0,function*(){try{return{data:yield yu(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return co(this,void 0,void 0,function*(){try{return{data:yield Wn(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}updateBucket(e,t){return co(this,void 0,void 0,function*(){try{return{data:yield I4(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}emptyBucket(e){return co(this,void 0,void 0,function*(){try{return{data:yield Wn(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}deleteBucket(e){return co(this,void 0,void 0,function*(){try{return{data:yield ev(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}}class O4 extends L4{constructor(e,t={},r){super(e,t,r)}from(e){return new C4(this.url,this.headers,e,this.fetch)}}const R4="2.39.7";let ys="";typeof Deno!="undefined"?ys="deno":typeof document!="undefined"?ys="web":typeof navigator!="undefined"&&navigator.product==="ReactNative"?ys="react-native":ys="node";const F4={"X-Client-Info":`supabase-js-${ys}/${R4}`},N4={headers:F4},P4={schema:"public"},D4={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},M4={};var z4=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const B4=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=Wu:e=fetch,(...t)=>e(...t)},U4=()=>typeof Headers=="undefined"?Y0:Headers,G4=(i,e,t)=>{const r=B4(t),n=U4();return(a,o)=>z4(void 0,void 0,void 0,function*(){var s;const l=(s=yield e())!==null&&s!==void 0?s:i;let d=new n(o==null?void 0:o.headers);return d.has("apikey")||d.set("apikey",i),d.has("Authorization")||d.set("Authorization",`Bearer ${l}`),r(a,Object.assign(Object.assign({},o),{headers:d}))})};function j4(i){return i.replace(/\/$/,"")}function V4(i,e){const{db:t,auth:r,realtime:n,global:a}=i,{db:o,auth:s,realtime:l,global:d}=e;return{db:Object.assign(Object.assign({},o),t),auth:Object.assign(Object.assign({},s),r),realtime:Object.assign(Object.assign({},l),n),global:Object.assign(Object.assign({},d),a)}}function H4(i){return Math.round(Date.now()/1e3)+i}function q4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const e=Math.random()*16|0;return(i=="x"?e:e&3|8).toString(16)})}const qr=()=>typeof document!="undefined",ba={tested:!1,writable:!1},Is=()=>{if(!qr())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch(e){return!1}if(ba.tested)return ba.writable;const i=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(i,i),globalThis.localStorage.removeItem(i),ba.tested=!0,ba.writable=!0}catch(e){ba.tested=!0,ba.writable=!1}return ba.writable};function Gc(i){const e={},t=new URL(i);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((n,a)=>{e[a]=n})}catch(r){}return t.searchParams.forEach((r,n)=>{e[n]=r}),e}const tv=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=(...t)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},W4=i=>typeof i=="object"&&i!==null&&"status"in i&&"ok"in i&&"json"in i&&typeof i.json=="function",_a=(i,e,t)=>fe(void 0,null,function*(){yield i.setItem(e,JSON.stringify(t))}),Ml=(i,e)=>fe(void 0,null,function*(){const t=yield i.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch(r){return t}}),jc=(i,e)=>fe(void 0,null,function*(){yield i.removeItem(e)});function X4(i){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",r,n,a,o,s,l,d,c=0;for(i=i.replace("-","+").replace("_","/");c>4,n=(s&15)<<4|l>>2,a=(l&3)<<6|d,t=t+String.fromCharCode(r),l!=64&&n!=0&&(t=t+String.fromCharCode(n)),d!=64&&a!=0&&(t=t+String.fromCharCode(a));return t}class Ed{constructor(){this.promise=new Ed.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}Ed.promiseConstructor=Promise;function sg(i){const e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=i.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");const r=t[1];return JSON.parse(X4(r))}function Y4(i){return fe(this,null,function*(){return yield new Promise(e=>{setTimeout(()=>e(null),i)})})}function Z4(i,e){return new Promise((r,n)=>{fe(this,null,function*(){for(let a=0;a<1/0;a++)try{const o=yield i(a);if(!e(a,null,o)){r(o);return}}catch(o){if(!e(a,o)){n(o);return}}})})}function K4(i){return("0"+i.toString(16)).substr(-2)}function uo(){const e=new Uint32Array(56);if(typeof crypto=="undefined"){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=t.length;let n="";for(let a=0;a<56;a++)n+=t.charAt(Math.floor(Math.random()*r));return n}return crypto.getRandomValues(e),Array.from(e,K4).join("")}function J4(i){return fe(this,null,function*(){const t=new TextEncoder().encode(i),r=yield crypto.subtle.digest("SHA-256",t),n=new Uint8Array(r);return Array.from(n).map(a=>String.fromCharCode(a)).join("")})}function Q4(i){return btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function fo(i){return fe(this,null,function*(){if(!(typeof crypto!="undefined"&&typeof crypto.subtle!="undefined"&&typeof TextEncoder!="undefined"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),i;const t=yield J4(i);return Q4(t)})}class Ku extends Error{constructor(e,t){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t}}function Bt(i){return typeof i=="object"&&i!==null&&"__isAuthError"in i}class e5 extends Ku{constructor(e,t){super(e,t),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}function t5(i){return Bt(i)&&i.name==="AuthApiError"}class iv extends Ku{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class Da extends Ku{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class ho extends Da{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class Vc extends Da{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500)}}class zl extends Da{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class Bl extends Da{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class lg extends Da{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class xu extends Da{constructor(e,t){super(e,"AuthRetryableFetchError",t)}}function Hc(i){return Bt(i)&&i.name==="AuthRetryableFetchError"}class i5 extends Da{constructor(e,t,r){super(e,"AuthWeakPasswordError",t),this.reasons=r}}var r5=function(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(i);ni.msg||i.message||i.error_description||i.error||JSON.stringify(i),n5=[502,503,504];function dg(i){return fe(this,null,function*(){if(!W4(i))throw new xu(bo(i),0);if(n5.includes(i.status))throw new xu(bo(i),i.status);let e;try{e=yield i.json()}catch(t){throw new iv(bo(t),t)}throw typeof e=="object"&&e&&typeof e.weak_password=="object"&&e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)?new i5(bo(e),i.status,e.weak_password.reasons):new e5(bo(e),i.status||500)})}const a5=(i,e,t,r)=>{const n={method:i,headers:(e==null?void 0:e.headers)||{}};return i==="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),t))};function jt(i,e,t,r){return fe(this,null,function*(){var n;const a=Object.assign({},r==null?void 0:r.headers);r!=null&&r.jwt&&(a.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 s=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=yield o5(i,e,t+s,{headers:a,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}})}function o5(i,e,t,r,n,a){return fe(this,null,function*(){const o=a5(e,r,n,a);let s;try{s=yield i(t,o)}catch(l){throw console.error(l),new xu(bo(l),0)}if(s.ok||(yield dg(s)),r!=null&&r.noResolveJson)return s;try{return yield s.json()}catch(l){yield dg(l)}})}function ya(i){var e;let t=null;c5(i)&&(t=Object.assign({},i),i.expires_at||(t.expires_at=H4(i.expires_in)));const r=(e=i.user)!==null&&e!==void 0?e:i;return{data:{session:t,user:r},error:null}}function cg(i){const e=ya(i);return!e.error&&i.weak_password&&typeof i.weak_password=="object"&&Array.isArray(i.weak_password.reasons)&&i.weak_password.reasons.length&&i.weak_password.message&&typeof i.weak_password.message=="string"&&i.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)&&(e.data.weak_password=i.weak_password),e}function Xn(i){var e;return{data:{user:(e=i.user)!==null&&e!==void 0?e:i},error:null}}function s5(i){return{data:i,error:null}}function l5(i){const{action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:a}=i,o=r5(i,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),s={action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:a},l=Object.assign({},o);return{data:{properties:s,user:l},error:null}}function d5(i){return i}function c5(i){return i.access_token&&i.refresh_token&&i.expires_in}var u5=function(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(i);n0&&(m.forEach(p=>{const y=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),x=JSON.parse(p.split(";")[1].split("=")[1]);d[`${x}Page`]=y}),d.total=parseInt(f)),{data:Object.assign(Object.assign({},u),d),error:null}}catch(d){if(Bt(d))return{data:{users:[]},error:d};throw d}})}getUserById(e){return fe(this,null,function*(){try{return yield jt(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Xn})}catch(t){if(Bt(t))return{data:{user:null},error:t};throw t}})}updateUserById(e,t){return fe(this,null,function*(){try{return yield jt(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:Xn})}catch(r){if(Bt(r))return{data:{user:null},error:r};throw r}})}deleteUser(e,t=!1){return fe(this,null,function*(){try{return yield jt(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:Xn})}catch(r){if(Bt(r))return{data:{user:null},error:r};throw r}})}_listFactors(e){return fe(this,null,function*(){try{const{data:t,error:r}=yield jt(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:t,error:r}}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}_deleteFactor(e){return fe(this,null,function*(){try{return{data:yield jt(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}}const rv="0.0.0",h5="http://localhost:9999",m5="supabase.auth.token",p5={"X-Client-Info":`gotrue-js/${rv}`},ug=10,g5={getItem:i=>Is()?globalThis.localStorage.getItem(i):null,setItem:(i,e)=>{Is()&&globalThis.localStorage.setItem(i,e)},removeItem:i=>{Is()&&globalThis.localStorage.removeItem(i)}};function fg(i={}){return{getItem:e=>i[e]||null,setItem:(e,t)=>{i[e]=t},removeItem:e=>{delete i[e]}}}function v5(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(i){typeof self!="undefined"&&(self.globalThis=self)}}const mo={debug:!!(globalThis&&Is()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class nv extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class b5 extends nv{}function _5(i,e,t){return fe(this,null,function*(){mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",i,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),mo.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",i)},e),yield globalThis.navigator.locks.request(i,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},n=>fe(this,null,function*(){if(n){mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",i,n.name);try{return yield t()}finally{mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",i,n.name)}}else{if(e===0)throw mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",i),new b5(`Acquiring an exclusive Navigator LockManager lock "${i}" immediately failed`);if(mo.debug)try{const a=yield globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}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"),yield t()}}))})}v5();const y5={url:h5,storageKey:m5,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:p5,flowType:"implicit",debug:!1},ms=30*1e3,hg=3;function mg(i,e,t){return fe(this,null,function*(){return yield t()})}class Ns{constructor(e){var t,r;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Ns.nextInstanceID,Ns.nextInstanceID+=1,this.instanceID>0&&qr()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const n=Object.assign(Object.assign({},y5),e);if(this.logDebugMessages=!!n.debug,typeof n.debug=="function"&&(this.logger=n.debug),this.persistSession=n.persistSession,this.storageKey=n.storageKey,this.autoRefreshToken=n.autoRefreshToken,this.admin=new f5({url:n.url,headers:n.headers,fetch:n.fetch}),this.url=n.url,this.headers=n.headers,this.fetch=tv(n.fetch),this.lock=n.lock||mg,this.detectSessionInUrl=n.detectSessionInUrl,this.flowType=n.flowType,n.lock?this.lock=n.lock:qr()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=_5:this.lock=mg,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?n.storage?this.storage=n.storage:Is()?this.storage=g5:(this.memoryStorage={},this.storage=fg(this.memoryStorage)):(this.memoryStorage={},this.storage=fg(this.memoryStorage)),qr()&&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)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",a=>fe(this,null,function*(){this._debug("received broadcast notification from other tab or client",a),yield this._notifyAllSubscribers(a.data.event,a.data.session,!1)}))}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${rv}) ${new Date().toISOString()}`,...e),this}initialize(){return fe(this,null,function*(){return this.initializePromise?yield this.initializePromise:(this.initializePromise=fe(this,null,function*(){return yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._initialize()}))}),yield this.initializePromise)})}_initialize(){return fe(this,null,function*(){try{const e=qr()?yield this._isPKCEFlow():!1;if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){const{data:t,error:r}=yield this._getSessionFromURL(e);if(r)return this._debug("#_initialize()","error detecting session from URL",r),(r==null?void 0:r.message)==="Identity is already linked"||(r==null?void 0:r.message)==="Identity is already linked to another user"?{error:r}:(yield this._removeSession(),{error:r});const{session:n,redirectType:a}=t;return this._debug("#_initialize()","detected session in URL",n,"redirect type",a),yield this._saveSession(n),setTimeout(()=>fe(this,null,function*(){a==="recovery"?yield this._notifyAllSubscribers("PASSWORD_RECOVERY",n):yield this._notifyAllSubscribers("SIGNED_IN",n)}),0),{error:null}}return yield this._recoverAndRefresh(),{error:null}}catch(e){return Bt(e)?{error:e}:{error:new iv("Unexpected error during initialization",e)}}finally{yield this._handleVisibilityChange(),this._debug("#_initialize()","end")}})}signUp(e){return fe(this,null,function*(){var t,r,n;try{yield this._removeSession();let a;if("email"in e){const{email:c,password:u,options:f}=e;let m=null,p=null;if(this.flowType==="pkce"){const y=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,y),m=yield fo(y),p=y===m?"plain":"s256"}a=yield jt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:c,password:u,data:(t=f==null?void 0:f.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:p},xform:ya})}else if("phone"in e){const{phone:c,password:u,options:f}=e;a=yield jt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:c,password:u,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:ya})}else throw new zl("You must provide either an email or phone number and a password");const{data:o,error:s}=a;if(s||!o)return{data:{user:null,session:null},error:s};const l=o.session,d=o.user;return o.session&&(yield this._saveSession(o.session),yield this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:d,session:l},error:null}}catch(a){if(Bt(a))return{data:{user:null,session:null},error:a};throw a}})}signInWithPassword(e){return fe(this,null,function*(){try{yield this._removeSession();let t;if("email"in e){const{email:a,password:o,options:s}=e;t=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:o,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:cg})}else if("phone"in e){const{phone:a,password:o,options:s}=e;t=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:o,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:cg})}else throw new zl("You must provide either an email or phone number and a password");const{data:r,error:n}=t;return n?{data:{user:null,session:null},error:n}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new Vc}:(r.session&&(yield this._saveSession(r.session),yield this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:n})}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}signInWithOAuth(e){return fe(this,null,function*(){var t,r,n,a;return yield this._removeSession(),yield this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.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:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})})}exchangeCodeForSession(e){return fe(this,null,function*(){return yield this.initializePromise,this._acquireLock(-1,()=>fe(this,null,function*(){return this._exchangeCodeForSession(e)}))})}_exchangeCodeForSession(e){return fe(this,null,function*(){const t=yield Ml(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(t!=null?t:"").split("/"),{data:a,error:o}=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:ya});return yield jc(this.storage,`${this.storageKey}-code-verifier`),o?{data:{user:null,session:null,redirectType:null},error:o}:!a||!a.session||!a.user?{data:{user:null,session:null,redirectType:null},error:new Vc}:(a.session&&(yield this._saveSession(a.session),yield this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:Object.assign(Object.assign({},a),{redirectType:n!=null?n:null}),error:o})})}signInWithIdToken(e){return fe(this,null,function*(){yield this._removeSession();try{const{options:t,provider:r,token:n,access_token:a,nonce:o}=e,s=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:n,access_token:a,nonce:o,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:ya}),{data:l,error:d}=s;return d?{data:{user:null,session:null},error:d}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new Vc}:(l.session&&(yield this._saveSession(l.session),yield this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:d})}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}signInWithOtp(e){return fe(this,null,function*(){var t,r,n,a,o;try{if(yield this._removeSession(),"email"in e){const{email:s,options:l}=e;let d=null,c=null;if(this.flowType==="pkce"){const f=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,f),d=yield fo(f),c=f===d?"plain":"s256"}const{error:u}=yield jt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:(t=l==null?void 0:l.data)!==null&&t!==void 0?t:{},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:d,code_challenge_method:c},redirectTo:l==null?void 0:l.emailRedirectTo});return{data:{user:null,session:null},error:u}}if("phone"in e){const{phone:s,options:l}=e,{data:d,error:c}=yield jt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:s,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(a=l==null?void 0:l.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:d==null?void 0:d.message_id},error:c}}throw new zl("You must provide either an email or phone number.")}catch(s){if(Bt(s))return{data:{user:null,session:null},error:s};throw s}})}verifyOtp(e){return fe(this,null,function*(){var t,r;try{e.type!=="email_change"&&e.type!=="phone_change"&&(yield this._removeSession());let n,a;"options"in e&&(n=(t=e.options)===null||t===void 0?void 0:t.redirectTo,a=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:s}=yield jt(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:n,xform:ya});if(s)throw s;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,d=o.user;return l!=null&&l.access_token&&(yield this._saveSession(l),yield this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:d,session:l},error:null}}catch(n){if(Bt(n))return{data:{user:null,session:null},error:n};throw n}})}signInWithSSO(e){return fe(this,null,function*(){var t,r,n;try{yield this._removeSession();let a=null,o=null;if(this.flowType==="pkce"){const s=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,s),a=yield fo(s),o=s===a?"plain":"s256"}return yield jt(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=(t=e.options)===null||t===void 0?void 0:t.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:o}),headers:this.headers,xform:s5})}catch(a){if(Bt(a))return{data:null,error:a};throw a}})}reauthenticate(){return fe(this,null,function*(){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._reauthenticate()}))})}_reauthenticate(){return fe(this,null,function*(){try{return yield this._useSession(e=>fe(this,null,function*(){const{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new ho;const{error:n}=yield jt(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:n}}))}catch(e){if(Bt(e))return{data:{user:null,session:null},error:e};throw e}})}resend(e){return fe(this,null,function*(){try{e.type!="email_change"&&e.type!="phone_change"&&(yield this._removeSession());const t=`${this.url}/resend`;if("email"in e){const{email:r,type:n,options:a}=e,{error:o}=yield jt(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:r,type:n,options:a}=e,{data:o,error:s}=yield jt(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:n,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:s}}throw new zl("You must provide either an email or phone number and a type")}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}getSession(){return fe(this,null,function*(){return yield this.initializePromise,this._acquireLock(-1,()=>fe(this,null,function*(){return this._useSession(e=>fe(this,null,function*(){return e}))}))})}_acquireLock(e,t){return fe(this,null,function*(){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=fe(this,null,function*(){return yield r,yield t()});return this.pendingInLock.push(fe(this,null,function*(){try{yield n}catch(a){}})),n}return yield this.lock(`lock:${this.storageKey}`,e,()=>fe(this,null,function*(){this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=t();for(this.pendingInLock.push(fe(this,null,function*(){try{yield r}catch(n){}})),yield r;this.pendingInLock.length;){const n=[...this.pendingInLock];yield Promise.all(n),this.pendingInLock.splice(0,n.length)}return yield r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}}))}finally{this._debug("#_acquireLock","end")}})}_useSession(e){return fe(this,null,function*(){this._debug("#_useSession","begin");try{const t=yield this.__loadSession();return yield e(t)}finally{this._debug("#_useSession","end")}})}__loadSession(){return fe(this,null,function*(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const t=yield Ml(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),yield this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r)return{data:{session:e},error:null};const{session:n,error:a}=yield this._callRefreshToken(e.refresh_token);return a?{data:{session:null},error:a}:{data:{session:n},error:null}}finally{this._debug("#__loadSession()","end")}})}getUser(e){return fe(this,null,function*(){return e?yield this._getUser(e):(yield this.initializePromise,this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._getUser()})))})}_getUser(e){return fe(this,null,function*(){try{return e?yield jt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Xn}):yield this._useSession(t=>fe(this,null,function*(){var r,n;const{data:a,error:o}=t;if(o)throw o;return yield jt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(n=(r=a.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0,xform:Xn})}))}catch(t){if(Bt(t))return{data:{user:null},error:t};throw t}})}updateUser(r){return fe(this,arguments,function*(e,t={}){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._updateUser(e,t)}))})}_updateUser(r){return fe(this,arguments,function*(e,t={}){try{return yield this._useSession(n=>fe(this,null,function*(){const{data:a,error:o}=n;if(o)throw o;if(!a.session)throw new ho;const s=a.session;let l=null,d=null;if(this.flowType==="pkce"&&e.email!=null){const f=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,f),l=yield fo(f),d=f===l?"plain":"s256"}const{data:c,error:u}=yield jt(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:l,code_challenge_method:d}),jwt:s.access_token,xform:Xn});if(u)throw u;return s.user=c.user,yield this._saveSession(s),yield this._notifyAllSubscribers("USER_UPDATED",s),{data:{user:s.user},error:null}}))}catch(n){if(Bt(n))return{data:{user:null},error:n};throw n}})}_decodeJWT(e){return sg(e)}setSession(e){return fe(this,null,function*(){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._setSession(e)}))})}_setSession(e){return fe(this,null,function*(){try{if(!e.access_token||!e.refresh_token)throw new ho;const t=Date.now()/1e3;let r=t,n=!0,a=null;const o=sg(e.access_token);if(o.exp&&(r=o.exp,n=r<=t),n){const{session:s,error:l}=yield this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!s)return{data:{user:null,session:null},error:null};a=s}else{const{data:s,error:l}=yield this._getUser(e.access_token);if(l)throw l;a={access_token:e.access_token,refresh_token:e.refresh_token,user:s.user,token_type:"bearer",expires_in:r-t,expires_at:r},yield this._saveSession(a),yield this._notifyAllSubscribers("SIGNED_IN",a)}return{data:{user:a.user,session:a},error:null}}catch(t){if(Bt(t))return{data:{session:null,user:null},error:t};throw t}})}refreshSession(e){return fe(this,null,function*(){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._refreshSession(e)}))})}_refreshSession(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;if(!e){const{data:o,error:s}=t;if(s)throw s;e=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new ho;const{session:n,error:a}=yield this._callRefreshToken(e.refresh_token);return a?{data:{user:null,session:null},error:a}:n?{data:{user:n.user,session:n},error:null}:{data:{user:null,session:null},error:null}}))}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}_getSessionFromURL(e){return fe(this,null,function*(){try{if(!qr())throw new Bl("No browser detected.");if(this.flowType==="implicit"&&!this._isImplicitGrantFlow())throw new Bl("Not a valid implicit grant flow url.");if(this.flowType=="pkce"&&!e)throw new lg("Not a valid PKCE flow url.");const t=Gc(window.location.href);if(e){if(!t.code)throw new lg("No code detected.");const{data:k,error:I}=yield this._exchangeCodeForSession(t.code);if(I)throw I;const v=new URL(window.location.href);return v.searchParams.delete("code"),window.history.replaceState(window.history.state,"",v.toString()),{data:{session:k.session,redirectType:null},error:null}}if(t.error||t.error_description||t.error_code)throw new Bl(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});const{provider_token:r,provider_refresh_token:n,access_token:a,refresh_token:o,expires_in:s,expires_at:l,token_type:d}=t;if(!a||!s||!o||!d)throw new Bl("No session defined in URL");const c=Math.round(Date.now()/1e3),u=parseInt(s);let f=c+u;l&&(f=parseInt(l));const m=f-c;m*1e3<=ms&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${u}s`);const p=f-u;c-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,f,c):c-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clok for skew",p,f,c);const{data:y,error:x}=yield this._getUser(a);if(x)throw x;const E={provider_token:r,provider_refresh_token:n,access_token:a,expires_in:u,expires_at:f,refresh_token:o,token_type:d,user:y.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:E,redirectType:t.type},error:null}}catch(t){if(Bt(t))return{data:{session:null,redirectType:null},error:t};throw t}})}_isImplicitGrantFlow(){const e=Gc(window.location.href);return!!(qr()&&(e.access_token||e.error_description))}_isPKCEFlow(){return fe(this,null,function*(){const e=Gc(window.location.href),t=yield Ml(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)})}signOut(){return fe(this,arguments,function*(e={scope:"global"}){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._signOut(e)}))})}_signOut(){return fe(this,arguments,function*({scope:e}={scope:"global"}){return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;if(a)return{error:a};const o=(r=n.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:s}=yield this.admin.signOut(o,e);if(s&&!(t5(s)&&(s.status===404||s.status===401)))return{error:s}}return e!=="others"&&(yield this._removeSession(),yield jc(this.storage,`${this.storageKey}-code-verifier`),yield this._notifyAllSubscribers("SIGNED_OUT",null)),{error:null}}))})}onAuthStateChange(e){const t=q4(),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),fe(this,null,function*(){yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){this._emitInitialSession(t)}))}),{data:{subscription:r}}}_emitInitialSession(e){return fe(this,null,function*(){return yield this._useSession(t=>fe(this,null,function*(){var r,n;try{const{data:{session:a},error:o}=t;if(o)throw o;yield(r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",a),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){yield(n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a)}}))})}resetPasswordForEmail(r){return fe(this,arguments,function*(e,t={}){let n=null,a=null;if(this.flowType==="pkce"){const o=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,`${o}/PASSWORD_RECOVERY`),n=yield fo(o),a=o===n?"plain":"s256"}try{return yield jt(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(o){if(Bt(o))return{data:null,error:o};throw o}})}getUserIdentities(){return fe(this,null,function*(){var e;try{const{data:t,error:r}=yield this.getUser();if(r)throw r;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}linkIdentity(e){return fe(this,null,function*(){var t;try{const{data:r,error:n}=yield this._useSession(a=>fe(this,null,function*(){var o,s,l,d,c;const{data:u,error:f}=a;if(f)throw f;const m=yield this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(s=e.options)===null||s===void 0?void 0:s.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return yield jt(this.fetch,"GET",m,{headers:this.headers,jwt:(c=(d=u.session)===null||d===void 0?void 0:d.access_token)!==null&&c!==void 0?c:void 0})}));if(n)throw n;return qr()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),{data:{provider:e.provider,url:r==null?void 0:r.url},error:null}}catch(r){if(Bt(r))return{data:{provider:e.provider,url:null},error:r};throw r}})}unlinkIdentity(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r,n;const{data:a,error:o}=t;if(o)throw o;return yield jt(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(r=a.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}_refreshAccessToken(e){return fe(this,null,function*(){const t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{const r=Date.now();return yield Z4(n=>fe(this,null,function*(){return yield Y4(n*200),this._debug(t,"refreshing attempt",n),yield jt(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:ya})}),(n,a,o)=>o&&o.error&&Hc(o.error)&&Date.now()+(n+1)*200-rfe(this,null,function*(){try{yield s.callback(e,t)}catch(l){a.push(l)}}));if(yield Promise.all(o),a.length>0){for(let s=0;sthis._autoRefreshTokenTick(),ms);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno!="undefined"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(()=>fe(this,null,function*(){yield this.initializePromise,yield this._autoRefreshTokenTick()}),0)})}_stopAutoRefresh(){return fe(this,null,function*(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)})}startAutoRefresh(){return fe(this,null,function*(){this._removeVisibilityChangedCallback(),yield this._startAutoRefresh()})}stopAutoRefresh(){return fe(this,null,function*(){this._removeVisibilityChangedCallback(),yield this._stopAutoRefresh()})}_autoRefreshTokenTick(){return fe(this,null,function*(){this._debug("#_autoRefreshTokenTick()","begin");try{yield this._acquireLock(0,()=>fe(this,null,function*(){try{const e=Date.now();try{return yield this._useSession(t=>fe(this,null,function*(){const{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((r.expires_at*1e3-e)/ms);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${ms}ms, refresh threshold is ${hg} ticks`),n<=hg&&(yield this._callRefreshToken(r.refresh_token))}))}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}))}catch(e){if(e.isAcquireTimeout||e instanceof nv)this._debug("auto refresh token tick lock not available");else throw e}})}_handleVisibilityChange(){return fe(this,null,function*(){if(this._debug("#_handleVisibilityChange()"),!qr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=()=>fe(this,null,function*(){return yield this._onVisibilityChanged(!1)}),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),yield this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}})}_onVisibilityChanged(e){return fe(this,null,function*(){const t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}yield this._recoverAndRefresh()})))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()})}_getUrlForProvider(e,t,r){return fe(this,null,function*(){const n=[`provider=${encodeURIComponent(t)}`];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 a=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,a);const o=yield fo(a),s=a===o?"plain":"s256";this._debug("PKCE","code verifier",`${a.substring(0,5)}...`,"code challenge",o,"method",s);const l=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(s)}`});n.push(l.toString())}if(r!=null&&r.queryParams){const a=new URLSearchParams(r.queryParams);n.push(a.toString())}return r!=null&&r.skipBrowserRedirect&&n.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${n.join("&")}`})}_unenroll(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;return a?{data:null,error:a}:yield jt(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(t){if(Bt(t))return{data:null,error:t};throw t}})}_enroll(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r,n;const{data:a,error:o}=t;if(o)return{data:null,error:o};const{data:s,error:l}=yield jt(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:(r=a==null?void 0:a.session)===null||r===void 0?void 0:r.access_token});return l?{data:null,error:l}:(!((n=s==null?void 0:s.totp)===null||n===void 0)&&n.qr_code&&(s.totp.qr_code=`data:image/svg+xml;utf-8,${s.totp.qr_code}`),{data:s,error:null})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}_verify(e){return fe(this,null,function*(){return this._acquireLock(-1,()=>fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;if(a)return{data:null,error:a};const{data:o,error:s}=yield jt(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});return s?{data:null,error:s}:(yield this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),yield this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:s})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}}))})}_challenge(e){return fe(this,null,function*(){return this._acquireLock(-1,()=>fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;return a?{data:null,error:a}:yield jt(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}}))})}_challengeAndVerify(e){return fe(this,null,function*(){const{data:t,error:r}=yield this._challenge({factorId:e.factorId});return r?{data:null,error:r}:yield this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})})}_listFactors(){return fe(this,null,function*(){const{data:{user:e},error:t}=yield this.getUser();if(t)return{data:null,error:t};const r=(e==null?void 0:e.factors)||[],n=r.filter(a=>a.factor_type==="totp"&&a.status==="verified");return{data:{all:r,totp:n},error:null}})}_getAuthenticatorAssuranceLevel(){return fe(this,null,function*(){return this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._useSession(e=>fe(this,null,function*(){var t,r;const{data:{session:n},error:a}=e;if(a)return{data:null,error:a};if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const o=this._decodeJWT(n.access_token);let s=null;o.aal&&(s=o.aal);let l=s;((r=(t=n.user.factors)===null||t===void 0?void 0:t.filter(u=>u.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const c=o.amr||[];return{data:{currentLevel:s,nextLevel:l,currentAuthenticationMethods:c},error:null}}))}))})}}Ns.nextInstanceID=0;class x5 extends Ns{constructor(e){super(e)}}var w5=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};class S5{constructor(e,t,r){var n,a,o,s,l,d,c,u;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const f=j4(e);this.realtimeUrl=`${f}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${f}/auth/v1`,this.storageUrl=`${f}/storage/v1`,this.functionsUrl=`${f}/functions/v1`;const m=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,p={db:P4,realtime:M4,auth:Object.assign(Object.assign({},D4),{storageKey:m}),global:N4},y=V4(r!=null?r:{},p);this.storageKey=(a=(n=y.auth)===null||n===void 0?void 0:n.storageKey)!==null&&a!==void 0?a:"",this.headers=(s=(o=y.global)===null||o===void 0?void 0:o.headers)!==null&&s!==void 0?s:{},this.auth=this._initSupabaseAuthClient((l=y.auth)!==null&&l!==void 0?l:{},this.headers,(d=y.global)===null||d===void 0?void 0:d.fetch),this.fetch=G4(t,this._getAccessToken.bind(this),(c=y.global)===null||c===void 0?void 0:c.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},y.realtime)),this.rest=new Xu(`${f}/rest/v1`,{headers:this.headers,schema:(u=y.db)===null||u===void 0?void 0:u.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new YA(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new O4(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},r={}){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return w5(this,void 0,void 0,function*(){const{data:r}=yield this.auth.getSession();return(t=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,storageKey:a,flowType:o,debug:s},l,d){const c={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new x5({url:this.authUrl,headers:Object.assign(Object.assign({},c),l),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,flowType:o,debug:s,fetch:d})}_initRealtimeClient(e){return new _4(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,r)=>{this._handleTokenChanged(t,"CLIENT",r==null?void 0:r.access_token)})}_handleTokenChanged(e,t,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?(this.realtime.setAuth(r!=null?r:null),this.changedAccessToken=r):e==="SIGNED_OUT"&&(this.realtime.setAuth(this.supabaseKey),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const E5=(i,e,t)=>new S5(i,e,t),T5=E5("https://xovkkfhojasbjinfslpx.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhvdmtrZmhvamFzYmppbmZzbHB4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTM1ODQ0ODAsImV4cCI6MjAwOTE2MDQ4MH0.L3-X0p_un0oSTNubPwtfGo0D8g2bkPIfz7CaZ-iRYXY");function I5(i){return fe(this,null,function*(){const{error:e}=yield T5.from("metrics").insert(i);return e})}var pg=[],ps=[];function A5(i,e){if(i&&typeof document!="undefined"){var t,r=e.prepend===!0?"prepend":"append",n=e.singleTag===!0,a=typeof e.container=="string"?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(n){var o=pg.indexOf(a);o===-1&&(o=pg.push(a)-1,ps[o]={}),t=ps[o]&&ps[o][r]?ps[o][r]:ps[o][r]=s()}else t=s();i.charCodeAt(0)===65279&&(i=i.substring(1)),t.styleSheet?t.styleSheet.cssText+=i:t.appendChild(document.createTextNode(i))}function s(){var l=document.createElement("style");if(l.setAttribute("type","text/css"),e.attributes)for(var d=Object.keys(e.attributes),c=0;ci.id,nodeLabelClassName:void 0,nodeLabelColor:void 0,hoveredNodeLabelClassName:void 0,hoveredNodeLabelColor:void 0,onSetData:void 0,onNodesFiltered:void 0,onLinksFiltered:void 0,onLabelClick:void 0};let Ju=Ao,vg=Ao,bg=Ao,av=sv,ov=lv;typeof Uint8Array!="undefined"&&(Ju=function(i){return new Uint8Array(i)},vg=function(i){return new Uint16Array(i)},bg=function(i){return new Uint32Array(i)},av=function(i,e){if(i.length>=e)return i;var t=new i.constructor(e);return t.set(i),t},ov=function(i,e){var t;switch(e){case 16:t=vg(i.length);break;case 32:t=bg(i.length);break;default:throw new Error("invalid array width!")}return t.set(i),t});function Ao(i){for(var e=new Array(i),t=-1;++t32)throw new Error("invalid array width!");return i}function gn(i){this.length=i,this.subarrays=1,this.width=8,this.masks={0:0},this[0]=Ju(i)}gn.prototype.lengthen=function(i){var e,t;for(e=0,t=this.subarrays;e>>0,!(e>=32&&!t))return e<32&&t&1<=i;r--)this[e][r]=0;this.length=i};gn.prototype.zero=function(i){var e,t;for(e=0,t=this.subarrays;e>>0),a!=(o===r?n:0))return!1;return!0};const Yn={array8:Ao,array16:Ao,array32:Ao,arrayLengthen:sv,arrayWiden:lv,bitarray:gn},k5=(i,e)=>function(t){var r=t.length;return[i.left(t,e,0,r),i.right(t,e,0,r)]},$5=(i,e)=>{var t=e[0],r=e[1];return function(n){var a=n.length;return[i.left(n,t,0,a),i.left(n,r,0,a)]}},L5=i=>[0,i.length],po={filterExact:k5,filterRange:$5,filterAll:L5},Ps=i=>i,sn=()=>null,Ul=()=>0;function dv(i){function e(n,a,o){for(var s=o-a,l=(s>>>1)+1;--l>0;)r(n,l,s,a);return n}function t(n,a,o){for(var s=o-a,l;--s>0;)l=n[a],n[a]=n[a+s],n[a+s]=l,r(n,1,s,a);return n}function r(n,a,o,s){for(var l=n[--s+a],d=i(l),c;(c=a<<1)<=o&&(ci(n[s+c+1])&&c++,!(d<=i(n[s+c])));)n[s+a]=n[s+c],a=c;n[s+a]=l}return e.sort=t,e}const Td=dv(Ps);Td.by=dv;function cv(i){var e=Td.by(i);function t(r,n,a,o){var s=new Array(o=Math.min(a-n,o)),l,d,c;for(d=0;dl&&(s[0]=c,l=i(e(s,0,o)[0]));while(++n>>1;i(r[s])>>1;n{for(var r=0,n=e.length,a=t?JSON.parse(JSON.stringify(i)):new Array(n);ri+1,R5=i=>i-1,F5=i=>function(e,t){return e+ +i(t)},N5=i=>function(e,t){return e-i(t)},Vn={reduceIncrement:O5,reduceDecrement:R5,reduceAdd:F5,reduceSubtract:N5};function P5(i,e,t,r,n){for(n in r=(t=t.split(".")).splice(-1,1),t)e=e[t[n]]=e[t[n]]||{};return i(e,r)}const D5=(i,e)=>{const t=i[e];return typeof t=="function"?t.call(i):t},M5=/\[([\w\d]+)\]/g,z5=(i,e)=>P5(D5,i,e.replace(M5,".$1"));var Hn=-1;Us.heap=Td;Us.heapselect=Qu;Us.bisect=vd;Us.permute=Zl;function Us(){var i={add:l,remove:d,dimension:f,groupAll:m,size:p,all:y,allFiltered:x,onChange:E,isElementFiltered:u},e=[],t=0,r,n=[],a=[],o=[],s=[];r=new Yn.bitarray(0);function l(I){var v=t,M=I.length;return M&&(e=e.concat(I),r.lengthen(t+=M),a.forEach(function(K){K(I,v,M)}),k("dataAdded")),i}function d(I){for(var v=new Array(t),M=[],K=typeof I=="function",L=function(de){return K?I(e[de],de):r.zero(de)},R=0,W=0;R>7]&=~(1<<(L&63));return R}function u(I,v){var M=c(v||[]);return r.zeroExceptMask(I,M)}function f(I,v){if(typeof I=="string"){var M=I;I=function(Ze){return z5(Ze,M)}}var K={filter:It,filterExact:ii,filterRange:vi,filterFunction:Vt,filterAll:Ki,currentFilter:st,hasCurrentFilter:ft,top:Qt,bottom:_,group:X,groupAll:bi,dispose:Ma,remove:Ma,accessor:I,id:function(){return Oe}},L,R,W,Oe,me,de,N,C,Q,V,ne=[],Ve=function(Ze){return qc(Ze).sort(function(et,ge){var ie=N[et],Et=N[ge];return ieEt?1:et-ge})},Re=po.filterAll,Ge,tt,ot,he=[],bt=[],wt=0,pt=0,Lt=0,xe;a.unshift(Qe),a.push(dt),o.push(Se);var le=r.add();W=le.offset,L=le.one,R=~L,Oe=W<<7|Math.log(L)/Math.log(2),Qe(e,0,t),dt(e,0,t);function Qe(Ze,et,ge){var ie,Et;if(v){Lt=0,cr=0,xe=[];for(var nt=0;ntwt)for(ie=wt,Et=Math.min(et,pt);iept)for(ie=Math.max(et,pt),Et=ge;ie0&&(nt=et);--ie>=wt&&Ze>0;)r.zero(Et=de[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze));if(v)for(ie=0;ie0;ie++)r.zero(Et=ne[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze));return ge}function _(Ze,et){var ge=[],ie,Et,nt=0;if(et&&et>0&&(nt=et),v)for(ie=0;ie0;ie++)r.zero(Et=ne[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze));for(ie=wt;ie0;)r.zero(Et=de[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze)),ie++;return ge}function X(Ze){var et={top:Id,all:Wi,reduce:Bo,reduceCount:Gs,reduceSum:Ad,order:js,orderNatural:Vs,size:Hs,dispose:_i,remove:_i};bt.push(et);var ge,ie,Et=8,nt=_g(Et),at=0,ri,qt,Ri,Ai,mr,Si=sn,ni=sn,qi=!0,_r=Ze===sn,Gr;arguments.length<1&&(Ze=Ps),n.push(Si),he.push(vn),o.push(ea),vn(me,de,0,t);function vn(Ke,Pt,Ht,Di){v&&(Gr=Ht,Ht=me.length-Ke.length,Di=Ke.length);var Dt=ge,kt=v?[]:xa(at,nt),Wt=Ri,ai=Ai,Xi=mr,Ji=at,Qi=0,bn=0,Pr,Rn,za,_n,yn,Uo;for(qi&&(Wt=Xi=sn),qi&&(ai=Xi=sn),ge=new Array(at),at=0,v?ie=Ji?ie:[]:ie=Ji>1?Yn.arrayLengthen(ie,t):xa(t,nt),Ji&&(za=(Rn=Dt[0]).key);bn=_n);)++bn;for(;bn=Di));)_n=Ze(Ke[bn]);qs()}for(;QiQi)if(v)for(Qi=0;Qi1||v?(Si=On,ni=ta):(!at&&_r&&(at=1,ge=[{key:null,value:Xi()}]),at===1?(Si=di,ni=cr):(Si=sn,ni=sn),ie=null),n[Pr]=Si;function qs(){if(v){at++;return}++at===nt&&(kt=Yn.arrayWiden(kt,Et<<=1),ie=Yn.arrayWiden(ie,Et),nt=_g(Et))}}function ea(Ke){if(at>1||v){var Pt=at,Ht=ge,Di=xa(Pt,Pt),Dt,kt,Wt;if(v){for(Dt=0,Wt=0;Dt1||v)if(v)for(Dt=0;Dt1||v?(ni=ta,Si=On):at===1?(ni=cr,Si=di):ni=Si=sn}else if(at===1){if(_r)return;for(var ai=0;ai=0&&n.splice(Ke,1),Ke=he.indexOf(vn),Ke>=0&&he.splice(Ke,1),Ke=o.indexOf(ea),Ke>=0&&o.splice(Ke,1),Ke=bt.indexOf(et),Ke>=0&&bt.splice(Ke,1),et}return Gs().orderNatural()}function bi(){var Ze=X(sn),et=Ze.all;return delete Ze.all,delete Ze.top,delete Ze.order,delete Ze.orderNatural,delete Ze.size,Ze.value=function(){return et()[0].value},Ze}function Ma(){bt.forEach(function(et){et.dispose()});var Ze=a.indexOf(Qe);return Ze>=0&&a.splice(Ze,1),Ze=a.indexOf(dt),Ze>=0&&a.splice(Ze,1),Ze=o.indexOf(Se),Ze>=0&&o.splice(Ze,1),r.masks[W]&=R,Ki()}return K}function m(){var I={reduce:de,reduceCount:N,reduceSum:C,value:Q,dispose:V,remove:V},v,M,K,L,R=!0;n.push(Oe),a.push(W),W(e,0);function W(ne,Ve){var Re;if(!R)for(Re=Ve;Re=0&&n.splice(ne,1),ne=a.indexOf(W),ne>=0&&a.splice(ne,1),I}return N()}function p(){return t}function y(){return e}function x(I){var v=[],M=0,K=c(I||[]);for(M=0;M{var r,n,a;switch(t){case"filtered":(r=this.onFiltered)===null||r===void 0||r.call(this),this._filters.forEach(o=>{var s;(s=o.onFiltered)===null||s===void 0||s.call(o)});break;case"dataAdded":(n=this.onDataAdded)===null||n===void 0||n.call(this),this._filters.forEach(o=>{var s;(s=o.onDataAdded)===null||s===void 0||s.call(o)});break;case"dataRemoved":(a=this.onDataRemoved)===null||a===void 0||a.call(this),this._filters.forEach(o=>{var s;(s=o.onDataRemoved)===null||s===void 0||s.call(o)})}})}addRecords(e){const{_crossfilter:t}=this;this._records=e,t.remove(),t.add(e)}getFilteredRecords(e){const{_crossfilter:t}=this;return(e==null?void 0:e.getFilteredRecords())||t.allFiltered()}addFilter(e=!0){const t=new B5(this._crossfilter,()=>{this._filters.delete(t)},e?this._syncUpFunction:void 0);return this._filters.add(t),t}clearFilters(){this._filters.forEach(e=>{e.clear()})}isAnyFiltersActive(e){for(const t of this._filters.values())if(t!==e&&t.isActive())return!0;return!1}getAllRecords(){return this._records}}class U5{constructor(e,t){var r;this._data={nodes:[],links:[]},this._previousData={nodes:[],links:[]},this._cosmographConfig={},this._cosmosConfig={},this._nodesForTopLabels=new Set,this._nodesForForcedLabels=new Set,this._trackedNodeToLabel=new Map,this._isLabelsDestroyed=!1,this._svgParser=new DOMParser,this._nodesCrossfilter=new yg(this._applyLinksFilter.bind(this)),this._linksCrossfilter=new yg(this._applyNodesFilter.bind(this)),this._nodesFilter=this._nodesCrossfilter.addFilter(!1),this._linksFilter=this._linksCrossfilter.addFilter(!1),this._selectedNodesFilter=this._nodesCrossfilter.addFilter(),this._isDataDifferent=()=>{const a=JSON.stringify(this._data.nodes),o=JSON.stringify(this._previousData.nodes),s=JSON.stringify(this._data.links),l=JSON.stringify(this._previousData.links);return a!==o||s!==l},this._onClick=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onClick)===null||s===void 0||s.call(o,...a)},this._onLabelClick=(a,o)=>{var s,l,d;const c=(s=this._cosmos)===null||s===void 0?void 0:s.graph.getNodeById(o.id);c&&((d=(l=this._cosmographConfig).onLabelClick)===null||d===void 0||d.call(l,c,a))},this._onHoveredNodeClick=a=>{var o,s;this._hoveredNode&&((s=(o=this._cosmographConfig).onLabelClick)===null||s===void 0||s.call(o,this._hoveredNode,a))},this._onNodeMouseOver=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onNodeMouseOver)===null||s===void 0||s.call(o,...a);const[l,,d]=a;this._hoveredNode=l,this._renderLabelForHovered(l,d)},this._onNodeMouseOut=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onNodeMouseOut)===null||s===void 0||s.call(o,...a),this._renderLabelForHovered()},this._onMouseMove=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onMouseMove)===null||s===void 0||s.call(o,...a);const[l,,d]=a;this._renderLabelForHovered(l,d)},this._onZoomStart=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onZoomStart)===null||s===void 0||s.call(o,...a)},this._onZoom=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onZoom)===null||s===void 0||s.call(o,...a),this._renderLabelForHovered(),this._renderLabels()},this._onZoomEnd=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onZoomEnd)===null||s===void 0||s.call(o,...a)},this._onStart=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationStart)===null||s===void 0||s.call(o,...a)},this._onTick=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationTick)===null||s===void 0||s.call(o,...a),this._renderLabels()},this._onEnd=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationEnd)===null||s===void 0||s.call(o,...a)},this._onPause=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationPause)===null||s===void 0||s.call(o,...a)},this._onRestart=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationRestart)===null||s===void 0||s.call(o,...a)},this._containerNode=e,this._containerNode.classList.add(gs.cosmograph),this._cosmographConfig=La(gg,t!=null?t:{}),this._cosmosConfig=this._createCosmosConfig(t),this._canvasElement=document.createElement("canvas"),this._labelsDivElement=document.createElement("div"),this._watermarkDivElement=document.createElement("div"),this._watermarkDivElement.classList.add(gs.watermark),this._watermarkDivElement.onclick=()=>{var a;return(a=window.open("https://cosmograph.app/","_blank"))===null||a===void 0?void 0:a.focus()},e.appendChild(this._canvasElement),e.appendChild(this._labelsDivElement),e.appendChild(this._watermarkDivElement),this._cssLabelsRenderer=new oE(this._labelsDivElement,{dispatchWheelEventElement:this._canvasElement,pointerEvents:"all",onLabelClick:this._onLabelClick.bind(this)}),this._hoveredCssLabel=new I0(this._labelsDivElement),this._hoveredCssLabel.setPointerEvents("all"),this._hoveredCssLabel.element.addEventListener("click",this._onHoveredNodeClick.bind(this)),this._linksFilter.setAccessor(a=>[a.source,a.target]),this._nodesFilter.setAccessor(a=>a.id),this._selectedNodesFilter.setAccessor(a=>a.id),this._nodesCrossfilter.onFiltered=()=>{var a,o,s,l;let d;this._nodesCrossfilter.isAnyFiltersActive()?(d=this._nodesCrossfilter.getFilteredRecords(),(a=this._cosmos)===null||a===void 0||a.selectNodesByIds(d.map(c=>c.id))):(o=this._cosmos)===null||o===void 0||o.unselectNodes(),this._updateSelectedNodesSet(d),(l=(s=this._cosmographConfig).onNodesFiltered)===null||l===void 0||l.call(s,d)},this._linksCrossfilter.onFiltered=()=>{var a,o;let s;this._linksCrossfilter.isAnyFiltersActive()&&(s=this._linksCrossfilter.getFilteredRecords()),(o=(a=this._cosmographConfig).onLinksFiltered)===null||o===void 0||o.call(a,s)};const n=this._svgParser.parseFromString(UA,"image/svg+xml").firstChild;(r=this._watermarkDivElement)===null||r===void 0||r.appendChild(n)}get data(){return this._data}get progress(){var e;return(e=this._cosmos)===null||e===void 0?void 0:e.progress}get isSimulationRunning(){var e;return(e=this._cosmos)===null||e===void 0?void 0:e.isSimulationRunning}get maxPointSize(){var e;return(e=this._cosmos)===null||e===void 0?void 0:e.maxPointSize}setData(e,t){var r,n,a,o;const{_cosmographConfig:s}=this;this._data={nodes:e,links:t};const l=s.disableSimulation===null?!t.length:s.disableSimulation;this._cosmos||(this._disableSimulation=l,this._cosmosConfig.disableSimulation=this._disableSimulation,this._cosmos=new iE(this._canvasElement,this._cosmosConfig),this.cosmos=this._cosmos),this._disableSimulation!==l&&console.warn(`The \`disableSimulation\` was initialized to \`${this._disableSimulation}\` during initialization and will not be modified.`),this._cosmos.setData(e,t),this._nodesCrossfilter.addRecords(e),this._linksCrossfilter.addRecords(t),this._updateLabels(),(n=(r=this._cosmographConfig).onSetData)===null||n===void 0||n.call(r,e,t),this._isDataDifferent()&&(["cosmograph.app"].includes(window.location.hostname)||I5({browser:navigator.userAgent,hostname:window.location.hostname,mode:null,is_library_metric:!0,links_count:t.length,links_have_time:null,links_raw_columns:t.length&&(a=Object.keys(t==null?void 0:t[0]).length)!==null&&a!==void 0?a:0,links_raw_lines:null,nodes_count:e.length,nodes_have_time:null,nodes_raw_columns:e.length&&(o=Object.keys(e==null?void 0:e[0]).length)!==null&&o!==void 0?o:0,nodes_raw_lines:null})),this._previousData={nodes:e,links:t}}setConfig(e){var t,r;if(this._cosmographConfig=La(gg,e!=null?e:{}),this._cosmosConfig=this._createCosmosConfig(e),(t=this._cosmos)===null||t===void 0||t.setConfig(this._cosmosConfig),e==null?void 0:e.backgroundColor){const n=(r=An(e==null?void 0:e.backgroundColor))===null||r===void 0?void 0:r.formatHex();if(n){const a=this._checkBrightness(n),o=document.querySelector(":root");a>.65?o==null||o.style.setProperty("--cosmograph-watermark-color","#000000"):o==null||o.style.setProperty("--cosmograph-watermark-color","#ffffff")}}this._updateLabels()}addNodesFilter(){return this._nodesCrossfilter.addFilter()}addLinksFilter(){return this._linksCrossfilter.addFilter()}selectNodesInRange(e){var t;if(!this._cosmos)return;this._cosmos.selectNodesInRange(e);const r=new Set(((t=this.getSelectedNodes())!==null&&t!==void 0?t:[]).map(n=>n.id));this._selectedNodesFilter.applyFilter(n=>r.has(n))}selectNodes(e){if(!this._cosmos)return;const t=new Set(e.map(r=>r.id));this._selectedNodesFilter.applyFilter(r=>t.has(r))}selectNode(e,t=!1){if(!this._cosmos)return;const r=new Set([e,...t&&this._cosmos.getAdjacentNodes(e.id)||[]].map(n=>n.id));this._selectedNodesFilter.applyFilter(n=>r.has(n))}unselectNodes(){this._cosmos&&this._selectedNodesFilter.clear()}getSelectedNodes(){if(this._cosmos)return this._cosmos.getSelectedNodes()}zoomToNode(e){this._cosmos&&this._cosmos.zoomToNodeById(e.id)}setZoomLevel(e,t=0){this._cosmos&&this._cosmos.setZoomLevel(e,t)}getZoomLevel(){if(this._cosmos)return this._cosmos.getZoomLevel()}getNodePositions(){if(this._cosmos)return this._cosmos.getNodePositions()}getNodePositionsMap(){if(this._cosmos)return this._cosmos.getNodePositionsMap()}getNodePositionsArray(){if(this._cosmos)return this._cosmos.getNodePositionsArray()}fitView(e=250){this._cosmos&&this._cosmos.fitView(e)}fitViewByNodeIds(e,t=250){this._cosmos&&this._cosmos.fitViewByNodeIds(e,t)}focusNode(e){this._cosmos&&this._cosmos.setFocusedNodeById(e==null?void 0:e.id)}getAdjacentNodes(e){if(this._cosmos)return this._cosmos.getAdjacentNodes(e)}spaceToScreenPosition(e){if(this._cosmos)return this._cosmos.spaceToScreenPosition(e)}spaceToScreenRadius(e){if(this._cosmos)return this._cosmos.spaceToScreenRadius(e)}getNodeRadiusByIndex(e){if(this._cosmos)return this._cosmos.getNodeRadiusByIndex(e)}getNodeRadiusById(e){if(this._cosmos)return this._cosmos.getNodeRadiusById(e)}getSampledNodePositionsMap(){if(this._cosmos)return this._cosmos.getSampledNodePositionsMap()}start(e=1){this._cosmos&&this._cosmos.start(e)}pause(){this._cosmos&&this._cosmos.pause()}restart(){this._cosmos&&this._cosmos.restart()}step(){this._cosmos&&this._cosmos.step()}remove(){var e;(e=this._cosmos)===null||e===void 0||e.destroy(),this._isLabelsDestroyed||(this._containerNode.innerHTML="",this._isLabelsDestroyed=!0,this._hoveredCssLabel.element.removeEventListener("click",this._onHoveredNodeClick.bind(this)),this._hoveredCssLabel.destroy(),this._cssLabelsRenderer.destroy())}create(){this._cosmos&&this._cosmos.create()}getNodeDegrees(){if(this._cosmos)return this._cosmos.graph.degree}_createCosmosConfig(e){const t=Il(Ei({},e),{simulation:Il(Ei({},Object.keys(e!=null?e:{}).filter(r=>r.indexOf("simulation")!==-1).reduce((r,n)=>{const a=n.replace("simulation","");return r[a.charAt(0).toLowerCase()+a.slice(1)]=e==null?void 0:e[n],r},{})),{onStart:this._onStart.bind(this),onTick:this._onTick.bind(this),onEnd:this._onEnd.bind(this),onPause:this._onPause.bind(this),onRestart:this._onRestart.bind(this)}),events:{onClick:this._onClick.bind(this),onNodeMouseOver:this._onNodeMouseOver.bind(this),onNodeMouseOut:this._onNodeMouseOut.bind(this),onMouseMove:this._onMouseMove.bind(this),onZoomStart:this._onZoomStart.bind(this),onZoom:this._onZoom.bind(this),onZoomEnd:this._onZoomEnd.bind(this)}});return delete t.disableSimulation,t}_updateLabels(){if(this._isLabelsDestroyed||!this._cosmos)return;const{_cosmos:e,data:{nodes:t},_cosmographConfig:{showTopLabels:r,showTopLabelsLimit:n,showLabelsFor:a,showTopLabelsValueKey:o,nodeLabelAccessor:s}}=this;if(this._nodesForTopLabels.clear(),r&&n){let l;l=o?[...t].sort((d,c)=>{const u=d[o],f=c[o];return typeof u=="number"&&typeof f=="number"?f-u:0}):Object.entries(e.graph.degree).sort((d,c)=>c[1]-d[1]).slice(0,n).map(d=>e.graph.getNodeByIndex(+d[0]));for(let d=0;d=t.length);d++){const c=l[d];c&&this._nodesForTopLabels.add(c)}}this._nodesForForcedLabels.clear(),a==null||a.forEach(this._nodesForForcedLabels.add,this._nodesForForcedLabels),this._trackedNodeToLabel.clear(),e.trackNodePositionsByIds([...r?this._nodesForTopLabels:[],...this._nodesForForcedLabels].map(l=>{var d;return this._trackedNodeToLabel.set(l,(d=s==null?void 0:s(l))!==null&&d!==void 0?d:l.id),l.id})),this._renderLabels()}_updateSelectedNodesSet(e){this._isLabelsDestroyed||(e?(this._selectedNodesSet=new Set,e==null||e.forEach(this._selectedNodesSet.add,this._selectedNodesSet)):this._selectedNodesSet=void 0,this._renderLabels())}_renderLabels(){if(this._isLabelsDestroyed||!this._cosmos)return;const{_cosmos:e,_selectedNodesSet:t,_cosmographConfig:{showDynamicLabels:r,nodeLabelAccessor:n,nodeLabelColor:a,nodeLabelClassName:o}}=this;let s=[];const l=e.getTrackedNodePositionsMap(),d=new Map;if(r){const c=this.getSampledNodePositionsMap();c==null||c.forEach((u,f)=>{var m;const p=e.graph.getNodeById(f);p&&d.set(p,[(m=n==null?void 0:n(p))!==null&&m!==void 0?m:p.id,u,gs.cosmographShowDynamicLabels,.7])})}this._nodesForTopLabels.forEach(c=>{d.set(c,[this._trackedNodeToLabel.get(c),l.get(c.id),gs.cosmographShowTopLabels,.9])}),this._nodesForForcedLabels.forEach(c=>{d.set(c,[this._trackedNodeToLabel.get(c),l.get(c.id),gs.cosmographShowLabelsFor,1])}),s=[...d.entries()].map(([c,[u,f,m,p]])=>{var y,x,E;const k=this.spaceToScreenPosition([(y=f==null?void 0:f[0])!==null&&y!==void 0?y:0,(x=f==null?void 0:f[1])!==null&&x!==void 0?x:0]),I=this.spaceToScreenRadius(e.config.nodeSizeScale*this.getNodeRadiusById(c.id)),v=!!t,M=t==null?void 0:t.has(c);return{id:c.id,text:u!=null?u:"",x:k[0],y:k[1]-(I+2),weight:v&&!M?.1:p,shouldBeShown:this._nodesForForcedLabels.has(c),style:v&&!M?"opacity: 0.1;":"",color:a&&(typeof a=="string"?a:a==null?void 0:a(c)),className:(E=typeof o=="string"?o:o==null?void 0:o(c))!==null&&E!==void 0?E:m}}),this._cssLabelsRenderer.setLabels(s),this._cssLabelsRenderer.draw(!0)}_renderLabelForHovered(e,t){var r,n;if(!this._cosmos)return;const{_cosmographConfig:{showHoveredNodeLabel:a,nodeLabelAccessor:o,hoveredNodeLabelClassName:s,hoveredNodeLabelColor:l}}=this;if(!this._isLabelsDestroyed){if(a&&e&&t){const d=this.spaceToScreenPosition(t),c=this.spaceToScreenRadius(this.getNodeRadiusById(e.id));this._hoveredCssLabel.setText((r=o==null?void 0:o(e))!==null&&r!==void 0?r:e.id),this._hoveredCssLabel.setVisibility(!0),this._hoveredCssLabel.setPosition(d[0],d[1]-(c+2)),this._hoveredCssLabel.setClassName(typeof s=="string"?s:(n=s==null?void 0:s(e))!==null&&n!==void 0?n:"");const u=l&&(typeof l=="string"?l:l==null?void 0:l(e));u&&this._hoveredCssLabel.setColor(u)}else this._hoveredCssLabel.setVisibility(!1);this._hoveredCssLabel.draw()}}_applyLinksFilter(){if(this._nodesCrossfilter.isAnyFiltersActive(this._nodesFilter)){const e=this._nodesCrossfilter.getFilteredRecords(this._nodesFilter),t=new Set(e.map(r=>r.id));this._linksFilter.applyFilter(r=>{const n=r==null?void 0:r[0],a=r==null?void 0:r[1];return t.has(n)&&t.has(a)})}else this._linksFilter.clear()}_applyNodesFilter(){if(this._linksCrossfilter.isAnyFiltersActive(this._linksFilter)){const e=this._linksCrossfilter.getFilteredRecords(this._linksFilter),t=new Set(e.map(r=>[r.source,r.target]).flat());this._nodesFilter.applyFilter(r=>t.has(r))}else this._nodesFilter.clear()}_checkBrightness(e){const t=(r=>{const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return n?{r:parseInt((n[1]||0).toString(),16),g:parseInt((n[2]||0).toString(),16),b:parseInt((n[3]||0).toString(),16)}:{r:0,g:0,b:0}})(e);return(.2126*t.r+.7152*t.g+.0722*t.b)/255}}const xg={onSelectResult:void 0,accessors:void 0};class G5{constructor(e,t,r){this._config={},this._data=[],this._defaultAccessors=[],this._createDefaultAccessorOptions=n=>n.length>0&&n[0]?Object.keys(n[0]).map(a=>({label:a,accessor:o=>String(o[a])})):[{label:"id",accessor:a=>a.id}],this._onSelect=(...n)=>{this._onSelectResult(...n)},this._onSearch=(...n)=>{var a,o;(o=(a=this._config).onSearch)===null||o===void 0||o.call(a,...n)},this._onEnter=(...n)=>{var a,o;(o=(a=this._config).onEnter)===null||o===void 0||o.call(a,...n)},this._onAccessorSelect=(...n)=>{var a,o;(o=(a=this._config).onAccessorSelect)===null||o===void 0||o.call(a,...n)},this._cosmograph=e,this._config=La(xg,r!=null?r:{}),this.search=new BA(t,this._createSearchConfig(r)),this._filter=this._cosmograph.addNodesFilter(),this._filter.onDataAdded=()=>{this._updateData()},this._updateData()}setConfig(e){const t=La(xg,e!=null?e:{});this._data.length&&t.accessors===void 0&&(t.accessors=this._defaultAccessors),this.search.setConfig(this._createSearchConfig(t)),this._config=t}_updateData(){const e=this._cosmograph.data.nodes;e!=null&&e.length&&(this._data=e,this.search.setData(this._data),this._config.accessors===void 0&&(this._defaultAccessors=this._createDefaultAccessorOptions(this._data),this.setConfig({accessors:this._defaultAccessors})))}getConfig(){return this._config}remove(){this.search.destroy()}setListState(e){this.search.setListState(e)}clearInput(){this.search.clearInput()}_onSelectResult(e){var t,r;this._cosmograph.pause(),this._cosmograph.zoomToNode(e),this._cosmograph.selectNode(e),(r=(t=this._config).onSelectResult)===null||r===void 0||r.call(t,e)}_createSearchConfig(e){return Il(Ei({},e),{events:{onSelect:this._onSelect.bind(this),onSearch:this._onSearch.bind(this),onEnter:this._onEnter.bind(this),onAccessorSelect:this._onAccessorSelect.bind(this)}})}}var bd;(function(i){i.Nodes="nodes",i.Links="links"})(bd||(bd={}));bd.Links;bd.Nodes;var wg={},Wc={},Xc=34,vs=10,Yc=13;function fv(i){return new Function("d","return {"+i.map(function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'}).join(",")+"}")}function j5(i,e){var t=fv(i);return function(r,n){return e(t(r),n,i)}}function Sg(i){var e=Object.create(null),t=[];return i.forEach(function(r){for(var n in r)n in e||t.push(e[n]=n)}),t}function Er(i,e){var t=i+"",r=t.length;return r9999?"+"+Er(i,6):Er(i,4)}function H5(i){var e=i.getUTCHours(),t=i.getUTCMinutes(),r=i.getUTCSeconds(),n=i.getUTCMilliseconds();return isNaN(i)?"Invalid Date":V5(i.getUTCFullYear())+"-"+Er(i.getUTCMonth()+1,2)+"-"+Er(i.getUTCDate(),2)+(n?"T"+Er(e,2)+":"+Er(t,2)+":"+Er(r,2)+"."+Er(n,3)+"Z":r?"T"+Er(e,2)+":"+Er(t,2)+":"+Er(r,2)+"Z":t||e?"T"+Er(e,2)+":"+Er(t,2)+"Z":"")}function q5(i){var e=new RegExp('["'+i+` + `}return Oe(String(V),!0)})((C=>{const Q={},V=Object.keys(C),ne=K.accessor(C);if(ne&&(Q[K.label]=ne),!m.ordering||!m.ordering.order&&!m.ordering.include){const Ge=Object.entries(C).findIndex(([tt,ot])=>K.accessor({[tt]:ot}));Ge!==-1&&V.splice(Ge,1);for(const tt of V)Q[tt]=C[tt];return Q}const Ve=m.ordering.order||[];let Re=m.ordering.include?new Set(m.ordering.include):null;if(Re||(Re=new Set(V)),Ve.length>0)for(const Ge of Ve)Ge in C&&(Q[Ge]=C[Ge]);for(const Ge in C)!Object.prototype.hasOwnProperty.call(Q,Ge)&&Re.has(Ge)&&(Q[Ge]=C[Ge]);return Q})(N)),N=>{N.preventDefault()},p,N=>{f==null||f.setOpen(N)},n,a,function(N){Ft[N?"unshift":"push"](()=>{s=N,t(5,s)})},function(N){y=N,t(0,y)},function(N){r=N,t(12,r),t(21,p),t(2,E),t(1,m),t(3,k)},function(N){Ft[N?"unshift":"push"](()=>{l=N,t(6,l)})},function(N){k=N,t(3,k)},function(N){Ft[N?"unshift":"push"](()=>{f=N,t(10,f)})},function(N){Ft[N?"unshift":"push"](()=>{d=N,t(7,d)})}]}class zA extends hr{constructor(e){super(),fr(this,e,MA,NA,Zi,{config:1,data:21,textInput:0,setListState:22},null,[-1,-1])}get setListState(){return this.$$.ctx[22]}}let BA=class{constructor(e,t){this._config={},this._containerNode=e,this._config=La(Ss,t!=null?t:{}),this._search=new zA({target:e,props:{config:this._config}}),this._search.$on(cn.Input,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onSearch)===null||a===void 0?void 0:a.call(n,r)}),this._search.$on(cn.Select,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onSelect)===null||a===void 0?void 0:a.call(n,r)}),this._search.$on(cn.Enter,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onEnter)===null||a===void 0?void 0:a.call(n,r)}),this._search.$on(cn.AccessorSelect,({detail:r})=>{var n,a;return(a=(n=this._config.events)===null||n===void 0?void 0:n.onAccessorSelect)===null||a===void 0?void 0:a.call(n,r)})}setData(e){this._search.$set({data:e,textInput:""})}setConfig(e){this._config=La(Ss,e!=null?e:{}),this._search.$set({config:this._config,textInput:""})}setListState(e){this._search.setListState(e)}clearInput(){this._search.$set({textInput:""})}getConfig(){return this._config}destroy(){this._containerNode.innerHTML=""}};const UA='',GA="modulepreload",jA=function(i){return"/static/"+i},Qp={},Do=function(e,t,r){let n=Promise.resolve();if(t&&t.length>0){const a=document.getElementsByTagName("link");n=Promise.all(t.map(o=>{if(o=jA(o),o in Qp)return;Qp[o]=!0;const s=o.endsWith(".css"),l=s?'[rel="stylesheet"]':"";if(!!r)for(let u=a.length-1;u>=0;u--){const f=a[u];if(f.href===o&&(!s||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${l}`))return;const c=document.createElement("link");if(c.rel=s?"stylesheet":GA,s||(c.as="script",c.crossOrigin=""),c.href=o,document.head.appendChild(c),s)return new Promise((u,f)=>{c.addEventListener("load",u),c.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${o}`)))})}))}return n.then(()=>e()).catch(a=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a})},VA=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=(...t)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)};class qu extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}}class HA extends qu{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class qA extends qu{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class WA extends qu{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var XA=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};class YA{constructor(e,{headers:t={},customFetch:r}={}){this.url=e,this.headers=t,this.fetch=VA(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r;return XA(this,void 0,void 0,function*(){try{const{headers:n,method:a,body:o}=t;let s={},l;o&&(n&&!Object.prototype.hasOwnProperty.call(n,"Content-Type")||!n)&&(typeof Blob!="undefined"&&o instanceof Blob||o instanceof ArrayBuffer?(s["Content-Type"]="application/octet-stream",l=o):typeof o=="string"?(s["Content-Type"]="text/plain",l=o):typeof FormData!="undefined"&&o instanceof FormData?l=o:(s["Content-Type"]="application/json",l=JSON.stringify(o)));const d=yield this.fetch(`${this.url}/${e}`,{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},s),this.headers),n),body:l}).catch(m=>{throw new HA(m)}),c=d.headers.get("x-relay-error");if(c&&c==="true")throw new qA(d);if(!d.ok)throw new WA(d);let u=((r=d.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),f;return u==="application/json"?f=yield d.json():u==="application/octet-stream"?f=yield d.blob():u==="multipart/form-data"?f=yield d.formData():f=yield d.text(),{data:f,error:null}}catch(n){return{data:null,error:n}}})}}var ZA=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("unable to locate global object")},Mo=ZA();const KA=Mo.fetch,Wu=Mo.fetch.bind(Mo),Y0=Mo.Headers,JA=Mo.Request,QA=Mo.Response,Bs=Object.freeze(Object.defineProperty({__proto__:null,Headers:Y0,Request:JA,Response:QA,default:Wu,fetch:KA},Symbol.toStringTag,{value:"Module"}));class e4 extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}class t4{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch=="undefined"?this.fetch=Wu:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const r=this.fetch;let n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(a=>fe(this,null,function*(){var o,s,l;let d=null,c=null,u=null,f=a.status,m=a.statusText;if(a.ok){if(this.method!=="HEAD"){const E=yield a.text();E===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?c=E:c=JSON.parse(E))}const y=(o=this.headers.Prefer)===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),x=(s=a.headers.get("content-range"))===null||s===void 0?void 0:s.split("/");y&&x&&x.length>1&&(u=parseInt(x[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(c)&&(c.length>1?(d={code:"PGRST116",details:`Results contain ${c.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},c=null,u=null,f=406,m="Not Acceptable"):c.length===1?c=c[0]:c=null)}else{const y=yield a.text();try{d=JSON.parse(y),Array.isArray(d)&&a.status===404&&(c=[],d=null,f=200,m="OK")}catch(x){a.status===404&&y===""?(f=204,m="No Content"):d={message:y}}if(d&&this.isMaybeSingle&&(!((l=d==null?void 0:d.details)===null||l===void 0)&&l.includes("0 rows"))&&(d=null,f=200,m="OK"),d&&this.shouldThrowOnError)throw new e4(d)}return{error:d,data:c,count:u,status:f,statusText:m}}));return this.shouldThrowOnError||(n=n.catch(a=>{var o,s,l;return{error:{message:`${(o=a==null?void 0:a.name)!==null&&o!==void 0?o:"FetchError"}: ${a==null?void 0:a.message}`,details:`${(s=a==null?void 0:a.stack)!==null&&s!==void 0?s:""}`,hint:"",code:`${(l=a==null?void 0:a.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}}class i4 extends t4{select(e){let t=!1;const r=(e!=null?e:"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:a=n}={}){const o=a?`${a}.order`:"order",s=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${s?`${s},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){const n=typeof r=="undefined"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){const a=typeof n=="undefined"?"offset":`${n}.offset`,o=typeof n=="undefined"?"limit":`${n}.limit`;return this.url.searchParams.set(a,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:a=!1,format:o="text"}={}){var s;const l=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,a?"wal":null].filter(Boolean).join("|"),d=(s=this.headers.Accept)!==null&&s!==void 0?s:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${d}"; options=${l};`,o==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class vo extends i4{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=t.map(n=>typeof n=="string"&&new RegExp("[,()]").test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let a="";n==="plain"?a="pl":n==="phrase"?a="ph":n==="websearch"&&(a="w");const o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${a}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){const n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}}class r4{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=t,this.schema=r,this.fetch=n}select(e,{head:t=!1,count:r}={}){const n=t?"HEAD":"GET";let a=!1;const o=(e!=null?e:"*").split("").map(s=>/\s/.test(s)&&!a?"":(s==='"'&&(a=!a),s)).join("");return this.url.searchParams.set("select",o),r&&(this.headers.Prefer=`count=${r}`),new vo({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:r=!0}={}){const n="POST",a=[];if(this.headers.Prefer&&a.push(this.headers.Prefer),t&&a.push(`count=${t}`),r||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){const o=e.reduce((s,l)=>s.concat(Object.keys(l)),[]);if(o.length>0){const s=[...new Set(o)].map(l=>`"${l}"`);this.url.searchParams.set("columns",s.join(","))}}return new vo({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:a=!0}={}){const o="POST",s=[`resolution=${r?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&s.push(this.headers.Prefer),n&&s.push(`count=${n}`),a||s.push("missing=default"),this.headers.Prefer=s.join(","),Array.isArray(e)){const l=e.reduce((d,c)=>d.concat(Object.keys(c)),[]);if(l.length>0){const d=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",d.join(","))}}return new vo({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const r="PATCH",n=[];return this.headers.Prefer&&n.push(this.headers.Prefer),t&&n.push(`count=${t}`),this.headers.Prefer=n.join(","),new vo({method:r,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t="DELETE",r=[];return e&&r.push(`count=${e}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new vo({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const n4="1.9.2",a4={"X-Client-Info":`postgrest-js/${n4}`};class Xu{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=Object.assign(Object.assign({},a4),t),this.schemaName=r,this.fetch=n}from(e){const t=new URL(`${this.url}/${e}`);return new r4(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new Xu(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:n}={}){let a;const o=new URL(`${this.url}/rpc/${e}`);let s;r?(a="HEAD",Object.entries(t).forEach(([d,c])=>{o.searchParams.append(d,`${c}`)})):(a="POST",s=t);const l=Object.assign({},this.headers);return n&&(l.Prefer=`count=${n}`),new vo({method:a,url:o,headers:l,schema:this.schemaName,body:s,fetch:this.fetch,allowEmpty:!1})}}const o4="2.9.3",s4={"X-Client-Info":`realtime-js/${o4}`},l4="1.0.0",Z0=1e4,d4=1e3;var Io;(function(i){i[i.connecting=0]="connecting",i[i.open=1]="open",i[i.closing=2]="closing",i[i.closed=3]="closed"})(Io||(Io={}));var Fr;(function(i){i.closed="closed",i.errored="errored",i.joined="joined",i.joining="joining",i.leaving="leaving"})(Fr||(Fr={}));var Wr;(function(i){i.close="phx_close",i.error="phx_error",i.join="phx_join",i.reply="phx_reply",i.leave="phx_leave",i.access_token="access_token"})(Wr||(Wr={}));var bu;(function(i){i.websocket="websocket"})(bu||(bu={}));var wa;(function(i){i.Connecting="connecting",i.Open="open",i.Closing="closing",i.Closed="closed"})(wa||(wa={}));class K0{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}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))}}class c4{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const n=t.getUint8(1),a=t.getUint8(2);let o=this.HEADER_LENGTH+2;const s=r.decode(e.slice(o,o+n));o=o+n;const l=r.decode(e.slice(o,o+a));o=o+a;const d=JSON.parse(r.decode(e.slice(o,e.byteLength)));return{ref:null,topic:s,event:l,payload:d}}}class Bc{constructor(e,t,r={},n=Z0){this.channel=e,this.event=t,this.payload=r,this.timeout=n,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,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()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var eg;(function(i){i.SYNC="sync",i.JOIN="join",i.LEAVE="leave"})(eg||(eg={}));class Ts{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},n=>{const{onJoin:a,onLeave:o,onSync:s}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Ts.syncState(this.state,n,a,o),this.pendingDiffs.forEach(l=>{this.state=Ts.syncDiff(this.state,l,a,o)}),this.pendingDiffs=[],s()}),this.channel._on(r.diff,{},n=>{const{onJoin:a,onLeave:o,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=Ts.syncDiff(this.state,n,a,o),s())}),this.onJoin((n,a,o)=>{this.channel._trigger("presence",{event:"join",key:n,currentPresences:a,newPresences:o})}),this.onLeave((n,a,o)=>{this.channel._trigger("presence",{event:"leave",key:n,currentPresences:a,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,n){const a=this.cloneDeep(e),o=this.transformState(t),s={},l={};return this.map(a,(d,c)=>{o[d]||(l[d]=c)}),this.map(o,(d,c)=>{const u=a[d];if(u){const f=c.map(x=>x.presence_ref),m=u.map(x=>x.presence_ref),p=c.filter(x=>m.indexOf(x.presence_ref)<0),y=u.filter(x=>f.indexOf(x.presence_ref)<0);p.length>0&&(s[d]=p),y.length>0&&(l[d]=y)}else s[d]=c}),this.syncDiff(a,{joins:s,leaves:l},r,n)}static syncDiff(e,t,r,n){const{joins:a,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),n||(n=()=>{}),this.map(a,(s,l)=>{var d;const c=(d=e[s])!==null&&d!==void 0?d:[];if(e[s]=this.cloneDeep(l),c.length>0){const u=e[s].map(m=>m.presence_ref),f=c.filter(m=>u.indexOf(m.presence_ref)<0);e[s].unshift(...f)}r(s,c,l)}),this.map(o,(s,l)=>{let d=e[s];if(!d)return;const c=l.map(u=>u.presence_ref);d=d.filter(u=>c.indexOf(u.presence_ref)<0),e[s]=d,n(s,d,l),d.length===0&&delete e[s]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,r)=>{const n=e[r];return"metas"in n?t[r]=n.metas.map(a=>(a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a)):t[r]=n,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var gi;(function(i){i.abstime="abstime",i.bool="bool",i.date="date",i.daterange="daterange",i.float4="float4",i.float8="float8",i.int2="int2",i.int4="int4",i.int4range="int4range",i.int8="int8",i.int8range="int8range",i.json="json",i.jsonb="jsonb",i.money="money",i.numeric="numeric",i.oid="oid",i.reltime="reltime",i.text="text",i.time="time",i.timestamp="timestamp",i.timestamptz="timestamptz",i.timetz="timetz",i.tsrange="tsrange",i.tstzrange="tstzrange"})(gi||(gi={}));const tg=(i,e,t={})=>{var r;const n=(r=t.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((a,o)=>(a[o]=u4(o,i,e,n),a),{})},u4=(i,e,t,r)=>{const n=e.find(s=>s.name===i),a=n==null?void 0:n.type,o=t[i];return a&&!r.includes(a)?J0(a,o):_u(o)},J0=(i,e)=>{if(i.charAt(0)==="_"){const t=i.slice(1,i.length);return p4(e,t)}switch(i){case gi.bool:return f4(e);case gi.float4:case gi.float8:case gi.int2:case gi.int4:case gi.int8:case gi.numeric:case gi.oid:return h4(e);case gi.json:case gi.jsonb:return m4(e);case gi.timestamp:return g4(e);case gi.abstime:case gi.date:case gi.daterange:case gi.int4range:case gi.int8range:case gi.money:case gi.reltime:case gi.text:case gi.time:case gi.timestamptz:case gi.timetz:case gi.tsrange:case gi.tstzrange:return _u(e);default:return _u(e)}},_u=i=>i,f4=i=>{switch(i){case"t":return!0;case"f":return!1;default:return i}},h4=i=>{if(typeof i=="string"){const e=parseFloat(i);if(!Number.isNaN(e))return e}return i},m4=i=>{if(typeof i=="string")try{return JSON.parse(i)}catch(e){return console.log(`JSON parse error: ${e}`),i}return i},p4=(i,e)=>{if(typeof i!="string")return i;const t=i.length-1,r=i[t];if(i[0]==="{"&&r==="}"){let a;const o=i.slice(1,t);try{a=JSON.parse("["+o+"]")}catch(s){a=o?o.split(","):[]}return a.map(s=>J0(e,s))}return i},g4=i=>typeof i=="string"?i.replace(" ","T"):i;var ig;(function(i){i.ALL="*",i.INSERT="INSERT",i.UPDATE="UPDATE",i.DELETE="DELETE"})(ig||(ig={}));var rg;(function(i){i.BROADCAST="broadcast",i.PRESENCE="presence",i.POSTGRES_CHANGES="postgres_changes"})(rg||(rg={}));var ng;(function(i){i.SUBSCRIBED="SUBSCRIBED",i.TIMED_OUT="TIMED_OUT",i.CLOSED="CLOSED",i.CHANNEL_ERROR="CHANNEL_ERROR"})(ng||(ng={}));class Yu{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=Fr.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new Bc(this,Wr.join,this.params,this.timeout),this.rejoinTimer=new K0(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Fr.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(n=>n.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Fr.closed,this.socket._remove(this)}),this._onError(n=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,n),this.state=Fr.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Fr.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Wr.reply,{},(n,a)=>{this._trigger(this._replyEventName(a),n)}),this.presence=new Ts(this),this.broadcastEndpointURL=this._broadcastEndpointURL()}subscribe(e,t=this.timeout){var r,n;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:a,presence:o}}=this.params;this._onError(d=>e&&e("CHANNEL_ERROR",d)),this._onClose(()=>e&&e("CLOSED"));const s={},l={broadcast:a,presence:o,postgres_changes:(n=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(d=>d.filter))!==null&&n!==void 0?n:[]};this.socket.accessToken&&(s.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:l},s)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",({postgres_changes:d})=>{var c;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),d===void 0){e&&e("SUBSCRIBED");return}else{const u=this.bindings.postgres_changes,f=(c=u==null?void 0:u.length)!==null&&c!==void 0?c:0,m=[];for(let p=0;p{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(d).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}track(r){return fe(this,arguments,function*(e,t={}){return yield this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)})}untrack(){return fe(this,arguments,function*(e={}){return yield this.send({type:"presence",event:"untrack"},e)})}on(e,t,r){return this._on(e,t,r)}send(r){return fe(this,arguments,function*(e,t={}){var n,a;if(!this._canPush()&&e.type==="broadcast"){const{event:o,payload:s}=e,l={method:"POST",headers:{apikey:(n=this.socket.apiKey)!==null&&n!==void 0?n:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:s}]})};try{return(yield this._fetchWithTimeout(this.broadcastEndpointURL,l,(a=t.timeout)!==null&&a!==void 0?a:this.timeout)).ok?"ok":"error"}catch(d){return d.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var s,l,d;const c=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((d=(l=(s=this.params)===null||s===void 0?void 0:s.config)===null||l===void 0?void 0:l.broadcast)===null||d===void 0)&&d.ack)&&o("ok"),c.receive("ok",()=>o("ok")),c.receive("timeout",()=>o("timed out"))})})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Fr.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Wr.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{const n=new Bc(this,Wr.leave,{},e);n.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),n.send(),this._canPush()||n.trigger("ok",{})})}_broadcastEndpointURL(){let e=this.socket.endPoint;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"}_fetchWithTimeout(e,t,r){return fe(this,null,function*(){const n=new AbortController,a=setTimeout(()=>n.abort(),r),o=yield this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}));return clearTimeout(a),o})}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let n=new Bc(this,e,t,r);return this._canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var n,a;const o=e.toLocaleLowerCase(),{close:s,error:l,leave:d,join:c}=Wr;if(r&&[s,l,d,c].indexOf(o)>=0&&r!==this._joinRef())return;let f=this._onMessage(o,t,r);if(t&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(n=this.bindings.postgres_changes)===null||n===void 0||n.filter(m=>{var p,y,x;return((p=m.filter)===null||p===void 0?void 0:p.event)==="*"||((x=(y=m.filter)===null||y===void 0?void 0:y.event)===null||x===void 0?void 0:x.toLocaleLowerCase())===o}).map(m=>m.callback(f,r)):(a=this.bindings[o])===null||a===void 0||a.filter(m=>{var p,y,x,E,k,I;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in m){const v=m.id,M=(p=m.filter)===null||p===void 0?void 0:p.event;return v&&((y=t.ids)===null||y===void 0?void 0:y.includes(v))&&(M==="*"||(M==null?void 0:M.toLocaleLowerCase())===((x=t.data)===null||x===void 0?void 0:x.type.toLocaleLowerCase()))}else{const v=(k=(E=m==null?void 0:m.filter)===null||E===void 0?void 0:E.event)===null||k===void 0?void 0:k.toLocaleLowerCase();return v==="*"||v===((I=t==null?void 0:t.event)===null||I===void 0?void 0:I.toLocaleLowerCase())}else return m.type.toLocaleLowerCase()===o}).map(m=>{if(typeof f=="object"&&"ids"in f){const p=f.data,{schema:y,table:x,commit_timestamp:E,type:k,errors:I}=p;f=Object.assign(Object.assign({},{schema:y,table:x,commit_timestamp:E,eventType:k,new:{},old:{},errors:I}),this._getPayloadRecords(p))}m.callback(f,r)})}_isClosed(){return this.state===Fr.closed}_isJoined(){return this.state===Fr.joined}_isJoining(){return this.state===Fr.joining}_isLeaving(){return this.state===Fr.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){const n=e.toLocaleLowerCase(),a={type:n,filter:t,callback:r};return this.bindings[n]?this.bindings[n].push(a):this.bindings[n]=[a],this}_off(e,t){const r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(n=>{var a;return!(((a=n.type)===null||a===void 0?void 0:a.toLocaleLowerCase())===r&&Yu.isEqual(n.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(Wr.close,{},e)}_onError(e){this._on(Wr.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Fr.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=tg(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=tg(e.columns,e.old_record)),t}}const v4=()=>{},b4=typeof WebSocket!="undefined";class _4{constructor(e,t){var r;this.accessToken=null,this.apiKey=null,this.channels=[],this.endPoint="",this.headers=s4,this.params={},this.timeout=Z0,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=v4,this.conn=null,this.sendBuffer=[],this.serializer=new c4,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this._resolveFetch=a=>{let o;return a?o=a:typeof fetch=="undefined"?o=(...s)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:l})=>l(...s)):o=fetch,(...s)=>o(...s)},this.endPoint=`${e}/${bu.websocket}`,t!=null&&t.transport?this.transport=t.transport:this.transport=null,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const n=(r=t==null?void 0:t.params)===null||r===void 0?void 0:r.apikey;n&&(this.accessToken=n,this.apiKey=n),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:a=>[1e3,2e3,5e3,1e4][a-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(a,o)=>o(JSON.stringify(a)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new K0(()=>fe(this,null,function*(){this.disconnect(),this.connect()}),this.reconnectAfterMs),this.fetch=this._resolveFetch(t==null?void 0:t.fetch)}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this._endPointURL(),void 0,{headers:this.headers});return}if(b4){this.conn=new WebSocket(this._endPointURL()),this.setupConnection();return}this.conn=new y4(this._endPointURL(),void 0,{close:()=>{this.conn=null}}),Do(()=>import("./browser-C1tfp1OT.js").then(e=>e.b),__vite__mapDeps([])).then(({default:e})=>{this.conn=new e(this._endPointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t!=null?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}removeChannel(e){return fe(this,null,function*(){const t=yield e.unsubscribe();return this.channels.length===0&&this.disconnect(),t})}removeAllChannels(){return fe(this,null,function*(){const e=yield Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e})}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case Io.connecting:return wa.Connecting;case Io.open:return wa.Open;case Io.closing:return wa.Closing;default:return wa.Closed}}isConnected(){return this.connectionState()===wa.Open}channel(e,t={config:{}}){const r=new Yu(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){const{topic:t,event:r,payload:n,ref:a}=e,o=()=>{this.encode(e,s=>{var l;(l=this.conn)===null||l===void 0||l.send(s)})};this.log("push",`${t} ${r} (${a})`,n),this.isConnected()?o():this.sendBuffer.push(o)}setAuth(e){this.accessToken=e,this.channels.forEach(t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(Wr.access_token,{access_token:e})})}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:l4}))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:r,event:n,payload:a,ref:o}=t;(o&&o===this.pendingHeartbeatRef||n===(a==null?void 0:a.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${a.status||""} ${r} ${n} ${o&&"("+o+")"||""}`,a),this.channels.filter(s=>s._isMember(r)).forEach(s=>s._trigger(n,a,o)),this.stateChangeCallbacks.message.forEach(s=>s(t))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(Wr.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;const r=e.match(/\?/)?"&":"?",n=new URLSearchParams(t);return`${e}${r}${n}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(d4,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}class y4{constructor(e,t,r){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=Io.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=r.close}}class Zu extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function pr(i){return typeof i=="object"&&i!==null&&"__isStorageError"in i}class x4 extends Zu{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class ag extends Zu{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var w4=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const Q0=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=(...t)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},S4=()=>w4(void 0,void 0,void 0,function*(){return typeof Response=="undefined"?(yield Do(()=>Promise.resolve().then(()=>Bs),void 0)).Response:Response});var zo=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const Uc=i=>i.msg||i.message||i.error_description||i.error||JSON.stringify(i),E4=(i,e)=>zo(void 0,void 0,void 0,function*(){const t=yield S4();i instanceof t?i.json().then(r=>{e(new x4(Uc(r),i.status||500))}).catch(r=>{e(new ag(Uc(r),r))}):e(new ag(Uc(i),i))}),T4=(i,e,t,r)=>{const n={method:i,headers:(e==null?void 0:e.headers)||{}};return i==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),n.body=JSON.stringify(r),Object.assign(Object.assign({},n),t))};function Sd(i,e,t,r,n,a){return zo(this,void 0,void 0,function*(){return new Promise((o,s)=>{i(t,T4(e,r,n,a)).then(l=>{if(!l.ok)throw l;return r!=null&&r.noResolveJson?l:l.json()}).then(l=>o(l)).catch(l=>E4(l,s))})})}function yu(i,e,t,r){return zo(this,void 0,void 0,function*(){return Sd(i,"GET",e,t,r)})}function Wn(i,e,t,r,n){return zo(this,void 0,void 0,function*(){return Sd(i,"POST",e,r,n,t)})}function I4(i,e,t,r,n){return zo(this,void 0,void 0,function*(){return Sd(i,"PUT",e,r,n,t)})}function ev(i,e,t,r,n){return zo(this,void 0,void 0,function*(){return Sd(i,"DELETE",e,r,n,t)})}var zr=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const A4={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},og={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class C4{constructor(e,t={},r,n){this.url=e,this.headers=t,this.bucketId=r,this.fetch=Q0(n)}uploadOrUpdate(e,t,r,n){return zr(this,void 0,void 0,function*(){try{let a;const o=Object.assign(Object.assign({},og),n),s=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});typeof Blob!="undefined"&&r instanceof Blob?(a=new FormData,a.append("cacheControl",o.cacheControl),a.append("",r)):typeof FormData!="undefined"&&r instanceof FormData?(a=r,a.append("cacheControl",o.cacheControl)):(a=r,s["cache-control"]=`max-age=${o.cacheControl}`,s["content-type"]=o.contentType);const l=this._removeEmptyFolders(t),d=this._getFinalPath(l),c=yield this.fetch(`${this.url}/object/${d}`,Object.assign({method:e,body:a,headers:s},o!=null&&o.duplex?{duplex:o.duplex}:{})),u=yield c.json();return c.ok?{data:{path:l,id:u.Id,fullPath:u.Key},error:null}:{data:null,error:u}}catch(a){if(pr(a))return{data:null,error:a};throw a}})}upload(e,t,r){return zr(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,n){return zr(this,void 0,void 0,function*(){const a=this._removeEmptyFolders(e),o=this._getFinalPath(a),s=new URL(this.url+`/object/upload/sign/${o}`);s.searchParams.set("token",t);try{let l;const d=Object.assign({upsert:og.upsert},n),c=Object.assign(Object.assign({},this.headers),{"x-upsert":String(d.upsert)});typeof Blob!="undefined"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",d.cacheControl),l.append("",r)):typeof FormData!="undefined"&&r instanceof FormData?(l=r,l.append("cacheControl",d.cacheControl)):(l=r,c["cache-control"]=`max-age=${d.cacheControl}`,c["content-type"]=d.contentType);const u=yield this.fetch(s.toString(),{method:"PUT",body:l,headers:c}),f=yield u.json();return u.ok?{data:{path:a,fullPath:f.Key},error:null}:{data:null,error:f}}catch(l){if(pr(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e){return zr(this,void 0,void 0,function*(){try{let t=this._getFinalPath(e);const r=yield Wn(this.fetch,`${this.url}/object/upload/sign/${t}`,{},{headers:this.headers}),n=new URL(this.url+r.url),a=n.searchParams.get("token");if(!a)throw new Zu("No token returned by API");return{data:{signedUrl:n.toString(),path:e,token:a},error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}update(e,t,r){return zr(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t){return zr(this,void 0,void 0,function*(){try{return{data:yield Wn(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}copy(e,t){return zr(this,void 0,void 0,function*(){try{return{data:{path:(yield Wn(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers})).Key},error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}createSignedUrl(e,t,r){return zr(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),a=yield Wn(this.fetch,`${this.url}/object/sign/${n}`,Object.assign({expiresIn:t},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers});const o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return a={signedUrl:encodeURI(`${this.url}${a.signedURL}${o}`)},{data:a,error:null}}catch(n){if(pr(n))return{data:null,error:n};throw n}})}createSignedUrls(e,t,r){return zr(this,void 0,void 0,function*(){try{const n=yield Wn(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),a=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:n.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${a}`):null})),error:null}}catch(n){if(pr(n))return{data:null,error:n};throw n}})}download(e,t){return zr(this,void 0,void 0,function*(){const n=typeof(t==null?void 0:t.transform)!="undefined"?"render/image/authenticated":"object",a=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),o=a?`?${a}`:"";try{const s=this._getFinalPath(e);return{data:yield(yield yu(this.fetch,`${this.url}/${n}/${s}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(s){if(pr(s))return{data:null,error:s};throw s}})}getPublicUrl(e,t){const r=this._getFinalPath(e),n=[],a=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";a!==""&&n.push(a);const s=typeof(t==null?void 0:t.transform)!="undefined"?"render/image":"object",l=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});l!==""&&n.push(l);let d=n.join("&");return d!==""&&(d=`?${d}`),{data:{publicUrl:encodeURI(`${this.url}/${s}/public/${r}${d}`)}}}remove(e){return zr(this,void 0,void 0,function*(){try{return{data:yield ev(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}list(e,t,r){return zr(this,void 0,void 0,function*(){try{const n=Object.assign(Object.assign(Object.assign({},A4),t),{prefix:e||""});return{data:yield Wn(this.fetch,`${this.url}/object/list/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(pr(n))return{data:null,error:n};throw n}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const k4="2.5.5",$4={"X-Client-Info":`storage-js/${k4}`};var co=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};class L4{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},$4),t),this.fetch=Q0(r)}listBuckets(){return co(this,void 0,void 0,function*(){try{return{data:yield yu(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(pr(e))return{data:null,error:e};throw e}})}getBucket(e){return co(this,void 0,void 0,function*(){try{return{data:yield yu(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return co(this,void 0,void 0,function*(){try{return{data:yield Wn(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}updateBucket(e,t){return co(this,void 0,void 0,function*(){try{return{data:yield I4(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(pr(r))return{data:null,error:r};throw r}})}emptyBucket(e){return co(this,void 0,void 0,function*(){try{return{data:yield Wn(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}deleteBucket(e){return co(this,void 0,void 0,function*(){try{return{data:yield ev(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(pr(t))return{data:null,error:t};throw t}})}}class O4 extends L4{constructor(e,t={},r){super(e,t,r)}from(e){return new C4(this.url,this.headers,e,this.fetch)}}const R4="2.39.7";let ys="";typeof Deno!="undefined"?ys="deno":typeof document!="undefined"?ys="web":typeof navigator!="undefined"&&navigator.product==="ReactNative"?ys="react-native":ys="node";const F4={"X-Client-Info":`supabase-js-${ys}/${R4}`},N4={headers:F4},P4={schema:"public"},D4={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},M4={};var z4=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};const B4=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=Wu:e=fetch,(...t)=>e(...t)},U4=()=>typeof Headers=="undefined"?Y0:Headers,G4=(i,e,t)=>{const r=B4(t),n=U4();return(a,o)=>z4(void 0,void 0,void 0,function*(){var s;const l=(s=yield e())!==null&&s!==void 0?s:i;let d=new n(o==null?void 0:o.headers);return d.has("apikey")||d.set("apikey",i),d.has("Authorization")||d.set("Authorization",`Bearer ${l}`),r(a,Object.assign(Object.assign({},o),{headers:d}))})};function j4(i){return i.replace(/\/$/,"")}function V4(i,e){const{db:t,auth:r,realtime:n,global:a}=i,{db:o,auth:s,realtime:l,global:d}=e;return{db:Object.assign(Object.assign({},o),t),auth:Object.assign(Object.assign({},s),r),realtime:Object.assign(Object.assign({},l),n),global:Object.assign(Object.assign({},d),a)}}function H4(i){return Math.round(Date.now()/1e3)+i}function q4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const e=Math.random()*16|0;return(i=="x"?e:e&3|8).toString(16)})}const qr=()=>typeof document!="undefined",ba={tested:!1,writable:!1},Is=()=>{if(!qr())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch(e){return!1}if(ba.tested)return ba.writable;const i=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(i,i),globalThis.localStorage.removeItem(i),ba.tested=!0,ba.writable=!0}catch(e){ba.tested=!0,ba.writable=!1}return ba.writable};function Gc(i){const e={},t=new URL(i);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((n,a)=>{e[a]=n})}catch(r){}return t.searchParams.forEach((r,n)=>{e[n]=r}),e}const tv=i=>{let e;return i?e=i:typeof fetch=="undefined"?e=(...t)=>Do(()=>Promise.resolve().then(()=>Bs),void 0).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},W4=i=>typeof i=="object"&&i!==null&&"status"in i&&"ok"in i&&"json"in i&&typeof i.json=="function",_a=(i,e,t)=>fe(void 0,null,function*(){yield i.setItem(e,JSON.stringify(t))}),Ml=(i,e)=>fe(void 0,null,function*(){const t=yield i.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch(r){return t}}),jc=(i,e)=>fe(void 0,null,function*(){yield i.removeItem(e)});function X4(i){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",r,n,a,o,s,l,d,c=0;for(i=i.replace("-","+").replace("_","/");c>4,n=(s&15)<<4|l>>2,a=(l&3)<<6|d,t=t+String.fromCharCode(r),l!=64&&n!=0&&(t=t+String.fromCharCode(n)),d!=64&&a!=0&&(t=t+String.fromCharCode(a));return t}class Ed{constructor(){this.promise=new Ed.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}Ed.promiseConstructor=Promise;function sg(i){const e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=i.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");const r=t[1];return JSON.parse(X4(r))}function Y4(i){return fe(this,null,function*(){return yield new Promise(e=>{setTimeout(()=>e(null),i)})})}function Z4(i,e){return new Promise((r,n)=>{fe(this,null,function*(){for(let a=0;a<1/0;a++)try{const o=yield i(a);if(!e(a,null,o)){r(o);return}}catch(o){if(!e(a,o)){n(o);return}}})})}function K4(i){return("0"+i.toString(16)).substr(-2)}function uo(){const e=new Uint32Array(56);if(typeof crypto=="undefined"){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=t.length;let n="";for(let a=0;a<56;a++)n+=t.charAt(Math.floor(Math.random()*r));return n}return crypto.getRandomValues(e),Array.from(e,K4).join("")}function J4(i){return fe(this,null,function*(){const t=new TextEncoder().encode(i),r=yield crypto.subtle.digest("SHA-256",t),n=new Uint8Array(r);return Array.from(n).map(a=>String.fromCharCode(a)).join("")})}function Q4(i){return btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function fo(i){return fe(this,null,function*(){if(!(typeof crypto!="undefined"&&typeof crypto.subtle!="undefined"&&typeof TextEncoder!="undefined"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),i;const t=yield J4(i);return Q4(t)})}class Ku extends Error{constructor(e,t){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t}}function Bt(i){return typeof i=="object"&&i!==null&&"__isAuthError"in i}class e5 extends Ku{constructor(e,t){super(e,t),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}function t5(i){return Bt(i)&&i.name==="AuthApiError"}class iv extends Ku{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class Da extends Ku{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class ho extends Da{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class Vc extends Da{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500)}}class zl extends Da{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class Bl extends Da{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class lg extends Da{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class xu extends Da{constructor(e,t){super(e,"AuthRetryableFetchError",t)}}function Hc(i){return Bt(i)&&i.name==="AuthRetryableFetchError"}class i5 extends Da{constructor(e,t,r){super(e,"AuthWeakPasswordError",t),this.reasons=r}}var r5=function(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(i);ni.msg||i.message||i.error_description||i.error||JSON.stringify(i),n5=[502,503,504];function dg(i){return fe(this,null,function*(){if(!W4(i))throw new xu(bo(i),0);if(n5.includes(i.status))throw new xu(bo(i),i.status);let e;try{e=yield i.json()}catch(t){throw new iv(bo(t),t)}throw typeof e=="object"&&e&&typeof e.weak_password=="object"&&e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)?new i5(bo(e),i.status,e.weak_password.reasons):new e5(bo(e),i.status||500)})}const a5=(i,e,t,r)=>{const n={method:i,headers:(e==null?void 0:e.headers)||{}};return i==="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),t))};function jt(i,e,t,r){return fe(this,null,function*(){var n;const a=Object.assign({},r==null?void 0:r.headers);r!=null&&r.jwt&&(a.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 s=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=yield o5(i,e,t+s,{headers:a,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}})}function o5(i,e,t,r,n,a){return fe(this,null,function*(){const o=a5(e,r,n,a);let s;try{s=yield i(t,o)}catch(l){throw console.error(l),new xu(bo(l),0)}if(s.ok||(yield dg(s)),r!=null&&r.noResolveJson)return s;try{return yield s.json()}catch(l){yield dg(l)}})}function ya(i){var e;let t=null;c5(i)&&(t=Object.assign({},i),i.expires_at||(t.expires_at=H4(i.expires_in)));const r=(e=i.user)!==null&&e!==void 0?e:i;return{data:{session:t,user:r},error:null}}function cg(i){const e=ya(i);return!e.error&&i.weak_password&&typeof i.weak_password=="object"&&Array.isArray(i.weak_password.reasons)&&i.weak_password.reasons.length&&i.weak_password.message&&typeof i.weak_password.message=="string"&&i.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)&&(e.data.weak_password=i.weak_password),e}function Xn(i){var e;return{data:{user:(e=i.user)!==null&&e!==void 0?e:i},error:null}}function s5(i){return{data:i,error:null}}function l5(i){const{action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:a}=i,o=r5(i,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),s={action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:a},l=Object.assign({},o);return{data:{properties:s,user:l},error:null}}function d5(i){return i}function c5(i){return i.access_token&&i.refresh_token&&i.expires_in}var u5=function(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(i);n0&&(m.forEach(p=>{const y=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),x=JSON.parse(p.split(";")[1].split("=")[1]);d[`${x}Page`]=y}),d.total=parseInt(f)),{data:Object.assign(Object.assign({},u),d),error:null}}catch(d){if(Bt(d))return{data:{users:[]},error:d};throw d}})}getUserById(e){return fe(this,null,function*(){try{return yield jt(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Xn})}catch(t){if(Bt(t))return{data:{user:null},error:t};throw t}})}updateUserById(e,t){return fe(this,null,function*(){try{return yield jt(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:Xn})}catch(r){if(Bt(r))return{data:{user:null},error:r};throw r}})}deleteUser(e,t=!1){return fe(this,null,function*(){try{return yield jt(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:Xn})}catch(r){if(Bt(r))return{data:{user:null},error:r};throw r}})}_listFactors(e){return fe(this,null,function*(){try{const{data:t,error:r}=yield jt(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:t,error:r}}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}_deleteFactor(e){return fe(this,null,function*(){try{return{data:yield jt(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}}const rv="0.0.0",h5="http://localhost:9999",m5="supabase.auth.token",p5={"X-Client-Info":`gotrue-js/${rv}`},ug=10,g5={getItem:i=>Is()?globalThis.localStorage.getItem(i):null,setItem:(i,e)=>{Is()&&globalThis.localStorage.setItem(i,e)},removeItem:i=>{Is()&&globalThis.localStorage.removeItem(i)}};function fg(i={}){return{getItem:e=>i[e]||null,setItem:(e,t)=>{i[e]=t},removeItem:e=>{delete i[e]}}}function v5(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(i){typeof self!="undefined"&&(self.globalThis=self)}}const mo={debug:!!(globalThis&&Is()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class nv extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class b5 extends nv{}function _5(i,e,t){return fe(this,null,function*(){mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",i,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),mo.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",i)},e),yield globalThis.navigator.locks.request(i,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},n=>fe(this,null,function*(){if(n){mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",i,n.name);try{return yield t()}finally{mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",i,n.name)}}else{if(e===0)throw mo.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",i),new b5(`Acquiring an exclusive Navigator LockManager lock "${i}" immediately failed`);if(mo.debug)try{const a=yield globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}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"),yield t()}}))})}v5();const y5={url:h5,storageKey:m5,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:p5,flowType:"implicit",debug:!1},ms=30*1e3,hg=3;function mg(i,e,t){return fe(this,null,function*(){return yield t()})}class Ns{constructor(e){var t,r;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Ns.nextInstanceID,Ns.nextInstanceID+=1,this.instanceID>0&&qr()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const n=Object.assign(Object.assign({},y5),e);if(this.logDebugMessages=!!n.debug,typeof n.debug=="function"&&(this.logger=n.debug),this.persistSession=n.persistSession,this.storageKey=n.storageKey,this.autoRefreshToken=n.autoRefreshToken,this.admin=new f5({url:n.url,headers:n.headers,fetch:n.fetch}),this.url=n.url,this.headers=n.headers,this.fetch=tv(n.fetch),this.lock=n.lock||mg,this.detectSessionInUrl=n.detectSessionInUrl,this.flowType=n.flowType,n.lock?this.lock=n.lock:qr()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=_5:this.lock=mg,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?n.storage?this.storage=n.storage:Is()?this.storage=g5:(this.memoryStorage={},this.storage=fg(this.memoryStorage)):(this.memoryStorage={},this.storage=fg(this.memoryStorage)),qr()&&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)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",a=>fe(this,null,function*(){this._debug("received broadcast notification from other tab or client",a),yield this._notifyAllSubscribers(a.data.event,a.data.session,!1)}))}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${rv}) ${new Date().toISOString()}`,...e),this}initialize(){return fe(this,null,function*(){return this.initializePromise?yield this.initializePromise:(this.initializePromise=fe(this,null,function*(){return yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._initialize()}))}),yield this.initializePromise)})}_initialize(){return fe(this,null,function*(){try{const e=qr()?yield this._isPKCEFlow():!1;if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){const{data:t,error:r}=yield this._getSessionFromURL(e);if(r)return this._debug("#_initialize()","error detecting session from URL",r),(r==null?void 0:r.message)==="Identity is already linked"||(r==null?void 0:r.message)==="Identity is already linked to another user"?{error:r}:(yield this._removeSession(),{error:r});const{session:n,redirectType:a}=t;return this._debug("#_initialize()","detected session in URL",n,"redirect type",a),yield this._saveSession(n),setTimeout(()=>fe(this,null,function*(){a==="recovery"?yield this._notifyAllSubscribers("PASSWORD_RECOVERY",n):yield this._notifyAllSubscribers("SIGNED_IN",n)}),0),{error:null}}return yield this._recoverAndRefresh(),{error:null}}catch(e){return Bt(e)?{error:e}:{error:new iv("Unexpected error during initialization",e)}}finally{yield this._handleVisibilityChange(),this._debug("#_initialize()","end")}})}signUp(e){return fe(this,null,function*(){var t,r,n;try{yield this._removeSession();let a;if("email"in e){const{email:c,password:u,options:f}=e;let m=null,p=null;if(this.flowType==="pkce"){const y=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,y),m=yield fo(y),p=y===m?"plain":"s256"}a=yield jt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:c,password:u,data:(t=f==null?void 0:f.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:p},xform:ya})}else if("phone"in e){const{phone:c,password:u,options:f}=e;a=yield jt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:c,password:u,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:ya})}else throw new zl("You must provide either an email or phone number and a password");const{data:o,error:s}=a;if(s||!o)return{data:{user:null,session:null},error:s};const l=o.session,d=o.user;return o.session&&(yield this._saveSession(o.session),yield this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:d,session:l},error:null}}catch(a){if(Bt(a))return{data:{user:null,session:null},error:a};throw a}})}signInWithPassword(e){return fe(this,null,function*(){try{yield this._removeSession();let t;if("email"in e){const{email:a,password:o,options:s}=e;t=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:o,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:cg})}else if("phone"in e){const{phone:a,password:o,options:s}=e;t=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:o,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:cg})}else throw new zl("You must provide either an email or phone number and a password");const{data:r,error:n}=t;return n?{data:{user:null,session:null},error:n}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new Vc}:(r.session&&(yield this._saveSession(r.session),yield this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:n})}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}signInWithOAuth(e){return fe(this,null,function*(){var t,r,n,a;return yield this._removeSession(),yield this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.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:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})})}exchangeCodeForSession(e){return fe(this,null,function*(){return yield this.initializePromise,this._acquireLock(-1,()=>fe(this,null,function*(){return this._exchangeCodeForSession(e)}))})}_exchangeCodeForSession(e){return fe(this,null,function*(){const t=yield Ml(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(t!=null?t:"").split("/"),{data:a,error:o}=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:ya});return yield jc(this.storage,`${this.storageKey}-code-verifier`),o?{data:{user:null,session:null,redirectType:null},error:o}:!a||!a.session||!a.user?{data:{user:null,session:null,redirectType:null},error:new Vc}:(a.session&&(yield this._saveSession(a.session),yield this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:Object.assign(Object.assign({},a),{redirectType:n!=null?n:null}),error:o})})}signInWithIdToken(e){return fe(this,null,function*(){yield this._removeSession();try{const{options:t,provider:r,token:n,access_token:a,nonce:o}=e,s=yield jt(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:n,access_token:a,nonce:o,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:ya}),{data:l,error:d}=s;return d?{data:{user:null,session:null},error:d}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new Vc}:(l.session&&(yield this._saveSession(l.session),yield this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:d})}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}signInWithOtp(e){return fe(this,null,function*(){var t,r,n,a,o;try{if(yield this._removeSession(),"email"in e){const{email:s,options:l}=e;let d=null,c=null;if(this.flowType==="pkce"){const f=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,f),d=yield fo(f),c=f===d?"plain":"s256"}const{error:u}=yield jt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:(t=l==null?void 0:l.data)!==null&&t!==void 0?t:{},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:d,code_challenge_method:c},redirectTo:l==null?void 0:l.emailRedirectTo});return{data:{user:null,session:null},error:u}}if("phone"in e){const{phone:s,options:l}=e,{data:d,error:c}=yield jt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:s,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(a=l==null?void 0:l.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:d==null?void 0:d.message_id},error:c}}throw new zl("You must provide either an email or phone number.")}catch(s){if(Bt(s))return{data:{user:null,session:null},error:s};throw s}})}verifyOtp(e){return fe(this,null,function*(){var t,r;try{e.type!=="email_change"&&e.type!=="phone_change"&&(yield this._removeSession());let n,a;"options"in e&&(n=(t=e.options)===null||t===void 0?void 0:t.redirectTo,a=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:s}=yield jt(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:n,xform:ya});if(s)throw s;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,d=o.user;return l!=null&&l.access_token&&(yield this._saveSession(l),yield this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:d,session:l},error:null}}catch(n){if(Bt(n))return{data:{user:null,session:null},error:n};throw n}})}signInWithSSO(e){return fe(this,null,function*(){var t,r,n;try{yield this._removeSession();let a=null,o=null;if(this.flowType==="pkce"){const s=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,s),a=yield fo(s),o=s===a?"plain":"s256"}return yield jt(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=(t=e.options)===null||t===void 0?void 0:t.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:o}),headers:this.headers,xform:s5})}catch(a){if(Bt(a))return{data:null,error:a};throw a}})}reauthenticate(){return fe(this,null,function*(){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._reauthenticate()}))})}_reauthenticate(){return fe(this,null,function*(){try{return yield this._useSession(e=>fe(this,null,function*(){const{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new ho;const{error:n}=yield jt(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:n}}))}catch(e){if(Bt(e))return{data:{user:null,session:null},error:e};throw e}})}resend(e){return fe(this,null,function*(){try{e.type!="email_change"&&e.type!="phone_change"&&(yield this._removeSession());const t=`${this.url}/resend`;if("email"in e){const{email:r,type:n,options:a}=e,{error:o}=yield jt(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:r,type:n,options:a}=e,{data:o,error:s}=yield jt(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:n,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:s}}throw new zl("You must provide either an email or phone number and a type")}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}getSession(){return fe(this,null,function*(){return yield this.initializePromise,this._acquireLock(-1,()=>fe(this,null,function*(){return this._useSession(e=>fe(this,null,function*(){return e}))}))})}_acquireLock(e,t){return fe(this,null,function*(){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=fe(this,null,function*(){return yield r,yield t()});return this.pendingInLock.push(fe(this,null,function*(){try{yield n}catch(a){}})),n}return yield this.lock(`lock:${this.storageKey}`,e,()=>fe(this,null,function*(){this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=t();for(this.pendingInLock.push(fe(this,null,function*(){try{yield r}catch(n){}})),yield r;this.pendingInLock.length;){const n=[...this.pendingInLock];yield Promise.all(n),this.pendingInLock.splice(0,n.length)}return yield r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}}))}finally{this._debug("#_acquireLock","end")}})}_useSession(e){return fe(this,null,function*(){this._debug("#_useSession","begin");try{const t=yield this.__loadSession();return yield e(t)}finally{this._debug("#_useSession","end")}})}__loadSession(){return fe(this,null,function*(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const t=yield Ml(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),yield this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r)return{data:{session:e},error:null};const{session:n,error:a}=yield this._callRefreshToken(e.refresh_token);return a?{data:{session:null},error:a}:{data:{session:n},error:null}}finally{this._debug("#__loadSession()","end")}})}getUser(e){return fe(this,null,function*(){return e?yield this._getUser(e):(yield this.initializePromise,this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._getUser()})))})}_getUser(e){return fe(this,null,function*(){try{return e?yield jt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Xn}):yield this._useSession(t=>fe(this,null,function*(){var r,n;const{data:a,error:o}=t;if(o)throw o;return yield jt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(n=(r=a.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0,xform:Xn})}))}catch(t){if(Bt(t))return{data:{user:null},error:t};throw t}})}updateUser(r){return fe(this,arguments,function*(e,t={}){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._updateUser(e,t)}))})}_updateUser(r){return fe(this,arguments,function*(e,t={}){try{return yield this._useSession(n=>fe(this,null,function*(){const{data:a,error:o}=n;if(o)throw o;if(!a.session)throw new ho;const s=a.session;let l=null,d=null;if(this.flowType==="pkce"&&e.email!=null){const f=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,f),l=yield fo(f),d=f===l?"plain":"s256"}const{data:c,error:u}=yield jt(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:l,code_challenge_method:d}),jwt:s.access_token,xform:Xn});if(u)throw u;return s.user=c.user,yield this._saveSession(s),yield this._notifyAllSubscribers("USER_UPDATED",s),{data:{user:s.user},error:null}}))}catch(n){if(Bt(n))return{data:{user:null},error:n};throw n}})}_decodeJWT(e){return sg(e)}setSession(e){return fe(this,null,function*(){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._setSession(e)}))})}_setSession(e){return fe(this,null,function*(){try{if(!e.access_token||!e.refresh_token)throw new ho;const t=Date.now()/1e3;let r=t,n=!0,a=null;const o=sg(e.access_token);if(o.exp&&(r=o.exp,n=r<=t),n){const{session:s,error:l}=yield this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!s)return{data:{user:null,session:null},error:null};a=s}else{const{data:s,error:l}=yield this._getUser(e.access_token);if(l)throw l;a={access_token:e.access_token,refresh_token:e.refresh_token,user:s.user,token_type:"bearer",expires_in:r-t,expires_at:r},yield this._saveSession(a),yield this._notifyAllSubscribers("SIGNED_IN",a)}return{data:{user:a.user,session:a},error:null}}catch(t){if(Bt(t))return{data:{session:null,user:null},error:t};throw t}})}refreshSession(e){return fe(this,null,function*(){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._refreshSession(e)}))})}_refreshSession(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;if(!e){const{data:o,error:s}=t;if(s)throw s;e=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new ho;const{session:n,error:a}=yield this._callRefreshToken(e.refresh_token);return a?{data:{user:null,session:null},error:a}:n?{data:{user:n.user,session:n},error:null}:{data:{user:null,session:null},error:null}}))}catch(t){if(Bt(t))return{data:{user:null,session:null},error:t};throw t}})}_getSessionFromURL(e){return fe(this,null,function*(){try{if(!qr())throw new Bl("No browser detected.");if(this.flowType==="implicit"&&!this._isImplicitGrantFlow())throw new Bl("Not a valid implicit grant flow url.");if(this.flowType=="pkce"&&!e)throw new lg("Not a valid PKCE flow url.");const t=Gc(window.location.href);if(e){if(!t.code)throw new lg("No code detected.");const{data:k,error:I}=yield this._exchangeCodeForSession(t.code);if(I)throw I;const v=new URL(window.location.href);return v.searchParams.delete("code"),window.history.replaceState(window.history.state,"",v.toString()),{data:{session:k.session,redirectType:null},error:null}}if(t.error||t.error_description||t.error_code)throw new Bl(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});const{provider_token:r,provider_refresh_token:n,access_token:a,refresh_token:o,expires_in:s,expires_at:l,token_type:d}=t;if(!a||!s||!o||!d)throw new Bl("No session defined in URL");const c=Math.round(Date.now()/1e3),u=parseInt(s);let f=c+u;l&&(f=parseInt(l));const m=f-c;m*1e3<=ms&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${u}s`);const p=f-u;c-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,f,c):c-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clok for skew",p,f,c);const{data:y,error:x}=yield this._getUser(a);if(x)throw x;const E={provider_token:r,provider_refresh_token:n,access_token:a,expires_in:u,expires_at:f,refresh_token:o,token_type:d,user:y.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:E,redirectType:t.type},error:null}}catch(t){if(Bt(t))return{data:{session:null,redirectType:null},error:t};throw t}})}_isImplicitGrantFlow(){const e=Gc(window.location.href);return!!(qr()&&(e.access_token||e.error_description))}_isPKCEFlow(){return fe(this,null,function*(){const e=Gc(window.location.href),t=yield Ml(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)})}signOut(){return fe(this,arguments,function*(e={scope:"global"}){return yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._signOut(e)}))})}_signOut(){return fe(this,arguments,function*({scope:e}={scope:"global"}){return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;if(a)return{error:a};const o=(r=n.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:s}=yield this.admin.signOut(o,e);if(s&&!(t5(s)&&(s.status===404||s.status===401)))return{error:s}}return e!=="others"&&(yield this._removeSession(),yield jc(this.storage,`${this.storageKey}-code-verifier`),yield this._notifyAllSubscribers("SIGNED_OUT",null)),{error:null}}))})}onAuthStateChange(e){const t=q4(),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),fe(this,null,function*(){yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){this._emitInitialSession(t)}))}),{data:{subscription:r}}}_emitInitialSession(e){return fe(this,null,function*(){return yield this._useSession(t=>fe(this,null,function*(){var r,n;try{const{data:{session:a},error:o}=t;if(o)throw o;yield(r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",a),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){yield(n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a)}}))})}resetPasswordForEmail(r){return fe(this,arguments,function*(e,t={}){let n=null,a=null;if(this.flowType==="pkce"){const o=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,`${o}/PASSWORD_RECOVERY`),n=yield fo(o),a=o===n?"plain":"s256"}try{return yield jt(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(o){if(Bt(o))return{data:null,error:o};throw o}})}getUserIdentities(){return fe(this,null,function*(){var e;try{const{data:t,error:r}=yield this.getUser();if(r)throw r;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}linkIdentity(e){return fe(this,null,function*(){var t;try{const{data:r,error:n}=yield this._useSession(a=>fe(this,null,function*(){var o,s,l,d,c;const{data:u,error:f}=a;if(f)throw f;const m=yield this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(s=e.options)===null||s===void 0?void 0:s.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return yield jt(this.fetch,"GET",m,{headers:this.headers,jwt:(c=(d=u.session)===null||d===void 0?void 0:d.access_token)!==null&&c!==void 0?c:void 0})}));if(n)throw n;return qr()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),{data:{provider:e.provider,url:r==null?void 0:r.url},error:null}}catch(r){if(Bt(r))return{data:{provider:e.provider,url:null},error:r};throw r}})}unlinkIdentity(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r,n;const{data:a,error:o}=t;if(o)throw o;return yield jt(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(r=a.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}_refreshAccessToken(e){return fe(this,null,function*(){const t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{const r=Date.now();return yield Z4(n=>fe(this,null,function*(){return yield Y4(n*200),this._debug(t,"refreshing attempt",n),yield jt(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:ya})}),(n,a,o)=>o&&o.error&&Hc(o.error)&&Date.now()+(n+1)*200-rfe(this,null,function*(){try{yield s.callback(e,t)}catch(l){a.push(l)}}));if(yield Promise.all(o),a.length>0){for(let s=0;sthis._autoRefreshTokenTick(),ms);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno!="undefined"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(()=>fe(this,null,function*(){yield this.initializePromise,yield this._autoRefreshTokenTick()}),0)})}_stopAutoRefresh(){return fe(this,null,function*(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)})}startAutoRefresh(){return fe(this,null,function*(){this._removeVisibilityChangedCallback(),yield this._startAutoRefresh()})}stopAutoRefresh(){return fe(this,null,function*(){this._removeVisibilityChangedCallback(),yield this._stopAutoRefresh()})}_autoRefreshTokenTick(){return fe(this,null,function*(){this._debug("#_autoRefreshTokenTick()","begin");try{yield this._acquireLock(0,()=>fe(this,null,function*(){try{const e=Date.now();try{return yield this._useSession(t=>fe(this,null,function*(){const{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((r.expires_at*1e3-e)/ms);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${ms}ms, refresh threshold is ${hg} ticks`),n<=hg&&(yield this._callRefreshToken(r.refresh_token))}))}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}))}catch(e){if(e.isAcquireTimeout||e instanceof nv)this._debug("auto refresh token tick lock not available");else throw e}})}_handleVisibilityChange(){return fe(this,null,function*(){if(this._debug("#_handleVisibilityChange()"),!qr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=()=>fe(this,null,function*(){return yield this._onVisibilityChanged(!1)}),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),yield this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}})}_onVisibilityChanged(e){return fe(this,null,function*(){const t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(yield this.initializePromise,yield this._acquireLock(-1,()=>fe(this,null,function*(){if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}yield this._recoverAndRefresh()})))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()})}_getUrlForProvider(e,t,r){return fe(this,null,function*(){const n=[`provider=${encodeURIComponent(t)}`];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 a=uo();yield _a(this.storage,`${this.storageKey}-code-verifier`,a);const o=yield fo(a),s=a===o?"plain":"s256";this._debug("PKCE","code verifier",`${a.substring(0,5)}...`,"code challenge",o,"method",s);const l=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(s)}`});n.push(l.toString())}if(r!=null&&r.queryParams){const a=new URLSearchParams(r.queryParams);n.push(a.toString())}return r!=null&&r.skipBrowserRedirect&&n.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${n.join("&")}`})}_unenroll(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;return a?{data:null,error:a}:yield jt(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(t){if(Bt(t))return{data:null,error:t};throw t}})}_enroll(e){return fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r,n;const{data:a,error:o}=t;if(o)return{data:null,error:o};const{data:s,error:l}=yield jt(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:(r=a==null?void 0:a.session)===null||r===void 0?void 0:r.access_token});return l?{data:null,error:l}:(!((n=s==null?void 0:s.totp)===null||n===void 0)&&n.qr_code&&(s.totp.qr_code=`data:image/svg+xml;utf-8,${s.totp.qr_code}`),{data:s,error:null})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}})}_verify(e){return fe(this,null,function*(){return this._acquireLock(-1,()=>fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;if(a)return{data:null,error:a};const{data:o,error:s}=yield jt(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});return s?{data:null,error:s}:(yield this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),yield this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:s})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}}))})}_challenge(e){return fe(this,null,function*(){return this._acquireLock(-1,()=>fe(this,null,function*(){try{return yield this._useSession(t=>fe(this,null,function*(){var r;const{data:n,error:a}=t;return a?{data:null,error:a}:yield jt(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token})}))}catch(t){if(Bt(t))return{data:null,error:t};throw t}}))})}_challengeAndVerify(e){return fe(this,null,function*(){const{data:t,error:r}=yield this._challenge({factorId:e.factorId});return r?{data:null,error:r}:yield this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})})}_listFactors(){return fe(this,null,function*(){const{data:{user:e},error:t}=yield this.getUser();if(t)return{data:null,error:t};const r=(e==null?void 0:e.factors)||[],n=r.filter(a=>a.factor_type==="totp"&&a.status==="verified");return{data:{all:r,totp:n},error:null}})}_getAuthenticatorAssuranceLevel(){return fe(this,null,function*(){return this._acquireLock(-1,()=>fe(this,null,function*(){return yield this._useSession(e=>fe(this,null,function*(){var t,r;const{data:{session:n},error:a}=e;if(a)return{data:null,error:a};if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const o=this._decodeJWT(n.access_token);let s=null;o.aal&&(s=o.aal);let l=s;((r=(t=n.user.factors)===null||t===void 0?void 0:t.filter(u=>u.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const c=o.amr||[];return{data:{currentLevel:s,nextLevel:l,currentAuthenticationMethods:c},error:null}}))}))})}}Ns.nextInstanceID=0;class x5 extends Ns{constructor(e){super(e)}}var w5=function(i,e,t,r){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{d(r.next(c))}catch(u){o(u)}}function l(c){try{d(r.throw(c))}catch(u){o(u)}}function d(c){c.done?a(c.value):n(c.value).then(s,l)}d((r=r.apply(i,e||[])).next())})};class S5{constructor(e,t,r){var n,a,o,s,l,d,c,u;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const f=j4(e);this.realtimeUrl=`${f}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${f}/auth/v1`,this.storageUrl=`${f}/storage/v1`,this.functionsUrl=`${f}/functions/v1`;const m=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,p={db:P4,realtime:M4,auth:Object.assign(Object.assign({},D4),{storageKey:m}),global:N4},y=V4(r!=null?r:{},p);this.storageKey=(a=(n=y.auth)===null||n===void 0?void 0:n.storageKey)!==null&&a!==void 0?a:"",this.headers=(s=(o=y.global)===null||o===void 0?void 0:o.headers)!==null&&s!==void 0?s:{},this.auth=this._initSupabaseAuthClient((l=y.auth)!==null&&l!==void 0?l:{},this.headers,(d=y.global)===null||d===void 0?void 0:d.fetch),this.fetch=G4(t,this._getAccessToken.bind(this),(c=y.global)===null||c===void 0?void 0:c.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},y.realtime)),this.rest=new Xu(`${f}/rest/v1`,{headers:this.headers,schema:(u=y.db)===null||u===void 0?void 0:u.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new YA(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new O4(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},r={}){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return w5(this,void 0,void 0,function*(){const{data:r}=yield this.auth.getSession();return(t=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,storageKey:a,flowType:o,debug:s},l,d){const c={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new x5({url:this.authUrl,headers:Object.assign(Object.assign({},c),l),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,flowType:o,debug:s,fetch:d})}_initRealtimeClient(e){return new _4(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,r)=>{this._handleTokenChanged(t,"CLIENT",r==null?void 0:r.access_token)})}_handleTokenChanged(e,t,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?(this.realtime.setAuth(r!=null?r:null),this.changedAccessToken=r):e==="SIGNED_OUT"&&(this.realtime.setAuth(this.supabaseKey),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const E5=(i,e,t)=>new S5(i,e,t),T5=E5("https://xovkkfhojasbjinfslpx.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhvdmtrZmhvamFzYmppbmZzbHB4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTM1ODQ0ODAsImV4cCI6MjAwOTE2MDQ4MH0.L3-X0p_un0oSTNubPwtfGo0D8g2bkPIfz7CaZ-iRYXY");function I5(i){return fe(this,null,function*(){const{error:e}=yield T5.from("metrics").insert(i);return e})}var pg=[],ps=[];function A5(i,e){if(i&&typeof document!="undefined"){var t,r=e.prepend===!0?"prepend":"append",n=e.singleTag===!0,a=typeof e.container=="string"?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(n){var o=pg.indexOf(a);o===-1&&(o=pg.push(a)-1,ps[o]={}),t=ps[o]&&ps[o][r]?ps[o][r]:ps[o][r]=s()}else t=s();i.charCodeAt(0)===65279&&(i=i.substring(1)),t.styleSheet?t.styleSheet.cssText+=i:t.appendChild(document.createTextNode(i))}function s(){var l=document.createElement("style");if(l.setAttribute("type","text/css"),e.attributes)for(var d=Object.keys(e.attributes),c=0;ci.id,nodeLabelClassName:void 0,nodeLabelColor:void 0,hoveredNodeLabelClassName:void 0,hoveredNodeLabelColor:void 0,onSetData:void 0,onNodesFiltered:void 0,onLinksFiltered:void 0,onLabelClick:void 0};let Ju=Ao,vg=Ao,bg=Ao,av=sv,ov=lv;typeof Uint8Array!="undefined"&&(Ju=function(i){return new Uint8Array(i)},vg=function(i){return new Uint16Array(i)},bg=function(i){return new Uint32Array(i)},av=function(i,e){if(i.length>=e)return i;var t=new i.constructor(e);return t.set(i),t},ov=function(i,e){var t;switch(e){case 16:t=vg(i.length);break;case 32:t=bg(i.length);break;default:throw new Error("invalid array width!")}return t.set(i),t});function Ao(i){for(var e=new Array(i),t=-1;++t32)throw new Error("invalid array width!");return i}function gn(i){this.length=i,this.subarrays=1,this.width=8,this.masks={0:0},this[0]=Ju(i)}gn.prototype.lengthen=function(i){var e,t;for(e=0,t=this.subarrays;e>>0,!(e>=32&&!t))return e<32&&t&1<=i;r--)this[e][r]=0;this.length=i};gn.prototype.zero=function(i){var e,t;for(e=0,t=this.subarrays;e>>0),a!=(o===r?n:0))return!1;return!0};const Yn={array8:Ao,array16:Ao,array32:Ao,arrayLengthen:sv,arrayWiden:lv,bitarray:gn},k5=(i,e)=>function(t){var r=t.length;return[i.left(t,e,0,r),i.right(t,e,0,r)]},$5=(i,e)=>{var t=e[0],r=e[1];return function(n){var a=n.length;return[i.left(n,t,0,a),i.left(n,r,0,a)]}},L5=i=>[0,i.length],po={filterExact:k5,filterRange:$5,filterAll:L5},Ps=i=>i,sn=()=>null,Ul=()=>0;function dv(i){function e(n,a,o){for(var s=o-a,l=(s>>>1)+1;--l>0;)r(n,l,s,a);return n}function t(n,a,o){for(var s=o-a,l;--s>0;)l=n[a],n[a]=n[a+s],n[a+s]=l,r(n,1,s,a);return n}function r(n,a,o,s){for(var l=n[--s+a],d=i(l),c;(c=a<<1)<=o&&(ci(n[s+c+1])&&c++,!(d<=i(n[s+c])));)n[s+a]=n[s+c],a=c;n[s+a]=l}return e.sort=t,e}const Td=dv(Ps);Td.by=dv;function cv(i){var e=Td.by(i);function t(r,n,a,o){var s=new Array(o=Math.min(a-n,o)),l,d,c;for(d=0;dl&&(s[0]=c,l=i(e(s,0,o)[0]));while(++n>>1;i(r[s])>>1;n{for(var r=0,n=e.length,a=t?JSON.parse(JSON.stringify(i)):new Array(n);ri+1,R5=i=>i-1,F5=i=>function(e,t){return e+ +i(t)},N5=i=>function(e,t){return e-i(t)},Vn={reduceIncrement:O5,reduceDecrement:R5,reduceAdd:F5,reduceSubtract:N5};function P5(i,e,t,r,n){for(n in r=(t=t.split(".")).splice(-1,1),t)e=e[t[n]]=e[t[n]]||{};return i(e,r)}const D5=(i,e)=>{const t=i[e];return typeof t=="function"?t.call(i):t},M5=/\[([\w\d]+)\]/g,z5=(i,e)=>P5(D5,i,e.replace(M5,".$1"));var Hn=-1;Us.heap=Td;Us.heapselect=Qu;Us.bisect=vd;Us.permute=Zl;function Us(){var i={add:l,remove:d,dimension:f,groupAll:m,size:p,all:y,allFiltered:x,onChange:E,isElementFiltered:u},e=[],t=0,r,n=[],a=[],o=[],s=[];r=new Yn.bitarray(0);function l(I){var v=t,M=I.length;return M&&(e=e.concat(I),r.lengthen(t+=M),a.forEach(function(K){K(I,v,M)}),k("dataAdded")),i}function d(I){for(var v=new Array(t),M=[],K=typeof I=="function",L=function(de){return K?I(e[de],de):r.zero(de)},R=0,W=0;R>7]&=~(1<<(L&63));return R}function u(I,v){var M=c(v||[]);return r.zeroExceptMask(I,M)}function f(I,v){if(typeof I=="string"){var M=I;I=function(Ze){return z5(Ze,M)}}var K={filter:It,filterExact:ii,filterRange:vi,filterFunction:Vt,filterAll:Ki,currentFilter:st,hasCurrentFilter:ft,top:Qt,bottom:_,group:X,groupAll:bi,dispose:Ma,remove:Ma,accessor:I,id:function(){return Oe}},L,R,W,Oe,me,de,N,C,Q,V,ne=[],Ve=function(Ze){return qc(Ze).sort(function(et,ge){var ie=N[et],Et=N[ge];return ieEt?1:et-ge})},Re=po.filterAll,Ge,tt,ot,he=[],bt=[],wt=0,pt=0,Lt=0,xe;a.unshift(Qe),a.push(dt),o.push(Se);var le=r.add();W=le.offset,L=le.one,R=~L,Oe=W<<7|Math.log(L)/Math.log(2),Qe(e,0,t),dt(e,0,t);function Qe(Ze,et,ge){var ie,Et;if(v){Lt=0,cr=0,xe=[];for(var nt=0;ntwt)for(ie=wt,Et=Math.min(et,pt);iept)for(ie=Math.max(et,pt),Et=ge;ie0&&(nt=et);--ie>=wt&&Ze>0;)r.zero(Et=de[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze));if(v)for(ie=0;ie0;ie++)r.zero(Et=ne[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze));return ge}function _(Ze,et){var ge=[],ie,Et,nt=0;if(et&&et>0&&(nt=et),v)for(ie=0;ie0;ie++)r.zero(Et=ne[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze));for(ie=wt;ie0;)r.zero(Et=de[ie])&&(nt>0?--nt:(ge.push(e[Et]),--Ze)),ie++;return ge}function X(Ze){var et={top:Id,all:Wi,reduce:Bo,reduceCount:Gs,reduceSum:Ad,order:js,orderNatural:Vs,size:Hs,dispose:_i,remove:_i};bt.push(et);var ge,ie,Et=8,nt=_g(Et),at=0,ri,qt,Ri,Ai,mr,Si=sn,ni=sn,qi=!0,_r=Ze===sn,Gr;arguments.length<1&&(Ze=Ps),n.push(Si),he.push(vn),o.push(ea),vn(me,de,0,t);function vn(Ke,Pt,Ht,Di){v&&(Gr=Ht,Ht=me.length-Ke.length,Di=Ke.length);var Dt=ge,kt=v?[]:xa(at,nt),Wt=Ri,ai=Ai,Xi=mr,Ji=at,Qi=0,bn=0,Pr,Rn,za,_n,yn,Uo;for(qi&&(Wt=Xi=sn),qi&&(ai=Xi=sn),ge=new Array(at),at=0,v?ie=Ji?ie:[]:ie=Ji>1?Yn.arrayLengthen(ie,t):xa(t,nt),Ji&&(za=(Rn=Dt[0]).key);bn=_n);)++bn;for(;bn=Di));)_n=Ze(Ke[bn]);qs()}for(;QiQi)if(v)for(Qi=0;Qi1||v?(Si=On,ni=ta):(!at&&_r&&(at=1,ge=[{key:null,value:Xi()}]),at===1?(Si=di,ni=cr):(Si=sn,ni=sn),ie=null),n[Pr]=Si;function qs(){if(v){at++;return}++at===nt&&(kt=Yn.arrayWiden(kt,Et<<=1),ie=Yn.arrayWiden(ie,Et),nt=_g(Et))}}function ea(Ke){if(at>1||v){var Pt=at,Ht=ge,Di=xa(Pt,Pt),Dt,kt,Wt;if(v){for(Dt=0,Wt=0;Dt1||v)if(v)for(Dt=0;Dt1||v?(ni=ta,Si=On):at===1?(ni=cr,Si=di):ni=Si=sn}else if(at===1){if(_r)return;for(var ai=0;ai=0&&n.splice(Ke,1),Ke=he.indexOf(vn),Ke>=0&&he.splice(Ke,1),Ke=o.indexOf(ea),Ke>=0&&o.splice(Ke,1),Ke=bt.indexOf(et),Ke>=0&&bt.splice(Ke,1),et}return Gs().orderNatural()}function bi(){var Ze=X(sn),et=Ze.all;return delete Ze.all,delete Ze.top,delete Ze.order,delete Ze.orderNatural,delete Ze.size,Ze.value=function(){return et()[0].value},Ze}function Ma(){bt.forEach(function(et){et.dispose()});var Ze=a.indexOf(Qe);return Ze>=0&&a.splice(Ze,1),Ze=a.indexOf(dt),Ze>=0&&a.splice(Ze,1),Ze=o.indexOf(Se),Ze>=0&&o.splice(Ze,1),r.masks[W]&=R,Ki()}return K}function m(){var I={reduce:de,reduceCount:N,reduceSum:C,value:Q,dispose:V,remove:V},v,M,K,L,R=!0;n.push(Oe),a.push(W),W(e,0);function W(ne,Ve){var Re;if(!R)for(Re=Ve;Re=0&&n.splice(ne,1),ne=a.indexOf(W),ne>=0&&a.splice(ne,1),I}return N()}function p(){return t}function y(){return e}function x(I){var v=[],M=0,K=c(I||[]);for(M=0;M{var r,n,a;switch(t){case"filtered":(r=this.onFiltered)===null||r===void 0||r.call(this),this._filters.forEach(o=>{var s;(s=o.onFiltered)===null||s===void 0||s.call(o)});break;case"dataAdded":(n=this.onDataAdded)===null||n===void 0||n.call(this),this._filters.forEach(o=>{var s;(s=o.onDataAdded)===null||s===void 0||s.call(o)});break;case"dataRemoved":(a=this.onDataRemoved)===null||a===void 0||a.call(this),this._filters.forEach(o=>{var s;(s=o.onDataRemoved)===null||s===void 0||s.call(o)})}})}addRecords(e){const{_crossfilter:t}=this;this._records=e,t.remove(),t.add(e)}getFilteredRecords(e){const{_crossfilter:t}=this;return(e==null?void 0:e.getFilteredRecords())||t.allFiltered()}addFilter(e=!0){const t=new B5(this._crossfilter,()=>{this._filters.delete(t)},e?this._syncUpFunction:void 0);return this._filters.add(t),t}clearFilters(){this._filters.forEach(e=>{e.clear()})}isAnyFiltersActive(e){for(const t of this._filters.values())if(t!==e&&t.isActive())return!0;return!1}getAllRecords(){return this._records}}class U5{constructor(e,t){var r;this._data={nodes:[],links:[]},this._previousData={nodes:[],links:[]},this._cosmographConfig={},this._cosmosConfig={},this._nodesForTopLabels=new Set,this._nodesForForcedLabels=new Set,this._trackedNodeToLabel=new Map,this._isLabelsDestroyed=!1,this._svgParser=new DOMParser,this._nodesCrossfilter=new yg(this._applyLinksFilter.bind(this)),this._linksCrossfilter=new yg(this._applyNodesFilter.bind(this)),this._nodesFilter=this._nodesCrossfilter.addFilter(!1),this._linksFilter=this._linksCrossfilter.addFilter(!1),this._selectedNodesFilter=this._nodesCrossfilter.addFilter(),this._isDataDifferent=()=>{const a=JSON.stringify(this._data.nodes),o=JSON.stringify(this._previousData.nodes),s=JSON.stringify(this._data.links),l=JSON.stringify(this._previousData.links);return a!==o||s!==l},this._onClick=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onClick)===null||s===void 0||s.call(o,...a)},this._onLabelClick=(a,o)=>{var s,l,d;const c=(s=this._cosmos)===null||s===void 0?void 0:s.graph.getNodeById(o.id);c&&((d=(l=this._cosmographConfig).onLabelClick)===null||d===void 0||d.call(l,c,a))},this._onHoveredNodeClick=a=>{var o,s;this._hoveredNode&&((s=(o=this._cosmographConfig).onLabelClick)===null||s===void 0||s.call(o,this._hoveredNode,a))},this._onNodeMouseOver=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onNodeMouseOver)===null||s===void 0||s.call(o,...a);const[l,,d]=a;this._hoveredNode=l,this._renderLabelForHovered(l,d)},this._onNodeMouseOut=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onNodeMouseOut)===null||s===void 0||s.call(o,...a),this._renderLabelForHovered()},this._onMouseMove=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onMouseMove)===null||s===void 0||s.call(o,...a);const[l,,d]=a;this._renderLabelForHovered(l,d)},this._onZoomStart=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onZoomStart)===null||s===void 0||s.call(o,...a)},this._onZoom=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onZoom)===null||s===void 0||s.call(o,...a),this._renderLabelForHovered(),this._renderLabels()},this._onZoomEnd=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onZoomEnd)===null||s===void 0||s.call(o,...a)},this._onStart=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationStart)===null||s===void 0||s.call(o,...a)},this._onTick=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationTick)===null||s===void 0||s.call(o,...a),this._renderLabels()},this._onEnd=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationEnd)===null||s===void 0||s.call(o,...a)},this._onPause=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationPause)===null||s===void 0||s.call(o,...a)},this._onRestart=(...a)=>{var o,s;(s=(o=this._cosmographConfig).onSimulationRestart)===null||s===void 0||s.call(o,...a)},this._containerNode=e,this._containerNode.classList.add(gs.cosmograph),this._cosmographConfig=La(gg,t!=null?t:{}),this._cosmosConfig=this._createCosmosConfig(t),this._canvasElement=document.createElement("canvas"),this._labelsDivElement=document.createElement("div"),this._watermarkDivElement=document.createElement("div"),this._watermarkDivElement.classList.add(gs.watermark),this._watermarkDivElement.onclick=()=>{var a;return(a=window.open("https://cosmograph.app/","_blank"))===null||a===void 0?void 0:a.focus()},e.appendChild(this._canvasElement),e.appendChild(this._labelsDivElement),e.appendChild(this._watermarkDivElement),this._cssLabelsRenderer=new oE(this._labelsDivElement,{dispatchWheelEventElement:this._canvasElement,pointerEvents:"all",onLabelClick:this._onLabelClick.bind(this)}),this._hoveredCssLabel=new I0(this._labelsDivElement),this._hoveredCssLabel.setPointerEvents("all"),this._hoveredCssLabel.element.addEventListener("click",this._onHoveredNodeClick.bind(this)),this._linksFilter.setAccessor(a=>[a.source,a.target]),this._nodesFilter.setAccessor(a=>a.id),this._selectedNodesFilter.setAccessor(a=>a.id),this._nodesCrossfilter.onFiltered=()=>{var a,o,s,l;let d;this._nodesCrossfilter.isAnyFiltersActive()?(d=this._nodesCrossfilter.getFilteredRecords(),(a=this._cosmos)===null||a===void 0||a.selectNodesByIds(d.map(c=>c.id))):(o=this._cosmos)===null||o===void 0||o.unselectNodes(),this._updateSelectedNodesSet(d),(l=(s=this._cosmographConfig).onNodesFiltered)===null||l===void 0||l.call(s,d)},this._linksCrossfilter.onFiltered=()=>{var a,o;let s;this._linksCrossfilter.isAnyFiltersActive()&&(s=this._linksCrossfilter.getFilteredRecords()),(o=(a=this._cosmographConfig).onLinksFiltered)===null||o===void 0||o.call(a,s)};const n=this._svgParser.parseFromString(UA,"image/svg+xml").firstChild;(r=this._watermarkDivElement)===null||r===void 0||r.appendChild(n)}get data(){return this._data}get progress(){var e;return(e=this._cosmos)===null||e===void 0?void 0:e.progress}get isSimulationRunning(){var e;return(e=this._cosmos)===null||e===void 0?void 0:e.isSimulationRunning}get maxPointSize(){var e;return(e=this._cosmos)===null||e===void 0?void 0:e.maxPointSize}setData(e,t){var r,n,a,o;const{_cosmographConfig:s}=this;this._data={nodes:e,links:t};const l=s.disableSimulation===null?!t.length:s.disableSimulation;this._cosmos||(this._disableSimulation=l,this._cosmosConfig.disableSimulation=this._disableSimulation,this._cosmos=new iE(this._canvasElement,this._cosmosConfig),this.cosmos=this._cosmos),this._disableSimulation!==l&&console.warn(`The \`disableSimulation\` was initialized to \`${this._disableSimulation}\` during initialization and will not be modified.`),this._cosmos.setData(e,t),this._nodesCrossfilter.addRecords(e),this._linksCrossfilter.addRecords(t),this._updateLabels(),(n=(r=this._cosmographConfig).onSetData)===null||n===void 0||n.call(r,e,t),this._isDataDifferent()&&(["cosmograph.app"].includes(window.location.hostname)||I5({browser:navigator.userAgent,hostname:window.location.hostname,mode:null,is_library_metric:!0,links_count:t.length,links_have_time:null,links_raw_columns:t.length&&(a=Object.keys(t==null?void 0:t[0]).length)!==null&&a!==void 0?a:0,links_raw_lines:null,nodes_count:e.length,nodes_have_time:null,nodes_raw_columns:e.length&&(o=Object.keys(e==null?void 0:e[0]).length)!==null&&o!==void 0?o:0,nodes_raw_lines:null})),this._previousData={nodes:e,links:t}}setConfig(e){var t,r;if(this._cosmographConfig=La(gg,e!=null?e:{}),this._cosmosConfig=this._createCosmosConfig(e),(t=this._cosmos)===null||t===void 0||t.setConfig(this._cosmosConfig),e==null?void 0:e.backgroundColor){const n=(r=An(e==null?void 0:e.backgroundColor))===null||r===void 0?void 0:r.formatHex();if(n){const a=this._checkBrightness(n),o=document.querySelector(":root");a>.65?o==null||o.style.setProperty("--cosmograph-watermark-color","#000000"):o==null||o.style.setProperty("--cosmograph-watermark-color","#ffffff")}}this._updateLabels()}addNodesFilter(){return this._nodesCrossfilter.addFilter()}addLinksFilter(){return this._linksCrossfilter.addFilter()}selectNodesInRange(e){var t;if(!this._cosmos)return;this._cosmos.selectNodesInRange(e);const r=new Set(((t=this.getSelectedNodes())!==null&&t!==void 0?t:[]).map(n=>n.id));this._selectedNodesFilter.applyFilter(n=>r.has(n))}selectNodes(e){if(!this._cosmos)return;const t=new Set(e.map(r=>r.id));this._selectedNodesFilter.applyFilter(r=>t.has(r))}selectNode(e,t=!1){if(!this._cosmos)return;const r=new Set([e,...t&&this._cosmos.getAdjacentNodes(e.id)||[]].map(n=>n.id));this._selectedNodesFilter.applyFilter(n=>r.has(n))}unselectNodes(){this._cosmos&&this._selectedNodesFilter.clear()}getSelectedNodes(){if(this._cosmos)return this._cosmos.getSelectedNodes()}zoomToNode(e){this._cosmos&&this._cosmos.zoomToNodeById(e.id)}setZoomLevel(e,t=0){this._cosmos&&this._cosmos.setZoomLevel(e,t)}getZoomLevel(){if(this._cosmos)return this._cosmos.getZoomLevel()}getNodePositions(){if(this._cosmos)return this._cosmos.getNodePositions()}getNodePositionsMap(){if(this._cosmos)return this._cosmos.getNodePositionsMap()}getNodePositionsArray(){if(this._cosmos)return this._cosmos.getNodePositionsArray()}fitView(e=250){this._cosmos&&this._cosmos.fitView(e)}fitViewByNodeIds(e,t=250){this._cosmos&&this._cosmos.fitViewByNodeIds(e,t)}focusNode(e){this._cosmos&&this._cosmos.setFocusedNodeById(e==null?void 0:e.id)}getAdjacentNodes(e){if(this._cosmos)return this._cosmos.getAdjacentNodes(e)}spaceToScreenPosition(e){if(this._cosmos)return this._cosmos.spaceToScreenPosition(e)}spaceToScreenRadius(e){if(this._cosmos)return this._cosmos.spaceToScreenRadius(e)}getNodeRadiusByIndex(e){if(this._cosmos)return this._cosmos.getNodeRadiusByIndex(e)}getNodeRadiusById(e){if(this._cosmos)return this._cosmos.getNodeRadiusById(e)}getSampledNodePositionsMap(){if(this._cosmos)return this._cosmos.getSampledNodePositionsMap()}start(e=1){this._cosmos&&this._cosmos.start(e)}pause(){this._cosmos&&this._cosmos.pause()}restart(){this._cosmos&&this._cosmos.restart()}step(){this._cosmos&&this._cosmos.step()}remove(){var e;(e=this._cosmos)===null||e===void 0||e.destroy(),this._isLabelsDestroyed||(this._containerNode.innerHTML="",this._isLabelsDestroyed=!0,this._hoveredCssLabel.element.removeEventListener("click",this._onHoveredNodeClick.bind(this)),this._hoveredCssLabel.destroy(),this._cssLabelsRenderer.destroy())}create(){this._cosmos&&this._cosmos.create()}getNodeDegrees(){if(this._cosmos)return this._cosmos.graph.degree}_createCosmosConfig(e){const t=Il(Ei({},e),{simulation:Il(Ei({},Object.keys(e!=null?e:{}).filter(r=>r.indexOf("simulation")!==-1).reduce((r,n)=>{const a=n.replace("simulation","");return r[a.charAt(0).toLowerCase()+a.slice(1)]=e==null?void 0:e[n],r},{})),{onStart:this._onStart.bind(this),onTick:this._onTick.bind(this),onEnd:this._onEnd.bind(this),onPause:this._onPause.bind(this),onRestart:this._onRestart.bind(this)}),events:{onClick:this._onClick.bind(this),onNodeMouseOver:this._onNodeMouseOver.bind(this),onNodeMouseOut:this._onNodeMouseOut.bind(this),onMouseMove:this._onMouseMove.bind(this),onZoomStart:this._onZoomStart.bind(this),onZoom:this._onZoom.bind(this),onZoomEnd:this._onZoomEnd.bind(this)}});return delete t.disableSimulation,t}_updateLabels(){if(this._isLabelsDestroyed||!this._cosmos)return;const{_cosmos:e,data:{nodes:t},_cosmographConfig:{showTopLabels:r,showTopLabelsLimit:n,showLabelsFor:a,showTopLabelsValueKey:o,nodeLabelAccessor:s}}=this;if(this._nodesForTopLabels.clear(),r&&n){let l;l=o?[...t].sort((d,c)=>{const u=d[o],f=c[o];return typeof u=="number"&&typeof f=="number"?f-u:0}):Object.entries(e.graph.degree).sort((d,c)=>c[1]-d[1]).slice(0,n).map(d=>e.graph.getNodeByIndex(+d[0]));for(let d=0;d=t.length);d++){const c=l[d];c&&this._nodesForTopLabels.add(c)}}this._nodesForForcedLabels.clear(),a==null||a.forEach(this._nodesForForcedLabels.add,this._nodesForForcedLabels),this._trackedNodeToLabel.clear(),e.trackNodePositionsByIds([...r?this._nodesForTopLabels:[],...this._nodesForForcedLabels].map(l=>{var d;return this._trackedNodeToLabel.set(l,(d=s==null?void 0:s(l))!==null&&d!==void 0?d:l.id),l.id})),this._renderLabels()}_updateSelectedNodesSet(e){this._isLabelsDestroyed||(e?(this._selectedNodesSet=new Set,e==null||e.forEach(this._selectedNodesSet.add,this._selectedNodesSet)):this._selectedNodesSet=void 0,this._renderLabels())}_renderLabels(){if(this._isLabelsDestroyed||!this._cosmos)return;const{_cosmos:e,_selectedNodesSet:t,_cosmographConfig:{showDynamicLabels:r,nodeLabelAccessor:n,nodeLabelColor:a,nodeLabelClassName:o}}=this;let s=[];const l=e.getTrackedNodePositionsMap(),d=new Map;if(r){const c=this.getSampledNodePositionsMap();c==null||c.forEach((u,f)=>{var m;const p=e.graph.getNodeById(f);p&&d.set(p,[(m=n==null?void 0:n(p))!==null&&m!==void 0?m:p.id,u,gs.cosmographShowDynamicLabels,.7])})}this._nodesForTopLabels.forEach(c=>{d.set(c,[this._trackedNodeToLabel.get(c),l.get(c.id),gs.cosmographShowTopLabels,.9])}),this._nodesForForcedLabels.forEach(c=>{d.set(c,[this._trackedNodeToLabel.get(c),l.get(c.id),gs.cosmographShowLabelsFor,1])}),s=[...d.entries()].map(([c,[u,f,m,p]])=>{var y,x,E;const k=this.spaceToScreenPosition([(y=f==null?void 0:f[0])!==null&&y!==void 0?y:0,(x=f==null?void 0:f[1])!==null&&x!==void 0?x:0]),I=this.spaceToScreenRadius(e.config.nodeSizeScale*this.getNodeRadiusById(c.id)),v=!!t,M=t==null?void 0:t.has(c);return{id:c.id,text:u!=null?u:"",x:k[0],y:k[1]-(I+2),weight:v&&!M?.1:p,shouldBeShown:this._nodesForForcedLabels.has(c),style:v&&!M?"opacity: 0.1;":"",color:a&&(typeof a=="string"?a:a==null?void 0:a(c)),className:(E=typeof o=="string"?o:o==null?void 0:o(c))!==null&&E!==void 0?E:m}}),this._cssLabelsRenderer.setLabels(s),this._cssLabelsRenderer.draw(!0)}_renderLabelForHovered(e,t){var r,n;if(!this._cosmos)return;const{_cosmographConfig:{showHoveredNodeLabel:a,nodeLabelAccessor:o,hoveredNodeLabelClassName:s,hoveredNodeLabelColor:l}}=this;if(!this._isLabelsDestroyed){if(a&&e&&t){const d=this.spaceToScreenPosition(t),c=this.spaceToScreenRadius(this.getNodeRadiusById(e.id));this._hoveredCssLabel.setText((r=o==null?void 0:o(e))!==null&&r!==void 0?r:e.id),this._hoveredCssLabel.setVisibility(!0),this._hoveredCssLabel.setPosition(d[0],d[1]-(c+2)),this._hoveredCssLabel.setClassName(typeof s=="string"?s:(n=s==null?void 0:s(e))!==null&&n!==void 0?n:"");const u=l&&(typeof l=="string"?l:l==null?void 0:l(e));u&&this._hoveredCssLabel.setColor(u)}else this._hoveredCssLabel.setVisibility(!1);this._hoveredCssLabel.draw()}}_applyLinksFilter(){if(this._nodesCrossfilter.isAnyFiltersActive(this._nodesFilter)){const e=this._nodesCrossfilter.getFilteredRecords(this._nodesFilter),t=new Set(e.map(r=>r.id));this._linksFilter.applyFilter(r=>{const n=r==null?void 0:r[0],a=r==null?void 0:r[1];return t.has(n)&&t.has(a)})}else this._linksFilter.clear()}_applyNodesFilter(){if(this._linksCrossfilter.isAnyFiltersActive(this._linksFilter)){const e=this._linksCrossfilter.getFilteredRecords(this._linksFilter),t=new Set(e.map(r=>[r.source,r.target]).flat());this._nodesFilter.applyFilter(r=>t.has(r))}else this._nodesFilter.clear()}_checkBrightness(e){const t=(r=>{const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return n?{r:parseInt((n[1]||0).toString(),16),g:parseInt((n[2]||0).toString(),16),b:parseInt((n[3]||0).toString(),16)}:{r:0,g:0,b:0}})(e);return(.2126*t.r+.7152*t.g+.0722*t.b)/255}}const xg={onSelectResult:void 0,accessors:void 0};class G5{constructor(e,t,r){this._config={},this._data=[],this._defaultAccessors=[],this._createDefaultAccessorOptions=n=>n.length>0&&n[0]?Object.keys(n[0]).map(a=>({label:a,accessor:o=>String(o[a])})):[{label:"id",accessor:a=>a.id}],this._onSelect=(...n)=>{this._onSelectResult(...n)},this._onSearch=(...n)=>{var a,o;(o=(a=this._config).onSearch)===null||o===void 0||o.call(a,...n)},this._onEnter=(...n)=>{var a,o;(o=(a=this._config).onEnter)===null||o===void 0||o.call(a,...n)},this._onAccessorSelect=(...n)=>{var a,o;(o=(a=this._config).onAccessorSelect)===null||o===void 0||o.call(a,...n)},this._cosmograph=e,this._config=La(xg,r!=null?r:{}),this.search=new BA(t,this._createSearchConfig(r)),this._filter=this._cosmograph.addNodesFilter(),this._filter.onDataAdded=()=>{this._updateData()},this._updateData()}setConfig(e){const t=La(xg,e!=null?e:{});this._data.length&&t.accessors===void 0&&(t.accessors=this._defaultAccessors),this.search.setConfig(this._createSearchConfig(t)),this._config=t}_updateData(){const e=this._cosmograph.data.nodes;e!=null&&e.length&&(this._data=e,this.search.setData(this._data),this._config.accessors===void 0&&(this._defaultAccessors=this._createDefaultAccessorOptions(this._data),this.setConfig({accessors:this._defaultAccessors})))}getConfig(){return this._config}remove(){this.search.destroy()}setListState(e){this.search.setListState(e)}clearInput(){this.search.clearInput()}_onSelectResult(e){var t,r;this._cosmograph.pause(),this._cosmograph.zoomToNode(e),this._cosmograph.selectNode(e),(r=(t=this._config).onSelectResult)===null||r===void 0||r.call(t,e)}_createSearchConfig(e){return Il(Ei({},e),{events:{onSelect:this._onSelect.bind(this),onSearch:this._onSearch.bind(this),onEnter:this._onEnter.bind(this),onAccessorSelect:this._onAccessorSelect.bind(this)}})}}var bd;(function(i){i.Nodes="nodes",i.Links="links"})(bd||(bd={}));bd.Links;bd.Nodes;var wg={},Wc={},Xc=34,vs=10,Yc=13;function fv(i){return new Function("d","return {"+i.map(function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'}).join(",")+"}")}function j5(i,e){var t=fv(i);return function(r,n){return e(t(r),n,i)}}function Sg(i){var e=Object.create(null),t=[];return i.forEach(function(r){for(var n in r)n in e||t.push(e[n]=n)}),t}function Er(i,e){var t=i+"",r=t.length;return r9999?"+"+Er(i,6):Er(i,4)}function H5(i){var e=i.getUTCHours(),t=i.getUTCMinutes(),r=i.getUTCSeconds(),n=i.getUTCMilliseconds();return isNaN(i)?"Invalid Date":V5(i.getUTCFullYear())+"-"+Er(i.getUTCMonth()+1,2)+"-"+Er(i.getUTCDate(),2)+(n?"T"+Er(e,2)+":"+Er(t,2)+":"+Er(r,2)+"."+Er(n,3)+"Z":r?"T"+Er(e,2)+":"+Er(t,2)+":"+Er(r,2)+"Z":t||e?"T"+Er(e,2)+":"+Er(t,2)+"Z":"")}function q5(i){var e=new RegExp('["'+i+` \r]`),t=i.charCodeAt(0);function r(u,f){var m,p,y=n(u,function(x,E){if(m)return m(x,E-1);p=x,m=f?j5(x,f):fv(x)});return y.columns=p||[],y}function n(u,f){var m=[],p=u.length,y=0,x=0,E,k=p<=0,I=!1;u.charCodeAt(p-1)===vs&&--p,u.charCodeAt(p-1)===Yc&&--p;function v(){if(k)return Wc;if(I)return I=!1,wg;var K,L=y,R;if(u.charCodeAt(L)===Xc){for(;y++=p?k=!0:(R=u.charCodeAt(y++))===vs?I=!0:R===Yc&&(I=!0,u.charCodeAt(y)===vs&&++y),u.slice(L+1,K-1).replace(/""/g,'"')}for(;y{const t=i.map(d=>({source:parseInt(d.source),target:parseInt(d.target)})),r=e.map(d=>({id:parseInt(d.id),label:d.label,color:d.color})),n=document.getElementById("app");iC.style.visibility="hidden",n.appendChild(wu);const a=document.createElement("div");n.appendChild(a);const o={nodeColor:d=>d.color,nodeLabelAccessor:d=>d.label,nodeLabelColor:"white",hoveredNodeLabelColor:"white",linkWidth:2},s=new U5(wu,o),l=new G5(s,a);s.setData(r,t),l.setData(r)});export{Yg as g}; +`)}function d(u){return u.map(c).join(i)}function c(u){return u==null?"":u instanceof Date?H5(u):e.test(u+="")?'"'+u.replace(/"/g,'""')+'"':u}return{parse:r,parseRows:n,format:o,formatBody:s,formatRows:l,formatRow:d,formatValue:c}}var W5=q5(","),X5=W5.parse;function Y5(i){if(!i.ok)throw new Error(i.status+" "+i.statusText);return i.text()}function Z5(i,e){return fetch(i,e).then(Y5)}function K5(i){return function(e,t,r){return arguments.length===2&&typeof t=="function"&&(r=t,t=void 0),Z5(e,t).then(function(n){return i(n,r)})}}var hv=K5(X5);const J5="/media/edges.csv",Q5="/media/nodes.csv",eC=hv(J5),tC=hv(Q5),iC=document.getElementById("spinner"),rC=document.getElementById("legend"),wu=document.createElement("div");wu.style.height="800px";Promise.all([eC,tC]).then(([i,e])=>{const t=i.map(d=>({source:parseInt(d.source),target:parseInt(d.target)})),r=e.map(d=>({id:parseInt(d.id),label:d.label,color:d.color})),n=document.getElementById("app");iC.style.visibility="hidden",rC.style.visibility="visible",n.appendChild(wu);const a=document.createElement("div");n.appendChild(a);const o={nodeColor:d=>d.color,nodeLabelAccessor:d=>d.label,nodeLabelColor:"white",hoveredNodeLabelColor:"white",linkWidth:2},s=new U5(wu,o),l=new G5(s,a);s.setData(r,t),l.setData(r)});export{Yg as g}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] diff --git a/static/vite/manifest.info b/static/vite/manifest.info index 8aa8975..2181a2d 100644 --- a/static/vite/manifest.info +++ b/static/vite/manifest.info @@ -1,17 +1,17 @@ { - "_browser-Co2CjrBv.js": { - "file": "browser-Co2CjrBv.js", + "_browser-C1tfp1OT.js": { + "file": "browser-C1tfp1OT.js", "isDynamicEntry": true, "imports": [ "js/main.js" ] }, "js/main.js": { - "file": "main-BgjuSik3.js", + "file": "main-CE-ujooY.js", "src": "js/main.js", "isEntry": true, "dynamicImports": [ - "_browser-Co2CjrBv.js" + "_browser-C1tfp1OT.js" ] } } \ No newline at end of file