1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8448],{94579:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});var n=r(69703),s=r(11084),i=r(947);let a=["global","local","others"];var o=r(28898);class c{async signOut(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a[0];if(0>a.indexOf(t))throw Error("@supabase/auth-js: Parameter scope must be one of ".concat(a.join(", ")));try{return await (0,s.cY)(this.fetch,"POST","".concat(this.url,"/logout?scope=").concat(t),{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return await (0,s.cY)(this.fetch,"POST","".concat(this.url,"/invite"),{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:s.Br})}catch(e){if((0,o.f1)(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=(0,n._T)(e,["options"]),i=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(i.new_email=null==r?void 0:r.newEmail,delete i.newEmail),await (0,s.cY)(this.fetch,"POST","".concat(this.url,"/admin/generate_link"),{body:i,headers:this.headers,xform:s.lp,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if((0,o.f1)(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await (0,s.cY)(this.fetch,"POST","".concat(this.url,"/admin/users"),{body:e,headers:this.headers,xform:s.Br})}catch(e){if((0,o.f1)(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,n,i,a,c,l;try{let o={nextPage:null,lastPage:0,total:0},u=await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/users"),{headers:this.headers,noResolveJson:!0,query:{page:null!==(r=null===(t=null==e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==r?r:"",per_page:null!==(i=null===(n=null==e?void 0:e.perPage)||void 0===n?void 0:n.toString())&&void 0!==i?i:""},xform:s.Dy});if(u.error)throw u.error;let h=await u.json(),d=null!==(a=u.headers.get("x-total-count"))&&void 0!==a?a:0,f=null!==(l=null===(c=u.headers.get("link"))||void 0===c?void 0:c.split(","))&&void 0!==l?l:[];return f.length>0&&(f.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);o["".concat(r,"Page")]=t}),o.total=parseInt(d)),{data:Object.assign(Object.assign({},h),o),error:null}}catch(e){if((0,o.f1)(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){(0,i.ni)(e);try{return await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,xform:s.Br})}catch(e){if((0,o.f1)(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){(0,i.ni)(e);try{return await (0,s.cY)(this.fetch,"PUT","".concat(this.url,"/admin/users/").concat(e),{body:t,headers:this.headers,xform:s.Br})}catch(e){if((0,o.f1)(e))return{data:{user:null},error:e};throw e}}async deleteUser(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(0,i.ni)(e);try{return await (0,s.cY)(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,body:{should_soft_delete:t},xform:s.Br})}catch(e){if((0,o.f1)(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){(0,i.ni)(e.userId);try{let{data:t,error:r}=await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e.userId,"/factors"),{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:r}}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _deleteFactor(e){(0,i.ni)(e.userId),(0,i.ni)(e.id);try{return{data:await (0,s.cY)(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e.userId,"/factors/").concat(e.id),{headers:this.headers}),error:null}}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,n,i,a,c,l;try{let o={nextPage:null,lastPage:0,total:0},u=await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/oauth/clients"),{headers:this.headers,noResolveJson:!0,query:{page:null!==(r=null===(t=null==e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==r?r:"",per_page:null!==(i=null===(n=null==e?void 0:e.perPage)||void 0===n?void 0:n.toString())&&void 0!==i?i:""},xform:s.Dy});if(u.error)throw u.error;let h=await u.json(),d=null!==(a=u.headers.get("x-total-count"))&&void 0!==a?a:0,f=null!==(l=null===(c=u.headers.get("link"))||void 0===c?void 0:c.split(","))&&void 0!==l?l:[];return f.length>
10&&(f.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);o["".concat(r,"Page")]=t}),o.total=parseInt(d)),{data:Object.assign(Object.assign({},h),o),error:null}}catch(e){if((0,o.f1)(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await (0,s.cY)(this.fetch,"POST","".concat(this.url,"/admin/oauth/clients"),{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/oauth/clients/").concat(e),{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await (0,s.cY)(this.fetch,"PUT","".concat(this.url,"/admin/oauth/clients/").concat(e),{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await (0,s.cY)(this.fetch,"DELETE","".concat(this.url,"/admin/oauth/clients/").concat(e),{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await (0,s.cY)(this.fetch,"POST","".concat(this.url,"/admin/oauth/clients/").concat(e,"/regenerate_secret"),{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _listCustomProviders(e){try{let t={};return(null==e?void 0:e.type)&&(t.type=e.type),await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/custom-providers"),{headers:this.headers,query:t,xform:e=>{var t;return{data:{providers:null!==(t=null==e?void 0:e.providers)&&void 0!==t?t:[]},error:null}}})}catch(e){if((0,o.f1)(e))return{data:{providers:[]},error:e};throw e}}async _createCustomProvider(e){try{return await (0,s.cY)(this.fetch,"POST","".concat(this.url,"/admin/custom-providers"),{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _getCustomProvider(e){try{return await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/custom-providers/").concat(e),{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _updateCustomProvider(e,t){try{return await (0,s.cY)(this.fetch,"PUT","".concat(this.url,"/admin/custom-providers/").concat(e),{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _deleteCustomProvider(e){try{return await (0,s.cY)(this.fetch,"DELETE","".concat(this.url,"/admin/custom-providers/").concat(e),{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _adminListPasskeys(e){(0,i.ni)(e.userId);try{return await (0,s.cY)(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e.userId,"/passkeys"),{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}async _adminDeletePasskey(e){(0,i.ni)(e.userId),(0,i.ni)(e.passkeyId);try{return await (0,s.cY)(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e.userId,"/passkeys/").concat(e.passkeyId),{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.f1)(e))return{data:null,error:e};throw e}}constructor({url:e="",headers:t={},fetch:r,experimental:n}){this.url=e,this.headers=t,this.fetch=(0,i.eM)(r),this.experimental=null!=n?n:{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}}},55249:function(e,t,r){"use strict";r.d(t,{Tx:function(){return c},WU:function(){return l},rB:function(){return h},sy:function(){return u}});let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),s=" \n\r=".split(""),i=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<s.length;t+=1)e[s[t].charCodeAt(0)]=-2;for(let t=0;t<n.length;t+=1)e[n[t].charCodeAt(0)]=t;return e})();function a(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(n[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6;else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;)r(n[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function o(e,t,r){let n=i[e];if(n>-1)for(t.queue=t.queue<<6|n,t.queuedBits+=6;t.queuedBits>=8;)r(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===n)return;else throw Error('Invalid Base64-URL character "'.concat(String.fromCharCode(e),'"'))}function c(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=e=>{!function(e,t,r){if(0===t.utf8seq){if(e<=127){r(e);return}for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}}(e,n,r)};for(let t=0;t<e.length;t+=1)o(e.charCodeAt(t),s,i);return t.join("")}function l(e){let t=[],r={queue:0,queuedBits:0},n=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)o(e.charCodeAt(t),r,n);return new Uint8Array(t)}function u(e){let t=[];return!function(e,t){for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n>55295&&n<=56319){let t=(n-55296)*1024&65535;n=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127){t(e);return}if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>
16&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error("Unrecognized Unicode codepoint: ".concat(e.toString(16)))}(n,t)}}(e,e=>t.push(e)),new Uint8Array(t)}function h(e){let t=[],r={queue:0,queuedBits:0},n=e=>{t.push(e)};return e.forEach(e=>a(e,r,n)),a(null,r,n),t.join("")}},1295:function(e,t,r){"use strict";r.d(t,{F9:function(){return d},G1:function(){return c},HU:function(){return f},I8:function(){return o},Js:function(){return i},Kd:function(){return m},QN:function(){return u},Uf:function(){return l},Uj:function(){return a},Vr:function(){return p},Zd:function(){return g},r6:function(){return s},wA:function(){return h}});var n=r(47656);let s=3e4,i=3,a=9e4,o=6e4,c="http://localhost:9999",l="supabase.auth.token",u={"X-Client-Info":"gotrue-js/".concat(n.i)},h="X-Supabase-Api-Version",d={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},f=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,p="sb_flow_id",g=5,m=6e5},28898:function(e,t,r){"use strict";r.d(t,{AO:function(){return v},GF:function(){return l},Iu:function(){return o},LI:function(){return f},MZ:function(){return E},Po:function(){return g},Tw:function(){return a},UQ:function(){return k},Uw:function(){return m},Ws:function(){return i},eV:function(){return h},e_:function(){return d},f1:function(){return s},l4:function(){return n},p7:function(){return b},t:function(){return u},wo:function(){return p},xE:function(){return w},y4:function(){return y}});class n extends Error{toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}}function s(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class i extends n{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function a(e){return s(e)&&"AuthApiError"===e.name}class o extends n{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class c extends n{constructor(e,t,r,n){super(e,r,n),this.name=t,this.status=r}}class l extends c{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function u(e){return s(e)&&"AuthSessionMissingError"===e.name}class h extends c{constructor(){super("Auth session or user missing","AuthInvalidToken
1ResponseError",500,void 0)}}class d extends c{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class f extends c{toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}}function p(e){return s(e)&&"AuthImplicitGrantRedirectError"===e.name}class g extends c{toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}}class m extends c{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class y extends c{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function v(e){return s(e)&&"AuthRetryableFetchError"===e.name}class b extends c{constructor(e="Refresh result discarded: session state changed mid-flight (e.g., concurrent signOut)"){super(e,"AuthRefreshDiscardedError",409,void 0)}}function w(e){return s(e)&&"AuthRefreshDiscardedError"===e.name}class E extends c{toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}}class k extends c{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}},11084:function(e,t,r){"use strict";r.d(t,{Br:function(){return g},Dy:function(){return v},E_:function(){return m},cY:function(){return h},jv:function(){return p},lp:function(){return y},vI:function(){return f}});var n=r(69703),s=r(1295),i=r(947),a=r(28898);let o=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error}return JSON.stringify(e)},c=[500,501,502,503,504,520,521,522,523,524,525,526,527,528,529,530];async function l(e){var t;let r,n;if(!(0,i.Qw)(e))throw new a.y4(o(e),0);try{r=await e.json()}catch(t){if(c.includes(e.status))throw new a.y4(e.statusText||"HTTP ".concat(e.status),e.status);throw new a.Iu(o(t),t)}if(c.includes(e.status))throw new a.y4(o(r),e.status);let l=(0,i.xe)(e);if(l&&l.getTime()>=s.F9["2024-01-01"].timestamp&&"object"==typeof r&&r&&"string"==typeof r.code?n=r.code:"object"==typeof r&&r&&"string"==typeof r.error_code&&(n=r.error_code),n){if("weak_password"===n)throw new a.MZ(o(r),e.status,(null===(t=r.weak_password)||void 0===t?void 0:t.reasons)||[]);if("session_not_found"===n)throw new a.GF}else if("object"==typeof r&&r&&"object"==typeof r.weak_password&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new a.MZ(o(r),e.status,r.weak_password.reasons);throw new a.Ws(o(r),e.status||500,n)}let u=(e,t,r,n)=>{let s={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==t?void 0:t.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function h(e,t,r,n){var i;let a=Object.assign({},null==n?void 0:n.headers);a[s.wA]||(a[s.wA]=s.F9["2024-01-01"].name),(null==n?void 0:n.jwt)&&(a.Authorization="Bearer ".concat(n.jwt));let o=null!==(i=null==n?void 0:n.query)&&void 0!==i?i:{};(null==n?void 0:n.redirectTo)&&(o.redirect_to=n.redirectTo);let c=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await d(e,t,r+c,{headers:a,noResolveJson:null==n?void 0:n.noResolveJson},{},null==n?void 0:n.body);return(null==n?void 0:n.xform)?null==n?void 0:n.xform(l):{data:Object.assign({},l),error:null}}async function d(e,t,r,n,s,i){let c;let h=u(t,n,s,i);try{c=await e(r,Object.assign({},h))}catch(e){throw new a.y4(o(e),0)}if(c.ok||await l(c),null==n?void 0:n.noResolveJson)return c;try{return await c.json()}catch(e){await l(e)}}function f(e){var t;let r=null;return e.access_token&&e.refresh_token&&e.expires_in&&(r=Object.assign({},e),e.expires_at||(r.expires_at=(0,i.Fq)(e.expires_in))),{data:{session:r,user:null!==(t=e.user)&&void 0!==t?t:"string"==typeof(null==e?void 0:e.id)?e:null},error:null}}function p(e){let t=f(e);return!t.error&&e.weak_password&&"object"==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>
1e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function g(e){var t;return{data:{user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function m(e){return{data:e,error:null}}function y(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:a}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:a},user:Object.assign({},(0,n._T)(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function v(e){return e}},947:function(e,t,r){"use strict";r.d(t,{B8:function(){return F},BH:function(){return y},Dc:function(){return g},Fq:function(){return a},I8:function(){return W},K0:function(){return J},Ph:function(){return T},Qw:function(){return f},RZ:function(){return L},Rd:function(){return w},S:function(){return R},Sv:function(){return m},Z2:function(){return D},__:function(){return U},_v:function(){return b},bb:function(){return M},eM:function(){return d},eg:function(){return p},hJ:function(){return j},jU:function(){return c},ng:function(){return I},ni:function(){return H},o9:function(){return h},qR:function(){return O},s0:function(){return x},xP:function(){return o},xe:function(){return B},xp:function(){return v},y1:function(){return u}});var n=r(1295),s=r(28898),i=r(55249);function a(e){return Math.round(Date.now()/1e3)+e}function o(){return Symbol("auth-callback")}let c=()=>"undefined"!=typeof document,l={tested:!1,writable:!1},u=()=>{if(!c())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(l.tested)return l.writable;let e="lswt-".concat(Math.random()).concat(Math.random());try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),l.tested=!0,l.writable=!0}catch(e){l.tested=!0,l.writable=!1}return l.writable};function h(e){let t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{new URLSearchParams(r.hash.substring(1)).forEach((e,r)=>{t[r]=e})}catch(e){}return r.searchParams.forEach((e,r)=>{t[r]=e}),t}let d=e=>e?function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e(...r)}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch(...t)},f=e=>"object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json,p=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},g=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return null}},m=async(e,t)=>{await e.removeItem(t)};class y{constructor(){this.promise=new y.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function v(e){let t=e.split(".");if(3!==t.length)throw new s.UQ("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!n.HU.test(t[e]))throw new s.UQ("JWT not in base64url format");return{header:JSON.parse((0,i.Tx)(t[0])),payload:JSON.parse((0,i.Tx)(t[1])),signature:(0,i.WU)(t[2]),raw:{header:t[0],payload:t[1]}}}async function b(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function w(e,t){return new Promise((r,n)=>{(async()=>{for(let s=0;s<1/0;s++)try{let n=await e(s);if(!t(s,null,n)){r(n);return}}catch(e){if(!t(s,e)){n(e);return}}})()})}function E(e){return("0"+e.toString(16)).substr(-2)}async function k(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(e=>String.fromCharCode(e)).join("")}async function S(e){return"undefined"!=typeof crypto&&void 0!==crypto.subtle&&"undefined"!=typeof TextEncoder?btoa(await k(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):(console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e)}y.promiseConstructor=Promise;let A=/^[a-zA-Z0-9_-]{8,64}$/;function T(e){return"string"==typeof e&&A.test(e)?e:null}let O=(e,t)=>"".concat(e,"-flow-").concat(t,"-code-verifier"),_=e=>"".concat(e,"-flows-code-verifier");async function C(e,t){let r=await g(e,_(t));return Array.isArray(r)?r.filter(e=>null!==T(e)):[]}async function P(e,t,r,s,i){await p(e,O(t,r),s);let a=(await C(e,t)).filter(e=>e!==r);for(a.push(r);a.length>n.Zd;){let r=a.shift();await m(e,O(t,r)),null==i||i(r)}await p(e,_(t),a),await p(e,"".concat(t,"-code-verifier"),s)}async function j(e,t,r){if(r){let n=await g(e,O(t,r));return{verifier:"string"==typeof n?n:null,flowId:r}}let n=await g(e,"".concat(t,"-code-verifier"));return{verifier:"string"==typeof n?n:null,flowId:null}}async function R(e,t,r){let n="".concat(t,"-code-verifier");if(!r){await m(e,n);return}let s=O(t,r),i=await g(e,s);await m(e,s);let a=await C(e,t),o=a.filter(e=>e!==r);o.length!==a.length&&(o.length>0?await p(e,_(t),o):await m(e,_(t))),null!=i&&i===await g(e,n)&&await m(e,n)}async function x(e,t){for(let r of(await C(e,t)))await m(e,O(t,r));await m(e,_(t)),await m(e,"".concat(t,"-code-verifier"))}function I(e,t){let r=e.indexOf("#"),s=-1===r?e:e.slice(0,r),i=-1===r?"":e.slice(r),a=s.indexOf("?");if(-1!==a){let e=s.slice(0,a),t=s.slice(a+1).split("&").filter(e=>
1""!==e&&e!==n.Vr&&!e.startsWith("".concat(n.Vr,"=")));s=t.length>0?"".concat(e,"?").concat(t.join("&")):e}let o=s.includes("?")?"&":"?";return"".concat(s).concat(o).concat(n.Vr,"=").concat(encodeURIComponent(t)).concat(i)}async function U(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3?arguments[3]:void 0,s=function(){let e=new Uint32Array(56);if("undefined"==typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let n=0;n<56;n++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,E).join("")}(),i=s;r&&(i+="/recovery");let a=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,E).join("")}let e="";for(let t=0;t<32;t++)e+=Math.floor(16*Math.random()).toString(16);return e}();await P(e,t,a,i,n);let o=await S(s),c=s===o?"plain":"s256";return[o,c,a]}let N=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function B(e){let t=e.headers.get(n.wA);if(!t||!t.match(N))return null;try{return new Date("".concat(t,"T00:00:00.0Z"))}catch(e){return null}}function L(e){if(!e)throw Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}function D(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw Error("Invalid alg claim")}}let q=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function H(e){if(!q.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function M(e){if(!e.recoveryCodes)throw Error("@supabase/auth-js: the MFA recovery codes API is experimental and disabled by default. Enable it by passing `auth: { experimental: { recoveryCodes: true } }` to createClient (or to the GoTrueClient constructor).")}function F(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;if("symbol"==typeof t){let e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "'.concat(t,'" property of the session object is not supported. Please use getUser() instead.'))},set:(e,t)=>{throw Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))},deleteProperty:(e,t)=>{throw Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))}})}function J(e,t){return new Proxy(e,{get:(e,r,n)=>{if("__isInsecureUserWarningProxy"===r)return!0;if("symbol"==typeof r){let t=r.toString();if("Symbol(Symbol.toPrimitive)"===t||"Symbol(Symbol.toStringTag)"===t||"Symbol(util.inspect.custom)"===t||"Symbol(nodejs.util.inspect.custom)"===t)return Reflect.get(e,r,n)}return t.value||"string"!=typeof r||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(e,r,n)}})}function W(e){return JSON.parse(JSON.stringify(e))}},76942:function(e,t,r){"use strict";function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}r.d(t,{_:function(){return n}})},43551:function(e,t,r){"use strict";r.d(t,{mL:function(){return s}});var n=r(947);globalThis&&(0,n.y1)()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug");
1class s extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}},83180:function(e,t,r){"use strict";function n(){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)}}r.d(t,{Y:function(){return n}})},47656:function(e,t,r){"use strict";r.d(t,{i:function(){return n}});let n="2.117.2"},40194:function(e,t,r){"use strict";function n(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error('@supabase/auth-js: Address "'.concat(e,'" is invalid.'));return e.toLowerCase()}function s(e){return parseInt(e,16)}function i(e){return"0x"+Array.from(new TextEncoder().encode(e),e=>e.toString(16).padStart(2,"0")).join("")}function a(e){var t;let{chainId:r,domain:s,expirationTime:i,issuedAt:a=new Date,nonce:o,notBefore:c,requestId:l,resources:u,scheme:h,uri:d,version:f}=e;if(!Number.isInteger(r))throw Error('@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: '.concat(r));if(!s)throw Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw Error('@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: '.concat(o));if(!d)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==f)throw Error("@supabase/auth-js: Invalid SIWE message field \"version\". Version must be '1'. Provided value: ".concat(f));if(null===(t=e.statement)||void 0===t?void 0:t.includes("\n"))throw Error("@supabase/auth-js: Invalid SIWE message field \"statement\". Statement must not include '\\n'. Provided value: ".concat(e.statement));let p=n(e.address),g=h?"".concat(h,"://").concat(s):s,m=e.statement?"".concat(e.statement,"\n"):"",y="".concat(g," wants you to sign in with your Ethereum account:\n").concat(p,"\n\n").concat(m),v="URI: ".concat(d,"\nVersion: ").concat(f,"\nChain ID: ").concat(r).concat(o?"\nNonce: ".concat(o):"","\nIssued At: ").concat(a.toISOString());if(i&&(v+="\nExpiration Time: ".concat(i.toISOString())),c&&(v+="\nNot Before: ".concat(c.toISOString())),l&&(v+="\nRequest ID: ".concat(l)),u){let e="\nResources:";for(let t of u){if(!t||"string"!=typeof t)throw Error('@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: '.concat(t));e+="\n- ".concat(t)}v+=e}return"".concat(y,"\n").concat(v)}r.d(t,{H_:function(){return s},Kn:function(){return n},NC:function(){return i},eJ:function(){return a}})},50337:function(e,t,r){"use strict";r.d(t,{pw:function(){return k},TD:function(){return m},jl:function(){return y},By:function(){return h},jE:function(){return d},ir:function(){return v},hS:function(){return g},xd:function(){return f},eR:function(){return p},$M:function(){return u}});var n=r(69703),s=r(55249),i=r(28898),a=r(947);class o extends Error{toJSON(){return{name:this.name,message:this.message,code:this.code}}constructor({message:e,code:t,cause:r,name:n}){var s;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=null!==(s=null!=n?n:r instanceof Error?r.name:void 0)&&void 0!==s?s:"Unknown Error",this.code=t}}class c extends o{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}class l{createNewAbortSignal(){if(this.controller){let e=Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}let u=new l;function h(e){if(!e)throw Error("Credential creation options are required");if("undefined"!=typeof PublicKeyCredential&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);let{challenge:t,user:r,excludeCredentials:i}=e,a=(0,n._T)(e,["challenge","user","excludeCredentials"]),o=(0,s.WU)(t).buffer,c=Object.assign(Object.assign({},r),{id:(0,s.WU)(r.id).buffer}),l=Object.assign(Object.assign({},a),{challenge:o,user:c});if(i&&i.length>0){l.excludeCredentials=Array(i.length);for(let e=0;e<i.length;e++){let t=i[e];l.excludeCredentials[e]=Object.assign(Object.assign({},t),{id:(0,s.WU)(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return l}function d(e){if(!e)throw Error("Credential request options are required");if("undefined"!=typeof PublicKeyCredential&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);let{challenge:t,allowCredentials:r}=e,i=(0,n._T)(e,["challenge","allowCredentials"]),a=(0,s.WU)(t).buffer,o=Object.assign(Object.assign({},i),{challenge:a});if(r&&r.length>0){o.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];o.allowCredentials[e]=Object.assign(Object.assign({},t),{id:(0,s.WU)(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return o}function f(e){var t;return"toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():{id:e.id,rawId:e.id,response:{attestationObject:(0,s.rB)(new Uint8Array(e.response.attestationObject)),clientDataJSON:(0,s.rB)(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0}}function p(e){var t;if("toJSON"in e&&"function"==typeof e.toJSON)return e.toJSON();let r=e.getClientExtensionResults(),n=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:(0,s.rB)(new Uint8Array(n.authenticatorData)),clientDataJSON:(0,s.rB)(new Uint8Array(n.clientDataJSON)),signature:(0,s.rB)(new Uint8Array(n.signature)),userHandle:n.userHandle?(0,s.rB)(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0}}function g(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function m(){var e,t;return!!((0,a.jU)()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&"function"==typeof(null===(e=null==navigator?void 0:navigator.credentials)||void 0===e?void 0:e.create)&&"function"==typeof(null===(t=null==navigator?void 0:navigator.credentials)||void 0===t?void 0:t.get))}async function y(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new c("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new c("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function(e){var t,r,n;let{error:s,options:i}=e,{publicKey:a}=i;if(!a)throw Error("options was missing required publicKey property");if("AbortError"===s.name){if(i.signal instanceof AbortSignal)return new o({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:s})}else if("ConstraintError"===s.name){if((null===(t=a.authenticatorSelection)||void 0===t?void 0:t.requireResidentKey)===!0)return new o({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:s});if("conditional"===i.mediation&&(null===(r=a.authenticatorSelection)||void 0===r?void 0:r.userVerification)==="required")return new o({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:s});if((null===(n=a.authenticatorSelection)||void 0===n?void 0:n.userVerification)==="required")return new o({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:s})}else if("InvalidStateError"===s.name)return new o({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:s});else if("NotAllowedError"===s.name)return new o({message:s.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s});else if("NotSupportedError"===s.name)return new o(0===a.pubKeyCredParams.filter(e=>"public-key"===e.type).length?{message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:s}:{message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:s});else if("SecurityError"===s.name){let e=window.location.hostname;if(!g(e))return new o({message:"".concat(window.location.hostname," is an invali
1d domain"),code:"ERROR_INVALID_DOMAIN",cause:s});if(a.rp.id!==e)return new o({message:'The RP ID "'.concat(a.rp.id,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:s})}else if("TypeError"===s.name){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new o({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:s})}else if("UnknownError"===s.name)return new o({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:s});return new o({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s})}({error:t,options:e})}}}async function v(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new c("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new c("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function(e){let{error:t,o
1ptions:r}=e,{publicKey:n}=r;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(r.signal instanceof AbortSignal)return new o({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if("NotAllowedError"===t.name)return new o({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});else if("SecurityError"===t.name){let e=window.location.hostname;if(!g(e))return new o({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rpId!==e)return new o({message:'The RP ID "'.concat(n.rpId,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("UnknownError"===t.name)return new o({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t});return new o({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}({error:t,options:e})}}}let b={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},w={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function E(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];let n=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),s=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),i={};for(let e of t)if(e)for(let t in e){let r=e[t];if(void 0!==r){if(Array.isArray(r))i[t]=r;else if(s(r))i[t]=r;else if(n(r)){let e=i[t];n(e)?i[t]=E(e,r):i[t]=E(r)}else i[t]=r}}return i}class k{async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge(e,t){var r,n,s,a,o;let{factorId:c,webauthn:l,friendlyName:h,signal:d}=e;try{let{data:e,error:i}=await this.client.mfa.challenge({factorId:c,webauthn:l});if(!e)return{data:null,error:i};let f=null!=d?d:u.createNewAbortSignal();if("create"===e.webauthn.type){let{user:t}=e.webauthn.credential_options.publicKey;if(!t.name){if(h)t.name="".concat(t.id,":").concat(h);else{let e=(await this.client.getUser()).data.user,n=(null===(r=null==e?void 0:e.user_metadata)||void 0===r?void 0:r.name)||(null==e?void 0:e.email)||(null==e?void 0:e.id)||"User";t.name="".concat(t.id,":").concat(n)}}t.displayName||(t.displayName=t.name)}switch(e.webauthn.type){case"create":{let r=(n=e.webauthn.credential_options.publicKey,s=null==t?void 0:t.create,E(b,n,s||{})),{data:i,error:a}=await y({publicKey:r,signal:f});if(i)return{data:{factorId:c,challengeId:e.id,webauthn:{type:e.webauthn.type,credential_response:i}},error:null};return{data:null,error:a}}case"request":{let r=(a=e.webauthn.credential_options.publicKey,o=null==t?void 0:t.request,E(w,a,o||{})),{data:n,error:s}=await v(Object.assign(Object.assign({},e.webauthn.credential_options),{publicKey:r,signal:f}));if(n)return{data:{factorId:c,challengeId:e.id,webauthn:{type:e.webauthn.type,credential_response:n}},error:null};return{data:null,error:s}}}}catch(e){if((0,i.f1)(e))return{data:null,error:e};return{data:null,error:new i.Iu("Unexpected error in challenge",e)}}}async _verify(e){let{challengeId:t,factorId:r,webauthn:n}=e;return this.client.mfa.verify({factorId:r,challengeId:t,webauthn:n})}async _authenticate(e,t){let{factorId:r,webauthn:{rpId:n=window.location.hostname,rpOrigins:s=[window.location.origin],signal:a}={}}=e;if(!n)return{data:null,error:new i.l4("rpId is required for WebAuthn authentication")};try{if(!m())return{data:null,error:new i.Iu("Browser does not support WebAuthn",null)};let{data:e,error:o}=await this.challenge({factorId:r,webauthn:{rpId:n,rpOrigins:s},signal:a},{request:t});if(!e)return{data:null,error:o};let{webauthn:c}=e;return this._verify({factorId:r,challengeId:e.challengeId,webauthn:{type:c.type,rpId:n,rpOrigins:s,credential_response:c.credential_response}})}catch(e){if((0,i.f1)(e))return{data:null,error:e};return{data:null,error:new i.Iu("Unexpected error in authenticate",e)}}}async _register(e,t){let{friendlyName:r,webauthn:{rpId:n=window.location.hostname,rpOrigins:s=[window.location.origin],signal:a}={}}=e;if(!n)return{data:null,error:new i.l4("rpId is required for WebAuthn registration")};try{if(!m())return{data:null,error:new i.Iu("Browser does not support WebAuthn",null)};let{data:e,error:o}=await this._enroll({friendlyName:r});if(!e)return await this.client.mfa.listFactors().then(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.all.find(e=>"webauthn"===e.factor_type&&e.friendly_name===r&&"unverified"===e.status)}).then(e=>e?this.client.mfa.unenroll({factorId:null==e?void 0:e.id}):void 0),{data:null,error:o};let{data:c,error:l}=await this._challenge({factorId:e.id,friendlyName:e.friendly_name,webauthn:{rpId:n,rpOrigins:s},signal:a},{create:t});if(!c)return{data:null,error:l};return this._verify({factorId:e.id,challengeId:c.challengeId,webauthn:{rpId:n,rpOrigins:s,type:c.webauthn.type,credential_response:c.webauthn.credential_response}})}catch(e){if((0,i.f1)(e))return{data:null,error:e};return{data:null,error:new i.Iu("Unexpected error in register",e)}}}constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}}},71809:function(e,t,r){"use strict";let n;r.d(t,{A:function(){return A}});var s=r(77969),i=r(75546);let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),o=" \n\r=".split(""),c=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<o.length;t+=1)e[o[t].charCodeAt(0)]=-2;for(let t=0;t<a.length;t+=1)e[a[t].charCodeAt(0)]=t;return e})();function l(e){let t=[],r=0,n=0;if(function(e,t){for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n>55295&&n<=56319){let t=(n-55296)*1024&65535;n=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127){t(e);return}if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>
16&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error("Unrecognized Unicode codepoint: ".concat(e.toString(16)))}(n,t)}}(e,e=>{for(r=r<<8|e,n+=8;n>=6;){let e=r>>n-6&63;t.push(a[e]),n-=6}}),n>0)for(r<<=6-n,n=6;n>=6;){let e=r>>n-6&63;t.push(a[e]),n-=6}return t.join("")}function u(){return void 0!==window.document}i.Qc,i.qC;let h=/^(.*)[.](0|[1-9][0-9]*)$/;function d(e,t){if(e===t)return!0;let r=e.match(h);return!!r&&r[1]===t}function f(e,t,r){let n=null!=r?r:3180,s=encodeURIComponent(t);if(s.length<=n)return[{name:e,value:t}];let i=[];for(;s.length>0;){let e=s.slice(0,n),t=e.lastIndexOf("%");t>n-3&&(e=e.slice(0,t));let r="";for(;e.length>0;)try{r=decodeURIComponent(e);break}catch(t){if(t instanceof URIError&&"%"===e.at(-3)&&e.length>3)e=e.slice(0,e.length-3);else throw t}i.push(r),s=s.slice(e.length)}return i.map((t,r)=>({name:"".concat(e,".").concat(r),value:t}))}async function p(e,t){let r=await t(e);if(r)return r;let n=[];for(let r=0;;r++){let s="".concat(e,".").concat(r),i=await t(s);if(!i)break;n.push(i)}return n.length>0?n.join(""):null}let g={path:"/",sameSite:"lax",httpOnly:!1,maxAge:3456e4},m="base64-",y=/-flow-[A-Za-z0-9_-]{8,64}-code-verifier$/;function v(e){let t;if(!e.startsWith(m))return e;try{t=function(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},n={utf8seq:0,codepoint:0},s=0,i=0;for(let t=0;t<e.length;t+=1){let a=c[e.charCodeAt(t)];if(a>-1)for(s=s<<6|a,i+=6;i>=8;)(function(e,t,r){if(0===t.utf8seq){if(e<=127){r(e);return}for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}})(s>>i-8&255,n,r),i-=8;else if(-2===a)continue;else throw Error('Invalid Base64-URL character "'.concat(e.at(t),'" at position ').concat(t))}return t.join("")}(e.substring(m.length))}catch(e){return console.warn("@supabase/ssr: could not base64url-decode chunked cookie value, treating as absent. Cookie chunks may have been written partially across responses.",e),null}try{JSON.parse(t)}catch(e){return console.warn("@supabase/ssr: chunked cookie decoded to invalid JSON, treating as absent. This usually indicates that cookie chunks from different writes were combined (e.g. response committed before all Set-Cookie headers were sent)."),null}return t}async function b(e,t){var r;let{getAll:n,setAll:s,setItems:i,removedItems:a}=e,o=t.cookieEncoding,c=null!==(r=t.cookieOptions)&&void 0!==r?r:null,u=await n([...i?Object.keys(i):[],...a?Object.keys(a):[]]),h=(null==u?void 0:u.map(e=>{let{name:t}=e;return t}))||[],p=new Map((null==u?void 0:u.map(e=>{let{name:t,value:r}=e;return[t,r]}))||[]),y=Object.keys(a).flatMap(e=>h.filter(t=>d(t,e))),v=Object.keys(i).flatMap(e=>{let t=new Set(h.filter(t=>d(t,e))),r=i[e];"base64url"===o&&(r=m+l(r));let n=f(e,r);return n.forEach(e=>{t.delete(e.name)}),y.push(...t),n}).filter(e=>{let{name:t,value:r}=e;return p.get(t)!==r}),b=y.filter(e=>p.has(e)),w={...g,...c,maxAge:0},E={...g,...c,maxAge:g.maxAge};delete w.name,delete E.name;let k=w.domain&&b.length>0?(()=>{let{domain:e,...t}=w;return t})():null;(0!==b.length||0!==v.length)&&await s([...k?b.map(e=>({name:e,value:"",options:k})):[],...b.map(e=>({name:e,value:"",options:w})),...v.map(e=>{let{name:t,value:r}=e;return{name:t,value:r,options:E}})],{"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"})}let w=new Set;var E=r(49079);let k=!1,S=["@supabase/auth-helpers-nextjs","@supabase/auth-helpers-react","@supabase/auth-helpers-remix","@supabase/auth-helpers-sveltekit"];function A(e,t,r){var a,o,c,h,A,T,O,_,C,P,j,R,x;!function(){var e;if(k||void 0===E||!(null===(e=E.env)||void 0===e?void 0:e.npm_package_name))return;let t=E.env.npm_package_name;S.includes(t)&&(k=!0,console.warn("\nââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ\nâ â ï¸ IMPORTANT: Package Consolidation Notice â\nâ â\nâ The ".concat(t.padEnd(35)," package name is deprecated. â\nâ â\nâ You are now using @supabase/ssr - a unified solution for all frameworks. â\nâ â\nâ The auth-helpers packages have been consolidated into @supabase/ssr â\nâ to provide better maintenance and consistent APIs across frameworks. â\nâ â\nâ Please update your package.json to use @supabase/ssr directly: â\nâ npm uninstall ").concat(t.padEnd(42)," â\nâ npm install @supabase/ssr â\nâ â\nâ For more information, visit: â\nâ https://supabase.com/docs/guides/auth/server-side â\nââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ\n ")))}();let I=(null==r?void 0:r.isSingleton)===!0||(!r||!("isSingleton"in r))&&u();if(I&&n)return n;if(!e||!t)throw Error("@supabase/ssr: Your project's URL and API key are required to create a Supabase client!\n\nCheck your Supabase project's API settings to find these values\n\nhttps://supabase.com/dashboard/project/_/settings/api");(null==r?void 0:null===(a=r.auth)||void 0===a?void 0:a.storage)&&(x="@supabase/ssr: createBrowserClient always manages the session via cookies, so the `auth.storage` option you passed is ignored. If you don't need the session to be readable on the server, use @supabase/supabase-js's createClient directly with your own `storage` instead.",w.has(x)||(w.add(x),console.warn(x)));let{storage:U}=function(e,t){let r,n;let s=e.cookies&&("get"in e.cookies||"getAll"in e.cookies)?e.cookies:null,a=e.cookieEncoding,o={},c={},h=()=>{let e=(0,i.Qc)(document.cookie);return Object.keys(e).map(t=>{var r;return{name:t,value:null!==(r=e[t])&&void 0!==r?r:""}})};if(s){if("get"in s){let e=async e=>{let t=e.flatMap(e=>[e,...Array.from({length:5}).map((t,r)=>"".concat(e,".").concat(r))]),r=[];for(let e=0;e<t.length;e+=1){let n=await s.get(t[e]);(n||"string"==typeof n)&&r.push({name:t[e],value:n})}return r};if(r=async t=>await e(t),"set"in s&&"remove"in s)n=async e=>{for(let t=0;t<e.length;t+=1){let{name:r,value:n,options:i}=e[t];n?await s.set(r,n,i):await s.remove(r,i)}};else if(t)n=async()=>{console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for c
1orrectness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)")}else if("getAll"in s){if(r=async()=>await s.getAll(),"setAll"in s)n=s.setAll;else if(t)n=async()=>{console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)")}else throw Error("@supabase/ssr: ".concat(t?"createServerClient":"createBrowserClient"," requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).").concat(u()?" As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically.":""))}else if(!t&&u())r=()=>h(),n=e=>{e.forEach(e=>{let{name:t,value:r,options:n}=e;document.cookie=(0,i.qC)(t,r,n)})};else if(t)throw Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");else r=()=>[],n=()=>{throw Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed")};if(!t)return{getAll:r,setAll:n,setItems:o,removedItems:c,storage:{isServer:!1,getItem:async e=>{let t=await r([e]),n=await p(e,async e=>{let r=(null==t?void 0:t.find(t=>{let{name:r}=t;return r===e}))||null;return r?r.value:null});return n?v(n):null},setItem:async(t,s)=>{let i=await r([t]),o=(null==i?void 0:i.map(e=>{let{name:t}=e;return t}))||[],c=new Set(o.filter(e=>d(e,t))),u=s;"base64url"===a&&(u=m+l(s));let h=f(t,u);h.forEach(e=>{let{name:t}=e;c.delete(t)});let p={...g,...null==e?void 0:e.cookieOptions,maxAge:0},y={...g,...null==e?void 0:e.cookieOptions,maxAge:g.maxAge};delete p.name,delete y.name;let v=p.domain?(()=>{let{domain:e,...t}=p;return t})():null,b=[...v?[...c].map(e=>({name:e,value:"",options:v})):[],...[...c].map(e=>({name:e,value:"",options:p})),...h.map(e=>{let{name:t,value:r}=e;return{name:t,value:r,options:y}})];b.length>0&&await n(b,{})},removeItem:async t=>{let s=await r([t]),i=((null==s?void 0:s.map(e=>{let{name:t}=e;return t}))||[]).filter(e=>d(e,t));if(0===i.length)return;let a={...g,...null==e?void 0:e.cookieOptions,maxAge:0};delete a.name;let o=a.domain?(()=>{let{domain:e,...t}=a;return t})():null,c=[...o?i.map(e=>({name:e,value:"",options:o})):[],...i.map(e=>({name:e,value:"",options:a}))];await n(c,{})}}};let w=n,E=!1;return{getAll:r,setAll:n=async(e,t)=>{let r=!E&&Object.keys(t).length>0;await w(e,r?t:{}),r&&(E=!0)},setItems:o,removedItems:c,storage:{isServer:!0,getItem:async e=>{if("string"==typeof o[e])return o[e];if(c[e])return null;let t=await r([e]),n=await p(e,async e=>{let r=(null==t?void 0:t.find(t=>{let{name:r}=t;return r===e}))||null;return r?r.value:null});return n?"string"!=typeof n?n:v(n):null},setItem:async(t,s)=>{if(t.endsWith("-code-verifier")){var i;await b({getAll:r,setAll:n,setItems:{[t]:s},removedItems:{}},{cookieOptions:null!==(i=null==e?void 0:e.cookieOptions)&&void 0!==i?i:null,cookieEncoding:a})}o[t]=s,delete c[t]},removeItem:async t=>{var s;(y.test(t)||t.endsWith("-flows-code-verifier"))&&await b({getAll:r,setAll:n,setItems:{},removedItems:{[t]:!0}},{cookieOptions:null!==(s=null==e?void 0:e.cookieOptions)&&void 0!==s?s:null,cookieEncoding:a}),delete o[t],c[t]=!0}}}}({...r,cookieEncoding:null!==(_=null==r?void 0:r.cookieEncoding)&&void 0!==_?_:"base64url"},!1),N=(0,s.createClient)(e,t,{...r,global:{...null==r?void 0:r.global,headers:{...null==r?void 0:null===(o=r.global)||void 0===o?void 0:o.headers,"X-Client-Info":"supabase-ssr/".concat("0.12.7"," createBrowserClient")}},auth:{...null==r?void 0:r.auth,...(null==r?void 0:null===(c=r.cookieOptions)||void 0===c?void 0:c.name)?{storageKey:r.cookieOptions.name}:null,flowType:"pkce",autoRefreshToken:null!==(C=null==r?void 0:null===(h=r.auth)||void 0===h?void 0:h.autoRefreshToken)&&void 0!==C?C:u(),detectSessionInUrl:null!==(P=null==r?void 0:null===(A=r.auth)||void 0===A?void 0:A.detectSessionInUrl)&&void 0!==P?P:u(),persistSession:null===(j=null==r?void 0:null===(T=r.auth)||void 0===T?void 0:T.persistSession)||void 0===j||j,storage:U,...(null==r?void 0:r.cookies)&&"encode"in r.cookies&&"tokens-only"===r.cookies.encode?{userStorage:null!==(R=null==r?void 0:null===(O=r.auth)||void 0===O?void 0:O.userStorage)&&void 0!==R?R:u()?window.localStorage:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}()}:null}});return I&&(n=N),N}},66033:function(e,t){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return(r+n)*3/4-n},t.toByteArray=function(e){var t,r,i=c(e),a=i[0],o=i[1],l=new s((a+o)*3/4-o),u=0,h=o>0?a-4:a;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],l[u++]=t>>16&255,l[u++]=t>>8&255,l[u++]=255&t;return 2===o&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,l[u++]=255&t),1===o&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,s=n%3,i=[],a=0,o=n-s;a<o;a+=16383)i.push(function(e,t,n){for(var s,i=[],a=t;a<n;a+=3)i.push(r[(s=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]))>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return i.join("")}(e,a,a+16383>o?o:a+16383));return 1===s?i.push(r[(t=e[n-1])>>2]+r[t<<4&63]+"=="):2===s&&i.push(r[(t=(e[n-2]<<8)+e[n-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),i.join("")};for(var r=[],n=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
1+/",a=0,o=i.length;a<o;++a)r[a]=i[a],n[i.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},23663:function(e,t,r){"use strict";/*! 2 * The buffer module from node.js, for the browser. 3 * 4 * @author Feross Aboukhadijeh <https://feross.org> 5 * @license MIT 6 */var n=r(66033),s=r(61531),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>2147483647)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return u(e)}return c(e,t,r)}function c(e,t,r){if("string"==typeof e)return function(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!o.isEncoding(t))throw TypeError("Unknown encoding: "+t);var r=0|p(e,t),n=a(r),s=n.write(e,t);return s!==r&&(n=n.slice(0,s)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(P(e,Uint8Array)){var t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return h(e)}(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(P(e,ArrayBuffer)||e&&P(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(P(e,SharedArrayBuffer)||e&&P(e.buffer,SharedArrayBuffer)))return d(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return o.from(n,t,r);var s=function(e){if(o.isBuffer(e)){var t,r=0|f(e.length),n=a(r);return 0===n.length||e.copy(n,0,0,r),n}return void 0!==e.length?"number"!=typeof e.length||(t=e.length)!=t?a(0):h(e):"Buffer"===e.type&&Array.isArray(e.data)?h(e.data):void 0}(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return l(e),a(e<0?0:0|f(e))}function h(e){for(var t=e.length<0?0:0|f(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function d(e,t,r){var n;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),n}function f(e){if(e>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function p(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||P(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return O(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _(e).length;default:if(s)return n?-1:O(e).length;t=(""+t).toLowerCase(),s=!0}}function g(e,t,r){var s,i,a=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var s="",i=t;i<r;++i)s+=j[e[i]];return s}(this,t,r);case"utf8":case"utf-8":return b(this,t,r);case"ascii":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var s=t;s<r;++s)n+=String.fromCharCode(127&e[s]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var s=t;s<r;++s)n+=String.fromCharCode(e[s]);return n}(this,t,r);case"base64":return s=t,i=r,0===s&&i===this.length?n.fromByteArray(this):n.fromByteArray(this.slice(s,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var n=e.slice(t,r),s="",i=0;i<n.length-1;i+=2)s+=String.fromCharCode(n[i]+256*n[i+1]);return s}(this,t,r);default:if(a)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,s){var i;if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),(i=r=+r)!=i&&(r=s?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(s)return -1;r=e.length-1}
vendor: 14,581 bytes, line 6
6else if(r<0){if(!s)return -1;r=0}if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,s);if("number"==typeof t)return(t&=255,"function"==typeof Uint8Array.prototype.indexOf)?s?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,s);throw TypeError("val must be string, number or Buffer")}function v(e,t,r,n,s){var i,a=1,o=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;a=2,o/=2,c/=2,r/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(s){var u=-1;for(i=r;i<o;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*a}else -1!==u&&(i-=i-u),u=-1}else for(r+c>o&&(r=o-c),i=r;i>=0;i--){for(var h=!0,d=0;d<c;d++)if(l(e,i+d)!==l(t,d)){h=!1;break}if(h)return i}return -1}function b(e,t,r){r=Math.min(e.length,r);for(var n=[],s=t;s<r;){var i,a,o,c,l=e[s],u=null,h=l>239?4:l>223?3:l>191?2:1;if(s+h<=r)switch(h){case 1:l<128&&(u=l);break;case 2:(192&(i=e[s+1]))==128&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:i=e[s+1],a=e[s+2],(192&i)==128&&(192&a)==128&&(c=(15&l)<<12|(63&i)<<6|63&a)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=e[s+1],a=e[s+2],o=e[s+3],(192&i)==128&&(192&a)==128&&(192&o)==128&&(c=(15&l)<<18|(63&i)<<12|(63&a)<<6|63&o)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),s+=h}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}function w(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function E(e,t,r,n,s,i){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<i)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function k(e,t,r,n,s,i){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function S(e,t,r,n,i){return t=+t,r>>>=0,i||k(e,t,r,4,34028234663852886e22,-34028234663852886e22),s.write(e,t,r,n,23,4),r+4}function A(e,t,r,n,i){return t=+t,r>>>=0,i||k(e,t,r,8,17976931348623157e292,-17976931348623157e292),s.write(e,t,r,n,52,8),r+8}t.Buffer=o,t.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=2147483647,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return c(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(l(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},o.allocUnsafe=function(e){return u(e)},o.allocUnsafeSlow=function(e){return u(e)},o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(P(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),P(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,s=0,i=Math.min(r,n);s<i;++s)if(e[s]!==t[s]){r=e[s],n=t[s];break}return r<n?-1:n<r?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=o.allocUnsafe(t),s=0;for(r=0;r<e.length;++r){var i=e[r];if(P(i,Uint8Array))s+i.length>n.length?o.from(i).copy(n,s):Uint8Array.prototype.set.call(n,i,s);else if(o.isBuffer(i))i.copy(n,s);else throw TypeError('"list" argument must be an Array of Buffers');s+=i.length}return n},o.byteLength=p,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?b(this,0,e):g.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(e,t,r,n,s){if(P(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),t<0||r>e.length||n<0||s>this.length)throw RangeError("out of range index");if(n>=s&&t>=r)return 0;if(n>=s)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var i=s-n,a=r-t,c=Math.min(i,a),l=this.slice(n,s),u=e.slice(t,r),h=0;h<c;++h)if(l[h]!==u[h]){i=l[h],a=u[h];break}return i<a?-1:a<i?1:0},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)},o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s,i,a,o,c,l,u,h,d=this.length-t;if((void 0===r||r>d)&&(r=d),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var f=!1;;)switch(n){case"hex":return function(e,t,r,n){r=Number(r)||0;var s=e.length-r;n?(n=Number(n))>s&&(n=s):n=s;var i=t.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var o=parseInt(t.substr(2*a,2),16);if(o!=o)break;e[r+a]=o}return a}(this,e,t,r);case"utf8":case"utf-8":return s=t,i=r,C(O(e,this.length-s),this,s,i);case"ascii":case"latin1":case"binary":return a=t,o=r,C(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(e),this,a,o);case"base64":return c=t,l=r,C(_(e),this,c,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u=t,h=r,C(function(e,t){for(var r,n,s=[],i=0;i<e.length&&!((t-=2)<0);++i)n=(r=e.charCodeAt(i))>>8,s.push(r%256),s.push(n);return s}(e,this.length-u),this,u,h);default:if(f)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),f=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUintLE=o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],s=1,i=0;++i<t&&(s*=256);)n+=this[e+i]*s;return n},o.prototype.readUintBE=o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n},o.prototype.readUint8=o.prototype.readUInt8=function(e,t){return e>>>=0,t||w(e,1,this.length),this[e]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],s=1,i=0;++i<t&&(s*=256);)n+=this[e+i]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=t,s=1,i=this[e+--n];n>0&&(s*=256);)i+=this[e+--n]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*t)),i},o.prototype.readInt8=function(e,t){return(e>>>=0,t||w(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||w(e,4,this.length),s.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||w(e,4,this.length),s.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||w(e,8,this.length),s.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||w(e,8,this.length),s.read(this,e,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;E(this,e,t,r,s,0)}var i=1,a=0;for(this[t]=255&e;++a<r&&(i*=256);)this[t+a]=e/i&255;return t+r},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;E(this,e,t,r,s,0)}var i=r-1,a=1;for(this[t+i]=255&e;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+r},o.prototype.writeUint8=o.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var s=Math.pow(2,8*r-1);E(this,e,t,r,s-1,-s)}var i=0,a=1,o=0;for(this[t]=255&e;++i<r&&(a*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var s=Math.pow(2,8*r-1);E(this,e,t,r,s-1,-s)}var i=r-1,a=1,o=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||E(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return S(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return S(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return A(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return A(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var s=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),s},o.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===e.length){var s,i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var a=o.isBuffer(e)?e:o.from(e,n),c=a.length;
6if(0===c)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=a[s%c]}return this};var T=/[^+/0-9A-Za-z-_]/g;function O(e,t){t=t||1/0;for(var r,n=e.length,s=null,i=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!s){if(r>56319||a+1===n){(t-=3)>-1&&i.push(239,191,189);continue}s=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&(t-=3)>-1&&i.push(239,191,189);if(s=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return i}function _(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function C(e,t,r,n){for(var s=0;s<n&&!(s+r>=t.length)&&!(s>=e.length);++s)t[s+r]=e[s];return s}function P(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var j=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var n=16*r,s=0;s<16;++s)t[n+s]=e[r]+e[s];return t}()},75546:function(e,t){"use strict";t.Qc=function(e,t){let r=new o,n=e.length;if(n<2)return r;let s=(null==t?void 0:t.decode)||u,i=0;do{let t=function(e,t,r){let n=e.indexOf("=",t);return n<r?n:-1}(e,i,n);if(-1===t)break;let a=function(e,t,r){let n=e.indexOf(";",t);return -1===n?r:n}(e,i,n);if(t>a){i=e.lastIndexOf(";",t-1)+1;continue}let o=l(e,i,t);void 0===r[o]&&(r[o]=s(l(e,t+1,a))),i=a+1}while(i<n);return r},t.qC=c,t.qC=c;let r=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,n=/^[\u0021-\u003A\u003C-\u007E]*$/,s=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,i=/^[\u0020-\u003A\u003D-\u007E]*$/,a=Object.prototype.toString,o=(()=>{let e=function(){};return e.prototype=Object.create(null),e})();function c(e,t,o){let c="object"==typeof e?e:{...o,name:e,value:String(t)},l="object"==typeof t?t:o,u=(null==l?void 0:l.encode)||encodeURIComponent;if(!r.test(c.name))throw TypeError("argument name is invalid: ".concat(c.name));let h=c.value?u(c.value):"";if(!n.test(h))throw TypeError("argument val is invalid: ".concat(c.value));let d=c.name+"="+h;if(void 0!==c.maxAge){if(!Number.isInteger(c.maxAge))throw TypeError("option maxAge is invalid: ".concat(c.maxAge));d+="; Max-Age="+c.maxAge}if(c.domain){if(!s.test(c.domain))throw TypeError("option domain is invalid: ".concat(c.domain));d+="; Domain="+c.domain}if(c.path){if(!i.test(c.path))throw TypeError("option path is invalid: ".concat(c.path));d+="; Path="+c.path}if(c.expires){var f;if(f=c.expires,"[object Date]"!==a.call(f)||!Number.isFinite(c.expires.valueOf()))throw TypeError("option expires is invali
6d: ".concat(c.expires));d+="; Expires="+c.expires.toUTCString()}if(c.httpOnly&&(d+="; HttpOnly"),c.secure&&(d+="; Secure"),c.partitioned&&(d+="; Partitioned"),c.priority)switch("string"==typeof c.priority?c.priority.toLowerCase():void 0){case"low":d+="; Priority=Low";break;case"medium":d+="; Priority=Medium";break;case"high":d+="; Priority=High";break;default:throw TypeError("option priority is invalid: ".concat(c.priority))}if(c.sameSite)switch("string"==typeof c.sameSite?c.sameSite.toLowerCase():c.sameSite){case!0:case"strict":d+="; SameSite=Strict";break;case"lax":d+="; SameSite=Lax";break;case"none":d+="; SameSite=None";break;default:throw TypeError("option sameSite is invalid: ".concat(c.sameSite))}return d}function l(e,t,r){let n=t,s=r;do{let t=e.charCodeAt(n);if(32!==t&&9!==t)break}while(++n<s);for(;s>n;){let t=e.charCodeAt(s-1);if(32!==t&&9!==t)break;s--}return e.slice(n,s)}function u(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch(t){return e}}},61531:function(e,t){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */t.read=function(e,t,r,n,s){var i,a,o=8*s-n-1,c=(1<<o)-1,l=c>>1,u=-7,h=r?s-1:0,d=r?-1:1,f=e[t+h];for(h+=d,i=f&(1<<-u)-1,f>>=-u,u+=o;u>0;i=256*i+e[t+h],h+=d,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=n;u>0;a=256*a+e[t+h],h+=d,u-=8);if(0===i)i=1-l;else{if(i===c)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),i-=l}return(f?-1:1)*a*Math.pow(2,i-n)},t.write=function(e,t,r,n,s,i){var a,o,c,l=8*i-s-1,u=(1<<l)-1,h=u>>1,d=23===s?5960464477539062e-23:0,f=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(isNaN(t=Math.abs(t))||t===1/0?(o=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+h>=1?t+=d/c:t+=d*Math.pow(2,1-h),t*c>=2&&(a++,c/=2),a+h>=u?(o=0,a=u):a+h>=1?(o=(t*c-1)*Math.pow(2,s),a+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,s),a=0));s>=8;e[r+f]=255&o,f+=p,o/=256,s-=8);for(a=a<<s|o,l+=s;l>0;e[r+f]=255&a,f+=p,a/=256,l-=8);e[r+f-p]|=128*g}},77969:function(e,t,r){"use strict";let n,s,i;r.d(t,{createClient:function(){return tY}});let a=Symbol.for("@supabase/supabase-js.traceContextExtractor");var o,c,l,u,h,d,f,p,g,m,y,v,b,w,E=r(69703);let k=e=>e?function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e(...r)}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch(...t)};class S extends Error{toJSON(){return{name:this.name,message:this.message,context:this.context}}constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}}class A extends S{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class T 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)}}(o=f||(f={})).Any="any",o.ApNortheast1="ap-northeast-1",o.ApNortheast2="ap-northeast-2",o.ApSouth1="ap-south-1",o.ApSoutheast1="ap-southeast-1",o.ApSoutheast2="ap-southeast-2",o.CaCentral1="ca-central-1",o.EuCentral1="eu-central-1",o.EuWest1="eu-west-1",o.EuWest2="eu-west-2",o.EuWest3="eu-west-3",o.SaEast1="sa-east-1",o.UsEast1="us-east-1",o.UsWest1="us-west-1",o.UsWest2="us-west-2";class _{setAuth(e){this.headers.Authorization="Bearer ".concat(e)}invoke(e){return(0,E.mG)(this,arguments,void 0,function*(e){var t,r;let n,s,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let r;let{headers:o,method:c,body:l,signal:u,timeout:h}=a,d={},{region:f}=a;f||(f=this.region);let p=new URL("".concat(this.url,"/").concat(e));f&&"any"!==f&&(d["x-region"]=f,p.searchParams.set("forceFunctionRegion",f));let g=!!o&&Object.keys(o).some(e=>"content-type"===e.toLowerCase());l&&!g?"undefined"!=typeof Blob&&l instanceof Blob||l instanceof ArrayBuffer?(d["Content-Type"]="application/octet-stream",r=l):"string"==typeof l?(d["Content-Type"]="text/plain",r=l):"undefined"!=typeof FormData&&l instanceof FormData?r=l:(d["Content-Type"]="application/json",r=JSON.stringify(l)):r=!l||"string"==typeof l||"undefined"!=typeof Blob&&l instanceof Blob||l instanceof ArrayBuffer||"undefined"!=typeof FormData&&l instanceof FormData?l:JSON.stringify(l);let m=u;h&&(s=new AbortController,n=setTimeout(()=>s.abort(),h),u?(m=s.signal,i=()=>s.abort(),u.addEventListener("abort",i)):m=s.signal);let y=yield this.fetch(p.toString(),{method:c||"POST",headers:Object.assign(Object.assign(Object.assign({},d),this.headers),o),body:r,signal:m}).catch(e=>{throw new A(e)}),v=y.headers.get("x-relay-error");
6if(v&&"true"===v)throw new T(y);if(!y.ok)throw new O(y);let b=(null!==(t=y.headers.get("Content-Type"))&&void 0!==t?t:"text/plain").split(";")[0].trim().toLowerCase();return{data:"application/json"===b?yield y.json():"application/octet-stream"===b||"application/pdf"===b?yield y.blob():"text/event-stream"===b?y:"multipart/form-data"===b?yield y.formData():yield y.text(),error:null,response:y}}catch(e){return{data:null,error:e,response:e instanceof O||e instanceof T?e.context:void 0}}finally{n&&clearTimeout(n),i&&(null===(r=a.signal)||void 0===r||r.removeEventListener("abort",i))}})}constructor(e,{headers:t={},customFetch:r,region:n=f.Any}={}){this.url=e,this.headers=t,this.region=n,this.fetch=k(r)}}var C=class extends Error{toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};let P=e=>Math.min(1e3*2**e,3e4),j=[520,503],R=["GET","HEAD","OPTIONS"];function x(e){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=x(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=x(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==x(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function N(e,t){return new Promise(r=>{if(null==t?void 0:t.aborted){r();return}let n=setTimeout(()=>{null==t||t.removeEventListener("abort",s),r()},e);function s(){clearTimeout(n),r()}null==t||t.addEventListener("abort",s)})}async function B(e,t,r,n){let s=0;for(;;){var i,a,o,c,l;let u;let h=U({},r.headers);s>0&&(h["X-Retry-Count"]=String(s));try{u=await e(t,{method:r.method,headers:h,body:r.body,signal:r.signal})}catch(e){if((null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"||!R.includes(r.method))throw e;if(n&&s<3){let e=P(s);s++,await N(e,r.signal);continue}throw e}if(i=r.method,a=u.status,o=s,n&&!(o>=3)&&R.includes(i)&&j.includes(a)){let e=null!==(c=null===(l=u.headers)||void 0===l?void 0:l.get("Retry-After"))&&void 0!==c?c:null,t=null!==e?1e3*Math.max(0,parseInt(e,10)||0):P(s);await u.text(),s++,await N(t,r.signal);continue}return u}}var L=class{throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if("text/csv"===this.headers.get("Accept"))throw Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(e,t){var r=this;if(void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){let e=this.headers.get("Accept");"application/vnd.pgrst.object+json"===e?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):e&&"application/json"!==e||this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}let n=this.fetch,s=(async()=>{let e={};r.headers.forEach((t,r)=>{e[r]=t});let t=await B(n,r.url.toString(),{method:r.method,headers:e,body:JSON.stringify(r.body,(e,t)=>"bigint"==typeof t?t.toString():t),signal:r.signal},r.retryEnabled);return await r.processResponse(t)})();return this.shouldThrowOnError||(s=s.catch(e=>{var t,r,n,s,i,a;let o="",c="",l="",u=null==e?void 0:e.cause;if(u){let t=null!==(r=null==u?void 0:u.message)&&void 0!==r?r:"",a=null!==(n=null==u?void 0:u.code)&&void 0!==n?n:"";o="".concat(null!==(s=null==e?void 0:e.name)&&void 0!==s?s:"FetchError",": ").concat(null==e?void 0:e.message)+"\n\nCaused by: ".concat(null!==(i=null==u?void 0:u.name)&&void 0!==i?i:"Error",": ").concat(t),a&&(o+=" (".concat(a,")")),(null==u?void 0:u.stack)&&(o+="\n".concat(u.stack))}else o=null!==(a=null==e?void 0:e.stack)&&void 0!==a?a:"";let h=this.url.toString().length;return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"?(l="",c="Request was aborted (timeout or manual cancellation)",h>this.urlLengthLimit&&(c+=". Note: Your request URL is ".concat(h," characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side."))):((null==u?void 0:u.name)==="HeadersOverflowError"||(null==u?void 0:u.code)==="UND_ERR_HEADERS_OVERFLOW")&&(l="",c="HTTP headers exceeded server limits (typically 16KB)",h>this.urlLengthLimit&&(c+=". Your request URL is ".concat(h," characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead."))),{success:!1,error:{message:"".concat(null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError",": ").concat(null==e?void 0:e.message),details:o,hint:c,code:l},data:null,count:null,status:0,statusText:""}}
6)),s.then(e,t)}async processResponse(e){var t,r,n,s;let i=null,a=null,o=null,c=e.status,l=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();if(""===t);else if("text/csv"===this.headers.get("Accept"))a=t;else if(this.headers.get("Accept")&&(null===(n=this.headers.get("Accept"))||void 0===n?void 0:n.includes("application/vnd.pgrst.plan+text")))a=t;else try{a=JSON.parse(t)}catch(e){if(i={message:t},a=null,this.shouldThrowOnError)throw new C({message:t,details:"",hint:"",code:""})}}let u=null===(t=this.headers.get("Prefer"))||void 0===t?void 0:t.match(/count=(exact|planned|estimated)/),h=null===(r=e.headers.get("content-range"))||void 0===r?void 0:r.split("/");if(u&&h&&h.length>1&&(o=parseInt(h[1])),this.isMaybeSingle&&Array.isArray(a)){if(a.length>1){if(i={code:"PGRST116",details:"Results contain ".concat(a.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},a=null,o=null,c=406,l="Not Acceptable",this.shouldThrowOnError)throw new C(U(U({},i),{},{hint:null!==(s=i.hint)&&void 0!==s?s:""}))}else a=1===a.length?a[0]:null}}else{let t=await e.text();try{i=JSON.parse(t),Array.isArray(i)&&404===e.status&&(a=[],i=null,c=200,l="OK")}catch(r){404===e.status&&""===t?(c=204,l="No Content"):i={message:t}}if(i&&this.shouldThrowOnError)throw new C(i)}return{success:null===i,error:i,data:a,count:o,status:c,statusText:l}}returns(){return this}overrideTypes(){return this}constructor(e){var t,r,n,s,i;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(r=e.isMaybeSingle)&&void 0!==r&&r,this.shouldStripNulls=null!==(n=e.shouldStripNulls)&&void 0!==n&&n,this.urlLengthLimit=null!==(s=e.urlLengthLimit)&&void 0!==s?s:8e3,this.retryEnabled=null===(i=e.retry)||void 0===i||i,e.fetch?this.fetch=e.fetch:this.fetch=fetch}},D=class extends L{throwOnError(){return super.throwOnError()}select(e){let t=!1,r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e){let{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:s=n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=s?"".concat(s,".order"):"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,"".concat(a?"".concat(a,","):"").concat(e,".").concat(t?"asc":"desc").concat(void 0===r?"":r?".nullsfirst":".nullslast")),this}limit(e){let{foreignTable:t,referencedTable:r=t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.url.searchParams.set(void 0===r?"limit":"".concat(r,".limit"),"".concat(e)),this}range(e,t){let{foreignTable:r,referencedTable:n=r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=void 0===n?"offset":"".concat(n,".offset"),i=void 0===n?"limit":"".concat(n,".limit");return this.url.searchParams.set(s,"".concat(e)),this.url.searchParams.set(i,"".concat(t-e+1)),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain(){var e;let{analyze:t=!1,verbose:r=!1,settings:n=!1,buffers:s=!1,wal:i=!1,format:a="text"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=[t?"analyze":null,r?"verbose":null,n?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),c=null!==(e=this.headers.get("Accept"))&&void 0!==e?e:"application/json";return this.headers.set("Accept","application/vnd.pgrst.plan+".concat(a,'; for="').concat(c,'"; options=').concat(o,";")),this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer","max-affected=".concat(e)),this}};let q=RegExp("[,()]");var H=class extends D{throwOnError(){return super.throwOnError()}eq(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this}neq(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this}gt(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this}gte(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this}lt(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this}lte(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this}like(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this}likeAllOf(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this}likeAnyOf(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this}ilike(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this}regexMatch(e,t){return this.url.searchParams.append(e,"match.".concat(t)),this}regexIMatch(e,t){return this.url.searchParams.append(e,"imatch.".concat(t)),this}is(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this}isDistinct(e,t){return this.url.searchParams.append(e,"isdistinct.".concat(t)),this}in(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&q.test(e)?'"'.concat(e,'"'):"".concat(e)).join(",");return this.url.searchParams.append(e,"in.(".concat(r,")")),this}notIn(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&q.test(e)?'"'.concat(e,'"'):"".concat(e)).join(",");return this.url.searchParams.append(e,"not.in.(".concat(r,")")),this}contains(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this}containedBy(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this}rangeGt(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this}rangeGte(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this}rangeLt(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this}rangeLte(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this}overlaps(e,t){return"string"==typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this}
6textSearch(e,t){let{config:r,type:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s="";return"plain"===n?s="pl":"phrase"===n?s="ph":"websearch"===n&&(s="w"),this.url.searchParams.append(e,"".concat(s,"fts").concat(void 0===r?"":"(".concat(r,")"),".").concat(t)),this}match(e){return Object.entries(e).filter(e=>{let[t,r]=e;return void 0!==r}).forEach(e=>{let[t,r]=e;this.url.searchParams.append(t,"eq.".concat(r))}),this}not(e,t,r){return this.url.searchParams.append(e,"not.".concat(t,".").concat(r)),this}or(e){let{foreignTable:t,referencedTable:r=t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.url.searchParams.append(r?"".concat(r,".or"):"or","(".concat(e,")")),this}filter(e,t,r){return this.url.searchParams.append(e,"".concat(t,".").concat(r)),this}},M=class{cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){let{head:r=!1,count:n}=null!=t?t:{},s=!1,i=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!s?"":('"'===e&&(s=!s),e)).join(""),{url:a,headers:o}=this.cloneRequestState();return a.searchParams.set("select",i),n&&o.append("Prefer","count=".concat(n)),new H({method:r?"HEAD":"GET",url:a,headers:o,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e){var t;let{count:r,defaultToNull:n=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{url:s,headers:i}=this.cloneRequestState();if(r&&i.append("Prefer","count=".concat(r)),n||i.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>'"'.concat(e,'"'));s.searchParams.set("columns",e.join(","))}}return new H({method:"POST",url:s,headers:i,schema:this.schema,body:e,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e){var t;let{onConflict:r,ignoreDuplicates:n=!1,count:s,defaultToNull:i=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{url:a,headers:o}=this.cloneRequestState();if(o.append("Prefer","resolution=".concat(n?"ignore":"merge","-duplicates")),void 0!==r&&a.searchParams.set("on_conflict",r),s&&o.append("Prefer","count=".concat(s)),i||o.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>'"'.concat(e,'"'));a.searchParams.set("columns",e.join(","))}}return new H({method:"POST",url:a,headers:o,schema:this.schema,body:e,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e){var t;let{count:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{url:n,headers:s}=this.cloneRequestState();return r&&s.append("Prefer","count=".concat(r)),new H({method:"PATCH",url:n,headers:s,schema:this.schema,body:e,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete(){var e;let{count:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{url:r,headers:n}=this.cloneRequestState();return t&&n.append("Prefer","count=".concat(t)),new H({method:"DELETE",url:r,headers:n,schema:this.schema,fetch:null!==(e=this.fetch)&&void 0!==e?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}constructor(e,{headers:t={},schema:r,fetch:n,urlLengthLimit:s=8e3,retry:i}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n,this.urlLengthLimit=s,this.retry=i}};function F(e,t,r){var n;return{success:!1,error:new C({message:"".concat(null!==(n=null==e?void 0:e.name)&&void 0!==n?n:"FetchError",": ").concat(null==e?void 0:e.message),details:"",hint:"",code:""}),data:null,count:null,status:t,statusText:r}}var J=class e{from(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");return new M(new URL("".concat(this.url,"/").concat(e)),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new e(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}async getOpenApiSpec(){var e,t;let r,n;let s=new Headers(this.headers);s.set("Accept","application/openapi+json"),this.schemaName&&s.set("Accept-Profile",this.schemaName);let i={};
6s.forEach((e,t)=>{i[t]=e});let a=null!==(e=this.fetch)&&void 0!==e?e:globalThis.fetch;try{r=await B(a,"".concat(this.url,"/"),{method:"GET",headers:i},null===(t=this.retry)||void 0===t||t)}catch(e){return F(e,0,"")}try{n=await r.text()}catch(e){return F(e,r.status,r.statusText)}if(r.ok)try{return{success:!0,error:null,data:JSON.parse(n),count:null,status:r.status,statusText:r.statusText}}catch(e){}return{success:!1,error:function(e,t){try{let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t)){var r,n,s,i;return new C({message:String(null!==(r=t.message)&&void 0!==r?r:e),details:null!==(n=t.details)&&void 0!==n?n:"",hint:null!==(s=t.hint)&&void 0!==s?s:"",code:null!==(i=t.code)&&void 0!==i?i:""})}}catch(e){}return new C({message:e||t,details:"",hint:"",code:""})}(n,r.statusText),data:null,count:null,status:r.status,statusText:r.statusText}}rpc(e){var t;let r,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{head:i=!1,get:a=!1,count:o}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=new URL("".concat(this.url,"/rpc/").concat(e)),l=e=>null!==e&&"object"==typeof e&&(!Array.isArray(e)||e.some(l)),u=i&&Object.values(s).some(l);u?(r="POST",n=s):i||a?(r=i?"HEAD":"GET",Object.entries(s).filter(e=>{let[t,r]=e;return void 0!==r}).map(e=>{let[t,r]=e;return[t,Array.isArray(r)?"{".concat(r.join(","),"}"):"".concat(r)]}).forEach(e=>{let[t,r]=e;c.searchParams.append(t,r)})):(r="POST",n=s);let h=new Headers(this.headers);return u?h.set("Prefer",o?"count=".concat(o,",return=minimal"):"return=minimal"):o&&h.set("Prefer","count=".concat(o)),new H({method:r,url:c,headers:h,schema:this.schemaName,body:n,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}constructor(e,{headers:t={},schema:r,fetch:n,timeout:s,urlLengthLimit:i=8e3,retry:a}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.urlLengthLimit=i;let o=null!=n?n:globalThis.fetch;void 0!==s&&s>0?this.fetch=(e,t)=>{let r=new AbortController,n=setTimeout(()=>r.abort(),s),i=null==t?void 0:t.signal;if(i){if(i.aborted)return clearTimeout(n),o(e,t);let s=()=>{clearTimeout(n),r.abort()};return i.addEventListener("abort",s,{once:!0}),o(e,U(U({},t),{},{signal:r.signal})).finally(()=>{clearTimeout(n),i.removeEventListener("abort",s)})}return o(e,U(U({},t),{},{signal:r.signal})).finally(()=>clearTimeout(n))}:this.fetch=o,this.retry=a}};class W{static detectEnvironment(){var e;if("undefined"!=typeof WebSocket)return{type:"native",wsConstructor:WebSocket};let t=globalThis;if("undefined"!=typeof globalThis&&void 0!==t.WebSocket)return{type:"native",wsConstructor:t.WebSocket};let n=void 0!==r.g?r.g:void 0;if(n&&void 0!==n.WebSocket)return{type:"native",wsConstructor:n.WebSocket};if("undefined"!=typeof globalThis&&void 0!==t.WebSocketPair&&void 0===globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("undefined"!=typeof globalThis&&t.EdgeRuntime||"undefined"!=typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};let s=globalThis.process;if(s){let e=s.versions;if(e&&e.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){let e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+="\n\nSuggested solution: ".concat(e.workaround)),Error(t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type}catch(e){return!1}}constructor(){}}let V="realtime-js/".concat("2.117.2"),G="2.0.0",K={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},z={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"},Y={connecting:"connecting",closing:"closing",closed:"closed"};class ${encode(e,t){return e.event!==this.BROADCAST_EVENT||e.payload instanceof ArrayBuffer||"string"!=typeof e.payload.event?t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload])):t(this._binaryEncodeUserBroadcastPush(e))}_binaryEncodeUserBroadcastPush(e){var t;return this._isArrayBuffer(null===(t=e.payload)||void 0===t?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var t,r;let n=null!==(r=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==r?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var t,r;let n=null!==(r=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==r?r:{},s=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,s)}_encodeUserBroadcastPush(e,t,r){let n=new TextEncoder,s=n.encode(e.topic),i=n.encode(null!==(g=e.ref)&&void 0!==g?g:""),a=n.encode(null!==(m=e.join_ref)&&void 0!==m?m:""),o=n.encode(e.payload.event),c=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},l=n.encode(0===Object.keys(c).length?"":JSON.stringify(c));if(a.length>255)throw Error("joinRef length ".concat(a.length," exceeds maximum of 255"));if(i.length>255)throw Error("ref length ".concat(i.length," exceeds maximum of 255"));if(s.length>255)throw Error("topic length ".concat(s.length," exceeds maximum of 255"));if(o.length>255)throw Error("userEvent length ".concat(o.length," exceeds maximum of 255"));if(l.length>255)throw Error("metadata length ".concat(l.length," exceeds maximum of 255"));let u=this.USER_BROADCAST_PUSH_META_LENGTH+a.length+i.length+s.length+o.length+l.length,h=new ArrayBuffer(this.HEADER_LENGTH+u),d=new DataView(
6h),f=new Uint8Array(h),p=0;d.setUint8(p++,this.KINDS.userBroadcastPush),d.setUint8(p++,a.length),d.setUint8(p++,i.length),d.setUint8(p++,s.length),d.setUint8(p++,o.length),d.setUint8(p++,l.length),d.setUint8(p++,t),f.set(a,p),p+=a.length,f.set(i,p),p+=i.length,f.set(s,p),p+=s.length,f.set(o,p),p+=o.length,f.set(l,p),p+=l.length;var g,m,y=new Uint8Array(h.byteLength+r.byteLength);return y.set(new Uint8Array(h),0),y.set(new Uint8Array(r),h.byteLength),y.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let[r,n,s,i,a]=JSON.parse(e);return t({join_ref:r,ref:n,topic:s,event:i,payload:a})}return t({})}_binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),n=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,n)}_decodeUserBroadcast(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+4,c=r.decode(e.slice(o,o+n));o+=n;let l=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+i));o+=i;let h=e.slice(o,e.byteLength),d=a===this.JSON_ENCODING?JSON.parse(r.decode(h)):h,f={type:this.BROADCAST_EVENT,event:l,payload:d};return i>0&&(f.meta=JSON.parse(u)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:f}}_isArrayBuffer(e){var t;return e instanceof ArrayBuffer||(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)==="ArrayBuffer"}_pick(e,t){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(e=>{let[r]=e;return t.includes(r)})):{}}constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=e?e:[]}}(c=p||(p={})).abstime="abstime",c.bool="bool",c.date="date",c.daterange="daterange",c.float4="float4",c.float8="float8",c.int2="int2",c.int4="int4",c.int4range="int4range",c.int8="int8",c.int8range="int8range",c.json="json",c.jsonb="jsonb",c.money="money",c.numeric="numeric",c.oid="oid",c.reltime="reltime",c.text="text",c.time="time",c.timestamp="timestamp",c.timestamptz="timestamptz",c.timetz="timetz",c.tsrange="tsrange",c.tstzrange="tstzrange";let X=function(e,t){var r;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=null!==(r=n.skipTypes)&&void 0!==r?r:[];return t?Object.keys(t).reduce((r,n)=>(r[n]=Q(n,e,t,s),r),{}):{}},Q=(e,t,r,n)=>{let s=t.find(t=>t.name===e),i=null==s?void 0:s.type,a=r[e];return i&&!n.includes(i)?Z(i,a):ee(a)},Z=(e,t)=>{if("_"===e.charAt(0))return es(t,e.slice(1,e.length));switch(e){case p.bool:return et(t);case p.float4:case p.float8:case p.int2:case p.int4:case p.int8:case p.numeric:case p.oid:return er(t);case p.json:case p.jsonb:return en(t);case p.timestamp:return ei(t);case p.abstime:case p.date:case p.daterange:case p.int4range:case p.int8range:case p.money:case p.reltime:case p.text:case p.time:case p.timestamptz:case p.timetz:case p.tsrange:case p.tstzrange:default:return ee(t)}},ee=e=>e,et=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},er=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},en=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e},es=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,n=e[r];if("{"===e[0]&&"}"===n){let n;let s=e.slice(1,r);try{n=JSON.parse("["+s+"]")}catch(e){n=s?s.split(","):[]}return n.map(e=>Z(t,e))}return e},ei=e=>"string"==typeof e?e.replace(" ","T"):e,ea=e=>{let t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),""===t.pathname||"/"===t.pathname?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};var eo=e=>"function"==typeof e?e:function(){return e},ec="undefined"!=typeof self?self:null,el=window,eu=ec||el||globalThis,eh={connecting:0,open:1,closing:2,closed:3},ed={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ef={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},ep={longpoll:"longpoll",websocket:"websocket"},eg="base64url.bearer.phx.",em=class{resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,j
6oin_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive(e){let{status:t,response:r,_ref:n}=e;this.recHooks.filter(e=>e.status===t).forEach(e=>e.callback(r))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}constructor(e,t,r,n){this.channel=e,this.event=t,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=n,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}},ey=class{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))}constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}},ev=class{join(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;if(!this.joinedOnce)return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush;throw Error("tried to join multiple times. 'join' can only be called a single time per channel instance")}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=ed.closed,this.bindings=[]}onClose(e){this.on(ef.close,e)}onError(e){return this.on(ef.error,t=>e(t))}on(e,t){let r=this.bindingRef++;return this.bindings.push({event:e,ref:r,callback:t}),r}off(e,t){this.bindings=this.bindings.filter(r=>!(r.event===e&&(void 0===t||t===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.timeout;if(t=t||{},!this.joinedOnce)throw Error("tried to push '".concat(e,"' to '").concat(this.topic,"' before joining. Use channel.join() before pushing events"));let n=new em(this,e,function(){return t},r);return this.canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}leave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=ed.leav
6ing;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel","leave ".concat(this.topic)),this.trigger(ef.close,"leave")},r=new em(this,ef.leave,eo({}),e);return r.receive("ok",()=>t()).receive("timeout",()=>t()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(e,t,r){return t}filterBindings(e,t,r){return!0}isMember(e,t,r,n){return this.topic===e&&(!n||n===this.joinRef()||(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:r,joinRef:n}),!1))}joinRef(){return this.joinPush.ref}rejoin(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=ed.joining,this.joinPush.resend(e))}trigger(e,t,r,n){let s=this.onMessage(e,t,r,n);if(t&&!s)throw Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(n=>n.event===e&&this.filterBindings(n,t,r));for(let e=0;e<i.length;e++)i[e].callback(s,r,n||this.joinRef())}replyEventName(e){return"chan_reply_".concat(e)}isClosed(){return this.state===ed.closed}isErrored(){return this.state===ed.errored}isJoined(){return this.state===ed.joined}isJoining(){return this.state===ed.joining}isLeaving(){return this.state===ed.leaving}constructor(e,t,r){this.state=ed.closed,this.topic=e,this.params=eo(t||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new em(this,ef.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new ey(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=ed.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=ed.errored,this.socket.hasLogger()&&this.socket.log("channel","error ".concat(this.topic),e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel","close ".concat(this.topic)),this.state=ed.closed,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel","error ".concat(this.topic),e),this.isJoining()&&this.joinPush.reset(),this.state=ed.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel","timeout ".concat(this.topic),this.joinPush.timeout),new em(this,ef.leave,eo({}),this.timeout).send(),this.state=ed.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(ef.reply,(e,t)=>{this.trigger(this.replyEventName(t),e)})}},eb=class{static request(e,t,r,n,s,i,a){if(eu.XDomainRequest){let r=new eu.XDomainRequest;return this.xdomainRequest(r,e,t,n,s,i,a)}if(eu.XMLHttpRequest){let o=new eu.XMLHttpRequest;return this.xhrRequest(o,e,t,r,n,s,i,a)}if(eu.fetch&&eu.AbortController)return this.fetchRequest(e,t,r,n,s,i,a);throw Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,r,n,s,i,a){let o={method:e,headers:r,body:n},c=null;return s&&(c=new AbortController,setTimeout(()=>c.abort(),s),o.signal=c.signal),eu.fetch(t,o).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>a&&a(e)).catch(e=>{"AbortError"===e.name&&i?i():a&&a(null)}),c}static xdomainRequest(e,t,r,n,s,i,a){return e.timeout=s,e.open(t,r),e.onload=()=>{let t=this.parseJSON(e.responseText);a&&a(t)},i&&(e.ontimeout=i),e.onprogress=()=>{},e.send(n),e}static xhrRequest(e,t,r,n,s,i,a,o){for(let[s,a]of(e.open(t,r,!0),e.timeout=i,Object.entries(n)))e.setRequestHeader(s,a);return e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{4===e.readyState&&o&&o(this.parseJSON(e.responseText))},a&&(e.ontimeout=a),e.send(s),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch(t){return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let r=[];for(var n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let s=t?"".concat(t,"[").concat(n,"]"):n,i=e[n];"object"==typeof i?r.push(this.serialize(i,s)):r.push(encodeURIComponent(s)+"="+encodeURIComponent(i))}return r.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?";return"".concat(e).concat(r).concat(this.serialize(t))}},ew=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let e=0;e<n;e++)t+=String.fromCharCode(r[e]);return btoa(t)},eE=class{normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(RegExp("(.*)/"+ep.websocket),"$1/"+ep.longpoll)}endpointURL(){return eb.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,r){this.close(e,t,r),this.readyState=eh.connecting}
6ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===eh.open||this.readyState===eh.connecting}poll(){let e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:r,messages:n}=e;if(410===t&&null!==this.token){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=r}else t=0;switch(t){case 200:n.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=eh.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw Error("unhandled poll status ".concat(t))}})}send(e){"string"!=typeof e&&(e=ew(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.awaitingBatchAck=!0;let r=t+100,n=e.slice(t,r);this.ajax("POST",{"Content-Type":"application/x-ndjson"},n.join("\n"),()=>
6this.onerror("timeout"),t=>{t&&200===t.status?r<e.length?this.batchSend(e,r):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1:(this.awaitingBatchAck=!1,this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,r){for(let e of this.reqs)e.abort();this.readyState=eh.closed;let n=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"undefined"!=typeof CloseEvent?this.onclose(new CloseEvent("close",n)):this.onclose(n)}ajax(e,t,r,n,s){let i;i=eb.request(e,this.endpointURL(),t,r,this.timeout,()=>{this.reqs.delete(i),n()},e=>{this.reqs.delete(i),this.isActive()&&s(e)}),this.reqs.add(i)}constructor(e,t){t&&2===t.length&&t[1].startsWith(eg)&&(this.authToken=atob(t[1].slice(eg.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=eh.connecting,setTimeout(()=>this.poll(),0)}},ek=class e{onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,r,n){let s=this.toNullProtoObj(this.clone(e));t=this.toNullProtoObj(t);let i=Object.create(null),a=Object.create(null);return this.map(s,(e,r)=>{t[e]||(a[e]=r)}),this.map(t,(e,t)=>{let r=s[e];if(r){let n=t.metas.map(e=>e.phx_ref),s=r.metas.map(e=>e.phx_ref),o=t.metas.filter(e=>0>s.indexOf(e.phx_ref)),c=r.metas.filter(e=>0>n.indexOf(e.phx_ref));o.length>0&&(i[e]=t,i[e].metas=o),c.length>0&&(a[e]=this.clone(r),a[e].metas=c)}else i[e]=t}),this.syncDiff(s,{joins:i,leaves:a},r,n)}static syncDiff(e,t,r,n){e=this.toNullProtoObj(e);let{joins:s,leaves:i}=this.clone(t);return r||(r=function(){}),n||(n=function(){}),this.map(s,(t,n)=>{let s=e[t];if(e[t]=this.clone(n),s){let r=e[t].metas.map(e=>e.phx_ref),n=s.metas.filter(e=>0>r.indexOf(e.phx_ref));e[t].metas.unshift(...n)}r(t,s,n)}),this.map(i,(t,r)=>{let s=e[t];if(!s)return;let i=r.metas.map(e=>e.phx_ref);s.metas=s.metas.filter(e=>0>i.indexOf(e.phx_ref)),n(t,s,r),0===s.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,r)=>t(e,r))}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static toNullProtoObj(e){if(null===Object.getPrototypeOf(e))return e;let t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=e[r]}),t}static clone(e){return JSON.parse(JSON.stringify(e))}constructor(t,r={}){let n=r.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(n.state,t=>{let{onJoin:r,onLeave:n,onSync:s}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,r,n),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,r,n)}),this.pendingDiffs=[],s()}),this.channel.on(n.diff,t=>{let{onJoin:r,onLeave:n,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,r,n),s())})}},eS={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){return e.payload.constructor===ArrayBuffer?t(this.binaryEncode(e)):t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload]))},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[r,n,s,i,a]=JSON.parse(e);return t({join_ref:r,ref:n,topic:s,event:i,payload:a})}},binaryEncode(e){let{join_ref:t,ref:r,event:n,topic:s,payload:i}=e,a=new TextEncoder,o=a.encode(t),c=a.encode(r),l=a.encode(s),u=a.encode(n);this.assertFieldSize(o.byteLength,"join_ref"),this.assertFieldSize(c.byteLength,"ref"),this.assertFieldSize(l.byteLength,"topic"),this.assertFieldSize(u.byteLength,"event");let h=this.META_LENGTH+o.byteLength+c.byteLength+l.byteLength+u.byteLength,d=new ArrayBuffer(this.HEADER_LENGTH+h),f=new Uint8Array(d),p=new DataView(d),g=0;p.setUint8(g++,this.KINDS.push),p.setUint8(g++,o.byteLength),p.setUint8(g++,c.byteLength),p.setUint8(g++,l.byteLength),p.setUint8(g++,u.byteLength),f.set(o,g),g+=o.byteLength,f.set(c,g),g+=c.byteLength,f.set(l,g),g+=l.byteLength,f.set(u,g),g+=u.byteLength;var m=new Uint8Array(d.byteLength+i.byteLength);return m.set(f,0),m.set(new Uint8Array(i),d.byteLength),m.buffer},assertFieldSize(e,t){if(e>255)throw Error("unable to convert ".concat(t," to binary: must be less than or equal to 255 bytes, but is ").concat(e," bytes"))},binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),n=new TextDecoder;
6switch(r){case this.KINDS.push:return this.decodePush(e,t,n);case this.KINDS.reply:return this.decodeReply(e,t,n);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,n)}},decodePush(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=t.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(e.slice(a,a+n));a+=n;let c=r.decode(e.slice(a,a+s));a+=s;let l=r.decode(e.slice(a,a+i));return a+=i,{join_ref:o,ref:null,topic:c,event:l,payload:e.slice(a,e.byteLength)}},decodeReply(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,c=r.decode(e.slice(o,o+n));o+=n;let l=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+i));o+=i;let h=r.decode(e.slice(o,o+a));o+=a;let d=e.slice(o,e.byteLength);return{join_ref:c,ref:l,topic:u,event:ef.reply,payload:{status:h,response:d}}},decodeBroadcast(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=this.HEADER_LENGTH+2,a=r.decode(e.slice(i,i+n));i+=n;let o=r.decode(e.slice(i,i+s));return i+=s,{join_ref:null,ref:null,topic:a,event:o,payload:e.slice(i,e.byteLength)}}},eA=class{getLongPollTransport(){return eE}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=eb.appendParams(eb.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?"".concat(this.protocol(),":").concat(e):"".concat(this.protocol(),"://").concat(location.host).concat(e)}disconnect(e,t,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,r)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=eo(e)),(!this.conn||this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==eE?this.connectWithF
6allback(eE,this.longPollFallbackMs):this.transportConnect())}log(e,t,r){this.logger&&this.logger(e,t,r)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let n=this.onMessage(s=>{s.ref===t&&(this.off([n]),e(Date.now()-r))});return!0}transportName(e){return e===eE?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix","".concat(eg).concat(btoa(this.authToken()).replace(/=/g,""))]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e){let t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2500;clearTimeout(this.fallbackTimer);let s=!1,i=!0,a=this.transportName(e),o=n=>{this.log("transport","falling back to ".concat(a,"..."),n),this.off([t,r]),i=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession("phx:fallback:".concat(a)))return o("memorized");this.fallbackTimer=setTimeout(o,n),r=this.onError(e=>{this.log("transport","error",e),i&&!s&&(clearTimeout(this.fallbackTimer),o(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(s=!0,!i){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession("phx:fallback:".concat(t),"true"),this.log("transport","established ".concat(t," fallback"))}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,n),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport","connected to ".concat(this.endPointURL())),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,r){if(!this.conn)return e&&e();let n=this.conn;this.waitForBufferDone(n,()=>{t?n.close(t,r||""):n.close(),this.waitForSocketClosed(n,()=>{this.conn===n&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(5===r||!e.bufferedAmount){t();return}setTimeout(()=>{this.waitForBufferDone(e,t,r+1)},150*r)}waitForSocketClosed(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(5===r||e.readyState===eh.closed){t();return}setTimeout(()=>{this.waitForSocketClosed(e,t,r+1)},150*r)}
6onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",e,t,r),(t===this.transport||r>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(ef.error,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case eh.connecting:return"connecting";case eh.open:return"open";case eh.closing:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(t=>{let[r]=t;return -1===e.indexOf(r)})}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new ev(e,t,this);return this.channels.push(r),r}push(e){if(this.hasLogger()){let{topic:t,event:r,payload:n,ref:s,join_ref:i}=e;this.log("push","".concat(t," ").concat(r," (").concat(i,", ").concat(s,")"),n)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:r,payload:n,ref:s,join_ref:i}=e;if(s&&s===this.pendingHeartbeatRef){let e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===n.status?"ok":"error",e)}catch(e){this.log("error","error in heartbeat callback",e)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive","".concat(n.status||""," ").concat(t," ").concat(r," ").concat(s&&"("+s+")"||"").trim(),n);for(let e=0;e<this.channels.length;e++){let a=this.channels[e];a.isMember(t,r,n,i)&&a.trigger(r,n,s,i)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];try{this.stateChangeCallbacks[e].forEach(t=>{let[n,s]=t;try{s(...r)}catch(t){this.log("error","error in ".concat(e," callback"),t)}})}catch(t){this.log("error","error triggering ".concat(e," callbacks"),t)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",'leaving duplicate topic "'.concat(e,'"')),t.leave())}constructor(e,t={}){var r,n;this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||1e4,this.transport=t.transport||eu.WebSocket||eE,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let s=null;try{s=eu&&eu.sessionStorage}catch(e){}this.sessionStore=t.sessionStorage||s,this.establishedConnections=0,this.defaultEncoder=eS.encode.bind(eS),this.defaultDecoder=eS.decode.bind(eS),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==eE?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;el&&el.addEventListener&&(el.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),i=this.connectClock)}),el.addEventListener("pageshow",e=>{i===this.connectClock&&(i=null,this.connect())}),el.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=null===(r=t.autoSendHeartbeat)||void 0===r||r,this.heartbeatCallback=null!==(n=t.heartbeatCallback)&&void 0!==n?n:()=>{},this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,r)=>{console.log("".concat(e,": ").concat(t),r)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=eo(t.params||{}),this.endPoint="".concat(e,"/").concat(ep.websocket),this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new ey(()=>
6{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken&&eo(t.authToken)}};class eT{get state(){return eT.transformState(this.presence.state)}static transformState(e){return Object.getOwnPropertyNames(e=JSON.parse(JSON.stringify(e))).reduce((t,r)=>{let n=e[r];return t[r]=eO(n),t},{})}static onJoinPayload(e,t,r){return{event:"join",key:e,currentPresences:e_(t),newPresences:eO(r)}}static onLeavePayload(e,t,r){return{event:"leave",key:e,currentPresences:e_(t),leftPresences:eO(r)}}constructor(e,t){let r=(null==t?void 0:t.events)&&{events:t.events};this.presence=new ek(e.getChannel(),r),this.presence.onJoin((t,r,n)=>{let s=eT.onJoinPayload(t,r,n);e.getChannel().trigger("presence",s)}),this.presence.onLeave((t,r,n)=>{let s=eT.onLeavePayload(t,r,n);e.getChannel().trigger("presence",s)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}}function eO(e){return e.metas.map(e=>{let t=Object.defineProperties({},Object.getOwnPropertyDescriptors(e));return t.presence_ref=t.phx_ref,delete t.phx_ref,delete t.phx_ref_prev,t})}function e_(e){return(null==e?void 0:e.metas)?eO(e):[]}(l=g||(g={})).SYNC="sync",l.JOIN="join",l.LEAVE="leave";class eC{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new eT(this.channel.channelAdapter,t)}}class eP{get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,t){return this.channel.on(e,t)}off(e,t){this.channel.off(e,t)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,t,r){let n;try{n=this.channel.push(e,t,r)}catch(t){throw Error("tried to push '".concat(e,"' to '").concat(this.channel.topic,"' before joining. Use channel.subscribe() before pushing events"))}if(this.channel.pushBuffer.length>100){let e=this.channel.pushBuffer.shift();e.cancelTimeout(),this.socket.log("channel","discarded push due to buffer overflow: ".concat(e.event),e.payload())}return n}updateJoinPayload(e){let t=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},t),e)}canPush(){return this.socket.isConnected()&&this.state===K.joined}isJoined(){return this.state===K.joined}isJoining(){return this.state===K.joining}isClosed(){return this.state===K.closed}isLeaving(){return this.state===K.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}constructor(e,t,r){let n={config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config)};this.channel=e.getSocket().channel(t,n),this.socket=e}}let ej=/[,()"\\]/,eR=e=>ej.test(e)||e!==e.trim(),ex=e=>'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"'),eI=e=>{let t=null===e?"null":String(e);return eR(t)?ex(t):t},eU=e=>null===e?"null":String(e),eN=(e,t)=>{if("in"===e){let e=Array.isArray(t)?t:[t];if(0===e.length)throw Error("Realtime `in` filter requires at least one value.");let r=Array.from(new Set(e)).map(e=>eI(e)).join(",");return"in.(".concat(r,")")}return"is"===e?"is.".concat(eU(t)):"".concat(e,".").concat(eI(t))};class eB{add(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this.filters.push("".concat(e,"=").concat(n?"not.":"").concat(eN(t,r))),this}eq(e,t){return this.add(e,"eq",t)}neq(e,t){return this.add(e,"neq",t)}gt(e,t){return this.add(e,"gt",t)}gte(e,t){return this.add(e,"gte",t)}lt(e,t){return this.add(e,"lt",t)}lte(e,t){return this.add(e,"lte",t)}in(e,t){return this.add(e,"in",t)}like(e,t){return this.add(e,"like",t)}ilike(e,t){return this.add(e,"ilike",t)}match(e,t){return this.add(e,"match",t)}imatch(e,t){return this.add(e,"imatch",t)}is(e,t){return this.add(e,"is",t)}isDistinct(e,t){return this.add(e,"isdistinct",t)}not(e,t,r){return this.add(e,t,r,!0)}build(){return this.filters.join(",")}toString(){return this.build()}constructor(){this.filters=[]}}(u=m||(m={})).ALL="*",u.INSERT="INSERT",u.UPDATE="UPDATE",u.DELETE="DELETE",(h=y||(y={})).BROADCAST="broadcast",h.PRESENCE="presence",h.POSTGRES_CHANGES="postgres_changes",h.SYSTEM="system",(d=v||(v={})).SUBSCRIBED="SUBSCRIBED",d.TIMED_OUT="TIMED_OUT",d.CLOSED="CLOSED",d.CHANNEL_ERROR="CHANNEL_ERROR";class eL{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}subscribe(e){var t,r,n,s;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.timeout;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){let{config:{broadcast:a,presence:o,private:c,postgres_changes_options:l}}=this.params,u=null!==(r=null===(t=this.bindings.postgres_changes)||void 0===t?void 0:t.map(e=>e.filter))&&void 0!==r?r:[],h=!!this.bindings[y.PRESENCE]&&this.bindings[y.PRESENCE].length>0||(null===(n=this.params.config.presence)||void 0===n?void 0:n.enabled)===!0,d={},f=Object.assign({broadcast:a,presence:Object.assign(Object.assign({},o),{enabled:h}),postgres_changes:u,private:c},l?{postgres_changes_options:l}:{});this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(t=>{null==e||e(v.CHANNEL_ERROR,function(e){if(e instanceof Error)return e;if("string"==typeof e)return Error(e);
6if(e&&"object"==typeof e){if("number"==typeof e.code){let t="string"==typeof e.reason&&e.reason?" (".concat(e.reason,")"):"";return Error("socket closed: ".concat(e.code).concat(t),{cause:e})}return Error("channel error: transport failure",{cause:e})}return Error("channel error: connection lost")}(t))}),this._onClose(()=>null==e?void 0:e(v.CLOSED)),this.updateJoinPayload(Object.assign({config:f},d)),this._updateFilterMessage();let p=(null==l?void 0:l.wait)&&u.length>0?Math.max(i,(null!==(s=l.timeout)&&void 0!==s?s:15e3)+1e4):i;this.channelAdapter.subscribe(p).receive("ok",async t=>{let{postgres_changes:r}=t;if(this.socket._isManualToken()||this.socket.setAuth(),void 0===r){null==e||e(v.SUBSCRIBED);return}this._updatePostgresBindings(r,e)}).receive("error",t=>{this.state=K.errored;let r=Object.values(t).join(", ")||"error";null==e||e(v.CHANNEL_ERROR,Error(r,{cause:t}))}).receive("timeout",()=>{null==e||e(v.TIMED_OUT)})}return this}_updatePostgresBindings(e,t){var r;let n=this.bindings.postgres_changes,s=null!==(r=null==n?void 0:n.length)&&void 0!==r?r:0,i=[];for(let r=0;r<s;r++){let s=n[r],{filter:{event:a,schema:o,table:c,filter:l}}=s,u=e&&e[r];if(u&&u.event===a&&eL.isFilterValueEqual(u.schema,o)&&eL.isFilterValueEqual(u.table,c)&&eL.isFilterValueEqual(u.filter,l))i.push(Object.assign(Object.assign({},s),{id:u.id}));else{this.unsubscribe(),this.state=K.errored,null==t||t(v.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=i,this.state!=K.errored&&t&&t(v.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.send({type:"presence",event:"track",payload:e},t)}async untrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){let n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),s=e===y.PRESENCE||e===y.POSTGRES_CHANGES;if(n&&s)throw this.socket.log("channel","cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`.")),Error("cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`."));return this._on(e,t,r)}async httpSend(e,t){var r;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null==t)return Promise.reject(Error("Payload is required for httpSend()"));let s=t instanceof ArrayBuffer||ArrayBuffer.isView(t),i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":s?"application/octet-stream":"application/json"};this.socket.accessTokenValue&&(i.Authorization="Bearer ".concat(this.socket.accessTokenValue));let a=new URL(this.broadcastEndpointURL);a.pathname+="/".concat(encodeURIComponent(this.subTopic),"/events/").concat(encodeURIComponent(e)),this.private&&a.searchParams.set("private","true");let o={method:"POST",headers:i,body:s?t:JSON.stringify(t)},c=await this._fetchWithTimeout(a.toString(),o,null!==(r=n.timeout)&&void 0!==r?r:this.timeout);if(202===c.status)return{success:!0};if(404===c.status)return Promise.reject(Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/migrations/httpsend-server-version.md"));let l=c.statusText;try{let e=await c.json();l=e.error||e.message||l}catch(e){}return Promise.reject(Error(l))}async send(e){var t,r;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.channelAdapter.canPush()||"broadcast"!==e.type)return new Promise(t=>{var r,s,i;let a=this.channelAdapter.push(e.type,e,n.timeout||this.timeout);"broadcast"!==e.type||(null===(i=null===(s=null===(r=this.params)||void 0===r?void 0:r.config)||void 0===s?void 0:s.broadcast)||void 0===i?void 0:i.ack)||t("ok"),a.receive("ok",()=>t("ok")),a.receive("error",()=>t("error")),a.receive("timeout",()=>t("timed out"))});{let s="Realtime send() is automatically falling back to REST API. This behavior will be deprecated
6in the future. Please use httpSend() explicitly for REST delivery.";this.socket.hasLogger()?this.socket.log("channel",s):console.warn(s);let{event:i,payload:a}=e,o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(o.Authorization="Bearer ".concat(this.socket.accessTokenValue));let c={method:"POST",headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,c,null!==(t=n.timeout)&&void 0!==t?t:this.timeout);return await (null===(r=e.body)||void 0===r?void 0:r.cancel()),e.ok?"ok":"error"}catch(e){if(e instanceof Error&&"AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;return new Promise(t=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>t("ok")).receive("timeout",()=>t("timed out")).receive("error",()=>t("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,t,r){let n=new AbortController,s=setTimeout(()=>n.abort(),r),i=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}));return clearTimeout(s),i}_on(e,t,r){var n;let s=e.toLocaleLowerCase(),i=null==t?void 0:t.filter;if((i instanceof eB||"object"==typeof i&&null!==i&&"function"==typeof i.build)&&(t=Object.assign(Object.assign({},t),{filter:i.build()})),s===y.POSTGRES_CHANGES&&(null===(n=this.bindings[s])||void 0===n?void 0:n.find(e=>eL.isSamePostgresFilter(e.filter,t))))return this.socket.log("error","duplicate `postgres_changes` binding for ".concat(this.topic," ignored"),t),this;let a=this.channelAdapter.on(e,r),o={type:s,filter:t,callback:r,ref:a};return this.bindings[s]?this.bindings[s].push(o):this.bindings[s]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,t,r)=>{var n,s,i,a,o,c,l;let u=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(u,r))return!1;let h=null===(n=this.bindings[u])||void 0===n?void 0:n.find(t=>t.ref===e.ref);if(!h)return!0;if(!["broadcast","presence","postgres_changes"].includes(u))return h.type.toLocaleLowerCase()===u;if("id"in h){let e=h.id,r=null===(s=h.filter)||void 0===s?void 0:s.event;return e&&(null===(i=t.ids)||void 0===i?void 0:i.includes(e))&&("*"===r||(null==r?void 0:r.toLocaleLowerCase())===(null===(a=t.data)||void 0===a?void 0:a.type.toLocaleLowerCase()))}{let e=null===(c=null===(o=null==h?void 0:h.filter)||void 0===o?void 0:o.event)||void 0===c?void 0:c.toLocaleLowerCase();return"*"===e||e===(null===(l=null==t?void 0:t.event)||void 0===l?void 0:l.toLocaleLowerCase())}})}_notThisChannelEvent(e,t){let{close:r,error:n,leave:s,join:i}=z;return t&&[r,n,s,i].includes(e)&&t!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,t,r)=>{if("object"==typeof t&&"ids"in t){let e=t.data,{schema:r,table:n,commit_timestamp:s,type:i,errors:a}=e;return Object.assign(Object.assign({},{schema:r,table:n,commit_timestamp:s,eventType:i,new:{},old:{},errors:a}),this._getPayloadRecords(e))}return t})}copyBindings(e){if(this.joinedOnce)throw Error("cannot copy bindings into joined channel");for(let t in e.bindings)for(let r of e.bindings[t])this._on(r.type,r.filter,r.callback)}static isFilterValueEqual(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)}static isSamePostgresFilter(e,t){var r,n,s,i;let a=null!==(n=null===(r=null==e?void 0:e.select)||void 0===r?void 0:r.join())&&void 0!==n?n:void 0,o=null!==(i=null===(s=null==t?void 0:t.select)||void 0===s?void 0:s.join())&&void 0!==i?i:void 0;return(null==e?void 0:e.event)===(null==t?void 0:t.event)&&eL.isFilterValueEqual(null==e?void 0:e.schema,null==t?void 0:t.schema)&&eL.isFilterValueEqual(null==e?void 0:e.table,null==t?void 0:t.table)&&eL.isFilterValueEqual(null==e?void 0:e.filter,null==t?void 0:t.filter)&&a===o}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=X(e.columns,e.record)),("UPDATE"===e.type||"DELET
6E"===e.type)&&(t.old=X(e.columns,e.old_record)),t}constructor(e,t={config:{}},r){var n,s;if(this.topic=e,this.params=t,this.socket=r,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.channelAdapter=new eP(this.socket.socketAdapter,e,this.params),this.presence=new eC(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=ea(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(null===(s=null===(n=this.params.config)||void 0===n?void 0:n.broadcast)||void 0===s?void 0:s.replay))throw Error("tried to use replay on public channel '".concat(this.topic,"'. It must be a private channel."))}}class eD{get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e4;return new Promise(s=>{setTimeout(()=>s("timeout"),n),this.socket.disconnect(()=>{e(),s("ok")},t,r)})}push(e){this.socket.push(e)}log(e,t,r){this.socket.log(e,t,r)}hasLogger(){return this.socket.hasLogger()}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==Y.connecting}isDisconnecting(){return this.socket.connectionState()==Y.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}constructor(e,t){this.socket=new eA(e,t)}}let eq={HEARTBEAT_INTERVAL:25e3},eH=[1e3,2e3,5e3,1e4];class eM{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(t){let e=t.message;throw Error("WebSocket not available: ".concat(e))}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,t){return(this._cancelPendingDisconnect(),this.isDisconnecting())?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,t)}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return"ok"===t&&e.teardown(),t}async removeAllChannels(){let e=this.channels.map(async e=>{let t=await e.unsubscribe();return e.teardown(),t}),t=await Promise.all(e);return await this.disconnect(),t}log(e,t,r){this.socketAdapter.log(e,t,r)}hasLogger(){return this.socketAdapter.hasLogger()}connectionState(){return this.socketAdapter.connectionState()||Y.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}},r="realtime:".concat(e),n=this.getChannels().find(e=>e.topic===r);if(n)return n;{let r=new eL("realtime:".concat(e),t,this);return this._cancelPendingDisconnect(),this.channels.push(r),r}}push(e){this.socketAdapter.push(e)}async setAuth(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=++this._authGeneration,r=this._performAuth(e,t);t===this._authGeneration&&(this._authPromise=r);try{await r}finally{this._authPromise===r&&(this._authPromise=null)}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(t=>t.topic!==e.topic),0===this.channels.length&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),0===this._disconnectOnEmptyChannelsAfterMs){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}
6this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,0===this.channels.length&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport","deferred disconnect scheduled in ".concat(this._disconnectOnEmptyChannelsAfterMs,"ms"))}_cancelPendingDisconnect(){null!==this._pendingDisconnectTimer&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e,t){let r;let n=!1;if(e)r=e,n=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(e){this.log("error","Error fetching access token from callback",e),r=this.accessTokenValue}else r=this.accessTokenValue;t===this._authGeneration&&(this.accessToken?this._manuallySetToken=!1:n&&(this._manuallySetToken=!0),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(e=>{let t={access_token:r,version:V};e.updateJoinPayload(t),e.joinedOnce&&e.channelAdapter.isJoined()&&e.channelAdapter.push(z.access_token,{access_token:r})})))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"general";this._isManualToken()||this.setAuth().catch(t=>{this.log("error","Error setting auth in ".concat(e),t)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(e=>{this.log("error","error waiting for auth on connect",e)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(t,r)=>{"disconnected"!==t&&("sent"==t&&this._setAuthSafely(),e&&e(t,r))}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker","starting worker for from ".concat(this.workerUrl)):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob(['\n addEventListener("message", (e) => {\n if (e.data.event === "start") {\n setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);\n }\n });'],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var t,r,n,s,i,a,o,c,l,u,h,d;let f,p;this.worker=null!==(t=null==e?void 0:e.worker)&&void 0!==t&&t,this.accessToken=null!==(r=null==e?void 0:e.accessToken)&&void 0!==r?r:null;let g={};g.timeout=null!==(n=null==e?void 0:e.timeout)&&void 0!==n?n:1e4,g.heartbeatIntervalMs=null!==(s=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==s?s:eq.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=null!==(i=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)&&void 0!==i?i:2*(null!==(a=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==a?a:eq.HEARTBEAT_INTERVAL),g.transport=null!==(o=null==e?void 0:e.transport)&&void 0!==o?o:W.getWebSocketConstructor(),g.params=null==e?void 0:e.params,g.logger=null==e?void 0:e.logger,g.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),g.sessionStorage=null!==(c=null==e?void 0:e.sessionStorage)&&void 0!==c?c:function(){try{if("undefined"!=typeof globalThis&&globalThis.sessionStorage)return globalThis.sessionStorage}catch(e){}return function(){let e=new Map;return{get length(){return e.size},clear(){e.clear()},getItem:t=>e.has(t)?e.get(t):null,key(t){var r;return null!==(r=Array.from(e.keys())[t])&&void 0!==r?r:null},removeItem(t){e.delete(t)},setItem(t,r){e.set(t,String(r))}}}()}(),g.reconnectAfterMs=null!==(l=null==e?void 0:e.reconnectAfterMs)&&void 0!==l?l:e=>eH[e-1]||1e4;let m=null!==(u=null==e?void 0:e.vsn)&&void 0!==u?u:G;switch(m){case"1.0.0":f=(e,t)=>
6t(JSON.stringify(e)),p=(e,t)=>t(JSON.parse(e));break;case G:f=this.serializer.encode.bind(this.serializer),p=this.serializer.decode.bind(this.serializer);break;default:throw Error("Unsupported serializer version: ".concat(g.vsn))}if(g.vsn=m,g.encode=null!==(h=null==e?void 0:e.encode)&&void 0!==h?h:f,g.decode=null!==(d=null==e?void 0:e.decode)&&void 0!==d?d:p,g.beforeReconnect=this._reconnectAuth.bind(this),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,g.params=Object.assign(Object.assign({},g.params),{log_level:this.logLevel})),this.worker){if(!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl,g.autoSendHeartbeat=!this.worker}return g}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}constructor(e,t){var r;if(this.channels=[],this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new $,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=e=>e?function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e(...r)}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch(...t)},!(null===(r=null==t?void 0:t.params)||void 0===r?void 0:r.apikey))throw Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey;let n=this._initializeOptions(t);this.socketAdapter=new eD(e,n),this.httpEndpoint=ea(e),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}}var eF=class extends Error{isNotFound(){return 404===this.status}isConflict(){return 409===this.status}isAuthenticationTimeout(){return 419===this.status}constructor(e,t){var r;super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown="CommitStateUnknownException"===t.icebergType||[500,502,504].includes(t.status)&&(null===(r=t.icebergType)||void 0===r?void 0:r.includes("CommitState"))===!0}};async function eJ(e){return e&&"none"!==e.type?"bearer"===e.type?{Authorization:"Bearer ".concat(e.token)}:"header"===e.type?{[e.name]:e.value}:"custom"===e.type?await e.getHeaders():{}:{}}function eW(e){return e.join("\x1f")}var eV=class{async listNamespaces(e){let t=e?{parent:eW(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces"),query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){let r={namespace:e.namespace,properties:null==t?void 0:t.properties};return(await this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces"),body:r})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:"".concat(this.prefix,"/namespaces/").concat(eW(e.namespace))})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(eW(e.namespace))})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:"".concat(this.prefix,"/namespaces/").concat(eW(e.namespace))}),!0}catch(e){if(e instanceof eF&&404===e.status)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof eF&&409===e.status)return;throw e}}constructor(e,t=""){this.client=e,this.prefix=t}};function eG(e){return e.join("\x1f")}var eK=class{async listTables(e){return(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(eG(e.namespace),"/tables")})).data.identifiers}async createTable(e,t){let r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces/").concat(eG(e.namespace),"/tables"),body:t,headers:r})).data.metadata}async updateTable(e,t){let r=await this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces/").concat(eG(e.namespace),"/tables/").concat(e.name),body:t});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(e,t){var r;await this.client.request({method:"DELETE",path:"".concat(this.prefix,"/namespaces/").concat(eG(e.namespace),"/tables/").concat(e.name),query:{purgeRequested:String(null!==(r=null==t?void 0:t.purge)&&void 0!==r&&r)}})}async loadTable(e){let t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(eG(e.namespace),"/tables/").concat(e.name),headers:t})).data.metadata}async tableExists(e){let t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:"".concat(this.prefix,"/namespaces/").concat(eG(e.namespace),"/tables/").concat(e.name),headers:t}),!0}catch(e){if(e instanceof eF&&404===e.status)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(r){if(r instanceof eF&&409===r.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw r}}constructor(e,t="",r){this.client=e,this.prefix=t,this.accessDelegation=r}},ez=class{async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}
6async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}constructor(e){var t;let r="v1";e.catalogName&&(r+="/".concat(e.catalogName));let n=e.baseUrl.endsWith("/")?e.baseUrl:"".concat(e.baseUrl,"/");this.client=function(e){var t;let r=null!==(t=e.fetchImpl)&&void 0!==t?t:globalThis.fetch;return{async request(t){let{method:n,path:s,query:i,body:a,headers:o}=t,c=function(e,t,r){let n=new URL(t,e);if(r)for(let[e,t]of Object.entries(r))void 0!==t&&n.searchParams.set(e,t);return n.toString()}(e.baseUrl,s,i),l=await eJ(e.auth),u=await r(c,{method:n,headers:{...a?{"Content-Type":"application/json"}:{},...l,...o},body:a?JSON.stringify(a):void 0}),h=await u.text(),d=(u.headers.get("content-type")||"").includes("application/json"),f=d&&h?JSON.parse(h):h;if(!u.ok){var p;let e=d?f:void 0,t=null==e?void 0:e.error;throw new eF(null!==(p=null==t?void 0:t.message)&&void 0!==p?p:"Request failed with status ".concat(u.status),{status:u.status,icebergType:null==t?void 0:t.type,icebergCode:null==t?void 0:t.code,details:e})}return{status:u.status,headers:u.headers,data:f}}}}({baseUrl:n,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=null===(t=e.accessDelegation)||void 0===t?void 0:t.join(","),this.namespaceOps=new eV(this.client,r),this.tableOps=new eK(this.client,r,this.accessDelegation)}},eY=r(23663).Buffer;function e$(e){return(e$="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function eX(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function eQ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?eX(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=e$(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=e$(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==e$(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):eX(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var eZ=class extends Error{toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}constructor(e,t="storage",r,n){super(e),this.__isStorageError=!0,this.namespace=t,this.name="vectors"===t?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=n}};function e0(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}var e1=class extends eZ{toJSON(){return eQ(eQ({},super.toJSON()),{},{code:this.code})}constructor(e,t,r,n="storage",s){super(e,n,t,r),this.name="vectors"===n?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=r,this.co
6de=s}},e2=class extends eZ{constructor(e,t,r="storage"){super(e,r),this.name="vectors"===r?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function e5(e,t,r){let n=eQ({},e),s=t.toLowerCase();for(let e of Object.keys(n))e.toLowerCase()===s&&delete n[e];return n[s]=r,n}let e6=e=>e?function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e(...r)}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch(...t)},e8=e=>{if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},e4=e=>{if(Array.isArray(e))return e.map(e=>e4(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(e=>{let[r,n]=e;t[r.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""))]=e4(n)}),t},e3=e=>!(!e||"string"!=typeof e||0===e.length||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\"))&&/^[\w!.\*'() &$@=;:+,?-]+$/.test(e),e9=e=>e.split("/").map(encodeURIComponent).join("/"),e7=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error;if("object"==typeof e.error&&null!==e.error){let t=e.error;if("string"==typeof t.message)return t.message}}return JSON.stringify(e)},te=async(e,t,r,n)=>{if(null!==e&&"object"==typeof e&&"json"in e&&"function"==typeof e.json){let r=parseInt(String(e.status),10);Number.isFinite(r)||(r=500),e.json().then(e=>{let s=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||r+"";t(new e1(e7(e),r,s,n,null==e?void 0:e.code))}).catch(()=>{let s=r+"";t(new e1(e.statusText||"HTTP ".concat(r," error"),r,s,n))})}else t(new e2(e7(e),e,n))},tt=(e,t,r,n)=>{let s={method:e,headers:(null==t?void 0:t.headers)||{}};if("GET"===e||"HEAD"===e||!n)return eQ(eQ({},s),r);if(e8(n)){var i;let e;let r=(null==t?void 0:t.headers)||{};for(let[t,n]of Object.entries(r))"content-type"===t.toLowerCase()&&(e=n);s.headers=e5(r,"Content-Type",null!==(i=e)&&void 0!==i?i:"application/json"),s.body=JSON.stringify(n)}else s.body=n;return(null==t?void 0:t.duplex)&&(s.duplex=t.duplex),eQ(eQ({},s),r)};async function tr(e,t,r,n,s,i,a){return new Promise((o,c)=>{e(r,tt(t,n,s,i)).then(e=>{if(!e.ok)throw e;if(null==n?void 0:n.noResolveJson)return e;if("vectors"===a){let t=e.headers.get("content-type");if("0"===e.headers.get("content-length")||204===e.status||!t||!t.includes("application/json"))return{}}return e.json()}).then(e=>o(e)).catch(e=>te(e,c,n,a))})}function tn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"storage";return{get:async(t,r,n,s)=>tr(t,"GET",r,n,s,void 0,e),post:async(t,r,n,s,i)=>tr(t,"POST",r,s,i,n,e),put:async(t,r,n,s,i)=>tr(t,"PUT",r,s,i,n,e),head:async(t,r,n,s)=>tr(t,"HEAD",r,eQ(eQ({},n),{},{noResolveJson:!0}),s,void 0,e),remove:async(t,r,n,s,i)=>tr(t,"DELETE",r,s,i,n,e)}}let{get:ts,post:ti,put:ta,head:to,remove:tc}=tn("storage"),tl=tn("vectors");var tu=class{throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=e5(this.headers,e,t),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(e0(e))return{data:null,error:e};throw e}}constructor(e,t={},r,n="storage"){this.shouldThrowOnError=!1,this.url=e,this.headers=function(e){let t={};for(let[r,n]of Object.entries(e))t[r.toLowerCase()]=n;return t}(t),this.fetch=e6(r),this.namespace=n}};n=Symbol.toStringTag;var th=class{then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(e0(e))return{data:null,error:e};throw e}}constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[n]="StreamDownloadBuilder",this.promise=null}};s=Symbol.toStringTag;var td=class{asStream(){return new th(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:await (await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(e0(e))return{data:null,error:e};throw e}}constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[s]="BlobDownloadBuilder",this.promise=null}};let tf={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},tp={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var tg=class extends tu{async uploadOrUpdate(e,t,r,n){var s=this;return s.handleOperation(async()=>{let i;let a=eQ(eQ({},tp),n),o=eQ(eQ({},s.headers),"POST"===e&&{"x-upsert":String(a.upsert)}),c=a.metadata;if("undefined"!=typeof Blob&&r instanceof Blob?((i=new FormData).append("cacheControl",a.cacheControl),c&&i.append("metadata",s.encodeMetadata(c)),i.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?((i=r).has("cacheControl")||i.append("cacheControl",a.cacheControl),c&&!i.has("metadata")&&i.append("metadata",s.encodeMetadata(c))):(i=r,o["cache-control"]="max-age=".concat(a.cacheControl),o["content-type"]=a.contentType,c&&(o["x-metadata"]=s.toBase64(s.encodeMetadata(c))),("undefined"!=typeof ReadableStream&&i instanceof ReadableStream||i&&"object"==typeof i&&"pipe"in i&&"function"==typeof i.pipe)&&!a.duplex&&(a.duplex="half")),null==n?void 0:n.headers)for(let[e,t]of Object.entries(n.headers))o=e5(o,e,t);let l=s._removeEmptyFolders(t),u=s._getFinalPath(l),h=await ("PUT"==e?ta:ti)(s.fetch,"".concat(s.url,"/object/").concat(u),i,eQ({headers:o},(null==a?void 0:a.duplex)?{duplex:a.duplex}:{}));return{path:l,id:h.Id,fullPath:h.Key}})}async upload(e,t,r){return this.uploadOrUpdate("POST",e,t,r)}async uploadToSignedUrl(e,t,r,n){var s=this;let i=s._removeEmptyFolders(e),a=s._getFinalPath(i),o=new URL(s.url+"/object/upload/sign/".concat(a));return o.searchParams.set("token",t),s.handleOperation(async()=>{let e;let t=eQ(eQ({},tp),n),a=eQ(eQ({},s.headers),{"x-upsert":String(t.upsert)}),c=t.metadata;if("undefined"!=typeof Blob&&r instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),c&&e.append("metadata",s.encodeMetadata(c)),e.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?((e=r).has("cacheControl")||e.append("cacheControl",t.cacheControl),c&&!e.has("metadata")&&e.append("metadata",s.encodeMetadata(c))):(e=r,a["cache-control"]="max-age=".concat(t.cacheControl),a["content-type"]=t.contentType,c&&(a["x-metadata"]=s.toBase64(s.encodeMetadata(c))),("undefined"!=typeof ReadableStream&&e instanceof ReadableStream||e&&"object"==typeof e&&"pipe"in e&&"function"==typeof e.pipe)&&!t.duplex&&(t.duplex="half")),null==n?void 0:n.headers)for(let[e,t]of Object.entries(n.headers))a=e5(a,e,t);return{path:i,fullPath:(await ta(s.fetch,o.toString(),e,eQ({headers:a},(null==t?void 0:t.duplex)?{duplex:t.duplex}:{}))).Key}})}async createSignedUploadUrl(e,t){var r=this;return r.handleOperation(async()=>{let n=r._getFinalPath(e),s=eQ({},r.headers);(null==t?void 0:t.upsert)&&(s["x-upsert"]="true");let i=await ti(r.fetch,"".concat(r.url,"/object/upload/sign/").concat(n),{},{headers:s}),a=new URL(r.url+i.url),o=a.searchParams.get("token");if(!o)throw new eZ("No token returned by API");return{signedUrl:a.toString(),path:e,token:o}})}async update(e,t,r){return this.uploadOrUpdate("PUT",e,t,r)}async move(e,t,r){var n=this;return n.handleOperation(async()=>await ti(n.fetch,"".concat(n.url,"/object/move"),{bucketId:n.bucketId,sourceKey:e,destinationKey:t,de
6stinationBucket:null==r?void 0:r.destinationBucket,sourceVersionId:null==r?void 0:r.sourceVersionId},{headers:n.headers}))}async copy(e,t,r){var n=this;return n.handleOperation(async()=>({path:(await ti(n.fetch,"".concat(n.url,"/object/copy"),{bucketId:n.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket,sourceVersionId:null==r?void 0:r.sourceVersionId},{headers:n.headers})).Key}))}async createSignedUrl(e,t,r){var n=this;return n.handleOperation(async()=>{let s=n._getFinalPath(e),i="object"==typeof(null==r?void 0:r.transform)&&null!==r.transform&&Object.keys(r.transform).length>0,a=await ti(n.fetch,"".concat(n.url,"/object/sign/").concat(s),eQ(eQ({expiresIn:t},i?{transform:r.transform}:{}),(null==r?void 0:r.versionId)!=null?{versionId:r.versionId}:{}),{headers:n.headers}),o=new URLSearchParams;(null==r?void 0:r.download)&&o.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&o.set("cacheNonce",String(r.cacheNonce));let c=o.toString();return{signedUrl:encodeURI("".concat(n.url).concat(a.signedURL).concat(c?"&".concat(c):""))}})}async createSignedUrls(e,t,r){var n=this;return n.handleOperation(async()=>{let s=await ti(n.fetch,"".concat(n.url,"/object/sign/").concat(n.bucketId),{expiresIn:t,paths:e},{headers:n.headers}),i=new URLSearchParams;(null==r?void 0:r.download)&&i.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&i.set("cacheNonce",String(r.cacheNonce));let a=i.toString();return s.map(e=>eQ(eQ({},e),{},{signedUrl:e.signedURL?encodeURI("".concat(n.url).concat(e.signedURL).concat(a?"&".concat(a):"")):null}))})}download(e,t,r){let n="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image/authenticated":"object",s=new URLSearchParams;(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(s,t.transform),(null==t?void 0:t.cacheNonce)!=null&&s.set("cacheNonce",String(t.cacheNonce)),(null==t?void 0:t.versionId)!=null&&s.set("versionId",String(t.versionId));let i=s.toString(),a=this._getFinalPath(e);return new td(()=>ts(this.fetch,"".concat(this.url,"/").concat(n,"/").concat(a).concat(i?"?".concat(i):""),{headers:this.headers,noResolveJson:!0},r),this.shouldThrowOnError)}async info(e,t){var r=this;let n=r._getFinalPath(e),s=new URLSearchParams;(null==t?void 0:t.versionId)!=null&&s.set("versionId",String(t.versionId));let i=s.toString();return r.handleOperation(async()=>e4(await ts(r.fetch,"".concat(r.url,"/object/info/").concat(n).concat(i?"?".concat(i):""),{headers:r.headers})))}async exists(e){var t;let r=this._getFinalPath(e);try{return await to(this.fetch,"".concat(this.url,"/object/").concat(r),{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(e0(e)){let r=e instanceof e1?e.status:e instanceof e2?null===(t=e.originalError)||void 0===t?void 0:t.status:void 0;if(void 0!==r&&[400,404].includes(r))return{data:!1,error:e}}throw e}}getPublicUrl(e,t){let r=this._getFinalPath(e),n=new URLSearchParams;(null==t?void 0:t.download)&&n.set("download",!0===t.download?"":t.download),(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(n,t.transform),(null==t?void 0:t.cacheNonce)!=null&&n.set("cacheNonce",String(t.cacheNonce)),(null==t?void 0:t.versionId)!=null&&n.set("versionId",String(t.versionId));let s=n.toString(),i="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI("".concat(this.url,"/").concat(i,"/public/").concat(r))+(s?"?".concat(s):"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await tc(t.fetch,"".concat(t.url,"/object/").concat(t.bucketId),{prefixes:e},{headers:t.headers}))}async purgeCache(e,t,r){var n=this;return n.handleOperation(async()=>{let s=e9(n._getFinalPath(e)),i=new URLSearchParams;(null==t?void 0:t.transformations)&&i.set("transformations","true");let a=i.toString();return await tc(n.fetch,"".concat(n.url,"/cdn/").concat(s).concat(a?"?".concat(a):""),{},{headers:n.headers},r)})}async list(e,t,r){var n=this;return n.handleOperation(async()=>{let s=(null==t?void 0:t.sortBy)?eQ(eQ({},tf.sortBy),t.sortBy):tf.sortBy,i=eQ(eQ(eQ({},tf),t),{},{sortBy:s,prefix:e||""});return await ti(n.fetch,"".concat(n.url,"/object/list/").concat(n.bucketId),i,{headers:n.headers},r)})}async listV2(e,t){var r=this;return r.handleOperation(async()=>{let n=eQ({},e);return await ti(r.fetch,"".concat(r.url,"/object/list-v2/").concat(r.bucketId),n,{headers:r.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==eY?eY.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return"".concat(this.bucketId,"/").concat(e.replace(/^\/+/,""))}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("qual
6ity",t.quality.toString()),e}constructor(e,t={},r,n){super(e,t,n,"storage"),this.bucketId=r}};let tm={"X-Client-Info":"storage-js/".concat("2.117.2")};var ty=class extends tu{async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=t.listBucketOptionsToQueryString(e);return await ts(t.fetch,"".concat(t.url,"/bucket").concat(r),{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await ts(t.fetch,"".concat(t.url,"/bucket/").concat(e),{headers:t.headers}))}async createBucket(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{public:!1};var r=this;return r.handleOperation(async()=>await ti(r.fetch,"".concat(r.url,"/bucket"),{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes,versioning_status:t.versioningStatus},{headers:r.headers}))}async updateBucket(e,t){var r=this;return r.handleOperation(async()=>await ta(r.fetch,"".concat(r.url,"/bucket/").concat(e),{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes,versioning_status:t.versioningStatus},{headers:r.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await ti(t.fetch,"".concat(t.url,"/bucket/").concat(e,"/empty"),{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await tc(t.fetch,"".concat(t.url,"/bucket/").concat(e),{},{headers:t.headers}))}async getBucketLifecycle(e){var t=this;return t.handleOperation(async()=>await ts(t.fetch,t.bucketLifecycleUrl(e),{headers:t.headers}))}async updateBucketLifecycle(e,t){var r=this;return r.handleOperation(async()=>await ta(r.fetch,r.bucketLifecycleUrl(e),t,{headers:r.headers}))}async deleteBucketLifecycle(e){var t=this;return t.handleOperation(async()=>await tc(t.fetch,t.bucketLifecycleUrl(e),{},{headers:t.headers}))}async purgeBucketCache(e,t,r){var n=this;return n.handleOperation(async()=>{let s=new URLSearchParams;(null==t?void 0:t.transformations)&&s.set("transformations","true");let i=s.toString();return await tc(n.fetch,"".concat(n.url,"/cdn/").concat(e9(e)).concat(i?"?".concat(i):""),{},{headers:n.headers},r)})}bucketLifecycleUrl(e){return"".concat(this.url,"/bucket/").concat(e9(e),"/lifecycle")}listBucketOptionsToQueryString(e){let t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}constructor(e,t={},r,n){let s=new URL(e);(null==n?void 0:n.useNewHostname)&&/supabase\.(co|in|red)$/.test(s.hostname)&&!s.hostname.includes("storage.supabase.")&&(s.hostname=s.hostname.replace("supabase.","storage.supabase.")),super(s.href.replace(/\/$/,""),eQ(eQ({},tm),t),r,"storage")}},tv=class extends tu{async createBucket(e){var t=this;return t.handleOperation(async()=>await ti(t.fetch,"".concat(t.url,"/bucket"),{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=new URLSearchParams;(null==e?void 0:e.limit)!==void 0&&r.set("limit",e.limit.toString()),(null==e?void 0:e.offset)!==void 0&&r.set("offset",e.offset.toString()),(null==e?void 0:e.sortColumn)&&r.set("sortColumn",e.sortColumn),(null==e?void 0:e.sortOrder)&&r.set("sortOrder",e.sortOrder),(null==e?void 0:e.search)&&r.set("search",e.search);let n=r.toString(),s=n?"".concat(t.url,"/bucket?").concat(n):"".concat(t.url,"/bucket");return await ts(t.fetch,s,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await tc(t.fetch,"".concat(t.url,"/bucket/").concat(e),{},{headers:t.headers}))}from(e){var t=this;if(!e3(e))throw new eZ("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");let r=new ez({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}),n=this.shouldThrowOnError;return new Proxy(r,{get(e,t){let r=e[t];return"function"!=typeof r?r:async function(){for(var t=arguments.length,s=Array(t),i=0;i<t;i++)s[i]=arguments[i];try{return{data:await r.apply(e,s),error:null}}catch(e){if(n)throw e;return{data:null,error:e}}}}})}constructor(e,t={},r){super(e.replace(/\/$/,""),eQ(eQ({},tm),t),r,"storage")}},tb=class extends tu{async createIndex(e){var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/CreateIndex"),e,{headers:t.headers})||{})}async getIndex(e,t){var r=this;return r.handleOperation(async()=>await tl.post(r.fetch,"".concat(r.url,"/GetIndex"),{vectorBucketName:e,indexName:t},{headers:r.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/ListIndexes"),e,{headers:t.headers}))}async deleteIndex(e,t){var r=this;return r.handleOperation(async()=>await tl.post(r.fetch,"".concat(r.url,"/DeleteIndex"),{vectorBucketName:e,indexName:t},{headers:r.headers})||{})}constructor(e,t={},r){super(e.replace(/\/$/,""),eQ(eQ({},tm),{},{"Content-Type":"application/json"},t),r,"vectors")}},tw=class extends tu{async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/PutVectors"),e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/GetVectors"),e,{headers:t.headers}))}async listVectors(e){var t=this;if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw Error("segmentCount must be between 1 and 16");
6if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error("segmentIndex must be between 0 and ".concat(e.segmentCount-1))}return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/ListVectors"),e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/QueryVectors"),e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/DeleteVectors"),e,{headers:t.headers})||{})}constructor(e,t={},r){super(e.replace(/\/$/,""),eQ(eQ({},tm),{},{"Content-Type":"application/json"},t),r,"vectors")}},tE=class extends tu{async createBucket(e){var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/CreateVectorBucket"),{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/GetVectorBucket"),{vectorBucketName:e},{headers:t.headers}))}async listBuckets(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/ListVectorBuckets"),e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await tl.post(t.fetch,"".concat(t.url,"/DeleteVectorBucket"),{vectorBucketName:e},{headers:t.headers})||{})}constructor(e,t={},r){super(e.replace(/\/$/,""),eQ(eQ({},tm),{},{"Content-Type":"application/json"},t),r,"vectors")}},tk=class extends tE{from(e){return new tS(this.url,this.headers,e,this.fetch)}async createBucket(e){return super.createBucket.call(this,e)}async getBucket(e){return super.getBucket.call(this,e)}async listBuckets(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return super.listBuckets.call(this,e)}async deleteBucket(e){return super.deleteBucket.call(this,e)}constructor(e,t={}){super(e,t.headers||{},t.fetch)}},tS=class extends tb{async createIndex(e){return super.createIndex.call(this,eQ(eQ({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return super.listIndexes.call(this,eQ(eQ({},e),{},{vectorBucketName:this.vectorBucketName}))}async getIndex(e){return super.getIndex.call(this,this.vectorBucketName,e)}async deleteIndex(e){return super.deleteIndex.call(this,this.vectorBucketName,e)}index(e){return new tA(this.url,this.headers,this.vectorBucketName,e,this.fetch)}constructor(e,t,r,n){super(e,t,n),this.vectorBucketName=r}},tA=class extends tw{async putVectors(e){return super.putVectors.call(this,eQ(eQ({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async getVectors(e){return super.getVectors.call(this,eQ(eQ({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async listVectors(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return super.listVectors.call(this,eQ(eQ({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async queryVectors(e){return super.queryVectors.call(this,eQ(eQ({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async deleteVectors(e){return super.deleteVectors.call(this,eQ(eQ({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}constructor(e,t,r,n,s){super(e,t,s),this.vectorBucketName=r,this.indexName=n}},tT=class extends ty{from(e){return new tg(this.url,this.headers,e,this.fetch)}get vectors(){return new tk(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new tv(this.url+"/iceberg",this.headers,this.fetch)}constructor(e,t={},r,n){super(e,t,r,n)}};r(94579);var tO=r(55982).Z;r(43551);let t_="";if("undefined"!=typeof Deno)t_="deno",i=null===(b=Deno.version)||void 0===b?void 0:b.deno;else if("undefined"!=typeof document)t_="web";else if("undefined"!=typeof navigator&&"ReactNative"===navigator.product)t_="react-native";else{t_="node";let e=globalThis.process;i=null==e||null===(w=e.version)||void 0===w?void 0:w.replace(/^v/,"")}let tC=["runtime=".concat(t_)];i&&tC.push("runtime-version=".concat(i));let tP={headers:{"X-Client-Info":"supabase-js/".concat("2.117.2","; ").concat(tC.join("; "))}},tj={schema:"public"},tR={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},tx={},tI={enabled:!1,respectSamplingDecision:!0};function tU(e){return(tU="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function tN(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function tB(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
6t%2?tN(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=tU(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=tU(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==tU(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tN(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let tL=e=>e?function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e(...r)}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch(...t)},tD=()=>Headers,tq=e=>e.startsWith("sb_publishable_")||e.startsWith("sb_secret_"),tH=new Set,tM=e=>{var t,r;if(!e.startsWith("sb_")||tq(e)||e.startsWith("sb_temp_"))return;let n=null!==(t=null===(r=e.match(/^sb_[a-zA-Z0-9]+_/))||void 0===r?void 0:r[0])&&void 0!==t?t:"unknown";tH.has(n)||(tH.add(n),console.warn("@supabase/supabase-js: Unrecognized Supabase API key format. The client will proceed and send this key as-is; if you see authentication errors you may need to upgrade @supabase/supabase-js to a version that recognizes this key type."))},tF=(e,t,r,n,s,i)=>{let o=tL(n),c=tD(),l=(null==s?void 0:s.enabled)===!0,u=(null==s?void 0:s.respectSamplingDecision)!==!1,h=l?function(e){let t=[];try{let r=new URL(e);t.push(r.hostname)}catch(e){}return t.push("*.supabase.co","*.supabase.in"),t.push("localhost","127.0.0.1","[::1]"),t}(t):null,d=!((null==i?void 0:i.omitApiKeyAsBearer)&&tq(e));return async(t,n)=>{let s=await r(),i=new c(null==n?void 0:n.headers);if(i.has("apikey")||i.set("apikey",e),!i.has("Authorization")){let t=null!=s?s:d?e:null;t&&i.set("Authorization","Bearer ".concat(t))}if(h){let e=function(e,t,r){let n=globalThis[a];if(!n)return tJ||(tJ=!0,console.warn("@supabase/supabase-js: tracePropagation is enabled but the tracing runtime is not loaded, so trace headers will not be attached. Add `import '@supabase/supabase-js/tracing'` at your application entry point (requires the OpenTelemetry API package to be installed). The CDN/UMD build does not support trace propagation.")),null;if(!function(e,t){let r;if(!e||!t||0===t.length)return!1;if(e instanceof URL)r=e;else try{r=new URL(e)}catch(e){return!1}for(let e of t)try{if("string"==typeof e){if(function(e,t){if(t===e)return!0;if(t.startsWith("*.")){let r=t.slice(2);if(e.endsWith(r)&&(e===r||e.endsWith("."+r)))return!0}return!1}(r.hostname,e))return!0}else if(e instanceof RegExp){if(e.test(r.hostname))return!0}else if("function"==typeof e&&e(r))return!0}catch(e){continue}return!1}("string"==typeof e?e:e instanceof URL?e:e.url,t))return null;let s=n();if(!s||!s.traceparent){var i;if((null==s||null===(i=s.carrierKeys)||void 0===i?void 0:i.length)&&!tW){tW=!0;let e=s.carrierKeys.includes("sentry-trace")?" Sentry detected: set `propagateTraceparent: true` in Sentry.init() to emit it.":" Configure your tracing SDK to emit W3C trace context on outgoing requests.";console.warn("@supabase/supabase-js: tracePropagation is enabled and a tracing SDK is active, but its propagator wrote [".concat(s.carrierKeys.join(", "),"] and no W3C traceparent header, so trace headers will not be attached.")+e)}return null}if(r){let e=function(e){if(!e||"string"!=typeof e)return null;let t=e.split("-");if(4!==t.length)return null;let[r,n,s,i]=t;if(2!==r.length||32!==n.length||16!==s.length||2!==i.length)return null;let a=/^[0-9a-f]+$/i;return a.test(r)&&a.test(n)&&a.test(s)&&a.test(i)&&"00000000000000000000000000000000"!==n&&"0000000000000000"!==s?{version:r,traceId:n,parentId:s,traceFlags:i,isSampled:(1&parseInt(i,16))==1}:null}(s.traceparent);if(e&&!e.isSampled)return{traceparent:s.traceparent}}return s}(t,h,u);e&&(e.traceparent&&!i.has("traceparent")&&i.set("traceparent",e.traceparent),e.tracestate&&!i.has("tracestate")&&i.set("tracestate",e.tracestate),e.baggage&&!i.has("baggage")&&i.set("baggage",e.baggage))}return o(t,tB(tB({},n),{},{headers:i}))}},tJ=!1,tW=!1;function tV(e){return"boolean"==typeof e?{enabled:e}:e}let tG=!1;
6var tK=class extends tO{constructor(e){super(e)}},tz=class{get functions(){return new _(this.functionsUrl.href,{headers:this.headers,customFetch:this.functionsFetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}getOpenApiSpec(){return this.rest.getOpenApiSpec()}rpc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{head:!1,get:!1,count:void 0};return this.rest.rpc(e,t,r)}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getSessionToken(){var e,t;if(this.accessToken)return await this.accessToken();let{data:r}=await this.auth.getSession();return null!==(e=null===(t=r.session)||void 0===t?void 0:t.access_token)&&void 0!==e?e:null}async _getAccessToken(){var e;return null!==(e=await this._getSessionToken())&&void 0!==e?e:this.supabaseKey}_initSupabaseAuthClient(e,t,r){let{autoRefreshToken:n,persistSession:s,detectSessionInUrl:i,storage:a,userStorage:o,storageKey:c,flowType:l,lock:u,debug:h,throwOnError:d,experimental:f,lockAcquireTimeout:p,skipAutoInitialize:g}=e,m={Authorization:"Bearer ".concat(this.supabaseKey),apikey:"".concat(this.supabaseKey)};return new tK({url:this.authUrl.href,headers:tB(tB({},m),t),storageKey:c,autoRefreshToken:n,persistSession:s,detectSessionInUrl:i,storage:a,userStorage:o,flowType:l,lock:u,debug:h,throwOnError:d,experimental:f,fetch:r,lockAcquireTimeout:p,skipAutoInitialize:g,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new eM(this.realtimeUrl.href,tB(tB({},e),{},{params:tB(tB({},{apikey:this.supabaseKey}),null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)})}_handleTokenChanged(e,t,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e||"INITIAL_SESSION"===e)&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}constructor(e,t,r){var n,s,i;this.supabaseUrl=e,this.supabaseKey=t;let a=function(e){let t=null==e?void 0:e.trim();if(!t)throw Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(t.endsWith("/")?t:t+"/")}catch(e){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}(e);if(!t)throw Error("supabaseKey is required.");tM(t),!tG&&"object"==typeof r&&null!==r&&"schema"in r&&void 0!==r.schema&&(tG=!0,console.warn('@supabase/supabase-js: The "schema" option must be nested under "db", e.g. createClient(url, key, { db: { schema: \'myschema\' } }). A top-level "schema" is ignored and queries go to the default schema.')),this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);let o="sb-".concat(a.hostname.split(".")[0],"-auth-token"),c=function(e,t){var r,n,s,i,a,o;let{db:c,auth:l,realtime:u,global:h}=e,{db:d,auth:f,realtime:p,global:g}=t,m=tV(e.tracePropagation),y=tV(t.tracePropagation),v={db:tB(tB({},d),c),auth:tB(tB({},f),l),realtime:tB(tB({},p),u),storage:{},global:tB(tB(tB({},g),h),{},{headers:tB(tB({},null!==(r=null==g?void 0:g.headers)&&void 0!==r?r:{}),null!==(n=null==h?void 0:h.headers)&&void 0!==n?n:{})}),tracePropagation:{enabled:null!==(s=null!==(i=null==m?void 0:m.enabled)&&void 0!==i?i:null==y?void 0:y.enabled)&&void 0!==s&&s,respectSamplingDecision:null===(a=null!==(o=null==m?void 0:m.respectSamplingDecision)&&void 0!==o?o:null==y?void 0:y.respectSamplingDecision)||void 0===a||a},accessToken:async()=>""};return e.accessToken?v.accessToken=e.accessToken:delete v.accessToken,v}(null!=r?r:{},{db:tj,realtime:tx,auth:tB(tB({},tR),{},{storageKey:o}),global:tP,tracePropagation:tI});this.settings=c,this.storageKey=null!==(n=c.auth.storageKey)&&void 0!==n?n:"",this.headers=null!==(s=c.global.headers)&&void 0!==s?s:{},c.accessToken?(this.accessToken=c.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error("@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.".concat(String(t)," is not possible"))}})):this.auth=this._initSupabaseAuthClient(null!==(i=c.auth)&&void 0!==i?i:{},this.headers,c.global.fetch),this.fetch=tF(t,e,this._getSessionToken.bind(this),c.global.fetch,c.tracePropagation),this.functionsFetch=tF(t,e,this._getSessionToken.bind(this),c.global.fetch,c.tracePropagation,{omitApiKeyAsBearer
6:!0}),this.realtime=this._initRealtimeClient(tB({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},c.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new J(new URL("rest/v1",a).href,{headers:this.headers,schema:c.db.schema,fetch:this.fetch,timeout:c.db.timeout,urlLengthLimit:c.db.urlLengthLimit,retry:c.db.retry}),this.storage=new tT(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),c.accessToken||this._listenForAuthEvents()}};let tY=(e,t,r)=>new tz(e,t,r)},69703:function(e,t,r){"use strict";function n(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)0>t.indexOf(n[s])&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function s(e,t,r,n){return new(r||(r=Promise))(function(s,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function o(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,o)}c((n=n.apply(e,t||[])).next())})}r.d(t,{_T:function(){return n},mG:function(){return s}}),"function"==typeof SuppressedError&&SuppressedError}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.