@nvwa-app/sdk-core 0.4.12 → 0.4.13

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 CHANGED
@@ -1,5 +1,5 @@
1
- import * as _supabase_postgrest_js from '@supabase/postgrest-js';
2
- import { PostgrestClient } from '@supabase/postgrest-js';
1
+ import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
2
+ import { PostgrestClient } from '@nvwa-app/postgrest-js';
3
3
  import { User } from 'better-auth';
4
4
  import { createAuthClient } from 'better-auth/client';
5
5
 
@@ -198,7 +198,7 @@ declare class NvwaEdgeFunctions {
198
198
  }
199
199
 
200
200
  declare const ENTITIES_BASE_PATH = "/entities";
201
- declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient, handleUnauthorized: () => void) => PostgrestClient<any, {} | _supabase_postgrest_js.PostgrestClientOptions, "public", any>;
201
+ declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient, handleUnauthorized: () => void) => PostgrestClient<any, {} | _nvwa_app_postgrest_js.PostgrestClientOptions, "public", any>;
202
202
 
203
203
  interface INvwa {
204
204
  entities: PostgrestClient;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import * as _supabase_postgrest_js from '@supabase/postgrest-js';
2
- import { PostgrestClient } from '@supabase/postgrest-js';
1
+ import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
2
+ import { PostgrestClient } from '@nvwa-app/postgrest-js';
3
3
  import { User } from 'better-auth';
4
4
  import { createAuthClient } from 'better-auth/client';
5
5
 
@@ -198,7 +198,7 @@ declare class NvwaEdgeFunctions {
198
198
  }
199
199
 
200
200
  declare const ENTITIES_BASE_PATH = "/entities";
201
- declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient, handleUnauthorized: () => void) => PostgrestClient<any, {} | _supabase_postgrest_js.PostgrestClientOptions, "public", any>;
201
+ declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient, handleUnauthorized: () => void) => PostgrestClient<any, {} | _nvwa_app_postgrest_js.PostgrestClientOptions, "public", any>;
202
202
 
