@nvwa-app/sdk-core 4.0.0 → 5.0.1

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
@@ -67,7 +67,7 @@ interface RequestInit$1 {
67
67
  type RequestInfo = string | {
68
68
  url?: string;
69
69
  } | URL;
70
- declare class Request {
70
+ declare class Request$1 {
71
71
  readonly url: string;
72
72
  readonly method: string;
73
73
  readonly headers: Headers;
@@ -75,7 +75,7 @@ declare class Request {
75
75
  readonly timeout?: number;
76
76
  readonly signal?: any;
77
77
  constructor(input: RequestInfo, init?: RequestInit$1);
78
- clone(): Request;
78
+ clone(): Request$1;
79
79
  toString(): string;
80
80
  }
81
81
 
@@ -228,8 +228,8 @@ declare class OverlayManager {
228
228
  declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
229
229
 
230
230
  /**
231
- * Payment 客户端:供生成应用(项目侧)调用项目自己的 payment API(由 Example 提供)。
232
- * 仅封装请求形态,不涉及持久化;与 Workspace 积分充值无关。
231
+ * Payment 客户端:供生成应用(项目侧)调用项目 runtime 内置的 payment API
232
+ * 请求形态与 ProjectPaymentApi(@Rpc)一致;与 Workspace 积分充值无关。
233
233
  */
234
234
  interface CreatePaymentParams {
235
235
  /** 金额(最小单位,如分) */
@@ -279,11 +279,12 @@ declare class PaymentClient {
279
279
  private pathPrefix;
280
280
  private fetchImpl;
281
281
  constructor(baseUrl: string, pathPrefix?: string, fetchImpl?: PaymentFetch);
282
- private url;
282
+ /** RPC 风格路径:baseUrl + pathPrefix + /methodName,POST JSON body */
283
+ private rpc;
283
284
  /**
284
285
  * 获取在当前端可用的 payment provider 列表。
285
286
  * - 可传 platform:只返回在该端能完成支付的 provider(如微信小程序内仅返回 wechat-pay)。
286
- * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤;否则可传 ?platform=xxx 由 backend 过滤。
287
+ * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤。
287
288
  * 若 backend 未实现该接口则返回空数组。
288
289
  */
289
290
  getConfiguredProviders(options?: {
@@ -304,6 +305,71 @@ declare class PaymentClient {
304
305
  cancelOrder(orderId: number): Promise<void>;
305
306
  }
306
307
 
308
+ /**
309
+ * Auth 常量与客户端:CURRENT_JWT_KEY 供 NvwaHttpClient 使用;
310
+ * AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
311
+ */
312
+ declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
313
+ interface AuthSession {
314
+ user?: {
315
+ id: string;
316
+ email?: string;
317
+ name?: string;
318
+ [k: string]: unknown;
319
+ };
320
+ session?: {
321
+ token?: string;
322
+ [k: string]: unknown;
323
+ };
324
+ [k: string]: unknown;
325
+ }
326
+ interface AuthClientOptions {
327
+ /** Auth 路径,默认 "/auth"(与 runtime 的 basePath 一致) */
328
+ authPath?: string;
329
+ /** 自定义 fetch,默认全局 fetch */
330
+ fetchImpl?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
331
+ }
332
+ /**
333
+ * 项目侧 Auth 客户端:getSession、邮箱登录、登出。
334
+ * baseUrl 为项目根地址(如 "https://xxx.nvwa.app"),请求发往 baseUrl + authPath。
335
+ */
336
+ declare class AuthClient {
337
+ private baseUrl;
338
+ private authPath;
339
+ private fetchImpl;
340
+ constructor(baseUrl: string, options?: AuthClientOptions);
341
+ private url;
342
+ /**
343
+ * 获取当前 session(依赖 cookie 或 Authorization header,与 runtime 配置一致)。
344
+ */
345
+ getSession(): Promise<{
346
+ data: AuthSession | null;
347
+ error?: {
348
+ message: string;
349
+ status: number;
350
+ };
351
+ }>;
352
+ /**
353
+ * 邮箱密码登录。
354
+ */
355
+ signInWithEmail(email: string, password: string): Promise<{
356
+ data?: AuthSession;
357
+ error?: {
358
+ message: string;
359
+ status: number;
360
+ };
361
+ }>;
362
+ /**
363
+ * 登出。
364
+ */
365
+ signOut(): Promise<{
366
+ error?: {
367
+ message: string;
368
+ status: number;
369
+ };
370
+ }>;
371
+ }
372
+
307
373
  interface INvwa {
308
374
  entities: PostgrestClient;
309
375
  functions: NvwaEdgeFunctions;
@@ -311,4 +377,4 @@ interface INvwa {
311
377
  skill: NvwaSkill;
312
378
  }
313
379
 
314
- export { AbortController, AbortSignal, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
380
+ export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthSession, CURRENT_JWT_KEY, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
package/dist/index.d.ts CHANGED
@@ -67,7 +67,7 @@ interface RequestInit$1 {
67
67
  type RequestInfo = string | {
68
68
  url?: string;
69
69
  } | URL;
70
- declare class Request {
70
+ declare class Request$1 {
71
71
  readonly url: string;
72
72
  readonly method: string;
73
73
  readonly headers: Headers;
@@ -75,7 +75,7 @@ declare class Request {
75
75
  readonly timeout?: number;
76
76
  readonly signal?: any;
77
77
  constructor(input: RequestInfo, init?: RequestInit$1);
78
- clone(): Request;
78
+ clone(): Request$1;
79
79
  toString(): string;
80
80
  }
81
81
 
@@ -228,8 +228,8 @@ declare class OverlayManager {
228
228
  declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
229
229
 
230
230
  /**
231
- * Payment 客户端:供生成应用(项目侧)调用项目自己的 payment API(由 Example 提供)。
232
- * 仅封装请求形态,不涉及持久化;与 Workspace 积分充值无关。
231
+ * Payment 客户端:供生成应用(项目侧)调用项目 runtime 内置的 payment API
232
+ * 请求形态与 ProjectPaymentApi(@Rpc)一致;与 Workspace 积分充值无关。
233
233
  */
234
234
  interface CreatePaymentParams {
235
235
  /** 金额(最小单位,如分) */
@@ -279,11 +279,12 @@ declare class PaymentClient {
279
279
  private pathPrefix;
280
280
  private fetchImpl;
281
281
  constructor(baseUrl: string, pathPrefix?: string, fetchImpl?: PaymentFetch);
282
- private url;
282
+ /** RPC 风格路径:baseUrl + pathPrefix + /methodName,POST JSON body */
283
+ private rpc;
283
284
  /**
284
285
  * 获取在当前端可用的 payment provider 列表。
285
286
  * - 可传 platform:只返回在该端能完成支付的 provider(如微信小程序内仅返回 wechat-pay)。
286
- * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤;否则可传 ?platform=xxx 由 backend 过滤。
287
+ * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤。
287
288
  * 若 backend 未实现该接口则返回空数组。
288
289
  */
289
290
  getConfiguredProviders(options?: {
@@ -304,6 +305,71 @@ declare class PaymentClient {
304
305
  cancelOrder(orderId: number): Promise<void>;
305
306
  }
306
307
 
308
+ /**
309
+ * Auth 常量与客户端:CURRENT_JWT_KEY 供 NvwaHttpClient 使用;
310
+ * AuthClient 调用项目 runtime 的 /auth 接口(better-auth)。
311
+ */
312
+ declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
313
+ interface AuthSession {
314
+ user?: {
315
+ id: string;
316
+ email?: string;
317
+ name?: string;
318
+ [k: string]: unknown;
319
+ };
320
+ session?: {
321
+ token?: string;
322
+ [k: string]: unknown;
323
+ };
324
+ [k: string]: unknown;
325
+ }
326
+ interface AuthClientOptions {
327
+ /** Auth 路径,默认 "/auth"(与 runtime 的 basePath 一致) */
328
+ authPath?: string;
329
+ /** 自定义 fetch,默认全局 fetch */
330
+ fetchImpl?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
331
+ }
332
+ /**
333
+ * 项目侧 Auth 客户端:getSession、邮箱登录、登出。
334
+ * baseUrl 为项目根地址(如 "https://xxx.nvwa.app"),请求发往 baseUrl + authPath。
335
+ */
336
+ declare class AuthClient {
337
+ private baseUrl;
338
+ private authPath;
339
+ private fetchImpl;
340
+ constructor(baseUrl: string, options?: AuthClientOptions);
341
+ private url;
342
+ /**
343
+ * 获取当前 session(依赖 cookie 或 Authorization header,与 runtime 配置一致)。
344
+ */
345
+ getSession(): Promise<{
346
+ data: AuthSession | null;
347
+ error?: {
348
+ message: string;
349
+ status: number;
350
+ };
351
+ }>;
352
+ /**
353
+ * 邮箱密码登录。
354
+ */
355
+ signInWithEmail(email: string, password: string): Promise<{
356
+ data?: AuthSession;
357
+ error?: {
358
+ message: string;
359
+ status: number;
360
+ };
361
+ }>;
362
+ /**
363
+ * 登出。
364
+ */
365
+ signOut(): Promise<{
366
+ error?: {
367
+ message: string;
368
+ status: number;
369
+ };
370
+ }>;
371
+ }
372
+
307
373
  interface INvwa {
308
374
  entities: PostgrestClient;
309
375
  functions: NvwaEdgeFunctions;
@@ -311,4 +377,4 @@ interface INvwa {
311
377
  skill: NvwaSkill;
312
378
  }
313
379
 
314
- export { AbortController, AbortSignal, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
380
+ export { AbortController, AbortSignal, AuthClient, type AuthClientOptions, type AuthSession, CURRENT_JWT_KEY, type CreatePaymentParams, type CreatePaymentResponse, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, type OrderStatus, OverlayManager, type PayParams, PaymentClient, type PaymentFetch, type PaymentOrderStatus, type PaymentPlatform, Request$1 as Request, type RequestInfo, type RequestInit$1 as RequestInit, Response$1 as Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var st=Object.create;var L=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var pe=(s,e)=>()=>(s&&(e=s(s=0)),e);var _=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),fe=(s,e)=>{for(var t in e)L(s,t,{get:e[t],enumerable:!0})},me=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ot(e))!at.call(s,n)&&n!==t&&L(s,n,{get:()=>e[n],enumerable:!(r=nt(e,n))||r.enumerable});return s};var lt=(s,e,t)=>(t=s!=null?st(it(s)):{},me(e||!s||!s.__esModule?L(t,"default",{value:s,enumerable:!0}):t,s)),E=s=>me(L({},"__esModule",{value:!0}),s);var h=pe(()=>{"use strict"});var x={};fe(x,{__addDisposableResource:()=>Fe,__assign:()=>N,__asyncDelegator:()=>Ie,__asyncGenerator:()=>Ae,__asyncValues:()=>Le,__await:()=>T,__awaiter:()=>Te,__classPrivateFieldGet:()=>qe,__classPrivateFieldIn:()=>Be,__classPrivateFieldSet:()=>De,__createBinding:()=>M,__decorate:()=>Pe,__disposeResources:()=>ze,__esDecorate:()=>Ee,__exportStar:()=>je,__extends:()=>we,__generator:()=>Re,__importDefault:()=>Me,__importStar:()=>ke,__makeTemplateObject:()=>Ne,__metadata:()=>$e,__param:()=>_e,__propKey:()=>Oe,__read:()=>J,__rest:()=>be,__rewriteRelativeImportExtension:()=>Ge,__runInitializers:()=>xe,__setFunctionName:()=>Se,__spread:()=>He,__spreadArray:()=>Ue,__spreadArrays:()=>Ce,__values:()=>k,default:()=>pt});function we(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");z(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function be(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function Pe(s,e,t,r){var n=arguments.length,o=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(i=s[a])&&(o=(n<3?i(o):n>3?i(e,t,o):i(e,t))||o);return n>3&&o&&Object.defineProperty(e,t,o),o}function _e(s,e){return function(t,r){e(t,r,s)}}function Ee(s,e,t,r,n,o){function i(P){if(P!==void 0&&typeof P!="function")throw new TypeError("Function expected");return P}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&s?r.static?s:s.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,m=!1,p=t.length-1;p>=0;p--){var y={};for(var b in r)y[b]=b==="access"?{}:r[b];for(var b in r.access)y.access[b]=r.access[b];y.addInitializer=function(P){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(P||null))};var g=(0,t[p])(a==="accessor"?{get:u.get,set:u.set}:u[c],y);if(a==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(d=i(g.get))&&(u.get=d),(d=i(g.set))&&(u.set=d),(d=i(g.init))&&n.unshift(d)}else(d=i(g))&&(a==="field"?n.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),m=!0}function xe(s,e,t){for(var r=arguments.length>2,n=0;n<e.length;n++)t=r?e[n].call(s,t):e[n].call(s);return r?t:void 0}function Oe(s){return typeof s=="symbol"?s:"".concat(s)}function Se(s,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(s,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function $e(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function Te(s,e,t,r){function n(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{l(r.next(u))}catch(d){i(d)}}function c(u){try{l(r.throw(u))}catch(d){i(d)}}function l(u){u.done?o(u.value):n(u.value).then(a,c)}l((r=r.apply(s,e||[])).next())})}function Re(s,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(o=l[0]&2?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){t.label=l[1];break}if(l[0]===6&&t.label<o[1]){t.label=o[1],o=l;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(l);break}o[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(u){l=[6,u],n=0}finally{r=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function je(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&M(e,s,t)}function k(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],r=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&r>=s.length&&(s=void 0),{value:s&&s[r++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function J(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,o=[],i;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o}function He(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(J(arguments[e]));return s}function Ce(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var r=Array(s),n=0,e=0;e<t;e++)for(var o=arguments[e],i=0,a=o.length;i<a;i++,n++)r[n]=o[i];return r}function Ue(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,o;r<n;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return s.concat(o||Array.prototype.slice.call(e))}function T(s){return this instanceof T?(this.v=s,this):new T(s)}function Ae(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),n[Symbol.asyncIterator]=function(){return this},n;function i(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(n[p]=function(b){return new Promise(function(g,P){o.push([p,b,g,P])>1||c(p,b)})},y&&(n[p]=y(n[p])))}function c(p,y){try{l(r[p](y))}catch(b){m(o[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(u,d):m(o[0][2],p)}function u(p){c("next",p)}function d(p){c("throw",p)}function m(p,y){p(y),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Ie(s){var e,t;return e={},r("next"),r("throw",function(n){throw n}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(n,o){e[n]=s[n]?function(i){return(t=!t)?{value:T(s[n](i)),done:!1}:o?o(i):i}:o}}function Le(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof k=="function"?k(s):s[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=s[o]&&function(i){return new Promise(function(a,c){i=s[o](i),n(a,c,i.done,i.value)})}}function n(o,i,a,c){Promise.resolve(c).then(function(l){o({value:l,done:a})},i)}}function Ne(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function ke(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t=G(s),r=0;r<t.length;r++)t[r]!=="default"&&M(e,s,t[r]);return ut(e,s),e}function Me(s){return s&&s.__esModule?s:{default:s}}function qe(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}function De(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}function Be(s,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof s=="function"?e===s:s.has(e)}function Fe(s,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,n;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(n=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");n&&(r=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function ze(s){function e(o){s.error=s.hasError?new dt(o,s.error,"An error was suppressed during disposal."):o,s.hasError=!0}var t,r=0;function n(){for(;t=s.stack.pop();)try{if(!t.async&&r===1)return r=0,s.stack.push(t),Promise.resolve().then(n);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(o).then(n,function(i){return e(i),n()})}else r|=1}catch(i){e(i)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function Ge(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,o,i){return r?e?".jsx":".js":n&&(!o||!i)?t:n+o+"."+i.toLowerCase()+"js"}):s}var z,N,M,ut,G,dt,pt,O=pe(()=>{"use strict";h();z=function(s,e){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},z(s,e)};N=function(){return N=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},N.apply(this,arguments)};M=Object.create?(function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}):(function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]});ut=Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}):function(s,e){s.default=e},G=function(s){return G=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},G(s)};dt=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};pt={__extends:we,__assign:N,__rest:be,__decorate:Pe,__param:_e,__esDecorate:Ee,__runInitializers:xe,__propKey:Oe,__setFunctionName:Se,__metadata:$e,__awaiter:Te,__generator:Re,__createBinding:M,__exportStar:je,__values:k,__read:J,__spread:He,__spreadArrays:Ce,__spreadArray:Ue,__await:T,__asyncGenerator:Ae,__asyncDelegator:Ie,__asyncValues:Le,__makeTemplateObject:Ne,__importStar:ke,__importDefault:Me,__classPrivateFieldGet:qe,__classPrivateFieldSet:De,__classPrivateFieldIn:Be,__addDisposableResource:Fe,__disposeResources:ze,__rewriteRelativeImportExtension:Ge}});var Y=_(V=>{"use strict";h();Object.defineProperty(V,"__esModule",{value:!0});var W=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};V.default=W});var X=_(K=>{"use strict";h();Object.defineProperty(K,"__esModule",{value:!0});var ft=(O(),E(x)),mt=ft.__importDefault(Y()),Q=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,a,c,l;let u=null,d=null,m=null,p=o.status,y=o.statusText;if(o.ok){if(this.method!=="HEAD"){let I=await o.text();I===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=I:d=JSON.parse(I))}let g=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),P=(c=o.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");g&&P&&P.length>1&&(m=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let g=await o.text();try{u=JSON.parse(g),Array.isArray(u)&&o.status===404&&(d=[],u=null,p=200,y="OK")}catch{o.status===404&&g===""?(p=204,y="No Content"):u={message:g}}if(u&&this.isMaybeSingle&&(!((l=u?.details)===null||l===void 0)&&l.includes("0 rows"))&&(u=null,p=200,y="OK"),u&&this.shouldThrowOnError)throw new mt.default(u)}return{error:u,data:d,count:m,status:p,statusText:y}});return this.shouldThrowOnError||(n=n.catch(o=>{var i,a,c;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(a=o?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=o?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};K.default=Q});var te=_(ee=>{"use strict";h();Object.defineProperty(ee,"__esModule",{value:!0});var yt=(O(),E(x)),gt=yt.__importDefault(X()),Z=class extends gt.default{select(e){let t=!1,r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:o=n}={}){let i=o?`${o}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){let o=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:o=!1,format:i="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,o?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${c};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};ee.default=Z});var q=_(se=>{"use strict";h();Object.defineProperty(se,"__esModule",{value:!0});var vt=(O(),E(x)),wt=vt.__importDefault(te()),bt=new RegExp("[,()]"),re=class extends wt.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(n=>typeof n=="string"&&bt.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let o="";n==="plain"?o="pl":n==="phrase"?o="ph":n==="websearch"&&(o="w");let i=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};se.default=re});var ie=_(oe=>{"use strict";h();Object.defineProperty(oe,"__esModule",{value:!0});var Pt=(O(),E(x)),A=Pt.__importDefault(q()),ne=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n}select(e,t){let{head:r=!1,count:n}=t??{},o=r?"HEAD":"GET",i=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new A.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(i.length>0){let a=[...new Set(i)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new A.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:o=!0}={}){var i;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.reduce((l,u)=>l.concat(Object.keys(u)),[]);if(c.length>0){let l=[...new Set(c)].map(u=>`"${u}"`);this.url.searchParams.set("columns",l.join(","))}}return new A.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var r;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new A.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new A.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};oe.default=ne});var We=_(le=>{"use strict";h();Object.defineProperty(le,"__esModule",{value:!0});var Je=(O(),E(x)),_t=Je.__importDefault(ie()),Et=Je.__importDefault(q()),ae=class s{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=n}from(e){let t=new URL(`${this.url}/${e}`);return new _t.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new s(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:o}={}){var i;let a,c=new URL(`${this.url}/rpc/${e}`),l;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{c.searchParams.append(d,m)})):(a="POST",l=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Et.default({method:a,url:c,headers:u,schema:this.schemaName,body:l,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};le.default=ae});var et=_(w=>{"use strict";h();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var R=(O(),E(x)),Ve=R.__importDefault(We());w.PostgrestClient=Ve.default;var Ye=R.__importDefault(ie());w.PostgrestQueryBuilder=Ye.default;var Qe=R.__importDefault(q());w.PostgrestFilterBuilder=Qe.default;var Ke=R.__importDefault(te());w.PostgrestTransformBuilder=Ke.default;var Xe=R.__importDefault(X());w.PostgrestBuilder=Xe.default;var Ze=R.__importDefault(Y());w.PostgrestError=Ze.default;w.default={PostgrestClient:Ve.default,PostgrestQueryBuilder:Ye.default,PostgrestFilterBuilder:Qe.default,PostgrestTransformBuilder:Ke.default,PostgrestBuilder:Xe.default,PostgrestError:Ze.default}});var $t={};fe($t,{AbortController:()=>U,AbortSignal:()=>$,ENTITIES_BASE_PATH:()=>rt,FILE_STORAGE_BASE_PATH:()=>ge,GENERATE_UPLOAD_URL_PATH:()=>ve,Headers:()=>v,NvwaEdgeFunctions:()=>D,NvwaFileStorage:()=>F,NvwaHttpClient:()=>B,NvwaSkill:()=>he,OverlayManager:()=>ue,PaymentClient:()=>de,Request:()=>H,Response:()=>C,URL:()=>j,URLSearchParams:()=>S,createPostgrestClient:()=>xt,getSourceLocationFromDOM:()=>Ot,polyfill:()=>ht});module.exports=E($t);h();h();var D=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};h();h();var ye="nvwa_current_jwt";h();h();var v=class s{constructor(e){this.headerMap=new Map;if(e){if(e instanceof s)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),n=this.headerMap.get(r);this.headerMap.set(r,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},S=class s{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof s)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[n,o]=r.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let n of r)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},j=class s{constructor(e,t){let r;if(e instanceof s)r=e.href;else if(t){let o=t instanceof s?t.href:t;r=this.resolve(o,e)}else r=e;let n=this.parseUrl(r);this.href=r,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new S(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let r=this.parseUrl(e),n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",n=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let c=n.match(/^([^@]*)@(.+)$/),l="",u="",d=n;if(c){let b=c[1];d=c[2];let g=b.match(/^([^:]*):?(.*)$/);g&&(l=g[1]||"",u=g[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),p=m?m[1]:d,y=m&&m[2]?m[2]:"";return{protocol:r?`${r}:`:"",username:l,password:u,host:d,hostname:p,port:y,pathname:o,search:i,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};h();var H=class s{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof v?t.headers:new v(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new s(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};h();var C=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ct(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ct(s){return s?new v(s):new v}h();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 e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},U=class{constructor(){this._signal=new $}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};h();function ht(s){s.URL=j,s.URLSearchParams=S,s.Headers=v,s.Request=H,s.Response=C,s.AbortController=U,s.AbortSignal=$}var B=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(ye),n=new v(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let i=await this.customFetch(e,{...t,headers:n});if(i.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return i}};h();var ge="/storage",ve=ge+"/generateUploadUrl",F=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ve,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new v({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await n.json();return{url:o.split("?")[0]}}};h();h();h();var ce=lt(et(),1),{PostgrestClient:tt,PostgrestQueryBuilder:Cr,PostgrestFilterBuilder:Ur,PostgrestTransformBuilder:Ar,PostgrestBuilder:Ir,PostgrestError:Lr}=ce.default||ce;var rt="/entities",xt=(s,e)=>new tt(s+rt,{fetch:e.fetchWithAuth.bind(e)});h();var he=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};h();var ue=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
1
+ "use strict";var nt=Object.create;var L=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var me=(s,e)=>()=>(s&&(e=s(s=0)),e);var _=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),ye=(s,e)=>{for(var t in e)L(s,t,{get:e[t],enumerable:!0})},ge=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ot(e))!lt.call(s,n)&&n!==t&&L(s,n,{get:()=>e[n],enumerable:!(r=it(e,n))||r.enumerable});return s};var ct=(s,e,t)=>(t=s!=null?nt(at(s)):{},ge(e||!s||!s.__esModule?L(t,"default",{value:s,enumerable:!0}):t,s)),E=s=>ge(L({},"__esModule",{value:!0}),s);var c=me(()=>{"use strict"});var x={};ye(x,{__addDisposableResource:()=>ze,__assign:()=>M,__asyncDelegator:()=>Le,__asyncGenerator:()=>Ue,__asyncValues:()=>Ne,__await:()=>T,__awaiter:()=>Re,__classPrivateFieldGet:()=>De,__classPrivateFieldIn:()=>Fe,__classPrivateFieldSet:()=>Be,__createBinding:()=>D,__decorate:()=>_e,__disposeResources:()=>Ge,__esDecorate:()=>xe,__exportStar:()=>Ae,__extends:()=>be,__generator:()=>je,__importDefault:()=>qe,__importStar:()=>Me,__makeTemplateObject:()=>ke,__metadata:()=>Te,__param:()=>Ee,__propKey:()=>Se,__read:()=>V,__rest:()=>Pe,__rewriteRelativeImportExtension:()=>Je,__runInitializers:()=>Oe,__setFunctionName:()=>$e,__spread:()=>Ce,__spreadArray:()=>Ie,__spreadArrays:()=>He,__values:()=>q,default:()=>mt});function be(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");J(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Pe(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function _e(s,e,t,r){var n=arguments.length,i=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i}function Ee(s,e){return function(t,r){e(t,r,s)}}function xe(s,e,t,r,n,i){function o(P){if(P!==void 0&&typeof P!="function")throw new TypeError("Function expected");return P}for(var a=r.kind,u=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&s?r.static?s:s.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,m=!1,p=t.length-1;p>=0;p--){var y={};for(var b in r)y[b]=b==="access"?{}:r[b];for(var b in r.access)y.access[b]=r.access[b];y.addInitializer=function(P){if(m)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(P||null))};var g=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[u],y);if(a==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(d=o(g.get))&&(h.get=d),(d=o(g.set))&&(h.set=d),(d=o(g.init))&&n.unshift(d)}else(d=o(g))&&(a==="field"?n.unshift(d):h[u]=d)}l&&Object.defineProperty(l,r.name,h),m=!0}function Oe(s,e,t){for(var r=arguments.length>2,n=0;n<e.length;n++)t=r?e[n].call(s,t):e[n].call(s);return r?t:void 0}function Se(s){return typeof s=="symbol"?s:"".concat(s)}function $e(s,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(s,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Te(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function Re(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function u(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):n(h.value).then(a,u)}l((r=r.apply(s,e||[])).next())})}function je(s,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return u([l,h])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(i=l[0]&2?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(h){l=[6,h],n=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Ae(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&D(e,s,t)}function q(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],r=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&r>=s.length&&(s=void 0),{value:s&&s[r++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function V(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,i=[],o;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)i.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Ce(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(V(arguments[e]));return s}function He(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var r=Array(s),n=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,n++)r[n]=i[o];return r}function Ie(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,i;r<n;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return s.concat(i||Array.prototype.slice.call(e))}function T(s){return this instanceof T?(this.v=s,this):new T(s)}function Ue(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(n[p]=function(b){return new Promise(function(g,P){i.push([p,b,g,P])>1||u(p,b)})},y&&(n[p]=y(n[p])))}function u(p,y){try{l(r[p](y))}catch(b){m(i[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(h,d):m(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function m(p,y){p(y),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Le(s){var e,t;return e={},r("next"),r("throw",function(n){throw n}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(n,i){e[n]=s[n]?function(o){return(t=!t)?{value:T(s[n](o)),done:!1}:i?i(o):o}:i}}function Ne(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof q=="function"?q(s):s[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=s[i]&&function(o){return new Promise(function(a,u){o=s[i](o),n(a,u,o.done,o.value)})}}function n(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}}function ke(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function Me(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t=W(s),r=0;r<t.length;r++)t[r]!=="default"&&D(e,s,t[r]);return pt(e,s),e}function qe(s){return s&&s.__esModule?s:{default:s}}function De(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}function Be(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}function Fe(s,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof s=="function"?e===s:s.has(e)}function ze(s,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,n;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(n=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");n&&(r=function(){try{n.call(this)}catch(i){return Promise.reject(i)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function Ge(s){function e(i){s.error=s.hasError?new ft(i,s.error,"An error was suppressed during disposal."):i,s.hasError=!0}var t,r=0;function n(){for(;t=s.stack.pop();)try{if(!t.async&&r===1)return r=0,s.stack.push(t),Promise.resolve().then(n);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(n,function(o){return e(o),n()})}else r|=1}catch(o){e(o)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function Je(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,i,o){return r?e?".jsx":".js":n&&(!i||!o)?t:n+i+"."+o.toLowerCase()+"js"}):s}var J,M,D,pt,W,ft,mt,O=me(()=>{"use strict";c();J=function(s,e){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},J(s,e)};M=function(){return M=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},M.apply(this,arguments)};D=Object.create?(function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}):(function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]});pt=Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}):function(s,e){s.default=e},W=function(s){return W=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},W(s)};ft=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};mt={__extends:be,__assign:M,__rest:Pe,__decorate:_e,__param:Ee,__esDecorate:xe,__runInitializers:Oe,__propKey:Se,__setFunctionName:$e,__metadata:Te,__awaiter:Re,__generator:je,__createBinding:D,__exportStar:Ae,__values:q,__read:V,__spread:Ce,__spreadArrays:He,__spreadArray:Ie,__await:T,__asyncGenerator:Ue,__asyncDelegator:Le,__asyncValues:Ne,__makeTemplateObject:ke,__importStar:Me,__importDefault:qe,__classPrivateFieldGet:De,__classPrivateFieldSet:Be,__classPrivateFieldIn:Fe,__addDisposableResource:ze,__disposeResources:Ge,__rewriteRelativeImportExtension:Je}});var K=_(Q=>{"use strict";c();Object.defineProperty(Q,"__esModule",{value:!0});var Y=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Q.default=Y});var ee=_(Z=>{"use strict";c();Object.defineProperty(Z,"__esModule",{value:!0});var yt=(O(),E(x)),gt=yt.__importDefault(K()),X=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,u,l;let h=null,d=null,m=null,p=i.status,y=i.statusText;if(i.ok){if(this.method!=="HEAD"){let U=await i.text();U===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=U:d=JSON.parse(U))}let g=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),P=(u=i.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");g&&P&&P.length>1&&(m=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(h={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,m=null,p=406,y="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let g=await i.text();try{h=JSON.parse(g),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,y="OK")}catch{i.status===404&&g===""?(p=204,y="No Content"):h={message:g}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,y="OK"),h&&this.shouldThrowOnError)throw new gt.default(h)}return{error:h,data:d,count:m,status:p,statusText:y}});return this.shouldThrowOnError||(n=n.catch(i=>{var o,a,u;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(u=i?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};Z.default=X});var se=_(re=>{"use strict";c();Object.defineProperty(re,"__esModule",{value:!0});var vt=(O(),E(x)),wt=vt.__importDefault(ee()),te=class extends wt.default{select(e){let t=!1,r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:i=n}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){let i=typeof n>"u"?"offset":`${n}.offset`,o=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:i=!1,format:o="text"}={}){var a;let u=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${u};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};re.default=te});var B=_(ie=>{"use strict";c();Object.defineProperty(ie,"__esModule",{value:!0});var bt=(O(),E(x)),Pt=bt.__importDefault(se()),_t=new RegExp("[,()]"),ne=class extends Pt.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(n=>typeof n=="string"&&_t.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let i="";n==="plain"?i="pl":n==="phrase"?i="ph":n==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};ie.default=ne});var le=_(ae=>{"use strict";c();Object.defineProperty(ae,"__esModule",{value:!0});var Et=(O(),E(x)),I=Et.__importDefault(B()),oe=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n}select(e,t){let{head:r=!1,count:n}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(u=>/\s/.test(u)&&!o?"":(u==='"'&&(o=!o),u)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new I.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(o.length>0){let a=[...new Set(o)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new I.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let u=e.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(u.length>0){let l=[...new Set(u)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new I.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new I.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new I.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};ae.default=oe});var Ve=_(ue=>{"use strict";c();Object.defineProperty(ue,"__esModule",{value:!0});var We=(O(),E(x)),xt=We.__importDefault(le()),Ot=We.__importDefault(B()),ce=class s{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=n}from(e){let t=new URL(`${this.url}/${e}`);return new xt.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new s(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:i}={}){var o;let a,u=new URL(`${this.url}/rpc/${e}`),l;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,m])=>m!==void 0).map(([d,m])=>[d,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([d,m])=>{u.searchParams.append(d,m)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new Ot.default({method:a,url:u,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};ue.default=ce});var tt=_(w=>{"use strict";c();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var R=(O(),E(x)),Ye=R.__importDefault(Ve());w.PostgrestClient=Ye.default;var Qe=R.__importDefault(le());w.PostgrestQueryBuilder=Qe.default;var Ke=R.__importDefault(B());w.PostgrestFilterBuilder=Ke.default;var Xe=R.__importDefault(se());w.PostgrestTransformBuilder=Xe.default;var Ze=R.__importDefault(ee());w.PostgrestBuilder=Ze.default;var et=R.__importDefault(K());w.PostgrestError=et.default;w.default={PostgrestClient:Ye.default,PostgrestQueryBuilder:Qe.default,PostgrestFilterBuilder:Ke.default,PostgrestTransformBuilder:Xe.default,PostgrestBuilder:Ze.default,PostgrestError:et.default}});var Rt={};ye(Rt,{AbortController:()=>H,AbortSignal:()=>$,AuthClient:()=>N,CURRENT_JWT_KEY:()=>k,ENTITIES_BASE_PATH:()=>st,FILE_STORAGE_BASE_PATH:()=>ve,GENERATE_UPLOAD_URL_PATH:()=>we,Headers:()=>v,NvwaEdgeFunctions:()=>F,NvwaFileStorage:()=>G,NvwaHttpClient:()=>z,NvwaSkill:()=>de,OverlayManager:()=>pe,PaymentClient:()=>fe,Request:()=>A,Response:()=>C,URL:()=>j,URLSearchParams:()=>S,createPostgrestClient:()=>St,getSourceLocationFromDOM:()=>$t,polyfill:()=>dt});module.exports=E(Rt);c();c();var F=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};c();c();var k="nvwa_current_jwt",ut=typeof fetch<"u"?fetch:(()=>{throw new Error("AuthClient requires fetch")})(),N=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??ut}url(e){return`${`${this.baseUrl}/${this.authPath}`.replace(/\/+/g,"/")}/${e.replace(/^\//,"")}`}async getSession(){try{let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:t})}),n=await r.text();return r.ok?{data:n?JSON.parse(n):void 0}:{error:{message:n||r.statusText,status:r.status}}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}};c();c();var v=class s{constructor(e){this.headerMap=new Map;if(e){if(e instanceof s)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),n=this.headerMap.get(r);this.headerMap.set(r,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},S=class s{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof s)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[n,i]=r.split("=");n&&this.append(decodeURIComponent(n),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let n of r)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},j=class s{constructor(e,t){let r;if(e instanceof s)r=e.href;else if(t){let i=t instanceof s?t.href:t;r=this.resolve(i,e)}else r=e;let n=this.parseUrl(r);this.href=r,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new S(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",n=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),l="",h="",d=n;if(u){let b=u[1];d=u[2];let g=b.match(/^([^:]*):?(.*)$/);g&&(l=g[1]||"",h=g[2]||"")}let m=d.match(/^([^:]+):?(\d*)$/),p=m?m[1]:d,y=m&&m[2]?m[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:y,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};c();var A=class s{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof v?t.headers:new v(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new s(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};c();var C=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ht(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ht(s){return s?new v(s):new v}c();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 e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},H=class{constructor(){this._signal=new $}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};c();function dt(s){s.URL=j,s.URLSearchParams=S,s.Headers=v,s.Request=A,s.Response=C,s.AbortController=H,s.AbortSignal=$}var z=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(k),n=new v(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:n});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};c();var ve="/storage",we=ve+"/generateUploadUrl",G=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+we,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new v({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await n.json();return{url:i.split("?")[0]}}};c();c();c();var he=ct(tt(),1),{PostgrestClient:rt,PostgrestQueryBuilder:Ir,PostgrestFilterBuilder:Ur,PostgrestTransformBuilder:Lr,PostgrestBuilder:Nr,PostgrestError:kr}=he.default||he;var st="/entities",St=(s,e)=>new rt(s+st,{fetch:e.fetchWithAuth.bind(e)});c();var de=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};c();var pe=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+o}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let c=e.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.style.top=`${c.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=e.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Ot(s="root"){if(typeof document>"u")return null;let e=document.getElementById(s)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let n=e.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}h();var St=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),de=class{constructor(e,t="/functions/payment",r=St){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}url(e){let t=this.baseUrl.replace(/\/$/,""),r=this.pathPrefix.replace(/^\/?/,"").replace(/\/?$/,"");return`${t}/${r}/${e}`}async getConfiguredProviders(e){try{let t=e?.platform,r=t?`providers?platform=${encodeURIComponent(t)}`:"providers",n=await this.fetchImpl(this.url(r),{method:"GET"});if(!n.ok)return[];let i=(await n.json())?.providers;if(!Array.isArray(i))return[];if(i.length===0)return[];if(typeof i[0]=="string")return i;let c=i;return t?c.filter(l=>!l.supportedPlatforms||l.supportedPlatforms.includes(t)).map(l=>l.id):c.map(l=>l.id)}catch{return[]}}async createPayment(e){let t=await this.fetchImpl(this.url("create-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata})});if(!t.ok){let i=await t.text();throw new Error(`createPayment failed: ${t.status} ${i}`)}let r=await t.json(),n=r.orderId??r.order?.id;if(n==null)throw new Error("createPayment: missing orderId in response");let o=r.codeUrl?{codeUrl:r.codeUrl}:r.formHtml||r.paymentFormHtml?{formHtml:r.formHtml??r.paymentFormHtml??""}:r.clientSecret?{clientSecret:r.clientSecret}:r;return{orderId:Number(n),payParams:o,order:r.order}}async queryOrder(e){let t=await this.fetchImpl(this.url(`get-order?orderId=${encodeURIComponent(e)}`),{method:"GET"});if(!t.ok){let c=await t.text();throw new Error(`queryOrder failed: ${t.status} ${c}`)}let r=await t.json(),o=r.order??r,i=o?.status??"pending",a=o?.id??r.orderId??e;return{orderId:Number(a),status:i,order:o}}async cancelOrder(e){let t=await this.fetchImpl(this.url("cancel-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:e})});if(!t.ok&&t.status!==404){let r=await t.text();throw new Error(`cancelOrder failed: ${t.status} ${r}`)}}};0&&(module.exports={AbortController,AbortSignal,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,OverlayManager,PaymentClient,Request,Response,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill});
33
+ `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+i}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let u=e.getBoundingClientRect();a.style.left=`${u.left+window.scrollX}px`,a.style.top=`${u.top+window.scrollY-a.offsetHeight-8}px`,u.top<a.offsetHeight+8&&(a.style.top=`${u.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let i=this.createTooltip();t?i.textContent=t:i.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=e.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function $t(s="root"){if(typeof document>"u")return null;let e=document.getElementById(s)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let n=e.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}c();var Tt=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),fe=class{constructor(e,t="/functions/payment",r=Tt){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}async rpc(e,t){let r=this.baseUrl.replace(/\/$/,""),n=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${n}/${e}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){let a=await o.text();throw new Error(`${e} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(e){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=e?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(e){let t=await this.rpc("createOrder",{amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata});if(t.orderId==null)throw new Error("createPayment: missing orderId in response");return t}async queryOrder(e){let t=await this.rpc("getOrder",{orderId:e});return{orderId:t.orderId??e,status:t.status??"pending",order:t.order}}async cancelOrder(e){await this.rpc("cancelOrder",{orderId:e})}};0&&(module.exports={AbortController,AbortSignal,AuthClient,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,OverlayManager,PaymentClient,Request,Response,URL,URLSearchParams,createPostgrestClient,getSourceLocationFromDOM,polyfill});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var et=Object.create;var A=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var le=(s,e)=>()=>(s&&(e=s(s=0)),e);var E=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),ot=(s,e)=>{for(var t in e)A(s,t,{get:e[t],enumerable:!0})},ce=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of rt(e))!nt.call(s,n)&&n!==t&&A(s,n,{get:()=>e[n],enumerable:!(r=tt(e,n))||r.enumerable});return s};var it=(s,e,t)=>(t=s!=null?et(st(s)):{},ce(e||!s||!s.__esModule?A(t,"default",{value:s,enumerable:!0}):t,s)),S=s=>ce(A({},"__esModule",{value:!0}),s);import $t from"path";import{fileURLToPath as Rt}from"url";var h=le(()=>{"use strict"});var x={};ot(x,{__addDisposableResource:()=>ke,__assign:()=>k,__asyncDelegator:()=>je,__asyncGenerator:()=>Re,__asyncValues:()=>He,__await:()=>$,__awaiter:()=>Ee,__classPrivateFieldGet:()=>Ue,__classPrivateFieldIn:()=>Ne,__classPrivateFieldSet:()=>Le,__createBinding:()=>q,__decorate:()=>ye,__disposeResources:()=>Me,__esDecorate:()=>ve,__exportStar:()=>Oe,__extends:()=>fe,__generator:()=>xe,__importDefault:()=>Ie,__importStar:()=>Ae,__makeTemplateObject:()=>Ce,__metadata:()=>_e,__param:()=>ge,__propKey:()=>be,__read:()=>z,__rest:()=>me,__rewriteRelativeImportExtension:()=>qe,__runInitializers:()=>we,__setFunctionName:()=>Pe,__spread:()=>Se,__spreadArray:()=>Te,__spreadArrays:()=>$e,__values:()=>M,default:()=>dt});function fe(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");B(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function me(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function ye(s,e,t,r){var n=arguments.length,o=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(i=s[a])&&(o=(n<3?i(o):n>3?i(e,t,o):i(e,t))||o);return n>3&&o&&Object.defineProperty(e,t,o),o}function ge(s,e){return function(t,r){e(t,r,s)}}function ve(s,e,t,r,n,o){function i(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&s?r.static?s:s.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,y=!1,p=t.length-1;p>=0;p--){var g={};for(var b in r)g[b]=b==="access"?{}:r[b];for(var b in r.access)g.access[b]=r.access[b];g.addInitializer=function(_){if(y)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(_||null))};var v=(0,t[p])(a==="accessor"?{get:u.get,set:u.set}:u[c],g);if(a==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(d=i(v.get))&&(u.get=d),(d=i(v.set))&&(u.set=d),(d=i(v.init))&&n.unshift(d)}else(d=i(v))&&(a==="field"?n.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),y=!0}function we(s,e,t){for(var r=arguments.length>2,n=0;n<e.length;n++)t=r?e[n].call(s,t):e[n].call(s);return r?t:void 0}function be(s){return typeof s=="symbol"?s:"".concat(s)}function Pe(s,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(s,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function _e(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function Ee(s,e,t,r){function n(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{l(r.next(u))}catch(d){i(d)}}function c(u){try{l(r.throw(u))}catch(d){i(d)}}function l(u){u.done?o(u.value):n(u.value).then(a,c)}l((r=r.apply(s,e||[])).next())})}function xe(s,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(o=l[0]&2?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){t.label=l[1];break}if(l[0]===6&&t.label<o[1]){t.label=o[1],o=l;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(l);break}o[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(u){l=[6,u],n=0}finally{r=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Oe(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&q(e,s,t)}function M(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],r=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&r>=s.length&&(s=void 0),{value:s&&s[r++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function z(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,o=[],i;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o}function Se(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(z(arguments[e]));return s}function $e(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var r=Array(s),n=0,e=0;e<t;e++)for(var o=arguments[e],i=0,a=o.length;i<a;i++,n++)r[n]=o[i];return r}function Te(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,o;r<n;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return s.concat(o||Array.prototype.slice.call(e))}function $(s){return this instanceof $?(this.v=s,this):new $(s)}function Re(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),n[Symbol.asyncIterator]=function(){return this},n;function i(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){r[p]&&(n[p]=function(b){return new Promise(function(v,_){o.push([p,b,v,_])>1||c(p,b)})},g&&(n[p]=g(n[p])))}function c(p,g){try{l(r[p](g))}catch(b){y(o[0][3],b)}}function l(p){p.value instanceof $?Promise.resolve(p.value.v).then(u,d):y(o[0][2],p)}function u(p){c("next",p)}function d(p){c("throw",p)}function y(p,g){p(g),o.shift(),o.length&&c(o[0][0],o[0][1])}}function je(s){var e,t;return e={},r("next"),r("throw",function(n){throw n}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(n,o){e[n]=s[n]?function(i){return(t=!t)?{value:$(s[n](i)),done:!1}:o?o(i):i}:o}}function He(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof M=="function"?M(s):s[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=s[o]&&function(i){return new Promise(function(a,c){i=s[o](i),n(a,c,i.done,i.value)})}}function n(o,i,a,c){Promise.resolve(c).then(function(l){o({value:l,done:a})},i)}}function Ce(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function Ae(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t=F(s),r=0;r<t.length;r++)t[r]!=="default"&&q(e,s,t[r]);return ht(e,s),e}function Ie(s){return s&&s.__esModule?s:{default:s}}function Ue(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}function Le(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}function Ne(s,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof s=="function"?e===s:s.has(e)}function ke(s,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,n;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(n=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");n&&(r=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function Me(s){function e(o){s.error=s.hasError?new ut(o,s.error,"An error was suppressed during disposal."):o,s.hasError=!0}var t,r=0;function n(){for(;t=s.stack.pop();)try{if(!t.async&&r===1)return r=0,s.stack.push(t),Promise.resolve().then(n);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(o).then(n,function(i){return e(i),n()})}else r|=1}catch(i){e(i)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function qe(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,o,i){return r?e?".jsx":".js":n&&(!o||!i)?t:n+o+"."+i.toLowerCase()+"js"}):s}var B,k,q,ht,F,ut,dt,O=le(()=>{"use strict";h();B=function(s,e){return B=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},B(s,e)};k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},k.apply(this,arguments)};q=Object.create?(function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}):(function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]});ht=Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}):function(s,e){s.default=e},F=function(s){return F=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},F(s)};ut=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};dt={__extends:fe,__assign:k,__rest:me,__decorate:ye,__param:ge,__esDecorate:ve,__runInitializers:we,__propKey:be,__setFunctionName:Pe,__metadata:_e,__awaiter:Ee,__generator:xe,__createBinding:q,__exportStar:Oe,__values:M,__read:z,__spread:Se,__spreadArrays:$e,__spreadArray:Te,__await:$,__asyncGenerator:Re,__asyncDelegator:je,__asyncValues:He,__makeTemplateObject:Ce,__importStar:Ae,__importDefault:Ie,__classPrivateFieldGet:Ue,__classPrivateFieldSet:Le,__classPrivateFieldIn:Ne,__addDisposableResource:ke,__disposeResources:Me,__rewriteRelativeImportExtension:qe}});var W=E(J=>{"use strict";h();Object.defineProperty(J,"__esModule",{value:!0});var G=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};J.default=G});var Q=E(Y=>{"use strict";h();Object.defineProperty(Y,"__esModule",{value:!0});var pt=(O(),S(x)),ft=pt.__importDefault(W()),V=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,a,c,l;let u=null,d=null,y=null,p=o.status,g=o.statusText;if(o.ok){if(this.method!=="HEAD"){let C=await o.text();C===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text"))?d=C:d=JSON.parse(C))}let v=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(c=o.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");v&&_&&_.length>1&&(y=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,y=null,p=406,g="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let v=await o.text();try{u=JSON.parse(v),Array.isArray(u)&&o.status===404&&(d=[],u=null,p=200,g="OK")}catch{o.status===404&&v===""?(p=204,g="No Content"):u={message:v}}if(u&&this.isMaybeSingle&&(!((l=u?.details)===null||l===void 0)&&l.includes("0 rows"))&&(u=null,p=200,g="OK"),u&&this.shouldThrowOnError)throw new ft.default(u)}return{error:u,data:d,count:y,status:p,statusText:g}});return this.shouldThrowOnError||(n=n.catch(o=>{var i,a,c;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(a=o?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(c=o?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};Y.default=V});var Z=E(X=>{"use strict";h();Object.defineProperty(X,"__esModule",{value:!0});var mt=(O(),S(x)),yt=mt.__importDefault(Q()),K=class extends yt.default{select(e){let t=!1,r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:o=n}={}){let i=o?`${o}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){let o=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:o=!1,format:i="text"}={}){var a;let c=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,o?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${c};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};X.default=K});var D=E(te=>{"use strict";h();Object.defineProperty(te,"__esModule",{value:!0});var gt=(O(),S(x)),vt=gt.__importDefault(Z()),wt=new RegExp("[,()]"),ee=class extends vt.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(n=>typeof n=="string"&&wt.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let o="";n==="plain"?o="pl":n==="phrase"?o="ph":n==="websearch"&&(o="w");let i=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};te.default=ee});var ne=E(se=>{"use strict";h();Object.defineProperty(se,"__esModule",{value:!0});var bt=(O(),S(x)),H=bt.__importDefault(D()),re=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n}select(e,t){let{head:r=!1,count:n}=t??{},o=r?"HEAD":"GET",i=!1,a=(e??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new H.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(i.length>0){let a=[...new Set(i)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new H.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:o=!0}={}){var i;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let c=e.reduce((l,u)=>l.concat(Object.keys(u)),[]);if(c.length>0){let l=[...new Set(c)].map(u=>`"${u}"`);this.url.searchParams.set("columns",l.join(","))}}return new H.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var r;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new H.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new H.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};se.default=re});var Be=E(ie=>{"use strict";h();Object.defineProperty(ie,"__esModule",{value:!0});var De=(O(),S(x)),Pt=De.__importDefault(ne()),_t=De.__importDefault(D()),oe=class s{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=n}from(e){let t=new URL(`${this.url}/${e}`);return new Pt.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new s(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:o}={}){var i;let a,c=new URL(`${this.url}/rpc/${e}`),l;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,y])=>y!==void 0).map(([d,y])=>[d,Array.isArray(y)?`{${y.join(",")}}`:`${y}`]).forEach(([d,y])=>{c.searchParams.append(d,y)})):(a="POST",l=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new _t.default({method:a,url:c,headers:u,schema:this.schemaName,body:l,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};ie.default=oe});var Ye=E(w=>{"use strict";h();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var T=(O(),S(x)),Fe=T.__importDefault(Be());w.PostgrestClient=Fe.default;var ze=T.__importDefault(ne());w.PostgrestQueryBuilder=ze.default;var Ge=T.__importDefault(D());w.PostgrestFilterBuilder=Ge.default;var Je=T.__importDefault(Z());w.PostgrestTransformBuilder=Je.default;var We=T.__importDefault(Q());w.PostgrestBuilder=We.default;var Ve=T.__importDefault(W());w.PostgrestError=Ve.default;w.default={PostgrestClient:Fe.default,PostgrestQueryBuilder:ze.default,PostgrestFilterBuilder:Ge.default,PostgrestTransformBuilder:Je.default,PostgrestBuilder:We.default,PostgrestError:Ve.default}});h();h();var he=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};h();h();var ue="nvwa_current_jwt";h();h();var P=class s{constructor(e){this.headerMap=new Map;if(e){if(e instanceof s)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),n=this.headerMap.get(r);this.headerMap.set(r,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},R=class s{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof s)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[n,o]=r.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let n of r)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},I=class s{constructor(e,t){let r;if(e instanceof s)r=e.href;else if(t){let o=t instanceof s?t.href:t;r=this.resolve(o,e)}else r=e;let n=this.parseUrl(r);this.href=r,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new R(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let r=this.parseUrl(e),n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",n=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let c=n.match(/^([^@]*)@(.+)$/),l="",u="",d=n;if(c){let b=c[1];d=c[2];let v=b.match(/^([^:]*):?(.*)$/);v&&(l=v[1]||"",u=v[2]||"")}let y=d.match(/^([^:]+):?(\d*)$/),p=y?y[1]:d,g=y&&y[2]?y[2]:"";return{protocol:r?`${r}:`:"",username:l,password:u,host:d,hostname:p,port:g,pathname:o,search:i,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};h();var U=class s{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof P?t.headers:new P(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new s(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};h();var L=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=at(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function at(s){return s?new P(s):new P}h();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 e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},N=class{constructor(){this._signal=new j}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};h();function Yt(s){s.URL=I,s.URLSearchParams=R,s.Headers=P,s.Request=U,s.Response=L,s.AbortController=N,s.AbortSignal=j}var de=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(ue),n=new P(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let i=await this.customFetch(e,{...t,headers:n});if(i.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return i}};h();var lt="/storage",ct=lt+"/generateUploadUrl",pe=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ct,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new P({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await n.json();return{url:o.split("?")[0]}}};h();h();h();var ae=it(Ye(),1),{PostgrestClient:Qe,PostgrestQueryBuilder:Ir,PostgrestFilterBuilder:Ur,PostgrestTransformBuilder:Lr,PostgrestBuilder:Nr,PostgrestError:kr}=ae.default||ae;var Et="/entities",Br=(s,e)=>new Qe(s+Et,{fetch:e.fetchWithAuth.bind(e)});h();var Ke=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};h();var Xe=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
1
+ var tt=Object.create;var H=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var ue=(s,e)=>()=>(s&&(e=s(s=0)),e);var E=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),ot=(s,e)=>{for(var t in e)H(s,t,{get:e[t],enumerable:!0})},he=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of st(e))!it.call(s,n)&&n!==t&&H(s,n,{get:()=>e[n],enumerable:!(r=rt(e,n))||r.enumerable});return s};var at=(s,e,t)=>(t=s!=null?tt(nt(s)):{},he(e||!s||!s.__esModule?H(t,"default",{value:s,enumerable:!0}):t,s)),S=s=>he(H({},"__esModule",{value:!0}),s);import Rt from"path";import{fileURLToPath as At}from"url";var c=ue(()=>{"use strict"});var x={};ot(x,{__addDisposableResource:()=>Me,__assign:()=>k,__asyncDelegator:()=>Ae,__asyncGenerator:()=>je,__asyncValues:()=>Ce,__await:()=>T,__awaiter:()=>xe,__classPrivateFieldGet:()=>Le,__classPrivateFieldIn:()=>ke,__classPrivateFieldSet:()=>Ne,__createBinding:()=>q,__decorate:()=>ge,__disposeResources:()=>qe,__esDecorate:()=>we,__exportStar:()=>Se,__extends:()=>me,__generator:()=>Oe,__importDefault:()=>Ue,__importStar:()=>Ie,__makeTemplateObject:()=>He,__metadata:()=>Ee,__param:()=>ve,__propKey:()=>Pe,__read:()=>J,__rest:()=>ye,__rewriteRelativeImportExtension:()=>De,__runInitializers:()=>be,__setFunctionName:()=>_e,__spread:()=>Te,__spreadArray:()=>Re,__spreadArrays:()=>$e,__values:()=>M,default:()=>ft});function me(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");z(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function ye(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function ge(s,e,t,r){var n=arguments.length,i=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i}function ve(s,e){return function(t,r){e(t,r,s)}}function we(s,e,t,r,n,i){function o(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var a=r.kind,u=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&s?r.static?s:s.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,y=!1,p=t.length-1;p>=0;p--){var g={};for(var b in r)g[b]=b==="access"?{}:r[b];for(var b in r.access)g.access[b]=r.access[b];g.addInitializer=function(_){if(y)throw new TypeError("Cannot add initializers after decoration has completed");i.push(o(_||null))};var v=(0,t[p])(a==="accessor"?{get:h.get,set:h.set}:h[u],g);if(a==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(d=o(v.get))&&(h.get=d),(d=o(v.set))&&(h.set=d),(d=o(v.init))&&n.unshift(d)}else(d=o(v))&&(a==="field"?n.unshift(d):h[u]=d)}l&&Object.defineProperty(l,r.name,h),y=!0}function be(s,e,t){for(var r=arguments.length>2,n=0;n<e.length;n++)t=r?e[n].call(s,t):e[n].call(s);return r?t:void 0}function Pe(s){return typeof s=="symbol"?s:"".concat(s)}function _e(s,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(s,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Ee(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}function xe(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(h){try{l(r.next(h))}catch(d){o(d)}}function u(h){try{l(r.throw(h))}catch(d){o(d)}}function l(h){h.done?i(h.value):n(h.value).then(a,u)}l((r=r.apply(s,e||[])).next())})}function Oe(s,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return u([l,h])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,n&&(i=l[0]&2?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){t.label=l[1];break}if(l[0]===6&&t.label<i[1]){t.label=i[1],i=l;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(l);break}i[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(h){l=[6,h],n=0}finally{r=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Se(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&q(e,s,t)}function M(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],r=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&r>=s.length&&(s=void 0),{value:s&&s[r++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function J(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,i=[],o;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)i.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function Te(){for(var s=[],e=0;e<arguments.length;e++)s=s.concat(J(arguments[e]));return s}function $e(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var r=Array(s),n=0,e=0;e<t;e++)for(var i=arguments[e],o=0,a=i.length;o<a;o++,n++)r[n]=i[o];return r}function Re(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,i;r<n;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return s.concat(i||Array.prototype.slice.call(e))}function T(s){return this instanceof T?(this.v=s,this):new T(s)}function je(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(s,e||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){r[p]&&(n[p]=function(b){return new Promise(function(v,_){i.push([p,b,v,_])>1||u(p,b)})},g&&(n[p]=g(n[p])))}function u(p,g){try{l(r[p](g))}catch(b){y(i[0][3],b)}}function l(p){p.value instanceof T?Promise.resolve(p.value.v).then(h,d):y(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function y(p,g){p(g),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Ae(s){var e,t;return e={},r("next"),r("throw",function(n){throw n}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(n,i){e[n]=s[n]?function(o){return(t=!t)?{value:T(s[n](o)),done:!1}:i?i(o):o}:i}}function Ce(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof M=="function"?M(s):s[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=s[i]&&function(o){return new Promise(function(a,u){o=s[i](o),n(a,u,o.done,o.value)})}}function n(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}}function He(s,e){return Object.defineProperty?Object.defineProperty(s,"raw",{value:e}):s.raw=e,s}function Ie(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t=G(s),r=0;r<t.length;r++)t[r]!=="default"&&q(e,s,t[r]);return dt(e,s),e}function Ue(s){return s&&s.__esModule?s:{default:s}}function Le(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}function Ne(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}function ke(s,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof s=="function"?e===s:s.has(e)}function Me(s,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,n;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(n=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");n&&(r=function(){try{n.call(this)}catch(i){return Promise.reject(i)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e}function qe(s){function e(i){s.error=s.hasError?new pt(i,s.error,"An error was suppressed during disposal."):i,s.hasError=!0}var t,r=0;function n(){for(;t=s.stack.pop();)try{if(!t.async&&r===1)return r=0,s.stack.push(t),Promise.resolve().then(n);if(t.dispose){var i=t.dispose.call(t.value);if(t.async)return r|=2,Promise.resolve(i).then(n,function(o){return e(o),n()})}else r|=1}catch(o){e(o)}if(r===1)return s.hasError?Promise.reject(s.error):Promise.resolve();if(s.hasError)throw s.error}return n()}function De(s,e){return typeof s=="string"&&/^\.\.?\//.test(s)?s.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,i,o){return r?e?".jsx":".js":n&&(!i||!o)?t:n+i+"."+o.toLowerCase()+"js"}):s}var z,k,q,dt,G,pt,ft,O=ue(()=>{"use strict";c();z=function(s,e){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},z(s,e)};k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},k.apply(this,arguments)};q=Object.create?(function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}):(function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]});dt=Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}):function(s,e){s.default=e},G=function(s){return G=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},G(s)};pt=typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r};ft={__extends:me,__assign:k,__rest:ye,__decorate:ge,__param:ve,__esDecorate:we,__runInitializers:be,__propKey:Pe,__setFunctionName:_e,__metadata:Ee,__awaiter:xe,__generator:Oe,__createBinding:q,__exportStar:Se,__values:M,__read:J,__spread:Te,__spreadArrays:$e,__spreadArray:Re,__await:T,__asyncGenerator:je,__asyncDelegator:Ae,__asyncValues:Ce,__makeTemplateObject:He,__importStar:Ie,__importDefault:Ue,__classPrivateFieldGet:Le,__classPrivateFieldSet:Ne,__classPrivateFieldIn:ke,__addDisposableResource:Me,__disposeResources:qe,__rewriteRelativeImportExtension:De}});var Y=E(V=>{"use strict";c();Object.defineProperty(V,"__esModule",{value:!0});var W=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};V.default=W});var X=E(K=>{"use strict";c();Object.defineProperty(K,"__esModule",{value:!0});var mt=(O(),S(x)),yt=mt.__importDefault(Y()),Q=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,u,l;let h=null,d=null,y=null,p=i.status,g=i.statusText;if(i.ok){if(this.method!=="HEAD"){let C=await i.text();C===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?d=C:d=JSON.parse(C))}let v=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(u=i.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");v&&_&&_.length>1&&(y=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,y=null,p=406,g="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{let v=await i.text();try{h=JSON.parse(v),Array.isArray(h)&&i.status===404&&(d=[],h=null,p=200,g="OK")}catch{i.status===404&&v===""?(p=204,g="No Content"):h={message:v}}if(h&&this.isMaybeSingle&&(!((l=h?.details)===null||l===void 0)&&l.includes("0 rows"))&&(h=null,p=200,g="OK"),h&&this.shouldThrowOnError)throw new yt.default(h)}return{error:h,data:d,count:y,status:p,statusText:g}});return this.shouldThrowOnError||(n=n.catch(i=>{var o,a,u;return{error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:`${(a=i?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(u=i?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};K.default=Q});var te=E(ee=>{"use strict";c();Object.defineProperty(ee,"__esModule",{value:!0});var gt=(O(),S(x)),vt=gt.__importDefault(X()),Z=class extends vt.default{select(e){let t=!1,r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:i=n}={}){let o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){let i=typeof n>"u"?"offset":`${n}.offset`,o=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:i=!1,format:o="text"}={}){var a;let u=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${l}"; options=${u};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};ee.default=Z});var D=E(se=>{"use strict";c();Object.defineProperty(se,"__esModule",{value:!0});var wt=(O(),S(x)),bt=wt.__importDefault(te()),Pt=new RegExp("[,()]"),re=class extends bt.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(n=>typeof n=="string"&&Pt.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let i="";n==="plain"?i="pl":n==="phrase"?i="ph":n==="websearch"&&(i="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};se.default=re});var oe=E(ie=>{"use strict";c();Object.defineProperty(ie,"__esModule",{value:!0});var _t=(O(),S(x)),A=_t.__importDefault(D()),ne=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n}select(e,t){let{head:r=!1,count:n}=t??{},i=r?"HEAD":"GET",o=!1,a=(e??"*").split("").map(u=>/\s/.test(u)&&!o?"":(u==='"'&&(o=!o),u)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new A.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let o=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(o.length>0){let a=[...new Set(o)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new A.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:i=!0}={}){var o;let a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let u=e.reduce((l,h)=>l.concat(Object.keys(h)),[]);if(u.length>0){let l=[...new Set(u)].map(h=>`"${h}"`);this.url.searchParams.set("columns",l.join(","))}}return new A.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;let n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new A.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;let r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new A.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};ie.default=ne});var Fe=E(le=>{"use strict";c();Object.defineProperty(le,"__esModule",{value:!0});var Be=(O(),S(x)),Et=Be.__importDefault(oe()),xt=Be.__importDefault(D()),ae=class s{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=n}from(e){let t=new URL(`${this.url}/${e}`);return new Et.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new s(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:i}={}){var o;let a,u=new URL(`${this.url}/rpc/${e}`),l;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([d,y])=>y!==void 0).map(([d,y])=>[d,Array.isArray(y)?`{${y.join(",")}}`:`${y}`]).forEach(([d,y])=>{u.searchParams.append(d,y)})):(a="POST",l=t);let h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new xt.default({method:a,url:u,headers:h,schema:this.schemaName,body:l,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};le.default=ae});var Qe=E(w=>{"use strict";c();Object.defineProperty(w,"__esModule",{value:!0});w.PostgrestError=w.PostgrestBuilder=w.PostgrestTransformBuilder=w.PostgrestFilterBuilder=w.PostgrestQueryBuilder=w.PostgrestClient=void 0;var $=(O(),S(x)),ze=$.__importDefault(Fe());w.PostgrestClient=ze.default;var Ge=$.__importDefault(oe());w.PostgrestQueryBuilder=Ge.default;var Je=$.__importDefault(D());w.PostgrestFilterBuilder=Je.default;var We=$.__importDefault(te());w.PostgrestTransformBuilder=We.default;var Ve=$.__importDefault(X());w.PostgrestBuilder=Ve.default;var Ye=$.__importDefault(Y());w.PostgrestError=Ye.default;w.default={PostgrestClient:ze.default,PostgrestQueryBuilder:Ge.default,PostgrestFilterBuilder:Je.default,PostgrestTransformBuilder:We.default,PostgrestBuilder:Ve.default,PostgrestError:Ye.default}});c();c();var de=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};c();c();var F="nvwa_current_jwt",lt=typeof fetch<"u"?fetch:(()=>{throw new Error("AuthClient requires fetch")})(),B=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??lt}url(e){return`${`${this.baseUrl}/${this.authPath}`.replace(/\/+/g,"/")}/${e.replace(/^\//,"")}`}async getSession(){try{let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:"include"});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:t})}),n=await r.text();return r.ok?{data:n?JSON.parse(n):void 0}:{error:{message:n||r.statusText,status:r.status}}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:"include"});return e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}};c();c();var P=class s{constructor(e){this.headerMap=new Map;if(e){if(e instanceof s)e.forEach((t,r)=>this.set(r,t));else if(Array.isArray(e))for(let[t,r]of e)this.set(t,String(r));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let r=e.toLowerCase(),n=this.headerMap.get(r);this.headerMap.set(r,n?`${n}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,r]of this.headerMap.entries())e(r,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},R=class s{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof s)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,r]of e)this.append(t,r);else if(e&&typeof e=="object")for(let[t,r]of Object.entries(e))this.set(t,r)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let r of t)if(r){let[n,i]=r.split("=");n&&this.append(decodeURIComponent(n),i?decodeURIComponent(i):"")}}append(e,t){let r=this.params.get(e)||[];r.push(t),this.params.set(e,r)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[r])=>t.localeCompare(r));this.params=new Map(e)}toString(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[t,r]of this.params.entries())for(let n of r)e(n,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,r]of this.params.entries())for(let n of r)e.push([t,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},I=class s{constructor(e,t){let r;if(e instanceof s)r=e.href;else if(t){let i=t instanceof s?t.href:t;r=this.resolve(i,e)}else r=e;let n=this.parseUrl(r);this.href=r,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new R(n.search),this.hash=n.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let i=this.parseUrl(e);return`${i.protocol}//${i.host}${t}`}let r=this.parseUrl(e),n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return`${r.protocol}//${r.host}${n}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let r=t[2]||"",n=t[4]||"",i=t[5]||"/",o=t[7]?`?${t[7]}`:"",a=t[9]?`#${t[9]}`:"";if(!r&&!n&&!i.startsWith("/")&&!i.includes("/")&&!i.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),l="",h="",d=n;if(u){let b=u[1];d=u[2];let v=b.match(/^([^:]*):?(.*)$/);v&&(l=v[1]||"",h=v[2]||"")}let y=d.match(/^([^:]+):?(\d*)$/),p=y?y[1]:d,g=y&&y[2]?y[2]:"";return{protocol:r?`${r}:`:"",username:l,password:h,host:d,hostname:p,port:g,pathname:i,search:o,hash:a}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};c();var U=class s{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof P?t.headers:new P(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new s(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};c();var L=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ct(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ct(s){return s?new P(s):new P}c();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 e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},N=class{constructor(){this._signal=new j}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};c();function Kt(s){s.URL=I,s.URLSearchParams=R,s.Headers=P,s.Request=U,s.Response=L,s.AbortController=N,s.AbortSignal=j}var pe=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(F),n=new P(t?.headers);r&&n.set("Authorization",`Bearer ${r}`);let i=t?.method||"GET";if((i==="POST"||i==="PUT"||i==="PATCH")&&t?.body){let a=n.get("Content-Type");(!a||a.includes("text/plain"))&&n.set("Content-Type","application/json")}let o=await this.customFetch(e,{...t,headers:n});if(o.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return o}};c();var ut="/storage",ht=ut+"/generateUploadUrl",fe=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ht,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let n=await this.http.fetch(r,{method:"PUT",body:e,headers:new P({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:i}=await n.json();return{url:i.split("?")[0]}}};c();c();c();var ce=at(Qe(),1),{PostgrestClient:Ke,PostgrestQueryBuilder:Lr,PostgrestFilterBuilder:Nr,PostgrestTransformBuilder:kr,PostgrestBuilder:Mr,PostgrestError:qr}=ce.default||ce;var Ot="/entities",zr=(s,e)=>new Ke(s+Ot,{fetch:e.fetchWithAuth.bind(e)});c();var Xe=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,i=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(i.status!==200)throw new Error(i.message);return i.data}};c();var Ze=class{constructor(){this.hoverOverlay=null;this.selectedOverlay=null;this.tooltip=null;this.hoverElement=null;this.selectedElement=null;this.hoverUpdateHandler=null;this.selectedUpdateHandler=null;this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@ var et=Object.create;var A=Object.defineProperty;var tt=Object.getOwnPropertyDes
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+o}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let c=e.getBoundingClientRect();a.style.left=`${c.left+window.scrollX}px`,a.style.top=`${c.top+window.scrollY-a.offsetHeight-8}px`,c.top<a.offsetHeight+8&&(a.style.top=`${c.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=e.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Wr(s="root"){if(typeof document>"u")return null;let e=document.getElementById(s)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let n=e.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}h();var xt=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),Ze=class{constructor(e,t="/functions/payment",r=xt){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}url(e){let t=this.baseUrl.replace(/\/$/,""),r=this.pathPrefix.replace(/^\/?/,"").replace(/\/?$/,"");return`${t}/${r}/${e}`}async getConfiguredProviders(e){try{let t=e?.platform,r=t?`providers?platform=${encodeURIComponent(t)}`:"providers",n=await this.fetchImpl(this.url(r),{method:"GET"});if(!n.ok)return[];let i=(await n.json())?.providers;if(!Array.isArray(i))return[];if(i.length===0)return[];if(typeof i[0]=="string")return i;let c=i;return t?c.filter(l=>!l.supportedPlatforms||l.supportedPlatforms.includes(t)).map(l=>l.id):c.map(l=>l.id)}catch{return[]}}async createPayment(e){let t=await this.fetchImpl(this.url("create-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata})});if(!t.ok){let i=await t.text();throw new Error(`createPayment failed: ${t.status} ${i}`)}let r=await t.json(),n=r.orderId??r.order?.id;if(n==null)throw new Error("createPayment: missing orderId in response");let o=r.codeUrl?{codeUrl:r.codeUrl}:r.formHtml||r.paymentFormHtml?{formHtml:r.formHtml??r.paymentFormHtml??""}:r.clientSecret?{clientSecret:r.clientSecret}:r;return{orderId:Number(n),payParams:o,order:r.order}}async queryOrder(e){let t=await this.fetchImpl(this.url(`get-order?orderId=${encodeURIComponent(e)}`),{method:"GET"});if(!t.ok){let c=await t.text();throw new Error(`queryOrder failed: ${t.status} ${c}`)}let r=await t.json(),o=r.order??r,i=o?.status??"pending",a=o?.id??r.orderId??e;return{orderId:Number(a),status:i,order:o}}async cancelOrder(e){let t=await this.fetchImpl(this.url("cancel-order"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:e})});if(!t.ok&&t.status!==404){let r=await t.text();throw new Error(`cancelOrder failed: ${t.status} ${r}`)}}};export{N as AbortController,j as AbortSignal,Et as ENTITIES_BASE_PATH,lt as FILE_STORAGE_BASE_PATH,ct as GENERATE_UPLOAD_URL_PATH,P as Headers,he as NvwaEdgeFunctions,pe as NvwaFileStorage,de as NvwaHttpClient,Ke as NvwaSkill,Xe as OverlayManager,Ze as PaymentClient,U as Request,L as Response,I as URL,R as URLSearchParams,Br as createPostgrestClient,Wr as getSourceLocationFromDOM,Yt as polyfill};
33
+ `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+n}px`,e.style.top=`${r.top+i}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let a=this.createTooltip();t?a.textContent=t:a.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let u=e.getBoundingClientRect();a.style.left=`${u.left+window.scrollX}px`,a.style.top=`${u.top+window.scrollY-a.offsetHeight-8}px`,u.top<a.offsetHeight+8&&(a.style.top=`${u.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let n=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let i=this.createTooltip();t?i.textContent=t:i.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,i.style.display="block";let o=e.getBoundingClientRect();i.style.left=`${o.left+window.scrollX}px`,i.style.top=`${o.top+window.scrollY-i.offsetHeight-8}px`,o.top<i.offsetHeight+8&&(i.style.top=`${o.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let n=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=n,window.addEventListener("scroll",n,!0),window.addEventListener("resize",n)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Yr(s="root"){if(typeof document>"u")return null;let e=document.getElementById(s)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let r=t.getAttribute("data-source-location");if(r)return r}if(e.firstElementChild){let n=e.firstElementChild.getAttribute("data-source-location");if(n)return n}return null}c();var St=typeof fetch<"u"?fetch:(()=>{throw new Error("payment client requires fetch")})(),et=class{constructor(e,t="/functions/payment",r=St){this.baseUrl=e;this.pathPrefix=t;this.fetchImpl=r}async rpc(e,t){let r=this.baseUrl.replace(/\/$/,""),n=this.pathPrefix.replace(/^\/?/,"").replace(/\/$/,""),i=`${r}/${n}/${e}`,o=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){let a=await o.text();throw new Error(`${e} failed: ${o.status} ${a}`)}if(!(o.status===204||!o.body))return await o.json()}async getConfiguredProviders(e){try{let r=(await this.rpc("getConfiguredProviders",{}))?.providers;if(!Array.isArray(r))return[];if(r.length===0)return[];if(typeof r[0]=="string")return r;let i=r,o=e?.platform;return o?i.filter(a=>!a.supportedPlatforms||a.supportedPlatforms.includes(o)).map(a=>a.id):i.map(a=>a.id)}catch{return[]}}async createPayment(e){let t=await this.rpc("createOrder",{amount:e.amount,subject:e.subject,currency:e.currency??"cny",providerId:e.providerId,metadata:e.metadata});if(t.orderId==null)throw new Error("createPayment: missing orderId in response");return t}async queryOrder(e){let t=await this.rpc("getOrder",{orderId:e});return{orderId:t.orderId??e,status:t.status??"pending",order:t.order}}async cancelOrder(e){await this.rpc("cancelOrder",{orderId:e})}};export{N as AbortController,j as AbortSignal,B as AuthClient,F as CURRENT_JWT_KEY,Ot as ENTITIES_BASE_PATH,ut as FILE_STORAGE_BASE_PATH,ht as GENERATE_UPLOAD_URL_PATH,P as Headers,de as NvwaEdgeFunctions,fe as NvwaFileStorage,pe as NvwaHttpClient,Xe as NvwaSkill,Ze as OverlayManager,et as PaymentClient,U as Request,L as Response,I as URL,R as URLSearchParams,zr as createPostgrestClient,Yr as getSourceLocationFromDOM,Kt as polyfill};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-core",
3
- "version": "4.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "NVWA跨端通用工具类核心接口",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",