@nvwa-app/sdk-core 6.0.18 → 6.0.20

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
@@ -189,6 +189,10 @@ declare class NvwaCapability {
189
189
  }
190
190
 
191
191
  declare const ENTITIES_BASE_PATH = "/entities";
192
+ /**
193
+ * 创建带鉴权的 PostgREST 客户端。所有请求经 fetchWithAuth 发送,
194
+ * 会从 storage 读取 JWT 并设置 Authorization: Bearer,跨子域/跨域时必须通过此客户端调用 entities。
195
+ */
192
196
  declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient) => PostgrestClient<any, {} | _nvwa_app_postgrest_js.PostgrestClientOptions, "public", any>;
193
197
 
194
198
  /**
@@ -320,9 +324,11 @@ declare class PaymentClient {
320
324
  * Auth 常量与客户端:CURRENT_JWT_KEY 供 NvwaHttpClient 使用;
321
325
  * AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
322
326
  */
323
- declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
324
- declare const LOGIN_TOKEN_KEY = "nvwa_login_token";
325
- declare const LOGIN_USER_PROFILE_KEY = "nvwa_user_profile";
327
+ /** better-auth bearer 插件在登录/注册成功时通过此响应头返回 token */
328
+ declare const SET_AUTH_TOKEN_HEADER = "set-auth-token";
329
+ declare const CURRENT_JWT_KEY = "current_jwt";
330
+ declare const LOGIN_TOKEN_KEY = "login_token";
331
+ declare const LOGIN_USER_PROFILE_KEY = "user_profile";
326
332
  interface AuthUser {
327
333
  id: string;
328
334
  name?: string;
@@ -368,11 +374,17 @@ interface AuthClientOptions {
368
374
  authPath?: string;
369
375
  /** 自定义 fetch,默认全局 fetch */
370
376
  fetchImpl?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
371
- /** 可选本地存储:提供后登录态会持久化,currentUser/getCurrentJwt 优先从存储读取 */
377
+ /** 可选本地存储:提供后登录态会持久化,currentUser/getCurrentJwt 优先从存储读取;与 NvwaHttpClient 共用 */
372
378
  storage?: NvwaLocalStorage;
379
+ /**
380
+ * 请求是否携带 cookie。默认 "omit":鉴权统一用 JWT(storage + Authorization: Bearer),
381
+ * 与 uniapp / 跨子域一致,不依赖 cookie。
382
+ */
383
+ credentials?: RequestCredentials;
373
384
  }
374
385
  /**
375
386
  * 项目侧 Auth 客户端:getSession、登录/登出、currentUser、getCurrentJwt。
387
+ * 鉴权统一使用 JWT(storage + Authorization: Bearer),不使用 cookie;web 与 uniapp 行为一致。
376
388
  * baseUrl 为项目根地址(如 "https://xxx.nvwa.app"),请求发往 baseUrl + authPath。
377
389
  * 传入 storage 时登录态会持久化,currentUser/getCurrentJwt 优先从存储读取(与 NvwaHttpClient 共用 JWT)。
378
390
  */
@@ -381,6 +393,8 @@ declare class AuthClient {
381
393
  private authPath;
382
394
  private fetchImpl;
383
395
  private storage;
396
+ /** 统一 JWT 鉴权,不使用 cookie */
397
+ private credentials;
384
398
  constructor(baseUrl: string, options?: AuthClientOptions);
385
399
  /**
386
400
  * 获取当前用户。有 storage 时优先从本地缓存读取,否则请求 getSession()。
@@ -390,11 +404,14 @@ declare class AuthClient {
390
404
  * 获取当前 JWT。有 storage 时优先从本地缓存读取(与 NvwaHttpClient 共用),否则请求 getToken()。
391
405
  */
392
406
  getCurrentJwt(): Promise<string | null>;
407
+ /**
408
+ * 持久化登录态。优先使用 better-auth 响应头 set-auth-token,否则用 body 中的 token。
409
+ */
393
410
  private persistLogin;
394
411
  private clearLogin;
395
412
  private url;
396
413
  /**
397
- * 获取当前 session(依赖 cookie Authorization header,与 runtime 配置一致)。
414
+ * 获取当前 session。有 storage 时从 storage 取 token 并带 Authorization: Bearer(JWT 鉴权,不带 cookie)。
398
415
  */
399
416
  getSession(): Promise<{
400
417
  data: AuthSession | null;
@@ -414,7 +431,7 @@ declare class AuthClient {
414
431
  };
415
432
  }>;
416
433
  /**
417
- * 登出。
434
+ * 登出。有 storage 时带 Authorization: Bearer 以便服务端识别 session。
418
435
  */
419
436
  signOut(): Promise<{
420
437
  error?: {
@@ -471,4 +488,4 @@ interface INvwa {
471
488
  capability: NvwaCapability;
472
489
  }
473
490
 
474
- export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CapabilityExecuteResponse, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaCapability, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SignUpBody, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
491
+ export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CapabilityExecuteResponse, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaCapability, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
package/dist/index.d.ts CHANGED
@@ -189,6 +189,10 @@ declare class NvwaCapability {
189
189
  }
190
190
 
191
191
  declare const ENTITIES_BASE_PATH = "/entities";
192
+ /**
193
+ * 创建带鉴权的 PostgREST 客户端。所有请求经 fetchWithAuth 发送,
194
+ * 会从 storage 读取 JWT 并设置 Authorization: Bearer,跨子域/跨域时必须通过此客户端调用 entities。
195
+ */
192
196
  declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClient) => PostgrestClient<any, {} | _nvwa_app_postgrest_js.PostgrestClientOptions, "public", any>;
193
197
 
194
198
  /**
@@ -320,9 +324,11 @@ declare class PaymentClient {
320
324
  * Auth 常量与客户端:CURRENT_JWT_KEY 供 NvwaHttpClient 使用;
321
325
  * AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
322
326
  */
323
- declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
324
- declare const LOGIN_TOKEN_KEY = "nvwa_login_token";
325
- declare const LOGIN_USER_PROFILE_KEY = "nvwa_user_profile";
327
+ /** better-auth bearer 插件在登录/注册成功时通过此响应头返回 token */
328
+ declare const SET_AUTH_TOKEN_HEADER = "set-auth-token";
329
+ declare const CURRENT_JWT_KEY = "current_jwt";
330
+ declare const LOGIN_TOKEN_KEY = "login_token";
331
+ declare const LOGIN_USER_PROFILE_KEY = "user_profile";
326
332
  interface AuthUser {
327
333
  id: string;
328
334
  name?: string;
@@ -368,11 +374,17 @@ interface AuthClientOptions {
368
374
  authPath?: string;
369
375
  /** 自定义 fetch,默认全局 fetch */
370
376
  fetchImpl?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
371
- /** 可选本地存储:提供后登录态会持久化,currentUser/getCurrentJwt 优先从存储读取 */
377
+ /** 可选本地存储:提供后登录态会持久化,currentUser/getCurrentJwt 优先从存储读取;与 NvwaHttpClient 共用 */
372
378
  storage?: NvwaLocalStorage;
379
+ /**
380
+ * 请求是否携带 cookie。默认 "omit":鉴权统一用 JWT(storage + Authorization: Bearer),
381
+ * 与 uniapp / 跨子域一致,不依赖 cookie。
382
+ */
383
+ credentials?: RequestCredentials;
373
384
  }
374
385
  /**
375
386
  * 项目侧 Auth 客户端:getSession、登录/登出、currentUser、getCurrentJwt。
387
+ * 鉴权统一使用 JWT(storage + Authorization: Bearer),不使用 cookie;web 与 uniapp 行为一致。
376
388
  * baseUrl 为项目根地址(如 "https://xxx.nvwa.app"),请求发往 baseUrl + authPath。
377
389
  * 传入 storage 时登录态会持久化,currentUser/getCurrentJwt 优先从存储读取(与 NvwaHttpClient 共用 JWT)。
378
390
  */
@@ -381,6 +393,8 @@ declare class AuthClient {
381
393
  private authPath;
382
394
  private fetchImpl;
383
395
  private storage;
396
+ /** 统一 JWT 鉴权,不使用 cookie */
397
+ private credentials;
384
398
  constructor(baseUrl: string, options?: AuthClientOptions);
385
399
  /**
386
400
  * 获取当前用户。有 storage 时优先从本地缓存读取,否则请求 getSession()。
@@ -390,11 +404,14 @@ declare class AuthClient {
390
404
  * 获取当前 JWT。有 storage 时优先从本地缓存读取(与 NvwaHttpClient 共用),否则请求 getToken()。
391
405
  */
392
406
  getCurrentJwt(): Promise<string | null>;
407
+ /**
408
+ * 持久化登录态。优先使用 better-auth 响应头 set-auth-token,否则用 body 中的 token。
409
+ */
393
410
  private persistLogin;
394
411
  private clearLogin;
395
412
  private url;
396
413
  /**
397
- * 获取当前 session(依赖 cookie Authorization header,与 runtime 配置一致)。
414
+ * 获取当前 session。有 storage 时从 storage 取 token 并带 Authorization: Bearer(JWT 鉴权,不带 cookie)。
398
415
  */
399
416
  getSession(): Promise<{
400
417
  data: AuthSession | null;
@@ -414,7 +431,7 @@ declare class AuthClient {
414
431
  };
415
432
  }>;
416
433
  /**
417
- * 登出。
434
+ * 登出。有 storage 时带 Authorization: Bearer 以便服务端识别 session。
418
435
  */
419
436
  signOut(): Promise<{
420
437
  error?: {
@@ -471,4 +488,4 @@ interface INvwa {
471
488
  capability: NvwaCapability;
472
489
  }
473
490
 
474
- export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CapabilityExecuteResponse, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaCapability, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SignUpBody, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
491
+ export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, type CapabilityExecuteResponse, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaCapability, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ae=Object.create;var M=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var vt=(n,t)=>()=>(n&&(t=n(n=0)),t);var E=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),wt=(n,t)=>{for(var e in t)M(n,e,{get:t[e],enumerable:!0})},bt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ue(t))!he.call(n,s)&&s!==e&&M(n,s,{get:()=>t[s],enumerable:!(r=le(t,s))||r.enumerable});return n};var de=(n,t,e)=>(e=n!=null?ae(ce(n)):{},bt(t||!n||!n.__esModule?M(e,"default",{value:n,enumerable:!0}):e,n)),x=n=>bt(M({},"__esModule",{value:!0}),n);var u=vt(()=>{"use strict"});var O={};wt(O,{__addDisposableResource:()=>Wt,__assign:()=>D,__asyncDelegator:()=>Mt,__asyncGenerator:()=>kt,__asyncValues:()=>qt,__await:()=>U,__awaiter:()=>jt,__classPrivateFieldGet:()=>Jt,__classPrivateFieldIn:()=>zt,__classPrivateFieldSet:()=>Gt,__createBinding:()=>F,__decorate:()=>Ot,__disposeResources:()=>Yt,__esDecorate:()=>Rt,__exportStar:()=>It,__extends:()=>Et,__generator:()=>Ct,__importDefault:()=>Ft,__importStar:()=>Bt,__makeTemplateObject:()=>Dt,__metadata:()=>Ut,__param:()=>St,__propKey:()=>$t,__read:()=>V,__rest:()=>xt,__rewriteRelativeImportExtension:()=>Kt,__runInitializers:()=>Tt,__setFunctionName:()=>At,__spread:()=>Lt,__spreadArray:()=>Nt,__spreadArrays:()=>Ht,__values:()=>B,default:()=>ve});function Et(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Y(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function xt(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(e[r[s]]=n[r[s]]);return e}function Ot(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(t,e,i):o(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i}function St(n,t){return function(e,r){t(e,r,n)}}function Rt(n,t,e,r,s,i){function o(P){if(P!==void 0&&typeof P!="function")throw new TypeError("Function expected");return P}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!t&&n?r.static?n:n.prototype:null,h=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,m=!1,p=e.length-1;p>=0;p--){var g={};for(var b in r)g[b]=b==="access"?{}:r[b];for(var b in r.access)g.access[b]=r.access[b];g.addInitializer=function(P){if(m)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(P||null))};var y=(0,e[p])(a==="accessor"?{get:h.get,set:h.set}:h[c],g);if(a==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(d=o(y.get))&&(h.get=d),(d=o(y.set))&&(h.set=d),(d=o(y.init))&&s.unshift(d)}else(d=o(y))&&(a==="field"?s.unshift(d):h[c]=d)}l&&Object.defineProperty(l,r.name,h),m=!0}function Tt(n,t,e){for(var r=arguments.length>2,s=0;s<t.length;s++)e=r?t[s].call(n,e):t[s].call(n);return r?e:void 0}function $t(n){return typeof n=="symbol"?n:"".concat(n)}function At(n,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function Ut(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function jt(n,t,e,r){function s(i){return i instanceof e?i:new e(function(o){o(i)})}return new(e||(e=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function c(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):s(h.value).then(a,c)}l((r=r.apply(n,t||[])).next())})}function Ct(n,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(e=0)),e;)try{if(r=1,s&&(i=l[0]&2?s.return:l[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,l[1])).done)return i;switch(s=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,s=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){e.label=l[1];break}if(l[0]===6&&e.label<i[1]){e.label=i[1],i=l;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(l);break}i[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function It(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&F(t,n,e)}function B(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function V(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return i}function Lt(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(V(arguments[t]));return n}function Ht(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var r=Array(n),s=0,t=0;t<e;t++)for(var i=arguments[t],o=0,a=i.length;o<a;o++,s++)r[s]=i[o];return r}function Nt(n,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return n.concat(i||Array.prototype.slice.call(t))}function U(n){return this instanceof U?(this.v=n,this):new U(n)}function kt(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){r[p]&&(s[p]=function(b){return new Promise(function(y,P){i.push([p,b,y,P])>1||c(p,b)})},g&&(s[p]=g(s[p])))}function c(p,g){try{l(r[p](g))}catch(b){m(i[0][3],b)}}function l(p){p.value instanceof U?Promise.resolve(p.value.v).then(h,d):m(i[0][2],p)}function h(p){c("next",p)}function d(p){c("throw",p)}function m(p,g){p(g),i.shift(),i.length&&c(i[0][0],i[0][1])}}function Mt(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,i){t[s]=n[s]?function(o){return(e=!e)?{value:U(n[s](o)),done:!1}:i?i(o):o}:i}}function qt(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof B=="function"?B(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(i){e[i]=n[i]&&function(o){return new Promise(function(a,c){o=n[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}function Dt(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}function Bt(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=K(n),r=0;r<e.length;r++)e[r]!=="default"&&F(t,n,e[r]);return ge(t,n),t}function Ft(n){return n&&n.__esModule?n:{default:n}}function Jt(n,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(n):r?r.value:t.get(n)}function Gt(n,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,e):s?s.value=e:t.set(n,e),e}function zt(n,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?t===n:n.has(t)}function Wt(n,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,s;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],e&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(i){return Promise.reject(i)}}),n.stack.push({value:t,dispose:r,async:e})}else e&&n.stack.push({async:!0});return t}function Yt(n){function t(i){n.error=n.hasError?new ye(i,n.error,"An error was suppressed during disposal."):i,n.hasError=!0}var e,r=0;function s(){for(;e=n.stack.pop();)try{if(!e.async&&r===1)return r=0,n.stack.push(e),Promise.resolve().then(s);if(e.dispose){var i=e.dispose.call(e.value);if(e.async)return r|=2,Promise.resolve(i).then(s,function(o){return t(o),s()})}else r|=1}catch(o){t(o)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Kt(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,i,o){return r?t?".jsx":".js":s&&(!i||!o)?e:s+i+"."+o.toLowerCase()+"js"}):n}var Y,D,F,ge,K,ye,ve,S=vt(()=>{"use strict";u();Y=function(n,t){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},Y(n,t)};D=function(){return D=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},D.apply(this,arguments)};F=Object.create?(function(n,t,e,r){r===void 0&&(r=e);var s=Object.getOwnPropertyDescriptor(t,e);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(n,r,s)}):(function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]});ge=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},K=function(n){return K=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},K(n)};ye=typeof SuppressedError=="function"?SuppressedError:function(n,t,e){var r=new Error(e);return r.name="SuppressedError",r.error=n,r.suppressed=t,r};ve={__extends:Et,__assign:D,__rest:xt,__decorate:Ot,__param:St,__esDecorate:Rt,__runInitializers:Tt,__propKey:$t,__setFunctionName:At,__metadata:Ut,__awaiter:jt,__generator:Ct,__createBinding:F,__exportStar:It,__values:B,__read:V,__spread:Lt,__spreadArrays:Ht,__spreadArray:Nt,__await:U,__asyncGenerator:kt,__asyncDelegator:Mt,__asyncValues:qt,__makeTemplateObject:Dt,__importStar:Bt,__importDefault:Ft,__classPrivateFieldGet:Jt,__classPrivateFieldSet:Gt,__classPrivateFieldIn:zt,__addDisposableResource:Wt,__disposeResources:Yt,__rewriteRelativeImportExtension:Kt}});var Z=E(X=>{"use strict";u();Object.defineProperty(X,"__esModule",{value:!0});var Q=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}};X.default=Q});var rt=E(et=>{"use strict";u();Object.defineProperty(et,"__esModule",{value:!0});var we=(S(),x(O)),be=we.__importDefault(Z()),tt=class{constructor(t){var e,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){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 r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c,l;let h=null,d=null,m=null,p=i.status,g=i.statusText;if(i.ok){if(this.method!=="HEAD"){let k=await i.text();k===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=k:d=JSON.parse(k))}let y=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),P=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");y&&P&&P.length>1&&(m=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,p=406,g="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let y=await i.text();try{h=JSON.parse(y),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,g="OK")}catch{i.status===404&&y===""?(p=204,g="No Content"):h={message:y}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,g="OK"),h&&this.shouldThrowOnError)throw new be.default(h)}return{error:h,data:d,count:m,status:p,statusText:g}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,c;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=i?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(t,e)}returns(){return this}overrideTypes(){return this}};et.default=tt});var it=E(nt=>{"use strict";u();Object.defineProperty(nt,"__esModule",{value:!0});var Pe=(S(),x(O)),_e=Pe.__importDefault(rt()),st=class extends _e.default{select(t){let e=!1,r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){let i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${t}`),this.url.searchParams.set(o,`${e-t+1}`),this}abortSignal(t){return this.signal=t,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:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;let c=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${c};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};nt.default=st});var J=E(at=>{"use strict";u();Object.defineProperty(at,"__esModule",{value:!0});var Ee=(S(),x(O)),xe=Ee.__importDefault(it()),Oe=new RegExp("[,()]"),ot=class extends xe.default{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}in(t,e){let r=Array.from(new Set(e)).map(s=>typeof s=="string"&&Oe.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${i}fts${o}.${e}`),this}match(t){return Object.entries(t).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}};at.default=ot});var ct=E(ut=>{"use strict";u();Object.defineProperty(ut,"__esModule",{value:!0});var Se=(S(),x(O)),N=Se.__importDefault(J()),lt=class{constructor(t,{headers:e={},schema:r,fetch:s}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s}select(t,e){let{head:r=!1,count:s}=e??{},i=r?"HEAD":"GET",o=!1,a=(t??"*").split("").map(c=>/\s/.test(c)&&!o?"":(c==='"'&&(o=!o),c)).join("");return this.url.searchParams.set("select",a),s&&this.headers.append("Prefer",`count=${s}`),new N.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;let i="POST";if(e&&this.headers.append("Prefer",`count=${e}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let o=t.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){let a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new N.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&this.url.searchParams.set("on_conflict",e),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let c=t.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(c.length>0){let l=[...new Set(c)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new N.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(t,{count:e}={}){var r;let s="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new N.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:t}={}){var e;let r="DELETE";return t&&this.headers.append("Prefer",`count=${t}`),new N.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}};ut.default=lt});var Qt=E(dt=>{"use strict";u();Object.defineProperty(dt,"__esModule",{value:!0});var Vt=(S(),x(O)),Re=Vt.__importDefault(ct()),Te=Vt.__importDefault(J()),ht=class n{constructor(t,{headers:e={},schema:r,fetch:s}={}){this.url=t,this.headers=new Headers(e),this.schemaName=r,this.fetch=s}from(t){let e=new URL(`${this.url}/${t}`);return new Re.default(e,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(t){return new n(this.url,{headers:this.headers,schema:t,fetch:this.fetch})}rpc(t,e={},{head:r=!1,get:s=!1,count:i}={}){var o;let a,c=new URL(`${this.url}/rpc/${t}`),l;r||s?(a=r?"HEAD":"GET",Object.entries(e).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{c.searchParams.append(d,m)})):(a="POST",l=e);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new Te.default({method:a,url:c,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};dt.default=ht});var ne=E(w=>{"use strict";u();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var j=(S(),x(O)),Xt=j.__importDefault(Qt());w.PostgrestClient=Xt.default;var Zt=j.__importDefault(ct());w.PostgrestQueryBuilder=Zt.default;var te=j.__importDefault(J());w.PostgrestFilterBuilder=te.default;var ee=j.__importDefault(it());w.PostgrestTransformBuilder=ee.default;var re=j.__importDefault(rt());w.PostgrestBuilder=re.default;var se=j.__importDefault(Z());w.PostgrestError=se.default;w.default={PostgrestClient:Xt.default,PostgrestQueryBuilder:Zt.default,PostgrestFilterBuilder:te.default,PostgrestTransformBuilder:ee.default,PostgrestBuilder:re.default,PostgrestError:se.default}});var je={};wt(je,{AbortController:()=>H,AbortSignal:()=>A,AuthClient:()=>q,CURRENT_JWT_KEY:()=>_,ENTITIES_BASE_PATH:()=>oe,FILE_STORAGE_BASE_PATH:()=>Pt,GENERATE_UPLOAD_URL_PATH:()=>_t,Headers:()=>v,LOGIN_TOKEN_KEY:()=>R,LOGIN_USER_PROFILE_KEY:()=>T,NvwaCapability:()=>mt,NvwaEdgeFunctions:()=>G,NvwaFileStorage:()=>W,NvwaHttpClient:()=>z,NvwaSkill:()=>ft,OverlayManager:()=>gt,PaymentClient:()=>yt,Request:()=>I,Response:()=>L,URL:()=>C,URLSearchParams:()=>$,createPostgrestClient:()=>$e,getSourceLocationFromDOM:()=>Ae,polyfill:()=>me});module.exports=x(je);u();u();var G=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};u();u();var _="nvwa_current_jwt",R="nvwa_login_token",T="nvwa_user_profile",pe=typeof fetch<"u"?(n,t)=>fetch(n,t):(()=>{throw new Error("AuthClient requires fetch")})(),q=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??pe,this.storage=e.storage??null,typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] AuthClient baseUrl:",this.baseUrl,"authPath:",this.authPath)}async currentUser(){if(this.storage){let r=await this.storage.get(T);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(T,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(_);if(e!=null)return e;let r=await this.storage.get(R),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(_,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t){if(!this.storage)return;let e=t.token??t.session?.token;e&&await this.storage.set(R,e),t.user&&await this.storage.set(T,t.user);let r=e??await this.storage.get(R),{data:s}=await this.getToken(r??void 0);s?.token&&await this.storage.set(_,s.token)}async clearLogin(){this.storage&&(await this.storage.remove(R),await this.storage.remove(T),await this.storage.remove(_))}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",r),r}async getSession(){try{let t=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return t.ok?{data:await t.json()}:{data:null,error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return i&&await this.persistLogin({user:i.user,session:i.session}),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return await this.clearLogin(),t.ok?{}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data),e}async getToken(t){try{let e={};t&&(e.Authorization=`Bearer ${t}`);let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:"include",...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data),r}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.data??i??void 0}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var v=class n{constructor(t){this.headerMap=new Map;if(t){if(t instanceof n)t.forEach((e,r)=>this.set(r,e));else if(Array.isArray(t))for(let[e,r]of t)this.set(e,String(r));else if(typeof t=="object")for(let e of Object.keys(t))this.set(e,String(t[e]))}}append(t,e){let r=t.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${e}`:e)}set(t,e){this.headerMap.set(t.toLowerCase(),String(e))}get(t){let e=this.headerMap.get(t.toLowerCase());return e??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[e,r]of this.headerMap.entries())t(r,e,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},$=class n{constructor(t){this.params=new Map;if(t){if(typeof t=="string")this.parseString(t);else if(t instanceof n)this.params=new Map(t.params);else if(Array.isArray(t))for(let[e,r]of t)this.append(e,r);else if(t&&typeof t=="object")for(let[e,r]of Object.entries(t))this.set(e,r)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let e=t.split("&");for(let r of e)if(r){let[s,i]=r.split("=");s&&this.append(decodeURIComponent(s),i?decodeURIComponent(i):"")}}append(t,e){let r=this.params.get(t)||[];r.push(e),this.params.set(t,r)}delete(t){this.params.delete(t)}get(t){let e=this.params.get(t);return e?e[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,e){this.params.set(t,[e])}sort(){let t=Array.from(this.params.entries()).sort(([e],[r])=>e.localeCompare(r));this.params=new Map(t)}toString(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push(`${encodeURIComponent(e)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[e,r]of this.params.entries())for(let s of r)t(s,e,this)}keys(){return this.params.keys()}values(){let t=[];for(let e of this.params.values())t.push(...e);return t[Symbol.iterator]()}entries(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push([e,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},C=class n{constructor(t,e){let r;if(t instanceof n)r=t.href;else if(e){let i=e instanceof n?e.href:e;r=this.resolve(i,t)}else r=t;let s=this.parseUrl(r);this.href=r,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 $(s.search),this.hash=s.hash}resolve(t,e){if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("//"))return`${this.parseUrl(t).protocol}${e}`;if(e.startsWith("/")){let i=this.parseUrl(t);return`${i.protocol}//${i.host}${e}`}let r=this.parseUrl(t),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${e}`}parseUrl(t){let e=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)throw new TypeError("Invalid URL");let r=e[2]||"",s=e[4]||"",i=e[5]||"/",o=e[7]?`?${e[7]}`:"",a=e[9]?`#${e[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",d=s;if(c){let b=c[1];d=c[2];let y=b.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",h=y[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),p=m?m[1]:d,g=m&&m[2]?m[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:g,pathname:i,search:o,hash:a}}toString(){let t=this.searchParams.toString(),e=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${e}${this.hash}`}toJSON(){return this.toString()}};u();var I=class n{constructor(t,e){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=(e?.method||"GET").toUpperCase(),this.headers=e?.headers instanceof v?e.headers:new v(e?.headers),this.body=e?.body,this.timeout=e?.timeout,this.signal=e?.signal||void 0}clone(){return new n(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var L=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=fe(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function fe(n){return n?new v(n):new v}u();var A=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},H=class{constructor(){this._signal=new A}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function me(n){n.URL=C,n.URLSearchParams=$,n.Headers=v,n.Request=I,n.Response=L,n.AbortController=H,n.AbortSignal=A}var z=class{constructor(t,e,r){console.log("NvwaHttpClient constructor",t,e,r),this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(_),s=new v(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=e?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&e?.body){let a=s.get("Content-Type");(!a||a.includes("text/plain"))&&s.set("Content-Type","application/json")}let o=await this.customFetch(t,{...e,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};u();var Pt="/storage",_t=Pt+"/generateUploadUrl",W=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+_t,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new v({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var pt=de(ne(),1),{PostgrestClient:ie,PostgrestQueryBuilder:Nr,PostgrestFilterBuilder:kr,PostgrestTransformBuilder:Mr,PostgrestBuilder:qr,PostgrestError:Dr}=pt.default||pt;var oe="/entities",$e=(n,t)=>new ie(n+oe,{fetch:t.fetchWithAuth.bind(t)});u();var ft=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var mt=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var gt=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 t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
1
+ "use strict";var lt=Object.create;var M=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var ht=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty;var we=(n,e)=>()=>(n&&(e=n(n=0)),e);var x=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),be=(n,e)=>{for(var t in e)M(n,t,{get:e[t],enumerable:!0})},Pe=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ct(e))!dt.call(n,s)&&s!==t&&M(n,s,{get:()=>e[s],enumerable:!(r=ut(e,s))||r.enumerable});return n};var pt=(n,e,t)=>(t=n!=null?lt(ht(n)):{},Pe(e||!n||!n.__esModule?M(t,"default",{value:n,enumerable:!0}):t,n)),O=n=>Pe(M({},"__esModule",{value:!0}),n);var u=we(()=>{"use strict"});var R={};be(R,{__addDisposableResource:()=>Ke,__assign:()=>B,__asyncDelegator:()=>Me,__asyncGenerator:()=>qe,__asyncValues:()=>De,__await:()=>j,__awaiter:()=>Ce,__classPrivateFieldGet:()=>Je,__classPrivateFieldIn:()=>We,__classPrivateFieldSet:()=>Ge,__createBinding:()=>z,__decorate:()=>Se,__disposeResources:()=>Ye,__esDecorate:()=>Te,__exportStar:()=>Ie,__extends:()=>xe,__generator:()=>He,__importDefault:()=>ze,__importStar:()=>Fe,__makeTemplateObject:()=>Be,__metadata:()=>je,__param:()=>Re,__propKey:()=>Ae,__read:()=>Q,__rest:()=>Oe,__rewriteRelativeImportExtension:()=>Ve,__runInitializers:()=>$e,__setFunctionName:()=>Ue,__spread:()=>Le,__spreadArray:()=>ke,__spreadArrays:()=>Ne,__values:()=>F,default:()=>wt});function xe(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Y(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oe(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function Se(n,e,t,r){var s=arguments.length,i=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(e,t,i):o(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i}function Re(n,e){return function(t,r){e(t,r,n)}}function Te(n,e,t,r,s,i){function o(P){if(P!==void 0&&typeof P!="function")throw new TypeError("Function expected");return P}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&n?r.static?n:n.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,m=!1,p=t.length-1;p>=0;p--){var g={};for(var b in r)g[b]=b==="access"?{}:r[b];for(var b in r.access)g.access[b]=r.access[b];g.addInitializer=function(P){if(m)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(P||null))};var y=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[c],g);if(a==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(d=o(y.get))&&(h.get=d),(d=o(y.set))&&(h.set=d),(d=o(y.init))&&s.unshift(d)}else(d=o(y))&&(a==="field"?s.unshift(d):h[c]=d)}l&&Object.defineProperty(l,r.name,h),m=!0}function $e(n,e,t){for(var r=arguments.length>2,s=0;s<e.length;s++)t=r?e[s].call(n,t):e[s].call(n);return r?t:void 0}function Ae(n){return typeof n=="symbol"?n:"".concat(n)}function Ue(n,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function je(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function Ce(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function c(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):s(h.value).then(a,c)}l((r=r.apply(n,e||[])).next())})}function He(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,s&&(i=l[0]&2?s.return:l[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,l[1])).done)return i;switch(s=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(h){l=[6,h],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Ie(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&z(e,n,t)}function F(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Le(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(Q(arguments[e]));return n}function Ne(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),s=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,s++)r[s]=i[o];return r}function ke(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}function j(n){return this instanceof j?(this.v=n,this):new j(n)}function qe(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){r[p]&&(s[p]=function(b){return new Promise(function(y,P){i.push([p,b,y,P])>1||c(p,b)})},g&&(s[p]=g(s[p])))}function c(p,g){try{l(r[p](g))}catch(b){m(i[0][3],b)}}function l(p){p.value instanceof j?Promise.resolve(p.value.v).then(h,d):m(i[0][2],p)}function h(p){c("next",p)}function d(p){c("throw",p)}function m(p,g){p(g),i.shift(),i.length&&c(i[0][0],i[0][1])}}function Me(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:j(n[s](o)),done:!1}:i?i(o):o}:i}}function De(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof F=="function"?F(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,c){o=n[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}function Be(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function Fe(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t=V(n),r=0;r<t.length;r++)t[r]!=="default"&&z(e,n,t[r]);return yt(e,n),e}function ze(n){return n&&n.__esModule?n:{default:n}}function Je(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}function Ge(n,e,t,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}function We(n,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?e===n:n.has(e)}function Ke(n,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(i){return Promise.reject(i)}}),n.stack.push({value:e,dispose:r,async:t})}else t&&n.stack.push({async:!0});return e}function Ye(n){function e(i){n.error=n.hasError?new vt(i,n.error,"An error was suppressed during disposal."):i,n.hasError=!0}var t,r=0;function s(){for(;t=n.stack.pop();)try{if(!t.async&&r===1)return r=0,n.stack.push(t),Promise.resolve().then(s);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(s,function(o){return e(o),s()})}else r|=1}catch(o){e(o)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Ve(n,e){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,s,i,o){return r?e?".jsx":".js":s&&(!i||!o)?t:s+i+"."+o.toLowerCase()+"js"}):n}var Y,B,z,yt,V,vt,wt,T=we(()=>{"use strict";u();Y=function(n,e){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},Y(n,e)};B=function(){return B=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},B.apply(this,arguments)};z=Object.create?(function(n,e,t,r){r===void 0&&(r=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,r,s)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]});yt=Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e},V=function(n){return V=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},V(n)};vt=typeof SuppressedError=="function"?SuppressedError:function(n,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=n,r.suppressed=e,r};wt={__extends:xe,__assign:B,__rest:Oe,__decorate:Se,__param:Re,__esDecorate:Te,__runInitializers:$e,__propKey:Ae,__setFunctionName:Ue,__metadata:je,__awaiter:Ce,__generator:He,__createBinding:z,__exportStar:Ie,__values:F,__read:Q,__spread:Le,__spreadArrays:Ne,__spreadArray:ke,__await:j,__asyncGenerator:qe,__asyncDelegator:Me,__asyncValues:De,__makeTemplateObject:Be,__importStar:Fe,__importDefault:ze,__classPrivateFieldGet:Je,__classPrivateFieldSet:Ge,__classPrivateFieldIn:We,__addDisposableResource:Ke,__disposeResources:Ye,__rewriteRelativeImportExtension:Ve}});var ee=x(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var X=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Z.default=X});var se=x(re=>{"use strict";u();Object.defineProperty(re,"__esModule",{value:!0});var bt=(T(),O(R)),Pt=bt.__importDefault(ee()),te=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c,l;let h=null,d=null,m=null,p=i.status,g=i.statusText;if(i.ok){if(this.method!=="HEAD"){let q=await i.text();q===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=q:d=JSON.parse(q))}let y=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),P=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");y&&P&&P.length>1&&(m=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,p=406,g="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let y=await i.text();try{h=JSON.parse(y),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,g="OK")}catch{i.status===404&&y===""?(p=204,g="No Content"):h={message:y}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,g="OK"),h&&this.shouldThrowOnError)throw new Pt.default(h)}return{error:h,data:d,count:m,status:p,statusText:g}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,c;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=i?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};re.default=te});var oe=x(ie=>{"use strict";u();Object.defineProperty(ie,"__esModule",{value:!0});var _t=(T(),O(R)),Et=_t.__importDefault(se()),ne=class extends Et.default{select(e){let t=!1,r=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${c};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};ie.default=ne});var J=x(le=>{"use strict";u();Object.defineProperty(le,"__esModule",{value:!0});var xt=(T(),O(R)),Ot=xt.__importDefault(oe()),St=new RegExp("[,()]"),ae=class extends Ot.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(s=>typeof s=="string"&&St.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};le.default=ae});var he=x(ce=>{"use strict";u();Object.defineProperty(ce,"__esModule",{value:!0});var Rt=(T(),O(R)),k=Rt.__importDefault(J()),ue=class{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s}select(e,t){let{head:r=!1,count:s}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!o?"":(c==='"'&&(o=!o),c)).join("");return this.url.searchParams.set("select",a),s&&this.headers.append("Prefer",`count=${s}`),new k.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){let a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new k.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(c.length>0){let l=[...new Set(c)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new k.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new k.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new k.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};ce.default=ue});var Xe=x(pe=>{"use strict";u();Object.defineProperty(pe,"__esModule",{value:!0});var Qe=(T(),O(R)),Tt=Qe.__importDefault(he()),$t=Qe.__importDefault(J()),de=class n{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new Tt.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new n(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:s=!1,count:i}={}){var o;let a,c=new URL(`${this.url}/rpc/${e}`),l;r||s?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{c.searchParams.append(d,m)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new $t.default({method:a,url:c,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};pe.default=de});var it=x(w=>{"use strict";u();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var C=(T(),O(R)),Ze=C.__importDefault(Xe());w.PostgrestClient=Ze.default;var et=C.__importDefault(he());w.PostgrestQueryBuilder=et.default;var tt=C.__importDefault(J());w.PostgrestFilterBuilder=tt.default;var rt=C.__importDefault(oe());w.PostgrestTransformBuilder=rt.default;var st=C.__importDefault(se());w.PostgrestBuilder=st.default;var nt=C.__importDefault(ee());w.PostgrestError=nt.default;w.default={PostgrestClient:Ze.default,PostgrestQueryBuilder:et.default,PostgrestFilterBuilder:tt.default,PostgrestTransformBuilder:rt.default,PostgrestBuilder:st.default,PostgrestError:nt.default}});var Ct={};be(Ct,{AbortController:()=>N,AbortSignal:()=>U,AuthClient:()=>D,CURRENT_JWT_KEY:()=>_,ENTITIES_BASE_PATH:()=>at,FILE_STORAGE_BASE_PATH:()=>_e,GENERATE_UPLOAD_URL_PATH:()=>Ee,Headers:()=>v,LOGIN_TOKEN_KEY:()=>E,LOGIN_USER_PROFILE_KEY:()=>$,NvwaCapability:()=>ge,NvwaEdgeFunctions:()=>G,NvwaFileStorage:()=>K,NvwaHttpClient:()=>W,NvwaSkill:()=>me,OverlayManager:()=>ye,PaymentClient:()=>ve,Request:()=>I,Response:()=>L,SET_AUTH_TOKEN_HEADER:()=>S,URL:()=>H,URLSearchParams:()=>A,createPostgrestClient:()=>At,getSourceLocationFromDOM:()=>Ut,polyfill:()=>gt});module.exports=O(Ct);u();u();var G=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};u();u();var S="set-auth-token",_="current_jwt",E="login_token",$="user_profile",ft=typeof fetch<"u"?(n,e)=>fetch(n,e):(()=>{throw new Error("AuthClient requires fetch")})(),D=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??ft,this.storage=t.storage??null,this.credentials=t.credentials??"omit"}async currentUser(){if(this.storage){let r=await this.storage.get($);if(r!=null)return r}let{data:e}=await this.getSession(),t=e?.user??null;return t&&this.storage&&await this.storage.set($,t),t}async getCurrentJwt(){if(this.storage){let t=await this.storage.get(_);if(t!=null)return t;let r=await this.storage.get(E),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(_,s.token),s.token):null}let{data:e}=await this.getToken();return e?.token??null}async persistLogin(e,t){if(!this.storage)return;let r=t?.trim()&&t||e.token||e.session?.token;r&&await this.storage.set(E,r),e.user&&await this.storage.set($,e.user);let s=r??await this.storage.get(E),{data:i}=await this.getToken(s??void 0);i?.token&&await this.storage.set(_,i.token)}async clearLogin(){this.storage&&(await this.storage.remove(E),await this.storage.remove($),await this.storage.remove(_))}url(e){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${e.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",r),r}async getSession(){try{let e={};if(this.storage){let s=await this.storage.get(E)??await this.storage.get(_);s!=null&&(e.Authorization=`Bearer ${s}`)}let t=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return t.ok?{data:await t.json()}:{data:null,error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:e,password:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0,o=r.headers.get(S);return i&&await this.persistLogin({user:i.user,session:i.session},o),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e={};if(this.storage){let r=await this.storage.get(E)??await this.storage.get(_);r!=null&&(e.Authorization=`Bearer ${r}`)}let t=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return await this.clearLogin(),t.ok?{}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signUp(e){let t=await this.postJson("sign-up/email",e),r=t.response?.headers.get(S);return t.data&&await this.persistLogin(t.data,r??void 0),t}async getToken(e){try{let t={};if(e)t.Authorization=`Bearer ${e}`;else if(this.storage){let o=await this.storage.get(E)??await this.storage.get(_);o!=null&&(t.Authorization=`Bearer ${o}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithUsername(e,t){let r=await this.postJson("sign-in/username",{username:e,password:t}),s=r.response?.headers.get(S);return r.data&&await this.persistLogin(r.data,s??void 0),r}async signInWithPhoneNumber(e,t,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:e,password:t,rememberMe:r}),i=s.response?.headers.get(S);return s.data&&await this.persistLogin(s.data,i??void 0),s}async sendPhoneNumberOtp(e){let t=await this.postJson("phone-number/send-otp",{phoneNumber:e});return t.error?{error:t.error}:{}}async verifyPhoneNumber(e,t){let r=await this.postJson("phone-number/verify",{phoneNumber:e,code:t}),s=r.response?.headers.get(S);return r.data&&await this.persistLogin(r.data,s??void 0),r}async postJson(e,t){try{let r=await this.fetchImpl(this.url(e),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(t)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.data??i??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var v=class n{constructor(e){this.headerMap=new Map;if(e){if(e instanceof n)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},A=class n{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof n)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[s,i]=r.split("=");s&&this.append(decodeURIComponent(s),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let s of r)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},H=class n{constructor(e,t){let r;if(e instanceof n)r=e.href;else if(t){let i=t instanceof n?t.href:t;r=this.resolve(i,e)}else r=e;let s=this.parseUrl(r);this.href=r,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 A(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",s=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",d=s;if(c){let b=c[1];d=c[2];let y=b.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",h=y[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),p=m?m[1]:d,g=m&&m[2]?m[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:g,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};u();var I=class n{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof v?t.headers:new v(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new n(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var L=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=mt(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 mt(n){return n?new v(n):new v}u();var U=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]"}},N=class{constructor(){this._signal=new U}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function gt(n){n.URL=H,n.URLSearchParams=A,n.Headers=v,n.Request=I,n.Response=L,n.AbortController=N,n.AbortSignal=U}var W=class{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(_),s=new v(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=s.get("Content-Type");(!a||a.includes("text/plain"))&&s.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};u();var _e="/storage",Ee=_e+"/generateUploadUrl",K=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Ee,{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 s=await this.http.fetch(r,{method:"PUT",body:e,headers:new v({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var fe=pt(it(),1),{PostgrestClient:ot,PostgrestQueryBuilder:kr,PostgrestFilterBuilder:qr,PostgrestTransformBuilder:Mr,PostgrestBuilder:Dr,PostgrestError:Br}=fe.default||fe;var at="/entities",At=(n,e)=>new ot(n+at,{fetch:e.fetchWithAuth.bind(e)});u();var me=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var ge=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t!=null?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var ye=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(t)}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(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+i}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let a=this.createTooltip();e?a.textContent=e:a.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let c=t.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.style.top=`${c.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let i=this.createTooltip();e?i.textContent=e:i.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=t.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}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 t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function Ae(n="root"){if(typeof document>"u")return null;let t=document.getElementById(n)||document.body;if(!t)return null;let e=t.querySelector("[data-source-location]");if(e){let r=e.getAttribute("data-source-location");if(r)return r}if(t.firstElementChild){let s=t.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();var Ue=typeof fetch<"u"?(n,t)=>fetch(n,t):(()=>{throw new Error("payment client requires fetch")})(),yt=class{constructor(t,e="/payment",r=Ue){this.baseUrl=t;this.pathPrefix=e;this.fetchImpl=r}async rpc(t,e){let r=this.baseUrl.replace(/\/$/,""),s=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${s}/${t}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})});if(!o.ok){let a=await o.text();throw new Error(`${t} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(t){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=t?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(t){let e=await this.rpc("createOrder",{amount:t.amount,subject:t.subject,currency:t.currency??"cny",providerId:t.providerId,metadata:t.metadata});if(e.orderId==null)throw new Error("createPayment: missing orderId in response");return e}async queryOrder(t){let e=await this.rpc("getOrder",{orderId:t});return{orderId:e.orderId??t,status:e.status??"pending",order:e.order}}async cancelOrder(t){await this.rpc("cancelOrder",{orderId:t})}};0&&(module.exports={AbortController,AbortSignal,AuthClient,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaCapability,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,OverlayManager,PaymentClient,Request,Response,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill});
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(),s=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+s}px`,e.style.top=`${r.top+i}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 c=e.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.style.top=`${c.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 s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let i=this.createTooltip();t?i.textContent=t:i.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=e.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.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 s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}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(n="root"){if(typeof document>"u")return null;let e=document.getElementById(n)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();var jt=typeof fetch<"u"?(n,e)=>fetch(n,e):(()=>{throw new Error("payment client requires fetch")})(),ve=class{constructor(e,t="/payment",r=jt){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}async rpc(e,t){let r=this.baseUrl.replace(/\/$/,""),s=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${s}/${e}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){let a=await o.text();throw new Error(`${e} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(e){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=e?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(e){let t=await this.rpc("createOrder",{amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata});if(t.orderId==null)throw new Error("createPayment: missing orderId in response");return t}async queryOrder(e){let t=await this.rpc("getOrder",{orderId:e});return{orderId:t.orderId??e,status:t.status??"pending",order:t.order}}async cancelOrder(e){await this.rpc("cancelOrder",{orderId:e})}};0&&(module.exports={AbortController,AbortSignal,AuthClient,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaCapability,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,OverlayManager,PaymentClient,Request,Response,SET_AUTH_TOKEN_HEADER,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var ne=Object.create;var H=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var dt=(n,t)=>()=>(n&&(t=n(n=0)),t);var E=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),ue=(n,t)=>{for(var e in t)H(n,e,{get:t[e],enumerable:!0})},pt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!le.call(n,s)&&s!==e&&H(n,s,{get:()=>t[s],enumerable:!(r=ie(t,s))||r.enumerable});return n};var ce=(n,t,e)=>(e=n!=null?ne(ae(n)):{},pt(t||!n||!n.__esModule?H(e,"default",{value:n,enumerable:!0}):e,n)),R=n=>pt(H({},"__esModule",{value:!0}),n);import je from"path";import{fileURLToPath as Le}from"url";var u=dt(()=>{"use strict"});var O={};ue(O,{__addDisposableResource:()=>Dt,__assign:()=>D,__asyncDelegator:()=>Ct,__asyncGenerator:()=>jt,__asyncValues:()=>Lt,__await:()=>T,__awaiter:()=>St,__classPrivateFieldGet:()=>kt,__classPrivateFieldIn:()=>Mt,__classPrivateFieldSet:()=>qt,__createBinding:()=>F,__decorate:()=>wt,__disposeResources:()=>Bt,__esDecorate:()=>Pt,__exportStar:()=>Tt,__extends:()=>yt,__generator:()=>Rt,__importDefault:()=>Nt,__importStar:()=>Ht,__makeTemplateObject:()=>It,__metadata:()=>Ot,__param:()=>bt,__propKey:()=>Et,__read:()=>Y,__rest:()=>vt,__rewriteRelativeImportExtension:()=>Ft,__runInitializers:()=>_t,__setFunctionName:()=>xt,__spread:()=>$t,__spreadArray:()=>Ut,__spreadArrays:()=>At,__values:()=>B,default:()=>ye});function yt(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");z(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function vt(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(e[r[s]]=n[r[s]]);return e}function wt(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(t,e,i):o(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i}function bt(n,t){return function(e,r){t(e,r,n)}}function Pt(n,t,e,r,s,i){function o(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!t&&n?r.static?n:n.prototype:null,h=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,g=!1,p=e.length-1;p>=0;p--){var y={};for(var b in r)y[b]=b==="access"?{}:r[b];for(var b in r.access)y.access[b]=r.access[b];y.addInitializer=function(_){if(g)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(_||null))};var v=(0,e[p])(a==="accessor"?{get:h.get,set:h.set}:h[c],y);if(a==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(d=o(v.get))&&(h.get=d),(d=o(v.set))&&(h.set=d),(d=o(v.init))&&s.unshift(d)}else(d=o(v))&&(a==="field"?s.unshift(d):h[c]=d)}l&&Object.defineProperty(l,r.name,h),g=!0}function _t(n,t,e){for(var r=arguments.length>2,s=0;s<t.length;s++)e=r?t[s].call(n,e):t[s].call(n);return r?e:void 0}function Et(n){return typeof n=="symbol"?n:"".concat(n)}function xt(n,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function Ot(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function St(n,t,e,r){function s(i){return i instanceof e?i:new e(function(o){o(i)})}return new(e||(e=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function c(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):s(h.value).then(a,c)}l((r=r.apply(n,t||[])).next())})}function Rt(n,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(e=0)),e;)try{if(r=1,s&&(i=l[0]&2?s.return:l[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,l[1])).done)return i;switch(s=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,s=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){e.label=l[1];break}if(l[0]===6&&e.label<i[1]){e.label=i[1],i=l;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(l);break}i[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Tt(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&F(t,n,e)}function B(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Y(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return i}function $t(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(Y(arguments[t]));return n}function At(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var r=Array(n),s=0,t=0;t<e;t++)for(var i=arguments[t],o=0,a=i.length;o<a;o++,s++)r[s]=i[o];return r}function Ut(n,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return n.concat(i||Array.prototype.slice.call(t))}function T(n){return this instanceof T?(this.v=n,this):new T(n)}function jt(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(s[p]=function(b){return new Promise(function(v,_){i.push([p,b,v,_])>1||c(p,b)})},y&&(s[p]=y(s[p])))}function c(p,y){try{l(r[p](y))}catch(b){g(i[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(h,d):g(i[0][2],p)}function h(p){c("next",p)}function d(p){c("throw",p)}function g(p,y){p(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function Ct(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,i){t[s]=n[s]?function(o){return(e=!e)?{value:T(n[s](o)),done:!1}:i?i(o):o}:i}}function Lt(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof B=="function"?B(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(i){e[i]=n[i]&&function(o){return new Promise(function(a,c){o=n[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}function It(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}function Ht(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=W(n),r=0;r<e.length;r++)e[r]!=="default"&&F(t,n,e[r]);return me(t,n),t}function Nt(n){return n&&n.__esModule?n:{default:n}}function kt(n,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(n):r?r.value:t.get(n)}function qt(n,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,e):s?s.value=e:t.set(n,e),e}function Mt(n,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?t===n:n.has(t)}function Dt(n,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,s;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],e&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(i){return Promise.reject(i)}}),n.stack.push({value:t,dispose:r,async:e})}else e&&n.stack.push({async:!0});return t}function Bt(n){function t(i){n.error=n.hasError?new ge(i,n.error,"An error was suppressed during disposal."):i,n.hasError=!0}var e,r=0;function s(){for(;e=n.stack.pop();)try{if(!e.async&&r===1)return r=0,n.stack.push(e),Promise.resolve().then(s);if(e.dispose){var i=e.dispose.call(e.value);if(e.async)return r|=2,Promise.resolve(i).then(s,function(o){return t(o),s()})}else r|=1}catch(o){t(o)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Ft(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,i,o){return r?t?".jsx":".js":s&&(!i||!o)?e:s+i+"."+o.toLowerCase()+"js"}):n}var z,D,F,me,W,ge,ye,S=dt(()=>{"use strict";u();z=function(n,t){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},z(n,t)};D=function(){return D=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},D.apply(this,arguments)};F=Object.create?(function(n,t,e,r){r===void 0&&(r=e);var s=Object.getOwnPropertyDescriptor(t,e);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(n,r,s)}):(function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]});me=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},W=function(n){return W=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},W(n)};ge=typeof SuppressedError=="function"?SuppressedError:function(n,t,e){var r=new Error(e);return r.name="SuppressedError",r.error=n,r.suppressed=t,r};ye={__extends:yt,__assign:D,__rest:vt,__decorate:wt,__param:bt,__esDecorate:Pt,__runInitializers:_t,__propKey:Et,__setFunctionName:xt,__metadata:Ot,__awaiter:St,__generator:Rt,__createBinding:F,__exportStar:Tt,__values:B,__read:Y,__spread:$t,__spreadArrays:At,__spreadArray:Ut,__await:T,__asyncGenerator:jt,__asyncDelegator:Ct,__asyncValues:Lt,__makeTemplateObject:It,__importStar:Ht,__importDefault:Nt,__classPrivateFieldGet:kt,__classPrivateFieldSet:qt,__classPrivateFieldIn:Mt,__addDisposableResource:Dt,__disposeResources:Bt,__rewriteRelativeImportExtension:Ft}});var Q=E(V=>{"use strict";u();Object.defineProperty(V,"__esModule",{value:!0});var K=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}};V.default=K});var tt=E(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var ve=(S(),R(O)),we=ve.__importDefault(Q()),X=class{constructor(t){var e,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){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 r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c,l;let h=null,d=null,g=null,p=i.status,y=i.statusText;if(i.ok){if(this.method!=="HEAD"){let I=await i.text();I===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=I:d=JSON.parse(I))}let v=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");v&&_&&_.length>1&&(g=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,g=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let v=await i.text();try{h=JSON.parse(v),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,y="OK")}catch{i.status===404&&v===""?(p=204,y="No Content"):h={message:v}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,y="OK"),h&&this.shouldThrowOnError)throw new we.default(h)}return{error:h,data:d,count:g,status:p,statusText:y}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,c;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=i?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(t,e)}returns(){return this}overrideTypes(){return this}};Z.default=X});var st=E(rt=>{"use strict";u();Object.defineProperty(rt,"__esModule",{value:!0});var be=(S(),R(O)),Pe=be.__importDefault(tt()),et=class extends Pe.default{select(t){let e=!1,r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){let i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${t}`),this.url.searchParams.set(o,`${e-t+1}`),this}abortSignal(t){return this.signal=t,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:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;let c=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${c};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};rt.default=et});var J=E(it=>{"use strict";u();Object.defineProperty(it,"__esModule",{value:!0});var _e=(S(),R(O)),Ee=_e.__importDefault(st()),xe=new RegExp("[,()]"),nt=class extends Ee.default{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}in(t,e){let r=Array.from(new Set(e)).map(s=>typeof s=="string"&&xe.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${i}fts${o}.${e}`),this}match(t){return Object.entries(t).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}};it.default=nt});var lt=E(at=>{"use strict";u();Object.defineProperty(at,"__esModule",{value:!0});var Oe=(S(),R(O)),L=Oe.__importDefault(J()),ot=class{constructor(t,{headers:e={},schema:r,fetch:s}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s}select(t,e){let{head:r=!1,count:s}=e??{},i=r?"HEAD":"GET",o=!1,a=(t??"*").split("").map(c=>/\s/.test(c)&&!o?"":(c==='"'&&(o=!o),c)).join("");return this.url.searchParams.set("select",a),s&&this.headers.append("Prefer",`count=${s}`),new L.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;let i="POST";if(e&&this.headers.append("Prefer",`count=${e}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let o=t.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){let a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new L.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&this.url.searchParams.set("on_conflict",e),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(t)){let c=t.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(c.length>0){let l=[...new Set(c)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new L.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(t,{count:e}={}){var r;let s="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new L.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:t}={}){var e;let r="DELETE";return t&&this.headers.append("Prefer",`count=${t}`),new L.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}};at.default=ot});var Gt=E(ct=>{"use strict";u();Object.defineProperty(ct,"__esModule",{value:!0});var Jt=(S(),R(O)),Se=Jt.__importDefault(lt()),Re=Jt.__importDefault(J()),ut=class n{constructor(t,{headers:e={},schema:r,fetch:s}={}){this.url=t,this.headers=new Headers(e),this.schemaName=r,this.fetch=s}from(t){let e=new URL(`${this.url}/${t}`);return new Se.default(e,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(t){return new n(this.url,{headers:this.headers,schema:t,fetch:this.fetch})}rpc(t,e={},{head:r=!1,get:s=!1,count:i}={}){var o;let a,c=new URL(`${this.url}/rpc/${t}`),l;r||s?(a=r?"HEAD":"GET",Object.entries(e).filter(([d,g])=>g!==void 0).map(([d,g])=>[d,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([d,g])=>{c.searchParams.append(d,g)})):(a="POST",l=e);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new Re.default({method:a,url:c,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};ct.default=ut});var Xt=E(w=>{"use strict";u();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var $=(S(),R(O)),zt=$.__importDefault(Gt());w.PostgrestClient=zt.default;var Wt=$.__importDefault(lt());w.PostgrestQueryBuilder=Wt.default;var Yt=$.__importDefault(J());w.PostgrestFilterBuilder=Yt.default;var Kt=$.__importDefault(st());w.PostgrestTransformBuilder=Kt.default;var Vt=$.__importDefault(tt());w.PostgrestBuilder=Vt.default;var Qt=$.__importDefault(Q());w.PostgrestError=Qt.default;w.default={PostgrestClient:zt.default,PostgrestQueryBuilder:Wt.default,PostgrestFilterBuilder:Yt.default,PostgrestTransformBuilder:Kt.default,PostgrestBuilder:Vt.default,PostgrestError:Qt.default}});u();u();var ft=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};u();u();var x="nvwa_current_jwt",A="nvwa_login_token",U="nvwa_user_profile",he=typeof fetch<"u"?(n,t)=>fetch(n,t):(()=>{throw new Error("AuthClient requires fetch")})(),G=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??he,this.storage=e.storage??null,typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] AuthClient baseUrl:",this.baseUrl,"authPath:",this.authPath)}async currentUser(){if(this.storage){let r=await this.storage.get(U);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(U,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(x);if(e!=null)return e;let r=await this.storage.get(A),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(x,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t){if(!this.storage)return;let e=t.token??t.session?.token;e&&await this.storage.set(A,e),t.user&&await this.storage.set(U,t.user);let r=e??await this.storage.get(A),{data:s}=await this.getToken(r??void 0);s?.token&&await this.storage.set(x,s.token)}async clearLogin(){this.storage&&(await this.storage.remove(A),await this.storage.remove(U),await this.storage.remove(x))}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",r),r}async getSession(){try{let t=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return t.ok?{data:await t.json()}:{data:null,error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return i&&await this.persistLogin({user:i.user,session:i.session}),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return await this.clearLogin(),t.ok?{}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data),e}async getToken(t){try{let e={};t&&(e.Authorization=`Bearer ${t}`);let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:"include",...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data),r}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.data??i??void 0}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var P=class n{constructor(t){this.headerMap=new Map;if(t){if(t instanceof n)t.forEach((e,r)=>this.set(r,e));else if(Array.isArray(t))for(let[e,r]of t)this.set(e,String(r));else if(typeof t=="object")for(let e of Object.keys(t))this.set(e,String(t[e]))}}append(t,e){let r=t.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${e}`:e)}set(t,e){this.headerMap.set(t.toLowerCase(),String(e))}get(t){let e=this.headerMap.get(t.toLowerCase());return e??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[e,r]of this.headerMap.entries())t(r,e,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},j=class n{constructor(t){this.params=new Map;if(t){if(typeof t=="string")this.parseString(t);else if(t instanceof n)this.params=new Map(t.params);else if(Array.isArray(t))for(let[e,r]of t)this.append(e,r);else if(t&&typeof t=="object")for(let[e,r]of Object.entries(t))this.set(e,r)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let e=t.split("&");for(let r of e)if(r){let[s,i]=r.split("=");s&&this.append(decodeURIComponent(s),i?decodeURIComponent(i):"")}}append(t,e){let r=this.params.get(t)||[];r.push(e),this.params.set(t,r)}delete(t){this.params.delete(t)}get(t){let e=this.params.get(t);return e?e[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,e){this.params.set(t,[e])}sort(){let t=Array.from(this.params.entries()).sort(([e],[r])=>e.localeCompare(r));this.params=new Map(t)}toString(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push(`${encodeURIComponent(e)}=${encodeURIComponent(s)}`);return t.join("&")}forEach(t){for(let[e,r]of this.params.entries())for(let s of r)t(s,e,this)}keys(){return this.params.keys()}values(){let t=[];for(let e of this.params.values())t.push(...e);return t[Symbol.iterator]()}entries(){let t=[];for(let[e,r]of this.params.entries())for(let s of r)t.push([e,s]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},N=class n{constructor(t,e){let r;if(t instanceof n)r=t.href;else if(e){let i=e instanceof n?e.href:e;r=this.resolve(i,t)}else r=t;let s=this.parseUrl(r);this.href=r,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 j(s.search),this.hash=s.hash}resolve(t,e){if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("//"))return`${this.parseUrl(t).protocol}${e}`;if(e.startsWith("/")){let i=this.parseUrl(t);return`${i.protocol}//${i.host}${e}`}let r=this.parseUrl(t),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${e}`}parseUrl(t){let e=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)throw new TypeError("Invalid URL");let r=e[2]||"",s=e[4]||"",i=e[5]||"/",o=e[7]?`?${e[7]}`:"",a=e[9]?`#${e[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",d=s;if(c){let b=c[1];d=c[2];let v=b.match(/^([^:]*):?(.*)$/);v&&(l=v[1]||"",h=v[2]||"")}let g=d.match(/^([^:]+):?(\d*)$/),p=g?g[1]:d,y=g&&g[2]?g[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:y,pathname:i,search:o,hash:a}}toString(){let t=this.searchParams.toString(),e=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${e}${this.hash}`}toJSON(){return this.toString()}};u();var k=class n{constructor(t,e){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=(e?.method||"GET").toUpperCase(),this.headers=e?.headers instanceof P?e.headers:new P(e?.headers),this.body=e?.body,this.timeout=e?.timeout,this.signal=e?.signal||void 0}clone(){return new n(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var q=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=de(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function de(n){return n?new P(n):new P}u();var C=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},M=class{constructor(){this._signal=new C}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function tr(n){n.URL=N,n.URLSearchParams=j,n.Headers=P,n.Request=k,n.Response=q,n.AbortController=M,n.AbortSignal=C}var mt=class{constructor(t,e,r){console.log("NvwaHttpClient constructor",t,e,r),this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(x),s=new P(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=e?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&e?.body){let a=s.get("Content-Type");(!a||a.includes("text/plain"))&&s.set("Content-Type","application/json")}let o=await this.customFetch(t,{...e,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};u();var pe="/storage",fe=pe+"/generateUploadUrl",gt=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+fe,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new P({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var ht=ce(Xt(),1),{PostgrestClient:Zt,PostgrestQueryBuilder:qr,PostgrestFilterBuilder:Mr,PostgrestTransformBuilder:Dr,PostgrestBuilder:Br,PostgrestError:Fr}=ht.default||ht;var Te="/entities",Wr=(n,t)=>new Zt(n+Te,{fetch:t.fetchWithAuth.bind(t)});u();var te=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var ee=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var re=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 t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
1
+ var it=Object.create;var N=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var pe=(n,e)=>()=>(n&&(e=n(n=0)),e);var O=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ct=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},fe=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of at(e))!ut.call(n,s)&&s!==t&&N(n,s,{get:()=>e[s],enumerable:!(r=ot(e,s))||r.enumerable});return n};var ht=(n,e,t)=>(t=n!=null?it(lt(n)):{},fe(e||!n||!n.__esModule?N(t,"default",{value:n,enumerable:!0}):t,n)),T=n=>fe(N({},"__esModule",{value:!0}),n);import Ct from"path";import{fileURLToPath as Lt}from"url";var u=pe(()=>{"use strict"});var S={};ct(S,{__addDisposableResource:()=>Be,__assign:()=>B,__asyncDelegator:()=>He,__asyncGenerator:()=>Ce,__asyncValues:()=>Le,__await:()=>A,__awaiter:()=>Re,__classPrivateFieldGet:()=>qe,__classPrivateFieldIn:()=>De,__classPrivateFieldSet:()=>Me,__createBinding:()=>z,__decorate:()=>be,__disposeResources:()=>Fe,__esDecorate:()=>_e,__exportStar:()=>$e,__extends:()=>ve,__generator:()=>Te,__importDefault:()=>ke,__importStar:()=>Ne,__makeTemplateObject:()=>Ie,__metadata:()=>Se,__param:()=>Pe,__propKey:()=>xe,__read:()=>Y,__rest:()=>we,__rewriteRelativeImportExtension:()=>ze,__runInitializers:()=>Ee,__setFunctionName:()=>Oe,__spread:()=>Ae,__spreadArray:()=>Ue,__spreadArrays:()=>je,__values:()=>F,default:()=>vt});function ve(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");W(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function we(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function be(n,e,t,r){var s=arguments.length,i=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(e,t,i):o(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i}function Pe(n,e){return function(t,r){e(t,r,n)}}function _e(n,e,t,r,s,i){function o(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&n?r.static?n:n.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,g=!1,p=t.length-1;p>=0;p--){var y={};for(var b in r)y[b]=b==="access"?{}:r[b];for(var b in r.access)y.access[b]=r.access[b];y.addInitializer=function(_){if(g)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(_||null))};var v=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[c],y);if(a==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(d=o(v.get))&&(h.get=d),(d=o(v.set))&&(h.set=d),(d=o(v.init))&&s.unshift(d)}else(d=o(v))&&(a==="field"?s.unshift(d):h[c]=d)}l&&Object.defineProperty(l,r.name,h),g=!0}function Ee(n,e,t){for(var r=arguments.length>2,s=0;s<e.length;s++)t=r?e[s].call(n,t):e[s].call(n);return r?t:void 0}function xe(n){return typeof n=="symbol"?n:"".concat(n)}function Oe(n,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Se(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function Re(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function c(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):s(h.value).then(a,c)}l((r=r.apply(n,e||[])).next())})}function Te(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,s&&(i=l[0]&2?s.return:l[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,l[1])).done)return i;switch(s=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(h){l=[6,h],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function $e(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&z(e,n,t)}function F(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Y(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Ae(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(Y(arguments[e]));return n}function je(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),s=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,s++)r[s]=i[o];return r}function Ue(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}function A(n){return this instanceof A?(this.v=n,this):new A(n)}function Ce(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(s[p]=function(b){return new Promise(function(v,_){i.push([p,b,v,_])>1||c(p,b)})},y&&(s[p]=y(s[p])))}function c(p,y){try{l(r[p](y))}catch(b){g(i[0][3],b)}}function l(p){p.value instanceof A?Promise.resolve(p.value.v).then(h,d):g(i[0][2],p)}function h(p){c("next",p)}function d(p){c("throw",p)}function g(p,y){p(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function He(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:A(n[s](o)),done:!1}:i?i(o):o}:i}}function Le(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof F=="function"?F(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,c){o=n[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}function Ie(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function Ne(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t=K(n),r=0;r<t.length;r++)t[r]!=="default"&&z(e,n,t[r]);return gt(e,n),e}function ke(n){return n&&n.__esModule?n:{default:n}}function qe(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}function Me(n,e,t,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}function De(n,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?e===n:n.has(e)}function Be(n,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(i){return Promise.reject(i)}}),n.stack.push({value:e,dispose:r,async:t})}else t&&n.stack.push({async:!0});return e}function Fe(n){function e(i){n.error=n.hasError?new yt(i,n.error,"An error was suppressed during disposal."):i,n.hasError=!0}var t,r=0;function s(){for(;t=n.stack.pop();)try{if(!t.async&&r===1)return r=0,n.stack.push(t),Promise.resolve().then(s);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(s,function(o){return e(o),s()})}else r|=1}catch(o){e(o)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function ze(n,e){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,s,i,o){return r?e?".jsx":".js":s&&(!i||!o)?t:s+i+"."+o.toLowerCase()+"js"}):n}var W,B,z,gt,K,yt,vt,R=pe(()=>{"use strict";u();W=function(n,e){return W=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},W(n,e)};B=function(){return B=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},B.apply(this,arguments)};z=Object.create?(function(n,e,t,r){r===void 0&&(r=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,r,s)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]});gt=Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e},K=function(n){return K=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},K(n)};yt=typeof SuppressedError=="function"?SuppressedError:function(n,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=n,r.suppressed=e,r};vt={__extends:ve,__assign:B,__rest:we,__decorate:be,__param:Pe,__esDecorate:_e,__runInitializers:Ee,__propKey:xe,__setFunctionName:Oe,__metadata:Se,__awaiter:Re,__generator:Te,__createBinding:z,__exportStar:$e,__values:F,__read:Y,__spread:Ae,__spreadArrays:je,__spreadArray:Ue,__await:A,__asyncGenerator:Ce,__asyncDelegator:He,__asyncValues:Le,__makeTemplateObject:Ie,__importStar:Ne,__importDefault:ke,__classPrivateFieldGet:qe,__classPrivateFieldSet:Me,__classPrivateFieldIn:De,__addDisposableResource:Be,__disposeResources:Fe,__rewriteRelativeImportExtension:ze}});var X=O(Q=>{"use strict";u();Object.defineProperty(Q,"__esModule",{value:!0});var V=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Q.default=V});var te=O(ee=>{"use strict";u();Object.defineProperty(ee,"__esModule",{value:!0});var wt=(R(),T(S)),bt=wt.__importDefault(X()),Z=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c,l;let h=null,d=null,g=null,p=i.status,y=i.statusText;if(i.ok){if(this.method!=="HEAD"){let I=await i.text();I===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=I:d=JSON.parse(I))}let v=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");v&&_&&_.length>1&&(g=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,g=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let v=await i.text();try{h=JSON.parse(v),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,y="OK")}catch{i.status===404&&v===""?(p=204,y="No Content"):h={message:v}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,y="OK"),h&&this.shouldThrowOnError)throw new bt.default(h)}return{error:h,data:d,count:g,status:p,statusText:y}});return this.shouldThrowOnError||(s=s.catch(i=>{var o,a,c;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=i?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};ee.default=Z});var ne=O(se=>{"use strict";u();Object.defineProperty(se,"__esModule",{value:!0});var Pt=(R(),T(S)),_t=Pt.__importDefault(te()),re=class extends _t.default{select(e){let t=!1,r=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let i=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${c};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};se.default=re});var J=O(oe=>{"use strict";u();Object.defineProperty(oe,"__esModule",{value:!0});var Et=(R(),T(S)),xt=Et.__importDefault(ne()),Ot=new RegExp("[,()]"),ie=class extends xt.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(s=>typeof s=="string"&&Ot.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};oe.default=ie});var ue=O(le=>{"use strict";u();Object.defineProperty(le,"__esModule",{value:!0});var St=(R(),T(S)),L=St.__importDefault(J()),ae=class{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s}select(e,t){let{head:r=!1,count:s}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!o?"":(c==='"'&&(o=!o),c)).join("");return this.url.searchParams.set("select",a),s&&this.headers.append("Prefer",`count=${s}`),new L.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){let a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new L.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(c.length>0){let l=[...new Set(c)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new L.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new L.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new L.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};le.default=ae});var Ge=O(he=>{"use strict";u();Object.defineProperty(he,"__esModule",{value:!0});var Je=(R(),T(S)),Rt=Je.__importDefault(ue()),Tt=Je.__importDefault(J()),ce=class n{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new Rt.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new n(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:s=!1,count:i}={}){var o;let a,c=new URL(`${this.url}/rpc/${e}`),l;r||s?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,g])=>g!==void 0).map(([d,g])=>[d,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([d,g])=>{c.searchParams.append(d,g)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new Tt.default({method:a,url:c,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};he.default=ce});var Ze=O(w=>{"use strict";u();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var j=(R(),T(S)),We=j.__importDefault(Ge());w.PostgrestClient=We.default;var Ke=j.__importDefault(ue());w.PostgrestQueryBuilder=Ke.default;var Ye=j.__importDefault(J());w.PostgrestFilterBuilder=Ye.default;var Ve=j.__importDefault(ne());w.PostgrestTransformBuilder=Ve.default;var Qe=j.__importDefault(te());w.PostgrestBuilder=Qe.default;var Xe=j.__importDefault(X());w.PostgrestError=Xe.default;w.default={PostgrestClient:We.default,PostgrestQueryBuilder:Ke.default,PostgrestFilterBuilder:Ye.default,PostgrestTransformBuilder:Ve.default,PostgrestBuilder:Qe.default,PostgrestError:Xe.default}});u();u();var me=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};u();u();var $="set-auth-token",E="current_jwt",x="login_token",U="user_profile",dt=typeof fetch<"u"?(n,e)=>fetch(n,e):(()=>{throw new Error("AuthClient requires fetch")})(),G=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??dt,this.storage=t.storage??null,this.credentials=t.credentials??"omit"}async currentUser(){if(this.storage){let r=await this.storage.get(U);if(r!=null)return r}let{data:e}=await this.getSession(),t=e?.user??null;return t&&this.storage&&await this.storage.set(U,t),t}async getCurrentJwt(){if(this.storage){let t=await this.storage.get(E);if(t!=null)return t;let r=await this.storage.get(x),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(E,s.token),s.token):null}let{data:e}=await this.getToken();return e?.token??null}async persistLogin(e,t){if(!this.storage)return;let r=t?.trim()&&t||e.token||e.session?.token;r&&await this.storage.set(x,r),e.user&&await this.storage.set(U,e.user);let s=r??await this.storage.get(x),{data:i}=await this.getToken(s??void 0);i?.token&&await this.storage.set(E,i.token)}async clearLogin(){this.storage&&(await this.storage.remove(x),await this.storage.remove(U),await this.storage.remove(E))}url(e){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${e.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",r),r}async getSession(){try{let e={};if(this.storage){let s=await this.storage.get(x)??await this.storage.get(E);s!=null&&(e.Authorization=`Bearer ${s}`)}let t=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return t.ok?{data:await t.json()}:{data:null,error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:e,password:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0,o=r.headers.get($);return i&&await this.persistLogin({user:i.user,session:i.session},o),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e={};if(this.storage){let r=await this.storage.get(x)??await this.storage.get(E);r!=null&&(e.Authorization=`Bearer ${r}`)}let t=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return await this.clearLogin(),t.ok?{}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signUp(e){let t=await this.postJson("sign-up/email",e),r=t.response?.headers.get($);return t.data&&await this.persistLogin(t.data,r??void 0),t}async getToken(e){try{let t={};if(e)t.Authorization=`Bearer ${e}`;else if(this.storage){let o=await this.storage.get(x)??await this.storage.get(E);o!=null&&(t.Authorization=`Bearer ${o}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.token!=null?{token:i.token}:void 0}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithUsername(e,t){let r=await this.postJson("sign-in/username",{username:e,password:t}),s=r.response?.headers.get($);return r.data&&await this.persistLogin(r.data,s??void 0),r}async signInWithPhoneNumber(e,t,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:e,password:t,rememberMe:r}),i=s.response?.headers.get($);return s.data&&await this.persistLogin(s.data,i??void 0),s}async sendPhoneNumberOtp(e){let t=await this.postJson("phone-number/send-otp",{phoneNumber:e});return t.error?{error:t.error}:{}}async verifyPhoneNumber(e,t){let r=await this.postJson("phone-number/verify",{phoneNumber:e,code:t}),s=r.response?.headers.get($);return r.data&&await this.persistLogin(r.data,s??void 0),r}async postJson(e,t){try{let r=await this.fetchImpl(this.url(e),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(t)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let i=s?JSON.parse(s):void 0;return{data:i?.data??i??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var P=class n{constructor(e){this.headerMap=new Map;if(e){if(e instanceof n)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),s=this.headerMap.get(r);this.headerMap.set(r,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},C=class n{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof n)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[s,i]=r.split("=");s&&this.append(decodeURIComponent(s),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let s of r)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let s of r)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},k=class n{constructor(e,t){let r;if(e instanceof n)r=e.href;else if(t){let i=t instanceof n?t.href:t;r=this.resolve(i,e)}else r=e;let s=this.parseUrl(r);this.href=r,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 C(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",s=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",d=s;if(c){let b=c[1];d=c[2];let v=b.match(/^([^:]*):?(.*)$/);v&&(l=v[1]||"",h=v[2]||"")}let g=d.match(/^([^:]+):?(\d*)$/),p=g?g[1]:d,y=g&&g[2]?g[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:y,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};u();var q=class n{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof P?t.headers:new P(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new n(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};u();var M=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=pt(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 pt(n){return n?new P(n):new P}u();var H=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]"}},D=class{constructor(){this._signal=new H}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function tr(n){n.URL=k,n.URLSearchParams=C,n.Headers=P,n.Request=q,n.Response=M,n.AbortController=D,n.AbortSignal=H}var ge=class{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(E),s=new P(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=s.get("Content-Type");(!a||a.includes("text/plain"))&&s.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:s});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};u();var ft="/storage",mt=ft+"/generateUploadUrl",ye=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+mt,{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 s=await this.http.fetch(r,{method:"PUT",body:e,headers:new P({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var de=ht(Ze(),1),{PostgrestClient:et,PostgrestQueryBuilder:Mr,PostgrestFilterBuilder:Dr,PostgrestTransformBuilder:Br,PostgrestBuilder:Fr,PostgrestError:zr}=de.default||de;var $t="/entities",Kr=(n,e)=>new et(n+$t,{fetch:e.fetchWithAuth.bind(e)});u();var tt=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var rt=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t!=null?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};u();var st=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 ne=Object.create;var H=Object.defineProperty;var ie=Object.getOwnPropertyDes
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(t)}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(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+i}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let a=this.createTooltip();e?a.textContent=e:a.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let c=t.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.style.top=`${c.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let i=this.createTooltip();e?i.textContent=e:i.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=t.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}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 t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function ts(n="root"){if(typeof document>"u")return null;let t=document.getElementById(n)||document.body;if(!t)return null;let e=t.querySelector("[data-source-location]");if(e){let r=e.getAttribute("data-source-location");if(r)return r}if(t.firstElementChild){let s=t.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();var $e=typeof fetch<"u"?(n,t)=>fetch(n,t):(()=>{throw new Error("payment client requires fetch")})(),se=class{constructor(t,e="/payment",r=$e){this.baseUrl=t;this.pathPrefix=e;this.fetchImpl=r}async rpc(t,e){let r=this.baseUrl.replace(/\/$/,""),s=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${s}/${t}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})});if(!o.ok){let a=await o.text();throw new Error(`${t} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(t){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=t?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(t){let e=await this.rpc("createOrder",{amount:t.amount,subject:t.subject,currency:t.currency??"cny",providerId:t.providerId,metadata:t.metadata});if(e.orderId==null)throw new Error("createPayment: missing orderId in response");return e}async queryOrder(t){let e=await this.rpc("getOrder",{orderId:t});return{orderId:e.orderId??t,status:e.status??"pending",order:e.order}}async cancelOrder(t){await this.rpc("cancelOrder",{orderId:t})}};export{M as AbortController,C as AbortSignal,G as AuthClient,x as CURRENT_JWT_KEY,Te as ENTITIES_BASE_PATH,pe as FILE_STORAGE_BASE_PATH,fe as GENERATE_UPLOAD_URL_PATH,P as Headers,A as LOGIN_TOKEN_KEY,U as LOGIN_USER_PROFILE_KEY,ee as NvwaCapability,ft as NvwaEdgeFunctions,gt as NvwaFileStorage,mt as NvwaHttpClient,te as NvwaSkill,re as OverlayManager,se as PaymentClient,k as Request,q as Response,N as URL,j as URLSearchParams,Wr as createPostgrestClient,ts as getSourceLocationFromDOM,tr as polyfill};
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(),s=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+s}px`,e.style.top=`${r.top+i}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 c=e.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.style.top=`${c.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 s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let i=this.createTooltip();t?i.textContent=t:i.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=e.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.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 s=()=>{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=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}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 ts(n="root"){if(typeof document>"u")return null;let e=document.getElementById(n)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}u();var At=typeof fetch<"u"?(n,e)=>fetch(n,e):(()=>{throw new Error("payment client requires fetch")})(),nt=class{constructor(e,t="/payment",r=At){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}async rpc(e,t){let r=this.baseUrl.replace(/\/$/,""),s=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${s}/${e}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){let a=await o.text();throw new Error(`${e} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(e){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=e?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(e){let t=await this.rpc("createOrder",{amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata});if(t.orderId==null)throw new Error("createPayment: missing orderId in response");return t}async queryOrder(e){let t=await this.rpc("getOrder",{orderId:e});return{orderId:t.orderId??e,status:t.status??"pending",order:t.order}}async cancelOrder(e){await this.rpc("cancelOrder",{orderId:e})}};export{D as AbortController,H as AbortSignal,G as AuthClient,E as CURRENT_JWT_KEY,$t as ENTITIES_BASE_PATH,ft as FILE_STORAGE_BASE_PATH,mt as GENERATE_UPLOAD_URL_PATH,P as Headers,x as LOGIN_TOKEN_KEY,U as LOGIN_USER_PROFILE_KEY,rt as NvwaCapability,me as NvwaEdgeFunctions,ye as NvwaFileStorage,ge as NvwaHttpClient,tt as NvwaSkill,st as OverlayManager,nt as PaymentClient,q as Request,M as Response,$ as SET_AUTH_TOKEN_HEADER,k as URL,C as URLSearchParams,Kr as createPostgrestClient,ts as getSourceLocationFromDOM,tr as polyfill};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-core",
3
- "version": "6.0.18",
3
+ "version": "6.0.20",
4
4
  "description": "NVWA跨端通用工具类核心接口",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",