@nvwa-app/sdk-core 0.10.10 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,17 +1,5 @@
1
1
  import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
2
2
  import { PostgrestClient } from '@nvwa-app/postgrest-js';
3
- import { User } from 'better-auth';
4
- import { createAuthClient } from 'better-auth/client';
5
-
6
- interface NvwaLocalStorage {
7
- get(key: string): Promise<any | null>;
8
- /**
9
- * @param expires 过期时间(秒),可选
10
- */
11
- set(key: string, value: any, expires?: number): Promise<void>;
12
- remove(key: string): Promise<void>;
13
- clear(): Promise<void>;
14
- }
15
3
 
16
4
  declare class Headers {
17
5
  private readonly headerMap;
@@ -66,7 +54,7 @@ declare class URL$1 {
66
54
  toJSON(): string;
67
55
  }
68
56
 
69
- interface RequestInit {
57
+ interface RequestInit$1 {
70
58
  method?: string;
71
59
  headers?: Headers;
72
60
  body?: any;
@@ -86,7 +74,7 @@ declare class Request {
86
74
  readonly body?: any;
87
75
  readonly timeout?: number;
88
76
  readonly signal?: any;
89
- constructor(input: RequestInfo, init?: RequestInit);
77
+ constructor(input: RequestInfo, init?: RequestInit$1);
90
78
  clone(): Request;
91
79
  toString(): string;
92
80
  }
@@ -96,7 +84,7 @@ interface ResponseInit {
96
84
  statusText?: string;
97
85
  headers?: Headers;
98
86
  }
99
- declare class Response {
87
+ declare class Response$1 {
100
88
  private readonly bodyData;
101
89
  readonly status: number;
102
90
  readonly statusText: string;
@@ -129,39 +117,16 @@ declare class AbortController {
129
117
 
130
118
  declare function polyfill(_global: any): void;
131
119
 
132
- type NvwaFetch = (input: string | URL$1 | RequestInfo, init?: RequestInit) => Promise<Response>;
120
+ type NvwaFetch = (input: string | URL$1 | RequestInfo, init?: RequestInit$1) => Promise<Response$1>;
133
121
 
134
- declare const AUTH_BASE_PATH = "/auth";
135
- declare const LOGIN_TOKEN_KEY = "nvwa_login_token";
136
- declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
137
- declare const LOGIN_USER_PROFILE_KEY = "nvwa_user_profile";
138
- type RegisterUser = {
139
- name: string;
140
- username: string;
141
- password: string;
142
- image: string;
143
- email?: string;
144
- };
145
- type NvwaAppUser = {
146
- username: string;
147
- displayUsername: string;
148
- } & User;
149
- type AuthClient = ReturnType<typeof createAuthClient<BetterAuthClientOptions>>;
150
- type SignInResult = ReturnType<ReturnType<typeof createAuthClient>["signIn"]["email"]>;
151
- declare class NvwaAuthClient {
152
- protected storage: NvwaLocalStorage;
153
- protected authClient: AuthClient;
154
- constructor(baseUrl: string, fetch: NvwaFetch, storage: NvwaLocalStorage);
155
- currentUser(): Promise<User | null>;
156
- getCurrentJwt(): Promise<string | null>;
157
- signUp(user: RegisterUser): Promise<void>;
158
- sendPhoneNumberCode(phoneNumber: string): Promise<void>;
159
- signInWithPhoneNumberCode(phoneNumber: string, code: string): Promise<void>;
160
- signInWithPhoneNumber(phoneNumber: string, password: string, rememberMe?: boolean): Promise<void>;
161
- signInWithUsername(username: string, password: string): Promise<void>;
162
- handleLogin(result: SignInResult): Promise<void>;
163
- signOut(): Promise<void>;
164
- updateUserPassword(oldPassword: string, newPassword: string, revokeOtherSessions?: boolean): Promise<void>;
122
+ interface NvwaLocalStorage {
123
+ get(key: string): Promise<any | null>;
124
+ /**
125
+ * @param expires 过期时间(秒),可选
126
+ */
127
+ set(key: string, value: any, expires?: number): Promise<void>;
128
+ remove(key: string): Promise<void>;
129
+ clear(): Promise<void>;
165
130
  }
166
131
 
167
132
  type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD";
@@ -170,8 +135,8 @@ declare class NvwaHttpClient {
170
135
  protected customFetch: NvwaFetch;
171
136
  protected handleUnauthorized: () => void;
172
137
  constructor(storage: NvwaLocalStorage, customFetch: NvwaFetch, handleUnauthorized: () => void);
173
- fetch(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
174
- fetchWithAuth(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
138
+ fetch(url: string | URL$1 | RequestInfo, request?: RequestInit$1): Promise<Response$1>;
139
+ fetchWithAuth(url: string | URL$1 | RequestInfo, request?: RequestInit$1): Promise<Response$1>;
175
140
  }
176
141
 
177
142
  type HttpUploadFileResponse = {
@@ -216,7 +181,7 @@ declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClien
216
181
  * 公共的 Inspector 消息类型定义
217
182
  */
218
183
  interface HoverInspectorMessage {
219
- type: 'HOVER_INSPECTOR_ENABLE' | 'HOVER_INSPECTOR_DISABLE' | 'HOVER_INSPECTOR_ELEMENT_HOVER' | 'HOVER_INSPECTOR_ELEMENT_LEAVE' | 'HOVER_INSPECTOR_ELEMENT_SELECT';
184
+ type: "HOVER_INSPECTOR_ENABLE" | "HOVER_INSPECTOR_DISABLE" | "HOVER_INSPECTOR_ELEMENT_HOVER" | "HOVER_INSPECTOR_ELEMENT_LEAVE" | "HOVER_INSPECTOR_ELEMENT_SELECT";
220
185
  sourceLocation?: string | null;
221
186
  elementInfo?: {
222
187
  tagName: string;
@@ -225,7 +190,7 @@ interface HoverInspectorMessage {
225
190
  };
226
191
  }
227
192
  interface IframeSourceLocationMessage {
228
- type: 'GET_SOURCE_LOCATION_REQUEST' | 'GET_SOURCE_LOCATION_RESPONSE';
193
+ type: "GET_SOURCE_LOCATION_REQUEST" | "GET_SOURCE_LOCATION_RESPONSE";
229
194
  sourceLocation?: string | null;
230
195
  error?: string;
231
196
  requestId?: string;
@@ -260,12 +225,88 @@ declare class OverlayManager {
260
225
  */
261
226
  declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
262
227
 
228
+ /**
229
+ * Payment 客户端:供生成应用(项目侧)调用项目自己的 payment API(由 Example 提供)。
230
+ * 仅封装请求形态,不涉及持久化;与 Workspace 积分充值无关。
231
+ */
232
+ interface CreatePaymentParams {
233
+ /** 金额(最小单位,如分) */
234
+ amount: number;
235
+ /** 标的描述(如 "商品购买") */
236
+ subject: string;
237
+ /** 货币,默认 cny */
238
+ currency?: string;
239
+ /** 支付方式:native(扫码)| h5(跳转)等,由项目 backend 与 provider 决定 */
240
+ method?: "native" | "h5";
241
+ /** 指定 provider(如 "wechat-pay" | "alipay" | "stripe"),不传时由 backend 用默认/首个已配置 provider */
242
+ providerId?: string;
243
+ /** 业务元数据 */
244
+ metadata?: Record<string, unknown>;
245
+ }
246
+ /** 创建支付返回的支付参数(按渠道不同) */
247
+ type PayParams = {
248
+ codeUrl: string;
249
+ } | {
250
+ formHtml: string;
251
+ } | {
252
+ clientSecret: string;
253
+ } | Record<string, unknown>;
254
+ interface CreatePaymentResponse {
255
+ orderId: number;
256
+ /** 统一抽象:用于展示二维码 / 跳转表单 / Stripe Element 等 */
257
+ payParams: PayParams;
258
+ /** 兼容 example 的 codeUrl 等字段(可选) */
259
+ order?: Record<string, unknown>;
260
+ }
261
+ type PaymentOrderStatus = "pending" | "processing" | "succeeded" | "failed" | "canceled" | "refunded";
262
+ interface OrderStatus {
263
+ orderId: number;
264
+ status: PaymentOrderStatus;
265
+ order?: Record<string, unknown>;
266
+ }
267
+ type PaymentFetch = (input: string, init?: RequestInit) => Promise<Response>;
268
+ /** 端类型:与 capability Provider 的 supportedPlatforms 一致,用于按端过滤可用 provider */
269
+ type PaymentPlatform = "web" | "uniapp" | "wechat-miniprogram";
270
+ /**
271
+ * 项目侧 Payment 客户端:调用项目自己的 create-order / get-order 等接口。
272
+ * baseUrl 为项目 backend 根地址(如 "" 或 "https://api.example.com"),
273
+ * pathPrefix 默认为 "/functions/payment",与 Example 的 functions 路径一致。
274
+ */
275
+ declare class PaymentClient {
276
+ private baseUrl;
277
+ private pathPrefix;
278
+ private fetchImpl;
279
+ constructor(baseUrl: string, pathPrefix?: string, fetchImpl?: PaymentFetch);
280
+ private url;
281
+ /**
282
+ * 获取在当前端可用的 payment provider 列表。
283
+ * - 可传 platform:只返回在该端能完成支付的 provider(如微信小程序内仅返回 wechat-pay)。
284
+ * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤;否则可传 ?platform=xxx 由 backend 过滤。
285
+ * 若 backend 未实现该接口则返回空数组。
286
+ */
287
+ getConfiguredProviders(options?: {
288
+ platform?: PaymentPlatform;
289
+ }): Promise<string[]>;
290
+ /**
291
+ * 创建支付订单,返回 orderId 与 payParams(codeUrl / formHtml / clientSecret 等)。
292
+ * 可传 providerId 指定 provider,不传时由 backend 用默认/首个已配置 provider。
293
+ */
294
+ createPayment(params: CreatePaymentParams): Promise<CreatePaymentResponse>;
295
+ /**
296
+ * 查询订单状态。
297
+ */
298
+ queryOrder(orderId: number): Promise<OrderStatus>;
299
+ /**
300
+ * 取消订单(若项目 backend 支持)。
301
+ */
302
+ cancelOrder(orderId: number): Promise<void>;
303
+ }
304
+
263
305
  interface INvwa {
264
306
  entities: PostgrestClient;
265
- auth: NvwaAuthClient;
266
307
  functions: NvwaEdgeFunctions;
267
308
  fileStorage: NvwaFileStorage;
268
309
  skill: NvwaSkill;
269
310
  }
270
311
 
271
- export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, CURRENT_JWT_KEY, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, OverlayManager, type RegisterUser, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
312
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,5 @@
1
1
  import * as _nvwa_app_postgrest_js from '@nvwa-app/postgrest-js';
2
2
  import { PostgrestClient } from '@nvwa-app/postgrest-js';
3
- import { User } from 'better-auth';
4
- import { createAuthClient } from 'better-auth/client';
5
-
6
- interface NvwaLocalStorage {
7
- get(key: string): Promise<any | null>;
8
- /**
9
- * @param expires 过期时间(秒),可选
10
- */
11
- set(key: string, value: any, expires?: number): Promise<void>;
12
- remove(key: string): Promise<void>;
13
- clear(): Promise<void>;
14
- }
15
3
 
16
4
  declare class Headers {
17
5
  private readonly headerMap;
@@ -66,7 +54,7 @@ declare class URL$1 {
66
54
  toJSON(): string;
67
55
  }
68
56
 
69
- interface RequestInit {
57
+ interface RequestInit$1 {
70
58
  method?: string;
71
59
  headers?: Headers;
72
60
  body?: any;
@@ -86,7 +74,7 @@ declare class Request {
86
74
  readonly body?: any;
87
75
  readonly timeout?: number;
88
76
  readonly signal?: any;
89
- constructor(input: RequestInfo, init?: RequestInit);
77
+ constructor(input: RequestInfo, init?: RequestInit$1);
90
78
  clone(): Request;
91
79
  toString(): string;
92
80
  }
@@ -96,7 +84,7 @@ interface ResponseInit {
96
84
  statusText?: string;
97
85
  headers?: Headers;
98
86
  }
99
- declare class Response {
87
+ declare class Response$1 {
100
88
  private readonly bodyData;
101
89
  readonly status: number;
102
90
  readonly statusText: string;
@@ -129,39 +117,16 @@ declare class AbortController {
129
117
 
130
118
  declare function polyfill(_global: any): void;
131
119
 
132
- type NvwaFetch = (input: string | URL$1 | RequestInfo, init?: RequestInit) => Promise<Response>;
120
+ type NvwaFetch = (input: string | URL$1 | RequestInfo, init?: RequestInit$1) => Promise<Response$1>;
133
121
 
134
- declare const AUTH_BASE_PATH = "/auth";
135
- declare const LOGIN_TOKEN_KEY = "nvwa_login_token";
136
- declare const CURRENT_JWT_KEY = "nvwa_current_jwt";
137
- declare const LOGIN_USER_PROFILE_KEY = "nvwa_user_profile";
138
- type RegisterUser = {
139
- name: string;
140
- username: string;
141
- password: string;
142
- image: string;
143
- email?: string;
144
- };
145
- type NvwaAppUser = {
146
- username: string;
147
- displayUsername: string;
148
- } & User;
149
- type AuthClient = ReturnType<typeof createAuthClient<BetterAuthClientOptions>>;
150
- type SignInResult = ReturnType<ReturnType<typeof createAuthClient>["signIn"]["email"]>;
151
- declare class NvwaAuthClient {
152
- protected storage: NvwaLocalStorage;
153
- protected authClient: AuthClient;
154
- constructor(baseUrl: string, fetch: NvwaFetch, storage: NvwaLocalStorage);
155
- currentUser(): Promise<User | null>;
156
- getCurrentJwt(): Promise<string | null>;
157
- signUp(user: RegisterUser): Promise<void>;
158
- sendPhoneNumberCode(phoneNumber: string): Promise<void>;
159
- signInWithPhoneNumberCode(phoneNumber: string, code: string): Promise<void>;
160
- signInWithPhoneNumber(phoneNumber: string, password: string, rememberMe?: boolean): Promise<void>;
161
- signInWithUsername(username: string, password: string): Promise<void>;
162
- handleLogin(result: SignInResult): Promise<void>;
163
- signOut(): Promise<void>;
164
- updateUserPassword(oldPassword: string, newPassword: string, revokeOtherSessions?: boolean): Promise<void>;
122
+ interface NvwaLocalStorage {
123
+ get(key: string): Promise<any | null>;
124
+ /**
125
+ * @param expires 过期时间(秒),可选
126
+ */
127
+ set(key: string, value: any, expires?: number): Promise<void>;
128
+ remove(key: string): Promise<void>;
129
+ clear(): Promise<void>;
165
130
  }
166
131
 
167
132
  type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD";
@@ -170,8 +135,8 @@ declare class NvwaHttpClient {
170
135
  protected customFetch: NvwaFetch;
171
136
  protected handleUnauthorized: () => void;
172
137
  constructor(storage: NvwaLocalStorage, customFetch: NvwaFetch, handleUnauthorized: () => void);
173
- fetch(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
174
- fetchWithAuth(url: string | URL$1 | RequestInfo, request?: RequestInit): Promise<Response>;
138
+ fetch(url: string | URL$1 | RequestInfo, request?: RequestInit$1): Promise<Response$1>;
139
+ fetchWithAuth(url: string | URL$1 | RequestInfo, request?: RequestInit$1): Promise<Response$1>;
175
140
  }
176
141
 
177
142
  type HttpUploadFileResponse = {
@@ -216,7 +181,7 @@ declare const createPostgrestClient: (baseUrl: string, httpClient: NvwaHttpClien
216
181
  * 公共的 Inspector 消息类型定义
217
182
  */
218
183
  interface HoverInspectorMessage {
219
- type: 'HOVER_INSPECTOR_ENABLE' | 'HOVER_INSPECTOR_DISABLE' | 'HOVER_INSPECTOR_ELEMENT_HOVER' | 'HOVER_INSPECTOR_ELEMENT_LEAVE' | 'HOVER_INSPECTOR_ELEMENT_SELECT';
184
+ type: "HOVER_INSPECTOR_ENABLE" | "HOVER_INSPECTOR_DISABLE" | "HOVER_INSPECTOR_ELEMENT_HOVER" | "HOVER_INSPECTOR_ELEMENT_LEAVE" | "HOVER_INSPECTOR_ELEMENT_SELECT";
220
185
  sourceLocation?: string | null;
221
186
  elementInfo?: {
222
187
  tagName: string;
@@ -225,7 +190,7 @@ interface HoverInspectorMessage {
225
190
  };
226
191
  }
227
192
  interface IframeSourceLocationMessage {
228
- type: 'GET_SOURCE_LOCATION_REQUEST' | 'GET_SOURCE_LOCATION_RESPONSE';
193
+ type: "GET_SOURCE_LOCATION_REQUEST" | "GET_SOURCE_LOCATION_RESPONSE";
229
194
  sourceLocation?: string | null;
230
195
  error?: string;
231
196
  requestId?: string;
@@ -260,12 +225,88 @@ declare class OverlayManager {
260
225
  */
261
226
  declare function getSourceLocationFromDOM(rootSelector?: string): string | null;
262
227
 
228
+ /**
229
+ * Payment 客户端:供生成应用(项目侧)调用项目自己的 payment API(由 Example 提供)。
230
+ * 仅封装请求形态,不涉及持久化;与 Workspace 积分充值无关。
231
+ */
232
+ interface CreatePaymentParams {
233
+ /** 金额(最小单位,如分) */
234
+ amount: number;
235
+ /** 标的描述(如 "商品购买") */
236
+ subject: string;
237
+ /** 货币,默认 cny */
238
+ currency?: string;
239
+ /** 支付方式:native(扫码)| h5(跳转)等,由项目 backend 与 provider 决定 */
240
+ method?: "native" | "h5";
241
+ /** 指定 provider(如 "wechat-pay" | "alipay" | "stripe"),不传时由 backend 用默认/首个已配置 provider */
242
+ providerId?: string;
243
+ /** 业务元数据 */
244
+ metadata?: Record<string, unknown>;
245
+ }
246
+ /** 创建支付返回的支付参数(按渠道不同) */
247
+ type PayParams = {
248
+ codeUrl: string;
249
+ } | {
250
+ formHtml: string;
251
+ } | {
252
+ clientSecret: string;
253
+ } | Record<string, unknown>;
254
+ interface CreatePaymentResponse {
255
+ orderId: number;
256
+ /** 统一抽象:用于展示二维码 / 跳转表单 / Stripe Element 等 */
257
+ payParams: PayParams;
258
+ /** 兼容 example 的 codeUrl 等字段(可选) */
259
+ order?: Record<string, unknown>;
260
+ }
261
+ type PaymentOrderStatus = "pending" | "processing" | "succeeded" | "failed" | "canceled" | "refunded";
262
+ interface OrderStatus {
263
+ orderId: number;
264
+ status: PaymentOrderStatus;
265
+ order?: Record<string, unknown>;
266
+ }
267
+ type PaymentFetch = (input: string, init?: RequestInit) => Promise<Response>;
268
+ /** 端类型:与 capability Provider 的 supportedPlatforms 一致,用于按端过滤可用 provider */
269
+ type PaymentPlatform = "web" | "uniapp" | "wechat-miniprogram";
270
+ /**
271
+ * 项目侧 Payment 客户端:调用项目自己的 create-order / get-order 等接口。
272
+ * baseUrl 为项目 backend 根地址(如 "" 或 "https://api.example.com"),
273
+ * pathPrefix 默认为 "/functions/payment",与 Example 的 functions 路径一致。
274
+ */
275
+ declare class PaymentClient {
276
+ private baseUrl;
277
+ private pathPrefix;
278
+ private fetchImpl;
279
+ constructor(baseUrl: string, pathPrefix?: string, fetchImpl?: PaymentFetch);
280
+ private url;
281
+ /**
282
+ * 获取在当前端可用的 payment provider 列表。
283
+ * - 可传 platform:只返回在该端能完成支付的 provider(如微信小程序内仅返回 wechat-pay)。
284
+ * - 若 backend 返回带 supportedPlatforms 的列表,则按 platform 在客户端过滤;否则可传 ?platform=xxx 由 backend 过滤。
285
+ * 若 backend 未实现该接口则返回空数组。
286
+ */
287
+ getConfiguredProviders(options?: {
288
+ platform?: PaymentPlatform;
289
+ }): Promise<string[]>;
290
+ /**
291
+ * 创建支付订单,返回 orderId 与 payParams(codeUrl / formHtml / clientSecret 等)。
292
+ * 可传 providerId 指定 provider,不传时由 backend 用默认/首个已配置 provider。
293
+ */
294
+ createPayment(params: CreatePaymentParams): Promise<CreatePaymentResponse>;
295
+ /**
296
+ * 查询订单状态。
297
+ */
298
+ queryOrder(orderId: number): Promise<OrderStatus>;
299
+ /**
300
+ * 取消订单(若项目 backend 支持)。
301
+ */
302
+ cancelOrder(orderId: number): Promise<void>;
303
+ }
304
+
263
305
  interface INvwa {
264
306
  entities: PostgrestClient;
265
- auth: NvwaAuthClient;
266
307
  functions: NvwaEdgeFunctions;
267
308
  fileStorage: NvwaFileStorage;
268
309
  skill: NvwaSkill;
269
310
  }
270
311
 
271
- export { AUTH_BASE_PATH, AbortController, AbortSignal, type AuthClient, CURRENT_JWT_KEY, ENTITIES_BASE_PATH, FILE_STORAGE_BASE_PATH, type FunctionInvokeOptions, GENERATE_UPLOAD_URL_PATH, Headers, type HoverInspectorMessage, type HttpMethod, type HttpUploadFileResponse, type INvwa, type IframeSourceLocationMessage, LOGIN_TOKEN_KEY, LOGIN_USER_PROFILE_KEY, type NvwaAppUser, NvwaAuthClient, NvwaEdgeFunctions, type NvwaFetch, NvwaFileStorage, NvwaHttpClient, type NvwaLocalStorage, NvwaSkill, OverlayManager, type RegisterUser, Request, type RequestInfo, type RequestInit, Response, type ResponseInit, type SkillExecuteResponse, URL$1 as URL, URLSearchParams, createPostgrestClient, getSourceLocationFromDOM, polyfill };
312
+ 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 };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Er=Object.create;var ce=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Or=Object.getPrototypeOf,Tr=Object.prototype.hasOwnProperty;var st=(r,e)=>()=>(r&&(e=r(r=0)),e);var B=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ot=(r,e)=>{for(var t in e)ce(r,t,{get:e[t],enumerable:!0})},it=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Rr(e))!Tr.call(r,s)&&s!==t&&ce(r,s,{get:()=>e[s],enumerable:!(n=_r(e,s))||n.enumerable});return r};var Pr=(r,e,t)=>(t=r!=null?Er(Or(r)):{},it(e||!r||!r.__esModule?ce(t,"default",{value:r,enumerable:!0}):t,r)),q=r=>it(ce({},"__esModule",{value:!0}),r);var a=st(()=>{"use strict"});var z={};ot(z,{__addDisposableResource:()=>sr,__assign:()=>we,__asyncDelegator:()=>Yt,__asyncGenerator:()=>Jt,__asyncValues:()=>Qt,__await:()=>Y,__awaiter:()=>Ft,__classPrivateFieldGet:()=>tr,__classPrivateFieldIn:()=>nr,__classPrivateFieldSet:()=>rr,__createBinding:()=>be,__decorate:()=>Dt,__disposeResources:()=>or,__esDecorate:()=>kt,__exportStar:()=>Gt,__extends:()=>Lt,__generator:()=>zt,__importDefault:()=>er,__importStar:()=>Zt,__makeTemplateObject:()=>Xt,__metadata:()=>qt,__param:()=>Mt,__propKey:()=>Ht,__read:()=>De,__rest:()=>$t,__rewriteRelativeImportExtension:()=>ir,__runInitializers:()=>jt,__setFunctionName:()=>Bt,__spread:()=>Vt,__spreadArray:()=>Kt,__spreadArrays:()=>Wt,__values:()=>ve,default:()=>$n});function Lt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Le(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function $t(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function Dt(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var l=r.length-1;l>=0;l--)(i=r[l])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function Mt(r,e){return function(t,n){e(t,n,r)}}function kt(r,e,t,n,s,o){function i(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var l=n.kind,d=l==="getter"?"get":l==="setter"?"set":"value",c=!e&&r?n.static?r:r.prototype:null,u=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),f,p=!1,g=t.length-1;g>=0;g--){var w={};for(var E in n)w[E]=E==="access"?{}:n[E];for(var E in n.access)w.access[E]=n.access[E];w.addInitializer=function(_){if(p)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(_||null))};var y=(0,t[g])(l==="accessor"?{get:u.get,set:u.set}:u[d],w);if(l==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(f=i(y.get))&&(u.get=f),(f=i(y.set))&&(u.set=f),(f=i(y.init))&&s.unshift(f)}else(f=i(y))&&(l==="field"?s.unshift(f):u[d]=f)}c&&Object.defineProperty(c,n.name,u),p=!0}function jt(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Ht(r){return typeof r=="symbol"?r:"".concat(r)}function Bt(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function qt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Ft(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function l(u){try{c(n.next(u))}catch(f){i(f)}}function d(u){try{c(n.throw(u))}catch(f){i(f)}}function c(u){u.done?o(u.value):s(u.value).then(l,d)}c((n=n.apply(r,e||[])).next())})}function zt(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(c){return function(u){return d([c,u])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(t=0)),t;)try{if(n=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,s=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],s=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Gt(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&be(e,r,t)}function ve(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function De(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(l){i={error:l}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function Vt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(De(arguments[e]));return r}function Wt(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,l=o.length;i<l;i++,s++)n[s]=o[i];return n}function Kt(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function Y(r){return this instanceof Y?(this.v=r,this):new Y(r)}function Jt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(g){return function(w){return Promise.resolve(w).then(g,f)}}function l(g,w){n[g]&&(s[g]=function(E){return new Promise(function(y,_){o.push([g,E,y,_])>1||d(g,E)})},w&&(s[g]=w(s[g])))}function d(g,w){try{c(n[g](w))}catch(E){p(o[0][3],E)}}function c(g){g.value instanceof Y?Promise.resolve(g.value.v).then(u,f):p(o[0][2],g)}function u(g){d("next",g)}function f(g){d("throw",g)}function p(g,w){g(w),o.shift(),o.length&&d(o[0][0],o[0][1])}}function Yt(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:Y(r[s](i)),done:!1}:o?o(i):i}:o}}function Qt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof ve=="function"?ve(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(l,d){i=r[o](i),s(l,d,i.done,i.value)})}}function s(o,i,l,d){Promise.resolve(d).then(function(c){o({value:c,done:l})},i)}}function Xt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Zt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=$e(r),n=0;n<t.length;n++)t[n]!=="default"&&be(e,r,t[n]);return Nn(e,r),e}function er(r){return r&&r.__esModule?r:{default:r}}function tr(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function rr(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function nr(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function sr(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function or(r){function e(o){r.error=r.hasError?new Ln(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function ir(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Le,we,be,Nn,$e,Ln,$n,G=st(()=>{"use strict";a();Le=function(r,e){return Le=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Le(r,e)};we=function(){return we=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},we.apply(this,arguments)};be=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});Nn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},$e=function(r){return $e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},$e(r)};Ln=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};$n={__extends:Lt,__assign:we,__rest:$t,__decorate:Dt,__param:Mt,__esDecorate:kt,__runInitializers:jt,__propKey:Ht,__setFunctionName:Bt,__metadata:qt,__awaiter:Ft,__generator:zt,__createBinding:be,__exportStar:Gt,__values:ve,__read:De,__spread:Vt,__spreadArrays:Wt,__spreadArray:Kt,__await:Y,__asyncGenerator:Jt,__asyncDelegator:Yt,__asyncValues:Qt,__makeTemplateObject:Xt,__importStar:Zt,__importDefault:er,__classPrivateFieldGet:tr,__classPrivateFieldSet:rr,__classPrivateFieldIn:nr,__addDisposableResource:sr,__disposeResources:or,__rewriteRelativeImportExtension:ir}});var je=B(ke=>{"use strict";a();Object.defineProperty(ke,"__esModule",{value:!0});var Me=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};ke.default=Me});var qe=B(Be=>{"use strict";a();Object.defineProperty(Be,"__esModule",{value:!0});var Dn=(G(),q(z)),Mn=Dn.__importDefault(je()),He=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,l,d,c;let u=null,f=null,p=null,g=o.status,w=o.statusText;if(o.ok){if(this.method!=="HEAD"){let S=await o.text();S===""||(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"))?f=S:f=JSON.parse(S))}let y=(l=this.headers.get("Prefer"))===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),_=(d=o.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");y&&_&&_.length>1&&(p=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(f)&&(f.length>1?(u={code:"PGRST116",details:`Results contain ${f.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},f=null,p=null,g=406,w="Not Acceptable"):f.length===1?f=f[0]:f=null)}else{let y=await o.text();try{u=JSON.parse(y),Array.isArray(u)&&o.status===404&&(f=[],u=null,g=200,w="OK")}catch{o.status===404&&y===""?(g=204,w="No Content"):u={message:y}}if(u&&this.isMaybeSingle&&(!((c=u?.details)===null||c===void 0)&&c.includes("0 rows"))&&(u=null,g=200,w="OK"),u&&this.shouldThrowOnError)throw new Mn.default(u)}return{error:u,data:f,count:p,status:g,statusText:w}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,l,d;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(l=o?.stack)!==null&&l!==void 0?l:""}`,hint:"",code:`${(d=o?.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Be.default=He});var Ge=B(ze=>{"use strict";a();Object.defineProperty(ze,"__esModule",{value:!0});var kn=(G(),q(z)),jn=kn.__importDefault(qe()),Fe=class extends jn.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",l=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${l?`${l},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var l;let d=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),c=(l=this.headers.get("Accept"))!==null&&l!==void 0?l:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${c}"; options=${d};`),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}};ze.default=Fe});var Ee=B(We=>{"use strict";a();Object.defineProperty(We,"__esModule",{value:!0});var Hn=(G(),q(z)),Bn=Hn.__importDefault(Ge()),qn=new RegExp("[,()]"),Ve=class extends Bn.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let n=Array.from(new Set(t)).map(s=>typeof s=="string"&&qn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};We.default=Ve});var Ye=B(Je=>{"use strict";a();Object.defineProperty(Je,"__esModule",{value:!0});var Fn=(G(),q(z)),ae=Fn.__importDefault(Ee()),Ke=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,l=(e??"*").split("").map(d=>/\s/.test(d)&&!i?"":(d==='"'&&(i=!i),d)).join("");return this.url.searchParams.set("select",l),s&&this.headers.append("Prefer",`count=${s}`),new ae.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((l,d)=>l.concat(Object.keys(d)),[]);if(i.length>0){let l=[...new Set(i)].map(d=>`"${d}"`);this.url.searchParams.set("columns",l.join(","))}}return new ae.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let l="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let d=e.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(d.length>0){let c=[...new Set(d)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new ae.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new ae.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new ae.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Je.default=Ke});var lr=B(Xe=>{"use strict";a();Object.defineProperty(Xe,"__esModule",{value:!0});var ar=(G(),q(z)),zn=ar.__importDefault(Ye()),Gn=ar.__importDefault(Ee()),Qe=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new zn.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:o}={}){var i;let l,d=new URL(`${this.url}/rpc/${e}`),c;n||s?(l=n?"HEAD":"GET",Object.entries(t).filter(([f,p])=>p!==void 0).map(([f,p])=>[f,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([f,p])=>{d.searchParams.append(f,p)})):(l="POST",c=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new Gn.default({method:l,url:d,headers:u,schema:this.schemaName,body:c,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Xe.default=Qe});var mr=B(P=>{"use strict";a();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var Q=(G(),q(z)),cr=Q.__importDefault(lr());P.PostgrestClient=cr.default;var ur=Q.__importDefault(Ye());P.PostgrestQueryBuilder=ur.default;var dr=Q.__importDefault(Ee());P.PostgrestFilterBuilder=dr.default;var fr=Q.__importDefault(Ge());P.PostgrestTransformBuilder=fr.default;var hr=Q.__importDefault(qe());P.PostgrestBuilder=hr.default;var pr=Q.__importDefault(je());P.PostgrestError=pr.default;P.default={PostgrestClient:cr.default,PostgrestQueryBuilder:ur.default,PostgrestFilterBuilder:dr.default,PostgrestTransformBuilder:fr.default,PostgrestBuilder:hr.default,PostgrestError:pr.default}});var Kn={};ot(Kn,{AUTH_BASE_PATH:()=>Ct,AbortController:()=>ie,AbortSignal:()=>J,CURRENT_JWT_KEY:()=>W,ENTITIES_BASE_PATH:()=>yr,FILE_STORAGE_BASE_PATH:()=>Ut,GENERATE_UPLOAD_URL_PATH:()=>Nt,Headers:()=>T,LOGIN_TOKEN_KEY:()=>ge,LOGIN_USER_PROFILE_KEY:()=>ye,NvwaAuthClient:()=>Ie,NvwaEdgeFunctions:()=>Ce,NvwaFileStorage:()=>Ne,NvwaHttpClient:()=>Ue,NvwaSkill:()=>et,OverlayManager:()=>tt,Request:()=>se,Response:()=>oe,URL:()=>ne,URLSearchParams:()=>K,createPostgrestClient:()=>Vn,getSourceLocationFromDOM:()=>Wn,polyfill:()=>Un});module.exports=q(Kn);a();a();a();a();a();a();var Sr=Object.defineProperty,Ar=Object.defineProperties,xr=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,Ir=Object.prototype.hasOwnProperty,Cr=Object.prototype.propertyIsEnumerable,lt=(r,e,t)=>e in r?Sr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e)=>{for(var t in e||(e={}))Ir.call(e,t)&&lt(r,t,e[t]);if(at)for(var t of at(e))Cr.call(e,t)&&lt(r,t,e[t]);return r},N=(r,e)=>Ar(r,xr(e)),Ur=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Nr=async(r,e)=>{var t,n,s,o,i,l;let d=e||{},c={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:d,hooks:c};for(let u of e?.plugins||[]){if(u.init){let f=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));d=f.options||d,r=f.url}c.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),c.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),c.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),c.onError.push((i=u.hooks)==null?void 0:i.onError),c.onRetry.push((l=u.hooks)==null?void 0:l.onRetry)}return{url:r,options:d,hooks:c}},ct=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(){return this.options.delay}},Lr=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(r){return Math.min(this.options.maxDelay,this.options.baseDelay*2**r)}};function $r(r){if(typeof r=="number")return new ct({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new ct(r);case"exponential":return new Lr(r);default:throw new Error("Invalid retry strategy")}}var Dr=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Mr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function kr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Mr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function jr(r){try{return JSON.parse(r),!0}catch{return!1}}function ft(r){if(r===void 0)return!1;let e=typeof r;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(r)?!0:r.buffer?!1:r.constructor&&r.constructor.name==="Object"||typeof r.toJSON=="function"}function ut(r){try{return JSON.parse(r)}catch{return r}}function dt(r){return typeof r=="function"}function Hr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&dt(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&dt(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Br(r){let e=new Headers(r?.headers),t=await Dr(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=qr(r?.body);n&&e.set("content-type",n)}return e}function qr(r){return ft(r)?"application/json":null}function Fr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(ft(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function zr(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return pt.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Gr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var Vr=class ht extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,ht.prototype)}};async function ue(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new Vr(t.issues);return t.value}var pt=["get","post","put","patch","delete"];var Wr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let l=((s=(n=r.plugins)==null?void 0:n.find(d=>{var c;return(c=d.schema)!=null&&c.config?e.startsWith(d.schema.config.baseURL||"")||e.startsWith(d.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(l){let d=e;(o=l.config)!=null&&o.prefix&&d.startsWith(l.config.prefix)&&(d=d.replace(l.config.prefix,""),l.config.baseURL&&(e=e.replace(l.config.prefix,l.config.baseURL))),(i=l.config)!=null&&i.baseURL&&d.startsWith(l.config.baseURL)&&(d=d.replace(l.config.baseURL,""));let c=l.schema[d];if(c){let u=N(C({},t),{method:c.method,output:c.output});return t?.disableValidation||(u=N(C({},u),{body:c.input?await ue(c.input,t?.body):t?.body,params:c.params?await ue(c.params,t?.params):t?.params,query:c.query?await ue(c.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),mt=r=>{async function e(t,n){let s=N(C(C({},r),n),{plugins:[...r?.plugins||[],Wr(r||{})]});if(r?.catchAllError)try{return await Re(t,s)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await Re(t,s)}return e};function Kr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let f=r.toString().split("@")[1].split("/")[0];pt.includes(f)&&(r=r.replace(`@${f}/`,"/"))}o.endsWith("/")||(o+="/");let[i,l]=r.replace(o,"").split("?"),d=new URLSearchParams(l);for(let[f,p]of Object.entries(s||{}))p!=null&&d.set(f,String(p));if(n)if(Array.isArray(n)){let f=i.split("/").filter(p=>p.startsWith(":"));for(let[p,g]of f.entries()){let w=n[p];i=i.replace(g,w)}}else for(let[f,p]of Object.entries(n))i=i.replace(`:${f}`,String(p));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let c=d.toString();return c=c.length>0?`?${c}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${c}`,o):`${o}${i}${c}`}var Re=async(r,e)=>{var t,n,s,o,i,l,d,c;let{hooks:u,url:f,options:p}=await Nr(r,e),g=Hr(p),w=new AbortController,E=(t=p.signal)!=null?t:w.signal,y=Kr(f,p),_=Fr(p),S=await Br(p),D=zr(f,p),m=N(C({},p),{url:y,headers:S,body:_,method:D,signal:E});for(let I of u.onRequest)if(I){let O=await I(m);O instanceof Object&&(m=O)}("pipeTo"in m&&typeof m.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in m||(m.duplex="half"));let{clearTimeout:H}=Gr(p,w),b=await g(m.url,m);H();let rt={response:b,request:m};for(let I of u.onResponse)if(I){let O=await I(N(C({},rt),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?b.clone():b}));O instanceof Response?b=O:O instanceof Object&&(b=O.response)}if(b.ok){if(!(m.method!=="HEAD"))return{data:"",error:null};let O=kr(b),M={data:"",response:b,request:m};if(O==="json"||O==="text"){let k=await b.text(),br=await((o=m.jsonParser)!=null?o:ut)(k);M.data=br}else M.data=await b[O]();m?.output&&m.output&&!m.disableValidation&&(M.data=await ue(m.output,M.data));for(let k of u.onSuccess)k&&await k(N(C({},M),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?b.clone():b}));return e?.throw?M.data:{data:M.data,error:null}}let wr=(l=e?.jsonParser)!=null?l:ut,le=await b.text(),nt=jr(le),_e=nt?await wr(le):null,vr={response:b,responseText:le,request:m,error:N(C({},_e),{status:b.status,statusText:b.statusText})};for(let I of u.onError)I&&await I(N(C({},vr),{response:(d=e?.hookOptions)!=null&&d.cloneResponse?b.clone():b}));if(e?.retry){let I=$r(e.retry),O=(c=e.retryAttempt)!=null?c:0;if(await I.shouldAttemptRetry(O,b)){for(let k of u.onRetry)k&&await k(rt);let M=I.getDelay(O);return await new Promise(k=>setTimeout(k,M)),await Re(r,N(C({},e),{retryAttempt:O+1}))}}if(e?.throw)throw new Ur(b.status,b.statusText,nt?_e:le);return{data:null,error:N(C({},_e),{status:b.status,statusText:b.statusText})}};a();a();var de=Object.create(null),X=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?de:globalThis),x=new Proxy(de,{get(r,e){return X()[e]??de[e]},has(r,e){let t=X();return e in t||e in de},set(r,e,t){let n=X(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=X(!0);return delete t[e],!0},ownKeys(){let r=X(!0);return Object.keys(r)}});var ns=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function v(r,e){return typeof process<"u"&&process.env?process.env[r]??e:typeof Deno<"u"?Deno.env.get(r)??e:typeof Bun<"u"?Bun.env[r]??e:e}var ss=Object.freeze({get BETTER_AUTH_SECRET(){return v("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return v("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return v("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return v("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return v("NODE_ENV","development")},get PACKAGE_VERSION(){return v("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return v("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Z=1,R=4,L=8,A=24,gt={eterm:R,cons25:R,console:R,cygwin:R,dtterm:R,gnome:R,hurd:R,jfbterm:R,konsole:R,kterm:R,mlterm:R,mosh:A,putty:R,st:R,"rxvt-unicode-24bit":A,terminator:A,"xterm-kitty":A},Jr=new Map(Object.entries({APPVEYOR:L,BUILDKITE:L,CIRCLECI:A,DRONE:L,GITEA_ACTIONS:A,GITHUB_ACTIONS:A,GITLAB_CI:L,TRAVIS:L})),Yr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Qr(){if(v("FORCE_COLOR")!==void 0)switch(v("FORCE_COLOR")){case"":case"1":case"true":return R;case"2":return L;case"3":return A;default:return Z}if(v("NODE_DISABLE_COLORS")!==void 0&&v("NODE_DISABLE_COLORS")!==""||v("NO_COLOR")!==void 0&&v("NO_COLOR")!==""||v("TERM")==="dumb")return Z;if(v("TMUX"))return A;if("TF_BUILD"in x&&"AGENT_NAME"in x)return R;if("CI"in x){for(let{0:r,1:e}of Jr)if(r in x)return e;return v("CI_NAME")==="codeship"?L:Z}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(v("TEAMCITY_VERSION"))!==null?R:Z;switch(v("TERM_PROGRAM")){case"iTerm.app":return!v("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(v("TERM_PROGRAM_VERSION"))!==null?L:A;case"HyperTerm":case"MacTerm":return A;case"Apple_Terminal":return L}if(v("COLORTERM")==="truecolor"||v("COLORTERM")==="24bit")return A;if(v("TERM")){if(/truecolor/.exec(v("TERM"))!==null)return A;if(/^xterm-256/.exec(v("TERM"))!==null)return L;let r=v("TERM").toLowerCase();if(gt[r])return gt[r];if(Yr.some(e=>e.exec(r)!==null))return R}return v("COLORTERM")?R:Z}var $={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},Oe=["info","success","warn","error","debug"];function Xr(r,e){return Oe.indexOf(e)<=Oe.indexOf(r)}var Zr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},en=(r,e,t)=>{let n=new Date().toISOString();return t?`${$.dim}${n}${$.reset} ${Zr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},tn=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Qr()!==1,o=(l,d,c=[])=>{if(!e||!Xr(t,l))return;let u=en(l,d,s);if(!r||typeof r.log!="function"){l==="error"?console.error(u,...c):l==="warn"?console.warn(u,...c):console.log(u,...c);return}r.log(l==="success"?"info":l,d,...c)};return{...Object.fromEntries(Oe.map(l=>[l,(...[d,...c])=>o(l,d,c)])),get level(){return t}}},os=tn();a();a();var fs={USER_NOT_FOUND:"User not found",FAILED_TO_CREATE_USER:"Failed to create user",FAILED_TO_CREATE_SESSION:"Failed to create session",FAILED_TO_UPDATE_USER:"Failed to update user",FAILED_TO_GET_SESSION:"Failed to get session",INVALID_PASSWORD:"Invalid password",INVALID_EMAIL:"Invalid email",INVALID_EMAIL_OR_PASSWORD:"Invalid email or password",SOCIAL_ACCOUNT_ALREADY_LINKED:"Social account already linked",PROVIDER_NOT_FOUND:"Provider not found",INVALID_TOKEN:"Invalid token",ID_TOKEN_NOT_SUPPORTED:"id_token not supported",FAILED_TO_GET_USER_INFO:"Failed to get user info",USER_EMAIL_NOT_FOUND:"User email not found",EMAIL_NOT_VERIFIED:"Email not verified",PASSWORD_TOO_SHORT:"Password too short",PASSWORD_TOO_LONG:"Password too long",USER_ALREADY_EXISTS:"User already exists.",USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:"User already exists. Use another email.",EMAIL_CAN_NOT_BE_UPDATED:"Email can not be updated",CREDENTIAL_ACCOUNT_NOT_FOUND:"Credential account not found",SESSION_EXPIRED:"Session expired. Re-authenticate to perform this action.",FAILED_TO_UNLINK_LAST_ACCOUNT:"You can't unlink your last account",ACCOUNT_NOT_FOUND:"Account not found",USER_ALREADY_HAS_PASSWORD:"User already has a password. Provide that to delete the account."},F=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function rn(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new F(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function ee(r,e="/api/auth"){if(rn(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function yt(r,e,t,n){if(r)return ee(r,e);if(n!==!1){let i=x.BETTER_AUTH_URL||x.NEXT_PUBLIC_BETTER_AUTH_URL||x.PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_BETTER_AUTH_URL||x.NUXT_PUBLIC_AUTH_URL||(x.BASE_URL!=="/"?x.BASE_URL:void 0);if(i)return ee(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return ee(`${o}://${s}`,e);if(t){let i=nn(t.url);if(!i)throw new F("Could not get origin from request. Please provide a valid base URL.");return ee(i,e)}if(typeof window<"u"&&window.location)return ee(window.location.origin,e)}function nn(r){try{return new URL(r).origin}catch{return null}}a();a();a();var te=Symbol("clean");var U=[],j=0,fe=4,sn=0,re=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=j+fe;o<U.length;)U[o]===n?U.splice(o,fe):o+=fe;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){sn++;let o=!U.length;for(let i of e)U.push(i,t.value,n,s);if(o){for(j=0;j<U.length;j+=fe)U[j](U[j+1],U[j+2],U[j+3]);U.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[te]=()=>{e=[],t.lc=0,t.off()}),t};a();var on=5,V=6,he=10,an=(r,e,t,n)=>(r.events=r.events||{},r.events[t+he]||(r.events[t+he]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+he](),delete r.events[t+he])});var wt=1e3,Te=(r,e)=>an(r,n=>{let s=e(n);s&&r.events[V].push(s)},on,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[V]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[V])i();r.events[V]=[]}},wt)},process.env.NODE_ENV!=="production"){let i=r[te];r[te]=()=>{for(let l of r.events[V])l();r.events[V]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});a();var ln=typeof window>"u",pe=(r,e,t,n)=>{let s=re({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let d=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...d,query:{...d?.query,...l?.query},async onSuccess(c){s.set({data:c.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onSuccess?.(c)},async onError(c){let{request:u}=c,f=typeof u.retry=="number"?u.retry:u.retry?.attempts,p=u.retryAttempt||0;f&&p<f||(s.set({error:c.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onError?.(c))},async onRequest(c){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await d?.onRequest?.(c)}}).catch(c=>{s.set({error:c,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let l of r)l.subscribe(()=>{ln||(i?o():Te(s,()=>{let d=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),l.off(),clearTimeout(d)}}))});return s};a();var cn={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},un=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,vt={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},dn=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function fn(r){return r instanceof Date&&!isNaN(r.getTime())}function hn(r){let e=dn.exec(r);if(!e)return null;let[,t,n,s,o,i,l,d,c,u,f]=e,p=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(l,10),d?parseInt(d.padEnd(3,"0"),10):0));if(c){let g=(parseInt(u,10)*60+parseInt(f,10))*(c==="+"?-1:1);p.setUTCMinutes(p.getUTCMinutes()+g)}return fn(p)?p:null}function pn(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=e;if(typeof r!="string")return r;let i=r.trim();if(i.length>0&&i[0]==='"'&&i.endsWith('"')&&!i.slice(1,-1).includes('"'))return i.slice(1,-1);let l=i.toLowerCase();if(l.length<=9&&l in vt)return vt[l];if(!un.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(cn).some(([c,u])=>{let f=u.test(i);return f&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${c} pattern`),f})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,f)=>{if(u==="__proto__"||u==="constructor"&&f&&typeof f=="object"&&"prototype"in f){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof f=="string"){let p=hn(f);if(p)return p}return s?s(u,f):f})}catch(c){if(t)throw c;return r}}function bt(r,e={strict:!0}){return pn(r,e)}var mn={id:"redirect",name:"Redirect",hooks:{onSuccess(r){if(r.data?.url&&r.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=r.data.url}catch{}}}};function gn(r){let e=re(!1);return{session:pe(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var Et=(r,e)=>{let t="credentials"in Request.prototype,n=yt(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=r?.plugins?.flatMap(m=>m.fetchPlugins).filter(m=>m!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:r?.fetchOptions?.onSuccess,onError:r?.fetchOptions?.onError,onRequest:r?.fetchOptions?.onRequest,onResponse:r?.fetchOptions?.onResponse}},{onSuccess:i,onError:l,onRequest:d,onResponse:c,...u}=r?.fetchOptions||{},f=mt({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(m){return m?bt(m,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[mn],...s]}),{$sessionSignal:p,session:g}=gn(f),w=r?.plugins||[],E={},y={$sessionSignal:p,session:g},_={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},S=[{signal:"$sessionSignal",matcher(m){return m==="/sign-out"||m==="/update-user"||m.startsWith("/sign-in")||m.startsWith("/sign-up")||m==="/delete-user"||m==="/verify-email"}}];for(let m of w)m.getAtoms&&Object.assign(y,m.getAtoms?.(f)),m.pathMethods&&Object.assign(_,m.pathMethods),m.atomListeners&&S.push(...m.atomListeners);let D={notify:m=>{y[m].set(!y[m].get())},listen:(m,H)=>{y[m].subscribe(H)},atoms:y};for(let m of w)m.getActions&&Object.assign(E,m.getActions?.(f,D,r));return{get baseURL(){return n},pluginsActions:E,pluginsAtoms:y,pluginPathMethods:_,atomListeners:S,$fetch:f,$store:D}};function yn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function wn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function _t(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(l,d){if(typeof d!="string"||d==="then"||d==="catch"||d==="finally")return;let c=[...i,d],u=r;for(let f of c)if(u&&typeof u=="object"&&f in u)u=u[f];else{u=void 0;break}return typeof u=="function"||yn(u)?u:o(c)},apply:async(l,d,c)=>{let u="/"+i.map(S=>S.replace(/[A-Z]/g,D=>`-${D.toLowerCase()}`)).join("/"),f=c[0]||{},p=c[1]||{},{query:g,fetchOptions:w,...E}=f,y={...p,...w},_=wn(u,t,f);return await e(u,{...y,body:_==="GET"?void 0:{...E,...y?.body||{}},query:g||y?.query,method:_,async onSuccess(S){if(await y?.onSuccess?.(S),!s)return;let D=s.filter(m=>m.matcher(u));if(D.length)for(let m of D){let H=n[m.signal];if(!H)return;let b=H.get();setTimeout(()=>{H.set(!b)},10)}}})}})}return o()}a();function Rt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Pe(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=Et(r),l={};for(let[u,f]of Object.entries(n))l[`use${Rt(u)}`]=f;let d={...t,...l,$fetch:s,$store:i};return _t(d,s,e,n,o)}a();a();a();function vn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(l=>i.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(d=>i.includes(d)):n=l.actions.every(d=>i.includes(d))}else throw new F("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function me(r){return{newRole(e){return vn(e)},statements:r}}var bn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Se=me(bn),En=Se.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),_n=Se.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Rn=Se.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});a();a();a();a();a();a();a();a();a();a();a();var Ae=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Pt=new Ae;a();a();a();a();a();a();a();a();var An={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},St=me(An),xn=St.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),In=St.newRole({user:[],session:[]});a();a();var At=()=>({id:"username",$InferServerPlugin:{}});var xt=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(r){return r==="/phone-number/update"||r==="/phone-number/verify"},signal:"$sessionSignal"}]});var It=()=>({id:"better-auth-client",$InferServerPlugin:{}});var Ct="/auth",ge="nvwa_login_token",W="nvwa_current_jwt",ye="nvwa_user_profile",Ie=class{constructor(e,t,n){this.storage=n;let s=Pe({baseURL:e,basePath:Ct,plugins:[At(),xt(),It()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let o=await this.storage.get(W);if(console.log("jwt",o),o)return o;let i=await this.storage.get(ge);return console.log("loginToken",i),i}}}});this.authClient=s}async currentUser(){return await this.storage.get(ye)}async getCurrentJwt(){return await this.storage.get(W)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let n=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.handleLogin(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(n)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ge,e.data?.token),await this.storage.set(ye,e.data?.user);let{data:t,error:n}=await this.authClient.token();if(n)throw new Error(n.message);await this.storage.set(W,t.token)}async signOut(){await this.storage.remove(ge),await this.storage.remove(ye)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.handleLogin(s)}};a();var Ce=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};a();a();a();var T=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},K=class r{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},ne=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new K(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",l=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let d=s.match(/^([^@]*)@(.+)$/),c="",u="",f=s;if(d){let E=d[1];f=d[2];let y=E.match(/^([^:]*):?(.*)$/);y&&(c=y[1]||"",u=y[2]||"")}let p=f.match(/^([^:]+):?(\d*)$/),g=p?p[1]:f,w=p&&p[2]?p[2]:"";return{protocol:n?`${n}:`:"",username:c,password:u,host:f,hostname:g,port:w,pathname:o,search:i,hash:l}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};a();var se=class r{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof T?t.headers:new T(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new r(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};a();var oe=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=Cn(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 Cn(r){return r?new T(r):new T}a();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]"}},ie=class{constructor(){this._signal=new J}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};a();function Un(r){r.URL=ne,r.URLSearchParams=K,r.Headers=T,r.Request=se,r.Response=oe,r.AbortController=ie,r.AbortSignal=J}var Ue=class{constructor(e,t,n){console.log("NvwaHttpClient constructor",e,t,n),this.storage=e,this.customFetch=t,this.handleUnauthorized=n}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let n=await this.storage.get(W),s=new T(t?.headers);n&&s.set("Authorization",`Bearer ${n}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let l=s.get("Content-Type");(!l||l.includes("text/plain"))&&s.set("Content-Type","application/json")}let i=await this.customFetch(e,{...t,headers:s});if(i.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return i}};a();var Ut="/storage",Nt=Ut+"/generateUploadUrl",Ne=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Nt,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=await t.json();if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(n,{method:"PUT",body:e,headers:new T({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};a();a();a();var Ze=Pr(mr(),1),{PostgrestClient:gr,PostgrestQueryBuilder:pl,PostgrestFilterBuilder:ml,PostgrestTransformBuilder:gl,PostgrestBuilder:yl,PostgrestError:wl}=Ze.default||Ze;var yr="/entities",Vn=(r,e)=>new gr(r+yr,{fetch:e.fetchWithAuth.bind(e)});a();var et=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let n=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(n,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};a();var tt=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 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:()=>Ue,__asyncGenerator:()=>Ie,__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:()=>Ae,__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 Ae(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 Ie(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 Ue(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:Ae,__await:T,__asyncGenerator:Ie,__asyncDelegator:Ue,__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 U=await o.text();U===""||(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=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=(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)),I=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 I.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 I.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 I.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 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})}};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:()=>A,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){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};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]"}},A=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=A,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:Ar,PostgrestTransformBuilder:Ir,PostgrestBuilder:Ur,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=`
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 n=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;n.width>0&&n.height>0?(e.style.left=`${n.left+s}px`,e.style.top=`${n.top+o}px`,e.style.width=`${n.width}px`,e.style.height=`${n.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 l=this.createTooltip();t?l.textContent=t:l.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,l.style.display="block";let d=e.getBoundingClientRect();l.style.left=`${d.left+window.scrollX}px`,l.style.top=`${d.top+window.scrollY-l.offsetHeight-8}px`,d.top<l.offsetHeight+8&&(l.style.top=`${d.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let n=this.createOverlay("hover");this.updateOverlayPosition(n,e),this.hoverOverlay=n,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let 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 n=this.createOverlay("selected");this.updateOverlayPosition(n,e),this.selectedOverlay=n,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Wn(r="root"){if(typeof document>"u")return null;let e=document.getElementById(r)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let n=t.getAttribute("data-source-location");if(n)return n}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}0&&(module.exports={AUTH_BASE_PATH,AbortController,AbortSignal,CURRENT_JWT_KEY,ENTITIES_BASE_PATH,FILE_STORAGE_BASE_PATH,GENERATE_UPLOAD_URL_PATH,Headers,LOGIN_TOKEN_KEY,LOGIN_USER_PROFILE_KEY,NvwaAuthClient,NvwaEdgeFunctions,NvwaFileStorage,NvwaHttpClient,NvwaSkill,OverlayManager,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,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});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var yr=Object.create;var ie=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var vr=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty;var Ze=(r,e)=>()=>(r&&(e=r(r=0)),e);var F=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_r=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},et=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vr(e))!Er.call(r,s)&&s!==t&&ie(r,s,{get:()=>e[s],enumerable:!(n=wr(e,s))||n.enumerable});return r};var Rr=(r,e,t)=>(t=r!=null?yr(br(r)):{},et(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),V=r=>et(ie({},"__esModule",{value:!0}),r);import Jn from"path";import{fileURLToPath as Qn}from"url";var a=Ze(()=>{"use strict"});var z={};_r(z,{__addDisposableResource:()=>Zt,__assign:()=>ye,__asyncDelegator:()=>Gt,__asyncGenerator:()=>zt,__asyncValues:()=>Vt,__await:()=>K,__awaiter:()=>Mt,__classPrivateFieldGet:()=>Yt,__classPrivateFieldIn:()=>Xt,__classPrivateFieldSet:()=>Qt,__createBinding:()=>ve,__decorate:()=>Ct,__disposeResources:()=>er,__esDecorate:()=>Ut,__exportStar:()=>Ht,__extends:()=>xt,__generator:()=>jt,__importDefault:()=>Jt,__importStar:()=>Kt,__makeTemplateObject:()=>Wt,__metadata:()=>kt,__param:()=>Nt,__propKey:()=>Dt,__read:()=>Ue,__rest:()=>It,__rewriteRelativeImportExtension:()=>tr,__runInitializers:()=>Lt,__setFunctionName:()=>$t,__spread:()=>Bt,__spreadArray:()=>qt,__spreadArrays:()=>Ft,__values:()=>we,default:()=>Ln});function xt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ce(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function It(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function Ct(r,e,t,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var l=r.length-1;l>=0;l--)(i=r[l])&&(o=(s<3?i(o):s>3?i(e,t,o):i(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function Nt(r,e){return function(t,n){e(t,n,r)}}function Ut(r,e,t,n,s,o){function i(R){if(R!==void 0&&typeof R!="function")throw new TypeError("Function expected");return R}for(var l=n.kind,d=l==="getter"?"get":l==="setter"?"set":"value",c=!e&&r?n.static?r:r.prototype:null,u=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),f,m=!1,y=t.length-1;y>=0;y--){var v={};for(var _ in n)v[_]=_==="access"?{}:n[_];for(var _ in n.access)v.access[_]=n.access[_];v.addInitializer=function(R){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(R||null))};var w=(0,t[y])(l==="accessor"?{get:u.get,set:u.set}:u[d],v);if(l==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(f=i(w.get))&&(u.get=f),(f=i(w.set))&&(u.set=f),(f=i(w.init))&&s.unshift(f)}else(f=i(w))&&(l==="field"?s.unshift(f):u[d]=f)}c&&Object.defineProperty(c,n.name,u),m=!0}function Lt(r,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(r,t):e[s].call(r);return n?t:void 0}function Dt(r){return typeof r=="symbol"?r:"".concat(r)}function $t(r,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function kt(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Mt(r,e,t,n){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function l(u){try{c(n.next(u))}catch(f){i(f)}}function d(u){try{c(n.throw(u))}catch(f){i(f)}}function c(u){u.done?o(u.value):s(u.value).then(l,d)}c((n=n.apply(r,e||[])).next())})}function jt(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(c){return function(u){return d([c,u])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(t=0)),t;)try{if(n=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,s=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],s=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Ht(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ve(e,r,t)}function we(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ue(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(l){i={error:l}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}function Bt(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Ue(arguments[e]));return r}function Ft(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var o=arguments[e],i=0,l=o.length;i<l;i++,s++)n[s]=o[i];return n}function qt(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function K(r){return this instanceof K?(this.v=r,this):new K(r)}function zt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(y){return function(v){return Promise.resolve(v).then(y,f)}}function l(y,v){n[y]&&(s[y]=function(_){return new Promise(function(w,R){o.push([y,_,w,R])>1||d(y,_)})},v&&(s[y]=v(s[y])))}function d(y,v){try{c(n[y](v))}catch(_){m(o[0][3],_)}}function c(y){y.value instanceof K?Promise.resolve(y.value.v).then(u,f):m(o[0][2],y)}function u(y){d("next",y)}function f(y){d("throw",y)}function m(y,v){y(v),o.shift(),o.length&&d(o[0][0],o[0][1])}}function Gt(r){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,o){e[s]=r[s]?function(i){return(t=!t)?{value:K(r[s](i)),done:!1}:o?o(i):i}:o}}function Vt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof we=="function"?we(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(i){return new Promise(function(l,d){i=r[o](i),s(l,d,i.done,i.value)})}}function s(o,i,l,d){Promise.resolve(d).then(function(c){o({value:c,done:l})},i)}}function Wt(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Kt(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t=Ne(r),n=0;n<t.length;n++)t[n]!=="default"&&ve(e,r,t[n]);return Nn(e,r),e}function Jt(r){return r&&r.__esModule?r:{default:r}}function Yt(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Qt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}function Xt(r,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?e===r:r.has(e)}function Zt(r,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e}function er(r){function e(o){r.error=r.hasError?new Un(o,r.error,"An error was suppressed during disposal."):o,r.hasError=!0}var t,n=0;function s(){for(;t=r.stack.pop();)try{if(!t.async&&n===1)return n=0,r.stack.push(t),Promise.resolve().then(s);if(t.dispose){var o=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else n|=1}catch(i){e(i)}if(n===1)return r.hasError?Promise.reject(r.error):Promise.resolve();if(r.hasError)throw r.error}return s()}function tr(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,o,i){return n?e?".jsx":".js":s&&(!o||!i)?t:s+o+"."+i.toLowerCase()+"js"}):r}var Ce,ye,ve,Nn,Ne,Un,Ln,G=Ze(()=>{"use strict";a();Ce=function(r,e){return Ce=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ce(r,e)};ye=function(){return ye=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ye.apply(this,arguments)};ve=Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]});Nn=Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e},Ne=function(r){return Ne=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ne(r)};Un=typeof SuppressedError=="function"?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n};Ln={__extends:xt,__assign:ye,__rest:It,__decorate:Ct,__param:Nt,__esDecorate:Ut,__runInitializers:Lt,__propKey:Dt,__setFunctionName:$t,__metadata:kt,__awaiter:Mt,__generator:jt,__createBinding:ve,__exportStar:Ht,__values:we,__read:Ue,__spread:Bt,__spreadArrays:Ft,__spreadArray:qt,__await:K,__asyncGenerator:zt,__asyncDelegator:Gt,__asyncValues:Vt,__makeTemplateObject:Wt,__importStar:Kt,__importDefault:Jt,__classPrivateFieldGet:Yt,__classPrivateFieldSet:Qt,__classPrivateFieldIn:Xt,__addDisposableResource:Zt,__disposeResources:er,__rewriteRelativeImportExtension:tr}});var $e=F(De=>{"use strict";a();Object.defineProperty(De,"__esModule",{value:!0});var Le=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};De.default=Le});var je=F(Me=>{"use strict";a();Object.defineProperty(Me,"__esModule",{value:!0});var Dn=(G(),V(z)),$n=Dn.__importDefault($e()),ke=class{constructor(e){var t,n;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,l,d,c;let u=null,f=null,m=null,y=o.status,v=o.statusText;if(o.ok){if(this.method!=="HEAD"){let A=await o.text();A===""||(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"))?f=A:f=JSON.parse(A))}let w=(l=this.headers.get("Prefer"))===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),R=(d=o.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");w&&R&&R.length>1&&(m=parseInt(R[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(f)&&(f.length>1?(u={code:"PGRST116",details:`Results contain ${f.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},f=null,m=null,y=406,v="Not Acceptable"):f.length===1?f=f[0]:f=null)}else{let w=await o.text();try{u=JSON.parse(w),Array.isArray(u)&&o.status===404&&(f=[],u=null,y=200,v="OK")}catch{o.status===404&&w===""?(y=204,v="No Content"):u={message:w}}if(u&&this.isMaybeSingle&&(!((c=u?.details)===null||c===void 0)&&c.includes("0 rows"))&&(u=null,y=200,v="OK"),u&&this.shouldThrowOnError)throw new $n.default(u)}return{error:u,data:f,count:m,status:y,statusText:v}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,l,d;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(l=o?.stack)!==null&&l!==void 0?l:""}`,hint:"",code:`${(d=o?.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}};Me.default=ke});var Fe=F(Be=>{"use strict";a();Object.defineProperty(Be,"__esModule",{value:!0});var kn=(G(),V(z)),Mn=kn.__importDefault(je()),He=class extends Mn.default{select(e){let t=!1,n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){let i=o?`${o}.order`:"order",l=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${l?`${l},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var l;let d=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),c=(l=this.headers.get("Accept"))!==null&&l!==void 0?l:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${c}"; options=${d};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};Be.default=He});var be=F(ze=>{"use strict";a();Object.defineProperty(ze,"__esModule",{value:!0});var jn=(G(),V(z)),Hn=jn.__importDefault(Fe()),Bn=new RegExp("[,()]"),qe=class extends Hn.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let n=Array.from(new Set(t)).map(s=>typeof s=="string"&&Bn.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");let i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};ze.default=qe});var We=F(Ve=>{"use strict";a();Object.defineProperty(Ve,"__esModule",{value:!0});var Fn=(G(),V(z)),se=Fn.__importDefault(be()),Ge=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s}select(e,t){let{head:n=!1,count:s}=t??{},o=n?"HEAD":"GET",i=!1,l=(e??"*").split("").map(d=>/\s/.test(d)&&!i?"":(d==='"'&&(i=!i),d)).join("");return this.url.searchParams.set("select",l),s&&this.headers.append("Prefer",`count=${s}`),new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;let o="POST";if(t&&this.headers.append("Prefer",`count=${t}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let i=e.reduce((l,d)=>l.concat(Object.keys(d)),[]);if(i.length>0){let l=[...new Set(i)].map(d=>`"${d}"`);this.url.searchParams.set("columns",l.join(","))}}return new se.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){var i;let l="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),s&&this.headers.append("Prefer",`count=${s}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let d=e.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(d.length>0){let c=[...new Set(d)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new se.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(e,{count:t}={}){var n;let s="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new se.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:e}={}){var t;let n="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new se.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Ve.default=Ge});var nr=F(Je=>{"use strict";a();Object.defineProperty(Je,"__esModule",{value:!0});var rr=(G(),V(z)),qn=rr.__importDefault(We()),zn=rr.__importDefault(be()),Ke=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new qn.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:o}={}){var i;let l,d=new URL(`${this.url}/rpc/${e}`),c;n||s?(l=n?"HEAD":"GET",Object.entries(t).filter(([f,m])=>m!==void 0).map(([f,m])=>[f,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([f,m])=>{d.searchParams.append(f,m)})):(l="POST",c=t);let u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new zn.default({method:l,url:d,headers:u,schema:this.schemaName,body:c,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};Je.default=Ke});var ur=F(P=>{"use strict";a();Object.defineProperty(P,"__esModule",{value:!0});P.PostgrestError=P.PostgrestBuilder=P.PostgrestTransformBuilder=P.PostgrestFilterBuilder=P.PostgrestQueryBuilder=P.PostgrestClient=void 0;var J=(G(),V(z)),sr=J.__importDefault(nr());P.PostgrestClient=sr.default;var or=J.__importDefault(We());P.PostgrestQueryBuilder=or.default;var ir=J.__importDefault(be());P.PostgrestFilterBuilder=ir.default;var ar=J.__importDefault(Fe());P.PostgrestTransformBuilder=ar.default;var lr=J.__importDefault(je());P.PostgrestBuilder=lr.default;var cr=J.__importDefault($e());P.PostgrestError=cr.default;P.default={PostgrestClient:sr.default,PostgrestQueryBuilder:or.default,PostgrestFilterBuilder:ir.default,PostgrestTransformBuilder:ar.default,PostgrestBuilder:lr.default,PostgrestError:cr.default}});a();a();a();a();a();a();var Or=Object.defineProperty,Tr=Object.defineProperties,Pr=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,Sr=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable,rt=(r,e,t)=>e in r?Or(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,N=(r,e)=>{for(var t in e||(e={}))Sr.call(e,t)&&rt(r,t,e[t]);if(tt)for(var t of tt(e))Ar.call(e,t)&&rt(r,t,e[t]);return r},L=(r,e)=>Tr(r,Pr(e)),xr=class extends Error{constructor(r,e,t){super(e||r.toString(),{cause:t}),this.status=r,this.statusText=e,this.error=t}},Ir=async(r,e)=>{var t,n,s,o,i,l;let d=e||{},c={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:r,options:d,hooks:c};for(let u of e?.plugins||[]){if(u.init){let f=await((t=u.init)==null?void 0:t.call(u,r.toString(),e));d=f.options||d,r=f.url}c.onRequest.push((n=u.hooks)==null?void 0:n.onRequest),c.onResponse.push((s=u.hooks)==null?void 0:s.onResponse),c.onSuccess.push((o=u.hooks)==null?void 0:o.onSuccess),c.onError.push((i=u.hooks)==null?void 0:i.onError),c.onRetry.push((l=u.hooks)==null?void 0:l.onRetry)}return{url:r,options:d,hooks:c}},nt=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(){return this.options.delay}},Cr=class{constructor(r){this.options=r}shouldAttemptRetry(r,e){return this.options.shouldRetry?Promise.resolve(r<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(r<this.options.attempts)}getDelay(r){return Math.min(this.options.maxDelay,this.options.baseDelay*2**r)}};function Nr(r){if(typeof r=="number")return new nt({type:"linear",attempts:r,delay:1e3});switch(r.type){case"linear":return new nt(r);case"exponential":return new Cr(r);default:throw new Error("Invalid retry strategy")}}var Ur=async r=>{let e={},t=async n=>typeof n=="function"?await n():n;if(r?.auth){if(r.auth.type==="Bearer"){let n=await t(r.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(r.auth.type==="Basic"){let n=t(r.auth.username),s=t(r.auth.password);if(!n||!s)return e;e.authorization=`Basic ${btoa(`${n}:${s}`)}`}else if(r.auth.type==="Custom"){let n=t(r.auth.value);if(!n)return e;e.authorization=`${t(r.auth.prefix)} ${n}`}}return e},Lr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Dr(r){let e=r.headers.get("content-type"),t=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Lr.test(n)?"json":t.has(n)||n.startsWith("text/")?"text":"blob"}function $r(r){try{return JSON.parse(r),!0}catch{return!1}}function it(r){if(r===void 0)return!1;let e=typeof r;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(r)?!0:r.buffer?!1:r.constructor&&r.constructor.name==="Object"||typeof r.toJSON=="function"}function st(r){try{return JSON.parse(r)}catch{return r}}function ot(r){return typeof r=="function"}function kr(r){if(r?.customFetchImpl)return r.customFetchImpl;if(typeof globalThis<"u"&&ot(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&ot(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Mr(r){let e=new Headers(r?.headers),t=await Ur(r);for(let[n,s]of Object.entries(t||{}))e.set(n,s);if(!e.has("content-type")){let n=jr(r?.body);n&&e.set("content-type",n)}return e}function jr(r){return it(r)?"application/json":null}function Hr(r){if(!r?.body)return null;let e=new Headers(r?.headers);if(it(r.body)&&!e.has("content-type")){for(let[t,n]of Object.entries(r?.body))n instanceof Date&&(r.body[t]=n.toISOString());return JSON.stringify(r.body)}return r.body}function Br(r,e){var t;if(e?.method)return e.method.toUpperCase();if(r.startsWith("@")){let n=(t=r.split("@")[1])==null?void 0:t.split("/")[0];return lt.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Fr(r,e){let t;return!r?.signal&&r?.timeout&&(t=setTimeout(()=>e?.abort(),r?.timeout)),{abortTimeout:t,clearTimeout:()=>{t&&clearTimeout(t)}}}var qr=class at extends Error{constructor(e,t){super(t||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,at.prototype)}};async function ae(r,e){let t=await r["~standard"].validate(e);if(t.issues)throw new qr(t.issues);return t.value}var lt=["get","post","put","patch","delete"];var zr=r=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(e,t){var n,s,o,i;let l=((s=(n=r.plugins)==null?void 0:n.find(d=>{var c;return(c=d.schema)!=null&&c.config?e.startsWith(d.schema.config.baseURL||"")||e.startsWith(d.schema.config.prefix||""):!1}))==null?void 0:s.schema)||r.schema;if(l){let d=e;(o=l.config)!=null&&o.prefix&&d.startsWith(l.config.prefix)&&(d=d.replace(l.config.prefix,""),l.config.baseURL&&(e=e.replace(l.config.prefix,l.config.baseURL))),(i=l.config)!=null&&i.baseURL&&d.startsWith(l.config.baseURL)&&(d=d.replace(l.config.baseURL,""));let c=l.schema[d];if(c){let u=L(N({},t),{method:c.method,output:c.output});return t?.disableValidation||(u=L(N({},u),{body:c.input?await ae(c.input,t?.body):t?.body,params:c.params?await ae(c.params,t?.params):t?.params,query:c.query?await ae(c.query,t?.query):t?.query})),{url:e,options:u}}}return{url:e,options:t}}}),ct=r=>{async function e(t,n){let s=L(N(N({},r),n),{plugins:[...r?.plugins||[],zr(r||{})]});if(r?.catchAllError)try{return await _e(t,s)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await _e(t,s)}return e};function Gr(r,e){let{baseURL:t,params:n,query:s}=e||{query:{},params:{},baseURL:""},o=r.startsWith("http")?r.split("/").slice(0,3).join("/"):t||"";if(r.startsWith("@")){let f=r.toString().split("@")[1].split("/")[0];lt.includes(f)&&(r=r.replace(`@${f}/`,"/"))}o.endsWith("/")||(o+="/");let[i,l]=r.replace(o,"").split("?"),d=new URLSearchParams(l);for(let[f,m]of Object.entries(s||{}))m!=null&&d.set(f,String(m));if(n)if(Array.isArray(n)){let f=i.split("/").filter(m=>m.startsWith(":"));for(let[m,y]of f.entries()){let v=n[m];i=i.replace(y,v)}}else for(let[f,m]of Object.entries(n))i=i.replace(`:${f}`,String(m));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let c=d.toString();return c=c.length>0?`?${c}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${i}${c}`,o):`${o}${i}${c}`}var _e=async(r,e)=>{var t,n,s,o,i,l,d,c;let{hooks:u,url:f,options:m}=await Ir(r,e),y=kr(m),v=new AbortController,_=(t=m.signal)!=null?t:v.signal,w=Gr(f,m),R=Hr(m),A=await Mr(m),k=Br(f,m),g=L(N({},m),{url:w,headers:A,body:R,method:k,signal:_});for(let C of u.onRequest)if(C){let T=await C(g);T instanceof Object&&(g=T)}("pipeTo"in g&&typeof g.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in g||(g.duplex="half"));let{clearTimeout:B}=Fr(m,v),E=await y(g.url,g);B();let Qe={response:E,request:g};for(let C of u.onResponse)if(C){let T=await C(L(N({},Qe),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?E.clone():E}));T instanceof Response?E=T:T instanceof Object&&(E=T.response)}if(E.ok){if(!(g.method!=="HEAD"))return{data:"",error:null};let T=Dr(E),M={data:"",response:E,request:g};if(T==="json"||T==="text"){let j=await E.text(),gr=await((o=g.jsonParser)!=null?o:st)(j);M.data=gr}else M.data=await E[T]();g?.output&&g.output&&!g.disableValidation&&(M.data=await ae(g.output,M.data));for(let j of u.onSuccess)j&&await j(L(N({},M),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?E.clone():E}));return e?.throw?M.data:{data:M.data,error:null}}let pr=(l=e?.jsonParser)!=null?l:st,oe=await E.text(),Xe=$r(oe),Ee=Xe?await pr(oe):null,mr={response:E,responseText:oe,request:g,error:L(N({},Ee),{status:E.status,statusText:E.statusText})};for(let C of u.onError)C&&await C(L(N({},mr),{response:(d=e?.hookOptions)!=null&&d.cloneResponse?E.clone():E}));if(e?.retry){let C=Nr(e.retry),T=(c=e.retryAttempt)!=null?c:0;if(await C.shouldAttemptRetry(T,E)){for(let j of u.onRetry)j&&await j(Qe);let M=C.getDelay(T);return await new Promise(j=>setTimeout(j,M)),await _e(r,L(N({},e),{retryAttempt:T+1}))}}if(e?.throw)throw new xr(E.status,E.statusText,Xe?Ee:oe);return{data:null,error:L(N({},Ee),{status:E.status,statusText:E.statusText})}};a();a();var le=Object.create(null),Y=r=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(r?le:globalThis),I=new Proxy(le,{get(r,e){return Y()[e]??le[e]},has(r,e){let t=Y();return e in t||e in le},set(r,e,t){let n=Y(!0);return n[e]=t,!0},deleteProperty(r,e){if(!e)return!1;let t=Y(!0);return delete t[e],!0},ownKeys(){let r=Y(!0);return Object.keys(r)}});var ss=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(r,e){return typeof process<"u"&&process.env?process.env[r]??e:typeof Deno<"u"?Deno.env.get(r)??e:typeof Bun<"u"?Bun.env[r]??e:e}var os=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),Q=1,O=4,D=8,x=24,ut={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:x,putty:O,st:O,"rxvt-unicode-24bit":x,terminator:x,"xterm-kitty":x},Vr=new Map(Object.entries({APPVEYOR:D,BUILDKITE:D,CIRCLECI:x,DRONE:D,GITEA_ACTIONS:x,GITHUB_ACTIONS:x,GITLAB_CI:D,TRAVIS:D})),Wr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Kr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return D;case"3":return x;default:return Q}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return Q;if(b("TMUX"))return x;if("TF_BUILD"in I&&"AGENT_NAME"in I)return O;if("CI"in I){for(let{0:r,1:e}of Vr)if(r in I)return e;return b("CI_NAME")==="codeship"?D:Q}if("TEAMCITY_VERSION"in I)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?O:Q;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?D:x;case"HyperTerm":case"MacTerm":return x;case"Apple_Terminal":return D}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return x;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return x;if(/^xterm-256/.exec(b("TERM"))!==null)return D;let r=b("TERM").toLowerCase();if(ut[r])return ut[r];if(Wr.some(e=>e.exec(r)!==null))return O}return b("COLORTERM")?O:Q}var $={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},Re=["info","success","warn","error","debug"];function Jr(r,e){return Re.indexOf(e)<=Re.indexOf(r)}var Yr={info:$.fg.blue,success:$.fg.green,warn:$.fg.yellow,error:$.fg.red,debug:$.fg.magenta},Qr=(r,e,t)=>{let n=new Date().toISOString();return t?`${$.dim}${n}${$.reset} ${Yr[r]}${r.toUpperCase()}${$.reset} ${$.bright}[Better Auth]:${$.reset} ${e}`:`${n} ${r.toUpperCase()} [Better Auth]: ${e}`},Xr=r=>{let e=r?.disabled!==!0,t=r?.level??"error",s=r?.disableColors!==void 0?!r.disableColors:Kr()!==1,o=(l,d,c=[])=>{if(!e||!Jr(t,l))return;let u=Qr(l,d,s);if(!r||typeof r.log!="function"){l==="error"?console.error(u,...c):l==="warn"?console.warn(u,...c):console.log(u,...c);return}r.log(l==="success"?"info":l,d,...c)};return{...Object.fromEntries(Re.map(l=>[l,(...[d,...c])=>o(l,d,c)])),get level(){return t}}},is=Xr();a();a();var hs={USER_NOT_FOUND:"User not found",FAILED_TO_CREATE_USER:"Failed to create user",FAILED_TO_CREATE_SESSION:"Failed to create session",FAILED_TO_UPDATE_USER:"Failed to update user",FAILED_TO_GET_SESSION:"Failed to get session",INVALID_PASSWORD:"Invalid password",INVALID_EMAIL:"Invalid email",INVALID_EMAIL_OR_PASSWORD:"Invalid email or password",SOCIAL_ACCOUNT_ALREADY_LINKED:"Social account already linked",PROVIDER_NOT_FOUND:"Provider not found",INVALID_TOKEN:"Invalid token",ID_TOKEN_NOT_SUPPORTED:"id_token not supported",FAILED_TO_GET_USER_INFO:"Failed to get user info",USER_EMAIL_NOT_FOUND:"User email not found",EMAIL_NOT_VERIFIED:"Email not verified",PASSWORD_TOO_SHORT:"Password too short",PASSWORD_TOO_LONG:"Password too long",USER_ALREADY_EXISTS:"User already exists.",USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:"User already exists. Use another email.",EMAIL_CAN_NOT_BE_UPDATED:"Email can not be updated",CREDENTIAL_ACCOUNT_NOT_FOUND:"Credential account not found",SESSION_EXPIRED:"Session expired. Re-authenticate to perform this action.",FAILED_TO_UNLINK_LAST_ACCOUNT:"You can't unlink your last account",ACCOUNT_NOT_FOUND:"Account not found",USER_ALREADY_HAS_PASSWORD:"User already has a password. Provide that to delete the account."},q=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Zr(r){try{return(new URL(r).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new q(`Invalid base URL: ${r}. Please provide a valid base URL.`)}}function X(r,e="/api/auth"){if(Zr(r))return r;let n=r.replace(/\/+$/,"");return!e||e==="/"?n:(e=e.startsWith("/")?e:`/${e}`,`${n}${e}`)}function dt(r,e,t,n){if(r)return X(r,e);if(n!==!1){let i=I.BETTER_AUTH_URL||I.NEXT_PUBLIC_BETTER_AUTH_URL||I.PUBLIC_BETTER_AUTH_URL||I.NUXT_PUBLIC_BETTER_AUTH_URL||I.NUXT_PUBLIC_AUTH_URL||(I.BASE_URL!=="/"?I.BASE_URL:void 0);if(i)return X(i,e)}let s=t?.headers.get("x-forwarded-host"),o=t?.headers.get("x-forwarded-proto");if(s&&o)return X(`${o}://${s}`,e);if(t){let i=en(t.url);if(!i)throw new q("Could not get origin from request. Please provide a valid base URL.");return X(i,e)}if(typeof window<"u"&&window.location)return X(window.location.origin,e)}function en(r){try{return new URL(r).origin}catch{return null}}a();a();a();var Z=Symbol("clean");var U=[],H=0,ce=4,tn=0,ee=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let o=H+ce;o<U.length;)U[o]===n?U.splice(o,ce):o+=ce;let s=e.indexOf(n);~s&&(e.splice(s,1),--t.lc||t.off())}},notify(n,s){tn++;let o=!U.length;for(let i of e)U.push(i,t.value,n,s);if(o){for(H=0;H<U.length;H+=ce)U[H](U[H+1],U[H+2],U[H+3]);U.length=0}},off(){},set(n){let s=t.value;s!==n&&(t.value=n,t.notify(s))},subscribe(n){let s=t.listen(n);return n(t.value),s},value:r};return process.env.NODE_ENV!=="production"&&(t[Z]=()=>{e=[],t.lc=0,t.off()}),t};a();var rn=5,W=6,ue=10,nn=(r,e,t,n)=>(r.events=r.events||{},r.events[t+ue]||(r.events[t+ue]=n(s=>{r.events[t].reduceRight((o,i)=>(i(o),o),{shared:{},...s})})),r.events[t]=r.events[t]||[],r.events[t].push(e),()=>{let s=r.events[t],o=s.indexOf(e);s.splice(o,1),s.length||(delete r.events[t],r.events[t+ue](),delete r.events[t+ue])});var ft=1e3,Oe=(r,e)=>nn(r,n=>{let s=e(n);s&&r.events[W].push(s)},rn,n=>{let s=r.listen;r.listen=(...i)=>(!r.lc&&!r.active&&(r.active=!0,n()),s(...i));let o=r.off;if(r.events[W]=[],r.off=()=>{o(),setTimeout(()=>{if(r.active&&!r.lc){r.active=!1;for(let i of r.events[W])i();r.events[W]=[]}},ft)},process.env.NODE_ENV!=="production"){let i=r[Z];r[Z]=()=>{for(let l of r.events[W])l();r.events[W]=[],r.active=!1,i()}}return()=>{r.listen=s,r.off=o}});a();var sn=typeof window>"u",de=(r,e,t,n)=>{let s=ee({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let d=typeof n=="function"?n({data:s.get().data,error:s.get().error,isPending:s.get().isPending}):n;t(e,{...d,query:{...d?.query,...l?.query},async onSuccess(c){s.set({data:c.data,error:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onSuccess?.(c)},async onError(c){let{request:u}=c,f=typeof u.retry=="number"?u.retry:u.retry?.attempts,m=u.retryAttempt||0;f&&m<f||(s.set({error:c.error,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch}),await d?.onError?.(c))},async onRequest(c){let u=s.get();s.set({isPending:u.data===null,data:u.data,error:null,isRefetching:!0,refetch:s.value.refetch}),await d?.onRequest?.(c)}}).catch(c=>{s.set({error:c,data:null,isPending:!1,isRefetching:!1,refetch:s.value.refetch})})};r=Array.isArray(r)?r:[r];let i=!1;for(let l of r)l.subscribe(()=>{sn||(i?o():Oe(s,()=>{let d=setTimeout(()=>{i||(o(),i=!0)},0);return()=>{s.off(),l.off(),clearTimeout(d)}}))});return s};a();var on={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},an=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,ht={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},ln=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function cn(r){return r instanceof Date&&!isNaN(r.getTime())}function un(r){let e=ln.exec(r);if(!e)return null;let[,t,n,s,o,i,l,d,c,u,f]=e,m=new Date(Date.UTC(parseInt(t,10),parseInt(n,10)-1,parseInt(s,10),parseInt(o,10),parseInt(i,10),parseInt(l,10),d?parseInt(d.padEnd(3,"0"),10):0));if(c){let y=(parseInt(u,10)*60+parseInt(f,10))*(c==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+y)}return cn(m)?m:null}function dn(r,e={}){let{strict:t=!1,warnings:n=!1,reviver:s,parseDates:o=!0}=e;if(typeof r!="string")return r;let i=r.trim();if(i.length>0&&i[0]==='"'&&i.endsWith('"')&&!i.slice(1,-1).includes('"'))return i.slice(1,-1);let l=i.toLowerCase();if(l.length<=9&&l in ht)return ht[l];if(!an.test(i)){if(t)throw new SyntaxError("[better-json] Invalid JSON");return r}if(Object.entries(on).some(([c,u])=>{let f=u.test(i);return f&&n&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${c} pattern`),f})&&t)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(i,(u,f)=>{if(u==="__proto__"||u==="constructor"&&f&&typeof f=="object"&&"prototype"in f){n&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof f=="string"){let m=un(f);if(m)return m}return s?s(u,f):f})}catch(c){if(t)throw c;return r}}function pt(r,e={strict:!0}){return dn(r,e)}var fn={id:"redirect",name:"Redirect",hooks:{onSuccess(r){if(r.data?.url&&r.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=r.data.url}catch{}}}};function hn(r){let e=ee(!1);return{session:de(e,"/get-session",r,{method:"GET"}),$sessionSignal:e}}var mt=(r,e)=>{let t="credentials"in Request.prototype,n=dt(r?.baseURL,r?.basePath,void 0,e)??"/api/auth",s=r?.plugins?.flatMap(g=>g.fetchPlugins).filter(g=>g!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:r?.fetchOptions?.onSuccess,onError:r?.fetchOptions?.onError,onRequest:r?.fetchOptions?.onRequest,onResponse:r?.fetchOptions?.onResponse}},{onSuccess:i,onError:l,onRequest:d,onResponse:c,...u}=r?.fetchOptions||{},f=ct({baseURL:n,...t?{credentials:"include"}:{},method:"GET",jsonParser(g){return g?pt(g,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[o,...u.plugins||[],...r?.disableDefaultFetchPlugins?[]:[fn],...s]}),{$sessionSignal:m,session:y}=hn(f),v=r?.plugins||[],_={},w={$sessionSignal:m,session:y},R={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},A=[{signal:"$sessionSignal",matcher(g){return g==="/sign-out"||g==="/update-user"||g.startsWith("/sign-in")||g.startsWith("/sign-up")||g==="/delete-user"||g==="/verify-email"}}];for(let g of v)g.getAtoms&&Object.assign(w,g.getAtoms?.(f)),g.pathMethods&&Object.assign(R,g.pathMethods),g.atomListeners&&A.push(...g.atomListeners);let k={notify:g=>{w[g].set(!w[g].get())},listen:(g,B)=>{w[g].subscribe(B)},atoms:w};for(let g of v)g.getActions&&Object.assign(_,g.getActions?.(f,k,r));return{get baseURL(){return n},pluginsActions:_,pluginsAtoms:w,pluginPathMethods:R,atomListeners:A,$fetch:f,$store:k}};function pn(r){return typeof r=="object"&&r!==null&&"get"in r&&typeof r.get=="function"&&"lc"in r&&typeof r.lc=="number"}function mn(r,e,t){let n=e[r],{fetchOptions:s,query:o,...i}=t||{};return n||(s?.method?s.method:i&&Object.keys(i).length>0?"POST":"GET")}function gt(r,e,t,n,s){function o(i=[]){return new Proxy(function(){},{get(l,d){if(typeof d!="string"||d==="then"||d==="catch"||d==="finally")return;let c=[...i,d],u=r;for(let f of c)if(u&&typeof u=="object"&&f in u)u=u[f];else{u=void 0;break}return typeof u=="function"||pn(u)?u:o(c)},apply:async(l,d,c)=>{let u="/"+i.map(A=>A.replace(/[A-Z]/g,k=>`-${k.toLowerCase()}`)).join("/"),f=c[0]||{},m=c[1]||{},{query:y,fetchOptions:v,..._}=f,w={...m,...v},R=mn(u,t,f);return await e(u,{...w,body:R==="GET"?void 0:{..._,...w?.body||{}},query:y||w?.query,method:R,async onSuccess(A){if(await w?.onSuccess?.(A),!s)return;let k=s.filter(g=>g.matcher(u));if(k.length)for(let g of k){let B=n[g.signal];if(!B)return;let E=B.get();setTimeout(()=>{B.set(!E)},10)}}})}})}return o()}a();function yt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Te(r){let{pluginPathMethods:e,pluginsActions:t,pluginsAtoms:n,$fetch:s,atomListeners:o,$store:i}=mt(r),l={};for(let[u,f]of Object.entries(n))l[`use${yt(u)}`]=f;let d={...t,...l,$fetch:s,$store:i};return gt(d,s,e,n,o)}a();a();a();function gn(r){return{authorize(e,t="AND"){let n=!1;for(let[s,o]of Object.entries(e)){let i=r[s];if(!i)return{success:!1,error:`You are not allowed to access resource: ${s}`};if(Array.isArray(o))n=o.every(l=>i.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?n=l.actions.some(d=>i.includes(d)):n=l.actions.every(d=>i.includes(d))}else throw new q("Invalid access control request");if(n&&t==="OR")return{success:n};if(!n&&t==="AND")return{success:!1,error:`unauthorized to access resource "${s}"`}}return n?{success:n}:{success:!1,error:"Not authorized"}},statements:r}}function fe(r){return{newRole(e){return gn(e)},statements:r}}var yn={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Pe=fe(yn),wn=Pe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),vn=Pe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),bn=Pe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});a();a();a();a();a();a();a();a();a();a();a();var Se=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},bt=new Se;a();a();a();a();a();a();a();a();var Tn={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Et=fe(Tn),Pn=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Sn=Et.newRole({user:[],session:[]});a();a();var _t=()=>({id:"username",$InferServerPlugin:{}});var Rt=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(r){return r==="/phone-number/update"||r==="/phone-number/verify"},signal:"$sessionSignal"}]});var Ot=()=>({id:"better-auth-client",$InferServerPlugin:{}});var An="/auth",xe="nvwa_login_token",te="nvwa_current_jwt",Ie="nvwa_user_profile",Tt=class{constructor(e,t,n){this.storage=n;let s=Te({baseURL:e,basePath:An,plugins:[_t(),Rt(),Ot()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let o=await this.storage.get(te);if(console.log("jwt",o),o)return o;let i=await this.storage.get(xe);return console.log("loginToken",i),i}}}});this.authClient=s}async currentUser(){return await this.storage.get(Ie)}async getCurrentJwt(){return await this.storage.get(te)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let n=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(n)}async signInWithPhoneNumber(e,t,n=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:n});this.handleLogin(s)}async signInWithUsername(e,t){let n=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(n)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(xe,e.data?.token),await this.storage.set(Ie,e.data?.user);let{data:t,error:n}=await this.authClient.token();if(n)throw new Error(n.message);await this.storage.set(te,t.token)}async signOut(){await this.storage.remove(xe),await this.storage.remove(Ie)}async updateUserPassword(e,t,n=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:n});this.handleLogin(s)}};a();var Pt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};a();a();a();var S=class r{constructor(e){this.headerMap=new Map;if(e){if(e instanceof r)e.forEach((t,n)=>this.set(n,t));else if(Array.isArray(e))for(let[t,n]of e)this.set(t,String(n));else if(typeof e=="object")for(let t of Object.keys(e))this.set(t,String(e[t]))}}append(e,t){let n=e.toLowerCase(),s=this.headerMap.get(n);this.headerMap.set(n,s?`${s}, ${t}`:t)}set(e,t){this.headerMap.set(e.toLowerCase(),String(t))}get(e){let t=this.headerMap.get(e.toLowerCase());return t??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[t,n]of this.headerMap.entries())e(n,t,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},re=class r{constructor(e){this.params=new Map;if(e){if(typeof e=="string")this.parseString(e);else if(e instanceof r)this.params=new Map(e.params);else if(Array.isArray(e))for(let[t,n]of e)this.append(t,n);else if(e&&typeof e=="object")for(let[t,n]of Object.entries(e))this.set(t,n)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let t=e.split("&");for(let n of t)if(n){let[s,o]=n.split("=");s&&this.append(decodeURIComponent(s),o?decodeURIComponent(o):"")}}append(e,t){let n=this.params.get(e)||[];n.push(t),this.params.set(e,n)}delete(e){this.params.delete(e)}get(e){let t=this.params.get(e);return t?t[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,t){this.params.set(e,[t])}sort(){let e=Array.from(this.params.entries()).sort(([t],[n])=>t.localeCompare(n));this.params=new Map(e)}toString(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);return e.join("&")}forEach(e){for(let[t,n]of this.params.entries())for(let s of n)e(s,t,this)}keys(){return this.params.keys()}values(){let e=[];for(let t of this.params.values())e.push(...t);return e[Symbol.iterator]()}entries(){let e=[];for(let[t,n]of this.params.entries())for(let s of n)e.push([t,s]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},he=class r{constructor(e,t){let n;if(e instanceof r)n=e.href;else if(t){let o=t instanceof r?t.href:t;n=this.resolve(o,e)}else n=e;let s=this.parseUrl(n);this.href=n,this.origin=`${s.protocol}//${s.host}`,this.protocol=s.protocol,this.username=s.username,this.password=s.password,this.host=s.host,this.hostname=s.hostname,this.port=s.port,this.pathname=s.pathname,this.search=s.search,this.searchParams=new re(s.search),this.hash=s.hash}resolve(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("//"))return`${this.parseUrl(e).protocol}${t}`;if(t.startsWith("/")){let o=this.parseUrl(e);return`${o.protocol}//${o.host}${t}`}let n=this.parseUrl(e),s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return`${n.protocol}//${n.host}${s}${t}`}parseUrl(e){let t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)throw new TypeError("Invalid URL");let n=t[2]||"",s=t[4]||"",o=t[5]||"/",i=t[7]?`?${t[7]}`:"",l=t[9]?`#${t[9]}`:"";if(!n&&!s&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let d=s.match(/^([^@]*)@(.+)$/),c="",u="",f=s;if(d){let _=d[1];f=d[2];let w=_.match(/^([^:]*):?(.*)$/);w&&(c=w[1]||"",u=w[2]||"")}let m=f.match(/^([^:]+):?(\d*)$/),y=m?m[1]:f,v=m&&m[2]?m[2]:"";return{protocol:n?`${n}:`:"",username:c,password:u,host:f,hostname:y,port:v,pathname:o,search:i,hash:l}}toString(){let e=this.searchParams.toString(),t=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${t}${this.hash}`}toJSON(){return this.toString()}};a();var pe=class r{constructor(e,t){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(t?.method||"GET").toUpperCase(),this.headers=t?.headers instanceof S?t.headers:new S(t?.headers),this.body=t?.body,this.timeout=t?.timeout,this.signal=t?.signal||void 0}clone(){return new r(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};a();var me=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=xn(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 xn(r){return r?new S(r):new S}a();var ne=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]"}},ge=class{constructor(){this._signal=new ne}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};a();function Ca(r){r.URL=he,r.URLSearchParams=re,r.Headers=S,r.Request=pe,r.Response=me,r.AbortController=ge,r.AbortSignal=ne}var St=class{constructor(e,t,n){console.log("NvwaHttpClient constructor",e,t,n),this.storage=e,this.customFetch=t,this.handleUnauthorized=n}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let n=await this.storage.get(te),s=new S(t?.headers);n&&s.set("Authorization",`Bearer ${n}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let l=s.get("Content-Type");(!l||l.includes("text/plain"))&&s.set("Content-Type","application/json")}let i=await this.customFetch(e,{...t,headers:s});if(i.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return i}};a();var In="/storage",Cn=In+"/generateUploadUrl",At=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Cn,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:n}=await t.json();if(!n)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(n,{method:"PUT",body:e,headers:new S({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};a();a();a();var Ye=Rr(ur(),1),{PostgrestClient:dr,PostgrestQueryBuilder:gl,PostgrestFilterBuilder:yl,PostgrestTransformBuilder:wl,PostgrestBuilder:vl,PostgrestError:bl}=Ye.default||Ye;var Gn="/entities",Ol=(r,e)=>new dr(r+Gn,{fetch:e.fetchWithAuth.bind(e)});a();var fr=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let n=`${this.baseUrl}/skill/${e}/execute`,o=await(await this.http.fetchWithAuth(n,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(o.status!==200)throw new Error(o.message);return o.data}};a();var hr=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 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){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};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=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@ var yr=Object.create;var ie=Object.defineProperty;var wr=Object.getOwnPropertyDe
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 n=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;n.width>0&&n.height>0?(e.style.left=`${n.left+s}px`,e.style.top=`${n.top+o}px`,e.style.width=`${n.width}px`,e.style.height=`${n.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 l=this.createTooltip();t?l.textContent=t:l.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,l.style.display="block";let d=e.getBoundingClientRect();l.style.left=`${d.left+window.scrollX}px`,l.style.top=`${d.top+window.scrollY-l.offsetHeight-8}px`,d.top<l.offsetHeight+8&&(l.style.top=`${d.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let n=this.createOverlay("hover");this.updateOverlayPosition(n,e),this.hoverOverlay=n,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let 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 n=this.createOverlay("selected");this.updateOverlayPosition(n,e),this.selectedOverlay=n,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function xl(r="root"){if(typeof document>"u")return null;let e=document.getElementById(r)||document.body;if(!e)return null;let t=e.querySelector("[data-source-location]");if(t){let n=t.getAttribute("data-source-location");if(n)return n}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}export{An as AUTH_BASE_PATH,ge as AbortController,ne as AbortSignal,te as CURRENT_JWT_KEY,Gn as ENTITIES_BASE_PATH,In as FILE_STORAGE_BASE_PATH,Cn as GENERATE_UPLOAD_URL_PATH,S as Headers,xe as LOGIN_TOKEN_KEY,Ie as LOGIN_USER_PROFILE_KEY,Tt as NvwaAuthClient,Pt as NvwaEdgeFunctions,At as NvwaFileStorage,St as NvwaHttpClient,fr as NvwaSkill,hr as OverlayManager,pe as Request,me as Response,he as URL,re as URLSearchParams,Ol as createPostgrestClient,xl as getSourceLocationFromDOM,Ca 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,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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-core",
3
- "version": "0.10.10",
3
+ "version": "1.0.0",
4
4
  "description": "NVWA跨端通用工具类核心接口",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,8 +29,7 @@
29
29
  "directory": "packages/sdk/core"
30
30
  },
31
31
  "dependencies": {
32
- "@nvwa-app/postgrest-js": "^2.77.0",
33
- "better-auth": "^1.3.34"
32
+ "@nvwa-app/postgrest-js": "^2.77.0"
34
33
  },
35
34
  "devDependencies": {
36
35
  "@types/node": "^24.3.0",
@@ -52,7 +51,6 @@
52
51
  "splitting": false,
53
52
  "shims": true,
54
53
  "noExternal": [
55
- "better-auth",
56
54
  "@nvwa-app/postgrest-js"
57
55
  ]
58
56
  },