1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[881],{3082:function(e,t,r){"use strict";var s,i=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,l={};((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})})(l,{createBrowserSupabaseClient:()=>createBrowserSupabaseClient,createClientComponentClient:()=>createClientComponentClient,createMiddlewareClient:()=>createMiddlewareClient,createMiddlewareSupabaseClient:()=>createMiddlewareSupabaseClient,createPagesBrowserClient:()=>h,createPagesServerClient:()=>createPagesServerClient,createRouteHandlerClient:()=>createRouteHandlerClient,createServerActionClient:()=>m,createServerComponentClient:()=>createServerComponentClient,createServerSupabaseClient:()=>createServerSupabaseClient}),e.exports=((e,t,r,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of o(t))a.call(e,r)||void 0===r||i(e,r,{get:()=>t[r],enumerable:!(s=n(t,r))||s.enumerable});return e})(i({},"__esModule",{value:!0}),l);var u=r(3850);function createClientComponentClient({supabaseUrl:e="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:t="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:r,cookieOptions:i,isSingleton:n=!0}={}){if(!e||!t)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");let createNewClient=()=>{var s;return(0,u.createSupabaseClient)(e,t,{...r,global:{...null==r?void 0:r.global,headers:{...null==(s=null==r?void 0:r.global)?void 0:s.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new u.BrowserCookieAuthStorageAdapter(i)}})};if(n){let e=s??createNewClient();return"undefined"==typeof window?e:(s||(s=e),s)}return createNewClient()}var h=createClientComponentClient,c=r(3850),d=r(8027),f=class extends c.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e}getCookie(e){var t,r,s;let i=(0,d.splitCookiesString)((null==(r=null==(t=this.context.res)?void 0:t.getHeader("set-cookie"))?void 0:r.toString())??"").map(t=>(0,c.parseCookies)(t)[e]).find(e=>!!e),n=i??(null==(s=this.context.req)?void 0:s.cookies[e]);return n}setCookie(e,t){this._setCookie(e,t)}deleteCookie(e){this._setCookie(e,"",{maxAge:0})}_setCookie(e,t,r){var s;let i=(0,d.splitCookiesString)((null==(s=this.context.res.getHeader("set-cookie"))?void 0:s.toString())??"").filter(t=>!(e in(0,c.parseCookies)(t))),n=(0,c.serializeCookie)(e,t,{...this.cookieOptions,...r,httpOnly:!1});this.context.res.setHeader("set-cookie",[...i,n])}};function createPagesServerClient(e,{supabaseUrl:t="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,c.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new f(e,i)}})}var p=r(3850),g=r(8027),y=class extends p.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e}getCookie(e){var t;let r=(0,g.splitCookiesString)((null==(t=this.context.res.headers.get("set-cookie"))?void 0:t.toString())??"").map(t=>(0,p.parseCookies)(t)[e]).find(e=>!!e);if(r)return r;let s=(0,p.parseCookies)(this.context.req.headers.get("cookie")??"");return s[e]}setCookie(e,t){this._setCookie(e,t)}deleteCookie(e){this._setCookie(e,"",{maxAge:0})}_setCookie(e,t,r){let s=(0,p.serializeCookie)(e,t,{...this.cookieOptions,...r,httpOnly:!1});this.context.res.headers&&this.context.res.headers.append("set-cookie",s)}};function createMiddlewareClient(e,{supabaseUrl:t="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,p.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new y(e,i)}})}var _=r(3850),w=class extends _.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e,this.isServer=!0}getCookie(e){var t;let r=this.context.cookies();return null==(t=r.get(e))?void 0:t.value}setCookie(e,t){}deleteCookie(e){}};function createServerComponentClient(e,{supabaseUrl:t="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,_.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new w(e,i)}})}
1var v=r(3850),b=class extends v.CookieAuthStorageAdapter{constructor(e,t){super(t),this.context=e}getCookie(e){var t;let r=this.context.cookies();return null==(t=r.get(e))?void 0:t.value}setCookie(e,t){let r=this.context.cookies();r.set(e,t,this.cookieOptions)}deleteCookie(e){let t=this.context.cookies();t.set(e,"",{...this.cookieOptions,maxAge:0})}};function createRouteHandlerClient(e,{supabaseUrl:t="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:s,cookieOptions:i}={}){var n;if(!t||!r)throw Error("either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!");return(0,v.createSupabaseClient)(t,r,{...s,global:{...null==s?void 0:s.global,headers:{...null==(n=null==s?void 0:s.global)?void 0:n.headers,"X-Client-Info":"@supabase/[email protected]"}},auth:{storage:new b(e,i)}})}var m=createRouteHandlerClient;function createBrowserSupabaseClient({supabaseUrl:e="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:t="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:r,cookieOptions:s}={}){return console.warn("Please utilize the `createPagesBrowserClient` function instead of the deprecated `createBrowserSupabaseClient` function. Learn more: https://supabase.com/docs/guides/auth/auth-helpers/nextjs-pages"),h({supabaseUrl:e,supabaseKey:t,options:r,cookieOptions:s})}function createServerSupabaseClient(e,{supabaseUrl:t="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:s,cookieOptions:i}={}){return console.warn("Please utilize the `createPagesServerClient` function instead of the deprecated `createServerSupabaseClient` function. Learn more: https://supabase.com/docs/guides/auth/auth-helpers/nextjs-pages"),createPagesServerClient(e,{supabaseUrl:t,supabaseKey:r,options:s,cookieOptions:i})}function createMiddlewareSupabaseClient(e,{supabaseUrl:t="https://plttgbfuusutdteznnww.supabase.co",supabaseKey:r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBsdHRnYmZ1dXN1dGR0ZXpubnd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI3ODUwNDIsImV4cCI6MjA3ODM2MTA0Mn0.IB78qkh2GsQvUQUZfgvdGJpFLwniR5fITD6Ck_UXJbE",options:s,cookieOptions:i}={}){return console.warn("Please utilize the `createMiddlewareClient` function instead of the deprecated `createMiddlewareSupabaseClient` function. Learn more: https://supabase.com/docs/guides/auth/auth-helpers/nextjs#middleware"),createMiddlewareClient(e,{supabaseUrl:t,supabaseKey:r,options:s,cookieOptions:i})}},9430:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(44),i=s.__importDefault(r(6711));let PostgrestBuilder=class PostgrestBuilder{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(r=e.isMaybeSingle)&&void 0!==r&&r,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json");let r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async e=>{var t,r,s,n;let o=null,a=null,l=null,u=e.status,h=e.statusText;if(e.ok){if("HEAD"!==this.method){let r=await e.text();""===r||(a="text/csv"===this.headers.get("Accept")?r:this.headers.get("Accept")&&(null===(t=this.headers.get("Accept"))||void 0===t?void 0:t.includes("application/vnd.pgrst.plan+text"))?r:JSON.parse(r))}let i=null===(r=this.headers.get("Prefer"))||void 0===r?void 0:r.match(/count=(exact|planned|estimated)/),n=null===(s=e.headers.get("content-range"))||void 0===s?void 0:s.split("/");i&&n&&n.length>1&&(l=parseInt(n[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(a)&&(a.length>1?(o={code:"PGRST116",details:`Results contain ${a.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},a=null,l=null,u=406,h="Not Acceptable"):a=1===a.length?a[0]:null)}else{let t=await e.text();try{o=JSON.parse(t),Array.isArray(o)&&404===e.status&&(a=[],o=null,u=200,h="OK")}catch(r){404===e.status&&""===t?(u=204,h="No Content"):o={message:t}}if(o&&this.isMaybeSingle&&(null===(n=null==o?void 0:o.details)||void 0===n?void 0:n.includes("0 rows"))&&(o=null,u=200,h="OK"),o&&this.shouldThrowOnError)throw new i.default(o)}let c={error:o,data:a,count:l,status:u,statusText:h};return c});return this.shouldThrowOnError||(s=s.catch(e=>{var t,r,s;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!==(s=null==e?void 0:e.code)&&void 0!==s?s:""}`},data:null,count:null,status:0,statusText:""}}
1)),s.then(e,t)}returns(){return this}overrideTypes(){return this}};t.default=PostgrestBuilder},8551:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(44),i=s.__importDefault(r(807)),n=s.__importDefault(r(4384));let PostgrestClient=class PostgrestClient{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new i.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new PostgrestClient(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:s=!1,count:i}={}){var o;let a,l;let u=new URL(`${this.url}/rpc/${e}`);r||s?(a=r?"HEAD":"GET",Object.entries(t).filter(([e,t])=>void 0!==t).map(([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}`]).forEach(([e,t])=>{u.searchParams.append(e,t)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new n.default({method:a,url:u,headers:h,schema:this.schemaName,body:l,fetch:null!==(o=this.fetch)&&void 0!==o?o:fetch})}};t.default=PostgrestClient},6711:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let PostgrestError=class PostgrestError extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.co
1de=e.code}};t.default=PostgrestError},4384:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(44),i=s.__importDefault(r(6471)),n=RegExp("[,()]");let PostgrestFilterBuilder=class PostgrestFilterBuilder extends i.default{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=Array.from(new Set(t)).map(e=>"string"==typeof e&&n.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:s}={}){let i="";"plain"===s?i="pl":"phrase"===s?i="ph":"websearch"===s&&(i="w");let n=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${i}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,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};t.default=PostgrestFilterBuilder},807:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(44),i=s.__importDefault(r(4384));let PostgrestQueryBuilder=class PostgrestQueryBuilder{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s}select(e,t){let{head:r=!1,count:s}=null!=t?t:{},n=!1,o=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!n?"":('"'===e&&(n=!n),e)).join("");return this.url.searchParams.set("select",o),s&&this.headers.append("Prefer",`count=${s}`),new i.default({method:r?"HEAD":"GET",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),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 i.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(s=this.fetch)&&void 0!==s?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var o;if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>
1e.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 i.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(o=this.fetch)&&void 0!==o?o:fetch})}update(e,{count:t}={}){var r;return t&&this.headers.append("Prefer",`count=${t}`),new i.default({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})}delete({count:e}={}){var t;return e&&this.headers.append("Prefer",`count=${e}`),new i.default({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch})}};t.default=PostgrestQueryBuilder},6471:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(44),i=s.__importDefault(r(9430));let PostgrestTransformBuilder=class PostgrestTransformBuilder extends i.default{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.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){let n=i?`${i}.order`:"order",o=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${o?`${o},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let i=void 0===s?"offset":`${s}.offset`,n=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(n,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return"GET"===this.method?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:n="text"}={}){var o;let a=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=null!==(o=this.headers.get("Accept"))&&void 0!==o?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${n}; for="${l}"; options=${a};`),this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};t.default=PostgrestTransformBuilder},4830:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;let s=r(44),i=s.__importDefault(r(8551));t.PostgrestClient=i.default;let n=s.__importDefault(r(807));t.PostgrestQueryBuilder=n.default;let o=s.__importDefault(r(4384));t.PostgrestFilterBuilder=o.default;let a=s.__importDefault(r(6471));t.PostgrestTransformBuilder=a.default;let l=s.__importDefault(r(9430));t.PostgrestBuilder=l.default;let u=s.__importDefault(r(6711));t.PostgrestError=u.default,t.default={PostgrestClient:i.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:o.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:l.default,PostgrestError:u.default}},2601:function(e,t,r){"use strict";var s,i;e.exports=(null==(s=r.g.process)?void 0:s.env)&&"object"==typeof(null==(i=r.g.process)?void 0:i.env)?r.g.process:r(8960)},263:function(e){!function(){var t={675:function(e,t){"use strict";t.byteLength=byteLength,t.toByteArray=toByteArray,t.fromByteArray=fromByteArray;for(var r=[],s=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=n.length;o<a;
1++o)r[o]=n[o],s[n.charCodeAt(o)]=o;function getLens(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var s=r===t?0:4-r%4;return[r,s]}function byteLength(e){var t=getLens(e),r=t[0],s=t[1];return(r+s)*3/4-s}function _byteLength(e,t,r){return(t+r)*3/4-r}function toByteArray(e){var t,r,n=getLens(e),o=n[0],a=n[1],l=new i(_byteLength(e,o,a)),u=0,h=a>0?o-4:o;for(r=0;r<h;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],l[u++]=t>>16&255,l[u++]=t>>8&255,l[u++]=255&t;return 2===a&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,l[u++]=255&t),1===a&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t),l}function tripletToBase64(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function encodeChunk(e,t,r){for(var s=[],i=t;i<r;i+=3)s.push(tripletToBase64((e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2])));return s.join("")}function fromByteArray(e){for(var t,s=e.length,i=s%3,n=[],o=0,a=s-i;o<a;o+=16383)n.push(encodeChunk(e,o,o+16383>a?a:o+16383));return 1===i?n.push(r[(t=e[s-1])>>2]+r[t<<4&63]+"=="):2===i&&n.push(r[(t=(e[s-2]<<8)+e[s-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),n.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},72:function(e,t,r){"use strict";/*! 2 * The buffer module from node.js, for the browser. 3 * 4 * @author Feross Aboukhadijeh <https://feross.org> 5 * @license MIT 6 */var s=r(675),i=r(783),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function typedArraySupport(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}function createBuffer(e){if(e>2147483647)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"==typeof e)return fromString(e,t);if(ArrayBuffer.isView(e))return fromArrayLike(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var s=e.valueOf&&e.valueOf();if(null!=s&&s!==e)return Buffer.from(s,t,r);var i=fromObject(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function alloc(e,t,r){return(assertSize(e),e<=0)?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!Buffer.isEncoding(t))throw TypeError("Unknown encoding: "+t);var r=0|byteLength(e,t),s=createBuffer(r),i=s.write(e,t);return i!==r&&(s=s.slice(0,i)),s}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),s=0;s<t;s+=1)r[s]=255&e[s];return r}function fromArrayBuffer(e,t,r){var s;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(s=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Buffer.prototype),s}function fromObject(e){if(Buffer.isBuffer(e)){var t,r=0|checked(e.length),s=createBuffer(r);return 0===s.length||e.copy(s,0,0,r),s}return void 0!==e.length?"number"!=typeof e.length||(t=e.length)!=t?createBuffer(0):fromArrayLike(e):"Buffer"===e.type&&Array.isArray(e.data)?fromArrayLike(e.data):void 0}function checked(e){if(e>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer.alloc(+e)}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(i)return s?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),i=!0}}function slowToString(e,t,r){var s=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(s)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function swap(e,t,r){var s=e[t];e[t]=e[r],e[r]=s}function bidirectionalIndexOf(e,t,r,s,i){var n;if(0===e.length)return -1;if("string"==typeof r?(s=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),(n=r=+r)!=n&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return -1;r=e.length-1}
6else if(r<0){if(!i)return -1;r=0}if("string"==typeof t&&(t=Buffer.from(t,s)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,s,i);if("number"==typeof t)return(t&=255,"function"==typeof Uint8Array.prototype.indexOf)?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,s,i);throw TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,s,i){var n,o=1,a=e.length,l=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return -1;o=2,a/=2,l/=2,r/=2}function read(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var u=-1;for(n=r;n<a;n++)if(read(e,n)===read(t,-1===u?0:n-u)){if(-1===u&&(u=n),n-u+1===l)return u*o}else -1!==u&&(n-=n-u),u=-1}else for(r+l>a&&(r=a-l),n=r;n>=0;n--){for(var h=!0,c=0;c<l;c++)if(read(e,n+c)!==read(t,c)){h=!1;break}if(h)return n}return -1}function hexWrite(e,t,r,s){r=Number(r)||0;var i=e.length-r;s?(s=Number(s))>i&&(s=i):s=i;var n=t.length;s>n/2&&(s=n/2);for(var o=0;o<s;++o){var a=parseInt(t.substr(2*o,2),16);if(a!=a)break;e[r+o]=a}return o}function utf8Write(e,t,r,s){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,s)}function latin1Write(e,t,r,s){return blitBuffer(asciiToBytes(t),e,r,s)}function base64Write(e,t,r,s){return blitBuffer(base64ToBytes(t),e,r,s)}function ucs2Write(e,t,r,s){return blitBuffer(utf16leToBytes(t,e.length-r),e,r,s)}function base64Slice(e,t,r){return 0===t&&r===e.length?s.fromByteArray(e):s.fromByteArray(e.slice(t,r))}function utf8Slice(e,t,r){r=Math.min(e.length,r);for(var s=[],i=t;i<r;){var n,o,a,l,u=e[i],h=null,c=u>239?4:u>223?3:u>191?2:1;if(i+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:(192&(n=e[i+1]))==128&&(l=(31&u)<<6|63&n)>127&&(h=l);break;case 3:n=e[i+1],o=e[i+2],(192&n)==128&&(192&o)==128&&(l=(15&u)<<12|(63&n)<<6|63&o)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:n=e[i+1],o=e[i+2],a=e[i+3],(192&n)==128&&(192&o)==128&&(192&a)==128&&(l=(15&u)<<18|(63&n)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|1023&h),s.push(h),i+=c}return decodeCodePointsArray(s)}function decodeCodePointsArray(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var r="",s=0;s<t;)r+=String.fromCharCode.apply(String,e.slice(s,s+=4096));return r}function asciiSlice(e,t,r){var s="";r=Math.min(e.length,r);for(var i=t;i<r;++i)s+=String.fromCharCode(127&e[i]);return s}function latin1Slice(e,t,r){var s="";r=Math.min(e.length,r);for(var i=t;i<r;++i)s+=String.fromCharCode(e[i]);return s}function hexSlice(e,t,r){var s=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);for(var i="",n=t;n<r;++n)i+=a[e[n]];return i}function utf16leSlice(e,t,r){for(var s=e.slice(t,r),i="",n=0;n<s.length;n+=2)i+=String.fromCharCode(s[n]+256*s[n+1]);return i}function checkOffset(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,s,i,n){if(!Buffer.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<n)throw RangeError('"value" argument is out of bounds');if(r+s>e.length)throw RangeError("Index out of range")}function checkIEEE754(e,t,r,s,i,n){if(r+s>e.length||r<0)throw RangeError("Index out of range")}function writeFloat(e,t,r,s,n){return t=+t,r>>>=0,n||checkIEEE754(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,s,23,4),r+4}function writeDouble(e,t,r,s,n){return t=+t,r>>>=0,n||checkIEEE754(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,s,52,8),r+8}t.Buffer=Buffer,t.SlowBuffer=SlowBuffer,t.INSPECT_MAX_BYTES=50,t.kMaxLength=2147483647,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(e,t,r){return alloc(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function(e,t){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,s=t.length,i=0,n=Math.min(r,s);i<n;++i)if(e[i]!==t[i]){r=e[i],s=t[i];break}return r<s?-1:s<r?1:0},Buffer.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Buffer.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,s=Buffer.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var n=e[r];if(isInstance(n,Uint8Array)&&(n=Buffer.from(n)),!Buffer.isBuffer(n))throw TypeError('"list" argument must be an Array of Buffers');n.copy(s,i),i+=n.length}return s},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)swap(this,t,t+1);return this},Buffer.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)swap(this,t,t+3),swap(this,t+1,t+2);return this},Buffer.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)swap(this,t,t+7),swap(this,t+1,t+6),swap(this,t+2,t+5),swap(this,t+3,t+4);return this},Buffer.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?utf8Slice(this,0,e):slowToString.apply(this,arguments)}
vendor: 9,212 bytes, line 6
6,Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(e){if(!Buffer.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(Buffer.prototype[n]=Buffer.prototype.inspect),Buffer.prototype.compare=function(e,t,r,s,i){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===s&&(s=0),void 0===i&&(i=this.length),t<0||r>e.length||s<0||i>this.length)throw RangeError("out of range index");if(s>=i&&t>=r)return 0;if(s>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,s>>>=0,i>>>=0,this===e)return 0;for(var n=i-s,o=r-t,a=Math.min(n,o),l=this.slice(s,i),u=e.slice(t,r),h=0;h<a;++h)if(l[h]!==u[h]){n=l[h],o=u[h];break}return n<o?-1:o<n?1:0},Buffer.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},Buffer.prototype.indexOf=function(e,t,r){return bidirectionalIndexOf(this,e,t,r,!0)},Buffer.prototype.lastIndexOf=function(e,t,r){return bidirectionalIndexOf(this,e,t,r,!1)},Buffer.prototype.write=function(e,t,r,s){if(void 0===t)s="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)s=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===s&&(s="utf8")):(s=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,n,o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var a=!1;;)switch(s){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return i=t,n=r,blitBuffer(asciiToBytes(e),this,i,n);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(a)throw TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),a=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},Buffer.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var s=this.subarray(e,t);return Object.setPrototypeOf(s,Buffer.prototype),s},Buffer.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var s=this[e],i=1,n=0;++n<t&&(i*=256);)s+=this[e+n]*i;return s},Buffer.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var s=this[e+--t],i=1;t>0&&(i*=256);)s+=this[e+--t]*i;return s},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var s=this[e],i=1,n=0;++n<t&&(i*=256);)s+=this[e+n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var s=t,i=1,n=this[e+--s];s>0&&(i*=256);)n+=this[e+--s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readInt8=function(e,t){return(e>>>=0,t||checkOffset(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),i.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),i.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),i.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),i.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,s){if(e=+e,t>>>=0,r>>>=0,!s){var i=Math.pow(2,8*r)-1;checkInt(this,e,t,r,i,0)}var n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},Buffer.prototype.writeUIntBE=function(e,t,r,s){if(e=+e,t>>>=0,r>>>=0,!s){var i=Math.pow(2,8*r)-1;checkInt(this,e,t,r,i,0)}var n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,s){if(e=+e,t>>>=0,!s){var i=Math.pow(2,8*r-1);checkInt(this,e,t,r,i-1,-i)}var n=0,o=1,a=0;for(this[t]=255&e;++n<r&&(o*=256);)e<0&&0===a&&0!==this[t+n-1]&&(a=1),this[t+n]=(e/o>>0)-a&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,s){if(e=+e,t>>>=0,!s){var i=Math.pow(2,8*r-1);checkInt(this,e,t,r,i-1,-i)}var n=r-1,o=1,a=0;for(this[t+n]=255&e;--n>=0&&(o*=256);)e<0&&0===a&&0!==this[t+n+1]&&(a=1),this[t+n]=(e/o>>0)-a&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,s){if(!Buffer.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<r&&(s=r),s===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(s<0)throw RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-r&&(s=e.length-t+r);var i=s-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,s);else if(this===e&&r<t&&t<s)for(var n=i-1;n>=0;--n)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,s),t);return i},Buffer.prototype.fill=function(e,t,r,s){if("string"==typeof e){if("string"==typeof t?(s=t,t=0,r=this.length):"string"==typeof r&&(s=r,r=this.length),void 0!==s&&"string"!=typeof s)throw TypeError("encoding must be a string");if("string"==typeof s&&!Buffer.isEncoding(s))throw TypeError("Unknown encoding: "+s);if(1===e.length){var i,n=e.charCodeAt(0);("utf8"===s&&n<128||"latin1"===s)&&(e=n)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var o=Buffer.isBuffer(e)?e:Buffer.from(e,s),a=o.length;
6if(0===a)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=o[i%a]}return this};var o=/[^+/0-9A-Za-z-_]/g;function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(o,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function utf8ToBytes(e,t){t=t||1/0;for(var r,s=e.length,i=null,n=[],o=0;o<s;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319||o+1===s){(t-=3)>-1&&n.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&n.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&n.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;n.push(r)}else if(r<2048){if((t-=2)<0)break;n.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;n.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;n.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return n}function asciiToBytes(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function utf16leToBytes(e,t){for(var r,s,i=[],n=0;n<e.length&&!((t-=2)<0);++n)s=(r=e.charCodeAt(n))>>8,i.push(r%256),i.push(s);return i}function base64ToBytes(e){return s.toByteArray(base64clean(e))}function blitBuffer(e,t,r,s){for(var i=0;i<s&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var a=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var s=16*r,i=0;i<16;++i)t[s+i]=e[r]+e[i];return t}()},783:function(e,t){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */t.read=function(e,t,r,s,i){var n,o,a=8*i-s-1,l=(1<<a)-1,u=l>>1,h=-7,c=r?i-1:0,d=r?-1:1,f=e[t+c];for(c+=d,n=f&(1<<-h)-1,f>>=-h,h+=a;h>0;n=256*n+e[t+c],c+=d,h-=8);for(o=n&(1<<-h)-1,n>>=-h,h+=s;h>0;o=256*o+e[t+c],c+=d,h-=8);if(0===n)n=1-u;else{if(n===l)return o?NaN:(f?-1:1)*(1/0);o+=Math.pow(2,s),n-=u}return(f?-1:1)*o*Math.pow(2,n-s)},t.write=function(e,t,r,s,i,n){var o,a,l,u=8*n-i-1,h=(1<<u)-1,c=h>>1,d=23===i?5960464477539062e-23:0,f=s?0:n-1,p=s?1:-1,g=t<0||0===t&&1/t<0?1:0;for(isNaN(t=Math.abs(t))||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+c>=1?t+=d/l:t+=d*Math.pow(2,1-c),t*l>=2&&(o++,l/=2),o+c>=h?(a=0,o=h):o+c>=1?(a=(t*l-1)*Math.pow(2,i),o+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,i),o=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[r+f]=255&o,f+=p,o/=256,u-=8);e[r+f-p]|=128*g}}},r={};function __nccwpck_require__(e){var s=r[e];if(void 0!==s)return s.exports;var i=r[e]={exports:{}},n=!0;try{t[e](i,i.exports,__nccwpck_require__),n=!1}finally{n&&delete r[e]}return i.exports}__nccwpck_require__.ab="//";var s=__nccwpck_require__(72);e.exports=s}()},8960:function(e){!function(){var t={229:function(e){var t,r,s,i=e.exports={};function defaultSetTimout(){throw Error("setTimeout has not been defined")}function defaultClearTimeout(){throw Error("clearTimeout has not been defined")}function runTimeout(e){if(t===setTimeout)return setTimeout(e,0);if((t===defaultSetTimout||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}function runClearTimeout(e){if(r===clearTimeout)return clearTimeout(e);if((r===defaultClearTimeout||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){t=defaultSetTimout}try{r="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){r=defaultClearTimeout}}();var n=[],o=!1,a=-1;function cleanUpNextTick(){o&&s&&(o=!1,s.length?n=s.concat(n):a=-1,n.length&&drainQueue())}function drainQueue(){if(!o){var e=runTimeout(cleanUpNextTick);o=!0;for(var t=n.length;t;){for(s=n,n=[];++a<t;)s&&s[a].run();a=-1,t=n.length}s=null,o=!1,runClearTimeout(e)}}function Item(e,t){this.fun=e,this.array=t}function noop(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];n.push(new Item(e,t)),1!==n.length||o||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=noop,i.addListener=noop,i.once=noop,i.off=noop,i.removeListener=noop,i.removeAllListeners=noop,i.emit=noop,i.prependListener=noop,i.prependOnceListener=noop,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},r={};function __nccwpck_require__(e){var s=r[e];if(void 0!==s)return s.exports;var i=r[e]={exports:{}},n=!0;try{t[e](i,i.exports,__nccwpck_require__),n=!1}finally{n&&delete r[e]}return i.exports}__nccwpck_require__.ab="//";var s=__nccwpck_require__(229);e.exports=s}()},622:function(e,t,r){"use strict";/** 7 * @license React 8 * react-jsx-runtime.production.min.js 9 * 10 * Copyright (c) Meta Platforms, Inc. and affiliates. 11 * 12 * This source code is licensed under the MIT license found in the 13 * LICENSE file in the root directory of this source tree. 14 */var s=r(2265),i=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),o=s.__SECRET_INT
14ERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function q(e,t,r){var s,l={},u=null,h=null;for(s in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(h=t.ref),t)n.call(t,s)&&!a.hasOwnProperty(s)&&(l[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps)void 0===l[s]&&(l[s]=t[s]);return{$$typeof:i,type:e,key:u,ref:h,props:l,_owner:o.current}}t.jsx=q,t.jsxs=q},7437:function(e,t,r){"use strict";e.exports=r(622)},8027:function(e){"use strict";var t={decodeValues:!0,map:!1,silent:!1};function isForbiddenKey(e){return"string"!=typeof e||e in{}}function createNullObj(){return Object.create(null)}function isNonEmptyString(e){return"string"==typeof e&&!!e.trim()}function parseString(e,r){var s=e.split(";").filter(isNonEmptyString),i=parseNameValuePair(s.shift()),n=i.name,o=i.value;if(r=r?Object.assign({},t,r):t,isForbiddenKey(n))return null;try{o=r.decodeValues?decodeURIComponent(o):o}catch(e){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",e)}var a=createNullObj();return a.name=n,a.value=o,s.forEach(function(e){var t=e.split("="),r=t.shift().trimLeft().toLowerCase();if(!isForbiddenKey(r)){var s=t.join("=");if("expires"===r)a.expires=new Date(s);else if("max-age"===r){var i=parseInt(s,10);Number.isNaN(i)||(a.maxAge=i)}else"secure"===r?a.secure=!0:"httponly"===r?a.httpOnly=!0:"samesite"===r?a.sameSite=s:"partitioned"===r?a.partitioned=!0:r&&(a[r]=s)}}),a}function parseNameValuePair(e){var t="",r="",s=e.split("=");return s.length>1?(t=s.shift(),r=s.join("=")):r=e,{name:t,value:r}}function parse(e,r){if(r=r?Object.assign({},t,r):t,!e)return r.map?createNullObj():[];if(e.headers){if("function"==typeof e.headers.getSetCookie)e=e.headers.getSetCookie();else if(e.headers["set-cookie"])e=e.headers["set-cookie"];else{var s=e.headers[Object.keys(e.headers).find(function(e){return"set-cookie"===e.toLowerCase()})];s||!e.headers.cookie||r.silent||console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),e=s}}if(Array.isArray(e)||(e=[e]),!r.map)return e.filter(isNonEmptyString).map(function(e){return parseString(e,r)}).filter(Boolean);var i=createNullObj();return e.filter(isNonEmptyString).reduce(function(e,t){var s=parseString(t,r);
14return s&&!isForbiddenKey(s.name)&&(e[s.name]=s),e},i)}function splitCookiesString(e){if(Array.isArray(e))return e;if("string"!=typeof e)return[];var t,r,s,i,n,o=[],a=0;function skipWhitespace(){for(;a<e.length&&/\s/.test(e.charAt(a));)a+=1;return a<e.length}function notSpecialChar(){return"="!==(r=e.charAt(a))&&";"!==r&&","!==r}for(;a<e.length;){for(t=a,n=!1;skipWhitespace();)if(","===(r=e.charAt(a))){for(s=a,a+=1,skipWhitespace(),i=a;a<e.length&¬SpecialChar();)a+=1;a<e.length&&"="===e.charAt(a)?(n=!0,a=i,o.push(e.substring(t,s)),t=a):a=s+1}else a+=1;(!n||a>=e.length)&&o.push(e.substring(t,e.length))}return o}e.exports=parse,e.exports.parse=parse,e.exports.parseString=parseString,e.exports.splitCookiesString=splitCookiesString},3850:function(e,t,r){"use strict";r.r(t),r.d(t,{BrowserCookieAuthStorageAdapter:function(){return eN},CookieAuthStorageAdapter:function(){return ex},DEFAULT_COOKIE_OPTIONS:function(){return eB},createSupabaseClient:function(){return createSupabaseClient},isBrowser:function(){return dist_isBrowser},parseCookies:function(){return e$},parseSupabaseCookie:function(){return parseSupabaseCookie},serializeCookie:function(){return eL},stringifySupabaseSession:function(){return stringifySupabaseSession}}),new TextEncoder;let s=new TextDecoder,decodeBase64=e=>{let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},base64url_decode=e=>{let t=e;t instanceof Uint8Array&&(t=s.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return decodeBase64(t)}catch(e){throw TypeError("The input to be decoded is not correctly encoded.")}};var i,n,o,a,l,u,h,c,d,f,p,g,y,_,w,v,b,m,E,S,k,A,T,O,C,I,R=r(44);let resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e);let FunctionsError=class FunctionsError extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}};let FunctionsFetchError=class FunctionsFetchError extends FunctionsError{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}};let FunctionsRelayError=class FunctionsRelayError extends FunctionsError{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}};let FunctionsHttpError=class FunctionsHttpError extends FunctionsError{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}};(i=_||(_={})).Any="any",i.ApNortheast1="ap-northeast-1",i.ApNortheast2="ap-northeast-2",i.ApSouth1="ap-south-1",i.ApSoutheast1="ap-southeast-1",i.ApSoutheast2="ap-southeast-2",i.CaCentral1="ca-central-1",i.EuCentral1="eu-central-1",i.EuWest1="eu-west-1",i.EuWest2="eu-west-2",i.EuWest3="eu-west-3",i.SaEast1="sa-east-1",i.UsEast1="us-east-1",i.UsWest1="us-west-1",i.UsWest2="us-west-2";let FunctionsClient=class FunctionsClient{constructor(e,{headers:t={},customFetch:r,region:s=_.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=resolveFetch(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return(0,R.__awaiter)(this,arguments,void 0,function*(e,t={}){var r;let s,i;try{let n;let{headers:o,method:a,body:l,signal:u,timeout:h}=t,c={},{region:d}=t;d||(d=this.region);let f=new URL(`${this.url}/${e}`);d&&"any"!==d&&(c["x-region"]=d,f.searchParams.set("forceFunctionRegion",d)),l&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?"undefined"!=typeof Blob&&l instanceof Blob||l instanceof ArrayBuffer?(c["Content-Type"]="application/octet-stream",n=l):"string"==typeof l?(c["Content-Type"]="text/plain",n=l):"undefined"!=typeof FormData&&l instanceof FormData?n=l:(c["Content-Type"]="application/json",n=JSON.stringify(l)):n=l;let p=u;h&&(i=new AbortController,s=setTimeout(()=>i.abort(),h),u?(p=i.signal,u.addEventListener("abort",()=>i.abort())):p=i.signal);let g=yield this.fetch(f.toString(),{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},c),this.headers),o),body:n,signal:p}).catch(e=>{throw new FunctionsFetchError(e)}),y=g.headers.get("x-relay-error");if(y&&"true"===y)throw new FunctionsRelayError(g);if(!g.ok)throw new FunctionsHttpError(g);let _=(null!==(r=g.headers.get("Content-Type"))&&void 0!==r?r:"text/plain").split(";")[0].trim();return{data:"application/json"===_?yield g.json():"application/octet-stream"
14===_||"application/pdf"===_?yield g.blob():"text/event-stream"===_?g:"multipart/form-data"===_?yield g.formData():yield g.text(),error:null,response:g}}catch(e){return{data:null,error:e,response:e instanceof FunctionsHttpError||e instanceof FunctionsRelayError?e.context:void 0}}finally{s&&clearTimeout(s)}})}};var j=r(4830),P=r.t(j,2);let{PostgrestClient:B,PostgrestQueryBuilder:U,PostgrestFilterBuilder:x,PostgrestTransformBuilder:N,PostgrestBuilder:$,PostgrestError:L}=j||P;var D=r(2601);let WebSocketFactory=class WebSocketFactory{static detectEnvironment(){var e;if("undefined"!=typeof WebSocket)return{type:"native",constructor:WebSocket};if("undefined"!=typeof globalThis&&void 0!==globalThis.WebSocket)return{type:"native",constructor:globalThis.WebSocket};if(void 0!==r.g&&void 0!==r.g.WebSocket)return{type:"native",constructor:r.g.WebSocket};if("undefined"!=typeof globalThis&&void 0!==globalThis.WebSocketPair&&void 0===globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("undefined"!=typeof globalThis&&globalThis.EdgeRuntime||"undefined"!=typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(void 0!==D){let e=D.versions;if(e&&e.node){let t=e.node,r=parseInt(t.replace(/^v/,"").split(".")[0]);return r>=22?void 0!==globalThis.WebSocket?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${r} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${r} detected without native WebSocket support.`,workaround:'For Node.js < 22, install "ws" package and provide it via the transport option:\nimport ws from "ws"\nnew RealtimeClient(url, { transport: ws })'}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){let e=this.detectEnvironment();if(e.constructor)return e.constructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+=` 15 16Suggested solution: ${e.workaround}`),Error(t)}static createWebSocket(e,t){let r=this.getWebSocketConstructor();return new r(e,t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type||"ws"===e.type}catch(e){return!1}}};let M="1.0.0";(n=w||(w={}))[n.connecting=0]="connecting",n[n.open=1]="open",n[n.closing=2]="closing",n[n.closed=3]="closed",(o=v||(v={})).closed="closed",o.errored="errored",o.joined="joined",o.joining="joining",o.leaving="leaving",(a=b||(b={})).close="phx_close",a.error="phx_error",a.join="phx_join",a.reply="phx_reply",a.leave="phx_leave",a.access_token="access_token",(m||(m={})).websocket="websocket",(l=E||(E={})).Connecting="connecting",l.Open="open",l.Closing="closing",l.Closed="closed";let Serializer=class Serializer{constructor(){this.HEADER_LENGTH=1,this.META_LENGTH=4,this.USER_BROADCAST_PUSH_META_LENGTH=5,this.KINDS={push:0,reply:1,broadcast:2,userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST="broadcast"}encode(e,t){return this._isArrayBuffer(e.payload)?t(this._binaryEncodePush(e)):e.event!==this.BROADCAST||e.payload instanceof ArrayBuffer||"string"!=typeof e.payload.event?t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload])):t(this._binaryEncodeUserBroadcastPush(e))}_binaryEncodePush(e){let{join_ref:t,ref:r,event:s,topic:i,payload:n}=e,o=this.META_LENGTH+t.length+r.length+i.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),u=0;l.setUint8(u++,this.KINDS.push),l.setUint8(u++,t.length),l.setUint8(u++,r.length),l.setUint8(u++,i.length),l.setUint8(u++,s.length),Array.from(t,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(r,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(i,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(s,e=>l.setUint8(u++,e.charCodeAt(0)));var h=new Uint8Array(a.byteLength+n.byteLength);return h.set(new Uint8Array(a),0),h.set(new Uint8Array(n),a.byteLength),h.buffer}_binaryEncodeUserBroadcastPush(e){var t;return this._isArrayBuffer(null===(t=e.payload)||void 0===t?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){let{join_ref:t,ref:r,topic:s}=e,i=e.payload.event,n=null!==(c=null===(h=e.payload)||void 0===h?void 0:h.payload)&&void 0!==c?c:new ArrayBuffer(0),o=this.USER_BROADCAST_PUSH_META_LENGTH+t.length+r.length+s.length+i.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),u=0;l.setUint8(u++,this.KINDS.userBroadcastPush),l.setUint8(u++,t.length),l.setUint8(u++,r.length),l.setUint8(u++,s.length),l.setUint8(u++,i.length),l.setUint8(u++,this.BINARY_ENCODING),Array.from(t,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(r,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(s,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(i,e=>l.setUint8(u++,e.charCodeAt(0)));var h,c,d=new Uint8Array(a.byteLength+n.byteLength);return d.set(new Uint8Array(a),0),d.set(new Uint8Array(n),a.byteLength),d.buffer}_encodeJsonUserBroadcastPush(e){let{join_ref:t,ref:r,topic:s}=e,i=e.payload.event,n=null!==(f=null===(d=e.payload)||void 0===d?void 0:d.payload)&&void 0!==f?f:{},o=new TextEncoder,a=o.encode(JSON.stringify(n)).buffer,l=this.USER_BROADCAST_PUSH_META_LENGTH+t.length+r.length+s.length+i.length,u=new ArrayBuffer(this.HEADER_LENGTH+l),h=new DataView(u),c=0;h.setUint8(c++,this.KINDS.userBroadcastPush),h.setUint8(c++,t.length),h.setUint8(c++,r.length),h.setUint8(c++,s.length),h.setUint8(c++,i.length),h.setUint8(c++,this.JSON_ENCODING),Array.from(t,e=>h.setUint8(c++,e.charCodeAt(0))),Array.from(r,e=>h.setUint8(c++,e.charCodeAt(0))),Array.from(s,e=>h.setUint8(c++,e.charCodeAt(0))),Array.from(i,e=>h.setUint8(c++,e.charCodeAt(0)));var d,f,p=new Uint8Array(u.byteLength+a.byteLength);return p.set(new Uint8Array(u),0),p.set(new Uint8Array(a),u.byteLength),p.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let r=JSON.parse(e),[s,i,n,o,a]=r;return t({join_ref:s,ref:i,topic:n,event:o,payload:a})}return t({})}_binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.push:return this._decodePush(e,t,s);case this.KINDS.reply:return this._decodeReply(e,t,s);
16case this.KINDS.broadcast:return this._decodeBroadcast(e,t,s);case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,t,s)}}_decodePush(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=r.decode(e.slice(o,o+s));o+=s;let l=r.decode(e.slice(o,o+i));o+=i;let u=r.decode(e.slice(o,o+n));o+=n;let h=JSON.parse(r.decode(e.slice(o,e.byteLength)));return{join_ref:a,ref:null,topic:l,event:u,payload:h}}_decodeReply(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=t.getUint8(3),o=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(e.slice(a,a+s));a+=s;let u=r.decode(e.slice(a,a+i));a+=i;let h=r.decode(e.slice(a,a+n));a+=n;let c=r.decode(e.slice(a,a+o));a+=o;let d=JSON.parse(r.decode(e.slice(a,e.byteLength)));return{join_ref:l,ref:u,topic:h,event:b.reply,payload:{status:c,response:d}}}_decodeBroadcast(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=this.HEADER_LENGTH+2,o=r.decode(e.slice(n,n+s));n+=s;let a=r.decode(e.slice(n,n+i));n+=i;let l=JSON.parse(r.decode(e.slice(n,e.byteLength)));return{join_ref:null,ref:null,topic:o,event:a,payload:l}}_decodeUserBroadcast(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=t.getUint8(3),o=t.getUint8(4),a=this.HEADER_LENGTH+4,l=r.decode(e.slice(a,a+s));a+=s;let u=r.decode(e.slice(a,a+i));a+=i;let h=r.decode(e.slice(a,a+n));a+=n;let c=e.slice(a,e.byteLength),d=o===this.JSON_ENCODING?JSON.parse(r.decode(c)):c,f={type:this.BROADCAST,event:u,payload:d};return n>0&&(f.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST,payload:f}}_isArrayBuffer(e){var t;return e instanceof ArrayBuffer||(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)==="ArrayBuffer"}};let Timer=class Timer{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),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}};(u=S||(S={})).abstime="abstime",u.bool="bool",u.date="date",u.daterange="daterange",u.float4="float4",u.float8="float8",u.int2="int2",u.int4="int4",u.int4range="int4range",u.int8="int8",u.int8range="int8range",u.json="json",u.jsonb="jsonb",u.money="money",u.numeric="numeric",u.oid="oid",u.reltime="reltime",u.text="text",u.time="time",u.timestamp="timestamp",u.timestamptz="timestamptz",u.timetz="timetz",u.tsrange="tsrange",u.tstzrange="tstzrange";let convertChangeData=(e,t,r={})=>{var s;let i=null!==(s=r.skipTypes)&&void 0!==s?s:[];return t?Object.keys(t).reduce((r,s)=>(r[s]=convertColumn(s,e,t,i),r),{}):{}},convertColumn=(e,t,r,s)=>{let i=t.find(t=>t.name===e),n=null==i?void 0:i.type,o=r[e];return n&&!s.includes(n)?convertCell(n,o):noop(o)},convertCell=(e,t)=>{if("_"===e.charAt(0)){let r=e.slice(1,e.length);return toArray(t,r)}switch(e){case S.bool:return toBoolean(t);case S.float4:case S.float8:case S.int2:case S.int4:case S.int8:case S.numeric:case S.oid:return toNumber(t);case S.json:case S.jsonb:return toJson(t);case S.timestamp:return toTimestampString(t);case S.abstime:case S.date:case S.daterange:case S.int4range:case S.int8range:case S.money:case S.reltime:case S.text:case S.time:case S.timestamptz:case S.timetz:case S.tsrange:case S.tstzrange:default:return noop(t)}},noop=e=>e,toBoolean=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},toNumber=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},toJson=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){console.log(`JSON parse error: ${e}`)}return e},toArray=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,s=e[r],i=e[0];if("{"===i&&"}"===s){let s;let i=e.slice(1,r);try{s=JSON.parse("["+i+"]")}catch(e){s=i?i.split(","):[]}return s.map(e=>convertCell(t,e))}return e},toTimestampString=e=>"string"==typeof e?e.replace(" ","T"):e,httpEndpointURL=e=>{let t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),""===t.pathname||"/"===t.pathname?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};let Push=class Push{constructor(e,t,r={},s=1e4){this.channel=e,this.event=t,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHo
16oks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t(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}};(h=k||(k={})).SYNC="sync",h.JOIN="join",h.LEAVE="leave";let RealtimePresence=class RealtimePresence{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,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:s}=this.caller;this.joinRef=this.channel._joinRef(),this.state=RealtimePresence.syncState(this.state,e,t,r),this.pendingDiffs.forEach(e=>{this.state=RealtimePresence.syncDiff(this.state,e,t,r)}),this.pendingDiffs=[],s()}),this.channel._on(r.diff,{},e=>{let{onJoin:t,onLeave:r,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=RealtimePresence.syncDiff(this.state,e,t,r),s())}),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,s){let i=this.cloneDeep(e),n=this.transformState(t),o={},a={};return this.map(i,(e,t)=>{n[e]||(a[e]=t)}),this.map(n,(e,t)=>{let r=i[e];if(r){let s=t.map(e=>e.presence_ref),i=r.map(e=>e.presence_ref),n=t.filter(e=>0>i.indexOf(e.presence_ref)),l=r.filter(e=>0>s.indexOf(e.presence_ref));n.length>0&&(o[e]=n),l.length>0&&(a[e]=l)}else o[e]=t}),this.syncDiff(i,{joins:o,leaves:a},r,s)}static syncDiff(e,t,r,s){let{joins:i,leaves:n}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(t,s)=>{var i;let n=null!==(i=e[t])&&void 0!==i?i:[];if(e[t]=this.cloneDeep(s),n.length>0){let r=e[t].map(e=>e.presence_ref),s=n.filter(e=>0>r.indexOf(e.presence_ref));e[t].unshift(...s)}r(t,n,s)}),this.map(n,(t,r)=>{let i=e[t];if(!i)return;let n=r.map(e=>e.presence_ref);i=i.filter(e=>0>n.indexOf(e.presence_ref)),e[t]=i,s(t,i,r),0===i.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 s=e[r];return"metas"in s?t[r]=s.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e)):t[r]=s,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()}};(c=A||(A={})).ALL="*",c.INSERT="INSERT",c.UPDATE="UPDATE",c.DELETE="DELETE",(d=T||(T={})).BROADCAST="broadcast",d.PRESENCE="presence",d.POSTGRES_CHANGES="postgres_changes",d.SYSTEM="system",(f=O||(O={})).SUBSCRIBED="SUBSCRIBED",f.TIMED_OUT="TIMED_OUT",f.CLOSED="CLOSED",f.CHANNEL_ERROR="CHANNEL_ERROR";let RealtimeChannel=class RealtimeChannel{constructor(e,t={config:{}},r){var s,i;if(this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=v.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new Push(this,b.join,this.params,this.timeout),this.rejoinTimer=new Timer(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=v.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e
16=>e.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=v.closed,this.socket._remove(this)}),this._onError(e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=v.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=v.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=v.errored,this.rejoinTimer.scheduleTimeout())}),this._on(b.reply,{},(e,t)=>{this._trigger(this._replyEventName(t),e)}),this.presence=new RealtimePresence(this),this.broadcastEndpointURL=httpEndpointURL(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(null===(i=null===(s=this.params.config)||void 0===s?void 0:s.broadcast)||void 0===i?void 0:i.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,t=this.timeout){var r,s,i;if(this.socket.isConnected()||this.socket.connect(),this.state==v.closed){let{config:{broadcast:n,presence:o,private:a}}=this.params,l=null!==(s=null===(r=this.bindings.postgres_changes)||void 0===r?void 0:r.map(e=>e.filter))&&void 0!==s?s:[],u=!!this.bindings[T.PRESENCE]&&this.bindings[T.PRESENCE].length>0||(null===(i=this.params.config.presence)||void 0===i?void 0:i.enabled)===!0,h={},c={broadcast:n,presence:Object.assign(Object.assign({},o),{enabled:u}),postgres_changes:l,private:a};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(t=>null==e?void 0:e(O.CHANNEL_ERROR,t)),this._onClose(()=>null==e?void 0:e(O.CLOSED)),this.updateJoinPayload(Object.assign({config:c},h)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:t})=>{var r;if(this.socket.setAuth(),void 0===t){null==e||e(O.SUBSCRIBED);return}{let s=this.bindings.postgres_changes,i=null!==(r=null==s?void 0:s.length)&&void 0!==r?r:0,n=[];for(let r=0;r<i;r++){let i=s[r],{filter:{event:o,schema:a,table:l,filter:u}}=i,h=t&&t[r];if(h&&h.event===o&&h.schema===a&&h.table===l&&h.filter===u)n.push(Object.assign(Object.assign({},i),{id:h.id}));else{this.unsubscribe(),this.state=v.errored,null==e||e(O.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=n,e&&e(O.SUBSCRIBED);return}}).receive("error",t=>{this.state=v.errored,null==e||e(O.CHANNEL_ERROR,Error(JSON.stringify(Object.values(t).join(", ")||"error")))}).receive("timeout",()=>{null==e||e(O.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){return this.state===v.joined&&e===T.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(e,t,r)}async httpSend(e,t,r={}){var s;let i=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(null==t)return Promise.reject("Payload is required for httpSend()");let n={method:"POST",headers:{Authorization:i,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:t,private:this.private}]})},o=await this._fetchWithTimeout(this.broadcastEndpointURL,n,null!==(s=r.timeout)&&void 0!==s?s:this.timeout);if(202===o.status)return{success:!0};let a=o.statusText;try{let e=await o.json();a=e.error||e.message||a}catch(e){}return Promise.reject(Error(a))}async send(e,t={}){var r,s;if(this._canPush()||"broadcast"!==e.type)return new Promise(r=>{var s,i,n;let o=this._push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null===(n=null===(i=null===(s=this.params)||void 0===s?void 0:s.config)||void 0===i?void 0:i.broadcast)||void 0===n?void 0:n.ack)||r("ok"),o.receive("ok",()=>r("ok")),o.receive("error",()=>r("error")),o.receive("timeout",()=>r("timed out"))});{console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated
16in the future. Please use httpSend() explicitly for REST delivery.");let{event:i,payload:n}=e,o=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",a={method:"POST",headers:{Authorization:o,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:n,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,a,null!==(r=t.timeout)&&void 0!==r?r:this.timeout);return await (null===(s=e.body)||void 0===s?void 0:s.cancel()),e.ok?"ok":"error"}catch(e){if("AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=v.leaving;let onClose=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(b.close,"leave",this._joinRef())};this.joinPush.destroy();let t=null;return new Promise(r=>{(t=new Push(this,b.leave,{},e)).receive("ok",()=>{onClose(),r("ok")}).receive("timeout",()=>{onClose(),r("timed out")}).receive("error",()=>{r("error")}),t.send(),this._canPush()||t.trigger("ok",{})}).finally(()=>{null==t||t.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=v.closed,this.bindings={}}async _fetchWithTimeout(e,t,r){let s=new AbortController,i=setTimeout(()=>s.abort(),r),n=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(i),n}_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 s=new Push(this,e,t,r);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>100){let e=this.pushBuffer.shift();e&&(e.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${e.event}`,e.payload))}}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var s,i;let n=e.toLocaleLowerCase(),{close:o,error:a,leave:l,join:u}=b;if(r&&[o,a,l,u].indexOf(n)>=0&&r!==this._joinRef())return;let h=this._onMessage(n,t,r);if(t&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(n)?null===(s=this.bindings.postgres_changes)||void 0===s||s.filter(e=>{var t,r,s;return(null===(t=e.filter)||void 0===t?void 0:t.event)==="*"||(null===(s=null===(r=e.filter)||void 0===r?void 0:r.event)||void 0===s?void 0:s.toLocaleLowerCase())===n}).map(e=>e.callback(h,r)):null===(i=this.bindings[n])||void 0===i||i.filter(e=>{var r,s,i,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===(s=t.ids)||void 0===s?void 0:s.includes(n))&&("*"===o||(null==o?void 0:o.toLocaleLowerCase())===(null===(i=t.data)||void 0===i?void 0:i.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 h&&"ids"in h){let e=h.data,{schema:t,table:r,commit_timestamp:s,type:i,errors:n}=e;h=Object.assign(Object.assign({},{schema:t,table:r,commit_timestamp:s,eventType:i,new:{},old:{},errors:n}),this._getPayloadRecords(e))}e.callback(h,r)})}_isClosed(){return this.state===v.closed}_isJoined(){return this.state===v.joined}_isJoining(){return this.state===v.joining}_isLeaving(){return this.state===v.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){let s=e.toLocaleLowerCase(),i={type:s,filter:t,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,t){let r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(e=>{var s;return!((null===(s=e.type)||void 0===s?void 0:s.toLocaleLowerCase())===r&&RealtimeChannel.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(b.close,{},e)}_onError(e){this._on(b.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=v.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=convertChangeData(e.columns,e.record)),("UPDATE"===e.type||"DELET
16E"===e.type)&&(t.old=convertChangeData(e.columns,e.old_record)),t}};let RealtimeClient_noop=()=>{},F={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},J=[1e3,2e3,5e3,1e4],W=` 17 addEventListener("message", (e) => { 18 if (e.data.event === "start") { 19 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 20 } 21 });`;let RealtimeClient=class RealtimeClient{constructor(e,t){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=1e4,this.transport=null,this.heartbeatIntervalMs=F.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=RealtimeClient_noop,this.ref=0,this.reconnectTimer=null,this.vsn=M,this.logger=RealtimeClient_noop,this.conn=null,this.sendBuffer=[],this.serializer=new Serializer,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),!(null===(r=null==t?void 0:t.params)||void 0===r?void 0:r.apikey))throw Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey,this.endPoint=`${e}/${m.websocket}`,this.httpEndpoint=httpEndpointURL(e),this._initializeOptions(t),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||null!==this.conn&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=WebSocketFactory.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");let e=t.message;if(e.includes("Node.js"))throw Error(`${e} 22 23To use Realtime in Node.js, you need to provide a WebSocket implementation: 24 25Option 1: Use Node.js 22+ which has native WebSocket support 26Option 2: Install and provide the "ws" package: 27 28 npm install ws 29 30 import ws from "ws" 31 const client = new RealtimeClient(url, { 32 ...options, 33 transport: ws 34 })`);throw Error(`WebSocket not available: ${e}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,t){if(!this.isDisconnecting()){if(this._setConnectionState("disconnecting",!0),this.conn){let r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},"function"==typeof this.conn.close&&(e?this.conn.close(e,null!=t?t:""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return 0===this.channels.length&&this.disconnect(),t}async removeAllChannels(){let e=await Promise.all(this.channels.map(e=>e.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case w.connecting:return E.Connecting;case w.open:return E.Open;case w.closing:return E.Closing;default:return E.Closed}}isConnected(){return this.connectionState()===E.Open}isConnecting(){return"connecting"===this._connectionState}isDisconnecting(){return"disconnecting"===this._connectionState}channel(e,t={config:{}}){let r=`realtime:${e}`,s=this.getChannels().find(e=>e.topic===r);if(s)return s;{let r=new RealtimeChannel(`realtime:${e}`,t,this);return this.channels.push(r),r}}push(e){let{topic:t,event:r,payload:s,ref:i}=e,callback=()=>{this.encode(e,e=>{var t;null===(t=this.conn)||void 0===t||t.send(e)})};this.log("push",`${t} ${r} (${i})`,s),this.isConnected()?callback():this.sendBuffer.push(callback)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this._wasManualDisconnect=!1,null===(e=this.conn)||void 0===e||e.close(1e3,"heartbeat timeout"),setTimeout(()=>{var e;this.isConnected()||null===(e=this.reconnectTimer)||void 0===e||e.scheduleTimeout()},F.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>
340&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let 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.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,e=>{if("phoenix"===e.topic&&"phx_reply"===e.event)try{this.heartbeatCallback("ok"===e.payload.status?"ok":"error")}catch(e){this.log("error","error in heartbeat callback",e)}e.ref&&e.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);let{topic:t,event:r,payload:s,ref:i}=e,n=i?`(${i})`:"",o=s.status||"";this.log("receive",`${o} ${t} ${r} ${n}`.trim(),s),this.channels.filter(e=>e._isMember(t)).forEach(e=>e._trigger(r,s,i)),this._triggerStateCallbacks("message",e)})}_clearTimer(e){var t;"heartbeat"===e&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):"reconnect"===e&&(null===(t=this.reconnectTimer)||void 0===t||t.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_teardownConnection(){if(this.conn){if(this.conn.readyState===w.open||this.conn.readyState===w.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`);let e=this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve());e.then(()=>{this.flushSendBuffer()}).catch(e=>{this.log("error","error waiting for auth on connect",e),this.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this.workerRef.terminate()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var t;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||null===(t=this.reconnectTimer)||void 0===t||t.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(b.error))}_appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${r}${s}`}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob([W],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_setConnectionState(e,t=!1){this._connectionState=e,"connecting"===e?this._wasManualDisconnect=!1:"disconnecting"===e&&(this._wasManualDisconnect=t)}async _performAuth(e=null){let t;t=e||(this.accessToken?await this.accessToken():this.accessTokenValue),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(e=>{t&&e.updateJoinPayload({access_token:t,version:"realtime-js/2.81.1"}),e.joinedOnce&&e._isJoined()&&e._push(b.access_token,{access_token:t})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(t=>{this.log("error",`error setting auth in ${e}`,t)})}_triggerStateCallbacks(e,t){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}_setupReconnectionTimer(){this.reconnectTimer=new Timer(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},F.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var t,r,s,i,n,o,a,l,u,h,c,d;switch(this.transport=null!==(t=null==e?void 0:e.transport)&&void 0!==t?t:null,this.timeout=null!==(r=null==e?void 0:e.timeout)&&void 0!==r?r:1e4,this.heartbeatIntervalMs=null!==(s=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==s?s:F.HEARTBEAT_INTERVAL,this.worker=null!==(i=null==e?void 0:e.worker)&&void 0!==i&&i,this.accessToken=null!==(n=null==e?void 0:e.accessToken)&&void 0!==n?n:null,this.heartbeatCallback=null!==(o=null==e?void 0:e.heartbeatCallback)&&void 0!==o?o:RealtimeClient_noop,this.vsn=null!==(a=null==e?void 0:e.vsn)&&void 0!==a?a:M,(null==e?void 0:e.params)&&(this.params=e.params),(null==e?void 0:e.logger)&&(this.logger=e.logger),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=null!==(l=null==e?void 0:e.reconnectAfterMs)&&void 0!==l?l:e=>J[e-1]||1e4,this.vsn){case M:this.encode=null!==(u=null==e?void 0:e.encode)&&void 0!==u?u:(e,t)=>
34t(JSON.stringify(e)),this.decode=null!==(h=null==e?void 0:e.decode)&&void 0!==h?h:(e,t)=>t(JSON.parse(e));break;case"2.0.0":this.encode=null!==(c=null==e?void 0:e.encode)&&void 0!==c?c:this.serializer.encode.bind(this.serializer),this.decode=null!==(d=null==e?void 0:e.decode)&&void 0!==d?d:this.serializer.decode.bind(this.serializer);break;default:throw Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if("undefined"!=typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl}}};let StorageError=class StorageError extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}};function isStorageError(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}let StorageApiError=class StorageApiError extends StorageError{constructor(e,t,r){super(e),this.name="StorageApiError",this.status=t,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};let StorageUnknownError=class StorageUnknownError extends StorageError{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}};let helpers_resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),resolveResponse=()=>Response,recursiveToCamel=e=>{if(Array.isArray(e))return e.map(e=>recursiveToCamel(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,r])=>{let s=e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""));t[s]=recursiveToCamel(r)}),t},isPlainObject=e=>{if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},_getErrorMessage=e=>{var t;return e.msg||e.message||e.error_description||("string"==typeof e.error?e.error:null===(t=e.error)||void 0===t?void 0:t.message)||JSON.stringify(e)},handleError=(e,t,r)=>(0,R.__awaiter)(void 0,void 0,void 0,function*(){let s=yield resolveResponse();e instanceof s&&!(null==r?void 0:r.noResolveJson)?e.json().then(r=>{let s=e.status||500,i=(null==r?void 0:r.statusCode)||s+"";t(new StorageApiError(_getErrorMessage(r),s,i))}).catch(e=>{t(new StorageUnknownError(_getErrorMessage(e),e))}):t(new StorageUnknownError(_getErrorMessage(e),e))}
34),_getRequestParams=(e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"!==e&&s?(isPlainObject(s)?(i.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),i.body=JSON.stringify(s)):i.body=s,(null==t?void 0:t.duplex)&&(i.duplex=t.duplex),Object.assign(Object.assign({},i),r)):i};function _handleRequest(e,t,r,s,i,n){return(0,R.__awaiter)(this,void 0,void 0,function*(){return new Promise((o,a)=>{e(r,_getRequestParams(t,s,i,n)).then(e=>{if(!e.ok)throw e;return(null==s?void 0:s.noResolveJson)?e:e.json()}).then(e=>o(e)).catch(e=>handleError(e,a,s))})})}function get(e,t,r,s){return(0,R.__awaiter)(this,void 0,void 0,function*(){return _handleRequest(e,"GET",t,r,s)})}function post(e,t,r,s,i){return(0,R.__awaiter)(this,void 0,void 0,function*(){return _handleRequest(e,"POST",t,s,i,r)})}function put(e,t,r,s,i){return(0,R.__awaiter)(this,void 0,void 0,function*(){return _handleRequest(e,"PUT",t,s,i,r)})}function head(e,t,r,s){return(0,R.__awaiter)(this,void 0,void 0,function*(){return _handleRequest(e,"HEAD",t,Object.assign(Object.assign({},r),{noResolveJson:!0}),s)})}function remove(e,t,r,s,i){return(0,R.__awaiter)(this,void 0,void 0,function*(){return _handleRequest(e,"DELETE",t,s,i,r)})}let StreamDownloadBuilder=class StreamDownloadBuilder{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}execute(){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let e=yield this.downloadFn();return{data:e.body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}};let BlobDownloadBuilder=class BlobDownloadBuilder{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[C]="BlobDownloadBuilder",this.promise=null}asStream(){return new StreamDownloadBuilder(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let e=yield this.downloadFn();return{data:yield e.blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}};C=Symbol.toStringTag;var V=r(263).Buffer;let z={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},K={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};let StorageFileApi=class StorageFileApi{constructor(e,t={},r,s){this.shouldThrowOnError=!1,this.url=e,this.headers=t,this.bucketId=r,this.fetch=helpers_resolveFetch(s)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(e,t,r,s){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let i;let n=Object.assign(Object.assign({},K),s),o=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(n.upsert)}),a=n.metadata;if("undefined"!=typeof Blob&&r instanceof Blob)(i=new FormData).append("cacheControl",n.cacheControl),a&&i.append("metadata",this.encodeMetadata(a)),i.append("",r);else if("undefined"!=typeof FormData&&r instanceof FormData)(i=r).has("cacheControl")||i.append("cacheControl",n.cacheControl),a&&!i.has("metadata")&&i.append("metadata",this.encodeMetadata(a));else{i=r,o["cache-control"]=`max-age=${n.cacheControl}`,o["content-type"]=n.contentType,a&&(o["x-metadata"]=this.toBase64(this.encodeMetadata(a)));let e="undefined"!=typeof ReadableStream&&i instanceof ReadableStream||i&&"object"==typeof i&&"pipe"in i&&"function"==typeof i.pipe;e&&!n.duplex&&(n.duplex="half")}(null==s?void 0:s.headers)&&(o=Object.assign(Object.assign({},o),s.headers));let l=this._removeEmptyFolders(t),u=this._getFinalPath(l),h=yield("PUT"==e?put:post)(this.fetch,`${this.url}/object/${u}`,i,Object.assign({headers:o},(null==n?void 0:n.duplex)?{duplex:n.duplex}:{}));return{data:{path:l,id:h.Id,fullPath:h.Key},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}upload(e,t,r){return(0,R.__awaiter)(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,s){return(0,R.__awaiter)(this,void 0,void 0,function*(){let i=this._removeEmptyFolders(e),n=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${n}`);o.searchParams.set("token",t);try{let e;let t=Object.assign({upsert:K.upsert},s),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 put(this.fetch,o.toString(),e,{headers:n});return{data:{path:i,fullPath:a.Key},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}createSignedUploadUrl(e,t){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e),s=Object.assign({},this.headers);(null==t?void 0:t.upsert)&&(s["x-upsert"]="true");let i=yield post(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:s}),n=new URL(this.url+i.url),o=n.searchParams.get("token");if(!o)throw new StorageError("No token returned by API");return{data:{signedUrl:n.toString(),path:e,token:o},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}update(e,t,r){return(0,R.__awaiter)(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t,r){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let s=yield post(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,de
34stinationBucket:null==r?void 0:r.destinationBucket},{headers:this.headers});return{data:s,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}copy(e,t,r){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let s=yield post(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:this.headers});return{data:{path:s.Key},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}createSignedUrl(e,t,r){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield post(this.fetch,`${this.url}/object/sign/${s}`,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}${i.signedURL}${n}`);return{data:i={signedUrl:o},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}createSignedUrls(e,t,r){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let s=yield post(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=(null==r?void 0:r.download)?`&download=${!0===r.download?"":r.download}`:"";return{data:s.map(e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null})),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}download(e,t){let r=void 0!==(null==t?void 0:t.transform),s=r?"render/image/authenticated":"object",i=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),n=i?`?${i}`:"",o=this._getFinalPath(e);return new BlobDownloadBuilder(()=>get(this.fetch,`${this.url}/${s}/${o}${n}`,{headers:this.headers,noResolveJson:!0}),this.shouldThrowOnError)}info(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let e=yield get(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:recursiveToCamel(e),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}exists(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield head(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e)&&e instanceof StorageUnknownError){let t=e.originalError;if([400,404].includes(null==t?void 0:t.status))return{data:!1,error:e}}throw e}})}getPublicUrl(e,t){let r=this._getFinalPath(e),s=[],i=(null==t?void 0:t.download)?`download=${!0===t.download?"":t.download}`:"";""!==i&&s.push(i);let n=void 0!==(null==t?void 0:t.transform),o=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==o&&s.push(o);let a=s.join("&");return""!==a&&(a=`?${a}`),{data:{publicUrl:encodeURI(`${this.url}/${n?"render/image":"object"}/public/${r}${a}`)}}}remove(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield remove(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}list(e,t,r){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let s=Object.assign(Object.assign(Object.assign({},z),t),{prefix:e||""}),i=yield post(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r);return{data:i,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}listV2(e,t){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let r=Object.assign({},e),s=yield post(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},t);return{data:s,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==V?V.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_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 G="2.81.1",H={"X-Client-Info":`storage-js/${G}`};let StorageBucketApi=class StorageBucketApi{constructor(e,t={},r,s){this.shouldThrowOnError=!1;let i=new URL(e);if(null==s?void 0:s.useNewHostname){let e=/supabase\.(co|in|red)$/.test(i.hostname);e&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase."))}this.url=i.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},H),t),this.fetch=helpers_resolveFetch(r)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=this.listBucketOptionsToQueryString(e),r=yield get(this.fetch,`${this.url}/bucket${t}`,{headers:this.headers});return{data:r,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}getBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield get(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}createBucket(e){return(0,R.__awaiter)(this,arguments,void 0,function*(e,t={public:!1}){try{let r=yield post(this.fetch,`${this.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers});return{data:r,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}updateBucket(e,t){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let r=yield put(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(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}emptyBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield post(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}deleteBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield remove(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}listBucketOptionsToQueryString(e){let t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}};let StorageAnalyticsApi=class StorageAnalyticsApi{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},H),t),this.fetch=helpers_resolveFetch(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield post(this.fetch,`${this.url}/bucket`,{name:e},{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}listBuckets(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=new URLSearchParams;(null==e?void 0:e.limit)!==void 0&&t.set("limit",e.limit.toString()),(null==e?void 0:e.offset)!==void 0&&t.set("offset",e.offset.toString()),(null==e?void 0:e.sortColumn)&&t.set("sortColumn",e.sortColumn),(null==e?void 0:e.sortOrder)&&t.set("sortOrder",e.sortOrder),(null==e?void 0:e.search)&&t.set("search",e.search);let r=t.toString(),s=r?`${this.url}/bucket?${r}`:`${this.url}/bucket`,i=yield get(this.fetch,s,{headers:this.headers});return{data:i,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}deleteBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield remove(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageError(e))return{data:null,error:e};throw e}})}};let X={"X-Client-Info":`storage-js/${G}`,"Content-Type":"application/json"};
34let StorageVectorsError=class StorageVectorsError extends Error{constructor(e){super(e),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}};function isStorageVectorsError(e){return"object"==typeof e&&null!==e&&"__isStorageVectorsError"in e}let StorageVectorsApiError=class StorageVectorsApiError extends StorageVectorsError{constructor(e,t,r){super(e),this.name="StorageVectorsApiError",this.status=t,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};let StorageVectorsUnknownError=class StorageVectorsUnknownError extends StorageVectorsError{constructor(e,t){super(e),this.name="StorageVectorsUnknownError",this.originalError=t}};(p=I||(I={})).InternalError="InternalError",p.S3VectorConflictException="S3VectorConflictException",p.S3VectorNotFoundException="S3VectorNotFoundException",p.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",p.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",p.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded";let vectors_helpers_resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),helpers_isPlainObject=e=>{if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},fetch_getErrorMessage=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),fetch_handleError=(e,t,r)=>(0,R.__awaiter)(void 0,void 0,void 0,function*(){let s=e&&"object"==typeof e&&"status"in e&&"ok"in e&&"number"==typeof e.status;if(!s||(null==r?void 0:r.noResolveJson))t(new StorageVectorsUnknownError(fetch_getErrorMessage(e),e));else{let r=e.status||500;if("function"==typeof e.json)e.json().then(e=>{let s=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||r+"";t(new StorageVectorsApiError(fetch_getErrorMessage(e),r,s))}).catch(()=>{let s=r+"",i=e.statusText||`HTTP ${r} error`;t(new StorageVectorsApiError(i,r,s))});else{let s=r+"",i=e.statusText||`HTTP ${r} error`;t(new StorageVectorsApiError(i,r,s))}}}
34),fetch_getRequestParams=(e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"!==e&&s?(helpers_isPlainObject(s)?(i.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),i.body=JSON.stringify(s)):i.body=s,Object.assign(Object.assign({},i),r)):i};function fetch_handleRequest(e,t,r,s,i,n){return(0,R.__awaiter)(this,void 0,void 0,function*(){return new Promise((o,a)=>{e(r,fetch_getRequestParams(t,s,i,n)).then(e=>{if(!e.ok)throw e;if(null==s?void 0:s.noResolveJson)return e;let t=e.headers.get("content-type");return t&&t.includes("application/json")?e.json():{}}).then(e=>o(e)).catch(e=>fetch_handleError(e,a,s))})})}function fetch_post(e,t,r,s,i){return(0,R.__awaiter)(this,void 0,void 0,function*(){return fetch_handleRequest(e,"POST",t,s,i,r)})}let VectorIndexApi=class VectorIndexApi{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},X),t),this.fetch=vectors_helpers_resolveFetch(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield fetch_post(this.fetch,`${this.url}/CreateIndex`,e,{headers:this.headers});return{data:t||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}getIndex(e,t){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let r=yield fetch_post(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers});return{data:r,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}listIndexes(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield fetch_post(this.fetch,`${this.url}/ListIndexes`,e,{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}deleteIndex(e,t){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let r=yield fetch_post(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers});return{data:r||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}};let VectorDataApi=class VectorDataApi{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},X),t),this.fetch=vectors_helpers_resolveFetch(r)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{if(e.vectors.length<1||e.vectors.length>500)throw Error("Vector batch size must be between 1 and 500 items");let t=yield fetch_post(this.fetch,`${this.url}/PutVectors`,e,{headers:this.headers});return{data:t||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}getVectors(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield fetch_post(this.fetch,`${this.url}/GetVectors`,e,{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}listVectors(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw Error("segmentCount must be between 1 and 16");if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}let t=yield fetch_post(this.fetch,`${this.url}/ListVectors`,e,{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}queryVectors(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield fetch_post(this.fetch,`${this.url}/QueryVectors`,e,{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}deleteVectors(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{if(e.keys.length<1||e.keys.length>
34500)throw Error("Keys batch size must be between 1 and 500 items");let t=yield fetch_post(this.fetch,`${this.url}/DeleteVectors`,e,{headers:this.headers});return{data:t||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}};let VectorBucketApi=class VectorBucketApi{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},X),t),this.fetch=vectors_helpers_resolveFetch(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield fetch_post(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:this.headers});return{data:t||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}getBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield fetch_post(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:e},{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}listBuckets(){return(0,R.__awaiter)(this,arguments,void 0,function*(e={}){try{let t=yield fetch_post(this.fetch,`${this.url}/ListVectorBuckets`,e,{headers:this.headers});return{data:t,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}deleteBucket(e){return(0,R.__awaiter)(this,void 0,void 0,function*(){try{let t=yield fetch_post(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:this.headers});return{data:t||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(isStorageVectorsError(e))return{data:null,error:e};throw e}})}};let StorageVectorsClient=class StorageVectorsClient extends VectorBucketApi{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new VectorBucketScope(this.url,this.headers,e,this.fetch)}};let VectorBucketScope=class VectorBucketScope extends VectorIndexApi{constructor(e,t,r,s){super(e,t,s),this.vectorBucketName=r}createIndex(e){let t=Object.create(null,{createIndex:{get:()=>super.createIndex}});return(0,R.__awaiter)(this,void 0,void 0,function*(){return t.createIndex.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){let e=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return(0,R.__awaiter)(this,arguments,void 0,function*(t={}){return e.listIndexes.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName}))})}getIndex(e){let t=Object.create(null,{getIndex:{get:()=>super.getIndex}});return(0,R.__awaiter)(this,void 0,void 0,function*(){return t.getIndex.call(this,this.vectorBucketName,e)})}deleteIndex(e){let t=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return(0,R.__awaiter)(this,void 0,void 0,function*(){return t.deleteIndex.call(this,this.vectorBucketName,e)})}index(e){return new VectorIndexScope(this.url,this.headers,this.vectorBucketName,e,this.fetch)}};let VectorIndexScope=class VectorIndexScope extends VectorDataApi{constructor(e,t,r,s,i){super(e,t,i),this.vectorBucketName=r,this.indexName=s}putVectors(e){let t=Object.create(null,{putVectors:{get:()=>super.putVectors}});return(0,R.__awaiter)(this,void 0,void 0,function*(){return t.putVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(e){let t=Object.create(null,{getVectors:{get:()=>super.getVectors}});return(0,R.__awaiter)(this,void 0,void 0,function*(){return t.getVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){let e=Object.create(null,{listVectors:{get:()=>super.listVectors}});return(0,R.__awaiter)(this,arguments,void 0,function*(t={}){return e.listVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(e){let t=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return(0,R.__awaiter)(this,void 0,void 0,function*(){return t.queryVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(e){let t=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return(0,R.__awaiter)(this,void 0,void 0,function*(){return t.deleteVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}};let StorageClient=class StorageClient extends StorageBucketApi{constructor(e,t={},r,s){super(e,t,r,s)}from(e){return new StorageFileApi(this.url,this.headers,e,this.fetch)}get vectors(){return new StorageVectorsClient(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new StorageAnalyticsApi(this.url+"/iceberg",this.headers,this.fetch)}};let Y="";Y="undefined"!=typeof Deno?"deno":"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";let Z={"X-Client-Info":`supabase-js-${Y}/2.81.1`},Q={headers:Z},ee={schema:"public"},et={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},er={},fetch_resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),resolveHeadersConstructor=()=>Headers,fetchWithAuth=(e,t,r)=>{let s=fetch_resolveFetch(r),i=resolveHeadersConstructor();return async(r,n)=>{var o;let a=null!==(o=await t())&&void 0!==o?o:e,l=new i(null==n?void 0:n.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization",`Bearer ${a}`),s(r,Object.assign(Object.assign({},n),{headers:l}))}};function ensureTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function applySettingDefaults(e,t){var r,s;let{db:i,auth:n,realtime:o,global:a}=e,{db:l,auth:u,realtime:h,global:c}=t,d={db:Object.assign(Object.assign({},l),i),auth:Object.assign(Object.assign({},u),n),realtime:Object.assign(Object.assign({},h),o),storage:{},global:Object.assign(Object.assign(Object.assign({},c),a),{headers:Object.assign(Object.assign({},null!==(r=null==c?void 0:c.headers)&&void 0!==r?r:{}),null!==(s=null==a?void 0:a.headers)&&void 0!==s?s:{})}),accessToken:async()=>""};return e.accessToken?d.accessToken=e.accessToken:delete d.accessToken,d}function validateSupabaseUrl(e){let t=null==e?void 0:e.trim();if(!t)throw Error("supabaseUrl is required.");
34if(!t.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(ensureTrailingSlash(t))}catch(e){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}let es="2.81.1",ei={"X-Client-Info":`gotrue-js/${es}`},en="X-Supabase-Api-Version",eo={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},ea=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;let AuthError=class AuthError extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}};function isAuthError(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}let AuthApiError=class AuthApiError extends AuthError{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}};function isAuthApiError(e){return isAuthError(e)&&"AuthApiError"===e.name}let AuthUnknownError=class AuthUnknownError extends AuthError{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}};let CustomAuthError=class CustomAuthError extends AuthError{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}};let AuthSessionMissingError=class AuthSessionMissingError extends CustomAuthError{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};function isAuthSessionMissingError(e){return isAuthError(e)&&"AuthSessionMissingError"===e.name}
34let AuthInvalidTokenResponseError=class AuthInvalidTokenResponseError extends CustomAuthError{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}};let AuthInvalidCredentialsError=class AuthInvalidCredentialsError extends CustomAuthError{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}};let AuthImplicitGrantRedirectError=class AuthImplicitGrantRedirectError extends CustomAuthError{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};function isAuthImplicitGrantRedirectError(e){return isAuthError(e)&&"AuthImplicitGrantRedirectError"===e.name}let AuthPKCEGrantCodeExchangeError=class AuthPKCEGrantCodeExchangeError extends CustomAuthError{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};let AuthRetryableFetchError=class AuthRetryableFetchError extends CustomAuthError{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}};function isAuthRetryableFetchError(e){return isAuthError(e)&&"AuthRetryableFetchError"===e.name}let AuthWeakPasswordError=class AuthWeakPasswordError extends CustomAuthError{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}};let AuthInvalidJwtError=class AuthInvalidJwtError extends CustomAuthError{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}};let el="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),eu=" \n\r=".split(""),eh=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<eu.length;t+=1)e[eu[t].charCodeAt(0)]=-2;for(let t=0;t<el.length;t+=1)e[el[t].charCodeAt(0)]=t;return e})();function byteToBase64URL(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;){let e=t.queue>>t.queuedBits-6&63;r(el[e]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){let e=t.queue>>t.queuedBits-6&63;r(el[e]),t.queuedBits-=6}}function byteFromBase64URL(e,t,r){let s=eh[e];if(s>-1)for(t.queue=t.queue<<6|s,t.queuedBits+=6;t.queuedBits>=8;)r(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===s)return;else throw Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}function stringFromBase64URL(e){let t=[],utf8Emit=e=>{t.push(String.fromCodePoint(e))},r={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},byteEmit=e=>{stringFromUTF8(e,r,utf8Emit)};for(let t=0;t<e.length;t+=1)byteFromBase64URL(e.charCodeAt(t),s,byteEmit);return t.join("")}function codepointToUTF8(e,t){if(e<=127){t(e);return}if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function stringToUTF8(e,t){for(let r=0;r<e.length;r+=1){let s=e.charCodeAt(r);if(s>55295&&s<=56319){let t=(s-55296)*1024&65535,i=e.charCodeAt(r+1)-56320&65535;s=(i|t)+65536,r+=1}codepointToUTF8(s,t)}}function stringFromUTF8(e,t,r){if(0===t.utf8seq){if(e<=127){r(e);return}for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}}function base64UrlToUint8Array(e){let t=[],r={queue:0,queuedBits:0},onByte=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)byteFromBase64URL(e.charCodeAt(t),r,onByte);return new Uint8Array(t)}function stringToUint8Array(e){let t=[];return stringToUTF8(e,e=>t.push(e)),new Uint8Array(t)}function bytesToBase64URL(e){let t=[],r={queue:0,queuedBits:0},onChar=e=>{t.push(e)};return e.forEach(e=>byteToBase64URL(e,r,onChar)),byteToBase64URL(null,r,onChar),t.join("")}function expiresAt(e){let t=Math.round(Date.now()/1e3);return t+e}function generateCallbackId(){return Symbol("auth-callback")}let helpers_isBrowser=()=>"undefined"!=typeof window&&"undefined"!=typeof document,ec={tested:!1,writable:!1},supportsLocalStorage=()=>{if(!helpers_isBrowser())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(ec.tested)return ec.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),ec.tested=!0,ec.writable=!0}catch(e){ec.tested=!0,ec.writable=!1}return ec.writable};function parseParametersFromURL(e){let t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{let e=new URLSearchParams(r.hash.substring(1));e.forEach((e,r)=>{t[r]=e})}catch(e){}
34return r.searchParams.forEach((e,r)=>{t[r]=e}),t}let lib_helpers_resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),looksLikeFetchResponse=e=>"object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json,setItemAsync=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},getItemAsync=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return r}},removeItemAsync=async(e,t)=>{await e.removeItem(t)};let Deferred=class Deferred{constructor(){this.promise=new Deferred.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}};function decodeJWT(e){let t=e.split(".");if(3!==t.length)throw new AuthInvalidJwtError("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!ea.test(t[e]))throw new AuthInvalidJwtError("JWT not in base64url format");let r={header:JSON.parse(stringFromBase64URL(t[0])),payload:JSON.parse(stringFromBase64URL(t[1])),signature:base64UrlToUint8Array(t[2]),raw:{header:t[0],payload:t[1]}};return r}async function sleep(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function retryable(e,t){let r=new Promise((r,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{let s=await e(i);if(!t(i,null,s)){r(s);return}}catch(e){if(!t(i,e)){s(e);return}}})()});return r}function dec2hex(e){return("0"+e.toString(16)).substr(-2)}function generatePKCEVerifier(){let e=new Uint32Array(56);if("undefined"==typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let s=0;s<56;s++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,dec2hex).join("")}async function sha256(e){let t=new TextEncoder,r=t.encode(e),s=await crypto.subtle.digest("SHA-256",r),i=new Uint8Array(s);return Array.from(i).map(e=>String.fromCharCode(e)).join("")}async function generatePKCEChallenge(e){let t="undefined"!=typeof crypto&&void 0!==crypto.subtle&&"undefined"!=typeof TextEncoder;if(!t)return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e;let r=await sha256(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function getCodeChallengeAndMethod(e,t,r=!1){let s=generatePKCEVerifier(),i=s;r&&(i+="/PASSWORD_RECOVERY"),await setItemAsync(e,`${t}-code-verifier`,i);let n=await generatePKCEChallenge(s),o=s===n?"plain":"s256";return[n,o]}Deferred.promiseConstructor=Promise;let ed=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function parseResponseAPIVersion(e){let t=e.headers.get(en);if(!t||!t.match(ed))return null;try{let e=new Date(`${t}T00:00:00.0Z`);return e}catch(e){return null}}function validateExp(e){if(!e)throw Error("Missing exp claim");let t=Math.floor(Date.now()/1e3);if(e<=t)throw Error("JWT has expired")}function getAlgorithm(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw Error("Invalid alg claim")}}let ef=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function validateUUID(e){if(!ef.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function userNotAvailableProxy(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;if("symbol"==typeof t){let e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${t}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function insecureUserWarningProxy(e,t){return new Proxy(e,{get:(e,r,s)=>{if("__isInsecureUserWarningProxy"===r)return!0;
34if("symbol"==typeof r){let t=r.toString();if("Symbol(Symbol.toPrimitive)"===t||"Symbol(Symbol.toStringTag)"===t||"Symbol(util.inspect.custom)"===t||"Symbol(nodejs.util.inspect.custom)"===t)return Reflect.get(e,r,s)}return t.value||"string"!=typeof r||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(e,r,s)}})}function deepClone(e){return JSON.parse(JSON.stringify(e))}let lib_fetch_getErrorMessage=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),ep=[502,503,504];async function lib_fetch_handleError(e){var t;let r,s;if(!looksLikeFetchResponse(e))throw new AuthRetryableFetchError(lib_fetch_getErrorMessage(e),0);if(ep.includes(e.status))throw new AuthRetryableFetchError(lib_fetch_getErrorMessage(e),e.status);try{r=await e.json()}catch(e){throw new AuthUnknownError(lib_fetch_getErrorMessage(e),e)}let i=parseResponseAPIVersion(e);if(i&&i.getTime()>=eo["2024-01-01"].timestamp&&"object"==typeof r&&r&&"string"==typeof r.code?s=r.code:"object"==typeof r&&r&&"string"==typeof r.error_code&&(s=r.error_code),s){if("weak_password"===s)throw new AuthWeakPasswordError(lib_fetch_getErrorMessage(r),e.status,(null===(t=r.weak_password)||void 0===t?void 0:t.reasons)||[]);if("session_not_found"===s)throw new AuthSessionMissingError}else if("object"==typeof r&&r&&"object"==typeof r.weak_password&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new AuthWeakPasswordError(lib_fetch_getErrorMessage(r),e.status,r.weak_password.reasons);throw new AuthApiError(lib_fetch_getErrorMessage(r),e.status||500,s)}
34let lib_fetch_getRequestParams=(e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==t?void 0:t.headers),i.body=JSON.stringify(s),Object.assign(Object.assign({},i),r))};async function _request(e,t,r,s){var i;let n=Object.assign({},null==s?void 0:s.headers);n[en]||(n[en]=eo["2024-01-01"].name),(null==s?void 0:s.jwt)&&(n.Authorization=`Bearer ${s.jwt}`);let o=null!==(i=null==s?void 0:s.query)&&void 0!==i?i:{};(null==s?void 0:s.redirectTo)&&(o.redirect_to=s.redirectTo);let a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await lib_fetch_handleRequest(e,t,r+a,{headers:n,noResolveJson:null==s?void 0:s.noResolveJson},{},null==s?void 0:s.body);return(null==s?void 0:s.xform)?null==s?void 0:s.xform(l):{data:Object.assign({},l),error:null}}async function lib_fetch_handleRequest(e,t,r,s,i,n){let o;let a=lib_fetch_getRequestParams(t,s,i,n);try{o=await e(r,Object.assign({},a))}catch(e){throw console.error(e),new AuthRetryableFetchError(lib_fetch_getErrorMessage(e),0)}if(o.ok||await lib_fetch_handleError(o),null==s?void 0:s.noResolveJson)return o;try{return await o.json()}catch(e){await lib_fetch_handleError(e)}}function _sessionResponse(e){var t;let r=null;hasSession(e)&&(r=Object.assign({},e),e.expires_at||(r.expires_at=expiresAt(e.expires_in)));let s=null!==(t=e.user)&&void 0!==t?t:e;return{data:{session:r,user:s},error:null}}function _sessionResponsePassword(e){let t=_sessionResponse(e);return!t.error&&e.weak_password&&"object"==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function _userResponse(e){var t;let r=null!==(t=e.user)&&void 0!==t?t:e;return{data:{user:r},error:null}}function _ssoResponse(e){return{data:e,error:null}}function _generateLinkResponse(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:n}=e,o=(0,R.__rest)(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:s,redirect_to:i,verification_type:n},user:a},error:null}}function _noResolveJsonResponse(e){return e}function hasSession(e){return e.access_token&&e.refresh_token&&e.expires_in}let eg=["global","local","others"];let GoTrueAdminApi_GoTrueAdminApi=class GoTrueAdminApi_GoTrueAdminApi{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=lib_helpers_resolveFetch(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,t=eg[0]){if(0>eg.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${eg.join(", ")}`);try{return await _request(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(isAuthError(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await _request(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:_userResponse})}catch(e){if(isAuthError(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=(0,R.__rest)(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=null==r?void 0:r.newEmail,delete s.newEmail),await _request(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:_generateLinkResponse,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(isAuthError(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await _request(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:_userResponse})}catch(e){if(isAuthError(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,s,i,n,o,a;try{let l={nextPage:null,lastPage:0,total:0},u=await _request(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!==(i=null===(s=null==e?void 0:e.perPage)||void 0===s?void 0:s.toString())&&void 0!==i?i:""}
34,xform:_noResolveJsonResponse});if(u.error)throw u.error;let h=await u.json(),c=null!==(n=u.headers.get("x-total-count"))&&void 0!==n?n:0,d=null!==(a=null===(o=u.headers.get("link"))||void 0===o?void 0:o.split(","))&&void 0!==a?a:[];return d.length>0&&(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(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(isAuthError(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){validateUUID(e);try{return await _request(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:_userResponse})}catch(e){if(isAuthError(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){validateUUID(e);try{return await _request(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:_userResponse})}catch(e){if(isAuthError(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){validateUUID(e);try{return await _request(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:_userResponse})}catch(e){if(isAuthError(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){validateUUID(e.userId);try{let{data:t,error:r}=await _request(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(isAuthError(e))return{data:null,error:e};throw e}}async _deleteFactor(e){validateUUID(e.userId),validateUUID(e.id);try{let t=await _request(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers});return{data:t,error:null}}catch(e){if(isAuthError(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,s,i,n,o,a;try{let l={nextPage:null,lastPage:0,total:0},u=await _request(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{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!==(i=null===(s=null==e?void 0:e.perPage)||void 0===s?void 0:s.toString())&&void 0!==i?i:""}
34,xform:_noResolveJsonResponse});if(u.error)throw u.error;let h=await u.json(),c=null!==(n=u.headers.get("x-total-count"))&&void 0!==n?n:0,d=null!==(a=null===(o=u.headers.get("link"))||void 0===o?void 0:o.split(","))&&void 0!==a?a:[];return d.length>0&&(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(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(isAuthError(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await _request(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(isAuthError(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await _request(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(isAuthError(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await _request(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(isAuthError(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await _request(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(isAuthError(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await _request(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(isAuthError(e))return{data:null,error:e};throw e}}};function memoryLocalStorageAdapter(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}let ey={debug:!!(globalThis&&supportsLocalStorage()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))};let LockAcquireTimeoutError=class LockAcquireTimeoutError extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}};let NavigatorLockAcquireTimeoutError=class NavigatorLockAcquireTimeoutError extends LockAcquireTimeoutError{};async function navigatorLock(e,t,r){ey.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);let s=new globalThis.AbortController;return t>0&&setTimeout(()=>{s.abort(),ey.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:s.signal},async s=>{if(s){ey.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,s.name);try{return await r()}finally{ey.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,s.name)}}else{if(0===t)throw ey.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new NavigatorLockAcquireTimeoutError(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(ey.debug)try{let e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null," "))}catch(e){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",e)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}function polyfillGlobalThis(){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)}}function getAddress(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}function fromHex(e){return parseInt(e,16)}function toHex(e){let t=new TextEncoder().encode(e),r=Array.from(t,e=>e.toString(16).padStart(2,"0")).join("");return"0x"+r}function createSiweMessage(e){var t;let{chainId:r,domain:s,expirationTime:i,issuedAt:n=new Date,nonce:o,notBefore:a,requestId:l,resources:u,scheme:h,uri:c,version:d}=e;if(!Number.isInteger(r))throw Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!c)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==d)throw Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);if(null===(t=e.statement)||void 0===t?void 0:t.includes("\n"))throw Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`);let f=getAddress(e.address),p=h?`${h}://${s}`:s,g=e.statement?`${e.statement} 35`:"",y=`${p} wants you to sign in with your Ethereum account: 36${f} 37 38${g}`,_=`URI: ${c} 39Version: ${d}
40Chain ID: ${r}${o?` 41Nonce: ${o}`:""} 42Issued At: ${n.toISOString()}`;if(i&&(_+=` 43Expiration Time: ${i.toISOString()}`),a&&(_+=` 44Not Before: ${a.toISOString()}`),l&&(_+=` 45Request ID: ${l}`),u){let e="\nResources:";for(let t of u){if(!t||"string"!=typeof t)throw Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${t}`);e+=` 46- ${t}`}_+=e}return`${y} 47${_}`}let WebAuthnError=class WebAuthnError extends Error{constructor({message:e,code:t,cause:r,name:s}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=null!==(i=null!=s?s:r instanceof Error?r.name:void 0)&&void 0!==i?i:"Unknown Error",this.code=t}};let WebAuthnUnknownError=class WebAuthnUnknownError extends WebAuthnError{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}};function identifyRegistrationError({error:e,options:t}){var r,s,i;let{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new WebAuthnError({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if((null===(r=n.authenticatorSelection)||void 0===r?void 0:r.requireResidentKey)===!0)return new WebAuthnError({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if("conditional"===t.mediation&&(null===(s=n.authenticatorSelection)||void 0===s?void 0:s.userVerification)==="required")return new WebAuthnError({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if((null===(i=n.authenticatorSelection)||void 0===i?void 0:i.userVerification)==="required")return new WebAuthnError({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else if("InvalidStateError"===e.name)return new WebAuthnError({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});else if("NotAllowedError"===e.name)return new WebAuthnError({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("NotSupportedError"===e.name){let t=n.pubKeyCredParams.filter(e=>"public-key"===e.type);return new WebAuthnError(0===t.length?{message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}:{message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e})}else if("SecurityError"===e.name){let t=window.location.hostname;if(!isValidDomain(t))return new WebAuthnError({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new WebAuthnError({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new WebAuthnError({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new WebAuthnError({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new WebAuthnError({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}function identifyAuthenticationError({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new WebAuthnError({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("NotAllowedError"===e.name)return new WebAuthnError({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!isValidDomain(t))return new WebAuthnError({message:`${window.location.hostname}
47 is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new WebAuthnError({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new WebAuthnError({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new WebAuthnError({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}let WebAuthnAbortService=class WebAuthnAbortService{createNewAbortSignal(){if(this.controller){let e=Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}};let e_=new WebAuthnAbortService;function deserializeCredentialCreationOptions(e){if(!e)throw Error("Credential creation options are required");if("undefined"!=typeof PublicKeyCredential&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);let{challenge:t,user:r,excludeCredentials:s}=e,i=(0,R.__rest)(e,["challenge","user","excludeCredentials"]),n=base64UrlToUint8Array(t).buffer,o=Object.assign(Object.assign({},r),{id:base64UrlToUint8Array(r.id).buffer}),a=Object.assign(Object.assign({},i),{challenge:n,user:o});if(s&&s.length>0){a.excludeCredentials=Array(s.length);for(let e=0;e<s.length;e++){let t=s[e];a.excludeCredentials[e]=Object.assign(Object.assign({},t),{id:base64UrlToUint8Array(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return a}function deserializeCredentialRequestOptions(e){if(!e)throw Error("Credential request options are required");if("undefined"!=typeof PublicKeyCredential&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);let{challenge:t,allowCredentials:r}=e,s=(0,R.__rest)(e,["challenge","allowCredentials"]),i=base64UrlToUint8Array(t).buffer,n=Object.assign(Object.assign({},s),{challenge:i});if(r&&r.length>0){n.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];n.allowCredentials[e]=Object.assign(Object.assign({},t),{id:base64UrlToUint8Array(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return n}function serializeCredentialCreationResponse(e){var t;return"toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():{id:e.id,rawId:e.id,response:{attestationObject:bytesToBase64URL(new Uint8Array(e.response.attestationObject)),clientDataJSON:bytesToBase64URL(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0}}function serializeCredentialRequestResponse(e){var t;if("toJSON"in e&&"function"==typeof e.toJSON)return e.toJSON();let r=e.getClientExtensionResults(),s=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:bytesToBase64URL(new Uint8Array(s.authenticatorData)),clientDataJSON:bytesToBase64URL(new Uint8Array(s.clientDataJSON)),signature:bytesToBase64URL(new Uint8Array(s.signature)),userHandle:s.userHandle?bytesToBase64URL(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0}}function isValidDomain(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function browserSupportsWebAuthn(){var e,t;return!!(helpers_isBrowser()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&"function"==typeof(null===(e=null==navigator?void 0:navigator.credentials)||void 0===e?void 0:e.create)&&"function"==typeof(null===(t=null==navigator?void 0:navigator.credentials)||void 0===t?void 0:t.get))}async function createCredential(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new WebAuthnUnknownError("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new WebAuthnUnknownError("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:identifyRegistrationError({error:t,o
47ptions:e})}}}async function getCredential(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new WebAuthnUnknownError("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new WebAuthnUnknownError("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:identifyAuthenticationError({error:t,options:e})}}}let ew={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},ev={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function deepMerge(...e){let isObject=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),isArrayBufferLike=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),t={};for(let r of e)if(r)for(let e in r){let s=r[e];if(void 0!==s){if(Array.isArray(s))t[e]=s;else if(isArrayBufferLike(s))t[e]=s;else if(isObject(s)){let r=t[e];isObject(r)?t[e]=deepMerge(r,s):t[e]=deepMerge(s)}else t[e]=s}}return t}function mergeCredentialCreationOptions(e,t){return deepMerge(ew,e,t||{})}function mergeCredentialRequestOptions(e,t){return deepMerge(ev,e,t||{})}let WebAuthnApi=class WebAuthnApi{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:t,friendlyName:r,signal:s},i){try{let{data:n,error:o}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!n)return{data:null,error:o};let a=null!=s?s:e_.createNewAbortSignal();if("create"===n.webauthn.type){let{user:e}=n.webauthn.credential_options.publicKey;e.name||(e.name=`${e.id}:${r}`),e.displayName||(e.displayName=e.name)}switch(n.webauthn.type){case"create":{let t=mergeCredentialCreationOptions(n.webauthn.credential_options.publicKey,null==i?void 0:i.create),{data:r,error:s}=await createCredential({publicKey:t,signal:a});if(r)return{data:{factorId:e,challengeId:n.id,webauthn:{type:n.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}case"request":{let t=mergeCredentialRequestOptions(n.webauthn.credential_options.publicKey,null==i?void 0:i.request),{data:r,error:s}=await getCredential(Object.assign(Object.assign({},n.webauthn.credential_options),{publicKey:t,signal:a}));if(r)return{data:{factorId:e,challengeId:n.id,webauthn:{type:n.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}}}catch(e){if(isAuthError(e))return{data:null,error:e};return{data:null,error:new AuthUnknownError("Unexpected error in challenge",e)}}}async _verify({challengeId:e,factorId:t,webauthn:r}){return this.client.mfa.verify({factorId:t,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:t="undefined"!=typeof window?window.location.hostname:void 0,rpOrigins:r="undefined"!=typeof window?[window.location.origin]:void 0,signal:s}={}},i){if(!t)return{data:null,error:new AuthError("rpId is required for WebAuthn authentication")};try{if(!browserSupportsWebAuthn())return{data:null,error:new AuthUnknownError("Browser does not support WebAuthn",null)};let{data:n,error:o}=await this.challenge({factorId:e,webauthn:{rpId:t,rpOrigins:r},signal:s},{request:i});if(!n)return{data:null,error:o};let{webauthn:a}=n;return this._verify({factorId:e,challengeId:n.challengeId,webauthn:{type:a.type,rpId:t,rpOrigins:r,credential_response:a.credential_response}})}catch(e){if(isAuthError(e))return{data:null,error:e};return{data:null,error:new AuthUnknownError("Unexpected error in authenticate",e)}}}async _register({friendlyName:e,webauthn:{rpId:t="undefined"!=typeof window?window.location.hostname:void 0,rpOrigins:r="undefined"!=typeof window?[window.location.origin]:void 0,signal:s}={}},i){if(!t)return{data:null,error:new AuthError("rpId is required for WebAuthn registration")};try{if(!browserSupportsWebAuthn())return{data:null,error:new AuthUnknownError("Browser does not support WebAuthn",null)};let{data:n,error:o}=await this._enroll({friendlyName:e});if(!n)return await this.client.mfa.listFactors().then(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r.all.find(t=>"webauthn"===t.factor_type&&t.friendly_name===e&&"unverified"!==t.status)}).then(e=>e?this.client.mfa.unenroll({factorId:null==e?void 0:e.id}):void 0),{data:null,error:o};let{data:a,error:l}=await this._challenge({factorId:n.id,friendlyName:n.friendly_name,webauthn:{rpId:t,rpOrigins:r},signal:s},{create:i});if(!a)return{data:null,error:l};return this._verify({factorId:n.id,challengeId:a.challengeId,webauthn:{rpId:t,rpOrigins:r,type:a.webauthn.type,credential_response:a.webauthn.credential_response}})}catch(e){if(isAuthError(e))return{data:null,error:e};return{data:null,error:new AuthUnknownError("Unexpected error in register",e)}}}};polyfillGlobalThis();let eb={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:ei,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1};async function lockNoOp(e,t,r){return await r()}let em={};let GoTrueClient=class GoTrueClient{get jwks(){var e,t;return null!==(t=null===(e=em[this.storageKey])||void 0===e?void 0:e.jwks)&&void 0!==t?t:{keys:[]}}set jwks(e){em[this.storageKey]=Object.assign(Object.assign({},em[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!==(t=null===(e=em[this.storageKey])||void 0===e?void 0:e.cachedAt)&&void 0!==t?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){em[this.storageKey]=Object.assign(Object.assign({},em[this.storageKey]),{cachedAt:e})}constructor(e){var t,r,s;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;let i=Object.assign(Object.assign({},eb),e);if(this.storageKey=i.storageKey,this.instanceID=null!==(t=GoTrueClient.nextInstanceID[this.storageKey])&&void 0!==t?t:0,GoTrueClient.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,"function"==typeof i.debug&&(this.logger=i.debug),this.instanceID>0&&helpers_isBrowser()){let e=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(e),this.logDebugMessages&&console.trace(e)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.admin=new GoTrueAdminApi_GoTrueAdminApi({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=lib_helpers_resolveFetch(i.fetch),this.lock=i.lock||lockNoOp,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,i.lock?this.lock=i.lock:helpers_isBrowser()&&(null===(r=null==globalThis?void 0:globalThis.navigator)||void 0===r?void 0:r.locks)?this.lock=navigatorLock:this.lock=lockNoOp,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new WebAuthnApi(this)}
47,this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:supportsLocalStorage()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=memoryLocalStorageAdapter(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=memoryLocalStorageAdapter(this.memoryStorage)),helpers_isBrowser()&&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===(s=this.broadcastChannel)||void 0===s||s.addEventListener("message",async e=>{this._debug("received broadcast notification from other tab or client",e),await this._notifyAllSubscribers(e.data.event,e.data.session,!1)})}this.initialize()}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${es}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise||(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))()),await this.initializePromise}async _initialize(){var e;try{let t={},r="none";if(helpers_isBrowser()&&(t=parseParametersFromURL(window.location.href),this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce")),helpers_isBrowser()&&this.detectSessionInUrl&&"none"!==r){let{data:s,error:i}=await this._getSessionFromURL(t,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),isAuthImplicitGrantRedirectError(i)){let t=null===(e=i.details)||void 0===e?void 0:e.code;if("identity_already_exists"===t||"identity_not_found"===t||"single_identity_not_deletable"===t)return{error:i}}return await this._removeSession(),{error:i}}let{session:n,redirectType:o}=s;return this._debug("#_initialize()","detected session in URL",n,"redirect type",o),await this._saveSession(n),setTimeout(async()=>{"recovery"===o?await this._notifyAllSubscribers("PASSWORD_RECOVERY",n):await this._notifyAllSubscribers("SIGNED_IN",n)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){if(isAuthError(e))return this._returnResult({error:e});return this._returnResult({error:new AuthUnknownError("Unexpected error during initialization",e)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,s;try{let i=await _request(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:null!==(r=null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.data)&&void 0!==r?r:{},gotrue_meta_security:{captcha_token:null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.captchaToken}},xform:_sessionResponse}),{data:n,error:o}=i;if(o||!n)return this._returnResult({data:{user:null,session:null},error:o});let a=n.session,l=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",a)),this._returnResult({data:{user:l,session:a},error:null})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signUp(e){var t,r,s;try{let i;if("email"in e){let{email:r,password:s,options:n}=e,o=null,a=null;"pkce"===this.flowType&&([o,a]=await getCodeChallengeAndMethod(this.storage,this.storageKey)),i=await _request(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==n?void 0:n.emailRedirectTo,body:{email:r,password:s,data:null!==(t=null==n?void 0:n.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken},code_challenge:o,code_challenge_method:a},xform:_sessionResponse})}else if("phone"in e){let{phone:t,password:n,options:o}=e;i=await _request(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!==(s=null==o?void 0:o.channel)&&void 0!==s?s:"sms",gotrue_meta_security:{captcha_token:null==o?void 0:o.captchaToken}},xform:_sessionResponse})}else throw new AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:n,error:o}=i;if(o||!n)return this._returnResult({data:{user:null,session:null},error:o});let a=n.session,l=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",a)),this._returnResult({data:{user:l,session:a},error:null})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithPassword(e){try{let t;if("email"in e){let{email:r,password:s,options:i}=e;t=await _request(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:_sessionResponsePassword})}else if("phone"in e){let{phone:r,password:s,options:i}=e;t=await _request(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:_sessionResponsePassword})}else throw new AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:r,error:s}=t;if(s)return this._returnResult({data:{user:null,session:null},error:s});
47if(!r||!r.session||!r.user){let e=new AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOAuth(e){var t,r,s,i;return await 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===(s=e.options)||void 0===s?void 0:s.queryParams,skipBrowserRedirect:null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){let{chain:t}=e;switch(t){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw Error(`@supabase/auth-js: Unsupported chain "${t}"`)}}async signInWithEthereum(e){var t,r,s,i,n,o,a,l,u,h,c;let d,f;if("message"in e)d=e.message,f=e.signature;else{let h;let{chain:c,wallet:p,statement:g,options:y}=e;if(helpers_isBrowser()){if("object"==typeof p)h=p;else{let e=window;if("ethereum"in e&&"object"==typeof e.ethereum&&"request"in e.ethereum&&"function"==typeof e.ethereum.request)h=e.ethereum;else throw Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}}else{if("object"!=typeof p||!(null==y?void 0:y.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");h=p}let _=new URL(null!==(t=null==y?void 0:y.url)&&void 0!==t?t:window.location.href),w=await h.request({method:"eth_requestAccounts"}).then(e=>e).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!w||0===w.length)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let v=getAddress(w[0]),b=null===(r=null==y?void 0:y.signInWithEthereum)||void 0===r?void 0:r.chainId;if(!b){let e=await h.request({method:"eth_chainId"});b=fromHex(e)}let m={domain:_.host,address:v,statement:g,uri:_.href,version:"1",chainId:b,nonce:null===(s=null==y?void 0:y.signInWithEthereum)||void 0===s?void 0:s.nonce,issuedAt:null!==(n=null===(i=null==y?void 0:y.signInWithEthereum)||void 0===i?void 0:i.issuedAt)&&void 0!==n?n:new Date,expirationTime:null===(o=null==y?void 0:y.signInWithEthereum)||void 0===o?void 0:o.expirationTime,notBefore:null===(a=null==y?void 0:y.signInWithEthereum)||void 0===a?void 0:a.notBefore,requestId:null===(l=null==y?void 0:y.signInWithEthereum)||void 0===l?void 0:l.requestId,resources:null===(u=null==y?void 0:y.signInWithEthereum)||void 0===u?void 0:u.resources};d=createSiweMessage(m),f=await h.request({method:"personal_sign",params:[toHex(d),v]})}try{let{data:t,error:r}=await _request(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:d,signature:f},(null===(h=e.options)||void 0===h?void 0:h.captchaToken)?{gotrue_meta_security:{captcha_token:null===(c=e.options)||void 0===c?void 0:c.captchaToken}}:null),xform:_sessionResponse});if(r)throw r;
47if(!t||!t.session||!t.user){let e=new AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSolana(e){var t,r,s,i,n,o,a,l,u,h,c,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{let c;let{chain:d,wallet:g,statement:y,options:_}=e;if(helpers_isBrowser()){if("object"==typeof g)c=g;else{let e=window;if("solana"in e&&"object"==typeof e.solana&&("signIn"in e.solana&&"function"==typeof e.solana.signIn||"signMessage"in e.solana&&"function"==typeof e.solana.signMessage))c=e.solana;else throw Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}}else{if("object"!=typeof g||!(null==_?void 0:_.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");c=g}let w=new URL(null!==(t=null==_?void 0:_.url)&&void 0!==t?t:window.location.href);if("signIn"in c&&c.signIn){let e;let t=await c.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==_?void 0:_.signInWithSolana),{version:"1",domain:w.host,uri:w.href}),y?{statement:y}:null));if(Array.isArray(t)&&t[0]&&"object"==typeof t[0])e=t[0];else if(t&&"object"==typeof t&&"signedMessage"in t&&"signature"in t)e=t;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in e&&"signature"in e&&("string"==typeof e.signedMessage||e.signedMessage instanceof Uint8Array)&&e.signature instanceof Uint8Array)f="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),p=e.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in c)||"function"!=typeof c.signMessage||!("publicKey"in c)||"object"!=typeof c||!c.publicKey||!("toBase58"in c.publicKey)||"function"!=typeof c.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");f=[`${w.host} wants you to sign in with your Solana account:`,c.publicKey.toBase58(),...y?["",y,""]:[""],"Version: 1",`URI: ${w.href}`,`Issued At: ${null!==(s=null===(r=null==_?void 0:_.signInWithSolana)||void 0===r?void 0:r.issuedAt)&&void 0!==s?s:new Date().toISOString()}`,...(null===(i=null==_?void 0:_.signInWithSolana)||void 0===i?void 0:i.notBefore)?[`Not Before: ${_.signInWithSolana.notBefore}`]:[],...(null===(n=null==_?void 0:_.signInWithSolana)||void 0===n?void 0:n.expirationTime)?[`Expiration Time: ${_.signInWithSolana.expirationTime}`]:[],...(null===(o=null==_?void 0:_.signInWithSolana)||void 0===o?void 0:o.chainId)?[`Chain ID: ${_.signInWithSolana.chainId}`]:[],...(null===(a=null==_?void 0:_.signInWithSolana)||void 0===a?void 0:a.nonce)?[`Nonce: ${_.signInWithSolana.nonce}`]:[],...(null===(l=null==_?void 0:_.signInWithSolana)||void 0===l?void 0:l.requestId)?[`Request ID: ${_.signInWithSolana.requestId}`]:[],...(null===(h=null===(u=null==_?void 0:_.signInWithSolana)||void 0===u?void 0:u.resources)||void 0===h?void 0:h.length)?["Resources",..._.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join("\n");let e=await c.signMessage(new TextEncoder().encode(f),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");p=e}}try{let{data:t,error:r}=await _request(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:f,signature:bytesToBase64URL(p)},(null===(c=e.options)||void 0===c?void 0:c.captchaToken)?{gotrue_meta_security:{captcha_token:null===(d=e.options)||void 0===d?void 0:d.captchaToken}}:null),xform:_sessionResponse});if(r)throw r;
47if(!t||!t.session||!t.user){let e=new AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _exchangeCodeForSession(e){let t=await getItemAsync(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(null!=t?t:"").split("/");try{let{data:t,error:i}=await _request(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:_sessionResponse});if(await removeItemAsync(this.storage,`${this.storageKey}-code-verifier`),i)throw i;if(!t||!t.session||!t.user){let e=new AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!=s?s:null}),error:i})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null,redirectType:null},error:e});throw e}}async signInWithIdToken(e){try{let{options:t,provider:r,token:s,access_token:i,nonce:n}=e,o=await _request(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:i,nonce:n,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:_sessionResponse}),{data:a,error:l}=o;if(l)return this._returnResult({data:{user:null,session:null},error:l});
47if(!a||!a.session||!a.user){let e=new AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),this._returnResult({data:a,error:l})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOtp(e){var t,r,s,i,n;try{if("email"in e){let{email:s,options:i}=e,n=null,o=null;"pkce"===this.flowType&&([n,o]=await getCodeChallengeAndMethod(this.storage,this.storageKey));let{error:a}=await _request(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:null!==(t=null==i?void 0:i.data)&&void 0!==t?t:{},create_user:null===(r=null==i?void 0:i.shouldCreateUser)||void 0===r||r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:n,code_challenge_method:o},redirectTo:null==i?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:a})}if("phone"in e){let{phone:t,options:r}=e,{data:o,error:a}=await _request(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!==(s=null==r?void 0:r.data)&&void 0!==s?s:{},create_user:null===(i=null==r?void 0:r.shouldCreateUser)||void 0===i||i,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 this._returnResult({data:{user:null,session:null,messageId:null==o?void 0:o.message_id},error:a})}throw new AuthInvalidCredentialsError("You must provide either an email or phone number.")}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async verifyOtp(e){var t,r;try{let s,i;"options"in e&&(s=null===(t=e.options)||void 0===t?void 0:t.redirectTo,i=null===(r=e.options)||void 0===r?void 0:r.captchaToken);let{data:n,error:o}=await _request(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:_sessionResponse});if(o)throw o;if(!n){let e=Error("An error occurred on token verification.");throw e}let a=n.session,l=n.user;return(null==a?void 0:a.access_token)&&(await this._saveSession(a),await this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",a)),this._returnResult({data:{user:l,session:a},error:null})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSSO(e){var t,r,s,i,n;try{let o=null,a=null;"pkce"===this.flowType&&([o,a]=await getCodeChallengeAndMethod(this.storage,this.storageKey));let l=await _request(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===(s=null==e?void 0:e.options)||void 0===s?void 0:s.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:a}),headers:this.headers,xform:_ssoResponse});return(null===(i=l.data)||void 0===i?void 0:i.url)&&helpers_isBrowser()&&!(null===(n=e.options)||void 0===n?void 0:n.skipBrowserRedirect)&&window.location.assign(l.data.url),this._returnResult(l)}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new AuthSessionMissingError;let{error:s}=await _request(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:r,type:s,options:i}=e,{error:n}=await _request(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},redirectTo:null==i?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:n})}if("phone"in e){let{phone:r,type:s,options:i}=e,{data:n,error:o}=await _request(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null==n?void 0:n.message_id},error:o})}throw new AuthInvalidCredentialsError("You must provide either an email or phone number and a type")}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async getSession(){await this.initializePromise;let e=await this._acquireLock(-1,async()=>this._useSession(async e=>e));return e}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await r}catch(e){}})()),r}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(e){}})()),await e;this.pendingInLock.length;){let e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack);try{let e=null,t=await getItemAsync(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),null!==t&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not val
47id"),await this._removeSession())),!e)return{data:{session:null},error:null};let r=!!e.expires_at&&1e3*e.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){let t=await getItemAsync(this.userStorage,this.storageKey+"-user");(null==t?void 0:t.user)?e.user=t.user:e.user=userNotAvailableProxy()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){let t={value:this.suppressGetSessionWarning};e.user=insecureUserWarningProxy(e.user,t),t.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}let{data:s,error:i}=await this._callRefreshToken(e.refresh_token);if(i)return this._returnResult({data:{session:null},error:i});return this._returnResult({data:{session:s},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let t=await this._acquireLock(-1,async()=>await this._getUser());return t}async _getUser(e){try{if(e)return await _request(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:_userResponse});return await this._useSession(async e=>{var t,r,s;let{data:i,error:n}=e;if(n)throw n;return(null===(t=i.session)||void 0===t?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await _request(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!==(s=null===(r=i.session)||void 0===r?void 0:r.access_token)&&void 0!==s?s:void 0,xform:_userResponse}):{data:{user:null},error:new AuthSessionMissingError}})}catch(e){if(isAuthError(e))return isAuthSessionMissingError(e)&&(await this._removeSession(),await removeItemAsync(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:e});throw e}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async r=>{let{data:s,error:i}=r;if(i)throw i;if(!s.session)throw new AuthSessionMissingError;let n=s.session,o=null,a=null;"pkce"===this.flowType&&null!=e.email&&([o,a]=await getCodeChallengeAndMethod(this.storage,this.storageKey));let{data:l,error:u}=await _request(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:null==t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:a}),jwt:n.access_token,xform:_userResponse});if(u)throw u;return n.user=l.user,await this._saveSession(n),await this._notifyAllSubscribers("USER_UPDATED",n),this._returnResult({data:{user:n.user},error:null})})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null},error:e});throw e}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new AuthSessionMissingError;let t=Date.now()/1e3,r=t,s=!0,i=null,{payload:n}=decodeJWT(e.access_token);if(n.exp&&(s=(r=n.exp)<=t),s){let{data:t,error:r}=await this._callRefreshToken(e.refresh_token);if(r)return this._returnResult({data:{user:null,session:null},error:r});if(!t)return{data:{user:null,session:null},error:null};i=t}else{let{data:s,error:n}=await this._getUser(e.access_token);if(n)throw n;i={access_token:e.access_token,refresh_token:e.refresh_token,user:s.user,token_type:"bearer",expires_in:r-t,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(e){if(isAuthError(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var r;if(!e){let{data:s,error:i}=t;if(i)throw i;e=null!==(r=s.session)&&void 0!==r?r:void 0}if(!(null==e?void 0:e.refresh_token))throw new AuthSessionMissingError;let{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _getSessionFromURL(e,t){try{if(!helpers_isBrowser())throw new AuthImplicitGrantRedirectError("No browser detected.");
47if(e.error||e.error_description||e.error_code)throw new AuthImplicitGrantRedirectError(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if("pkce"===this.flowType)throw new AuthPKCEGrantCodeExchangeError("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new AuthImplicitGrantRedirectError("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new AuthPKCEGrantCodeExchangeError("No code detected.");let{data:t,error:r}=await this._exchangeCodeForSession(e.code);if(r)throw r;let s=new URL(window.location.href);return s.searchParams.delete("code"),window.history.replaceState(window.history.state,"",s.toString()),{data:{session:t.session,redirectType:null},error:null}}let{provider_token:r,provider_refresh_token:s,access_token:i,refresh_token:n,expires_in:o,expires_at:a,token_type:l}=e;if(!i||!o||!n||!l)throw new AuthImplicitGrantRedirectError("No session defined in URL");let u=Math.round(Date.now()/1e3),h=parseInt(o),c=u+h;a&&(c=parseInt(a));let d=c-u;1e3*d<=3e4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${d}s, should have been closer to ${h}s`);let f=c-h;u-f>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",f,c,u):u-f<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",f,c,u);let{data:p,error:g}=await this._getUser(i);if(g)throw g;let y={provider_token:r,provider_refresh_token:s,access_token:i,expires_in:h,expires_at:c,refresh_token:n,token_type:l,user:p.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:y,redirectType:e.type},error:null})}catch(e){if(isAuthError(e))return this._returnResult({data:{session:null,redirectType:null},error:e});throw e}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await getItemAsync(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i)return this._returnResult({error:i});let n=null===(r=s.session)||void 0===r?void 0:r.access_token;if(n){let{error:t}=await this.admin.signOut(n,e);if(t&&!(isAuthApiError(t)&&(404===t.status||401===t.status||403===t.status)))return this._returnResult({error:t})}return"others"!==e&&(await this._removeSession(),await removeItemAsync(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){let t=generateCallbackId(),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),(async()=>{await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})})(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,s;try{let{data:{session:s},error:i}=t;if(i)throw i;await (null===(r=this.stateChangeEmitters.get(e))||void 0===r?void 0:r.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",e,"session",s)}catch(t){await (null===(s=this.stateChangeEmitters.get(e))||void 0===s?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),console.error(t)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null;"pkce"===this.flowType&&([r,s]=await getCodeChallengeAndMethod(this.storage,this.storageKey,!0));try{return await _request(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async getUserIdentities(){var e;try{let{data:t,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:null!==(e=t.user.identities)&&void 0!==e?e:[]},error:null})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var t;try{let{data:r,error:s}=await this._useSession(async t=>{var r,s,i,n,o;let{data:a,error:l}=t;if(l)throw l;let u=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null===(r=e.options)||void 0===r?void 0:r.redirectTo,scopes:null===(s=e.options)||void 0===s?void 0:s.scopes,queryParams:null===(i=e.options)||void 0===i?void 0:i.queryParams,skipBrowserRedirect:!0});return await _request(this.fetch,"GET",u,{headers:this.headers,jwt:null!==(o=null===(n=a.session)||void 0===n?void 0:n.access_token)&&void 0!==o?o:void 0})});if(s)throw s;return!helpers_isBrowser()||(null===(t=e.options)||void 0===t?void 0:t.skipBrowserRedirect)||window.location.assign(null==r?void 0:r.url),this._returnResult({data:{provider:e.provider,url:null==r?void 0:r.url},error:null})}catch(t){if(isAuthError(t))return this._returnResult({data:{provider:e.provider,url:null},error:t});throw t}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var r;try{let{error:s,data:{session:i}}=t;if(s)throw s;let{options:n,provider:o,token:a,access_token:l,nonce:u}=e,h=await _request(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:null!==(r=null==i?void 0:i.access_token)&&void 0!==r?r:void 0,body:{provider:o,id_token:a,access_token:l,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:_sessionResponse}),{data:c,error:d}=h;if(d)return this._returnResult({data:{user:null,session:null},error:d});if(!c||!c.session||!c.user)return this._returnResult({data:{user:null,session:null}
47,error:new AuthInvalidTokenResponseError});return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("USER_UPDATED",c.session)),this._returnResult({data:c,error:d})}catch(e){if(isAuthError(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,s;let{data:i,error:n}=t;if(n)throw n;return await _request(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!==(s=null===(r=i.session)||void 0===r?void 0:r.access_token)&&void 0!==s?s:void 0})})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{let r=Date.now();return await retryable(async r=>(r>0&&await sleep(200*Math.pow(2,r-1)),this._debug(t,"refreshing attempt",r),await _request(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:_sessionResponse})),(e,t)=>t&&isAuthRetryableFetchError(t)&&Date.now()+200*Math.pow(2,e)-r<3e4)}catch(e){if(this._debug(t,"error",e),isAuthError(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}finally{this._debug(t,"end")}}_isValidSession(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),helpers_isBrowser()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,t;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let s=await getItemAsync(this.storage,this.storageKey);if(s&&this.userStorage){let t=await getItemAsync(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:s.user},await setItemAsync(this.userStorage,this.storageKey+"-user",t)),s.user=null!==(e=null==t?void 0:t.user)&&void 0!==e?e:userNotAvailableProxy()}else if(s&&!s.user&&!s.user){let e=await getItemAsync(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(s.user=e.user,await removeItemAsync(this.storage,this.storageKey+"-user"),await setItemAsync(this.storage,this.storageKey,s)):s.user=userNotAvailableProxy()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),null!==s&&await this._removeSession();return}let i=(null!==(t=s.expires_at)&&void 0!==t?t:1/0)*1e3-Date.now()<9e4;if(this._debug(r,`session has${i?"":" not"} expired with margin of 90000s`),i){if(this.autoRefreshToken&&s.refresh_token){let{error:e}=await this._callRefreshToken(s.refresh_token);e&&(console.error(e),isAuthRetryableFetchError(e)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}else if(s.user&&!0===s.user.__isUserNotAvailableProxy)try{let{data:e,error:t}=await this._getUser(s.access_token);!t&&(null==e?void 0:e.user)?(s.user=e.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(e){console.error("Error getting user data:",e),this._debug(r,"error getting user data, skipping SIGNED_IN notification",e)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(e){this._debug(r,"error",e),console.error(e);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new AuthSessionMissingError;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new Deferred;let{data:t,error:r}=await this._refreshAccessToken(e);if(r)throw r;if(!t.session)throw new AuthSessionMissingError;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let s={data:t.session,error:null};return this.refreshingDeferred.resolve(s),s}catch(e){if(this._debug(s,"error",e),isAuthError(e)){let r={data:null,error:e};return isAuthRetryableFetchError(e)||await this._removeSession(),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,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});let s=[],i=Array.from(this.stateChangeEmitters.values()).map(async r=>{try{await r.callback(e,t)}catch(e){s.push(e)}});if(await Promise.all(i),s.length>0){for(let e=0;e<s.length;e+=1)console.error(s[e]);throw s[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;let t=Object.assign({},e),r=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!r&&t.user&&await setItemAsync(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let s=deepClone(e);await setItemAsync(this.storage,this.storageKey,s)}else{let e=deepClone(t);await setItemAsync(this.storage,this.storageKey,e)}}async _removeSession(){this._debug("#_removeSession()"),await removeItemAsync(this.storage,this.storageKey),await removeItemAsync(this.storage,this.storageKey+"-code-verifier"),await removeItemAsync(this.storage,this.storageKey+"-user"),this.userStorage&&await removeItemAsync(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&helpers_isBrowser()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
47catch(e){console.error("removing visibilitychange callback failed",e)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");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),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let s=Math.floor((1e3*r.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),s<=3&&await this._callRefreshToken(r.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof LockAcquireTimeoutError)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!helpers_isBrowser()||!(null==window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),null==window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if("visible"!==document.visibilityState){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){let s=[`provider=${encodeURIComponent(t)}`];if((null==r?void 0:r.redirectTo)&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),(null==r?void 0:r.scopes)&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),"pkce"===this.flowType){let[e,t]=await getCodeChallengeAndMethod(this.storage,this.storageKey),r=new URLSearchParams({code_challenge:`${encodeURIComponent(e)}`,code_challenge_method:`${encodeURIComponent(t)}`});s.push(r.toString())}if(null==r?void 0:r.queryParams){let e=new URLSearchParams(r.queryParams);s.push(e.toString())}return(null==r?void 0:r.skipBrowserRedirect)&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;return i?this._returnResult({data:null,error:i}):await _request(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null===(r=null==s?void 0:s.session)||void 0===r?void 0:r.access_token})})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async _enroll(e){try{return await this._useSession(async t=>{var r,s;let{data:i,error:n}=t;if(n)return this._returnResult({data:null,error:n});let o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:"totp"===e.factorType?{issuer:e.issuer}:{}),{data:a,error:l}=await _request(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:null===(r=null==i?void 0:i.session)||void 0===r?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):("totp"===e.factorType&&"totp"===a.type&&(null===(s=null==a?void 0:a.totp)||void 0===s?void 0:s.qr_code)&&(a.totp.qr_code=`data:image/svg+xml;utf-8,${a.totp.qr_code}`),this._returnResult({data:a,error:null}))})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i)return this._returnResult({data:null,error:i});let n=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?serializeCredentialCreationResponse(e.webauthn.credential_response):serializeCredentialRequestResponse(e.webauthn.credential_response)})}:{code:e.code}),{data:o,error:a}=await _request(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:n,headers:this.headers,jwt:null===(r=null==s?void 0:s.session)||void 0===r?void 0:r.access_token});return a?this._returnResult({data:null,error:a}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),this._returnResult({data:o,error:a}))})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i)return this._returnResult({data:null,error:i});let n=await _request(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:null===(r=null==s?void 0:s.session)||void 0===r?void 0:r.access_token});if(n.error)return n;let{data:o}=n;if("webauthn"!==o.type)return{data:o,error:null};switch(o.webauthn.type){case"create":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:deserializeCredentialCreationOptions(o.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:deserializeCredentialRequestOptions(o.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}})}async _challengeAndVerify(e){let{data:t,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){var e;let{data:{user:t},error:r}=await this.getUser();if(r)return{data:null,error:r};let s={all:[],phone:[],totp:[],webauthn:[]};for(let r of null!==(e=null==t?void 0:t.factors)&&void 0!==e?e:[])s.all.push(r),"verified"===r.status&&s[r.factor_type].push(r);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(){var e,t;let{data:{session:r},error:s}
47=await this.getSession();if(s)return this._returnResult({data:null,error:s});if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:i}=decodeJWT(r.access_token),n=null;i.aal&&(n=i.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=i.amr||[];return{data:{currentLevel:n,nextLevel:o,currentAuthenticationMethods:l},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?await _request(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new AuthSessionMissingError})})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async _approveAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new AuthSessionMissingError});let n=await _request(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&helpers_isBrowser()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async _denyAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new AuthSessionMissingError});let n=await _request(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&helpers_isBrowser()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}async fetchJwk(e,t={keys:[]}){let r=t.keys.find(t=>t.kid===e);if(r)return r;let s=Date.now();if((r=this.jwks.keys.find(t=>t.kid===e))&&this.jwks_cached_at+6e5>s)return r;let{data:i,error:n}=await _request(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(n)throw n;return i.keys&&0!==i.keys.length&&(this.jwks=i,this.jwks_cached_at=s,r=i.keys.find(t=>t.kid===e))?r:null}async getClaims(e,t={}){try{let r=e;if(!r){let{data:e,error:t}
47=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});r=e.session.access_token}let{header:s,payload:i,signature:n,raw:{header:o,payload:a}}=decodeJWT(r);(null==t?void 0:t.allowExpired)||validateExp(i.exp);let l=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks);if(!l){let{error:e}=await this.getUser(r);if(e)throw e;return{data:{claims:i,header:s,signature:n},error:null}}let u=getAlgorithm(s.alg),h=await crypto.subtle.importKey("jwk",l,u,!0,["verify"]),c=await crypto.subtle.verify(u,h,n,stringToUint8Array(`${o}.${a}`));if(!c)throw new AuthInvalidJwtError("Invalid JWT signature");return{data:{claims:i,header:s,signature:n},error:null}}catch(e){if(isAuthError(e))return this._returnResult({data:null,error:e});throw e}}};GoTrueClient.nextInstanceID={};var eE=GoTrueClient;let SupabaseAuthClient=class SupabaseAuthClient extends eE{constructor(e){super(e)}};let SupabaseClient=class SupabaseClient{constructor(e,t,r){var s,i,n;this.supabaseUrl=e,this.supabaseKey=t;let o=validateSupabaseUrl(e);if(!t)throw Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",o),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",o),this.storageUrl=new URL("storage/v1",o),this.functionsUrl=new URL("functions/v1",o);let a=`sb-${o.hostname.split(".")[0]}-auth-token`,l={db:ee,realtime:er,auth:Object.assign(Object.assign({},et),{storageKey:a}),global:Q},u=applySettingDefaults(null!=r?r:{},l);this.storageKey=null!==(s=u.auth.storageKey)&&void 0!==s?s:"",this.headers=null!==(i=u.global.headers)&&void 0!==i?i:{},u.accessToken?(this.accessToken=u.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(t)} is not possible`)}})):this.auth=this._initSupabaseAuthClient(null!==(n=u.auth)&&void 0!==n?n:{},this.headers,u.global.fetch),this.fetch=fetchWithAuth(t,this._getAccessToken.bind(this),u.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},u.realtime)),this.accessToken&&this.accessToken().then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new B(new URL("rest/v1",o).href,{headers:this.headers,schema:u.db.schema,fetch:this.fetch}),this.storage=new StorageClient(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),u.accessToken||this._listenForAuthEvents()}get functions(){return new FunctionsClient(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},r={head:!1,get:!1,count:void 0}){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()}async _getAccessToken(){var e,t;if(this.accessToken)return await this.accessToken();let{data:r}=await this.auth.getSession();return null!==(t=null===(e=r.session)||void 0===e?void 0:e.access_token)&&void 0!==t?t:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:i,storageKey:n,flowType:o,lock:a,debug:l,throwOnError:u},h,c){let d={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new SupabaseAuthClient({url:this.authUrl.href,headers:Object.assign(Object.assign({},d),h),storageKey:n,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:i,flowType:o,lock:a,debug:l,throwOnError:u,fetch:c,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new RealtimeClient(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},null==e?void 0:e.params)}))}_listenForAuthEvents(){let e=this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)});return e}_handleTokenChanged(e,t,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}};var eS=r(2601);let createClient=(e,t,r)=>new SupabaseClient(e,t,r);(function(){if("undefined"!=typeof window||void 0===eS)return!1;let e=eS.version;if(null==e)return!1;let t=e.match(/^v(\d+)\./);if(!t)return!1;let r=parseInt(t[1],10);return r<=18})()&&console.warn(`â ï¸ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to N
47ode.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217`);var ek=Object.create,eA=Object.defineProperty,eT=Object.getOwnPropertyDescriptor,eO=Object.getOwnPropertyNames,eC=Object.getPrototypeOf,eI=Object.prototype.hasOwnProperty,__copyProps=(e,t,r,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of eO(t))eI.call(e,i)||i===r||eA(e,i,{get:()=>t[i],enumerable:!(s=eT(t,i))||s.enumerable});return e},__toESM=(e,t,r)=>(r=null!=e?ek(eC(e)):{},__copyProps(!t&&e&&e.__esModule?r:eA(r,"default",{value:e,enumerable:!0}),e)),eR=(g={"../../node_modules/.pnpm/[email protected]/node_modules/cookie/index.js"(e){e.parse=parse3,e.serialize=serialize3;var t=Object.prototype.toString,r=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function parse3(e,t){if("string"!=typeof e)throw TypeError("argument str must be a string");for(var r={},s=(t||{}).decode||decode,i=0;i<e.length;){var n=e.indexOf("=",i);if(-1===n)break;var o=e.indexOf(";",i);if(-1===o)o=e.length;else if(o<n){i=e.lastIndexOf(";",n-1)+1;continue}var a=e.slice(i,n).trim();if(void 0===r[a]){var l=e.slice(n+1,o).trim();34===l.charCodeAt(0)&&(l=l.slice(1,-1)),r[a]=tryDecode(l,s)}i=o+1}return r}function serialize3(e,t,s){var i=s||{},n=i.encode||encode;if("function"!=typeof n)throw TypeError("option encode is invalid");if(!r.test(e))throw TypeError("argument name is invalid");var o=n(t);if(o&&!r.test(o))throw TypeError("argument val is invalid");var a=e+"="+o;if(null!=i.maxAge){var l=i.maxAge-0;if(isNaN(l)||!isFinite(l))throw TypeError("option maxAge is invalid");a+="; Max-Age="+Math.floor(l)}if(i.domain){if(!r.test(i.domain))throw TypeError("option domain is invalid");a+="; Domain="+i.domain}if(i.path){if(!r.test(i.path))throw TypeError("option path is invalid");a+="; Path="+i.path}if(i.expires){var u=i.expires;if(!isDate(u)||isNaN(u.valueOf()))throw TypeError("option expires is invali
47d");a+="; Expires="+u.toUTCString()}if(i.httpOnly&&(a+="; HttpOnly"),i.secure&&(a+="; Secure"),i.priority)switch("string"==typeof i.priority?i.priority.toLowerCase():i.priority){case"low":a+="; Priority=Low";break;case"medium":a+="; Priority=Medium";break;case"high":a+="; Priority=High";break;default:throw TypeError("option priority is invalid")}if(i.sameSite)switch("string"==typeof i.sameSite?i.sameSite.toLowerCase():i.sameSite){case!0:case"strict":a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"none":a+="; SameSite=None";break;default:throw TypeError("option sameSite is invalid")}return a}function decode(e){return -1!==e.indexOf("%")?decodeURIComponent(e):e}function encode(e){return encodeURIComponent(e)}function isDate(e){return"[object Date]"===t.call(e)||e instanceof Date}function tryDecode(e,t){try{return t(e)}catch(t){return e}}}},function(){return y||(0,g[eO(g)[0]])((y={exports:{}}).exports,y),y.exports}),ej=__toESM(eR()),eP=__toESM(eR());function parseSupabaseCookie(e){if(!e)return null;try{let t=JSON.parse(e);if(!t)return null;if("Object"===t.constructor.name)return t;if("Array"!==t.constructor.name)throw Error(`Unexpected format: ${t.constructor.name}`);let[r,s,i]=t[0].split("."),n=base64url_decode(s),o=new TextDecoder,{exp:a,sub:l,...u}=JSON.parse(o.decode(n));return{expires_at:a,expires_in:a-Math.round(Date.now()/1e3),token_type:"bearer",access_token:t[0],refresh_token:t[1],provider_token:t[2],provider_refresh_token:t[3],user:{id:l,factors:t[4],...u}}}catch(e){return console.warn("Failed to parse cookie string:",e),null}}function stringifySupabaseSession(e){var t;return JSON.stringify([e.access_token,e.refresh_token,e.provider_token,e.provider_refresh_token,(null==(t=e.user)?void 0:t.factors)??null])}function dist_isBrowser(){return"undefined"!=typeof window&&void 0!==window.document}var eB={path:"/",sameSite:"lax",maxAge:31536e6};function createChunkRegExp(e){return RegExp(".{1,"+e+"}","g")}var eU=createChunkRegExp(3180);function createChunks(e,t,r){let s=void 0!==r?createChunkRegExp(r):eU,i=Math.ceil(t.length/(r??3180));if(1===i)return[{name:e,value:t}];let n=[],o=t.match(s);return null==o||o.forEach((t,r)=>{let s=`${e}.${r}`;n.push({name:s,value:t})}),n}function combineChunks(e,t=()=>null){let r=[];for(let s=0;;s++){let i=`${e}.${s}`,n=t(i);if(!n)break;r.push(n)}return r.length?r.join(""):null}var ex=class{constructor(e){this.cookieOptions={...eB,...e,maxAge:eB.maxAge}}getItem(e){let t=this.getCookie(e);if(e.endsWith("-code-verifier")&&t)return t;if(t)return JSON.stringify(parseSupabaseCookie(t));let r=combineChunks(e,e=>this.getCookie(e));return null!==r?JSON.stringify(parseSupabaseCookie(r)):null}setItem(e,t){if(e.endsWith("-code-verifier")){this.setCookie(e,t);return}let r=JSON.parse(t),s=stringifySupabaseSession(r),i=createChunks(e,s);i.forEach(e=>{this.setCookie(e.name,e.value)})}removeItem(e){this._deleteSingleCookie(e),this._deleteChunkedCookies(e)}_deleteSingleCookie(e){this.getCookie(e)&&this.deleteCookie(e)}_deleteChunkedCookies(e,t=0){for(let r=t;;r++){let t=`${e}.${r}`,s=this.getCookie(t);if(void 0===s)break;this.deleteCookie(t)}}},eN=class extends ex{constructor(e){super(e)}getCookie(e){if(!dist_isBrowser())return null;let t=(0,ej.parse)(document.cookie);return t[e]}setCookie(e,t){if(!dist_isBrowser())return null;document.cookie=(0,ej.serialize)(e,t,{...this.cookieOptions,httpOnly:!1})}deleteCookie(e){if(!dist_isBrowser())return null;document.cookie=(0,ej.serialize)(e,"",{...this.cookieOptions,maxAge:0,httpOnly:!1})}};function createSupabaseClient(e,t,r){var s;let i=dist_isBrowser();return createClient(e,t,{...r,auth:{flowType:"pkce",autoRefreshToken:i,detectSessionInUrl:i,persistSession:!0,storage:r.auth.storage,...(null==(s=r.auth)?void 0:s.storageKey)?{storageKey:r.auth.storageKey}:{}}})}var e$=eP.parse,eL=eP.serialize;/*! Bundled license information: 48 49cookie/index.js: 50 (*! 51 * cookie 52 * Copyright(c) 2012-2014 Roman Shtylman 53 * Copyright(c) 2015 Douglas Christopher Wilson 54 * MIT Licensed 55 *) 56*/},44:function(e,t,r){"use strict";r.r(t),r.d(t,{__addDisposableResource:function(){return __addDisposableResource},__assign:function(){return __assign},__asyncDelegator:function(){return __asyncDelegator},__asyncGenerator:function(){return __asyncGenerator},__asyncValues:function(){return __asyncValues},__await:function(){return __await},__awaiter:function(){return __awaiter},__classPrivateFieldGet:function(){return __classPrivateFieldGet},__classPrivateFieldIn:function(){return __classPrivateFieldIn},__classPrivateFieldSet:function(){return __classPrivateFieldSet},__createBinding:function(){return s},__decorate:function(){return __decorate},__disposeResources:function(){return __disposeResources},__esDecorate:function(){return __esDecorate},__exportStar:function(){return __exportStar},__extends:function(){return __extends},__generator:function(){return __generator},__importDefault:function(){return __importDefault},__importStar:function(){return __importStar}
56,__makeTemplateObject:function(){return __makeTemplateObject},__metadata:function(){return __metadata},__param:function(){return __param},__propKey:function(){return __propKey},__read:function(){return __read},__rest:function(){return __rest},__rewriteRelativeImportExtension:function(){return __rewriteRelativeImportExtension},__runInitializers:function(){return __runInitializers},__setFunctionName:function(){return __setFunctionName},__spread:function(){return __spread},__spreadArray:function(){return __spreadArray},__spreadArrays:function(){return __spreadArrays},__values:function(){return __values}});var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function __rest(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,s=Object.getOwnPropertySymbols(e);i<s.length;i++)0>t.indexOf(s[i])&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(r[s[i]]=e[s[i]]);return r}function __decorate(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n<3?i(o):n>3?i(t,r,o):i(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function __param(e,t){return function(r,s){t(r,s,e)}}function __esDecorate(e,t,r,s,i,n){function accept(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var o,a=s.kind,l="getter"===a?"get":"setter"===a?"set":"value",u=!t&&e?s.static?e:e.prototype:null,h=t||(u?Object.getOwnPropertyDescriptor(u,s.name):{}),c=!1,d=r.length-1;d>=0;d--){var f={};for(var p in s)f[p]="access"===p?{}:s[p];for(var p in s.access)f.access[p]=s.access[p];f.addInitializer=function(e){if(c)throw TypeError("Cannot add initializers after decoration has completed");n.push(accept(e||null))};var g=(0,r[d])("accessor"===a?{get:h.get,set:h.set}:h[l],f);if("accessor"===a){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw TypeError("Object expected");(o=accept(g.get))&&(h.get=o),(o=accept(g.set))&&(h.set=o),(o=accept(g.init))&&i.unshift(o)}else(o=accept(g))&&("field"===a?i.unshift(o):h[l]=o)}u&&Object.defineProperty(u,s.name,h),c=!0}function __runInitializers(e,t,r){for(var s=arguments.length>2,i=0;i<t.length;i++)r=s?t[i].call(e,r):t[i].call(e);return s?r:void 0}function __propKey(e){return"symbol"==typeof e?e:"".concat(e)}function __setFunctionName(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function __metadata(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function __awaiter(e,t,r,s){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,i){function fulfilled(e){try{step(s.next(e))}catch(e){i(e)}}function rejected(e){try{step(s.throw(e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((s=s.apply(e,t||[])).next())})}function __generator(e,t){var r,s,i,n={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=verb(0),o.throw=verb(1),o.return=verb(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function verb(e){return function(t){return step([e,t])}}function step(a){if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(i=2&a[0]?s.return:a[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,a[1])).done)return i;switch(s=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(!(i=(i=n.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){n=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(6===a[0]&&n.label<i[1]){n.label=i[1],i=a;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(a);break}i[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e],s=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}var s=Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);
56(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]};function __exportStar(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||s(t,e,r)}function __values(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var s,i,n=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(e){i={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return o}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}function __spreadArrays(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),i=0,t=0;t<r;t++)for(var n=arguments[t],o=0,a=n.length;o<a;o++,i++)s[i]=n[o];return s}function __spreadArray(e,t,r){if(r||2==arguments.length)for(var s,i=0,n=t.length;i<n;i++)!s&&i in t||(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return e.concat(s||Array.prototype.slice.call(t))}function __await(e){return this instanceof __await?(this.v=e,this):new __await(e)}function __asyncGenerator(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var s,i=r.apply(e,t||[]),n=[];return s=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),verb("next"),verb("throw"),verb("return",awaitReturn),s[Symbol.asyncIterator]=function(){return this},s;function awaitReturn(e){return function(t){return Promise.resolve(t).then(e,reject)}}function verb(e,t){i[e]&&(s[e]=function(t){return new Promise(function(r,s){n.push([e,t,r,s])>1||resume(e,t)})},t&&(s[e]=t(s[e])))}function resume(e,t){try{step(i[e](t))}catch(e){settle(n[0][3],e)}}function step(e){e.value instanceof __await?Promise.resolve(e.value.v).then(fulfill,reject):settle(n[0][2],e)}function fulfill(e){resume("next",e)}function reject(e){resume("throw",e)}function settle(e,t){e(t),n.shift(),n.length&&resume(n[0][0],n[0][1])}}function __asyncDelegator(e){var t,r;return t={},verb("next"),verb("throw",function(e){throw e}),verb("return"),t[Symbol.iterator]=function(){return this},t;function verb(s,i){t[s]=e[s]?function(t){return(r=!r)?{value:__await(e[s](t)),done:!1}:i?i(t):t}:i}}function __asyncValues(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=__values(e),t={},verb("next"),verb("throw"),verb("return"),t[Symbol.asyncIterator]=function(){return this},t);function verb(r){t[r]=e[r]&&function(t){return new Promise(function(s,i){settle(s,i,(t=e[r](t)).done,t.value)})}}function settle(e,t,r,s){Promise.resolve(s).then(function(t){e({value:t,done:r})},t)}}
56function __makeTemplateObject(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var i=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},ownKeys=function(e){return(ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function __importStar(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=ownKeys(e),n=0;n<r.length;n++)"default"!==r[n]&&s(t,e,r[n]);return i(t,e),t}function __importDefault(e){return e&&e.__esModule?e:{default:e}}function __classPrivateFieldGet(e,t,r,s){if("a"===r&&!s)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)}function __classPrivateFieldSet(e,t,r,s,i){if("m"===s)throw TypeError("Private method is not writable");if("a"===s&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,r):i?i.value=r:t.set(e,r),r}function __classPrivateFieldIn(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function __addDisposableResource(e,t,r){if(null!=t){var s,i;if("object"!=typeof t&&"function"!=typeof t)throw TypeError("Object expected.");if(r){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(i=s)}if("function"!=typeof s)throw TypeError("Object not disposable.");i&&(s=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}var n="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var s=Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s};function __disposeResources(e){function fail(t){e.error=e.hasError?new n(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var t,r=0;function next(){for(;t=e.stack.pop();)try{if(!t.async&&1===r)return r=0,e.stack.push(t),Promise.resolve().then(next);if(t.dispose){var s=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(s).then(next,function(e){return fail(e),next()})}else r|=1}catch(e){fail(e)}if(1===r)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return next()}function __rewriteRelativeImportExtension(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,i,n){return r?t?".jsx":".js":!s||i&&n?s+i+"."+n.toLowerCase()+"js":e}):e}t.default={__extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter,__generator,__createBinding:s,__exportStar,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateOb
56ject,__importStar,__importDefault,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension}}}]);
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.