xiaozuoassistant 0.1.44 → 0.1.47

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/bin/cli.js CHANGED
@@ -23,6 +23,7 @@ const packageRoot = path.resolve(__dirname, '..');
23
23
 
24
24
  const args = process.argv.slice(2);
25
25
  const command = args[0];
26
+ const commandArgs = args.slice(1);
26
27
 
27
28
  const EXPORT_FILENAME = 'xiaozuoAssistant-backup.tar.gz';
28
29
 
@@ -58,6 +59,22 @@ function getPidFilePath() {
58
59
  return path.join(CWD, 'logs', 'server.pid');
59
60
  }
60
61
 
62
+ function hasFlag(flag) {
63
+ return commandArgs.includes(flag);
64
+ }
65
+
66
+ function getFlagValue(name) {
67
+ const idx = commandArgs.findIndex(a => a === name);
68
+ if (idx < 0) return null;
69
+ const next = commandArgs[idx + 1];
70
+ if (!next || next.startsWith('-')) return null;
71
+ return next;
72
+ }
73
+
74
+ function getRegistry() {
75
+ return getFlagValue('--registry') || process.env.npm_config_registry || 'https://registry.npmjs.org';
76
+ }
77
+
61
78
  function isProcessRunning(pid) {
62
79
  try {
63
80
  process.kill(pid, 0);
@@ -186,6 +203,131 @@ async function stopServer() {
186
203
  console.error('[CLI] ❌ 停止失败:端口仍在占用。');
187
204
  }
188
205
 
206
+ async function runCommand(cmd, cmdArgs, options = {}) {
207
+ const child = spawn(cmd, cmdArgs, { stdio: 'inherit', ...options });
208
+ const code = await new Promise((resolve) => child.on('close', resolve));
209
+ return typeof code === 'number' ? code : 1;
210
+ }
211
+
212
+ async function runWithSudoIfNeeded(cmd, cmdArgs, options = {}) {
213
+ const code = await runCommand(cmd, cmdArgs, options);
214
+ if (code === 0) return 0;
215
+
216
+ const canSudo = process.platform !== 'win32' && process.stdin.isTTY;
217
+ if (!canSudo) return code;
218
+
219
+ console.log('[CLI] 权限不足,尝试使用 sudo 继续...');
220
+ return await runCommand('sudo', [cmd, ...cmdArgs], options);
221
+ }
222
+
223
+ async function updateApp() {
224
+ const registry = getRegistry();
225
+ const port = getPortFromConfig();
226
+ const pidFile = getPidFilePath();
227
+
228
+ const runningByPid = fs.existsSync(pidFile) && (() => {
229
+ try {
230
+ const pid = Number(fs.readFileSync(pidFile, 'utf-8').trim());
231
+ return Number.isFinite(pid) && pid > 0 && isProcessRunning(pid);
232
+ } catch {
233
+ return false;
234
+ }
235
+ })();
236
+ const runningByPort = await isPortOpen(port);
237
+ const wasRunning = runningByPid || runningByPort;
238
+
239
+ if (wasRunning) {
240
+ console.log('[CLI] 检测到服务正在运行,更新前将自动停止...');
241
+ await stopServer();
242
+ }
243
+
244
+ console.log(`[CLI] 正在更新 xiaozuoassistant(registry=${registry})...`);
245
+ const code = await runWithSudoIfNeeded('npm', ['install', '-g', 'xiaozuoassistant@latest', `--registry=${registry}`]);
246
+ if (code !== 0) {
247
+ console.error('[CLI] ❌ 更新失败。');
248
+ if (wasRunning) {
249
+ console.log('[CLI] 更新失败,尝试恢复启动旧版本服务...');
250
+ await runCommand('node', [path.join(packageRoot, 'bin', 'cli.js'), 'start'], { cwd: CWD });
251
+ }
252
+ process.exit(code);
253
+ }
254
+
255
+ console.log('[CLI] ✅ 更新完成。');
256
+
257
+ if (wasRunning) {
258
+ console.log('[CLI] 正在自动重启服务...');
259
+ const restartCode = await runCommand('xiaozuoAssistant', ['start'], { cwd: CWD });
260
+ process.exit(restartCode);
261
+ }
262
+ }
263
+
264
+ async function removeApp() {
265
+ const registry = getRegistry();
266
+ const targets = ['config.json', 'memories', 'data', 'logs', 'sessions', 'workspace']
267
+ .map(p => path.join(CWD, p));
268
+
269
+ const doRemove = async () => {
270
+ await stopServer();
271
+
272
+ console.log('[CLI] 正在删除本地数据(当前目录)...');
273
+ for (const target of targets) {
274
+ try {
275
+ if (fs.existsSync(target)) {
276
+ fs.rmSync(target, { recursive: true, force: true });
277
+ console.log(`[CLI] 已删除:${target}`);
278
+ }
279
+ } catch (e) {
280
+ console.error(`[CLI] 删除失败:${target}`);
281
+ console.error(e);
282
+ }
283
+ }
284
+
285
+ console.log('[CLI] 正在卸载全局包 xiaozuoassistant...');
286
+ const code = await runWithSudoIfNeeded('npm', ['uninstall', '-g', 'xiaozuoassistant', `--registry=${registry}`]);
287
+ if (code !== 0) {
288
+ console.error('[CLI] ❌ 卸载失败。');
289
+ process.exit(code);
290
+ }
291
+
292
+ console.log('[CLI] ✅ 已卸载并清理数据。');
293
+ };
294
+
295
+ if (hasFlag('--yes') || hasFlag('-y')) {
296
+ await doRemove();
297
+ return;
298
+ }
299
+
300
+ console.log('[CLI] remove 将执行以下操作:');
301
+ console.log(' 1) 停止后台服务');
302
+ console.log(' 2) 删除当前目录下的数据:');
303
+ for (const target of targets) console.log(` - ${target}`);
304
+ console.log(' 3) 卸载全局 npm 包:xiaozuoassistant');
305
+ process.stdout.write('确认继续?(y/N) ');
306
+ process.stdin.once('data', async (data) => {
307
+ const answer = data.toString().trim().toLowerCase();
308
+ if (answer === 'y' || answer === 'yes') {
309
+ await doRemove();
310
+ } else {
311
+ console.log('已取消。');
312
+ }
313
+ process.exit(0);
314
+ });
315
+ }
316
+
317
+ function printVersion() {
318
+ try {
319
+ const pkgPath = path.join(packageRoot, 'package.json');
320
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
321
+ console.log(`${pkg.name}@${pkg.version}`);
322
+ console.log('Package Root:', packageRoot);
323
+ console.log('Node Version:', process.version);
324
+ } catch {
325
+ console.log('xiaozuoassistant@unknown');
326
+ console.log('Package Root:', packageRoot);
327
+ console.log('Node Version:', process.version);
328
+ }
329
+ }
330
+
189
331
  async function exportData() {
190
332
  console.log('📦 Starting data export...');
191
333
 
@@ -420,6 +562,12 @@ if (command === 'start') {
420
562
  console.log('Package Root:', packageRoot);
421
563
  console.log('Node Version:', process.version);
422
564
  console.log('Doctor check complete.');
565
+ } else if (command === 'version') {
566
+ printVersion();
567
+ } else if (command === 'update') {
568
+ updateApp();
569
+ } else if (command === 'remove') {
570
+ removeApp();
423
571
  } else if (command === 'export') {
424
572
  exportData();
425
573
  } else if (command === 'import') {
@@ -432,6 +580,9 @@ if (command === 'start') {
432
580
  console.log(' start Start the xiaozuoAssistant server');
433
581
  console.log(' stop Stop the xiaozuoAssistant server');
434
582
  console.log(' doctor Check the health and configuration');
583
+ console.log(' version Print package version and environment');
584
+ console.log(' update Update xiaozuoassistant and auto-restart if running');
585
+ console.log(' remove Uninstall and delete data in current directory');
435
586
  console.log(' export Backup local data (config, memories) to a file');
436
587
  console.log(' import Restore data from a backup file');
437
588
  }
@@ -1,2 +1,2 @@
1
- import{c as R,g as z}from"./index-BPATxdcV.js";function X(w,d){for(var b=0;b<d.length;b++){const y=d[b];if(typeof y!="string"&&!Array.isArray(y)){for(const h in y)if(h!=="default"&&!(h in w)){const p=Object.getOwnPropertyDescriptor(y,h);p&&Object.defineProperty(w,h,p.get?p:{enumerable:!0,get:()=>y[h]})}}}return Object.freeze(Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}))}var A={exports:{}},U;function J(){return U||(U=1,(function(w,d){var b=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof R<"u"&&R,y=(function(){function p(){this.fetch=!1,this.DOMException=b.DOMException}return p.prototype=b,new p})();(function(p){(function(u){var a=typeof p<"u"&&p||typeof self<"u"&&self||typeof a<"u"&&a,f={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function S(e){return e&&DataView.prototype.isPrototypeOf(e)}if(f.arrayBuffer)var F=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(e){return e&&F.indexOf(Object.prototype.toString.call(e))>-1};function v(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function E(e){return typeof e!="string"&&(e=String(e)),e}function T(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return f.iterable&&(t[Symbol.iterator]=function(){return t}),t}function s(e){this.map={},e instanceof s?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}s.prototype.append=function(e,t){e=v(e),t=E(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},s.prototype.delete=function(e){delete this.map[v(e)]},s.prototype.get=function(e){return e=v(e),this.has(e)?this.map[e]:null},s.prototype.has=function(e){return this.map.hasOwnProperty(v(e))},s.prototype.set=function(e,t){this.map[v(e)]=E(t)},s.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},s.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),T(e)},s.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),T(e)},s.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),T(e)},f.iterable&&(s.prototype[Symbol.iterator]=s.prototype.entries);function B(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function P(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function M(e){var t=new FileReader,r=P(t);return t.readAsArrayBuffer(e),r}function q(e){var t=new FileReader,r=P(t);return t.readAsText(e),r}function H(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function D(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function x(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:f.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:f.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():f.arrayBuffer&&f.blob&&S(e)?(this._bodyArrayBuffer=D(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||I(e))?this._bodyArrayBuffer=D(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=B(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return q(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(H(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function C(e){var t=e.toUpperCase();return L.indexOf(t)>-1?t:e}function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new s(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new s(t.headers)),this.method=C(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})};function k(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),i=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(o))}}),t}function N(e){var t=new s,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
1
+ import{c as R,g as z}from"./index-BfEuvtsz.js";function X(w,d){for(var b=0;b<d.length;b++){const y=d[b];if(typeof y!="string"&&!Array.isArray(y)){for(const h in y)if(h!=="default"&&!(h in w)){const p=Object.getOwnPropertyDescriptor(y,h);p&&Object.defineProperty(w,h,p.get?p:{enumerable:!0,get:()=>y[h]})}}}return Object.freeze(Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}))}var A={exports:{}},U;function J(){return U||(U=1,(function(w,d){var b=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof R<"u"&&R,y=(function(){function p(){this.fetch=!1,this.DOMException=b.DOMException}return p.prototype=b,new p})();(function(p){(function(u){var a=typeof p<"u"&&p||typeof self<"u"&&self||typeof a<"u"&&a,f={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function S(e){return e&&DataView.prototype.isPrototypeOf(e)}if(f.arrayBuffer)var F=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(e){return e&&F.indexOf(Object.prototype.toString.call(e))>-1};function v(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function E(e){return typeof e!="string"&&(e=String(e)),e}function T(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return f.iterable&&(t[Symbol.iterator]=function(){return t}),t}function s(e){this.map={},e instanceof s?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}s.prototype.append=function(e,t){e=v(e),t=E(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},s.prototype.delete=function(e){delete this.map[v(e)]},s.prototype.get=function(e){return e=v(e),this.has(e)?this.map[e]:null},s.prototype.has=function(e){return this.map.hasOwnProperty(v(e))},s.prototype.set=function(e,t){this.map[v(e)]=E(t)},s.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},s.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),T(e)},s.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),T(e)},s.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),T(e)},f.iterable&&(s.prototype[Symbol.iterator]=s.prototype.entries);function B(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function P(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function M(e){var t=new FileReader,r=P(t);return t.readAsArrayBuffer(e),r}function q(e){var t=new FileReader,r=P(t);return t.readAsText(e),r}function H(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function D(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function x(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:f.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:f.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():f.arrayBuffer&&f.blob&&S(e)?(this._bodyArrayBuffer=D(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||I(e))?this._bodyArrayBuffer=D(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=B(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return q(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(H(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function C(e){var t=e.toUpperCase();return L.indexOf(t)>-1?t:e}function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new s(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new s(t.headers)),this.method=C(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})};function k(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),i=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(o))}}),t}function N(e){var t=new s,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
2
2
  `)===0?n.substr(1,n.length):n}).forEach(function(n){var i=n.split(":"),o=i.shift().trim();if(o){var _=i.join(":").trim();t.append(o,_)}}),t}x.call(m.prototype);function c(e,t){if(!(this instanceof c))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new s(t.headers),this.url=t.url||"",this._initBody(e)}x.call(c.prototype),c.prototype.clone=function(){return new c(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new s(this.headers),url:this.url})},c.error=function(){var e=new c(null,{status:0,statusText:""});return e.type="error",e};var G=[301,302,303,307,308];c.redirect=function(e,t){if(G.indexOf(t)===-1)throw new RangeError("Invalid status code");return new c(null,{status:t,headers:{location:e}})},u.DOMException=a.DOMException;try{new u.DOMException}catch{u.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function O(e,t){return new Promise(function(r,n){var i=new m(e,t);if(i.signal&&i.signal.aborted)return n(new u.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function _(){o.abort()}o.onload=function(){var l={status:o.status,statusText:o.statusText,headers:N(o.getAllResponseHeaders()||"")};l.url="responseURL"in o?o.responseURL:l.headers.get("X-Request-URL");var g="response"in o?o.response:o.responseText;setTimeout(function(){r(new c(g,l))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.onabort=function(){setTimeout(function(){n(new u.DOMException("Aborted","AbortError"))},0)};function V(l){try{return l===""&&a.location.href?a.location.href:l}catch{return l}}o.open(i.method,V(i.url),!0),i.credentials==="include"?o.withCredentials=!0:i.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(f.blob?o.responseType="blob":f.arrayBuffer&&i.headers.get("Content-Type")&&i.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof s)?Object.getOwnPropertyNames(t.headers).forEach(function(l){o.setRequestHeader(l,E(t.headers[l]))}):i.headers.forEach(function(l,g){o.setRequestHeader(g,l)}),i.signal&&(i.signal.addEventListener("abort",_),o.onreadystatechange=function(){o.readyState===4&&i.signal.removeEventListener("abort",_)}),o.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}return O.polyfill=!0,a.fetch||(a.fetch=O,a.Headers=s,a.Request=m,a.Response=c),u.Headers=s,u.Request=m,u.Response=c,u.fetch=O,u})({})})(y),y.fetch.ponyfill=!0,delete y.fetch.polyfill;var h=b.fetch?b:y;d=h.fetch,d.default=h.fetch,d.fetch=h.fetch,d.Headers=h.Headers,d.Request=h.Request,d.Response=h.Response,w.exports=d})(A,A.exports)),A.exports}var j=J();const K=z(j),W=X({__proto__:null,default:K},[j]);export{W as b};