@nvwa-app/sdk-uniapp 0.10.0 → 0.10.10

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,4 +1,4 @@
1
- import { NvwaLocalStorage, INvwa, NvwaAuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill } from '@nvwa-app/sdk-core';
1
+ import { NvwaLocalStorage, NvwaFetch, INvwa, NvwaAuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill } from '@nvwa-app/sdk-core';
2
2
  export { polyfill } from '@nvwa-app/sdk-core';
3
3
 
4
4
  declare class UniAppLocalStorage implements NvwaLocalStorage {
@@ -32,6 +32,8 @@ declare function getIframeSourceLocation(iframe: HTMLIFrameElement | null, targe
32
32
  */
33
33
  declare function setupIframeSourceLocationListener(): (() => void) | undefined;
34
34
 
35
+ declare const uniappFetch: NvwaFetch;
36
+
35
37
  declare const localStorage: UniAppLocalStorage;
36
38
  declare class Nvwa implements INvwa {
37
39
  auth: NvwaAuthClient;
@@ -43,4 +45,4 @@ declare class Nvwa implements INvwa {
43
45
  constructor(baseUrl: string, handleUnauthorized: () => void);
44
46
  }
45
47
 
46
- export { Nvwa as default, disableIframeHoverInspector, enableIframeHoverInspector, getIframeSourceLocation, localStorage, setupIframeHoverInspector, setupIframeSourceLocationListener };
48
+ export { Nvwa as default, disableIframeHoverInspector, enableIframeHoverInspector, getIframeSourceLocation, localStorage, setupIframeHoverInspector, setupIframeSourceLocationListener, uniappFetch };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NvwaLocalStorage, INvwa, NvwaAuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill } from '@nvwa-app/sdk-core';
1
+ import { NvwaLocalStorage, NvwaFetch, INvwa, NvwaAuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill } from '@nvwa-app/sdk-core';
2
2
  export { polyfill } from '@nvwa-app/sdk-core';
3
3
 
4
4
  declare class UniAppLocalStorage implements NvwaLocalStorage {
@@ -32,6 +32,8 @@ declare function getIframeSourceLocation(iframe: HTMLIFrameElement | null, targe
32
32
  */
33
33
  declare function setupIframeSourceLocationListener(): (() => void) | undefined;
34
34
 
35
+ declare const uniappFetch: NvwaFetch;
36
+
35
37
  declare const localStorage: UniAppLocalStorage;
36
38
  declare class Nvwa implements INvwa {
37
39
  auth: NvwaAuthClient;
@@ -43,4 +45,4 @@ declare class Nvwa implements INvwa {
43
45
  constructor(baseUrl: string, handleUnauthorized: () => void);
44
46
  }
45
47
 
46
- export { Nvwa as default, disableIframeHoverInspector, enableIframeHoverInspector, getIframeSourceLocation, localStorage, setupIframeHoverInspector, setupIframeSourceLocationListener };
48
+ export { Nvwa as default, disableIframeHoverInspector, enableIframeHoverInspector, getIframeSourceLocation, localStorage, setupIframeHoverInspector, setupIframeSourceLocationListener, uniappFetch };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ce=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Bt=Object.prototype.hasOwnProperty;var Ft=(e,t)=>{for(var r in t)ce(e,r,{get:t[r],enumerable:!0})},qt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of kt(t))!Bt.call(e,s)&&s!==r&&ce(e,s,{get:()=>t[s],enumerable:!(n=Ht(t,s))||n.enumerable});return e};var Gt=e=>qt(ce({},"__esModule",{value:!0}),e);var Sn={};Ft(Sn,{default:()=>le,disableIframeHoverInspector:()=>bn,enableIframeHoverInspector:()=>En,getIframeSourceLocation:()=>_n,localStorage:()=>Oe,polyfill:()=>Lt,setupIframeHoverInspector:()=>wn,setupIframeSourceLocationListener:()=>On});module.exports=Gt(Sn);var Wt=Object.create,ae=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Vt=Object.getOwnPropertyNames,Yt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty,Ce=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Jt=(e,t)=>{for(var r in t)ae(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Vt(t))!Kt.call(e,s)&&s!==r&&ae(e,s,{get:()=>t[s],enumerable:!(n=zt(t,s))||n.enumerable});return e},Xt=(e,t,r)=>(r=e!=null?Wt(Yt(e)):{},Ue(t||!e||!e.__esModule?ae(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ue(ae({},"__esModule",{value:!0}),e),p=Ce(()=>{"use strict"}),M={};Jt(M,{__addDisposableResource:()=>at,__assign:()=>Y,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>F,__awaiter:()=>We,__classPrivateFieldGet:()=>nt,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>st,__createBinding:()=>K,__decorate:()=>Me,__disposeResources:()=>it,__esDecorate:()=>ke,__exportStar:()=>Ve,__extends:()=>je,__generator:()=>ze,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>He,__propKey:()=>Fe,__read:()=>ge,__rest:()=>De,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>Be,__setFunctionName:()=>qe,__spread:()=>Ye,__spreadArray:()=>Je,__spreadArrays:()=>Ke,__values:()=>se,default:()=>ht});function je(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function De(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function Me(e,t,r,n){var s=arguments.length,o=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(s<3?a(o):s>3?a(t,r,o):a(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function He(e,t){return function(r,n){t(r,n,e)}}function ke(e,t,r,n,s,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=n.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?n.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,n.name):{}),h,y=!1,d=r.length-1;d>=0;d--){var m={};for(var v in n)m[v]=v==="access"?{}:n[v];for(var v in n.access)m.access[v]=n.access[v];m.addInitializer=function(w){if(y)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||null))};var g=(0,r[d])(l==="accessor"?{get:c.get,set:c.set}:c[u],m);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&s.unshift(h)}else(h=a(g))&&(l==="field"?s.unshift(h):c[u]=h)}i&&Object.defineProperty(i,n.name,c),y=!0}function Be(e,t,r){for(var n=arguments.length>2,s=0;s<t.length;s++)r=n?t[s].call(e,r):t[s].call(e);return n?r:void 0}function Fe(e){return typeof e=="symbol"?e:"".concat(e)}function qe(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Ge(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function We(e,t,r,n){function s(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(n.next(c))}catch(h){a(h)}}function u(c){try{i(n.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):s(c.value).then(l,u)}i((n=n.apply(e,t||[])).next())})}function ze(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(n=1,s&&(o=i[0]&2?s.return:i[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,i[1])).done)return o;switch(s=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,s=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],s=0}finally{n=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function Ve(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&K(t,e,r)}function se(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ge(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,o=[],a;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(l){a={error:l}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ge(arguments[t]));return e}function Ke(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),s=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,s++)n[s]=o[a];return n}function Je(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,o;n<s;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function F(e){return this instanceof F?(this.v=e,this):new F(e)}function Xe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(d){return function(m){return Promise.resolve(m).then(d,h)}}function l(d,m){n[d]&&(s[d]=function(v){return new Promise(function(g,w){o.push([d,v,g,w])>1||u(d,v)})},m&&(s[d]=m(s[d])))}function u(d,m){try{i(n[d](m))}catch(v){y(o[0][3],v)}}function i(d){d.value instanceof F?Promise.resolve(d.value.v).then(c,h):y(o[0][2],d)}function c(d){u("next",d)}function h(d){u("throw",d)}function y(d,m){d(m),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Qe(e){var t,r;return t={},n("next"),n("throw",function(s){throw s}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(s,o){t[s]=e[s]?function(a){return(r=!r)?{value:F(e[s](a)),done:!1}:o?o(a):a}:o}}function Ze(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof se=="function"?se(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),s(l,u,a.done,a.value)})}}function s(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function et(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function tt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),n=0;n<r.length;n++)r[n]!=="default"&&K(t,e,r[n]);return ut(t,e),t}function rt(e){return e&&e.__esModule?e:{default:e}}function nt(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function st(e,t,r,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 t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(e,r):s?s.value=r:t.set(e,r),r}function ot(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function at(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var n,s;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(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)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}function it(e){function t(o){e.error=e.hasError?new ct(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,n=0;function s(){for(;r=e.stack.pop();)try{if(!r.async&&n===1)return n=0,e.stack.push(r),Promise.resolve().then(s);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(o).then(s,function(a){return t(a),s()})}else n|=1}catch(a){t(a)}if(n===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return s()}function lt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,s,o,a){return n?t?".jsx":".js":s&&(!o||!a)?r:s+o+"."+a.toLowerCase()+"js"}):e}var Z,Y,K,ut,ee,ct,ht,G=Ce(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},Z(e,t)},Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Y.apply(this,arguments)},K=Object.create?(function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ut=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[r.length]=n);return r},ee(e)},ct=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n},ht={__extends:je,__assign:Y,__rest:De,__decorate:Me,__param:He,__esDecorate:ke,__runInitializers:Be,__propKey:Fe,__setFunctionName:qe,__metadata:Ge,__awaiter:We,__generator:ze,__createBinding:K,__exportStar:Ve,__values:se,__read:ge,__spread:Ye,__spreadArrays:Ke,__spreadArray:Je,__await:F,__asyncGenerator:Xe,__asyncDelegator:Qe,__asyncValues:Ze,__makeTemplateObject:et,__importStar:tt,__importDefault:rt,__classPrivateFieldGet:nt,__classPrivateFieldSet:st,__classPrivateFieldIn:ot,__addDisposableResource:at,__disposeResources:it,__rewriteRelativeImportExtension:lt}}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(dt()),n=class{constructor(s){var o,a;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(o=s.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=s.signal,this.isMaybeSingle=(a=s.isMaybeSingle)!==null&&a!==void 0?a:!1,s.fetch?this.fetch=s.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,o){return this.headers=new Headers(this.headers),this.headers.set(s,o),this}then(s,o){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 a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,y;let d=null,m=null,v=null,g=u.status,w=u.statusText;if(u.ok){if(this.method!=="HEAD"){let f=await u.text();f===""||(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")?m=f:m=JSON.parse(f))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),S=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&S&&S.length>1&&(v=parseInt(S[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(m)&&(m.length>1?(d={code:"PGRST116",details:`Results contain ${m.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},m=null,v=null,g=406,w="Not Acceptable"):m.length===1?m=m[0]:m=null)}else{let T=await u.text();try{d=JSON.parse(T),Array.isArray(d)&&u.status===404&&(m=[],d=null,g=200,w="OK")}catch{u.status===404&&T===""?(g=204,w="No Content"):d={message:T}}if(d&&this.isMaybeSingle&&!((y=d?.details)===null||y===void 0)&&y.includes("0 rows")&&(d=null,g=200,w="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:m,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(s,o)}returns(){return this}overrideTypes(){return this}};e.default=n}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(pt()),n=class extends r.default{select(s){let o=!1,a=(s??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${s}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${s}`),this}range(s,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${s}`),this.url.searchParams.set(i,`${o-s+1}`),this}abortSignal(s){return this.signal=s,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:s=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[s?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),y=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${y}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}};e.default=n}),ve=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ft()),n=new RegExp("[,()]"),s=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&n.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=s}),mt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ve()),n=class{constructor(s,{headers:o={},schema:a,fetch:l}){this.url=s,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(s,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(s??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let i=s.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(s,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let h=s.reduce((y,d)=>y.concat(Object.keys(d)),[]);if(h.length>0){let y=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",y.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(s,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:s}={}){var o;let a="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=n}),Qt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(mt()),n=t.__importDefault(ve()),s=class yt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new yt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let y,d=new URL(`${this.url}/rpc/${a}`),m;u||i?(y=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{d.searchParams.append(g,w)})):(y="POST",m=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new n.default({method:y,url:d,headers:v,schema:this.schemaName,body:m,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=s}),Zt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(M)),r=t.__importDefault(Qt());e.PostgrestClient=r.default;var n=t.__importDefault(mt());e.PostgrestQueryBuilder=n.default;var s=t.__importDefault(ve());e.PostgrestFilterBuilder=s.default;var o=t.__importDefault(ft());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(pt());e.PostgrestBuilder=a.default;var l=t.__importDefault(dt());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:s.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var er=Object.defineProperty,tr=Object.defineProperties,rr=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))nr.call(t,r)&&Re(e,r,t[r]);if(Pe)for(var r of Pe(t))sr.call(t,r)&&Re(e,r,t[r]);return e},N=(e,t)=>tr(e,rr(t)),or=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},ar=async(e,t)=>{var r,n,s,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((n=c.hooks)==null?void 0:n.onRequest),i.onResponse.push((s=c.hooks)==null?void 0:s.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Ae=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},ir=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function lr(e){if(typeof e=="number")return new Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(e);case"exponential":return new ir(e);default:throw new Error("Invalid retry strategy")}}var ur=async e=>{let t={},r=async n=>typeof n=="function"?await n():n;if(e?.auth){if(e.auth.type==="Bearer"){let n=await r(e.auth.token);if(!n)return t;t.authorization=`Bearer ${n}`}else if(e.auth.type==="Basic"){let n=r(e.auth.username),s=r(e.auth.password);if(!n||!s)return t;t.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(e.auth.type==="Custom"){let n=r(e.auth.value);if(!n)return t;t.authorization=`${r(e.auth.prefix)} ${n}`}}return t},cr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function hr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let n=t.split(";").shift()||"";return cr.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function dr(e){try{return JSON.parse(e),!0}catch{return!1}}function gt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function Ie(e){try{return JSON.parse(e)}catch{return e}}function Le(e){return typeof e=="function"}function pr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&Le(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Le(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function fr(e){let t=new Headers(e?.headers),r=await ur(e);for(let[n,s]of Object.entries(r||{}))t.set(n,s);if(!t.has("content-type")){let n=mr(e?.body);n&&t.set("content-type",n)}return t}function mr(e){return gt(e)?"application/json":null}function yr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(gt(e.body)&&!t.has("content-type")){for(let[r,n]of Object.entries(e?.body))n instanceof Date&&(e.body[r]=n.toISOString());return JSON.stringify(e.body)}return e.body}function gr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let n=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return wt.includes(n)?n.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function vr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var wr=class vt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,vt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new wr(r.issues);return r.value}var wt=["get","post","put","patch","delete"],Er=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var n,s,o,a;let l=((s=(n=e.plugins)==null?void 0:n.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:s.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=N(L({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=N(L({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),br=e=>{async function t(r,n){let s=N(L(L({},e),n),{plugins:[...e?.plugins||[],Er(e||{})]});if(e?.catchAllError)try{return await pe(r,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 pe(r,s)}return t};function _r(e,t){let{baseURL:r,params:n,query:s}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];wt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(s||{}))h!=null&&u.set(c,String(h));if(n)if(Array.isArray(n)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,y]of c.entries()){let d=n[h];a=a.replace(y,d)}}else for(let[c,h]of Object.entries(n))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var pe=async(e,t)=>{var r,n,s,o,a,l,u,i;let{hooks:c,url:h,options:y}=await ar(e,t),d=pr(y),m=new AbortController,v=(r=y.signal)!=null?r:m.signal,g=_r(h,y),w=yr(y),T=await fr(y),S=gr(h,y),f=N(L({},y),{url:g,headers:T,body:w,method:S,signal:v});for(let P of c.onRequest)if(P){let _=await P(f);_ instanceof Object&&(f=_)}("pipeTo"in f&&typeof f.pipeTo=="function"||typeof((n=t?.body)==null?void 0:n.pipe)=="function")&&("duplex"in f||(f.duplex="half"));let{clearTimeout:j}=vr(y,m),b=await d(f.url,f);j();let Te={response:b,request:f};for(let P of c.onResponse)if(P){let _=await P(N(L({},Te),{response:(s=t?.hookOptions)!=null&&s.cloneResponse?b.clone():b}));_ instanceof Response?b=_:_ instanceof Object&&(b=_.response)}if(b.ok){if(f.method==="HEAD")return{data:"",error:null};let P=hr(b),_={data:"",response:b,request:f};if(P==="json"||P==="text"){let H=await b.text(),k=await((o=f.jsonParser)!=null?o:Ie)(H);_.data=k}else _.data=await b[P]();f?.output&&f.output&&!f.disableValidation&&(_.data=await te(f.output,_.data));for(let H of c.onSuccess)H&&await H(N(L({},_),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?b.clone():b}));return t?.throw?_.data:{data:_.data,error:null}}let Dt=(l=t?.jsonParser)!=null?l:Ie,J=await b.text(),Se=dr(J),ue=Se?await Dt(J):null,Mt={response:b,responseText:J,request:f,error:N(L({},ue),{status:b.status,statusText:b.statusText})};for(let P of c.onError)P&&await P(N(L({},Mt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?b.clone():b}));if(t?.retry){let P=lr(t.retry),_=(i=t.retryAttempt)!=null?i:0;if(await P.shouldAttemptRetry(_,b)){for(let k of c.onRetry)k&&await k(Te);let H=P.getDelay(_);return await new Promise(k=>setTimeout(k,H)),await pe(e,N(L({},t),{retryAttempt:_+1}))}}if(t?.throw)throw new or(b.status,b.statusText,Se?ue:J);return{data:null,error:N(L({},ue),{status:b.status,statusText:b.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let n=W(!0);return n[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),Rn=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function E(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var An=Object.freeze({get BETTER_AUTH_SECRET(){return E("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return E("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return E("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return E("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return E("NODE_ENV","development")},get PACKAGE_VERSION(){return E("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return E("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,O=4,x=8,R=24,Ne={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:R,putty:O,st:O,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},Or=new Map(Object.entries({APPVEYOR:x,BUILDKITE:x,CIRCLECI:R,DRONE:x,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:x,TRAVIS:x})),Tr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Sr(){if(E("FORCE_COLOR")!==void 0)switch(E("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return x;case"3":return R;default:return z}if(E("NODE_DISABLE_COLORS")!==void 0&&E("NODE_DISABLE_COLORS")!==""||E("NO_COLOR")!==void 0&&E("NO_COLOR")!==""||E("TERM")==="dumb")return z;if(E("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of Or)if(e in A)return t;return E("CI_NAME")==="codeship"?x:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(E("TEAMCITY_VERSION"))!==null?O:z;switch(E("TERM_PROGRAM")){case"iTerm.app":return!E("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(E("TERM_PROGRAM_VERSION"))!==null?x:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return x}if(E("COLORTERM")==="truecolor"||E("COLORTERM")==="24bit")return R;if(E("TERM")){if(/truecolor/.exec(E("TERM"))!==null)return R;if(/^xterm-256/.exec(E("TERM"))!==null)return x;let e=E("TERM").toLowerCase();if(Ne[e])return Ne[e];if(Tr.some(t=>t.exec(e)!==null))return O}return E("COLORTERM")?O:z}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"}},fe=["info","success","warn","error","debug"];function Pr(e,t){return fe.indexOf(t)<=fe.indexOf(e)}var Rr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Ar=(e,t,r)=>{let n=new Date().toISOString();return r?`${$.dim}${n}${$.reset} ${Rr[e]}${e.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${t}`:`${n} ${e.toUpperCase()} [Better Auth]: ${t}`},Ir=e=>{let t=e?.disabled!==!0,r=e?.level??"error",n=e?.disableColors!==void 0?!e.disableColors:Sr()!==1,s=(o,a,l=[])=>{if(!t||!Pr(r,o))return;let u=Ar(o,a,n);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(fe.map(o=>[o,(...[a,...l])=>s(o,a,l)])),get level(){return r}}},In=Ir();p();p();var we=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Lr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new we(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function V(e,t="/api/auth"){if(Lr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Nr(e,t,r,n){if(e)return V(e,t);if(n!==!1){let a=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(a)return V(a,t)}let s=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(s&&o)return V(`${o}://${s}`,t);if(r){let a=xr(r.url);if(!a)throw new we("Could not get origin from request. Please provide a valid base URL.");return V(a,t)}if(typeof window<"u"&&window.location)return V(window.location.origin,t)}function xr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var me=Symbol("clean"),I=[],U=0,X=4,$r=0,Et=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=U+X;o<I.length;)I[o]===n?I.splice(o,X):o+=X;let s=t.indexOf(n);~s&&(t.splice(s,1),--r.lc||r.off())}},notify(n,s){$r++;let o=!I.length;for(let a of t)I.push(a,r.value,n,s);if(o){for(U=0;U<I.length;U+=X)I[U](I[U+1],I[U+2],I[U+3]);I.length=0}},off(){},set(n){let s=r.value;s!==n&&(r.value=n,r.notify(s))},subscribe(n){let s=r.listen(n);return n(r.value),s},value:e};return process.env.NODE_ENV!=="production"&&(r[me]=()=>{t=[],r.lc=0,r.off()}),r};p();var Cr=5,B=6,Q=10,Ur=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=n(s=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...s})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let s=e.events[r],o=s.indexOf(t);s.splice(o,1),s.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),jr=1e3,Dr=(e,t)=>Ur(e,r=>{let n=t(r);n&&e.events[B].push(n)},Cr,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let s=e.off;if(e.events[B]=[],e.off=()=>{s(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[B])o();e.events[B]=[]}},jr)},process.env.NODE_ENV!=="production"){let o=e[me];e[me]=()=>{for(let a of e.events[B])a();e.events[B]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=s}});p();var Mr=typeof window>"u",Hr=(e,t,r,n)=>{let s=Et({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){s.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,y=c.retryAttempt||0;h&&y<h||(s.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=s.get();s.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{s.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Mr||(a?o():Dr(s,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{s.off(),l.off(),clearTimeout(u)}}))});return s};p();var kr={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*:/},Br=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,xe={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},Fr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function qr(e){return e instanceof Date&&!isNaN(e.getTime())}function Gr(e){let t=Fr.exec(e);if(!t)return null;let[,r,n,s,o,a,l,u,i,c,h]=t,y=new Date(Date.UTC(parseInt(r,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let d=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);y.setUTCMinutes(y.getUTCMinutes()+d)}return qr(y)?y:null}function Wr(e,t={}){let{strict:r=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in xe)return xe[l];if(!Br.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(kr).some(([u,i])=>{let c=i.test(a);return c&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Gr(i);if(c)return c}return s?s(u,i):i})}catch(u){if(r)throw u;return e}}function zr(e,t={strict:!0}){return Wr(e,t)}var Vr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Yr(e){let t=Et(!1);return{session:Hr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Kr=(e,t)=>{let r="credentials"in Request.prototype,n=Nr(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",s=e?.plugins?.flatMap(f=>f.fetchPlugins).filter(f=>f!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=br({baseURL:n,...r?{credentials:"include"}:{},method:"GET",jsonParser(f){return f?zr(f,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Vr],...s]}),{$sessionSignal:y,session:d}=Yr(h),m=e?.plugins||[],v={},g={$sessionSignal:y,session:d},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(f){return f==="/sign-out"||f==="/update-user"||f.startsWith("/sign-in")||f.startsWith("/sign-up")||f==="/delete-user"||f==="/verify-email"}}];for(let f of m)f.getAtoms&&Object.assign(g,f.getAtoms?.(h)),f.pathMethods&&Object.assign(w,f.pathMethods),f.atomListeners&&T.push(...f.atomListeners);let S={notify:f=>{g[f].set(!g[f].get())},listen:(f,j)=>{g[f].subscribe(j)},atoms:g};for(let f of m)f.getActions&&Object.assign(v,f.getActions?.(h,S,e));return{get baseURL(){return n},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:T,$fetch:h,$store:S}};function Jr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Xr(e,t,r){let n=t[e],{fetchOptions:s,query:o,...a}=r||{};return n||(s?.method?s.method:a&&Object.keys(a).length>0?"POST":"GET")}function Qr(e,t,r,n,s){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Jr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,S=>`-${S.toLowerCase()}`)).join("/"),h=i[0]||{},y=i[1]||{},{query:d,fetchOptions:m,...v}=h,g={...y,...m},w=Xr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:d||g?.query,method:w,async onSuccess(T){if(await g?.onSuccess?.(T),!s)return;let S=s.filter(f=>f.matcher(c));if(S.length)for(let f of S){let j=n[f.signal];if(!j)return;let b=j.get();setTimeout(()=>{j.set(!b)},10)}}})}})}return o()}p();function Zr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function en(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:a}=Kr(e),l={};for(let[i,c]of Object.entries(n))l[`use${Zr(i)}`]=c;let u={...r,...l,$fetch:s,$store:a};return Qr(u,s,t,n,o)}p();p();p();function tn(e){return{authorize(t,r="AND"){let n=!1;for(let[s,o]of Object.entries(t)){let a=e[s];if(!a)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(u=>a.includes(u)):n=l.actions.every(u=>a.includes(u))}else throw new we("Invalid access control request");if(n&&r==="OR")return{success:n};if(!n&&r==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:e}}function bt(e){return{newRole(t){return tn(t)},statements:e}}var rn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Ee=bt(rn),Ln=Ee.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Nn=Ee.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),xn=Ee.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var nn=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}}},$n=new nn;p();p();p();p();p();p();p();p();var sn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=bt(sn),Cn=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Un=_t.newRole({user:[],session:[]});p();p();var on=()=>({id:"username",$InferServerPlugin:{}}),an=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),ln=()=>({id:"better-auth-client",$InferServerPlugin:{}}),un="/auth",he="nvwa_login_token",ne="nvwa_current_jwt",de="nvwa_user_profile",Ot=class{constructor(e,t,r){this.storage=r;let n=en({baseURL:e,basePath:un,plugins:[on(),an(),ln()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let s=await this.storage.get(ne);if(console.log("jwt",s),s)return s;let o=await this.storage.get(he);return console.log("loginToken",o),o}}}});this.authClient=n}async currentUser(){return await this.storage.get(de)}async getCurrentJwt(){return await this.storage.get(ne)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let n=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(n)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(he,e.data?.token),await this.storage.set(de,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(ne,t.token)}async signOut(){await this.storage.remove(he),await this.storage.remove(de)}async updateUserPassword(e,t,r=!1){let n=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(n)}};p();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var C=class St{constructor(t){if(this.headerMap=new Map,t){if(t instanceof St)t.forEach((r,n)=>this.set(n,r));else if(Array.isArray(t))for(let[r,n]of t)this.set(r,String(n));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let n=t.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,n]of this.headerMap.entries())t(n,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Pt=class Rt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Rt)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,n]of t)this.append(r,n);else if(t&&typeof t=="object")for(let[r,n]of Object.entries(t))this.set(r,n)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let n of r)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(t,r){let n=this.params.get(t)||[];n.push(r),this.params.set(t,n)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[n])=>r.localeCompare(n));this.params=new Map(t)}toString(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[r,n]of this.params.entries())for(let s of n)t(s,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push([r,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},cn=class ye{constructor(t,r){let n;if(t instanceof ye)n=t.href;else if(r){let o=r instanceof ye?r.href:r;n=this.resolve(o,t)}else n=t;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 Pt(s.search),this.hash=s.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let n=this.parseUrl(t),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let n=r[2]||"",s=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=s.match(/^([^@]*)@(.+)$/),i="",c="",h=s;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let y=h.match(/^([^:]+):?(\d*)$/),d=y?y[1]:h,m=y&&y[2]?y[2]:"";return{protocol:n?`${n}:`:"",username:i,password:c,host:h,hostname:d,port:m,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var hn=class At{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof C?r.headers:new C(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new At(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var be=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=dn(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 dn(e){return e?new C(e):new C}p();var It=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]"}},pn=class{constructor(){this._signal=new It}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function Lt(e){e.URL=cn,e.URLSearchParams=Pt,e.Headers=C,e.Request=hn,e.Response=be,e.AbortController=pn,e.AbortSignal=It}var Nt=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(ne),n=new C(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let s=await this.customFetch(e,{...t,headers:n});if(s.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return s}};p();var fn="/storage",mn=fn+"/generateUploadUrl",xt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+mn,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new C({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:s}=await n.json();return{url:s.split("?")[0]}}};p();p();p();var $e=Xt(Zt(),1),{PostgrestClient:yn,PostgrestQueryBuilder:jn,PostgrestFilterBuilder:Dn,PostgrestTransformBuilder:Mn,PostgrestBuilder:Hn,PostgrestError:kn}=$e.default||$e,gn="/entities",$t=(e,t)=>new yn(e+gn,{fetch:t.fetchWithAuth.bind(t)});p();var Ct=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,n=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(n.status!==200)throw new Error(n.message);return n.data}};p();var Ut=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
1
+ "use strict";var he=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var qt=(e,t)=>{for(var r in t)he(e,r,{get:t[r],enumerable:!0})},Gt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Bt(t))!Ft.call(e,s)&&s!==r&&he(e,s,{get:()=>t[s],enumerable:!(n=kt(t,s))||n.enumerable});return e};var Wt=e=>Gt(he({},"__esModule",{value:!0}),e);var Sn={};qt(Sn,{default:()=>ue,disableIframeHoverInspector:()=>bn,enableIframeHoverInspector:()=>En,getIframeSourceLocation:()=>_n,localStorage:()=>Te,polyfill:()=>Nt,setupIframeHoverInspector:()=>wn,setupIframeSourceLocationListener:()=>On,uniappFetch:()=>le});module.exports=Wt(Sn);var zt=Object.create,ae=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Yt=Object.getOwnPropertyNames,Kt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,Ue=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Xt=(e,t)=>{for(var r in t)ae(e,r,{get:t[r],enumerable:!0})},je=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Yt(t))!Jt.call(e,s)&&s!==r&&ae(e,s,{get:()=>t[s],enumerable:!(n=Vt(t,s))||n.enumerable});return e},Qt=(e,t,r)=>(r=e!=null?zt(Kt(e)):{},je(t||!e||!e.__esModule?ae(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>je(ae({},"__esModule",{value:!0}),e),p=Ue(()=>{"use strict"}),M={};Xt(M,{__addDisposableResource:()=>it,__assign:()=>Y,__asyncDelegator:()=>Ze,__asyncGenerator:()=>Qe,__asyncValues:()=>et,__await:()=>F,__awaiter:()=>ze,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>at,__classPrivateFieldSet:()=>ot,__createBinding:()=>K,__decorate:()=>He,__disposeResources:()=>lt,__esDecorate:()=>Be,__exportStar:()=>Ye,__extends:()=>De,__generator:()=>Ve,__importDefault:()=>nt,__importStar:()=>rt,__makeTemplateObject:()=>tt,__metadata:()=>We,__param:()=>ke,__propKey:()=>qe,__read:()=>ve,__rest:()=>Me,__rewriteRelativeImportExtension:()=>ut,__runInitializers:()=>Fe,__setFunctionName:()=>Ge,__spread:()=>Ke,__spreadArray:()=>Xe,__spreadArrays:()=>Je,__values:()=>se,default:()=>dt});function De(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Me(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function He(e,t,r,n){var s=arguments.length,o=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(s<3?a(o):s>3?a(t,r,o):a(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function ke(e,t){return function(r,n){t(r,n,e)}}function Be(e,t,r,n,s,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=n.kind,c=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?n.static?e:e.prototype:null,u=t||(i?Object.getOwnPropertyDescriptor(i,n.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var m={};for(var v in n)m[v]=v==="access"?{}:n[v];for(var v in n.access)m.access[v]=n.access[v];m.addInitializer=function(w){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||null))};var g=(0,r[d])(l==="accessor"?{get:u.get,set:u.set}:u[c],m);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(u.get=h),(h=a(g.set))&&(u.set=h),(h=a(g.init))&&s.unshift(h)}else(h=a(g))&&(l==="field"?s.unshift(h):u[c]=h)}i&&Object.defineProperty(i,n.name,u),f=!0}function Fe(e,t,r){for(var n=arguments.length>2,s=0;s<t.length;s++)r=n?t[s].call(e,r):t[s].call(e);return n?r:void 0}function qe(e){return typeof e=="symbol"?e:"".concat(e)}function Ge(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function We(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function ze(e,t,r,n){function s(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(u){try{i(n.next(u))}catch(h){a(h)}}function c(u){try{i(n.throw(u))}catch(h){a(h)}}function i(u){u.done?o(u.value):s(u.value).then(l,c)}i((n=n.apply(e,t||[])).next())})}function Ve(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(u){return c([i,u])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(n=1,s&&(o=i[0]&2?s.return:i[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,i[1])).done)return o;switch(s=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,s=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(u){i=[6,u],s=0}finally{n=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function Ye(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&K(t,e,r)}function se(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ve(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,o=[],a;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(l){a={error:l}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ve(arguments[t]));return e}function Je(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),s=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,s++)n[s]=o[a];return n}function Xe(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,o;n<s;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function F(e){return this instanceof F?(this.v=e,this):new F(e)}function Qe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(d){return function(m){return Promise.resolve(m).then(d,h)}}function l(d,m){n[d]&&(s[d]=function(v){return new Promise(function(g,w){o.push([d,v,g,w])>1||c(d,v)})},m&&(s[d]=m(s[d])))}function c(d,m){try{i(n[d](m))}catch(v){f(o[0][3],v)}}function i(d){d.value instanceof F?Promise.resolve(d.value.v).then(u,h):f(o[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,m){d(m),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Ze(e){var t,r;return t={},n("next"),n("throw",function(s){throw s}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(s,o){t[s]=e[s]?function(a){return(r=!r)?{value:F(e[s](a)),done:!1}:o?o(a):a}:o}}function et(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof se=="function"?se(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(a){return new Promise(function(l,c){a=e[o](a),s(l,c,a.done,a.value)})}}function s(o,a,l,c){Promise.resolve(c).then(function(i){o({value:i,done:l})},a)}}function tt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function rt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),n=0;n<r.length;n++)r[n]!=="default"&&K(t,e,r[n]);return ct(t,e),t}function nt(e){return e&&e.__esModule?e:{default:e}}function st(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function ot(e,t,r,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 t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(e,r):s?s.value=r:t.set(e,r),r}function at(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function it(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var n,s;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(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)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}function lt(e){function t(o){e.error=e.hasError?new ht(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,n=0;function s(){for(;r=e.stack.pop();)try{if(!r.async&&n===1)return n=0,e.stack.push(r),Promise.resolve().then(s);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(o).then(s,function(a){return t(a),s()})}else n|=1}catch(a){t(a)}if(n===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return s()}function ut(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,s,o,a){return n?t?".jsx":".js":s&&(!o||!a)?r:s+o+"."+a.toLowerCase()+"js"}):e}var Z,Y,K,ct,ee,ht,dt,G=Ue(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},Z(e,t)},Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Y.apply(this,arguments)},K=Object.create?(function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ct=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[r.length]=n);return r},ee(e)},ht=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n},dt={__extends:De,__assign:Y,__rest:Me,__decorate:He,__param:ke,__esDecorate:Be,__runInitializers:Fe,__propKey:qe,__setFunctionName:Ge,__metadata:We,__awaiter:ze,__generator:Ve,__createBinding:K,__exportStar:Ye,__values:se,__read:ve,__spread:Ke,__spreadArrays:Je,__spreadArray:Xe,__await:F,__asyncGenerator:Qe,__asyncDelegator:Ze,__asyncValues:et,__makeTemplateObject:tt,__importStar:rt,__importDefault:nt,__classPrivateFieldGet:st,__classPrivateFieldSet:ot,__classPrivateFieldIn:at,__addDisposableResource:it,__disposeResources:lt,__rewriteRelativeImportExtension:ut}}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(pt()),n=class{constructor(s){var o,a;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(o=s.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=s.signal,this.isMaybeSingle=(a=s.isMaybeSingle)!==null&&a!==void 0?a:!1,s.fetch?this.fetch=s.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,o){return this.headers=new Headers(this.headers),this.headers.set(s,o),this}then(s,o){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 a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var i,u,h,f;let d=null,m=null,v=null,g=c.status,w=c.statusText;if(c.ok){if(this.method!=="HEAD"){let y=await c.text();y===""||(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")?m=y:m=JSON.parse(y))}let T=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),S=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&S&&S.length>1&&(v=parseInt(S[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(m)&&(m.length>1?(d={code:"PGRST116",details:`Results contain ${m.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},m=null,v=null,g=406,w="Not Acceptable"):m.length===1?m=m[0]:m=null)}else{let T=await c.text();try{d=JSON.parse(T),Array.isArray(d)&&c.status===404&&(m=[],d=null,g=200,w="OK")}catch{c.status===404&&T===""?(g=204,w="No Content"):d={message:T}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,g=200,w="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:m,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(c=>{var i,u,h;return{error:{message:`${(i=c?.name)!==null&&i!==void 0?i:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(s,o)}returns(){return this}overrideTypes(){return this}};e.default=n}),mt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ft()),n=class extends r.default{select(s){let o=!1,a=(s??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:c=l}={}){let i=c?`${c}.order`:"order",u=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${u?`${u},`:""}${s}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${s}`),this}range(s,o,{foreignTable:a,referencedTable:l=a}={}){let c=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(c,`${s}`),this.url.searchParams.set(i,`${o-s+1}`),this}abortSignal(s){return this.signal=s,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:s=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:c=!1,format:i="text"}={}){var u;let h=[s?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${f}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}};e.default=n}),we=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(mt()),n=new RegExp("[,()]"),s=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(c=>typeof c=="string"&&n.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:c}={}){let i="";c==="plain"?i="pl":c==="phrase"?i="ph":c==="websearch"&&(i="w");let u=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${u}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let c=l?`${l}.or`:"or";return this.url.searchParams.append(c,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=s}),yt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(we()),n=class{constructor(s,{headers:o={},schema:a,fetch:l}){this.url=s,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(s,o){let{head:a=!1,count:l}=o??{},c=a?"HEAD":"GET",i=!1,u=(s??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",u),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:o,defaultToNull:a=!0}={}){var l;let c="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let i=s.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(i.length>0){let u=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(s,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:c=!0}={}){var i;let u="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let h=s.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(s,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:s}={}){var o;let a="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=n}),Zt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(yt()),n=t.__importDefault(we()),s=class gt{constructor(a,{headers:l={},schema:c,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=c,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new gt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:c=!1,get:i=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${a}`),m;c||i?(f=c?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{d.searchParams.append(g,w)})):(f="POST",m=l);let v=new Headers(this.headers);return u&&v.set("Prefer",`count=${u}`),new n.default({method:f,url:d,headers:v,schema:this.schemaName,body:m,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=s}),er=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(M)),r=t.__importDefault(Zt());e.PostgrestClient=r.default;var n=t.__importDefault(yt());e.PostgrestQueryBuilder=n.default;var s=t.__importDefault(we());e.PostgrestFilterBuilder=s.default;var o=t.__importDefault(mt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(ft());e.PostgrestBuilder=a.default;var l=t.__importDefault(pt());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:s.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var tr=Object.defineProperty,rr=Object.defineProperties,nr=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,sr=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,Ae=(e,t,r)=>t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,I=(e,t)=>{for(var r in t||(t={}))sr.call(t,r)&&Ae(e,r,t[r]);if(Re)for(var r of Re(t))or.call(t,r)&&Ae(e,r,t[r]);return e},N=(e,t)=>rr(e,nr(t)),ar=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},ir=async(e,t)=>{var r,n,s,o,a,l;let c=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:c,hooks:i};for(let u of t?.plugins||[]){if(u.init){let h=await((r=u.init)==null?void 0:r.call(u,e.toString(),t));c=h.options||c,e=h.url}i.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),i.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),i.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),i.onError.push((a=u.hooks)==null?void 0:a.onError),i.onRetry.push((l=u.hooks)==null?void 0:l.onRetry)}return{url:e,options:c,hooks:i}},Le=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},lr=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function ur(e){if(typeof e=="number")return new Le({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Le(e);case"exponential":return new lr(e);default:throw new Error("Invalid retry strategy")}}var cr=async e=>{let t={},r=async n=>typeof n=="function"?await n():n;if(e?.auth){if(e.auth.type==="Bearer"){let n=await r(e.auth.token);if(!n)return t;t.authorization=`Bearer ${n}`}else if(e.auth.type==="Basic"){let n=r(e.auth.username),s=r(e.auth.password);if(!n||!s)return t;t.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(e.auth.type==="Custom"){let n=r(e.auth.value);if(!n)return t;t.authorization=`${r(e.auth.prefix)} ${n}`}}return t},hr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function dr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let n=t.split(";").shift()||"";return hr.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function pr(e){try{return JSON.parse(e),!0}catch{return!1}}function vt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function Ie(e){try{return JSON.parse(e)}catch{return e}}function Ne(e){return typeof e=="function"}function fr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&Ne(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Ne(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function mr(e){let t=new Headers(e?.headers),r=await cr(e);for(let[n,s]of Object.entries(r||{}))t.set(n,s);if(!t.has("content-type")){let n=yr(e?.body);n&&t.set("content-type",n)}return t}function yr(e){return vt(e)?"application/json":null}function gr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(vt(e.body)&&!t.has("content-type")){for(let[r,n]of Object.entries(e?.body))n instanceof Date&&(e.body[r]=n.toISOString());return JSON.stringify(e.body)}return e.body}function vr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let n=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return Et.includes(n)?n.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function wr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var Er=class wt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,wt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new Er(r.issues);return r.value}var Et=["get","post","put","patch","delete"],br=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var n,s,o,a;let l=((s=(n=e.plugins)==null?void 0:n.find(c=>{var i;return(i=c.schema)!=null&&i.config?t.startsWith(c.schema.config.baseURL||"")||t.startsWith(c.schema.config.prefix||""):!1}))==null?void 0:s.schema)||e.schema;if(l){let c=t;(o=l.config)!=null&&o.prefix&&c.startsWith(l.config.prefix)&&(c=c.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&c.startsWith(l.config.baseURL)&&(c=c.replace(l.config.baseURL,""));let i=l.schema[c];if(i){let u=N(I({},r),{method:i.method,output:i.output});return r?.disableValidation||(u=N(I({},u),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:u}}}return{url:t,options:r}}}),_r=e=>{async function t(r,n){let s=N(I(I({},e),n),{plugins:[...e?.plugins||[],br(e||{})]});if(e?.catchAllError)try{return await fe(r,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 fe(r,s)}return t};function Or(e,t){let{baseURL:r,params:n,query:s}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let u=e.toString().split("@")[1].split("/")[0];Et.includes(u)&&(e=e.replace(`@${u}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),c=new URLSearchParams(l);for(let[u,h]of Object.entries(s||{}))h!=null&&c.set(u,String(h));if(n)if(Array.isArray(n)){let u=a.split("/").filter(h=>h.startsWith(":"));for(let[h,f]of u.entries()){let d=n[h];a=a.replace(f,d)}}else for(let[u,h]of Object.entries(n))a=a.replace(`:${u}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=c.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var fe=async(e,t)=>{var r,n,s,o,a,l,c,i;let{hooks:u,url:h,options:f}=await ir(e,t),d=fr(f),m=new AbortController,v=(r=f.signal)!=null?r:m.signal,g=Or(h,f),w=gr(f),T=await mr(f),S=vr(h,f),y=N(I({},f),{url:g,headers:T,body:w,method:S,signal:v});for(let P of u.onRequest)if(P){let _=await P(y);_ instanceof Object&&(y=_)}("pipeTo"in y&&typeof y.pipeTo=="function"||typeof((n=t?.body)==null?void 0:n.pipe)=="function")&&("duplex"in y||(y.duplex="half"));let{clearTimeout:j}=wr(f,m),b=await d(y.url,y);j();let Se={response:b,request:y};for(let P of u.onResponse)if(P){let _=await P(N(I({},Se),{response:(s=t?.hookOptions)!=null&&s.cloneResponse?b.clone():b}));_ instanceof Response?b=_:_ instanceof Object&&(b=_.response)}if(b.ok){if(y.method==="HEAD")return{data:"",error:null};let P=dr(b),_={data:"",response:b,request:y};if(P==="json"||P==="text"){let H=await b.text(),k=await((o=y.jsonParser)!=null?o:Ie)(H);_.data=k}else _.data=await b[P]();y?.output&&y.output&&!y.disableValidation&&(_.data=await te(y.output,_.data));for(let H of u.onSuccess)H&&await H(N(I({},_),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?b.clone():b}));return t?.throw?_.data:{data:_.data,error:null}}let Mt=(l=t?.jsonParser)!=null?l:Ie,J=await b.text(),Pe=pr(J),ce=Pe?await Mt(J):null,Ht={response:b,responseText:J,request:y,error:N(I({},ce),{status:b.status,statusText:b.statusText})};for(let P of u.onError)P&&await P(N(I({},Ht),{response:(c=t?.hookOptions)!=null&&c.cloneResponse?b.clone():b}));if(t?.retry){let P=ur(t.retry),_=(i=t.retryAttempt)!=null?i:0;if(await P.shouldAttemptRetry(_,b)){for(let k of u.onRetry)k&&await k(Se);let H=P.getDelay(_);return await new Promise(k=>setTimeout(k,H)),await fe(e,N(I({},t),{retryAttempt:_+1}))}}if(t?.throw)throw new ar(b.status,b.statusText,Pe?ce:J);return{data:null,error:N(I({},ce),{status:b.status,statusText:b.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let n=W(!0);return n[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),Rn=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function E(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var An=Object.freeze({get BETTER_AUTH_SECRET(){return E("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return E("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return E("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return E("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return E("NODE_ENV","development")},get PACKAGE_VERSION(){return E("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return E("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,O=4,x=8,R=24,xe={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:R,putty:O,st:O,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},Tr=new Map(Object.entries({APPVEYOR:x,BUILDKITE:x,CIRCLECI:R,DRONE:x,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:x,TRAVIS:x})),Sr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Pr(){if(E("FORCE_COLOR")!==void 0)switch(E("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return x;case"3":return R;default:return z}if(E("NODE_DISABLE_COLORS")!==void 0&&E("NODE_DISABLE_COLORS")!==""||E("NO_COLOR")!==void 0&&E("NO_COLOR")!==""||E("TERM")==="dumb")return z;if(E("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of Tr)if(e in A)return t;return E("CI_NAME")==="codeship"?x:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(E("TEAMCITY_VERSION"))!==null?O:z;switch(E("TERM_PROGRAM")){case"iTerm.app":return!E("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(E("TERM_PROGRAM_VERSION"))!==null?x:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return x}if(E("COLORTERM")==="truecolor"||E("COLORTERM")==="24bit")return R;if(E("TERM")){if(/truecolor/.exec(E("TERM"))!==null)return R;if(/^xterm-256/.exec(E("TERM"))!==null)return x;let e=E("TERM").toLowerCase();if(xe[e])return xe[e];if(Sr.some(t=>t.exec(e)!==null))return O}return E("COLORTERM")?O:z}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"}},me=["info","success","warn","error","debug"];function Rr(e,t){return me.indexOf(t)<=me.indexOf(e)}var Ar={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Lr=(e,t,r)=>{let n=new Date().toISOString();return r?`${$.dim}${n}${$.reset} ${Ar[e]}${e.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${t}`:`${n} ${e.toUpperCase()} [Better Auth]: ${t}`},Ir=e=>{let t=e?.disabled!==!0,r=e?.level??"error",n=e?.disableColors!==void 0?!e.disableColors:Pr()!==1,s=(o,a,l=[])=>{if(!t||!Rr(r,o))return;let c=Lr(o,a,n);if(!e||typeof e.log!="function"){o==="error"?console.error(c,...l):o==="warn"?console.warn(c,...l):console.log(c,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(me.map(o=>[o,(...[a,...l])=>s(o,a,l)])),get level(){return r}}},Ln=Ir();p();p();var Ee=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Nr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new Ee(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function V(e,t="/api/auth"){if(Nr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function xr(e,t,r,n){if(e)return V(e,t);if(n!==!1){let a=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(a)return V(a,t)}let s=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(s&&o)return V(`${o}://${s}`,t);if(r){let a=$r(r.url);if(!a)throw new Ee("Could not get origin from request. Please provide a valid base URL.");return V(a,t)}if(typeof window<"u"&&window.location)return V(window.location.origin,t)}function $r(e){try{return new URL(e).origin}catch{return null}}p();p();p();var ye=Symbol("clean"),L=[],U=0,X=4,Cr=0,bt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=U+X;o<L.length;)L[o]===n?L.splice(o,X):o+=X;let s=t.indexOf(n);~s&&(t.splice(s,1),--r.lc||r.off())}},notify(n,s){Cr++;let o=!L.length;for(let a of t)L.push(a,r.value,n,s);if(o){for(U=0;U<L.length;U+=X)L[U](L[U+1],L[U+2],L[U+3]);L.length=0}},off(){},set(n){let s=r.value;s!==n&&(r.value=n,r.notify(s))},subscribe(n){let s=r.listen(n);return n(r.value),s},value:e};return process.env.NODE_ENV!=="production"&&(r[ye]=()=>{t=[],r.lc=0,r.off()}),r};p();var Ur=5,B=6,Q=10,jr=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=n(s=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...s})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let s=e.events[r],o=s.indexOf(t);s.splice(o,1),s.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),Dr=1e3,Mr=(e,t)=>jr(e,r=>{let n=t(r);n&&e.events[B].push(n)},Ur,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let s=e.off;if(e.events[B]=[],e.off=()=>{s(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[B])o();e.events[B]=[]}},Dr)},process.env.NODE_ENV!=="production"){let o=e[ye];e[ye]=()=>{for(let a of e.events[B])a();e.events[B]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=s}});p();var Hr=typeof window>"u",kr=(e,t,r,n)=>{let s=bt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let c=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;r(t,{...c,query:{...c?.query,...l?.query},async onSuccess(i){s.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await c?.onSuccess?.(i)},async onError(i){let{request:u}=i,h=typeof u.retry=="number"?u.retry:u.retry?.attempts,f=u.retryAttempt||0;h&&f<h||(s.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await c?.onError?.(i))},async onRequest(i){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await c?.onRequest?.(i)}}).catch(i=>{s.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Hr||(a?o():Mr(s,()=>{let c=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{s.off(),l.off(),clearTimeout(c)}}))});return s};p();var Br={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*:/},Fr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,$e={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},qr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Gr(e){return e instanceof Date&&!isNaN(e.getTime())}function Wr(e){let t=qr.exec(e);if(!t)return null;let[,r,n,s,o,a,l,c,i,u,h]=t,f=new Date(Date.UTC(parseInt(r,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),c?parseInt(c.padEnd(3,"0"),10):0));if(i){let d=(parseInt(u,10)*60+parseInt(h,10))*(i==="+"?-1:1);f.setUTCMinutes(f.getUTCMinutes()+d)}return Gr(f)?f:null}function zr(e,t={}){let{strict:r=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in $e)return $e[l];if(!Fr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Br).some(([c,i])=>{let u=i.test(a);return u&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${c} pattern`),u})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(c,i)=>{if(c==="__proto__"||c==="constructor"&&i&&typeof i=="object"&&"prototype"in i){n&&console.warn(`[better-json] Dropping "${c}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let u=Wr(i);if(u)return u}return s?s(c,i):i})}catch(c){if(r)throw c;return e}}function Vr(e,t={strict:!0}){return zr(e,t)}var Yr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Kr(e){let t=bt(!1);return{session:kr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Jr=(e,t)=>{let r="credentials"in Request.prototype,n=xr(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",s=e?.plugins?.flatMap(y=>y.fetchPlugins).filter(y=>y!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:c,onResponse:i,...u}=e?.fetchOptions||{},h=_r({baseURL:n,...r?{credentials:"include"}:{},method:"GET",jsonParser(y){return y?Vr(y,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Yr],...s]}),{$sessionSignal:f,session:d}=Kr(h),m=e?.plugins||[],v={},g={$sessionSignal:f,session:d},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(y){return y==="/sign-out"||y==="/update-user"||y.startsWith("/sign-in")||y.startsWith("/sign-up")||y==="/delete-user"||y==="/verify-email"}}];for(let y of m)y.getAtoms&&Object.assign(g,y.getAtoms?.(h)),y.pathMethods&&Object.assign(w,y.pathMethods),y.atomListeners&&T.push(...y.atomListeners);let S={notify:y=>{g[y].set(!g[y].get())},listen:(y,j)=>{g[y].subscribe(j)},atoms:g};for(let y of m)y.getActions&&Object.assign(v,y.getActions?.(h,S,e));return{get baseURL(){return n},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:T,$fetch:h,$store:S}};function Xr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Qr(e,t,r){let n=t[e],{fetchOptions:s,query:o,...a}=r||{};return n||(s?.method?s.method:a&&Object.keys(a).length>0?"POST":"GET")}function Zr(e,t,r,n,s){function o(a=[]){return new Proxy(function(){},{get(l,c){if(typeof c!="string"||c==="then"||c==="catch"||c==="finally")return;let i=[...a,c],u=e;for(let h of i)if(u&&typeof u=="object"&&h in u)u=u[h];else{u=void 0;break}return typeof u=="function"||Xr(u)?u:o(i)},apply:async(l,c,i)=>{let u="/"+a.map(T=>T.replace(/[A-Z]/g,S=>`-${S.toLowerCase()}`)).join("/"),h=i[0]||{},f=i[1]||{},{query:d,fetchOptions:m,...v}=h,g={...f,...m},w=Qr(u,r,h);return await t(u,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:d||g?.query,method:w,async onSuccess(T){if(await g?.onSuccess?.(T),!s)return;let S=s.filter(y=>y.matcher(u));if(S.length)for(let y of S){let j=n[y.signal];if(!j)return;let b=j.get();setTimeout(()=>{j.set(!b)},10)}}})}})}return o()}p();function en(e){return e.charAt(0).toUpperCase()+e.slice(1)}function tn(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:a}=Jr(e),l={};for(let[i,u]of Object.entries(n))l[`use${en(i)}`]=u;let c={...r,...l,$fetch:s,$store:a};return Zr(c,s,t,n,o)}p();p();p();function rn(e){return{authorize(t,r="AND"){let n=!1;for(let[s,o]of Object.entries(t)){let a=e[s];if(!a)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(c=>a.includes(c)):n=l.actions.every(c=>a.includes(c))}else throw new Ee("Invalid access control request");if(n&&r==="OR")return{success:n};if(!n&&r==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:e}}function _t(e){return{newRole(t){return rn(t)},statements:e}}var nn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},be=_t(nn),In=be.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Nn=be.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),xn=be.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var sn=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}}},$n=new sn;p();p();p();p();p();p();p();p();var on={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Ot=_t(on),Cn=Ot.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Un=Ot.newRole({user:[],session:[]});p();p();var an=()=>({id:"username",$InferServerPlugin:{}}),ln=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),un=()=>({id:"better-auth-client",$InferServerPlugin:{}}),cn="/auth",de="nvwa_login_token",ne="nvwa_current_jwt",pe="nvwa_user_profile",Tt=class{constructor(e,t,r){this.storage=r;let n=tn({baseURL:e,basePath:cn,plugins:[an(),ln(),un()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let s=await this.storage.get(ne);if(console.log("jwt",s),s)return s;let o=await this.storage.get(de);return console.log("loginToken",o),o}}}});this.authClient=n}async currentUser(){return await this.storage.get(pe)}async getCurrentJwt(){return await this.storage.get(ne)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let n=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(n)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(de,e.data?.token),await this.storage.set(pe,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(ne,t.token)}async signOut(){await this.storage.remove(de),await this.storage.remove(pe)}async updateUserPassword(e,t,r=!1){let n=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(n)}};p();var St=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var C=class Pt{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Pt)t.forEach((r,n)=>this.set(n,r));else if(Array.isArray(t))for(let[r,n]of t)this.set(r,String(n));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let n=t.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,n]of this.headerMap.entries())t(n,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Rt=class At{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof At)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,n]of t)this.append(r,n);else if(t&&typeof t=="object")for(let[r,n]of Object.entries(t))this.set(r,n)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let n of r)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(t,r){let n=this.params.get(t)||[];n.push(r),this.params.set(t,n)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[n])=>r.localeCompare(n));this.params=new Map(t)}toString(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[r,n]of this.params.entries())for(let s of n)t(s,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push([r,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},hn=class ge{constructor(t,r){let n;if(t instanceof ge)n=t.href;else if(r){let o=r instanceof ge?r.href:r;n=this.resolve(o,t)}else n=t;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 Rt(s.search),this.hash=s.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let n=this.parseUrl(t),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let n=r[2]||"",s=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),i="",u="",h=s;if(c){let v=c[1];h=c[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",u=g[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,m=f&&f[2]?f[2]:"";return{protocol:n?`${n}:`:"",username:i,password:u,host:h,hostname:d,port:m,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var dn=class Lt{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof C?r.headers:new C(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Lt(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var _e=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=pn(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 pn(e){return e?new C(e):new C}p();var It=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]"}},fn=class{constructor(){this._signal=new It}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function Nt(e){e.URL=hn,e.URLSearchParams=Rt,e.Headers=C,e.Request=dn,e.Response=_e,e.AbortController=fn,e.AbortSignal=It}var xt=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(ne),n=new C(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let s=t?.method||"GET";if((s==="POST"||s==="PUT"||s==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:n});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};p();var mn="/storage",yn=mn+"/generateUploadUrl",$t=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+yn,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new C({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:s}=await n.json();return{url:s.split("?")[0]}}};p();p();p();var Ce=Qt(er(),1),{PostgrestClient:gn,PostgrestQueryBuilder:jn,PostgrestFilterBuilder:Dn,PostgrestTransformBuilder:Mn,PostgrestBuilder:Hn,PostgrestError:kn}=Ce.default||Ce,vn="/entities",Ct=(e,t)=>new gn(e+vn,{fetch:t.fetchWithAuth.bind(t)});p();var Ut=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,n=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(n.status!==200)throw new Error(n.message);return n.data}};p();var jt=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,s=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+s}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let l=e.getBoundingClientRect();a.style.left=`${l.left+window.scrollX}px`,a.style.top=`${l.top+window.scrollY-a.offsetHeight-8}px`,l.top<a.offsetHeight+8&&(a.style.top=`${l.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let s=this.createTooltip();t?s.textContent=t:s.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,s.style.display="block";let o=e.getBoundingClientRect();s.style.left=`${o.left+window.scrollX}px`,s.style.top=`${o.top+window.scrollY-s.offsetHeight-8}px`,o.top<s.offsetHeight+8&&(s.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function jt(e="root"){if(typeof document>"u")return null;let t=document.getElementById(e)||document.body;if(!t)return null;let r=t.querySelector("[data-source-location]");if(r){let n=r.getAttribute("data-source-location");if(n)return n}if(t.firstElementChild){let n=t.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}var ie=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),n=uni.getStorageSync(r);return n?n.expires&&Date.now()>n.expires?(await this.remove(t),null):n.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,n){try{let s=this.getKey(t),o={value:r,expires:n?Date.now()+n*1e3:null,timestamp:Date.now()};uni.setStorageSync(s,o)}catch(s){throw console.error("UniAppStorageService set error:",s),s}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var vn=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let n=(t?.method||"GET").toUpperCase(),s={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{s[i]=u});else if(Array.isArray(l))for(let[u,i]of l)s[u]=i;else Object.assign(s,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",u(d);return}let c=!1,h=[],y=uni.request({url:r,method:n,data:o,header:s,timeout:a,success:d=>{if(c)return;c=!0;let m=d.statusCode,v="",g=new C,w=d.header||d.headers||{};Object.keys(w).forEach(T=>{let S=w[T];g.set(T,typeof S=="string"?S:String(S))}),l(new be(d.data,{status:m,statusText:v,headers:g}))},fail:d=>{if(c)return;c=!0;let m=d?.errMsg||d?.message||"Network Error",v=new Error(m);/(abort|aborted|canceled|cancelled)/i.test(String(m))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(c)return;try{y?.abort?.()}catch{}let m=new Error("The operation was aborted");m.name="AbortError",c=!0,u(m)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})},_e=vn;function wn(){if(typeof window>"u"||window===window.parent)return;let e=!1,t=new Ut;function r(u){let i=u;for(;i;){let c=i.getAttribute("data-source-location");if(c)return c;i=i.parentElement}return null}let n=null;function s(u){e&&(n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let i=u.target;if(!i||i===document.body||i===document.documentElement){t.removeHighlight();return}if(i.tagName.toLowerCase()==="img"){let d=r(i);t.highlightElement(i,d);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:d,elementInfo:{tagName:i.tagName.toLowerCase(),className:i.className||"",id:i.id||""}};window.parent.postMessage(m,"*");return}let c=i,h=r(i);if(!h){let d=i.parentElement;for(;d&&d!==document.body&&d!==document.documentElement;){let m=r(d);if(m){c=d,h=m;break}d=d.parentElement}}t.highlightElement(c,h);let y={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:h,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(y,"*")}))}function o(){if(!e)return;t.removeHighlight();let u={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(u,"*")}function a(u){if(!e)return;u.preventDefault(),u.stopPropagation();let i=u.target;if(!i||i===document.body||i===document.documentElement)return;let c=r(i);t.selectElement(i,c);let h={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:c,elementInfo:{tagName:i.tagName.toLowerCase(),className:i.className||"",id:i.id||""}};window.parent.postMessage(h,"*")}function l(u){u.data?.type==="HOVER_INSPECTOR_ENABLE"?(e=!0,document.addEventListener("mousemove",s),document.addEventListener("mouseleave",o),document.addEventListener("click",a,!0)):u.data?.type==="HOVER_INSPECTOR_DISABLE"&&(e=!1,document.removeEventListener("mousemove",s),document.removeEventListener("mouseleave",o),document.removeEventListener("click",a,!0),t.removeHighlight(),t.clearSelection())}return window.addEventListener("message",l),()=>{window.removeEventListener("message",l),document.removeEventListener("mousemove",s),document.removeEventListener("mouseleave",o),document.removeEventListener("click",a,!0),t.cleanup()}}function En(e,t){if(!e||!e.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};e.contentWindow.postMessage(r,t)}function bn(e,t){if(!e||!e.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};e.contentWindow.postMessage(r,t)}function _n(e,t,r=5e3){return new Promise((n,s)=>{if(!e||!e.contentWindow){s(new Error("Invalid iframe element"));return}let o=`source-location-${Date.now()}-${Math.random()}`,a=setTimeout(()=>{window.removeEventListener("message",l),s(new Error("Request timeout"))},r),l=i=>{i.origin===t&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===o&&(clearTimeout(a),window.removeEventListener("message",l),i.data.error?s(new Error(i.data.error)):n(i.data.sourceLocation||null))};window.addEventListener("message",l);let u={type:"GET_SOURCE_LOCATION_REQUEST",requestId:o};try{e.contentWindow.postMessage(u,t)}catch(i){clearTimeout(a),window.removeEventListener("message",l),s(i)}})}function On(){if(typeof window>"u"||window===window.parent)return;let e=t=>{if(t.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:Tn(),requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}catch(r){let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}function Tn(){return jt("app")}var Oe=new ie,le=class{constructor(t,r){this.auth=new Ot(t,_e,Oe),this.httpClient=new Nt(Oe,_e,r),this.fileStorage=new xt(t,this.httpClient),this.entities=$t(t,this.httpClient),this.functions=new Tt(this.httpClient),this.skill=new Ct(t,this.httpClient)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,polyfill,setupIframeHoverInspector,setupIframeSourceLocationListener});
33
+ `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,s=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+s}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let l=e.getBoundingClientRect();a.style.left=`${l.left+window.scrollX}px`,a.style.top=`${l.top+window.scrollY-a.offsetHeight-8}px`,l.top<a.offsetHeight+8&&(a.style.top=`${l.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let s=this.createTooltip();t?s.textContent=t:s.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,s.style.display="block";let o=e.getBoundingClientRect();s.style.left=`${o.left+window.scrollX}px`,s.style.top=`${o.top+window.scrollY-s.offsetHeight-8}px`,o.top<s.offsetHeight+8&&(s.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Dt(e="root"){if(typeof document>"u")return null;let t=document.getElementById(e)||document.body;if(!t)return null;let r=t.querySelector("[data-source-location]");if(r){let n=r.getAttribute("data-source-location");if(n)return n}if(t.firstElementChild){let n=t.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}var ie=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),n=uni.getStorageSync(r);return n?n.expires&&Date.now()>n.expires?(await this.remove(t),null):n.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,n){try{let s=this.getKey(t),o={value:r,expires:n?Date.now()+n*1e3:null,timestamp:Date.now()};uni.setStorageSync(s,o)}catch(s){throw console.error("UniAppStorageService set error:",s),s}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var le=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let n=(t?.method||"GET").toUpperCase(),s={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((c,i)=>{s[i]=c});else if(Array.isArray(l))for(let[c,i]of l)s[c]=i;else Object.assign(s,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let c={};l.forEach((i,u)=>{c[u]=i}),o=c}else o=l}let a=t?.timeout||3e4;return new Promise((l,c)=>{let i=t?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:n,data:o,header:s,timeout:a,success:d=>{if(u)return;u=!0;let m=d.statusCode,v="",g=new C,w=d.header||d.headers||{};Object.keys(w).forEach(T=>{let S=w[T];g.set(T,typeof S=="string"?S:String(S))}),l(new _e(d.data,{status:m,statusText:v,headers:g}))},fail:d=>{if(u)return;u=!0;let m=d?.errMsg||d?.message||"Network Error",v=new Error(m);/(abort|aborted|canceled|cancelled)/i.test(String(m))&&(v.name="AbortError"),c(v)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let m=new Error("The operation was aborted");m.name="AbortError",u=!0,c(m)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=le);var Oe=le;function wn(){if(typeof window>"u"||window===window.parent)return;let e=!1,t=new jt;function r(i){if(!i)return!1;let u=i.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function n(i){let u=i,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let s=null;function o(i){e&&(s!==null&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{let u=i.target;if(!u||u===document.body||u===document.documentElement){t.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let m=n(u);t.highlightElement(u,m);let v={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:m,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(v,"*");return}let h=u,f=n(u);if(!f){let m=u.parentElement;for(;m&&m!==document.body&&m!==document.documentElement;){let v=n(m);if(v){h=m,f=v;break}m=m.parentElement}}t.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function a(){if(!e)return;t.removeHighlight();let i={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(i,"*")}function l(i){if(!e)return;i.preventDefault(),i.stopPropagation();let u=i.target;if(!u||u===document.body||u===document.documentElement)return;let h=n(u);t.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(i){i.data?.type==="HOVER_INSPECTOR_ENABLE"?(e=!0,document.addEventListener("mousemove",o),document.addEventListener("mouseleave",a),document.addEventListener("click",l,!0)):i.data?.type==="HOVER_INSPECTOR_DISABLE"&&(e=!1,document.removeEventListener("mousemove",o),document.removeEventListener("mouseleave",a),document.removeEventListener("click",l,!0),t.removeHighlight(),t.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",o),document.removeEventListener("mouseleave",a),document.removeEventListener("click",l,!0),t.cleanup()}}function En(e,t){if(!e||!e.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};e.contentWindow.postMessage(r,t)}function bn(e,t){if(!e||!e.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};e.contentWindow.postMessage(r,t)}function _n(e,t,r=5e3){return new Promise((n,s)=>{if(!e||!e.contentWindow){s(new Error("Invalid iframe element"));return}let o=`source-location-${Date.now()}-${Math.random()}`,a=setTimeout(()=>{window.removeEventListener("message",l),s(new Error("Request timeout"))},r),l=i=>{i.origin===t&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===o&&(clearTimeout(a),window.removeEventListener("message",l),i.data.error?s(new Error(i.data.error)):n(i.data.sourceLocation||null))};window.addEventListener("message",l);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:o};try{e.contentWindow.postMessage(c,t)}catch(i){clearTimeout(a),window.removeEventListener("message",l),s(i)}})}function On(){if(typeof window>"u"||window===window.parent)return;let e=t=>{if(t.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:Tn(),requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}catch(r){let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}function Tn(){return Dt("app")}var Te=new ie,ue=class{constructor(t,r){this.auth=new Tt(t,Oe,Te),this.httpClient=new xt(Te,Oe,r),this.fileStorage=new $t(t,this.httpClient),this.entities=Ct(t,this.httpClient),this.functions=new St(this.httpClient),this.skill=new Ut(t,this.httpClient)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,polyfill,setupIframeHoverInspector,setupIframeSourceLocationListener,uniappFetch});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var Mt=Object.create,ie=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,kt=Object.getOwnPropertyNames,Bt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty,$e=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),qt=(e,t)=>{for(var r in t)ie(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of kt(t))!Ft.call(e,s)&&s!==r&&ie(e,s,{get:()=>t[s],enumerable:!(n=Ht(t,s))||n.enumerable});return e},Gt=(e,t,r)=>(r=e!=null?Mt(Bt(e)):{},Ce(t||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ce(ie({},"__esModule",{value:!0}),e),p=$e(()=>{"use strict"}),M={};qt(M,{__addDisposableResource:()=>ot,__assign:()=>Y,__asyncDelegator:()=>Xe,__asyncGenerator:()=>Je,__asyncValues:()=>Qe,__await:()=>F,__awaiter:()=>Ge,__classPrivateFieldGet:()=>rt,__classPrivateFieldIn:()=>st,__classPrivateFieldSet:()=>nt,__createBinding:()=>K,__decorate:()=>De,__disposeResources:()=>at,__esDecorate:()=>He,__exportStar:()=>ze,__extends:()=>Ue,__generator:()=>We,__importDefault:()=>tt,__importStar:()=>et,__makeTemplateObject:()=>Ze,__metadata:()=>qe,__param:()=>Me,__propKey:()=>Be,__read:()=>ye,__rest:()=>je,__rewriteRelativeImportExtension:()=>it,__runInitializers:()=>ke,__setFunctionName:()=>Fe,__spread:()=>Ve,__spreadArray:()=>Ke,__spreadArrays:()=>Ye,__values:()=>se,default:()=>ct});function Ue(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function je(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function De(e,t,r,n){var s=arguments.length,o=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(s<3?a(o):s>3?a(t,r,o):a(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function Me(e,t){return function(r,n){t(r,n,e)}}function He(e,t,r,n,s,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=n.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?n.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,n.name):{}),h,y=!1,d=r.length-1;d>=0;d--){var m={};for(var v in n)m[v]=v==="access"?{}:n[v];for(var v in n.access)m.access[v]=n.access[v];m.addInitializer=function(w){if(y)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||null))};var g=(0,r[d])(l==="accessor"?{get:c.get,set:c.set}:c[u],m);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&s.unshift(h)}else(h=a(g))&&(l==="field"?s.unshift(h):c[u]=h)}i&&Object.defineProperty(i,n.name,c),y=!0}function ke(e,t,r){for(var n=arguments.length>2,s=0;s<t.length;s++)r=n?t[s].call(e,r):t[s].call(e);return n?r:void 0}function Be(e){return typeof e=="symbol"?e:"".concat(e)}function Fe(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function qe(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ge(e,t,r,n){function s(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(n.next(c))}catch(h){a(h)}}function u(c){try{i(n.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):s(c.value).then(l,u)}i((n=n.apply(e,t||[])).next())})}function We(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(n=1,s&&(o=i[0]&2?s.return:i[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,i[1])).done)return o;switch(s=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,s=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],s=0}finally{n=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&K(t,e,r)}function se(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ye(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,o=[],a;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(l){a={error:l}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ye(arguments[t]));return e}function Ye(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),s=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,s++)n[s]=o[a];return n}function Ke(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,o;n<s;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function F(e){return this instanceof F?(this.v=e,this):new F(e)}function Je(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(d){return function(m){return Promise.resolve(m).then(d,h)}}function l(d,m){n[d]&&(s[d]=function(v){return new Promise(function(g,w){o.push([d,v,g,w])>1||u(d,v)})},m&&(s[d]=m(s[d])))}function u(d,m){try{i(n[d](m))}catch(v){y(o[0][3],v)}}function i(d){d.value instanceof F?Promise.resolve(d.value.v).then(c,h):y(o[0][2],d)}function c(d){u("next",d)}function h(d){u("throw",d)}function y(d,m){d(m),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Xe(e){var t,r;return t={},n("next"),n("throw",function(s){throw s}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(s,o){t[s]=e[s]?function(a){return(r=!r)?{value:F(e[s](a)),done:!1}:o?o(a):a}:o}}function Qe(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof se=="function"?se(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),s(l,u,a.done,a.value)})}}function s(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function Ze(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function et(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),n=0;n<r.length;n++)r[n]!=="default"&&K(t,e,r[n]);return lt(t,e),t}function tt(e){return e&&e.__esModule?e:{default:e}}function rt(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function nt(e,t,r,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 t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(e,r):s?s.value=r:t.set(e,r),r}function st(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function ot(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var n,s;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(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)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}function at(e){function t(o){e.error=e.hasError?new ut(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,n=0;function s(){for(;r=e.stack.pop();)try{if(!r.async&&n===1)return n=0,e.stack.push(r),Promise.resolve().then(s);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(o).then(s,function(a){return t(a),s()})}else n|=1}catch(a){t(a)}if(n===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return s()}function it(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,s,o,a){return n?t?".jsx":".js":s&&(!o||!a)?r:s+o+"."+a.toLowerCase()+"js"}):e}var Z,Y,K,lt,ee,ut,ct,G=$e(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},Z(e,t)},Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Y.apply(this,arguments)},K=Object.create?(function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),lt=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[r.length]=n);return r},ee(e)},ut=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n},ct={__extends:Ue,__assign:Y,__rest:je,__decorate:De,__param:Me,__esDecorate:He,__runInitializers:ke,__propKey:Be,__setFunctionName:Fe,__metadata:qe,__awaiter:Ge,__generator:We,__createBinding:K,__exportStar:ze,__values:se,__read:ye,__spread:Ve,__spreadArrays:Ye,__spreadArray:Ke,__await:F,__asyncGenerator:Je,__asyncDelegator:Xe,__asyncValues:Qe,__makeTemplateObject:Ze,__importStar:et,__importDefault:tt,__classPrivateFieldGet:rt,__classPrivateFieldSet:nt,__classPrivateFieldIn:st,__addDisposableResource:ot,__disposeResources:at,__rewriteRelativeImportExtension:it}}),ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ht()),n=class{constructor(s){var o,a;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(o=s.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=s.signal,this.isMaybeSingle=(a=s.isMaybeSingle)!==null&&a!==void 0?a:!1,s.fetch?this.fetch=s.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,o){return this.headers=new Headers(this.headers),this.headers.set(s,o),this}then(s,o){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 a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,y;let d=null,m=null,v=null,g=u.status,w=u.statusText;if(u.ok){if(this.method!=="HEAD"){let f=await u.text();f===""||(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")?m=f:m=JSON.parse(f))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),S=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&S&&S.length>1&&(v=parseInt(S[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(m)&&(m.length>1?(d={code:"PGRST116",details:`Results contain ${m.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},m=null,v=null,g=406,w="Not Acceptable"):m.length===1?m=m[0]:m=null)}else{let T=await u.text();try{d=JSON.parse(T),Array.isArray(d)&&u.status===404&&(m=[],d=null,g=200,w="OK")}catch{u.status===404&&T===""?(g=204,w="No Content"):d={message:T}}if(d&&this.isMaybeSingle&&!((y=d?.details)===null||y===void 0)&&y.includes("0 rows")&&(d=null,g=200,w="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:m,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(s,o)}returns(){return this}overrideTypes(){return this}};e.default=n}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(dt()),n=class extends r.default{select(s){let o=!1,a=(s??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${s}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${s}`),this}range(s,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${s}`),this.url.searchParams.set(i,`${o-s+1}`),this}abortSignal(s){return this.signal=s,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:s=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[s?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),y=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${y}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}};e.default=n}),ge=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(pt()),n=new RegExp("[,()]"),s=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&n.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=s}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ge()),n=class{constructor(s,{headers:o={},schema:a,fetch:l}){this.url=s,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(s,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(s??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let i=s.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(s,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let h=s.reduce((y,d)=>y.concat(Object.keys(d)),[]);if(h.length>0){let y=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",y.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(s,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:s}={}){var o;let a="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=n}),Wt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ft()),n=t.__importDefault(ge()),s=class mt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new mt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let y,d=new URL(`${this.url}/rpc/${a}`),m;u||i?(y=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{d.searchParams.append(g,w)})):(y="POST",m=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new n.default({method:y,url:d,headers:v,schema:this.schemaName,body:m,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=s}),zt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(M)),r=t.__importDefault(Wt());e.PostgrestClient=r.default;var n=t.__importDefault(ft());e.PostgrestQueryBuilder=n.default;var s=t.__importDefault(ge());e.PostgrestFilterBuilder=s.default;var o=t.__importDefault(pt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(dt());e.PostgrestBuilder=a.default;var l=t.__importDefault(ht());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:s.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Vt=Object.defineProperty,Yt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,Jt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,Pe=(e,t,r)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))Jt.call(t,r)&&Pe(e,r,t[r]);if(Se)for(var r of Se(t))Xt.call(t,r)&&Pe(e,r,t[r]);return e},N=(e,t)=>Yt(e,Kt(t)),Qt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Zt=async(e,t)=>{var r,n,s,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((n=c.hooks)==null?void 0:n.onRequest),i.onResponse.push((s=c.hooks)==null?void 0:s.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Re=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},er=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function tr(e){if(typeof e=="number")return new Re({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Re(e);case"exponential":return new er(e);default:throw new Error("Invalid retry strategy")}}var rr=async e=>{let t={},r=async n=>typeof n=="function"?await n():n;if(e?.auth){if(e.auth.type==="Bearer"){let n=await r(e.auth.token);if(!n)return t;t.authorization=`Bearer ${n}`}else if(e.auth.type==="Basic"){let n=r(e.auth.username),s=r(e.auth.password);if(!n||!s)return t;t.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(e.auth.type==="Custom"){let n=r(e.auth.value);if(!n)return t;t.authorization=`${r(e.auth.prefix)} ${n}`}}return t},nr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function sr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let n=t.split(";").shift()||"";return nr.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function or(e){try{return JSON.parse(e),!0}catch{return!1}}function yt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function Ae(e){try{return JSON.parse(e)}catch{return e}}function Ie(e){return typeof e=="function"}function ar(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&Ie(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Ie(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function ir(e){let t=new Headers(e?.headers),r=await rr(e);for(let[n,s]of Object.entries(r||{}))t.set(n,s);if(!t.has("content-type")){let n=lr(e?.body);n&&t.set("content-type",n)}return t}function lr(e){return yt(e)?"application/json":null}function ur(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(yt(e.body)&&!t.has("content-type")){for(let[r,n]of Object.entries(e?.body))n instanceof Date&&(e.body[r]=n.toISOString());return JSON.stringify(e.body)}return e.body}function cr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let n=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return vt.includes(n)?n.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function hr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var dr=class gt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,gt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new dr(r.issues);return r.value}var vt=["get","post","put","patch","delete"],pr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var n,s,o,a;let l=((s=(n=e.plugins)==null?void 0:n.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:s.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=N(L({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=N(L({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),fr=e=>{async function t(r,n){let s=N(L(L({},e),n),{plugins:[...e?.plugins||[],pr(e||{})]});if(e?.catchAllError)try{return await de(r,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 de(r,s)}return t};function mr(e,t){let{baseURL:r,params:n,query:s}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];vt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(s||{}))h!=null&&u.set(c,String(h));if(n)if(Array.isArray(n)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,y]of c.entries()){let d=n[h];a=a.replace(y,d)}}else for(let[c,h]of Object.entries(n))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var de=async(e,t)=>{var r,n,s,o,a,l,u,i;let{hooks:c,url:h,options:y}=await Zt(e,t),d=ar(y),m=new AbortController,v=(r=y.signal)!=null?r:m.signal,g=mr(h,y),w=ur(y),T=await ir(y),S=cr(h,y),f=N(L({},y),{url:g,headers:T,body:w,method:S,signal:v});for(let P of c.onRequest)if(P){let _=await P(f);_ instanceof Object&&(f=_)}("pipeTo"in f&&typeof f.pipeTo=="function"||typeof((n=t?.body)==null?void 0:n.pipe)=="function")&&("duplex"in f||(f.duplex="half"));let{clearTimeout:j}=hr(y,m),b=await d(f.url,f);j();let Oe={response:b,request:f};for(let P of c.onResponse)if(P){let _=await P(N(L({},Oe),{response:(s=t?.hookOptions)!=null&&s.cloneResponse?b.clone():b}));_ instanceof Response?b=_:_ instanceof Object&&(b=_.response)}if(b.ok){if(f.method==="HEAD")return{data:"",error:null};let P=sr(b),_={data:"",response:b,request:f};if(P==="json"||P==="text"){let H=await b.text(),k=await((o=f.jsonParser)!=null?o:Ae)(H);_.data=k}else _.data=await b[P]();f?.output&&f.output&&!f.disableValidation&&(_.data=await te(f.output,_.data));for(let H of c.onSuccess)H&&await H(N(L({},_),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?b.clone():b}));return t?.throw?_.data:{data:_.data,error:null}}let jt=(l=t?.jsonParser)!=null?l:Ae,J=await b.text(),Te=or(J),ue=Te?await jt(J):null,Dt={response:b,responseText:J,request:f,error:N(L({},ue),{status:b.status,statusText:b.statusText})};for(let P of c.onError)P&&await P(N(L({},Dt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?b.clone():b}));if(t?.retry){let P=tr(t.retry),_=(i=t.retryAttempt)!=null?i:0;if(await P.shouldAttemptRetry(_,b)){for(let k of c.onRetry)k&&await k(Oe);let H=P.getDelay(_);return await new Promise(k=>setTimeout(k,H)),await de(e,N(L({},t),{retryAttempt:_+1}))}}if(t?.throw)throw new Qt(b.status,b.statusText,Te?ue:J);return{data:null,error:N(L({},ue),{status:b.status,statusText:b.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let n=W(!0);return n[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),fn=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function E(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var mn=Object.freeze({get BETTER_AUTH_SECRET(){return E("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return E("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return E("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return E("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return E("NODE_ENV","development")},get PACKAGE_VERSION(){return E("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return E("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,O=4,x=8,R=24,Le={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:R,putty:O,st:O,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},yr=new Map(Object.entries({APPVEYOR:x,BUILDKITE:x,CIRCLECI:R,DRONE:x,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:x,TRAVIS:x})),gr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function vr(){if(E("FORCE_COLOR")!==void 0)switch(E("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return x;case"3":return R;default:return z}if(E("NODE_DISABLE_COLORS")!==void 0&&E("NODE_DISABLE_COLORS")!==""||E("NO_COLOR")!==void 0&&E("NO_COLOR")!==""||E("TERM")==="dumb")return z;if(E("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of yr)if(e in A)return t;return E("CI_NAME")==="codeship"?x:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(E("TEAMCITY_VERSION"))!==null?O:z;switch(E("TERM_PROGRAM")){case"iTerm.app":return!E("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(E("TERM_PROGRAM_VERSION"))!==null?x:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return x}if(E("COLORTERM")==="truecolor"||E("COLORTERM")==="24bit")return R;if(E("TERM")){if(/truecolor/.exec(E("TERM"))!==null)return R;if(/^xterm-256/.exec(E("TERM"))!==null)return x;let e=E("TERM").toLowerCase();if(Le[e])return Le[e];if(gr.some(t=>t.exec(e)!==null))return O}return E("COLORTERM")?O:z}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"}},pe=["info","success","warn","error","debug"];function wr(e,t){return pe.indexOf(t)<=pe.indexOf(e)}var Er={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},br=(e,t,r)=>{let n=new Date().toISOString();return r?`${$.dim}${n}${$.reset} ${Er[e]}${e.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${t}`:`${n} ${e.toUpperCase()} [Better Auth]: ${t}`},_r=e=>{let t=e?.disabled!==!0,r=e?.level??"error",n=e?.disableColors!==void 0?!e.disableColors:vr()!==1,s=(o,a,l=[])=>{if(!t||!wr(r,o))return;let u=br(o,a,n);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(pe.map(o=>[o,(...[a,...l])=>s(o,a,l)])),get level(){return r}}},yn=_r();p();p();var ve=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Or(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new ve(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function V(e,t="/api/auth"){if(Or(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Tr(e,t,r,n){if(e)return V(e,t);if(n!==!1){let a=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(a)return V(a,t)}let s=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(s&&o)return V(`${o}://${s}`,t);if(r){let a=Sr(r.url);if(!a)throw new ve("Could not get origin from request. Please provide a valid base URL.");return V(a,t)}if(typeof window<"u"&&window.location)return V(window.location.origin,t)}function Sr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var fe=Symbol("clean"),I=[],U=0,X=4,Pr=0,wt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=U+X;o<I.length;)I[o]===n?I.splice(o,X):o+=X;let s=t.indexOf(n);~s&&(t.splice(s,1),--r.lc||r.off())}},notify(n,s){Pr++;let o=!I.length;for(let a of t)I.push(a,r.value,n,s);if(o){for(U=0;U<I.length;U+=X)I[U](I[U+1],I[U+2],I[U+3]);I.length=0}},off(){},set(n){let s=r.value;s!==n&&(r.value=n,r.notify(s))},subscribe(n){let s=r.listen(n);return n(r.value),s},value:e};return process.env.NODE_ENV!=="production"&&(r[fe]=()=>{t=[],r.lc=0,r.off()}),r};p();var Rr=5,B=6,Q=10,Ar=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=n(s=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...s})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let s=e.events[r],o=s.indexOf(t);s.splice(o,1),s.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),Ir=1e3,Lr=(e,t)=>Ar(e,r=>{let n=t(r);n&&e.events[B].push(n)},Rr,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let s=e.off;if(e.events[B]=[],e.off=()=>{s(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[B])o();e.events[B]=[]}},Ir)},process.env.NODE_ENV!=="production"){let o=e[fe];e[fe]=()=>{for(let a of e.events[B])a();e.events[B]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=s}});p();var Nr=typeof window>"u",xr=(e,t,r,n)=>{let s=wt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){s.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,y=c.retryAttempt||0;h&&y<h||(s.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=s.get();s.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{s.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Nr||(a?o():Lr(s,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{s.off(),l.off(),clearTimeout(u)}}))});return s};p();var $r={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Cr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Ne={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},Ur=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function jr(e){return e instanceof Date&&!isNaN(e.getTime())}function Dr(e){let t=Ur.exec(e);if(!t)return null;let[,r,n,s,o,a,l,u,i,c,h]=t,y=new Date(Date.UTC(parseInt(r,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let d=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);y.setUTCMinutes(y.getUTCMinutes()+d)}return jr(y)?y:null}function Mr(e,t={}){let{strict:r=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in Ne)return Ne[l];if(!Cr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries($r).some(([u,i])=>{let c=i.test(a);return c&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Dr(i);if(c)return c}return s?s(u,i):i})}catch(u){if(r)throw u;return e}}function Hr(e,t={strict:!0}){return Mr(e,t)}var kr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Br(e){let t=wt(!1);return{session:xr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Fr=(e,t)=>{let r="credentials"in Request.prototype,n=Tr(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",s=e?.plugins?.flatMap(f=>f.fetchPlugins).filter(f=>f!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=fr({baseURL:n,...r?{credentials:"include"}:{},method:"GET",jsonParser(f){return f?Hr(f,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[kr],...s]}),{$sessionSignal:y,session:d}=Br(h),m=e?.plugins||[],v={},g={$sessionSignal:y,session:d},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(f){return f==="/sign-out"||f==="/update-user"||f.startsWith("/sign-in")||f.startsWith("/sign-up")||f==="/delete-user"||f==="/verify-email"}}];for(let f of m)f.getAtoms&&Object.assign(g,f.getAtoms?.(h)),f.pathMethods&&Object.assign(w,f.pathMethods),f.atomListeners&&T.push(...f.atomListeners);let S={notify:f=>{g[f].set(!g[f].get())},listen:(f,j)=>{g[f].subscribe(j)},atoms:g};for(let f of m)f.getActions&&Object.assign(v,f.getActions?.(h,S,e));return{get baseURL(){return n},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:T,$fetch:h,$store:S}};function qr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Gr(e,t,r){let n=t[e],{fetchOptions:s,query:o,...a}=r||{};return n||(s?.method?s.method:a&&Object.keys(a).length>0?"POST":"GET")}function Wr(e,t,r,n,s){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||qr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,S=>`-${S.toLowerCase()}`)).join("/"),h=i[0]||{},y=i[1]||{},{query:d,fetchOptions:m,...v}=h,g={...y,...m},w=Gr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:d||g?.query,method:w,async onSuccess(T){if(await g?.onSuccess?.(T),!s)return;let S=s.filter(f=>f.matcher(c));if(S.length)for(let f of S){let j=n[f.signal];if(!j)return;let b=j.get();setTimeout(()=>{j.set(!b)},10)}}})}})}return o()}p();function zr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Vr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:a}=Fr(e),l={};for(let[i,c]of Object.entries(n))l[`use${zr(i)}`]=c;let u={...r,...l,$fetch:s,$store:a};return Wr(u,s,t,n,o)}p();p();p();function Yr(e){return{authorize(t,r="AND"){let n=!1;for(let[s,o]of Object.entries(t)){let a=e[s];if(!a)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(u=>a.includes(u)):n=l.actions.every(u=>a.includes(u))}else throw new ve("Invalid access control request");if(n&&r==="OR")return{success:n};if(!n&&r==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:e}}function Et(e){return{newRole(t){return Yr(t)},statements:e}}var Kr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},we=Et(Kr),gn=we.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),vn=we.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),wn=we.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var Jr=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}}},En=new Jr;p();p();p();p();p();p();p();p();var Xr={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},bt=Et(Xr),bn=bt.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),_n=bt.newRole({user:[],session:[]});p();p();var Qr=()=>({id:"username",$InferServerPlugin:{}}),Zr=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),en=()=>({id:"better-auth-client",$InferServerPlugin:{}}),tn="/auth",ce="nvwa_login_token",ne="nvwa_current_jwt",he="nvwa_user_profile",_t=class{constructor(e,t,r){this.storage=r;let n=Vr({baseURL:e,basePath:tn,plugins:[Qr(),Zr(),en()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let s=await this.storage.get(ne);if(console.log("jwt",s),s)return s;let o=await this.storage.get(ce);return console.log("loginToken",o),o}}}});this.authClient=n}async currentUser(){return await this.storage.get(he)}async getCurrentJwt(){return await this.storage.get(ne)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let n=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(n)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ce,e.data?.token),await this.storage.set(he,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(ne,t.token)}async signOut(){await this.storage.remove(ce),await this.storage.remove(he)}async updateUserPassword(e,t,r=!1){let n=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(n)}};p();var Ot=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var C=class Tt{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Tt)t.forEach((r,n)=>this.set(n,r));else if(Array.isArray(t))for(let[r,n]of t)this.set(r,String(n));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let n=t.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,n]of this.headerMap.entries())t(n,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},St=class Pt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Pt)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,n]of t)this.append(r,n);else if(t&&typeof t=="object")for(let[r,n]of Object.entries(t))this.set(r,n)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let n of r)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(t,r){let n=this.params.get(t)||[];n.push(r),this.params.set(t,n)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[n])=>r.localeCompare(n));this.params=new Map(t)}toString(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[r,n]of this.params.entries())for(let s of n)t(s,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push([r,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},rn=class me{constructor(t,r){let n;if(t instanceof me)n=t.href;else if(r){let o=r instanceof me?r.href:r;n=this.resolve(o,t)}else n=t;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 St(s.search),this.hash=s.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let n=this.parseUrl(t),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let n=r[2]||"",s=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=s.match(/^([^@]*)@(.+)$/),i="",c="",h=s;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let y=h.match(/^([^:]+):?(\d*)$/),d=y?y[1]:h,m=y&&y[2]?y[2]:"";return{protocol:n?`${n}:`:"",username:i,password:c,host:h,hostname:d,port:m,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var nn=class Rt{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof C?r.headers:new C(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Rt(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var Ee=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=sn(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 sn(e){return e?new C(e):new C}p();var At=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]"}},on=class{constructor(){this._signal=new At}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function an(e){e.URL=rn,e.URLSearchParams=St,e.Headers=C,e.Request=nn,e.Response=Ee,e.AbortController=on,e.AbortSignal=At}var It=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(ne),n=new C(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let s=await this.customFetch(e,{...t,headers:n});if(s.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return s}};p();var ln="/storage",un=ln+"/generateUploadUrl",Lt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+un,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new C({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:s}=await n.json();return{url:s.split("?")[0]}}};p();p();p();var xe=Gt(zt(),1),{PostgrestClient:cn,PostgrestQueryBuilder:On,PostgrestFilterBuilder:Tn,PostgrestTransformBuilder:Sn,PostgrestBuilder:Pn,PostgrestError:Rn}=xe.default||xe,hn="/entities",Nt=(e,t)=>new cn(e+hn,{fetch:t.fetchWithAuth.bind(t)});p();var xt=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,n=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(n.status!==200)throw new Error(n.message);return n.data}};p();var $t=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
1
+ var Ht=Object.create,ie=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,Bt=Object.getOwnPropertyNames,Ft=Object.getPrototypeOf,qt=Object.prototype.hasOwnProperty,Ce=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Gt=(e,t)=>{for(var r in t)ie(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Bt(t))!qt.call(e,s)&&s!==r&&ie(e,s,{get:()=>t[s],enumerable:!(n=kt(t,s))||n.enumerable});return e},Wt=(e,t,r)=>(r=e!=null?Ht(Ft(e)):{},Ue(t||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ue(ie({},"__esModule",{value:!0}),e),p=Ce(()=>{"use strict"}),M={};Gt(M,{__addDisposableResource:()=>at,__assign:()=>Y,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>F,__awaiter:()=>We,__classPrivateFieldGet:()=>nt,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>st,__createBinding:()=>K,__decorate:()=>Me,__disposeResources:()=>it,__esDecorate:()=>ke,__exportStar:()=>Ve,__extends:()=>je,__generator:()=>ze,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>He,__propKey:()=>Fe,__read:()=>ye,__rest:()=>De,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>Be,__setFunctionName:()=>qe,__spread:()=>Ye,__spreadArray:()=>Je,__spreadArrays:()=>Ke,__values:()=>se,default:()=>ht});function je(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function De(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function Me(e,t,r,n){var s=arguments.length,o=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(s<3?a(o):s>3?a(t,r,o):a(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function He(e,t){return function(r,n){t(r,n,e)}}function ke(e,t,r,n,s,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=n.kind,c=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?n.static?e:e.prototype:null,u=t||(i?Object.getOwnPropertyDescriptor(i,n.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var m={};for(var v in n)m[v]=v==="access"?{}:n[v];for(var v in n.access)m.access[v]=n.access[v];m.addInitializer=function(w){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||null))};var g=(0,r[d])(l==="accessor"?{get:u.get,set:u.set}:u[c],m);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(u.get=h),(h=a(g.set))&&(u.set=h),(h=a(g.init))&&s.unshift(h)}else(h=a(g))&&(l==="field"?s.unshift(h):u[c]=h)}i&&Object.defineProperty(i,n.name,u),f=!0}function Be(e,t,r){for(var n=arguments.length>2,s=0;s<t.length;s++)r=n?t[s].call(e,r):t[s].call(e);return n?r:void 0}function Fe(e){return typeof e=="symbol"?e:"".concat(e)}function qe(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Ge(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function We(e,t,r,n){function s(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(u){try{i(n.next(u))}catch(h){a(h)}}function c(u){try{i(n.throw(u))}catch(h){a(h)}}function i(u){u.done?o(u.value):s(u.value).then(l,c)}i((n=n.apply(e,t||[])).next())})}function ze(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(u){return c([i,u])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(n=1,s&&(o=i[0]&2?s.return:i[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,i[1])).done)return o;switch(s=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,s=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(u){i=[6,u],s=0}finally{n=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function Ve(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&K(t,e,r)}function se(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ye(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,o=[],a;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(l){a={error:l}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ye(arguments[t]));return e}function Ke(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),s=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,s++)n[s]=o[a];return n}function Je(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,o;n<s;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function F(e){return this instanceof F?(this.v=e,this):new F(e)}function Xe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(d){return function(m){return Promise.resolve(m).then(d,h)}}function l(d,m){n[d]&&(s[d]=function(v){return new Promise(function(g,w){o.push([d,v,g,w])>1||c(d,v)})},m&&(s[d]=m(s[d])))}function c(d,m){try{i(n[d](m))}catch(v){f(o[0][3],v)}}function i(d){d.value instanceof F?Promise.resolve(d.value.v).then(u,h):f(o[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,m){d(m),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Qe(e){var t,r;return t={},n("next"),n("throw",function(s){throw s}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(s,o){t[s]=e[s]?function(a){return(r=!r)?{value:F(e[s](a)),done:!1}:o?o(a):a}:o}}function Ze(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof se=="function"?se(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(a){return new Promise(function(l,c){a=e[o](a),s(l,c,a.done,a.value)})}}function s(o,a,l,c){Promise.resolve(c).then(function(i){o({value:i,done:l})},a)}}function et(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function tt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),n=0;n<r.length;n++)r[n]!=="default"&&K(t,e,r[n]);return ut(t,e),t}function rt(e){return e&&e.__esModule?e:{default:e}}function nt(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function st(e,t,r,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 t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(e,r):s?s.value=r:t.set(e,r),r}function ot(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function at(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var n,s;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(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)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}function it(e){function t(o){e.error=e.hasError?new ct(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,n=0;function s(){for(;r=e.stack.pop();)try{if(!r.async&&n===1)return n=0,e.stack.push(r),Promise.resolve().then(s);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(o).then(s,function(a){return t(a),s()})}else n|=1}catch(a){t(a)}if(n===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return s()}function lt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,s,o,a){return n?t?".jsx":".js":s&&(!o||!a)?r:s+o+"."+a.toLowerCase()+"js"}):e}var Z,Y,K,ut,ee,ct,ht,G=Ce(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},Z(e,t)},Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Y.apply(this,arguments)},K=Object.create?(function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ut=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[r.length]=n);return r},ee(e)},ct=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n},ht={__extends:je,__assign:Y,__rest:De,__decorate:Me,__param:He,__esDecorate:ke,__runInitializers:Be,__propKey:Fe,__setFunctionName:qe,__metadata:Ge,__awaiter:We,__generator:ze,__createBinding:K,__exportStar:Ve,__values:se,__read:ye,__spread:Ye,__spreadArrays:Ke,__spreadArray:Je,__await:F,__asyncGenerator:Xe,__asyncDelegator:Qe,__asyncValues:Ze,__makeTemplateObject:et,__importStar:tt,__importDefault:rt,__classPrivateFieldGet:nt,__classPrivateFieldSet:st,__classPrivateFieldIn:ot,__addDisposableResource:at,__disposeResources:it,__rewriteRelativeImportExtension:lt}}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(dt()),n=class{constructor(s){var o,a;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(o=s.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=s.signal,this.isMaybeSingle=(a=s.isMaybeSingle)!==null&&a!==void 0?a:!1,s.fetch?this.fetch=s.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,o){return this.headers=new Headers(this.headers),this.headers.set(s,o),this}then(s,o){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 a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var i,u,h,f;let d=null,m=null,v=null,g=c.status,w=c.statusText;if(c.ok){if(this.method!=="HEAD"){let y=await c.text();y===""||(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")?m=y:m=JSON.parse(y))}let T=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),S=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&S&&S.length>1&&(v=parseInt(S[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(m)&&(m.length>1?(d={code:"PGRST116",details:`Results contain ${m.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},m=null,v=null,g=406,w="Not Acceptable"):m.length===1?m=m[0]:m=null)}else{let T=await c.text();try{d=JSON.parse(T),Array.isArray(d)&&c.status===404&&(m=[],d=null,g=200,w="OK")}catch{c.status===404&&T===""?(g=204,w="No Content"):d={message:T}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,g=200,w="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:m,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(c=>{var i,u,h;return{error:{message:`${(i=c?.name)!==null&&i!==void 0?i:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(s,o)}returns(){return this}overrideTypes(){return this}};e.default=n}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(pt()),n=class extends r.default{select(s){let o=!1,a=(s??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:c=l}={}){let i=c?`${c}.order`:"order",u=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${u?`${u},`:""}${s}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${s}`),this}range(s,o,{foreignTable:a,referencedTable:l=a}={}){let c=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(c,`${s}`),this.url.searchParams.set(i,`${o-s+1}`),this}abortSignal(s){return this.signal=s,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:s=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:c=!1,format:i="text"}={}){var u;let h=[s?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${f}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}};e.default=n}),ge=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ft()),n=new RegExp("[,()]"),s=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(c=>typeof c=="string"&&n.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:c}={}){let i="";c==="plain"?i="pl":c==="phrase"?i="ph":c==="websearch"&&(i="w");let u=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${u}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let c=l?`${l}.or`:"or";return this.url.searchParams.append(c,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=s}),mt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(ge()),n=class{constructor(s,{headers:o={},schema:a,fetch:l}){this.url=s,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(s,o){let{head:a=!1,count:l}=o??{},c=a?"HEAD":"GET",i=!1,u=(s??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",u),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:o,defaultToNull:a=!0}={}){var l;let c="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let i=s.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(i.length>0){let u=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(s,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:c=!0}={}){var i;let u="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(s)){let h=s.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(s,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:s}={}){var o;let a="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=n}),zt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(M)),r=t.__importDefault(mt()),n=t.__importDefault(ge()),s=class yt{constructor(a,{headers:l={},schema:c,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=c,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new yt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:c=!1,get:i=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${a}`),m;c||i?(f=c?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{d.searchParams.append(g,w)})):(f="POST",m=l);let v=new Headers(this.headers);return u&&v.set("Prefer",`count=${u}`),new n.default({method:f,url:d,headers:v,schema:this.schemaName,body:m,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=s}),Vt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(M)),r=t.__importDefault(zt());e.PostgrestClient=r.default;var n=t.__importDefault(mt());e.PostgrestQueryBuilder=n.default;var s=t.__importDefault(ge());e.PostgrestFilterBuilder=s.default;var o=t.__importDefault(ft());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(pt());e.PostgrestBuilder=a.default;var l=t.__importDefault(dt());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:s.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Yt=Object.defineProperty,Kt=Object.defineProperties,Jt=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Xt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,I=(e,t)=>{for(var r in t||(t={}))Xt.call(t,r)&&Re(e,r,t[r]);if(Pe)for(var r of Pe(t))Qt.call(t,r)&&Re(e,r,t[r]);return e},N=(e,t)=>Kt(e,Jt(t)),Zt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},er=async(e,t)=>{var r,n,s,o,a,l;let c=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:c,hooks:i};for(let u of t?.plugins||[]){if(u.init){let h=await((r=u.init)==null?void 0:r.call(u,e.toString(),t));c=h.options||c,e=h.url}i.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),i.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),i.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),i.onError.push((a=u.hooks)==null?void 0:a.onError),i.onRetry.push((l=u.hooks)==null?void 0:l.onRetry)}return{url:e,options:c,hooks:i}},Ae=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},tr=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function rr(e){if(typeof e=="number")return new Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(e);case"exponential":return new tr(e);default:throw new Error("Invalid retry strategy")}}var nr=async e=>{let t={},r=async n=>typeof n=="function"?await n():n;if(e?.auth){if(e.auth.type==="Bearer"){let n=await r(e.auth.token);if(!n)return t;t.authorization=`Bearer ${n}`}else if(e.auth.type==="Basic"){let n=r(e.auth.username),s=r(e.auth.password);if(!n||!s)return t;t.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(e.auth.type==="Custom"){let n=r(e.auth.value);if(!n)return t;t.authorization=`${r(e.auth.prefix)} ${n}`}}return t},sr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function or(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let n=t.split(";").shift()||"";return sr.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function ar(e){try{return JSON.parse(e),!0}catch{return!1}}function gt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function Le(e){try{return JSON.parse(e)}catch{return e}}function Ie(e){return typeof e=="function"}function ir(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&Ie(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Ie(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function lr(e){let t=new Headers(e?.headers),r=await nr(e);for(let[n,s]of Object.entries(r||{}))t.set(n,s);if(!t.has("content-type")){let n=ur(e?.body);n&&t.set("content-type",n)}return t}function ur(e){return gt(e)?"application/json":null}function cr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(gt(e.body)&&!t.has("content-type")){for(let[r,n]of Object.entries(e?.body))n instanceof Date&&(e.body[r]=n.toISOString());return JSON.stringify(e.body)}return e.body}function hr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let n=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return wt.includes(n)?n.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function dr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var pr=class vt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,vt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new pr(r.issues);return r.value}var wt=["get","post","put","patch","delete"],fr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var n,s,o,a;let l=((s=(n=e.plugins)==null?void 0:n.find(c=>{var i;return(i=c.schema)!=null&&i.config?t.startsWith(c.schema.config.baseURL||"")||t.startsWith(c.schema.config.prefix||""):!1}))==null?void 0:s.schema)||e.schema;if(l){let c=t;(o=l.config)!=null&&o.prefix&&c.startsWith(l.config.prefix)&&(c=c.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&c.startsWith(l.config.baseURL)&&(c=c.replace(l.config.baseURL,""));let i=l.schema[c];if(i){let u=N(I({},r),{method:i.method,output:i.output});return r?.disableValidation||(u=N(I({},u),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:u}}}return{url:t,options:r}}}),mr=e=>{async function t(r,n){let s=N(I(I({},e),n),{plugins:[...e?.plugins||[],fr(e||{})]});if(e?.catchAllError)try{return await de(r,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 de(r,s)}return t};function yr(e,t){let{baseURL:r,params:n,query:s}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let u=e.toString().split("@")[1].split("/")[0];wt.includes(u)&&(e=e.replace(`@${u}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),c=new URLSearchParams(l);for(let[u,h]of Object.entries(s||{}))h!=null&&c.set(u,String(h));if(n)if(Array.isArray(n)){let u=a.split("/").filter(h=>h.startsWith(":"));for(let[h,f]of u.entries()){let d=n[h];a=a.replace(f,d)}}else for(let[u,h]of Object.entries(n))a=a.replace(`:${u}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=c.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var de=async(e,t)=>{var r,n,s,o,a,l,c,i;let{hooks:u,url:h,options:f}=await er(e,t),d=ir(f),m=new AbortController,v=(r=f.signal)!=null?r:m.signal,g=yr(h,f),w=cr(f),T=await lr(f),S=hr(h,f),y=N(I({},f),{url:g,headers:T,body:w,method:S,signal:v});for(let P of u.onRequest)if(P){let _=await P(y);_ instanceof Object&&(y=_)}("pipeTo"in y&&typeof y.pipeTo=="function"||typeof((n=t?.body)==null?void 0:n.pipe)=="function")&&("duplex"in y||(y.duplex="half"));let{clearTimeout:j}=dr(f,m),b=await d(y.url,y);j();let Te={response:b,request:y};for(let P of u.onResponse)if(P){let _=await P(N(I({},Te),{response:(s=t?.hookOptions)!=null&&s.cloneResponse?b.clone():b}));_ instanceof Response?b=_:_ instanceof Object&&(b=_.response)}if(b.ok){if(y.method==="HEAD")return{data:"",error:null};let P=or(b),_={data:"",response:b,request:y};if(P==="json"||P==="text"){let H=await b.text(),k=await((o=y.jsonParser)!=null?o:Le)(H);_.data=k}else _.data=await b[P]();y?.output&&y.output&&!y.disableValidation&&(_.data=await te(y.output,_.data));for(let H of u.onSuccess)H&&await H(N(I({},_),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?b.clone():b}));return t?.throw?_.data:{data:_.data,error:null}}let Dt=(l=t?.jsonParser)!=null?l:Le,J=await b.text(),Se=ar(J),ue=Se?await Dt(J):null,Mt={response:b,responseText:J,request:y,error:N(I({},ue),{status:b.status,statusText:b.statusText})};for(let P of u.onError)P&&await P(N(I({},Mt),{response:(c=t?.hookOptions)!=null&&c.cloneResponse?b.clone():b}));if(t?.retry){let P=rr(t.retry),_=(i=t.retryAttempt)!=null?i:0;if(await P.shouldAttemptRetry(_,b)){for(let k of u.onRetry)k&&await k(Te);let H=P.getDelay(_);return await new Promise(k=>setTimeout(k,H)),await de(e,N(I({},t),{retryAttempt:_+1}))}}if(t?.throw)throw new Zt(b.status,b.statusText,Se?ue:J);return{data:null,error:N(I({},ue),{status:b.status,statusText:b.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let n=W(!0);return n[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),fn=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function E(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var mn=Object.freeze({get BETTER_AUTH_SECRET(){return E("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return E("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return E("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return E("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return E("NODE_ENV","development")},get PACKAGE_VERSION(){return E("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return E("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,O=4,x=8,R=24,Ne={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:R,putty:O,st:O,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},gr=new Map(Object.entries({APPVEYOR:x,BUILDKITE:x,CIRCLECI:R,DRONE:x,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:x,TRAVIS:x})),vr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function wr(){if(E("FORCE_COLOR")!==void 0)switch(E("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return x;case"3":return R;default:return z}if(E("NODE_DISABLE_COLORS")!==void 0&&E("NODE_DISABLE_COLORS")!==""||E("NO_COLOR")!==void 0&&E("NO_COLOR")!==""||E("TERM")==="dumb")return z;if(E("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of gr)if(e in A)return t;return E("CI_NAME")==="codeship"?x:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(E("TEAMCITY_VERSION"))!==null?O:z;switch(E("TERM_PROGRAM")){case"iTerm.app":return!E("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(E("TERM_PROGRAM_VERSION"))!==null?x:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return x}if(E("COLORTERM")==="truecolor"||E("COLORTERM")==="24bit")return R;if(E("TERM")){if(/truecolor/.exec(E("TERM"))!==null)return R;if(/^xterm-256/.exec(E("TERM"))!==null)return x;let e=E("TERM").toLowerCase();if(Ne[e])return Ne[e];if(vr.some(t=>t.exec(e)!==null))return O}return E("COLORTERM")?O:z}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"}},pe=["info","success","warn","error","debug"];function Er(e,t){return pe.indexOf(t)<=pe.indexOf(e)}var br={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},_r=(e,t,r)=>{let n=new Date().toISOString();return r?`${$.dim}${n}${$.reset} ${br[e]}${e.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${t}`:`${n} ${e.toUpperCase()} [Better Auth]: ${t}`},Or=e=>{let t=e?.disabled!==!0,r=e?.level??"error",n=e?.disableColors!==void 0?!e.disableColors:wr()!==1,s=(o,a,l=[])=>{if(!t||!Er(r,o))return;let c=_r(o,a,n);if(!e||typeof e.log!="function"){o==="error"?console.error(c,...l):o==="warn"?console.warn(c,...l):console.log(c,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(pe.map(o=>[o,(...[a,...l])=>s(o,a,l)])),get level(){return r}}},yn=Or();p();p();var ve=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Tr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new ve(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function V(e,t="/api/auth"){if(Tr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Sr(e,t,r,n){if(e)return V(e,t);if(n!==!1){let a=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(a)return V(a,t)}let s=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(s&&o)return V(`${o}://${s}`,t);if(r){let a=Pr(r.url);if(!a)throw new ve("Could not get origin from request. Please provide a valid base URL.");return V(a,t)}if(typeof window<"u"&&window.location)return V(window.location.origin,t)}function Pr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var fe=Symbol("clean"),L=[],U=0,X=4,Rr=0,Et=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=U+X;o<L.length;)L[o]===n?L.splice(o,X):o+=X;let s=t.indexOf(n);~s&&(t.splice(s,1),--r.lc||r.off())}},notify(n,s){Rr++;let o=!L.length;for(let a of t)L.push(a,r.value,n,s);if(o){for(U=0;U<L.length;U+=X)L[U](L[U+1],L[U+2],L[U+3]);L.length=0}},off(){},set(n){let s=r.value;s!==n&&(r.value=n,r.notify(s))},subscribe(n){let s=r.listen(n);return n(r.value),s},value:e};return process.env.NODE_ENV!=="production"&&(r[fe]=()=>{t=[],r.lc=0,r.off()}),r};p();var Ar=5,B=6,Q=10,Lr=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=n(s=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...s})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let s=e.events[r],o=s.indexOf(t);s.splice(o,1),s.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),Ir=1e3,Nr=(e,t)=>Lr(e,r=>{let n=t(r);n&&e.events[B].push(n)},Ar,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let s=e.off;if(e.events[B]=[],e.off=()=>{s(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[B])o();e.events[B]=[]}},Ir)},process.env.NODE_ENV!=="production"){let o=e[fe];e[fe]=()=>{for(let a of e.events[B])a();e.events[B]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=s}});p();var xr=typeof window>"u",$r=(e,t,r,n)=>{let s=Et({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let c=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;r(t,{...c,query:{...c?.query,...l?.query},async onSuccess(i){s.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await c?.onSuccess?.(i)},async onError(i){let{request:u}=i,h=typeof u.retry=="number"?u.retry:u.retry?.attempts,f=u.retryAttempt||0;h&&f<h||(s.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await c?.onError?.(i))},async onRequest(i){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await c?.onRequest?.(i)}}).catch(i=>{s.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{xr||(a?o():Nr(s,()=>{let c=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{s.off(),l.off(),clearTimeout(c)}}))});return s};p();var Cr={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*:/},Ur=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,xe={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},jr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Dr(e){return e instanceof Date&&!isNaN(e.getTime())}function Mr(e){let t=jr.exec(e);if(!t)return null;let[,r,n,s,o,a,l,c,i,u,h]=t,f=new Date(Date.UTC(parseInt(r,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),c?parseInt(c.padEnd(3,"0"),10):0));if(i){let d=(parseInt(u,10)*60+parseInt(h,10))*(i==="+"?-1:1);f.setUTCMinutes(f.getUTCMinutes()+d)}return Dr(f)?f:null}function Hr(e,t={}){let{strict:r=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in xe)return xe[l];if(!Ur.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Cr).some(([c,i])=>{let u=i.test(a);return u&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${c} pattern`),u})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(c,i)=>{if(c==="__proto__"||c==="constructor"&&i&&typeof i=="object"&&"prototype"in i){n&&console.warn(`[better-json] Dropping "${c}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let u=Mr(i);if(u)return u}return s?s(c,i):i})}catch(c){if(r)throw c;return e}}function kr(e,t={strict:!0}){return Hr(e,t)}var Br={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Fr(e){let t=Et(!1);return{session:$r(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var qr=(e,t)=>{let r="credentials"in Request.prototype,n=Sr(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",s=e?.plugins?.flatMap(y=>y.fetchPlugins).filter(y=>y!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:c,onResponse:i,...u}=e?.fetchOptions||{},h=mr({baseURL:n,...r?{credentials:"include"}:{},method:"GET",jsonParser(y){return y?kr(y,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Br],...s]}),{$sessionSignal:f,session:d}=Fr(h),m=e?.plugins||[],v={},g={$sessionSignal:f,session:d},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(y){return y==="/sign-out"||y==="/update-user"||y.startsWith("/sign-in")||y.startsWith("/sign-up")||y==="/delete-user"||y==="/verify-email"}}];for(let y of m)y.getAtoms&&Object.assign(g,y.getAtoms?.(h)),y.pathMethods&&Object.assign(w,y.pathMethods),y.atomListeners&&T.push(...y.atomListeners);let S={notify:y=>{g[y].set(!g[y].get())},listen:(y,j)=>{g[y].subscribe(j)},atoms:g};for(let y of m)y.getActions&&Object.assign(v,y.getActions?.(h,S,e));return{get baseURL(){return n},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:T,$fetch:h,$store:S}};function Gr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Wr(e,t,r){let n=t[e],{fetchOptions:s,query:o,...a}=r||{};return n||(s?.method?s.method:a&&Object.keys(a).length>0?"POST":"GET")}function zr(e,t,r,n,s){function o(a=[]){return new Proxy(function(){},{get(l,c){if(typeof c!="string"||c==="then"||c==="catch"||c==="finally")return;let i=[...a,c],u=e;for(let h of i)if(u&&typeof u=="object"&&h in u)u=u[h];else{u=void 0;break}return typeof u=="function"||Gr(u)?u:o(i)},apply:async(l,c,i)=>{let u="/"+a.map(T=>T.replace(/[A-Z]/g,S=>`-${S.toLowerCase()}`)).join("/"),h=i[0]||{},f=i[1]||{},{query:d,fetchOptions:m,...v}=h,g={...f,...m},w=Wr(u,r,h);return await t(u,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:d||g?.query,method:w,async onSuccess(T){if(await g?.onSuccess?.(T),!s)return;let S=s.filter(y=>y.matcher(u));if(S.length)for(let y of S){let j=n[y.signal];if(!j)return;let b=j.get();setTimeout(()=>{j.set(!b)},10)}}})}})}return o()}p();function Vr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Yr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:a}=qr(e),l={};for(let[i,u]of Object.entries(n))l[`use${Vr(i)}`]=u;let c={...r,...l,$fetch:s,$store:a};return zr(c,s,t,n,o)}p();p();p();function Kr(e){return{authorize(t,r="AND"){let n=!1;for(let[s,o]of Object.entries(t)){let a=e[s];if(!a)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(c=>a.includes(c)):n=l.actions.every(c=>a.includes(c))}else throw new ve("Invalid access control request");if(n&&r==="OR")return{success:n};if(!n&&r==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:e}}function bt(e){return{newRole(t){return Kr(t)},statements:e}}var Jr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},we=bt(Jr),gn=we.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),vn=we.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),wn=we.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var Xr=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}}},En=new Xr;p();p();p();p();p();p();p();p();var Qr={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=bt(Qr),bn=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),_n=_t.newRole({user:[],session:[]});p();p();var Zr=()=>({id:"username",$InferServerPlugin:{}}),en=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),tn=()=>({id:"better-auth-client",$InferServerPlugin:{}}),rn="/auth",ce="nvwa_login_token",ne="nvwa_current_jwt",he="nvwa_user_profile",Ot=class{constructor(e,t,r){this.storage=r;let n=Yr({baseURL:e,basePath:rn,plugins:[Zr(),en(),tn()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let s=await this.storage.get(ne);if(console.log("jwt",s),s)return s;let o=await this.storage.get(ce);return console.log("loginToken",o),o}}}});this.authClient=n}async currentUser(){return await this.storage.get(he)}async getCurrentJwt(){return await this.storage.get(ne)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let n=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(n)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ce,e.data?.token),await this.storage.set(he,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(ne,t.token)}async signOut(){await this.storage.remove(ce),await this.storage.remove(he)}async updateUserPassword(e,t,r=!1){let n=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(n)}};p();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var C=class St{constructor(t){if(this.headerMap=new Map,t){if(t instanceof St)t.forEach((r,n)=>this.set(n,r));else if(Array.isArray(t))for(let[r,n]of t)this.set(r,String(n));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let n=t.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,n]of this.headerMap.entries())t(n,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Pt=class Rt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Rt)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,n]of t)this.append(r,n);else if(t&&typeof t=="object")for(let[r,n]of Object.entries(t))this.set(r,n)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let n of r)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(t,r){let n=this.params.get(t)||[];n.push(r),this.params.set(t,n)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[n])=>r.localeCompare(n));this.params=new Map(t)}toString(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[r,n]of this.params.entries())for(let s of n)t(s,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,n]of this.params.entries())for(let s of n)t.push([r,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},nn=class me{constructor(t,r){let n;if(t instanceof me)n=t.href;else if(r){let o=r instanceof me?r.href:r;n=this.resolve(o,t)}else n=t;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 Pt(s.search),this.hash=s.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let n=this.parseUrl(t),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let n=r[2]||"",s=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),i="",u="",h=s;if(c){let v=c[1];h=c[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",u=g[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,m=f&&f[2]?f[2]:"";return{protocol:n?`${n}:`:"",username:i,password:u,host:h,hostname:d,port:m,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var sn=class At{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof C?r.headers:new C(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new At(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var Ee=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=on(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 on(e){return e?new C(e):new C}p();var Lt=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]"}},an=class{constructor(){this._signal=new Lt}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function ln(e){e.URL=nn,e.URLSearchParams=Pt,e.Headers=C,e.Request=sn,e.Response=Ee,e.AbortController=an,e.AbortSignal=Lt}var It=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(ne),n=new C(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let s=t?.method||"GET";if((s==="POST"||s==="PUT"||s==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:n});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};p();var un="/storage",cn=un+"/generateUploadUrl",Nt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+cn,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new C({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:s}=await n.json();return{url:s.split("?")[0]}}};p();p();p();var $e=Wt(Vt(),1),{PostgrestClient:hn,PostgrestQueryBuilder:On,PostgrestFilterBuilder:Tn,PostgrestTransformBuilder:Sn,PostgrestBuilder:Pn,PostgrestError:Rn}=$e.default||$e,dn="/entities",xt=(e,t)=>new hn(e+dn,{fetch:t.fetchWithAuth.bind(t)});p();var $t=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,n=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(n.status!==200)throw new Error(n.message);return n.data}};p();var Ct=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@ var Mt=Object.create,ie=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,s=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+s}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let l=e.getBoundingClientRect();a.style.left=`${l.left+window.scrollX}px`,a.style.top=`${l.top+window.scrollY-a.offsetHeight-8}px`,l.top<a.offsetHeight+8&&(a.style.top=`${l.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let s=this.createTooltip();t?s.textContent=t:s.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,s.style.display="block";let o=e.getBoundingClientRect();s.style.left=`${o.left+window.scrollX}px`,s.style.top=`${o.top+window.scrollY-s.offsetHeight-8}px`,o.top<s.offsetHeight+8&&(s.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Ct(e="root"){if(typeof document>"u")return null;let t=document.getElementById(e)||document.body;if(!t)return null;let r=t.querySelector("[data-source-location]");if(r){let n=r.getAttribute("data-source-location");if(n)return n}if(t.firstElementChild){let n=t.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}var le=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),n=uni.getStorageSync(r);return n?n.expires&&Date.now()>n.expires?(await this.remove(t),null):n.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,n){try{let s=this.getKey(t),o={value:r,expires:n?Date.now()+n*1e3:null,timestamp:Date.now()};uni.setStorageSync(s,o)}catch(s){throw console.error("UniAppStorageService set error:",s),s}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var dn=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let n=(t?.method||"GET").toUpperCase(),s={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{s[i]=u});else if(Array.isArray(l))for(let[u,i]of l)s[u]=i;else Object.assign(s,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",u(d);return}let c=!1,h=[],y=uni.request({url:r,method:n,data:o,header:s,timeout:a,success:d=>{if(c)return;c=!0;let m=d.statusCode,v="",g=new C,w=d.header||d.headers||{};Object.keys(w).forEach(T=>{let S=w[T];g.set(T,typeof S=="string"?S:String(S))}),l(new Ee(d.data,{status:m,statusText:v,headers:g}))},fail:d=>{if(c)return;c=!0;let m=d?.errMsg||d?.message||"Network Error",v=new Error(m);/(abort|aborted|canceled|cancelled)/i.test(String(m))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(c)return;try{y?.abort?.()}catch{}let m=new Error("The operation was aborted");m.name="AbortError",c=!0,u(m)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})},be=dn;function as(){if(typeof window>"u"||window===window.parent)return;let e=!1,t=new $t;function r(u){let i=u;for(;i;){let c=i.getAttribute("data-source-location");if(c)return c;i=i.parentElement}return null}let n=null;function s(u){e&&(n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let i=u.target;if(!i||i===document.body||i===document.documentElement){t.removeHighlight();return}if(i.tagName.toLowerCase()==="img"){let d=r(i);t.highlightElement(i,d);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:d,elementInfo:{tagName:i.tagName.toLowerCase(),className:i.className||"",id:i.id||""}};window.parent.postMessage(m,"*");return}let c=i,h=r(i);if(!h){let d=i.parentElement;for(;d&&d!==document.body&&d!==document.documentElement;){let m=r(d);if(m){c=d,h=m;break}d=d.parentElement}}t.highlightElement(c,h);let y={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:h,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(y,"*")}))}function o(){if(!e)return;t.removeHighlight();let u={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(u,"*")}function a(u){if(!e)return;u.preventDefault(),u.stopPropagation();let i=u.target;if(!i||i===document.body||i===document.documentElement)return;let c=r(i);t.selectElement(i,c);let h={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:c,elementInfo:{tagName:i.tagName.toLowerCase(),className:i.className||"",id:i.id||""}};window.parent.postMessage(h,"*")}function l(u){u.data?.type==="HOVER_INSPECTOR_ENABLE"?(e=!0,document.addEventListener("mousemove",s),document.addEventListener("mouseleave",o),document.addEventListener("click",a,!0)):u.data?.type==="HOVER_INSPECTOR_DISABLE"&&(e=!1,document.removeEventListener("mousemove",s),document.removeEventListener("mouseleave",o),document.removeEventListener("click",a,!0),t.removeHighlight(),t.clearSelection())}return window.addEventListener("message",l),()=>{window.removeEventListener("message",l),document.removeEventListener("mousemove",s),document.removeEventListener("mouseleave",o),document.removeEventListener("click",a,!0),t.cleanup()}}function is(e,t){if(!e||!e.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};e.contentWindow.postMessage(r,t)}function ls(e,t){if(!e||!e.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};e.contentWindow.postMessage(r,t)}function us(e,t,r=5e3){return new Promise((n,s)=>{if(!e||!e.contentWindow){s(new Error("Invalid iframe element"));return}let o=`source-location-${Date.now()}-${Math.random()}`,a=setTimeout(()=>{window.removeEventListener("message",l),s(new Error("Request timeout"))},r),l=i=>{i.origin===t&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===o&&(clearTimeout(a),window.removeEventListener("message",l),i.data.error?s(new Error(i.data.error)):n(i.data.sourceLocation||null))};window.addEventListener("message",l);let u={type:"GET_SOURCE_LOCATION_REQUEST",requestId:o};try{e.contentWindow.postMessage(u,t)}catch(i){clearTimeout(a),window.removeEventListener("message",l),s(i)}})}function cs(){if(typeof window>"u"||window===window.parent)return;let e=t=>{if(t.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:pn(),requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}catch(r){let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}function pn(){return Ct("app")}var Ut=new le,_e=class{constructor(t,r){this.auth=new _t(t,be,Ut),this.httpClient=new It(Ut,be,r),this.fileStorage=new Lt(t,this.httpClient),this.entities=Nt(t,this.httpClient),this.functions=new Ot(this.httpClient),this.skill=new xt(t,this.httpClient)}};export{_e as default,ls as disableIframeHoverInspector,is as enableIframeHoverInspector,us as getIframeSourceLocation,Ut as localStorage,an as polyfill,as as setupIframeHoverInspector,cs as setupIframeSourceLocationListener};
33
+ `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,s=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+s}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let l=e.getBoundingClientRect();a.style.left=`${l.left+window.scrollX}px`,a.style.top=`${l.top+window.scrollY-a.offsetHeight-8}px`,l.top<a.offsetHeight+8&&(a.style.top=`${l.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let s=this.createTooltip();t?s.textContent=t:s.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,s.style.display="block";let o=e.getBoundingClientRect();s.style.left=`${o.left+window.scrollX}px`,s.style.top=`${o.top+window.scrollY-s.offsetHeight-8}px`,o.top<s.offsetHeight+8&&(s.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Ut(e="root"){if(typeof document>"u")return null;let t=document.getElementById(e)||document.body;if(!t)return null;let r=t.querySelector("[data-source-location]");if(r){let n=r.getAttribute("data-source-location");if(n)return n}if(t.firstElementChild){let n=t.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}var le=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),n=uni.getStorageSync(r);return n?n.expires&&Date.now()>n.expires?(await this.remove(t),null):n.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,n){try{let s=this.getKey(t),o={value:r,expires:n?Date.now()+n*1e3:null,timestamp:Date.now()};uni.setStorageSync(s,o)}catch(s){throw console.error("UniAppStorageService set error:",s),s}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var be=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let n=(t?.method||"GET").toUpperCase(),s={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((c,i)=>{s[i]=c});else if(Array.isArray(l))for(let[c,i]of l)s[c]=i;else Object.assign(s,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let c={};l.forEach((i,u)=>{c[u]=i}),o=c}else o=l}let a=t?.timeout||3e4;return new Promise((l,c)=>{let i=t?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:n,data:o,header:s,timeout:a,success:d=>{if(u)return;u=!0;let m=d.statusCode,v="",g=new C,w=d.header||d.headers||{};Object.keys(w).forEach(T=>{let S=w[T];g.set(T,typeof S=="string"?S:String(S))}),l(new Ee(d.data,{status:m,statusText:v,headers:g}))},fail:d=>{if(u)return;u=!0;let m=d?.errMsg||d?.message||"Network Error",v=new Error(m);/(abort|aborted|canceled|cancelled)/i.test(String(m))&&(v.name="AbortError"),c(v)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let m=new Error("The operation was aborted");m.name="AbortError",u=!0,c(m)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=be);var _e=be;function as(){if(typeof window>"u"||window===window.parent)return;let e=!1,t=new Ct;function r(i){if(!i)return!1;let u=i.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function n(i){let u=i,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let s=null;function o(i){e&&(s!==null&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{let u=i.target;if(!u||u===document.body||u===document.documentElement){t.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let m=n(u);t.highlightElement(u,m);let v={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:m,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(v,"*");return}let h=u,f=n(u);if(!f){let m=u.parentElement;for(;m&&m!==document.body&&m!==document.documentElement;){let v=n(m);if(v){h=m,f=v;break}m=m.parentElement}}t.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function a(){if(!e)return;t.removeHighlight();let i={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(i,"*")}function l(i){if(!e)return;i.preventDefault(),i.stopPropagation();let u=i.target;if(!u||u===document.body||u===document.documentElement)return;let h=n(u);t.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(i){i.data?.type==="HOVER_INSPECTOR_ENABLE"?(e=!0,document.addEventListener("mousemove",o),document.addEventListener("mouseleave",a),document.addEventListener("click",l,!0)):i.data?.type==="HOVER_INSPECTOR_DISABLE"&&(e=!1,document.removeEventListener("mousemove",o),document.removeEventListener("mouseleave",a),document.removeEventListener("click",l,!0),t.removeHighlight(),t.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",o),document.removeEventListener("mouseleave",a),document.removeEventListener("click",l,!0),t.cleanup()}}function is(e,t){if(!e||!e.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};e.contentWindow.postMessage(r,t)}function ls(e,t){if(!e||!e.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};e.contentWindow.postMessage(r,t)}function us(e,t,r=5e3){return new Promise((n,s)=>{if(!e||!e.contentWindow){s(new Error("Invalid iframe element"));return}let o=`source-location-${Date.now()}-${Math.random()}`,a=setTimeout(()=>{window.removeEventListener("message",l),s(new Error("Request timeout"))},r),l=i=>{i.origin===t&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===o&&(clearTimeout(a),window.removeEventListener("message",l),i.data.error?s(new Error(i.data.error)):n(i.data.sourceLocation||null))};window.addEventListener("message",l);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:o};try{e.contentWindow.postMessage(c,t)}catch(i){clearTimeout(a),window.removeEventListener("message",l),s(i)}})}function cs(){if(typeof window>"u"||window===window.parent)return;let e=t=>{if(t.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:pn(),requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}catch(r){let n={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:t.data.requestId};window.parent.postMessage(n,t.origin)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}function pn(){return Ut("app")}var jt=new le,Oe=class{constructor(t,r){this.auth=new Ot(t,_e,jt),this.httpClient=new It(jt,_e,r),this.fileStorage=new Nt(t,this.httpClient),this.entities=xt(t,this.httpClient),this.functions=new Tt(this.httpClient),this.skill=new $t(t,this.httpClient)}};export{Oe as default,ls as disableIframeHoverInspector,is as enableIframeHoverInspector,us as getIframeSourceLocation,jt as localStorage,ln as polyfill,as as setupIframeHoverInspector,cs as setupIframeSourceLocationListener,be as uniappFetch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-uniapp",
3
- "version": "0.10.0",
3
+ "version": "0.10.10",
4
4
  "description": "NVWA跨端通用工具类UniApp端实现",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",