@nvwa-app/sdk-core 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -719
- package/package.json +18 -7
- package/dist/index.cjs +0 -740
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -223
- package/dist/index.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
|
|
2
2
|
import { PostgrestClient } from '@nvwa-app/postgrest-js';
|
|
3
|
-
import {
|
|
3
|
+
import { User } from 'better-auth';
|
|
4
4
|
import { createAuthClient } from 'better-auth/client';
|
|
5
5
|
|
|
6
6
|
interface NvwaLocalStorage {
|
|
@@ -219,5 +219,4 @@ interface INvwa {
|
|
|
219
219
|
fileStorage: NvwaFileStorage;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
export { AUTH_BASE_PATH, AbortController, AbortSignal, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, FetchResponse, GENERATE_UPLOAD_URL_PATH, Headers, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaAuthClient, NvwaEdgeFunctions, NvwaFileStorage, NvwaHttpClient, Request, Response, URL$1 as URL, URLSearchParams, createPostgrestClient, polyfill };
|
|
223
|
-
export type { AuthClient, FunctionInvokeOptions, HttpMethod, HttpRequest, HttpResponse, HttpUploadFileResponse, INvwa, NvwaAppUser, NvwaFetch, NvwaLocalStorage, RequestInfo, RequestInit, ResponseInit };
|
|
222
|
+
export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, FetchResponse, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HttpMethod, type HttpRequest, type HttpResponse, type HttpUploadFileResponse, type INvwa, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, URL$1 as URL, URLSearchParams, createPostgrestClient, polyfill };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
|
|
2
2
|
import { PostgrestClient } from '@nvwa-app/postgrest-js';
|
|
3
|
-
import {
|
|
3
|
+
import { User } from 'better-auth';
|
|
4
4
|
import { createAuthClient } from 'better-auth/client';
|
|
5
5
|
|
|
6
6
|
interface NvwaLocalStorage {
|
|
@@ -219,5 +219,4 @@ interface INvwa {
|
|
|
219
219
|
fileStorage: NvwaFileStorage;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
export { AUTH_BASE_PATH, AbortController, AbortSignal, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, FetchResponse, GENERATE_UPLOAD_URL_PATH, Headers, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaAuthClient, NvwaEdgeFunctions, NvwaFileStorage, NvwaHttpClient, Request, Response, URL$1 as URL, URLSearchParams, createPostgrestClient, polyfill };
|
|
223
|
-
export type { AuthClient, FunctionInvokeOptions, HttpMethod, HttpRequest, HttpResponse, HttpUploadFileResponse, INvwa, NvwaAppUser, NvwaFetch, NvwaLocalStorage, RequestInfo, RequestInit, ResponseInit };
|
|
222
|
+
export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, FetchResponse, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HttpMethod, type HttpRequest, type HttpResponse, type HttpUploadFileResponse, type INvwa, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, URL$1 as URL, URLSearchParams, createPostgrestClient, polyfill };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Gt=Object.create;var ge=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Yt=(r,e)=>()=>(r&&(e=r(r=0)),e);var F=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Qt=(r,e)=>{for(var t in e)ge(r,t,{get:e[t],enumerable:!0})},st=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vt(e))!Jt.call(r,n)&&n!==t&&ge(r,n,{get:()=>e[n],enumerable:!(s=zt(e,n))||s.enumerable});return r};var Xt=(r,e,t)=>(t=r!=null?Gt(Kt(r)):{},st(e||!r||!r.__esModule?ge(t,"default",{value:r,enumerable:!0}):t,r)),Zt=r=>st(ge({},"__esModule",{value:!0}),r);var a=Yt(()=>{"use strict"});var se=F(T=>{"use strict";a();Object.defineProperty(T,"__esModule",{value:!0});T.File=T.FormData=T.Blob=T.FetchResponse=T.URL=T.URLSearchParams=T.FetchHeaders=void 0;var te=class{constructor(e){if(this.map=new Map,e)for(let[t,s]of Object.entries(e))this.set(t,s)}get(e){var t;return(t=this.map.get(e))!==null&&t!==void 0?t:null}set(e,t){this.map.set(e,t)}has(e){return this.map.has(e)}append(e,t){let s=this.map.get(e);s?this.map.set(e,`${s}${t}`):this.map.set(e,t)}delete(e){this.map.delete(e)}forEach(e){this.map.forEach(e)}size(){return this.map.size}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}headers(){return Object.fromEntries(this.map.entries())}[Symbol.iterator](){return this.map[Symbol.iterator]()}};T.FetchHeaders=te;var Se=class r{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,s]of e)this.append(t,s);else if(e&&typeof e=="object")for(let[t,s]of Object.entries(e))this.set(t,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let s of t)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(e,t){let s=this.params.get(e)||[];s.push(t),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[s])=>t.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[t,s]of this.params.entries())for(let n of s)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,s]of this.params.entries())for(let n of s)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,s]of this.params.entries())for(let n of s)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}};T.URLSearchParams=Se;var _e=class r{constructor(e,t){let s;if(e instanceof r)s=e.href;else if(t){let o=t instanceof r?t.href:t;s=this.resolve(o,e)}else s=e;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new Se(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let s=this.parseUrl(e),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let s=t[2]||"",n=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let d=n.match(/^([^@]*)@(.+)$/),u="",l="",h=n;if(d){let I=d[1];h=d[2];let y=I.match(/^([^:]*):?(.*)$/);y&&(u=y[1]||"",l=y[2]||"")}let p=h.match(/^([^:]+):?(\d*)$/),R=p?p[1]:h,E=p&&p[2]?p[2]:"";return{protocol:s?`${s}:`:"",username:u,password:l,host:h,hostname:R,port:E,pathname:o,search:i,hash:c}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};T.URL=_e;var Fe=class r{constructor(e,t){var s,n;this.status=(s=t?.status)!==null&&s!==void 0?s:200,this.statusText=(n=t?.statusText)!==null&&n!==void 0?n:"",this.headers=new te(t?.headers),this.ok=this.status>=200&&this.status<300,this.redirected=!1,this.url="",this.bodyUsed=!1,this.body=e||null}async arrayBuffer(){if(this.bodyUsed)throw new TypeError("Body has already been consumed");return this.bodyUsed=!0,this.body===null?new ArrayBuffer(0):new TextEncoder().encode(this.body).buffer}async blob(){if(this.bodyUsed)throw new TypeError("Body has already been consumed");return this.bodyUsed=!0,new re([this.body||""])}async formData(){if(this.bodyUsed)throw new TypeError("Body has already been consumed");return this.bodyUsed=!0,new Pe}async json(){if(this.bodyUsed)throw new TypeError("Body has already been consumed");return this.bodyUsed=!0,this.body===null?null:JSON.parse(this.body)}async text(){if(this.bodyUsed)throw new TypeError("Body has already been consumed");return this.bodyUsed=!0,this.body||""}clone(){if(this.bodyUsed)throw new TypeError("Body has already been consumed");return new r(this.body,{status:this.status,statusText:this.statusText,headers:this.headers.headers()})}static error(){let e=new r(null,{status:0,statusText:""});return Object.defineProperty(e,"type",{value:"error",writable:!1}),e}static redirect(e,t=302){let s=e instanceof _e?e.href:e,n=new r(null,{status:t,statusText:"Found"});return n.headers.set("Location",s),n}static json(e,t){let s=JSON.stringify(e),n=new te(t?.headers);return n.set("Content-Type","application/json"),new r(s,Object.assign(Object.assign({},t),{headers:n.headers()}))}};T.FetchResponse=Fe;var re=class r{constructor(e,t){this._content=e||[],this.type=t?.type||"";let s=0;for(let n of this._content)typeof n=="string"?s+=new TextEncoder().encode(n).length:n instanceof ArrayBuffer?s+=n.byteLength:n instanceof Uint8Array&&(s+=n.length);this.size=s}async text(){let e="";for(let t of this._content)typeof t=="string"?e+=t:t instanceof ArrayBuffer?e+=new TextDecoder().decode(t):t instanceof Uint8Array&&(e+=new TextDecoder().decode(t));return e}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}slice(e,t,s){return new r(this._content.slice(e,t),{type:s})}};T.Blob=re;var Pe=class{constructor(){this._entries=[]}append(e,t,s){this._entries.push([e,t])}delete(e){this._entries=this._entries.filter(([t])=>t!==e)}get(e){let t=this._entries.find(([s])=>s===e);return t?t[1]:null}getAll(e){return this._entries.filter(([t])=>t===e).map(([,t])=>t)}has(e){return this._entries.some(([t])=>t===e)}set(e,t,s){this.delete(e),this.append(e,t,s)}forEach(e){for(let[t,s]of this._entries)e(s,t,this)}keys(){return this._entries.map(([e])=>e)[Symbol.iterator]()}values(){return this._entries.map(([,e])=>e)[Symbol.iterator]()}entries(){return this._entries[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}};T.FormData=Pe;var He=class extends re{constructor(e,t,s){super(e,s),this.name=t,this.lastModified=s?.lastModified||Date.now()}};T.File=He});var Ge=F(We=>{"use strict";a();Object.defineProperty(We,"__esModule",{value:!0});var qe=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};We.default=qe});var Ve=F(ne=>{"use strict";a();var ss=ne&&ne.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ne,"__esModule",{value:!0});var ns=ss(Ge()),Ut=se(),ze=class{constructor(e){var t,s;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Ut.FetchHeaders(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(s=e.isMaybeSingle)!==null&&s!==void 0?s:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Ut.FetchHeaders(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let s=this.fetch,n=s(this.url.toString(),{method:this.method,headers:this.headers.headers(),body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,d,u;let l=null,h=null,p=null,R=o.status,E=o.statusText;if(o.ok){if(this.method!=="HEAD"){let _=await o.text();_===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?h=_:h=JSON.parse(_))}let y=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),O=(d=o.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");y&&O&&O.length>1&&(p=parseInt(O[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(h)&&(h.length>1?(l={code:"PGRST116",details:`Results contain ${h.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},h=null,p=null,R=406,E="Not Acceptable"):h.length===1?h=h[0]:h=null)}else{let y=await o.text();try{l=JSON.parse(y),Array.isArray(l)&&o.status===404&&(h=[],l=null,R=200,E="OK")}catch{o.status===404&&y===""?(R=204,E="No Content"):l={message:y}}if(l&&this.isMaybeSingle&&(!((u=l?.details)===null||u===void 0)&&u.includes("0 rows"))&&(l=null,R=200,E="OK"),l&&this.shouldThrowOnError)throw new ns.default(l)}return{error:l,data:h,count:p,status:R,statusText:E}});return this.shouldThrowOnError||(n=n.catch(o=>{var i,c,d;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(c=o?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(d=o?.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};ne.default=ze});var Je=F(oe=>{"use strict";a();var os=oe&&oe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(oe,"__esModule",{value:!0});var as=os(Ve()),Ke=class extends as.default{select(e){let t=!1,s=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:s,foreignTable:n,referencedTable:o=n}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:s=t}={}){let n=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:s,referencedTable:n=s}={}){let o=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${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.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:s=!1,buffers:n=!1,wal:o=!1,format:i="text"}={}){var c;let d=[e?"analyze":null,t?"verbose":null,s?"settings":null,n?"buffers":null,o?"wal":null].filter(Boolean).join("|"),u=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${u}"; options=${d};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};oe.default=Ke});var Ae=F(ae=>{"use strict";a();var is=ae&&ae.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ae,"__esModule",{value:!0});var ls=is(Je()),Ye=class extends ls.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let s=Array.from(new Set(t)).map(n=>typeof n=="string"&&new RegExp("[,()]").test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${s})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:s,type:n}={}){let o="";n==="plain"?o="pl":n==="phrase"?o="ph":n==="websearch"&&(o="w");let i=s===void 0?"":`(${s})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,s])=>{this.url.searchParams.append(t,`eq.${s}`)}),this}not(e,t,s){return this.url.searchParams.append(e,`not.${t}.${s}`),this}or(e,{foreignTable:t,referencedTable:s=t}={}){let n=s?`${s}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,s){return this.url.searchParams.append(e,`${t}.${s}`),this}};ae.default=Ye});var Xe=F(le=>{"use strict";a();var cs=le&&le.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(le,"__esModule",{value:!0});var us=se(),ie=cs(Ae()),Qe=class{constructor(e,{headers:t={},schema:s,fetch:n}){this.url=e,this.headers=new us.FetchHeaders(t),this.schema=s,this.fetch=n}select(e,t){let{head:s=!1,count:n}=t??{},o=s?"HEAD":"GET",i=!1,c=(e??"*").split("").map(d=>/\s/.test(d)&&!i?"":(d==='"'&&(i=!i),d)).join("");return this.url.searchParams.set("select",c),n&&this.headers.append("Prefer",`count=${n}`),new ie.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:s=!0}={}){var n;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),s||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,d)=>c.concat(Object.keys(d)),[]);if(i.length>0){let c=[...new Set(i)].map(d=>`"${d}"`);this.url.searchParams.set("columns",c.join(","))}}return new ie.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:s=!1,count:n,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let d=e.reduce((u,l)=>u.concat(Object.keys(l)),[]);if(d.length>0){let u=[...new Set(d)].map(l=>`"${l}"`);this.url.searchParams.set("columns",u.join(","))}}return new ie.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var s;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new ie.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}delete({count:e}={}){var t;let s="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new ie.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};le.default=Qe});var xt=F(ue=>{"use strict";a();var It=ue&&ue.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ue,"__esModule",{value:!0});var ds=It(Xe()),hs=It(Ae()),ce=se(),Ze=class r{constructor(e,{headers:t={},schema:s,fetch:n}={}){this.url=e,this.headers=new ce.FetchHeaders(t),this.schemaName=s,this.fetch=n}from(e){let t=new ce.URL(`${this.url}/${e}`);return new ds.default(t,{headers:new ce.FetchHeaders(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:s=!1,get:n=!1,count:o}={}){var i;let c,d=new ce.URL(`${this.url}/rpc/${e}`),u;s||n?(c=s?"HEAD":"GET",Object.entries(t).filter(([h,p])=>p!==void 0).map(([h,p])=>[h,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([h,p])=>{d.searchParams.append(h,p)})):(c="POST",u=t);let l=new ce.FetchHeaders(this.headers);return o&&l.set("Prefer",`count=${o}`),new hs.default({method:c,url:d,headers:l,schema:this.schemaName,body:u,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};ue.default=Ze});var Mt=F(g=>{"use strict";a();var z=g&&g.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(g,"__esModule",{value:!0});g.File=g.FormData=g.Blob=g.FetchResponse=g.FetchHeaders=g.URLSearchParams=g.URL=g.PostgrestError=g.PostgrestBuilder=g.PostgrestTransformBuilder=g.PostgrestFilterBuilder=g.PostgrestQueryBuilder=g.PostgrestClient=void 0;var Ct=z(xt());g.PostgrestClient=Ct.default;var Nt=z(Xe());g.PostgrestQueryBuilder=Nt.default;var Lt=z(Ae());g.PostgrestFilterBuilder=Lt.default;var $t=z(Je());g.PostgrestTransformBuilder=$t.default;var Dt=z(Ve());g.PostgrestBuilder=Dt.default;var kt=z(Ge());g.PostgrestError=kt.default;var k=se();Object.defineProperty(g,"FetchHeaders",{enumerable:!0,get:function(){return k.FetchHeaders}});Object.defineProperty(g,"FetchResponse",{enumerable:!0,get:function(){return k.FetchResponse}});Object.defineProperty(g,"URL",{enumerable:!0,get:function(){return k.URL}});Object.defineProperty(g,"URLSearchParams",{enumerable:!0,get:function(){return k.URLSearchParams}});Object.defineProperty(g,"Blob",{enumerable:!0,get:function(){return k.Blob}});Object.defineProperty(g,"FormData",{enumerable:!0,get:function(){return k.FormData}});Object.defineProperty(g,"File",{enumerable:!0,get:function(){return k.File}});g.default={PostgrestClient:Ct.default,PostgrestQueryBuilder:Nt.default,PostgrestFilterBuilder:Lt.default,PostgrestTransformBuilder:$t.default,PostgrestBuilder:Dt.default,PostgrestError:kt.default,URLSearchParams:k.URLSearchParams,FetchHeaders:k.FetchHeaders,FetchResponse:k.FetchResponse}});var ys={};Qt(ys,{AUTH_BASE_PATH:()=>Pt,AbortController:()=>pe,AbortSignal:()=>K,ENTITIES_BASE_PATH:()=>Ft,FILE_STORAGE_BASE_PATH:()=>At,FetchResponse:()=>Me,GENERATE_UPLOAD_URL_PATH:()=>Ot,Headers:()=>N,LOGIN_TOKEN_KEY:()=>ee,LOGIN_USER_PROFILE_KEY:()=>Te,NvwaAuthClient:()=>De,NvwaEdgeFunctions:()=>ke,NvwaFileStorage:()=>je,NvwaHttpClient:()=>Be,Request:()=>he,Response:()=>fe,URL:()=>de,URLSearchParams:()=>V,createPostgrestClient:()=>ps,polyfill:()=>gs});module.exports=Zt(ys);a();a();a();a();a();a();var er=Object.defineProperty,tr=Object.defineProperties,rr=Object.getOwnPropertyDescriptors,nt=Object.getOwnPropertySymbols,sr=Object.prototype.hasOwnProperty,nr=Object.prototype.propertyIsEnumerable,ot=(r,e,t)=>e in r?er(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,x=(r,e)=>{for(var t in e||(e={}))sr.call(e,t)&&ot(r,t,e[t]);if(nt)for(var t of nt(e))nr.call(e,t)&&ot(r,t,e[t]);return r},L=(r,e)=>tr(r,rr(e)),or=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},ar=async(r,e)=>{var t,s,n,o,i,c;let d=e||{},u={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:d,hooks:u};for(let l of e?.plugins||[]){if(l.init){let h=await((t=l.init)==null?void 0:t.call(l,r.toString(),e));d=h.options||d,r=h.url}u.onRequest.push((s=l.hooks)==null?void 0:s.onRequest),u.onResponse.push((n=l.hooks)==null?void 0:n.onResponse),u.onSuccess.push((o=l.hooks)==null?void 0:o.onSuccess),u.onError.push((i=l.hooks)==null?void 0:i.onError),u.onRetry.push((c=l.hooks)==null?void 0:c.onRetry)}return{url:r,options:d,hooks:u}},at=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(){return this.options.delay}},ir=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(r){return Math.min(this.options.maxDelay,this.options.baseDelay*2**r)}};function lr(r){if(typeof r=="number")return new at({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new at(r);case"exponential":return new ir(r);default:throw new Error("Invalid retry strategy")}}var cr=async r=>{let e={},t=async s=>typeof s=="function"?await s():s;if(r?.auth){if(r.auth.type==="Bearer"){let s=await t(r.auth.token);if(!s)return e;e.authorization=`Bearer ${s}`}else if(r.auth.type==="Basic"){let s=t(r.auth.username),n=t(r.auth.password);if(!s||!n)return e;e.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(r.auth.type==="Custom"){let s=t(r.auth.value);if(!s)return e;e.authorization=`${t(r.auth.prefix)} ${s}`}}return e},ur=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function dr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let s=e.split(";").shift()||"";return ur.test(s)?"json":t.has(s)||s.startsWith("text/")?"text":"blob"}function hr(r){try{return JSON.parse(r),!0}catch{return!1}}function ct(r){if(r===void 0)return!1;let e=typeof r;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(r)?!0:r.buffer?!1:r.constructor&&r.constructor.name==="Object"||typeof r.toJSON=="function"}function it(r){try{return JSON.parse(r)}catch{return r}}function lt(r){return typeof r=="function"}function fr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&<(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&<(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function pr(r){let e=new Headers(r?.headers),t=await cr(r);for(let[s,n]of Object.entries(t||{}))e.set(s,n);if(!e.has("content-type")){let s=mr(r?.body);s&&e.set("content-type",s)}return e}function mr(r){return ct(r)?"application/json":null}function gr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ct(r.body)&&!e.has("content-type")){for(let[t,s]of Object.entries(r?.body))s instanceof Date&&(r.body[t]=s.toISOString());return JSON.stringify(r.body)}return r.body}function yr(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let s=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return dt.includes(s)?s.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function br(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Rr=class ut extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,ut.prototype)}};async function ye(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Rr(t.issues);return t.value}var dt=["get","post","put","patch","delete"];var wr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var s,n,o,i;let c=((n=(s=r.plugins)==null?void 0:s.find(d=>{var u;return(u=d.schema)!=null&&u.config?e.startsWith(d.schema.config.baseURL||"")||e.startsWith(d.schema.config.prefix||""):!1}))==null?void 0:n.schema)||r.schema;if(c){let d=e;(o=c.config)!=null&&o.prefix&&d.startsWith(c.config.prefix)&&(d=d.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&d.startsWith(c.config.baseURL)&&(d=d.replace(c.config.baseURL,""));let u=c.schema[d];if(u){let l=L(x({},t),{method:u.method,output:u.output});return t?.disableValidation||(l=L(x({},l),{body:u.input?await ye(u.input,t?.body):t?.body,params:u.params?await ye(u.params,t?.params):t?.params,query:u.query?await ye(u.query,t?.query):t?.query})),{url:e,options:l}}}return{url:e,options:t}}}),ht=r=>{async function e(t,s){let n=L(x(x({},r),s),{plugins:[...r?.plugins||[],wr(r||{})]});if(r?.catchAllError)try{return await Ue(t,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await Ue(t,n)}return e};function Er(r,e){let{baseURL:t,params:s,query:n}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let h=r.toString().split("@")[1].split("/")[0];dt.includes(h)&&(r=r.replace(`@${h}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),d=new URLSearchParams(c);for(let[h,p]of Object.entries(n||{}))p!=null&&d.set(h,String(p));if(s)if(Array.isArray(s)){let h=i.split("/").filter(p=>p.startsWith(":"));for(let[p,R]of h.entries()){let E=s[p];i=i.replace(R,E)}}else for(let[h,p]of Object.entries(s))i=i.replace(`:${h}`,String(p));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let u=d.toString();return u=u.length>0?`?${u}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${u}`,o):`${o}${i}${u}`}var Ue=async(r,e)=>{var t,s,n,o,i,c,d,u;let{hooks:l,url:h,options:p}=await ar(r,e),R=fr(p),E=new AbortController,I=(t=p.signal)!=null?t:E.signal,y=Er(h,p),O=gr(p),_=await pr(p),M=yr(h,p),m=L(x({},p),{url:y,headers:_,body:O,method:M,signal:I});for(let U of l.onRequest)if(U){let S=await U(m);S instanceof Object&&(m=S)}("pipeTo"in m&&typeof m.pipeTo=="function"||typeof((s=e?.body)==null?void 0:s.pipe)=="function")&&("duplex"in m||(m.duplex="half"));let{clearTimeout:q}=br(p,E),w=await R(m.url,m);q();let tt={response:w,request:m};for(let U of l.onResponse)if(U){let S=await U(L(x({},tt),{response:(n=e?.hookOptions)!=null&&n.cloneResponse?w.clone():w}));S instanceof Response?w=S:S instanceof Object&&(w=S.response)}if(w.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let S=dr(w),B={data:"",response:w,request:m};if(S==="json"||S==="text"){let j=await w.text(),Wt=await((o=m.jsonParser)!=null?o:it)(j);B.data=Wt}else B.data=await w[S]();m?.output&&m.output&&!m.disableValidation&&(B.data=await ye(m.output,B.data));for(let j of l.onSuccess)j&&await j(L(x({},B),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?w.clone():w}));return e?.throw?B.data:{data:B.data,error:null}}let Ht=(c=e?.jsonParser)!=null?c:it,me=await w.text(),rt=hr(me),Oe=rt?await Ht(me):null,qt={response:w,responseText:me,request:m,error:L(x({},Oe),{status:w.status,statusText:w.statusText})};for(let U of l.onError)U&&await U(L(x({},qt),{response:(d=e?.hookOptions)!=null&&d.cloneResponse?w.clone():w}));if(e?.retry){let U=lr(e.retry),S=(u=e.retryAttempt)!=null?u:0;if(await U.shouldAttemptRetry(S,w)){for(let j of l.onRetry)j&&await j(tt);let B=U.getDelay(S);return await new Promise(j=>setTimeout(j,B)),await Ue(r,L(x({},e),{retryAttempt:S+1}))}}if(e?.throw)throw new or(w.status,w.statusText,rt?Oe:me);return{data:null,error:L(x({},Oe),{status:w.status,statusText:w.statusText})}};a();a();var be=Object.create(null),J=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?be:globalThis),A=new Proxy(be,{get(r,e){return J()[e]??be[e]},has(r,e){let t=J();return e in t||e in be},set(r,e,t){let s=J(!0);return s[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=J(!0);return delete t[e],!0},ownKeys(){let r=J(!0);return Object.keys(r)}});var Ps=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(r,e){return typeof process<"u"&&process.env?process.env[r]??e:typeof Deno<"u"?Deno.env.get(r)??e:typeof Bun<"u"?Bun.env[r]??e:e}var As=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Y=1,v=4,$=8,P=24,ft={eterm:v,cons25:v,console:v,cygwin:v,dtterm:v,gnome:v,hurd:v,jfbterm:v,konsole:v,kterm:v,mlterm:v,mosh:P,putty:v,st:v,"rxvt-unicode-24bit":P,terminator:P,"xterm-kitty":P},vr=new Map(Object.entries({APPVEYOR:$,BUILDKITE:$,CIRCLECI:P,DRONE:$,GITEA_ACTIONS:P,GITHUB_ACTIONS:P,GITLAB_CI:$,TRAVIS:$})),Tr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Sr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return v;case"2":return $;case"3":return P;default:return Y}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return Y;if(b("TMUX"))return P;if("TF_BUILD"in A&&"AGENT_NAME"in A)return v;if("CI"in A){for(let{0:r,1:e}of vr)if(r in A)return e;return b("CI_NAME")==="codeship"?$:Y}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?v:Y;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?$:P;case"HyperTerm":case"MacTerm":return P;case"Apple_Terminal":return $}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return P;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return P;if(/^xterm-256/.exec(b("TERM"))!==null)return $;let r=b("TERM").toLowerCase();if(ft[r])return ft[r];if(Tr.some(e=>e.exec(r)!==null))return v}return b("COLORTERM")?v:Y}var D={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},Ie=["info","success","warn","error","debug"];function _r(r,e){return Ie.indexOf(e)<=Ie.indexOf(r)}var Pr={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},Ar=(r,e,t)=>{let s=new Date().toISOString();return t?`${D.dim}${s}${D.reset} ${Pr[r]}${r.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.reset} ${e}`:`${s} ${r.toUpperCase()} [Better Auth]: ${e}`},Or=r=>{let e=r?.disabled!==!0,t=r?.level??"error",n=r?.disableColors!==void 0?!r.disableColors:Sr()!==1,o=(c,d,u=[])=>{if(!e||!_r(t,c))return;let l=Ar(c,d,n);if(!r||typeof r.log!="function"){c==="error"?console.error(l,...u):c==="warn"?console.warn(l,...u):console.log(l,...u);return}r.log(c==="success"?"info":c,d,...u)};return{...Object.fromEntries(Ie.map(c=>[c,(...[d,...u])=>o(c,d,u)])),get level(){return t}}},Os=Or();a();a();var $s={USER_NOT_FOUND:"User not found",FAILED_TO_CREATE_USER:"Failed to create user",FAILED_TO_CREATE_SESSION:"Failed to create session",FAILED_TO_UPDATE_USER:"Failed to update user",FAILED_TO_GET_SESSION:"Failed to get session",INVALID_PASSWORD:"Invalid password",INVALID_EMAIL:"Invalid email",INVALID_EMAIL_OR_PASSWORD:"Invalid email or password",SOCIAL_ACCOUNT_ALREADY_LINKED:"Social account already linked",PROVIDER_NOT_FOUND:"Provider not found",INVALID_TOKEN:"Invalid token",ID_TOKEN_NOT_SUPPORTED:"id_token not supported",FAILED_TO_GET_USER_INFO:"Failed to get user info",USER_EMAIL_NOT_FOUND:"User email not found",EMAIL_NOT_VERIFIED:"Email not verified",PASSWORD_TOO_SHORT:"Password too short",PASSWORD_TOO_LONG:"Password too long",USER_ALREADY_EXISTS:"User already exists.",USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:"User already exists. Use another email.",EMAIL_CAN_NOT_BE_UPDATED:"Email can not be updated",CREDENTIAL_ACCOUNT_NOT_FOUND:"Credential account not found",SESSION_EXPIRED:"Session expired. Re-authenticate to perform this action.",FAILED_TO_UNLINK_LAST_ACCOUNT:"You can't unlink your last account",ACCOUNT_NOT_FOUND:"Account not found",USER_ALREADY_HAS_PASSWORD:"User already has a password. Provide that to delete the account."},W=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Ur(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new W(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function Q(r,e="/api/auth"){if(Ur(r))return r;let s=r.replace(/\/+$/,"");return!e||e==="/"?s:(e=e.startsWith("/")?e:`/${e}`,`${s}${e}`)}function pt(r,e,t,s){if(r)return Q(r,e);if(s!==!1){let i=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(i)return Q(i,e)}let n=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(n&&o)return Q(`${o}://${n}`,e);if(t){let i=Ir(t.url);if(!i)throw new W("Could not get origin from request. Please provide a valid base URL.");return Q(i,e)}if(typeof window<"u"&&window.location)return Q(window.location.origin,e)}function Ir(r){try{return new URL(r).origin}catch{return null}}a();a();a();var X=Symbol("clean");var C=[],H=0,Re=4,xr=0,Z=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(s){return t.lc=e.push(s),()=>{for(let o=H+Re;o<C.length;)C[o]===s?C.splice(o,Re):o+=Re;let n=e.indexOf(s);~n&&(e.splice(n,1),--t.lc||t.off())}},notify(s,n){xr++;let o=!C.length;for(let i of e)C.push(i,t.value,s,n);if(o){for(H=0;H<C.length;H+=Re)C[H](C[H+1],C[H+2],C[H+3]);C.length=0}},off(){},set(s){let n=t.value;n!==s&&(t.value=s,t.notify(n))},subscribe(s){let n=t.listen(s);return s(t.value),n},value:r};return process.env.NODE_ENV!=="production"&&(t[X]=()=>{e=[],t.lc=0,t.off()}),t};a();var Cr=5,G=6,we=10,Nr=(r,e,t,s)=>(r.events=r.events||{},r.events[t+we]||(r.events[t+we]=s(n=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...n})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let n=r.events[t],o=n.indexOf(e);n.splice(o,1),n.length||(delete r.events[t],r.events[t+we](),delete r.events[t+we])});var mt=1e3,xe=(r,e)=>Nr(r,s=>{let n=e(s);n&&r.events[G].push(n)},Cr,s=>{let n=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,s()),n(...i));let o=r.off;if(r.events[G]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[G])i();r.events[G]=[]}},mt)},process.env.NODE_ENV!=="production"){let i=r[X];r[X]=()=>{for(let c of r.events[G])c();r.events[G]=[],r.active=!1,i()}}return()=>{r.listen=n,r.off=o}});a();var Lr=typeof window>"u",Ee=(r,e,t,s)=>{let n=Z({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let d=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;t(e,{...d,query:{...d?.query,...c?.query},async onSuccess(u){n.set({data:u.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await d?.onSuccess?.(u)},async onError(u){let{request:l}=u,h=typeof l.retry=="number"?l.retry:l.retry?.attempts,p=l.retryAttempt||0;h&&p<h||(n.set({error:u.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await d?.onError?.(u))},async onRequest(u){let l=n.get();n.set({isPending:l.data===null,data:l.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await d?.onRequest?.(u)}}).catch(u=>{n.set({error:u,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{Lr||(i?o():xe(n,()=>{let d=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{n.off(),c.off(),clearTimeout(d)}}))});return n};a();var $r={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Dr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,gt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},kr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Mr(r){return r instanceof Date&&!isNaN(r.getTime())}function Br(r){let e=kr.exec(r);if(!e)return null;let[,t,s,n,o,i,c,d,u,l,h]=e,p=new Date(Date.UTC(parseInt(t,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),d?parseInt(d.padEnd(3,"0"),10):0));if(u){let R=(parseInt(l,10)*60+parseInt(h,10))*(u==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+R)}return Mr(p)?p:null}function jr(r,e={}){let{strict:t=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=e;if(typeof r!="string")return r;let i=r.trim();if(i.length>0&&i[0]==='"'&&i.endsWith('"')&&!i.slice(1,-1).includes('"'))return i.slice(1,-1);let c=i.toLowerCase();if(c.length<=9&&c in gt)return gt[c];if(!Dr.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries($r).some(([u,l])=>{let h=l.test(i);return h&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),h})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(l,h)=>{if(l==="__proto__"||l==="constructor"&&h&&typeof h=="object"&&"prototype"in h){s&&console.warn(`[better-json] Dropping "${l}" key to prevent prototype pollution`);return}if(o&&typeof h=="string"){let p=Br(h);if(p)return p}return n?n(l,h):h})}catch(u){if(t)throw u;return r}}function yt(r,e={strict:!0}){return jr(r,e)}var Fr={id:"redirect",name:"Redirect",hooks:{onSuccess(r){if(r.data?.url&&r.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=r.data.url}catch{}}}};function Hr(r){let e=Z(!1);return{session:Ee(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var bt=(r,e)=>{let t="credentials"in Request.prototype,s=pt(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",n=r?.plugins?.flatMap(m=>m.fetchPlugins).filter(m=>m!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:r?.fetchOptions?.onSuccess,onError:r?.fetchOptions?.onError,onRequest:r?.fetchOptions?.onRequest,onResponse:r?.fetchOptions?.onResponse}},{onSuccess:i,onError:c,onRequest:d,onResponse:u,...l}=r?.fetchOptions||{},h=ht({baseURL:s,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?yt(m,{strict:!1}):null},customFetchImpl:fetch,...l,plugins:[o,...l.plugins||[],...r?.disableDefaultFetchPlugins?[]:[Fr],...n]}),{$sessionSignal:p,session:R}=Hr(h),E=r?.plugins||[],I={},y={$sessionSignal:p,session:R},O={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},_=[{signal:"$sessionSignal",matcher(m){return m==="/sign-out"||m==="/update-user"||m.startsWith("/sign-in")||m.startsWith("/sign-up")||m==="/delete-user"||m==="/verify-email"}}];for(let m of E)m.getAtoms&&Object.assign(y,m.getAtoms?.(h)),m.pathMethods&&Object.assign(O,m.pathMethods),m.atomListeners&&_.push(...m.atomListeners);let M={notify:m=>{y[m].set(!y[m].get())},listen:(m,q)=>{y[m].subscribe(q)},atoms:y};for(let m of E)m.getActions&&Object.assign(I,m.getActions?.(h,M,r));return{get baseURL(){return s},pluginsActions:I,pluginsAtoms:y,pluginPathMethods:O,atomListeners:_,$fetch:h,$store:M}};function qr(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function Wr(r,e,t){let s=e[r],{fetchOptions:n,query:o,...i}=t||{};return s||(n?.method?n.method:i&&Object.keys(i).length>0?"POST":"GET")}function Rt(r,e,t,s,n){function o(i=[]){return new Proxy(function(){},{get(c,d){if(typeof d!="string"||d==="then"||d==="catch"||d==="finally")return;let u=[...i,d],l=r;for(let h of u)if(l&&typeof l=="object"&&h in l)l=l[h];else{l=void 0;break}return typeof l=="function"||qr(l)?l:o(u)},apply:async(c,d,u)=>{let l="/"+i.map(_=>_.replace(/[A-Z]/g,M=>`-${M.toLowerCase()}`)).join("/"),h=u[0]||{},p=u[1]||{},{query:R,fetchOptions:E,...I}=h,y={...p,...E},O=Wr(l,t,h);return await e(l,{...y,body:O==="GET"?void 0:{...I,...y?.body||{}},query:R||y?.query,method:O,async onSuccess(_){if(await y?.onSuccess?.(_),!n)return;let M=n.filter(m=>m.matcher(l));if(M.length)for(let m of M){let q=s[m.signal];if(!q)return;let w=q.get();setTimeout(()=>{q.set(!w)},10)}}})}})}return o()}a();function wt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Ce(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:i}=bt(r),c={};for(let[l,h]of Object.entries(s))c[`use${wt(l)}`]=h;let d={...t,...c,$fetch:n,$store:i};return Rt(d,n,e,s,o)}a();a();a();function Gr(r){return{authorize(e,t="AND"){let s=!1;for(let[n,o]of Object.entries(e)){let i=r[n];if(!i)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?s=c.actions.some(d=>i.includes(d)):s=c.actions.every(d=>i.includes(d))}else throw new W("Invalid access control request");if(s&&t==="OR")return{success:s};if(!s&&t==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:r}}function ve(r){return{newRole(e){return Gr(e)},statements:r}}var zr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Ne=ve(zr),Vr=Ne.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Kr=Ne.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Jr=Ne.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});a();a();a();a();a();a();a();a();a();a();a();var Le=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Tt=new Le;a();a();a();a();a();a();a();a();var es={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},St=ve(es),ts=St.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),rs=St.newRole({user:[],session:[]});a();a();var _t=()=>({id:"username",$InferServerPlugin:{}});var Pt="/auth",ee="nvwa_login_token",Te="nvwa_user_profile",De=class{constructor(e,t,s){this.storage=s,this.authClient=Ce({baseURL:e,basePath:Pt,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>s.get(ee)},onSuccess:n=>{let o=n.response.headers.get("set-auth-token");o&&s.set(ee,o)}},plugins:[_t()]})}async currentUser(){return await this.storage.get(Te)}async signUp(e,t){let s=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:t});this.saveSession(s)}async signInWithUsername(e,t){let s=await this.authClient.signIn.username({username:e,password:t});this.saveSession(s)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(ee,e.data?.token),this.storage.set(Te,e.data?.user)}async signOut(){await this.storage.remove(ee),await this.storage.remove(Te)}async updateUserPassword(e,t,s=!1){let n=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:s});this.saveSession(n)}};a();var ke=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};a();var Me=class{constructor(e,t,s,n,o){this.ok=e,this.status=t,this.statusText=s,this.headers=n,this.body=o}async text(){return typeof this.body=="string"?this.body:JSON.stringify(this.body)}async json(){if(typeof this.body=="string")try{return JSON.parse(this.body)}catch{return this.body}return this.body}async arrayBuffer(){if(this.body instanceof ArrayBuffer)return this.body;if(typeof this.body=="string")return new TextEncoder().encode(this.body).buffer;throw new Error("Cannot convert body to ArrayBuffer")}async blob(){if(this.body instanceof Blob)return this.body;if(typeof this.body=="string")return new Blob([this.body],{type:this.headers["content-type"]||"text/plain"});throw new Error("Cannot convert body to Blob")}},Be=class{async jsonRequest(e,t){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,s)}async jsonRequestWithAuth(e,t,s){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,n,s)}};a();var At="/storage",Ot=At+"/generateUploadUrl",je=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+Ot,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:s}=t.body;if(!s)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(s,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};a();a();a();var Bt=Xt(Mt(),1),{PostgrestClient:jt,PostgrestQueryBuilder:ii,PostgrestFilterBuilder:li,PostgrestTransformBuilder:ci,PostgrestBuilder:ui,PostgrestError:di,FetchHeaders:hi,FetchResponse:et,PostgrestFetch:fi,URL:pi,URLSearchParams:mi}=Bt.default;var Ft="/entities",fs=(r,e)=>async(s,n)=>{console.log("customFetch",s,n);let o;if(typeof s=="string")o=s;else if(s&&typeof s=="object")if(typeof s.toString=="function"&&!s.url)o=s.toString();else if(s.url)o=s.url,n||(n={}),n.method=s.method,n.headers=s.headers,n.body=s.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(n?.method||"GET").toUpperCase(),c={};if(n?.headers)if(n.headers&&typeof n.headers.forEach=="function")n.headers.forEach((R,E)=>{c[E]=R});else if(Array.isArray(n.headers))for(let[R,E]of n.headers)c[R]=E;else Object.assign(c,n.headers);let d=n?.body,u;try{u=await r.requestWithAuth(o,{method:i,data:d,headers:c},e)}catch(R){return new et(R?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let l=u.body,h=null;return(u.headers["content-type"]||u.headers["Content-Type"]||"").startsWith("application/json")&&typeof l!="string"?h=JSON.stringify(l):typeof l=="string"||l&&(l.constructor===Blob||l.constructor===ArrayBuffer||typeof l.getReader=="function")?h=l:h=JSON.stringify(l),new et(h,{status:u.status,headers:u.headers})},ps=(r,e,t)=>new jt(r+Ft,{fetch:fs(e,t)});a();a();var N=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,s)=>this.set(s,t));else if(Array.isArray(e))for(let[t,s]of e)this.set(t,String(s));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let s=e.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,s]of this.headerMap.entries())e(s,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},V=class r{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,s]of e)this.append(t,s);else if(e&&typeof e=="object")for(let[t,s]of Object.entries(e))this.set(t,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let s of t)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(e,t){let s=this.params.get(e)||[];s.push(t),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[s])=>t.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[t,s]of this.params.entries())for(let n of s)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,s]of this.params.entries())for(let n of s)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,s]of this.params.entries())for(let n of s)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},de=class r{constructor(e,t){let s;if(e instanceof r)s=e.href;else if(t){let o=t instanceof r?t.href:t;s=this.resolve(o,e)}else s=e;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new V(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let s=this.parseUrl(e),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let s=t[2]||"",n=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let d=n.match(/^([^@]*)@(.+)$/),u="",l="",h=n;if(d){let I=d[1];h=d[2];let y=I.match(/^([^:]*):?(.*)$/);y&&(u=y[1]||"",l=y[2]||"")}let p=h.match(/^([^:]+):?(\d*)$/),R=p?p[1]:h,E=p&&p[2]?p[2]:"";return{protocol:s?`${s}:`:"",username:u,password:l,host:h,hostname:R,port:E,pathname:o,search:i,hash:c}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};a();var he=class r{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof N?t.headers:new N(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new r(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};a();var fe=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ms(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ms(r){return r?new N(r):new N}a();var K=class{constructor(){this._aborted=!1;this.listeners=new Set;this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},pe=class{constructor(){this._signal=new K}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};a();function gs(r){r.URL=de,r.URLSearchParams=V,r.Headers=N,r.Request=he,r.Response=fe,r.AbortController=pe,r.AbortSignal=K}0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,FetchResponse,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,Request,Response,URL,URLSearchParams,createPostgrestClient,polyfill});
|