@kivii.com/bridge 1.1.7 → 1.1.9

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/README.md CHANGED
@@ -6,9 +6,10 @@
6
6
 
7
7
  - 🚀 **轻量级**:核心库体积小,按需加载
8
8
  - 🔧 **依赖注入**:支持模块替换和扩展
9
+ - 🪝 **Hook 钩子**:灵活的事件钩子系统,支持请求拦截和响应处理
9
10
  - 📦 **多格式支持**:UMD、ESM、CommonJS
10
11
  - 🌐 **跨平台**:支持浏览器和 Node.js 环境
11
- - 📝 **TypeScript**:完整的类型定义
12
+ - � **Type\*Script**:完整的类型定义
12
13
  - 🛠️ **可扩展**:模块化设计,易于扩展
13
14
  - 🎭 **Mock 支持**:内置 Mock 请求模块,轻松切换到测试数据
14
15
  - 📥 **文件下载**:支持进度监控、自动下载、表单下载、错误处理
@@ -152,6 +153,33 @@ const response3 = await getChatTest(); // 或 getChatTest().then((res: any) => {
152
153
  console.log(response3);
153
154
  ```
154
155
 
156
+ ### 错误处理(Request 模块)
157
+
158
+ 当使用 `kivii.request.send(...)` 或 `kivii.request.get/post/...` 时,库在遇到服务器返回非 2xx 状态码时会通过 Promise reject 抛出错误。为了兼顾标准 `Error` 语义与实用性,抛出的 `Error` 实例会在自身上附带服务端响应的详细信息,调用方可以直接访问这些字段来获取服务端返回体和状态。
159
+
160
+ 当存在服务器响应时,Error 实例上通常会包含以下字段:
161
+
162
+ - `status`:HTTP 状态码(例如 `404`)
163
+ - `statusText`:状态文本(例如 `Not Found`)
164
+ - `data`:服务端返回的响应体(通常为 JSON)
165
+ - `headers`:响应头(已转换为普通对象)
166
+ - `config`:请求的部分配置信息(`url`、`method`、`timeout`)
167
+
168
+ 注意:浏览器 DevTools 在打印 `Error` 时默认只展示 `message` 与 `stack`,不会自动把这些附加字段展开显示。调试时可以用下面的方式查看完整信息:
169
+
170
+ ```javascript
171
+ kivii.request.send({...})
172
+ .then(res => console.log('Request response:', res))
173
+ .catch(err => {
174
+ // 以对象形式查看 Error,包含附加字段
175
+ console.dir(err);
176
+ // 或展开为普通对象以便控制台一目了然
177
+ console.log('as plain obj', { ...err });
178
+ console.log('status:', err.status);
179
+ console.log('data:', err.data);
180
+ });
181
+ ```
182
+
155
183
  **📖 详细文档:[Request 模块 API](./src/docs/request.md)**
156
184
 
157
185
  ### 日志记录
@@ -165,6 +193,50 @@ kivii.logger.error('错误信息', new Error('Something went wrong'));
165
193
 
166
194
  **📖 详细文档:[Logger 模块 API](./src/docs/logger.md)**
167
195
 
196
+ ### Hook 钩子系统
197
+
198
+ ```javascript
199
+ // 配置式注册钩子
200
+ kivii.config.init({
201
+ hooks: {
202
+ // 请求前:添加认证令牌
203
+ 'request.before': config => {
204
+ const token = localStorage.getItem('token');
205
+ if (token) {
206
+ config.headers = config.headers || {};
207
+ config.headers.Authorization = `Bearer ${token}`;
208
+ }
209
+ return config;
210
+ },
211
+
212
+ // 响应后:处理 404
213
+ 'request.response.status:404': response => {
214
+ response.data.message = '页面未找到';
215
+ return response;
216
+ },
217
+
218
+ // 错误处理
219
+ 'request.error': error => {
220
+ console.error('请求失败:', error.message);
221
+ return error;
222
+ },
223
+ },
224
+ });
225
+
226
+ // 编程式注册钩子
227
+ kivii.hook.register('request.before', config => {
228
+ console.log('发送请求:', config.method, config.url);
229
+ return config;
230
+ });
231
+
232
+ kivii.hook.register('request.response', response => {
233
+ console.log('响应已接收:', response.status);
234
+ return response;
235
+ });
236
+ ```
237
+
238
+ **📖 详细文档:[Hook 模块 API](./src/docs/hook.md)**
239
+
168
240
  ### Mock 请求
169
241
 
170
242
  ```javascript
@@ -240,7 +312,7 @@ kivii.downloader.form({
240
312
  },
241
313
  data: {
242
314
  Kvids: '14D96D8B-E187-4DD3-99D2-AECD38695DA7',
243
- FolderPath: '/Certificate/Check/Files'
315
+ FolderPath: '/Certificate/Check/Files',
244
316
  },
245
317
  });
