@supabase/supabase-js 1.36.0-next.21 → 1.36.0-next.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/main/SupabaseClient.d.ts +15 -24
  2. package/dist/main/SupabaseClient.d.ts.map +1 -1
  3. package/dist/main/SupabaseClient.js +23 -65
  4. package/dist/main/SupabaseClient.js.map +1 -1
  5. package/dist/main/index.d.ts +1 -1
  6. package/dist/main/index.d.ts.map +1 -1
  7. package/dist/main/lib/types.d.ts +0 -15
  8. package/dist/main/lib/types.d.ts.map +1 -1
  9. package/dist/main/lib/version.d.ts +1 -1
  10. package/dist/main/lib/version.js +1 -1
  11. package/dist/module/SupabaseClient.d.ts +15 -24
  12. package/dist/module/SupabaseClient.d.ts.map +1 -1
  13. package/dist/module/SupabaseClient.js +23 -65
  14. package/dist/module/SupabaseClient.js.map +1 -1
  15. package/dist/module/index.d.ts +1 -1
  16. package/dist/module/index.d.ts.map +1 -1
  17. package/dist/module/lib/types.d.ts +0 -15
  18. package/dist/module/lib/types.d.ts.map +1 -1
  19. package/dist/module/lib/version.d.ts +1 -1
  20. package/dist/module/lib/version.js +1 -1
  21. package/dist/umd/supabase.js +1 -1
  22. package/package.json +7 -7
  23. package/src/SupabaseClient.ts +24 -74
  24. package/src/index.ts +1 -1
  25. package/src/lib/types.ts +0 -16
  26. package/src/lib/version.ts +1 -1
  27. package/dist/main/lib/SupabaseRealtimeChannel.d.ts +0 -37
  28. package/dist/main/lib/SupabaseRealtimeChannel.d.ts.map +0 -1
  29. package/dist/main/lib/SupabaseRealtimeChannel.js +0 -123
  30. package/dist/main/lib/SupabaseRealtimeChannel.js.map +0 -1
  31. package/dist/module/lib/SupabaseRealtimeChannel.d.ts +0 -37
  32. package/dist/module/lib/SupabaseRealtimeChannel.d.ts.map +0 -1
  33. package/dist/module/lib/SupabaseRealtimeChannel.js +0 -119
  34. package/dist/module/lib/SupabaseRealtimeChannel.js.map +0 -1
  35. package/src/lib/SupabaseRealtimeChannel.ts +0 -138
