@nvwa-app/sdk-core 6.0.55 → 6.1.0

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
@@ -12,7 +12,39 @@ import { PostgrestClient } from '@nvwa-app/postgrest-js';
12
12
  * 与 payment-gateway 一致:codeUrl(扫码)、formHtml(跳转/表单)、
13
13
  * clientSecret(Stripe)、jsapiPayParams(微信内 H5/小程序)等。
14
14
  */
15
- type PayParams = {
15
+ interface WechatJsapiPayParams {
16
+ appId: string;
17
+ timeStamp: string;
18
+ nonceStr: string;
19
+ package: string;
20
+ signType: "RSA";
21
+ paySign: string;
22
+ }
23
+ type TypedPayParams = {
24
+ kind: "wechat_jsapi";
25
+ mode?: "jsapi";
26
+ jsapiPayParams: WechatJsapiPayParams;
27
+ prepayId?: string;
28
+ } | {
29
+ kind: "wechat_native_qr";
30
+ codeUrl: string;
31
+ mode?: "native";
32
+ } | {
33
+ kind: "alipay_miniprogram";
34
+ tradeNO: string;
35
+ } | {
36
+ kind: "alipay_page";
37
+ formHtml: string;
38
+ } | {
39
+ kind: "redirect_url";
40
+ redirectUrl: string;
41
+ } | {
42
+ kind: "stripe_client_secret";
43
+ clientSecret: string;
44
+ } | {
45
+ kind: "wechat_jsapi_deferred";
46
+ };
47
+ type LegacyPayParams = {
16
48
  codeUrl: string;
17
49
  } | {
18
50
  redirectUrl: string;
@@ -20,16 +52,25 @@ type PayParams = {
20
52
  formHtml: string;
21
53
  } | {
22
54
  clientSecret: string;
55
+ } | {
56
+ tradeNO: string;
23
57
  } | {
24
58
  jsapiPayParams?: unknown;
25
59
  } | Record<string, unknown>;
60
+ type PayParams = TypedPayParams | LegacyPayParams;
61
+ interface PaymentRequestCallbacks {
62
+ onSuccess?: () => void;
63
+ onFailure?: (error: unknown) => void;
64
+ onCancel?: (error: unknown) => void;
65
+ }
66
+ declare function normalizePayParams(payParams: PayParams): TypedPayParams | null;
26
67
  /**
27
68
  * 发起支付:接收 payParams,按当前端类型与渠道完成调起。
28
69
  * 渠道(如 Wechat)与端类型(如 Desktop-web、MP-Wechat、Mobile-web)由后端 getPaymentInfo 决定;
29
70
  * React 实现 Wechat + Desktop-web;Uniapp 实现 wechat-platform 的 MP-Wechat、Mobile-web。
30
71
  */
31
72
  interface IPaymentLauncher {
32
- requestPayment(payParams: PayParams): Promise<void>;
73
+ requestPayment(payParams: PayParams, callbacks?: PaymentRequestCallbacks): Promise<void>;
33
74
  }
34
75
  /**
35
76
  * 业务层 create order 返回给前端的订单结果(与 examples payment-create-order 对齐)。
@@ -53,7 +94,7 @@ type CreatePaymentResponse = PaymentOrderResult;
53
94
  /**
54
95
  * 从业务 create order 返回结果发起的纯前端封装:不发起任何后端请求。
55
96
  */
56
- declare function requestPaymentFromOrderResult(result: PaymentOrderResult, launcher: IPaymentLauncher): Promise<void>;
97
+ declare function requestPaymentFromOrderResult(result: PaymentOrderResult, launcher: IPaymentLauncher, callbacks?: PaymentRequestCallbacks): Promise<void>;
57
98
 
58
99
  declare class Headers {
59
100
  private readonly headerMap;
@@ -515,4 +556,4 @@ interface INvwa {
515
556
  endpointType: string;
516
557
  }
517
558
 
518
- export { AbortController, AbortSignal, type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, 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 IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, URL$1 as URL, URLSearchParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, createPostgrestClient, getSourceLocationFromDOM, polyfill, requestPaymentFromOrderResult };
559
+ export { AbortController, AbortSignal, type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, 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 IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type LegacyPayParams, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, type PaymentRequestCallbacks, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, type TypedPayParams, URL$1 as URL, URLSearchParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, type WechatJsapiPayParams, createPostgrestClient, getSourceLocationFromDOM, normalizePayParams, polyfill, requestPaymentFromOrderResult };
package/dist/index.d.ts CHANGED
@@ -12,7 +12,39 @@ import { PostgrestClient } from '@nvwa-app/postgrest-js';
12
12
  * 与 payment-gateway 一致:codeUrl(扫码)、formHtml(跳转/表单)、
13
13
  * clientSecret(Stripe)、jsapiPayParams(微信内 H5/小程序)等。
14
14
  */
15
- type PayParams = {
15
+ interface WechatJsapiPayParams {
16
+ appId: string;
17
+ timeStamp: string;
18
+ nonceStr: string;
19
+ package: string;
20
+ signType: "RSA";
21
+ paySign: string;
22
+ }
23
+ type TypedPayParams = {
24
+ kind: "wechat_jsapi";
25
+ mode?: "jsapi";
26
+ jsapiPayParams: WechatJsapiPayParams;
27
+ prepayId?: string;
28
+ } | {
29
+ kind: "wechat_native_qr";
30
+ codeUrl: string;
31
+ mode?: "native";
32
+ } | {
33
+ kind: "alipay_miniprogram";
34
+ tradeNO: string;
35
+ } | {
36
+ kind: "alipay_page";
37
+ formHtml: string;
38
+ } | {
39
+ kind: "redirect_url";
40
+ redirectUrl: string;
41
+ } | {
42
+ kind: "stripe_client_secret";
43
+ clientSecret: string;
44
+ } | {
45
+ kind: "wechat_jsapi_deferred";
46
+ };
47
+ type LegacyPayParams = {
16
48
  codeUrl: string;
17
49
  } | {
18
50
  redirectUrl: string;
@@ -20,16 +52,25 @@ type PayParams = {
20
52
  formHtml: string;
21
53
  } | {
22
54
  clientSecret: string;
55
+ } | {
56
+ tradeNO: string;
23
57
  } | {
24
58
  jsapiPayParams?: unknown;
25
59
  } | Record<string, unknown>;
60
+ type PayParams = TypedPayParams | LegacyPayParams;
61
+ interface PaymentRequestCallbacks {
62
+ onSuccess?: () => void;
63
+ onFailure?: (error: unknown) => void;
64
+ onCancel?: (error: unknown) => void;
65
+ }
66
+ declare function normalizePayParams(payParams: PayParams): TypedPayParams | null;
26
67
  /**
27
68
  * 发起支付:接收 payParams,按当前端类型与渠道完成调起。
28
69
  * 渠道(如 Wechat)与端类型(如 Desktop-web、MP-Wechat、Mobile-web)由后端 getPaymentInfo 决定;
29
70
  * React 实现 Wechat + Desktop-web;Uniapp 实现 wechat-platform 的 MP-Wechat、Mobile-web。
30
71
  */
31
72
  interface IPaymentLauncher {
32
- requestPayment(payParams: PayParams): Promise<void>;
73
+ requestPayment(payParams: PayParams, callbacks?: PaymentRequestCallbacks): Promise<void>;
33
74
  }
34
75
  /**
35
76
  * 业务层 create order 返回给前端的订单结果(与 examples payment-create-order 对齐)。
@@ -53,7 +94,7 @@ type CreatePaymentResponse = PaymentOrderResult;
53
94
  /**
54
95
  * 从业务 create order 返回结果发起的纯前端封装:不发起任何后端请求。
55
96
  */
56
- declare function requestPaymentFromOrderResult(result: PaymentOrderResult, launcher: IPaymentLauncher): Promise<void>;
97
+ declare function requestPaymentFromOrderResult(result: PaymentOrderResult, launcher: IPaymentLauncher, callbacks?: PaymentRequestCallbacks): Promise<void>;
57
98
 
58
99
  declare class Headers {
59
100
  private readonly headerMap;
@@ -515,4 +556,4 @@ interface INvwa {
515
556
  endpointType: string;
516
557
  }
517
558
 
518
- export { AbortController, AbortSignal, type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, 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 IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, URL$1 as URL, URLSearchParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, createPostgrestClient, getSourceLocationFromDOM, polyfill, requestPaymentFromOrderResult };
559
+ export { AbortController, AbortSignal, type AlipayCodeLoginResult, type AlipayOpenPlatformIdentity, AuthClient, type AuthClientOptions, type AuthResult, type AuthSession, type AuthUser, CURRENT_JWT_KEY, 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 IPaymentLauncher, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type LegacyPayParams, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, OverlayManager, type PayParams, type PaymentOrderResult, type PaymentRequestCallbacks, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, SET_AUTH_TOKEN_HEADER, type SignUpBody, type TypedPayParams, URL$1 as URL, URLSearchParams, type WeChatCodeLoginResult, type WeChatOpenPlatformIdentity, type WechatJsapiPayParams, createPostgrestClient, getSourceLocationFromDOM, normalizePayParams, polyfill, requestPaymentFromOrderResult };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ie=Object.create;var q=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var mt=(n,t)=>()=>(n&&(t=n(n=0)),t);var x=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),yt=(n,t)=>{for(var e in t)q(n,e,{get:t[e],enumerable:!0})},wt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!ue.call(n,s)&&s!==e&&q(n,s,{get:()=>t[s],enumerable:!(r=ae(t,s))||r.enumerable});return n};var he=(n,t,e)=>(e=n!=null?ie(le(n)):{},wt(t||!n||!n.__esModule?q(e,"default",{value:n,enumerable:!0}):e,n)),S=n=>wt(q({},"__esModule",{value:!0}),n);var u=mt(()=>{"use strict"});var R={};yt(R,{__addDisposableResource:()=>zt,__assign:()=>D,__asyncDelegator:()=>kt,__asyncGenerator:()=>Nt,__asyncValues:()=>Ht,__await:()=>U,__awaiter:()=>$t,__classPrivateFieldGet:()=>Bt,__classPrivateFieldIn:()=>Wt,__classPrivateFieldSet:()=>Ft,__createBinding:()=>F,__decorate:()=>Et,__disposeResources:()=>Jt,__esDecorate:()=>xt,__exportStar:()=>Ct,__extends:()=>Pt,__generator:()=>Ut,__importDefault:()=>Dt,__importStar:()=>Mt,__makeTemplateObject:()=>qt,__metadata:()=>At,__param:()=>Ot,__propKey:()=>Rt,__read:()=>Q,__rest:()=>_t,__rewriteRelativeImportExtension:()=>Gt,__runInitializers:()=>St,__setFunctionName:()=>Tt,__spread:()=>Lt,__spreadArray:()=>jt,__spreadArrays:()=>It,__values:()=>B,default:()=>me});function Pt(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 _t(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 Et(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(i=(s<3?a(i):s>3?a(t,e,i):a(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i}function Ot(n,t){return function(e,r){t(e,r,n)}}function xt(n,t,e,r,s,i){function a(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var o=r.kind,h=o==="getter"?"get":o==="setter"?"set":"value",l=!t&&n?r.static?n:n.prototype:null,c=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=e.length-1;p>=0;p--){var m={};for(var P in r)m[P]=P==="access"?{}:r[P];for(var P in r.access)m.access[P]=r.access[P];m.addInitializer=function(_){if(f)throw new TypeError("Cannot add initializers after decoration has completed");i.push(a(_||null))};var y=(0,e[p])(o==="accessor"?{get:c.get,set:c.set}:c[h],m);if(o==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(d=a(y.get))&&(c.get=d),(d=a(y.set))&&(c.set=d),(d=a(y.init))&&s.unshift(d)}else(d=a(y))&&(o==="field"?s.unshift(d):c[h]=d)}l&&Object.defineProperty(l,r.name,c),f=!0}function St(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 Rt(n){return typeof n=="symbol"?n:"".concat(n)}function Tt(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 At(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function $t(n,t,e,r){function s(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function o(c){try{l(r.next(c))}catch(d){a(d)}}function h(c){try{l(r.throw(c))}catch(d){a(d)}}function l(c){c.done?i(c.value):s(c.value).then(o,h)}l((r=r.apply(n,t||[])).next())})}function Ut(n,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(c){return h([l,c])}}function h(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=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(c){l=[6,c],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Ct(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 Q(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],a;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(a)throw a.error}}return i}function Lt(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(Q(arguments[t]));return n}function It(){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],a=0,o=i.length;a<o;a++,s++)r[s]=i[a];return r}function jt(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 Nt(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),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(p){return function(m){return Promise.resolve(m).then(p,d)}}function o(p,m){r[p]&&(s[p]=function(P){return new Promise(function(y,_){i.push([p,P,y,_])>1||h(p,P)})},m&&(s[p]=m(s[p])))}function h(p,m){try{l(r[p](m))}catch(P){f(i[0][3],P)}}function l(p){p.value instanceof U?Promise.resolve(p.value.v).then(c,d):f(i[0][2],p)}function c(p){h("next",p)}function d(p){h("throw",p)}function f(p,m){p(m),i.shift(),i.length&&h(i[0][0],i[0][1])}}function kt(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(a){return(e=!e)?{value:U(n[s](a)),done:!1}:i?i(a):a}:i}}function Ht(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(a){return new Promise(function(o,h){a=n[i](a),s(o,h,a.done,a.value)})}}function s(i,a,o,h){Promise.resolve(h).then(function(l){i({value:l,done:o})},a)}}function qt(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}function Mt(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=V(n),r=0;r<e.length;r++)e[r]!=="default"&&F(t,n,e[r]);return fe(t,n),t}function Dt(n){return n&&n.__esModule?n:{default:n}}function Bt(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 Ft(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 Wt(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 zt(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 Jt(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(a){return t(a),s()})}else r|=1}catch(a){t(a)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Gt(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,i,a){return r?t?".jsx":".js":s&&(!i||!a)?e:s+i+"."+a.toLowerCase()+"js"}):n}var Y,D,F,fe,V,ge,me,T=mt(()=>{"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]});fe=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},V=function(n){return V=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},V(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};me={__extends:Pt,__assign:D,__rest:_t,__decorate:Et,__param:Ot,__esDecorate:xt,__runInitializers:St,__propKey:Rt,__setFunctionName:Tt,__metadata:At,__awaiter:$t,__generator:Ut,__createBinding:F,__exportStar:Ct,__values:B,__read:Q,__spread:Lt,__spreadArrays:It,__spreadArray:jt,__await:U,__asyncGenerator:Nt,__asyncDelegator:kt,__asyncValues:Ht,__makeTemplateObject:qt,__importStar:Mt,__importDefault:Dt,__classPrivateFieldGet:Bt,__classPrivateFieldSet:Ft,__classPrivateFieldIn:Wt,__addDisposableResource:zt,__disposeResources:Jt,__rewriteRelativeImportExtension:Gt}});var tt=x(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var X=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}};Z.default=X});var st=x(rt=>{"use strict";u();Object.defineProperty(rt,"__esModule",{value:!0});var ye=(T(),S(R)),we=ye.__importDefault(tt()),et=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 a,o,h,l;let c=null,d=null,f=null,p=i.status,m=i.statusText;if(i.ok){if(this.method!=="HEAD"){let H=await i.text();H===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((a=this.headers.get("Accept"))===null||a===void 0)&&a.includes("application/vnd.pgrst.plan+text"))?d=H:d=JSON.parse(H))}let y=(o=this.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),_=(h=i.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");y&&_&&_.length>1&&(f=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(c={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,f=null,p=406,m="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let y=await i.text();try{c=JSON.parse(y),Array.isArray(c)&&i.status===404&&(d=[],c=null,p=200,m="OK")}catch{i.status===404&&y===""?(p=204,m="No Content"):c={message:y}}if(c&&this.isMaybeSingle&&(!((l=c?.details)===null||l===void 0)&&l.includes("0 rows"))&&(c=null,p=200,m="OK"),c&&this.shouldThrowOnError)throw new we.default(c)}return{error:c,data:d,count:f,status:p,statusText:m}});return this.shouldThrowOnError||(s=s.catch(i=>{var a,o,h;return{error:{message:`${(a=i?.name)!==null&&a!==void 0?a:"FetchError"}: ${i?.message}`,details:`${(o=i?.stack)!==null&&o!==void 0?o:""}`,hint:"",code:`${(h=i?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),s.then(t,e)}returns(){return this}overrideTypes(){return this}};rt.default=et});var at=x(it=>{"use strict";u();Object.defineProperty(it,"__esModule",{value:!0});var ve=(T(),S(R)),be=ve.__importDefault(st()),nt=class extends be.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 a=i?`${i}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${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`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${t}`),this.url.searchParams.set(a,`${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:a="text"}={}){var o;let h=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${h};`),a==="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}};it.default=nt});var W=x(lt=>{"use strict";u();Object.defineProperty(lt,"__esModule",{value:!0});var Pe=(T(),S(R)),_e=Pe.__importDefault(at()),Ee=new RegExp("[,()]"),ot=class extends _e.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"&&Ee.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 a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${i}fts${a}.${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}};lt.default=ot});var ct=x(ht=>{"use strict";u();Object.defineProperty(ht,"__esModule",{value:!0});var Oe=(T(),S(R)),k=Oe.__importDefault(W()),ut=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",a=!1,o=(t??"*").split("").map(h=>/\s/.test(h)&&!a?"":(h==='"'&&(a=!a),h)).join("");return this.url.searchParams.set("select",o),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(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 a=t.reduce((o,h)=>o.concat(Object.keys(h)),[]);if(a.length>0){let o=[...new Set(a)].map(h=>`"${h}"`);this.url.searchParams.set("columns",o.join(","))}}return new k.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 a;let o="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 h=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(h.length>0){let l=[...new Set(h)].map(c=>`"${c}"`);this.url.searchParams.set("columns",l.join(","))}}return new k.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}update(t,{count:e}={}){var r;let s="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new k.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 k.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}};ht.default=ut});var Yt=x(pt=>{"use strict";u();Object.defineProperty(pt,"__esModule",{value:!0});var Kt=(T(),S(R)),xe=Kt.__importDefault(ct()),Se=Kt.__importDefault(W()),dt=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 xe.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 a;let o,h=new URL(`${this.url}/rpc/${t}`),l;r||s?(o=r?"HEAD":"GET",Object.entries(e).filter(([d,f])=>f!==void 0).map(([d,f])=>[d,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([d,f])=>{h.searchParams.append(d,f)})):(o="POST",l=e);let c=new Headers(this.headers);return i&&c.set("Prefer",`count=${i}`),new Se.default({method:o,url:h,headers:c,schema:this.schemaName,body:l,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};pt.default=dt});var re=x(b=>{"use strict";u();Object.defineProperty(b,"__esModule",{value:!0});b.PostgrestError=b.PostgrestBuilder=b.PostgrestTransformBuilder=b.PostgrestFilterBuilder=b.PostgrestQueryBuilder=b.PostgrestClient=void 0;var C=(T(),S(R)),Vt=C.__importDefault(Yt());b.PostgrestClient=Vt.default;var Qt=C.__importDefault(ct());b.PostgrestQueryBuilder=Qt.default;var Xt=C.__importDefault(W());b.PostgrestFilterBuilder=Xt.default;var Zt=C.__importDefault(at());b.PostgrestTransformBuilder=Zt.default;var te=C.__importDefault(st());b.PostgrestBuilder=te.default;var ee=C.__importDefault(tt());b.PostgrestError=ee.default;b.default={PostgrestClient:Vt.default,PostgrestQueryBuilder:Qt.default,PostgrestFilterBuilder:Xt.default,PostgrestTransformBuilder:Zt.default,PostgrestBuilder:te.default,PostgrestError:ee.default}});var $e={};yt($e,{AbortController:()=>N,AbortSignal:()=>$,AuthClient:()=>M,CURRENT_JWT_KEY:()=>w,ENTITIES_BASE_PATH:()=>ne,FILE_STORAGE_BASE_PATH:()=>vt,GENERATE_UPLOAD_URL_PATH:()=>bt,Headers:()=>v,LOGIN_TOKEN_KEY:()=>E,LOGIN_USER_PROFILE_KEY:()=>O,NvwaEdgeFunctions:()=>z,NvwaFileStorage:()=>K,NvwaHttpClient:()=>G,OverlayManager:()=>gt,Request:()=>I,Response:()=>j,SET_AUTH_TOKEN_HEADER:()=>J,URL:()=>L,URLSearchParams:()=>A,createPostgrestClient:()=>Re,getSourceLocationFromDOM:()=>Te,polyfill:()=>pe,requestPaymentFromOrderResult:()=>Ae});module.exports=S($e);u();u();var z=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 w="nvwa_current_jwt",E="nvwa_login_token",O="nvwa_user_profile",J="set-auth-token",ce=typeof fetch<"u"?(n,t)=>fetch(n,t):()=>{throw new Error("AuthClient requires fetch")},M=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??ce,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(O);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(O,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(w);if(e!=null)return e;let r=await this.storage.get(E),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(w,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let s=e?.headers.get(J)?.trim()||t.token||t.session?.token;s&&await this.storage.set(E,s),t.user&&await this.storage.set(O,t.user);let i=s??await this.storage.get(E),{data:a}=await this.getToken(i??void 0);a?.token&&await this.storage.set(w,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(E),await this.storage.remove(O),await this.storage.remove(w))}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",r),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),r}async getSession(){try{let t={};if(this.storage){let s=await this.storage.get(E)??await this.storage.get(w);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.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:this.credentials,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},r),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(E)??await this.storage.get(w);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.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.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(E)??await this.storage.get(w);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...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.response),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.response),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.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(w,a.token),await this.storage.set(E,a.token),await this.storage.set(O,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(w,a.token),await this.storage.set(E,a.token),await this.storage.set(O,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,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,response:r}}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()}},A=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}},L=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 A(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]||"/",a=e[7]?`?${e[7]}`:"",o=e[9]?`#${e[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let h=s.match(/^([^@]*)@(.+)$/),l="",c="",d=s;if(h){let P=h[1];d=h[2];let y=P.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",c=y[2]||"")}let f=d.match(/^([^:]+):?(\d*)$/),p=f?f[1]:d,m=f&&f[2]?f[2]:"";return{protocol:r?`${r}:`:"",username:l,password:c,host:d,hostname:p,port:m,pathname:i,search:a,hash:o}}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 j=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 v(n):new v}u();var $=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]"}},N=class{constructor(){this._signal=new $}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function pe(n){n.URL=L,n.URLSearchParams=A,n.Headers=v,n.Request=I,n.Response=j,n.AbortController=N,n.AbortSignal=$}var G=class{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(w),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 o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};u();var vt="/storage",bt=vt+"/generateUploadUrl",K=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+bt,{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 ft=he(re(),1),{PostgrestClient:se,PostgrestQueryBuilder:jr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:kr,PostgrestBuilder:Hr,PostgrestError:qr}=ft.default||ft;var ne="/entities",Re=(n,t)=>new se(n+ne,{fetch:t.fetchWithAuth.bind(t)});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 ie=Object.create;var q=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var mt=(n,t)=>()=>(n&&(t=n(n=0)),t);var x=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),yt=(n,t)=>{for(var e in t)q(n,e,{get:t[e],enumerable:!0})},wt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!ue.call(n,s)&&s!==e&&q(n,s,{get:()=>t[s],enumerable:!(r=ae(t,s))||r.enumerable});return n};var ce=(n,t,e)=>(e=n!=null?ie(le(n)):{},wt(t||!n||!n.__esModule?q(e,"default",{value:n,enumerable:!0}):e,n)),S=n=>wt(q({},"__esModule",{value:!0}),n);var u=mt(()=>{"use strict"});var R={};yt(R,{__addDisposableResource:()=>zt,__assign:()=>D,__asyncDelegator:()=>Nt,__asyncGenerator:()=>Lt,__asyncValues:()=>Ht,__await:()=>U,__awaiter:()=>$t,__classPrivateFieldGet:()=>Bt,__classPrivateFieldIn:()=>Wt,__classPrivateFieldSet:()=>Ft,__createBinding:()=>F,__decorate:()=>Et,__disposeResources:()=>Jt,__esDecorate:()=>xt,__exportStar:()=>kt,__extends:()=>Pt,__generator:()=>Ut,__importDefault:()=>Dt,__importStar:()=>Mt,__makeTemplateObject:()=>qt,__metadata:()=>At,__param:()=>Ot,__propKey:()=>Rt,__read:()=>Q,__rest:()=>_t,__rewriteRelativeImportExtension:()=>Gt,__runInitializers:()=>St,__setFunctionName:()=>Tt,__spread:()=>jt,__spreadArray:()=>It,__spreadArrays:()=>Ct,__values:()=>B,default:()=>me});function Pt(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 _t(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 Et(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(i=(s<3?a(i):s>3?a(t,e,i):a(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i}function Ot(n,t){return function(e,r){t(e,r,n)}}function xt(n,t,e,r,s,i){function a(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var o=r.kind,c=o==="getter"?"get":o==="setter"?"set":"value",l=!t&&n?r.static?n:n.prototype:null,h=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=e.length-1;p>=0;p--){var m={};for(var P in r)m[P]=P==="access"?{}:r[P];for(var P in r.access)m.access[P]=r.access[P];m.addInitializer=function(_){if(f)throw new TypeError("Cannot add initializers after decoration has completed");i.push(a(_||null))};var y=(0,e[p])(o==="accessor"?{get:h.get,set:h.set}:h[c],m);if(o==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(d=a(y.get))&&(h.get=d),(d=a(y.set))&&(h.set=d),(d=a(y.init))&&s.unshift(d)}else(d=a(y))&&(o==="field"?s.unshift(d):h[c]=d)}l&&Object.defineProperty(l,r.name,h),f=!0}function St(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 Rt(n){return typeof n=="symbol"?n:"".concat(n)}function Tt(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 At(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function $t(n,t,e,r){function s(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function o(h){try{l(r.next(h))}catch(d){a(d)}}function c(h){try{l(r.throw(h))}catch(d){a(d)}}function l(h){h.done?i(h.value):s(h.value).then(o,c)}l((r=r.apply(n,t||[])).next())})}function Ut(n,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=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 kt(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 Q(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],a;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(a)throw a.error}}return i}function jt(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(Q(arguments[t]));return n}function Ct(){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],a=0,o=i.length;a<o;a++,s++)r[s]=i[a];return r}function It(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 Lt(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),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(p){return function(m){return Promise.resolve(m).then(p,d)}}function o(p,m){r[p]&&(s[p]=function(P){return new Promise(function(y,_){i.push([p,P,y,_])>1||c(p,P)})},m&&(s[p]=m(s[p])))}function c(p,m){try{l(r[p](m))}catch(P){f(i[0][3],P)}}function l(p){p.value instanceof U?Promise.resolve(p.value.v).then(h,d):f(i[0][2],p)}function h(p){c("next",p)}function d(p){c("throw",p)}function f(p,m){p(m),i.shift(),i.length&&c(i[0][0],i[0][1])}}function Nt(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(a){return(e=!e)?{value:U(n[s](a)),done:!1}:i?i(a):a}:i}}function Ht(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(a){return new Promise(function(o,c){a=n[i](a),s(o,c,a.done,a.value)})}}function s(i,a,o,c){Promise.resolve(c).then(function(l){i({value:l,done:o})},a)}}function qt(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}function Mt(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=V(n),r=0;r<e.length;r++)e[r]!=="default"&&F(t,n,e[r]);return fe(t,n),t}function Dt(n){return n&&n.__esModule?n:{default:n}}function Bt(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 Ft(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 Wt(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 zt(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 Jt(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(a){return t(a),s()})}else r|=1}catch(a){t(a)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Gt(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,i,a){return r?t?".jsx":".js":s&&(!i||!a)?e:s+i+"."+a.toLowerCase()+"js"}):n}var Y,D,F,fe,V,ge,me,T=mt(()=>{"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]});fe=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},V=function(n){return V=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},V(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};me={__extends:Pt,__assign:D,__rest:_t,__decorate:Et,__param:Ot,__esDecorate:xt,__runInitializers:St,__propKey:Rt,__setFunctionName:Tt,__metadata:At,__awaiter:$t,__generator:Ut,__createBinding:F,__exportStar:kt,__values:B,__read:Q,__spread:jt,__spreadArrays:Ct,__spreadArray:It,__await:U,__asyncGenerator:Lt,__asyncDelegator:Nt,__asyncValues:Ht,__makeTemplateObject:qt,__importStar:Mt,__importDefault:Dt,__classPrivateFieldGet:Bt,__classPrivateFieldSet:Ft,__classPrivateFieldIn:Wt,__addDisposableResource:zt,__disposeResources:Jt,__rewriteRelativeImportExtension:Gt}});var tt=x(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var X=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}};Z.default=X});var st=x(rt=>{"use strict";u();Object.defineProperty(rt,"__esModule",{value:!0});var ye=(T(),S(R)),we=ye.__importDefault(tt()),et=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 a,o,c,l;let h=null,d=null,f=null,p=i.status,m=i.statusText;if(i.ok){if(this.method!=="HEAD"){let H=await i.text();H===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((a=this.headers.get("Accept"))===null||a===void 0)&&a.includes("application/vnd.pgrst.plan+text"))?d=H:d=JSON.parse(H))}let y=(o=this.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),_=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");y&&_&&_.length>1&&(f=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,f=null,p=406,m="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,m="OK")}catch{i.status===404&&y===""?(p=204,m="No Content"):h={message:y}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,m="OK"),h&&this.shouldThrowOnError)throw new we.default(h)}return{error:h,data:d,count:f,status:p,statusText:m}});return this.shouldThrowOnError||(s=s.catch(i=>{var a,o,c;return{error:{message:`${(a=i?.name)!==null&&a!==void 0?a:"FetchError"}: ${i?.message}`,details:`${(o=i?.stack)!==null&&o!==void 0?o:""}`,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}};rt.default=et});var at=x(it=>{"use strict";u();Object.defineProperty(it,"__esModule",{value:!0});var ve=(T(),S(R)),be=ve.__importDefault(st()),nt=class extends be.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 a=i?`${i}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${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`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${t}`),this.url.searchParams.set(a,`${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:a="text"}={}){var o;let c=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${c};`),a==="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}};it.default=nt});var W=x(lt=>{"use strict";u();Object.defineProperty(lt,"__esModule",{value:!0});var Pe=(T(),S(R)),_e=Pe.__importDefault(at()),Ee=new RegExp("[,()]"),ot=class extends _e.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"&&Ee.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 a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${i}fts${a}.${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}};lt.default=ot});var ht=x(ct=>{"use strict";u();Object.defineProperty(ct,"__esModule",{value:!0});var Oe=(T(),S(R)),N=Oe.__importDefault(W()),ut=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",a=!1,o=(t??"*").split("").map(c=>/\s/.test(c)&&!a?"":(c==='"'&&(a=!a),c)).join("");return this.url.searchParams.set("select",o),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 a=t.reduce((o,c)=>o.concat(Object.keys(c)),[]);if(a.length>0){let o=[...new Set(a)].map(c=>`"${c}"`);this.url.searchParams.set("columns",o.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 a;let o="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:o,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a: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})}};ct.default=ut});var Yt=x(pt=>{"use strict";u();Object.defineProperty(pt,"__esModule",{value:!0});var Kt=(T(),S(R)),xe=Kt.__importDefault(ht()),Se=Kt.__importDefault(W()),dt=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 xe.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 a;let o,c=new URL(`${this.url}/rpc/${t}`),l;r||s?(o=r?"HEAD":"GET",Object.entries(e).filter(([d,f])=>f!==void 0).map(([d,f])=>[d,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([d,f])=>{c.searchParams.append(d,f)})):(o="POST",l=e);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new Se.default({method:o,url:c,headers:h,schema:this.schemaName,body:l,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};pt.default=dt});var re=x(b=>{"use strict";u();Object.defineProperty(b,"__esModule",{value:!0});b.PostgrestError=b.PostgrestBuilder=b.PostgrestTransformBuilder=b.PostgrestFilterBuilder=b.PostgrestQueryBuilder=b.PostgrestClient=void 0;var k=(T(),S(R)),Vt=k.__importDefault(Yt());b.PostgrestClient=Vt.default;var Qt=k.__importDefault(ht());b.PostgrestQueryBuilder=Qt.default;var Xt=k.__importDefault(W());b.PostgrestFilterBuilder=Xt.default;var Zt=k.__importDefault(at());b.PostgrestTransformBuilder=Zt.default;var te=k.__importDefault(st());b.PostgrestBuilder=te.default;var ee=k.__importDefault(tt());b.PostgrestError=ee.default;b.default={PostgrestClient:Vt.default,PostgrestQueryBuilder:Qt.default,PostgrestFilterBuilder:Xt.default,PostgrestTransformBuilder:Zt.default,PostgrestBuilder:te.default,PostgrestError:ee.default}});var Ue={};yt(Ue,{AbortController:()=>L,AbortSignal:()=>$,AuthClient:()=>M,CURRENT_JWT_KEY:()=>w,ENTITIES_BASE_PATH:()=>ne,FILE_STORAGE_BASE_PATH:()=>vt,GENERATE_UPLOAD_URL_PATH:()=>bt,Headers:()=>v,LOGIN_TOKEN_KEY:()=>E,LOGIN_USER_PROFILE_KEY:()=>O,NvwaEdgeFunctions:()=>z,NvwaFileStorage:()=>K,NvwaHttpClient:()=>G,OverlayManager:()=>gt,Request:()=>C,Response:()=>I,SET_AUTH_TOKEN_HEADER:()=>J,URL:()=>j,URLSearchParams:()=>A,createPostgrestClient:()=>Re,getSourceLocationFromDOM:()=>Te,normalizePayParams:()=>Ae,polyfill:()=>pe,requestPaymentFromOrderResult:()=>$e});module.exports=S(Ue);u();u();var z=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 w="nvwa_current_jwt",E="nvwa_login_token",O="nvwa_user_profile",J="set-auth-token",he=typeof fetch<"u"?(n,t)=>fetch(n,t):()=>{throw new Error("AuthClient requires fetch")},M=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??he,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(O);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(O,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(w);if(e!=null)return e;let r=await this.storage.get(E),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(w,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let s=e?.headers.get(J)?.trim()||t.token||t.session?.token;s&&await this.storage.set(E,s),t.user&&await this.storage.set(O,t.user);let i=s??await this.storage.get(E),{data:a}=await this.getToken(i??void 0);a?.token&&await this.storage.set(w,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(E),await this.storage.remove(O),await this.storage.remove(w))}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",r),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),r}async getSession(){try{let t={};if(this.storage){let s=await this.storage.get(E)??await this.storage.get(w);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.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:this.credentials,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},r),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(E)??await this.storage.get(w);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.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.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(E)??await this.storage.get(w);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...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.response),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.response),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.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(w,a.token),await this.storage.set(E,a.token),await this.storage.set(O,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(w,a.token),await this.storage.set(E,a.token),await this.storage.set(O,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,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,response:r}}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()}},A=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}},j=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 A(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]||"/",a=e[7]?`?${e[7]}`:"",o=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 P=c[1];d=c[2];let y=P.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",h=y[2]||"")}let f=d.match(/^([^:]+):?(\d*)$/),p=f?f[1]:d,m=f&&f[2]?f[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:m,pathname:i,search:a,hash:o}}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 C=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 I=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 v(n):new v}u();var $=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]"}},L=class{constructor(){this._signal=new $}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function pe(n){n.URL=j,n.URLSearchParams=A,n.Headers=v,n.Request=C,n.Response=I,n.AbortController=L,n.AbortSignal=$}var G=class{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(w),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 o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};u();var vt="/storage",bt=vt+"/generateUploadUrl",K=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+bt,{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 ft=ce(re(),1),{PostgrestClient:se,PostgrestQueryBuilder:Lr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:Hr,PostgrestBuilder:qr,PostgrestError:Mr}=ft.default||ft;var ne="/entities",Re=(n,t)=>new se(n+ne,{fetch:t.fetchWithAuth.bind(t)});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=`
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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let h=t.getBoundingClientRect();o.style.left=`${h.left+window.scrollX}px`,o.style.top=`${h.top+window.scrollY-o.offsetHeight-8}px`,h.top<o.offsetHeight+8&&(o.style.top=`${h.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 a=t.getBoundingClientRect();i.style.left=`${a.left+window.scrollX}px`,i.style.top=`${a.top+window.scrollY-i.offsetHeight-8}px`,a.top<i.offsetHeight+8&&(i.style.top=`${a.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 Te(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();function Ae(n,t){return t.requestPayment(n.payParams)}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,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,OverlayManager,Request,Response,SET_AUTH_TOKEN_HEADER,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill,requestPaymentFromOrderResult});
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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let c=t.getBoundingClientRect();o.style.left=`${c.left+window.scrollX}px`,o.style.top=`${c.top+window.scrollY-o.offsetHeight-8}px`,c.top<o.offsetHeight+8&&(o.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 a=t.getBoundingClientRect();i.style.left=`${a.left+window.scrollX}px`,i.style.top=`${a.top+window.scrollY-i.offsetHeight-8}px`,a.top<i.offsetHeight+8&&(i.style.top=`${a.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 Te(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();function Ae(n){let t=n;if(typeof t.kind=="string")return t;if(typeof t.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:t.tradeNO};if(typeof t.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:t.clientSecret};if(typeof t.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:t.redirectUrl};if(typeof t.formHtml=="string")return{kind:"alipay_page",formHtml:t.formHtml};if(typeof t.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:t.codeUrl};let e=t.jsapiPayParams??t;return typeof e.timeStamp=="string"&&typeof e.nonceStr=="string"&&typeof e.package=="string"&&typeof e.paySign=="string"&&typeof e.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:e.appId,timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign}}:null}function $e(n,t,e){return t.requestPayment(n.payParams,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,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,OverlayManager,Request,Response,SET_AUTH_TOKEN_HEADER,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,normalizePayParams,polyfill,requestPaymentFromOrderResult});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var re=Object.create;var N=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var dt=(n,t)=>()=>(n&&(t=n(n=0)),t);var x=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),oe=(n,t)=>{for(var e in t)N(n,e,{get:t[e],enumerable:!0})},pt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ne(t))!ae.call(n,s)&&s!==e&&N(n,s,{get:()=>t[s],enumerable:!(r=se(t,s))||r.enumerable});return n};var le=(n,t,e)=>(e=n!=null?re(ie(n)):{},pt(t||!n||!n.__esModule?N(e,"default",{value:n,enumerable:!0}):e,n)),A=n=>pt(N({},"__esModule",{value:!0}),n);import Ae from"path";import{fileURLToPath as Ce}from"url";var u=dt(()=>{"use strict"});var R={};oe(R,{__addDisposableResource:()=>Bt,__assign:()=>D,__asyncDelegator:()=>jt,__asyncGenerator:()=>Lt,__asyncValues:()=>It,__await:()=>$,__awaiter:()=>Rt,__classPrivateFieldGet:()=>qt,__classPrivateFieldIn:()=>Dt,__classPrivateFieldSet:()=>Mt,__createBinding:()=>F,__decorate:()=>bt,__disposeResources:()=>Ft,__esDecorate:()=>_t,__exportStar:()=>At,__extends:()=>wt,__generator:()=>Tt,__importDefault:()=>Ht,__importStar:()=>kt,__makeTemplateObject:()=>Nt,__metadata:()=>St,__param:()=>Pt,__propKey:()=>Ot,__read:()=>K,__rest:()=>vt,__rewriteRelativeImportExtension:()=>Wt,__runInitializers:()=>Et,__setFunctionName:()=>xt,__spread:()=>$t,__spreadArray:()=>Ut,__spreadArrays:()=>Ct,__values:()=>B,default:()=>ge});function wt(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(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 bt(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(i=(s<3?a(i):s>3?a(t,e,i):a(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i}function Pt(n,t){return function(e,r){t(e,r,n)}}function _t(n,t,e,r,s,i){function a(E){if(E!==void 0&&typeof E!="function")throw new TypeError("Function expected");return E}for(var o=r.kind,h=o==="getter"?"get":o==="setter"?"set":"value",l=!t&&n?r.static?n:n.prototype:null,c=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=e.length-1;p>=0;p--){var y={};for(var P in r)y[P]=P==="access"?{}:r[P];for(var P in r.access)y.access[P]=r.access[P];y.addInitializer=function(E){if(f)throw new TypeError("Cannot add initializers after decoration has completed");i.push(a(E||null))};var w=(0,e[p])(o==="accessor"?{get:c.get,set:c.set}:c[h],y);if(o==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(d=a(w.get))&&(c.get=d),(d=a(w.set))&&(c.set=d),(d=a(w.init))&&s.unshift(d)}else(d=a(w))&&(o==="field"?s.unshift(d):c[h]=d)}l&&Object.defineProperty(l,r.name,c),f=!0}function Et(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 Ot(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 St(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function Rt(n,t,e,r){function s(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function o(c){try{l(r.next(c))}catch(d){a(d)}}function h(c){try{l(r.throw(c))}catch(d){a(d)}}function l(c){c.done?i(c.value):s(c.value).then(o,h)}l((r=r.apply(n,t||[])).next())})}function Tt(n,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(c){return h([l,c])}}function h(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=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(c){l=[6,c],s=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function At(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 K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],a;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(a)throw a.error}}return i}function $t(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(K(arguments[t]));return n}function Ct(){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],a=0,o=i.length;a<o;a++,s++)r[s]=i[a];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 $(n){return this instanceof $?(this.v=n,this):new $(n)}function Lt(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),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(p){return function(y){return Promise.resolve(y).then(p,d)}}function o(p,y){r[p]&&(s[p]=function(P){return new Promise(function(w,E){i.push([p,P,w,E])>1||h(p,P)})},y&&(s[p]=y(s[p])))}function h(p,y){try{l(r[p](y))}catch(P){f(i[0][3],P)}}function l(p){p.value instanceof $?Promise.resolve(p.value.v).then(c,d):f(i[0][2],p)}function c(p){h("next",p)}function d(p){h("throw",p)}function f(p,y){p(y),i.shift(),i.length&&h(i[0][0],i[0][1])}}function jt(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(a){return(e=!e)?{value:$(n[s](a)),done:!1}:i?i(a):a}:i}}function It(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(a){return new Promise(function(o,h){a=n[i](a),s(o,h,a.done,a.value)})}}function s(i,a,o,h){Promise.resolve(h).then(function(l){i({value:l,done:o})},a)}}function Nt(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}function kt(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=G(n),r=0;r<e.length;r++)e[r]!=="default"&&F(t,n,e[r]);return pe(t,n),t}function Ht(n){return n&&n.__esModule?n:{default:n}}function qt(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 Mt(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 Dt(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 Bt(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 Ft(n){function t(i){n.error=n.hasError?new fe(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(a){return t(a),s()})}else r|=1}catch(a){t(a)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Wt(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,i,a){return r?t?".jsx":".js":s&&(!i||!a)?e:s+i+"."+a.toLowerCase()+"js"}):n}var J,D,F,pe,G,fe,ge,T=dt(()=>{"use strict";u();J=function(n,t){return J=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])},J(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]});pe=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},G=function(n){return G=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},G(n)};fe=typeof SuppressedError=="function"?SuppressedError:function(n,t,e){var r=new Error(e);return r.name="SuppressedError",r.error=n,r.suppressed=t,r};ge={__extends:wt,__assign:D,__rest:vt,__decorate:bt,__param:Pt,__esDecorate:_t,__runInitializers:Et,__propKey:Ot,__setFunctionName:xt,__metadata:St,__awaiter:Rt,__generator:Tt,__createBinding:F,__exportStar:At,__values:B,__read:K,__spread:$t,__spreadArrays:Ct,__spreadArray:Ut,__await:$,__asyncGenerator:Lt,__asyncDelegator:jt,__asyncValues:It,__makeTemplateObject:Nt,__importStar:kt,__importDefault:Ht,__classPrivateFieldGet:qt,__classPrivateFieldSet:Mt,__classPrivateFieldIn:Dt,__addDisposableResource:Bt,__disposeResources:Ft,__rewriteRelativeImportExtension:Wt}});var Q=x(V=>{"use strict";u();Object.defineProperty(V,"__esModule",{value:!0});var Y=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=Y});var tt=x(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var me=(T(),A(R)),ye=me.__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 a,o,h,l;let c=null,d=null,f=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")&&(!((a=this.headers.get("Accept"))===null||a===void 0)&&a.includes("application/vnd.pgrst.plan+text"))?d=I:d=JSON.parse(I))}let w=(o=this.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),E=(h=i.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");w&&E&&E.length>1&&(f=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(c={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,f=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let w=await i.text();try{c=JSON.parse(w),Array.isArray(c)&&i.status===404&&(d=[],c=null,p=200,y="OK")}catch{i.status===404&&w===""?(p=204,y="No Content"):c={message:w}}if(c&&this.isMaybeSingle&&(!((l=c?.details)===null||l===void 0)&&l.includes("0 rows"))&&(c=null,p=200,y="OK"),c&&this.shouldThrowOnError)throw new ye.default(c)}return{error:c,data:d,count:f,status:p,statusText:y}});return this.shouldThrowOnError||(s=s.catch(i=>{var a,o,h;return{error:{message:`${(a=i?.name)!==null&&a!==void 0?a:"FetchError"}: ${i?.message}`,details:`${(o=i?.stack)!==null&&o!==void 0?o:""}`,hint:"",code:`${(h=i?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),s.then(t,e)}returns(){return this}overrideTypes(){return this}};Z.default=X});var st=x(rt=>{"use strict";u();Object.defineProperty(rt,"__esModule",{value:!0});var we=(T(),A(R)),ve=we.__importDefault(tt()),et=class extends ve.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 a=i?`${i}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${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`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${t}`),this.url.searchParams.set(a,`${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:a="text"}={}){var o;let h=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${h};`),a==="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 W=x(it=>{"use strict";u();Object.defineProperty(it,"__esModule",{value:!0});var be=(T(),A(R)),Pe=be.__importDefault(st()),_e=new RegExp("[,()]"),nt=class extends Pe.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"&&_e.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 a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${i}fts${a}.${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=x(ot=>{"use strict";u();Object.defineProperty(ot,"__esModule",{value:!0});var Ee=(T(),A(R)),j=Ee.__importDefault(W()),at=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",a=!1,o=(t??"*").split("").map(h=>/\s/.test(h)&&!a?"":(h==='"'&&(a=!a),h)).join("");return this.url.searchParams.set("select",o),s&&this.headers.append("Prefer",`count=${s}`),new j.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 a=t.reduce((o,h)=>o.concat(Object.keys(h)),[]);if(a.length>0){let o=[...new Set(a)].map(h=>`"${h}"`);this.url.searchParams.set("columns",o.join(","))}}return new j.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 a;let o="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 h=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(h.length>0){let l=[...new Set(h)].map(c=>`"${c}"`);this.url.searchParams.set("columns",l.join(","))}}return new j.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}update(t,{count:e}={}){var r;let s="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new j.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 j.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}};ot.default=at});var Jt=x(ht=>{"use strict";u();Object.defineProperty(ht,"__esModule",{value:!0});var zt=(T(),A(R)),Oe=zt.__importDefault(lt()),xe=zt.__importDefault(W()),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 Oe.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 a;let o,h=new URL(`${this.url}/rpc/${t}`),l;r||s?(o=r?"HEAD":"GET",Object.entries(e).filter(([d,f])=>f!==void 0).map(([d,f])=>[d,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([d,f])=>{h.searchParams.append(d,f)})):(o="POST",l=e);let c=new Headers(this.headers);return i&&c.set("Prefer",`count=${i}`),new xe.default({method:o,url:h,headers:c,schema:this.schemaName,body:l,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};ht.default=ut});var Zt=x(b=>{"use strict";u();Object.defineProperty(b,"__esModule",{value:!0});b.PostgrestError=b.PostgrestBuilder=b.PostgrestTransformBuilder=b.PostgrestFilterBuilder=b.PostgrestQueryBuilder=b.PostgrestClient=void 0;var C=(T(),A(R)),Gt=C.__importDefault(Jt());b.PostgrestClient=Gt.default;var Kt=C.__importDefault(lt());b.PostgrestQueryBuilder=Kt.default;var Yt=C.__importDefault(W());b.PostgrestFilterBuilder=Yt.default;var Vt=C.__importDefault(st());b.PostgrestTransformBuilder=Vt.default;var Qt=C.__importDefault(tt());b.PostgrestBuilder=Qt.default;var Xt=C.__importDefault(Q());b.PostgrestError=Xt.default;b.default={PostgrestClient:Gt.default,PostgrestQueryBuilder:Kt.default,PostgrestFilterBuilder:Yt.default,PostgrestTransformBuilder:Vt.default,PostgrestBuilder:Qt.default,PostgrestError:Xt.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 v="nvwa_current_jwt",O="nvwa_login_token",S="nvwa_user_profile",gt="set-auth-token",ue=typeof fetch<"u"?(n,t)=>fetch(n,t):()=>{throw new Error("AuthClient requires fetch")},z=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??ue,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(S);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(S,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(O),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let s=e?.headers.get(gt)?.trim()||t.token||t.session?.token;s&&await this.storage.set(O,s),t.user&&await this.storage.set(S,t.user);let i=s??await this.storage.get(O),{data:a}=await this.getToken(i??void 0);a?.token&&await this.storage.set(v,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(O),await this.storage.remove(S),await this.storage.remove(v))}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",r),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),r}async getSession(){try{let t={};if(this.storage){let s=await this.storage.get(O)??await this.storage.get(v);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.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:this.credentials,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},r),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(O)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.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.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(O)??await this.storage.get(v);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...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.response),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.response),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.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(O,a.token),await this.storage.set(S,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(O,a.token),await this.storage.set(S,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,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,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var _=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()}},U=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}},k=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 U(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]||"/",a=e[7]?`?${e[7]}`:"",o=e[9]?`#${e[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let h=s.match(/^([^@]*)@(.+)$/),l="",c="",d=s;if(h){let P=h[1];d=h[2];let w=P.match(/^([^:]*):?(.*)$/);w&&(l=w[1]||"",c=w[2]||"")}let f=d.match(/^([^:]+):?(\d*)$/),p=f?f[1]:d,y=f&&f[2]?f[2]:"";return{protocol:r?`${r}:`:"",username:l,password:c,host:d,hostname:p,port:y,pathname:i,search:a,hash:o}}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 H=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 _?e.headers:new _(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=he(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 he(n){return n?new _(n):new _}u();var L=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 L}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function Qe(n){n.URL=k,n.URLSearchParams=U,n.Headers=_,n.Request=H,n.Response=q,n.AbortController=M,n.AbortSignal=L}var mt=class{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(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=e?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};u();var ce="/storage",de=ce+"/generateUploadUrl",yt=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+de,{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 _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var ct=le(Zt(),1),{PostgrestClient:te,PostgrestQueryBuilder:Nr,PostgrestFilterBuilder:kr,PostgrestTransformBuilder:Hr,PostgrestBuilder:qr,PostgrestError:Mr}=ct.default||ct;var Se="/entities",Wr=(n,t)=>new te(n+Se,{fetch:t.fetchWithAuth.bind(t)});u();var ee=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 re=Object.create;var L=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var pt=(n,t)=>()=>(n&&(t=n(n=0)),t);var x=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),oe=(n,t)=>{for(var e in t)L(n,e,{get:t[e],enumerable:!0})},dt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ne(t))!ae.call(n,s)&&s!==e&&L(n,s,{get:()=>t[s],enumerable:!(r=se(t,s))||r.enumerable});return n};var le=(n,t,e)=>(e=n!=null?re(ie(n)):{},dt(t||!n||!n.__esModule?L(e,"default",{value:n,enumerable:!0}):e,n)),A=n=>dt(L({},"__esModule",{value:!0}),n);import Ae from"path";import{fileURLToPath as ke}from"url";var u=pt(()=>{"use strict"});var R={};oe(R,{__addDisposableResource:()=>Bt,__assign:()=>D,__asyncDelegator:()=>Ct,__asyncGenerator:()=>jt,__asyncValues:()=>It,__await:()=>$,__awaiter:()=>Rt,__classPrivateFieldGet:()=>qt,__classPrivateFieldIn:()=>Dt,__classPrivateFieldSet:()=>Mt,__createBinding:()=>F,__decorate:()=>bt,__disposeResources:()=>Ft,__esDecorate:()=>_t,__exportStar:()=>At,__extends:()=>wt,__generator:()=>Tt,__importDefault:()=>Ht,__importStar:()=>Nt,__makeTemplateObject:()=>Lt,__metadata:()=>St,__param:()=>Pt,__propKey:()=>Ot,__read:()=>K,__rest:()=>vt,__rewriteRelativeImportExtension:()=>Wt,__runInitializers:()=>Et,__setFunctionName:()=>xt,__spread:()=>$t,__spreadArray:()=>Ut,__spreadArrays:()=>kt,__values:()=>B,default:()=>ge});function wt(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(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 bt(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(i=(s<3?a(i):s>3?a(t,e,i):a(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i}function Pt(n,t){return function(e,r){t(e,r,n)}}function _t(n,t,e,r,s,i){function a(E){if(E!==void 0&&typeof E!="function")throw new TypeError("Function expected");return E}for(var o=r.kind,c=o==="getter"?"get":o==="setter"?"set":"value",l=!t&&n?r.static?n:n.prototype:null,h=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),p,f=!1,d=e.length-1;d>=0;d--){var y={};for(var P in r)y[P]=P==="access"?{}:r[P];for(var P in r.access)y.access[P]=r.access[P];y.addInitializer=function(E){if(f)throw new TypeError("Cannot add initializers after decoration has completed");i.push(a(E||null))};var w=(0,e[d])(o==="accessor"?{get:h.get,set:h.set}:h[c],y);if(o==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(p=a(w.get))&&(h.get=p),(p=a(w.set))&&(h.set=p),(p=a(w.init))&&s.unshift(p)}else(p=a(w))&&(o==="field"?s.unshift(p):h[c]=p)}l&&Object.defineProperty(l,r.name,h),f=!0}function Et(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 Ot(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 St(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function Rt(n,t,e,r){function s(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function o(h){try{l(r.next(h))}catch(p){a(p)}}function c(h){try{l(r.throw(h))}catch(p){a(p)}}function l(h){h.done?i(h.value):s(h.value).then(o,c)}l((r=r.apply(n,t||[])).next())})}function Tt(n,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=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 At(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 K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],a;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(a)throw a.error}}return i}function $t(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(K(arguments[t]));return n}function kt(){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],a=0,o=i.length;a<o;a++,s++)r[s]=i[a];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 $(n){return this instanceof $?(this.v=n,this):new $(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),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(d){return function(y){return Promise.resolve(y).then(d,p)}}function o(d,y){r[d]&&(s[d]=function(P){return new Promise(function(w,E){i.push([d,P,w,E])>1||c(d,P)})},y&&(s[d]=y(s[d])))}function c(d,y){try{l(r[d](y))}catch(P){f(i[0][3],P)}}function l(d){d.value instanceof $?Promise.resolve(d.value.v).then(h,p):f(i[0][2],d)}function h(d){c("next",d)}function p(d){c("throw",d)}function f(d,y){d(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(a){return(e=!e)?{value:$(n[s](a)),done:!1}:i?i(a):a}:i}}function It(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(a){return new Promise(function(o,c){a=n[i](a),s(o,c,a.done,a.value)})}}function s(i,a,o,c){Promise.resolve(c).then(function(l){i({value:l,done:o})},a)}}function Lt(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}function Nt(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=G(n),r=0;r<e.length;r++)e[r]!=="default"&&F(t,n,e[r]);return de(t,n),t}function Ht(n){return n&&n.__esModule?n:{default:n}}function qt(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 Mt(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 Dt(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 Bt(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 Ft(n){function t(i){n.error=n.hasError?new fe(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(a){return t(a),s()})}else r|=1}catch(a){t(a)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s()}function Wt(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,s,i,a){return r?t?".jsx":".js":s&&(!i||!a)?e:s+i+"."+a.toLowerCase()+"js"}):n}var J,D,F,de,G,fe,ge,T=pt(()=>{"use strict";u();J=function(n,t){return J=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])},J(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]});de=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},G=function(n){return G=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},G(n)};fe=typeof SuppressedError=="function"?SuppressedError:function(n,t,e){var r=new Error(e);return r.name="SuppressedError",r.error=n,r.suppressed=t,r};ge={__extends:wt,__assign:D,__rest:vt,__decorate:bt,__param:Pt,__esDecorate:_t,__runInitializers:Et,__propKey:Ot,__setFunctionName:xt,__metadata:St,__awaiter:Rt,__generator:Tt,__createBinding:F,__exportStar:At,__values:B,__read:K,__spread:$t,__spreadArrays:kt,__spreadArray:Ut,__await:$,__asyncGenerator:jt,__asyncDelegator:Ct,__asyncValues:It,__makeTemplateObject:Lt,__importStar:Nt,__importDefault:Ht,__classPrivateFieldGet:qt,__classPrivateFieldSet:Mt,__classPrivateFieldIn:Dt,__addDisposableResource:Bt,__disposeResources:Ft,__rewriteRelativeImportExtension:Wt}});var Q=x(V=>{"use strict";u();Object.defineProperty(V,"__esModule",{value:!0});var Y=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=Y});var tt=x(Z=>{"use strict";u();Object.defineProperty(Z,"__esModule",{value:!0});var me=(T(),A(R)),ye=me.__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 a,o,c,l;let h=null,p=null,f=null,d=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")&&(!((a=this.headers.get("Accept"))===null||a===void 0)&&a.includes("application/vnd.pgrst.plan+text"))?p=I:p=JSON.parse(I))}let w=(o=this.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),E=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");w&&E&&E.length>1&&(f=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(h={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,f=null,d=406,y="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let w=await i.text();try{h=JSON.parse(w),Array.isArray(h)&&i.status===404&&(p=[],h=null,d=200,y="OK")}catch{i.status===404&&w===""?(d=204,y="No Content"):h={message:w}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,d=200,y="OK"),h&&this.shouldThrowOnError)throw new ye.default(h)}return{error:h,data:p,count:f,status:d,statusText:y}});return this.shouldThrowOnError||(s=s.catch(i=>{var a,o,c;return{error:{message:`${(a=i?.name)!==null&&a!==void 0?a:"FetchError"}: ${i?.message}`,details:`${(o=i?.stack)!==null&&o!==void 0?o:""}`,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=x(rt=>{"use strict";u();Object.defineProperty(rt,"__esModule",{value:!0});var we=(T(),A(R)),ve=we.__importDefault(tt()),et=class extends ve.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 a=i?`${i}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${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`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${t}`),this.url.searchParams.set(a,`${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:a="text"}={}){var o;let c=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${c};`),a==="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 W=x(it=>{"use strict";u();Object.defineProperty(it,"__esModule",{value:!0});var be=(T(),A(R)),Pe=be.__importDefault(st()),_e=new RegExp("[,()]"),nt=class extends Pe.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"&&_e.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 a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${i}fts${a}.${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=x(ot=>{"use strict";u();Object.defineProperty(ot,"__esModule",{value:!0});var Ee=(T(),A(R)),C=Ee.__importDefault(W()),at=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",a=!1,o=(t??"*").split("").map(c=>/\s/.test(c)&&!a?"":(c==='"'&&(a=!a),c)).join("");return this.url.searchParams.set("select",o),s&&this.headers.append("Prefer",`count=${s}`),new C.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 a=t.reduce((o,c)=>o.concat(Object.keys(c)),[]);if(a.length>0){let o=[...new Set(a)].map(c=>`"${c}"`);this.url.searchParams.set("columns",o.join(","))}}return new C.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 a;let o="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 C.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}update(t,{count:e}={}){var r;let s="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new C.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 C.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}};ot.default=at});var Jt=x(ct=>{"use strict";u();Object.defineProperty(ct,"__esModule",{value:!0});var zt=(T(),A(R)),Oe=zt.__importDefault(lt()),xe=zt.__importDefault(W()),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 Oe.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 a;let o,c=new URL(`${this.url}/rpc/${t}`),l;r||s?(o=r?"HEAD":"GET",Object.entries(e).filter(([p,f])=>f!==void 0).map(([p,f])=>[p,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([p,f])=>{c.searchParams.append(p,f)})):(o="POST",l=e);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new xe.default({method:o,url:c,headers:h,schema:this.schemaName,body:l,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};ct.default=ut});var Zt=x(b=>{"use strict";u();Object.defineProperty(b,"__esModule",{value:!0});b.PostgrestError=b.PostgrestBuilder=b.PostgrestTransformBuilder=b.PostgrestFilterBuilder=b.PostgrestQueryBuilder=b.PostgrestClient=void 0;var k=(T(),A(R)),Gt=k.__importDefault(Jt());b.PostgrestClient=Gt.default;var Kt=k.__importDefault(lt());b.PostgrestQueryBuilder=Kt.default;var Yt=k.__importDefault(W());b.PostgrestFilterBuilder=Yt.default;var Vt=k.__importDefault(st());b.PostgrestTransformBuilder=Vt.default;var Qt=k.__importDefault(tt());b.PostgrestBuilder=Qt.default;var Xt=k.__importDefault(Q());b.PostgrestError=Xt.default;b.default={PostgrestClient:Gt.default,PostgrestQueryBuilder:Kt.default,PostgrestFilterBuilder:Yt.default,PostgrestTransformBuilder:Vt.default,PostgrestBuilder:Qt.default,PostgrestError:Xt.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 v="nvwa_current_jwt",O="nvwa_login_token",S="nvwa_user_profile",gt="set-auth-token",ue=typeof fetch<"u"?(n,t)=>fetch(n,t):()=>{throw new Error("AuthClient requires fetch")},z=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??ue,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(S);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(S,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(O),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let s=e?.headers.get(gt)?.trim()||t.token||t.session?.token;s&&await this.storage.set(O,s),t.user&&await this.storage.set(S,t.user);let i=s??await this.storage.get(O),{data:a}=await this.getToken(i??void 0);a?.token&&await this.storage.set(v,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(O),await this.storage.remove(S),await this.storage.remove(v))}url(t){let r=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",r),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),r}async getSession(){try{let t={};if(this.storage){let s=await this.storage.get(O)??await this.storage.get(v);s!=null&&(t.Authorization=`Bearer ${s}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.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:this.credentials,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},r),{data:i}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(O)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.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.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(O)??await this.storage.get(v);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...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.response),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.response),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.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(O,a.token),await this.storage.set(S,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(O,a.token),await this.storage.set(S,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),i=await s.text();if(!s.ok)return{error:{message:i||s.statusText,status:s.status}};let a=i?JSON.parse(i):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,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,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};u();u();var _=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()}},U=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 U(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]||"/",a=e[7]?`?${e[7]}`:"",o=e[9]?`#${e[9]}`:"";if(!r&&!s&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let c=s.match(/^([^@]*)@(.+)$/),l="",h="",p=s;if(c){let P=c[1];p=c[2];let w=P.match(/^([^:]*):?(.*)$/);w&&(l=w[1]||"",h=w[2]||"")}let f=p.match(/^([^:]+):?(\d*)$/),d=f?f[1]:p,y=f&&f[2]?f[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:p,hostname:d,port:y,pathname:i,search:a,hash:o}}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 H=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 _?e.headers:new _(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=ce(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 ce(n){return n?new _(n):new _}u();var j=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 j}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};u();function Qe(n){n.URL=N,n.URLSearchParams=U,n.Headers=_,n.Request=H,n.Response=q,n.AbortController=M,n.AbortSignal=j}var mt=class{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(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let i=e?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};u();var he="/storage",pe=he+"/generateUploadUrl",yt=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+pe,{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 _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:i}=await s.json();return{url:i.split("?")[0]}}};u();u();u();var ht=le(Zt(),1),{PostgrestClient:te,PostgrestQueryBuilder:Lr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:Hr,PostgrestBuilder:qr,PostgrestError:Mr}=ht.default||ht;var Se="/entities",Wr=(n,t)=>new te(n+Se,{fetch:t.fetchWithAuth.bind(t)});u();var ee=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=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@ var re=Object.create;var N=Object.defineProperty;var se=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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let h=t.getBoundingClientRect();o.style.left=`${h.left+window.scrollX}px`,o.style.top=`${h.top+window.scrollY-o.offsetHeight-8}px`,h.top<o.offsetHeight+8&&(o.style.top=`${h.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 a=t.getBoundingClientRect();i.style.left=`${a.left+window.scrollX}px`,i.style.top=`${a.top+window.scrollY-i.offsetHeight-8}px`,a.top<i.offsetHeight+8&&(i.style.top=`${a.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 Gr(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();function Vr(n,t){return t.requestPayment(n.payParams)}export{M as AbortController,L as AbortSignal,z as AuthClient,v as CURRENT_JWT_KEY,Se as ENTITIES_BASE_PATH,ce as FILE_STORAGE_BASE_PATH,de as GENERATE_UPLOAD_URL_PATH,_ as Headers,O as LOGIN_TOKEN_KEY,S as LOGIN_USER_PROFILE_KEY,ft as NvwaEdgeFunctions,yt as NvwaFileStorage,mt as NvwaHttpClient,ee as OverlayManager,H as Request,q as Response,gt as SET_AUTH_TOKEN_HEADER,k as URL,U as URLSearchParams,Wr as createPostgrestClient,Gr as getSourceLocationFromDOM,Qe as polyfill,Vr as requestPaymentFromOrderResult};
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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let c=t.getBoundingClientRect();o.style.left=`${c.left+window.scrollX}px`,o.style.top=`${c.top+window.scrollY-o.offsetHeight-8}px`,c.top<o.offsetHeight+8&&(o.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 a=t.getBoundingClientRect();i.style.left=`${a.left+window.scrollX}px`,i.style.top=`${a.top+window.scrollY-i.offsetHeight-8}px`,a.top<i.offsetHeight+8&&(i.style.top=`${a.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 Gr(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();function Vr(n){let t=n;if(typeof t.kind=="string")return t;if(typeof t.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:t.tradeNO};if(typeof t.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:t.clientSecret};if(typeof t.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:t.redirectUrl};if(typeof t.formHtml=="string")return{kind:"alipay_page",formHtml:t.formHtml};if(typeof t.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:t.codeUrl};let e=t.jsapiPayParams??t;return typeof e.timeStamp=="string"&&typeof e.nonceStr=="string"&&typeof e.package=="string"&&typeof e.paySign=="string"&&typeof e.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:e.appId,timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign}}:null}function Qr(n,t,e){return t.requestPayment(n.payParams,e)}export{M as AbortController,j as AbortSignal,z as AuthClient,v as CURRENT_JWT_KEY,Se as ENTITIES_BASE_PATH,he as FILE_STORAGE_BASE_PATH,pe as GENERATE_UPLOAD_URL_PATH,_ as Headers,O as LOGIN_TOKEN_KEY,S as LOGIN_USER_PROFILE_KEY,ft as NvwaEdgeFunctions,yt as NvwaFileStorage,mt as NvwaHttpClient,ee as OverlayManager,H as Request,q as Response,gt as SET_AUTH_TOKEN_HEADER,N as URL,U as URLSearchParams,Wr as createPostgrestClient,Gr as getSourceLocationFromDOM,Vr as normalizePayParams,Qe as polyfill,Qr as requestPaymentFromOrderResult};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-core",
3
- "version": "6.0.55",
3
+ "version": "6.1.0",
4
4
  "description": "NVWA跨端通用工具类核心接口",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",