246
318
  ```
@@ -292,10 +364,11 @@ pnpm test:watch
292
364
  ### 核心文档
293
365
 
294
366
  - [Request 模块文档](./src/docs/request.md) - HTTP 请求、拦截器、错误处理
367
+ - [Hook 模块文档](./src/docs/hook.md) - 钩子系统、请求拦截、响应处理
295
368
  - [Mock 模块文档](./src/docs/mock.md) - Mock 请求、测试数据、开发调试
296
369
  - [Logger 模块文档](./src/docs/logger.md) - 日志记录、自定义日志器
297
370
  - [Downloader 模块文档](./src/docs/downloader.md) - 文件下载、进度监控、自动下载
298
- - [配置管理文档](./src/docs/config.md) - 配置管理、环境配置、配置验证
371
+ - [Config 模块文档](./src/docs/config.md) - 配置管理、环境配置、配置验证
299
372
  - [测试文档](./tests/README.md) - 测试说明、覆盖率报告
300
373
 
301
374
  ### 快速链接
@@ -1 +1 @@
1
- {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/core/Config.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM;IAEjB,OAAO,CAAC,OAAO,CAA+B;IAE9C;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAMvC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAQlC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAQrB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQzB;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAoB5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAQ7B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAwBtB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAevB"}
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/core/Config.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IAEjB,OAAO,CAAC,OAAO,CAA+B;IAE9C;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAevC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAQlC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAQrB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQzB;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAoB5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAQ7B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAwBtB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAevB"}
@@ -1,5 +1,5 @@
1
1
  import { Config } from './Config';
2
- import { IRequest, ILogger, INavagator, IStorage, IDownloader } from '../interfaces';
2
+ import { IRequest, ILogger, INavagator, IStorage, IDownloader, IHook } from '../interfaces';
3
3
  /**
4
4
  * Kivii 核心类
5
5
  * 负责管理系统级模块,如配置、日志、请求等
@@ -91,6 +91,18 @@ export declare class Kivii {
91
91
  * @returns {IStorage} 存储实例
92
92
  */
93
93
  get storage(): IStorage;
94
+ /**
95
+ * Hook 系统实例
96
+ * 用于处理系统钩子
97
+ * 默认使用 Hook 实现
98
+ * @private
99
+ */
100
+ private _hook;
101
+ /**
102
+ * 获取 Hook 系统实例
103
+ * @returns {IHook} Hook 系统实例
104
+ */
105
+ get hook(): IHook;
94
106
  /**
95
107
  * 依赖注入方法
96
108
  * 用于动态替换系统模块的实现
@@ -1 +1 @@
1
- {"version":3,"file":"Kivii.d.ts","sourceRoot":"","sources":["../../src/core/Kivii.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAEpF;;;;GAIG;AACH,qBAAa,KAAK;IAChB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS,CAAQ;IAEhC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB,CAA+B;IAExD;;;;;OAKG;IACH,OAAO,KAAK,gBAAgB,GAY3B;IAED;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAwB;IAEvC;;;OAGG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;;;;OAKG;IACH,OAAO,CAAC,UAAU,CAAgC;IAElD;;;OAGG;IACH,IAAW,SAAS,IAAI,UAAU,CAEjC;IACD;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAA0B;IAEzC;;;OAGG;IACH,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAA4B;IAE5C;;;OAGG;IACH,IAAW,OAAO,IAAI,QAAQ,CAE7B;IAED;;;;;OAKG;IACH,OAAO,CAAC,WAAW,CAAkC;IAErD;;;OAGG;IACH,IAAW,UAAU,IAAI,WAAW,CAEnC;IAED,OAAO,CAAC,QAAQ,CAA4B;IAE5C;;;OAGG;IACH,IAAW,OAAO,IAAI,QAAQ,CAE7B;IAED;;;;OAIG;IACI,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAUpC;;;;OAIG;IACI,UAAU,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI1D;;;;OAIG;WACW,WAAW,IAAI,KAAK;CAMnC"}
1
+ {"version":3,"file":"Kivii.d.ts","sourceRoot":"","sources":["../../src/core/Kivii.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAE3F;;;;GAIG;AACH,qBAAa,KAAK;IAChB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS,CAAQ;IAEhC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB,CAA+B;IAExD;;;;;OAKG;IACH,OAAO,KAAK,gBAAgB,GAY3B;IAED;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAwB;IAEvC;;;OAGG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;;;;OAKG;IACH,OAAO,CAAC,UAAU,CAAgC;IAElD;;;OAGG;IACH,IAAW,SAAS,IAAI,UAAU,CAEjC;IACD;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAA0B;IAEzC;;;OAGG;IACH,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAA4B;IAE5C;;;OAGG;IACH,IAAW,OAAO,IAAI,QAAQ,CAE7B;IAED;;;;;OAKG;IACH,OAAO,CAAC,WAAW,CAAkC;IAErD;;;OAGG;IACH,IAAW,UAAU,IAAI,WAAW,CAEnC;IAED,OAAO,CAAC,QAAQ,CAA4B;IAE5C;;;OAGG;IACH,IAAW,OAAO,IAAI,QAAQ,CAE7B;IAED;;;;;OAKG;IACH,OAAO,CAAC,KAAK,CAAsB;IAEnC;;;OAGG;IACH,IAAW,IAAI,IAAI,KAAK,CAEvB;IAED;;;;OAIG;IACI,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAUpC;;;;OAIG;IACI,UAAU,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI1D;;;;OAIG;WACW,WAAW,IAAI,KAAK;CAMnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,QAAA,MAAM,KAAK,OAAsB,CAAC;AAUlC;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb;;;;;OAKG;IACH,MAAM,KAAK,EAAE,KAAK,CAAC;IAEnB,UAAU,MAAM;QACZ;;WAEG;QACH,KAAK,EAAE,OAAO,KAAK,CAAC;KACvB;CACF;AAGD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,QAAA,MAAM,KAAK,OAAsB,CAAC;AAWlC;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb;;;;;OAKG;IACH,MAAM,KAAK,EAAE,KAAK,CAAC;IAEnB,UAAU,MAAM;QACZ;;WAEG;QACH,KAAK,EAAE,OAAO,KAAK,CAAC;KACvB;CACF;AAGD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,eAAe,KAAK,CAAC"}
@@ -20,10 +20,10 @@ export interface IDialogOptions {
20
20
  mask?: boolean;
21
21
  /** 点击遮罩层是否关闭 */
22
22
  maskClosable?: boolean;
23
- /** 打开时的回调 */
24
- onOpen?: () => void;
25
- /** 关闭时的回调 */
26
- onClose?: () => void;
23
+ /** 创建时的回调 */
24
+ onCreate?: () => void;
25
+ /** 销毁时的回调 */
26
+ onDestroy?: () => void;
27
27
  }
28
28
  export declare class IDialog {
29
29
  readonly interfaceType: string;
@@ -1 +1 @@
1
- {"version":3,"file":"IDialog.d.ts","sourceRoot":"","sources":["../../src/interfaces/IDialog.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,WAAW,cAAc;IAC7B,SAAS;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,WAAW;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS;IACT,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,SAAS;IACT,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,eAAe;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gBAAgB;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa;IACb,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa;IACb,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,qBAAa,OAAO;IAClB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAa;IAE3C;;;;OAIG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhE;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI5F;;;OAGG;IACG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAEjD;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAE9D,aAAa;IACb,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAEjD,aAAa;IACb,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAE/C,aAAa;IACb,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAEjD,aAAa;IACb,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAE9C,aAAa;IACb,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAEnC,aAAa;IACb,WAAW,IAAI,IAAI;IAEnB,cAAc;IACd,QAAQ,IAAI,IAAI;CACjB"}
1
+ {"version":3,"file":"IDialog.d.ts","sourceRoot":"","sources":["../../src/interfaces/IDialog.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,WAAW,cAAc;IAC7B,SAAS;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,WAAW;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS;IACT,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,SAAS;IACT,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,eAAe;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gBAAgB;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,aAAa;IACb,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,qBAAa,OAAO;IAClB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAa;IAE3C;;;;OAIG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhE;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI5F;;;OAGG;IACG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAEjD;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAE9D,aAAa;IACb,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAEjD,aAAa;IACb,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAE/C,aAAa;IACb,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAEjD,aAAa;IACb,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAE9C,aAAa;IACb,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAEnC,aAAa;IACb,WAAW,IAAI,IAAI;IAEnB,cAAc;IACd,QAAQ,IAAI,IAAI;CACjB"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * 钩子处理函数类型
3
+ * @param context 上下文对象
4
+ * @returns 修改后的上下文对象或 Promise
5
+ */
6
+ export type HookHandler<T = any> = (context: T) => T | Promise<T>;
7
+ /**
8
+ * 钩子配置对象类型
9
+ */
10
+ export type HookConfig = Record<string, HookHandler | HookHandler[]>;
11
+ /**
12
+ * Hook 系统接口
13
+ */
14
+ export declare class IHook {
15
+ readonly interfaceType: string;
16
+ /**
17
+ * 批量初始化钩子
18
+ * @param hooks 钩子配置对象
19
+ */
20
+ init(hooks: HookConfig): void;
21
+ /**
22
+ * 注册钩子处理函数
23
+ * @param hookKey 钩子键
24
+ * @param handler 处理函数
25
+ */
26
+ register(hookKey: string, handler: HookHandler): void;
27
+ /**
28
+ * 注销钩子处理函数
29
+ * @param hookKey 钩子键
30
+ * @param handler 可选的处理函数,不传则注销该键的所有处理函数
31
+ */
32
+ unregister(hookKey: string, handler?: HookHandler): void;
33
+ /**
34
+ * 执行钩子
35
+ * @param hookKey 钩子键
36
+ * @param context 上下文对象
37
+ * @returns 处理后的上下文对象
38
+ */
39
+ execute<T = any>(hookKey: string, context: T): Promise<T>;
40
+ /**
41
+ * 检查钩子是否存在
42
+ * @param hookKey 钩子键
43
+ * @returns 是否存在
44
+ */
45
+ has(hookKey: string): boolean;
46
+ /**
47
+ * 清空所有钩子
48
+ */
49
+ clear(): void;
50
+ }
51
+ //# sourceMappingURL=IHook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IHook.d.ts","sourceRoot":"","sources":["../../src/interfaces/IHook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC,CAAC;AAErE;;GAEG;AACH,qBAAa,KAAK;IAChB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAW;IAEzC;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAI7B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAIrD;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;IAIxD;;;;;OAKG;IACG,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/D;;;;OAIG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI7B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -3,4 +3,6 @@ export * from './ILogger';
3
3
  export * from './INavagator';
4
4
  export * from './IStorage';
5
5
  export * from './IDownloader';
6
+ export * from './IHook';
7
+ export type { HookHandler, HookConfig } from './IHook';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Kivii={})}(this,function(e){"use strict";class t{constructor(){this.configs=new Map}init(e){for(const[t,n]of Object.entries(e))this.set(t,n)}set(e,t){e.includes(".")?this.setNestedValue(e,t):this.configs.set(e,t)}get(e){return e.includes(".")?this.getNestedValue(e):this.configs.get(e)}has(e){return e.includes(".")?void 0!==this.getNestedValue(e):this.configs.has(e)}delete(e){if(e.includes(".")){const t=e.split("."),n=t[0],r=t.slice(1).join(".");if(this.configs.has(n)){const e=this.configs.get(n);if("object"==typeof e&&null!==e)return delete e[r],!0}return!1}return this.configs.delete(e)}clear(){this.configs.clear()}getAll(){const e={};for(const[t,n]of this.configs)e[t]=n;return e}setNestedValue(e,t){const n=e.split("."),r=n[0];let o=this.configs.get(r);o&&"object"==typeof o||(o={},this.configs.set(r,o));let s=o;for(let e=1;e<n.length-1;e++)s[n[e]]&&"object"==typeof s[n[e]]||(s[n[e]]={}),s=s[n[e]];s[n[n.length-1]]=t}getNestedValue(e){const t=e.split("."),n=t[0];let r=this.configs.get(n);for(let e=1;e<t.length;e++){if(!r||"object"!=typeof r||!(t[e]in r))return;r=r[t[e]]}return r}}class n{constructor(){this.interfaceType="IRequest"}async send(e){throw new Error("Method not implemented.")}async get(e,t){return this.send({url:e,method:"GET",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async post(e,t,n){return this.send({url:e,method:"POST",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}async put(e,t,n){return this.send({url:e,method:"PUT",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}async delete(e,t){return this.send({url:e,method:"DELETE",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async patch(e,t,n){return this.send({url:e,method:"PATCH",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}}class r{constructor(){this.interfaceType="ILogger"}debug(e,t){}error(e,t){}info(e,t){}warn(e,t){}}class o{constructor(){this.interfaceType="INavagator"}go(e,t){}push(e,t){}back(){}replace(e,t){}open(e,t){}}class s{constructor(){this.interfaceType="IStorage"}set(e,t){}get(e){return null}remove(e){}clear(){}keys(){return[]}has(e){return!1}}class i{constructor(){this.interfaceType="IDownloader"}async download(e){throw new Error("Method not implemented.")}form(e){throw new Error("Method not implemented.")}}class a{constructor(){this._privateVariables=new Map,this._config=new t,this._navigator=new o,this._logger=new r,this._request=new n,this._downloader=new i,this._storage=new s}get privateVariables(){if(0===this._privateVariables.size)for(const e of Object.keys(this))if(e.startsWith("_")){const t=this[e];"interfaceType"in t&&this._privateVariables.set(t.interfaceType,t)}return this._privateVariables}get config(){return this._config}get navigator(){return this.privateVariables.get(this._navigator.interfaceType)||this._navigator}get logger(){return this.privateVariables.get(this._logger.interfaceType)||this._logger}get request(){return this.privateVariables.get(this._request.interfaceType)||this._request}get downloader(){return this.privateVariables.get(this._downloader.interfaceType)||this._downloader}get storage(){return this.privateVariables.get(this._storage.interfaceType)||this._storage}register(e){if(!("interfaceType"in e))return void this.logger.warn("无法注入实例:实例必须包含 interfaceType 属性");const t=e.interfaceType;this._privateVariables.set(t,e),this.logger.info(`成功注入实例:${t}`)}tryResolve(e){return this.privateVariables.get(e)}static getInstance(){return a._instance||(a._instance=new a),a._instance}}function c(e,t){return function(){return e.apply(t,arguments)}}const{toString:l}=Object.prototype,{getPrototypeOf:u}=Object,{iterator:d,toStringTag:f}=Symbol,h=(p=Object.create(null),e=>{const t=l.call(e);return p[t]||(p[t]=t.slice(8,-1).toLowerCase())});var p;const m=e=>(e=e.toLowerCase(),t=>h(t)===e),g=e=>t=>typeof t===e,{isArray:y}=Array,b=g("undefined");function w(e){return null!==e&&!b(e)&&null!==e.constructor&&!b(e.constructor)&&O(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const E=m("ArrayBuffer");const v=g("string"),O=g("function"),S=g("number"),R=e=>null!==e&&"object"==typeof e,T=e=>{if("object"!==h(e))return!1;const t=u(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||f in e||d in e)},A=m("Date"),x=m("File"),j=m("Blob"),N=m("FileList"),C=m("URLSearchParams"),[_,P,U,L]=["ReadableStream","Request","Response","Headers"].map(m);function k(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),y(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(w(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}function D(e,t){if(w(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,B=e=>!b(e)&&e!==F;const I=(q="undefined"!=typeof Uint8Array&&u(Uint8Array),e=>q&&e instanceof q);var q;const M=m("HTMLFormElement"),V=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),z=m("RegExp"),J=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};k(n,(n,o)=>{let s;!1!==(s=t(n,o,e))&&(r[o]=s||n)}),Object.defineProperties(e,r)};const H=m("AsyncFunction"),W=($="function"==typeof setImmediate,K=O(F.postMessage),$?setImmediate:K?(G=`axios@${Math.random()}`,X=[],F.addEventListener("message",({source:e,data:t})=>{e===F&&t===G&&X.length&&X.shift()()},!1),e=>{X.push(e),F.postMessage(G,"*")}):e=>setTimeout(e));var $,K,G,X;const Q="undefined"!=typeof queueMicrotask?queueMicrotask.bind(F):"undefined"!=typeof process&&process.nextTick||W;var Z={isArray:y,isArrayBuffer:E,isBuffer:w,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||O(e.append)&&("formdata"===(t=h(e))||"object"===t&&O(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&E(e.buffer),t},isString:v,isNumber:S,isBoolean:e=>!0===e||!1===e,isObject:R,isPlainObject:T,isEmptyObject:e=>{if(!R(e)||w(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:_,isRequest:P,isResponse:U,isHeaders:L,isUndefined:b,isDate:A,isFile:x,isBlob:j,isRegExp:z,isFunction:O,isStream:e=>R(e)&&O(e.pipe),isURLSearchParams:C,isTypedArray:I,isFileList:N,forEach:k,merge:function e(){const{caseless:t,skipUndefined:n}=B(this)&&this||{},r={},o=(o,s)=>{const i=t&&D(r,s)||s;T(r[i])&&T(o)?r[i]=e(r[i],o):T(o)?r[i]=e({},o):y(o)?r[i]=o.slice():n&&b(o)||(r[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&k(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(k(t,(t,r)=>{n&&O(t)?e[r]=c(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],r&&!r(i,e,t)||a[i]||(t[i]=e[i],a[i]=!0);e=!1!==n&&u(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:h,kindOfTest:m,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(y(e))return e;let t=e.length;if(!S(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[d]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:M,hasOwnProperty:V,hasOwnProp:V,reduceDescriptors:J,freezeMethods:e=>{J(e,(t,n)=>{if(O(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];O(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return y(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:D,global:F,isContextDefined:B,isSpecCompliantForm:function(e){return!!(e&&O(e.append)&&"FormData"===e[f]&&e[d])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(R(e)){if(t.indexOf(e)>=0)return;if(w(e))return e;if(!("toJSON"in e)){t[r]=e;const o=y(e)?[]:{};return k(e,(e,t)=>{const s=n(e,r+1);!b(s)&&(o[t]=s)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:H,isThenable:e=>e&&(R(e)||O(e))&&O(e.then)&&O(e.catch),setImmediate:W,asap:Q,isIterable:e=>null!=e&&O(e[d])};function Y(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}Z.inherits(Y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Z.toJSONObject(this.config),code:this.code,status:this.status}}});const ee=Y.prototype,te={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{te[e]={value:e}}),Object.defineProperties(Y,te),Object.defineProperty(ee,"isAxiosError",{value:!0}),Y.from=(e,t,n,r,o,s)=>{const i=Object.create(ee);Z.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return Y.call(i,a,c,n,r,o),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};function ne(e){return Z.isPlainObject(e)||Z.isArray(e)}function re(e){return Z.endsWith(e,"[]")?e.slice(0,-2):e}function oe(e,t,n){return e?e.concat(t).map(function(e,t){return e=re(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const se=Z.toFlatObject(Z,{},null,function(e){return/^is[A-Z]/.test(e)});function ie(e,t,n){if(!Z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Z.isUndefined(t[e])})).metaTokens,o=n.visitor||l,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Z.isSpecCompliantForm(t);if(!Z.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Z.isDate(e))return e.toISOString();if(Z.isBoolean(e))return e.toString();if(!a&&Z.isBlob(e))throw new Y("Blob is not supported. Use a Buffer instead.");return Z.isArrayBuffer(e)||Z.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(Z.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Z.isArray(e)&&function(e){return Z.isArray(e)&&!e.some(ne)}(e)||(Z.isFileList(e)||Z.endsWith(n,"[]"))&&(a=Z.toArray(e)))return n=re(n),a.forEach(function(e,r){!Z.isUndefined(e)&&null!==e&&t.append(!0===i?oe([n],r,s):null===i?n:n+"[]",c(e))}),!1;return!!ne(e)||(t.append(oe(o,n,s),c(e)),!1)}const u=[],d=Object.assign(se,{defaultVisitor:l,convertValue:c,isVisitable:ne});if(!Z.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Z.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),Z.forEach(n,function(n,s){!0===(!(Z.isUndefined(n)||null===n)&&o.call(t,n,Z.isString(s)?s.trim():s,r,d))&&e(n,r?r.concat(s):[s])}),u.pop()}}(e),t}function ae(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ce(e,t){this._pairs=[],e&&ie(e,this,t)}const le=ce.prototype;function ue(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function de(e,t,n){if(!t)return e;const r=n&&n.encode||ue;Z.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(s=o?o(t,n):Z.isURLSearchParams(t)?t.toString():new ce(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}le.append=function(e,t){this._pairs.push([e,t])},le.toString=function(e){const t=e?function(t){return e.call(this,t,ae)}:ae;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class fe{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Z.forEach(this.handlers,function(t){null!==t&&e(t)})}}var he={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},pe={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ce,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const me="undefined"!=typeof window&&"undefined"!=typeof document,ge="object"==typeof navigator&&navigator||void 0,ye=me&&(!ge||["ReactNative","NativeScript","NS"].indexOf(ge.product)<0),be="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,we=me&&window.location.href||"http://localhost";var Ee={...Object.freeze({__proto__:null,hasBrowserEnv:me,hasStandardBrowserEnv:ye,hasStandardBrowserWebWorkerEnv:be,navigator:ge,origin:we}),...pe};function ve(e){function t(e,n,r,o){let s=e[o++];if("__proto__"===s)return!0;const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&Z.isArray(r)?r.length:s,a)return Z.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i;r[s]&&Z.isObject(r[s])||(r[s]=[]);return t(e,n,r[s],o)&&Z.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i}if(Z.isFormData(e)&&Z.isFunction(e.entries)){const n={};return Z.forEachEntry(e,(e,r)=>{t(function(e){return Z.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const Oe={transitional:he,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Z.isObject(e);o&&Z.isHTMLForm(e)&&(e=new FormData(e));if(Z.isFormData(e))return r?JSON.stringify(ve(e)):e;if(Z.isArrayBuffer(e)||Z.isBuffer(e)||Z.isStream(e)||Z.isFile(e)||Z.isBlob(e)||Z.isReadableStream(e))return e;if(Z.isArrayBufferView(e))return e.buffer;if(Z.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ie(e,new Ee.classes.URLSearchParams,{visitor:function(e,t,n,r){return Ee.isNode&&Z.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((s=Z.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return ie(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(Z.isString(e))try{return(t||JSON.parse)(e),Z.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Oe.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Z.isResponse(e)||Z.isReadableStream(e))return e;if(e&&Z.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw Y.from(e,Y.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ee.classes.FormData,Blob:Ee.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Z.forEach(["delete","get","head","post","put","patch"],e=>{Oe.headers[e]={}});const Se=Z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Re=Symbol("internals");function Te(e){return e&&String(e).trim().toLowerCase()}function Ae(e){return!1===e||null==e?e:Z.isArray(e)?e.map(Ae):String(e)}function xe(e,t,n,r,o){return Z.isFunction(r)?r.call(this,t,n):(o&&(t=n),Z.isString(t)?Z.isString(r)?-1!==t.indexOf(r):Z.isRegExp(r)?r.test(t):void 0:void 0)}let je=class{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Te(t);if(!o)throw new Error("header name must be a non-empty string");const s=Z.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Ae(e))}const s=(e,t)=>Z.forEach(e,(e,n)=>o(e,n,t));if(Z.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(Z.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Se[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Z.isObject(e)&&Z.isIterable(e)){let n,r,o={};for(const t of e){if(!Z.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?Z.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}s(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Te(e)){const n=Z.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Z.isFunction(t))return t.call(this,e,n);if(Z.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Te(e)){const n=Z.findKey(this,e);return!(!n||void 0===this[n]||t&&!xe(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Te(e)){const o=Z.findKey(n,e);!o||t&&!xe(0,n[o],o,t)||(delete n[o],r=!0)}}return Z.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!xe(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Z.forEach(this,(r,o)=>{const s=Z.findKey(n,o);if(s)return t[s]=Ae(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();i!==o&&delete t[o],t[i]=Ae(r),n[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Z.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Z.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[Re]=this[Re]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Te(e);t[r]||(!function(e,t){const n=Z.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return Z.isArray(e)?e.forEach(r):r(e),this}};function Ne(e,t){const n=this||Oe,r=t||n,o=je.from(r.headers);let s=r.data;return Z.forEach(e,function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ce(e){return!(!e||!e.__CANCEL__)}function _e(e,t,n){Y.call(this,null==e?"canceled":e,Y.ERR_CANCELED,t,n),this.name="CanceledError"}function Pe(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Y("Request failed with status code "+n.status,[Y.ERR_BAD_REQUEST,Y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}je.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Z.reduceDescriptors(je.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Z.freezeMethods(je),Z.inherits(_e,Y,{__CANCEL__:!0});const Ue=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=r[i];o||(o=c),n[s]=a,r[s]=c;let u=i,d=0;for(;u!==s;)d+=n[u++],u%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const f=l&&c-l;return f?Math.round(1e3*d/f):void 0}}(50,250);return function(e,t){let n,r,o=0,s=1e3/t;const i=(t,s=Date.now())=>{o=s,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=s?i(e,t):(n=e,r||(r=setTimeout(()=>{r=null,i(n)},s-a)))},()=>n&&i(n)]}(n=>{const s=n.loaded,i=n.lengthComputable?n.total:void 0,a=s-r,c=o(a);r=s;e({loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:n,lengthComputable:null!=i,[t?"download":"upload"]:!0})},n)},Le=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ke=e=>(...t)=>Z.asap(()=>e(...t));var De=Ee.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ee.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ee.origin),Ee.navigator&&/(msie|trident)/i.test(Ee.navigator.userAgent)):()=>!0,Fe=Ee.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];Z.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),Z.isString(r)&&i.push("path="+r),Z.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Be(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Ie=e=>e instanceof je?{...e}:e;function qe(e,t){t=t||{};const n={};function r(e,t,n,r){return Z.isPlainObject(e)&&Z.isPlainObject(t)?Z.merge.call({caseless:r},e,t):Z.isPlainObject(t)?Z.merge({},t):Z.isArray(t)?t.slice():t}function o(e,t,n,o){return Z.isUndefined(t)?Z.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function s(e,t){if(!Z.isUndefined(t))return r(void 0,t)}function i(e,t){return Z.isUndefined(t)?Z.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return s in t?r(n,o):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t,n)=>o(Ie(e),Ie(t),0,!0)};return Z.forEach(Object.keys({...e,...t}),function(r){const s=c[r]||o,i=s(e[r],t[r],r);Z.isUndefined(i)&&s!==a||(n[r]=i)}),n}var Me=e=>{const t=qe({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=je.from(i),t.url=de(Be(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Z.isFormData(n))if(Ee.hasStandardBrowserEnv||Ee.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Z.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&i.set(e,n)})}if(Ee.hasStandardBrowserEnv&&(r&&Z.isFunction(r)&&(r=r(t)),r||!1!==r&&De(t.url))){const e=o&&s&&Fe.read(s);e&&i.set(o,e)}return t};var Ve="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Me(e);let o=r.data;const s=je.from(r.headers).normalize();let i,a,c,l,u,{responseType:d,onUploadProgress:f,onDownloadProgress:h}=r;function p(){l&&l(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(i),r.signal&&r.signal.removeEventListener("abort",i)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=je.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Pe(function(e){t(e),p()},function(e){n(e),p()},{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new Y("Request aborted",Y.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=new Y(t&&t.message?t.message:"Network Error",Y.ERR_NETWORK,e,m);r.event=t||null,n(r),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||he;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Y(t,o.clarifyTimeoutError?Y.ETIMEDOUT:Y.ECONNABORTED,e,m)),m=null},void 0===o&&s.setContentType(null),"setRequestHeader"in m&&Z.forEach(s.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Z.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),d&&"json"!==d&&(m.responseType=r.responseType),h&&([c,u]=Ue(h,!0),m.addEventListener("progress",c)),f&&m.upload&&([a,l]=Ue(f),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(i=t=>{m&&(n(!t||t.type?new _e(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(i),r.signal&&(r.signal.aborted?i():r.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===Ee.protocols.indexOf(y)?n(new Y("Unsupported protocol "+y+":",Y.ERR_BAD_REQUEST,e)):m.send(o||null)})};const ze=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,i();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Y?t:new _e(t instanceof Error?t.message:t))}};let s=t&&setTimeout(()=>{s=null,o(new Y(`timeout ${t} of ms exceeded`,Y.ETIMEDOUT))},t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>Z.asap(i),a}},Je=function*(e,t){let n=e.byteLength;if(n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},He=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},We=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of He(e))yield*Je(n,t)}(e,t);let s,i=0,a=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let s=r.byteLength;if(n){let e=i+=s;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:$e}=Z,Ke=(({Request:e,Response:t})=>({Request:e,Response:t}))(Z.global),{ReadableStream:Ge,TextEncoder:Xe}=Z.global,Qe=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ze=e=>{e=Z.merge.call({skipUndefined:!0},Ke,e);const{fetch:t,Request:n,Response:r}=e,o=t?$e(t):"function"==typeof fetch,s=$e(n),i=$e(r);if(!o)return!1;const a=o&&$e(Ge),c=o&&("function"==typeof Xe?(l=new Xe,e=>l.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var l;const u=s&&a&&Qe(()=>{let e=!1;const t=new n(Ee.origin,{body:new Ge,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=i&&a&&Qe(()=>Z.isReadableStream(new r("").body)),f={stream:d&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!f[e]&&(f[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new Y(`Response type '${e}' is not supported`,Y.ERR_NOT_SUPPORT,n)})});const h=async(e,t)=>{const r=Z.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Z.isBlob(e))return e.size;if(Z.isSpecCompliantForm(e)){const t=new n(Ee.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Z.isArrayBufferView(e)||Z.isArrayBuffer(e)?e.byteLength:(Z.isURLSearchParams(e)&&(e+=""),Z.isString(e)?(await c(e)).byteLength:void 0)})(t):r};return async e=>{let{url:o,method:i,data:a,signal:c,cancelToken:l,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:y,headers:b,withCredentials:w="same-origin",fetchOptions:E}=Me(e),v=t||fetch;y=y?(y+"").toLowerCase():"text";let O=ze([c,l&&l.toAbortSignal()],p),S=null;const R=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let T;try{if(g&&u&&"get"!==i&&"head"!==i&&0!==(T=await h(b,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(Z.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=Le(T,Ue(ke(g)));a=We(t.body,65536,e,n)}}Z.isString(w)||(w=w?"include":"omit");const t=s&&"credentials"in n.prototype,c={...E,signal:O,method:i.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?w:void 0};S=s&&new n(o,c);let l=await(s?v(S,E):v(o,c));const p=d&&("stream"===y||"response"===y);if(d&&(m||p&&R)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=l[t]});const t=Z.toFiniteNumber(l.headers.get("content-length")),[n,o]=m&&Le(t,Ue(ke(m),!0))||[];l=new r(We(l.body,65536,n,()=>{o&&o(),R&&R()}),e)}y=y||"text";let A=await f[Z.findKey(f,y)||"text"](l,e);return!p&&R&&R(),await new Promise((t,n)=>{Pe(t,n,{data:A,headers:je.from(l.headers),status:l.status,statusText:l.statusText,config:e,request:S})})}catch(t){if(R&&R(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Y("Network Error",Y.ERR_NETWORK,e,S),{cause:t.cause||t});throw Y.from(t,t&&t.code,e,S)}}},Ye=new Map,et=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i,a,c=s.length,l=Ye;for(;c--;)i=s[c],a=l.get(i),void 0===a&&l.set(i,a=c?new Map:Ze(t)),l=a;return a};et();const tt={http:null,xhr:Ve,fetch:{get:et}};Z.forEach(tt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const nt=e=>`- ${e}`,rt=e=>Z.isFunction(e)||null===e||!1===e;var ot=(e,t)=>{e=Z.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){let n;if(r=e[i],o=r,!rt(r)&&(o=tt[(n=String(r)).toLowerCase()],void 0===o))throw new Y(`Unknown adapter '${n}'`);if(o&&(Z.isFunction(o)||(o=o.get(t))))break;s[n||"#"+i]=o}if(!o){const e=Object.entries(s).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Y("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(nt).join("\n"):" "+nt(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o};function st(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new _e(null,e)}function it(e){st(e),e.headers=je.from(e.headers),e.data=Ne.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ot(e.adapter||Oe.adapter,e)(e).then(function(t){return st(e),t.data=Ne.call(e,e.transformResponse,t),t.headers=je.from(t.headers),t},function(t){return Ce(t)||(st(e),t&&t.response&&(t.response.data=Ne.call(e,e.transformResponse,t.response),t.response.headers=je.from(t.response.headers))),Promise.reject(t)})}const at="1.12.2",ct={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ct[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const lt={};ct.transitional=function(e,t,n){function r(e,t){return"[Axios v"+at+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new Y(r(o," has been removed"+(t?" in "+t:"")),Y.ERR_DEPRECATED);return t&&!lt[o]&&(lt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}},ct.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var ut={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Y("options must be an object",Y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new Y("option "+s+" must be "+n,Y.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new Y("Unknown option "+s,Y.ERR_BAD_OPTION)}},validators:ct};const dt=ut.validators;let ft=class{constructor(e){this.defaults=e||{},this.interceptors={request:new fe,response:new fe}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=qe(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&ut.assertOptions(n,{silentJSONParsing:dt.transitional(dt.boolean),forcedJSONParsing:dt.transitional(dt.boolean),clarifyTimeoutError:dt.transitional(dt.boolean)},!1),null!=r&&(Z.isFunction(r)?t.paramsSerializer={serialize:r}:ut.assertOptions(r,{encode:dt.function,serialize:dt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ut.assertOptions(t,{baseUrl:dt.spelling("baseURL"),withXsrfToken:dt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&Z.merge(o.common,o[t.method]);o&&Z.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=je.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,d=0;if(!a){const e=[it.bind(this),void 0];for(e.unshift(...i),e.push(...c),u=e.length,l=Promise.resolve(t);d<u;)l=l.then(e[d++],e[d++]);return l}u=i.length;let f=t;for(;d<u;){const e=i[d++],t=i[d++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=it.call(this,f)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)l=l.then(c[d++],c[d++]);return l}getUri(e){return de(Be((e=qe(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Z.forEach(["delete","get","head","options"],function(e){ft.prototype[e]=function(t,n){return this.request(qe(n||{},{method:e,url:t,data:(n||{}).data}))}}),Z.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(qe(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ft.prototype[e]=t(),ft.prototype[e+"Form"]=t(!0)});const ht={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ht).forEach(([e,t])=>{ht[t]=e});const pt=function e(t){const n=new ft(t),r=c(ft.prototype.request,n);return Z.extend(r,ft.prototype,n,{allOwnKeys:!0}),Z.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(qe(t,n))},r}(Oe);pt.Axios=ft,pt.CanceledError=_e,pt.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new _e(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},pt.isCancel=Ce,pt.VERSION=at,pt.toFormData=ie,pt.AxiosError=Y,pt.Cancel=pt.CanceledError,pt.all=function(e){return Promise.all(e)},pt.spread=function(e){return function(t){return e.apply(null,t)}},pt.isAxiosError=function(e){return Z.isObject(e)&&!0===e.isAxiosError},pt.mergeConfig=qe,pt.AxiosHeaders=je,pt.formToJSON=e=>ve(Z.isHTMLForm(e)?new FormData(e):e),pt.getAdapter=ot,pt.HttpStatusCode=ht,pt.default=pt;const{Axios:mt,AxiosError:gt,CanceledError:yt,isCancel:bt,CancelToken:wt,VERSION:Et,all:vt,Cancel:Ot,isAxiosError:St,spread:Rt,toFormData:Tt,AxiosHeaders:At,HttpStatusCode:xt,formToJSON:jt,getAdapter:Nt,mergeConfig:Ct}=pt;const _t=a.getInstance();_t.register(new class extends r{debug(e,t){this.isLogEnabled()&&console.log(`[DEBUG] ${e}`,t||"")}error(e,t){this.isLogEnabled()&&console.error(`[ERROR] ${e}`,t||"")}info(e,t){this.isLogEnabled()&&console.info(`[INFO] ${e}`,t||"")}warn(e,t){this.isLogEnabled()&&console.warn(`[WARN] ${e}`,t||"")}isLogEnabled(){return!1!==a.getInstance().config.get("logger.enabled")}}),_t.register(new class extends n{constructor(){super(...arguments),this.interceptorsSetup=!1}get axiosInstance(){return this._axiosInstance||(this._axiosInstance=pt.create()),this._axiosInstance}async send(e){const t=a.getInstance().config;this.interceptorsSetup||(this.setupInterceptors(),this.interceptorsSetup=!0);try{const n={...this.getDefaultConfig(t),...this.convertToAxiosConfig(e)},r=await this.axiosInstance.request(n);return this.convertResponse(r)}catch(e){throw this.handleError(e)}}setupInterceptors(){this.axiosInstance.interceptors.request.use(e=>e,e=>Promise.reject(e)),this.axiosInstance.interceptors.response.use(e=>e,e=>Promise.reject(e))}getDefaultConfig(e){const t={},n=e.get("request.baseURL");n&&(t.baseURL=n);const r=e.get("request.timeout");r&&(t.timeout=r);const o=e.get("request.headers");return o&&(t.headers=o),t}convertToAxiosConfig(e){const t={url:e.url,method:e.method||"GET"};return void 0!==e.timeout&&(t.timeout=e.timeout),e.responseType&&(t.responseType=e.responseType),e.header&&Object.keys(e.header).length>0&&(t.headers=e.header),e.params&&Object.keys(e.params).length>0&&(t.params=e.params),e.data&&Object.keys(e.data).length>0&&(t.data=e.data),e.onDownloadProgress&&(t.onDownloadProgress=e.onDownloadProgress),t}convertResponse(e){const t=e.headers&&"object"==typeof e.headers?{...e.headers}:e.headers;return{data:e.data,status:e.status,statusText:e.statusText,headers:t,config:{url:e.config.url,method:e.config.method,timeout:e.config.timeout}}}handleError(e){if(e.response){const t=`请求失败: ${e.response.status} ${e.response.statusText}`;return new Error(t)}return e.request?new Error("网络请求超时或无法连接到服务器"):new Error(`请求配置错误: ${e.message}`)}async get(e,t){return this.send({url:e,method:"GET",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async post(e,t,n){return this.send({url:e,method:"POST",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}async put(e,t,n){return this.send({url:e,method:"PUT",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}async delete(e,t){return this.send({url:e,method:"DELETE",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async patch(e,t,n){return this.send({url:e,method:"PATCH",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}}),_t.register(new class extends s{getNestedValue(e,t){return t.reduce((e,t)=>null==e?void 0:e[t],e)}setNestedValue(e,t,n){const r=t[t.length-1];t.slice(0,-1).reduce((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t]),e)[r]=n}deleteNestedValue(e,t){if(0===t.length)return!1;const n=t[t.length-1],r=t.slice(0,-1),o=this.getNestedValue(e,r);return!(!o||"object"!=typeof o||!(n in o))&&(delete o[n],!0)}set(e,t){const n=e.split(".");if(1===n.length)localStorage.setItem(e,JSON.stringify(t));else{const e=n[0],r=localStorage.getItem(e);let o;try{o=r?JSON.parse(r):{},("object"!=typeof o||null===o||Array.isArray(o))&&(o={})}catch(e){o={}}this.setNestedValue(o,n.slice(1),t),localStorage.setItem(e,JSON.stringify(o))}}get(e){if(!e){const e={};for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(n)try{e[n]=JSON.parse(localStorage.getItem(n))}catch(t){e[n]=localStorage.getItem(n)}}return e}const t=e.split("."),n=t[0],r=localStorage.getItem(n);if(!r)return null;try{const e=JSON.parse(r);return 1===t.length?e:this.getNestedValue(e,t.slice(1))}catch(e){return r}}remove(e){const t=e.split(".");if(1===t.length)localStorage.removeItem(e);else{const e=t[0],n=localStorage.getItem(e);if(n)try{const r=JSON.parse(n);this.deleteNestedValue(r,t.slice(1))&&localStorage.setItem(e,JSON.stringify(r))}catch(e){}}}clear(){localStorage.clear()}keys(){return Object.keys(localStorage)}has(e){const t=e.split("."),n=t[0],r=localStorage.getItem(n);if(!r)return!1;if(1===t.length)return!0;try{const e=JSON.parse(r);return void 0!==this.getNestedValue(e,t.slice(1))}catch(e){return!1}}}),_t.register(new class extends i{form(e){var t;const n=a.getInstance().config.get("request.baseURL");try{let r=e.url;if(n&&!e.url.startsWith("http://")&&!e.url.startsWith("https://")){const t=n.endsWith("/")||e.url.startsWith("/")?"":"/";r=n+t+e.url}const o=document.createElement("form");if(o.method=e.method||"POST",o.action=r,o.style.display="none",null===(t=e.header)||void 0===t?void 0:t.Authorization){const t=document.createElement("a");t.href=r;const n=new URLSearchParams(t.search);n.set("Authorization",e.header.Authorization),t.search=n.toString(),o.action=t.href}if(e.params){const t=document.createElement("a");t.href=o.action;const n=new URLSearchParams(t.search);Object.entries(e.params).forEach(([e,t])=>{n.set(e,String(t))}),t.search=n.toString(),o.action=t.href}if(e.data&&Object.entries(e.data).forEach(([e,t])=>{const n=document.createElement("input");n.type="hidden",n.name=e,n.value=String(t),o.appendChild(n)}),document.body.appendChild(o),o.submit(),document.body.removeChild(o),e.onSuccess){const t={filename:"Unknown",size:0,type:"application/octet-stream",duration:0,blob:new Blob,url:r,autoDownloaded:!0};e.onSuccess(t)}}catch(t){const n=new Error(`Form download failed: ${t.message}`);throw e.onError&&e.onError(n),n}}async download(e){const t=a.getInstance().request,n=Date.now();try{const r=await t.send({url:e.url,method:e.method||"GET",header:e.header,params:e.params,data:e.data,timeout:e.timeout,responseType:"blob",onDownloadProgress:t=>{if(e.onProgress){const r=this.calculateProgress(t,n);e.onProgress(r)}}});let o;if(console.log(r.headers),r.data instanceof Blob)o=r.data;else if(r.data instanceof ArrayBuffer){const e=r.headers["content-type"]||"application/octet-stream";o=new Blob([r.data],{type:e})}else{const e=r.headers["content-type"]||"application/octet-stream";o=new Blob([r.data],{type:e})}const s=this.extractFilename(e.filename,r.headers,e.url),i=o.type||"application/octet-stream",a=o.size,c={filename:s,size:a,type:i,duration:Date.now()-n,blob:o,url:e.url};if(!1!==e.autoDownload){const t=e.downloadMethod||"both",n=this.createDownloadLink(c,t);c.downloadUrl=n.url,c.autoDownloaded=n.triggered}return e.onSuccess&&e.onSuccess(c),c}catch(t){let n;throw n=t.response?new Error(`Download failed: ${t.response.status} ${t.response.statusText}`):t.request?new Error("Network timeout or unable to connect to server"):new Error(`Download configuration error: ${t.message}`),e.onError&&e.onError(n),n}}calculateProgress(e,t){const n=e.loaded,r=e.total,o=r>0?Math.round(n/r*100):0,s=(Date.now()-t)/1e3,i=s>0?n/s:0;return{loaded:n,total:r,percentage:o,speed:i,remainingTime:i>0?(r-n)/i:0}}extractFilename(e,t,n){if(e)return e;const r=(null==t?void 0:t["content-disposition"])||(null==t?void 0:t["Content-Disposition"]);if(r){const e=r.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(e&&e[1])return e[1].replace(/['"]/g,"")}if(n)try{let e;e=n.startsWith("http://")||n.startsWith("https://")?new URL(n).pathname:n;const t=e.split("/").pop();if(t&&t.includes("."))return t}catch(e){const t=n.split("/").pop();if(t&&t.includes("."))return t}return`download_${Date.now()}`}createDownloadLink(e,t){try{if(!(e.blob&&e.blob instanceof Blob))throw new Error("Invalid blob data for download");if(0===e.blob.size)throw new Error("Empty blob data");const n=URL.createObjectURL(e.blob);let r=!1;return"link"!==t&&"both"!==t||(this.triggerDownload(n,e.filename),r=!0),{url:n,triggered:r}}catch(e){return console.error("Failed to create download link:",e),{url:"",triggered:!1}}}triggerDownload(e,t){try{const n=document.createElement("a");n.href=e,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>{URL.revokeObjectURL(e)},1e3)}catch(e){console.error("Failed to trigger download:",e)}}}),"undefined"!=typeof window&&(window.kivii=_t),e.Kivii=a,e.MockRequest=class extends n{async send(e){const t=a.getInstance().config.get("mock");if(!t)throw new Error("Mock data not configured");const n=e.url||"",r=n.split("/").filter(e=>e&&""!==e);let o=t;for(const t of r){if(!o||"object"!=typeof o||!(t in o)){o=void 0;break}o="function"==typeof o[t]?o[t]({method:e.method,params:e.params,data:e.data}):o[t]}if(void 0===o)throw new Error(`Mock data not found for URL: ${n}`);return{data:o,status:200,statusText:"OK",headers:{},config:e}}async get(e,t){return this.send({url:e,method:"GET",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async post(e,t,n){return this.send({url:e,method:"POST",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}async put(e,t,n){return this.send({url:e,method:"PUT",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}async delete(e,t){return this.send({url:e,method:"DELETE",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async patch(e,t,n){return this.send({url:e,method:"PATCH",header:(null==n?void 0:n.header)||{},params:(null==n?void 0:n.params)||{},data:t||{},timeout:null==n?void 0:n.timeout})}},e.default=_t,e.kivii=_t,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Kivii={})}(this,function(e){"use strict";class t{constructor(){this.configs=new Map}init(e){if(e.hooks){c.getInstance().hook.init(e.hooks)}for(const[t,r]of Object.entries(e))"hooks"!==t&&this.set(t,r)}set(e,t){e.includes(".")?this.setNestedValue(e,t):this.configs.set(e,t)}get(e){return e.includes(".")?this.getNestedValue(e):this.configs.get(e)}has(e){return e.includes(".")?void 0!==this.getNestedValue(e):this.configs.has(e)}delete(e){if(e.includes(".")){const t=e.split("."),r=t[0],n=t.slice(1).join(".");if(this.configs.has(r)){const e=this.configs.get(r);if("object"==typeof e&&null!==e)return delete e[n],!0}return!1}return this.configs.delete(e)}clear(){this.configs.clear()}getAll(){const e={};for(const[t,r]of this.configs)e[t]=r;return e}setNestedValue(e,t){const r=e.split("."),n=r[0];let o=this.configs.get(n);o&&"object"==typeof o||(o={},this.configs.set(n,o));let s=o;for(let e=1;e<r.length-1;e++)s[r[e]]&&"object"==typeof s[r[e]]||(s[r[e]]={}),s=s[r[e]];s[r[r.length-1]]=t}getNestedValue(e){const t=e.split("."),r=t[0];let n=this.configs.get(r);for(let e=1;e<t.length;e++){if(!n||"object"!=typeof n||!(t[e]in n))return;n=n[t[e]]}return n}}class r{constructor(){this.interfaceType="IRequest"}async send(e){throw new Error("Method not implemented.")}async get(e,t){return this.send({url:e,method:"GET",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async post(e,t,r){return this.send({url:e,method:"POST",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}async put(e,t,r){return this.send({url:e,method:"PUT",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}async delete(e,t){return this.send({url:e,method:"DELETE",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async patch(e,t,r){return this.send({url:e,method:"PATCH",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}}class n{constructor(){this.interfaceType="ILogger"}debug(e,t){}error(e,t){}info(e,t){}warn(e,t){}}class o{constructor(){this.interfaceType="INavagator"}go(e,t){}push(e,t){}back(){}replace(e,t){}open(e,t){}}class s{constructor(){this.interfaceType="IStorage"}set(e,t){}get(e){return null}remove(e){}clear(){}keys(){return[]}has(e){return!1}}class i{constructor(){this.interfaceType="IDownloader"}async download(e){throw new Error("Method not implemented.")}form(e){throw new Error("Method not implemented.")}}class a{constructor(){this.interfaceType="IHook"}init(e){throw new Error("Method not implemented.")}register(e,t){throw new Error("Method not implemented.")}unregister(e,t){throw new Error("Method not implemented.")}async execute(e,t){throw new Error("Method not implemented.")}has(e){throw new Error("Method not implemented.")}clear(){throw new Error("Method not implemented.")}}class c{constructor(){this._privateVariables=new Map,this._config=new t,this._navigator=new o,this._logger=new n,this._request=new r,this._downloader=new i,this._storage=new s,this._hook=new a}get privateVariables(){if(0===this._privateVariables.size)for(const e of Object.keys(this))if(e.startsWith("_")){const t=this[e];"interfaceType"in t&&this._privateVariables.set(t.interfaceType,t)}return this._privateVariables}get config(){return this._config}get navigator(){return this.privateVariables.get(this._navigator.interfaceType)||this._navigator}get logger(){return this.privateVariables.get(this._logger.interfaceType)||this._logger}get request(){return this.privateVariables.get(this._request.interfaceType)||this._request}get downloader(){return this.privateVariables.get(this._downloader.interfaceType)||this._downloader}get storage(){return this.privateVariables.get(this._storage.interfaceType)||this._storage}get hook(){return this.privateVariables.get(this._hook.interfaceType)||this._hook}register(e){if(!("interfaceType"in e))return void this.logger.warn("无法注入实例:实例必须包含 interfaceType 属性");const t=e.interfaceType;this._privateVariables.set(t,e),this.logger.info(`成功注入实例:${t}`)}tryResolve(e){return this.privateVariables.get(e)}static getInstance(){return c._instance||(c._instance=new c),c._instance}}function l(e,t){return function(){return e.apply(t,arguments)}}const{toString:u}=Object.prototype,{getPrototypeOf:d}=Object,{iterator:h,toStringTag:f}=Symbol,p=(m=Object.create(null),e=>{const t=u.call(e);return m[t]||(m[t]=t.slice(8,-1).toLowerCase())});var m;const g=e=>(e=e.toLowerCase(),t=>p(t)===e),y=e=>t=>typeof t===e,{isArray:b}=Array,w=y("undefined");function E(e){return null!==e&&!w(e)&&null!==e.constructor&&!w(e.constructor)&&S(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const v=g("ArrayBuffer");const O=y("string"),S=y("function"),R=y("number"),T=e=>null!==e&&"object"==typeof e,A=e=>{if("object"!==p(e))return!1;const t=d(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||f in e||h in e)},x=g("Date"),k=g("File"),j=g("Blob"),N=g("FileList"),C=g("URLSearchParams"),[_,P,U,L]=["ReadableStream","Request","Response","Headers"].map(g);function D(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),b(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(E(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(n=0;n<s;n++)i=o[n],t.call(null,e[i],i,e)}}function F(e,t){if(E(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,o=r.length;for(;o-- >0;)if(n=r[o],t===n.toLowerCase())return n;return null}const B="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,I=e=>!w(e)&&e!==B;const q=(M="undefined"!=typeof Uint8Array&&d(Uint8Array),e=>M&&e instanceof M);var M;const V=g("HTMLFormElement"),H=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),z=g("RegExp"),$=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};D(r,(r,o)=>{let s;!1!==(s=t(r,o,e))&&(n[o]=s||r)}),Object.defineProperties(e,n)};const J=g("AsyncFunction"),W=(K="function"==typeof setImmediate,G=S(B.postMessage),K?setImmediate:G?(X=`axios@${Math.random()}`,Q=[],B.addEventListener("message",({source:e,data:t})=>{e===B&&t===X&&Q.length&&Q.shift()()},!1),e=>{Q.push(e),B.postMessage(X,"*")}):e=>setTimeout(e));var K,G,X,Q;const Z="undefined"!=typeof queueMicrotask?queueMicrotask.bind(B):"undefined"!=typeof process&&process.nextTick||W;var Y={isArray:b,isArrayBuffer:v,isBuffer:E,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||S(e.append)&&("formdata"===(t=p(e))||"object"===t&&S(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&v(e.buffer),t},isString:O,isNumber:R,isBoolean:e=>!0===e||!1===e,isObject:T,isPlainObject:A,isEmptyObject:e=>{if(!T(e)||E(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:_,isRequest:P,isResponse:U,isHeaders:L,isUndefined:w,isDate:x,isFile:k,isBlob:j,isRegExp:z,isFunction:S,isStream:e=>T(e)&&S(e.pipe),isURLSearchParams:C,isTypedArray:q,isFileList:N,forEach:D,merge:function e(){const{caseless:t,skipUndefined:r}=I(this)&&this||{},n={},o=(o,s)=>{const i=t&&F(n,s)||s;A(n[i])&&A(o)?n[i]=e(n[i],o):A(o)?n[i]=e({},o):b(o)?n[i]=o.slice():r&&w(o)||(n[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&D(arguments[e],o);return n},extend:(e,t,r,{allOwnKeys:n}={})=>(D(t,(t,n)=>{r&&S(t)?e[n]=l(t,r):e[n]=t},{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let o,s,i;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],n&&!n(i,e,t)||a[i]||(t[i]=e[i],a[i]=!0);e=!1!==r&&d(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:p,kindOfTest:g,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(b(e))return e;let t=e.length;if(!R(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[h]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:V,hasOwnProperty:H,hasOwnProp:H,reduceDescriptors:$,freezeMethods:e=>{$(e,(t,r)=>{if(S(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];S(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return b(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:F,global:B,isContextDefined:I,isSpecCompliantForm:function(e){return!!(e&&S(e.append)&&"FormData"===e[f]&&e[h])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(T(e)){if(t.indexOf(e)>=0)return;if(E(e))return e;if(!("toJSON"in e)){t[n]=e;const o=b(e)?[]:{};return D(e,(e,t)=>{const s=r(e,n+1);!w(s)&&(o[t]=s)}),t[n]=void 0,o}}return e};return r(e,0)},isAsyncFn:J,isThenable:e=>e&&(T(e)||S(e))&&S(e.then)&&S(e.catch),setImmediate:W,asap:Z,isIterable:e=>null!=e&&S(e[h])};function ee(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}Y.inherits(ee,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Y.toJSONObject(this.config),code:this.code,status:this.status}}});const te=ee.prototype,re={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{re[e]={value:e}}),Object.defineProperties(ee,re),Object.defineProperty(te,"isAxiosError",{value:!0}),ee.from=(e,t,r,n,o,s)=>{const i=Object.create(te);Y.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return ee.call(i,a,c,r,n,o),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};function ne(e){return Y.isPlainObject(e)||Y.isArray(e)}function oe(e){return Y.endsWith(e,"[]")?e.slice(0,-2):e}function se(e,t,r){return e?e.concat(t).map(function(e,t){return e=oe(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}const ie=Y.toFlatObject(Y,{},null,function(e){return/^is[A-Z]/.test(e)});function ae(e,t,r){if(!Y.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=Y.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Y.isUndefined(t[e])})).metaTokens,o=r.visitor||l,s=r.dots,i=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Y.isSpecCompliantForm(t);if(!Y.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Y.isDate(e))return e.toISOString();if(Y.isBoolean(e))return e.toString();if(!a&&Y.isBlob(e))throw new ee("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(e)||Y.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,r,o){let a=e;if(e&&!o&&"object"==typeof e)if(Y.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(Y.isArray(e)&&function(e){return Y.isArray(e)&&!e.some(ne)}(e)||(Y.isFileList(e)||Y.endsWith(r,"[]"))&&(a=Y.toArray(e)))return r=oe(r),a.forEach(function(e,n){!Y.isUndefined(e)&&null!==e&&t.append(!0===i?se([r],n,s):null===i?r:r+"[]",c(e))}),!1;return!!ne(e)||(t.append(se(o,r,s),c(e)),!1)}const u=[],d=Object.assign(ie,{defaultVisitor:l,convertValue:c,isVisitable:ne});if(!Y.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!Y.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),Y.forEach(r,function(r,s){!0===(!(Y.isUndefined(r)||null===r)&&o.call(t,r,Y.isString(s)?s.trim():s,n,d))&&e(r,n?n.concat(s):[s])}),u.pop()}}(e),t}function ce(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function le(e,t){this._pairs=[],e&&ae(e,this,t)}const ue=le.prototype;function de(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function he(e,t,r){if(!t)return e;const n=r&&r.encode||de;Y.isFunction(r)&&(r={serialize:r});const o=r&&r.serialize;let s;if(s=o?o(t,r):Y.isURLSearchParams(t)?t.toString():new le(t,r).toString(n),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}ue.append=function(e,t){this._pairs.push([e,t])},ue.toString=function(e){const t=e?function(t){return e.call(this,t,ce)}:ce;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class fe{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Y.forEach(this.handlers,function(t){null!==t&&e(t)})}}var pe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},me={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:le,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ge="undefined"!=typeof window&&"undefined"!=typeof document,ye="object"==typeof navigator&&navigator||void 0,be=ge&&(!ye||["ReactNative","NativeScript","NS"].indexOf(ye.product)<0),we="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Ee=ge&&window.location.href||"http://localhost";var ve={...Object.freeze({__proto__:null,hasBrowserEnv:ge,hasStandardBrowserEnv:be,hasStandardBrowserWebWorkerEnv:we,navigator:ye,origin:Ee}),...me};function Oe(e){function t(e,r,n,o){let s=e[o++];if("__proto__"===s)return!0;const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&Y.isArray(n)?n.length:s,a)return Y.hasOwnProp(n,s)?n[s]=[n[s],r]:n[s]=r,!i;n[s]&&Y.isObject(n[s])||(n[s]=[]);return t(e,r,n[s],o)&&Y.isArray(n[s])&&(n[s]=function(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}(n[s])),!i}if(Y.isFormData(e)&&Y.isFunction(e.entries)){const r={};return Y.forEachEntry(e,(e,n)=>{t(function(e){return Y.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,r,0)}),r}return null}const Se={transitional:pe,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,o=Y.isObject(e);o&&Y.isHTMLForm(e)&&(e=new FormData(e));if(Y.isFormData(e))return n?JSON.stringify(Oe(e)):e;if(Y.isArrayBuffer(e)||Y.isBuffer(e)||Y.isStream(e)||Y.isFile(e)||Y.isBlob(e)||Y.isReadableStream(e))return e;if(Y.isArrayBufferView(e))return e.buffer;if(Y.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ae(e,new ve.classes.URLSearchParams,{visitor:function(e,t,r,n){return ve.isNode&&Y.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((s=Y.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return ae(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e,t,r){if(Y.isString(e))try{return(t||JSON.parse)(e),Y.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Se.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Y.isResponse(e)||Y.isReadableStream(e))return e;if(e&&Y.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(e){if(r){if("SyntaxError"===e.name)throw ee.from(e,ee.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ve.classes.FormData,Blob:ve.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],e=>{Se.headers[e]={}});const Re=Y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Te=Symbol("internals");function Ae(e){return e&&String(e).trim().toLowerCase()}function xe(e){return!1===e||null==e?e:Y.isArray(e)?e.map(xe):String(e)}function ke(e,t,r,n,o){return Y.isFunction(n)?n.call(this,t,r):(o&&(t=r),Y.isString(t)?Y.isString(n)?-1!==t.indexOf(n):Y.isRegExp(n)?n.test(t):void 0:void 0)}let je=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function o(e,t,r){const o=Ae(t);if(!o)throw new Error("header name must be a non-empty string");const s=Y.findKey(n,o);(!s||void 0===n[s]||!0===r||void 0===r&&!1!==n[s])&&(n[s||t]=xe(e))}const s=(e,t)=>Y.forEach(e,(e,r)=>o(e,r,t));if(Y.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(Y.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let r,n,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&Re[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(e),t);else if(Y.isObject(e)&&Y.isIterable(e)){let r,n,o={};for(const t of e){if(!Y.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[n=t[0]]=(r=o[n])?Y.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}s(o,t)}else null!=e&&o(t,e,r);return this}get(e,t){if(e=Ae(e)){const r=Y.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(Y.isFunction(t))return t.call(this,e,r);if(Y.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ae(e)){const r=Y.findKey(this,e);return!(!r||void 0===this[r]||t&&!ke(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function o(e){if(e=Ae(e)){const o=Y.findKey(r,e);!o||t&&!ke(0,r[o],o,t)||(delete r[o],n=!0)}}return Y.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const o=t[r];e&&!ke(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,r={};return Y.forEach(this,(n,o)=>{const s=Y.findKey(r,o);if(s)return t[s]=xe(n),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}(o):String(o).trim();i!==o&&delete t[o],t[i]=xe(n),r[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Y.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&Y.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const t=(this[Te]=this[Te]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Ae(e);t[n]||(!function(e,t){const r=Y.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})})}(r,e),t[n]=!0)}return Y.isArray(e)?e.forEach(n):n(e),this}};function Ne(e,t){const r=this||Se,n=t||r,o=je.from(n.headers);let s=n.data;return Y.forEach(e,function(e){s=e.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ce(e){return!(!e||!e.__CANCEL__)}function _e(e,t,r){ee.call(this,null==e?"canceled":e,ee.ERR_CANCELED,t,r),this.name="CanceledError"}function Pe(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new ee("Request failed with status code "+r.status,[ee.ERR_BAD_REQUEST,ee.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}je.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Y.reduceDescriptors(je.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),Y.freezeMethods(je),Y.inherits(_e,ee,{__CANCEL__:!0});const Ue=(e,t,r=3)=>{let n=0;const o=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=n[i];o||(o=c),r[s]=a,n[s]=c;let u=i,d=0;for(;u!==s;)d+=r[u++],u%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const h=l&&c-l;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(e,t){let r,n,o=0,s=1e3/t;const i=(t,s=Date.now())=>{o=s,r=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=s?i(e,t):(r=e,n||(n=setTimeout(()=>{n=null,i(r)},s-a)))},()=>r&&i(r)]}(r=>{const s=r.loaded,i=r.lengthComputable?r.total:void 0,a=s-n,c=o(a);n=s;e({loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:r,lengthComputable:null!=i,[t?"download":"upload"]:!0})},r)},Le=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},De=e=>(...t)=>Y.asap(()=>e(...t));var Fe=ve.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ve.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ve.origin),ve.navigator&&/(msie|trident)/i.test(ve.navigator.userAgent)):()=>!0,Be=ve.hasStandardBrowserEnv?{write(e,t,r,n,o,s){const i=[e+"="+encodeURIComponent(t)];Y.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),Y.isString(n)&&i.push("path="+n),Y.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ie(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const qe=e=>e instanceof je?{...e}:e;function Me(e,t){t=t||{};const r={};function n(e,t,r,n){return Y.isPlainObject(e)&&Y.isPlainObject(t)?Y.merge.call({caseless:n},e,t):Y.isPlainObject(t)?Y.merge({},t):Y.isArray(t)?t.slice():t}function o(e,t,r,o){return Y.isUndefined(t)?Y.isUndefined(e)?void 0:n(void 0,e,0,o):n(e,t,0,o)}function s(e,t){if(!Y.isUndefined(t))return n(void 0,t)}function i(e,t){return Y.isUndefined(t)?Y.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,o,s){return s in t?n(r,o):s in e?n(void 0,r):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t,r)=>o(qe(e),qe(t),0,!0)};return Y.forEach(Object.keys({...e,...t}),function(n){const s=c[n]||o,i=s(e[n],t[n],n);Y.isUndefined(i)&&s!==a||(r[n]=i)}),r}var Ve=e=>{const t=Me({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=je.from(i),t.url=he(Ie(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Y.isFormData(r))if(ve.hasStandardBrowserEnv||ve.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Y.isFunction(r.getHeaders)){const e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,r])=>{t.includes(e.toLowerCase())&&i.set(e,r)})}if(ve.hasStandardBrowserEnv&&(n&&Y.isFunction(n)&&(n=n(t)),n||!1!==n&&Fe(t.url))){const e=o&&s&&Be.read(s);e&&i.set(o,e)}return t};var He="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){const n=Ve(e);let o=n.data;const s=je.from(n.headers).normalize();let i,a,c,l,u,{responseType:d,onUploadProgress:h,onDownloadProgress:f}=n;function p(){l&&l(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(i),n.signal&&n.signal.removeEventListener("abort",i)}let m=new XMLHttpRequest;function g(){if(!m)return;const n=je.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Pe(function(e){t(e),p()},function(e){r(e),p()},{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:n,config:e,request:m}),m=null}m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(r(new ee("Request aborted",ee.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const n=new ee(t&&t.message?t.message:"Network Error",ee.ERR_NETWORK,e,m);n.event=t||null,r(n),m=null},m.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const o=n.transitional||pe;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new ee(t,o.clarifyTimeoutError?ee.ETIMEDOUT:ee.ECONNABORTED,e,m)),m=null},void 0===o&&s.setContentType(null),"setRequestHeader"in m&&Y.forEach(s.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Y.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),d&&"json"!==d&&(m.responseType=n.responseType),f&&([c,u]=Ue(f,!0),m.addEventListener("progress",c)),h&&m.upload&&([a,l]=Ue(h),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",l)),(n.cancelToken||n.signal)&&(i=t=>{m&&(r(!t||t.type?new _e(null,e,m):t),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(i),n.signal&&(n.signal.aborted?i():n.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);y&&-1===ve.protocols.indexOf(y)?r(new ee("Unsupported protocol "+y+":",ee.ERR_BAD_REQUEST,e)):m.send(o||null)})};const ze=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const o=function(e){if(!r){r=!0,i();const t=e instanceof Error?e:this.reason;n.abort(t instanceof ee?t:new _e(t instanceof Error?t.message:t))}};let s=t&&setTimeout(()=>{s=null,o(new ee(`timeout ${t} of ms exceeded`,ee.ETIMEDOUT))},t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=n;return a.unsubscribe=()=>Y.asap(i),a}},$e=function*(e,t){let r=e.byteLength;if(r<t)return void(yield e);let n,o=0;for(;o<r;)n=o+t,yield e.slice(o,n),o=n},Je=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},We=(e,t,r,n)=>{const o=async function*(e,t){for await(const r of Je(e))yield*$e(r,t)}(e,t);let s,i=0,a=e=>{s||(s=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await o.next();if(t)return a(),void e.close();let s=n.byteLength;if(r){let e=i+=s;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:Ke}=Y,Ge=(({Request:e,Response:t})=>({Request:e,Response:t}))(Y.global),{ReadableStream:Xe,TextEncoder:Qe}=Y.global,Ze=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ye=e=>{e=Y.merge.call({skipUndefined:!0},Ge,e);const{fetch:t,Request:r,Response:n}=e,o=t?Ke(t):"function"==typeof fetch,s=Ke(r),i=Ke(n);if(!o)return!1;const a=o&&Ke(Xe),c=o&&("function"==typeof Qe?(l=new Qe,e=>l.encode(e)):async e=>new Uint8Array(await new r(e).arrayBuffer()));var l;const u=s&&a&&Ze(()=>{let e=!1;const t=new r(ve.origin,{body:new Xe,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=i&&a&&Ze(()=>Y.isReadableStream(new n("").body)),h={stream:d&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!h[e]&&(h[e]=(t,r)=>{let n=t&&t[e];if(n)return n.call(t);throw new ee(`Response type '${e}' is not supported`,ee.ERR_NOT_SUPPORT,r)})});const f=async(e,t)=>{const n=Y.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Y.isBlob(e))return e.size;if(Y.isSpecCompliantForm(e)){const t=new r(ve.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Y.isArrayBufferView(e)||Y.isArrayBuffer(e)?e.byteLength:(Y.isURLSearchParams(e)&&(e+=""),Y.isString(e)?(await c(e)).byteLength:void 0)})(t):n};return async e=>{let{url:o,method:i,data:a,signal:c,cancelToken:l,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:y,headers:b,withCredentials:w="same-origin",fetchOptions:E}=Ve(e),v=t||fetch;y=y?(y+"").toLowerCase():"text";let O=ze([c,l&&l.toAbortSignal()],p),S=null;const R=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let T;try{if(g&&u&&"get"!==i&&"head"!==i&&0!==(T=await f(b,a))){let e,t=new r(o,{method:"POST",body:a,duplex:"half"});if(Y.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,r]=Le(T,Ue(De(g)));a=We(t.body,65536,e,r)}}Y.isString(w)||(w=w?"include":"omit");const t=s&&"credentials"in r.prototype,c={...E,signal:O,method:i.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?w:void 0};S=s&&new r(o,c);let l=await(s?v(S,E):v(o,c));const p=d&&("stream"===y||"response"===y);if(d&&(m||p&&R)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=l[t]});const t=Y.toFiniteNumber(l.headers.get("content-length")),[r,o]=m&&Le(t,Ue(De(m),!0))||[];l=new n(We(l.body,65536,r,()=>{o&&o(),R&&R()}),e)}y=y||"text";let A=await h[Y.findKey(h,y)||"text"](l,e);return!p&&R&&R(),await new Promise((t,r)=>{Pe(t,r,{data:A,headers:je.from(l.headers),status:l.status,statusText:l.statusText,config:e,request:S})})}catch(t){if(R&&R(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new ee("Network Error",ee.ERR_NETWORK,e,S),{cause:t.cause||t});throw ee.from(t,t&&t.code,e,S)}}},et=new Map,tt=e=>{let t=e?e.env:{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i,a,c=s.length,l=et;for(;c--;)i=s[c],a=l.get(i),void 0===a&&l.set(i,a=c?new Map:Ye(t)),l=a;return a};tt();const rt={http:null,xhr:He,fetch:{get:tt}};Y.forEach(rt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const nt=e=>`- ${e}`,ot=e=>Y.isFunction(e)||null===e||!1===e;var st=(e,t)=>{e=Y.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let i=0;i<r;i++){let r;if(n=e[i],o=n,!ot(n)&&(o=rt[(r=String(n)).toLowerCase()],void 0===o))throw new ee(`Unknown adapter '${r}'`);if(o&&(Y.isFunction(o)||(o=o.get(t))))break;s[r||"#"+i]=o}if(!o){const e=Object.entries(s).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new ee("There is no suitable adapter to dispatch the request "+(r?e.length>1?"since :\n"+e.map(nt).join("\n"):" "+nt(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o};function it(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new _e(null,e)}function at(e){it(e),e.headers=je.from(e.headers),e.data=Ne.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return st(e.adapter||Se.adapter,e)(e).then(function(t){return it(e),t.data=Ne.call(e,e.transformResponse,t),t.headers=je.from(t.headers),t},function(t){return Ce(t)||(it(e),t&&t.response&&(t.response.data=Ne.call(e,e.transformResponse,t.response),t.response.headers=je.from(t.response.headers))),Promise.reject(t)})}const ct="1.12.2",lt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{lt[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const ut={};lt.transitional=function(e,t,r){function n(e,t){return"[Axios v"+ct+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,o,s)=>{if(!1===e)throw new ee(n(o," has been removed"+(t?" in "+t:"")),ee.ERR_DEPRECATED);return t&&!ut[o]&&(ut[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,s)}},lt.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var dt={assertOptions:function(e,t,r){if("object"!=typeof e)throw new ee("options must be an object",ee.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const t=e[s],r=void 0===t||i(t,s,e);if(!0!==r)throw new ee("option "+s+" must be "+r,ee.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new ee("Unknown option "+s,ee.ERR_BAD_OPTION)}},validators:lt};const ht=dt.validators;let ft=class{constructor(e){this.defaults=e||{},this.interceptors={request:new fe,response:new fe}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Me(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;void 0!==r&&dt.assertOptions(r,{silentJSONParsing:ht.transitional(ht.boolean),forcedJSONParsing:ht.transitional(ht.boolean),clarifyTimeoutError:ht.transitional(ht.boolean)},!1),null!=n&&(Y.isFunction(n)?t.paramsSerializer={serialize:n}:dt.assertOptions(n,{encode:ht.function,serialize:ht.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),dt.assertOptions(t,{baseUrl:ht.spelling("baseURL"),withXsrfToken:ht.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&Y.merge(o.common,o[t.method]);o&&Y.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=je.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,d=0;if(!a){const e=[at.bind(this),void 0];for(e.unshift(...i),e.push(...c),u=e.length,l=Promise.resolve(t);d<u;)l=l.then(e[d++],e[d++]);return l}u=i.length;let h=t;for(;d<u;){const e=i[d++],t=i[d++];try{h=e(h)}catch(e){t.call(this,e);break}}try{l=at.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)l=l.then(c[d++],c[d++]);return l}getUri(e){return he(Ie((e=Me(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(e){ft.prototype[e]=function(t,r){return this.request(Me(r||{},{method:e,url:t,data:(r||{}).data}))}}),Y.forEach(["post","put","patch"],function(e){function t(t){return function(r,n,o){return this.request(Me(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ft.prototype[e]=t(),ft.prototype[e+"Form"]=t(!0)});const pt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(pt).forEach(([e,t])=>{pt[t]=e});const mt=function e(t){const r=new ft(t),n=l(ft.prototype.request,r);return Y.extend(n,ft.prototype,r,{allOwnKeys:!0}),Y.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(Me(t,r))},n}(Se);mt.Axios=ft,mt.CanceledError=_e,mt.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,o){r.reason||(r.reason=new _e(e,n,o),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},mt.isCancel=Ce,mt.VERSION=ct,mt.toFormData=ae,mt.AxiosError=ee,mt.Cancel=mt.CanceledError,mt.all=function(e){return Promise.all(e)},mt.spread=function(e){return function(t){return e.apply(null,t)}},mt.isAxiosError=function(e){return Y.isObject(e)&&!0===e.isAxiosError},mt.mergeConfig=Me,mt.AxiosHeaders=je,mt.formToJSON=e=>Oe(Y.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=st,mt.HttpStatusCode=pt,mt.default=mt;const{Axios:gt,AxiosError:yt,CanceledError:bt,isCancel:wt,CancelToken:Et,VERSION:vt,all:Ot,Cancel:St,isAxiosError:Rt,spread:Tt,toFormData:At,AxiosHeaders:xt,HttpStatusCode:kt,formToJSON:jt,getAdapter:Nt,mergeConfig:Ct}=mt;const _t=c.getInstance();_t.register(new class extends n{debug(e,t){this.isLogEnabled()&&console.log(`[DEBUG] ${e}`,t||"")}error(e,t){this.isLogEnabled()&&console.error(`[ERROR] ${e}`,t||"")}info(e,t){this.isLogEnabled()&&console.info(`[INFO] ${e}`,t||"")}warn(e,t){this.isLogEnabled()&&console.warn(`[WARN] ${e}`,t||"")}isLogEnabled(){return!1!==c.getInstance().config.get("logger.enabled")}}),_t.register(new class extends r{constructor(){super(...arguments),this.interceptorsSetup=!1}get axiosInstance(){return this._axiosInstance||(this._axiosInstance=mt.create()),this._axiosInstance}async send(e){const t=c.getInstance(),r=t.config;this.interceptorsSetup||(this.setupInterceptors(),this.interceptorsSetup=!0);try{let n={...this.getDefaultConfig(r),...this.convertToAxiosConfig(e)};const o=(e.method||"GET").toUpperCase();n=await t.hook.execute(`request.before.method:${o}`,n),n=await t.hook.execute("request.before",n);const s=await this.axiosInstance.request(n);let i=this.convertResponse(s);return i=await t.hook.execute(`request.response.status:${s.status}`,i),i=await t.hook.execute("request.response",i),i}catch(e){let r=this.handleError(e);throw e.response&&(r=await t.hook.execute(`request.error.status:${e.response.status}`,r)),r=await t.hook.execute("request.error",r),r}}setupInterceptors(){this.axiosInstance.interceptors.request.use(e=>e,e=>Promise.reject(e)),this.axiosInstance.interceptors.response.use(e=>e,e=>Promise.reject(e))}getDefaultConfig(e){const t={},r=e.get("request.baseURL");r&&(t.baseURL=r);const n=e.get("request.timeout");n&&(t.timeout=n);const o=e.get("request.headers");return o&&(t.headers=o),t}convertToAxiosConfig(e){const t={url:e.url,method:e.method||"GET"};return void 0!==e.timeout&&(t.timeout=e.timeout),e.responseType&&(t.responseType=e.responseType),e.header&&Object.keys(e.header).length>0&&(t.headers=e.header),e.params&&Object.keys(e.params).length>0&&(t.params=e.params),e.data&&Object.keys(e.data).length>0&&(t.data=e.data),e.onDownloadProgress&&(t.onDownloadProgress=e.onDownloadProgress),t}convertResponse(e){const t=e.headers&&"object"==typeof e.headers?{...e.headers}:e.headers;return{data:e.data,status:e.status,statusText:e.statusText,headers:t,config:{url:e.config.url,method:e.config.method,timeout:e.config.timeout}}}handleError(e){if(e.response){const{status:t,statusText:r,data:n,headers:o,config:s}=e.response,i=new Error(`请求失败: ${t} ${r}`);return i.status=t,i.statusText=r,i.data=n,i.headers=o&&"object"==typeof o?{...o}:o,i.config={url:null==s?void 0:s.url,method:null==s?void 0:s.method,timeout:null==s?void 0:s.timeout},i}if(e.request){const t=new Error("网络请求超时或无法连接到服务器");return t.request=e.request,t}return new Error(`请求配置错误: ${e.message}`)}async get(e,t){return this.send({url:e,method:"GET",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async post(e,t,r){return this.send({url:e,method:"POST",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}async put(e,t,r){return this.send({url:e,method:"PUT",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}async delete(e,t){return this.send({url:e,method:"DELETE",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async patch(e,t,r){return this.send({url:e,method:"PATCH",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}}),_t.register(new class extends s{getNestedValue(e,t){return t.reduce((e,t)=>null==e?void 0:e[t],e)}setNestedValue(e,t,r){const n=t[t.length-1];t.slice(0,-1).reduce((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t]),e)[n]=r}deleteNestedValue(e,t){if(0===t.length)return!1;const r=t[t.length-1],n=t.slice(0,-1),o=this.getNestedValue(e,n);return!(!o||"object"!=typeof o||!(r in o))&&(delete o[r],!0)}set(e,t){const r=e.split(".");if(1===r.length)localStorage.setItem(e,JSON.stringify(t));else{const e=r[0],n=localStorage.getItem(e);let o;try{o=n?JSON.parse(n):{},("object"!=typeof o||null===o||Array.isArray(o))&&(o={})}catch(e){o={}}this.setNestedValue(o,r.slice(1),t),localStorage.setItem(e,JSON.stringify(o))}}get(e){if(!e){const e={};for(let t=0;t<localStorage.length;t++){const r=localStorage.key(t);if(r)try{e[r]=JSON.parse(localStorage.getItem(r))}catch(t){e[r]=localStorage.getItem(r)}}return e}const t=e.split("."),r=t[0],n=localStorage.getItem(r);if(!n)return null;try{const e=JSON.parse(n);return 1===t.length?e:this.getNestedValue(e,t.slice(1))}catch(e){return n}}remove(e){const t=e.split(".");if(1===t.length)localStorage.removeItem(e);else{const e=t[0],r=localStorage.getItem(e);if(r)try{const n=JSON.parse(r);this.deleteNestedValue(n,t.slice(1))&&localStorage.setItem(e,JSON.stringify(n))}catch(e){}}}clear(){localStorage.clear()}keys(){return Object.keys(localStorage)}has(e){const t=e.split("."),r=t[0],n=localStorage.getItem(r);if(!n)return!1;if(1===t.length)return!0;try{const e=JSON.parse(n);return void 0!==this.getNestedValue(e,t.slice(1))}catch(e){return!1}}}),_t.register(new class extends i{form(e){var t;const r=c.getInstance().config.get("request.baseURL");try{let n=e.url;if(r&&!e.url.startsWith("http://")&&!e.url.startsWith("https://")){const t=r.endsWith("/")||e.url.startsWith("/")?"":"/";n=r+t+e.url}const o=document.createElement("form");if(o.method=e.method||"POST",o.action=n,o.style.display="none",null===(t=e.header)||void 0===t?void 0:t.Authorization){const t=document.createElement("a");t.href=n;const r=new URLSearchParams(t.search);r.set("Authorization",e.header.Authorization),t.search=r.toString(),o.action=t.href}if(e.params){const t=document.createElement("a");t.href=o.action;const r=new URLSearchParams(t.search);Object.entries(e.params).forEach(([e,t])=>{r.set(e,String(t))}),t.search=r.toString(),o.action=t.href}if(e.data&&Object.entries(e.data).forEach(([e,t])=>{const r=document.createElement("input");r.type="hidden",r.name=e,r.value=String(t),o.appendChild(r)}),document.body.appendChild(o),o.submit(),document.body.removeChild(o),e.onSuccess){const t={filename:"Unknown",size:0,type:"application/octet-stream",duration:0,blob:new Blob,url:n,autoDownloaded:!0};e.onSuccess(t)}}catch(t){const r=new Error(`Form download failed: ${t.message}`);throw e.onError&&e.onError(r),r}}async download(e){const t=c.getInstance().request,r=Date.now();try{const n=await t.send({url:e.url,method:e.method||"GET",header:e.header,params:e.params,data:e.data,timeout:e.timeout,responseType:"blob",onDownloadProgress:t=>{if(e.onProgress&&t.total>0){const n=this.calculateProgress(t,r);e.onProgress(n)}}});let o;if(console.log(n.headers),n.data instanceof Blob)o=n.data;else if(n.data instanceof ArrayBuffer){const e=n.headers["content-type"]||"application/octet-stream";o=new Blob([n.data],{type:e})}else{const e=n.headers["content-type"]||"application/octet-stream";o=new Blob([n.data],{type:e})}const s=this.extractFilename(e.filename,n.headers,e.url),i=o.type||"application/octet-stream",a=o.size,c={filename:s,size:a,type:i,duration:Date.now()-r,blob:o,url:e.url};if(!1!==e.autoDownload){const t=e.downloadMethod||"both",r=this.createDownloadLink(c,t);c.downloadUrl=r.url,c.autoDownloaded=r.triggered}return e.onSuccess&&e.onSuccess(c),c}catch(t){let r;throw r=t.response?new Error(`Download failed: ${t.response.status} ${t.response.statusText}`):t.request?new Error("Network timeout or unable to connect to server"):new Error(`Download configuration error: ${t.message}`),e.onError&&e.onError(r),r}}calculateProgress(e,t){const r=e.loaded,n=e.total,o=n>0?Math.round(r/n*100):0,s=(Date.now()-t)/1e3,i=s>0?r/s:0;return{loaded:r,total:n,percentage:o,speed:i,remainingTime:i>0?(n-r)/i:0}}extractFilename(e,t,r){if(e)return e;const n=(null==t?void 0:t["content-disposition"])||(null==t?void 0:t["Content-Disposition"]);if(n){const e=n.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(e&&e[1])return e[1].replace(/['"]/g,"")}if(r)try{let e;e=r.startsWith("http://")||r.startsWith("https://")?new URL(r).pathname:r;const t=e.split("/").pop();if(t&&t.includes("."))return t}catch(e){const t=r.split("/").pop();if(t&&t.includes("."))return t}return`download_${Date.now()}`}createDownloadLink(e,t){try{if(!(e.blob&&e.blob instanceof Blob))throw new Error("Invalid blob data for download");if(0===e.blob.size)throw new Error("Empty blob data");const r=URL.createObjectURL(e.blob);let n=!1;return"link"!==t&&"both"!==t||(this.triggerDownload(r,e.filename),n=!0),{url:r,triggered:n}}catch(e){return console.error("Failed to create download link:",e),{url:"",triggered:!1}}}triggerDownload(e,t){try{const r=document.createElement("a");r.href=e,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(e)},1e3)}catch(e){console.error("Failed to trigger download:",e)}}}),_t.register(new class extends a{constructor(){super(...arguments),this.interfaceType="IHook",this.registry=new Map}init(e){for(const[t,r]of Object.entries(e))Array.isArray(r)?r.forEach(e=>this.register(t,e)):this.register(t,r)}register(e,t){if(!this.isValidHookKey(e))return void this.logWarning(`Invalid hook key: ${e}`);if("function"!=typeof t)return void this.logWarning(`Handler must be a function for hook key: ${e}`);const r=this.registry.get(e)||[];r.push(t),this.registry.set(e,r)}unregister(e,t){if(!t)return void this.registry.delete(e);const r=this.registry.get(e);if(r){const n=r.indexOf(t);n>-1&&r.splice(n,1),0===r.length&&this.registry.delete(e)}}async execute(e,t){const r=this.findMatchingHandlers(e,t);if(0===r.length)return t;let n=t;for(const o of r)try{const e=o(n);n=e instanceof Promise?await e:e,void 0===n&&(n=t)}catch(t){this.logError(`Error executing hook ${e}:`,t)}return n}has(e){return this.registry.has(e)&&this.registry.get(e).length>0}clear(){this.registry.clear()}findMatchingHandlers(e,t){const r=[];for(const[n,o]of this.registry)this.isKeyMatch(n,e,t)&&r.push(...o);return r}isKeyMatch(e,t,r){if(e===t)return!0;const[n,o]=this.parseHookKey(e),[s,i]=this.parseHookKey(t);return n===s&&(!o||!!i&&o.value===i.value)}parseHookKey(e){const t=e.lastIndexOf(":");if(-1===t)return[e,null];const r=e.substring(0,t),n=e.substring(t+1),o=r.split(".");return[r,{field:o[o.length-1],value:n}]}isValidHookKey(e){return"string"==typeof e&&e.length>0}logWarning(e){c.getInstance().logger.warn(`[Hook] ${e}`)}logError(e,t){c.getInstance().logger.error(`[Hook] ${e}`,t)}}),"undefined"!=typeof window&&(window.kivii=_t),e.Kivii=c,e.MockRequest=class extends r{async send(e){const t=c.getInstance().config.get("mock");if(!t)throw new Error("Mock data not configured");const r=e.url||"",n=r.split("/").filter(e=>e&&""!==e);let o=t;for(const t of n){if(!o||"object"!=typeof o||!(t in o)){o=void 0;break}o="function"==typeof o[t]?o[t]({method:e.method,params:e.params,data:e.data}):o[t]}if(void 0===o)throw new Error(`Mock data not found for URL: ${r}`);return{data:o,status:200,statusText:"OK",headers:{},config:e}}async get(e,t){return this.send({url:e,method:"GET",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async post(e,t,r){return this.send({url:e,method:"POST",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}async put(e,t,r){return this.send({url:e,method:"PUT",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}async delete(e,t){return this.send({url:e,method:"DELETE",header:(null==t?void 0:t.header)||{},params:(null==t?void 0:t.params)||{},data:(null==t?void 0:t.data)||{},timeout:null==t?void 0:t.timeout})}async patch(e,t,r){return this.send({url:e,method:"PATCH",header:(null==r?void 0:r.header)||{},params:(null==r?void 0:r.params)||{},data:t||{},timeout:null==r?void 0:r.timeout})}},e.default=_t,e.kivii=_t,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=kivii.bridge.min.js.map