203
203
  interface INvwa {
204
204
  entities: PostgrestClient;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var yr=Object.create;var ce=Object.defineProperty;var br=Object.getOwnPropertyDescriptor;var wr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Rr=Object.prototype.hasOwnProperty;var tt=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),rt=(r,e)=>{for(var t in e)ce(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wr(e))!Rr.call(r,s)&&s!==t&&ce(r,s,{get:()=>e[s],enumerable:!(n=br(e,s))||n.enumerable});return r};var vr=(r,e,t)=>(t=r!=null?yr(_r(r)):{},nt(e||!r||!r.__esModule?ce(t,"default",{value:r,enumerable:!0}):t,r)),F=r=>nt(ce({},"__esModule",{value:!0}),r);var l=tt(()=>{"use strict"});var W={};rt(W,{__addDisposableResource:()=>Zt,__assign:()=>ye,__asyncDelegator:()=>Wt,__asyncGenerator:()=>Gt,__asyncValues:()=>Vt,__await:()=>K,__awaiter:()=>kt,__classPrivateFieldGet:()=>Yt,__classPrivateFieldIn:()=>Xt,__classPrivateFieldSet:()=>Qt,__createBinding:()=>we,__decorate:()=>Ut,__disposeResources:()=>er,__esDecorate:()=>Nt,__exportStar:()=>Bt,__extends:()=>xt,__generator:()=>Mt,__importDefault:()=>Jt,__importStar:()=>Kt,__makeTemplateObject:()=>zt,__metadata:()=>jt,__param:()=>Ct,__propKey:()=>Dt,__read:()=>De,__rest:()=>It,__rewriteRelativeImportExtension:()=>tr,__runInitializers:()=>Lt,__setFunctionName:()=>$t,__spread:()=>qt,__spreadArray:()=>Ft,__spreadArrays:()=>Ht,__values:()=>be,default:()=>xn});function xt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ne(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function It(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function Ut(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function Ct(r,e){return function(t,n){e(t,n,r)}}function Nt(r,e,t,n,s,o){function i(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var c=n.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?n.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,n.name):{}),d,p=!1,g=t.length-1;g>=0;g--){var y={};for(var R in n)y[R]=R==="access"?{}:n[R];for(var R in n.access)y.access[R]=n.access[R];y.addInitializer=function(v){if(p)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(v||null))};var b=(0,t[g])(c==="accessor"?{get:u.get,set:u.set}:u[f],y);if(c==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(d=i(b.get))&&(u.get=d),(d=i(b.set))&&(u.set=d),(d=i(b.init))&&s.unshift(d)}else(d=i(b))&&(c==="field"?s.unshift(d):u[f]=d)}a&&Object.defineProperty(a,n.name,u),p=!0}function Lt(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Dt(r){return typeof r=="symbol"?r:"".concat(r)}function $t(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function jt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function kt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(n.next(u))}catch(d){i(d)}}function f(u){try{a(n.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):s(u.value).then(c,f)}a((n=n.apply(r,e||[])).next())})}function Mt(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(n=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,s=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Bt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&we(e,r,t)}function be(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function De(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function qt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(De(arguments[e]));return r}function Ht(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,s++)n[s]=o[i];return n}function Ft(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function K(r){return this instanceof K?(this.v=r,this):new K(r)}function Gt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(g){return function(y){return Promise.resolve(y).then(g,d)}}function c(g,y){n[g]&&(s[g]=function(R){return new Promise(function(b,v){o.push([g,R,b,v])>1||f(g,R)})},y&&(s[g]=y(s[g])))}function f(g,y){try{a(n[g](y))}catch(R){p(o[0][3],R)}}function a(g){g.value instanceof K?Promise.resolve(g.value.v).then(u,d):p(o[0][2],g)}function u(g){f("next",g)}function d(g){f("throw",g)}function p(g,y){g(y),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Wt(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:K(r[s](i)),done:!1}:o?o(i):i}:o}}function Vt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof be=="function"?be(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),s(c,f,i.done,i.value)})}}function s(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function zt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Kt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Le(r),n=0;n<t.length;n++)t[n]!=="default"&&we(e,r,t[n]);return On(e,r),e}function Jt(r){return r&&r.__esModule?r:{default:r}}function Yt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Qt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function Xt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Zt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function er(r){function e(o){r.error=r.hasError?new An(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function tr(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ne,ye,we,On,Le,An,xn,V=tt(()=>{"use strict";l();Ne=function(r,e){return Ne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ne(r,e)};ye=function(){return ye=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ye.apply(this,arguments)};we=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});On=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Le=function(r){return Le=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Le(r)};An=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};xn={__extends:xt,__assign:ye,__rest:It,__decorate:Ut,__param:Ct,__esDecorate:Nt,__runInitializers:Lt,__propKey:Dt,__setFunctionName:$t,__metadata:jt,__awaiter:kt,__generator:Mt,__createBinding:we,__exportStar:Bt,__values:be,__read:De,__spread:qt,__spreadArrays:Ht,__spreadArray:Ft,__await:K,__asyncGenerator:Gt,__asyncDelegator:Wt,__asyncValues:Vt,__makeTemplateObject:zt,__importStar:Kt,__importDefault:Jt,__classPrivateFieldGet:Yt,__classPrivateFieldSet:Qt,__classPrivateFieldIn:Xt,__addDisposableResource:Zt,__disposeResources:er,__rewriteRelativeImportExtension:tr}});var ke=H(je=>{"use strict";l();Object.defineProperty(je,"__esModule",{value:!0});var $e=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};je.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var rr=(V(),F(W)),In=rr.__importDefault(require("@supabase/node-fetch")),Un=rr.__importDefault(ke()),Me=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=In.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){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 n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,p=null,g=o.status,y=o.statusText;if(o.ok){if(this.method!=="HEAD"){let P=await o.text();P===""||(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"))?d=P:d=JSON.parse(P))}let b=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),v=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");b&&v&&v.length>1&&(p=parseInt(v[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,p=null,g=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let b=await o.text();try{u=JSON.parse(b),Array.isArray(u)&&o.status===404&&(d=[],u=null,g=200,y="OK")}catch{o.status===404&&b===""?(g=204,y="No Content"):u={message:b}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,g=200,y="OK"),u&&this.shouldThrowOnError)throw new Un.default(u)}return{error:u,data:d,count:p,status:g,statusText:y}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,c,f;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:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Be.default=Me});var Ge=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Cn=(V(),F(W)),Nn=Cn.__importDefault(qe()),He=class extends Nn.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.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:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),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}};Fe.default=He});var _e=H(Ve=>{"use strict";l();Object.defineProperty(Ve,"__esModule",{value:!0});var Ln=(V(),F(W)),Dn=Ln.__importDefault(Ge()),$n=new RegExp("[,()]"),We=class extends Dn.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 n=Array.from(new Set(t)).map(s=>typeof s=="string"&&$n.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),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:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Ve.default=We});var Je=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var jn=(V(),F(W)),se=jn.__importDefault(_e()),ze=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),s&&this.headers.append("Prefer",`count=${s}`),new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new se.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 n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new se.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new se.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Ke.default=ze});var sr=H(Qe=>{"use strict";l();Object.defineProperty(Qe,"__esModule",{value:!0});var nr=(V(),F(W)),kn=nr.__importDefault(Je()),Mn=nr.__importDefault(_e()),Ye=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new kn.default(t,{headers:new Headers(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:n=!1,get:s=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([d,p])=>p!==void 0).map(([d,p])=>[d,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([d,p])=>{f.searchParams.append(d,p)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Mn.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Qe.default=Ye});var fr=H(S=>{"use strict";l();Object.defineProperty(S,"__esModule",{value:!0});S.PostgrestError=S.PostgrestBuilder=S.PostgrestTransformBuilder=S.PostgrestFilterBuilder=S.PostgrestQueryBuilder=S.PostgrestClient=void 0;var J=(V(),F(W)),or=J.__importDefault(sr());S.PostgrestClient=or.default;var ir=J.__importDefault(Je());S.PostgrestQueryBuilder=ir.default;var ar=J.__importDefault(_e());S.PostgrestFilterBuilder=ar.default;var lr=J.__importDefault(Ge());S.PostgrestTransformBuilder=lr.default;var cr=J.__importDefault(qe());S.PostgrestBuilder=cr.default;var ur=J.__importDefault(ke());S.PostgrestError=ur.default;S.default={PostgrestClient:or.default,PostgrestQueryBuilder:ir.default,PostgrestFilterBuilder:ar.default,PostgrestTransformBuilder:lr.default,PostgrestBuilder:cr.default,PostgrestError:ur.default}});var Gn={};rt(Gn,{AUTH_BASE_PATH:()=>Pt,AbortController:()=>ae,AbortSignal:()=>Q,ENTITIES_BASE_PATH:()=>hr,FILE_STORAGE_BASE_PATH:()=>Ot,GENERATE_UPLOAD_URL_PATH:()=>At,Headers:()=>x,LOGIN_TOKEN_KEY:()=>ne,LOGIN_USER_PROFILE_KEY:()=>ge,NvwaAuthClient:()=>xe,NvwaEdgeFunctions:()=>Ie,NvwaFileStorage:()=>Ce,NvwaHttpClient:()=>Ue,Request:()=>ie,Response:()=>B,URL:()=>oe,URLSearchParams:()=>Y,createPostgrestClient:()=>Fn,polyfill:()=>qn});module.exports=F(Gn);l();l();l();l();l();l();var Er=Object.defineProperty,Tr=Object.defineProperties,Sr=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,Pr=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable,ot=(r,e,t)=>e in r?Er(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,U=(r,e)=>{for(var t in e||(e={}))Pr.call(e,t)&&ot(r,t,e[t]);if(st)for(var t of st(e))Or.call(e,t)&&ot(r,t,e[t]);return r},N=(r,e)=>Tr(r,Sr(e)),Ar=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},xr=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),a.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},it=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 Ur(r){if(typeof r=="number")return new it({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new it(r);case"exponential":return new Ir(r);default:throw new Error("Invalid retry strategy")}}var Cr=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Nr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Lr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Nr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function Dr(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 at(r){try{return JSON.parse(r)}catch{return r}}function lt(r){return typeof r=="function"}function $r(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&lt(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&lt(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function jr(r){let e=new Headers(r?.headers),t=await Cr(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=kr(r?.body);n&&e.set("content-type",n)}return e}function kr(r){return ct(r)?"application/json":null}function Mr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ct(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function Br(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return ft.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function qr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Hr=class ut extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,ut.prototype)}};async function ue(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Hr(t.issues);return t.value}var ft=["get","post","put","patch","delete"];var Fr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let c=((s=(n=r.plugins)==null?void 0:n.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=N(U({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=N(U({},u),{body:a.input?await ue(a.input,t?.body):t?.body,params:a.params?await ue(a.params,t?.params):t?.params,query:a.query?await ue(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),dt=r=>{async function e(t,n){let s=N(U(U({},r),n),{plugins:[...r?.plugins||[],Fr(r||{})]});if(r?.catchAllError)try{return await ve(t,s)}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 ve(t,s)}return e};function Gr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];ft.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,p]of Object.entries(s||{}))p!=null&&f.set(d,String(p));if(n)if(Array.isArray(n)){let d=i.split("/").filter(p=>p.startsWith(":"));for(let[p,g]of d.entries()){let y=n[p];i=i.replace(g,y)}}else for(let[d,p]of Object.entries(n))i=i.replace(`:${d}`,String(p));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var ve=async(r,e)=>{var t,n,s,o,i,c,f,a;let{hooks:u,url:d,options:p}=await xr(r,e),g=$r(p),y=new AbortController,R=(t=p.signal)!=null?t:y.signal,b=Gr(d,p),v=Mr(p),P=await jr(p),$=Br(d,p),m=N(U({},p),{url:b,headers:P,body:v,method:$,signal:R});for(let I of u.onRequest)if(I){let T=await I(m);T instanceof Object&&(m=T)}("pipeTo"in m&&typeof m.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in m||(m.duplex="half"));let{clearTimeout:q}=qr(p,y),_=await g(m.url,m);q();let Ze={response:_,request:m};for(let I of u.onResponse)if(I){let T=await I(N(U({},Ze),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?_.clone():_}));T instanceof Response?_=T:T instanceof Object&&(_=T.response)}if(_.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let T=Lr(_),j={data:"",response:_,request:m};if(T==="json"||T==="text"){let k=await _.text(),gr=await((o=m.jsonParser)!=null?o:at)(k);j.data=gr}else j.data=await _[T]();m?.output&&m.output&&!m.disableValidation&&(j.data=await ue(m.output,j.data));for(let k of u.onSuccess)k&&await k(N(U({},j),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?_.clone():_}));return e?.throw?j.data:{data:j.data,error:null}}let pr=(c=e?.jsonParser)!=null?c:at,le=await _.text(),et=Dr(le),Re=et?await pr(le):null,mr={response:_,responseText:le,request:m,error:N(U({},Re),{status:_.status,statusText:_.statusText})};for(let I of u.onError)I&&await I(N(U({},mr),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?_.clone():_}));if(e?.retry){let I=Ur(e.retry),T=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(T,_)){for(let k of u.onRetry)k&&await k(Ze);let j=I.getDelay(T);return await new Promise(k=>setTimeout(k,j)),await ve(r,N(U({},e),{retryAttempt:T+1}))}}if(e?.throw)throw new Ar(_.status,_.statusText,et?Re:le);return{data:null,error:N(U({},Re),{status:_.status,statusText:_.statusText})}};l();l();var fe=Object.create(null),X=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?fe:globalThis),A=new Proxy(fe,{get(r,e){return X()[e]??fe[e]},has(r,e){let t=X();return e in t||e in fe},set(r,e,t){let n=X(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=X(!0);return delete t[e],!0},ownKeys(){let r=X(!0);return Object.keys(r)}});var Zn=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(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 es=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Z=1,E=4,L=8,O=24,ht={eterm:E,cons25:E,console:E,cygwin:E,dtterm:E,gnome:E,hurd:E,jfbterm:E,konsole:E,kterm:E,mlterm:E,mosh:O,putty:E,st:E,"rxvt-unicode-24bit":O,terminator:O,"xterm-kitty":O},Wr=new Map(Object.entries({APPVEYOR:L,BUILDKITE:L,CIRCLECI:O,DRONE:L,GITEA_ACTIONS:O,GITHUB_ACTIONS:O,GITLAB_CI:L,TRAVIS:L})),Vr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function zr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return E;case"2":return L;case"3":return O;default:return Z}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return Z;if(w("TMUX"))return O;if("TF_BUILD"in A&&"AGENT_NAME"in A)return E;if("CI"in A){for(let{0:r,1:e}of Wr)if(r in A)return e;return w("CI_NAME")==="codeship"?L:Z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?E:Z;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?L:O;case"HyperTerm":case"MacTerm":return O;case"Apple_Terminal":return L}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return O;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return O;if(/^xterm-256/.exec(w("TERM"))!==null)return L;let r=w("TERM").toLowerCase();if(ht[r])return ht[r];if(Vr.some(e=>e.exec(r)!==null))return E}return w("COLORTERM")?E:Z}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"}},Ee=["info","success","warn","error","debug"];function Kr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var Jr={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},Yr=(r,e,t)=>{let n=new Date().toISOString();return t?`${D.dim}${n}${D.reset} ${Jr[r]}${r.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Qr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:zr()!==1,o=(c,f,a=[])=>{if(!e||!Kr(t,c))return;let u=Yr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},ts=Qr();l();l();var ls={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."},G=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Xr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new G(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function ee(r,e="/api/auth"){if(Xr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function pt(r,e,t,n){if(r)return ee(r,e);if(n!==!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 ee(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return ee(`${o}://${s}`,e);if(t){let i=Zr(t.url);if(!i)throw new G("Could not get origin from request. Please provide a valid base URL.");return ee(i,e)}if(typeof window<"u"&&window.location)return ee(window.location.origin,e)}function Zr(r){try{return new URL(r).origin}catch{return null}}l();l();l();var te=Symbol("clean");var C=[],M=0,de=4,en=0,re=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=M+de;o<C.length;)C[o]===n?C.splice(o,de):o+=de;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){en++;let o=!C.length;for(let i of e)C.push(i,t.value,n,s);if(o){for(M=0;M<C.length;M+=de)C[M](C[M+1],C[M+2],C[M+3]);C.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[te]=()=>{e=[],t.lc=0,t.off()}),t};l();var tn=5,z=6,he=10,rn=(r,e,t,n)=>(r.events=r.events||{},r.events[t+he]||(r.events[t+he]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+he](),delete r.events[t+he])});var mt=1e3,Te=(r,e)=>rn(r,n=>{let s=e(n);s&&r.events[z].push(s)},tn,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[z]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[z])i();r.events[z]=[]}},mt)},process.env.NODE_ENV!=="production"){let i=r[te];r[te]=()=>{for(let c of r.events[z])c();r.events[z]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});l();var nn=typeof window>"u",pe=(r,e,t,n)=>{let s=re({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){s.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,p=u.retryAttempt||0;d&&p<d||(s.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{s.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{nn||(i?o():Te(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};l();var sn={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*:/},on=/^\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},an=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ln(r){return r instanceof Date&&!isNaN(r.getTime())}function cn(r){let e=an.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,a,u,d]=e,p=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let g=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+g)}return ln(p)?p:null}function un(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,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(!on.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(sn).some(([a,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let p=cn(d);if(p)return p}return s?s(u,d):d})}catch(a){if(t)throw a;return r}}function yt(r,e={strict:!0}){return un(r,e)}var fn={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 dn(r){let e=re(!1);return{session:pe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var bt=(r,e)=>{let t="credentials"in Request.prototype,n=pt(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=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:f,onResponse:a,...u}=r?.fetchOptions||{},d=dt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?yt(m,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[fn],...s]}),{$sessionSignal:p,session:g}=dn(d),y=r?.plugins||[],R={},b={$sessionSignal:p,session:g},v={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},P=[{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 y)m.getAtoms&&Object.assign(b,m.getAtoms?.(d)),m.pathMethods&&Object.assign(v,m.pathMethods),m.atomListeners&&P.push(...m.atomListeners);let $={notify:m=>{b[m].set(!b[m].get())},listen:(m,q)=>{b[m].subscribe(q)},atoms:b};for(let m of y)m.getActions&&Object.assign(R,m.getActions?.(d,$,r));return{get baseURL(){return n},pluginsActions:R,pluginsAtoms:b,pluginPathMethods:v,atomListeners:P,$fetch:d,$store:$}};function hn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function pn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function wt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||hn(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(P=>P.replace(/[A-Z]/g,$=>`-${$.toLowerCase()}`)).join("/"),d=a[0]||{},p=a[1]||{},{query:g,fetchOptions:y,...R}=d,b={...p,...y},v=pn(u,t,d);return await e(u,{...b,body:v==="GET"?void 0:{...R,...b?.body||{}},query:g||b?.query,method:v,async onSuccess(P){if(await b?.onSuccess?.(P),!s)return;let $=s.filter(m=>m.matcher(u));if($.length)for(let m of $){let q=n[m.signal];if(!q)return;let _=q.get();setTimeout(()=>{q.set(!_)},10)}}})}})}return o()}l();function _t(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Se(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=bt(r),c={};for(let[u,d]of Object.entries(n))c[`use${_t(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return wt(f,s,e,n,o)}l();l();l();function mn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?n=c.actions.some(f=>i.includes(f)):n=c.actions.every(f=>i.includes(f))}else throw new G("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function me(r){return{newRole(e){return mn(e)},statements:r}}var gn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Pe=me(gn),yn=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),bn=Pe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),wn=Pe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=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}}},Et=new Oe;l();l();l();l();l();l();l();l();var Tn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Tt=me(Tn),Sn=Tt.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Pn=Tt.newRole({user:[],session:[]});l();l();var St=()=>({id:"username",$InferServerPlugin:{}});var Pt="/auth",ne="nvwa_login_token",ge="nvwa_user_profile",xe=class{constructor(e,t,n){this.storage=n,this.authClient=Se({baseURL:e,basePath:Pt,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>n.get(ne)},onSuccess:s=>{let o=s.response.headers.get("set-auth-token");o&&n.set(ne,o)}},plugins:[St()]})}async currentUser(){return await this.storage.get(ge)}async signUp(e,t){let n=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(n)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.saveSession(n)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(ne,e.data?.token),this.storage.set(ge,e.data?.user)}async signOut(){await this.storage.remove(ne),await this.storage.remove(ge)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.saveSession(s)}};l();var Ie=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}};l();var Ue=class{async jsonRequest(e,t){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,n)}async jsonRequestWithAuth(e,t,n){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,n)}};l();var Ot="/storage",At=Ot+"/generateUploadUrl",Ce=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+At,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=t.body;if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(n,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Xe=vr(fr(),1),{PostgrestClient:dr,PostgrestQueryBuilder:Ca,PostgrestFilterBuilder:Na,PostgrestTransformBuilder:La,PostgrestBuilder:Da,PostgrestError:$a}=Xe.default||Xe;l();l();var x=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${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,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Y=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,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}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],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,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,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},oe=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new Y(s.search),this.hash=s.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 n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=s.match(/^([^@]*)@(.+)$/),a="",u="",d=s;if(f){let R=f[1];d=f[2];let b=R.match(/^([^:]*):?(.*)$/);b&&(a=b[1]||"",u=b[2]||"")}let p=d.match(/^([^:]+):?(\d*)$/),g=p?p[1]:d,y=p&&p[2]?p[2]:"";return{protocol:n?`${n}:`:"",username:a,password:u,host:d,hostname:g,port:y,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()}};l();var ie=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 x?t.headers:new x(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}};l();var B=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=Bn(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 Bn(r){return r?new x(r):new x}l();var Q=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]"}},ae=class{constructor(){this._signal=new Q}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function qn(r){r.URL=oe,r.URLSearchParams=Y,r.Headers=x,r.Request=ie,r.Response=B,r.AbortController=ae,r.AbortSignal=Q}var hr="/entities",Hn=(r,e)=>async(n,s)=>{console.log("customFetch",n,s);let o;if(typeof n=="string")o=n;else if(n&&typeof n=="object")if(typeof n.toString=="function"&&!n.url)o=n.toString();else if(n.url)o=n.url,s||(s={}),s.method=n.method,s.headers=n.headers,s.body=n.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(s?.method||"GET").toUpperCase(),c={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((g,y)=>{c[y]=g});else if(Array.isArray(s.headers))for(let[g,y]of s.headers)c[g]=y;else Object.assign(c,s.headers);let f=s?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(g){return new B(g?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new B(d,{status:a.status,headers:new x(a.headers)})},Fn=(r,e,t)=>new dr(r+hr,{fetch:Hn(e,t)});0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,Request,Response,URL,URLSearchParams,createPostgrestClient,polyfill});
1
+ "use strict";var gr=Object.create;var ce=Object.defineProperty;var yr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var wr=Object.getPrototypeOf,_r=Object.prototype.hasOwnProperty;var tt=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),rt=(r,e)=>{for(var t in e)ce(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of br(e))!_r.call(r,s)&&s!==t&&ce(r,s,{get:()=>e[s],enumerable:!(n=yr(e,s))||n.enumerable});return r};var Rr=(r,e,t)=>(t=r!=null?gr(wr(r)):{},nt(e||!r||!r.__esModule?ce(t,"default",{value:r,enumerable:!0}):t,r)),F=r=>nt(ce({},"__esModule",{value:!0}),r);var l=tt(()=>{"use strict"});var W={};rt(W,{__addDisposableResource:()=>Zt,__assign:()=>ye,__asyncDelegator:()=>Wt,__asyncGenerator:()=>Gt,__asyncValues:()=>Vt,__await:()=>K,__awaiter:()=>kt,__classPrivateFieldGet:()=>Yt,__classPrivateFieldIn:()=>Xt,__classPrivateFieldSet:()=>Qt,__createBinding:()=>we,__decorate:()=>Ut,__disposeResources:()=>er,__esDecorate:()=>Nt,__exportStar:()=>Bt,__extends:()=>xt,__generator:()=>Mt,__importDefault:()=>Jt,__importStar:()=>Kt,__makeTemplateObject:()=>zt,__metadata:()=>jt,__param:()=>Ct,__propKey:()=>Dt,__read:()=>De,__rest:()=>It,__rewriteRelativeImportExtension:()=>tr,__runInitializers:()=>Lt,__setFunctionName:()=>$t,__spread:()=>qt,__spreadArray:()=>Ft,__spreadArrays:()=>Ht,__values:()=>be,default:()=>An});function xt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ne(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function It(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function Ut(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function Ct(r,e){return function(t,n){e(t,n,r)}}function Nt(r,e,t,n,s,o){function i(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var c=n.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?n.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,n.name):{}),d,p=!1,g=t.length-1;g>=0;g--){var y={};for(var R in n)y[R]=R==="access"?{}:n[R];for(var R in n.access)y.access[R]=n.access[R];y.addInitializer=function(v){if(p)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(v||null))};var b=(0,t[g])(c==="accessor"?{get:u.get,set:u.set}:u[f],y);if(c==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(d=i(b.get))&&(u.get=d),(d=i(b.set))&&(u.set=d),(d=i(b.init))&&s.unshift(d)}else(d=i(b))&&(c==="field"?s.unshift(d):u[f]=d)}a&&Object.defineProperty(a,n.name,u),p=!0}function Lt(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Dt(r){return typeof r=="symbol"?r:"".concat(r)}function $t(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function jt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function kt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(n.next(u))}catch(d){i(d)}}function f(u){try{a(n.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):s(u.value).then(c,f)}a((n=n.apply(r,e||[])).next())})}function Mt(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(n=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,s=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Bt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&we(e,r,t)}function be(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function De(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function qt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(De(arguments[e]));return r}function Ht(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,s++)n[s]=o[i];return n}function Ft(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function K(r){return this instanceof K?(this.v=r,this):new K(r)}function Gt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(g){return function(y){return Promise.resolve(y).then(g,d)}}function c(g,y){n[g]&&(s[g]=function(R){return new Promise(function(b,v){o.push([g,R,b,v])>1||f(g,R)})},y&&(s[g]=y(s[g])))}function f(g,y){try{a(n[g](y))}catch(R){p(o[0][3],R)}}function a(g){g.value instanceof K?Promise.resolve(g.value.v).then(u,d):p(o[0][2],g)}function u(g){f("next",g)}function d(g){f("throw",g)}function p(g,y){g(y),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Wt(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:K(r[s](i)),done:!1}:o?o(i):i}:o}}function Vt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof be=="function"?be(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),s(c,f,i.done,i.value)})}}function s(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function zt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Kt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Le(r),n=0;n<t.length;n++)t[n]!=="default"&&we(e,r,t[n]);return Pn(e,r),e}function Jt(r){return r&&r.__esModule?r:{default:r}}function Yt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Qt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function Xt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Zt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function er(r){function e(o){r.error=r.hasError?new On(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function tr(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ne,ye,we,Pn,Le,On,An,V=tt(()=>{"use strict";l();Ne=function(r,e){return Ne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ne(r,e)};ye=function(){return ye=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ye.apply(this,arguments)};we=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});Pn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Le=function(r){return Le=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Le(r)};On=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};An={__extends:xt,__assign:ye,__rest:It,__decorate:Ut,__param:Ct,__esDecorate:Nt,__runInitializers:Lt,__propKey:Dt,__setFunctionName:$t,__metadata:jt,__awaiter:kt,__generator:Mt,__createBinding:we,__exportStar:Bt,__values:be,__read:De,__spread:qt,__spreadArrays:Ht,__spreadArray:Ft,__await:K,__asyncGenerator:Gt,__asyncDelegator:Wt,__asyncValues:Vt,__makeTemplateObject:zt,__importStar:Kt,__importDefault:Jt,__classPrivateFieldGet:Yt,__classPrivateFieldSet:Qt,__classPrivateFieldIn:Xt,__addDisposableResource:Zt,__disposeResources:er,__rewriteRelativeImportExtension:tr}});var ke=H(je=>{"use strict";l();Object.defineProperty(je,"__esModule",{value:!0});var $e=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};je.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var xn=(V(),F(W)),In=xn.__importDefault(ke()),Me=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){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 n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,p=null,g=o.status,y=o.statusText;if(o.ok){if(this.method!=="HEAD"){let P=await o.text();P===""||(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"))?d=P:d=JSON.parse(P))}let b=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),v=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");b&&v&&v.length>1&&(p=parseInt(v[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,p=null,g=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let b=await o.text();try{u=JSON.parse(b),Array.isArray(u)&&o.status===404&&(d=[],u=null,g=200,y="OK")}catch{o.status===404&&b===""?(g=204,y="No Content"):u={message:b}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,g=200,y="OK"),u&&this.shouldThrowOnError)throw new In.default(u)}return{error:u,data:d,count:p,status:g,statusText:y}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,c,f;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:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Be.default=Me});var Ge=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Un=(V(),F(W)),Cn=Un.__importDefault(qe()),He=class extends Cn.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.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:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),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}};Fe.default=He});var _e=H(Ve=>{"use strict";l();Object.defineProperty(Ve,"__esModule",{value:!0});var Nn=(V(),F(W)),Ln=Nn.__importDefault(Ge()),Dn=new RegExp("[,()]"),We=class extends Ln.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 n=Array.from(new Set(t)).map(s=>typeof s=="string"&&Dn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),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:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Ve.default=We});var Je=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var $n=(V(),F(W)),se=$n.__importDefault(_e()),ze=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),s&&this.headers.append("Prefer",`count=${s}`),new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new se.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 n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new se.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new se.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Ke.default=ze});var nr=H(Qe=>{"use strict";l();Object.defineProperty(Qe,"__esModule",{value:!0});var rr=(V(),F(W)),jn=rr.__importDefault(Je()),kn=rr.__importDefault(_e()),Ye=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new jn.default(t,{headers:new Headers(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:n=!1,get:s=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([d,p])=>p!==void 0).map(([d,p])=>[d,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([d,p])=>{f.searchParams.append(d,p)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new kn.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Qe.default=Ye});var ur=H(S=>{"use strict";l();Object.defineProperty(S,"__esModule",{value:!0});S.PostgrestError=S.PostgrestBuilder=S.PostgrestTransformBuilder=S.PostgrestFilterBuilder=S.PostgrestQueryBuilder=S.PostgrestClient=void 0;var J=(V(),F(W)),sr=J.__importDefault(nr());S.PostgrestClient=sr.default;var or=J.__importDefault(Je());S.PostgrestQueryBuilder=or.default;var ir=J.__importDefault(_e());S.PostgrestFilterBuilder=ir.default;var ar=J.__importDefault(Ge());S.PostgrestTransformBuilder=ar.default;var lr=J.__importDefault(qe());S.PostgrestBuilder=lr.default;var cr=J.__importDefault(ke());S.PostgrestError=cr.default;S.default={PostgrestClient:sr.default,PostgrestQueryBuilder:or.default,PostgrestFilterBuilder:ir.default,PostgrestTransformBuilder:ar.default,PostgrestBuilder:lr.default,PostgrestError:cr.default}});var Fn={};rt(Fn,{AUTH_BASE_PATH:()=>Pt,AbortController:()=>ae,AbortSignal:()=>Q,ENTITIES_BASE_PATH:()=>dr,FILE_STORAGE_BASE_PATH:()=>Ot,GENERATE_UPLOAD_URL_PATH:()=>At,Headers:()=>x,LOGIN_TOKEN_KEY:()=>ne,LOGIN_USER_PROFILE_KEY:()=>ge,NvwaAuthClient:()=>xe,NvwaEdgeFunctions:()=>Ie,NvwaFileStorage:()=>Ce,NvwaHttpClient:()=>Ue,Request:()=>ie,Response:()=>B,URL:()=>oe,URLSearchParams:()=>Y,createPostgrestClient:()=>Hn,polyfill:()=>Bn});module.exports=F(Fn);l();l();l();l();l();l();var vr=Object.defineProperty,Er=Object.defineProperties,Tr=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,Sr=Object.prototype.hasOwnProperty,Pr=Object.prototype.propertyIsEnumerable,ot=(r,e,t)=>e in r?vr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,U=(r,e)=>{for(var t in e||(e={}))Sr.call(e,t)&&ot(r,t,e[t]);if(st)for(var t of st(e))Pr.call(e,t)&&ot(r,t,e[t]);return r},N=(r,e)=>Er(r,Tr(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,n,s,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),a.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},it=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}},xr=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 Ir(r){if(typeof r=="number")return new it({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new it(r);case"exponential":return new xr(r);default:throw new Error("Invalid retry strategy")}}var Ur=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Cr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Nr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Cr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function Lr(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 at(r){try{return JSON.parse(r)}catch{return r}}function lt(r){return typeof r=="function"}function Dr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&lt(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&lt(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function $r(r){let e=new Headers(r?.headers),t=await Ur(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=jr(r?.body);n&&e.set("content-type",n)}return e}function jr(r){return ct(r)?"application/json":null}function kr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ct(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function Mr(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return ft.includes(n)?n.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 qr=class ut extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,ut.prototype)}};async function ue(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new qr(t.issues);return t.value}var ft=["get","post","put","patch","delete"];var Hr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let c=((s=(n=r.plugins)==null?void 0:n.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=N(U({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=N(U({},u),{body:a.input?await ue(a.input,t?.body):t?.body,params:a.params?await ue(a.params,t?.params):t?.params,query:a.query?await ue(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),dt=r=>{async function e(t,n){let s=N(U(U({},r),n),{plugins:[...r?.plugins||[],Hr(r||{})]});if(r?.catchAllError)try{return await ve(t,s)}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 ve(t,s)}return e};function Fr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];ft.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,p]of Object.entries(s||{}))p!=null&&f.set(d,String(p));if(n)if(Array.isArray(n)){let d=i.split("/").filter(p=>p.startsWith(":"));for(let[p,g]of d.entries()){let y=n[p];i=i.replace(g,y)}}else for(let[d,p]of Object.entries(n))i=i.replace(`:${d}`,String(p));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var ve=async(r,e)=>{var t,n,s,o,i,c,f,a;let{hooks:u,url:d,options:p}=await Ar(r,e),g=Dr(p),y=new AbortController,R=(t=p.signal)!=null?t:y.signal,b=Fr(d,p),v=kr(p),P=await $r(p),$=Mr(d,p),m=N(U({},p),{url:b,headers:P,body:v,method:$,signal:R});for(let I of u.onRequest)if(I){let T=await I(m);T instanceof Object&&(m=T)}("pipeTo"in m&&typeof m.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in m||(m.duplex="half"));let{clearTimeout:q}=Br(p,y),_=await g(m.url,m);q();let Ze={response:_,request:m};for(let I of u.onResponse)if(I){let T=await I(N(U({},Ze),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?_.clone():_}));T instanceof Response?_=T:T instanceof Object&&(_=T.response)}if(_.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let T=Nr(_),j={data:"",response:_,request:m};if(T==="json"||T==="text"){let k=await _.text(),mr=await((o=m.jsonParser)!=null?o:at)(k);j.data=mr}else j.data=await _[T]();m?.output&&m.output&&!m.disableValidation&&(j.data=await ue(m.output,j.data));for(let k of u.onSuccess)k&&await k(N(U({},j),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?_.clone():_}));return e?.throw?j.data:{data:j.data,error:null}}let hr=(c=e?.jsonParser)!=null?c:at,le=await _.text(),et=Lr(le),Re=et?await hr(le):null,pr={response:_,responseText:le,request:m,error:N(U({},Re),{status:_.status,statusText:_.statusText})};for(let I of u.onError)I&&await I(N(U({},pr),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?_.clone():_}));if(e?.retry){let I=Ir(e.retry),T=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(T,_)){for(let k of u.onRetry)k&&await k(Ze);let j=I.getDelay(T);return await new Promise(k=>setTimeout(k,j)),await ve(r,N(U({},e),{retryAttempt:T+1}))}}if(e?.throw)throw new Or(_.status,_.statusText,et?Re:le);return{data:null,error:N(U({},Re),{status:_.status,statusText:_.statusText})}};l();l();var fe=Object.create(null),X=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?fe:globalThis),A=new Proxy(fe,{get(r,e){return X()[e]??fe[e]},has(r,e){let t=X();return e in t||e in fe},set(r,e,t){let n=X(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=X(!0);return delete t[e],!0},ownKeys(){let r=X(!0);return Object.keys(r)}});var Xn=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(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 Zn=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Z=1,E=4,L=8,O=24,ht={eterm:E,cons25:E,console:E,cygwin:E,dtterm:E,gnome:E,hurd:E,jfbterm:E,konsole:E,kterm:E,mlterm:E,mosh:O,putty:E,st:E,"rxvt-unicode-24bit":O,terminator:O,"xterm-kitty":O},Gr=new Map(Object.entries({APPVEYOR:L,BUILDKITE:L,CIRCLECI:O,DRONE:L,GITEA_ACTIONS:O,GITHUB_ACTIONS:O,GITLAB_CI:L,TRAVIS:L})),Wr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Vr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return E;case"2":return L;case"3":return O;default:return Z}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return Z;if(w("TMUX"))return O;if("TF_BUILD"in A&&"AGENT_NAME"in A)return E;if("CI"in A){for(let{0:r,1:e}of Gr)if(r in A)return e;return w("CI_NAME")==="codeship"?L:Z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?E:Z;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?L:O;case"HyperTerm":case"MacTerm":return O;case"Apple_Terminal":return L}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return O;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return O;if(/^xterm-256/.exec(w("TERM"))!==null)return L;let r=w("TERM").toLowerCase();if(ht[r])return ht[r];if(Wr.some(e=>e.exec(r)!==null))return E}return w("COLORTERM")?E:Z}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"}},Ee=["info","success","warn","error","debug"];function zr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var Kr={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},Jr=(r,e,t)=>{let n=new Date().toISOString();return t?`${D.dim}${n}${D.reset} ${Kr[r]}${r.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Yr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Vr()!==1,o=(c,f,a=[])=>{if(!e||!zr(t,c))return;let u=Jr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},es=Yr();l();l();var as={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."},G=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Qr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new G(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function ee(r,e="/api/auth"){if(Qr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function pt(r,e,t,n){if(r)return ee(r,e);if(n!==!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 ee(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return ee(`${o}://${s}`,e);if(t){let i=Xr(t.url);if(!i)throw new G("Could not get origin from request. Please provide a valid base URL.");return ee(i,e)}if(typeof window<"u"&&window.location)return ee(window.location.origin,e)}function Xr(r){try{return new URL(r).origin}catch{return null}}l();l();l();var te=Symbol("clean");var C=[],M=0,de=4,Zr=0,re=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=M+de;o<C.length;)C[o]===n?C.splice(o,de):o+=de;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){Zr++;let o=!C.length;for(let i of e)C.push(i,t.value,n,s);if(o){for(M=0;M<C.length;M+=de)C[M](C[M+1],C[M+2],C[M+3]);C.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[te]=()=>{e=[],t.lc=0,t.off()}),t};l();var en=5,z=6,he=10,tn=(r,e,t,n)=>(r.events=r.events||{},r.events[t+he]||(r.events[t+he]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+he](),delete r.events[t+he])});var mt=1e3,Te=(r,e)=>tn(r,n=>{let s=e(n);s&&r.events[z].push(s)},en,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[z]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[z])i();r.events[z]=[]}},mt)},process.env.NODE_ENV!=="production"){let i=r[te];r[te]=()=>{for(let c of r.events[z])c();r.events[z]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});l();var rn=typeof window>"u",pe=(r,e,t,n)=>{let s=re({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){s.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,p=u.retryAttempt||0;d&&p<d||(s.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{s.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{rn||(i?o():Te(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};l();var nn={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*:/},sn=/^\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},on=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function an(r){return r instanceof Date&&!isNaN(r.getTime())}function ln(r){let e=on.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,a,u,d]=e,p=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let g=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+g)}return an(p)?p:null}function cn(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,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(!sn.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(nn).some(([a,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let p=ln(d);if(p)return p}return s?s(u,d):d})}catch(a){if(t)throw a;return r}}function yt(r,e={strict:!0}){return cn(r,e)}var un={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 fn(r){let e=re(!1);return{session:pe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var bt=(r,e)=>{let t="credentials"in Request.prototype,n=pt(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=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:f,onResponse:a,...u}=r?.fetchOptions||{},d=dt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?yt(m,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[un],...s]}),{$sessionSignal:p,session:g}=fn(d),y=r?.plugins||[],R={},b={$sessionSignal:p,session:g},v={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},P=[{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 y)m.getAtoms&&Object.assign(b,m.getAtoms?.(d)),m.pathMethods&&Object.assign(v,m.pathMethods),m.atomListeners&&P.push(...m.atomListeners);let $={notify:m=>{b[m].set(!b[m].get())},listen:(m,q)=>{b[m].subscribe(q)},atoms:b};for(let m of y)m.getActions&&Object.assign(R,m.getActions?.(d,$,r));return{get baseURL(){return n},pluginsActions:R,pluginsAtoms:b,pluginPathMethods:v,atomListeners:P,$fetch:d,$store:$}};function dn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function hn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function wt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||dn(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(P=>P.replace(/[A-Z]/g,$=>`-${$.toLowerCase()}`)).join("/"),d=a[0]||{},p=a[1]||{},{query:g,fetchOptions:y,...R}=d,b={...p,...y},v=hn(u,t,d);return await e(u,{...b,body:v==="GET"?void 0:{...R,...b?.body||{}},query:g||b?.query,method:v,async onSuccess(P){if(await b?.onSuccess?.(P),!s)return;let $=s.filter(m=>m.matcher(u));if($.length)for(let m of $){let q=n[m.signal];if(!q)return;let _=q.get();setTimeout(()=>{q.set(!_)},10)}}})}})}return o()}l();function _t(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Se(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=bt(r),c={};for(let[u,d]of Object.entries(n))c[`use${_t(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return wt(f,s,e,n,o)}l();l();l();function pn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?n=c.actions.some(f=>i.includes(f)):n=c.actions.every(f=>i.includes(f))}else throw new G("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function me(r){return{newRole(e){return pn(e)},statements:r}}var mn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Pe=me(mn),gn=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),yn=Pe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),bn=Pe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=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}}},Et=new Oe;l();l();l();l();l();l();l();l();var En={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Tt=me(En),Tn=Tt.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Sn=Tt.newRole({user:[],session:[]});l();l();var St=()=>({id:"username",$InferServerPlugin:{}});var Pt="/auth",ne="nvwa_login_token",ge="nvwa_user_profile",xe=class{constructor(e,t,n){this.storage=n,this.authClient=Se({baseURL:e,basePath:Pt,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>n.get(ne)},onSuccess:s=>{let o=s.response.headers.get("set-auth-token");o&&n.set(ne,o)}},plugins:[St()]})}async currentUser(){return await this.storage.get(ge)}async signUp(e,t){let n=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(n)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.saveSession(n)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(ne,e.data?.token),this.storage.set(ge,e.data?.user)}async signOut(){await this.storage.remove(ne),await this.storage.remove(ge)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.saveSession(s)}};l();var Ie=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}};l();var Ue=class{async jsonRequest(e,t){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,n)}async jsonRequestWithAuth(e,t,n){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,n)}};l();var Ot="/storage",At=Ot+"/generateUploadUrl",Ce=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+At,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=t.body;if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(n,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Xe=Rr(ur(),1),{PostgrestClient:fr,PostgrestQueryBuilder:Ua,PostgrestFilterBuilder:Ca,PostgrestTransformBuilder:Na,PostgrestBuilder:La,PostgrestError:Da}=Xe.default||Xe;l();l();var x=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${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,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Y=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,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}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],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,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,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},oe=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new Y(s.search),this.hash=s.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 n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=s.match(/^([^@]*)@(.+)$/),a="",u="",d=s;if(f){let R=f[1];d=f[2];let b=R.match(/^([^:]*):?(.*)$/);b&&(a=b[1]||"",u=b[2]||"")}let p=d.match(/^([^:]+):?(\d*)$/),g=p?p[1]:d,y=p&&p[2]?p[2]:"";return{protocol:n?`${n}:`:"",username:a,password:u,host:d,hostname:g,port:y,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()}};l();var ie=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 x?t.headers:new x(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}};l();var B=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=Mn(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 Mn(r){return r?new x(r):new x}l();var Q=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]"}},ae=class{constructor(){this._signal=new Q}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function Bn(r){r.URL=oe,r.URLSearchParams=Y,r.Headers=x,r.Request=ie,r.Response=B,r.AbortController=ae,r.AbortSignal=Q}var dr="/entities",qn=(r,e)=>async(n,s)=>{console.log("customFetch",n,s);let o;if(typeof n=="string")o=n;else if(n&&typeof n=="object")if(typeof n.toString=="function"&&!n.url)o=n.toString();else if(n.url)o=n.url,s||(s={}),s.method=n.method,s.headers=n.headers,s.body=n.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(s?.method||"GET").toUpperCase(),c={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((g,y)=>{c[y]=g});else if(Array.isArray(s.headers))for(let[g,y]of s.headers)c[g]=y;else Object.assign(c,s.headers);let f=s?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(g){return new B(g?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new B(d,{status:a.status,headers:new x(a.headers)})},Hn=(r,e,t)=>new fr(r+dr,{fetch:qn(e,t)});0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,Request,Response,URL,URLSearchParams,createPostgrestClient,polyfill});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var hr=Object.create;var ie=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty;var br=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Xe=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),wr=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},Ze=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of mr(e))!yr.call(r,s)&&s!==t&&ie(r,s,{get:()=>e[s],enumerable:!(n=pr(e,s))||n.enumerable});return r};var _r=(r,e,t)=>(t=r!=null?hr(gr(r)):{},Ze(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),z=r=>Ze(ie({},"__esModule",{value:!0}),r);import zn from"path";import{fileURLToPath as Jn}from"url";var l=Xe(()=>{"use strict"});var G={};wr(G,{__addDisposableResource:()=>Yt,__assign:()=>pe,__asyncDelegator:()=>Ht,__asyncGenerator:()=>qt,__asyncValues:()=>Ft,__await:()=>J,__awaiter:()=>Dt,__classPrivateFieldGet:()=>zt,__classPrivateFieldIn:()=>Jt,__classPrivateFieldSet:()=>Kt,__createBinding:()=>ge,__decorate:()=>At,__disposeResources:()=>Qt,__esDecorate:()=>It,__exportStar:()=>jt,__extends:()=>Pt,__generator:()=>$t,__importDefault:()=>Vt,__importStar:()=>Wt,__makeTemplateObject:()=>Gt,__metadata:()=>Lt,__param:()=>xt,__propKey:()=>Ct,__read:()=>Ce,__rest:()=>Ot,__rewriteRelativeImportExtension:()=>Xt,__runInitializers:()=>Ut,__setFunctionName:()=>Nt,__spread:()=>kt,__spreadArray:()=>Bt,__spreadArrays:()=>Mt,__values:()=>me,default:()=>In});function Pt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ie(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Ot(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function At(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function xt(r,e){return function(t,n){e(t,n,r)}}function It(r,e,t,n,s,o){function i(E){if(E!==void 0&&typeof E!="function")throw new TypeError("Function expected");return E}for(var c=n.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?n.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,n.name):{}),d,m=!1,y=t.length-1;y>=0;y--){var b={};for(var R in n)b[R]=R==="access"?{}:n[R];for(var R in n.access)b.access[R]=n.access[R];b.addInitializer=function(E){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(E||null))};var w=(0,t[y])(c==="accessor"?{get:u.get,set:u.set}:u[f],b);if(c==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(d=i(w.get))&&(u.get=d),(d=i(w.set))&&(u.set=d),(d=i(w.init))&&s.unshift(d)}else(d=i(w))&&(c==="field"?s.unshift(d):u[f]=d)}a&&Object.defineProperty(a,n.name,u),m=!0}function Ut(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Ct(r){return typeof r=="symbol"?r:"".concat(r)}function Nt(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Lt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Dt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(n.next(u))}catch(d){i(d)}}function f(u){try{a(n.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):s(u.value).then(c,f)}a((n=n.apply(r,e||[])).next())})}function $t(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(n=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,s=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function jt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ge(e,r,t)}function me(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ce(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function kt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Ce(arguments[e]));return r}function Mt(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,s++)n[s]=o[i];return n}function Bt(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function J(r){return this instanceof J?(this.v=r,this):new J(r)}function qt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(y){return function(b){return Promise.resolve(b).then(y,d)}}function c(y,b){n[y]&&(s[y]=function(R){return new Promise(function(w,E){o.push([y,R,w,E])>1||f(y,R)})},b&&(s[y]=b(s[y])))}function f(y,b){try{a(n[y](b))}catch(R){m(o[0][3],R)}}function a(y){y.value instanceof J?Promise.resolve(y.value.v).then(u,d):m(o[0][2],y)}function u(y){f("next",y)}function d(y){f("throw",y)}function m(y,b){y(b),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Ht(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:J(r[s](i)),done:!1}:o?o(i):i}:o}}function Ft(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof me=="function"?me(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),s(c,f,i.done,i.value)})}}function s(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function Gt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Ue(r),n=0;n<t.length;n++)t[n]!=="default"&&ge(e,r,t[n]);return An(e,r),e}function Vt(r){return r&&r.__esModule?r:{default:r}}function zt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Kt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function Jt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Yt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function Qt(r){function e(o){r.error=r.hasError?new xn(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function Xt(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ie,pe,ge,An,Ue,xn,In,W=Xe(()=>{"use strict";l();Ie=function(r,e){return Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ie(r,e)};pe=function(){return pe=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},pe.apply(this,arguments)};ge=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});An=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Ue=function(r){return Ue=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ue(r)};xn=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};In={__extends:Pt,__assign:pe,__rest:Ot,__decorate:At,__param:xt,__esDecorate:It,__runInitializers:Ut,__propKey:Ct,__setFunctionName:Nt,__metadata:Lt,__awaiter:Dt,__generator:$t,__createBinding:ge,__exportStar:jt,__values:me,__read:Ce,__spread:kt,__spreadArrays:Mt,__spreadArray:Bt,__await:J,__asyncGenerator:qt,__asyncDelegator:Ht,__asyncValues:Ft,__makeTemplateObject:Gt,__importStar:Wt,__importDefault:Vt,__classPrivateFieldGet:zt,__classPrivateFieldSet:Kt,__classPrivateFieldIn:Jt,__addDisposableResource:Yt,__disposeResources:Qt,__rewriteRelativeImportExtension:Xt}});var De=H(Le=>{"use strict";l();Object.defineProperty(Le,"__esModule",{value:!0});var Ne=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Le.default=Ne});var ke=H(je=>{"use strict";l();Object.defineProperty(je,"__esModule",{value:!0});var Zt=(W(),z(G)),Un=Zt.__importDefault(br("@supabase/node-fetch")),Cn=Zt.__importDefault(De()),$e=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=Un.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){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 n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,m=null,y=o.status,b=o.statusText;if(o.ok){if(this.method!=="HEAD"){let O=await o.text();O===""||(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"))?d=O:d=JSON.parse(O))}let w=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),E=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");w&&E&&E.length>1&&(m=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,y=406,b="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let w=await o.text();try{u=JSON.parse(w),Array.isArray(u)&&o.status===404&&(d=[],u=null,y=200,b="OK")}catch{o.status===404&&w===""?(y=204,b="No Content"):u={message:w}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,y=200,b="OK"),u&&this.shouldThrowOnError)throw new Cn.default(u)}return{error:u,data:d,count:m,status:y,statusText:b}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,c,f;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:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};je.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var Nn=(W(),z(G)),Ln=Nn.__importDefault(ke()),Me=class extends Ln.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.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:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),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}};Be.default=Me});var ye=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Dn=(W(),z(G)),$n=Dn.__importDefault(qe()),jn=new RegExp("[,()]"),He=class extends $n.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 n=Array.from(new Set(t)).map(s=>typeof s=="string"&&jn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),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:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Fe.default=He});var Ve=H(We=>{"use strict";l();Object.defineProperty(We,"__esModule",{value:!0});var kn=(W(),z(G)),re=kn.__importDefault(ye()),Ge=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),s&&this.headers.append("Prefer",`count=${s}`),new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new re.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 n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new re.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new re.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};We.default=Ge});var tr=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var er=(W(),z(G)),Mn=er.__importDefault(Ve()),Bn=er.__importDefault(ye()),ze=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new Mn.default(t,{headers:new Headers(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:n=!1,get:s=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{f.searchParams.append(d,m)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Bn.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Ke.default=ze});var lr=H(P=>{"use strict";l();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var Y=(W(),z(G)),rr=Y.__importDefault(tr());P.PostgrestClient=rr.default;var nr=Y.__importDefault(Ve());P.PostgrestQueryBuilder=nr.default;var sr=Y.__importDefault(ye());P.PostgrestFilterBuilder=sr.default;var or=Y.__importDefault(qe());P.PostgrestTransformBuilder=or.default;var ir=Y.__importDefault(ke());P.PostgrestBuilder=ir.default;var ar=Y.__importDefault(De());P.PostgrestError=ar.default;P.default={PostgrestClient:rr.default,PostgrestQueryBuilder:nr.default,PostgrestFilterBuilder:sr.default,PostgrestTransformBuilder:or.default,PostgrestBuilder:ir.default,PostgrestError:ar.default}});l();l();l();l();l();l();var vr=Object.defineProperty,Rr=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,tt=(r,e,t)=>e in r?vr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&tt(r,t,e[t]);if(et)for(var t of et(e))Sr.call(e,t)&&tt(r,t,e[t]);return r},L=(r,e)=>Rr(r,Er(e)),Pr=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Or=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),a.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},rt=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}},Ar=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 xr(r){if(typeof r=="number")return new rt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new rt(r);case"exponential":return new Ar(r);default:throw new Error("Invalid retry strategy")}}var Ir=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Ur=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Cr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Ur.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function Nr(r){try{return JSON.parse(r),!0}catch{return!1}}function ot(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 nt(r){try{return JSON.parse(r)}catch{return r}}function st(r){return typeof r=="function"}function Lr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&st(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&st(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Dr(r){let e=new Headers(r?.headers),t=await Ir(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=$r(r?.body);n&&e.set("content-type",n)}return e}function $r(r){return ot(r)?"application/json":null}function jr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ot(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function kr(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return at.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Mr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Br=class it extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,it.prototype)}};async function ae(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Br(t.issues);return t.value}var at=["get","post","put","patch","delete"];var qr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let c=((s=(n=r.plugins)==null?void 0:n.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=L(C({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=L(C({},u),{body:a.input?await ae(a.input,t?.body):t?.body,params:a.params?await ae(a.params,t?.params):t?.params,query:a.query?await ae(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),lt=r=>{async function e(t,n){let s=L(C(C({},r),n),{plugins:[...r?.plugins||[],qr(r||{})]});if(r?.catchAllError)try{return await Re(t,s)}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 Re(t,s)}return e};function Hr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];at.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,m]of Object.entries(s||{}))m!=null&&f.set(d,String(m));if(n)if(Array.isArray(n)){let d=i.split("/").filter(m=>m.startsWith(":"));for(let[m,y]of d.entries()){let b=n[m];i=i.replace(y,b)}}else for(let[d,m]of Object.entries(n))i=i.replace(`:${d}`,String(m));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var Re=async(r,e)=>{var t,n,s,o,i,c,f,a;let{hooks:u,url:d,options:m}=await Or(r,e),y=Lr(m),b=new AbortController,R=(t=m.signal)!=null?t:b.signal,w=Hr(d,m),E=jr(m),O=await Dr(m),j=kr(d,m),g=L(C({},m),{url:w,headers:O,body:E,method:j,signal:R});for(let I of u.onRequest)if(I){let S=await I(g);S instanceof Object&&(g=S)}("pipeTo"in g&&typeof g.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in g||(g.duplex="half"));let{clearTimeout:q}=Mr(m,b),v=await y(g.url,g);q();let Ye={response:v,request:g};for(let I of u.onResponse)if(I){let S=await I(L(C({},Ye),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?v.clone():v}));S instanceof Response?v=S:S instanceof Object&&(v=S.response)}if(v.ok){if(!(g.method!=="HEAD"))return{data:"",error:null};let S=Cr(v),k={data:"",response:v,request:g};if(S==="json"||S==="text"){let M=await v.text(),dr=await((o=g.jsonParser)!=null?o:nt)(M);k.data=dr}else k.data=await v[S]();g?.output&&g.output&&!g.disableValidation&&(k.data=await ae(g.output,k.data));for(let M of u.onSuccess)M&&await M(L(C({},k),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?v.clone():v}));return e?.throw?k.data:{data:k.data,error:null}}let ur=(c=e?.jsonParser)!=null?c:nt,oe=await v.text(),Qe=Nr(oe),ve=Qe?await ur(oe):null,fr={response:v,responseText:oe,request:g,error:L(C({},ve),{status:v.status,statusText:v.statusText})};for(let I of u.onError)I&&await I(L(C({},fr),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?v.clone():v}));if(e?.retry){let I=xr(e.retry),S=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(S,v)){for(let M of u.onRetry)M&&await M(Ye);let k=I.getDelay(S);return await new Promise(M=>setTimeout(M,k)),await Re(r,L(C({},e),{retryAttempt:S+1}))}}if(e?.throw)throw new Pr(v.status,v.statusText,Qe?ve:oe);return{data:null,error:L(C({},ve),{status:v.status,statusText:v.statusText})}};l();l();var le=Object.create(null),Q=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?le:globalThis),x=new Proxy(le,{get(r,e){return Q()[e]??le[e]},has(r,e){let t=Q();return e in t||e in le},set(r,e,t){let n=Q(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=Q(!0);return delete t[e],!0},ownKeys(){let r=Q(!0);return Object.keys(r)}});var rs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function _(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 ns=Object.freeze({get BETTER_AUTH_SECRET(){return _("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return _("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return _("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return _("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return _("NODE_ENV","development")},get PACKAGE_VERSION(){return _("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return _("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),X=1,T=4,D=8,A=24,ct={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:A,putty:T,st:T,"rxvt-unicode-24bit":A,terminator:A,"xterm-kitty":A},Fr=new Map(Object.entries({APPVEYOR:D,BUILDKITE:D,CIRCLECI:A,DRONE:D,GITEA_ACTIONS:A,GITHUB_ACTIONS:A,GITLAB_CI:D,TRAVIS:D})),Gr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Wr(){if(_("FORCE_COLOR")!==void 0)switch(_("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return D;case"3":return A;default:return X}if(_("NODE_DISABLE_COLORS")!==void 0&&_("NODE_DISABLE_COLORS")!==""||_("NO_COLOR")!==void 0&&_("NO_COLOR")!==""||_("TERM")==="dumb")return X;if(_("TMUX"))return A;if("TF_BUILD"in x&&"AGENT_NAME"in x)return T;if("CI"in x){for(let{0:r,1:e}of Fr)if(r in x)return e;return _("CI_NAME")==="codeship"?D:X}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(_("TEAMCITY_VERSION"))!==null?T:X;switch(_("TERM_PROGRAM")){case"iTerm.app":return!_("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(_("TERM_PROGRAM_VERSION"))!==null?D:A;case"HyperTerm":case"MacTerm":return A;case"Apple_Terminal":return D}if(_("COLORTERM")==="truecolor"||_("COLORTERM")==="24bit")return A;if(_("TERM")){if(/truecolor/.exec(_("TERM"))!==null)return A;if(/^xterm-256/.exec(_("TERM"))!==null)return D;let r=_("TERM").toLowerCase();if(ct[r])return ct[r];if(Gr.some(e=>e.exec(r)!==null))return T}return _("COLORTERM")?T:X}var $={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"}},Ee=["info","success","warn","error","debug"];function Vr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var zr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Kr=(r,e,t)=>{let n=new Date().toISOString();return t?`${$.dim}${n}${$.reset} ${zr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Jr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Wr()!==1,o=(c,f,a=[])=>{if(!e||!Vr(t,c))return;let u=Kr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},ss=Jr();l();l();var fs={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."},F=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Yr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function Z(r,e="/api/auth"){if(Yr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function ut(r,e,t,n){if(r)return Z(r,e);if(n!==!1){let i=x.BETTER_AUTH_URL||x.NEXT_PUBLIC_BETTER_AUTH_URL||x.PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_AUTH_URL||(x.BASE_URL!=="/"?x.BASE_URL:void 0);if(i)return Z(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return Z(`${o}://${s}`,e);if(t){let i=Qr(t.url);if(!i)throw new F("Could not get origin from request. Please provide a valid base URL.");return Z(i,e)}if(typeof window<"u"&&window.location)return Z(window.location.origin,e)}function Qr(r){try{return new URL(r).origin}catch{return null}}l();l();l();var ee=Symbol("clean");var N=[],B=0,ce=4,Xr=0,te=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=B+ce;o<N.length;)N[o]===n?N.splice(o,ce):o+=ce;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){Xr++;let o=!N.length;for(let i of e)N.push(i,t.value,n,s);if(o){for(B=0;B<N.length;B+=ce)N[B](N[B+1],N[B+2],N[B+3]);N.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[ee]=()=>{e=[],t.lc=0,t.off()}),t};l();var Zr=5,K=6,ue=10,en=(r,e,t,n)=>(r.events=r.events||{},r.events[t+ue]||(r.events[t+ue]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+ue](),delete r.events[t+ue])});var ft=1e3,Te=(r,e)=>en(r,n=>{let s=e(n);s&&r.events[K].push(s)},Zr,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[K]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[K])i();r.events[K]=[]}},ft)},process.env.NODE_ENV!=="production"){let i=r[ee];r[ee]=()=>{for(let c of r.events[K])c();r.events[K]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});l();var tn=typeof window>"u",fe=(r,e,t,n)=>{let s=te({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){s.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,m=u.retryAttempt||0;d&&m<d||(s.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{s.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{tn||(i?o():Te(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};l();var rn={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*:/},nn=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,dt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},sn=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function on(r){return r instanceof Date&&!isNaN(r.getTime())}function an(r){let e=sn.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,a,u,d]=e,m=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let y=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+y)}return on(m)?m:null}function ln(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,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 dt)return dt[c];if(!nn.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(rn).some(([a,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let m=an(d);if(m)return m}return s?s(u,d):d})}catch(a){if(t)throw a;return r}}function ht(r,e={strict:!0}){return ln(r,e)}var cn={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 un(r){let e=te(!1);return{session:fe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var pt=(r,e)=>{let t="credentials"in Request.prototype,n=ut(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=r?.plugins?.flatMap(g=>g.fetchPlugins).filter(g=>g!==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:f,onResponse:a,...u}=r?.fetchOptions||{},d=lt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(g){return g?ht(g,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[cn],...s]}),{$sessionSignal:m,session:y}=un(d),b=r?.plugins||[],R={},w={$sessionSignal:m,session:y},E={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{signal:"$sessionSignal",matcher(g){return g==="/sign-out"||g==="/update-user"||g.startsWith("/sign-in")||g.startsWith("/sign-up")||g==="/delete-user"||g==="/verify-email"}}];for(let g of b)g.getAtoms&&Object.assign(w,g.getAtoms?.(d)),g.pathMethods&&Object.assign(E,g.pathMethods),g.atomListeners&&O.push(...g.atomListeners);let j={notify:g=>{w[g].set(!w[g].get())},listen:(g,q)=>{w[g].subscribe(q)},atoms:w};for(let g of b)g.getActions&&Object.assign(R,g.getActions?.(d,j,r));return{get baseURL(){return n},pluginsActions:R,pluginsAtoms:w,pluginPathMethods:E,atomListeners:O,$fetch:d,$store:j}};function fn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function dn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function mt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||fn(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(O=>O.replace(/[A-Z]/g,j=>`-${j.toLowerCase()}`)).join("/"),d=a[0]||{},m=a[1]||{},{query:y,fetchOptions:b,...R}=d,w={...m,...b},E=dn(u,t,d);return await e(u,{...w,body:E==="GET"?void 0:{...R,...w?.body||{}},query:y||w?.query,method:E,async onSuccess(O){if(await w?.onSuccess?.(O),!s)return;let j=s.filter(g=>g.matcher(u));if(j.length)for(let g of j){let q=n[g.signal];if(!q)return;let v=q.get();setTimeout(()=>{q.set(!v)},10)}}})}})}return o()}l();function gt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Se(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=pt(r),c={};for(let[u,d]of Object.entries(n))c[`use${gt(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return mt(f,s,e,n,o)}l();l();l();function hn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?n=c.actions.some(f=>i.includes(f)):n=c.actions.every(f=>i.includes(f))}else throw new F("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function de(r){return{newRole(e){return hn(e)},statements:r}}var pn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Pe=de(pn),mn=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),gn=Pe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),yn=Pe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=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}}},wt=new Oe;l();l();l();l();l();l();l();l();var Rn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=de(Rn),En=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Tn=_t.newRole({user:[],session:[]});l();l();var vt=()=>({id:"username",$InferServerPlugin:{}});var Sn="/auth",he="nvwa_login_token",xe="nvwa_user_profile",Rt=class{constructor(e,t,n){this.storage=n,this.authClient=Se({baseURL:e,basePath:Sn,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>n.get(he)},onSuccess:s=>{let o=s.response.headers.get("set-auth-token");o&&n.set(he,o)}},plugins:[vt()]})}async currentUser(){return await this.storage.get(xe)}async signUp(e,t){let n=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(n)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.saveSession(n)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(he,e.data?.token),this.storage.set(xe,e.data?.user)}async signOut(){await this.storage.remove(he),await this.storage.remove(xe)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.saveSession(s)}};l();var Et=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}};l();var Tt=class{async jsonRequest(e,t){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,n)}async jsonRequestWithAuth(e,t,n){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,n)}};l();var Pn="/storage",On=Pn+"/generateUploadUrl",St=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+On,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=t.body;if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(n,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Je=_r(lr(),1),{PostgrestClient:cr,PostgrestQueryBuilder:Da,PostgrestFilterBuilder:$a,PostgrestTransformBuilder:ja,PostgrestBuilder:ka,PostgrestError:Ma}=Je.default||Je;l();l();var U=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${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,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},ne=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,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}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],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,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,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},be=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new ne(s.search),this.hash=s.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 n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=s.match(/^([^@]*)@(.+)$/),a="",u="",d=s;if(f){let R=f[1];d=f[2];let w=R.match(/^([^:]*):?(.*)$/);w&&(a=w[1]||"",u=w[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),y=m?m[1]:d,b=m&&m[2]?m[2]:"";return{protocol:n?`${n}:`:"",username:a,password:u,host:d,hostname:y,port:b,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()}};l();var we=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 U?t.headers:new U(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}};l();var V=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=qn(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 qn(r){return r?new U(r):new U}l();var se=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]"}},_e=class{constructor(){this._signal=new se}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function rl(r){r.URL=be,r.URLSearchParams=ne,r.Headers=U,r.Request=we,r.Response=V,r.AbortController=_e,r.AbortSignal=se}var Hn="/entities",Fn=(r,e)=>async(n,s)=>{console.log("customFetch",n,s);let o;if(typeof n=="string")o=n;else if(n&&typeof n=="object")if(typeof n.toString=="function"&&!n.url)o=n.toString();else if(n.url)o=n.url,s||(s={}),s.method=n.method,s.headers=n.headers,s.body=n.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(s?.method||"GET").toUpperCase(),c={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((y,b)=>{c[b]=y});else if(Array.isArray(s.headers))for(let[y,b]of s.headers)c[y]=b;else Object.assign(c,s.headers);let f=s?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(y){return new V(y?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new V(d,{status:a.status,headers:new U(a.headers)})},bl=(r,e,t)=>new cr(r+Hn,{fetch:Fn(e,t)});export{Sn as AUTH_BASE_PATH,_e as AbortController,se as AbortSignal,Hn as ENTITIES_BASE_PATH,Pn as FILE_STORAGE_BASE_PATH,On as GENERATE_UPLOAD_URL_PATH,U as Headers,he as LOGIN_TOKEN_KEY,xe as LOGIN_USER_PROFILE_KEY,Rt as NvwaAuthClient,Et as NvwaEdgeFunctions,St as NvwaFileStorage,Tt as NvwaHttpClient,we as Request,V as Response,be as URL,ne as URLSearchParams,bl as createPostgrestClient,rl as polyfill};
1
+ var dr=Object.create;var ie=Object.defineProperty;var hr=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var Xe=(r,e)=>()=>(r&&(e=r(r=0)),e);var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),yr=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},Ze=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of pr(e))!gr.call(r,s)&&s!==t&&ie(r,s,{get:()=>e[s],enumerable:!(n=hr(e,s))||n.enumerable});return r};var br=(r,e,t)=>(t=r!=null?dr(mr(r)):{},Ze(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),z=r=>Ze(ie({},"__esModule",{value:!0}),r);import Wn from"path";import{fileURLToPath as zn}from"url";var l=Xe(()=>{"use strict"});var G={};yr(G,{__addDisposableResource:()=>Yt,__assign:()=>pe,__asyncDelegator:()=>Ht,__asyncGenerator:()=>qt,__asyncValues:()=>Ft,__await:()=>J,__awaiter:()=>Dt,__classPrivateFieldGet:()=>zt,__classPrivateFieldIn:()=>Jt,__classPrivateFieldSet:()=>Kt,__createBinding:()=>ge,__decorate:()=>At,__disposeResources:()=>Qt,__esDecorate:()=>It,__exportStar:()=>jt,__extends:()=>Pt,__generator:()=>$t,__importDefault:()=>Vt,__importStar:()=>Wt,__makeTemplateObject:()=>Gt,__metadata:()=>Lt,__param:()=>xt,__propKey:()=>Ct,__read:()=>Ce,__rest:()=>Ot,__rewriteRelativeImportExtension:()=>Xt,__runInitializers:()=>Ut,__setFunctionName:()=>Nt,__spread:()=>kt,__spreadArray:()=>Bt,__spreadArrays:()=>Mt,__values:()=>me,default:()=>An});function Pt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ie(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Ot(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function At(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(i=r[c])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function xt(r,e){return function(t,n){e(t,n,r)}}function It(r,e,t,n,s,o){function i(E){if(E!==void 0&&typeof E!="function")throw new TypeError("Function expected");return E}for(var c=n.kind,f=c==="getter"?"get":c==="setter"?"set":"value",a=!e&&r?n.static?r:r.prototype:null,u=e||(a?Object.getOwnPropertyDescriptor(a,n.name):{}),d,m=!1,y=t.length-1;y>=0;y--){var b={};for(var R in n)b[R]=R==="access"?{}:n[R];for(var R in n.access)b.access[R]=n.access[R];b.addInitializer=function(E){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(E||null))};var w=(0,t[y])(c==="accessor"?{get:u.get,set:u.set}:u[f],b);if(c==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(d=i(w.get))&&(u.get=d),(d=i(w.set))&&(u.set=d),(d=i(w.init))&&s.unshift(d)}else(d=i(w))&&(c==="field"?s.unshift(d):u[f]=d)}a&&Object.defineProperty(a,n.name,u),m=!0}function Ut(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Ct(r){return typeof r=="symbol"?r:"".concat(r)}function Nt(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Lt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Dt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function c(u){try{a(n.next(u))}catch(d){i(d)}}function f(u){try{a(n.throw(u))}catch(d){i(d)}}function a(u){u.done?o(u.value):s(u.value).then(c,f)}a((n=n.apply(r,e||[])).next())})}function $t(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(u){return f([a,u])}}function f(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(t=0)),t;)try{if(n=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,s=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1],o=a;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(a);break}o[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(u){a=[6,u],s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function jt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ge(e,r,t)}function me(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ce(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function kt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Ce(arguments[e]));return r}function Mt(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,c=o.length;i<c;i++,s++)n[s]=o[i];return n}function Bt(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function J(r){return this instanceof J?(this.v=r,this):new J(r)}function qt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(y){return function(b){return Promise.resolve(b).then(y,d)}}function c(y,b){n[y]&&(s[y]=function(R){return new Promise(function(w,E){o.push([y,R,w,E])>1||f(y,R)})},b&&(s[y]=b(s[y])))}function f(y,b){try{a(n[y](b))}catch(R){m(o[0][3],R)}}function a(y){y.value instanceof J?Promise.resolve(y.value.v).then(u,d):m(o[0][2],y)}function u(y){f("next",y)}function d(y){f("throw",y)}function m(y,b){y(b),o.shift(),o.length&&f(o[0][0],o[0][1])}}function Ht(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:J(r[s](i)),done:!1}:o?o(i):i}:o}}function Ft(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof me=="function"?me(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(c,f){i=r[o](i),s(c,f,i.done,i.value)})}}function s(o,i,c,f){Promise.resolve(f).then(function(a){o({value:a,done:c})},i)}}function Gt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Ue(r),n=0;n<t.length;n++)t[n]!=="default"&&ge(e,r,t[n]);return Pn(e,r),e}function Vt(r){return r&&r.__esModule?r:{default:r}}function zt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Kt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function Jt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Yt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function Qt(r){function e(o){r.error=r.hasError?new On(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function Xt(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ie,pe,ge,Pn,Ue,On,An,W=Xe(()=>{"use strict";l();Ie=function(r,e){return Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ie(r,e)};pe=function(){return pe=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},pe.apply(this,arguments)};ge=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});Pn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Ue=function(r){return Ue=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ue(r)};On=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};An={__extends:Pt,__assign:pe,__rest:Ot,__decorate:At,__param:xt,__esDecorate:It,__runInitializers:Ut,__propKey:Ct,__setFunctionName:Nt,__metadata:Lt,__awaiter:Dt,__generator:$t,__createBinding:ge,__exportStar:jt,__values:me,__read:Ce,__spread:kt,__spreadArrays:Mt,__spreadArray:Bt,__await:J,__asyncGenerator:qt,__asyncDelegator:Ht,__asyncValues:Ft,__makeTemplateObject:Gt,__importStar:Wt,__importDefault:Vt,__classPrivateFieldGet:zt,__classPrivateFieldSet:Kt,__classPrivateFieldIn:Jt,__addDisposableResource:Yt,__disposeResources:Qt,__rewriteRelativeImportExtension:Xt}});var De=H(Le=>{"use strict";l();Object.defineProperty(Le,"__esModule",{value:!0});var Ne=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Le.default=Ne});var ke=H(je=>{"use strict";l();Object.defineProperty(je,"__esModule",{value:!0});var xn=(W(),z(G)),In=xn.__importDefault(De()),$e=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){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 n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,c,f,a;let u=null,d=null,m=null,y=o.status,b=o.statusText;if(o.ok){if(this.method!=="HEAD"){let O=await o.text();O===""||(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"))?d=O:d=JSON.parse(O))}let w=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),E=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");w&&E&&E.length>1&&(m=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,y=406,b="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let w=await o.text();try{u=JSON.parse(w),Array.isArray(u)&&o.status===404&&(d=[],u=null,y=200,b="OK")}catch{o.status===404&&w===""?(y=204,b="No Content"):u={message:w}}if(u&&this.isMaybeSingle&&(!((a=u?.details)===null||a===void 0)&&a.includes("0 rows"))&&(u=null,y=200,b="OK"),u&&this.shouldThrowOnError)throw new In.default(u)}return{error:u,data:d,count:m,status:y,statusText:b}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,c,f;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:`${(f=o?.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};je.default=$e});var qe=H(Be=>{"use strict";l();Object.defineProperty(Be,"__esModule",{value:!0});var Un=(W(),z(G)),Cn=Un.__importDefault(ke()),Me=class extends Cn.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.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:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var c;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),a=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${a}"; options=${f};`),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}};Be.default=Me});var ye=H(Fe=>{"use strict";l();Object.defineProperty(Fe,"__esModule",{value:!0});var Nn=(W(),z(G)),Ln=Nn.__importDefault(qe()),Dn=new RegExp("[,()]"),He=class extends Ln.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 n=Array.from(new Set(t)).map(s=>typeof s=="string"&&Dn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),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:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Fe.default=He});var Ve=H(We=>{"use strict";l();Object.defineProperty(We,"__esModule",{value:!0});var $n=(W(),z(G)),re=$n.__importDefault(ye()),Ge=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,c=(e??"*").split("").map(f=>/\s/.test(f)&&!i?"":(f==='"'&&(i=!i),f)).join("");return this.url.searchParams.set("select",c),s&&this.headers.append("Prefer",`count=${s}`),new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((c,f)=>c.concat(Object.keys(f)),[]);if(i.length>0){let c=[...new Set(i)].map(f=>`"${f}"`);this.url.searchParams.set("columns",c.join(","))}}return new re.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let f=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(f.length>0){let a=[...new Set(f)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new re.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 n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new re.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new re.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};We.default=Ge});var er=H(Ke=>{"use strict";l();Object.defineProperty(Ke,"__esModule",{value:!0});var Zt=(W(),z(G)),jn=Zt.__importDefault(Ve()),kn=Zt.__importDefault(ye()),ze=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new jn.default(t,{headers:new Headers(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:n=!1,get:s=!1,count:o}={}){var i;let c,f=new URL(`${this.url}/rpc/${e}`),a;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{f.searchParams.append(d,m)})):(c="POST",a=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new kn.default({method:c,url:f,headers:u,schema:this.schemaName,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Ke.default=ze});var ar=H(P=>{"use strict";l();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var Y=(W(),z(G)),tr=Y.__importDefault(er());P.PostgrestClient=tr.default;var rr=Y.__importDefault(Ve());P.PostgrestQueryBuilder=rr.default;var nr=Y.__importDefault(ye());P.PostgrestFilterBuilder=nr.default;var sr=Y.__importDefault(qe());P.PostgrestTransformBuilder=sr.default;var or=Y.__importDefault(ke());P.PostgrestBuilder=or.default;var ir=Y.__importDefault(De());P.PostgrestError=ir.default;P.default={PostgrestClient:tr.default,PostgrestQueryBuilder:rr.default,PostgrestFilterBuilder:nr.default,PostgrestTransformBuilder:sr.default,PostgrestBuilder:or.default,PostgrestError:ir.default}});l();l();l();l();l();l();var wr=Object.defineProperty,_r=Object.defineProperties,vr=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,Rr=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable,tt=(r,e,t)=>e in r?wr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e)=>{for(var t in e||(e={}))Rr.call(e,t)&&tt(r,t,e[t]);if(et)for(var t of et(e))Er.call(e,t)&&tt(r,t,e[t]);return r},L=(r,e)=>_r(r,vr(e)),Tr=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Sr=async(r,e)=>{var t,n,s,o,i,c;let f=e||{},a={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:f,hooks:a};for(let u of e?.plugins||[]){if(u.init){let d=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));f=d.options||f,r=d.url}a.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),a.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),a.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),a.onError.push((i=u.hooks)==null?void 0:i.onError),a.onRetry.push((c=u.hooks)==null?void 0:c.onRetry)}return{url:r,options:f,hooks:a}},rt=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}},Pr=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 Or(r){if(typeof r=="number")return new rt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new rt(r);case"exponential":return new Pr(r);default:throw new Error("Invalid retry strategy")}}var Ar=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},xr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ir(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return xr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function Ur(r){try{return JSON.parse(r),!0}catch{return!1}}function ot(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 nt(r){try{return JSON.parse(r)}catch{return r}}function st(r){return typeof r=="function"}function Cr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&st(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&st(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Nr(r){let e=new Headers(r?.headers),t=await Ar(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=Lr(r?.body);n&&e.set("content-type",n)}return e}function Lr(r){return ot(r)?"application/json":null}function Dr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ot(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function $r(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return at.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function jr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var kr=class it extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,it.prototype)}};async function ae(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new kr(t.issues);return t.value}var at=["get","post","put","patch","delete"];var Mr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let c=((s=(n=r.plugins)==null?void 0:n.find(f=>{var a;return(a=f.schema)!=null&&a.config?e.startsWith(f.schema.config.baseURL||"")||e.startsWith(f.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(c){let f=e;(o=c.config)!=null&&o.prefix&&f.startsWith(c.config.prefix)&&(f=f.replace(c.config.prefix,""),c.config.baseURL&&(e=e.replace(c.config.prefix,c.config.baseURL))),(i=c.config)!=null&&i.baseURL&&f.startsWith(c.config.baseURL)&&(f=f.replace(c.config.baseURL,""));let a=c.schema[f];if(a){let u=L(C({},t),{method:a.method,output:a.output});return t?.disableValidation||(u=L(C({},u),{body:a.input?await ae(a.input,t?.body):t?.body,params:a.params?await ae(a.params,t?.params):t?.params,query:a.query?await ae(a.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),lt=r=>{async function e(t,n){let s=L(C(C({},r),n),{plugins:[...r?.plugins||[],Mr(r||{})]});if(r?.catchAllError)try{return await Re(t,s)}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 Re(t,s)}return e};function Br(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let d=r.toString().split("@")[1].split("/")[0];at.includes(d)&&(r=r.replace(`@${d}/`,"/"))}o.endsWith("/")||(o+="/");let[i,c]=r.replace(o,"").split("?"),f=new URLSearchParams(c);for(let[d,m]of Object.entries(s||{}))m!=null&&f.set(d,String(m));if(n)if(Array.isArray(n)){let d=i.split("/").filter(m=>m.startsWith(":"));for(let[m,y]of d.entries()){let b=n[m];i=i.replace(y,b)}}else for(let[d,m]of Object.entries(n))i=i.replace(`:${d}`,String(m));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let a=f.toString();return a=a.length>0?`?${a}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${a}`,o):`${o}${i}${a}`}var Re=async(r,e)=>{var t,n,s,o,i,c,f,a;let{hooks:u,url:d,options:m}=await Sr(r,e),y=Cr(m),b=new AbortController,R=(t=m.signal)!=null?t:b.signal,w=Br(d,m),E=Dr(m),O=await Nr(m),j=$r(d,m),g=L(C({},m),{url:w,headers:O,body:E,method:j,signal:R});for(let I of u.onRequest)if(I){let S=await I(g);S instanceof Object&&(g=S)}("pipeTo"in g&&typeof g.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in g||(g.duplex="half"));let{clearTimeout:q}=jr(m,b),v=await y(g.url,g);q();let Ye={response:v,request:g};for(let I of u.onResponse)if(I){let S=await I(L(C({},Ye),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?v.clone():v}));S instanceof Response?v=S:S instanceof Object&&(v=S.response)}if(v.ok){if(!(g.method!=="HEAD"))return{data:"",error:null};let S=Ir(v),k={data:"",response:v,request:g};if(S==="json"||S==="text"){let M=await v.text(),fr=await((o=g.jsonParser)!=null?o:nt)(M);k.data=fr}else k.data=await v[S]();g?.output&&g.output&&!g.disableValidation&&(k.data=await ae(g.output,k.data));for(let M of u.onSuccess)M&&await M(L(C({},k),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?v.clone():v}));return e?.throw?k.data:{data:k.data,error:null}}let cr=(c=e?.jsonParser)!=null?c:nt,oe=await v.text(),Qe=Ur(oe),ve=Qe?await cr(oe):null,ur={response:v,responseText:oe,request:g,error:L(C({},ve),{status:v.status,statusText:v.statusText})};for(let I of u.onError)I&&await I(L(C({},ur),{response:(f=e?.hookOptions)!=null&&f.cloneResponse?v.clone():v}));if(e?.retry){let I=Or(e.retry),S=(a=e.retryAttempt)!=null?a:0;if(await I.shouldAttemptRetry(S,v)){for(let M of u.onRetry)M&&await M(Ye);let k=I.getDelay(S);return await new Promise(M=>setTimeout(M,k)),await Re(r,L(C({},e),{retryAttempt:S+1}))}}if(e?.throw)throw new Tr(v.status,v.statusText,Qe?ve:oe);return{data:null,error:L(C({},ve),{status:v.status,statusText:v.statusText})}};l();l();var le=Object.create(null),Q=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?le:globalThis),x=new Proxy(le,{get(r,e){return Q()[e]??le[e]},has(r,e){let t=Q();return e in t||e in le},set(r,e,t){let n=Q(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=Q(!0);return delete t[e],!0},ownKeys(){let r=Q(!0);return Object.keys(r)}});var es=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function _(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 ts=Object.freeze({get BETTER_AUTH_SECRET(){return _("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return _("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return _("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return _("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return _("NODE_ENV","development")},get PACKAGE_VERSION(){return _("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return _("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),X=1,T=4,D=8,A=24,ct={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:A,putty:T,st:T,"rxvt-unicode-24bit":A,terminator:A,"xterm-kitty":A},qr=new Map(Object.entries({APPVEYOR:D,BUILDKITE:D,CIRCLECI:A,DRONE:D,GITEA_ACTIONS:A,GITHUB_ACTIONS:A,GITLAB_CI:D,TRAVIS:D})),Hr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Fr(){if(_("FORCE_COLOR")!==void 0)switch(_("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return D;case"3":return A;default:return X}if(_("NODE_DISABLE_COLORS")!==void 0&&_("NODE_DISABLE_COLORS")!==""||_("NO_COLOR")!==void 0&&_("NO_COLOR")!==""||_("TERM")==="dumb")return X;if(_("TMUX"))return A;if("TF_BUILD"in x&&"AGENT_NAME"in x)return T;if("CI"in x){for(let{0:r,1:e}of qr)if(r in x)return e;return _("CI_NAME")==="codeship"?D:X}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(_("TEAMCITY_VERSION"))!==null?T:X;switch(_("TERM_PROGRAM")){case"iTerm.app":return!_("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(_("TERM_PROGRAM_VERSION"))!==null?D:A;case"HyperTerm":case"MacTerm":return A;case"Apple_Terminal":return D}if(_("COLORTERM")==="truecolor"||_("COLORTERM")==="24bit")return A;if(_("TERM")){if(/truecolor/.exec(_("TERM"))!==null)return A;if(/^xterm-256/.exec(_("TERM"))!==null)return D;let r=_("TERM").toLowerCase();if(ct[r])return ct[r];if(Hr.some(e=>e.exec(r)!==null))return T}return _("COLORTERM")?T:X}var $={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"}},Ee=["info","success","warn","error","debug"];function Gr(r,e){return Ee.indexOf(e)<=Ee.indexOf(r)}var Wr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Vr=(r,e,t)=>{let n=new Date().toISOString();return t?`${$.dim}${n}${$.reset} ${Wr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},zr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Fr()!==1,o=(c,f,a=[])=>{if(!e||!Gr(t,c))return;let u=Vr(c,f,s);if(!r||typeof r.log!="function"){c==="error"?console.error(u,...a):c==="warn"?console.warn(u,...a):console.log(u,...a);return}r.log(c==="success"?"info":c,f,...a)};return{...Object.fromEntries(Ee.map(c=>[c,(...[f,...a])=>o(c,f,a)])),get level(){return t}}},rs=zr();l();l();var cs={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."},F=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Kr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function Z(r,e="/api/auth"){if(Kr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function ut(r,e,t,n){if(r)return Z(r,e);if(n!==!1){let i=x.BETTER_AUTH_URL||x.NEXT_PUBLIC_BETTER_AUTH_URL||x.PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_AUTH_URL||(x.BASE_URL!=="/"?x.BASE_URL:void 0);if(i)return Z(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return Z(`${o}://${s}`,e);if(t){let i=Jr(t.url);if(!i)throw new F("Could not get origin from request. Please provide a valid base URL.");return Z(i,e)}if(typeof window<"u"&&window.location)return Z(window.location.origin,e)}function Jr(r){try{return new URL(r).origin}catch{return null}}l();l();l();var ee=Symbol("clean");var N=[],B=0,ce=4,Yr=0,te=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=B+ce;o<N.length;)N[o]===n?N.splice(o,ce):o+=ce;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){Yr++;let o=!N.length;for(let i of e)N.push(i,t.value,n,s);if(o){for(B=0;B<N.length;B+=ce)N[B](N[B+1],N[B+2],N[B+3]);N.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[ee]=()=>{e=[],t.lc=0,t.off()}),t};l();var Qr=5,K=6,ue=10,Xr=(r,e,t,n)=>(r.events=r.events||{},r.events[t+ue]||(r.events[t+ue]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+ue](),delete r.events[t+ue])});var ft=1e3,Te=(r,e)=>Xr(r,n=>{let s=e(n);s&&r.events[K].push(s)},Qr,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[K]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[K])i();r.events[K]=[]}},ft)},process.env.NODE_ENV!=="production"){let i=r[ee];r[ee]=()=>{for(let c of r.events[K])c();r.events[K]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});l();var Zr=typeof window>"u",fe=(r,e,t,n)=>{let s=te({data:null,error:null,isPending:!0,isRefetching:!1,refetch:c=>o(c)}),o=c=>{let f=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...f,query:{...f?.query,...c?.query},async onSuccess(a){s.set({data:a.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onSuccess?.(a)},async onError(a){let{request:u}=a,d=typeof u.retry=="number"?u.retry:u.retry?.attempts,m=u.retryAttempt||0;d&&m<d||(s.set({error:a.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await f?.onError?.(a))},async onRequest(a){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await f?.onRequest?.(a)}}).catch(a=>{s.set({error:a,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let c of r)c.subscribe(()=>{Zr||(i?o():Te(s,()=>{let f=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),c.off(),clearTimeout(f)}}))});return s};l();var en={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*:/},tn=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,dt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},rn=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function nn(r){return r instanceof Date&&!isNaN(r.getTime())}function sn(r){let e=rn.exec(r);if(!e)return null;let[,t,n,s,o,i,c,f,a,u,d]=e,m=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(c,10),f?parseInt(f.padEnd(3,"0"),10):0));if(a){let y=(parseInt(u,10)*60+parseInt(d,10))*(a==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+y)}return nn(m)?m:null}function on(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,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 dt)return dt[c];if(!tn.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(en).some(([a,u])=>{let d=u.test(i);return d&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${a} pattern`),d})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,d)=>{if(u==="__proto__"||u==="constructor"&&d&&typeof d=="object"&&"prototype"in d){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof d=="string"){let m=sn(d);if(m)return m}return s?s(u,d):d})}catch(a){if(t)throw a;return r}}function ht(r,e={strict:!0}){return on(r,e)}var an={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 ln(r){let e=te(!1);return{session:fe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var pt=(r,e)=>{let t="credentials"in Request.prototype,n=ut(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=r?.plugins?.flatMap(g=>g.fetchPlugins).filter(g=>g!==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:f,onResponse:a,...u}=r?.fetchOptions||{},d=lt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(g){return g?ht(g,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[an],...s]}),{$sessionSignal:m,session:y}=ln(d),b=r?.plugins||[],R={},w={$sessionSignal:m,session:y},E={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{signal:"$sessionSignal",matcher(g){return g==="/sign-out"||g==="/update-user"||g.startsWith("/sign-in")||g.startsWith("/sign-up")||g==="/delete-user"||g==="/verify-email"}}];for(let g of b)g.getAtoms&&Object.assign(w,g.getAtoms?.(d)),g.pathMethods&&Object.assign(E,g.pathMethods),g.atomListeners&&O.push(...g.atomListeners);let j={notify:g=>{w[g].set(!w[g].get())},listen:(g,q)=>{w[g].subscribe(q)},atoms:w};for(let g of b)g.getActions&&Object.assign(R,g.getActions?.(d,j,r));return{get baseURL(){return n},pluginsActions:R,pluginsAtoms:w,pluginPathMethods:E,atomListeners:O,$fetch:d,$store:j}};function cn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function un(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function mt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(c,f){if(typeof f!="string"||f==="then"||f==="catch"||f==="finally")return;let a=[...i,f],u=r;for(let d of a)if(u&&typeof u=="object"&&d in u)u=u[d];else{u=void 0;break}return typeof u=="function"||cn(u)?u:o(a)},apply:async(c,f,a)=>{let u="/"+i.map(O=>O.replace(/[A-Z]/g,j=>`-${j.toLowerCase()}`)).join("/"),d=a[0]||{},m=a[1]||{},{query:y,fetchOptions:b,...R}=d,w={...m,...b},E=un(u,t,d);return await e(u,{...w,body:E==="GET"?void 0:{...R,...w?.body||{}},query:y||w?.query,method:E,async onSuccess(O){if(await w?.onSuccess?.(O),!s)return;let j=s.filter(g=>g.matcher(u));if(j.length)for(let g of j){let q=n[g.signal];if(!q)return;let v=q.get();setTimeout(()=>{q.set(!v)},10)}}})}})}return o()}l();function gt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Se(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=pt(r),c={};for(let[u,d]of Object.entries(n))c[`use${gt(u)}`]=d;let f={...t,...c,$fetch:s,$store:i};return mt(f,s,e,n,o)}l();l();l();function fn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(c=>i.includes(c));else if(typeof o=="object"){let c=o;c.connector==="OR"?n=c.actions.some(f=>i.includes(f)):n=c.actions.every(f=>i.includes(f))}else throw new F("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function de(r){return{newRole(e){return fn(e)},statements:r}}var dn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Pe=de(dn),hn=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),pn=Pe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),mn=Pe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});l();l();l();l();l();l();l();l();l();l();l();var Oe=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}}},wt=new Oe;l();l();l();l();l();l();l();l();var _n={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=de(_n),vn=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Rn=_t.newRole({user:[],session:[]});l();l();var vt=()=>({id:"username",$InferServerPlugin:{}});var En="/auth",he="nvwa_login_token",xe="nvwa_user_profile",Rt=class{constructor(e,t,n){this.storage=n,this.authClient=Se({baseURL:e,basePath:En,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>n.get(he)},onSuccess:s=>{let o=s.response.headers.get("set-auth-token");o&&n.set(he,o)}},plugins:[vt()]})}async currentUser(){return await this.storage.get(xe)}async signUp(e,t){let n=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(n)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.saveSession(n)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(he,e.data?.token),this.storage.set(xe,e.data?.user)}async signOut(){await this.storage.remove(he),await this.storage.remove(xe)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.saveSession(s)}};l();var Et=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}};l();var Tt=class{async jsonRequest(e,t){let n={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,n)}async jsonRequestWithAuth(e,t,n){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,n)}};l();var Tn="/storage",Sn=Tn+"/generateUploadUrl",St=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+Sn,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=t.body;if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(n,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};l();l();l();var Je=br(ar(),1),{PostgrestClient:lr,PostgrestQueryBuilder:Na,PostgrestFilterBuilder:La,PostgrestTransformBuilder:Da,PostgrestBuilder:$a,PostgrestError:ja}=Je.default||Je;l();l();var U=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${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,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},ne=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,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}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],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,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,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},be=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new ne(s.search),this.hash=s.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 n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",c=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let f=s.match(/^([^@]*)@(.+)$/),a="",u="",d=s;if(f){let R=f[1];d=f[2];let w=R.match(/^([^:]*):?(.*)$/);w&&(a=w[1]||"",u=w[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),y=m?m[1]:d,b=m&&m[2]?m[2]:"";return{protocol:n?`${n}:`:"",username:a,password:u,host:d,hostname:y,port:b,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()}};l();var we=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 U?t.headers:new U(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}};l();var V=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=Mn(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 Mn(r){return r?new U(r):new U}l();var se=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]"}},_e=class{constructor(){this._signal=new se}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};l();function el(r){r.URL=be,r.URLSearchParams=ne,r.Headers=U,r.Request=we,r.Response=V,r.AbortController=_e,r.AbortSignal=se}var Bn="/entities",qn=(r,e)=>async(n,s)=>{console.log("customFetch",n,s);let o;if(typeof n=="string")o=n;else if(n&&typeof n=="object")if(typeof n.toString=="function"&&!n.url)o=n.toString();else if(n.url)o=n.url,s||(s={}),s.method=n.method,s.headers=n.headers,s.body=n.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let i=(s?.method||"GET").toUpperCase(),c={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((y,b)=>{c[b]=y});else if(Array.isArray(s.headers))for(let[y,b]of s.headers)c[y]=b;else Object.assign(c,s.headers);let f=s?.body,a;try{a=await r.requestWithAuth(o,{method:i,data:f,headers:c},e)}catch(y){return new V(y?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let u=a.body,d=null;return(a.headers["content-type"]||a.headers["Content-Type"]||"").startsWith("application/json")&&typeof u!="string"?d=JSON.stringify(u):typeof u=="string"||u&&(u.constructor===Blob||u.constructor===ArrayBuffer||typeof u.getReader=="function")?d=u:d=JSON.stringify(u),new V(d,{status:a.status,headers:new U(a.headers)})},gl=(r,e,t)=>new lr(r+Bn,{fetch:qn(e,t)});export{En as AUTH_BASE_PATH,_e as AbortController,se as AbortSignal,Bn as ENTITIES_BASE_PATH,Tn as FILE_STORAGE_BASE_PATH,Sn as GENERATE_UPLOAD_URL_PATH,U as Headers,he as LOGIN_TOKEN_KEY,xe as LOGIN_USER_PROFILE_KEY,Rt as NvwaAuthClient,Et as NvwaEdgeFunctions,St as NvwaFileStorage,Tt as NvwaHttpClient,we as Request,V as Response,be as URL,ne as URLSearchParams,gl as createPostgrestClient,el as polyfill};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-core",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "description": "NVWA跨端通用工具类核心接口",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,7 @@
29
29
  "directory": "packages/core"
30
30
  },
31
31
  "dependencies": {
32
- "@supabase/postgrest-js": "^2.77.0",
32
+ "@nvwa-app/postgrest-js": "^2.77.0",
33
33
  "better-auth": "^1.3.34"
34
34
  },
35
35
  "devDependencies": {
@@ -46,10 +46,7 @@
46
46
  "minify": true,
47
47
  "splitting": false,
48
48
  "shims": true,
49
- "external": [
50
- "@supabase/node-fetch"
51
- ],
52
- "noExternal": ["better-auth", "@supabase/postgrest-js"]
49
+ "noExternal": ["better-auth", "@nvwa-app/postgrest-js"]
53
50
  },
54
51
  "keywords": [
55
52
  "nvwa",