@openc3/js-common 6.2.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4216 @@
1
+ var Zt = Object.defineProperty;
2
+ var Qt = (n, e, t) => e in n ? Zt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var v = (n, e, t) => Qt(n, typeof e != "symbol" ? e + "" : e, t);
4
+ function gt(n, e) {
5
+ return function() {
6
+ return n.apply(e, arguments);
7
+ };
8
+ }
9
+ const { toString: Yt } = Object.prototype, { getPrototypeOf: $e } = Object, de = /* @__PURE__ */ ((n) => (e) => {
10
+ const t = Yt.call(e);
11
+ return n[t] || (n[t] = t.slice(8, -1).toLowerCase());
12
+ })(/* @__PURE__ */ Object.create(null)), $ = (n) => (n = n.toLowerCase(), (e) => de(e) === n), fe = (n) => (e) => typeof e === n, { isArray: K } = Array, Y = fe("undefined");
13
+ function en(n) {
14
+ return n !== null && !Y(n) && n.constructor !== null && !Y(n.constructor) && N(n.constructor.isBuffer) && n.constructor.isBuffer(n);
15
+ }
16
+ const bt = $("ArrayBuffer");
17
+ function tn(n) {
18
+ let e;
19
+ return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(n) : e = n && n.buffer && bt(n.buffer), e;
20
+ }
21
+ const nn = fe("string"), N = fe("function"), yt = fe("number"), pe = (n) => n !== null && typeof n == "object", sn = (n) => n === !0 || n === !1, ce = (n) => {
22
+ if (de(n) !== "object")
23
+ return !1;
24
+ const e = $e(n);
25
+ return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(Symbol.toStringTag in n) && !(Symbol.iterator in n);
26
+ }, rn = $("Date"), on = $("File"), cn = $("Blob"), an = $("FileList"), ln = (n) => pe(n) && N(n.pipe), un = (n) => {
27
+ let e;
28
+ return n && (typeof FormData == "function" && n instanceof FormData || N(n.append) && ((e = de(n)) === "formdata" || // detect form-data instance
29
+ e === "object" && N(n.toString) && n.toString() === "[object FormData]"));
30
+ }, hn = $("URLSearchParams"), [dn, fn, pn, mn] = ["ReadableStream", "Request", "Response", "Headers"].map($), gn = (n) => n.trim ? n.trim() : n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
31
+ function ee(n, e, { allOwnKeys: t = !1 } = {}) {
32
+ if (n === null || typeof n > "u")
33
+ return;
34
+ let s, r;
35
+ if (typeof n != "object" && (n = [n]), K(n))
36
+ for (s = 0, r = n.length; s < r; s++)
37
+ e.call(null, n[s], s, n);
38
+ else {
39
+ const i = t ? Object.getOwnPropertyNames(n) : Object.keys(n), o = i.length;
40
+ let c;
41
+ for (s = 0; s < o; s++)
42
+ c = i[s], e.call(null, n[c], c, n);
43
+ }
44
+ }
45
+ function wt(n, e) {
46
+ e = e.toLowerCase();
47
+ const t = Object.keys(n);
48
+ let s = t.length, r;
49
+ for (; s-- > 0; )
50
+ if (r = t[s], e === r.toLowerCase())
51
+ return r;
52
+ return null;
53
+ }
54
+ const H = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, _t = (n) => !Y(n) && n !== H;
55
+ function Oe() {
56
+ const { caseless: n } = _t(this) && this || {}, e = {}, t = (s, r) => {
57
+ const i = n && wt(e, r) || r;
58
+ ce(e[i]) && ce(s) ? e[i] = Oe(e[i], s) : ce(s) ? e[i] = Oe({}, s) : K(s) ? e[i] = s.slice() : e[i] = s;
59
+ };
60
+ for (let s = 0, r = arguments.length; s < r; s++)
61
+ arguments[s] && ee(arguments[s], t);
62
+ return e;
63
+ }
64
+ const bn = (n, e, t, { allOwnKeys: s } = {}) => (ee(e, (r, i) => {
65
+ t && N(r) ? n[i] = gt(r, t) : n[i] = r;
66
+ }, { allOwnKeys: s }), n), yn = (n) => (n.charCodeAt(0) === 65279 && (n = n.slice(1)), n), wn = (n, e, t, s) => {
67
+ n.prototype = Object.create(e.prototype, s), n.prototype.constructor = n, Object.defineProperty(n, "super", {
68
+ value: e.prototype
69
+ }), t && Object.assign(n.prototype, t);
70
+ }, _n = (n, e, t, s) => {
71
+ let r, i, o;
72
+ const c = {};
73
+ if (e = e || {}, n == null) return e;
74
+ do {
75
+ for (r = Object.getOwnPropertyNames(n), i = r.length; i-- > 0; )
76
+ o = r[i], (!s || s(o, n, e)) && !c[o] && (e[o] = n[o], c[o] = !0);
77
+ n = t !== !1 && $e(n);
78
+ } while (n && (!t || t(n, e)) && n !== Object.prototype);
79
+ return e;
80
+ }, En = (n, e, t) => {
81
+ n = String(n), (t === void 0 || t > n.length) && (t = n.length), t -= e.length;
82
+ const s = n.indexOf(e, t);
83
+ return s !== -1 && s === t;
84
+ }, Sn = (n) => {
85
+ if (!n) return null;
86
+ if (K(n)) return n;
87
+ let e = n.length;
88
+ if (!yt(e)) return null;
89
+ const t = new Array(e);
90
+ for (; e-- > 0; )
91
+ t[e] = n[e];
92
+ return t;
93
+ }, xn = /* @__PURE__ */ ((n) => (e) => n && e instanceof n)(typeof Uint8Array < "u" && $e(Uint8Array)), Rn = (n, e) => {
94
+ const s = (n && n[Symbol.iterator]).call(n);
95
+ let r;
96
+ for (; (r = s.next()) && !r.done; ) {
97
+ const i = r.value;
98
+ e.call(n, i[0], i[1]);
99
+ }
100
+ }, An = (n, e) => {
101
+ let t;
102
+ const s = [];
103
+ for (; (t = n.exec(e)) !== null; )
104
+ s.push(t);
105
+ return s;
106
+ }, Tn = $("HTMLFormElement"), On = (n) => n.toLowerCase().replace(
107
+ /[-_\s]([a-z\d])(\w*)/g,
108
+ function(t, s, r) {
109
+ return s.toUpperCase() + r;
110
+ }
111
+ ), Je = (({ hasOwnProperty: n }) => (e, t) => n.call(e, t))(Object.prototype), Cn = $("RegExp"), Et = (n, e) => {
112
+ const t = Object.getOwnPropertyDescriptors(n), s = {};
113
+ ee(t, (r, i) => {
114
+ let o;
115
+ (o = e(r, i, n)) !== !1 && (s[i] = o || r);
116
+ }), Object.defineProperties(n, s);
117
+ }, kn = (n) => {
118
+ Et(n, (e, t) => {
119
+ if (N(n) && ["arguments", "caller", "callee"].indexOf(t) !== -1)
120
+ return !1;
121
+ const s = n[t];
122
+ if (N(s)) {
123
+ if (e.enumerable = !1, "writable" in e) {
124
+ e.writable = !1;
125
+ return;
126
+ }
127
+ e.set || (e.set = () => {
128
+ throw Error("Can not rewrite read-only method '" + t + "'");
129
+ });
130
+ }
131
+ });
132
+ }, Nn = (n, e) => {
133
+ const t = {}, s = (r) => {
134
+ r.forEach((i) => {
135
+ t[i] = !0;
136
+ });
137
+ };
138
+ return K(n) ? s(n) : s(String(n).split(e)), t;
139
+ }, Pn = () => {
140
+ }, In = (n, e) => n != null && Number.isFinite(n = +n) ? n : e, Se = "abcdefghijklmnopqrstuvwxyz", We = "0123456789", St = {
141
+ DIGIT: We,
142
+ ALPHA: Se,
143
+ ALPHA_DIGIT: Se + Se.toUpperCase() + We
144
+ }, Ln = (n = 16, e = St.ALPHA_DIGIT) => {
145
+ let t = "";
146
+ const { length: s } = e;
147
+ for (; n--; )
148
+ t += e[Math.random() * s | 0];
149
+ return t;
150
+ };
151
+ function vn(n) {
152
+ return !!(n && N(n.append) && n[Symbol.toStringTag] === "FormData" && n[Symbol.iterator]);
153
+ }
154
+ const jn = (n) => {
155
+ const e = new Array(10), t = (s, r) => {
156
+ if (pe(s)) {
157
+ if (e.indexOf(s) >= 0)
158
+ return;
159
+ if (!("toJSON" in s)) {
160
+ e[r] = s;
161
+ const i = K(s) ? [] : {};
162
+ return ee(s, (o, c) => {
163
+ const h = t(o, r + 1);
164
+ !Y(h) && (i[c] = h);
165
+ }), e[r] = void 0, i;
166
+ }
167
+ }
168
+ return s;
169
+ };
170
+ return t(n, 0);
171
+ }, $n = $("AsyncFunction"), Fn = (n) => n && (pe(n) || N(n)) && N(n.then) && N(n.catch), xt = ((n, e) => n ? setImmediate : e ? ((t, s) => (H.addEventListener("message", ({ source: r, data: i }) => {
172
+ r === H && i === t && s.length && s.shift()();
173
+ }, !1), (r) => {
174
+ s.push(r), H.postMessage(t, "*");
175
+ }))(`axios@${Math.random()}`, []) : (t) => setTimeout(t))(
176
+ typeof setImmediate == "function",
177
+ N(H.postMessage)
178
+ ), Un = typeof queueMicrotask < "u" ? queueMicrotask.bind(H) : typeof process < "u" && process.nextTick || xt, l = {
179
+ isArray: K,
180
+ isArrayBuffer: bt,
181
+ isBuffer: en,
182
+ isFormData: un,
183
+ isArrayBufferView: tn,
184
+ isString: nn,
185
+ isNumber: yt,
186
+ isBoolean: sn,
187
+ isObject: pe,
188
+ isPlainObject: ce,
189
+ isReadableStream: dn,
190
+ isRequest: fn,
191
+ isResponse: pn,
192
+ isHeaders: mn,
193
+ isUndefined: Y,
194
+ isDate: rn,
195
+ isFile: on,
196
+ isBlob: cn,
197
+ isRegExp: Cn,
198
+ isFunction: N,
199
+ isStream: ln,
200
+ isURLSearchParams: hn,
201
+ isTypedArray: xn,
202
+ isFileList: an,
203
+ forEach: ee,
204
+ merge: Oe,
205
+ extend: bn,
206
+ trim: gn,
207
+ stripBOM: yn,
208
+ inherits: wn,
209
+ toFlatObject: _n,
210
+ kindOf: de,
211
+ kindOfTest: $,
212
+ endsWith: En,
213
+ toArray: Sn,
214
+ forEachEntry: Rn,
215
+ matchAll: An,
216
+ isHTMLForm: Tn,
217
+ hasOwnProperty: Je,
218
+ hasOwnProp: Je,
219
+ // an alias to avoid ESLint no-prototype-builtins detection
220
+ reduceDescriptors: Et,
221
+ freezeMethods: kn,
222
+ toObjectSet: Nn,
223
+ toCamelCase: On,
224
+ noop: Pn,
225
+ toFiniteNumber: In,
226
+ findKey: wt,
227
+ global: H,
228
+ isContextDefined: _t,
229
+ ALPHABET: St,
230
+ generateString: Ln,
231
+ isSpecCompliantForm: vn,
232
+ toJSONObject: jn,
233
+ isAsyncFn: $n,
234
+ isThenable: Fn,
235
+ setImmediate: xt,
236
+ asap: Un
237
+ };
238
+ function y(n, e, t, s, r) {
239
+ Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = n, this.name = "AxiosError", e && (this.code = e), t && (this.config = t), s && (this.request = s), r && (this.response = r, this.status = r.status ? r.status : null);
240
+ }
241
+ l.inherits(y, Error, {
242
+ toJSON: function() {
243
+ return {
244
+ // Standard
245
+ message: this.message,
246
+ name: this.name,
247
+ // Microsoft
248
+ description: this.description,
249
+ number: this.number,
250
+ // Mozilla
251
+ fileName: this.fileName,
252
+ lineNumber: this.lineNumber,
253
+ columnNumber: this.columnNumber,
254
+ stack: this.stack,
255
+ // Axios
256
+ config: l.toJSONObject(this.config),
257
+ code: this.code,
258
+ status: this.status
259
+ };
260
+ }
261
+ });
262
+ const Rt = y.prototype, At = {};
263
+ [
264
+ "ERR_BAD_OPTION_VALUE",
265
+ "ERR_BAD_OPTION",
266
+ "ECONNABORTED",
267
+ "ETIMEDOUT",
268
+ "ERR_NETWORK",
269
+ "ERR_FR_TOO_MANY_REDIRECTS",
270
+ "ERR_DEPRECATED",
271
+ "ERR_BAD_RESPONSE",
272
+ "ERR_BAD_REQUEST",
273
+ "ERR_CANCELED",
274
+ "ERR_NOT_SUPPORT",
275
+ "ERR_INVALID_URL"
276
+ // eslint-disable-next-line func-names
277
+ ].forEach((n) => {
278
+ At[n] = { value: n };
279
+ });
280
+ Object.defineProperties(y, At);
281
+ Object.defineProperty(Rt, "isAxiosError", { value: !0 });
282
+ y.from = (n, e, t, s, r, i) => {
283
+ const o = Object.create(Rt);
284
+ return l.toFlatObject(n, o, function(h) {
285
+ return h !== Error.prototype;
286
+ }, (c) => c !== "isAxiosError"), y.call(o, n.message, e, t, s, r), o.cause = n, o.name = n.name, i && Object.assign(o, i), o;
287
+ };
288
+ const Dn = null;
289
+ function Ce(n) {
290
+ return l.isPlainObject(n) || l.isArray(n);
291
+ }
292
+ function Tt(n) {
293
+ return l.endsWith(n, "[]") ? n.slice(0, -2) : n;
294
+ }
295
+ function Ke(n, e, t) {
296
+ return n ? n.concat(e).map(function(r, i) {
297
+ return r = Tt(r), !t && i ? "[" + r + "]" : r;
298
+ }).join(t ? "." : "") : e;
299
+ }
300
+ function qn(n) {
301
+ return l.isArray(n) && !n.some(Ce);
302
+ }
303
+ const Bn = l.toFlatObject(l, {}, null, function(e) {
304
+ return /^is[A-Z]/.test(e);
305
+ });
306
+ function me(n, e, t) {
307
+ if (!l.isObject(n))
308
+ throw new TypeError("target must be an object");
309
+ e = e || new FormData(), t = l.toFlatObject(t, {
310
+ metaTokens: !0,
311
+ dots: !1,
312
+ indexes: !1
313
+ }, !1, function(m, p) {
314
+ return !l.isUndefined(p[m]);
315
+ });
316
+ const s = t.metaTokens, r = t.visitor || a, i = t.dots, o = t.indexes, h = (t.Blob || typeof Blob < "u" && Blob) && l.isSpecCompliantForm(e);
317
+ if (!l.isFunction(r))
318
+ throw new TypeError("visitor must be a function");
319
+ function u(f) {
320
+ if (f === null) return "";
321
+ if (l.isDate(f))
322
+ return f.toISOString();
323
+ if (!h && l.isBlob(f))
324
+ throw new y("Blob is not supported. Use a Buffer instead.");
325
+ return l.isArrayBuffer(f) || l.isTypedArray(f) ? h && typeof Blob == "function" ? new Blob([f]) : Buffer.from(f) : f;
326
+ }
327
+ function a(f, m, p) {
328
+ let _ = f;
329
+ if (f && !p && typeof f == "object") {
330
+ if (l.endsWith(m, "{}"))
331
+ m = s ? m : m.slice(0, -2), f = JSON.stringify(f);
332
+ else if (l.isArray(f) && qn(f) || (l.isFileList(f) || l.endsWith(m, "[]")) && (_ = l.toArray(f)))
333
+ return m = Tt(m), _.forEach(function(S, k) {
334
+ !(l.isUndefined(S) || S === null) && e.append(
335
+ // eslint-disable-next-line no-nested-ternary
336
+ o === !0 ? Ke([m], k, i) : o === null ? m : m + "[]",
337
+ u(S)
338
+ );
339
+ }), !1;
340
+ }
341
+ return Ce(f) ? !0 : (e.append(Ke(p, m, i), u(f)), !1);
342
+ }
343
+ const d = [], g = Object.assign(Bn, {
344
+ defaultVisitor: a,
345
+ convertValue: u,
346
+ isVisitable: Ce
347
+ });
348
+ function b(f, m) {
349
+ if (!l.isUndefined(f)) {
350
+ if (d.indexOf(f) !== -1)
351
+ throw Error("Circular reference detected in " + m.join("."));
352
+ d.push(f), l.forEach(f, function(_, E) {
353
+ (!(l.isUndefined(_) || _ === null) && r.call(
354
+ e,
355
+ _,
356
+ l.isString(E) ? E.trim() : E,
357
+ m,
358
+ g
359
+ )) === !0 && b(_, m ? m.concat(E) : [E]);
360
+ }), d.pop();
361
+ }
362
+ }
363
+ if (!l.isObject(n))
364
+ throw new TypeError("data must be an object");
365
+ return b(n), e;
366
+ }
367
+ function Ge(n) {
368
+ const e = {
369
+ "!": "%21",
370
+ "'": "%27",
371
+ "(": "%28",
372
+ ")": "%29",
373
+ "~": "%7E",
374
+ "%20": "+",
375
+ "%00": "\0"
376
+ };
377
+ return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g, function(s) {
378
+ return e[s];
379
+ });
380
+ }
381
+ function Fe(n, e) {
382
+ this._pairs = [], n && me(n, this, e);
383
+ }
384
+ const Ot = Fe.prototype;
385
+ Ot.append = function(e, t) {
386
+ this._pairs.push([e, t]);
387
+ };
388
+ Ot.toString = function(e) {
389
+ const t = e ? function(s) {
390
+ return e.call(this, s, Ge);
391
+ } : Ge;
392
+ return this._pairs.map(function(r) {
393
+ return t(r[0]) + "=" + t(r[1]);
394
+ }, "").join("&");
395
+ };
396
+ function Mn(n) {
397
+ return encodeURIComponent(n).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
398
+ }
399
+ function Ct(n, e, t) {
400
+ if (!e)
401
+ return n;
402
+ const s = t && t.encode || Mn;
403
+ l.isFunction(t) && (t = {
404
+ serialize: t
405
+ });
406
+ const r = t && t.serialize;
407
+ let i;
408
+ if (r ? i = r(e, t) : i = l.isURLSearchParams(e) ? e.toString() : new Fe(e, t).toString(s), i) {
409
+ const o = n.indexOf("#");
410
+ o !== -1 && (n = n.slice(0, o)), n += (n.indexOf("?") === -1 ? "?" : "&") + i;
411
+ }
412
+ return n;
413
+ }
414
+ class Xe {
415
+ constructor() {
416
+ this.handlers = [];
417
+ }
418
+ /**
419
+ * Add a new interceptor to the stack
420
+ *
421
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
422
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
423
+ *
424
+ * @return {Number} An ID used to remove interceptor later
425
+ */
426
+ use(e, t, s) {
427
+ return this.handlers.push({
428
+ fulfilled: e,
429
+ rejected: t,
430
+ synchronous: s ? s.synchronous : !1,
431
+ runWhen: s ? s.runWhen : null
432
+ }), this.handlers.length - 1;
433
+ }
434
+ /**
435
+ * Remove an interceptor from the stack
436
+ *
437
+ * @param {Number} id The ID that was returned by `use`
438
+ *
439
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
440
+ */
441
+ eject(e) {
442
+ this.handlers[e] && (this.handlers[e] = null);
443
+ }
444
+ /**
445
+ * Clear all interceptors from the stack
446
+ *
447
+ * @returns {void}
448
+ */
449
+ clear() {
450
+ this.handlers && (this.handlers = []);
451
+ }
452
+ /**
453
+ * Iterate over all the registered interceptors
454
+ *
455
+ * This method is particularly useful for skipping over any
456
+ * interceptors that may have become `null` calling `eject`.
457
+ *
458
+ * @param {Function} fn The function to call for each interceptor
459
+ *
460
+ * @returns {void}
461
+ */
462
+ forEach(e) {
463
+ l.forEach(this.handlers, function(s) {
464
+ s !== null && e(s);
465
+ });
466
+ }
467
+ }
468
+ const kt = {
469
+ silentJSONParsing: !0,
470
+ forcedJSONParsing: !0,
471
+ clarifyTimeoutError: !1
472
+ }, Hn = typeof URLSearchParams < "u" ? URLSearchParams : Fe, zn = typeof FormData < "u" ? FormData : null, Vn = typeof Blob < "u" ? Blob : null, Jn = {
473
+ isBrowser: !0,
474
+ classes: {
475
+ URLSearchParams: Hn,
476
+ FormData: zn,
477
+ Blob: Vn
478
+ },
479
+ protocols: ["http", "https", "file", "blob", "url", "data"]
480
+ }, Ue = typeof window < "u" && typeof document < "u", ke = typeof navigator == "object" && navigator || void 0, Wn = Ue && (!ke || ["ReactNative", "NativeScript", "NS"].indexOf(ke.product) < 0), Kn = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
481
+ self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Gn = Ue && window.location.href || "http://localhost", Xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
482
+ __proto__: null,
483
+ hasBrowserEnv: Ue,
484
+ hasStandardBrowserEnv: Wn,
485
+ hasStandardBrowserWebWorkerEnv: Kn,
486
+ navigator: ke,
487
+ origin: Gn
488
+ }, Symbol.toStringTag, { value: "Module" })), T = {
489
+ ...Xn,
490
+ ...Jn
491
+ };
492
+ function Zn(n, e) {
493
+ return me(n, new T.classes.URLSearchParams(), Object.assign({
494
+ visitor: function(t, s, r, i) {
495
+ return T.isNode && l.isBuffer(t) ? (this.append(s, t.toString("base64")), !1) : i.defaultVisitor.apply(this, arguments);
496
+ }
497
+ }, e));
498
+ }
499
+ function Qn(n) {
500
+ return l.matchAll(/\w+|\[(\w*)]/g, n).map((e) => e[0] === "[]" ? "" : e[1] || e[0]);
501
+ }
502
+ function Yn(n) {
503
+ const e = {}, t = Object.keys(n);
504
+ let s;
505
+ const r = t.length;
506
+ let i;
507
+ for (s = 0; s < r; s++)
508
+ i = t[s], e[i] = n[i];
509
+ return e;
510
+ }
511
+ function Nt(n) {
512
+ function e(t, s, r, i) {
513
+ let o = t[i++];
514
+ if (o === "__proto__") return !0;
515
+ const c = Number.isFinite(+o), h = i >= t.length;
516
+ return o = !o && l.isArray(r) ? r.length : o, h ? (l.hasOwnProp(r, o) ? r[o] = [r[o], s] : r[o] = s, !c) : ((!r[o] || !l.isObject(r[o])) && (r[o] = []), e(t, s, r[o], i) && l.isArray(r[o]) && (r[o] = Yn(r[o])), !c);
517
+ }
518
+ if (l.isFormData(n) && l.isFunction(n.entries)) {
519
+ const t = {};
520
+ return l.forEachEntry(n, (s, r) => {
521
+ e(Qn(s), r, t, 0);
522
+ }), t;
523
+ }
524
+ return null;
525
+ }
526
+ function es(n, e, t) {
527
+ if (l.isString(n))
528
+ try {
529
+ return (e || JSON.parse)(n), l.trim(n);
530
+ } catch (s) {
531
+ if (s.name !== "SyntaxError")
532
+ throw s;
533
+ }
534
+ return (t || JSON.stringify)(n);
535
+ }
536
+ const te = {
537
+ transitional: kt,
538
+ adapter: ["xhr", "http", "fetch"],
539
+ transformRequest: [function(e, t) {
540
+ const s = t.getContentType() || "", r = s.indexOf("application/json") > -1, i = l.isObject(e);
541
+ if (i && l.isHTMLForm(e) && (e = new FormData(e)), l.isFormData(e))
542
+ return r ? JSON.stringify(Nt(e)) : e;
543
+ if (l.isArrayBuffer(e) || l.isBuffer(e) || l.isStream(e) || l.isFile(e) || l.isBlob(e) || l.isReadableStream(e))
544
+ return e;
545
+ if (l.isArrayBufferView(e))
546
+ return e.buffer;
547
+ if (l.isURLSearchParams(e))
548
+ return t.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString();
549
+ let c;
550
+ if (i) {
551
+ if (s.indexOf("application/x-www-form-urlencoded") > -1)
552
+ return Zn(e, this.formSerializer).toString();
553
+ if ((c = l.isFileList(e)) || s.indexOf("multipart/form-data") > -1) {
554
+ const h = this.env && this.env.FormData;
555
+ return me(
556
+ c ? { "files[]": e } : e,
557
+ h && new h(),
558
+ this.formSerializer
559
+ );
560
+ }
561
+ }
562
+ return i || r ? (t.setContentType("application/json", !1), es(e)) : e;
563
+ }],
564
+ transformResponse: [function(e) {
565
+ const t = this.transitional || te.transitional, s = t && t.forcedJSONParsing, r = this.responseType === "json";
566
+ if (l.isResponse(e) || l.isReadableStream(e))
567
+ return e;
568
+ if (e && l.isString(e) && (s && !this.responseType || r)) {
569
+ const o = !(t && t.silentJSONParsing) && r;
570
+ try {
571
+ return JSON.parse(e);
572
+ } catch (c) {
573
+ if (o)
574
+ throw c.name === "SyntaxError" ? y.from(c, y.ERR_BAD_RESPONSE, this, null, this.response) : c;
575
+ }
576
+ }
577
+ return e;
578
+ }],
579
+ /**
580
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
581
+ * timeout is not created.
582
+ */
583
+ timeout: 0,
584
+ xsrfCookieName: "XSRF-TOKEN",
585
+ xsrfHeaderName: "X-XSRF-TOKEN",
586
+ maxContentLength: -1,
587
+ maxBodyLength: -1,
588
+ env: {
589
+ FormData: T.classes.FormData,
590
+ Blob: T.classes.Blob
591
+ },
592
+ validateStatus: function(e) {
593
+ return e >= 200 && e < 300;
594
+ },
595
+ headers: {
596
+ common: {
597
+ Accept: "application/json, text/plain, */*",
598
+ "Content-Type": void 0
599
+ }
600
+ }
601
+ };
602
+ l.forEach(["delete", "get", "head", "post", "put", "patch"], (n) => {
603
+ te.headers[n] = {};
604
+ });
605
+ const ts = l.toObjectSet([
606
+ "age",
607
+ "authorization",
608
+ "content-length",
609
+ "content-type",
610
+ "etag",
611
+ "expires",
612
+ "from",
613
+ "host",
614
+ "if-modified-since",
615
+ "if-unmodified-since",
616
+ "last-modified",
617
+ "location",
618
+ "max-forwards",
619
+ "proxy-authorization",
620
+ "referer",
621
+ "retry-after",
622
+ "user-agent"
623
+ ]), ns = (n) => {
624
+ const e = {};
625
+ let t, s, r;
626
+ return n && n.split(`
627
+ `).forEach(function(o) {
628
+ r = o.indexOf(":"), t = o.substring(0, r).trim().toLowerCase(), s = o.substring(r + 1).trim(), !(!t || e[t] && ts[t]) && (t === "set-cookie" ? e[t] ? e[t].push(s) : e[t] = [s] : e[t] = e[t] ? e[t] + ", " + s : s);
629
+ }), e;
630
+ }, Ze = Symbol("internals");
631
+ function Z(n) {
632
+ return n && String(n).trim().toLowerCase();
633
+ }
634
+ function ae(n) {
635
+ return n === !1 || n == null ? n : l.isArray(n) ? n.map(ae) : String(n);
636
+ }
637
+ function ss(n) {
638
+ const e = /* @__PURE__ */ Object.create(null), t = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
639
+ let s;
640
+ for (; s = t.exec(n); )
641
+ e[s[1]] = s[2];
642
+ return e;
643
+ }
644
+ const rs = (n) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());
645
+ function xe(n, e, t, s, r) {
646
+ if (l.isFunction(s))
647
+ return s.call(this, e, t);
648
+ if (r && (e = t), !!l.isString(e)) {
649
+ if (l.isString(s))
650
+ return e.indexOf(s) !== -1;
651
+ if (l.isRegExp(s))
652
+ return s.test(e);
653
+ }
654
+ }
655
+ function is(n) {
656
+ return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (e, t, s) => t.toUpperCase() + s);
657
+ }
658
+ function os(n, e) {
659
+ const t = l.toCamelCase(" " + e);
660
+ ["get", "set", "has"].forEach((s) => {
661
+ Object.defineProperty(n, s + t, {
662
+ value: function(r, i, o) {
663
+ return this[s].call(this, e, r, i, o);
664
+ },
665
+ configurable: !0
666
+ });
667
+ });
668
+ }
669
+ let C = class {
670
+ constructor(e) {
671
+ e && this.set(e);
672
+ }
673
+ set(e, t, s) {
674
+ const r = this;
675
+ function i(c, h, u) {
676
+ const a = Z(h);
677
+ if (!a)
678
+ throw new Error("header name must be a non-empty string");
679
+ const d = l.findKey(r, a);
680
+ (!d || r[d] === void 0 || u === !0 || u === void 0 && r[d] !== !1) && (r[d || h] = ae(c));
681
+ }
682
+ const o = (c, h) => l.forEach(c, (u, a) => i(u, a, h));
683
+ if (l.isPlainObject(e) || e instanceof this.constructor)
684
+ o(e, t);
685
+ else if (l.isString(e) && (e = e.trim()) && !rs(e))
686
+ o(ns(e), t);
687
+ else if (l.isHeaders(e))
688
+ for (const [c, h] of e.entries())
689
+ i(h, c, s);
690
+ else
691
+ e != null && i(t, e, s);
692
+ return this;
693
+ }
694
+ get(e, t) {
695
+ if (e = Z(e), e) {
696
+ const s = l.findKey(this, e);
697
+ if (s) {
698
+ const r = this[s];
699
+ if (!t)
700
+ return r;
701
+ if (t === !0)
702
+ return ss(r);
703
+ if (l.isFunction(t))
704
+ return t.call(this, r, s);
705
+ if (l.isRegExp(t))
706
+ return t.exec(r);
707
+ throw new TypeError("parser must be boolean|regexp|function");
708
+ }
709
+ }
710
+ }
711
+ has(e, t) {
712
+ if (e = Z(e), e) {
713
+ const s = l.findKey(this, e);
714
+ return !!(s && this[s] !== void 0 && (!t || xe(this, this[s], s, t)));
715
+ }
716
+ return !1;
717
+ }
718
+ delete(e, t) {
719
+ const s = this;
720
+ let r = !1;
721
+ function i(o) {
722
+ if (o = Z(o), o) {
723
+ const c = l.findKey(s, o);
724
+ c && (!t || xe(s, s[c], c, t)) && (delete s[c], r = !0);
725
+ }
726
+ }
727
+ return l.isArray(e) ? e.forEach(i) : i(e), r;
728
+ }
729
+ clear(e) {
730
+ const t = Object.keys(this);
731
+ let s = t.length, r = !1;
732
+ for (; s--; ) {
733
+ const i = t[s];
734
+ (!e || xe(this, this[i], i, e, !0)) && (delete this[i], r = !0);
735
+ }
736
+ return r;
737
+ }
738
+ normalize(e) {
739
+ const t = this, s = {};
740
+ return l.forEach(this, (r, i) => {
741
+ const o = l.findKey(s, i);
742
+ if (o) {
743
+ t[o] = ae(r), delete t[i];
744
+ return;
745
+ }
746
+ const c = e ? is(i) : String(i).trim();
747
+ c !== i && delete t[i], t[c] = ae(r), s[c] = !0;
748
+ }), this;
749
+ }
750
+ concat(...e) {
751
+ return this.constructor.concat(this, ...e);
752
+ }
753
+ toJSON(e) {
754
+ const t = /* @__PURE__ */ Object.create(null);
755
+ return l.forEach(this, (s, r) => {
756
+ s != null && s !== !1 && (t[r] = e && l.isArray(s) ? s.join(", ") : s);
757
+ }), t;
758
+ }
759
+ [Symbol.iterator]() {
760
+ return Object.entries(this.toJSON())[Symbol.iterator]();
761
+ }
762
+ toString() {
763
+ return Object.entries(this.toJSON()).map(([e, t]) => e + ": " + t).join(`
764
+ `);
765
+ }
766
+ get [Symbol.toStringTag]() {
767
+ return "AxiosHeaders";
768
+ }
769
+ static from(e) {
770
+ return e instanceof this ? e : new this(e);
771
+ }
772
+ static concat(e, ...t) {
773
+ const s = new this(e);
774
+ return t.forEach((r) => s.set(r)), s;
775
+ }
776
+ static accessor(e) {
777
+ const s = (this[Ze] = this[Ze] = {
778
+ accessors: {}
779
+ }).accessors, r = this.prototype;
780
+ function i(o) {
781
+ const c = Z(o);
782
+ s[c] || (os(r, o), s[c] = !0);
783
+ }
784
+ return l.isArray(e) ? e.forEach(i) : i(e), this;
785
+ }
786
+ };
787
+ C.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
788
+ l.reduceDescriptors(C.prototype, ({ value: n }, e) => {
789
+ let t = e[0].toUpperCase() + e.slice(1);
790
+ return {
791
+ get: () => n,
792
+ set(s) {
793
+ this[t] = s;
794
+ }
795
+ };
796
+ });
797
+ l.freezeMethods(C);
798
+ function Re(n, e) {
799
+ const t = this || te, s = e || t, r = C.from(s.headers);
800
+ let i = s.data;
801
+ return l.forEach(n, function(c) {
802
+ i = c.call(t, i, r.normalize(), e ? e.status : void 0);
803
+ }), r.normalize(), i;
804
+ }
805
+ function Pt(n) {
806
+ return !!(n && n.__CANCEL__);
807
+ }
808
+ function G(n, e, t) {
809
+ y.call(this, n ?? "canceled", y.ERR_CANCELED, e, t), this.name = "CanceledError";
810
+ }
811
+ l.inherits(G, y, {
812
+ __CANCEL__: !0
813
+ });
814
+ function It(n, e, t) {
815
+ const s = t.config.validateStatus;
816
+ !t.status || !s || s(t.status) ? n(t) : e(new y(
817
+ "Request failed with status code " + t.status,
818
+ [y.ERR_BAD_REQUEST, y.ERR_BAD_RESPONSE][Math.floor(t.status / 100) - 4],
819
+ t.config,
820
+ t.request,
821
+ t
822
+ ));
823
+ }
824
+ function cs(n) {
825
+ const e = /^([-+\w]{1,25})(:?\/\/|:)/.exec(n);
826
+ return e && e[1] || "";
827
+ }
828
+ function as(n, e) {
829
+ n = n || 10;
830
+ const t = new Array(n), s = new Array(n);
831
+ let r = 0, i = 0, o;
832
+ return e = e !== void 0 ? e : 1e3, function(h) {
833
+ const u = Date.now(), a = s[i];
834
+ o || (o = u), t[r] = h, s[r] = u;
835
+ let d = i, g = 0;
836
+ for (; d !== r; )
837
+ g += t[d++], d = d % n;
838
+ if (r = (r + 1) % n, r === i && (i = (i + 1) % n), u - o < e)
839
+ return;
840
+ const b = a && u - a;
841
+ return b ? Math.round(g * 1e3 / b) : void 0;
842
+ };
843
+ }
844
+ function ls(n, e) {
845
+ let t = 0, s = 1e3 / e, r, i;
846
+ const o = (u, a = Date.now()) => {
847
+ t = a, r = null, i && (clearTimeout(i), i = null), n.apply(null, u);
848
+ };
849
+ return [(...u) => {
850
+ const a = Date.now(), d = a - t;
851
+ d >= s ? o(u, a) : (r = u, i || (i = setTimeout(() => {
852
+ i = null, o(r);
853
+ }, s - d)));
854
+ }, () => r && o(r)];
855
+ }
856
+ const ue = (n, e, t = 3) => {
857
+ let s = 0;
858
+ const r = as(50, 250);
859
+ return ls((i) => {
860
+ const o = i.loaded, c = i.lengthComputable ? i.total : void 0, h = o - s, u = r(h), a = o <= c;
861
+ s = o;
862
+ const d = {
863
+ loaded: o,
864
+ total: c,
865
+ progress: c ? o / c : void 0,
866
+ bytes: h,
867
+ rate: u || void 0,
868
+ estimated: u && c && a ? (c - o) / u : void 0,
869
+ event: i,
870
+ lengthComputable: c != null,
871
+ [e ? "download" : "upload"]: !0
872
+ };
873
+ n(d);
874
+ }, t);
875
+ }, Qe = (n, e) => {
876
+ const t = n != null;
877
+ return [(s) => e[0]({
878
+ lengthComputable: t,
879
+ total: n,
880
+ loaded: s
881
+ }), e[1]];
882
+ }, Ye = (n) => (...e) => l.asap(() => n(...e)), us = T.hasStandardBrowserEnv ? /* @__PURE__ */ ((n, e) => (t) => (t = new URL(t, T.origin), n.protocol === t.protocol && n.host === t.host && (e || n.port === t.port)))(
883
+ new URL(T.origin),
884
+ T.navigator && /(msie|trident)/i.test(T.navigator.userAgent)
885
+ ) : () => !0, hs = T.hasStandardBrowserEnv ? (
886
+ // Standard browser envs support document.cookie
887
+ {
888
+ write(n, e, t, s, r, i) {
889
+ const o = [n + "=" + encodeURIComponent(e)];
890
+ l.isNumber(t) && o.push("expires=" + new Date(t).toGMTString()), l.isString(s) && o.push("path=" + s), l.isString(r) && o.push("domain=" + r), i === !0 && o.push("secure"), document.cookie = o.join("; ");
891
+ },
892
+ read(n) {
893
+ const e = document.cookie.match(new RegExp("(^|;\\s*)(" + n + ")=([^;]*)"));
894
+ return e ? decodeURIComponent(e[3]) : null;
895
+ },
896
+ remove(n) {
897
+ this.write(n, "", Date.now() - 864e5);
898
+ }
899
+ }
900
+ ) : (
901
+ // Non-standard browser env (web workers, react-native) lack needed support.
902
+ {
903
+ write() {
904
+ },
905
+ read() {
906
+ return null;
907
+ },
908
+ remove() {
909
+ }
910
+ }
911
+ );
912
+ function ds(n) {
913
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(n);
914
+ }
915
+ function fs(n, e) {
916
+ return e ? n.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : n;
917
+ }
918
+ function Lt(n, e) {
919
+ return n && !ds(e) ? fs(n, e) : e;
920
+ }
921
+ const et = (n) => n instanceof C ? { ...n } : n;
922
+ function V(n, e) {
923
+ e = e || {};
924
+ const t = {};
925
+ function s(u, a, d, g) {
926
+ return l.isPlainObject(u) && l.isPlainObject(a) ? l.merge.call({ caseless: g }, u, a) : l.isPlainObject(a) ? l.merge({}, a) : l.isArray(a) ? a.slice() : a;
927
+ }
928
+ function r(u, a, d, g) {
929
+ if (l.isUndefined(a)) {
930
+ if (!l.isUndefined(u))
931
+ return s(void 0, u, d, g);
932
+ } else return s(u, a, d, g);
933
+ }
934
+ function i(u, a) {
935
+ if (!l.isUndefined(a))
936
+ return s(void 0, a);
937
+ }
938
+ function o(u, a) {
939
+ if (l.isUndefined(a)) {
940
+ if (!l.isUndefined(u))
941
+ return s(void 0, u);
942
+ } else return s(void 0, a);
943
+ }
944
+ function c(u, a, d) {
945
+ if (d in e)
946
+ return s(u, a);
947
+ if (d in n)
948
+ return s(void 0, u);
949
+ }
950
+ const h = {
951
+ url: i,
952
+ method: i,
953
+ data: i,
954
+ baseURL: o,
955
+ transformRequest: o,
956
+ transformResponse: o,
957
+ paramsSerializer: o,
958
+ timeout: o,
959
+ timeoutMessage: o,
960
+ withCredentials: o,
961
+ withXSRFToken: o,
962
+ adapter: o,
963
+ responseType: o,
964
+ xsrfCookieName: o,
965
+ xsrfHeaderName: o,
966
+ onUploadProgress: o,
967
+ onDownloadProgress: o,
968
+ decompress: o,
969
+ maxContentLength: o,
970
+ maxBodyLength: o,
971
+ beforeRedirect: o,
972
+ transport: o,
973
+ httpAgent: o,
974
+ httpsAgent: o,
975
+ cancelToken: o,
976
+ socketPath: o,
977
+ responseEncoding: o,
978
+ validateStatus: c,
979
+ headers: (u, a, d) => r(et(u), et(a), d, !0)
980
+ };
981
+ return l.forEach(Object.keys(Object.assign({}, n, e)), function(a) {
982
+ const d = h[a] || r, g = d(n[a], e[a], a);
983
+ l.isUndefined(g) && d !== c || (t[a] = g);
984
+ }), t;
985
+ }
986
+ const vt = (n) => {
987
+ const e = V({}, n);
988
+ let { data: t, withXSRFToken: s, xsrfHeaderName: r, xsrfCookieName: i, headers: o, auth: c } = e;
989
+ e.headers = o = C.from(o), e.url = Ct(Lt(e.baseURL, e.url), n.params, n.paramsSerializer), c && o.set(
990
+ "Authorization",
991
+ "Basic " + btoa((c.username || "") + ":" + (c.password ? unescape(encodeURIComponent(c.password)) : ""))
992
+ );
993
+ let h;
994
+ if (l.isFormData(t)) {
995
+ if (T.hasStandardBrowserEnv || T.hasStandardBrowserWebWorkerEnv)
996
+ o.setContentType(void 0);
997
+ else if ((h = o.getContentType()) !== !1) {
998
+ const [u, ...a] = h ? h.split(";").map((d) => d.trim()).filter(Boolean) : [];
999
+ o.setContentType([u || "multipart/form-data", ...a].join("; "));
1000
+ }
1001
+ }
1002
+ if (T.hasStandardBrowserEnv && (s && l.isFunction(s) && (s = s(e)), s || s !== !1 && us(e.url))) {
1003
+ const u = r && i && hs.read(i);
1004
+ u && o.set(r, u);
1005
+ }
1006
+ return e;
1007
+ }, ps = typeof XMLHttpRequest < "u", ms = ps && function(n) {
1008
+ return new Promise(function(t, s) {
1009
+ const r = vt(n);
1010
+ let i = r.data;
1011
+ const o = C.from(r.headers).normalize();
1012
+ let { responseType: c, onUploadProgress: h, onDownloadProgress: u } = r, a, d, g, b, f;
1013
+ function m() {
1014
+ b && b(), f && f(), r.cancelToken && r.cancelToken.unsubscribe(a), r.signal && r.signal.removeEventListener("abort", a);
1015
+ }
1016
+ let p = new XMLHttpRequest();
1017
+ p.open(r.method.toUpperCase(), r.url, !0), p.timeout = r.timeout;
1018
+ function _() {
1019
+ if (!p)
1020
+ return;
1021
+ const S = C.from(
1022
+ "getAllResponseHeaders" in p && p.getAllResponseHeaders()
1023
+ ), x = {
1024
+ data: !c || c === "text" || c === "json" ? p.responseText : p.response,
1025
+ status: p.status,
1026
+ statusText: p.statusText,
1027
+ headers: S,
1028
+ config: n,
1029
+ request: p
1030
+ };
1031
+ It(function(I) {
1032
+ t(I), m();
1033
+ }, function(I) {
1034
+ s(I), m();
1035
+ }, x), p = null;
1036
+ }
1037
+ "onloadend" in p ? p.onloadend = _ : p.onreadystatechange = function() {
1038
+ !p || p.readyState !== 4 || p.status === 0 && !(p.responseURL && p.responseURL.indexOf("file:") === 0) || setTimeout(_);
1039
+ }, p.onabort = function() {
1040
+ p && (s(new y("Request aborted", y.ECONNABORTED, n, p)), p = null);
1041
+ }, p.onerror = function() {
1042
+ s(new y("Network Error", y.ERR_NETWORK, n, p)), p = null;
1043
+ }, p.ontimeout = function() {
1044
+ let k = r.timeout ? "timeout of " + r.timeout + "ms exceeded" : "timeout exceeded";
1045
+ const x = r.transitional || kt;
1046
+ r.timeoutErrorMessage && (k = r.timeoutErrorMessage), s(new y(
1047
+ k,
1048
+ x.clarifyTimeoutError ? y.ETIMEDOUT : y.ECONNABORTED,
1049
+ n,
1050
+ p
1051
+ )), p = null;
1052
+ }, i === void 0 && o.setContentType(null), "setRequestHeader" in p && l.forEach(o.toJSON(), function(k, x) {
1053
+ p.setRequestHeader(x, k);
1054
+ }), l.isUndefined(r.withCredentials) || (p.withCredentials = !!r.withCredentials), c && c !== "json" && (p.responseType = r.responseType), u && ([g, f] = ue(u, !0), p.addEventListener("progress", g)), h && p.upload && ([d, b] = ue(h), p.upload.addEventListener("progress", d), p.upload.addEventListener("loadend", b)), (r.cancelToken || r.signal) && (a = (S) => {
1055
+ p && (s(!S || S.type ? new G(null, n, p) : S), p.abort(), p = null);
1056
+ }, r.cancelToken && r.cancelToken.subscribe(a), r.signal && (r.signal.aborted ? a() : r.signal.addEventListener("abort", a)));
1057
+ const E = cs(r.url);
1058
+ if (E && T.protocols.indexOf(E) === -1) {
1059
+ s(new y("Unsupported protocol " + E + ":", y.ERR_BAD_REQUEST, n));
1060
+ return;
1061
+ }
1062
+ p.send(i || null);
1063
+ });
1064
+ }, gs = (n, e) => {
1065
+ const { length: t } = n = n ? n.filter(Boolean) : [];
1066
+ if (e || t) {
1067
+ let s = new AbortController(), r;
1068
+ const i = function(u) {
1069
+ if (!r) {
1070
+ r = !0, c();
1071
+ const a = u instanceof Error ? u : this.reason;
1072
+ s.abort(a instanceof y ? a : new G(a instanceof Error ? a.message : a));
1073
+ }
1074
+ };
1075
+ let o = e && setTimeout(() => {
1076
+ o = null, i(new y(`timeout ${e} of ms exceeded`, y.ETIMEDOUT));
1077
+ }, e);
1078
+ const c = () => {
1079
+ n && (o && clearTimeout(o), o = null, n.forEach((u) => {
1080
+ u.unsubscribe ? u.unsubscribe(i) : u.removeEventListener("abort", i);
1081
+ }), n = null);
1082
+ };
1083
+ n.forEach((u) => u.addEventListener("abort", i));
1084
+ const { signal: h } = s;
1085
+ return h.unsubscribe = () => l.asap(c), h;
1086
+ }
1087
+ }, bs = function* (n, e) {
1088
+ let t = n.byteLength;
1089
+ if (t < e) {
1090
+ yield n;
1091
+ return;
1092
+ }
1093
+ let s = 0, r;
1094
+ for (; s < t; )
1095
+ r = s + e, yield n.slice(s, r), s = r;
1096
+ }, ys = async function* (n, e) {
1097
+ for await (const t of ws(n))
1098
+ yield* bs(t, e);
1099
+ }, ws = async function* (n) {
1100
+ if (n[Symbol.asyncIterator]) {
1101
+ yield* n;
1102
+ return;
1103
+ }
1104
+ const e = n.getReader();
1105
+ try {
1106
+ for (; ; ) {
1107
+ const { done: t, value: s } = await e.read();
1108
+ if (t)
1109
+ break;
1110
+ yield s;
1111
+ }
1112
+ } finally {
1113
+ await e.cancel();
1114
+ }
1115
+ }, tt = (n, e, t, s) => {
1116
+ const r = ys(n, e);
1117
+ let i = 0, o, c = (h) => {
1118
+ o || (o = !0, s && s(h));
1119
+ };
1120
+ return new ReadableStream({
1121
+ async pull(h) {
1122
+ try {
1123
+ const { done: u, value: a } = await r.next();
1124
+ if (u) {
1125
+ c(), h.close();
1126
+ return;
1127
+ }
1128
+ let d = a.byteLength;
1129
+ if (t) {
1130
+ let g = i += d;
1131
+ t(g);
1132
+ }
1133
+ h.enqueue(new Uint8Array(a));
1134
+ } catch (u) {
1135
+ throw c(u), u;
1136
+ }
1137
+ },
1138
+ cancel(h) {
1139
+ return c(h), r.return();
1140
+ }
1141
+ }, {
1142
+ highWaterMark: 2
1143
+ });
1144
+ }, ge = typeof fetch == "function" && typeof Request == "function" && typeof Response == "function", jt = ge && typeof ReadableStream == "function", _s = ge && (typeof TextEncoder == "function" ? /* @__PURE__ */ ((n) => (e) => n.encode(e))(new TextEncoder()) : async (n) => new Uint8Array(await new Response(n).arrayBuffer())), $t = (n, ...e) => {
1145
+ try {
1146
+ return !!n(...e);
1147
+ } catch {
1148
+ return !1;
1149
+ }
1150
+ }, Es = jt && $t(() => {
1151
+ let n = !1;
1152
+ const e = new Request(T.origin, {
1153
+ body: new ReadableStream(),
1154
+ method: "POST",
1155
+ get duplex() {
1156
+ return n = !0, "half";
1157
+ }
1158
+ }).headers.has("Content-Type");
1159
+ return n && !e;
1160
+ }), nt = 64 * 1024, Ne = jt && $t(() => l.isReadableStream(new Response("").body)), he = {
1161
+ stream: Ne && ((n) => n.body)
1162
+ };
1163
+ ge && ((n) => {
1164
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((e) => {
1165
+ !he[e] && (he[e] = l.isFunction(n[e]) ? (t) => t[e]() : (t, s) => {
1166
+ throw new y(`Response type '${e}' is not supported`, y.ERR_NOT_SUPPORT, s);
1167
+ });
1168
+ });
1169
+ })(new Response());
1170
+ const Ss = async (n) => {
1171
+ if (n == null)
1172
+ return 0;
1173
+ if (l.isBlob(n))
1174
+ return n.size;
1175
+ if (l.isSpecCompliantForm(n))
1176
+ return (await new Request(T.origin, {
1177
+ method: "POST",
1178
+ body: n
1179
+ }).arrayBuffer()).byteLength;
1180
+ if (l.isArrayBufferView(n) || l.isArrayBuffer(n))
1181
+ return n.byteLength;
1182
+ if (l.isURLSearchParams(n) && (n = n + ""), l.isString(n))
1183
+ return (await _s(n)).byteLength;
1184
+ }, xs = async (n, e) => {
1185
+ const t = l.toFiniteNumber(n.getContentLength());
1186
+ return t ?? Ss(e);
1187
+ }, Rs = ge && (async (n) => {
1188
+ let {
1189
+ url: e,
1190
+ method: t,
1191
+ data: s,
1192
+ signal: r,
1193
+ cancelToken: i,
1194
+ timeout: o,
1195
+ onDownloadProgress: c,
1196
+ onUploadProgress: h,
1197
+ responseType: u,
1198
+ headers: a,
1199
+ withCredentials: d = "same-origin",
1200
+ fetchOptions: g
1201
+ } = vt(n);
1202
+ u = u ? (u + "").toLowerCase() : "text";
1203
+ let b = gs([r, i && i.toAbortSignal()], o), f;
1204
+ const m = b && b.unsubscribe && (() => {
1205
+ b.unsubscribe();
1206
+ });
1207
+ let p;
1208
+ try {
1209
+ if (h && Es && t !== "get" && t !== "head" && (p = await xs(a, s)) !== 0) {
1210
+ let x = new Request(e, {
1211
+ method: "POST",
1212
+ body: s,
1213
+ duplex: "half"
1214
+ }), P;
1215
+ if (l.isFormData(s) && (P = x.headers.get("content-type")) && a.setContentType(P), x.body) {
1216
+ const [I, D] = Qe(
1217
+ p,
1218
+ ue(Ye(h))
1219
+ );
1220
+ s = tt(x.body, nt, I, D);
1221
+ }
1222
+ }
1223
+ l.isString(d) || (d = d ? "include" : "omit");
1224
+ const _ = "credentials" in Request.prototype;
1225
+ f = new Request(e, {
1226
+ ...g,
1227
+ signal: b,
1228
+ method: t.toUpperCase(),
1229
+ headers: a.normalize().toJSON(),
1230
+ body: s,
1231
+ duplex: "half",
1232
+ credentials: _ ? d : void 0
1233
+ });
1234
+ let E = await fetch(f);
1235
+ const S = Ne && (u === "stream" || u === "response");
1236
+ if (Ne && (c || S && m)) {
1237
+ const x = {};
1238
+ ["status", "statusText", "headers"].forEach((U) => {
1239
+ x[U] = E[U];
1240
+ });
1241
+ const P = l.toFiniteNumber(E.headers.get("content-length")), [I, D] = c && Qe(
1242
+ P,
1243
+ ue(Ye(c), !0)
1244
+ ) || [];
1245
+ E = new Response(
1246
+ tt(E.body, nt, I, () => {
1247
+ D && D(), m && m();
1248
+ }),
1249
+ x
1250
+ );
1251
+ }
1252
+ u = u || "text";
1253
+ let k = await he[l.findKey(he, u) || "text"](E, n);
1254
+ return !S && m && m(), await new Promise((x, P) => {
1255
+ It(x, P, {
1256
+ data: k,
1257
+ headers: C.from(E.headers),
1258
+ status: E.status,
1259
+ statusText: E.statusText,
1260
+ config: n,
1261
+ request: f
1262
+ });
1263
+ });
1264
+ } catch (_) {
1265
+ throw m && m(), _ && _.name === "TypeError" && /fetch/i.test(_.message) ? Object.assign(
1266
+ new y("Network Error", y.ERR_NETWORK, n, f),
1267
+ {
1268
+ cause: _.cause || _
1269
+ }
1270
+ ) : y.from(_, _ && _.code, n, f);
1271
+ }
1272
+ }), Pe = {
1273
+ http: Dn,
1274
+ xhr: ms,
1275
+ fetch: Rs
1276
+ };
1277
+ l.forEach(Pe, (n, e) => {
1278
+ if (n) {
1279
+ try {
1280
+ Object.defineProperty(n, "name", { value: e });
1281
+ } catch {
1282
+ }
1283
+ Object.defineProperty(n, "adapterName", { value: e });
1284
+ }
1285
+ });
1286
+ const st = (n) => `- ${n}`, As = (n) => l.isFunction(n) || n === null || n === !1, Ft = {
1287
+ getAdapter: (n) => {
1288
+ n = l.isArray(n) ? n : [n];
1289
+ const { length: e } = n;
1290
+ let t, s;
1291
+ const r = {};
1292
+ for (let i = 0; i < e; i++) {
1293
+ t = n[i];
1294
+ let o;
1295
+ if (s = t, !As(t) && (s = Pe[(o = String(t)).toLowerCase()], s === void 0))
1296
+ throw new y(`Unknown adapter '${o}'`);
1297
+ if (s)
1298
+ break;
1299
+ r[o || "#" + i] = s;
1300
+ }
1301
+ if (!s) {
1302
+ const i = Object.entries(r).map(
1303
+ ([c, h]) => `adapter ${c} ` + (h === !1 ? "is not supported by the environment" : "is not available in the build")
1304
+ );
1305
+ let o = e ? i.length > 1 ? `since :
1306
+ ` + i.map(st).join(`
1307
+ `) : " " + st(i[0]) : "as no adapter specified";
1308
+ throw new y(
1309
+ "There is no suitable adapter to dispatch the request " + o,
1310
+ "ERR_NOT_SUPPORT"
1311
+ );
1312
+ }
1313
+ return s;
1314
+ },
1315
+ adapters: Pe
1316
+ };
1317
+ function Ae(n) {
1318
+ if (n.cancelToken && n.cancelToken.throwIfRequested(), n.signal && n.signal.aborted)
1319
+ throw new G(null, n);
1320
+ }
1321
+ function rt(n) {
1322
+ return Ae(n), n.headers = C.from(n.headers), n.data = Re.call(
1323
+ n,
1324
+ n.transformRequest
1325
+ ), ["post", "put", "patch"].indexOf(n.method) !== -1 && n.headers.setContentType("application/x-www-form-urlencoded", !1), Ft.getAdapter(n.adapter || te.adapter)(n).then(function(s) {
1326
+ return Ae(n), s.data = Re.call(
1327
+ n,
1328
+ n.transformResponse,
1329
+ s
1330
+ ), s.headers = C.from(s.headers), s;
1331
+ }, function(s) {
1332
+ return Pt(s) || (Ae(n), s && s.response && (s.response.data = Re.call(
1333
+ n,
1334
+ n.transformResponse,
1335
+ s.response
1336
+ ), s.response.headers = C.from(s.response.headers))), Promise.reject(s);
1337
+ });
1338
+ }
1339
+ const Ut = "1.7.9", be = {};
1340
+ ["object", "boolean", "number", "function", "string", "symbol"].forEach((n, e) => {
1341
+ be[n] = function(s) {
1342
+ return typeof s === n || "a" + (e < 1 ? "n " : " ") + n;
1343
+ };
1344
+ });
1345
+ const it = {};
1346
+ be.transitional = function(e, t, s) {
1347
+ function r(i, o) {
1348
+ return "[Axios v" + Ut + "] Transitional option '" + i + "'" + o + (s ? ". " + s : "");
1349
+ }
1350
+ return (i, o, c) => {
1351
+ if (e === !1)
1352
+ throw new y(
1353
+ r(o, " has been removed" + (t ? " in " + t : "")),
1354
+ y.ERR_DEPRECATED
1355
+ );
1356
+ return t && !it[o] && (it[o] = !0, console.warn(
1357
+ r(
1358
+ o,
1359
+ " has been deprecated since v" + t + " and will be removed in the near future"
1360
+ )
1361
+ )), e ? e(i, o, c) : !0;
1362
+ };
1363
+ };
1364
+ be.spelling = function(e) {
1365
+ return (t, s) => (console.warn(`${s} is likely a misspelling of ${e}`), !0);
1366
+ };
1367
+ function Ts(n, e, t) {
1368
+ if (typeof n != "object")
1369
+ throw new y("options must be an object", y.ERR_BAD_OPTION_VALUE);
1370
+ const s = Object.keys(n);
1371
+ let r = s.length;
1372
+ for (; r-- > 0; ) {
1373
+ const i = s[r], o = e[i];
1374
+ if (o) {
1375
+ const c = n[i], h = c === void 0 || o(c, i, n);
1376
+ if (h !== !0)
1377
+ throw new y("option " + i + " must be " + h, y.ERR_BAD_OPTION_VALUE);
1378
+ continue;
1379
+ }
1380
+ if (t !== !0)
1381
+ throw new y("Unknown option " + i, y.ERR_BAD_OPTION);
1382
+ }
1383
+ }
1384
+ const le = {
1385
+ assertOptions: Ts,
1386
+ validators: be
1387
+ }, F = le.validators;
1388
+ let z = class {
1389
+ constructor(e) {
1390
+ this.defaults = e, this.interceptors = {
1391
+ request: new Xe(),
1392
+ response: new Xe()
1393
+ };
1394
+ }
1395
+ /**
1396
+ * Dispatch a request
1397
+ *
1398
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
1399
+ * @param {?Object} config
1400
+ *
1401
+ * @returns {Promise} The Promise to be fulfilled
1402
+ */
1403
+ async request(e, t) {
1404
+ try {
1405
+ return await this._request(e, t);
1406
+ } catch (s) {
1407
+ if (s instanceof Error) {
1408
+ let r = {};
1409
+ Error.captureStackTrace ? Error.captureStackTrace(r) : r = new Error();
1410
+ const i = r.stack ? r.stack.replace(/^.+\n/, "") : "";
1411
+ try {
1412
+ s.stack ? i && !String(s.stack).endsWith(i.replace(/^.+\n.+\n/, "")) && (s.stack += `
1413
+ ` + i) : s.stack = i;
1414
+ } catch {
1415
+ }
1416
+ }
1417
+ throw s;
1418
+ }
1419
+ }
1420
+ _request(e, t) {
1421
+ typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = V(this.defaults, t);
1422
+ const { transitional: s, paramsSerializer: r, headers: i } = t;
1423
+ s !== void 0 && le.assertOptions(s, {
1424
+ silentJSONParsing: F.transitional(F.boolean),
1425
+ forcedJSONParsing: F.transitional(F.boolean),
1426
+ clarifyTimeoutError: F.transitional(F.boolean)
1427
+ }, !1), r != null && (l.isFunction(r) ? t.paramsSerializer = {
1428
+ serialize: r
1429
+ } : le.assertOptions(r, {
1430
+ encode: F.function,
1431
+ serialize: F.function
1432
+ }, !0)), le.assertOptions(t, {
1433
+ baseUrl: F.spelling("baseURL"),
1434
+ withXsrfToken: F.spelling("withXSRFToken")
1435
+ }, !0), t.method = (t.method || this.defaults.method || "get").toLowerCase();
1436
+ let o = i && l.merge(
1437
+ i.common,
1438
+ i[t.method]
1439
+ );
1440
+ i && l.forEach(
1441
+ ["delete", "get", "head", "post", "put", "patch", "common"],
1442
+ (f) => {
1443
+ delete i[f];
1444
+ }
1445
+ ), t.headers = C.concat(o, i);
1446
+ const c = [];
1447
+ let h = !0;
1448
+ this.interceptors.request.forEach(function(m) {
1449
+ typeof m.runWhen == "function" && m.runWhen(t) === !1 || (h = h && m.synchronous, c.unshift(m.fulfilled, m.rejected));
1450
+ });
1451
+ const u = [];
1452
+ this.interceptors.response.forEach(function(m) {
1453
+ u.push(m.fulfilled, m.rejected);
1454
+ });
1455
+ let a, d = 0, g;
1456
+ if (!h) {
1457
+ const f = [rt.bind(this), void 0];
1458
+ for (f.unshift.apply(f, c), f.push.apply(f, u), g = f.length, a = Promise.resolve(t); d < g; )
1459
+ a = a.then(f[d++], f[d++]);
1460
+ return a;
1461
+ }
1462
+ g = c.length;
1463
+ let b = t;
1464
+ for (d = 0; d < g; ) {
1465
+ const f = c[d++], m = c[d++];
1466
+ try {
1467
+ b = f(b);
1468
+ } catch (p) {
1469
+ m.call(this, p);
1470
+ break;
1471
+ }
1472
+ }
1473
+ try {
1474
+ a = rt.call(this, b);
1475
+ } catch (f) {
1476
+ return Promise.reject(f);
1477
+ }
1478
+ for (d = 0, g = u.length; d < g; )
1479
+ a = a.then(u[d++], u[d++]);
1480
+ return a;
1481
+ }
1482
+ getUri(e) {
1483
+ e = V(this.defaults, e);
1484
+ const t = Lt(e.baseURL, e.url);
1485
+ return Ct(t, e.params, e.paramsSerializer);
1486
+ }
1487
+ };
1488
+ l.forEach(["delete", "get", "head", "options"], function(e) {
1489
+ z.prototype[e] = function(t, s) {
1490
+ return this.request(V(s || {}, {
1491
+ method: e,
1492
+ url: t,
1493
+ data: (s || {}).data
1494
+ }));
1495
+ };
1496
+ });
1497
+ l.forEach(["post", "put", "patch"], function(e) {
1498
+ function t(s) {
1499
+ return function(i, o, c) {
1500
+ return this.request(V(c || {}, {
1501
+ method: e,
1502
+ headers: s ? {
1503
+ "Content-Type": "multipart/form-data"
1504
+ } : {},
1505
+ url: i,
1506
+ data: o
1507
+ }));
1508
+ };
1509
+ }
1510
+ z.prototype[e] = t(), z.prototype[e + "Form"] = t(!0);
1511
+ });
1512
+ let Os = class Dt {
1513
+ constructor(e) {
1514
+ if (typeof e != "function")
1515
+ throw new TypeError("executor must be a function.");
1516
+ let t;
1517
+ this.promise = new Promise(function(i) {
1518
+ t = i;
1519
+ });
1520
+ const s = this;
1521
+ this.promise.then((r) => {
1522
+ if (!s._listeners) return;
1523
+ let i = s._listeners.length;
1524
+ for (; i-- > 0; )
1525
+ s._listeners[i](r);
1526
+ s._listeners = null;
1527
+ }), this.promise.then = (r) => {
1528
+ let i;
1529
+ const o = new Promise((c) => {
1530
+ s.subscribe(c), i = c;
1531
+ }).then(r);
1532
+ return o.cancel = function() {
1533
+ s.unsubscribe(i);
1534
+ }, o;
1535
+ }, e(function(i, o, c) {
1536
+ s.reason || (s.reason = new G(i, o, c), t(s.reason));
1537
+ });
1538
+ }
1539
+ /**
1540
+ * Throws a `CanceledError` if cancellation has been requested.
1541
+ */
1542
+ throwIfRequested() {
1543
+ if (this.reason)
1544
+ throw this.reason;
1545
+ }
1546
+ /**
1547
+ * Subscribe to the cancel signal
1548
+ */
1549
+ subscribe(e) {
1550
+ if (this.reason) {
1551
+ e(this.reason);
1552
+ return;
1553
+ }
1554
+ this._listeners ? this._listeners.push(e) : this._listeners = [e];
1555
+ }
1556
+ /**
1557
+ * Unsubscribe from the cancel signal
1558
+ */
1559
+ unsubscribe(e) {
1560
+ if (!this._listeners)
1561
+ return;
1562
+ const t = this._listeners.indexOf(e);
1563
+ t !== -1 && this._listeners.splice(t, 1);
1564
+ }
1565
+ toAbortSignal() {
1566
+ const e = new AbortController(), t = (s) => {
1567
+ e.abort(s);
1568
+ };
1569
+ return this.subscribe(t), e.signal.unsubscribe = () => this.unsubscribe(t), e.signal;
1570
+ }
1571
+ /**
1572
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
1573
+ * cancels the `CancelToken`.
1574
+ */
1575
+ static source() {
1576
+ let e;
1577
+ return {
1578
+ token: new Dt(function(r) {
1579
+ e = r;
1580
+ }),
1581
+ cancel: e
1582
+ };
1583
+ }
1584
+ };
1585
+ function Cs(n) {
1586
+ return function(t) {
1587
+ return n.apply(null, t);
1588
+ };
1589
+ }
1590
+ function ks(n) {
1591
+ return l.isObject(n) && n.isAxiosError === !0;
1592
+ }
1593
+ const Ie = {
1594
+ Continue: 100,
1595
+ SwitchingProtocols: 101,
1596
+ Processing: 102,
1597
+ EarlyHints: 103,
1598
+ Ok: 200,
1599
+ Created: 201,
1600
+ Accepted: 202,
1601
+ NonAuthoritativeInformation: 203,
1602
+ NoContent: 204,
1603
+ ResetContent: 205,
1604
+ PartialContent: 206,
1605
+ MultiStatus: 207,
1606
+ AlreadyReported: 208,
1607
+ ImUsed: 226,
1608
+ MultipleChoices: 300,
1609
+ MovedPermanently: 301,
1610
+ Found: 302,
1611
+ SeeOther: 303,
1612
+ NotModified: 304,
1613
+ UseProxy: 305,
1614
+ Unused: 306,
1615
+ TemporaryRedirect: 307,
1616
+ PermanentRedirect: 308,
1617
+ BadRequest: 400,
1618
+ Unauthorized: 401,
1619
+ PaymentRequired: 402,
1620
+ Forbidden: 403,
1621
+ NotFound: 404,
1622
+ MethodNotAllowed: 405,
1623
+ NotAcceptable: 406,
1624
+ ProxyAuthenticationRequired: 407,
1625
+ RequestTimeout: 408,
1626
+ Conflict: 409,
1627
+ Gone: 410,
1628
+ LengthRequired: 411,
1629
+ PreconditionFailed: 412,
1630
+ PayloadTooLarge: 413,
1631
+ UriTooLong: 414,
1632
+ UnsupportedMediaType: 415,
1633
+ RangeNotSatisfiable: 416,
1634
+ ExpectationFailed: 417,
1635
+ ImATeapot: 418,
1636
+ MisdirectedRequest: 421,
1637
+ UnprocessableEntity: 422,
1638
+ Locked: 423,
1639
+ FailedDependency: 424,
1640
+ TooEarly: 425,
1641
+ UpgradeRequired: 426,
1642
+ PreconditionRequired: 428,
1643
+ TooManyRequests: 429,
1644
+ RequestHeaderFieldsTooLarge: 431,
1645
+ UnavailableForLegalReasons: 451,
1646
+ InternalServerError: 500,
1647
+ NotImplemented: 501,
1648
+ BadGateway: 502,
1649
+ ServiceUnavailable: 503,
1650
+ GatewayTimeout: 504,
1651
+ HttpVersionNotSupported: 505,
1652
+ VariantAlsoNegotiates: 506,
1653
+ InsufficientStorage: 507,
1654
+ LoopDetected: 508,
1655
+ NotExtended: 510,
1656
+ NetworkAuthenticationRequired: 511
1657
+ };
1658
+ Object.entries(Ie).forEach(([n, e]) => {
1659
+ Ie[e] = n;
1660
+ });
1661
+ function qt(n) {
1662
+ const e = new z(n), t = gt(z.prototype.request, e);
1663
+ return l.extend(t, z.prototype, e, { allOwnKeys: !0 }), l.extend(t, e, null, { allOwnKeys: !0 }), t.create = function(r) {
1664
+ return qt(V(n, r));
1665
+ }, t;
1666
+ }
1667
+ const R = qt(te);
1668
+ R.Axios = z;
1669
+ R.CanceledError = G;
1670
+ R.CancelToken = Os;
1671
+ R.isCancel = Pt;
1672
+ R.VERSION = Ut;
1673
+ R.toFormData = me;
1674
+ R.AxiosError = y;
1675
+ R.Cancel = R.CanceledError;
1676
+ R.all = function(e) {
1677
+ return Promise.all(e);
1678
+ };
1679
+ R.spread = Cs;
1680
+ R.isAxiosError = ks;
1681
+ R.mergeConfig = V;
1682
+ R.AxiosHeaders = C;
1683
+ R.formToJSON = (n) => Nt(l.isHTMLForm(n) ? new FormData(n) : n);
1684
+ R.getAdapter = Ft.getAdapter;
1685
+ R.HttpStatusCode = Ie;
1686
+ R.default = R;
1687
+ const {
1688
+ Axios: Kr,
1689
+ AxiosError: Gr,
1690
+ CanceledError: Xr,
1691
+ isCancel: Zr,
1692
+ CancelToken: Qr,
1693
+ VERSION: Yr,
1694
+ all: ei,
1695
+ Cancel: ti,
1696
+ isAxiosError: ni,
1697
+ spread: si,
1698
+ toFormData: ri,
1699
+ AxiosHeaders: ii,
1700
+ HttpStatusCode: oi,
1701
+ formToJSON: ci,
1702
+ getAdapter: ai,
1703
+ mergeConfig: li
1704
+ } = R, De = R.create({
1705
+ baseURL: location.origin,
1706
+ timeout: 6e4,
1707
+ params: {}
1708
+ });
1709
+ De.interceptors.response.use(
1710
+ (n) => n,
1711
+ (n) => {
1712
+ var e, t, s, r, i, o, c, h, u, a, d;
1713
+ if (n.response) {
1714
+ if (n.response.status === 401 && OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity, !0).then(
1715
+ function(f) {
1716
+ f && OpenC3Auth.setTokens();
1717
+ }
1718
+ ), n.response.config.headers["Ignore-Errors"] && n.response.config.headers["Ignore-Errors"].includes(
1719
+ n.response.status.toString()
1720
+ ))
1721
+ return Promise.reject(n);
1722
+ let g = `HTTP ${n.response.status} - `;
1723
+ (e = n.response) != null && e.statusText && (g += `${n.response.statusText} `), (s = (t = n.response) == null ? void 0 : t.config) != null && s.data && (g += `${n.response.config.data} `), (i = (r = n.response) == null ? void 0 : r.data) != null && i.message ? g += `${n.response.data.message}` : (c = (o = n.response) == null ? void 0 : o.data) != null && c.exception ? g += `${n.response.data.exception}` : (a = (u = (h = n.response) == null ? void 0 : h.data) == null ? void 0 : u.error) != null && a.message ? (n.response.data.error.class && (g += `${n.response.data.error.class} `), g += `${n.response.data.error.message}`) : g += `${(d = n.response) == null ? void 0 : d.data}`;
1724
+ const { $cosmosNotify: b } = window;
1725
+ throw b && b.serious({
1726
+ title: "Network error",
1727
+ body: g
1728
+ }), n;
1729
+ } else
1730
+ throw n;
1731
+ }
1732
+ );
1733
+ const re = async function(n, e, {
1734
+ data: t,
1735
+ params: s = {},
1736
+ headers: r,
1737
+ noAuth: i = !1,
1738
+ noScope: o = !1,
1739
+ onUploadProgress: c = !1
1740
+ } = {}) {
1741
+ if (!i) {
1742
+ try {
1743
+ await OpenC3Auth.updateToken(
1744
+ OpenC3Auth.defaultMinValidity
1745
+ ) && OpenC3Auth.setTokens();
1746
+ } catch {
1747
+ OpenC3Auth.login();
1748
+ }
1749
+ r.Authorization = localStorage.openc3Token;
1750
+ }
1751
+ return r.manual = !0, !o && !s.scope && (s.scope = window.openc3Scope), De({
1752
+ method: n,
1753
+ url: e,
1754
+ data: t,
1755
+ params: s,
1756
+ headers: r,
1757
+ onUploadProgress: c
1758
+ });
1759
+ }, Le = {
1760
+ Accept: "application/json"
1761
+ }, ot = {
1762
+ ...Le,
1763
+ "Content-Type": "application/json"
1764
+ }, ui = {
1765
+ get: function(n, {
1766
+ params: e,
1767
+ headers: t = Le,
1768
+ noScope: s,
1769
+ noAuth: r,
1770
+ onUploadProgress: i
1771
+ } = {}) {
1772
+ return re("get", n, {
1773
+ params: e,
1774
+ headers: t,
1775
+ noScope: s,
1776
+ noAuth: r,
1777
+ onUploadProgress: i
1778
+ });
1779
+ },
1780
+ put: function(n, {
1781
+ data: e,
1782
+ params: t,
1783
+ headers: s = ot,
1784
+ noScope: r,
1785
+ noAuth: i,
1786
+ onUploadProgress: o
1787
+ } = {}) {
1788
+ return re("put", n, {
1789
+ data: e,
1790
+ params: t,
1791
+ headers: s,
1792
+ noScope: r,
1793
+ noAuth: i,
1794
+ onUploadProgress: o
1795
+ });
1796
+ },
1797
+ post: function(n, {
1798
+ data: e,
1799
+ params: t,
1800
+ headers: s = ot,
1801
+ noScope: r,
1802
+ noAuth: i,
1803
+ onUploadProgress: o
1804
+ } = {}) {
1805
+ return re("post", n, {
1806
+ data: e,
1807
+ params: t,
1808
+ headers: s,
1809
+ noScope: r,
1810
+ noAuth: i,
1811
+ onUploadProgress: o
1812
+ });
1813
+ },
1814
+ delete: function(n, {
1815
+ params: e,
1816
+ headers: t = Le,
1817
+ noScope: s,
1818
+ noAuth: r,
1819
+ onUploadProgress: i
1820
+ } = {}) {
1821
+ return re("delete", n, {
1822
+ params: e,
1823
+ headers: t,
1824
+ noScope: s,
1825
+ noAuth: r,
1826
+ onUploadProgress: i
1827
+ });
1828
+ }
1829
+ };
1830
+ let ye = () => ({
1831
+ emit(n, ...e) {
1832
+ for (let t = this.events[n] || [], s = 0, r = t.length; s < r; s++)
1833
+ t[s](...e);
1834
+ },
1835
+ events: {},
1836
+ on(n, e) {
1837
+ var t;
1838
+ return ((t = this.events)[n] || (t[n] = [])).push(e), () => {
1839
+ var s;
1840
+ this.events[n] = (s = this.events[n]) == null ? void 0 : s.filter((r) => e !== r);
1841
+ };
1842
+ }
1843
+ });
1844
+ class ne extends Error {
1845
+ constructor(e, t) {
1846
+ e instanceof Error ? (super(e.message), this.cause = e) : super(e), this.reason = t, this.name = "ReasonError";
1847
+ }
1848
+ }
1849
+ class qe extends ne {
1850
+ constructor(e) {
1851
+ super("Rejected", e), this.name = "SubscriptionRejectedError";
1852
+ }
1853
+ }
1854
+ class Ns extends ne {
1855
+ constructor(e) {
1856
+ super(e || "Timed out to receive subscription ack"), this.name = "SubscriptionTimeoutError";
1857
+ }
1858
+ }
1859
+ class j extends ne {
1860
+ constructor(e, t) {
1861
+ t ? super(e, t) : super("Disconnected", e), this.name = "DisconnectedError";
1862
+ }
1863
+ }
1864
+ class Ps extends j {
1865
+ constructor(e) {
1866
+ super(e, "stale_connection"), this.name = "StaleConnectionError";
1867
+ }
1868
+ }
1869
+ function Bt(n) {
1870
+ return n ? `{${Object.keys(n).sort().filter((t) => n[t] !== void 0).map((t) => {
1871
+ let s = JSON.stringify(n[t]);
1872
+ return `${JSON.stringify(t)}:${s}`;
1873
+ }).join(",")}}` : "";
1874
+ }
1875
+ class Is {
1876
+ constructor(e) {
1877
+ this.channel = e, this.listeners = [];
1878
+ }
1879
+ watch() {
1880
+ this.listeners.push(
1881
+ this.channel.on("presence", (e) => {
1882
+ if (e.type === "info") {
1883
+ this._state || (this._state = this.stateFromInfo(e));
1884
+ return;
1885
+ }
1886
+ this._state && (e.type === "join" ? this._state[e.id] = e.info : e.type === "leave" && delete this._state[e.id]);
1887
+ })
1888
+ );
1889
+ }
1890
+ // Reset the state to make sure the fresh one is
1891
+ // requested the next time info() is called
1892
+ reset() {
1893
+ delete this._state;
1894
+ }
1895
+ dispose() {
1896
+ delete this._info, delete this._state, this.listeners.forEach((e) => e()), this.listeners.length = 0;
1897
+ }
1898
+ async join(e, t) {
1899
+ if (!this._info)
1900
+ return this._info = { id: e, info: t }, this.channel.perform("$presence:join", this._info);
1901
+ }
1902
+ async leave() {
1903
+ if (!this._info) return;
1904
+ let e = await this.channel.perform("$presence:leave");
1905
+ return delete this._info, e;
1906
+ }
1907
+ async info() {
1908
+ return this._state ? this._state : (this._promise || (this._promise = this._sync()), await this._promise, this._state);
1909
+ }
1910
+ async _sync() {
1911
+ this.watch();
1912
+ try {
1913
+ let e = await this.channel.perform("$presence:info", {});
1914
+ return this._state = this.stateFromInfo(e), this._state;
1915
+ } finally {
1916
+ delete this._promise;
1917
+ }
1918
+ }
1919
+ stateFromInfo(e) {
1920
+ return e.records.reduce((t, { id: s, info: r }) => (t[s] = r, t), {});
1921
+ }
1922
+ }
1923
+ const B = Symbol("state");
1924
+ class Mt {
1925
+ // Unique channel identifier
1926
+ // static identifier = ''
1927
+ constructor(e = {}) {
1928
+ this.emitter = ye(), this.params = Object.freeze(e), this.presence = new Is(this), this.initialConnect = !0, this[B] = "idle";
1929
+ }
1930
+ get identifier() {
1931
+ return this._identifier ? this._identifier : (this._identifier = Bt({
1932
+ channel: this.channelId,
1933
+ ...this.params
1934
+ }), this._identifier);
1935
+ }
1936
+ get channelId() {
1937
+ return this.constructor.identifier;
1938
+ }
1939
+ get state() {
1940
+ return this[B];
1941
+ }
1942
+ attached(e) {
1943
+ if (this.receiver) {
1944
+ if (this.receiver !== e)
1945
+ throw Error("Already connected to a different receiver");
1946
+ return !1;
1947
+ }
1948
+ return this.receiver = e, !0;
1949
+ }
1950
+ connecting() {
1951
+ this[B] = "connecting";
1952
+ }
1953
+ connected() {
1954
+ if (this.state === "connected" || this.state === "closed") return;
1955
+ this[B] = "connected";
1956
+ let e = !1;
1957
+ this.initialConnect ? (this.initialConnect = !1, this.emit("connect", { reconnect: !1, restored: e })) : this.emit("connect", { reconnect: !0, restored: e });
1958
+ }
1959
+ restored() {
1960
+ if (this.state === "connected") throw Error("Already connected");
1961
+ this[B] = "connected";
1962
+ let e = !0, t = !0;
1963
+ this.initialConnect = !1, this.emit("connect", { reconnect: t, restored: e });
1964
+ }
1965
+ disconnected(e) {
1966
+ this.state === "disconnected" || this.state === "closed" || (this[B] = "disconnected", this.presence.reset(), this.emit("disconnect", e));
1967
+ }
1968
+ closed(e) {
1969
+ this.state !== "closed" && (this[B] = "closed", delete this.receiver, this.initialConnect = !0, this.presence.dispose(), this.emit("close", e));
1970
+ }
1971
+ disconnect() {
1972
+ this.state === "idle" || this.state === "closed" || this.receiver.unsubscribe(this);
1973
+ }
1974
+ async perform(e, t) {
1975
+ if (this.state === "idle" || this.state === "closed")
1976
+ throw Error("Channel is not subscribed");
1977
+ return this.receiver.perform(this.identifier, e, t);
1978
+ }
1979
+ async send(e) {
1980
+ return this.perform(void 0, e);
1981
+ }
1982
+ async whisper(e) {
1983
+ try {
1984
+ await this.perform("$whisper", e);
1985
+ } catch (t) {
1986
+ let s = this.receiver ? this.receiver.logger : null;
1987
+ s && s.warn("whisper failed: ", t);
1988
+ }
1989
+ }
1990
+ receive(e, t) {
1991
+ this.emit("message", e, t);
1992
+ }
1993
+ on(e, t) {
1994
+ return this.emitter.on(e, t);
1995
+ }
1996
+ once(e, t) {
1997
+ let s = this.emitter.on(e, (...r) => {
1998
+ s(), t(...r);
1999
+ });
2000
+ return s;
2001
+ }
2002
+ emit(e, ...t) {
2003
+ return this.emitter.emit(e, ...t);
2004
+ }
2005
+ ensureSubscribed() {
2006
+ return this.state === "connected" ? Promise.resolve() : this.state === "closed" ? Promise.reject(Error("Channel is unsubscribed")) : this.pendingSubscribe();
2007
+ }
2008
+ // This promise resolves when subscription is confirmed
2009
+ // and rejects when rejected or closed.
2010
+ // It ignores disconnect events.
2011
+ pendingSubscribe() {
2012
+ return this._pendingSubscribe ? this._pendingSubscribe : (this._pendingSubscribe = new Promise((e, t) => {
2013
+ let s = [() => delete this._pendingSubscribe];
2014
+ s.push(
2015
+ this.on("connect", () => {
2016
+ s.forEach((r) => r()), e();
2017
+ })
2018
+ ), s.push(
2019
+ this.on("close", (r) => {
2020
+ s.forEach((i) => i()), t(
2021
+ r || new ne(
2022
+ "Channel was disconnected before subscribing",
2023
+ "canceled"
2024
+ )
2025
+ );
2026
+ })
2027
+ );
2028
+ }), this._pendingSubscribe);
2029
+ }
2030
+ }
2031
+ class Ls {
2032
+ constructor(e) {
2033
+ this.id = e, this.intent = "unsubscribed", this.state = "idle", this.channels = [], this.disposed = !1, this._pendings = [];
2034
+ }
2035
+ add(e) {
2036
+ this.channels.includes(e) || this.channels.push(e);
2037
+ }
2038
+ remove(e) {
2039
+ let t = this.channels.indexOf(e);
2040
+ t > -1 && this.channels.splice(t, 1);
2041
+ }
2042
+ notify(e, ...t) {
2043
+ this.state = e === "restored" ? "connected" : e, t.length === 1 ? this.channels.forEach((s) => s[e](t[0])) : this.channels.forEach((s) => s[e]());
2044
+ }
2045
+ pending(e) {
2046
+ this._checkIntent(e);
2047
+ let t = this._pendings[0];
2048
+ return !t || t.intent !== e ? Promise.resolve() : t.promise;
2049
+ }
2050
+ ensureResubscribed() {
2051
+ this.disposed || (this.intent = void 0, this.ensureSubscribed());
2052
+ }
2053
+ ensureSubscribed() {
2054
+ if (this.intent === "subscribed") return;
2055
+ if (this.disposed) throw Error("Subscription is disposed");
2056
+ this.intent = "subscribed", !this._mergeWithPending("unsubscribed") && this.subscriber(this);
2057
+ }
2058
+ maybeUnsubscribe() {
2059
+ this.disposed || this.intent === "unsubscribed" || this.channels.length > 0 || (this.intent = "unsubscribed", this._mergeWithPending("subscribed")) || this.unsubscriber(this);
2060
+ }
2061
+ async acquire(e) {
2062
+ this._checkIntent(e);
2063
+ let t, r = {
2064
+ promise: new Promise((o) => {
2065
+ t = o;
2066
+ }),
2067
+ intent: e,
2068
+ release: () => {
2069
+ this._pendings.splice(this._pendings.indexOf(r), 1), t(r);
2070
+ },
2071
+ canceled: !1,
2072
+ acquired: !1
2073
+ }, i = this._pendingTop;
2074
+ return this._pendings.push(r), i && await i.promise, this.gvl && await this.gvl.acquire(r, e), r.acquired = !0, r;
2075
+ }
2076
+ close(e) {
2077
+ this.disposed = !0, this.intent = void 0, this.notify("closed", e);
2078
+ }
2079
+ _checkIntent(e) {
2080
+ if (!(e === "unsubscribed" || e === "subscribed"))
2081
+ throw Error(`Unknown subscription intent: ${e}`);
2082
+ }
2083
+ get _pendingTop() {
2084
+ return this._pendings.length ? this._pendings[this._pendings.length - 1] : void 0;
2085
+ }
2086
+ _mergeWithPending(e) {
2087
+ let t = this._pendingTop;
2088
+ return !t || t.acquired || t.intent !== e ? !1 : (this._pendings.pop(), t.canceled = !0, !0);
2089
+ }
2090
+ }
2091
+ class vs {
2092
+ constructor() {
2093
+ this.queue = [];
2094
+ }
2095
+ async acquire(e, t) {
2096
+ t === "subscribed" && (this.queue.push(
2097
+ e.promise.then(() => {
2098
+ this.queue.splice(this.queue.indexOf(e), 1);
2099
+ })
2100
+ ), this.queue.length > 1 && await this.queue[this.queue.length - 2]);
2101
+ }
2102
+ }
2103
+ class js {
2104
+ constructor(e) {
2105
+ e.concurrentSubscribes === !1 && (this.glv = new vs()), this._subscriptions = {}, this._localToRemote = {};
2106
+ }
2107
+ all() {
2108
+ return Object.values(this._subscriptions);
2109
+ }
2110
+ get(e) {
2111
+ return this._subscriptions[e];
2112
+ }
2113
+ create(e, { subscribe: t, unsubscribe: s }) {
2114
+ let r = this._subscriptions[e] = new Ls(e);
2115
+ return r.remoteId = this._localToRemote[e], r.subscriber = t, r.unsubscriber = s, r.gvl = this.glv, r;
2116
+ }
2117
+ remove(e) {
2118
+ delete this._subscriptions[e], delete this._localToRemote[e];
2119
+ }
2120
+ storeRemoteId(e, t) {
2121
+ this._localToRemote[e] = t;
2122
+ let s = this.get(e);
2123
+ s && (s.remoteId = t);
2124
+ }
2125
+ }
2126
+ class $s {
2127
+ constructor(e = {}) {
2128
+ this.subscriptions = new js(e), this._pendingMessages = [], this._remoteToLocal = {};
2129
+ }
2130
+ subscribe(e, t) {
2131
+ this._remoteToLocal[t] = e, this.subscriptions.storeRemoteId(e, t), this.flush(t);
2132
+ }
2133
+ unsubscribe(e) {
2134
+ let t = this.subscriptions.get(e);
2135
+ if (!t) return;
2136
+ let s = t.remoteId;
2137
+ s && delete this._remoteToLocal[s], this.subscriptions.remove(e);
2138
+ }
2139
+ transmit(e, t, s) {
2140
+ let r = this._remoteToLocal[e];
2141
+ if (!r) {
2142
+ this._pendingMessages.push([e, t, s]);
2143
+ return;
2144
+ }
2145
+ let i = this.subscriptions.get(r);
2146
+ i && i.channels.forEach((o) => {
2147
+ o.receive(t, s);
2148
+ });
2149
+ }
2150
+ notify(e, t, s) {
2151
+ let r = this._remoteToLocal[e];
2152
+ if (!r)
2153
+ return;
2154
+ let i = this.subscriptions.get(r);
2155
+ i && i.channels.forEach((o) => o.emit(t, s));
2156
+ }
2157
+ close() {
2158
+ this._pendingMessages.length = 0;
2159
+ }
2160
+ get size() {
2161
+ return this.channels.length;
2162
+ }
2163
+ get channels() {
2164
+ return this.subscriptions.all().flatMap((e) => e.channels);
2165
+ }
2166
+ flush(e) {
2167
+ let t = [];
2168
+ for (let s of this._pendingMessages)
2169
+ s[0] === e ? this.transmit(s[0], s[1], s[2]) : t.push(s);
2170
+ this._pendingMessages = t;
2171
+ }
2172
+ }
2173
+ const ct = {
2174
+ debug: 0,
2175
+ info: 1,
2176
+ warn: 2,
2177
+ error: 3
2178
+ };
2179
+ class Ht {
2180
+ constructor(e) {
2181
+ this.level = e || "warn";
2182
+ }
2183
+ log(e, t, s) {
2184
+ ct[e] < ct[this.level] || this.writeLogEntry(e, t, s);
2185
+ }
2186
+ writeLogEntry() {
2187
+ throw Error("Not implemented");
2188
+ }
2189
+ debug(e, t) {
2190
+ this.log("debug", e, t);
2191
+ }
2192
+ info(e, t) {
2193
+ this.log("info", e, t);
2194
+ }
2195
+ warn(e, t) {
2196
+ this.log("warn", e, t);
2197
+ }
2198
+ error(e, t) {
2199
+ this.log("error", e, t);
2200
+ }
2201
+ }
2202
+ class se extends Ht {
2203
+ writeLogEntry() {
2204
+ }
2205
+ }
2206
+ class Fs {
2207
+ encode(e) {
2208
+ return JSON.stringify(e);
2209
+ }
2210
+ decode(e) {
2211
+ try {
2212
+ return JSON.parse(e);
2213
+ } catch {
2214
+ }
2215
+ }
2216
+ }
2217
+ let Us = 0;
2218
+ class zt {
2219
+ constructor(e = {}) {
2220
+ let { logger: t } = e;
2221
+ this.logger = t || new se(), this.pendingSubscriptions = {}, this.pendingUnsubscriptions = {}, this.subscribeCooldownInterval = e.subscribeCooldownInterval || 250, this.subscribeRetryInterval = e.subscribeRetryInterval || 5e3;
2222
+ }
2223
+ attached(e) {
2224
+ this.cable = e;
2225
+ }
2226
+ subscribe(e, t) {
2227
+ let s = { channel: e };
2228
+ t && Object.assign(s, t);
2229
+ let r = Bt(s);
2230
+ if (this.pendingUnsubscriptions[r]) {
2231
+ let o = this.subscribeCooldownInterval * 1.5;
2232
+ return this.logger.debug(
2233
+ `unsubscribed recently, cooldown for ${o}`,
2234
+ r
2235
+ ), new Promise((c) => {
2236
+ setTimeout(() => {
2237
+ c(this.subscribe(e, t));
2238
+ }, o);
2239
+ });
2240
+ }
2241
+ if (this.pendingSubscriptions[r])
2242
+ return this.logger.warn("subscription is already pending, skipping", r), Promise.reject(Error("Already subscribing"));
2243
+ let i = this.subscribeRetryInterval;
2244
+ return new Promise((o, c) => {
2245
+ let h = ++Us;
2246
+ this.pendingSubscriptions[r] = {
2247
+ resolve: o,
2248
+ reject: c,
2249
+ id: h
2250
+ }, this.cable.send(this.buildSubscribeRequest(r)), this.maybeRetrySubscribe(h, r, i);
2251
+ });
2252
+ }
2253
+ buildSubscribeRequest(e) {
2254
+ return {
2255
+ command: "subscribe",
2256
+ identifier: e
2257
+ };
2258
+ }
2259
+ maybeRetrySubscribe(e, t, s) {
2260
+ setTimeout(() => {
2261
+ let r = this.pendingSubscriptions[t];
2262
+ r && r.id === e && (this.logger.warn(
2263
+ `no subscription ack received in ${s}ms, retrying subscribe`,
2264
+ t
2265
+ ), this.cable.send(this.buildSubscribeRequest(t)), this.maybeExpireSubscribe(e, t, s));
2266
+ }, s);
2267
+ }
2268
+ maybeExpireSubscribe(e, t, s) {
2269
+ setTimeout(() => {
2270
+ let r = this.pendingSubscriptions[t];
2271
+ r && r.id === e && (delete this.pendingSubscriptions[t], r.reject(
2272
+ new Ns(
2273
+ `Haven't received subscription ack in ${s * 2}ms for ${t}`
2274
+ )
2275
+ ));
2276
+ }, s);
2277
+ }
2278
+ unsubscribe(e) {
2279
+ return this.cable.send({
2280
+ command: "unsubscribe",
2281
+ identifier: e
2282
+ }), this.pendingUnsubscriptions[e] = !0, setTimeout(() => {
2283
+ delete this.pendingUnsubscriptions[e];
2284
+ }, this.subscribeCooldownInterval), Promise.resolve();
2285
+ }
2286
+ perform(e, t, s) {
2287
+ return t === "$whisper" ? this.whisper(e, s) : (s || (s = {}), s.action = t, this.cable.send({
2288
+ command: "message",
2289
+ identifier: e,
2290
+ data: JSON.stringify(s)
2291
+ }), Promise.resolve());
2292
+ }
2293
+ whisper(e, t) {
2294
+ return this.cable.send({
2295
+ command: "whisper",
2296
+ identifier: e,
2297
+ data: t
2298
+ }), Promise.resolve();
2299
+ }
2300
+ receive(e) {
2301
+ if (typeof e != "object") {
2302
+ this.logger.error("unsupported message format", { message: e });
2303
+ return;
2304
+ }
2305
+ let { type: t, identifier: s, message: r, reason: i, reconnect: o } = e;
2306
+ if (t === "ping")
2307
+ return this.cable.keepalive(e.message);
2308
+ if (this.cable.keepalive(), t === "welcome") {
2309
+ let c = e.sid;
2310
+ return c && this.cable.setSessionId(c), this.cable.connected();
2311
+ }
2312
+ if (t === "disconnect") {
2313
+ let c = new j(i);
2314
+ this.reset(c), o === !1 ? this.cable.closed(c) : this.cable.disconnected(c);
2315
+ return;
2316
+ }
2317
+ if (t === "confirm_subscription") {
2318
+ let c = this.pendingSubscriptions[s];
2319
+ if (!c) {
2320
+ this.logger.error("subscription not found, unsubscribing", {
2321
+ type: t,
2322
+ identifier: s
2323
+ }), this.unsubscribe(s);
2324
+ return;
2325
+ }
2326
+ return delete this.pendingSubscriptions[s], c.resolve(s);
2327
+ }
2328
+ if (t === "reject_subscription") {
2329
+ let c = this.pendingSubscriptions[s];
2330
+ return c ? (delete this.pendingSubscriptions[s], c.reject(new qe())) : this.logger.error("subscription not found", { type: t, identifier: s });
2331
+ }
2332
+ if (r)
2333
+ return { identifier: s, message: r };
2334
+ this.logger.warn(`unknown message type: ${t}`, { message: e });
2335
+ }
2336
+ reset(e) {
2337
+ for (let t in this.pendingSubscriptions)
2338
+ this.pendingSubscriptions[t].reject(e);
2339
+ this.pendingSubscriptions = {};
2340
+ }
2341
+ recoverableClosure() {
2342
+ return !1;
2343
+ }
2344
+ }
2345
+ const at = () => Date.now() / 1e3 | 0;
2346
+ class Ds extends zt {
2347
+ constructor(e = {}) {
2348
+ super(e), this.streamsPositions = {}, this.subscriptionStreams = {}, this.pendingHistory = {}, this.pendingPresence = {}, this.presenceInfo = {}, this.restoreSince = e.historyTimestamp, this.restoreSince === void 0 && (this.restoreSince = at()), this.sessionId = void 0, this.sendPongs = e.pongs;
2349
+ }
2350
+ reset(e) {
2351
+ for (let t in this.pendingPresence)
2352
+ this.pendingPresence[t].reject(e);
2353
+ return this.pendingPresence = {}, super.reset();
2354
+ }
2355
+ receive(e) {
2356
+ if (typeof e != "object") {
2357
+ this.logger.error("unsupported message format", { message: e });
2358
+ return;
2359
+ }
2360
+ let { type: t, identifier: s, message: r } = e;
2361
+ if (t === "disconnect" || t === "reject_subscription")
2362
+ return super.receive(e);
2363
+ if (t === "confirm_subscription")
2364
+ return this.subscriptionStreams[s] || (this.subscriptionStreams[s] = /* @__PURE__ */ new Set()), super.receive(e);
2365
+ if (t === "ping")
2366
+ return this.restoreSince && (this.restoreSince = at()), this.sendPongs && this.sendPong(), this.cable.keepalive(e.message);
2367
+ if (this.cable.keepalive(), t === "confirm_history") {
2368
+ this.logger.debug("history result received", e), this.cable.notify("history_received", s);
2369
+ return;
2370
+ }
2371
+ if (t === "reject_history") {
2372
+ this.logger.warn("failed to retrieve history", e), this.cable.notify("history_not_found", s);
2373
+ return;
2374
+ }
2375
+ if (t === "welcome") {
2376
+ if (this.sessionId = e.sid, this.sessionId && this.cable.setSessionId(this.sessionId), e.restored) {
2377
+ let i = e.restored_ids || Object.keys(this.subscriptionStreams);
2378
+ for (let o of i)
2379
+ this.cable.send({
2380
+ identifier: o,
2381
+ command: "history",
2382
+ history: this.historyRequestFor(o)
2383
+ }), this.presenceInfo[o] && this.cable.send({
2384
+ identifier: o,
2385
+ command: "join",
2386
+ presence: this.presenceInfo[o]
2387
+ });
2388
+ return this.cable.restored(i);
2389
+ }
2390
+ return this.cable.connected(this.sessionId);
2391
+ }
2392
+ if (t === "presence") {
2393
+ let i = r.type;
2394
+ if (i === "info") {
2395
+ let o = this.pendingPresence[s];
2396
+ o && (delete this.pendingPresence[s], o.resolve(r));
2397
+ } else if (i === "error") {
2398
+ let o = this.pendingPresence[s];
2399
+ o && (delete this.pendingPresence[s], o.reject(new Error("failed to retrieve presence")));
2400
+ }
2401
+ return {
2402
+ type: t,
2403
+ identifier: s,
2404
+ message: r
2405
+ };
2406
+ }
2407
+ if (r) {
2408
+ let i = this.trackStreamPosition(
2409
+ s,
2410
+ e.stream_id,
2411
+ e.epoch,
2412
+ e.offset
2413
+ );
2414
+ return { identifier: s, message: r, meta: i };
2415
+ }
2416
+ this.logger.warn(`unknown message type: ${t}`, { message: e });
2417
+ }
2418
+ perform(e, t, s) {
2419
+ switch (t) {
2420
+ case "$presence:join":
2421
+ return this.join(e, s);
2422
+ case "$presence:leave":
2423
+ return this.leave(e, s);
2424
+ case "$presence:info":
2425
+ return this.presence(e, s);
2426
+ }
2427
+ return super.perform(e, t, s);
2428
+ }
2429
+ unsubscribe(e) {
2430
+ return delete this.presenceInfo[e], super.unsubscribe(e);
2431
+ }
2432
+ buildSubscribeRequest(e) {
2433
+ let t = super.buildSubscribeRequest(e), s = this.historyRequestFor(e);
2434
+ s && (t.history = s, this.pendingHistory[e] = !0);
2435
+ let r = this.presenceInfo[e];
2436
+ return r && (t.presence = r), t;
2437
+ }
2438
+ // TODO: Which error can be non-recoverable?
2439
+ recoverableClosure() {
2440
+ return !!this.sessionId;
2441
+ }
2442
+ historyRequestFor(e) {
2443
+ let t = {}, s = !1;
2444
+ if (this.subscriptionStreams[e])
2445
+ for (let r of this.subscriptionStreams[e]) {
2446
+ let i = this.streamsPositions[r];
2447
+ i && (s = !0, t[r] = i);
2448
+ }
2449
+ if (!(!s && !this.restoreSince))
2450
+ return { since: this.restoreSince, streams: t };
2451
+ }
2452
+ trackStreamPosition(e, t, s, r) {
2453
+ if (!(!t || !s))
2454
+ return this.subscriptionStreams[e] || (this.subscriptionStreams[e] = /* @__PURE__ */ new Set()), this.subscriptionStreams[e].add(t), this.streamsPositions[t] = { epoch: s, offset: r }, { stream: t, epoch: s, offset: r };
2455
+ }
2456
+ // Send pongs asynchrounously—no need to block the main thread
2457
+ async sendPong() {
2458
+ await new Promise((e) => setTimeout(e, 0)), this.cable.state === "connected" && this.cable.send({ command: "pong" });
2459
+ }
2460
+ async join(e, t) {
2461
+ return this.presenceInfo[e] = t, this.cable.send({
2462
+ command: "join",
2463
+ identifier: e,
2464
+ presence: t
2465
+ }), Promise.resolve();
2466
+ }
2467
+ async leave(e, t) {
2468
+ return delete this.presenceInfo[e], this.cable.send({
2469
+ command: "leave",
2470
+ identifier: e,
2471
+ presence: t
2472
+ }), Promise.resolve();
2473
+ }
2474
+ presence(e, t) {
2475
+ return this.pendingPresence[e] ? (this.logger.warn("presence is already pending, skipping", e), Promise.reject(Error("presence request is already pending"))) : new Promise((s, r) => {
2476
+ this.pendingPresence[e] = {
2477
+ resolve: s,
2478
+ reject: r
2479
+ }, this.cable.send({
2480
+ command: "presence",
2481
+ identifier: e,
2482
+ data: t
2483
+ });
2484
+ });
2485
+ }
2486
+ }
2487
+ class qs extends ne {
2488
+ constructor() {
2489
+ super("No connection", "closed"), this.name = "NoConnectionError";
2490
+ }
2491
+ }
2492
+ class Be extends Mt {
2493
+ constructor(e, t) {
2494
+ super(t), this.channelId = e;
2495
+ }
2496
+ set channelId(e) {
2497
+ this._channelId = e;
2498
+ }
2499
+ get channelId() {
2500
+ return this._channelId;
2501
+ }
2502
+ }
2503
+ v(Be, "identifier", "__ghost__");
2504
+ const Bs = "$pubsub";
2505
+ class ve extends Mt {
2506
+ async perform(e, t) {
2507
+ if (e.startsWith("$"))
2508
+ return super.perform(e, t);
2509
+ throw Error("not implemented");
2510
+ }
2511
+ }
2512
+ v(ve, "identifier", Bs);
2513
+ const M = Symbol("state");
2514
+ let Ms = class {
2515
+ constructor({
2516
+ transport: e,
2517
+ protocol: t,
2518
+ encoder: s,
2519
+ logger: r,
2520
+ lazy: i,
2521
+ hubOptions: o,
2522
+ performFailures: c,
2523
+ transportConfigurator: h
2524
+ }) {
2525
+ this.emitter = ye(), this.transport = e, this.encoder = s, this.logger = r || new se(), this.protocol = t, this.performFailures = c || "throw", this.protocol.attached(this), this.hub = new $s(o || {}), this[M] = "idle", this.handleClose = this.handleClose.bind(this), this.handleIncoming = this.handleIncoming.bind(this), this.transportConfigurator = h, this.transport.on("close", this.handleClose), this.transport.on("data", this.handleIncoming), this.initialConnect = !0, this.recovering = !1, i === !1 && this.connect().catch(() => {
2526
+ });
2527
+ }
2528
+ get state() {
2529
+ return this[M];
2530
+ }
2531
+ async connect() {
2532
+ if (this.state === "connected") return Promise.resolve();
2533
+ if (this.state === "connecting")
2534
+ return this.pendingConnect();
2535
+ let e = this.state === "idle";
2536
+ this[M] = "connecting";
2537
+ let t = this.pendingConnect();
2538
+ this.logger.debug("connecting");
2539
+ try {
2540
+ this.transportConfigurator && await this.transportConfigurator(this.transport, {
2541
+ initial: e
2542
+ }), await this.transport.open();
2543
+ } catch (s) {
2544
+ this.handleClose(s);
2545
+ }
2546
+ return t;
2547
+ }
2548
+ setSessionId(e) {
2549
+ this.sessionId = e, this.transport.setParam("sid", e);
2550
+ }
2551
+ connected() {
2552
+ if (this.state === "connected") return;
2553
+ this.logger.info("connected"), this[M] = "connected", this.recovering && this.hub.subscriptions.all().forEach(
2554
+ (t) => t.notify(
2555
+ "disconnected",
2556
+ new j("recovery_failed")
2557
+ )
2558
+ ), this.hub.subscriptions.all().forEach((t) => this._resubscribe(t));
2559
+ let e = !1;
2560
+ this.recovering = !1, this.initialConnect ? (this.initialConnect = !1, this.emit("connect", { reconnect: !1, restored: e })) : this.emit("connect", { reconnect: !0, restored: e });
2561
+ }
2562
+ restored(e) {
2563
+ this.logger.info("connection recovered", { remoteIds: e }), this[M] = "connected", this.hub.subscriptions.all().forEach((r) => {
2564
+ e && r.remoteId && e.includes(r.remoteId) ? r.notify("restored") : (r.notify(
2565
+ "disconnected",
2566
+ new j("recovery_failed")
2567
+ ), this._resubscribe(r));
2568
+ });
2569
+ let t = !this.initialConnect, s = !0;
2570
+ this.recovering = !1, this.initialConnect = !1, this.emit("connect", { reconnect: t, restored: s });
2571
+ }
2572
+ notify(e, t, s) {
2573
+ t && typeof t != "string" && (s = t, t = void 0), t ? this.hub.notify(t, "info", { type: e, data: s }) : this.emit("info", { type: e, data: s });
2574
+ }
2575
+ handleClose(e) {
2576
+ this.logger.debug("transport closed", { error: e }), this.disconnected(new j(e, "transport_closed"));
2577
+ }
2578
+ disconnected(e) {
2579
+ (this.state === "connected" || this.state === "connecting") && (this.logger.info("disconnected", { reason: e }), this[M] = "disconnected", this.recovering = this.protocol.recoverableClosure(e), this.recovering ? this.hub.subscriptions.all().forEach((t) => t.notify("connecting")) : this.hub.subscriptions.all().forEach((t) => {
2580
+ t.notify("disconnected", e);
2581
+ }), this.protocol.reset(e), this.hub.close(), this.transport.close(), this.emit("disconnect", e));
2582
+ }
2583
+ closed(e) {
2584
+ if (this.state === "closed" || this.state === "idle") return;
2585
+ let t;
2586
+ e && (t = e instanceof j ? e : new j(e, void 0)), this.logger.info("closed", { reason: e || "user" }), this[M] = "closed";
2587
+ let s = t || new j("cable_closed");
2588
+ this.hub.subscriptions.all().forEach((r) => r.notify("disconnected", s)), this.hub.close(), this.protocol.reset(), this.transport.close(), this.initialConnect = !0, this.emit("close", t);
2589
+ }
2590
+ disconnect() {
2591
+ this.closed();
2592
+ }
2593
+ handleIncoming(e) {
2594
+ if (this.state === "closed" || this.state === "idle")
2595
+ return;
2596
+ let t = this.encoder.decode(e);
2597
+ if (t === void 0) {
2598
+ this.logger.error("failed to decode message", { message: e });
2599
+ return;
2600
+ }
2601
+ this.logger.debug("incoming data", t);
2602
+ let s = this.protocol.receive(t);
2603
+ if (s) {
2604
+ this.logger.debug("processed incoming message", s);
2605
+ let { type: r, identifier: i, message: o, meta: c } = s;
2606
+ r ? this.hub.notify(i, r, o) : this.hub.transmit(i, o, c);
2607
+ }
2608
+ }
2609
+ send(e) {
2610
+ if (this.state === "closed")
2611
+ throw Error("Cable is closed");
2612
+ let t = this.encoder.encode(e);
2613
+ if (t === void 0) {
2614
+ this.logger.error("failed to encode message", { message: e });
2615
+ return;
2616
+ }
2617
+ this.logger.debug("outgoing message", e), this.transport.send(t);
2618
+ }
2619
+ keepalive(e) {
2620
+ this.emit("keepalive", e);
2621
+ }
2622
+ streamFrom(e) {
2623
+ let t = new ve({ stream_name: e });
2624
+ return this.subscribe(t);
2625
+ }
2626
+ streamFromSigned(e) {
2627
+ let t = new ve({ signed_stream_name: e });
2628
+ return this.subscribe(t);
2629
+ }
2630
+ subscribeTo(e, t) {
2631
+ let s, r;
2632
+ return typeof e == "string" && (r = e, e = Be), s = r ? new e(r, t) : new e(t), this.subscribe(s);
2633
+ }
2634
+ subscribe(e) {
2635
+ if (!e.attached(this)) return e;
2636
+ let t = e.identifier;
2637
+ e.connecting();
2638
+ let s = this.hub.subscriptions.get(t) || this.hub.subscriptions.create(t, {
2639
+ subscribe: (r) => this._subscribe(r, e.channelId, e.params),
2640
+ unsubscribe: (r) => this._unsubscribe(r)
2641
+ });
2642
+ return s.add(e), s.intent === "subscribed" && s.state === "connected" && e.connected(), s.ensureSubscribed(), e;
2643
+ }
2644
+ async _resubscribe(e) {
2645
+ e.intent !== "subscribed" || !e.channels[0] || (e.notify("connecting"), e.ensureResubscribed());
2646
+ }
2647
+ async _subscribe(e, t, s) {
2648
+ let r = e.id;
2649
+ if (this.state === "idle" && this.connect().catch(() => {
2650
+ }), this.state !== "connected") {
2651
+ this.logger.debug("cancel subscribe, no connection", { identifier: r });
2652
+ return;
2653
+ }
2654
+ this.logger.debug("acquiring subscribe lock", { identifier: r });
2655
+ let i = await e.acquire("subscribed");
2656
+ if (i.canceled) {
2657
+ this.logger.debug("subscribe lock has been canceled", { identifier: r }), i.release();
2658
+ return;
2659
+ }
2660
+ if (this.logger.debug("subscribe lock has been acquired", { identifier: r }), e.intent !== "subscribed") {
2661
+ this.logger.debug("cancel subscribe request, already unsubscribed"), i.release();
2662
+ return;
2663
+ }
2664
+ if (this.state !== "connected") {
2665
+ this.logger.debug("cancel subscribe, no connection", { identifier: r }), i.release();
2666
+ return;
2667
+ }
2668
+ if (e.state === "connected") {
2669
+ this.logger.debug("already connected, skip subscribe command", {
2670
+ identifier: r
2671
+ }), e.notify("connected"), i.release();
2672
+ return;
2673
+ }
2674
+ let o = {
2675
+ identifier: t,
2676
+ params: s
2677
+ };
2678
+ this.logger.debug("subscribing", o);
2679
+ try {
2680
+ let c = await this.protocol.subscribe(t, s);
2681
+ this.hub.subscribe(r, c), this.logger.debug("subscribed", { ...o, remoteId: c }), e.notify("connected");
2682
+ } catch (c) {
2683
+ if (c) {
2684
+ if (c instanceof qe && this.logger.warn("rejected", o), c instanceof j) {
2685
+ this.logger.debug(
2686
+ "disconnected during subscription; will retry on connect",
2687
+ o
2688
+ ), i.release();
2689
+ return;
2690
+ }
2691
+ this.logger.error("failed to subscribe", {
2692
+ error: c,
2693
+ ...o
2694
+ });
2695
+ }
2696
+ e.close(c), this.hub.unsubscribe(r);
2697
+ }
2698
+ i.release();
2699
+ }
2700
+ unsubscribe(e) {
2701
+ let t = e.identifier, s = this.hub.subscriptions.get(t);
2702
+ if (!s)
2703
+ throw Error(`Subscription not found: ${t}`);
2704
+ s.remove(e), e.closed(), s.maybeUnsubscribe();
2705
+ }
2706
+ async _unsubscribe(e) {
2707
+ let t = e.id;
2708
+ this.logger.debug("acquiring unsubscribe lock", { identifier: t });
2709
+ let s = await e.acquire("unsubscribed");
2710
+ if (s.canceled) {
2711
+ this.logger.debug("unsubscribe lock has been canceled", { identifier: t }), s.release();
2712
+ return;
2713
+ }
2714
+ if (this.logger.debug("unsubscribe lock has been acquired", { identifier: t }), e.intent !== "unsubscribed") {
2715
+ this.logger.debug("cancel unsubscribe, no longer needed", {
2716
+ identifier: t,
2717
+ intent: e.intent
2718
+ }), s.release();
2719
+ return;
2720
+ }
2721
+ if (e.state === "disconnected" || e.state === "closed") {
2722
+ this.logger.debug(
2723
+ `already ${e.state} connected, skip unsubscribe command`,
2724
+ { identifier: t }
2725
+ ), s.release();
2726
+ return;
2727
+ }
2728
+ let r = e.remoteId;
2729
+ if (this.logger.debug("unsubscribing...", { remoteId: r }), this.state !== "connected") {
2730
+ this.logger.debug("unsubscribe skipped (cable is not connected)", {
2731
+ id: t
2732
+ }), e.close(), this.hub.unsubscribe(t), s.release();
2733
+ return;
2734
+ }
2735
+ try {
2736
+ await this.protocol.unsubscribe(r), this.logger.debug("unsubscribed remotely", { id: t });
2737
+ } catch (i) {
2738
+ i && (i instanceof j ? this.logger.debug(
2739
+ "cable disconnected during the unsubscribe command execution",
2740
+ { id: t, error: i }
2741
+ ) : this.logger.error("unsubscribe failed", {
2742
+ id: t,
2743
+ error: i
2744
+ }));
2745
+ }
2746
+ e.intent === "unsubscribed" ? (e.close(), this.hub.unsubscribe(t)) : e.state = "closed", s.release();
2747
+ }
2748
+ async perform(e, t, s) {
2749
+ if (this.performFailures === "throw")
2750
+ return this._perform(e, t, s);
2751
+ try {
2752
+ return await this._perform(e, t, s);
2753
+ } catch (r) {
2754
+ this.performFailures === "warn" && this.logger.warn("perform failed", { error: r });
2755
+ return;
2756
+ }
2757
+ }
2758
+ async _perform(e, t, s) {
2759
+ if (this.state === "connecting" && await this.pendingConnect(), this.state === "closed" || this.state === "disconnected")
2760
+ throw new qs();
2761
+ let r = this.hub.subscriptions.get(e);
2762
+ if (!r)
2763
+ throw Error(`Subscription not found: ${e}`);
2764
+ if (await r.pending("subscribed"), r.intent !== "subscribed")
2765
+ throw Error(`Subscription is closed: ${e}`);
2766
+ let i = r.remoteId, o = {
2767
+ id: i,
2768
+ action: t,
2769
+ payload: s
2770
+ };
2771
+ this.logger.debug("perform", o);
2772
+ try {
2773
+ let c = await this.protocol.perform(i, t, s);
2774
+ return c && this.logger.debug("perform result", {
2775
+ message: c,
2776
+ request: o
2777
+ }), c;
2778
+ } catch (c) {
2779
+ throw this.logger.error("perform failed", {
2780
+ error: c,
2781
+ request: o
2782
+ }), c;
2783
+ }
2784
+ }
2785
+ on(e, t) {
2786
+ return this.emitter.on(e, t);
2787
+ }
2788
+ once(e, t) {
2789
+ let s = this.emitter.on(e, (...r) => {
2790
+ s(), t(...r);
2791
+ });
2792
+ return s;
2793
+ }
2794
+ emit(e, ...t) {
2795
+ return this.emitter.emit(e, ...t);
2796
+ }
2797
+ pendingConnect() {
2798
+ return this._pendingConnect ? this._pendingConnect : (this._pendingConnect = new Promise((e, t) => {
2799
+ let s = [() => delete this._pendingConnect];
2800
+ s.push(
2801
+ this.on("connect", () => {
2802
+ s.forEach((r) => r()), e();
2803
+ })
2804
+ ), s.push(
2805
+ this.on("close", (r) => {
2806
+ s.forEach((i) => i()), t(r);
2807
+ })
2808
+ ), s.push(
2809
+ this.on("disconnect", (r) => {
2810
+ s.forEach((i) => i()), t(r);
2811
+ })
2812
+ );
2813
+ }), this._pendingConnect);
2814
+ }
2815
+ };
2816
+ const Hs = {
2817
+ maxMissingPings: 2,
2818
+ maxReconnectAttempts: 1 / 0
2819
+ }, W = () => Date.now(), Vt = (n, e) => {
2820
+ e = e || {};
2821
+ let { backoffRate: t, jitterRatio: s, maxInterval: r } = e;
2822
+ return t = t || 2, s === void 0 && (s = 0.5), (i) => {
2823
+ let o = n * t ** i, c = o * t, h = o + (c - o) * Math.random(), u = 2 * (Math.random() - 0.5) * s;
2824
+ return h = h * (1 + u), r && r < h && (h = r), h;
2825
+ };
2826
+ };
2827
+ let Jt = class {
2828
+ constructor({ pingInterval: e, ...t }) {
2829
+ if (this.pingInterval = e, !this.pingInterval)
2830
+ throw Error(`Incorrect pingInterval is provided: ${e}`);
2831
+ if (t = Object.assign({}, Hs, t), this.strategy = t.reconnectStrategy, !this.strategy)
2832
+ throw Error("Reconnect strategy must be provided");
2833
+ this.maxMissingPings = t.maxMissingPings, this.maxReconnectAttempts = t.maxReconnectAttempts, this.logger = t.logger || new se(), this.state = "pending_connect", this.attempts = 0, this.disconnectedAt = W();
2834
+ }
2835
+ watch(e) {
2836
+ this.target = e, this.initListeners();
2837
+ }
2838
+ reconnectNow() {
2839
+ return this.state === "connected" || this.state === "pending_connect" || this.state === "closed" ? !1 : (this.cancelReconnect(), this.state = "pending_connect", this.target.connect().catch((e) => {
2840
+ this.logger.info("Failed at reconnecting: " + e);
2841
+ }), !0);
2842
+ }
2843
+ initListeners() {
2844
+ this.unbind = [], this.unbind.push(
2845
+ this.target.on("connect", () => {
2846
+ this.attempts = 0, this.pingedAt = W(), this.state = "connected", this.cancelReconnect(), this.startPolling();
2847
+ })
2848
+ ), this.unbind.push(
2849
+ this.target.on("disconnect", () => {
2850
+ this.disconnectedAt = W(), this.state = "disconnected", this.stopPolling(), this.scheduleReconnect();
2851
+ })
2852
+ ), this.unbind.push(
2853
+ this.target.on("close", () => {
2854
+ this.disconnectedAt = W(), this.state = "closed", this.cancelReconnect(), this.stopPolling();
2855
+ })
2856
+ ), this.unbind.push(
2857
+ this.target.on("keepalive", () => {
2858
+ this.pingedAt = W();
2859
+ })
2860
+ ), this.unbind.push(() => {
2861
+ this.cancelReconnect(), this.stopPolling();
2862
+ });
2863
+ }
2864
+ dispose() {
2865
+ delete this.target, this.unbind && this.unbind.forEach((e) => e()), delete this.unbind;
2866
+ }
2867
+ startPolling() {
2868
+ this.pollId && clearTimeout(this.pollId);
2869
+ let e = this.pingInterval + (Math.random() - 0.5) * this.pingInterval * 0.5;
2870
+ this.pollId = setTimeout(() => {
2871
+ this.checkStale(), this.state === "connected" && this.startPolling();
2872
+ }, e);
2873
+ }
2874
+ stopPolling() {
2875
+ this.pollId && clearTimeout(this.pollId);
2876
+ }
2877
+ checkStale() {
2878
+ let e = W() - this.pingedAt;
2879
+ e > this.maxMissingPings * this.pingInterval && (this.logger.warn(`Stale connection: ${e}ms without pings`), this.state = "pending_disconnect", this.target.disconnected(new Ps()));
2880
+ }
2881
+ scheduleReconnect() {
2882
+ if (this.attempts >= this.maxReconnectAttempts) {
2883
+ this.target.close();
2884
+ return;
2885
+ }
2886
+ let e = this.strategy(this.attempts);
2887
+ this.attempts++, this.logger.info(`Reconnecting in ${e}ms (${this.attempts} attempt)`), this.state = "pending_reconnect", this.reconnnectId = setTimeout(() => this.reconnectNow(), e);
2888
+ }
2889
+ cancelReconnect() {
2890
+ this.reconnnectId && (clearTimeout(this.reconnnectId), delete this.reconnnectId);
2891
+ }
2892
+ };
2893
+ class zs {
2894
+ constructor(e, t = {}) {
2895
+ this.transports = e, this.transport = null, this.emitter = ye(), this.unbind = [], this.logger = t.logger || new se();
2896
+ }
2897
+ displayName() {
2898
+ return "fallbacked transport";
2899
+ }
2900
+ async open() {
2901
+ for (let e = 0; e < this.transports.length; e++) {
2902
+ let t = this.transports[e];
2903
+ try {
2904
+ this.transport = t, this.resetListeners(), this.logger.debug(`Trying to connect via ${t.displayName()}`), await t.open(), this.logger.debug(`Connected via ${t.displayName()}`);
2905
+ return;
2906
+ } catch (s) {
2907
+ this.logger.debug(
2908
+ `Failed to connect via ${t.displayName()}: ${s.message}`
2909
+ );
2910
+ }
2911
+ }
2912
+ throw this.transport = null, this.resetListeners(), new Error("Couldn't connect via any available transport");
2913
+ }
2914
+ send(e) {
2915
+ if (!this.transport)
2916
+ throw new Error("No transport is open");
2917
+ this.transport.send(e);
2918
+ }
2919
+ async close() {
2920
+ if (!this.transport)
2921
+ throw new Error("No transport is open");
2922
+ await this.transport.close(), this.transport = null;
2923
+ }
2924
+ setURL() {
2925
+ throw new Error("Not implemented. Set URL for each transport separately");
2926
+ }
2927
+ setParam(e, t) {
2928
+ this.transports.forEach((s) => {
2929
+ s.setParam(e, t);
2930
+ });
2931
+ }
2932
+ setToken(e, t) {
2933
+ this.transports.forEach((s) => {
2934
+ s.setToken(e, t);
2935
+ });
2936
+ }
2937
+ on(e, t) {
2938
+ return this.emitter.on(e, t);
2939
+ }
2940
+ once(e, t) {
2941
+ let s = this.emitter.on(e, (...r) => {
2942
+ s(), t(...r);
2943
+ });
2944
+ return s;
2945
+ }
2946
+ get url() {
2947
+ return this.transport ? this.transport.url : "";
2948
+ }
2949
+ resetListeners() {
2950
+ this.unbind.forEach((e) => e()), this.unbind.length = 0, this.transport && this.unbind.push(
2951
+ this.transport.on("open", () => {
2952
+ this.emitter.emit("open");
2953
+ }),
2954
+ this.transport.on("data", (e) => {
2955
+ this.emitter.emit("data", e);
2956
+ }),
2957
+ this.transport.on("close", (e) => {
2958
+ this.emitter.emit("close", e);
2959
+ }),
2960
+ this.transport.on("error", (e) => {
2961
+ this.emitter.emit("error", e);
2962
+ })
2963
+ );
2964
+ }
2965
+ }
2966
+ class Vs {
2967
+ constructor(e, t = {}) {
2968
+ this.url = e;
2969
+ let s = t.websocketImplementation;
2970
+ if (s)
2971
+ this.Impl = s;
2972
+ else if (typeof WebSocket < "u")
2973
+ this.Impl = WebSocket;
2974
+ else
2975
+ throw new Error("No WebSocket support");
2976
+ this.connected = !1, this.emitter = ye();
2977
+ let { format: r, subprotocol: i, authStrategy: o } = t;
2978
+ this.format = r || "text", this.connectionOptions = t.websocketOptions, this.authStrategy = o || "param", this.authProtocol = "", this.subprotocol = i;
2979
+ }
2980
+ displayName() {
2981
+ return "WebSocket(" + this.url + ")";
2982
+ }
2983
+ open() {
2984
+ let e = this.subprotocol;
2985
+ return this.authStrategy === "sub-protocol" && (e = [this.subprotocol, this.authProtocol]), this.connectionOptions ? this.ws = new this.Impl(this.url, e, this.connectionOptions) : this.ws = new this.Impl(this.url, e), this.ws.binaryType = "arraybuffer", this.initListeners(), new Promise((t, s) => {
2986
+ let r = [];
2987
+ r.push(
2988
+ this.once("open", () => {
2989
+ r.forEach((i) => i()), t();
2990
+ })
2991
+ ), r.push(
2992
+ this.once("close", () => {
2993
+ r.forEach((i) => i()), s(Error("WS connection closed"));
2994
+ })
2995
+ );
2996
+ });
2997
+ }
2998
+ setURL(e) {
2999
+ this.url = e;
3000
+ }
3001
+ setParam(e, t) {
3002
+ let s = new URL(this.url);
3003
+ s.searchParams.set(e, t);
3004
+ let r = `${s.protocol}//${s.host}${s.pathname}?${s.searchParams}`;
3005
+ this.setURL(r);
3006
+ }
3007
+ setToken(e, t = "jid") {
3008
+ if (this.authStrategy === "param")
3009
+ this.setParam(t, e);
3010
+ else if (this.authStrategy === "header") {
3011
+ this.connectionOptions = this.connectionOptions || {}, this.connectionOptions.headers = this.connectionOptions.headers || {};
3012
+ let s = `x-${t}`.toLowerCase();
3013
+ s = Object.keys(this.connectionOptions.headers).find(
3014
+ (i) => i.toLowerCase() === s
3015
+ ) || s, this.connectionOptions.headers[s] = e;
3016
+ } else if (this.authStrategy === "sub-protocol")
3017
+ this.authProtocol = `anycable-token.${e}`;
3018
+ else
3019
+ throw new Error("Unknown auth strategy: " + this.authStrategy);
3020
+ }
3021
+ send(e) {
3022
+ if (!this.ws || !this.connected)
3023
+ throw Error("WebSocket is not connected");
3024
+ this.ws.send(e);
3025
+ }
3026
+ close() {
3027
+ this.ws ? this.onclose() : this.connected = !1;
3028
+ }
3029
+ on(e, t) {
3030
+ return this.emitter.on(e, t);
3031
+ }
3032
+ once(e, t) {
3033
+ let s = this.emitter.on(e, (...r) => {
3034
+ s(), t(...r);
3035
+ });
3036
+ return s;
3037
+ }
3038
+ initListeners() {
3039
+ this.ws.onerror = (e) => {
3040
+ this.connected && this.emitter.emit("error", e.error || new Error("WS Error"));
3041
+ }, this.ws.onclose = () => {
3042
+ this.onclose();
3043
+ }, this.ws.onmessage = (e) => {
3044
+ let t = e.data;
3045
+ this.format === "binary" && (t = new Uint8Array(t)), this.emitter.emit("data", t);
3046
+ }, this.ws.onopen = () => {
3047
+ this.connected = !0, this.emitter.emit("open");
3048
+ };
3049
+ }
3050
+ onclose() {
3051
+ this.ws.onclose = void 0, this.ws.onmessage = void 0, this.ws.onopen = void 0, this.ws.close(), delete this.ws, this.connected = !1, this.emitter.emit("close");
3052
+ }
3053
+ }
3054
+ const Wt = {
3055
+ protocol: "actioncable-v1-json",
3056
+ pingInterval: 3e3,
3057
+ maxReconnectAttempts: 1 / 0,
3058
+ maxMissingPings: 2,
3059
+ logLevel: "warn",
3060
+ lazy: !0
3061
+ };
3062
+ function Js(n, e) {
3063
+ if (typeof n == "object" && typeof e > "u" && (e = n, n = void 0), e = e || {}, !n && !e.transport) throw Error("URL or transport must be specified");
3064
+ e = Object.assign({}, Wt, e);
3065
+ let {
3066
+ protocol: t,
3067
+ websocketImplementation: s,
3068
+ websocketFormat: r,
3069
+ websocketOptions: i,
3070
+ websocketAuthStrategy: o,
3071
+ fallbacks: c,
3072
+ logLevel: h,
3073
+ logger: u,
3074
+ transport: a,
3075
+ encoder: d,
3076
+ lazy: g,
3077
+ monitor: b,
3078
+ pingInterval: f,
3079
+ reconnectStrategy: m,
3080
+ maxMissingPings: p,
3081
+ maxReconnectAttempts: _,
3082
+ subprotocol: E,
3083
+ tokenRefresher: S,
3084
+ historyTimestamp: k,
3085
+ protocolOptions: x,
3086
+ concurrentSubscribes: P,
3087
+ performFailures: I,
3088
+ transportConfigurator: D,
3089
+ auth: U
3090
+ } = e;
3091
+ if (u = u || new se(h), typeof t == "string") {
3092
+ E = E || t;
3093
+ let J = t.substring(0, t.lastIndexOf("-")), O = t.substring(t.lastIndexOf("-") + 1);
3094
+ if (x = x || {}, J === "actioncable-v1")
3095
+ t = new zt({ logger: u, ...x });
3096
+ else if (J === "actioncable-v1-ext")
3097
+ t = new Ds({
3098
+ logger: u,
3099
+ historyTimestamp: k,
3100
+ ...x
3101
+ });
3102
+ else
3103
+ throw Error(`Protocol is not supported yet: ${t}`);
3104
+ if (O === "json")
3105
+ d = d || new Fs(), r = r || "text";
3106
+ else if (O === "msgpack") {
3107
+ if (r = "binary", !d)
3108
+ throw Error(
3109
+ "Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own"
3110
+ );
3111
+ } else if (O === "protobuf") {
3112
+ if (r = r || "binary", !d)
3113
+ throw Error(
3114
+ "Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own"
3115
+ );
3116
+ } else
3117
+ throw Error(`Protocol is not supported yet: ${t}`);
3118
+ }
3119
+ if (!t) throw Error("Protocol must be specified");
3120
+ a = a || new Vs(n, {
3121
+ websocketImplementation: s,
3122
+ websocketOptions: i,
3123
+ subprotocol: E,
3124
+ authStrategy: o,
3125
+ format: r
3126
+ }), c && (a = new zs([a, ...c], { logger: u })), U && U.token && a.setToken(U.token, U.param || "jid"), m = m || Vt(f), b !== !1 && (b = b || new Jt({
3127
+ pingInterval: f,
3128
+ reconnectStrategy: m,
3129
+ maxMissingPings: p,
3130
+ maxReconnectAttempts: _,
3131
+ logger: u
3132
+ }));
3133
+ let _e = { concurrentSubscribes: P }, L = new Ms({
3134
+ protocol: t,
3135
+ transport: a,
3136
+ encoder: d,
3137
+ logger: u,
3138
+ lazy: g,
3139
+ hubOptions: _e,
3140
+ performFailures: I,
3141
+ transportConfigurator: D
3142
+ });
3143
+ return b && (b.watch(L), L.monitor = b), S && Ws(L, async () => {
3144
+ try {
3145
+ await S(a);
3146
+ } catch (J) {
3147
+ return u.error("Failed to refresh authentication token: " + J), !1;
3148
+ }
3149
+ return L.connect().catch(() => {
3150
+ }), !0;
3151
+ }), L;
3152
+ }
3153
+ function Ws(n, e) {
3154
+ let t = !1;
3155
+ n.on("connect", () => t = !1), n.on("close", async (s) => {
3156
+ if (s) {
3157
+ if (t) {
3158
+ n.logger.warn("Token auto-refresh is disabled", s);
3159
+ return;
3160
+ }
3161
+ s.reason === "token_expired" && (t = !0, await e());
3162
+ }
3163
+ });
3164
+ }
3165
+ class Ks {
3166
+ constructor(e) {
3167
+ this.channel = e;
3168
+ }
3169
+ notify(e, ...t) {
3170
+ typeof this[e] == "function" && this[e](...t);
3171
+ }
3172
+ perform(e, t = {}) {
3173
+ this.channel.perform(e, t);
3174
+ }
3175
+ send(e) {
3176
+ this.channel.send(e);
3177
+ }
3178
+ get identifier() {
3179
+ return this.channel.identifier;
3180
+ }
3181
+ unsubscribe() {
3182
+ return this.channel.disconnect();
3183
+ }
3184
+ }
3185
+ class Gs extends Be {
3186
+ constructor(e, t, s) {
3187
+ super(e, t), this.subscription = new Ks(this), Object.assign(this.subscription, s), this.on("connect", () => this.subscription.notify("connected")), this.on(
3188
+ "disconnect",
3189
+ () => this.subscription.notify("disconnected", { allowReconnect: !0 })
3190
+ ), this.on("message", (r) => this.subscription.notify("received", r)), this.on("close", (r) => {
3191
+ r && r instanceof qe ? this.subscription.notify("rejected") : this.subscription.notify("disconnected", { allowReconnect: !1 });
3192
+ });
3193
+ }
3194
+ }
3195
+ class Xs {
3196
+ constructor(e) {
3197
+ this.cable = e;
3198
+ }
3199
+ create(e, t) {
3200
+ let s, r;
3201
+ typeof e == "object" ? (s = e.channel, delete e.channel, r = e) : (s = e, r = {});
3202
+ let i = new Gs(s, r, t);
3203
+ return i.subscription.notify("initialized"), this.cable.subscribe(i), i.subscription;
3204
+ }
3205
+ findAll(e) {
3206
+ return this.cable.hub.channels.filter((t) => t.identifier === e).map((t) => t.subscription);
3207
+ }
3208
+ }
3209
+ class Zs {
3210
+ constructor(e) {
3211
+ this.cable = e, this.subscriptions = new Xs(e);
3212
+ }
3213
+ }
3214
+ class Qs extends Ht {
3215
+ writeLogEntry(e, t, s) {
3216
+ s ? console[e](t, s) : console[e](t);
3217
+ }
3218
+ }
3219
+ class Ys extends Jt {
3220
+ watch(e) {
3221
+ super.watch(e), this.initActivityListeners();
3222
+ }
3223
+ initActivityListeners() {
3224
+ if (typeof document < "u" && typeof window < "u" && document.addEventListener && window.addEventListener) {
3225
+ let e = () => {
3226
+ document.hidden || this.reconnectNow() && this.logger.debug("Trigger reconnect due to visibility change");
3227
+ }, t = (r) => {
3228
+ this.reconnectNow() && this.logger.debug("Trigger reconnect", { event: r });
3229
+ }, s = () => this.disconnect(new j("page_frozen"));
3230
+ document.addEventListener("visibilitychange", e, !1), window.addEventListener("focus", t, !1), window.addEventListener("online", t, !1), window.addEventListener("resume", t, !1), window.addEventListener("freeze", s, !1), this.unbind.push(() => {
3231
+ document.removeEventListener("visibilitychange", e, !1), window.removeEventListener("focus", t, !1), window.removeEventListener("online", t, !1), window.removeEventListener("resume", t, !1), window.removeEventListener("freeze", s, !1);
3232
+ });
3233
+ }
3234
+ }
3235
+ disconnect(e) {
3236
+ this.state === "disconnected" || this.state === "closed" || (this.logger.info("Disconnecting", { reason: e.message }), this.cancelReconnect(), this.stopPolling(), this.state = "pending_disconnect", this.target.disconnected(e));
3237
+ }
3238
+ }
3239
+ const er = ["cable", "action-cable"], tr = "/cable", we = (n, e) => {
3240
+ for (let t of er) {
3241
+ let s = n.head.querySelector(`meta[name='${t}-${e}']`);
3242
+ if (s)
3243
+ return s.getAttribute("content");
3244
+ }
3245
+ }, lt = (n) => n.match(/wss?:\/\//) ? n : typeof window < "u" ? `${window.location.protocol.replace("http", "ws")}//${window.location.host}${n}` : n, nr = () => {
3246
+ if (typeof document < "u" && document.head) {
3247
+ let n = we(document, "url");
3248
+ if (n)
3249
+ return lt(n);
3250
+ }
3251
+ return lt(tr);
3252
+ }, sr = () => {
3253
+ if (typeof document < "u" && document.head) {
3254
+ let n = we(document, "history-timestamp");
3255
+ if (n)
3256
+ return n | 0;
3257
+ }
3258
+ }, rr = () => {
3259
+ if (typeof document < "u" && document.head)
3260
+ return we(document, "token");
3261
+ }, ir = () => {
3262
+ if (typeof document < "u" && document.head)
3263
+ return we(document, "token-param");
3264
+ };
3265
+ function or(n, e) {
3266
+ typeof n == "object" && typeof e > "u" && (e = n, n = void 0), n = n || nr(), e = e || {}, e.historyTimestamp || (e.historyTimestamp = sr());
3267
+ let t = rr();
3268
+ if (t) {
3269
+ let u = ir();
3270
+ e.auth = Object.assign({ token: t, param: u }, e.auth || {});
3271
+ }
3272
+ e = Object.assign({}, Wt, e);
3273
+ let {
3274
+ logLevel: s,
3275
+ logger: r,
3276
+ pingInterval: i,
3277
+ reconnectStrategy: o,
3278
+ maxMissingPings: c,
3279
+ maxReconnectAttempts: h
3280
+ } = e;
3281
+ return r = e.logger = e.logger || new Qs(s), o = e.reconnectStrategy = e.reconnectStrategy || Vt(i), e.monitor !== !1 && (e.monitor = e.monitor || new Ys({
3282
+ pingInterval: i,
3283
+ reconnectStrategy: o,
3284
+ maxMissingPings: c,
3285
+ maxReconnectAttempts: h,
3286
+ logger: r
3287
+ })), Js(n, e);
3288
+ }
3289
+ function cr(n, e) {
3290
+ let t = or(n, e);
3291
+ return new Zs(t);
3292
+ }
3293
+ class fi {
3294
+ constructor(e = "/openc3-api/cable") {
3295
+ this._cable = null, this._url = e;
3296
+ }
3297
+ disconnect() {
3298
+ this._cable && (this._cable.cable.disconnect(), this._cable = null);
3299
+ }
3300
+ createSubscription(e, t, s = {}, r = {}) {
3301
+ return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(
3302
+ (i) => {
3303
+ if (i && OpenC3Auth.setTokens(), this._cable == null) {
3304
+ let o = this._url + "?scope=" + encodeURIComponent(window.openc3Scope) + "&authorization=" + encodeURIComponent(localStorage.openc3Token);
3305
+ o = new URL(o, document.baseURI).href, this._cable = cr(o);
3306
+ }
3307
+ return this._cable.subscriptions.create(
3308
+ {
3309
+ channel: e,
3310
+ ...r
3311
+ },
3312
+ s
3313
+ );
3314
+ }
3315
+ );
3316
+ }
3317
+ recordPing() {
3318
+ }
3319
+ }
3320
+ class ut {
3321
+ constructor(e, t, s = "", r = "") {
3322
+ this.keyword = e.keyword, this.parameters = e.parameters, this.filename = e.filename, this.line = e.line, this.lineNumber = e.lineNumber, this.message = t, this.usage = s, this.url = r;
3323
+ }
3324
+ }
3325
+ class pi {
3326
+ constructor() {
3327
+ v(this, "keyword", null);
3328
+ v(this, "parameters", []);
3329
+ v(this, "filename", "");
3330
+ v(this, "line", "");
3331
+ v(this, "lineNumber", 0);
3332
+ v(this, "url", "https://docs.openc3.com/docs/configuration");
3333
+ }
3334
+ verify_num_parameters(e, t, s = "") {
3335
+ for (let r = 1; r <= e; r++)
3336
+ if (this.parameters[r - 1] === void 0)
3337
+ throw new ut(
3338
+ this,
3339
+ `Not enough parameters for ${this.keyword}.`,
3340
+ s,
3341
+ this.url
3342
+ );
3343
+ if (t && this.parameters[t] !== void 0)
3344
+ throw new ut(
3345
+ this,
3346
+ `Too many parameters for ${this.keyword}.`,
3347
+ s,
3348
+ this.url
3349
+ );
3350
+ }
3351
+ remove_quotes(e) {
3352
+ if (e.length < 2)
3353
+ return e;
3354
+ let t = e.charAt(0);
3355
+ if (t !== '"' && t !== "'")
3356
+ return e;
3357
+ let s = e.charAt(e.length - 1);
3358
+ return t !== s ? e : e.substring(1, e.length - 1);
3359
+ }
3360
+ scan_string(e, t) {
3361
+ if (!t.global) throw "rx must have 'global' flag set";
3362
+ let s = [];
3363
+ return e.replace(t, function(r) {
3364
+ return s.push(r), r;
3365
+ }), s;
3366
+ }
3367
+ parse_string(e, t, s, r, i) {
3368
+ let o = !1;
3369
+ this.line = "", this.keyword = null, this.parameters = [], this.filename = t;
3370
+ let c = e.split(`
3371
+ `), h = c.length;
3372
+ for (let u = 0; u < h; u++) {
3373
+ this.lineNumber = u + 1;
3374
+ let a = c[u].trim();
3375
+ if (a.length === 0)
3376
+ continue;
3377
+ if (o === !0) {
3378
+ if (a[0] === "#")
3379
+ continue;
3380
+ a = a.substring(1, a.length);
3381
+ }
3382
+ let d = a.charAt(a.length - 1), g = !1;
3383
+ switch (d) {
3384
+ case "+":
3385
+ g = !0;
3386
+ // Deliberate fall through
3387
+ case "\\":
3388
+ let _ = a.substring(0, a.length - 1).trim();
3389
+ this.line += _.substring(0, _.length - 1), g && (this.line += `
3390
+ `), o = !0;
3391
+ continue;
3392
+ case "&":
3393
+ this.line += a.substring(0, a.length - 1);
3394
+ continue;
3395
+ default:
3396
+ this.line += a;
3397
+ }
3398
+ o = !1;
3399
+ let b = /("([^\\"]|\\.)*")|('([^\\']|\\.)*')|\S+/g, f = this.scan_string(this.line, b), m = "";
3400
+ if (f.length > 0 && (m = m + f[0]), m.length === 0 || m.charAt(0) === "#" ? this.keyword = null : this.keyword = m.toUpperCase(), this.parameters = [], this.keyword === null) {
3401
+ s && i(this.keyword, this.parameters, this.line, this.lineNumber), this.line = "";
3402
+ continue;
3403
+ }
3404
+ let p = f.length;
3405
+ if (p > 1)
3406
+ for (let _ = 1; _ < p; _++) {
3407
+ let E = f[_];
3408
+ if (E.length > 0 && E.charAt(0) === "#")
3409
+ break;
3410
+ r ? this.parameters.push(this.remove_quotes(E)) : this.parameters.push(E);
3411
+ }
3412
+ i(this.keyword, this.parameters, this.line, this.lineNumber), this.line = "";
3413
+ }
3414
+ }
3415
+ // parse_string
3416
+ }
3417
+ function Me(n) {
3418
+ return ar.test(n);
3419
+ }
3420
+ const ar = /^-?[0-9]+$/;
3421
+ function Kt(n) {
3422
+ return lr.test(n);
3423
+ }
3424
+ const lr = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
3425
+ function Gt(n, e) {
3426
+ const t = Number.parseFloat(n), s = String(t), r = ht(n), i = ht(s);
3427
+ return !!(r === i || (e == null ? void 0 : e.approx) === !0 && !Me(n) && i.length >= 14 && r.startsWith(i.substring(0, 14)));
3428
+ }
3429
+ let Q = /* @__PURE__ */ function(n) {
3430
+ return n.underflow = "underflow", n.overflow = "overflow", n.truncate_integer = "truncate_integer", n.truncate_float = "truncate_float", n;
3431
+ }({});
3432
+ function ur(n) {
3433
+ if (Gt(n, {
3434
+ approx: !1
3435
+ }))
3436
+ return;
3437
+ if (Me(n))
3438
+ return Q.truncate_integer;
3439
+ const e = Number.parseFloat(n);
3440
+ return Number.isFinite(e) ? e === 0 ? Q.underflow : Q.truncate_float : Q.overflow;
3441
+ }
3442
+ function ht(n) {
3443
+ return n.replace(hr, "").replace(fr, "").replace(pr, "").replace(dr, "");
3444
+ }
3445
+ const hr = /[eE][+-]?\d+$/, dr = /^-?(0*)?/, fr = /\./, pr = /0+$/;
3446
+ class mr {
3447
+ constructor(e) {
3448
+ // numeric value as string
3449
+ // type information
3450
+ v(this, "isLosslessNumber", !0);
3451
+ if (!Kt(e))
3452
+ throw new Error(`Invalid number (value: "${e}")`);
3453
+ this.value = e;
3454
+ }
3455
+ /**
3456
+ * Get the value of the LosslessNumber as number or bigint.
3457
+ *
3458
+ * - a number is returned for safe numbers and decimal values that only lose some insignificant digits
3459
+ * - a bigint is returned for big integer numbers
3460
+ * - an Error is thrown for values that will overflow or underflow
3461
+ *
3462
+ * Note that you can implement your own strategy for conversion by just getting the value as string
3463
+ * via .toString(), and using util functions like isInteger, isSafeNumber, getUnsafeNumberReason,
3464
+ * and toSafeNumberOrThrow to convert it to a numeric value.
3465
+ */
3466
+ valueOf() {
3467
+ const e = ur(this.value);
3468
+ if (e === void 0 || e === Q.truncate_float)
3469
+ return Number.parseFloat(this.value);
3470
+ if (Me(this.value))
3471
+ return BigInt(this.value);
3472
+ throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${e} and become ${Number.parseFloat(this.value)}`);
3473
+ }
3474
+ /**
3475
+ * Get the value of the LosslessNumber as string.
3476
+ */
3477
+ toString() {
3478
+ return this.value;
3479
+ }
3480
+ // Note: we do NOT implement a .toJSON() method, and you should not implement
3481
+ // or use that, it cannot safely turn the numeric value in the string into
3482
+ // stringified JSON since it has to be parsed into a number first.
3483
+ }
3484
+ function gr(n) {
3485
+ return n && typeof n == "object" && n.isLosslessNumber === !0 || !1;
3486
+ }
3487
+ function br(n) {
3488
+ return new mr(n);
3489
+ }
3490
+ function yr(n, e) {
3491
+ return He({
3492
+ "": n
3493
+ }, "", n, e);
3494
+ }
3495
+ function He(n, e, t, s) {
3496
+ return Array.isArray(t) ? s.call(n, e, _r(t, s)) : t && typeof t == "object" && !gr(t) ? s.call(n, e, wr(t, s)) : s.call(n, e, t);
3497
+ }
3498
+ function wr(n, e) {
3499
+ for (const t of Object.keys(n)) {
3500
+ const s = He(n, t, n[t], e);
3501
+ s !== void 0 ? n[t] = s : delete n[t];
3502
+ }
3503
+ return n;
3504
+ }
3505
+ function _r(n, e) {
3506
+ for (let t = 0; t < n.length; t++)
3507
+ n[t] = He(n, String(t), n[t], e);
3508
+ return n;
3509
+ }
3510
+ function Er(n, e) {
3511
+ let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : br, s = 0;
3512
+ const r = c();
3513
+ return f(r), p(), e ? yr(r, e) : r;
3514
+ function i() {
3515
+ if (n.charCodeAt(s) === Or) {
3516
+ s++, u();
3517
+ const w = {};
3518
+ let A = !0;
3519
+ for (; s < n.length && n.charCodeAt(s) !== ft; ) {
3520
+ A ? A = !1 : (g(), u());
3521
+ const q = s, X = a();
3522
+ if (X === void 0) {
3523
+ S();
3524
+ return;
3525
+ }
3526
+ u(), b();
3527
+ const Ee = c();
3528
+ if (Ee === void 0) {
3529
+ U();
3530
+ return;
3531
+ }
3532
+ Object.prototype.hasOwnProperty.call(w, X) && !je(Ee, w[X]) && k(X, q + 1), w[X] = Ee;
3533
+ }
3534
+ return n.charCodeAt(s) !== ft && x(), s++, w;
3535
+ }
3536
+ }
3537
+ function o() {
3538
+ if (n.charCodeAt(s) === Cr) {
3539
+ s++, u();
3540
+ const w = [];
3541
+ let A = !0;
3542
+ for (; s < n.length && n.charCodeAt(s) !== pt; ) {
3543
+ A ? A = !1 : g();
3544
+ const q = c();
3545
+ m(q), w.push(q);
3546
+ }
3547
+ return n.charCodeAt(s) !== pt && P(), s++, w;
3548
+ }
3549
+ }
3550
+ function c() {
3551
+ u();
3552
+ const w = a() ?? d() ?? i() ?? o() ?? h("true", !0) ?? h("false", !1) ?? h("null", null);
3553
+ return u(), w;
3554
+ }
3555
+ function h(w, A) {
3556
+ if (n.slice(s, s + w.length) === w)
3557
+ return s += w.length, A;
3558
+ }
3559
+ function u() {
3560
+ for (; Sr(n.charCodeAt(s)); )
3561
+ s++;
3562
+ }
3563
+ function a() {
3564
+ if (n.charCodeAt(s) === Te) {
3565
+ s++;
3566
+ let w = "";
3567
+ for (; s < n.length && n.charCodeAt(s) !== Te; ) {
3568
+ if (n.charCodeAt(s) === Tr) {
3569
+ const A = n[s + 1], q = Ar[A];
3570
+ q !== void 0 ? (w += q, s++) : A === "u" ? ie(n.charCodeAt(s + 2)) && ie(n.charCodeAt(s + 3)) && ie(n.charCodeAt(s + 4)) && ie(n.charCodeAt(s + 5)) ? (w += String.fromCharCode(Number.parseInt(n.slice(s + 2, s + 6), 16)), s += 5) : _e(s) : D(s);
3571
+ } else
3572
+ Rr(n.charCodeAt(s)) ? w += n[s] : I(n[s]);
3573
+ s++;
3574
+ }
3575
+ return E(), s++, w;
3576
+ }
3577
+ }
3578
+ function d() {
3579
+ const w = s;
3580
+ if (n.charCodeAt(s) === mt && (s++, _(w)), n.charCodeAt(s) === ze)
3581
+ s++;
3582
+ else if (xr(n.charCodeAt(s)))
3583
+ for (s++; oe(n.charCodeAt(s)); )
3584
+ s++;
3585
+ if (n.charCodeAt(s) === $r)
3586
+ for (s++, _(w); oe(n.charCodeAt(s)); )
3587
+ s++;
3588
+ if (n.charCodeAt(s) === Br || n.charCodeAt(s) === qr)
3589
+ for (s++, (n.charCodeAt(s) === mt || n.charCodeAt(s) === Lr) && s++, _(w); oe(n.charCodeAt(s)); )
3590
+ s++;
3591
+ if (s > w)
3592
+ return t(n.slice(w, s));
3593
+ }
3594
+ function g() {
3595
+ if (n.charCodeAt(s) !== jr)
3596
+ throw new SyntaxError(`Comma ',' expected after value ${O()}`);
3597
+ s++;
3598
+ }
3599
+ function b() {
3600
+ if (n.charCodeAt(s) !== Fr)
3601
+ throw new SyntaxError(`Colon ':' expected after property name ${O()}`);
3602
+ s++;
3603
+ }
3604
+ function f(w) {
3605
+ if (w === void 0)
3606
+ throw new SyntaxError(`JSON value expected ${O()}`);
3607
+ }
3608
+ function m(w) {
3609
+ if (w === void 0)
3610
+ throw new SyntaxError(`Array item expected ${O()}`);
3611
+ }
3612
+ function p() {
3613
+ if (s < n.length)
3614
+ throw new SyntaxError(`Expected end of input ${O()}`);
3615
+ }
3616
+ function _(w) {
3617
+ if (!oe(n.charCodeAt(s))) {
3618
+ const A = n.slice(w, s);
3619
+ throw new SyntaxError(`Invalid number '${A}', expecting a digit ${O()}`);
3620
+ }
3621
+ }
3622
+ function E() {
3623
+ if (n.charCodeAt(s) !== Te)
3624
+ throw new SyntaxError(`End of string '"' expected ${O()}`);
3625
+ }
3626
+ function S() {
3627
+ throw new SyntaxError(`Quoted object key expected ${O()}`);
3628
+ }
3629
+ function k(w, A) {
3630
+ throw new SyntaxError(`Duplicate key '${w}' encountered at position ${A}`);
3631
+ }
3632
+ function x() {
3633
+ throw new SyntaxError(`Quoted object key or end of object '}' expected ${O()}`);
3634
+ }
3635
+ function P() {
3636
+ throw new SyntaxError(`Array item or end of array ']' expected ${O()}`);
3637
+ }
3638
+ function I(w) {
3639
+ throw new SyntaxError(`Invalid character '${w}' ${L()}`);
3640
+ }
3641
+ function D(w) {
3642
+ const A = n.slice(w, w + 2);
3643
+ throw new SyntaxError(`Invalid escape character '${A}' ${L()}`);
3644
+ }
3645
+ function U() {
3646
+ throw new SyntaxError(`Object value expected after ':' ${L()}`);
3647
+ }
3648
+ function _e(w) {
3649
+ const A = n.slice(w, w + 6);
3650
+ throw new SyntaxError(`Invalid unicode character '${A}' ${L()}`);
3651
+ }
3652
+ function L() {
3653
+ return `at position ${s}`;
3654
+ }
3655
+ function J() {
3656
+ return s < n.length ? `but got '${n[s]}'` : "but reached end of input";
3657
+ }
3658
+ function O() {
3659
+ return `${J()} ${L()}`;
3660
+ }
3661
+ }
3662
+ function Sr(n) {
3663
+ return n === kr || n === Nr || n === Pr || n === Ir;
3664
+ }
3665
+ function ie(n) {
3666
+ return n >= ze && n <= Ve || n >= Ur && n <= Mr || n >= Dr && n <= Hr;
3667
+ }
3668
+ function oe(n) {
3669
+ return n >= ze && n <= Ve;
3670
+ }
3671
+ function xr(n) {
3672
+ return n >= vr && n <= Ve;
3673
+ }
3674
+ function Rr(n) {
3675
+ return n >= 32 && n <= 1114111;
3676
+ }
3677
+ function je(n, e) {
3678
+ return n === e ? !0 : Array.isArray(n) && Array.isArray(e) ? n.length === e.length && n.every((t, s) => je(t, e[s])) : dt(n) && dt(e) ? [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(e)])].every((s) => je(n[s], e[s])) : !1;
3679
+ }
3680
+ function dt(n) {
3681
+ return typeof n == "object" && n !== null;
3682
+ }
3683
+ const Ar = {
3684
+ '"': '"',
3685
+ "\\": "\\",
3686
+ "/": "/",
3687
+ b: "\b",
3688
+ f: "\f",
3689
+ n: `
3690
+ `,
3691
+ r: "\r",
3692
+ t: " "
3693
+ // note that \u is handled separately in parseString()
3694
+ }, Tr = 92, Or = 123, ft = 125, Cr = 91, pt = 93, kr = 32, Nr = 10, Pr = 9, Ir = 13, Te = 34, Lr = 43, mt = 45, ze = 48, vr = 49, Ve = 57, jr = 44, $r = 46, Fr = 58, Ur = 65, Dr = 97, qr = 69, Br = 101, Mr = 70, Hr = 102;
3695
+ function Xt(n, e, t, s) {
3696
+ const r = void 0;
3697
+ return o(n, "");
3698
+ function o(a, d) {
3699
+ if (Array.isArray(s)) {
3700
+ const g = s.find((b) => b.test(a));
3701
+ if (g) {
3702
+ const b = g.stringify(a);
3703
+ if (typeof b != "string" || !Kt(b))
3704
+ throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${b})`);
3705
+ return b;
3706
+ }
3707
+ }
3708
+ if (typeof a == "boolean" || typeof a == "number" || typeof a == "string" || a === null || a instanceof Date || a instanceof Boolean || a instanceof Number || a instanceof String)
3709
+ return JSON.stringify(a);
3710
+ if (a != null && a.isLosslessNumber || typeof a == "bigint")
3711
+ return a.toString();
3712
+ if (Array.isArray(a))
3713
+ return c(a, d);
3714
+ if (a && typeof a == "object")
3715
+ return h(a, d);
3716
+ }
3717
+ function c(a, d) {
3718
+ if (a.length === 0)
3719
+ return "[]";
3720
+ const g = r ? d + r : void 0;
3721
+ let b = r ? `[
3722
+ ` : "[";
3723
+ for (let f = 0; f < a.length; f++) {
3724
+ const m = a[f];
3725
+ r && (b += g), typeof m < "u" && typeof m != "function" ? b += o(m, g) : b += "null", f < a.length - 1 && (b += r ? `,
3726
+ ` : ",");
3727
+ }
3728
+ return b += r ? `
3729
+ ${d}]` : "]", b;
3730
+ }
3731
+ function h(a, d) {
3732
+ if (typeof a.toJSON == "function")
3733
+ return Xt(a.toJSON(), e, t, void 0);
3734
+ const g = Array.isArray(e) ? e.map(String) : Object.keys(a);
3735
+ if (g.length === 0)
3736
+ return "{}";
3737
+ const b = r ? d + r : void 0;
3738
+ let f = !0, m = r ? `{
3739
+ ` : "{";
3740
+ for (const p of g) {
3741
+ const _ = a[p];
3742
+ if (u(p, _)) {
3743
+ f ? f = !1 : m += r ? `,
3744
+ ` : ",";
3745
+ const E = JSON.stringify(p);
3746
+ m += r ? `${b + E}: ` : `${E}:`, m += o(_, b);
3747
+ }
3748
+ }
3749
+ return m += r ? `
3750
+ ${d}}` : "}", m;
3751
+ }
3752
+ function u(a, d) {
3753
+ return typeof d < "u" && typeof d != "function" && typeof d != "symbol";
3754
+ }
3755
+ }
3756
+ function zr(n) {
3757
+ return Gt(n) ? parseFloat(n) : BigInt(n);
3758
+ }
3759
+ class mi {
3760
+ constructor() {
3761
+ v(this, "id", 1);
3762
+ }
3763
+ async exec(e, t, s = {}, r = {}, i = 6e4) {
3764
+ try {
3765
+ await OpenC3Auth.updateToken(
3766
+ OpenC3Auth.defaultMinValidity
3767
+ ) && OpenC3Auth.setTokens();
3768
+ } catch {
3769
+ OpenC3Auth.login();
3770
+ }
3771
+ this.id = this.id + 1;
3772
+ try {
3773
+ return s.scope = window.openc3Scope, r.manual = !0, (await De.post(
3774
+ "/openc3-api/api",
3775
+ {
3776
+ jsonrpc: "2.0",
3777
+ method: e,
3778
+ params: t,
3779
+ id: this.id,
3780
+ keyword_params: s
3781
+ },
3782
+ {
3783
+ headers: {
3784
+ Authorization: localStorage.openc3Token,
3785
+ "Content-Type": "application/json-rpc",
3786
+ ...r
3787
+ },
3788
+ timeout: i,
3789
+ transformRequest: [
3790
+ (c, h) => Xt(c)
3791
+ ],
3792
+ transformResponse: [
3793
+ (c) => Er(c, void 0, zr)
3794
+ ]
3795
+ }
3796
+ )).data.result;
3797
+ } catch (o) {
3798
+ let c = new Error();
3799
+ throw o.response ? (c.name = o.response.data.error.data.class, c.message = o.response.data.error.data.message, c.object = o.response.data.error) : o.request ? (c.name = "Request error", c.message = "Request error, no response received") : c.name = "Unknown error", c;
3800
+ }
3801
+ }
3802
+ decode_openc3_type(e) {
3803
+ if (e !== null && typeof e == "object" && e.json_class == "Float" && e.raw) {
3804
+ if (e.raw == "NaN")
3805
+ return NaN;
3806
+ if (e.raw == "Infinity")
3807
+ return 1 / 0;
3808
+ if (e.raw == "-Infinity")
3809
+ return -1 / 0;
3810
+ }
3811
+ return null;
3812
+ }
3813
+ encode_openc3_type(e) {
3814
+ return Number.isNaN(e) ? { json_class: "Float", raw: "NaN" } : e == Number.POSITIVE_INFINITY ? { json_class: "Float", raw: "Infinity" } : e == Number.NEGATIVE_INFINITY ? { json_class: "Float", raw: "-Infinity" } : null;
3815
+ }
3816
+ ensure_offline_access() {
3817
+ this.offline_access_needed().then((e) => {
3818
+ e && (localStorage.openc3OfflineToken ? this.set_offline_access(localStorage.openc3OfflineToken).then(() => {
3819
+ delete localStorage.openc3OfflineToken;
3820
+ }) : OpenC3Auth.getOfflineAccess());
3821
+ });
3822
+ }
3823
+ // ***********************************************
3824
+ // The following APIs are used by the CmdTlmServer
3825
+ // ***********************************************
3826
+ offline_access_needed() {
3827
+ return this.exec("offline_access_needed", []);
3828
+ }
3829
+ set_offline_access(e) {
3830
+ return this.exec("set_offline_access", [e]);
3831
+ }
3832
+ get_all_interface_info() {
3833
+ return this.exec("get_all_interface_info", []);
3834
+ }
3835
+ map_target_to_interface(e, t) {
3836
+ return this.exec("map_target_to_interface", [e, t]);
3837
+ }
3838
+ connect_interface(e, ...t) {
3839
+ return t.length > 0 ? this.exec("connect_interface", [
3840
+ e,
3841
+ ...t
3842
+ ]) : this.exec("connect_interface", [e]);
3843
+ }
3844
+ disconnect_interface(e) {
3845
+ return this.exec("disconnect_interface", [e]);
3846
+ }
3847
+ interface_cmd(e, t, ...s) {
3848
+ return this.exec("interface_cmd", [
3849
+ e,
3850
+ t,
3851
+ ...s
3852
+ ]);
3853
+ }
3854
+ get_all_router_info() {
3855
+ return this.exec("get_all_router_info", []);
3856
+ }
3857
+ connect_router(e) {
3858
+ return this.exec("connect_router", [e]);
3859
+ }
3860
+ disconnect_router(e) {
3861
+ return this.exec("disconnect_router", [e]);
3862
+ }
3863
+ get_target_interfaces() {
3864
+ return this.exec("get_target_interfaces", []);
3865
+ }
3866
+ get_tlm_cnts(e) {
3867
+ return this.exec("get_tlm_cnts", [e]);
3868
+ }
3869
+ get_item(e, t, s) {
3870
+ return this.exec("get_item", [e, t, s]);
3871
+ }
3872
+ get_param(e, t, s) {
3873
+ return this.exec("get_param", [e, t, s]);
3874
+ }
3875
+ // DEPRECATED for get_param
3876
+ get_parameter(e, t, s) {
3877
+ return this.exec("get_param", [e, t, s]);
3878
+ }
3879
+ get_limits_sets() {
3880
+ return this.exec("get_limits_sets", []);
3881
+ }
3882
+ get_limits_set() {
3883
+ return this.exec("get_limits_set", []);
3884
+ }
3885
+ set_limits_set(e) {
3886
+ return this.exec("set_limits_set", [e]);
3887
+ }
3888
+ // ***********************************************
3889
+ // End CmdTlmServer APIs
3890
+ // ***********************************************
3891
+ get_target(e) {
3892
+ return this.exec("get_target", [e]);
3893
+ }
3894
+ get_target_names() {
3895
+ return this.exec("get_target_names", []);
3896
+ }
3897
+ // DEPRECATED for get_target_names
3898
+ get_target_list() {
3899
+ return this.exec("get_target_names", []);
3900
+ }
3901
+ get_tlm(e, t) {
3902
+ return this.exec("get_tlm", [e, t]);
3903
+ }
3904
+ // DEPRECATED for get_tlm
3905
+ get_telemetry(e, t) {
3906
+ return this.exec("get_tlm", [e, t]);
3907
+ }
3908
+ get_all_tlm(e) {
3909
+ return this.exec("get_all_tlm", [e]);
3910
+ }
3911
+ // DEPRECATED for get_all_tlm
3912
+ get_all_telemetry(e) {
3913
+ return this.exec("get_all_tlm", [e]);
3914
+ }
3915
+ get_all_tlm_names(e, t = !1) {
3916
+ return this.exec("get_all_tlm_names", [e], { hidden: t });
3917
+ }
3918
+ // DEPRECATED for get_all_tlm_names
3919
+ get_all_telemetry_names(e) {
3920
+ return this.exec("get_all_tlm_names", [e]);
3921
+ }
3922
+ async get_tlm_packet(e, t, s, r = 30) {
3923
+ const i = await this.exec("get_tlm_packet", [e, t], {
3924
+ type: s,
3925
+ stale_time: r
3926
+ });
3927
+ if (i != null) {
3928
+ let o = i.length, c = null;
3929
+ for (let h = 0; h < o; h++)
3930
+ c = this.decode_openc3_type(i[h][1]), c !== null && (i[h][1] = c);
3931
+ }
3932
+ return i;
3933
+ }
3934
+ get_packet_derived_items(e, t) {
3935
+ return this.exec("get_packet_derived_items", [e, t]);
3936
+ }
3937
+ get_tlm_buffer(e, t) {
3938
+ return this.exec("get_tlm_buffer", [e, t]);
3939
+ }
3940
+ async get_tlm_values(e, t = 30, s = null) {
3941
+ let r = {
3942
+ stale_time: t
3943
+ };
3944
+ s !== null && (r.cache_timeout = s);
3945
+ const i = await this.exec(
3946
+ "get_tlm_values",
3947
+ [e],
3948
+ r,
3949
+ {},
3950
+ 1e4
3951
+ // 10s timeout ... should never be this long
3952
+ );
3953
+ let o = i[0].length, c = null;
3954
+ for (let h = 0; h < o; h++)
3955
+ c = this.decode_openc3_type(i[0][h]), c !== null && (i[0][h] = c);
3956
+ return i;
3957
+ }
3958
+ get_limits(e, t, s) {
3959
+ return this.exec("get_limits", [e, t, s]);
3960
+ }
3961
+ async tlm(e, t, s, r = "CONVERTED") {
3962
+ let i = null;
3963
+ if (t === void 0)
3964
+ i = await this.exec("tlm", [e]);
3965
+ else if (s === void 0)
3966
+ if (["RAW", "CONVERTED", "FORMATTED", "WITH_UNITS"].includes(t))
3967
+ i = await this.exec("tlm", [e], { type: t });
3968
+ else {
3969
+ let c = new Error();
3970
+ throw c.name = "TypeError", c.message = `Invalid data type ${t}. Valid options are RAW, CONVERTED, FORMATTED, and WITH_UNITS.`, c;
3971
+ }
3972
+ else
3973
+ i = await this.exec("tlm", [e, t, s], {
3974
+ type: r
3975
+ });
3976
+ let o = this.decode_openc3_type(i);
3977
+ return o !== null && (i = o), i;
3978
+ }
3979
+ async inject_tlm(e, t, s = null, r = "CONVERTED") {
3980
+ await this.exec("inject_tlm", [e, t, s], {
3981
+ type: r
3982
+ });
3983
+ }
3984
+ set_tlm(e, t, s, r) {
3985
+ return this.exec("set_tlm", [e, t, s], {
3986
+ type: r
3987
+ });
3988
+ }
3989
+ override_tlm(e, t, s, r) {
3990
+ return this.exec("override_tlm", [e, t, s], {
3991
+ type: r
3992
+ });
3993
+ }
3994
+ get_overrides() {
3995
+ return this.exec("get_overrides");
3996
+ }
3997
+ normalize_tlm(e, t, s, r) {
3998
+ return this.exec("normalize_tlm", [e, t, s], {
3999
+ type: r
4000
+ });
4001
+ }
4002
+ get_all_cmds(e) {
4003
+ return this.exec("get_all_cmds", [e]);
4004
+ }
4005
+ // DEPRECATED for get_all_cmds
4006
+ get_all_commands(e) {
4007
+ return this.exec("get_all_cmds", [e]);
4008
+ }
4009
+ get_all_cmd_names(e, t = !1) {
4010
+ return this.exec("get_all_cmd_names", [e], { hidden: t });
4011
+ }
4012
+ // DEPRECATED for get_all_cmd_names
4013
+ get_all_command_names(e) {
4014
+ return this.exec("get_all_cmd_names", [e]);
4015
+ }
4016
+ get_cmd(e, t) {
4017
+ return this.exec("get_cmd", [e, t]);
4018
+ }
4019
+ // DEPRECATED for get_cmd
4020
+ get_command(e, t) {
4021
+ return this.exec("get_cmd", [e, t]);
4022
+ }
4023
+ get_cmd_cnts(e) {
4024
+ return this.exec("get_cmd_cnts", [e]);
4025
+ }
4026
+ get_cmd_value(e, t, s, r = "CONVERTED") {
4027
+ return this.exec("get_cmd_value", [
4028
+ e,
4029
+ t,
4030
+ s,
4031
+ r
4032
+ ]);
4033
+ }
4034
+ get_cmd_buffer(e, t) {
4035
+ return this.exec("get_cmd_buffer", [e, t]);
4036
+ }
4037
+ // Implementation of functionality shared by cmd methods with param_lists.
4038
+ _cmd(e, t, s, r, i) {
4039
+ let o = null;
4040
+ for (let c in r)
4041
+ Object.prototype.hasOwnProperty.call(r, c) && (o = this.encode_openc3_type(r[c]), o !== null && (r[c] = o));
4042
+ return this.exec(
4043
+ e,
4044
+ [t, s, r],
4045
+ {},
4046
+ i
4047
+ );
4048
+ }
4049
+ get_cmd_hazardous(e, t, s, r = {}) {
4050
+ return t === void 0 ? this.exec("get_cmd_hazardous", e, {}, r) : this._cmd(
4051
+ "get_cmd_hazardous",
4052
+ e,
4053
+ t,
4054
+ s,
4055
+ r
4056
+ );
4057
+ }
4058
+ cmd(e, t, s, r = {}) {
4059
+ return t === void 0 ? this.exec("cmd", e, {}, r) : this._cmd(
4060
+ "cmd",
4061
+ e,
4062
+ t,
4063
+ s,
4064
+ r
4065
+ );
4066
+ }
4067
+ cmd_no_range_check(e, t, s, r = {}) {
4068
+ return t === void 0 ? this.exec("cmd_no_range_check", e, {}, r) : this._cmd(
4069
+ "cmd_no_range_check",
4070
+ e,
4071
+ t,
4072
+ s,
4073
+ r
4074
+ );
4075
+ }
4076
+ cmd_raw(e, t, s, r = {}) {
4077
+ return t === void 0 ? this.exec("cmd_raw", e, {}, r) : this._cmd(
4078
+ "cmd_raw",
4079
+ e,
4080
+ t,
4081
+ s,
4082
+ r
4083
+ );
4084
+ }
4085
+ cmd_raw_no_range_check(e, t, s, r = {}) {
4086
+ return t === void 0 ? this.exec("cmd_raw_no_range_check", e, {}, r) : this._cmd(
4087
+ "cmd_raw_no_range_check",
4088
+ e,
4089
+ t,
4090
+ s,
4091
+ r
4092
+ );
4093
+ }
4094
+ cmd_no_hazardous_check(e, t, s, r = {}) {
4095
+ return t === void 0 ? this.exec("cmd_no_hazardous_check", e, {}, r) : this._cmd(
4096
+ "cmd_no_hazardous_check",
4097
+ e,
4098
+ t,
4099
+ s,
4100
+ r
4101
+ );
4102
+ }
4103
+ cmd_no_checks(e, t, s, r = {}) {
4104
+ return t === void 0 ? this.exec("cmd_no_checks", e, {}, r) : this._cmd(
4105
+ "cmd_no_checks",
4106
+ e,
4107
+ t,
4108
+ s,
4109
+ r
4110
+ );
4111
+ }
4112
+ cmd_raw_no_hazardous_check(e, t, s, r = {}) {
4113
+ return t === void 0 ? this.exec(
4114
+ "cmd_raw_no_hazardous_check",
4115
+ e,
4116
+ {},
4117
+ r
4118
+ ) : this._cmd(
4119
+ "cmd_raw_no_hazardous_check",
4120
+ e,
4121
+ t,
4122
+ s,
4123
+ r
4124
+ );
4125
+ }
4126
+ cmd_raw_no_checks(e, t, s, r = {}) {
4127
+ return t === void 0 ? this.exec("cmd_raw_no_checks", e, {}, r) : this._cmd(
4128
+ "cmd_raw_no_checks",
4129
+ e,
4130
+ t,
4131
+ s,
4132
+ r
4133
+ );
4134
+ }
4135
+ build_cmd(e, t, s) {
4136
+ return t === void 0 ? this.exec("build_cmd", e) : this._cmd("build_cmd", e, t, s);
4137
+ }
4138
+ // DEPRECATED for build_cmd
4139
+ build_command(e, t, s) {
4140
+ return t === void 0 ? this.exec("build_cmd", e) : this._cmd("build_cmd", e, t, s);
4141
+ }
4142
+ get_interface_names() {
4143
+ return this.exec("get_interface_names", []);
4144
+ }
4145
+ send_raw(e, t) {
4146
+ return this.exec("send_raw", [e, t]);
4147
+ }
4148
+ list_configs(e) {
4149
+ return this.exec("list_configs", [e]);
4150
+ }
4151
+ load_config(e, t) {
4152
+ return this.exec("load_config", [e, t]);
4153
+ }
4154
+ save_config(e, t, s) {
4155
+ return this.exec("save_config", [e, t, s]);
4156
+ }
4157
+ delete_config(e, t) {
4158
+ return this.exec("delete_config", [e, t]);
4159
+ }
4160
+ enable_limits(e, t, s) {
4161
+ return this.exec("enable_limits", [e, t, s]);
4162
+ }
4163
+ disable_limits(e, t, s) {
4164
+ return this.exec("disable_limits", [e, t, s]);
4165
+ }
4166
+ get_out_of_limits() {
4167
+ return this.exec("get_out_of_limits", []);
4168
+ }
4169
+ get_overall_limits_state(e) {
4170
+ return this.exec("get_overall_limits_state", [e]);
4171
+ }
4172
+ list_settings() {
4173
+ return this.exec("list_settings", []);
4174
+ }
4175
+ get_all_settings() {
4176
+ return this.exec("get_all_settings", []);
4177
+ }
4178
+ get_setting(e) {
4179
+ return this.exec("get_setting", [e]);
4180
+ }
4181
+ get_settings(e) {
4182
+ return this.exec("get_settings", e);
4183
+ }
4184
+ set_setting(e, t) {
4185
+ return this.exec("set_setting", [e, t]);
4186
+ }
4187
+ update_news() {
4188
+ return this.exec("update_news", []);
4189
+ }
4190
+ // DEPRECATED for set_setting
4191
+ save_setting(e, t) {
4192
+ return this.exec("set_setting", [e, t]);
4193
+ }
4194
+ get_metrics() {
4195
+ return this.exec("get_metrics", []);
4196
+ }
4197
+ // TODO: Currently unused but seemed like a useful function
4198
+ async hashString(e) {
4199
+ if (window.isSecureContext) {
4200
+ const t = new TextEncoder().encode(e), s = await crypto.subtle.digest(
4201
+ "SHA-256",
4202
+ t
4203
+ ), r = new Uint8Array(s);
4204
+ return Array.from(r).map((i) => i.toString(16).padStart(2, "0")).join("");
4205
+ }
4206
+ }
4207
+ }
4208
+ export {
4209
+ ui as Api,
4210
+ fi as Cable,
4211
+ ut as ConfigParserError,
4212
+ pi as ConfigParserService,
4213
+ mi as OpenC3Api,
4214
+ De as axios
4215
+ };
4216
+ //# sourceMappingURL=services.js.map