@@ -1,2 +1,2 @@
1
- export declare const version = "1.36.0-next.21";
1
+ export declare const version = "1.36.0-next.24";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export const version = '1.36.0-next.21';
1
+ export const version = '1.36.0-next.24';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.supabase=t():e.supabase=t()}(self,(()=>(()=>{var e,t,r={982:(e,t,r)=>{"use strict";r.r(t),r.d(t,{FunctionsClient:()=>a,FunctionsError:()=>s,FunctionsFetchError:()=>n,FunctionsHttpError:()=>o,FunctionsRelayError:()=>i});class s extends Error{constructor(e,t="FunctionsError",r){super(e),super.name=t,this.context=r}}class n extends s{constructor(e){super("Failed to perform request to Edge Function","FunctionsFetchError",e)}}class i extends s{constructor(e){super("Relay error communicating with deno backend","FunctionsRelayError",e)}}class o extends s{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}class a{constructor(e,{headers:t={},customFetch:s}={}){this.url=e,this.headers=t,this.fetch=(e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>{return t=void 0,s=void 0,i=function*(){return yield(yield Promise.resolve().then(r.t.bind(r,98,23))).fetch(...e)},new((n=void 0)||(n=Promise))((function(e,r){function o(e){try{h(i.next(e))}catch(e){r(e)}}function a(e){try{h(i.throw(e))}catch(e){r(e)}}function h(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,a)}h((i=i.apply(t,s||[])).next())}));var t,s,n,i}:fetch),(...e)=>t(...e)})(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t,{headers:r={}}={}){var s,a,h,c,u;return a=this,h=void 0,u=function*(){try{let a,h={};t instanceof Blob||t instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",a=t):"string"==typeof t?(h["Content-Type"]="text/plain",a=t):t instanceof FormData?a=t:(h["Content-Type"]="application/json",a=JSON.stringify(t));const c=yield this.fetch(`${this.url}/${e}`,{method:"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),r),body:a}).catch((e=>{throw new n(e)})),u=c.headers.get("x-relay-error");if(u&&"true"===u)throw new i(c);if(!c.ok)throw new o(c);let l,d=(null!==(s=c.headers.get("Content-Type"))&&void 0!==s?s:"text/plain").split(";")[0].trim();return l="application/json"===d?yield c.json():"application/octet-stream"===d?yield c.blob():"multipart/form-data"===d?yield c.formData():yield c.text(),{data:l,error:null}}catch(e){return{data:null,error:e}}},new((c=void 0)||(c=Promise))((function(e,t){function r(e){try{n(u.next(e))}catch(e){t(e)}}function s(e){try{n(u.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof c?n:new c((function(e){e(n)}))).then(r,s)}n((u=u.apply(a,h||[])).next())}))}}},111:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AuthApiError:()=>i,AuthError:()=>s,AuthEventMissingError:()=>h,AuthInvalidCredentialsError:()=>l,AuthNoCookieError:()=>u,AuthSessionMissingError:()=>c,AuthUnknownError:()=>o,CustomAuthError:()=>a,GoTrueApi:()=>$,GoTrueClient:()=>R,isAuthError:()=>n});class s extends Error{constructor(e){super(e),this.__isAuthError=!0,this.name="AuthError"}}function n(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class i extends s{constructor(e,t){super(e),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class o extends s{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class a extends s{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class h extends a{constructor(){super("Auth event missing!","AuthEventMissingError",400)}}class c extends a{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class u extends a{constructor(){super("No cookie found!","AuthNoCookieError",401)}}class l extends a{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}var d=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};function f(e){return Math.round(Date.now()/1e3)+e}const p=()=>"undefined"!=typeof window;function v(e,t){var r;t||(t=(null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.href)||""),e=e.replace(/[\[\]]/g,"\\$&");const s=new RegExp("[?&#]"+e+"(=([^&#]*)|&|#|$)").exec(t);return s?s[2]?decodeURIComponent(s[2].replace(/\+/g," ")):"":null}const m=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>d(void 0,void 0,void 0,(function*(){return yield(yield Promise.resolve().then(r.t.bind(r,98,23))).fetch(...e)})):fetch),(...e)=>t(...e)},y=(e,t)=>d(void 0,void 0,void 0,(function*(){const r=p()&&(yield null==e?void 0:e.getItem(t));if(!r)return null;try{return JSON.parse(r)}catch(e){return r}}));class g{constructor(){this.promise=new g.promiseConstructor(((e,t)=>{this.resolve=e,this.reject=t}))}}g.promiseConstructor=Promise;var b=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const w=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e);function _(e,t,s,n,a,h){return b(this,void 0,void 0,(function*(){return new Promise(((c,u)=>{e(s,((e,t,r,s)=>{const n={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?n:(n.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))})(t,n,a,h)).then((e=>{if(!e.ok)throw e;return(null==n?void 0:n.noResolveJson)?e:e.json()})).then((e=>c(e))).catch((e=>((e,t)=>b(void 0,void 0,void 0,(function*(){const s=yield d(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(r.t.bind(r,98,23))).Response:Response}));e instanceof s?e.json().then((r=>{t(new i(w(r),e.status||500))})):t(new o(w(e),e))})))(e,u)))}))}))}function k(e,t,r,s){return b(this,void 0,void 0,(function*(){return _(e,"GET",t,r,s)}))}function T(e,t,r,s,n){return b(this,void 0,void 0,(function*(){return _(e,"POST",t,s,n,r)}))}function E(e,t,r,s,n){return b(this,void 0,void 0,(function*(){return _(e,"PUT",t,s,n,r)}))}const O="Request Failed",x={name:"sb",lifetime:28800,domain:"",path:"/",sameSite:"lax"};function S(e,t,r){const s=r.map((t=>{return r=t,s=function(e){if(!e||!e.headers||!e.headers.host)throw new o('The "host" request header is not available',new Error('The "host" request header is not available'));const t=e.headers.host.indexOf(":")>-1&&e.headers.host.split(":")[0]||e.headers.host;return!(["localhost","127.0.0.1"].indexOf(t)>-1||t.endsWith(".local"))}(e),function(e,t,r){const s=r||{},n=encodeURIComponent,i=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;if("function"!=typeof n)throw new TypeError("option encode is invalid");if(!i.test(e))throw new TypeError("argument name is invalid");const o=n(t);if(o&&!i.test(o))throw new TypeError("argument val is invalid");let a=e+"="+o;if(null!=s.maxAge){const e=s.maxAge-0;if(isNaN(e)||!isFinite(e))throw new TypeError("option maxAge is invalid");a+="; Max-Age="+Math.floor(e)}if(s.domain){if(!i.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain="+s.domain}if(s.path){if(!i.test(s.path))throw new TypeError("option path is invalid");a+="; Path="+s.path}if(s.expires){if("function"!=typeof s.expires.toUTCString)throw new TypeError("option expires is invalid");a+="; Expires="+s.expires.toUTCString()}if(s.httpOnly&&(a+="; HttpOnly"),s.secure&&(a+="; Secure"),s.sameSite)switch("string"==typeof s.sameSite?s.sameSite.toLowerCase():s.sameSite){case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return a}(r.name,r.value,{maxAge:r.maxAge,expires:new Date(Date.now()+1e3*r.maxAge),httpOnly:!0,secure:s,path:null!==(n=r.path)&&void 0!==n?n:"/",domain:null!==(i=r.domain)&&void 0!==i?i:"",sameSite:null!==(a=r.sameSite)&&void 0!==a?a:"lax"});var r,s,n,i,a})),n=t.getHeader("Set-Cookie");return n&&(n instanceof Array?Array.prototype.push.apply(s,n):"string"==typeof n&&s.push(n)),s}function j(e,t,r){t.setHeader("Set-Cookie",S(e,t,r))}var P=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};class ${constructor({url:e="",headers:t={},cookieOptions:r,fetch:s}){this.url=e,this.headers=t,this.cookieOptions=Object.assign(Object.assign({},x),r),this.fetch=m(s)}_createRequestHeaders(e){const t=Object.assign({},this.headers);return t.Authorization=`Bearer ${e}`,t}cookieName(){var e;return null!==(e=this.cookieOptions.name)&&void 0!==e?e:""}getUrlForProvider(e,t){const r=[`provider=${encodeURIComponent(e)}`];if((null==t?void 0:t.redirectTo)&&r.push(`redirect_to=${encodeURIComponent(t.redirectTo)}`),(null==t?void 0:t.scopes)&&r.push(`scopes=${encodeURIComponent(t.scopes)}`),null==t?void 0:t.queryParams){const e=new URLSearchParams(t.queryParams);r.push(`${e}`)}return`${this.url}/authorize?${r.join("&")}`}signUpWithEmail(e,t,r={}){return P(this,void 0,void 0,(function*(){try{const s=Object.assign({},this.headers);let n="";r.redirectTo&&(n="?redirect_to="+encodeURIComponent(r.redirectTo));const i=yield T(this.fetch,`${this.url}/signup${n}`,{email:e,password:t,data:r.data,gotrue_meta_security:{captcha_token:r.captchaToken}},{headers:s}),o=Object.assign({},i);return o.expires_in&&(o.expires_at=f(i.expires_in)),{data:o,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}signInWithEmail(e,t,r={}){return P(this,void 0,void 0,(function*(){try{const s=Object.assign({},this.headers),n=yield T(this.fetch,`${this.url}/token?grant_type=password`,{email:e,password:t,gotrue_meta_security:{hcaptcha_token:r.captchaToken}},{headers:s}),i=Object.assign({},n);return i.expires_in&&(i.expires_at=f(n.expires_in)),{data:i,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}signUpWithPhone(e,t,r={}){return P(this,void 0,void 0,(function*(){try{const s=Object.assign({},this.headers),n=yield T(this.fetch,`${this.url}/signup`,{phone:e,password:t,data:r.data,gotrue_meta_security:{captcha_token:r.captchaToken}},{headers:s}),i=Object.assign({},n);return i.expires_in&&(i.expires_at=f(n.expires_in)),{data:i,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}signInWithPhone(e,t,r={}){return P(this,void 0,void 0,(function*(){try{const s=Object.assign({},this.headers),n=yield T(this.fetch,`${this.url}/token?grant_type=password`,{phone:e,password:t,gotrue_meta_security:{hcaptcha_token:r.captchaToken}},{headers:s});return n.expires_in&&(n.expires_at=f(n.expires_in)),{session:n,error:null}}catch(e){if(n(e))return{session:null,error:e};throw e}}))}signInWithOpenIDConnect({id_token:e,nonce:t,client_id:r,issuer:s,provider:i}){return P(this,void 0,void 0,(function*(){try{const n=Object.assign({},this.headers),o="?grant_type=id_token",a=yield T(this.fetch,`${this.url}/token${o}`,{id_token:e,nonce:t,client_id:r,issuer:s,provider:i},{headers:n});return a.expires_in&&(a.expires_at=f(a.expires_in)),{session:a,error:null}}catch(e){if(n(e))return{session:null,error:e};throw e}}))}sendMagicLinkEmail(e,t={}){var r;return P(this,void 0,void 0,(function*(){try{const s=Object.assign({},this.headers);let n="";t.redirectTo&&(n+="?redirect_to="+encodeURIComponent(t.redirectTo));const i=null===(r=t.shouldCreateUser)||void 0===r||r;return{data:yield T(this.fetch,`${this.url}/otp${n}`,{email:e,create_user:i,gotrue_meta_security:{captcha_token:t.captchaToken}},{headers:s}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}sendMobileOTP(e,t={}){var r;return P(this,void 0,void 0,(function*(){try{const s=null===(r=t.shouldCreateUser)||void 0===r||r,n=Object.assign({},this.headers);return{data:yield T(this.fetch,`${this.url}/otp`,{phone:e,create_user:s,gotrue_meta_security:{captcha_token:t.captchaToken}},{headers:n}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}signOut(e){return P(this,void 0,void 0,(function*(){try{return yield T(this.fetch,`${this.url}/logout`,{},{headers:this._createRequestHeaders(e),noResolveJson:!0}),{error:null}}catch(e){if(n(e))return{error:e};throw e}}))}verifyMobileOTP(e,t,r={}){return P(this,void 0,void 0,(function*(){try{const s=Object.assign({},this.headers),n=yield T(this.fetch,`${this.url}/verify`,{phone:e,token:t,type:"sms",redirect_to:r.redirectTo},{headers:s}),i=Object.assign({},n);return i.expires_in&&(i.expires_at=f(n.expires_in)),{data:i,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}verifyOTP({email:e,phone:t,token:r,type:s="sms"},i={}){return P(this,void 0,void 0,(function*(){try{const n=Object.assign({},this.headers),o=yield T(this.fetch,`${this.url}/verify`,{email:e,phone:t,token:r,type:s,redirect_to:i.redirectTo},{headers:n}),a=Object.assign({},o);return a.expires_in&&(a.expires_at=f(o.expires_in)),{data:a,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}inviteUserByEmail(e,t={}){return P(this,void 0,void 0,(function*(){try{const r=Object.assign({},this.headers);let s="";return t.redirectTo&&(s+="?redirect_to="+encodeURIComponent(t.redirectTo)),{user:yield T(this.fetch,`${this.url}/invite${s}`,{email:e,data:t.data},{headers:r}),error:null}}catch(e){if(n(e))return{user:null,error:e};throw e}}))}resetPasswordForEmail(e,t={}){return P(this,void 0,void 0,(function*(){try{const r=Object.assign({},this.headers);let s="";return t.redirectTo&&(s+="?redirect_to="+encodeURIComponent(t.redirectTo)),{data:yield T(this.fetch,`${this.url}/recover${s}`,{email:e,gotrue_meta_security:{captcha_token:t.captchaToken}},{headers:r}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}refreshAccessToken(e){return P(this,void 0,void 0,(function*(){try{const t=yield T(this.fetch,`${this.url}/token?grant_type=refresh_token`,{refresh_token:e},{headers:this.headers}),r=Object.assign({},t);return r.expires_in&&(r.expires_at=f(t.expires_in)),{session:r,error:null}}catch(e){if(n(e))return{session:null,error:e};throw e}}))}setAuthCookie(e,t){"POST"!==e.method&&(t.setHeader("Allow","POST"),t.status(405).end("Method Not Allowed"));const{event:r,session:s}=e.body;if(!r)throw new h;if("SIGNED_IN"===r){if(!s)throw new c;j(e,t,[{key:"access-token",value:s.access_token},{key:"refresh-token",value:s.refresh_token}].map((e=>{var t;return{name:`${this.cookieName()}-${e.key}`,value:e.value,domain:this.cookieOptions.domain,maxAge:null!==(t=this.cookieOptions.lifetime)&&void 0!==t?t:0,path:this.cookieOptions.path,sameSite:this.cookieOptions.sameSite}})))}"SIGNED_OUT"===r&&j(e,t,["access-token","refresh-token"].map((e=>({name:`${this.cookieName()}-${e}`,value:"",maxAge:-1})))),t.status(200).json({})}deleteAuthCookie(e,t,{redirectTo:r="/"}){return j(e,t,["access-token","refresh-token"].map((e=>({name:`${this.cookieName()}-${e}`,value:"",maxAge:-1})))),t.redirect(307,r)}getAuthCookieString(e,t){"POST"!==e.method&&(t.setHeader("Allow","POST"),t.status(405).end("Method Not Allowed"));const{event:r,session:s}=e.body;if(!r)throw new h;if("SIGNED_IN"===r){if(!s)throw new c;return S(e,t,[{key:"access-token",value:s.access_token},{key:"refresh-token",value:s.refresh_token}].map((e=>{var t;return{name:`${this.cookieName()}-${e.key}`,value:e.value,domain:this.cookieOptions.domain,maxAge:null!==(t=this.cookieOptions.lifetime)&&void 0!==t?t:0,path:this.cookieOptions.path,sameSite:this.cookieOptions.sameSite}})))}return"SIGNED_OUT"===r?S(e,t,["access-token","refresh-token"].map((e=>({name:`${this.cookieName()}-${e}`,value:"",maxAge:-1})))):t.getHeader("Set-Cookie")}generateLink(e,t,r={}){return P(this,void 0,void 0,(function*(){try{return{data:yield T(this.fetch,`${this.url}/admin/generate_link`,{type:e,email:t,password:r.password,data:r.data,redirect_to:r.redirectTo},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}createUser(e){return P(this,void 0,void 0,(function*(){try{const t=yield T(this.fetch,`${this.url}/admin/users`,e,{headers:this.headers});return{user:t,data:t,error:null}}catch(e){if(n(e))return{user:null,data:null,error:e};throw e}}))}listUsers(){return P(this,void 0,void 0,(function*(){try{return{users:(yield k(this.fetch,`${this.url}/admin/users`,{headers:this.headers})).users,error:null}}catch(e){if(n(e))return{users:null,error:e};throw e}}))}getUserById(e){return P(this,void 0,void 0,(function*(){try{return{user:yield k(this.fetch,`${this.url}/admin/users/${e}`,{headers:this.headers}),error:null}}catch(e){if(n(e))return{user:null,error:e};throw e}}))}getUserByCookie(e,t){return P(this,void 0,void 0,(function*(){try{if(!e.cookies)throw new i("Not able to parse cookies! When using Express make sure the cookie-parser middleware is in use!",500);const r=e.cookies[`${this.cookieName()}-access-token`],s=e.cookies[`${this.cookieName()}-refresh-token`];if(!r)throw new u;const{user:n,error:o}=yield this.getUser(r);if(o){if(!s)throw new i("No refresh_token cookie found!",400);if(!t)throw new i("You need to pass the res object to automatically refresh the session!",400);const{session:r,error:n}=yield this.refreshAccessToken(s);if(n)throw n;if(r)return j(e,t,[{key:"access-token",value:r.access_token},{key:"refresh-token",value:r.refresh_token}].map((e=>{var t;return{name:`${this.cookieName()}-${e.key}`,value:e.value,domain:this.cookieOptions.domain,maxAge:null!==(t=this.cookieOptions.lifetime)&&void 0!==t?t:0,path:this.cookieOptions.path,sameSite:this.cookieOptions.sameSite}}))),{token:r.access_token,user:r.user,data:r.user,error:null}}return{token:r,user:n,data:n,error:null}}catch(e){if(n(e))return{token:null,user:null,data:null,error:e};throw e}}))}updateUserById(e,t){return P(this,void 0,void 0,(function*(){try{return{user:yield E(this.fetch,`${this.url}/admin/users/${e}`,t,{headers:this.headers}),error:null}}catch(e){if(n(e))return{user:null,error:e};throw e}}))}deleteUser(e){return P(this,void 0,void 0,(function*(){try{return{user:yield function(e,t,r,s,n){return b(this,void 0,void 0,(function*(){return _(e,"DELETE",t,s,undefined,r)}))}(this.fetch,`${this.url}/admin/users/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(n(e))return{user:null,error:e};throw e}}))}getUser(e){return P(this,void 0,void 0,(function*(){try{return{user:yield k(this.fetch,`${this.url}/user`,{headers:this._createRequestHeaders(e)}),error:null}}catch(e){if(n(e))return{user:null,error:e};throw e}}))}updateUser(e,t){return P(this,void 0,void 0,(function*(){try{return{user:yield E(this.fetch,`${this.url}/user`,t,{headers:this._createRequestHeaders(e)}),error:null}}catch(e){if(n(e))return{user:null,error:e};throw e}}))}}var A=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};!function(){if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!=typeof self&&(self.globalThis=self)}}();const C={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,multiTab:!0,headers:{"X-Client-Info":"gotrue-js/1.23.0-next.15"}};class R{constructor(e){this.stateChangeEmitters=new Map,this.networkRetries=0,this.refreshingDeferred=null;const t=Object.assign(Object.assign({},C),e);this.inMemorySession=null,this.storageKey=t.storageKey,this.autoRefreshToken=t.autoRefreshToken,this.persistSession=t.persistSession,this.storage=t.storage||globalThis.localStorage,this.api=new $({url:t.url,headers:t.headers,cookieOptions:t.cookieOptions,fetch:t.fetch}),this._recoverAndRefresh(),this._handleVisibilityChange(),t.detectSessionInUrl&&p()&&v("access_token")&&this.getSessionFromUrl({storeSession:!0}).then((({error:e})=>{if(e)throw new o("Error getting session from URL.",e)}))}signUp({email:e,password:t,phone:r},s={}){return A(this,void 0,void 0,(function*(){try{this._removeSession();const{data:n,error:i}=r&&t?yield this.api.signUpWithPhone(r,t,{data:s.data,captchaToken:s.captchaToken}):yield this.api.signUpWithEmail(e,t,{redirectTo:s.redirectTo,data:s.data,captchaToken:s.captchaToken});if(i)throw i;if(!n)throw"An error occurred on sign up.";let o=null,a=null;return n.access_token?(o=n,a=o.user,this._saveSession(o),this._notifyAllSubscribers("SIGNED_IN",o)):a=n,{data:{user:a,session:o},error:null}}catch(e){if(n(e))return{data:{user:null,session:null},error:e};throw e}}))}signInWithPassword(e){return A(this,void 0,void 0,(function*(){try{if(this._removeSession(),"email"in e){const{email:t,password:r,options:s}=e;return this._handleEmailSignIn(t,r,{captchaToken:null==s?void 0:s.captchaToken})}if("phone"in e){const{phone:t,password:r,options:s}=e;return this._handlePhoneSignIn(t,r,{captchaToken:null==s?void 0:s.captchaToken})}throw new l("You must provide either an email or phone number and a password.")}catch(e){if(n(e))return{data:{user:null,session:null},error:e};throw e}}))}signInWithOAuth(e){var t,r,s;return A(this,void 0,void 0,(function*(){return this._removeSession(),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})}))}signInWithOtp(e){return A(this,void 0,void 0,(function*(){try{if(this._removeSession(),"email"in e){const{email:t,options:r}=e,{error:s}=yield this.api.sendMagicLinkEmail(t,{redirectTo:null==r?void 0:r.emailRedirectTo,shouldCreateUser:null==r?void 0:r.shouldCreateUser,captchaToken:null==r?void 0:r.captchaToken});return{data:{user:null,session:null},error:s}}if("phone"in e){const{phone:t,options:r}=e,{error:s}=yield this.api.sendMobileOTP(t,{shouldCreateUser:null==r?void 0:r.shouldCreateUser,captchaToken:null==r?void 0:r.captchaToken});return{data:{user:null,session:null},error:s}}throw new l("You must provide either an email or phone number.")}catch(e){if(n(e))return{data:{user:null,session:null},error:e};throw e}}))}verifyOTP(e,t={}){return A(this,void 0,void 0,(function*(){try{this._removeSession();const{data:r,error:s}=yield this.api.verifyOTP(e,t);if(s)throw s;if(!r)throw"An error occurred on token verification.";let n=null,i=null;return r.access_token&&(n=r,i=n.user,this._saveSession(n),this._notifyAllSubscribers("SIGNED_IN",n)),r.id&&(i=r),{data:{user:i,session:n},error:null}}catch(e){if(n(e))return{data:{user:null,session:null},error:e};throw e}}))}getSession(){return A(this,void 0,void 0,(function*(){let e=null;if(this.persistSession){const t=yield y(this.storage,this.storageKey);this._doesSessionExist(t)?e=t:yield this._removeSession()}else e=this.inMemorySession;if(!e)return{session:null,error:null};if(!(e.expires_at&&e.expires_at<=Date.now()/1e3))return{session:e,error:null};const{session:t,error:r}=yield this._callRefreshToken(e.refresh_token);return r?{session:null,error:r}:{session:t,error:null}}))}getUser(){return A(this,void 0,void 0,(function*(){const{session:e,error:t}=yield this.getSession();return t?{user:null,error:t}:e?{user:e.user,error:null}:{user:null,error:null}}))}update(e){return A(this,void 0,void 0,(function*(){try{const{session:t,error:r}=yield this.getSession();if(r)throw r;if(!t)throw new c;const{user:s,error:n}=yield this.api.updateUser(t.access_token,e);if(n)throw n;return t.user=s,this._saveSession(t),this._notifyAllSubscribers("USER_UPDATED",t),{user:s,error:null}}catch(e){if(n(e))return{user:null,error:e};throw e}}))}setSession(e){return A(this,void 0,void 0,(function*(){try{if(!e)throw new c;const{session:t,error:r}=yield this.api.refreshAccessToken(e);return r?{session:null,error:r}:(this._saveSession(t),this._notifyAllSubscribers("TOKEN_REFRESHED",t),{session:t,error:null})}catch(e){if(n(e))return{session:null,error:e};throw e}}))}getSessionFromUrl(e){return A(this,void 0,void 0,(function*(){try{if(!p())throw new i("No browser detected.",500);const t=v("error_description");if(t)throw new i(t,500);const r=v("provider_token"),s=v("access_token");if(!s)throw new i("No access_token detected.",500);const n=v("expires_in");if(!n)throw new i("No expires_in detected.",500);const o=v("refresh_token");if(!o)throw new i("No refresh_token detected.",500);const a=v("token_type");if(!a)throw new i("No token_type detected.",500);const h=Math.round(Date.now()/1e3)+parseInt(n),{user:c,error:u}=yield this.api.getUser(s);if(u)throw u;const l={provider_token:r,access_token:s,expires_in:parseInt(n),expires_at:h,refresh_token:o,token_type:a,user:c};if(null==e?void 0:e.storeSession){this._saveSession(l);const e=v("type");this._notifyAllSubscribers("SIGNED_IN",l),"recovery"===e&&this._notifyAllSubscribers("PASSWORD_RECOVERY",l)}return window.location.hash="",{session:l,error:null}}catch(e){if(n(e))return{session:null,error:e};throw e}}))}signOut(){return A(this,void 0,void 0,(function*(){const{session:e,error:t}=yield this.getSession();if(t)return{error:t};const r=null==e?void 0:e.access_token;if(r){const{error:e}=yield this.api.signOut(r);if(e)return{error:e}}return this._removeSession(),this._notifyAllSubscribers("SIGNED_OUT",null),{error:null}}))}onAuthStateChange(e){try{const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})),r={id:t,callback:e,unsubscribe:()=>{this.stateChangeEmitters.delete(t)}};return this.stateChangeEmitters.set(t,r),{subscription:r,error:null}}catch(e){if(n(e))return{subscription:null,error:e};throw e}}_doesSessionExist(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}_handleEmailSignIn(e,t,r={}){var s,i;return A(this,void 0,void 0,(function*(){try{const{data:n,error:o}=yield this.api.signInWithEmail(e,t,{captchaToken:r.captchaToken});return o||!n?{data:{user:null,session:null},error:o}:(((null===(s=null==n?void 0:n.user)||void 0===s?void 0:s.confirmed_at)||(null===(i=null==n?void 0:n.user)||void 0===i?void 0:i.email_confirmed_at))&&(this._saveSession(n),this._notifyAllSubscribers("SIGNED_IN",n)),{data:{user:n.user,session:n},error:null})}catch(e){if(n(e))return{data:{user:null,session:null},error:e};throw e}}))}_handlePhoneSignIn(e,t,r={}){var s;return A(this,void 0,void 0,(function*(){try{const{session:n,error:i}=yield this.api.signInWithPhone(e,t,{captchaToken:r.captchaToken});return i||!n?{data:{session:null,user:null},error:i}:((null===(s=null==n?void 0:n.user)||void 0===s?void 0:s.phone_confirmed_at)&&(this._saveSession(n),this._notifyAllSubscribers("SIGNED_IN",n)),{data:{session:n,user:n.user},error:null})}catch(e){if(n(e))return{data:{session:null,user:null},error:e};throw e}}))}_handleProviderSignIn(e,t={}){const r=this.api.getUrlForProvider(e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return p()&&(window.location.href=r),{data:{provider:e,url:r},error:null}}_handleOpenIDConnectSignIn({id_token:e,nonce:t,client_id:r,issuer:s,provider:i}){return A(this,void 0,void 0,(function*(){if(e&&t&&(r&&s||i))try{const{session:n,error:o}=yield this.api.signInWithOpenIDConnect({id_token:e,nonce:t,client_id:r,issuer:s,provider:i});return o||!n?{user:null,session:null,error:o}:(this._saveSession(n),this._notifyAllSubscribers("SIGNED_IN",n),{user:n.user,session:n,error:null})}catch(e){if(n(e))return{user:null,session:null,error:e};throw e}throw new l("You must provide an OpenID Connect provider with your id token and nonce.")}))}_recoverAndRefresh(){var e;return A(this,void 0,void 0,(function*(){try{const t=yield y(this.storage,this.storageKey);if(!this._doesSessionExist(t))return yield this._removeSession(),null;const r=Math.round(Date.now()/1e3);if((null!==(e=t.expires_at)&&void 0!==e?e:1/0)<r+10)if(this.autoRefreshToken&&t.refresh_token){this.networkRetries++;const{error:e}=yield this._callRefreshToken(t.refresh_token);if(e){if(console.log(e.message),e.message===O&&this.networkRetries<10)return this.refreshTokenTimer&&clearTimeout(this.refreshTokenTimer),void(this.refreshTokenTimer=setTimeout((()=>this._recoverAndRefresh()),100*Math.pow(2,this.networkRetries)));yield this._removeSession()}this.networkRetries=0}else this._removeSession();else this.persistSession&&this._saveSession(t),this._notifyAllSubscribers("SIGNED_IN",t)}catch(e){return console.error(e),null}}))}_callRefreshToken(e){var t,r;return A(this,void 0,void 0,(function*(){if(this.refreshingDeferred)return this.refreshingDeferred.promise;try{if(this.refreshingDeferred=new g,!e)throw new c;const{session:t,error:r}=yield this.api.refreshAccessToken(e);if(r)throw r;if(!t)throw new c;this._saveSession(t),this._notifyAllSubscribers("TOKEN_REFRESHED",t);const s={session:t,error:null};return this.refreshingDeferred.resolve(s),s}catch(e){if(n(e)){const r={session:null,error:e};return null===(t=this.refreshingDeferred)||void 0===t||t.resolve(r),r}throw null===(r=this.refreshingDeferred)||void 0===r||r.reject(e),e}finally{this.refreshingDeferred=null}}))}_notifyAllSubscribers(e,t){this.stateChangeEmitters.forEach((r=>r.callback(e,t)))}_saveSession(e){this.persistSession||(this.inMemorySession=e);const t=e.expires_at;if(t){const r=t-Math.round(Date.now()/1e3),s=r>10?10:.5;this._startAutoRefreshToken(1e3*(r-s),e)}this.persistSession&&e.expires_at&&this._persistSession(e)}_persistSession(e){var t,r,s;t=this.storage,r=this.storageKey,s=e,d(void 0,void 0,void 0,(function*(){p()&&(yield null==t?void 0:t.setItem(r,JSON.stringify(s)))}))}_removeSession(){return A(this,void 0,void 0,(function*(){var e,t;this.persistSession?(e=this.storage,t=this.storageKey,d(void 0,void 0,void 0,(function*(){p()&&(yield null==e?void 0:e.removeItem(t))}))):this.inMemorySession=null,this.refreshTokenTimer&&clearTimeout(this.refreshTokenTimer)}))}_startAutoRefreshToken(e,t){this.refreshTokenTimer&&clearTimeout(this.refreshTokenTimer),e<=0||!this.autoRefreshToken||(this.refreshTokenTimer=setTimeout((()=>A(this,void 0,void 0,(function*(){this.networkRetries++;const{error:e}=yield this._callRefreshToken(t.refresh_token);e||(this.networkRetries=0),(null==e?void 0:e.message)===O&&this.networkRetries<10&&this._startAutoRefreshToken(100*Math.pow(2,this.networkRetries),t)}))),e),"function"==typeof this.refreshTokenTimer.unref&&this.refreshTokenTimer.unref())}_handleVisibilityChange(){if(!p()||!(null===window||void 0===window?void 0:window.addEventListener))return!1;try{null===window||void 0===window||window.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this._recoverAndRefresh()}))}catch(e){console.error("_handleVisibilityChange",e)}}}},189:(e,t,r)=>{"use strict";r.r(t),r.d(t,{PostgrestBuilder:()=>i,PostgrestClient:()=>u,PostgrestFilterBuilder:()=>a,PostgrestQueryBuilder:()=>h,PostgrestTransformBuilder:()=>o});var s=r(98),n=r.n(s);class i{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.allowEmpty=e.allowEmpty,e.fetch?this.fetch=e.fetch:"undefined"==typeof fetch?this.fetch=n():this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),"GET"!==this.method&&"HEAD"!==this.method&&(this.headers["Content-Type"]="application/json");let r=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then((e=>{return t=this,r=void 0,n=function*(){var t,r,s,n;let i,o,a,h=e.status,c=e.statusText;if(e.ok){const n=null===(t=this.headers.Prefer)||void 0===t?void 0:t.split(",").includes("return=minimal");if("HEAD"!==this.method&&!n){const t=yield e.text();t&&(o="text/csv"===this.headers.Accept?t:JSON.parse(t))}const i=null===(r=this.headers.Prefer)||void 0===r?void 0:r.match(/count=(exact|planned|estimated)/),h=null===(s=e.headers.get("content-range"))||void 0===s?void 0:s.split("/");i&&h&&h.length>1&&(a=parseInt(h[1]))}else{const t=yield e.text();try{i=JSON.parse(t)}catch(e){i={message:t}}if(i&&this.allowEmpty&&(null===(n=null==i?void 0:i.details)||void 0===n?void 0:n.includes("Results contain 0 rows"))&&(i=void 0,h=200,c="OK"),i&&this.shouldThrowOnError)throw i}return{error:i,data:o,count:a,status:h,statusText:c}},new((s=void 0)||(s=Promise))((function(e,i){function o(e){try{h(n.next(e))}catch(e){i(e)}}function a(e){try{h(n.throw(e))}catch(e){i(e)}}function h(t){var r;t.done?e(t.value):(r=t.value,r instanceof s?r:new s((function(e){e(r)}))).then(o,a)}h((n=n.apply(t,r||[])).next())}));var t,r,s,n}));return this.shouldThrowOnError||(r=r.catch((e=>({error:{message:`FetchError: ${e.message}`,details:"",hint:"",code:e.code||""},data:void 0,count:void 0,status:400,statusText:"Bad Request"})))),r.then(e,t)}}class o extends i{select(e){let t=!1;const r=(null!=e?e:"*").split("").map((e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e))).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s}={}){const n=s?`${s}.order`:"order",i=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${i?`${i},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t}={}){const r=void 0===t?"limit":`${t}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:r}={}){const s=void 0===r?"offset":`${r}.offset`,n=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this.url.searchParams.set(n,""+(t-e+1)),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.headers.Accept="application/vnd.pgrst.object+json",this.allowEmpty=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:n=!1}={}){const i=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),o=this.headers.Accept;return this.headers.Accept=`application/vnd.pgrst.plan+json; for="${o}"; options=${i};`,this}}class a extends o{not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t}={}){const r=t?`${t}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}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}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=t.map((e=>"string"==typeof e&&new RegExp("[,()]").test(e)?`"${e}"`:`${e}`)).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${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}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 n="";"plain"===s?n="pl":"phrase"===s?n="ph":"websearch"===s&&(n="w");const i=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${n}fts${i}.${t}`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}match(e){return Object.entries(e).forEach((([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)})),this}}class h{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=t,this.schema=r,this.fetch=s}select(e,{head:t=!1,count:r}={}){const s=t?"HEAD":"GET";let n=!1;const i=(null!=e?e:"*").split("").map((e=>/\s/.test(e)&&!n?"":('"'===e&&(n=!n),e))).join("");return this.url.searchParams.set("select",i),r&&(this.headers.Prefer=`count=${r}`),new a({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t}={}){const r=[],s=e;if(t&&r.push(`count=${t}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),Array.isArray(e)){const t=e.reduce(((e,t)=>e.concat(Object.keys(t))),[]);if(t.length>0){const e=[...new Set(t)].map((e=>`"${e}"`));this.url.searchParams.set("columns",e.join(","))}}return new a({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,count:r,ignoreDuplicates:s=!1}={}){const n=[`resolution=${s?"ignore":"merge"}-duplicates`];void 0!==t&&this.url.searchParams.set("on_conflict",t);const i=e;return r&&n.push(`count=${r}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new a({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const r=[],s=e;return t&&r.push(`count=${t}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new a({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t=[];return e&&t.push(`count=${e}`),this.headers.Prefer&&t.unshift(this.headers.Prefer),this.headers.Prefer=t.join(","),new a({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const c={"X-Client-Info":"postgrest-js/1.0.0-next.6"};class u{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},c),t),this.schema=r,this.fetch=s}from(e){const t=new URL(`${this.url}/${e}`);return new h(t,{headers:Object.assign({},this.headers),schema:this.schema,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:s}={}){let n;const i=new URL(`${this.url}/rpc/${e}`);let o;r?(n="HEAD",Object.entries(t).forEach((([e,t])=>{i.searchParams.append(e,`${t}`)}))):(n="POST",o=t);const h=Object.assign({},this.headers);return s&&(h.Prefer=`count=${s}`),new a({method:n,url:i,headers:h,schema:this.schema,body:o,fetch:this.fetch,allowEmpty:!1})}}},73:(e,t,r)=>{"use strict";r.r(t),r.d(t,{RealtimeChannel:()=>O,RealtimeClient:()=>S,RealtimePresence:()=>E,Transformers:()=>n});var s,n={};r.r(n),r.d(n,{PostgresTypes:()=>s,convertCell:()=>a,convertChangeData:()=>i,convertColumn:()=>o,toArray:()=>d,toBoolean:()=>c,toJson:()=>l,toNumber:()=>u,toTimestampString:()=>f}),function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(s||(s={}));const i=(e,t,r={})=>{var s;const n=null!==(s=r.skipTypes)&&void 0!==s?s:[];return Object.keys(t).reduce(((r,s)=>(r[s]=o(s,e,t,n),r)),{})},o=(e,t,r,s)=>{const n=t.find((t=>t.name===e)),i=null==n?void 0:n.type,o=r[e];return i&&!s.includes(i)?a(i,o):h(o)},a=(e,t)=>{if("_"===e.charAt(0)){const r=e.slice(1,e.length);return d(t,r)}switch(e){case s.bool:return c(t);case s.float4:case s.float8:case s.int2:case s.int4:case s.int8:case s.numeric:case s.oid:return u(t);case s.json:case s.jsonb:return l(t);case s.timestamp:return f(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 h(t)}},h=e=>e,c=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},u=e=>{if("string"==typeof e){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},l=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(t){return console.log(`JSON parse error: ${t}`),e}return e},d=(e,t)=>{if("string"!=typeof e)return e;const r=e.length-1,s=e[r];if("{"===e[0]&&"}"===s){let s;const n=e.slice(1,r);try{s=JSON.parse("["+n+"]")}catch(e){s=n?n.split(","):[]}return s.map((e=>a(t,e)))}return e},f=e=>"string"==typeof e?e.replace(" ","T"):e;var p=r(840);const v={"X-Client-Info":"realtime-js/1.8.0-next.13"};var m,y,g,b,w;!function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"}(m||(m={})),function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"}(y||(y={})),function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"}(g||(g={})),function(e){e.websocket="websocket"}(b||(b={})),function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"}(w||(w={}));class _{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout((()=>{this.tries=this.tries+1,this.callback()}),this.timerCalc(this.tries+1))}}class k{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t("string"==typeof e?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const s=t.getUint8(1),n=t.getUint8(2);let i=this.HEADER_LENGTH+2;const o=r.decode(e.slice(i,i+s));i+=s;const a=r.decode(e.slice(i,i+n));return i+=n,{ref:null,topic:o,event:a,payload:JSON.parse(r.decode(e.slice(i,e.byteLength)))}}}class T{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.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref}))}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}}class E{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel.on(r.state,{},(e=>{const{onJoin:t,onLeave:r,onSync:s}=this.caller;this.joinRef=this.channel.joinRef(),this.state=E.syncState(this.state,e,t,r),this.pendingDiffs.forEach((e=>{this.state=E.syncDiff(this.state,e,t,r)})),this.pendingDiffs=[],s()})),this.channel.on(r.diff,{},(e=>{const{onJoin:t,onLeave:r,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=E.syncDiff(this.state,e,t,r),s())}))}static syncState(e,t,r,s){const n=this.cloneDeep(e),i=this.transformState(t),o={},a={};return this.map(n,((e,t)=>{i[e]||(a[e]=t)})),this.map(i,((e,t)=>{const r=n[e];if(r){const s=t.map((e=>e.presence_ref)),n=r.map((e=>e.presence_ref)),i=t.filter((e=>n.indexOf(e.presence_ref)<0)),h=r.filter((e=>s.indexOf(e.presence_ref)<0));i.length>0&&(o[e]=i),h.length>0&&(a[e]=h)}else o[e]=t})),this.syncDiff(n,{joins:o,leaves:a},r,s)}static syncDiff(e,t,r,s){const{joins:n,leaves:i}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(n,((t,s)=>{var n;const i=null!==(n=e[t])&&void 0!==n?n:[];if(e[t]=this.cloneDeep(s),i.length>0){const r=e[t].map((e=>e.presence_ref)),s=i.filter((e=>r.indexOf(e.presence_ref)<0));e[t].unshift(...s)}r(t,i,s)})),this.map(i,((t,r)=>{let n=e[t];if(!n)return;const i=r.map((e=>e.presence_ref));n=n.filter((e=>i.indexOf(e.presence_ref)<0)),e[t]=n,s(t,n,r),0===n.length&&delete e[t]})),e}static list(e,t){return t||(t=(e,t)=>t),this.map(e,((e,r)=>t(e,r)))}static map(e,t){return Object.getOwnPropertyNames(e).map((r=>t(r,e[r])))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce(((t,r)=>{const s=e[r];return t[r]="metas"in s?s.metas.map((e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))):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}list(e){return E.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}}class O{constructor(e,t={},r){this.topic=e,this.params=t,this.socket=r,this.bindings=[],this.state=y.closed,this.joinedOnce=!1,this.pushBuffer=[],this.params.configs=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.configs),this.timeout=this.socket.timeout,this.joinPush=new T(this,g.join,this.params,this.timeout),this.rejoinTimer=new _((()=>this.rejoinUntilConnected()),this.socket.reconnectAfterMs),this.joinPush.receive("ok",(()=>{this.state=y.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach((e=>e.send())),this.pushBuffer=[]})),this.onClose((()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=y.closed,this.socket.remove(this)})),this.onError((e=>{this.isLeaving()||this.isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=y.errored,this.rejoinTimer.scheduleTimeout())})),this.joinPush.receive("timeout",(()=>{this.isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=y.errored,this.rejoinTimer.scheduleTimeout())})),this.on(g.reply,{},((e,t)=>{this.trigger(this.replyEventName(t),e)})),this.presence=new E(this),this.presence.onJoin(((e,t,r)=>{this.trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:r})})),this.presence.onLeave(((e,t,r)=>{this.trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:r})})),this.presence.onSync((()=>{this.trigger("presence",{event:"sync"})}))}rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this.rejoin()}subscribe(e=this.timeout){if(this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{configs:{broadcast:t,presence:r}}=this.params,s={broadcast:t,presence:r,realtime:this.bindings.filter((e=>"realtime"===e.type)).map((e=>e.filter))};return this.updateJoinPayload({configs:s}),this.joinedOnce=!0,this.rejoin(e),this.joinPush}}onClose(e){this.on(g.close,{},e)}onError(e){this.on(g.error,{},(t=>e(t)))}on(e,t,r){return this.bindings.push({type:e,filter:null!=t?t:{},callback:null!=r?r:()=>{}}),this}off(e,t){return this.bindings=this.bindings.filter((r=>!(r.type===e&&O.isEqual(r.filter,t)))),this}canPush(){return this.socket.isConnected()&&this.isJoined()}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 T(this,e,t,r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=y.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this.trigger(g.close,"leave",this.joinRef())};this.joinPush.destroy();const r=new T(this,g.leave,{},e);return r.receive("ok",(()=>t())).receive("timeout",(()=>t())),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(e,t,r){return t}isMember(e){return this.topic===e}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=y.joining,this.joinPush.resend(e))}trigger(e,t,r){const{close:s,error:n,leave:i,join:o}=g;if(r&&[s,n,i,o].indexOf(e)>=0&&r!==this.joinRef())return;const a=this.onMessage(e,t,r);if(t&&!a)throw"channel onMessage callbacks must return the payload, modified or unmodified";this.bindings.filter((r=>{var s,n;return(null==r?void 0:r.type)===e&&("*"===(null===(s=null==r?void 0:r.filter)||void 0===s?void 0:s.event)||(null===(n=null==r?void 0:r.filter)||void 0===n?void 0:n.event)===(null==t?void 0:t.event))})).map((e=>e.callback(a,r)))}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===y.closed}isErrored(){return this.state===y.errored}isJoined(){return this.state===y.joined}isJoining(){return this.state===y.joining}isLeaving(){return this.state===y.leaving}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}}const x=()=>{};class S{constructor(e,t){this.accessToken=null,this.channels=[],this.endPoint="",this.headers=v,this.params={},this.timeout=1e4,this.transport=p.w3cwebsocket,this.heartbeatIntervalMs=3e4,this.longpollerTimeout=2e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=x,this.conn=null,this.sendBuffer=[],this.serializer=new k,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.endPoint=`${e}/${b.websocket}`,(null==t?void 0:t.params)&&(this.params=t.params),(null==t?void 0:t.headers)&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),(null==t?void 0:t.timeout)&&(this.timeout=t.timeout),(null==t?void 0:t.logger)&&(this.logger=t.logger),(null==t?void 0:t.transport)&&(this.transport=t.transport),(null==t?void 0:t.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs),(null==t?void 0:t.longpollerTimeout)&&(this.longpollerTimeout=t.longpollerTimeout),this.reconnectAfterMs=(null==t?void 0:t.reconnectAfterMs)?t.reconnectAfterMs:e=>[1e3,2e3,5e3,1e4][e-1]||1e4,this.encode=(null==t?void 0:t.encode)?t.encode:(e,t)=>t(JSON.stringify(e)),this.decode=(null==t?void 0:t.decode)?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new _((()=>{return e=this,t=void 0,s=function*(){yield this.disconnect(),this.connect()},new((r=void 0)||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}));var e,t,r,s}),this.reconnectAfterMs)}connect(){this.conn||(this.conn=new this.transport(this.endPointURL(),[],null,this.headers),this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e)))}disconnect(e,t){return new Promise(((r,s)=>{try{this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t||""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset()),r({error:null,data:!0})}catch(e){r({error:e,data:!1})}}))}log(e,t,r){this.logger(e,t,r)}onOpen(e){this.stateChangeCallbacks.open.push(e)}onClose(e){this.stateChangeCallbacks.close.push(e)}onError(e){this.stateChangeCallbacks.error.push(e)}onMessage(e){this.stateChangeCallbacks.message.push(e)}connectionState(){switch(this.conn&&this.conn.readyState){case m.connecting:return w.Connecting;case m.open:return w.Open;case m.closing:return w.Closing;default:return w.Closed}}isConnected(){return this.connectionState()===w.Open}remove(e){this.channels=this.channels.filter((t=>t.joinRef()!==e.joinRef()))}channel(e,t={}){const r=new O(e,t,this);return this.channels.push(r),r}push(e){const{topic:t,event:r,payload:s,ref:n}=e;let i=()=>{this.encode(e,(e=>{var t;null===(t=this.conn)||void 0===t||t.send(e)}))};this.log("push",`${t} ${r} (${n})`,s),this.isConnected()?i():this.sendBuffer.push(i)}onConnMessage(e){this.decode(e.data,(e=>{let{topic:t,event:r,payload:s,ref:n}=e;(n&&n===this.pendingHeartbeatRef||r===(null==s?void 0:s.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${s.status||""} ${t} ${r} ${n&&"("+n+")"||""}`,s),this.channels.filter((e=>e.isMember(t))).forEach((e=>e.trigger(r,s,n))),this.stateChangeCallbacks.message.forEach((t=>t(e)))}))}endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}setAuth(e){this.accessToken=e,this.channels.forEach((t=>{e&&t.updateJoinPayload({user_token:e}),t.joinedOnce&&t.isJoined()&&t.push(g.access_token,{access_token:e})}))}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())}_onConnOpen(){this.log("transport",`connected to ${this.endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval((()=>this._sendHeartbeat()),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach((e=>e()))}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach((t=>t(e)))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach((t=>t(e)))}_triggerChanError(){this.channels.forEach((e=>e.trigger(g.error)))}_appendParams(e,t){if(0===Object.keys(t).length)return e;const r=e.match(/\?/)?"&":"?";return`${e}${r}${new URLSearchParams(t)}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach((e=>e())),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef)return this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),void(null===(e=this.conn)||void 0===e||e.close(1e3,"hearbeat timeout"));this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}},752:(e,t,r)=>{"use strict";r.r(t),r.d(t,{StorageApiError:()=>i,StorageClient:()=>_,StorageError:()=>s,StorageUnknownError:()=>o,isStorageError:()=>n});class s extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function n(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class i extends s{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class o extends s{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var a=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const h=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>a(void 0,void 0,void 0,(function*(){return yield(yield Promise.resolve().then(r.t.bind(r,98,23))).fetch(...e)})):fetch),(...e)=>t(...e)};var c=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const u=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e);function l(e,t,s,n,h,l){return c(this,void 0,void 0,(function*(){return new Promise(((d,f)=>{e(s,((e,t,r,s)=>{const n={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?n:(n.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))})(t,n,h,l)).then((e=>{if(!e.ok)throw e;return(null==n?void 0:n.noResolveJson)?e:e.json()})).then((e=>d(e))).catch((e=>((e,t)=>c(void 0,void 0,void 0,(function*(){const s=yield a(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(r.t.bind(r,98,23))).Response:Response}));e instanceof s?e.json().then((r=>{t(new i(u(r),e.status||500))})):t(new o(u(e),e))})))(e,f)))}))}))}function d(e,t,r,s){return c(this,void 0,void 0,(function*(){return l(e,"GET",t,r,s)}))}function f(e,t,r,s,n){return c(this,void 0,void 0,(function*(){return l(e,"POST",t,s,n,r)}))}function p(e,t,r,s,n){return c(this,void 0,void 0,(function*(){return l(e,"DELETE",t,s,n,r)}))}var v=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const m={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},y={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class g{constructor(e,t={},r,s){this.url=e,this.headers=t,this.bucketId=r,this.fetch=h(s)}uploadOrUpdate(e,t,r,s){return v(this,void 0,void 0,(function*(){try{let n;const i=Object.assign(Object.assign({},y),s),o=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(i.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?(n=new FormData,n.append("cacheControl",i.cacheControl),n.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(n=r,n.append("cacheControl",i.cacheControl)):(n=r,o["cache-control"]=`max-age=${i.cacheControl}`,o["content-type"]=i.contentType);const a=this._removeEmptyFolders(t),h=this._getFinalPath(a),c=yield this.fetch(`${this.url}/object/${h}`,{method:e,body:n,headers:o});return c.ok?{data:{path:a},error:null}:{data:null,error:yield c.json()}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}upload(e,t,r){return v(this,void 0,void 0,(function*(){return this.uploadOrUpdate("POST",e,t,r)}))}update(e,t,r){return v(this,void 0,void 0,(function*(){return this.uploadOrUpdate("PUT",e,t,r)}))}move(e,t){return v(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}copy(e,t){return v(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}createSignedUrl(e,t){return v(this,void 0,void 0,(function*(){try{const r=this._getFinalPath(e);let s=yield f(this.fetch,`${this.url}/object/sign/${r}`,{expiresIn:t},{headers:this.headers});return s={signedUrl:encodeURI(`${this.url}${s.signedURL}`)},{data:s,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}createSignedUrls(e,t){return v(this,void 0,void 0,(function*(){try{return{data:(yield f(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers})).map((e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}`):null}))),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}download(e){return v(this,void 0,void 0,(function*(){try{const t=this._getFinalPath(e),r=yield d(this.fetch,`${this.url}/object/${t}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}getPublicUrl(e){const t=this._getFinalPath(e);return{data:{publicUrl:encodeURI(`${this.url}/object/public/${t}`)}}}remove(e){return v(this,void 0,void 0,(function*(){try{return{data:yield p(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}list(e,t,r){return v(this,void 0,void 0,(function*(){try{const s=Object.assign(Object.assign(Object.assign({},m),t),{prefix:e||""});return{data:yield f(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}}const b={"X-Client-Info":"storage-js/1.8.0-next.5"};var w=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};class _ extends class{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},b),t),this.fetch=h(r)}listBuckets(){return w(this,void 0,void 0,(function*(){try{return{data:yield d(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}getBucket(e){return w(this,void 0,void 0,(function*(){try{return{data:yield d(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}createBucket(e,t={public:!1}){return w(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}updateBucket(e,t){return w(this,void 0,void 0,(function*(){try{const r=yield function(e,t,r,s,n){return c(this,void 0,void 0,(function*(){return l(e,"PUT",t,s,undefined,r)}))}(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public},{headers:this.headers});return{data:r,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}emptyBucket(e){return w(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}deleteBucket(e){return w(this,void 0,void 0,(function*(){try{return{data:yield p(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}}{constructor(e,t={},r){super(e,t,r)}from(e){return new g(this.url,this.headers,e,this.fetch)}}},98:function(e,t){var r="undefined"!=typeof self?self:this,s=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r="URLSearchParams"in e,s="Symbol"in e&&"iterator"in Symbol,n="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return s&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function m(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:n&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&n&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=m(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||h(e))?this._bodyArrayBuffer=m(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,r,s=f(this);if(s)return s;if(this._bodyBlob)return e=this._bodyBlob,r=p(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),s=0;s<t.length;s++)r[s]=String.fromCharCode(t[s]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=c(e),t=u(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[c(e)]},d.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},d.prototype.set=function(e,t){this.map[c(e)]=u(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),l(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),l(e)},s&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(e,t){var r,s,n=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(s=(r=t.method||this.method||"GET").toUpperCase(),g.indexOf(s)>-1?s:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),s=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(s),decodeURIComponent(n))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},y.call(b.prototype),y.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var k=[301,302,303,307,308];_.redirect=function(e,t){if(-1===k.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function T(e,r){return new Promise((function(s,i){var o=new b(e,r);if(o.signal&&o.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),s=r.shift().trim();if(s){var n=r.join(":").trim();t.append(s,n)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;s(new _(n,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&n&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",h)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}T.polyfill=!0,e.fetch||(e.fetch=T,e.Headers=d,e.Request=b,e.Response=_),t.Headers=d,t.Request=b,t.Response=_,t.fetch=T,Object.defineProperty(t,"__esModule",{value:!0})}({})}(s),s.fetch.ponyfill=!0,delete s.fetch.polyfill;var n=s;(t=n.fetch).default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,e.exports=t},284:e=>{var t=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};e.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return t()}try{return __global__||t()}finally{delete Object.prototype.__global__}}()},296:function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=r(982),i=r(189),o=r(73),a=r(752),h=r(678),c=r(716),u=r(610),l=r(283),d=r(548),f={headers:h.DEFAULT_HEADERS},p={schema:"public"},v={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0},m={};t.default=class{constructor(e,t,r){var s,n,o,a,h,l,d,y;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const g=(0,u.stripTrailingSlash)(e);if(this.realtimeUrl=`${g}/realtime/v1`.replace("http","ws"),this.authUrl=`${g}/auth/v1`,this.storageUrl=`${g}/storage/v1`,g.match(/(supabase\.co)|(supabase\.in)/)){const e=g.split(".");this.functionsUrl=`${e[0]}.functions.${e[1]}.${e[2]}`}else this.functionsUrl=`${g}/functions/v1`;const b=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,w={db:p,realtime:m,auth:Object.assign(Object.assign({},v),{storageKey:b}),global:f},_=(0,u.applySettingDefaults)(null!=r?r:{},w);this.storageKey=null!==(n=null===(s=_.auth)||void 0===s?void 0:s.storageKey)&&void 0!==n?n:"",this.headers=null!==(a=null===(o=_.global)||void 0===o?void 0:o.headers)&&void 0!==a?a:{},this.auth=this._initSupabaseAuthClient(null!==(h=_.auth)&&void 0!==h?h:{},this.headers,null===(l=_.global)||void 0===l?void 0:l.fetch),this.fetch=(0,c.fetchWithAuth)(t,this._getAccessToken.bind(this),null===(d=_.global)||void 0===d?void 0:d.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},_.realtime)),this.rest=new i.PostgrestClient(`${g}/rest/v1`,{headers:this.headers,schema:null===(y=_.db)||void 0===y?void 0:y.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new n.FunctionsClient(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new a.StorageClient(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}rpc(e,t={},r){return this.rest.rpc(e,t,r)}channel(e,t){return this.realtime.isConnected()||this.realtime.connect(),new d.SupabaseRealtimeChannel(e,t,this.realtime)}removeAllChannels(){return s(this,void 0,void 0,(function*(){const e=this.getChannels().slice(),t=e.map((e=>this.removeChannel(e)));return(yield Promise.all(t)).map((({error:t},r)=>({data:{channels:e[r]},error:t})))}))}removeChannel(e){return s(this,void 0,void 0,(function*(){const{error:t}=yield this._closeChannel(e),r=this.getChannels(),s=r.filter((e=>e.isJoined())).length;return 0===r.length&&(yield this.realtime.disconnect()),{data:{openChannels:s},error:t}}))}_getAccessToken(){var e;return s(this,void 0,void 0,(function*(){const{session:t}=yield this.auth.getSession();return null!==(e=null==t?void 0:t.access_token)&&void 0!==e?e:null}))}_closeChannel(e){return s(this,void 0,void 0,(function*(){let t=null;if(!e.isClosed()){const{error:r}=yield this._unsubscribeChannel(e);t=r}return this.realtime.remove(e),{error:t}}))}_unsubscribeChannel(e){return new Promise((t=>{e.unsubscribe().receive("ok",(()=>t({error:null}))).receive("error",(e=>t({error:e}))).receive("timeout",(()=>t({error:new Error("timed out")})))}))}getChannels(){return this.realtime.channels}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,cookieOptions:n,storageKey:i},o,a){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new l.SupabaseAuthClient({url:this.authUrl,headers:Object.assign(Object.assign({},o),h),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,fetch:a,cookieOptions:n})}_initRealtimeClient(e){return new o.RealtimeClient(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey,vsndate:"2022"},null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange(((e,t)=>{this._handleTokenChanged(e,null==t?void 0:t.access_token,"CLIENT")}))}_handleTokenChanged(e,t,r){"TOKEN_REFRESHED"!==e&&"SIGNED_IN"!==e||this.changedAccessToken===t?"SIGNED_OUT"!==e&&"USER_DELETED"!==e||(this.realtime.setAuth(this.supabaseKey),"STORAGE"==r&&this.auth.signOut()):(this.realtime.setAuth(t),this.changedAccessToken=t)}}},341:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||s(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createClient=t.SupabaseClient=void 0;const o=i(r(296));n(r(111),t),n(r(73),t);var a=r(296);Object.defineProperty(t,"SupabaseClient",{enumerable:!0,get:function(){return i(a).default}}),t.createClient=(e,t,r)=>new o.default(e,t,r)},283:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SupabaseAuthClient=void 0;const s=r(111);class n extends s.GoTrueClient{constructor(e){super(e)}}t.SupabaseAuthClient=n},548:function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.SupabaseRealtimeChannel=void 0;const n=r(73);t.SupabaseRealtimeChannel=class{constructor(e,t={},r){this.socket=r,this.channel=r.channel(`realtime:${e}`,t)}on(e,t,r){return this.channel.on(e,null!=t?t:{},(({payload:t})=>{let s=t;if("realtime"===e){const{schema:e,table:r,commit_timestamp:n,type:i,errors:o}=s;s={schema:e,table:r,commit_timestamp:n,eventType:i,new:{},old:{},errors:o},s=Object.assign(Object.assign({},s),this.getPayloadRecords(t))}r&&r(s)})),this}subscribe(e=(()=>{})){return this.socket.accessToken&&this.channel.updateJoinPayload({user_token:this.socket.accessToken}),this.channel.onError((t=>e("CHANNEL_ERROR",t))),this.channel.onClose((()=>e("CLOSED"))),this.channel.subscribe().receive("ok",(()=>{e("SUBSCRIBED"),this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken)})).receive("error",(t=>e("CHANNEL_ERROR",t))).receive("timeout",(()=>e("RETRYING_AFTER_TIMEOUT"))),this.channel}presenceList(){return this.channel.presence.list()}send(e,t={}){return new Promise((r=>{const s=performance.now(),n=t.timeout||this.channel.timeout;this.channel.push(e.type,e,n).receive("ok",(()=>{const e=performance.now()-s;r(["ok",e])})).receive("timeout",(()=>{r(["timeout",n])}))}))}track(e,t={}){return s(this,void 0,void 0,(function*(){return yield this.send({type:"presence",event:"track",payload:e},t)}))}untrack(e={}){return s(this,void 0,void 0,(function*(){return yield this.send({type:"presence",event:"untrack"},e)}))}getPayloadRecords(e){const t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=n.Transformers.convertChangeData(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=n.Transformers.convertChangeData(e.columns,e.old_record)),t}}},678:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_HEADERS=void 0;const s=r(506);t.DEFAULT_HEADERS={"X-Client-Info":`supabase-js/${s.version}`}},716:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},o=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchWithAuth=t.resolveHeadersConstructor=t.resolveFetch=void 0;const a=i(r(98));t.resolveFetch=e=>{let t;return t=e||("undefined"==typeof fetch?a.default:fetch),(...e)=>t(...e)},t.resolveHeadersConstructor=()=>"undefined"==typeof Headers?a.Headers:Headers,t.fetchWithAuth=(e,r,s)=>{const n=(0,t.resolveFetch)(s),i=(0,t.resolveHeadersConstructor)();return(t,s)=>o(void 0,void 0,void 0,(function*(){var o;const a=null!==(o=yield r())&&void 0!==o?o:e;let h=new i(null==s?void 0:s.headers);return h.has("apikey")||h.set("apikey",e),h.has("Authorization")||h.set("Authorization",`Bearer ${a}`),n(t,Object.assign(Object.assign({},s),{headers:h}))}))}},610:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applySettingDefaults=t.isBrowser=t.stripTrailingSlash=t.uuid=void 0,t.uuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.isBrowser=()=>"undefined"!=typeof window,t.applySettingDefaults=function(e,t){const{db:r,auth:s,realtime:n,global:i}=e,{db:o,auth:a,realtime:h,global:c}=t;return{db:Object.assign(Object.assign({},o),r),auth:Object.assign(Object.assign({},a),s),realtime:Object.assign(Object.assign({},h),n),global:Object.assign(Object.assign({},c),i)}}},506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="1.36.0-next.21"},840:(e,t,r)=>{var s;if("object"==typeof globalThis)s=globalThis;else try{s=r(284)}catch(e){}finally{if(s||"undefined"==typeof window||(s=window),!s)throw new Error("Could not determine global this")}var n=s.WebSocket||s.MozWebSocket,i=r(387);function o(e,t){return t?new n(e,t):new n(e)}n&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(o,e,{get:function(){return n[e]}})})),e.exports={w3cwebsocket:n?o:null,version:i}},387:(e,t,r)=>{e.exports=r(794).version},794:e=>{"use strict";e.exports={version:"1.0.34"}}},s={};function n(e){var t=s[e];if(void 0!==t)return t.exports;var i=s[e]={exports:{}};return r[e].call(i.exports,i,i.exports,n),i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(r,s){if(1&s&&(r=this(r)),8&s)return r;if("object"==typeof r&&r){if(4&s&&r.__esModule)return r;if(16&s&&"function"==typeof r.then)return r}var i=Object.create(null);n.r(i);var o={};e=e||[null,t({}),t([]),t(t)];for(var a=2&s&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>o[e]=()=>r[e]));return o.default=()=>r,n.d(i,o),i},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(341)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.supabase=t():e.supabase=t()}(self,(()=>(()=>{var e,t,r={982:(e,t,r)=>{"use strict";r.r(t),r.d(t,{FunctionsClient:()=>a,FunctionsError:()=>s,FunctionsFetchError:()=>n,FunctionsHttpError:()=>o,FunctionsRelayError:()=>i});class s extends Error{constructor(e,t="FunctionsError",r){super(e),super.name=t,this.context=r}}class n extends s{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class i extends s{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class o extends s{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}class a{constructor(e,{headers:t={},customFetch:s}={}){this.url=e,this.headers=t,this.fetch=(e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>{return t=void 0,s=void 0,i=function*(){return yield(yield Promise.resolve().then(r.t.bind(r,98,23))).fetch(...e)},new((n=void 0)||(n=Promise))((function(e,r){function o(e){try{h(i.next(e))}catch(e){r(e)}}function a(e){try{h(i.throw(e))}catch(e){r(e)}}function h(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,a)}h((i=i.apply(t,s||[])).next())}));var t,s,n,i}:fetch),(...e)=>t(...e)})(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r,s,a,h,c;return s=this,a=void 0,c=function*(){try{const{headers:s,body:a}=t;let h,c={};a&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&("undefined"!=typeof Blob&&a instanceof Blob||a instanceof ArrayBuffer?(c["Content-Type"]="application/octet-stream",h=a):"string"==typeof a?(c["Content-Type"]="text/plain",h=a):"undefined"!=typeof FormData&&a instanceof FormData?h=a:(c["Content-Type"]="application/json",h=JSON.stringify(a)));const l=yield this.fetch(`${this.url}/${e}`,{method:"POST",headers:Object.assign(Object.assign(Object.assign({},c),this.headers),s),body:h}).catch((e=>{throw new n(e)})),u=l.headers.get("x-relay-error");if(u&&"true"===u)throw new i(l);if(!l.ok)throw new o(l);let d,f=(null!==(r=l.headers.get("Content-Type"))&&void 0!==r?r:"text/plain").split(";")[0].trim();return d="application/json"===f?yield l.json():"application/octet-stream"===f?yield l.blob():"multipart/form-data"===f?yield l.formData():yield l.text(),{data:d,error:null}}catch(e){return{data:null,error:e}}},new((h=void 0)||(h=Promise))((function(e,t){function r(e){try{i(c.next(e))}catch(e){t(e)}}function n(e){try{i(c.throw(e))}catch(e){t(e)}}function i(t){var s;t.done?e(t.value):(s=t.value,s instanceof h?s:new h((function(e){e(s)}))).then(r,n)}i((c=c.apply(s,a||[])).next())}))}}},268:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AuthApiError:()=>u,AuthError:()=>c,AuthInvalidCredentialsError:()=>v,AuthRetryableFetchError:()=>y,AuthSessionMissingError:()=>p,AuthUnknownError:()=>d,CustomAuthError:()=>f,GoTrueAdminApi:()=>E,GoTrueClient:()=>O,isAuthError:()=>l});var s=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const n=()=>"undefined"!=typeof window;function i(e,t){var r;t||(t=(null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.href)||""),e=e.replace(/[\[\]]/g,"\\$&");const s=new RegExp("[?&#]"+e+"(=([^&#]*)|&|#|$)").exec(t);return s?s[2]?decodeURIComponent(s[2].replace(/\+/g," ")):"":null}const o=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>s(void 0,void 0,void 0,(function*(){return yield(yield Promise.resolve().then(r.t.bind(r,98,23))).fetch(...e)})):fetch),(...e)=>t(...e)},a=(e,t)=>s(void 0,void 0,void 0,(function*(){const r=n()&&(yield null==e?void 0:e.getItem(t));if(!r)return null;try{return JSON.parse(r)}catch(e){return r}}));class h{constructor(){this.promise=new h.promiseConstructor(((e,t)=>{this.resolve=e,this.reject=t}))}}h.promiseConstructor=Promise;class c extends Error{constructor(e){super(e),this.__isAuthError=!0,this.name="AuthError"}}function l(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class u extends c{constructor(e,t){super(e),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class d extends c{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class f extends c{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class p extends f{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class v extends f{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class y extends f{constructor(e,t){super(e,"AuthRetryableFetchError",t)}}var m=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const g=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e);function b(e,t,n,i){var o,a;return m(this,void 0,void 0,(function*(){const h=null!==(o=null==i?void 0:i.headers)&&void 0!==o?o:{};(null==i?void 0:i.jwt)&&(h.Authorization=`Bearer ${i.jwt}`);const c=null!==(a=null==i?void 0:i.query)&&void 0!==a?a:{};(null==i?void 0:i.redirectTo)&&(c.redirect_to=i.redirectTo);const l=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",f=yield function(e,t,n,i,o,a){return m(this,void 0,void 0,(function*(){return new Promise(((h,c)=>{e(n,((e,t,r,s)=>{const n={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?n:(n.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))})(t,i,o,a)).then((e=>{if(!e.ok)throw e;return(null==i?void 0:i.noResolveJson)?e:e.json()})).then((e=>h(e))).catch((e=>((e,t)=>m(void 0,void 0,void 0,(function*(){const n=yield s(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(r.t.bind(r,98,23))).Response:Response}));e instanceof n?e.status>=500&&e.status<=599?t(new y(g(e),e.status)):e.json().then((r=>{t(new u(g(r),e.status||500))})).catch((e=>{t(new d(g(e),e))})):t(new y(g(e),0))})))(e,c)))}))}))}(e,t,n+l,{headers:h,noResolveJson:null==i?void 0:i.noResolveJson},{},null==i?void 0:i.body);return(null==i?void 0:i.xform)?null==i?void 0:i.xform(f):{data:Object.assign({},f),error:null}}))}function w(e){var t;let r=null;var s;return function(e){return e.access_token&&e.refresh_token&&e.expires_in}(e)&&(r=Object.assign({},e),r.expires_at=(s=e.expires_in,Math.round(Date.now()/1e3)+s)),{data:{session:r,user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function _(e){var t;return{data:{user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}var T=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};class E{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=o(r)}signOut(e){return T(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"POST",`${this.url}/logout`,{jwt:e,noResolveJson:!0}),{error:null}}catch(e){if(l(e))return{error:e};throw e}}))}inviteUserByEmail(e,t={}){return T(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:_})}catch(e){if(l(e))return{data:{user:null},error:e};throw e}}))}generateLink(e,t,r={}){return T(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:{type:e,email:t,password:r.password,data:r.data,redirect_to:r.redirectTo},headers:this.headers})}catch(e){if(l(e))return{data:null,error:e};throw e}}))}createUser(e){return T(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:_})}catch(e){if(l(e))return{data:{user:null},error:e};throw e}}))}listUsers(){return T(this,void 0,void 0,(function*(){try{const{data:e,error:t}=yield b(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers});if(t)throw t;return{data:Object.assign({},e),error:null}}catch(e){if(l(e))return{data:{users:[]},error:e};throw e}}))}getUserById(e){return T(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:_})}catch(e){if(l(e))return{data:{user:null},error:e};throw e}}))}updateUserById(e,t){return T(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:_})}catch(e){if(l(e))return{data:{user:null},error:e};throw e}}))}deleteUser(e){return T(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:_})}catch(e){if(l(e))return{data:{user:null},error:e};throw e}}))}}var j=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};!function(){if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!=typeof self&&(self.globalThis=self)}}();const x={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,multiTab:!0,headers:{"X-Client-Info":"gotrue-js/1.23.0-next.20"}};class O{constructor(e){this.stateChangeEmitters=new Map,this.networkRetries=0,this.refreshingDeferred=null;const t=Object.assign(Object.assign({},x),e);this.inMemorySession=null,this.storageKey=t.storageKey,this.autoRefreshToken=t.autoRefreshToken,this.persistSession=t.persistSession,this.storage=t.storage||globalThis.localStorage,this.admin=new E({url:t.url,headers:t.headers,fetch:t.fetch}),this._recoverAndRefresh(),this._handleVisibilityChange(),this.url=t.url,this.headers=t.headers,this.fetch=o(t.fetch),t.detectSessionInUrl&&n()&&i("access_token")&&this._getSessionFromUrl().then((({error:e})=>{if(e)throw new d("Error getting session from URL.",e)}))}signUp({email:e,password:t,phone:r},s={}){return j(this,void 0,void 0,(function*(){try{this._removeSession();const{data:n,error:i}=r&&t?yield b(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:s.redirectTo,body:{phone:r,password:t,data:s.data,gotrue_meta_security:{captcha_token:s.captchaToken}},xform:w}):yield b(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:s.redirectTo,body:{email:e,password:t,data:s.data,gotrue_meta_security:{captcha_token:s.captchaToken}},xform:w});if(i)throw i;if(!n)throw"An error occurred on sign up.";const o=n.session,a=n.user;return n.session&&(this._saveSession(n.session),this._notifyAllSubscribers("SIGNED_IN",o)),{data:{user:a,session:o},error:null}}catch(e){if(l(e))return{data:{user:null,session:null},error:e};throw e}}))}signInWithPassword(e){return j(this,void 0,void 0,(function*(){try{if(this._removeSession(),"email"in e){const{email:t,password:r,options:s}=e;return yield b(this.fetch,"POST",`${this.url}/token?grant_type=password`,{body:{email:t,password:r,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}},xform:w})}if("phone"in e){const{phone:t,password:r,options:s}=e;return yield b(this.fetch,"POST",`${this.url}/token?grant_type=password`,{body:{phone:t,password:r,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}},xform:w})}throw new v("You must provide either an email or phone number and a password.")}catch(e){if(l(e))return{data:{user:null,session:null},error:e};throw e}}))}signInWithOAuth(e){var t,r,s;return j(this,void 0,void 0,(function*(){return this._removeSession(),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})}))}signInWithOtp(e){var t,r;return j(this,void 0,void 0,(function*(){try{if(this._removeSession(),"email"in e){const{email:r,options:s}=e,{error:n}=yield b(this.fetch,"POST",`${this.url}/otp`,{body:{email:r,create_user:null===(t=null==s?void 0:s.shouldCreateUser)||void 0===t||t,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}},redirectTo:null==s?void 0:s.emailRedirectTo,headers:this.headers});return{data:{user:null,session:null},error:n}}if("phone"in e){const{phone:t,options:s}=e,{error:n}=yield b(this.fetch,"POST",`${this.url}/otp`,{body:{phone:t,create_user:null===(r=null==s?void 0:s.shouldCreateUser)||void 0===r||r,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}}});return{data:{user:null,session:null},error:n}}throw new v("You must provide either an email or phone number.")}catch(e){if(l(e))return{data:{user:null,session:null},error:e};throw e}}))}verifyOTP(e,t={}){return j(this,void 0,void 0,(function*(){try{this._removeSession();const{data:r,error:s}=yield b(this.fetch,"POST",`${this.url}/verify`,{body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captchaToken:null==t?void 0:t.captchaToken}}),redirectTo:t.redirectTo,xform:w});if(s)throw s;if(!r)throw"An error occurred on token verification.";const n=r.session,i=r.user;return r.access_token&&(this._saveSession(n),this._notifyAllSubscribers("SIGNED_IN",n)),{data:{user:i,session:n},error:null}}catch(e){if(l(e))return{data:{user:null,session:null},error:e};throw e}}))}getSession(){return j(this,void 0,void 0,(function*(){let e=null;if(this.persistSession){const t=yield a(this.storage,this.storageKey);this._doesSessionExist(t)?e=t:yield this._removeSession()}else e=this.inMemorySession;if(!e)return{session:null,error:null};if(!(e.expires_at&&e.expires_at<=Date.now()/1e3))return{session:e,error:null};const{session:t,error:r}=yield this._callRefreshToken(e.refresh_token);return r?{session:null,error:r}:{session:t,error:null}}))}getUser(){return j(this,void 0,void 0,(function*(){try{let e="";if(!("Authorization"in this.headers)){const{session:t,error:r}=yield this.getSession();if(r)throw r;if(!t)throw new p;e=t.access_token}return yield b(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:_})}catch(e){if(l(e))return{data:{user:null},error:e};throw e}}))}updateUser(e){return j(this,void 0,void 0,(function*(){try{const{session:t,error:r}=yield this.getSession();if(r)throw r;if(!t)throw new p;const{data:s,error:n}=yield b(this.fetch,"PUT",`${this.url}/user`,{body:e,jwt:t.access_token,xform:_});if(n)throw n;return t.user=s.user,this._saveSession(t),this._notifyAllSubscribers("USER_UPDATED",t),{data:{user:t.user},error:null}}catch(e){if(l(e))return{data:{user:null},error:e};throw e}}))}setSession(e){return j(this,void 0,void 0,(function*(){try{if(!e)throw new p;const{data:t,error:r}=yield this._refreshAccessToken(e);return r?{data:{session:null,user:null},error:r}:(this._saveSession(t.session),this._notifyAllSubscribers("TOKEN_REFRESHED",t.session),{data:t,error:null})}catch(e){if(l(e))return{data:{session:null,user:null},error:e};throw e}}))}_getSessionFromUrl(){return j(this,void 0,void 0,(function*(){try{if(!n())throw new u("No browser detected.",500);const e=i("error_description");if(e)throw new u(e,500);const t=i("provider_token"),r=i("access_token");if(!r)throw new u("No access_token detected.",500);const s=i("expires_in");if(!s)throw new u("No expires_in detected.",500);const o=i("refresh_token");if(!o)throw new u("No refresh_token detected.",500);const a=i("token_type");if(!a)throw new u("No token_type detected.",500);const h=Math.round(Date.now()/1e3)+parseInt(s),{data:c,error:l}=yield this.getUser();if(l)throw l;const d=c.user,f={provider_token:t,access_token:r,expires_in:parseInt(s),expires_at:h,refresh_token:o,token_type:a,user:d};this._saveSession(f);const p=i("type");return this._notifyAllSubscribers("SIGNED_IN",f),"recovery"===p&&this._notifyAllSubscribers("PASSWORD_RECOVERY",f),window.location.hash="",{session:f,error:null}}catch(e){if(l(e))return{session:null,error:e};throw e}}))}signOut(){return j(this,void 0,void 0,(function*(){const{session:e,error:t}=yield this.getSession();if(t)return{error:t};const r=null==e?void 0:e.access_token;if(r){const{error:e}=yield this.admin.signOut(r);if(e)return{error:e}}return this._removeSession(),this._notifyAllSubscribers("SIGNED_OUT",null),{error:null}}))}onAuthStateChange(e){try{const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})),r={id:t,callback:e,unsubscribe:()=>{this.stateChangeEmitters.delete(t)}};return this.stateChangeEmitters.set(t,r),{subscription:r,error:null}}catch(e){if(l(e))return{subscription:null,error:e};throw e}}resetPasswordForEmail(e,t={}){return j(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(l(e))return{data:null,error:e};throw e}}))}_refreshAccessToken(e){return j(this,void 0,void 0,(function*(){try{return yield b(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:w})}catch(e){if(l(e))return{data:{session:null,user:null},error:e};throw e}}))}_doesSessionExist(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}_handleProviderSignIn(e,t={}){const r=this._getUrlForProvider(e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return n()&&(window.location.href=r),{data:{provider:e,url:r},error:null}}_recoverAndRefresh(){var e;return j(this,void 0,void 0,(function*(){try{const t=yield a(this.storage,this.storageKey);if(!this._doesSessionExist(t))return yield this._removeSession(),null;const r=Math.round(Date.now()/1e3);if((null!==(e=t.expires_at)&&void 0!==e?e:1/0)<r+10)if(this.autoRefreshToken&&t.refresh_token){this.networkRetries++;const{error:e}=yield this._callRefreshToken(t.refresh_token);if(e){if(console.log(e.message),e instanceof y&&this.networkRetries<10)return this.refreshTokenTimer&&clearTimeout(this.refreshTokenTimer),void(this.refreshTokenTimer=setTimeout((()=>this._recoverAndRefresh()),100*Math.pow(2,this.networkRetries)));yield this._removeSession()}this.networkRetries=0}else this._removeSession();else this.persistSession&&this._saveSession(t),this._notifyAllSubscribers("SIGNED_IN",t)}catch(e){return console.error(e),null}}))}_callRefreshToken(e){var t,r;return j(this,void 0,void 0,(function*(){if(this.refreshingDeferred)return this.refreshingDeferred.promise;try{if(this.refreshingDeferred=new h,!e)throw new p;const{data:t,error:r}=yield this._refreshAccessToken(e);if(r)throw r;if(!t.session)throw new p;this._saveSession(t.session),this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);const s={session:t.session,error:null};return this.refreshingDeferred.resolve(s),s}catch(e){if(l(e)){const r={session:null,error:e};return null===(t=this.refreshingDeferred)||void 0===t||t.resolve(r),r}throw null===(r=this.refreshingDeferred)||void 0===r||r.reject(e),e}finally{this.refreshingDeferred=null}}))}_notifyAllSubscribers(e,t){this.stateChangeEmitters.forEach((r=>r.callback(e,t)))}_saveSession(e){this.persistSession||(this.inMemorySession=e);const t=e.expires_at;if(t){const r=t-Math.round(Date.now()/1e3),s=r>10?10:.5;this._startAutoRefreshToken(1e3*(r-s),e)}this.persistSession&&e.expires_at&&this._persistSession(e)}_persistSession(e){var t,r,i;t=this.storage,r=this.storageKey,i=e,s(void 0,void 0,void 0,(function*(){n()&&(yield null==t?void 0:t.setItem(r,JSON.stringify(i)))}))}_removeSession(){return j(this,void 0,void 0,(function*(){var e,t;this.persistSession?(e=this.storage,t=this.storageKey,s(void 0,void 0,void 0,(function*(){n()&&(yield null==e?void 0:e.removeItem(t))}))):this.inMemorySession=null,this.refreshTokenTimer&&clearTimeout(this.refreshTokenTimer)}))}_startAutoRefreshToken(e,t){this.refreshTokenTimer&&clearTimeout(this.refreshTokenTimer),e<=0||!this.autoRefreshToken||(this.refreshTokenTimer=setTimeout((()=>j(this,void 0,void 0,(function*(){this.networkRetries++;const{error:e}=yield this._callRefreshToken(t.refresh_token);e||(this.networkRetries=0),e instanceof y&&this.networkRetries<10&&this._startAutoRefreshToken(100*Math.pow(2,this.networkRetries),t)}))),e),"function"==typeof this.refreshTokenTimer.unref&&this.refreshTokenTimer.unref())}_handleVisibilityChange(){if(!n()||!(null===window||void 0===window?void 0:window.addEventListener))return!1;try{null===window||void 0===window||window.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this._recoverAndRefresh()}))}catch(e){console.error("_handleVisibilityChange",e)}}_getUrlForProvider(e,t){const r=[`provider=${encodeURIComponent(e)}`];if((null==t?void 0:t.redirectTo)&&r.push(`redirect_to=${encodeURIComponent(t.redirectTo)}`),(null==t?void 0:t.scopes)&&r.push(`scopes=${encodeURIComponent(t.scopes)}`),null==t?void 0:t.queryParams){const e=new URLSearchParams(t.queryParams);r.push(e.toString())}return`${this.url}/authorize?${r.join("&")}`}}},189:(e,t,r)=>{"use strict";r.r(t),r.d(t,{PostgrestBuilder:()=>i,PostgrestClient:()=>l,PostgrestFilterBuilder:()=>a,PostgrestQueryBuilder:()=>h,PostgrestTransformBuilder:()=>o});var s=r(98),n=r.n(s);class i{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.allowEmpty=e.allowEmpty,e.fetch?this.fetch=e.fetch:"undefined"==typeof fetch?this.fetch=n():this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),"GET"!==this.method&&"HEAD"!==this.method&&(this.headers["Content-Type"]="application/json");let r=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then((e=>{return t=this,r=void 0,n=function*(){var t,r,s,n;let i,o,a,h=e.status,c=e.statusText;if(e.ok){const n=null===(t=this.headers.Prefer)||void 0===t?void 0:t.split(",").includes("return=minimal");if("HEAD"!==this.method&&!n){const t=yield e.text();t&&(o="text/csv"===this.headers.Accept?t:JSON.parse(t))}const i=null===(r=this.headers.Prefer)||void 0===r?void 0:r.match(/count=(exact|planned|estimated)/),h=null===(s=e.headers.get("content-range"))||void 0===s?void 0:s.split("/");i&&h&&h.length>1&&(a=parseInt(h[1]))}else{const t=yield e.text();try{i=JSON.parse(t)}catch(e){i={message:t}}if(i&&this.allowEmpty&&(null===(n=null==i?void 0:i.details)||void 0===n?void 0:n.includes("Results contain 0 rows"))&&(i=void 0,h=200,c="OK"),i&&this.shouldThrowOnError)throw i}return{error:i,data:o,count:a,status:h,statusText:c}},new((s=void 0)||(s=Promise))((function(e,i){function o(e){try{h(n.next(e))}catch(e){i(e)}}function a(e){try{h(n.throw(e))}catch(e){i(e)}}function h(t){var r;t.done?e(t.value):(r=t.value,r instanceof s?r:new s((function(e){e(r)}))).then(o,a)}h((n=n.apply(t,r||[])).next())}));var t,r,s,n}));return this.shouldThrowOnError||(r=r.catch((e=>({error:{message:`FetchError: ${e.message}`,details:"",hint:"",code:e.code||""},data:void 0,count:void 0,status:400,statusText:"Bad Request"})))),r.then(e,t)}}class o extends i{select(e){let t=!1;const r=(null!=e?e:"*").split("").map((e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e))).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s}={}){const n=s?`${s}.order`:"order",i=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${i?`${i},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t}={}){const r=void 0===t?"limit":`${t}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:r}={}){const s=void 0===r?"offset":`${r}.offset`,n=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this.url.searchParams.set(n,""+(t-e+1)),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.headers.Accept="application/vnd.pgrst.object+json",this.allowEmpty=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:n=!1}={}){const i=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),o=this.headers.Accept;return this.headers.Accept=`application/vnd.pgrst.plan+json; for="${o}"; options=${i};`,this}}class a extends o{not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t}={}){const r=t?`${t}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}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}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=t.map((e=>"string"==typeof e&&new RegExp("[,()]").test(e)?`"${e}"`:`${e}`)).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${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}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 n="";"plain"===s?n="pl":"phrase"===s?n="ph":"websearch"===s&&(n="w");const i=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${n}fts${i}.${t}`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}match(e){return Object.entries(e).forEach((([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)})),this}}class h{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=t,this.schema=r,this.fetch=s}select(e,{head:t=!1,count:r}={}){const s=t?"HEAD":"GET";let n=!1;const i=(null!=e?e:"*").split("").map((e=>/\s/.test(e)&&!n?"":('"'===e&&(n=!n),e))).join("");return this.url.searchParams.set("select",i),r&&(this.headers.Prefer=`count=${r}`),new a({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,rollback:r=!1}={}){const s=[],n=e;if(t&&s.push(`count=${t}`),r&&s.push("tx=rollback"),this.headers.Prefer&&s.unshift(this.headers.Prefer),this.headers.Prefer=s.join(","),Array.isArray(e)){const t=e.reduce(((e,t)=>e.concat(Object.keys(t))),[]);if(t.length>0){const e=[...new Set(t)].map((e=>`"${e}"`));this.url.searchParams.set("columns",e.join(","))}}return new a({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,count:r,ignoreDuplicates:s=!1,rollback:n=!1}={}){const i=[`resolution=${s?"ignore":"merge"}-duplicates`];void 0!==t&&this.url.searchParams.set("on_conflict",t);const o=e;return r&&i.push(`count=${r}`),n&&i.push("tx=rollback"),this.headers.Prefer&&i.unshift(this.headers.Prefer),this.headers.Prefer=i.join(","),new a({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t,rollback:r=!1}={}){const s=[],n=e;return t&&s.push(`count=${t}`),r&&s.push("tx=rollback"),this.headers.Prefer&&s.unshift(this.headers.Prefer),this.headers.Prefer=s.join(","),new a({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:this.fetch,allowEmpty:!1})}delete({count:e,rollback:t=!1}={}){const r=[];return e&&r.push(`count=${e}`),t&&r.push("tx=rollback"),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new a({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const c={"X-Client-Info":"postgrest-js/1.0.0-next.7"};class l{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},c),t),this.schema=r,this.fetch=s}from(e){const t=new URL(`${this.url}/${e}`);return new h(t,{headers:Object.assign({},this.headers),schema:this.schema,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:s,rollback:n=!1}={}){let i;const o=new URL(`${this.url}/rpc/${e}`);let h;r?(i="HEAD",Object.entries(t).forEach((([e,t])=>{o.searchParams.append(e,`${t}`)}))):(i="POST",h=t);const c=Object.assign({},this.headers);return c.Prefer=[s?`count=${s}`:null,n?"tx=rollback":null].join(","),new a({method:i,url:o,headers:c,schema:this.schema,body:h,fetch:this.fetch,allowEmpty:!1})}}},73:(e,t,r)=>{"use strict";r.r(t),r.d(t,{RealtimeChannel:()=>O,RealtimeClient:()=>P,RealtimePresence:()=>j,Transformers:()=>n});var s,n={};r.r(n),r.d(n,{PostgresTypes:()=>s,convertCell:()=>a,convertChangeData:()=>i,convertColumn:()=>o,toArray:()=>d,toBoolean:()=>c,toJson:()=>u,toNumber:()=>l,toTimestampString:()=>f}),function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(s||(s={}));const i=(e,t,r={})=>{var s;const n=null!==(s=r.skipTypes)&&void 0!==s?s:[];return Object.keys(t).reduce(((r,s)=>(r[s]=o(s,e,t,n),r)),{})},o=(e,t,r,s)=>{const n=t.find((t=>t.name===e)),i=null==n?void 0:n.type,o=r[e];return i&&!s.includes(i)?a(i,o):h(o)},a=(e,t)=>{if("_"===e.charAt(0)){const r=e.slice(1,e.length);return d(t,r)}switch(e){case s.bool:return c(t);case s.float4:case s.float8:case s.int2:case s.int4:case s.int8:case s.numeric:case s.oid:return l(t);case s.json:case s.jsonb:return u(t);case s.timestamp:return f(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 h(t)}},h=e=>e,c=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},l=e=>{if("string"==typeof e){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},u=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(t){return console.log(`JSON parse error: ${t}`),e}return e},d=(e,t)=>{if("string"!=typeof e)return e;const r=e.length-1,s=e[r];if("{"===e[0]&&"}"===s){let s;const n=e.slice(1,r);try{s=JSON.parse("["+n+"]")}catch(e){s=n?n.split(","):[]}return s.map((e=>a(t,e)))}return e},f=e=>"string"==typeof e?e.replace(" ","T"):e;var p=r(840);const v={"X-Client-Info":"realtime-js/1.8.0-next.16"};var y,m,g,b,w;!function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"}(y||(y={})),function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"}(m||(m={})),function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"}(g||(g={})),function(e){e.websocket="websocket"}(b||(b={})),function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"}(w||(w={}));class _{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout((()=>{this.tries=this.tries+1,this.callback()}),this.timerCalc(this.tries+1))}}class T{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t("string"==typeof e?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const s=t.getUint8(1),n=t.getUint8(2);let i=this.HEADER_LENGTH+2;const o=r.decode(e.slice(i,i+s));i+=s;const a=r.decode(e.slice(i,i+n));return i+=n,{ref:null,topic:o,event:a,payload:JSON.parse(r.decode(e.slice(i,e.byteLength)))}}}class E{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.recHooks=[],this.refEvent=null,this.rateLimited=!1}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,"rate limited"===this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref})&&(this.rateLimited=!0))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t(null===(r=this.receivedResp)||void 0===r?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){this.timeoutTimer||(this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,{},(e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(e)})),this.timeoutTimer=setTimeout((()=>{this.trigger("timeout",{})}),this.timeout))}trigger(e,t){this.refEvent&&this.channel.trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter((t=>t.status===e)).forEach((e=>e.callback(t)))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}class j{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel.on(r.state,{},(e=>{const{onJoin:t,onLeave:r,onSync:s}=this.caller;this.joinRef=this.channel.joinRef(),this.state=j.syncState(this.state,e,t,r),this.pendingDiffs.forEach((e=>{this.state=j.syncDiff(this.state,e,t,r)})),this.pendingDiffs=[],s()})),this.channel.on(r.diff,{},(e=>{const{onJoin:t,onLeave:r,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=j.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){const n=this.cloneDeep(e),i=this.transformState(t),o={},a={};return this.map(n,((e,t)=>{i[e]||(a[e]=t)})),this.map(i,((e,t)=>{const r=n[e];if(r){const s=t.map((e=>e.presence_ref)),n=r.map((e=>e.presence_ref)),i=t.filter((e=>n.indexOf(e.presence_ref)<0)),h=r.filter((e=>s.indexOf(e.presence_ref)<0));i.length>0&&(o[e]=i),h.length>0&&(a[e]=h)}else o[e]=t})),this.syncDiff(n,{joins:o,leaves:a},r,s)}static syncDiff(e,t,r,s){const{joins:n,leaves:i}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(n,((t,s)=>{var n;const i=null!==(n=e[t])&&void 0!==n?n:[];if(e[t]=this.cloneDeep(s),i.length>0){const r=e[t].map((e=>e.presence_ref)),s=i.filter((e=>r.indexOf(e.presence_ref)<0));e[t].unshift(...s)}r(t,i,s)})),this.map(i,((t,r)=>{let n=e[t];if(!n)return;const i=r.map((e=>e.presence_ref));n=n.filter((e=>i.indexOf(e.presence_ref)<0)),e[t]=n,s(t,n,r),0===n.length&&delete e[t]})),e}static list(e,t){return t||(t=(e,t)=>t),this.map(e,((e,r)=>t(e,r)))}static map(e,t){return Object.getOwnPropertyNames(e).map((r=>t(r,e[r])))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce(((t,r)=>{const s=e[r];return t[r]="metas"in s?s.metas.map((e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))):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}list(e){return j.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}}var x=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};class O{constructor(e,t={},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=m.closed,this.joinedOnce=!1,this.pushBuffer=[],this.params.configs=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.configs),this.timeout=this.socket.timeout,this.joinPush=new E(this,g.join,this.params,this.timeout),this.rejoinTimer=new _((()=>this.rejoinUntilConnected()),this.socket.reconnectAfterMs),this.joinPush.receive("ok",(()=>{this.state=m.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach((e=>e.send())),this.pushBuffer=[]})),this.onClose((()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=m.closed,this.socket.remove(this)})),this.onError((e=>{this.isLeaving()||this.isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=m.errored,this.rejoinTimer.scheduleTimeout())})),this.joinPush.receive("timeout",(()=>{this.isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=m.errored,this.rejoinTimer.scheduleTimeout())})),this.on(g.reply,{},((e,t)=>{this.trigger(this.replyEventName(t),e)})),this.presence=new j(this)}rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this.rejoin()}subscribe(e,t=this.timeout){var r,s;if(this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{configs:{broadcast:n,presence:i}}=this.params;this.onError((t=>e&&e("CHANNEL_ERROR",t))),this.onClose((()=>e&&e("CLOSED")));const o={},a={broadcast:n,presence:i,postgres_changes:null!==(s=null===(r=this.bindings.postgres_changes)||void 0===r?void 0:r.map((e=>e.filter)))&&void 0!==s?s:[]};this.socket.accessToken&&(o.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({configs:a},o)),this.joinedOnce=!0,this.rejoin(t),this.joinPush.receive("ok",(({postgres_changes:t})=>{var r;this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken);const s=this.bindings.postgres_changes,n=null!==(r=null==s?void 0:s.length)&&void 0!==r?r:0,i=[];for(let r=0;r<n;r++){const n=s[r],{filter:{event:o,schema:a,table:h,filter:c}}=n,l=t[r];if(!l||l.event!==o||l.schema!==a||l.table!==h||l.filter!==c)return this.unsubscribe(),void(e&&e("CHANNEL_ERROR",new Error("mismatch between server and client bindings for postgres changes")));i.push(Object.assign(Object.assign({},n),{id:l.id}))}this.bindings.postgres_changes=i,e&&e("SUBSCRIBED")})).receive("error",(t=>{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(t).join(", ")||"error")))})).receive("timeout",(()=>{e&&e("TIMED OUT")}))}}presenceState(){return this.presence.state}track(e,t={}){return x(this,void 0,void 0,(function*(){return yield this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}))}untrack(e={}){return x(this,void 0,void 0,(function*(){return yield this.send({type:"presence",event:"untrack"},e)}))}onClose(e){this.on(g.close,{},e)}onError(e){this.on(g.error,{},(t=>e(t)))}on(e,t,r){const s=e.toLocaleLowerCase(),n={type:s,filter:t,callback:r};return this.bindings[s]?this.bindings[s].push(n):this.bindings[s]=[n],this}off(e,t){const r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter((e=>{var s;return!((null===(s=e.type)||void 0===s?void 0:s.toLocaleLowerCase())===r&&O.isEqual(e.filter,t))})),this}canPush(){return this.socket.isConnected()&&this.isJoined()}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 E(this,e,t,r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}send(e,t={}){return new Promise((r=>{var s,n,i;const o=this.push(e.type,e,t.timeout||this.timeout);o.rateLimited&&r("rate limited"),"broadcast"!==e.type||(null===(i=null===(n=null===(s=this.params)||void 0===s?void 0:s.configs)||void 0===n?void 0:n.broadcast)||void 0===i?void 0:i.ack)||r("ok"),o.receive("ok",(()=>r("ok"))),o.receive("timeout",(()=>r("timed out")))}))}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=m.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this.trigger(g.close,"leave",this.joinRef())};return this.joinPush.destroy(),new Promise((r=>{const s=new E(this,g.leave,{},e);s.receive("ok",(()=>{t(),r("ok")})).receive("timeout",(()=>{t(),r("timed out")})).receive("error",(()=>{t(),r("error")})),s.send(),this.canPush()||s.trigger("ok",{})}))}onMessage(e,t,r){return t}isMember(e){return this.topic===e}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=m.joining,this.joinPush.resend(e))}trigger(e,t,r){var s;const n=e.toLocaleLowerCase(),{close:i,error:o,leave:a,join:h}=g;if(r&&[i,o,a,h].indexOf(n)>=0&&r!==this.joinRef())return;let c=this.onMessage(n,t,r);if(t&&!c)throw"channel onMessage callbacks must return the payload, modified or unmodified";null===(s=this.bindings[n])||void 0===s||s.filter((e=>{var r,s,i,o,a,h;if(["broadcast","presence","postgres_changes"].includes(n)){if("id"in e){const 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()))}{const 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===(h=null==t?void 0:t.event)||void 0===h?void 0:h.toLocaleLowerCase())}}return e.type.toLocaleLowerCase()===n})).map((e=>{if("object"==typeof c&&"ids"in c){const e=c.data,{schema:t,table:r,commit_timestamp:s,type:n,errors:i}=e,o={schema:t,table:r,commit_timestamp:s,eventType:n,new:{},old:{},errors:i};c=Object.assign(Object.assign({},o),this.getPayloadRecords(e))}e.callback(c,r)}))}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===m.closed}isErrored(){return this.state===m.errored}isJoined(){return this.state===m.joined}isJoining(){return this.state===m.joining}isLeaving(){return this.state===m.leaving}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}getPayloadRecords(e){const t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=i(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=i(e.columns,e.old_record)),t}}const k=()=>{};class P{constructor(e,t){var r;this.accessToken=null,this.channels=[],this.endPoint="",this.headers=v,this.params={},this.timeout=1e4,this.transport=p.w3cwebsocket,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=k,this.conn=null,this.sendBuffer=[],this.serializer=new T,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.eventsPerSecondLimitMs=100,this.inThrottle=!1,this.endPoint=`${e}/${b.websocket}`,(null==t?void 0:t.params)&&(this.params=t.params),(null==t?void 0:t.headers)&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),(null==t?void 0:t.timeout)&&(this.timeout=t.timeout),(null==t?void 0:t.logger)&&(this.logger=t.logger),(null==t?void 0:t.transport)&&(this.transport=t.transport),(null==t?void 0:t.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const s=null===(r=null==t?void 0:t.params)||void 0===r?void 0:r.eventsPerSecond;s&&(this.eventsPerSecondLimitMs=Math.floor(1e3/s)),this.reconnectAfterMs=(null==t?void 0:t.reconnectAfterMs)?t.reconnectAfterMs:e=>[1e3,2e3,5e3,1e4][e-1]||1e4,this.encode=(null==t?void 0:t.encode)?t.encode:(e,t)=>t(JSON.stringify(e)),this.decode=(null==t?void 0:t.decode)?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new _((()=>{return e=this,t=void 0,s=function*(){this.disconnect(),this.connect()},new((r=void 0)||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}));var e,t,r,s}),this.reconnectAfterMs)}connect(){this.conn||(this.conn=new this.transport(this.endPointURL(),[],null,this.headers),this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e)))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,null!=t?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}removeChannel(e){return e.unsubscribe().then((e=>(0===this.channels.length&&this.disconnect(),e)))}removeAllChannels(){return Promise.all(this.channels.map((e=>e.unsubscribe()))).then((e=>(this.disconnect(),e)))}log(e,t,r){this.logger(e,t,r)}onOpen(e){this.stateChangeCallbacks.open.push(e)}onClose(e){this.stateChangeCallbacks.close.push(e)}onError(e){this.stateChangeCallbacks.error.push(e)}onMessage(e){this.stateChangeCallbacks.message.push(e)}connectionState(){switch(this.conn&&this.conn.readyState){case y.connecting:return w.Connecting;case y.open:return w.Open;case y.closing:return w.Closing;default:return w.Closed}}isConnected(){return this.connectionState()===w.Open}remove(e){this.channels=this.channels.filter((t=>t.joinRef()!==e.joinRef()))}channel(e,t={}){this.isConnected()||this.connect();const r=new O(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){const{topic:t,event:r,payload:s,ref:n}=e;let i=()=>{this.encode(e,(e=>{var t;null===(t=this.conn)||void 0===t||t.send(e)}))};if(this.log("push",`${t} ${r} (${n})`,s),this.isConnected())if(["broadcast","presence","postgres_changes"].includes(r)){if(this.throttle(i)())return"rate limited"}else i();else this.sendBuffer.push(i)}onConnMessage(e){this.decode(e.data,(e=>{let{topic:t,event:r,payload:s,ref:n}=e;(n&&n===this.pendingHeartbeatRef||r===(null==s?void 0:s.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${s.status||""} ${t} ${r} ${n&&"("+n+")"||""}`,s),this.channels.filter((e=>e.isMember(t))).forEach((e=>e.trigger(r,s,n))),this.stateChangeCallbacks.message.forEach((t=>t(e)))}))}endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}setAuth(e){this.accessToken=e,this.channels.forEach((t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t.isJoined()&&t.push(g.access_token,{access_token:e})}))}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())}_onConnOpen(){this.log("transport",`connected to ${this.endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval((()=>this._sendHeartbeat()),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach((e=>e()))}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach((t=>t(e)))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach((t=>t(e)))}_triggerChanError(){this.channels.forEach((e=>e.trigger(g.error)))}_appendParams(e,t){if(0===Object.keys(t).length)return e;const r=e.match(/\?/)?"&":"?";return`${e}${r}${new URLSearchParams(t)}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach((e=>e())),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef)return this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),void(null===(e=this.conn)||void 0===e||e.close(1e3,"hearbeat timeout"));this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}throttle(e,t=this.eventsPerSecondLimitMs){return()=>!!this.inThrottle||(e(),this.inThrottle=!0,setTimeout((()=>{this.inThrottle=!1}),t),!1)}}},752:(e,t,r)=>{"use strict";r.r(t),r.d(t,{StorageApiError:()=>i,StorageClient:()=>_,StorageError:()=>s,StorageUnknownError:()=>o,isStorageError:()=>n});class s extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function n(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class i extends s{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class o extends s{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var a=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const h=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>a(void 0,void 0,void 0,(function*(){return yield(yield Promise.resolve().then(r.t.bind(r,98,23))).fetch(...e)})):fetch),(...e)=>t(...e)};var c=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const l=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e);function u(e,t,s,n,h,u){return c(this,void 0,void 0,(function*(){return new Promise(((d,f)=>{e(s,((e,t,r,s)=>{const n={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?n:(n.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))})(t,n,h,u)).then((e=>{if(!e.ok)throw e;return(null==n?void 0:n.noResolveJson)?e:e.json()})).then((e=>d(e))).catch((e=>((e,t)=>c(void 0,void 0,void 0,(function*(){const s=yield a(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(r.t.bind(r,98,23))).Response:Response}));e instanceof s?e.json().then((r=>{t(new i(l(r),e.status||500))})):t(new o(l(e),e))})))(e,f)))}))}))}function d(e,t,r,s){return c(this,void 0,void 0,(function*(){return u(e,"GET",t,r,s)}))}function f(e,t,r,s,n){return c(this,void 0,void 0,(function*(){return u(e,"POST",t,s,n,r)}))}function p(e,t,r,s,n){return c(this,void 0,void 0,(function*(){return u(e,"DELETE",t,s,n,r)}))}var v=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};const y={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},m={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class g{constructor(e,t={},r,s){this.url=e,this.headers=t,this.bucketId=r,this.fetch=h(s)}uploadOrUpdate(e,t,r,s){return v(this,void 0,void 0,(function*(){try{let n;const i=Object.assign(Object.assign({},m),s),o=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(i.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?(n=new FormData,n.append("cacheControl",i.cacheControl),n.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(n=r,n.append("cacheControl",i.cacheControl)):(n=r,o["cache-control"]=`max-age=${i.cacheControl}`,o["content-type"]=i.contentType);const a=this._removeEmptyFolders(t),h=this._getFinalPath(a),c=yield this.fetch(`${this.url}/object/${h}`,{method:e,body:n,headers:o});return c.ok?{data:{path:a},error:null}:{data:null,error:yield c.json()}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}upload(e,t,r){return v(this,void 0,void 0,(function*(){return this.uploadOrUpdate("POST",e,t,r)}))}update(e,t,r){return v(this,void 0,void 0,(function*(){return this.uploadOrUpdate("PUT",e,t,r)}))}move(e,t){return v(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}copy(e,t){return v(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}createSignedUrl(e,t){return v(this,void 0,void 0,(function*(){try{const r=this._getFinalPath(e);let s=yield f(this.fetch,`${this.url}/object/sign/${r}`,{expiresIn:t},{headers:this.headers});return s={signedUrl:encodeURI(`${this.url}${s.signedURL}`)},{data:s,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}createSignedUrls(e,t){return v(this,void 0,void 0,(function*(){try{return{data:(yield f(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers})).map((e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}`):null}))),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}download(e){return v(this,void 0,void 0,(function*(){try{const t=this._getFinalPath(e),r=yield d(this.fetch,`${this.url}/object/${t}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}getPublicUrl(e){const t=this._getFinalPath(e);return{data:{publicUrl:encodeURI(`${this.url}/object/public/${t}`)}}}remove(e){return v(this,void 0,void 0,(function*(){try{return{data:yield p(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}list(e,t,r){return v(this,void 0,void 0,(function*(){try{const s=Object.assign(Object.assign(Object.assign({},y),t),{prefix:e||""});return{data:yield f(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}}const b={"X-Client-Info":"storage-js/1.8.0-next.6"};var w=function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};class _ extends class{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},b),t),this.fetch=h(r)}listBuckets(){return w(this,void 0,void 0,(function*(){try{return{data:yield d(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}getBucket(e){return w(this,void 0,void 0,(function*(){try{return{data:yield d(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}createBucket(e,t={public:!1}){return w(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}updateBucket(e,t){return w(this,void 0,void 0,(function*(){try{const r=yield function(e,t,r,s,n){return c(this,void 0,void 0,(function*(){return u(e,"PUT",t,s,undefined,r)}))}(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public},{headers:this.headers});return{data:r,error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}emptyBucket(e){return w(this,void 0,void 0,(function*(){try{return{data:yield f(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}deleteBucket(e){return w(this,void 0,void 0,(function*(){try{return{data:yield p(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(n(e))return{data:null,error:e};throw e}}))}}{constructor(e,t={},r){super(e,t,r)}from(e){return new g(this.url,this.headers,e,this.fetch)}}},98:function(e,t){var r="undefined"!=typeof self?self:this,s=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r="URLSearchParams"in e,s="Symbol"in e&&"iterator"in Symbol,n="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function u(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return s&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:n&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&n&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||h(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,r,s=f(this);if(s)return s;if(this._bodyBlob)return e=this._bodyBlob,r=p(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),s=0;s<t.length;s++)r[s]=String.fromCharCode(t[s]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=c(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[c(e)]},d.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},d.prototype.set=function(e,t){this.map[c(e)]=l(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),u(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),u(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),u(e)},s&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(e,t){var r,s,n=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(s=(r=t.method||this.method||"GET").toUpperCase(),g.indexOf(s)>-1?s:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),s=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(s),decodeURIComponent(n))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},m.call(b.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var T=[301,302,303,307,308];_.redirect=function(e,t){if(-1===T.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function E(e,r){return new Promise((function(s,i){var o=new b(e,r);if(o.signal&&o.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),s=r.shift().trim();if(s){var n=r.join(":").trim();t.append(s,n)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;s(new _(n,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&n&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",h)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}E.polyfill=!0,e.fetch||(e.fetch=E,e.Headers=d,e.Request=b,e.Response=_),t.Headers=d,t.Request=b,t.Response=_,t.fetch=E,Object.defineProperty(t,"__esModule",{value:!0})}({})}(s),s.fetch.ponyfill=!0,delete s.fetch.polyfill;var n=s;(t=n.fetch).default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,e.exports=t},284:e=>{var t=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};e.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return t()}try{return __global__||t()}finally{delete Object.prototype.__global__}}()},296:function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=r(982),i=r(189),o=r(73),a=r(752),h=r(678),c=r(716),l=r(610),u=r(283),d={headers:h.DEFAULT_HEADERS},f={schema:"public"},p={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0},v={};t.default=class{constructor(e,t,r){var s,n,o,a,h,u,y,m;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const g=(0,l.stripTrailingSlash)(e);if(this.realtimeUrl=`${g}/realtime/v1`.replace("http","ws"),this.authUrl=`${g}/auth/v1`,this.storageUrl=`${g}/storage/v1`,g.match(/(supabase\.co)|(supabase\.in)/)){const e=g.split(".");this.functionsUrl=`${e[0]}.functions.${e[1]}.${e[2]}`}else this.functionsUrl=`${g}/functions/v1`;const b=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,w={db:f,realtime:v,auth:Object.assign(Object.assign({},p),{storageKey:b}),global:d},_=(0,l.applySettingDefaults)(null!=r?r:{},w);this.storageKey=null!==(n=null===(s=_.auth)||void 0===s?void 0:s.storageKey)&&void 0!==n?n:"",this.headers=null!==(a=null===(o=_.global)||void 0===o?void 0:o.headers)&&void 0!==a?a:{},this.auth=this._initSupabaseAuthClient(null!==(h=_.auth)&&void 0!==h?h:{},this.headers,null===(u=_.global)||void 0===u?void 0:u.fetch),this.fetch=(0,c.fetchWithAuth)(t,this._getAccessToken.bind(this),null===(y=_.global)||void 0===y?void 0:y.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},_.realtime)),this.rest=new i.PostgrestClient(`${g}/rest/v1`,{headers:this.headers,schema:null===(m=_.db)||void 0===m?void 0:m.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new n.FunctionsClient(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new a.StorageClient(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}rpc(e,t={},r){return this.rest.rpc(e,t,r)}channel(e,t={}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e;return s(this,void 0,void 0,(function*(){const{session:t}=yield this.auth.getSession();return null!==(e=null==t?void 0:t.access_token)&&void 0!==e?e:null}))}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,storageKey:n},i,o){const a={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new u.SupabaseAuthClient({url:this.authUrl,headers:Object.assign(Object.assign({},i),a),storageKey:n,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,fetch:o})}_initRealtimeClient(e){return new o.RealtimeClient(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange(((e,t)=>{this._handleTokenChanged(e,null==t?void 0:t.access_token,"CLIENT")}))}_handleTokenChanged(e,t,r){"TOKEN_REFRESHED"!==e&&"SIGNED_IN"!==e||this.changedAccessToken===t?"SIGNED_OUT"!==e&&"USER_DELETED"!==e||(this.realtime.setAuth(this.supabaseKey),"STORAGE"==r&&this.auth.signOut()):(this.realtime.setAuth(null!=t?t:null),this.changedAccessToken=t)}}},341:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||s(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createClient=t.SupabaseClient=void 0;const o=i(r(296));n(r(268),t),n(r(73),t);var a=r(296);Object.defineProperty(t,"SupabaseClient",{enumerable:!0,get:function(){return i(a).default}}),t.createClient=(e,t,r)=>new o.default(e,t,r)},283:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SupabaseAuthClient=void 0;const s=r(268);class n extends s.GoTrueClient{constructor(e){super(e)}}t.SupabaseAuthClient=n},678:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_HEADERS=void 0;const s=r(506);t.DEFAULT_HEADERS={"X-Client-Info":`supabase-js/${s.version}`}},716:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},o=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{h(s.next(e))}catch(e){i(e)}}function a(e){try{h(s.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchWithAuth=t.resolveHeadersConstructor=t.resolveFetch=void 0;const a=i(r(98));t.resolveFetch=e=>{let t;return t=e||("undefined"==typeof fetch?a.default:fetch),(...e)=>t(...e)},t.resolveHeadersConstructor=()=>"undefined"==typeof Headers?a.Headers:Headers,t.fetchWithAuth=(e,r,s)=>{const n=(0,t.resolveFetch)(s),i=(0,t.resolveHeadersConstructor)();return(t,s)=>o(void 0,void 0,void 0,(function*(){var o;const a=null!==(o=yield r())&&void 0!==o?o:e;let h=new i(null==s?void 0:s.headers);return h.has("apikey")||h.set("apikey",e),h.has("Authorization")||h.set("Authorization",`Bearer ${a}`),n(t,Object.assign(Object.assign({},s),{headers:h}))}))}},610:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applySettingDefaults=t.isBrowser=t.stripTrailingSlash=t.uuid=void 0,t.uuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.isBrowser=()=>"undefined"!=typeof window,t.applySettingDefaults=function(e,t){const{db:r,auth:s,realtime:n,global:i}=e,{db:o,auth:a,realtime:h,global:c}=t;return{db:Object.assign(Object.assign({},o),r),auth:Object.assign(Object.assign({},a),s),realtime:Object.assign(Object.assign({},h),n),global:Object.assign(Object.assign({},c),i)}}},506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="1.36.0-next.24"},840:(e,t,r)=>{var s;if("object"==typeof globalThis)s=globalThis;else try{s=r(284)}catch(e){}finally{if(s||"undefined"==typeof window||(s=window),!s)throw new Error("Could not determine global this")}var n=s.WebSocket||s.MozWebSocket,i=r(387);function o(e,t){return t?new n(e,t):new n(e)}n&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(o,e,{get:function(){return n[e]}})})),e.exports={w3cwebsocket:n?o:null,version:i}},387:(e,t,r)=>{e.exports=r(794).version},794:e=>{"use strict";e.exports={version:"1.0.34"}}},s={};function n(e){var t=s[e];if(void 0!==t)return t.exports;var i=s[e]={exports:{}};return r[e].call(i.exports,i,i.exports,n),i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(r,s){if(1&s&&(r=this(r)),8&s)return r;if("object"==typeof r&&r){if(4&s&&r.__esModule)return r;if(16&s&&"function"==typeof r.then)return r}var i=Object.create(null);n.r(i);var o={};e=e||[null,t({}),t([]),t(t)];for(var a=2&s&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>o[e]=()=>r[e]));return o.default=()=>r,n.d(i,o),i},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(341)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/supabase-js",
3
- "version": "1.36.0-next.21",
3
+ "version": "1.36.0-next.24",
4
4
  "description": "Isomorphic Javascript client for Supabase",
5
5
  "keywords": [
6
6
  "javascript",
@@ -37,11 +37,11 @@
37
37
  "docs:json": "typedoc --entryPoints src/index.ts --out docs --includes src/**/*.ts --json docs/spec.json"
38
38
  },
39
39
  "dependencies": {
40
- "@supabase/functions-js": "^1.4.0-next.1",
41
- "@supabase/gotrue-js": "^1.23.0-next.15",
42
- "@supabase/postgrest-js": "^1.0.0-next.6",
43
- "@supabase/realtime-js": "^1.8.0-next.13",
44
- "@supabase/storage-js": "^1.8.0-next.5",
40
+ "@supabase/functions-js": "^1.4.0-next.5",
41
+ "@supabase/gotrue-js": "^1.23.0-next.20",
42
+ "@supabase/postgrest-js": "^1.0.0-next.7",
43
+ "@supabase/realtime-js": "^1.8.0-next.16",
44
+ "@supabase/storage-js": "^1.8.0-next.6",
45
45
  "cross-fetch": "^3.1.5"
46
46
  },
47
47
  "devDependencies": {
@@ -55,7 +55,7 @@
55
55
  "semantic-release-plugin-update-version-in-files": "^1.1.0",
56
56
  "ts-jest": "^26.3.0",
57
57
  "ts-loader": "^8.0.11",
58
- "typedoc": "^0.22.13",
58
+ "typedoc": "^0.22.16",
59
59
  "typescript": "^4.5.5",
60
60
  "webpack": "^5.69.1",
61
61
  "webpack-cli": "^4.9.2"
@@ -11,7 +11,6 @@ import { DEFAULT_HEADERS } from './lib/constants'
11
11
  import { fetchWithAuth } from './lib/fetch'
12
12
  import { stripTrailingSlash, applySettingDefaults } from './lib/helpers'
13
13
  import { SupabaseAuthClient } from './lib/SupabaseAuthClient'
14
- import { SupabaseRealtimeChannel } from './lib/SupabaseRealtimeChannel'
15
14
  import { Fetch, GenericSchema, SupabaseClientOptions, SupabaseAuthClientOptions } from './lib/types'
16
15
 
17
16
  const DEFAULT_GLOBAL_OPTIONS = {
@@ -125,11 +124,6 @@ export default class SupabaseClient<
125
124
  })
126
125
 
127
126
  this._listenForAuthEvents()
128
-
129
- // In the future we might allow the user to pass in a logger to receive these events.
130
- // this.realtime.onOpen(() => console.log('OPEN'))
131
- // this.realtime.onClose(() => console.log('CLOSED'))
132
- // this.realtime.onError((e: Error) => console.log('Socket error', e))
133
127
  }
134
128
 
135
129
  /**
@@ -194,50 +188,38 @@ export default class SupabaseClient<
194
188
  }
195
189
 
196
190
  /**
197
- * Creates a channel with Broadcast and Presence.
191
+ * Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
192
+ *
193
+ * @param {string} name - The name of the Realtime channel.
194
+ * @param {Object} opts - The options to pass to the Realtime channel.
195
+ *
198
196
  */
199
- channel(name: string, opts?: { [key: string]: any }): SupabaseRealtimeChannel {
200
- if (!this.realtime.isConnected()) {
201
- this.realtime.connect()
202
- }
203
-
204
- return new SupabaseRealtimeChannel(name, opts, this.realtime)
197
+ channel(name: string, opts: { [key: string]: any } = {}): RealtimeChannel {
198
+ return this.realtime.channel(name, opts)
205
199
  }
206
200
 
207
201
  /**
208
- * Closes and removes all channels and returns a list of removed
209
- * channels and their errors.
202
+ * Returns all Realtime channels.
210
203
  */
211
- async removeAllChannels(): Promise<
212
- { data: { channels: RealtimeChannel }; error: Error | null }[]
213
- > {
214
- const allChans: RealtimeChannel[] = this.getChannels().slice()
215
- const allChanPromises = allChans.map((chan) => this.removeChannel(chan))
216
- const allRemovedChans = await Promise.all(allChanPromises)
217
-
218
- return allRemovedChans.map(({ error }, i) => {
219
- return {
220
- data: { channels: allChans[i] },
221
- error,
222
- }
223
- })
204
+ getChannels(): RealtimeChannel[] {
205
+ return this.realtime.getChannels()
224
206
  }
225
207
 
226
208
  /**
227
- * Closes and removes a channel and returns the number of open channels.
209
+ * Unsubscribes and removes Realtime channel from Realtime client.
210
+ *
211
+ * @param {RealtimeChannel} channel - The name of the Realtime channel.
228
212
  *
229
- * @param channel The channel you want to close and remove.
230
213
  */
231
- async removeChannel(
232
- channel: RealtimeChannel
233
- ): Promise<{ data: { openChannels: number }; error: Error | null }> {
234
- const { error } = await this._closeChannel(channel)
235
- const allChans: RealtimeChannel[] = this.getChannels()
236
- const openChanCount = allChans.filter((chan) => chan.isJoined()).length
237
-
238
- if (allChans.length === 0) await this.realtime.disconnect()
214
+ removeChannel(channel: RealtimeChannel): Promise<'ok' | 'timed out' | 'error'> {
215
+ return this.realtime.removeChannel(channel)
216
+ }
239
217
 
240
- return { data: { openChannels: openChanCount }, error }
218
+ /**
219
+ * Unsubscribes and removes all Realtime channels from Realtime client.
220
+ */
221
+ removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]> {
222
+ return this.realtime.removeAllChannels()
241
223
  }
242
224
 
243
225
  private async _getAccessToken() {
@@ -246,43 +228,12 @@ export default class SupabaseClient<
246
228
  return session?.access_token ?? null
247
229
  }
248
230
 
249
- private async _closeChannel(channel: RealtimeChannel): Promise<{ error: Error | null }> {
250
- let error = null
251
-
252
- if (!channel.isClosed()) {
253
- const { error: unsubError } = await this._unsubscribeChannel(channel)
254
- error = unsubError
255
- }
256
-
257
- this.realtime.remove(channel)
258
-
259
- return { error }
260
- }
261
-
262
- private _unsubscribeChannel(channel: RealtimeChannel): Promise<{ error: Error | null }> {
263
- return new Promise((resolve) => {
264
- channel
265
- .unsubscribe()
266
- .receive('ok', () => resolve({ error: null }))
267
- .receive('error', (error: Error) => resolve({ error }))
268
- .receive('timeout', () => resolve({ error: new Error('timed out') }))
269
- })
270
- }
271
-
272
- /**
273
- * Returns an array of all your channels.
274
- */
275
- getChannels(): RealtimeChannel[] {
276
- return this.realtime.channels as RealtimeChannel[]
277
- }
278
-
279
231
  private _initSupabaseAuthClient(
280
232
  {
281
233
  autoRefreshToken,
282
234
  persistSession,
283
235
  detectSessionInUrl,
284
236
  storage,
285
- cookieOptions,
286
237
  storageKey,
287
238
  }: SupabaseAuthClientOptions,
288
239
  headers?: Record<string, string>,
@@ -301,14 +252,13 @@ export default class SupabaseClient<
301
252
  detectSessionInUrl,
302
253
  storage,
303
254
  fetch,
304
- cookieOptions,
305
255
  })
306
256
  }
307
257
 
308
- private _initRealtimeClient(options?: RealtimeClientOptions) {
258
+ private _initRealtimeClient(options: RealtimeClientOptions) {
309
259
  return new RealtimeClient(this.realtimeUrl, {
310
260
  ...options,
311
- params: { ...{ apikey: this.supabaseKey, vsndate: '2022' }, ...options?.params },
261
+ params: { ...{ apikey: this.supabaseKey }, ...options?.params },
312
262
  })
313
263
  }
314
264
 
@@ -329,7 +279,7 @@ export default class SupabaseClient<
329
279
  this.changedAccessToken !== token
330
280
  ) {
331
281
  // Token has changed
332
- this.realtime.setAuth(token!)
282
+ this.realtime.setAuth(token ?? null)
333
283
 
334
284
  this.changedAccessToken = token
335
285
  } else if (event === 'SIGNED_OUT' || event === 'USER_DELETED') {