1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[802],{9802:function(e,t,r){"use strict";r.d(t,{eI:function(){return tp}});let i=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>{var t,i,s,n;return t=void 0,i=void 0,s=void 0,n=function*(){return yield(yield Promise.resolve().then(r.t.bind(r,4098,23))).fetch(...e)},new(s||(s=Promise))(function(e,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(t){var r;t.done?e(t.value):((r=t.value)instanceof s?r:new s(function(e){e(r)})).then(o,a)}l((n=n.apply(t,i||[])).next())})}:fetch),(...e)=>t(...e)};class s extends Error{constructor(e,t="FunctionsError",r){super(e),super.name=t,this.context=r}}class n extends s{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class o extends s{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class a extends s{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}class l{constructor(e,{headers:t={},customFetch:r}={}){this.url=e,this.headers=t,this.fetch=i(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r,i,s,l,h;return i=this,s=void 0,l=void 0,h=function*(){try{let i;let{headers:s,method:l,body:h}=t,c={};h&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&("undefined"!=typeof Blob&&h instanceof Blob||h instanceof ArrayBuffer?(c["Content-Type"]="application/octet-stream",i=h):"string"==typeof h?(c["Content-Type"]="text/plain",i=h):"undefined"!=typeof FormData&&h instanceof FormData?i=h:(c["Content-Type"]="application/json",i=JSON.stringify(h)));let u=yield this.fetch(`${this.url}/${e}`,{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},c),this.headers),s),body:i}).catch(e=>{throw new n(e)}),d=u.headers.get("x-relay-error");if(d&&"true"===d)throw new o(u);if(!u.ok)throw new a(u);let f=(null!==(r=u.headers.get("Content-Type"))&&void 0!==r?r:"text/plain").split(";")[0].trim();return{data:"application/json"===f?yield u.json():"application/octet-stream"===f?yield u.blob():"multipart/form-data"===f?yield u.formData():yield u.text(),error:null}}catch(e){return{data:null,error:e}}},new(l||(l=Promise))(function(e,t){function r(e){try{o(h.next(e))}catch(e){t(e)}}function n(e){try{o(h.throw(e))}catch(e){t(e)}}function o(t){var i;t.done?e(t.value):((i=t.value)instanceof l?i:new l(function(e){e(i)})).then(r,n)}o((h=h.apply(i,s||[])).next())})}}var h,c,u,d,f,p,v,y,m,g,b,_,w,T,S,E,k,O,j,P=r(4098),x=r.n(P);class ${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:"undefined"==typeof fetch?this.fetch=x():this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),"GET"!==this.method&&"HEAD"!==this.method&&(this.headers["Content-Type"]="application/json");let r=this.fetch,i=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async e=>{var t,r,i;let s=null,n=null,o=null,a=e.status,l=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();""===t||(n="text/csv"===this.headers.Accept?t:this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?t:JSON.parse(t))}let i=null===(t=this.headers.Prefer)||void 0===t?void 0:t.match(/count=(exact|planned|estimated)/),h=null===(r=e.headers.get("content-range"))||void 0===r?void 0:r.split("/");i&&h&&h.length>1&&(o=parseInt(h[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(n)&&(n.length>1?(s={code:"PGRST116",details:`Results contain ${n.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},n=null,o=null,a=406,l="Not Acceptable"):n=1===n.length?n[0]:null)}else{let t=await e.text();try{s=JSON.parse(t),Array.isArray(s)&&404===e.status&&(n=[],s=null,a=200,l="OK")}catch(r){404===e.status&&""===t?(a=204,l="No Content"):s={message:t}}if(s&&this.isMaybeSingle&&(null===(i=null==s?void 0:s.details)||void 0===i?void 0:i.includes("Results contain 0 rows"))&&(s=null,a=200,l="OK"),s&&this.shouldThrowOnError)throw s}let h={error:s,data:n,count:o,status:a,statusText:l};return h});return this.shouldThrowOnError||(i=i.catch(e=>{var t,r,i;return{error:{message:`${null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError"}: ${null==e?void 0:e.message}`,details:`${null!==(r=null==e?void 0:e.stack)&&void 0!==r?r:""}`,hint:"",code:`${null!==(i=null==e?void 0:e.code)&&void 0!==i?i:""}`},data:null,count:null,status:0,statusText:""}}
1)),i.then(e,t)}}class A extends ${select(e){let t=!1,r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).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:i}={}){let s=i?`${i}.order`:"order",n=this.url.searchParams.get(s);return this.url.searchParams.set(s,`${n?`${n},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t}={}){let r=void 0===t?"limit":`${t}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:r}={}){let i=void 0===r?"offset":`${r}.offset`,s=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(s,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return"GET"===this.method?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:i=!1,wal:s=!1,format:n="text"}={}){let o=[e?"analyze":null,t?"verbose":null,r?"settings":null,i?"buffers":null,s?"wal":null].filter(Boolean).join("|"),a=this.headers.Accept;return this.headers.Accept=`application/vnd.pgrst.plan+${n}; for="${a}"; options=${o};`,this}rollback(){var e;return(null!==(e=this.headers.Prefer)&&void 0!==e?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class C extends A{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){let r=t.map(e=>"string"==typeof e&&RegExp("[,()]").test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return"string"==typeof t?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"string"==typeof t?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"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:i}={}){let s="";"plain"===i?s="pl":"phrase"===i?s="ph":"websearch"===i&&(s="w");let n=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${s}fts${n}.${t}`),this}match(e){return Object.entries(e).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t}={}){let r=t?`${t}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}}class R{constructor(e,{headers:t={},schema:r,fetch:i}){this.url=e,this.headers=t,this.schema=r,this.fetch=i}
1select(e,{head:t=!1,count:r}={}){let i=!1,s=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!i?"":('"'===e&&(i=!i),e)).join("");return this.url.searchParams.set("select",s),r&&(this.headers.Prefer=`count=${r}`),new C({method:t?"HEAD":"GET",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:r=!0}={}){let i=[];if(this.headers.Prefer&&i.push(this.headers.Prefer),t&&i.push(`count=${t}`),r||i.push("missing=default"),this.headers.Prefer=i.join(","),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);this.url.searchParams.set("columns",e.join(","))}}return new C({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:i,defaultToNull:s=!0}={}){let n=[`resolution=${r?"ignore":"merge"}-duplicates`];if(void 0!==t&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&n.push(this.headers.Prefer),i&&n.push(`count=${i}`),s||n.push("missing=default"),this.headers.Prefer=n.join(","),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);this.url.searchParams.set("columns",e.join(","))}}return new C({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){let r=[];return this.headers.Prefer&&r.push(this.headers.Prefer),t&&r.push(`count=${t}`),this.headers.Prefer=r.join(","),new C({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let t=[];return e&&t.push(`count=${e}`),this.headers.Prefer&&t.unshift(this.headers.Prefer),this.headers.Prefer=t.join(","),new C({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}let I={"X-Client-Info":"postgrest-js/1.7.0"};class U{constructor(e,{headers:t={},schema:r,fetch:i}={}){this.url=e,this.headers=Object.assign(Object.assign({},I),t),this.schema=r,this.fetch=i}from(e){let t=new URL(`${this.url}/${e}`);return new R(t,{headers:Object.assign({},this.headers),schema:this.schema,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:i}={}){let s,n;let o=new URL(`${this.url}/rpc/${e}`);r?(s="HEAD",Object.entries(t).forEach(([e,t])=>{o.searchParams.append(e,`${t}`)})):(s="POST",n=t);let a=Object.assign({},this.headers);return i&&(a.Prefer=`count=${i}`),new C({method:s,url:o,headers:a,schema:this.schema,body:n,fetch:this.fetch,allowEmpty:!1})}}var D=r(5840);let N={"X-Client-Info":"realtime-js/2.7.2"};(b=h||(h={}))[b.connecting=0]="connecting",b[b.open=1]="open",b[b.closing=2]="closing",b[b.closed=3]="closed",(_=c||(c={})).closed="closed",_.errored="errored",_.joined="joined",_.joining="joining",_.leaving="leaving",(w=u||(u={})).close="phx_close",w.error="phx_error",w.join="phx_join",w.reply="phx_reply",w.leave="phx_leave",w.access_token="access_token",(d||(d={})).websocket="websocket",(T=f||(f={})).Connecting="connecting",T.Open="open",T.Closing="closing",T.Closed="closed";class L{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 B{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):"string"==typeof e?t(JSON.parse(e)):t({})}_binaryDecode(e){let t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){let i=t.getUint8(1),s=t.getUint8(2),n=this.HEADER_LENGTH+2,o=r.decode(e.slice(n,n+i));n+=i;let a=r.decode(e.slice(n,n+s));n+=s;let l=JSON.parse(r.decode(e.slice(n,e.byteLength)));return{ref:null,topic:o,event:a,payload:l}}}class F{constructor(e,t,r={},i=1e4){this.channel=e,this.event=t,this.payload=r,this.timeout=i,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHo
1oks=[],this.refEvent=null,this.rateLimited=!1}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){if(this._hasReceived("timeout"))return;this.startTimeout(),this.sent=!0;let e=this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()});"rate limited"===e&&(this.rateLimited=!0)}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t(null===(r=this.receivedResp)||void 0===r?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){this.timeoutTimer||(this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref),this.channel._on(this.refEvent,{},e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(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(t=>t.status===e).forEach(e=>e.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}(S=p||(p={})).SYNC="sync",S.JOIN="join",S.LEAVE="leave";class M{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let r=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},e=>{let{onJoin:t,onLeave:r,onSync:i}=this.caller;this.joinRef=this.channel._joinRef(),this.state=M.syncState(this.state,e,t,r),this.pendingDiffs.forEach(e=>{this.state=M.syncDiff(this.state,e,t,r)}),this.pendingDiffs=[],i()}),this.channel._on(r.diff,{},e=>{let{onJoin:t,onLeave:r,onSync:i}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=M.syncDiff(this.state,e,t,r),i())}),this.onJoin((e,t,r)=>{this.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:r})}),this.onLeave((e,t,r)=>{this.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:r})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,i){let s=this.cloneDeep(e),n=this.transformState(t),o={},a={};return this.map(s,(e,t)=>{n[e]||(a[e]=t)}),this.map(n,(e,t)=>{let r=s[e];if(r){let i=t.map(e=>e.presence_ref),s=r.map(e=>e.presence_ref),n=t.filter(e=>0>s.indexOf(e.presence_ref)),l=r.filter(e=>0>i.indexOf(e.presence_ref));n.length>0&&(o[e]=n),l.length>0&&(a[e]=l)}else o[e]=t}),this.syncDiff(s,{joins:o,leaves:a},r,i)}static syncDiff(e,t,r,i){let{joins:s,leaves:n}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),i||(i=()=>{}),this.map(s,(t,i)=>{var s;let n=null!==(s=e[t])&&void 0!==s?s:[];if(e[t]=this.cloneDeep(i),n.length>0){let r=e[t].map(e=>e.presence_ref),i=n.filter(e=>0>r.indexOf(e.presence_ref));e[t].unshift(...i)}r(t,n,i)}),this.map(n,(t,r)=>{let s=e[t];if(!s)return;let n=r.map(e=>e.presence_ref);s=s.filter(e=>0>n.indexOf(e.presence_ref)),e[t]=s,i(t,s,r),0===s.length&&delete e[t]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return Object.getOwnPropertyNames(e=this.cloneDeep(e)).reduce((t,r)=>{let i=e[r];return"metas"in i?t[r]=i.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e)):t[r]=i,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()}}(E=v||(v={})).abstime="abstime",E.bool="bool",E.date="date",E.daterange="daterange",E.float4="float4",E.float8="float8",E.int2="int2",E.int4="int4",E.int4range="int4range",E.int8="int8",E.int8range="int8range",E.json="json",E.jsonb="jsonb",E.money="money",E.numeric="numeric",E.oid="oid",E.reltime="reltime",E.text="text",E.time="time",E.timestamp="timestamp",E.timestamptz="timestamptz",E.timetz="timetz",E.tsrange="tsrange",E.tstzrange="tstzrange";let J=(e,t,r={})=>{var i;let s=null!==(i=r.skipTypes)&&void 0!==i?i:[];return Object.keys(t).reduce((r,i)=>(r[i]=H(i,e,t,s),r),{})},H=(e,t,r,i)=>{let s=t.find(t=>t.name===e),n=null==s?void 0:s.type,o=r[e];return n&&!i.includes(n)?z(n,o):G(o)},z=(e,t)=>{if("_"===e.charAt(0)){let r=e.slice(1,e.length);return W(t,r)}switch(e){case v.bool:return K(t);case v.float4:case v.float8:case v.int2:case v.int4:case v.int8:case v.numeric:case v.oid:return q(t);case v.json:case v.jsonb:return V(t);case v.timestamp:return X(t);case v.abstime:case v.date:case v.daterange:case v.int4range:case v.int8range:case v.money:case v.reltime:case v.text:case v.time:case v.timestamptz:case v.timetz:case v.tsrange:case v.tstzrange:default:return G(t)}},G=e=>e,K=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},q=e=>{if("string"==typeof e){let t=parseFloat(e);
1if(!Number.isNaN(t))return t}return e},V=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){console.log(`JSON parse error: ${e}`)}return e},W=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,i=e[r],s=e[0];if("{"===s&&"}"===i){let i;let s=e.slice(1,r);try{i=JSON.parse("["+s+"]")}catch(e){i=s?s.split(","):[]}return i.map(e=>z(t,e))}return e},X=e=>"string"==typeof e?e.replace(" ","T"):e;var Y=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};(k=y||(y={})).ALL="*",k.INSERT="INSERT",k.UPDATE="UPDATE",k.DELETE="DELETE",(O=m||(m={})).BROADCAST="broadcast",O.PRESENCE="presence",O.POSTGRES_CHANGES="postgres_changes",(j=g||(g={})).SUBSCRIBED="SUBSCRIBED",j.TIMED_OUT="TIMED_OUT",j.CLOSED="CLOSED",j.CHANNEL_ERROR="CHANNEL_ERROR";class Q{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=c.closed,this.joinedOnce=!1,this.pushBuffer=[],this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new F(this,u.join,this.params,this.timeout),this.rejoinTimer=new L(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=c.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=c.closed,this.socket._remove(this)}),this._onError(e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=c.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=c.errored,this.rejoinTimer.scheduleTimeout())}),this._on(u.reply,{},(e,t)=>{this._trigger(this._replyEventName(t),e)}),this.presence=new M(this)}subscribe(e,t=this.timeout){var r,i;if(this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{let{config:{broadcast:s,presence:n}}=this.params;this._onError(t=>e&&e("CHANNEL_ERROR",t)),this._onClose(()=>e&&e("CLOSED"));let o={},a={broadcast:s,presence:n,postgres_changes:null!==(i=null===(r=this.bindings.postgres_changes)||void 0===r?void 0:r.map(e=>e.filter))&&void 0!==i?i:[]};this.socket.accessToken&&(o.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:a},o)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",({postgres_changes:t})=>{var r;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),void 0===t){e&&e("SUBSCRIBED");return}{let i=this.bindings.postgres_changes,s=null!==(r=null==i?void 0:i.length)&&void 0!==r?r:0,n=[];for(let r=0;r<s;r++){let s=i[r],{filter:{event:o,schema:a,table:l,filter:h}}=s,c=t&&t[r];if(c&&c.event===o&&c.schema===a&&c.table===l&&c.filter===h)n.push(Object.assign(Object.assign({},s),{id:c.id}));else{this.unsubscribe(),e&&e("CHANNEL_ERROR",Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=n,e&&e("SUBSCRIBED");return}}).receive("error",t=>{e&&e("CHANNEL_ERROR",Error(JSON.stringify(Object.values(t).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}track(e,t={}){return Y(this,void 0,void 0,function*(){return yield this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)})}untrack(e={}){return Y(this,void 0,void 0,function*(){return yield this.send({type:"presence",event:"untrack"},e)})}on(e,t,r){return this._on(e,t,r)}send(e,t={}){return new Promise(r=>{var i,s,n;let o=this._push(e.type,e,t.timeout||this.timeout);o.rateLimited&&r("rate limited"),"broadcast"!==e.type||(null===(n=null===(s=null===(i=this.params)||void 0===i?void 0:i.config)||void 0===s?void 0:s.broadcast)||void 0===n?void 0:n.ack)||r("ok"),o.receive("ok",()=>r("ok")),o.receive("timeout",()=>r("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}
1unsubscribe(e=this.timeout){this.state=c.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(u.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{let i=new F(this,u.leave,{},e);i.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),i.send(),this._canPush()||i.trigger("ok",{})})}_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 i=new F(this,e,t,r);return this._canPush()?i.send():(i.startTimeout(),this.pushBuffer.push(i)),i}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var i,s;let n=e.toLocaleLowerCase(),{close:o,error:a,leave:l,join:h}=u;if(r&&[o,a,l,h].indexOf(n)>=0&&r!==this._joinRef())return;let c=this._onMessage(n,t,r);if(t&&!c)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(n)?null===(i=this.bindings.postgres_changes)||void 0===i||i.filter(e=>{var t,r,i;return(null===(t=e.filter)||void 0===t?void 0:t.event)==="*"||(null===(i=null===(r=e.filter)||void 0===r?void 0:r.event)||void 0===i?void 0:i.toLocaleLowerCase())===n}).map(e=>e.callback(c,r)):null===(s=this.bindings[n])||void 0===s||s.filter(e=>{var r,i,s,o,a,l;if(!["broadcast","presence","postgres_changes"].includes(n))return e.type.toLocaleLowerCase()===n;if("id"in e){let n=e.id,o=null===(r=e.filter)||void 0===r?void 0:r.event;return n&&(null===(i=t.ids)||void 0===i?void 0:i.includes(n))&&("*"===o||(null==o?void 0:o.toLocaleLowerCase())===(null===(s=t.data)||void 0===s?void 0:s.type.toLocaleLowerCase()))}{let r=null===(a=null===(o=null==e?void 0:e.filter)||void 0===o?void 0:o.event)||void 0===a?void 0:a.toLocaleLowerCase();return"*"===r||r===(null===(l=null==t?void 0:t.event)||void 0===l?void 0:l.toLocaleLowerCase())}}).map(e=>{if("object"==typeof c&&"ids"in c){let e=c.data,{schema:t,table:r,commit_timestamp:i,type:s,errors:n}=e;c=Object.assign(Object.assign({},{schema:t,table:r,commit_timestamp:i,eventType:s,new:{},old:{},errors:n}),this._getPayloadRecords(e))}e.callback(c,r)})}_isClosed(){return this.state===c.closed}_isJoined(){return this.state===c.joined}_isJoining(){return this.state===c.joining}_isLeaving(){return this.state===c.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){let i=e.toLocaleLowerCase(),s={type:i,filter:t,callback:r};return this.bindings[i]?this.bindings[i].push(s):this.bindings[i]=[s],this}_off(e,t){let r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(e=>{var i;return!((null===(i=e.type)||void 0===i?void 0:i.toLocaleLowerCase())===r&&Q.isEqual(e.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let 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(u.close,{},e)}_onError(e){this._on(u.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=c.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=J(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=J(e.columns,e.old_record)),t}}var Z=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};let ee=()=>{};class et{constructor(e,t){var r;this.accessToken=null,this.channels=[],this.endPoint="",this.headers=N,this.params={},this.timeout=1e4,this.transport=D.w3cwebsocket,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=ee,this.conn=null,this.sendBuffer=[],this.serializer
1=new B,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.eventsPerSecondLimitMs=100,this.inThrottle=!1,this.endPoint=`${e}/${d.websocket}`,(null==t?void 0:t.params)&&(this.params=t.params),(null==t?void 0:t.headers)&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),(null==t?void 0:t.timeout)&&(this.timeout=t.timeout),(null==t?void 0:t.logger)&&(this.logger=t.logger),(null==t?void 0:t.transport)&&(this.transport=t.transport),(null==t?void 0:t.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);let i=null===(r=null==t?void 0:t.params)||void 0===r?void 0:r.eventsPerSecond;i&&(this.eventsPerSecondLimitMs=Math.floor(1e3/i)),this.reconnectAfterMs=(null==t?void 0:t.reconnectAfterMs)?t.reconnectAfterMs:e=>[1e3,2e3,5e3,1e4][e-1]||1e4,this.encode=(null==t?void 0:t.encode)?t.encode:(e,t)=>t(JSON.stringify(e)),this.decode=(null==t?void 0:t.decode)?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new L(()=>Z(this,void 0,void 0,function*(){this.disconnect(),this.connect()}),this.reconnectAfterMs)}connect(){!this.conn&&(this.conn=new this.transport(this._endPointURL(),[],null,this.headers),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)))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,null!=t?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}removeChannel(e){return Z(this,void 0,void 0,function*(){let t=yield e.unsubscribe();return 0===this.channels.length&&this.disconnect(),t})}removeAllChannels(){return Z(this,void 0,void 0,function*(){let e=yield Promise.all(this.channels.map(e=>e.unsubscribe()));return this.disconnect(),e})}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case h.connecting:return f.Connecting;case h.open:return f.Open;case h.closing:return f.Closing;default:return f.Closed}}isConnected(){return this.connectionState()===f.Open}channel(e,t={config:{}}){this.isConnected()||this.connect();let r=new Q(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){let{topic:t,event:r,payload:i,ref:s}=e,n=()=>{this.encode(e,e=>{var t;null===(t=this.conn)||void 0===t||t.send(e)})};if(this.log("push",`${t} ${r} (${s})`,i),this.isConnected()){if(["broadcast","presence","postgres_changes"].includes(r)){let e=this._throttle(n)();if(e)return"rate limited"}else n()}else this.sendBuffer.push(n)}setAuth(e){this.accessToken=e,this.channels.forEach(t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(u.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(t=>t.topic===e&&(t._isJoined()||t._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}_onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:r,payload:i,ref:s}=e;(s&&s===this.pendingHeartbeatRef||r===(null==i?void 0:i.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${i.status||""} ${t} ${r} ${s&&"("+s+")"||""}`,i),this.channels.filter(e=>e._isMember(t)).forEach(e=>e._trigger(r,i,s)),this.stateChangeCallbacks.message.forEach(t=>t(e))})}_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))}
1_triggerChanError(){this.channels.forEach(e=>e._trigger(u.error))}_appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?",i=new URLSearchParams(t);return`${e}${r}${i}`}_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"),null===(e=this.conn)||void 0===e||e.close(1e3,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}_throttle(e,t=this.eventsPerSecondLimitMs){return()=>!!this.inThrottle||(e(),t>0&&(this.inThrottle=!0,setTimeout(()=>{this.inThrottle=!1},t)),!1)}}class er extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function ei(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class es extends er{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class en extends er{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var eo=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};let ea=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>eo(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(r.t.bind(r,4098,23))).fetch(...e)}):fetch),(...e)=>t(...e)},el=()=>eo(void 0,void 0,void 0,function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(r.t.bind(r,4098,23))).Response:Response});var eh=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};let ec=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),eu=(e,t)=>eh(void 0,void 0,void 0,function*(){let r=yield el();e instanceof r?e.json().then(r=>{t(new es(ec(r),e.status||500))}).catch(e=>{t(new en(ec(e),e))}):t(new en(ec(e),e))}),ed=(e,t,r,i)=>{let s={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?s:(s.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),s.body=JSON.stringify(i),Object.assign(Object.assign({},s),r))};function ef(e,t,r,i,s,n){return eh(this,void 0,void 0,function*(){return new Promise((o,a)=>{e(r,ed(t,i,s,n)).then(e=>{if(!e.ok)throw e;return(null==i?void 0:i.noResolveJson)?e:e.json()}).then(e=>o(e)).catch(e=>eu(e,a))})})}function ep(e,t,r,i){return eh(this,void 0,void 0,function*(){return ef(e,"GET",t,r,i)})}function ev(e,t,r,i,s){return eh(this,void 0,void 0,function*(){return ef(e,"POST",t,i,s,r)})}function ey(e,t,r,i,s){return eh(this,void 0,void 0,function*(){return ef(e,"DELETE",t,i,s,r)})}var em=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};let eg={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},eb={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class e_{constructor(e,t={},r,i){this.url=e,this.headers=t,this.bucketId=r,this.fetch=ea(i)}uploadOrUpdate(e,t,r,i){return em(this,void 0,void 0,function*(){try{let s;let n=Object.assign(Object.assign({},eb),i),o=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(n.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?((s=new FormData).append("cacheControl",n.cacheControl),s.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(s=r).append("cacheControl",n.cacheControl):(s=r,o["cache-control"]=`max-age=${n.cacheControl}`,o["content-type"]=n.contentType);let a=this._removeEmptyFolders(t),l=this._getFinalPath(a),h=yield this.fetch(`${this.url}/object/${l}`,Object.assign({method:e,body:s,headers:o},(null==n?void 0:n.duplex)?{duplex:n.duplex}:{}));if(h.ok)return{data:{path:a},error:null};{let e=yield h.json();return{data:null,error:e}}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}upload(e,t,r){return em(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}
1uploadToSignedUrl(e,t,r,i){return em(this,void 0,void 0,function*(){let s=this._removeEmptyFolders(e),n=this._getFinalPath(s),o=new URL(this.url+`/object/upload/sign/${n}`);o.searchParams.set("token",t);try{let e;let t=Object.assign({upsert:eb.upsert},i),n=Object.assign(Object.assign({},this.headers),{"x-upsert":String(t.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),e.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(e=r).append("cacheControl",t.cacheControl):(e=r,n["cache-control"]=`max-age=${t.cacheControl}`,n["content-type"]=t.contentType);let a=yield this.fetch(o.toString(),{method:"PUT",body:e,headers:n});if(a.ok)return{data:{path:s},error:null};{let e=yield a.json();return{data:null,error:e}}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}createSignedUploadUrl(e){return em(this,void 0,void 0,function*(){try{let t=this._getFinalPath(e),r=yield ev(this.fetch,`${this.url}/object/upload/sign/${t}`,{},{headers:this.headers}),i=new URL(this.url+r.url),s=i.searchParams.get("token");if(!s)throw new er("No token returned by API");return{data:{signedUrl:i.toString(),path:e,token:s},error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}update(e,t,r){return em(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t){return em(this,void 0,void 0,function*(){try{let r=yield ev(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers});return{data:r,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}copy(e,t){return em(this,void 0,void 0,function*(){try{let r=yield ev(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers});return{data:{path:r.Key},error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}createSignedUrl(e,t,r){return em(this,void 0,void 0,function*(){try{let i=this._getFinalPath(e),s=yield ev(this.fetch,`${this.url}/object/sign/${i}`,Object.assign({expiresIn:t},(null==r?void 0:r.transform)?{transform:r.transform}:{}),{headers:this.headers}),n=(null==r?void 0:r.download)?`&download=${!0===r.download?"":r.download}`:"",o=encodeURI(`${this.url}${s.signedURL}${n}`);return{data:s={signedUrl:o},error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}createSignedUrls(e,t,r){return em(this,void 0,void 0,function*(){try{let i=yield ev(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),s=(null==r?void 0:r.download)?`&download=${!0===r.download?"":r.download}`:"";return{data:i.map(e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${s}`):null})),error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}download(e,t){return em(this,void 0,void 0,function*(){let r=void 0!==(null==t?void 0:t.transform),i=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),s=i?`?${i}`:"";try{let t=this._getFinalPath(e),i=yield ep(this.fetch,`${this.url}/${r?"render/image/authenticated":"object"}/${t}${s}`,{headers:this.headers,noResolveJson:!0}),n=yield i.blob();return{data:n,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}getPublicUrl(e,t){let r=this._getFinalPath(e),i=[],s=(null==t?void 0:t.download)?`download=${!0===t.download?"":t.download}`:"";""!==s&&i.push(s);let n=void 0!==(null==t?void 0:t.transform),o=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==o&&i.push(o);let a=i.join("&");return""!==a&&(a=`?${a}`),{data:{publicUrl:encodeURI(`${this.url}/${n?"render/image":"object"}/public/${r}${a}`)}}}remove(e){return em(this,void 0,void 0,function*(){try{let t=yield ey(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers});return{data:t,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}list(e,t,r){return em(this,void 0,void 0,function*(){try{let i=Object.assign(Object.assign(Object.assign({},eg),t),{prefix:e||""}),s=yield ev(this.fetch,`${this.url}/object/list/${this.bucketId}`,i,{headers:this.headers},r);return{data:s,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let 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("&")}}let ew={"X-Client-Info":"storage-js/2.5.1"};var eT=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};class eS{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},ew),t),this.fetch=ea(r)}listBuckets(){return eT(this,void 0,void 0,function*(){try{let e=yield ep(this.fetch,`${this.url}/bucket`,{headers:this.headers});return{data:e,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}getBucket(e){return eT(this,void 0,void 0,function*(){try{let t=yield ep(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers});return{data:t,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}createBucket(e,t={public:!1}){return eT(this,void 0,void 0,function*(){try{let r=yield ev(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});return{data:r,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}updateBucket(e,t){return eT(this,void 0,void 0,function*(){try{let r=yield function(e,t,r,i,s){return eh(this,void 0,void 0,function*(){return ef(e,"PUT",t,i,void 0,r)})}(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});return{data:r,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}emptyBucket(e){return eT(this,void 0,void 0,function*(){try{let t=yield ev(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers});return{data:t,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}deleteBucket(e){return eT(this,void 0,void 0,function*(){try{let t=yield ey(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers});return{data:t,error:null}}catch(e){if(ei(e))return{data:null,error:e};throw e}})}}class eE extends eS{constructor(e,t={},r){super(e,t,r)}from(e){return new e_(this.url,this.headers,e,this.fetch)}}let ek=e=>{let t;return t=e||("undefined"==typeof fetch?x():fetch),(...e)=>t(...e)},eO=()=>"undefined"==typeof Headers?P.Headers:Headers,ej=(e,t,r)=>{let i=ek(r),s=eO();return(r,n)=>{var o,a,l,h;return o=void 0,a=void 0,l=void 0,h=function*(){var o;let a=null!==(o=yield t())&&void 0!==o?o:e,l=new s(null==n?void 0:n.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization",`Bearer ${a}`),i(r,Object.assign(Object.assign({},n),{headers:l}))},new(l||(l=Promise))(function(e,t){function r(e){try{s(h.next(e))}catch(e){t(e)}}function i(e){try{s(h.throw(e))}catch(e){t(e)}}function s(t){var s;t.done?e(t.value):((s=t.value)instanceof l?s:new l(function(e){e(s)})).then(r,i)}s((h=h.apply(o,a||[])).next())})}};var eP=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};let ex=()=>"undefined"!=typeof document,e$={tested:!1,writable:!1},eA=()=>{if(!ex())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(e$.tested)return e$.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),e$.tested=!0,e$.writable=!0}catch(e){e$.tested=!0,e$.writable=!1}return e$.writable};function eC(e,t){var r;t||(t=(null===(r=null==window?void 0:window.location)||void 0===r?void 0:r.href)||""),e=e.replace(/[\[\]]/g,"\\$&");let i=RegExp("[?&#]"+e+"(=([^&#]*)|&|#|$)"),s=i.exec(t);
1return s?s[2]?decodeURIComponent(s[2].replace(/\+/g," ")):"":null}let eR=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>eP(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(r.t.bind(r,4098,23))).fetch(...e)}):fetch),(...e)=>t(...e)},eI=e=>"object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json,eU=(e,t,r)=>eP(void 0,void 0,void 0,function*(){yield e.setItem(t,JSON.stringify(r))}),eD=(e,t)=>eP(void 0,void 0,void 0,function*(){let r=yield e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return r}}),eN=(e,t)=>eP(void 0,void 0,void 0,function*(){yield e.removeItem(t)});class eL{constructor(){this.promise=new eL.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function eB(e){let t=e.split(".");if(3!==t.length)throw Error("JWT is not valid: not a JWT structure");if(!/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i.test(t[1]))throw Error("JWT is not valid: payload is not in base64url format");let r=t[1];return JSON.parse(function(e){let t,r,i,s,n,o,a;let l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h="",c=0;for(e=e.replace("-","+").replace("_","/");c<e.length;)s=l.indexOf(e.charAt(c++)),n=l.indexOf(e.charAt(c++)),o=l.indexOf(e.charAt(c++)),a=l.indexOf(e.charAt(c++)),t=s<<2|n>>4,r=(15&n)<<4|o>>2,i=(3&o)<<6|a,h+=String.fromCharCode(t),64!=o&&0!=r&&(h+=String.fromCharCode(r)),64!=a&&0!=i&&(h+=String.fromCharCode(i));return h}(r))}function eF(e){return("0"+e.toString(16)).substr(-2)}function eM(){let e=new Uint32Array(56);if("undefined"==typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let i=0;i<56;i++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,eF).join("")}function eJ(e){return eP(this,void 0,void 0,function*(){if("undefined"==typeof crypto)return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e;let t=yield function(e){return eP(this,void 0,void 0,function*(){let t=new TextEncoder,r=t.encode(e),i=yield crypto.subtle.digest("SHA-256",r),s=new Uint8Array(i);return Array.from(s).map(e=>String.fromCharCode(e)).join("")})}(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")})}eL.promiseConstructor=Promise;class eH extends Error{constructor(e,t){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t}}function ez(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class eG extends eH{constructor(e,t){super(e,t),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class eK extends eH{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class eq extends eH{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class eV extends eq{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class eW extends eq{constructor(){super("Auth session or user missing","AuthInvalidToken
1ResponseError",500)}}class eX extends eq{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class eY extends eq{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 eQ extends eq{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 eZ extends eq{constructor(e,t){super(e,"AuthRetryableFetchError",t)}}var e0=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})},e1=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)0>t.indexOf(i[s])&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(r[i[s]]=e[i[s]]);return r};let e4=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),e2=(e,t)=>e0(void 0,void 0,void 0,function*(){eI(e)?[502,503,504].includes(e.status)?t(new eZ(e4(e),e.status)):e.json().then(r=>{t(new eG(e4(r),e.status||500))}).catch(e=>{t(new eK(e4(e),e))}):t(new eZ(e4(e),0))}),e3=(e,t,r,i)=>{let s={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==t?void 0:t.headers),s.body=JSON.stringify(i),Object.assign(Object.assign({},s),r))};function e8(e,t,r,i){var s;return e0(this,void 0,void 0,function*(){let n=Object.assign({},null==i?void 0:i.headers);(null==i?void 0:i.jwt)&&(n.Authorization=`Bearer ${i.jwt}`);let o=null!==(s=null==i?void 0:i.query)&&void 0!==s?s:{};(null==i?void 0:i.redirectTo)&&(o.redirect_to=i.redirectTo);let a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=yield function(e,t,r,i,s,n){return e0(this,void 0,void 0,function*(){return new Promise((o,a)=>{e(r,e3(t,i,s,n)).then(e=>{if(!e.ok)throw e;return(null==i?void 0:i.noResolveJson)?e:e.json()}).then(e=>o(e)).catch(e=>e2(e,a))})})}(e,t,r+a,{headers:n,noResolveJson:null==i?void 0:i.noResolveJson},{},null==i?void 0:i.body);return(null==i?void 0:i.xform)?null==i?void 0:i.xform(l):{data:Object.assign({},l),error:null}})}function e9(e){var t;let r=null;e.access_token&&e.refresh_token&&e.expires_in&&((r=Object.assign({},e)).expires_at=function(e){let t=Math.round(Date.now()/1e3);return t+e}(e.expires_in));let i=null!==(t=e.user)&&void 0!==t?t:e;return{data:{session:r,user:i},error:null}}function e5(e){var t;let r=null!==(t=e.user)&&void 0!==t?t:e;return{data:{user:r},error:null}}function e6(e){return{data:e,error:null}}function e7(e){let{action_link:t,email_otp:r,hashed_token:i,redirect_to:s,verification_type:n}=e,o=e1(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a=Object.assign({},o);return{data:{properties:{action_link:t,email_otp:r,hashed_token:i,redirect_to:s,verification_type:n},user:a},error:null}}function te(e){return e}var tt=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})},tr=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)0>t.indexOf(i[s])&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(r[i[s]]=e[i[s]]);return r};class ti{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=eR(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}signOut(e){return tt(this,void 0,void 0,function*(){try{return yield e8(this.fetch,"POST",`${this.url}/logout`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(ez(e))return{data:null,error:e};throw e}})}inviteUserByEmail(e,t={}){return tt(this,void 0,void 0,function*(){try{return yield e8(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:e5})}catch(e){if(ez(e))return{data:{user:null},error:e};throw e}})}generateLink(e){return tt(this,void 0,void 0,function*(){try{let{options:t}=e,r=tr(e,["options"]),i=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(i.new_email=null==r?void 0:r.newEmail,delete i.newEmail),yield e8(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:e7,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(ez(e))return{data:{properties:null,user:null},error:e};throw e}})}createUser(e){return tt(this,void 0,void 0,function*(){try{return yield e8(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:e5})}catch(e){if(ez(e))return{data:{user:null},error:e};throw e}})}listUsers(e){var t,r,i,s,n,o,a;return tt(this,void 0,void 0,function*(){try{let l={nextPage:null,lastPage:0,total:0},h=yield e8(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!==(r=null===(t=null==e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==r?r:"",per_page:null!==(s=null===(i=null==e?void 0:e.perPage)||void 0===i?void 0:i.toString())&&void 0!==s?s:""},xform:te});if(h.error)throw h.error;let c=yield h.json(),u=null!==(n=h.headers.get("x-total-count"))&&void 0!==n?n:0,d=null!==(a=null===(o=h.headers.get("link"))||void 0===o?void 0:o.split(","))&&void 0!==a?a:[];return d.length>
10&&(d.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(u)),{data:Object.assign(Object.assign({},c),l),error:null}}catch(e){if(ez(e))return{data:{users:[]},error:e};throw e}})}getUserById(e){return tt(this,void 0,void 0,function*(){try{return yield e8(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:e5})}catch(e){if(ez(e))return{data:{user:null},error:e};throw e}})}updateUserById(e,t){return tt(this,void 0,void 0,function*(){try{return yield e8(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:e5})}catch(e){if(ez(e))return{data:{user:null},error:e};throw e}})}deleteUser(e,t=!1){return tt(this,void 0,void 0,function*(){try{return yield e8(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:e5})}catch(e){if(ez(e))return{data:{user:null},error:e};throw e}})}_listFactors(e){return tt(this,void 0,void 0,function*(){try{let{data:t,error:r}=yield e8(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:r}}catch(e){if(ez(e))return{data:null,error:e};throw e}})}_deleteFactor(e){return tt(this,void 0,void 0,function*(){try{let t=yield e8(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers});return{data:t,error:null}}catch(e){if(ez(e))return{data:null,error:e};throw e}})}}var ts={getItem:e=>eA()?globalThis.localStorage.getItem(e):null,setItem:(e,t)=>{eA()&&globalThis.localStorage.setItem(e,t)},removeItem:e=>{eA()&&globalThis.localStorage.removeItem(e)}},tn=function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};!function(){if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!=typeof self&&(self.globalThis=self)}}();let to={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:{"X-Client-Info":"gotrue-js/2.29.0"},flowType:"implicit"};class ta{constructor(e){var t;this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.broadcastChannel=null;let r=Object.assign(Object.assign({},to),e);if(this.inMemorySession=null,this.storageKey=r.storageKey,this.autoRefreshToken=r.autoRefreshToken,this.persistSession=r.persistSession,this.storage=r.storage||ts,this.admin=new ti({url:r.url,headers:r.headers,fetch:r.fetch}),this.url=r.url,this.headers=r.headers,this.fetch=eR(r.fetch),this.detectSessionInUrl=r.detectSessionInUrl,this.flowType=r.flowType,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&&this.storage===ts&&!eA()&&console.warn(`No storage option exists to persist the session, which may result in unexpected behavior when using auth. 2 If you want to set persistSession to true, please provide a storage option or you may set persistSession to false to disable this warning.`),ex()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(e){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",e)}null===(t=this.broadcastChannel)||void 0===t||t.addEventListener("message",e=>{this._notifyAllSubscribers(e.data.event,e.data.session,!1)})}this.initialize()}initialize(){return this.initializePromise||(this.initializePromise=this._initialize()),this.initializePromise}_initialize(){return tn(this,void 0,void 0,function*(){if(this.initializePromise)return this.initializePromise;try{let e=!!ex()&&(yield this._isPKCEFlow());if(e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){let{data:t,error:r}=yield this._getSessionFromUrl(e);if(r)return yield this._removeSession(),{error:r};let{session:i,redirectType:s}=t;return yield this._saveSession(i),setTimeout(()=>{"recovery"===s?this._notifyAllSubscribers("PASSWORD_RECOVERY",i):this._notifyAllSubscribers("SIGNED_IN",i)},0),{error:null}}return yield this._recoverAndRefresh(),{error:null}}catch(e){if(ez(e))return{error:e};return{error:new eK("Unexpected error during initialization",e)}}finally{yield this._handleVisibilityChange()}})}signUp(e){var t,r,i;return tn(this,void 0,void 0,function*(){try{let s;if(yield this._removeSession(),"email"in e){let{email:r,password:i,options:n}=e,o=null,a=null;if("pkce"===this.flowType){let e=eM();yield eU(this.storage,`${this.storageKey}-code-verifier`,e),o=yield eJ(e),a=e===o?"plain":"s256"}s=yield e8(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==n?void 0:n.emailRedirectTo,body:{email:r,password:i,data:null!==(t=null==n?void 0:n.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}
2,code_challenge:o,code_challenge_method:a},xform:e9})}else if("phone"in e){let{phone:t,password:n,options:o}=e;s=yield e8(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!==(r=null==o?void 0:o.data)&&void 0!==r?r:{},channel:null!==(i=null==o?void 0:o.channel)&&void 0!==i?i:"sms",gotrue_meta_security:{captcha_token:null==o?void 0:o.captchaToken}},xform:e9})}else throw new eX("You must provide either an email or phone number and a password");let{data:n,error:o}=s;if(o||!n)return{data:{user:null,session:null},error:o};let a=n.session,l=n.user;return n.session&&(yield this._saveSession(n.session),this._notifyAllSubscribers("SIGNED_IN",a)),{data:{user:l,session:a},error:null}}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}signInWithPassword(e){return tn(this,void 0,void 0,function*(){try{let t;if(yield this._removeSession(),"email"in e){let{email:r,password:i,options:s}=e;t=yield e8(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:r,password:i,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}},xform:e9})}else if("phone"in e){let{phone:r,password:i,options:s}=e;t=yield e8(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:r,password:i,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}},xform:e9})}else throw new eX("You must provide either an email or phone number and a password");let{data:r,error:i}=t;if(i)return{data:{user:null,session:null},error:i};if(!r||!r.session||!r.user)return{data:{user:null,session:null},error:new eW};return r.session&&(yield this._saveSession(r.session),this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:{user:r.user,session:r.session},error:i}}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}signInWithOAuth(e){var t,r,i,s;return tn(this,void 0,void 0,function*(){return yield this._removeSession(),yield this._handleProviderSignIn(e.provider,{redirectTo:null===(t=e.options)||void 0===t?void 0:t.redirectTo,scopes:null===(r=e.options)||void 0===r?void 0:r.scopes,queryParams:null===(i=e.options)||void 0===i?void 0:i.queryParams,skipBrowserRedirect:null===(s=e.options)||void 0===s?void 0:s.skipBrowserRedirect})})}exchangeCodeForSession(e){return tn(this,void 0,void 0,function*(){let t=yield eD(this.storage,`${this.storageKey}-code-verifier`),{data:r,error:i}=yield e8(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:t},xform:e9});return(yield eN(this.storage,`${this.storageKey}-code-verifier`),i)?{data:{user:null,session:null},error:i}:r&&r.session&&r.user?(r.session&&(yield this._saveSession(r.session),this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:r,error:i}):{data:{user:null,session:null},error:new eW}})}signInWithIdToken(e){return tn(this,void 0,void 0,function*(){yield this._removeSession();try{let{options:t,provider:r,token:i,nonce:s}=e,n=yield e8(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:i,nonce:s,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:e9}),{data:o,error:a}=n;if(a)return{data:{user:null,session:null},error:a};if(!o||!o.session||!o.user)return{data:{user:null,session:null},error:new eW};return o.session&&(yield this._saveSession(o.session),this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:o,error:a}}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}signInWithOtp(e){var t,r,i,s,n;return tn(this,void 0,void 0,function*(){try{if(yield this._removeSession(),"email"in e){let{email:i,options:s}=e,n=null,o=null;if("pkce"===this.flowType){let e=eM();yield eU(this.storage,`${this.storageKey}-code-verifier`,e),n=yield eJ(e),o=e===n?"plain":"s256"}let{error:a}=yield e8(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:null!==(t=null==s?void 0:s.data)&&void 0!==t?t:{},create_user:null===(r=null==s?void 0:s.shouldCreateUser)||void 0===r||r,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken},code_challenge:n,code_challenge_method:o},redirectTo:null==s?void 0:s.emailRedirectTo});return{data:{user:null,session:null},error:a}}if("phone"in e){let{phone:t,options:r}=e,{error:o}=yield e8(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!==(i=null==r?void 0:r.data)&&void 0!==i?i:{},create_user:null===(s=null==r?void 0:r.shouldCreateUser)||void 0===s||s,gotrue_meta_security:{captcha_token:null==r?void 0:r.captchaToken},channel:null!==(n=null==r?void 0:r.channel)&&void 0!==n?n:"sms"}});return{data:{user:null,session:null},error:o}}throw new eX("You must provide either an email or phone number.")}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}verifyOtp(e){var t,r;return tn(this,void 0,void 0,function*(){try{"email_change"!==e.type&&"phone_change"!==e.type&&(yield this._removeSession());let{data:i,error:s}=yield e8(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:null===(t=e.options)||void 0===t?void 0:t.captchaToken}}),redirectTo:null===(r=e.options)||void 0===r?void 0:r.redirectTo,xform:e9});if(s)throw s;if(!i)throw Error("An error occurred on token verification.");let n=i.session,o=i.user;return(null==n?void 0:n.access_token)&&(yield this._saveSession(n),this._notifyAllSubscribers("SIGNED_IN",n)),{data:{user:o,session:n},error:null}}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}signInWithSSO(e){var t,r,i;return tn(this,void 0,void 0,function*(){try{return yield this._removeSession(),yield e8(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:null!==(r=null===(t=e.options)||void 0===t?void 0:t.redirectTo)&&void 0!==r?r:void 0}),(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0}),headers:this.headers,xform:e6})}catch(e){if(ez(e))return{data:null,error:e};throw e}})}reauthenticate(){return tn(this,void 0,void 0,function*(){try{let{data:{session:e},error:t}
2=yield this.getSession();if(t)throw t;if(!e)throw new eV;let{error:r}=yield e8(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:e.access_token});return{data:{user:null,session:null},error:r}}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}resend(e){return tn(this,void 0,void 0,function*(){try{yield this._removeSession();let t=`${this.url}/resend`;if("email"in e){let{email:r,type:i,options:s}=e,{error:n}=yield e8(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:i,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}}});return{data:{user:null,session:null},error:n}}if("phone"in e){let{phone:r,type:i,options:s}=e,{error:n}=yield e8(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:i,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}}});return{data:{user:null,session:null},error:n}}throw new eX("You must provide either an email or phone number and a type")}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}getSession(){return tn(this,void 0,void 0,function*(){yield this.initializePromise;let e=null;if(this.persistSession){let t=yield eD(this.storage,this.storageKey);null!==t&&(this._isValidSession(t)?e=t:yield this._removeSession())}else e=this.inMemorySession;if(!e)return{data:{session:null},error:null};let t=!!e.expires_at&&e.expires_at<=Date.now()/1e3;if(!t)return{data:{session:e},error:null};let{session:r,error:i}=yield this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:r},error:null}})}getUser(e){var t,r;return tn(this,void 0,void 0,function*(){try{if(!e){let{data:i,error:s}=yield this.getSession();if(s)throw s;e=null!==(r=null===(t=i.session)||void 0===t?void 0:t.access_token)&&void 0!==r?r:void 0}return yield e8(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:e5})}catch(e){if(ez(e))return{data:{user:null},error:e};throw e}})}updateUser(e,t={}){return tn(this,void 0,void 0,function*(){try{let{data:r,error:i}=yield this.getSession();if(i)throw i;if(!r.session)throw new eV;let s=r.session,{data:n,error:o}=yield e8(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:null==t?void 0:t.emailRedirectTo,body:e,jwt:s.access_token,xform:e5});if(o)throw o;return s.user=n.user,yield this._saveSession(s),this._notifyAllSubscribers("USER_UPDATED",s),{data:{user:s.user},error:null}}catch(e){if(ez(e))return{data:{user:null},error:e};throw e}})}_decodeJWT(e){return eB(e)}setSession(e){return tn(this,void 0,void 0,function*(){try{if(!e.access_token||!e.refresh_token)throw new eV;let t=Date.now()/1e3,r=t,i=!0,s=null,n=eB(e.access_token);if(n.exp&&(i=(r=n.exp)<=t),i){let{session:t,error:r}=yield this._callRefreshToken(e.refresh_token);if(r)return{data:{user:null,session:null},error:r};if(!t)return{data:{user:null,session:null},error:null};s=t}else{let{data:i,error:n}=yield this.getUser(e.access_token);if(n)throw n;s={access_token:e.access_token,refresh_token:e.refresh_token,user:i.user,token_type:"bearer",expires_in:r-t,expires_at:r},yield this._saveSession(s),this._notifyAllSubscribers("SIGNED_IN",s)}return{data:{user:s.user,session:s},error:null}}catch(e){if(ez(e))return{data:{session:null,user:null},error:e};throw e}})}refreshSession(e){var t;return tn(this,void 0,void 0,function*(){try{if(!e){let{data:r,error:i}=yield this.getSession();if(i)throw i;e=null!==(t=r.session)&&void 0!==t?t:void 0}if(!(null==e?void 0:e.refresh_token))throw new eV;let{session:r,error:i}=yield this._callRefreshToken(e.refresh_token);if(i)return{data:{user:null,session:null},error:i};if(!r)return{data:{user:null,session:null},error:null};return{data:{user:r.user,session:r},error:null}}catch(e){if(ez(e))return{data:{user:null,session:null},error:e};throw e}})}_getSessionFromUrl(e){return tn(this,void 0,void 0,function*(){try{if(!ex())throw new eY("No browser detected.");if("implicit"!==this.flowType||this._isImplicitGrantFlow()){if("pkce"==this.flowType&&!e)throw new eQ("Not a valid PKCE flow url.")}else throw new eY("Not a valid implicit grant flow url.");if(e){let e=eC("code");if(!e)throw new eQ("No code detected.");let{data:t,error:r}=yield this.exchangeCodeForSession(e);if(r)throw r;if(!t.session)throw new eQ("No session detected.");let i=new URL(window.location.href);return i.searchParams.delete("code"),window.history.replaceState(window.history.state,"",i.toString()),{data:{session:t.session,redirectType:null},error:null}}let t=eC("error_description");if(t){let e=eC("error_code");if(!e)throw new eY("No error_code detected.");let r=eC("error");
2if(!r)throw new eY("No error detected.");throw new eY(t,{error:r,code:e})}let r=eC("provider_token"),i=eC("provider_refresh_token"),s=eC("access_token");if(!s)throw new eY("No access_token detected.");let n=eC("expires_in");if(!n)throw new eY("No expires_in detected.");let o=eC("refresh_token");if(!o)throw new eY("No refresh_token detected.");let a=eC("token_type");if(!a)throw new eY("No token_type detected.");let l=Math.round(Date.now()/1e3),h=l+parseInt(n),{data:c,error:u}=yield this.getUser(s);if(u)throw u;let d=c.user,f={provider_token:r,provider_refresh_token:i,access_token:s,expires_in:parseInt(n),expires_at:h,refresh_token:o,token_type:a,user:d},p=eC("type");return window.location.hash="",{data:{session:f,redirectType:p},error:null}}catch(e){if(ez(e))return{data:{session:null,redirectType:null},error:e};throw e}})}_isImplicitGrantFlow(){return ex()&&(!!eC("access_token")||!!eC("error_description"))}_isPKCEFlow(){return tn(this,void 0,void 0,function*(){let e=yield eD(this.storage,`${this.storageKey}-code-verifier`);return!!eC("code")&&!!e})}signOut(){var e;return tn(this,void 0,void 0,function*(){let{data:t,error:r}=yield this.getSession();if(r)return{error:r};let i=null===(e=t.session)||void 0===e?void 0:e.access_token;if(i){let{error:e}=yield this.admin.signOut(i);if(e&&!(ez(e)&&"AuthApiError"===e.name&&(404===e.status||401===e.status)))return{error:e}}return yield this._removeSession(),yield eN(this.storage,`${this.storageKey}-code-verifier`),this._notifyAllSubscribers("SIGNED_OUT",null),{error:null}})}onAuthStateChange(e){let t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),r={id:t,callback:e,unsubscribe:()=>{this.stateChangeEmitters.delete(t)}};return this.stateChangeEmitters.set(t,r),this.emitInitialSession(t),{data:{subscription:r}}}emitInitialSession(e){var t,r;return tn(this,void 0,void 0,function*(){try{let{data:{session:r},error:i}=yield this.getSession();if(i)throw i;null===(t=this.stateChangeEmitters.get(e))||void 0===t||t.callback("INITIAL_SESSION",r)}catch(t){null===(r=this.stateChangeEmitters.get(e))||void 0===r||r.callback("INITIAL_SESSION",null),console.error(t)}})}resetPasswordForEmail(e,t={}){return tn(this,void 0,void 0,function*(){let r=null,i=null;if("pkce"===this.flowType){let e=eM();yield eU(this.storage,`${this.storageKey}-code-verifier`,e),r=yield eJ(e),i=e===r?"plain":"s256"}try{return yield e8(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:i,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(ez(e))return{data:null,error:e};throw e}})}_refreshAccessToken(e){return tn(this,void 0,void 0,function*(){try{let t=Date.now();return yield function(e,t){let r=new Promise((r,i)=>{eP(this,void 0,void 0,function*(){for(let s=0;s<1/0;s++)try{let i=yield e(s);if(!t(s,null,i)){r(i);return}}catch(e){if(!t(s,e)){i(e);return}}})});return r}(t=>tn(this,void 0,void 0,function*(){var r;return yield(r=200*t,new Promise(e=>{setTimeout(()=>e(null),r)})),yield e8(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:e9})}),(e,r,i)=>i&&i.error&&i.error instanceof eZ&&Date.now()+(e+1)*200-t<3e4)}catch(e){if(ez(e))return{data:{session:null,user:null},error:e};throw e}})}_isValidSession(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}_handleProviderSignIn(e,t){return tn(this,void 0,void 0,function*(){let r=yield this._getUrlForProvider(e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return ex()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}})}_recoverAndRefresh(){var e;return tn(this,void 0,void 0,function*(){try{let t=yield eD(this.storage,this.storageKey);if(!this._isValidSession(t)){null!==t&&(yield this._removeSession());return}let r=Math.round(Date.now()/1e3);if((null!==(e=t.expires_at)&&void 0!==e?e:1/0)<r+10){if(this.autoRefreshToken&&t.refresh_token){let{error:e}=yield this._callRefreshToken(t.refresh_token);e&&(console.log(e.message),yield this._removeSession())}}else this.persistSession&&(yield this._saveSession(t)),this._notifyAllSubscribers("SIGNED_IN",t)}catch(e){console.error(e);return}})}_callRefreshToken(e){var t,r;return tn(this,void 0,void 0,function*(){if(this.refreshingDeferred)return this.refreshingDeferred.promise;try{if(this.refreshingDeferred=new eL,!e)throw new eV;let{data:t,error:r}=yield this._refreshAccessToken(e);if(r)throw r;if(!t.session)throw new eV;yield this._saveSession(t.session),this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let i={session:t.session,error:null};return this.refreshingDeferred.resolve(i),i}catch(e){if(ez(e)){let r={session:null,error:e};return null===(t=this.refreshingDeferred)||void 0===t||t.resolve(r),r}throw null===(r=this.refreshingDeferred)||void 0===r||r.reject(e),e}finally{this.refreshingDeferred=null}})}_notifyAllSubscribers(e,t,r=!0){this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t}
2),this.stateChangeEmitters.forEach(r=>r.callback(e,t))}_saveSession(e){return tn(this,void 0,void 0,function*(){this.persistSession||(this.inMemorySession=e),this.persistSession&&e.expires_at&&(yield this._persistSession(e))})}_persistSession(e){return eU(this.storage,this.storageKey,e)}_removeSession(){return tn(this,void 0,void 0,function*(){this.persistSession?yield eN(this.storage,this.storageKey):this.inMemorySession=null})}_removeVisibilityChangedCallback(){let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ex()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(e){console.error("removing visibilitychange callback failed",e)}}_startAutoRefresh(){return tn(this,void 0,void 0,function*(){yield this._stopAutoRefresh();let e=setInterval(()=>this._autoRefreshTokenTick(),3e4);this.autoRefreshTicker=e,e&&"object"==typeof e&&"function"==typeof e.unref?e.unref():"undefined"!=typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(e),yield this._autoRefreshTokenTick()})}_stopAutoRefresh(){return tn(this,void 0,void 0,function*(){let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)})}startAutoRefresh(){return tn(this,void 0,void 0,function*(){this._removeVisibilityChangedCallback(),yield this._startAutoRefresh()})}stopAutoRefresh(){return tn(this,void 0,void 0,function*(){this._removeVisibilityChangedCallback(),yield this._stopAutoRefresh()})}_autoRefreshTokenTick(){return tn(this,void 0,void 0,function*(){let e=Date.now();try{let{data:{session:t}}=yield this.getSession();if(!t||!t.refresh_token||!t.expires_at)return;let r=Math.floor((1e3*t.expires_at-e)/3e4);r<3&&(yield this._callRefreshToken(t.refresh_token))}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}})}_handleVisibilityChange(){return tn(this,void 0,void 0,function*(){if(!ex()||!(null==window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=()=>tn(this,void 0,void 0,function*(){return yield this._onVisibilityChanged(!1)}),null==window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),yield this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}})}_onVisibilityChanged(e){return tn(this,void 0,void 0,function*(){"visible"===document.visibilityState?(e||(yield this.initializePromise,yield this._recoverAndRefresh()),this.autoRefreshToken&&this._startAutoRefresh()):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()})}_getUrlForProvider(e,t){return tn(this,void 0,void 0,function*(){let r=[`provider=${encodeURIComponent(e)}`];if((null==t?void 0:t.redirectTo)&&r.push(`redirect_to=${encodeURIComponent(t.redirectTo)}`),(null==t?void 0:t.scopes)&&r.push(`scopes=${encodeURIComponent(t.scopes)}`),"pkce"===this.flowType){let e=eM();yield eU(this.storage,`${this.storageKey}-code-verifier`,e);let t=yield eJ(e),i=e===t?"plain":"s256",s=new URLSearchParams({code_challenge:`${encodeURIComponent(t)}`,code_challenge_method:`${encodeURIComponent(i)}`});r.push(s.toString())}if(null==t?void 0:t.queryParams){let e=new URLSearchParams(t.queryParams);r.push(e.toString())}return`${this.url}/authorize?${r.join("&")}`})}_unenroll(e){var t;return tn(this,void 0,void 0,function*(){try{let{data:r,error:i}=yield this.getSession();if(i)return{data:null,error:i};return yield e8(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null===(t=null==r?void 0:r.session)||void 0===t?void 0:t.access_token})}catch(e){if(ez(e))return{data:null,error:e};throw e}})}_enroll(e){var t,r;return tn(this,void 0,void 0,function*(){try{let{data:i,error:s}=yield this.getSession();if(s)return{data:null,error:s};let{data:n,error:o}=yield e8(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:null===(t=null==i?void 0:i.session)||void 0===t?void 0:t.access_token});if(o)return{data:null,error:o};return(null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.qr_code)&&(n.totp.qr_code=`data:image/svg+xml;utf-8,${n.totp.qr_code}`),{data:n,error:null}}catch(e){if(ez(e))return{data:null,error:e};throw e}})}_verify(e){var t;return tn(this,void 0,void 0,function*(){try{let{data:r,error:i}
2=yield this.getSession();if(i)return{data:null,error:i};let{data:s,error:n}=yield e8(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:null===(t=null==r?void 0:r.session)||void 0===t?void 0:t.access_token});if(n)return{data:null,error:n};return yield this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+s.expires_in},s)),this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",s),{data:s,error:n}}catch(e){if(ez(e))return{data:null,error:e};throw e}})}_challenge(e){var t;return tn(this,void 0,void 0,function*(){try{let{data:r,error:i}=yield this.getSession();if(i)return{data:null,error:i};return yield e8(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:null===(t=null==r?void 0:r.session)||void 0===t?void 0:t.access_token})}catch(e){if(ez(e))return{data:null,error:e};throw e}})}_challengeAndVerify(e){return tn(this,void 0,void 0,function*(){let{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 tn(this,void 0,void 0,function*(){let{data:{user:e},error:t}=yield this.getUser();if(t)return{data:null,error:t};let r=(null==e?void 0:e.factors)||[],i=r.filter(e=>"totp"===e.factor_type&&"verified"===e.status);return{data:{all:r,totp:i},error:null}})}_getAuthenticatorAssuranceLevel(){var e,t;return tn(this,void 0,void 0,function*(){let{data:{session:r},error:i}=yield this.getSession();if(i)return{data:null,error:i};if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let s=this._decodeJWT(r.access_token),n=null;s.aal&&(n=s.aal);let o=n,a=null!==(t=null===(e=r.user.factors)||void 0===e?void 0:e.filter(e=>"verified"===e.status))&&void 0!==t?t:[];a.length>0&&(o="aal2");let l=s.amr||[];return{data:{currentLevel:n,nextLevel:o,currentAuthenticationMethods:l},error:null}})}}class tl extends ta{constructor(e){super(e)}}let th={headers:{"X-Client-Info":"supabase-js/2.24.0"}},tc={schema:"public"},tu={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},td={};class tf{constructor(e,t,r){var i,s,n,o,a,l,h,c;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw Error("supabaseUrl is required.");if(!t)throw Error("supabaseKey is required.");let u=e.replace(/\/$/,"");this.realtimeUrl=`${u}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${u}/auth/v1`,this.storageUrl=`${u}/storage/v1`,this.functionsUrl=`${u}/functions/v1`;let d=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,f={db:tc,realtime:td,auth:Object.assign(Object.assign({},tu),{storageKey:d}),global:th},p=function(e,t){let{db:r,auth:i,realtime:s,global:n}=e,{db:o,auth:a,realtime:l,global:h}=t;return{db:Object.assign(Object.assign({},o),r),auth:Object.assign(Object.assign({},a),i),realtime:Object.assign(Object.assign({},l),s),global:Object.assign(Object.assign({},h),n)}}(null!=r?r:{},f);this.storageKey=null!==(s=null===(i=p.auth)||void 0===i?void 0:i.storageKey)&&void 0!==s?s:"",this.headers=null!==(o=null===(n=p.global)||void 0===n?void 0:n.headers)&&void 0!==o?o:{},this.auth=this._initSupabaseAuthClient(null!==(a=p.auth)&&void 0!==a?a:{},this.headers,null===(l=p.global)||void 0===l?void 0:l.fetch),this.fetch=ej(t,this._getAccessToken.bind(this),null===(h=p.global)||void 0===h?void 0:h.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},p.realtime)),this.rest=new U(`${u}/rest/v1`,{headers:this.headers,schema:null===(c=p.db)||void 0===c?void 0:c.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new l(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new eE(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(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,r,i,s,n;return r=this,i=void 0,s=void 0,n=function*(){let{data:r}=yield this.auth.getSession();return null!==(t=null===(e=r.session)||void 0===e?void 0:e.access_token)&&void 0!==t?t:null}
2,new(s||(s=Promise))(function(e,t){function o(e){try{l(n.next(e))}catch(e){t(e)}}function a(e){try{l(n.throw(e))}catch(e){t(e)}}function l(t){var r;t.done?e(t.value):((r=t.value)instanceof s?r:new s(function(e){e(r)})).then(o,a)}l((n=n.apply(r,i||[])).next())})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:i,storageKey:s,flowType:n},o,a){let l={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new tl({url:this.authUrl,headers:Object.assign(Object.assign({},l),o),storageKey:s,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:i,flowType:n,fetch:a})}_initRealtimeClient(e){return new et(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,null==t?void 0:t.access_token,"CLIENT")})}_handleTokenChanged(e,t,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&this.changedAccessToken!==t?(this.realtime.setAuth(null!=t?t:null),this.changedAccessToken=t):"SIGNED_OUT"===e&&(this.realtime.setAuth(this.supabaseKey),"STORAGE"==r&&this.auth.signOut(),this.changedAccessToken=void 0)}}let tp=(e,t,r)=>new tf(e,t,r)},4098:function(e,t){var r="undefined"!=typeof self?self:this,i=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();(function(e){var t={searchParams:"URLSearchParams"in i,iterable:"Symbol"in i&&"iterator"in Symbol,blob:"FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in i,arrayBuffer:"ArrayBuffer"in i};if(t.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],s=ArrayBuffer.isView||function(e){return e&&r.indexOf(Object.prototype.toString.call(e))>-1};function n(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw TypeError("Invalid character in header field name");return e.toLowerCase()}function o(e){return"string"!=typeof e&&(e=String(e)),e}function a(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function l(e){this.map={},e instanceof l?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function u(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function d(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e){if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else{var r;t.arrayBuffer&&t.blob&&(r=e)&&DataView.prototype.isPrototypeOf(r)?(this._bodyArrayBuffer=d(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):t.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||s(e))?this._bodyArrayBuffer=d(e):this._bodyText=e=Object.prototype.toString.call(e)}}else this._bodyText="";!this.headers.get("content-type")&&("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(!this._bodyFormData)return Promise.resolve(new Blob([this._bodyText]));throw Error("could not read FormData body as blob")},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(u)}),this.text=function(){var e,t,r,i=h(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,r=c(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(!this._bodyFormData)return Promise.resolve(this._bodyText);throw Error("could not read FormData body as text")},t.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=n(e),t=o(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[n(e)]},l.prototype.get=function(e){return e=n(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(n(e))},l.prototype.set=function(e,t){this.map[n(e)]=o(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),a(e)},l.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),a(e)},l.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),a(e)},t.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);
2var p=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var r,i,s=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new l(t.headers)),this.method=(i=(r=t.method||this.method||"GET").toUpperCase(),p.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function y(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(s))}}),t}function m(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},f.call(v.prototype),f.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},m.error=function(){var e=new m(null,{status:0,statusText:""});return e.type="error",e};var g=[301,302,303,307,308];m.redirect=function(e,t){if(-1===g.indexOf(t))throw RangeError("Invalid status code");return new m(null,{status:t,headers:{location:e}})},e.DOMException=i.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(r,i){return new Promise(function(s,n){var o=new v(r,i);if(o.signal&&o.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),i=r.shift().trim();if(i){var s=r.join(":").trim();t.append(i,s)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;s(new m(i,r))},a.onerror=function(){n(TypeError("Network request failed"))},a.ontimeout=function(){n(TypeError("Network request failed"))},a.onabort=function(){n(new e.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),o.signal&&(o.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",h)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})}b.polyfill=!0,i.fetch||(i.fetch=b,i.Headers=l,i.Request=v,i.Response=m),e.Headers=l,e.Request=v,e.Response=m,e.fetch=b,Object.defineProperty(e,"__esModule",{value:!0})})({}),i.fetch.ponyfill=!0,delete i.fetch.polyfill,(t=i.fetch).default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,e.exports=t},284:function(e){var t=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw Error("Unable to resolve global `this`")};e.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return t()}try{if(!__global__)return t();return __global__}finally{delete Object.prototype.__global__}}()},5840:function(e,t,r){if("object"==typeof globalThis)i=globalThis;else try{i=r(284)}catch(e){}finally{if(i||"undefined"==typeof window||(i=window),!i)throw Error("Could not determine global this")}var i,s=i.WebSocket||i.MozWebSocket,n=r(9387);function o(e,t){return t?new s(e,t):new s(e)}s&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(o,e,{get:function(){return s[e]}})}),e.exports={w3cwebsocket:s?o:null,version:n}},9387:function(e,t,r){e.exports=r(9794).version},9794:function(e){"use strict";e.exports={version:"1.0.34"}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.