@mindline/sync 1.0.89 → 1.0.91

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.
Files changed (41) hide show
  1. package/.vs/VSWorkspaceState.json +4 -2
  2. package/.vs/slnx.sqlite +0 -0
  3. package/.vs/sync/CopilotIndices/17.14.260.54502/CodeChunks.db +0 -0
  4. package/.vs/sync/CopilotIndices/17.14.260.54502/SemanticSymbols.db +0 -0
  5. package/.vs/sync/FileContentIndex/{6ae8ea19-641b-4811-a4ef-e70ea6cb6339.vsidx → 0f447c8e-f707-40c3-aa4c-30bfeab10f57.vsidx} +0 -0
  6. package/.vs/sync/FileContentIndex/b3821e23-fbe8-43ca-9167-2deeb211602b.vsidx +0 -0
  7. package/.vs/sync/v17/.wsuo +0 -0
  8. package/.vs/sync/v17/DocumentLayout.backup.json +52 -2
  9. package/.vs/sync/v17/DocumentLayout.json +73 -22
  10. package/dist/actors.json.d.ts +22 -0
  11. package/dist/configs.json.d.ts +3 -0
  12. package/dist/index.d.ts +348 -0
  13. package/dist/resources.json.d.ts +60 -0
  14. package/dist/sync.es.js +4214 -0
  15. package/dist/sync.es.js.map +1 -0
  16. package/dist/sync.umd.js +54 -0
  17. package/dist/sync.umd.js.map +1 -0
  18. package/dist/syncmilestones.json.d.ts +25 -0
  19. package/dist/tenants.json.d.ts +13 -0
  20. package/dist/users.json.d.ts +15 -0
  21. package/dist/workspaces.json.d.ts +12 -0
  22. package/package.json +20 -12
  23. package/{index.ts → src/index.ts} +206 -148
  24. package/tsconfig.json +11 -14
  25. package/vite.config.ts +31 -0
  26. package/.vs/sync/FileContentIndex/9d767116-a2e8-4565-8920-26919169781d.vsidx +0 -0
  27. package/tasks.ts +0 -55
  28. /package/{README.md → src/README.md} +0 -0
  29. /package/{actors.json → src/actors.json} +0 -0
  30. /package/{configs.json → src/configs.json} +0 -0
  31. /package/{configs2.json → src/configs2.json} +0 -0
  32. /package/{index.d.ts → src/index.d.ts} +0 -0
  33. /package/{mockconfig.json → src/mockconfig.json} +0 -0
  34. /package/{resources.json → src/resources.json} +0 -0
  35. /package/{syncmilestones.json → src/syncmilestones.json} +0 -0
  36. /package/{tenants.json → src/tenants.json} +0 -0
  37. /package/{tenants2.json → src/tenants2.json} +0 -0
  38. /package/{users.json → src/users.json} +0 -0
  39. /package/{users2.json → src/users2.json} +0 -0
  40. /package/{workspaces.json → src/workspaces.json} +0 -0
  41. /package/{workspaces2.json → src/workspaces2.json} +0 -0
@@ -0,0 +1,4214 @@
1
+ var st = Object.defineProperty;
2
+ var Fe = (r) => {
3
+ throw TypeError(r);
4
+ };
5
+ var ot = (r, e, t) => e in r ? st(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
6
+ var d = (r, e, t) => ot(r, typeof e != "symbol" ? e + "" : e, t), rt = (r, e, t) => e.has(r) || Fe("Cannot " + t);
7
+ var we = (r, e, t) => e.has(r) ? Fe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t);
8
+ var Z = (r, e, t) => (rt(r, e, "access private method"), t);
9
+ class V extends Error {
10
+ /** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
11
+ *
12
+ * @param {string} errorMessage A descriptive error message.
13
+ * @param {number} statusCode The HTTP status code represented by this error.
14
+ */
15
+ constructor(e, t) {
16
+ const n = new.target.prototype;
17
+ super(`${e}: Status code '${t}'`), this.statusCode = t, this.__proto__ = n;
18
+ }
19
+ }
20
+ class Le extends Error {
21
+ /** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
22
+ *
23
+ * @param {string} errorMessage A descriptive error message.
24
+ */
25
+ constructor(e = "A timeout occurred.") {
26
+ const t = new.target.prototype;
27
+ super(e), this.__proto__ = t;
28
+ }
29
+ }
30
+ class K extends Error {
31
+ /** Constructs a new instance of {@link AbortError}.
32
+ *
33
+ * @param {string} errorMessage A descriptive error message.
34
+ */
35
+ constructor(e = "An abort occurred.") {
36
+ const t = new.target.prototype;
37
+ super(e), this.__proto__ = t;
38
+ }
39
+ }
40
+ class it extends Error {
41
+ /** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
42
+ *
43
+ * @param {string} message A descriptive error message.
44
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
45
+ */
46
+ constructor(e, t) {
47
+ const n = new.target.prototype;
48
+ super(e), this.transport = t, this.errorType = "UnsupportedTransportError", this.__proto__ = n;
49
+ }
50
+ }
51
+ class at extends Error {
52
+ /** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
53
+ *
54
+ * @param {string} message A descriptive error message.
55
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
56
+ */
57
+ constructor(e, t) {
58
+ const n = new.target.prototype;
59
+ super(e), this.transport = t, this.errorType = "DisabledTransportError", this.__proto__ = n;
60
+ }
61
+ }
62
+ class ct extends Error {
63
+ /** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
64
+ *
65
+ * @param {string} message A descriptive error message.
66
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
67
+ */
68
+ constructor(e, t) {
69
+ const n = new.target.prototype;
70
+ super(e), this.transport = t, this.errorType = "FailedToStartTransportError", this.__proto__ = n;
71
+ }
72
+ }
73
+ class Ue extends Error {
74
+ /** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
75
+ *
76
+ * @param {string} message A descriptive error message.
77
+ */
78
+ constructor(e) {
79
+ const t = new.target.prototype;
80
+ super(e), this.errorType = "FailedToNegotiateWithServerError", this.__proto__ = t;
81
+ }
82
+ }
83
+ class lt extends Error {
84
+ /** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
85
+ *
86
+ * @param {string} message A descriptive error message.
87
+ * @param {Error[]} innerErrors The collection of errors this error is aggregating.
88
+ */
89
+ constructor(e, t) {
90
+ const n = new.target.prototype;
91
+ super(e), this.innerErrors = t, this.__proto__ = n;
92
+ }
93
+ }
94
+ class Xe {
95
+ constructor(e, t, n) {
96
+ this.statusCode = e, this.statusText = t, this.content = n;
97
+ }
98
+ }
99
+ class Ie {
100
+ get(e, t) {
101
+ return this.send({
102
+ ...t,
103
+ method: "GET",
104
+ url: e
105
+ });
106
+ }
107
+ post(e, t) {
108
+ return this.send({
109
+ ...t,
110
+ method: "POST",
111
+ url: e
112
+ });
113
+ }
114
+ delete(e, t) {
115
+ return this.send({
116
+ ...t,
117
+ method: "DELETE",
118
+ url: e
119
+ });
120
+ }
121
+ /** Gets all cookies that apply to the specified URL.
122
+ *
123
+ * @param url The URL that the cookies are valid for.
124
+ * @returns {string} A string containing all the key-value cookie pairs for the specified URL.
125
+ */
126
+ // @ts-ignore
127
+ getCookieString(e) {
128
+ return "";
129
+ }
130
+ }
131
+ var h;
132
+ (function(r) {
133
+ r[r.Trace = 0] = "Trace", r[r.Debug = 1] = "Debug", r[r.Information = 2] = "Information", r[r.Warning = 3] = "Warning", r[r.Error = 4] = "Error", r[r.Critical = 5] = "Critical", r[r.None = 6] = "None";
134
+ })(h || (h = {}));
135
+ class fe {
136
+ constructor() {
137
+ }
138
+ /** @inheritDoc */
139
+ // eslint-disable-next-line
140
+ log(e, t) {
141
+ }
142
+ }
143
+ fe.instance = new fe();
144
+ const ut = "8.0.7";
145
+ class D {
146
+ static isRequired(e, t) {
147
+ if (e == null)
148
+ throw new Error(`The '${t}' argument is required.`);
149
+ }
150
+ static isNotEmpty(e, t) {
151
+ if (!e || e.match(/^\s*$/))
152
+ throw new Error(`The '${t}' argument should not be empty.`);
153
+ }
154
+ static isIn(e, t, n) {
155
+ if (!(e in t))
156
+ throw new Error(`Unknown ${n} value: ${e}.`);
157
+ }
158
+ }
159
+ class k {
160
+ // react-native has a window but no document so we should check both
161
+ static get isBrowser() {
162
+ return !k.isNode && typeof window == "object" && typeof window.document == "object";
163
+ }
164
+ // WebWorkers don't have a window object so the isBrowser check would fail
165
+ static get isWebWorker() {
166
+ return !k.isNode && typeof self == "object" && "importScripts" in self;
167
+ }
168
+ // react-native has a window but no document
169
+ static get isReactNative() {
170
+ return !k.isNode && typeof window == "object" && typeof window.document > "u";
171
+ }
172
+ // Node apps shouldn't have a window object, but WebWorkers don't either
173
+ // so we need to check for both WebWorker and window
174
+ static get isNode() {
175
+ return typeof process < "u" && process.release && process.release.name === "node";
176
+ }
177
+ }
178
+ function pe(r, e) {
179
+ let t = "";
180
+ return te(r) ? (t = `Binary data of length ${r.byteLength}`, e && (t += `. Content: '${dt(r)}'`)) : typeof r == "string" && (t = `String data of length ${r.length}`, e && (t += `. Content: '${r}'`)), t;
181
+ }
182
+ function dt(r) {
183
+ const e = new Uint8Array(r);
184
+ let t = "";
185
+ return e.forEach((n) => {
186
+ const s = n < 16 ? "0" : "";
187
+ t += `0x${s}${n.toString(16)} `;
188
+ }), t.substr(0, t.length - 1);
189
+ }
190
+ function te(r) {
191
+ return r && typeof ArrayBuffer < "u" && (r instanceof ArrayBuffer || // Sometimes we get an ArrayBuffer that doesn't satisfy instanceof
192
+ r.constructor && r.constructor.name === "ArrayBuffer");
193
+ }
194
+ async function Ze(r, e, t, n, s, o) {
195
+ const i = {}, [c, a] = ce();
196
+ i[c] = a, r.log(h.Trace, `(${e} transport) sending data. ${pe(s, o.logMessageContent)}.`);
197
+ const l = te(s) ? "arraybuffer" : "text", u = await t.post(n, {
198
+ content: s,
199
+ headers: { ...i, ...o.headers },
200
+ responseType: l,
201
+ timeout: o.timeout,
202
+ withCredentials: o.withCredentials
203
+ });
204
+ r.log(h.Trace, `(${e} transport) request complete. Response status: ${u.statusCode}.`);
205
+ }
206
+ function ht(r) {
207
+ return r === void 0 ? new be(h.Information) : r === null ? fe.instance : r.log !== void 0 ? r : new be(r);
208
+ }
209
+ class ft {
210
+ constructor(e, t) {
211
+ this._subject = e, this._observer = t;
212
+ }
213
+ dispose() {
214
+ const e = this._subject.observers.indexOf(this._observer);
215
+ e > -1 && this._subject.observers.splice(e, 1), this._subject.observers.length === 0 && this._subject.cancelCallback && this._subject.cancelCallback().catch((t) => {
216
+ });
217
+ }
218
+ }
219
+ class be {
220
+ constructor(e) {
221
+ this._minLevel = e, this.out = console;
222
+ }
223
+ log(e, t) {
224
+ if (e >= this._minLevel) {
225
+ const n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${h[e]}: ${t}`;
226
+ switch (e) {
227
+ case h.Critical:
228
+ case h.Error:
229
+ this.out.error(n);
230
+ break;
231
+ case h.Warning:
232
+ this.out.warn(n);
233
+ break;
234
+ case h.Information:
235
+ this.out.info(n);
236
+ break;
237
+ default:
238
+ this.out.log(n);
239
+ break;
240
+ }
241
+ }
242
+ }
243
+ }
244
+ function ce() {
245
+ let r = "X-SignalR-User-Agent";
246
+ return k.isNode && (r = "User-Agent"), [r, pt(ut, gt(), _t(), mt())];
247
+ }
248
+ function pt(r, e, t, n) {
249
+ let s = "Microsoft SignalR/";
250
+ const o = r.split(".");
251
+ return s += `${o[0]}.${o[1]}`, s += ` (${r}; `, e && e !== "" ? s += `${e}; ` : s += "Unknown OS; ", s += `${t}`, n ? s += `; ${n}` : s += "; Unknown Runtime Version", s += ")", s;
252
+ }
253
+ function gt() {
254
+ if (k.isNode)
255
+ switch (process.platform) {
256
+ case "win32":
257
+ return "Windows NT";
258
+ case "darwin":
259
+ return "macOS";
260
+ case "linux":
261
+ return "Linux";
262
+ default:
263
+ return process.platform;
264
+ }
265
+ else
266
+ return "";
267
+ }
268
+ function mt() {
269
+ if (k.isNode)
270
+ return process.versions.node;
271
+ }
272
+ function _t() {
273
+ return k.isNode ? "NodeJS" : "Browser";
274
+ }
275
+ function Ee(r) {
276
+ return r.stack ? r.stack : r.message ? r.message : `${r}`;
277
+ }
278
+ function yt() {
279
+ if (typeof globalThis < "u")
280
+ return globalThis;
281
+ if (typeof self < "u")
282
+ return self;
283
+ if (typeof window < "u")
284
+ return window;
285
+ if (typeof global < "u")
286
+ return global;
287
+ throw new Error("could not find global");
288
+ }
289
+ class wt extends Ie {
290
+ constructor(e) {
291
+ if (super(), this._logger = e, typeof fetch > "u" || k.isNode) {
292
+ const t = typeof __webpack_require__ == "function" ? __non_webpack_require__ : require;
293
+ this._jar = new (t("tough-cookie")).CookieJar(), typeof fetch > "u" ? this._fetchType = t("node-fetch") : this._fetchType = fetch, this._fetchType = t("fetch-cookie")(this._fetchType, this._jar);
294
+ } else
295
+ this._fetchType = fetch.bind(yt());
296
+ if (typeof AbortController > "u") {
297
+ const t = typeof __webpack_require__ == "function" ? __non_webpack_require__ : require;
298
+ this._abortControllerType = t("abort-controller");
299
+ } else
300
+ this._abortControllerType = AbortController;
301
+ }
302
+ /** @inheritDoc */
303
+ async send(e) {
304
+ if (e.abortSignal && e.abortSignal.aborted)
305
+ throw new K();
306
+ if (!e.method)
307
+ throw new Error("No method defined.");
308
+ if (!e.url)
309
+ throw new Error("No url defined.");
310
+ const t = new this._abortControllerType();
311
+ let n;
312
+ e.abortSignal && (e.abortSignal.onabort = () => {
313
+ t.abort(), n = new K();
314
+ });
315
+ let s = null;
316
+ if (e.timeout) {
317
+ const a = e.timeout;
318
+ s = setTimeout(() => {
319
+ t.abort(), this._logger.log(h.Warning, "Timeout from HTTP request."), n = new Le();
320
+ }, a);
321
+ }
322
+ e.content === "" && (e.content = void 0), e.content && (e.headers = e.headers || {}, te(e.content) ? e.headers["Content-Type"] = "application/octet-stream" : e.headers["Content-Type"] = "text/plain;charset=UTF-8");
323
+ let o;
324
+ try {
325
+ o = await this._fetchType(e.url, {
326
+ body: e.content,
327
+ cache: "no-cache",
328
+ credentials: e.withCredentials === !0 ? "include" : "same-origin",
329
+ headers: {
330
+ "X-Requested-With": "XMLHttpRequest",
331
+ ...e.headers
332
+ },
333
+ method: e.method,
334
+ mode: "cors",
335
+ redirect: "follow",
336
+ signal: t.signal
337
+ });
338
+ } catch (a) {
339
+ throw n || (this._logger.log(h.Warning, `Error from HTTP request. ${a}.`), a);
340
+ } finally {
341
+ s && clearTimeout(s), e.abortSignal && (e.abortSignal.onabort = null);
342
+ }
343
+ if (!o.ok) {
344
+ const a = await He(o, "text");
345
+ throw new V(a || o.statusText, o.status);
346
+ }
347
+ const c = await He(o, e.responseType);
348
+ return new Xe(o.status, o.statusText, c);
349
+ }
350
+ getCookieString(e) {
351
+ let t = "";
352
+ return k.isNode && this._jar && this._jar.getCookies(e, (n, s) => t = s.join("; ")), t;
353
+ }
354
+ }
355
+ function He(r, e) {
356
+ let t;
357
+ switch (e) {
358
+ case "arraybuffer":
359
+ t = r.arrayBuffer();
360
+ break;
361
+ case "text":
362
+ t = r.text();
363
+ break;
364
+ case "blob":
365
+ case "document":
366
+ case "json":
367
+ throw new Error(`${e} is not supported.`);
368
+ default:
369
+ t = r.text();
370
+ break;
371
+ }
372
+ return t;
373
+ }
374
+ class St extends Ie {
375
+ constructor(e) {
376
+ super(), this._logger = e;
377
+ }
378
+ /** @inheritDoc */
379
+ send(e) {
380
+ return e.abortSignal && e.abortSignal.aborted ? Promise.reject(new K()) : e.method ? e.url ? new Promise((t, n) => {
381
+ const s = new XMLHttpRequest();
382
+ s.open(e.method, e.url, !0), s.withCredentials = e.withCredentials === void 0 ? !0 : e.withCredentials, s.setRequestHeader("X-Requested-With", "XMLHttpRequest"), e.content === "" && (e.content = void 0), e.content && (te(e.content) ? s.setRequestHeader("Content-Type", "application/octet-stream") : s.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"));
383
+ const o = e.headers;
384
+ o && Object.keys(o).forEach((i) => {
385
+ s.setRequestHeader(i, o[i]);
386
+ }), e.responseType && (s.responseType = e.responseType), e.abortSignal && (e.abortSignal.onabort = () => {
387
+ s.abort(), n(new K());
388
+ }), e.timeout && (s.timeout = e.timeout), s.onload = () => {
389
+ e.abortSignal && (e.abortSignal.onabort = null), s.status >= 200 && s.status < 300 ? t(new Xe(s.status, s.statusText, s.response || s.responseText)) : n(new V(s.response || s.responseText || s.statusText, s.status));
390
+ }, s.onerror = () => {
391
+ this._logger.log(h.Warning, `Error from HTTP request. ${s.status}: ${s.statusText}.`), n(new V(s.statusText, s.status));
392
+ }, s.ontimeout = () => {
393
+ this._logger.log(h.Warning, "Timeout from HTTP request."), n(new Le());
394
+ }, s.send(e.content);
395
+ }) : Promise.reject(new Error("No url defined.")) : Promise.reject(new Error("No method defined."));
396
+ }
397
+ }
398
+ class bt extends Ie {
399
+ /** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */
400
+ constructor(e) {
401
+ if (super(), typeof fetch < "u" || k.isNode)
402
+ this._httpClient = new wt(e);
403
+ else if (typeof XMLHttpRequest < "u")
404
+ this._httpClient = new St(e);
405
+ else
406
+ throw new Error("No usable HttpClient found.");
407
+ }
408
+ /** @inheritDoc */
409
+ send(e) {
410
+ return e.abortSignal && e.abortSignal.aborted ? Promise.reject(new K()) : e.method ? e.url ? this._httpClient.send(e) : Promise.reject(new Error("No url defined.")) : Promise.reject(new Error("No method defined."));
411
+ }
412
+ getCookieString(e) {
413
+ return this._httpClient.getCookieString(e);
414
+ }
415
+ }
416
+ class q {
417
+ static write(e) {
418
+ return `${e}${q.RecordSeparator}`;
419
+ }
420
+ static parse(e) {
421
+ if (e[e.length - 1] !== q.RecordSeparator)
422
+ throw new Error("Message is incomplete.");
423
+ const t = e.split(q.RecordSeparator);
424
+ return t.pop(), t;
425
+ }
426
+ }
427
+ q.RecordSeparatorCode = 30;
428
+ q.RecordSeparator = String.fromCharCode(q.RecordSeparatorCode);
429
+ class Tt {
430
+ // Handshake request is always JSON
431
+ writeHandshakeRequest(e) {
432
+ return q.write(JSON.stringify(e));
433
+ }
434
+ parseHandshakeResponse(e) {
435
+ let t, n;
436
+ if (te(e)) {
437
+ const c = new Uint8Array(e), a = c.indexOf(q.RecordSeparatorCode);
438
+ if (a === -1)
439
+ throw new Error("Message is incomplete.");
440
+ const l = a + 1;
441
+ t = String.fromCharCode.apply(null, Array.prototype.slice.call(c.slice(0, l))), n = c.byteLength > l ? c.slice(l).buffer : null;
442
+ } else {
443
+ const c = e, a = c.indexOf(q.RecordSeparator);
444
+ if (a === -1)
445
+ throw new Error("Message is incomplete.");
446
+ const l = a + 1;
447
+ t = c.substring(0, l), n = c.length > l ? c.substring(l) : null;
448
+ }
449
+ const s = q.parse(t), o = JSON.parse(s[0]);
450
+ if (o.type)
451
+ throw new Error("Expected a handshake response from the server.");
452
+ return [n, o];
453
+ }
454
+ }
455
+ var _;
456
+ (function(r) {
457
+ r[r.Invocation = 1] = "Invocation", r[r.StreamItem = 2] = "StreamItem", r[r.Completion = 3] = "Completion", r[r.StreamInvocation = 4] = "StreamInvocation", r[r.CancelInvocation = 5] = "CancelInvocation", r[r.Ping = 6] = "Ping", r[r.Close = 7] = "Close", r[r.Ack = 8] = "Ack", r[r.Sequence = 9] = "Sequence";
458
+ })(_ || (_ = {}));
459
+ class Ct {
460
+ constructor() {
461
+ this.observers = [];
462
+ }
463
+ next(e) {
464
+ for (const t of this.observers)
465
+ t.next(e);
466
+ }
467
+ error(e) {
468
+ for (const t of this.observers)
469
+ t.error && t.error(e);
470
+ }
471
+ complete() {
472
+ for (const e of this.observers)
473
+ e.complete && e.complete();
474
+ }
475
+ subscribe(e) {
476
+ return this.observers.push(e), new ft(this, e);
477
+ }
478
+ }
479
+ class It {
480
+ constructor(e, t, n) {
481
+ this._bufferSize = 1e5, this._messages = [], this._totalMessageCount = 0, this._waitForSequenceMessage = !1, this._nextReceivingSequenceId = 1, this._latestReceivedSequenceId = 0, this._bufferedByteCount = 0, this._reconnectInProgress = !1, this._protocol = e, this._connection = t, this._bufferSize = n;
482
+ }
483
+ async _send(e) {
484
+ const t = this._protocol.writeMessage(e);
485
+ let n = Promise.resolve();
486
+ if (this._isInvocationMessage(e)) {
487
+ this._totalMessageCount++;
488
+ let s = () => {
489
+ }, o = () => {
490
+ };
491
+ te(t) ? this._bufferedByteCount += t.byteLength : this._bufferedByteCount += t.length, this._bufferedByteCount >= this._bufferSize && (n = new Promise((i, c) => {
492
+ s = i, o = c;
493
+ })), this._messages.push(new vt(t, this._totalMessageCount, s, o));
494
+ }
495
+ try {
496
+ this._reconnectInProgress || await this._connection.send(t);
497
+ } catch {
498
+ this._disconnected();
499
+ }
500
+ await n;
501
+ }
502
+ _ack(e) {
503
+ let t = -1;
504
+ for (let n = 0; n < this._messages.length; n++) {
505
+ const s = this._messages[n];
506
+ if (s._id <= e.sequenceId)
507
+ t = n, te(s._message) ? this._bufferedByteCount -= s._message.byteLength : this._bufferedByteCount -= s._message.length, s._resolver();
508
+ else if (this._bufferedByteCount < this._bufferSize)
509
+ s._resolver();
510
+ else
511
+ break;
512
+ }
513
+ t !== -1 && (this._messages = this._messages.slice(t + 1));
514
+ }
515
+ _shouldProcessMessage(e) {
516
+ if (this._waitForSequenceMessage)
517
+ return e.type !== _.Sequence ? !1 : (this._waitForSequenceMessage = !1, !0);
518
+ if (!this._isInvocationMessage(e))
519
+ return !0;
520
+ const t = this._nextReceivingSequenceId;
521
+ return this._nextReceivingSequenceId++, t <= this._latestReceivedSequenceId ? (t === this._latestReceivedSequenceId && this._ackTimer(), !1) : (this._latestReceivedSequenceId = t, this._ackTimer(), !0);
522
+ }
523
+ _resetSequence(e) {
524
+ if (e.sequenceId > this._nextReceivingSequenceId) {
525
+ this._connection.stop(new Error("Sequence ID greater than amount of messages we've received."));
526
+ return;
527
+ }
528
+ this._nextReceivingSequenceId = e.sequenceId;
529
+ }
530
+ _disconnected() {
531
+ this._reconnectInProgress = !0, this._waitForSequenceMessage = !0;
532
+ }
533
+ async _resend() {
534
+ const e = this._messages.length !== 0 ? this._messages[0]._id : this._totalMessageCount + 1;
535
+ await this._connection.send(this._protocol.writeMessage({ type: _.Sequence, sequenceId: e }));
536
+ const t = this._messages;
537
+ for (const n of t)
538
+ await this._connection.send(n._message);
539
+ this._reconnectInProgress = !1;
540
+ }
541
+ _dispose(e) {
542
+ e ?? (e = new Error("Unable to reconnect to server."));
543
+ for (const t of this._messages)
544
+ t._rejector(e);
545
+ }
546
+ _isInvocationMessage(e) {
547
+ switch (e.type) {
548
+ case _.Invocation:
549
+ case _.StreamItem:
550
+ case _.Completion:
551
+ case _.StreamInvocation:
552
+ case _.CancelInvocation:
553
+ return !0;
554
+ case _.Close:
555
+ case _.Sequence:
556
+ case _.Ping:
557
+ case _.Ack:
558
+ return !1;
559
+ }
560
+ }
561
+ _ackTimer() {
562
+ this._ackTimerHandle === void 0 && (this._ackTimerHandle = setTimeout(async () => {
563
+ try {
564
+ this._reconnectInProgress || await this._connection.send(this._protocol.writeMessage({ type: _.Ack, sequenceId: this._latestReceivedSequenceId }));
565
+ } catch {
566
+ }
567
+ clearTimeout(this._ackTimerHandle), this._ackTimerHandle = void 0;
568
+ }, 1e3));
569
+ }
570
+ }
571
+ class vt {
572
+ constructor(e, t, n, s) {
573
+ this._message = e, this._id = t, this._resolver = n, this._rejector = s;
574
+ }
575
+ }
576
+ const kt = 30 * 1e3, At = 15 * 1e3, Et = 1e5;
577
+ var v;
578
+ (function(r) {
579
+ r.Disconnected = "Disconnected", r.Connecting = "Connecting", r.Connected = "Connected", r.Disconnecting = "Disconnecting", r.Reconnecting = "Reconnecting";
580
+ })(v || (v = {}));
581
+ class Ge {
582
+ /** @internal */
583
+ // Using a public static factory method means we can have a private constructor and an _internal_
584
+ // create method that can be used by HubConnectionBuilder. An "internal" constructor would just
585
+ // be stripped away and the '.d.ts' file would have no constructor, which is interpreted as a
586
+ // public parameter-less constructor.
587
+ static create(e, t, n, s, o, i, c) {
588
+ return new Ge(e, t, n, s, o, i, c);
589
+ }
590
+ constructor(e, t, n, s, o, i, c) {
591
+ this._nextKeepAlive = 0, this._freezeEventListener = () => {
592
+ this._logger.log(h.Warning, "The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep");
593
+ }, D.isRequired(e, "connection"), D.isRequired(t, "logger"), D.isRequired(n, "protocol"), this.serverTimeoutInMilliseconds = o ?? kt, this.keepAliveIntervalInMilliseconds = i ?? At, this._statefulReconnectBufferSize = c ?? Et, this._logger = t, this._protocol = n, this.connection = e, this._reconnectPolicy = s, this._handshakeProtocol = new Tt(), this.connection.onreceive = (a) => this._processIncomingData(a), this.connection.onclose = (a) => this._connectionClosed(a), this._callbacks = {}, this._methods = {}, this._closedCallbacks = [], this._reconnectingCallbacks = [], this._reconnectedCallbacks = [], this._invocationId = 0, this._receivedHandshakeResponse = !1, this._connectionState = v.Disconnected, this._connectionStarted = !1, this._cachedPingMessage = this._protocol.writeMessage({ type: _.Ping });
594
+ }
595
+ /** Indicates the state of the {@link HubConnection} to the server. */
596
+ get state() {
597
+ return this._connectionState;
598
+ }
599
+ /** Represents the connection id of the {@link HubConnection} on the server. The connection id will be null when the connection is either
600
+ * in the disconnected state or if the negotiation step was skipped.
601
+ */
602
+ get connectionId() {
603
+ return this.connection && this.connection.connectionId || null;
604
+ }
605
+ /** Indicates the url of the {@link HubConnection} to the server. */
606
+ get baseUrl() {
607
+ return this.connection.baseUrl || "";
608
+ }
609
+ /**
610
+ * Sets a new url for the HubConnection. Note that the url can only be changed when the connection is in either the Disconnected or
611
+ * Reconnecting states.
612
+ * @param {string} url The url to connect to.
613
+ */
614
+ set baseUrl(e) {
615
+ if (this._connectionState !== v.Disconnected && this._connectionState !== v.Reconnecting)
616
+ throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");
617
+ if (!e)
618
+ throw new Error("The HubConnection url must be a valid url.");
619
+ this.connection.baseUrl = e;
620
+ }
621
+ /** Starts the connection.
622
+ *
623
+ * @returns {Promise<void>} A Promise that resolves when the connection has been successfully established, or rejects with an error.
624
+ */
625
+ start() {
626
+ return this._startPromise = this._startWithStateTransitions(), this._startPromise;
627
+ }
628
+ async _startWithStateTransitions() {
629
+ if (this._connectionState !== v.Disconnected)
630
+ return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));
631
+ this._connectionState = v.Connecting, this._logger.log(h.Debug, "Starting HubConnection.");
632
+ try {
633
+ await this._startInternal(), k.isBrowser && window.document.addEventListener("freeze", this._freezeEventListener), this._connectionState = v.Connected, this._connectionStarted = !0, this._logger.log(h.Debug, "HubConnection connected successfully.");
634
+ } catch (e) {
635
+ return this._connectionState = v.Disconnected, this._logger.log(h.Debug, `HubConnection failed to start successfully because of error '${e}'.`), Promise.reject(e);
636
+ }
637
+ }
638
+ async _startInternal() {
639
+ this._stopDuringStartError = void 0, this._receivedHandshakeResponse = !1;
640
+ const e = new Promise((t, n) => {
641
+ this._handshakeResolver = t, this._handshakeRejecter = n;
642
+ });
643
+ await this.connection.start(this._protocol.transferFormat);
644
+ try {
645
+ let t = this._protocol.version;
646
+ this.connection.features.reconnect || (t = 1);
647
+ const n = {
648
+ protocol: this._protocol.name,
649
+ version: t
650
+ };
651
+ if (this._logger.log(h.Debug, "Sending handshake request."), await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(n)), this._logger.log(h.Information, `Using HubProtocol '${this._protocol.name}'.`), this._cleanupTimeout(), this._resetTimeoutPeriod(), this._resetKeepAliveInterval(), await e, this._stopDuringStartError)
652
+ throw this._stopDuringStartError;
653
+ (this.connection.features.reconnect || !1) && (this._messageBuffer = new It(this._protocol, this.connection, this._statefulReconnectBufferSize), this.connection.features.disconnected = this._messageBuffer._disconnected.bind(this._messageBuffer), this.connection.features.resend = () => {
654
+ if (this._messageBuffer)
655
+ return this._messageBuffer._resend();
656
+ }), this.connection.features.inherentKeepAlive || await this._sendMessage(this._cachedPingMessage);
657
+ } catch (t) {
658
+ throw this._logger.log(h.Debug, `Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`), this._cleanupTimeout(), this._cleanupPingTimer(), await this.connection.stop(t), t;
659
+ }
660
+ }
661
+ /** Stops the connection.
662
+ *
663
+ * @returns {Promise<void>} A Promise that resolves when the connection has been successfully terminated, or rejects with an error.
664
+ */
665
+ async stop() {
666
+ const e = this._startPromise;
667
+ this.connection.features.reconnect = !1, this._stopPromise = this._stopInternal(), await this._stopPromise;
668
+ try {
669
+ await e;
670
+ } catch {
671
+ }
672
+ }
673
+ _stopInternal(e) {
674
+ if (this._connectionState === v.Disconnected)
675
+ return this._logger.log(h.Debug, `Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`), Promise.resolve();
676
+ if (this._connectionState === v.Disconnecting)
677
+ return this._logger.log(h.Debug, `Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`), this._stopPromise;
678
+ const t = this._connectionState;
679
+ return this._connectionState = v.Disconnecting, this._logger.log(h.Debug, "Stopping HubConnection."), this._reconnectDelayHandle ? (this._logger.log(h.Debug, "Connection stopped during reconnect delay. Done reconnecting."), clearTimeout(this._reconnectDelayHandle), this._reconnectDelayHandle = void 0, this._completeClose(), Promise.resolve()) : (t === v.Connected && this._sendCloseMessage(), this._cleanupTimeout(), this._cleanupPingTimer(), this._stopDuringStartError = e || new K("The connection was stopped before the hub handshake could complete."), this.connection.stop(e));
680
+ }
681
+ async _sendCloseMessage() {
682
+ try {
683
+ await this._sendWithProtocol(this._createCloseMessage());
684
+ } catch {
685
+ }
686
+ }
687
+ /** Invokes a streaming hub method on the server using the specified name and arguments.
688
+ *
689
+ * @typeparam T The type of the items returned by the server.
690
+ * @param {string} methodName The name of the server method to invoke.
691
+ * @param {any[]} args The arguments used to invoke the server method.
692
+ * @returns {IStreamResult<T>} An object that yields results from the server as they are received.
693
+ */
694
+ stream(e, ...t) {
695
+ const [n, s] = this._replaceStreamingParams(t), o = this._createStreamInvocation(e, t, s);
696
+ let i;
697
+ const c = new Ct();
698
+ return c.cancelCallback = () => {
699
+ const a = this._createCancelInvocation(o.invocationId);
700
+ return delete this._callbacks[o.invocationId], i.then(() => this._sendWithProtocol(a));
701
+ }, this._callbacks[o.invocationId] = (a, l) => {
702
+ if (l) {
703
+ c.error(l);
704
+ return;
705
+ } else a && (a.type === _.Completion ? a.error ? c.error(new Error(a.error)) : c.complete() : c.next(a.item));
706
+ }, i = this._sendWithProtocol(o).catch((a) => {
707
+ c.error(a), delete this._callbacks[o.invocationId];
708
+ }), this._launchStreams(n, i), c;
709
+ }
710
+ _sendMessage(e) {
711
+ return this._resetKeepAliveInterval(), this.connection.send(e);
712
+ }
713
+ /**
714
+ * Sends a js object to the server.
715
+ * @param message The js object to serialize and send.
716
+ */
717
+ _sendWithProtocol(e) {
718
+ return this._messageBuffer ? this._messageBuffer._send(e) : this._sendMessage(this._protocol.writeMessage(e));
719
+ }
720
+ /** Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver.
721
+ *
722
+ * The Promise returned by this method resolves when the client has sent the invocation to the server. The server may still
723
+ * be processing the invocation.
724
+ *
725
+ * @param {string} methodName The name of the server method to invoke.
726
+ * @param {any[]} args The arguments used to invoke the server method.
727
+ * @returns {Promise<void>} A Promise that resolves when the invocation has been successfully sent, or rejects with an error.
728
+ */
729
+ send(e, ...t) {
730
+ const [n, s] = this._replaceStreamingParams(t), o = this._sendWithProtocol(this._createInvocation(e, t, !0, s));
731
+ return this._launchStreams(n, o), o;
732
+ }
733
+ /** Invokes a hub method on the server using the specified name and arguments.
734
+ *
735
+ * The Promise returned by this method resolves when the server indicates it has finished invoking the method. When the promise
736
+ * resolves, the server has finished invoking the method. If the server method returns a result, it is produced as the result of
737
+ * resolving the Promise.
738
+ *
739
+ * @typeparam T The expected return type.
740
+ * @param {string} methodName The name of the server method to invoke.
741
+ * @param {any[]} args The arguments used to invoke the server method.
742
+ * @returns {Promise<T>} A Promise that resolves with the result of the server method (if any), or rejects with an error.
743
+ */
744
+ invoke(e, ...t) {
745
+ const [n, s] = this._replaceStreamingParams(t), o = this._createInvocation(e, t, !1, s);
746
+ return new Promise((c, a) => {
747
+ this._callbacks[o.invocationId] = (u, p) => {
748
+ if (p) {
749
+ a(p);
750
+ return;
751
+ } else u && (u.type === _.Completion ? u.error ? a(new Error(u.error)) : c(u.result) : a(new Error(`Unexpected message type: ${u.type}`)));
752
+ };
753
+ const l = this._sendWithProtocol(o).catch((u) => {
754
+ a(u), delete this._callbacks[o.invocationId];
755
+ });
756
+ this._launchStreams(n, l);
757
+ });
758
+ }
759
+ on(e, t) {
760
+ !e || !t || (e = e.toLowerCase(), this._methods[e] || (this._methods[e] = []), this._methods[e].indexOf(t) === -1 && this._methods[e].push(t));
761
+ }
762
+ off(e, t) {
763
+ if (!e)
764
+ return;
765
+ e = e.toLowerCase();
766
+ const n = this._methods[e];
767
+ if (n)
768
+ if (t) {
769
+ const s = n.indexOf(t);
770
+ s !== -1 && (n.splice(s, 1), n.length === 0 && delete this._methods[e]);
771
+ } else
772
+ delete this._methods[e];
773
+ }
774
+ /** Registers a handler that will be invoked when the connection is closed.
775
+ *
776
+ * @param {Function} callback The handler that will be invoked when the connection is closed. Optionally receives a single argument containing the error that caused the connection to close (if any).
777
+ */
778
+ onclose(e) {
779
+ e && this._closedCallbacks.push(e);
780
+ }
781
+ /** Registers a handler that will be invoked when the connection starts reconnecting.
782
+ *
783
+ * @param {Function} callback The handler that will be invoked when the connection starts reconnecting. Optionally receives a single argument containing the error that caused the connection to start reconnecting (if any).
784
+ */
785
+ onreconnecting(e) {
786
+ e && this._reconnectingCallbacks.push(e);
787
+ }
788
+ /** Registers a handler that will be invoked when the connection successfully reconnects.
789
+ *
790
+ * @param {Function} callback The handler that will be invoked when the connection successfully reconnects.
791
+ */
792
+ onreconnected(e) {
793
+ e && this._reconnectedCallbacks.push(e);
794
+ }
795
+ _processIncomingData(e) {
796
+ if (this._cleanupTimeout(), this._receivedHandshakeResponse || (e = this._processHandshakeResponse(e), this._receivedHandshakeResponse = !0), e) {
797
+ const t = this._protocol.parseMessages(e, this._logger);
798
+ for (const n of t)
799
+ if (!(this._messageBuffer && !this._messageBuffer._shouldProcessMessage(n)))
800
+ switch (n.type) {
801
+ case _.Invocation:
802
+ this._invokeClientMethod(n).catch((s) => {
803
+ this._logger.log(h.Error, `Invoke client method threw error: ${Ee(s)}`);
804
+ });
805
+ break;
806
+ case _.StreamItem:
807
+ case _.Completion: {
808
+ const s = this._callbacks[n.invocationId];
809
+ if (s) {
810
+ n.type === _.Completion && delete this._callbacks[n.invocationId];
811
+ try {
812
+ s(n);
813
+ } catch (o) {
814
+ this._logger.log(h.Error, `Stream callback threw error: ${Ee(o)}`);
815
+ }
816
+ }
817
+ break;
818
+ }
819
+ case _.Ping:
820
+ break;
821
+ case _.Close: {
822
+ this._logger.log(h.Information, "Close message received from server.");
823
+ const s = n.error ? new Error("Server returned an error on close: " + n.error) : void 0;
824
+ n.allowReconnect === !0 ? this.connection.stop(s) : this._stopPromise = this._stopInternal(s);
825
+ break;
826
+ }
827
+ case _.Ack:
828
+ this._messageBuffer && this._messageBuffer._ack(n);
829
+ break;
830
+ case _.Sequence:
831
+ this._messageBuffer && this._messageBuffer._resetSequence(n);
832
+ break;
833
+ default:
834
+ this._logger.log(h.Warning, `Invalid message type: ${n.type}.`);
835
+ break;
836
+ }
837
+ }
838
+ this._resetTimeoutPeriod();
839
+ }
840
+ _processHandshakeResponse(e) {
841
+ let t, n;
842
+ try {
843
+ [n, t] = this._handshakeProtocol.parseHandshakeResponse(e);
844
+ } catch (s) {
845
+ const o = "Error parsing handshake response: " + s;
846
+ this._logger.log(h.Error, o);
847
+ const i = new Error(o);
848
+ throw this._handshakeRejecter(i), i;
849
+ }
850
+ if (t.error) {
851
+ const s = "Server returned handshake error: " + t.error;
852
+ this._logger.log(h.Error, s);
853
+ const o = new Error(s);
854
+ throw this._handshakeRejecter(o), o;
855
+ } else
856
+ this._logger.log(h.Debug, "Server handshake complete.");
857
+ return this._handshakeResolver(), n;
858
+ }
859
+ _resetKeepAliveInterval() {
860
+ this.connection.features.inherentKeepAlive || (this._nextKeepAlive = (/* @__PURE__ */ new Date()).getTime() + this.keepAliveIntervalInMilliseconds, this._cleanupPingTimer());
861
+ }
862
+ _resetTimeoutPeriod() {
863
+ if ((!this.connection.features || !this.connection.features.inherentKeepAlive) && (this._timeoutHandle = setTimeout(() => this.serverTimeout(), this.serverTimeoutInMilliseconds), this._pingServerHandle === void 0)) {
864
+ let e = this._nextKeepAlive - (/* @__PURE__ */ new Date()).getTime();
865
+ e < 0 && (e = 0), this._pingServerHandle = setTimeout(async () => {
866
+ if (this._connectionState === v.Connected)
867
+ try {
868
+ await this._sendMessage(this._cachedPingMessage);
869
+ } catch {
870
+ this._cleanupPingTimer();
871
+ }
872
+ }, e);
873
+ }
874
+ }
875
+ // eslint-disable-next-line @typescript-eslint/naming-convention
876
+ serverTimeout() {
877
+ this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."));
878
+ }
879
+ async _invokeClientMethod(e) {
880
+ const t = e.target.toLowerCase(), n = this._methods[t];
881
+ if (!n) {
882
+ this._logger.log(h.Warning, `No client method with the name '${t}' found.`), e.invocationId && (this._logger.log(h.Warning, `No result given for '${t}' method and invocation ID '${e.invocationId}'.`), await this._sendWithProtocol(this._createCompletionMessage(e.invocationId, "Client didn't provide a result.", null)));
883
+ return;
884
+ }
885
+ const s = n.slice(), o = !!e.invocationId;
886
+ let i, c, a;
887
+ for (const l of s)
888
+ try {
889
+ const u = i;
890
+ i = await l.apply(this, e.arguments), o && i && u && (this._logger.log(h.Error, `Multiple results provided for '${t}'. Sending error to server.`), a = this._createCompletionMessage(e.invocationId, "Client provided multiple results.", null)), c = void 0;
891
+ } catch (u) {
892
+ c = u, this._logger.log(h.Error, `A callback for the method '${t}' threw error '${u}'.`);
893
+ }
894
+ a ? await this._sendWithProtocol(a) : o ? (c ? a = this._createCompletionMessage(e.invocationId, `${c}`, null) : i !== void 0 ? a = this._createCompletionMessage(e.invocationId, null, i) : (this._logger.log(h.Warning, `No result given for '${t}' method and invocation ID '${e.invocationId}'.`), a = this._createCompletionMessage(e.invocationId, "Client didn't provide a result.", null)), await this._sendWithProtocol(a)) : i && this._logger.log(h.Error, `Result given for '${t}' method but server is not expecting a result.`);
895
+ }
896
+ _connectionClosed(e) {
897
+ this._logger.log(h.Debug, `HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`), this._stopDuringStartError = this._stopDuringStartError || e || new K("The underlying connection was closed before the hub handshake could complete."), this._handshakeResolver && this._handshakeResolver(), this._cancelCallbacksWithError(e || new Error("Invocation canceled due to the underlying connection being closed.")), this._cleanupTimeout(), this._cleanupPingTimer(), this._connectionState === v.Disconnecting ? this._completeClose(e) : this._connectionState === v.Connected && this._reconnectPolicy ? this._reconnect(e) : this._connectionState === v.Connected && this._completeClose(e);
898
+ }
899
+ _completeClose(e) {
900
+ if (this._connectionStarted) {
901
+ this._connectionState = v.Disconnected, this._connectionStarted = !1, this._messageBuffer && (this._messageBuffer._dispose(e ?? new Error("Connection closed.")), this._messageBuffer = void 0), k.isBrowser && window.document.removeEventListener("freeze", this._freezeEventListener);
902
+ try {
903
+ this._closedCallbacks.forEach((t) => t.apply(this, [e]));
904
+ } catch (t) {
905
+ this._logger.log(h.Error, `An onclose callback called with error '${e}' threw error '${t}'.`);
906
+ }
907
+ }
908
+ }
909
+ async _reconnect(e) {
910
+ const t = Date.now();
911
+ let n = 0, s = e !== void 0 ? e : new Error("Attempting to reconnect due to a unknown error."), o = this._getNextRetryDelay(n++, 0, s);
912
+ if (o === null) {
913
+ this._logger.log(h.Debug, "Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."), this._completeClose(e);
914
+ return;
915
+ }
916
+ if (this._connectionState = v.Reconnecting, e ? this._logger.log(h.Information, `Connection reconnecting because of error '${e}'.`) : this._logger.log(h.Information, "Connection reconnecting."), this._reconnectingCallbacks.length !== 0) {
917
+ try {
918
+ this._reconnectingCallbacks.forEach((i) => i.apply(this, [e]));
919
+ } catch (i) {
920
+ this._logger.log(h.Error, `An onreconnecting callback called with error '${e}' threw error '${i}'.`);
921
+ }
922
+ if (this._connectionState !== v.Reconnecting) {
923
+ this._logger.log(h.Debug, "Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");
924
+ return;
925
+ }
926
+ }
927
+ for (; o !== null; ) {
928
+ if (this._logger.log(h.Information, `Reconnect attempt number ${n} will start in ${o} ms.`), await new Promise((i) => {
929
+ this._reconnectDelayHandle = setTimeout(i, o);
930
+ }), this._reconnectDelayHandle = void 0, this._connectionState !== v.Reconnecting) {
931
+ this._logger.log(h.Debug, "Connection left the reconnecting state during reconnect delay. Done reconnecting.");
932
+ return;
933
+ }
934
+ try {
935
+ if (await this._startInternal(), this._connectionState = v.Connected, this._logger.log(h.Information, "HubConnection reconnected successfully."), this._reconnectedCallbacks.length !== 0)
936
+ try {
937
+ this._reconnectedCallbacks.forEach((i) => i.apply(this, [this.connection.connectionId]));
938
+ } catch (i) {
939
+ this._logger.log(h.Error, `An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${i}'.`);
940
+ }
941
+ return;
942
+ } catch (i) {
943
+ if (this._logger.log(h.Information, `Reconnect attempt failed because of error '${i}'.`), this._connectionState !== v.Reconnecting) {
944
+ this._logger.log(h.Debug, `Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`), this._connectionState === v.Disconnecting && this._completeClose();
945
+ return;
946
+ }
947
+ s = i instanceof Error ? i : new Error(i.toString()), o = this._getNextRetryDelay(n++, Date.now() - t, s);
948
+ }
949
+ }
950
+ this._logger.log(h.Information, `Reconnect retries have been exhausted after ${Date.now() - t} ms and ${n} failed attempts. Connection disconnecting.`), this._completeClose();
951
+ }
952
+ _getNextRetryDelay(e, t, n) {
953
+ try {
954
+ return this._reconnectPolicy.nextRetryDelayInMilliseconds({
955
+ elapsedMilliseconds: t,
956
+ previousRetryCount: e,
957
+ retryReason: n
958
+ });
959
+ } catch (s) {
960
+ return this._logger.log(h.Error, `IRetryPolicy.nextRetryDelayInMilliseconds(${e}, ${t}) threw error '${s}'.`), null;
961
+ }
962
+ }
963
+ _cancelCallbacksWithError(e) {
964
+ const t = this._callbacks;
965
+ this._callbacks = {}, Object.keys(t).forEach((n) => {
966
+ const s = t[n];
967
+ try {
968
+ s(null, e);
969
+ } catch (o) {
970
+ this._logger.log(h.Error, `Stream 'error' callback called with '${e}' threw error: ${Ee(o)}`);
971
+ }
972
+ });
973
+ }
974
+ _cleanupPingTimer() {
975
+ this._pingServerHandle && (clearTimeout(this._pingServerHandle), this._pingServerHandle = void 0);
976
+ }
977
+ _cleanupTimeout() {
978
+ this._timeoutHandle && clearTimeout(this._timeoutHandle);
979
+ }
980
+ _createInvocation(e, t, n, s) {
981
+ if (n)
982
+ return s.length !== 0 ? {
983
+ arguments: t,
984
+ streamIds: s,
985
+ target: e,
986
+ type: _.Invocation
987
+ } : {
988
+ arguments: t,
989
+ target: e,
990
+ type: _.Invocation
991
+ };
992
+ {
993
+ const o = this._invocationId;
994
+ return this._invocationId++, s.length !== 0 ? {
995
+ arguments: t,
996
+ invocationId: o.toString(),
997
+ streamIds: s,
998
+ target: e,
999
+ type: _.Invocation
1000
+ } : {
1001
+ arguments: t,
1002
+ invocationId: o.toString(),
1003
+ target: e,
1004
+ type: _.Invocation
1005
+ };
1006
+ }
1007
+ }
1008
+ _launchStreams(e, t) {
1009
+ if (e.length !== 0) {
1010
+ t || (t = Promise.resolve());
1011
+ for (const n in e)
1012
+ e[n].subscribe({
1013
+ complete: () => {
1014
+ t = t.then(() => this._sendWithProtocol(this._createCompletionMessage(n)));
1015
+ },
1016
+ error: (s) => {
1017
+ let o;
1018
+ s instanceof Error ? o = s.message : s && s.toString ? o = s.toString() : o = "Unknown error", t = t.then(() => this._sendWithProtocol(this._createCompletionMessage(n, o)));
1019
+ },
1020
+ next: (s) => {
1021
+ t = t.then(() => this._sendWithProtocol(this._createStreamItemMessage(n, s)));
1022
+ }
1023
+ });
1024
+ }
1025
+ }
1026
+ _replaceStreamingParams(e) {
1027
+ const t = [], n = [];
1028
+ for (let s = 0; s < e.length; s++) {
1029
+ const o = e[s];
1030
+ if (this._isObservable(o)) {
1031
+ const i = this._invocationId;
1032
+ this._invocationId++, t[i] = o, n.push(i.toString()), e.splice(s, 1);
1033
+ }
1034
+ }
1035
+ return [t, n];
1036
+ }
1037
+ _isObservable(e) {
1038
+ return e && e.subscribe && typeof e.subscribe == "function";
1039
+ }
1040
+ _createStreamInvocation(e, t, n) {
1041
+ const s = this._invocationId;
1042
+ return this._invocationId++, n.length !== 0 ? {
1043
+ arguments: t,
1044
+ invocationId: s.toString(),
1045
+ streamIds: n,
1046
+ target: e,
1047
+ type: _.StreamInvocation
1048
+ } : {
1049
+ arguments: t,
1050
+ invocationId: s.toString(),
1051
+ target: e,
1052
+ type: _.StreamInvocation
1053
+ };
1054
+ }
1055
+ _createCancelInvocation(e) {
1056
+ return {
1057
+ invocationId: e,
1058
+ type: _.CancelInvocation
1059
+ };
1060
+ }
1061
+ _createStreamItemMessage(e, t) {
1062
+ return {
1063
+ invocationId: e,
1064
+ item: t,
1065
+ type: _.StreamItem
1066
+ };
1067
+ }
1068
+ _createCompletionMessage(e, t, n) {
1069
+ return t ? {
1070
+ error: t,
1071
+ invocationId: e,
1072
+ type: _.Completion
1073
+ } : {
1074
+ invocationId: e,
1075
+ result: n,
1076
+ type: _.Completion
1077
+ };
1078
+ }
1079
+ _createCloseMessage() {
1080
+ return { type: _.Close };
1081
+ }
1082
+ }
1083
+ const Pt = [0, 2e3, 1e4, 3e4, null];
1084
+ class je {
1085
+ constructor(e) {
1086
+ this._retryDelays = e !== void 0 ? [...e, null] : Pt;
1087
+ }
1088
+ nextRetryDelayInMilliseconds(e) {
1089
+ return this._retryDelays[e.previousRetryCount];
1090
+ }
1091
+ }
1092
+ class ee {
1093
+ }
1094
+ ee.Authorization = "Authorization";
1095
+ ee.Cookie = "Cookie";
1096
+ class $t extends Ie {
1097
+ constructor(e, t) {
1098
+ super(), this._innerClient = e, this._accessTokenFactory = t;
1099
+ }
1100
+ async send(e) {
1101
+ let t = !0;
1102
+ this._accessTokenFactory && (!this._accessToken || e.url && e.url.indexOf("/negotiate?") > 0) && (t = !1, this._accessToken = await this._accessTokenFactory()), this._setAuthorizationHeader(e);
1103
+ const n = await this._innerClient.send(e);
1104
+ return t && n.statusCode === 401 && this._accessTokenFactory ? (this._accessToken = await this._accessTokenFactory(), this._setAuthorizationHeader(e), await this._innerClient.send(e)) : n;
1105
+ }
1106
+ _setAuthorizationHeader(e) {
1107
+ e.headers || (e.headers = {}), this._accessToken ? e.headers[ee.Authorization] = `Bearer ${this._accessToken}` : this._accessTokenFactory && e.headers[ee.Authorization] && delete e.headers[ee.Authorization];
1108
+ }
1109
+ getCookieString(e) {
1110
+ return this._innerClient.getCookieString(e);
1111
+ }
1112
+ }
1113
+ var O;
1114
+ (function(r) {
1115
+ r[r.None = 0] = "None", r[r.WebSockets = 1] = "WebSockets", r[r.ServerSentEvents = 2] = "ServerSentEvents", r[r.LongPolling = 4] = "LongPolling";
1116
+ })(O || (O = {}));
1117
+ var B;
1118
+ (function(r) {
1119
+ r[r.Text = 1] = "Text", r[r.Binary = 2] = "Binary";
1120
+ })(B || (B = {}));
1121
+ let Dt = class {
1122
+ constructor() {
1123
+ this._isAborted = !1, this.onabort = null;
1124
+ }
1125
+ abort() {
1126
+ this._isAborted || (this._isAborted = !0, this.onabort && this.onabort());
1127
+ }
1128
+ get signal() {
1129
+ return this;
1130
+ }
1131
+ get aborted() {
1132
+ return this._isAborted;
1133
+ }
1134
+ };
1135
+ class ze {
1136
+ // This is an internal type, not exported from 'index' so this is really just internal.
1137
+ get pollAborted() {
1138
+ return this._pollAbort.aborted;
1139
+ }
1140
+ constructor(e, t, n) {
1141
+ this._httpClient = e, this._logger = t, this._pollAbort = new Dt(), this._options = n, this._running = !1, this.onreceive = null, this.onclose = null;
1142
+ }
1143
+ async connect(e, t) {
1144
+ if (D.isRequired(e, "url"), D.isRequired(t, "transferFormat"), D.isIn(t, B, "transferFormat"), this._url = e, this._logger.log(h.Trace, "(LongPolling transport) Connecting."), t === B.Binary && typeof XMLHttpRequest < "u" && typeof new XMLHttpRequest().responseType != "string")
1145
+ throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");
1146
+ const [n, s] = ce(), o = { [n]: s, ...this._options.headers }, i = {
1147
+ abortSignal: this._pollAbort.signal,
1148
+ headers: o,
1149
+ timeout: 1e5,
1150
+ withCredentials: this._options.withCredentials
1151
+ };
1152
+ t === B.Binary && (i.responseType = "arraybuffer");
1153
+ const c = `${e}&_=${Date.now()}`;
1154
+ this._logger.log(h.Trace, `(LongPolling transport) polling: ${c}.`);
1155
+ const a = await this._httpClient.get(c, i);
1156
+ a.statusCode !== 200 ? (this._logger.log(h.Error, `(LongPolling transport) Unexpected response code: ${a.statusCode}.`), this._closeError = new V(a.statusText || "", a.statusCode), this._running = !1) : this._running = !0, this._receiving = this._poll(this._url, i);
1157
+ }
1158
+ async _poll(e, t) {
1159
+ try {
1160
+ for (; this._running; )
1161
+ try {
1162
+ const n = `${e}&_=${Date.now()}`;
1163
+ this._logger.log(h.Trace, `(LongPolling transport) polling: ${n}.`);
1164
+ const s = await this._httpClient.get(n, t);
1165
+ s.statusCode === 204 ? (this._logger.log(h.Information, "(LongPolling transport) Poll terminated by server."), this._running = !1) : s.statusCode !== 200 ? (this._logger.log(h.Error, `(LongPolling transport) Unexpected response code: ${s.statusCode}.`), this._closeError = new V(s.statusText || "", s.statusCode), this._running = !1) : s.content ? (this._logger.log(h.Trace, `(LongPolling transport) data received. ${pe(s.content, this._options.logMessageContent)}.`), this.onreceive && this.onreceive(s.content)) : this._logger.log(h.Trace, "(LongPolling transport) Poll timed out, reissuing.");
1166
+ } catch (n) {
1167
+ this._running ? n instanceof Le ? this._logger.log(h.Trace, "(LongPolling transport) Poll timed out, reissuing.") : (this._closeError = n, this._running = !1) : this._logger.log(h.Trace, `(LongPolling transport) Poll errored after shutdown: ${n.message}`);
1168
+ }
1169
+ } finally {
1170
+ this._logger.log(h.Trace, "(LongPolling transport) Polling complete."), this.pollAborted || this._raiseOnClose();
1171
+ }
1172
+ }
1173
+ async send(e) {
1174
+ return this._running ? Ze(this._logger, "LongPolling", this._httpClient, this._url, e, this._options) : Promise.reject(new Error("Cannot send until the transport is connected"));
1175
+ }
1176
+ async stop() {
1177
+ this._logger.log(h.Trace, "(LongPolling transport) Stopping polling."), this._running = !1, this._pollAbort.abort();
1178
+ try {
1179
+ await this._receiving, this._logger.log(h.Trace, `(LongPolling transport) sending DELETE request to ${this._url}.`);
1180
+ const e = {}, [t, n] = ce();
1181
+ e[t] = n;
1182
+ const s = {
1183
+ headers: { ...e, ...this._options.headers },
1184
+ timeout: this._options.timeout,
1185
+ withCredentials: this._options.withCredentials
1186
+ };
1187
+ let o;
1188
+ try {
1189
+ await this._httpClient.delete(this._url, s);
1190
+ } catch (i) {
1191
+ o = i;
1192
+ }
1193
+ o ? o instanceof V && (o.statusCode === 404 ? this._logger.log(h.Trace, "(LongPolling transport) A 404 response was returned from sending a DELETE request.") : this._logger.log(h.Trace, `(LongPolling transport) Error sending a DELETE request: ${o}`)) : this._logger.log(h.Trace, "(LongPolling transport) DELETE request accepted.");
1194
+ } finally {
1195
+ this._logger.log(h.Trace, "(LongPolling transport) Stop finished."), this._raiseOnClose();
1196
+ }
1197
+ }
1198
+ _raiseOnClose() {
1199
+ if (this.onclose) {
1200
+ let e = "(LongPolling transport) Firing onclose event.";
1201
+ this._closeError && (e += " Error: " + this._closeError), this._logger.log(h.Trace, e), this.onclose(this._closeError);
1202
+ }
1203
+ }
1204
+ }
1205
+ class Rt {
1206
+ constructor(e, t, n, s) {
1207
+ this._httpClient = e, this._accessToken = t, this._logger = n, this._options = s, this.onreceive = null, this.onclose = null;
1208
+ }
1209
+ async connect(e, t) {
1210
+ return D.isRequired(e, "url"), D.isRequired(t, "transferFormat"), D.isIn(t, B, "transferFormat"), this._logger.log(h.Trace, "(SSE transport) Connecting."), this._url = e, this._accessToken && (e += (e.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(this._accessToken)}`), new Promise((n, s) => {
1211
+ let o = !1;
1212
+ if (t !== B.Text) {
1213
+ s(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));
1214
+ return;
1215
+ }
1216
+ let i;
1217
+ if (k.isBrowser || k.isWebWorker)
1218
+ i = new this._options.EventSource(e, { withCredentials: this._options.withCredentials });
1219
+ else {
1220
+ const c = this._httpClient.getCookieString(e), a = {};
1221
+ a.Cookie = c;
1222
+ const [l, u] = ce();
1223
+ a[l] = u, i = new this._options.EventSource(e, { withCredentials: this._options.withCredentials, headers: { ...a, ...this._options.headers } });
1224
+ }
1225
+ try {
1226
+ i.onmessage = (c) => {
1227
+ if (this.onreceive)
1228
+ try {
1229
+ this._logger.log(h.Trace, `(SSE transport) data received. ${pe(c.data, this._options.logMessageContent)}.`), this.onreceive(c.data);
1230
+ } catch (a) {
1231
+ this._close(a);
1232
+ return;
1233
+ }
1234
+ }, i.onerror = (c) => {
1235
+ o ? this._close() : s(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."));
1236
+ }, i.onopen = () => {
1237
+ this._logger.log(h.Information, `SSE connected to ${this._url}`), this._eventSource = i, o = !0, n();
1238
+ };
1239
+ } catch (c) {
1240
+ s(c);
1241
+ return;
1242
+ }
1243
+ });
1244
+ }
1245
+ async send(e) {
1246
+ return this._eventSource ? Ze(this._logger, "SSE", this._httpClient, this._url, e, this._options) : Promise.reject(new Error("Cannot send until the transport is connected"));
1247
+ }
1248
+ stop() {
1249
+ return this._close(), Promise.resolve();
1250
+ }
1251
+ _close(e) {
1252
+ this._eventSource && (this._eventSource.close(), this._eventSource = void 0, this.onclose && this.onclose(e));
1253
+ }
1254
+ }
1255
+ class xt {
1256
+ constructor(e, t, n, s, o, i) {
1257
+ this._logger = n, this._accessTokenFactory = t, this._logMessageContent = s, this._webSocketConstructor = o, this._httpClient = e, this.onreceive = null, this.onclose = null, this._headers = i;
1258
+ }
1259
+ async connect(e, t) {
1260
+ D.isRequired(e, "url"), D.isRequired(t, "transferFormat"), D.isIn(t, B, "transferFormat"), this._logger.log(h.Trace, "(WebSockets transport) Connecting.");
1261
+ let n;
1262
+ return this._accessTokenFactory && (n = await this._accessTokenFactory()), new Promise((s, o) => {
1263
+ e = e.replace(/^http/, "ws");
1264
+ let i;
1265
+ const c = this._httpClient.getCookieString(e);
1266
+ let a = !1;
1267
+ if (k.isNode || k.isReactNative) {
1268
+ const l = {}, [u, p] = ce();
1269
+ l[u] = p, n && (l[ee.Authorization] = `Bearer ${n}`), c && (l[ee.Cookie] = c), i = new this._webSocketConstructor(e, void 0, {
1270
+ headers: { ...l, ...this._headers }
1271
+ });
1272
+ } else
1273
+ n && (e += (e.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(n)}`);
1274
+ i || (i = new this._webSocketConstructor(e)), t === B.Binary && (i.binaryType = "arraybuffer"), i.onopen = (l) => {
1275
+ this._logger.log(h.Information, `WebSocket connected to ${e}.`), this._webSocket = i, a = !0, s();
1276
+ }, i.onerror = (l) => {
1277
+ let u = null;
1278
+ typeof ErrorEvent < "u" && l instanceof ErrorEvent ? u = l.error : u = "There was an error with the transport", this._logger.log(h.Information, `(WebSockets transport) ${u}.`);
1279
+ }, i.onmessage = (l) => {
1280
+ if (this._logger.log(h.Trace, `(WebSockets transport) data received. ${pe(l.data, this._logMessageContent)}.`), this.onreceive)
1281
+ try {
1282
+ this.onreceive(l.data);
1283
+ } catch (u) {
1284
+ this._close(u);
1285
+ return;
1286
+ }
1287
+ }, i.onclose = (l) => {
1288
+ if (a)
1289
+ this._close(l);
1290
+ else {
1291
+ let u = null;
1292
+ typeof ErrorEvent < "u" && l instanceof ErrorEvent ? u = l.error : u = "WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.", o(new Error(u));
1293
+ }
1294
+ };
1295
+ });
1296
+ }
1297
+ send(e) {
1298
+ return this._webSocket && this._webSocket.readyState === this._webSocketConstructor.OPEN ? (this._logger.log(h.Trace, `(WebSockets transport) sending data. ${pe(e, this._logMessageContent)}.`), this._webSocket.send(e), Promise.resolve()) : Promise.reject("WebSocket is not in the OPEN state");
1299
+ }
1300
+ stop() {
1301
+ return this._webSocket && this._close(void 0), Promise.resolve();
1302
+ }
1303
+ _close(e) {
1304
+ this._webSocket && (this._webSocket.onclose = () => {
1305
+ }, this._webSocket.onmessage = () => {
1306
+ }, this._webSocket.onerror = () => {
1307
+ }, this._webSocket.close(), this._webSocket = void 0), this._logger.log(h.Trace, "(WebSockets transport) socket closed."), this.onclose && (this._isCloseEvent(e) && (e.wasClean === !1 || e.code !== 1e3) ? this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason || "no reason given"}).`)) : e instanceof Error ? this.onclose(e) : this.onclose());
1308
+ }
1309
+ _isCloseEvent(e) {
1310
+ return e && typeof e.wasClean == "boolean" && typeof e.code == "number";
1311
+ }
1312
+ }
1313
+ const qe = 100;
1314
+ class Nt {
1315
+ constructor(e, t = {}) {
1316
+ if (this._stopPromiseResolver = () => {
1317
+ }, this.features = {}, this._negotiateVersion = 1, D.isRequired(e, "url"), this._logger = ht(t.logger), this.baseUrl = this._resolveUrl(e), t = t || {}, t.logMessageContent = t.logMessageContent === void 0 ? !1 : t.logMessageContent, typeof t.withCredentials == "boolean" || t.withCredentials === void 0)
1318
+ t.withCredentials = t.withCredentials === void 0 ? !0 : t.withCredentials;
1319
+ else
1320
+ throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");
1321
+ t.timeout = t.timeout === void 0 ? 100 * 1e3 : t.timeout;
1322
+ let n = null, s = null;
1323
+ if (k.isNode && typeof require < "u") {
1324
+ const o = typeof __webpack_require__ == "function" ? __non_webpack_require__ : require;
1325
+ n = o("ws"), s = o("eventsource");
1326
+ }
1327
+ !k.isNode && typeof WebSocket < "u" && !t.WebSocket ? t.WebSocket = WebSocket : k.isNode && !t.WebSocket && n && (t.WebSocket = n), !k.isNode && typeof EventSource < "u" && !t.EventSource ? t.EventSource = EventSource : k.isNode && !t.EventSource && typeof s < "u" && (t.EventSource = s), this._httpClient = new $t(t.httpClient || new bt(this._logger), t.accessTokenFactory), this._connectionState = "Disconnected", this._connectionStarted = !1, this._options = t, this.onreceive = null, this.onclose = null;
1328
+ }
1329
+ async start(e) {
1330
+ if (e = e || B.Binary, D.isIn(e, B, "transferFormat"), this._logger.log(h.Debug, `Starting connection with transfer format '${B[e]}'.`), this._connectionState !== "Disconnected")
1331
+ return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));
1332
+ if (this._connectionState = "Connecting", this._startInternalPromise = this._startInternal(e), await this._startInternalPromise, this._connectionState === "Disconnecting") {
1333
+ const t = "Failed to start the HttpConnection before stop() was called.";
1334
+ return this._logger.log(h.Error, t), await this._stopPromise, Promise.reject(new K(t));
1335
+ } else if (this._connectionState !== "Connected") {
1336
+ const t = "HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";
1337
+ return this._logger.log(h.Error, t), Promise.reject(new K(t));
1338
+ }
1339
+ this._connectionStarted = !0;
1340
+ }
1341
+ send(e) {
1342
+ return this._connectionState !== "Connected" ? Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")) : (this._sendQueue || (this._sendQueue = new We(this.transport)), this._sendQueue.send(e));
1343
+ }
1344
+ async stop(e) {
1345
+ if (this._connectionState === "Disconnected")
1346
+ return this._logger.log(h.Debug, `Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`), Promise.resolve();
1347
+ if (this._connectionState === "Disconnecting")
1348
+ return this._logger.log(h.Debug, `Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`), this._stopPromise;
1349
+ this._connectionState = "Disconnecting", this._stopPromise = new Promise((t) => {
1350
+ this._stopPromiseResolver = t;
1351
+ }), await this._stopInternal(e), await this._stopPromise;
1352
+ }
1353
+ async _stopInternal(e) {
1354
+ this._stopError = e;
1355
+ try {
1356
+ await this._startInternalPromise;
1357
+ } catch {
1358
+ }
1359
+ if (this.transport) {
1360
+ try {
1361
+ await this.transport.stop();
1362
+ } catch (t) {
1363
+ this._logger.log(h.Error, `HttpConnection.transport.stop() threw error '${t}'.`), this._stopConnection();
1364
+ }
1365
+ this.transport = void 0;
1366
+ } else
1367
+ this._logger.log(h.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.");
1368
+ }
1369
+ async _startInternal(e) {
1370
+ let t = this.baseUrl;
1371
+ this._accessTokenFactory = this._options.accessTokenFactory, this._httpClient._accessTokenFactory = this._accessTokenFactory;
1372
+ try {
1373
+ if (this._options.skipNegotiation)
1374
+ if (this._options.transport === O.WebSockets)
1375
+ this.transport = this._constructTransport(O.WebSockets), await this._startTransport(t, e);
1376
+ else
1377
+ throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");
1378
+ else {
1379
+ let n = null, s = 0;
1380
+ do {
1381
+ if (n = await this._getNegotiationResponse(t), this._connectionState === "Disconnecting" || this._connectionState === "Disconnected")
1382
+ throw new K("The connection was stopped during negotiation.");
1383
+ if (n.error)
1384
+ throw new Error(n.error);
1385
+ if (n.ProtocolVersion)
1386
+ throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");
1387
+ if (n.url && (t = n.url), n.accessToken) {
1388
+ const o = n.accessToken;
1389
+ this._accessTokenFactory = () => o, this._httpClient._accessToken = o, this._httpClient._accessTokenFactory = void 0;
1390
+ }
1391
+ s++;
1392
+ } while (n.url && s < qe);
1393
+ if (s === qe && n.url)
1394
+ throw new Error("Negotiate redirection limit exceeded.");
1395
+ await this._createTransport(t, this._options.transport, n, e);
1396
+ }
1397
+ this.transport instanceof ze && (this.features.inherentKeepAlive = !0), this._connectionState === "Connecting" && (this._logger.log(h.Debug, "The HttpConnection connected successfully."), this._connectionState = "Connected");
1398
+ } catch (n) {
1399
+ return this._logger.log(h.Error, "Failed to start the connection: " + n), this._connectionState = "Disconnected", this.transport = void 0, this._stopPromiseResolver(), Promise.reject(n);
1400
+ }
1401
+ }
1402
+ async _getNegotiationResponse(e) {
1403
+ const t = {}, [n, s] = ce();
1404
+ t[n] = s;
1405
+ const o = this._resolveNegotiateUrl(e);
1406
+ this._logger.log(h.Debug, `Sending negotiation request: ${o}.`);
1407
+ try {
1408
+ const i = await this._httpClient.post(o, {
1409
+ content: "",
1410
+ headers: { ...t, ...this._options.headers },
1411
+ timeout: this._options.timeout,
1412
+ withCredentials: this._options.withCredentials
1413
+ });
1414
+ if (i.statusCode !== 200)
1415
+ return Promise.reject(new Error(`Unexpected status code returned from negotiate '${i.statusCode}'`));
1416
+ const c = JSON.parse(i.content);
1417
+ return (!c.negotiateVersion || c.negotiateVersion < 1) && (c.connectionToken = c.connectionId), c.useStatefulReconnect && this._options._useStatefulReconnect !== !0 ? Promise.reject(new Ue("Client didn't negotiate Stateful Reconnect but the server did.")) : c;
1418
+ } catch (i) {
1419
+ let c = "Failed to complete negotiation with the server: " + i;
1420
+ return i instanceof V && i.statusCode === 404 && (c = c + " Either this is not a SignalR endpoint or there is a proxy blocking the connection."), this._logger.log(h.Error, c), Promise.reject(new Ue(c));
1421
+ }
1422
+ }
1423
+ _createConnectUrl(e, t) {
1424
+ return t ? e + (e.indexOf("?") === -1 ? "?" : "&") + `id=${t}` : e;
1425
+ }
1426
+ async _createTransport(e, t, n, s) {
1427
+ let o = this._createConnectUrl(e, n.connectionToken);
1428
+ if (this._isITransport(t)) {
1429
+ this._logger.log(h.Debug, "Connection was provided an instance of ITransport, using that directly."), this.transport = t, await this._startTransport(o, s), this.connectionId = n.connectionId;
1430
+ return;
1431
+ }
1432
+ const i = [], c = n.availableTransports || [];
1433
+ let a = n;
1434
+ for (const l of c) {
1435
+ const u = this._resolveTransportOrError(l, t, s, (a == null ? void 0 : a.useStatefulReconnect) === !0);
1436
+ if (u instanceof Error)
1437
+ i.push(`${l.transport} failed:`), i.push(u);
1438
+ else if (this._isITransport(u)) {
1439
+ if (this.transport = u, !a) {
1440
+ try {
1441
+ a = await this._getNegotiationResponse(e);
1442
+ } catch (p) {
1443
+ return Promise.reject(p);
1444
+ }
1445
+ o = this._createConnectUrl(e, a.connectionToken);
1446
+ }
1447
+ try {
1448
+ await this._startTransport(o, s), this.connectionId = a.connectionId;
1449
+ return;
1450
+ } catch (p) {
1451
+ if (this._logger.log(h.Error, `Failed to start the transport '${l.transport}': ${p}`), a = void 0, i.push(new ct(`${l.transport} failed: ${p}`, O[l.transport])), this._connectionState !== "Connecting") {
1452
+ const f = "Failed to select transport before stop() was called.";
1453
+ return this._logger.log(h.Debug, f), Promise.reject(new K(f));
1454
+ }
1455
+ }
1456
+ }
1457
+ }
1458
+ return i.length > 0 ? Promise.reject(new lt(`Unable to connect to the server with any of the available transports. ${i.join(" ")}`, i)) : Promise.reject(new Error("None of the transports supported by the client are supported by the server."));
1459
+ }
1460
+ _constructTransport(e) {
1461
+ switch (e) {
1462
+ case O.WebSockets:
1463
+ if (!this._options.WebSocket)
1464
+ throw new Error("'WebSocket' is not supported in your environment.");
1465
+ return new xt(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent, this._options.WebSocket, this._options.headers || {});
1466
+ case O.ServerSentEvents:
1467
+ if (!this._options.EventSource)
1468
+ throw new Error("'EventSource' is not supported in your environment.");
1469
+ return new Rt(this._httpClient, this._httpClient._accessToken, this._logger, this._options);
1470
+ case O.LongPolling:
1471
+ return new ze(this._httpClient, this._logger, this._options);
1472
+ default:
1473
+ throw new Error(`Unknown transport: ${e}.`);
1474
+ }
1475
+ }
1476
+ _startTransport(e, t) {
1477
+ return this.transport.onreceive = this.onreceive, this.features.reconnect ? this.transport.onclose = async (n) => {
1478
+ let s = !1;
1479
+ if (this.features.reconnect)
1480
+ try {
1481
+ this.features.disconnected(), await this.transport.connect(e, t), await this.features.resend();
1482
+ } catch {
1483
+ s = !0;
1484
+ }
1485
+ else {
1486
+ this._stopConnection(n);
1487
+ return;
1488
+ }
1489
+ s && this._stopConnection(n);
1490
+ } : this.transport.onclose = (n) => this._stopConnection(n), this.transport.connect(e, t);
1491
+ }
1492
+ _resolveTransportOrError(e, t, n, s) {
1493
+ const o = O[e.transport];
1494
+ if (o == null)
1495
+ return this._logger.log(h.Debug, `Skipping transport '${e.transport}' because it is not supported by this client.`), new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);
1496
+ if (Ot(t, o))
1497
+ if (e.transferFormats.map((c) => B[c]).indexOf(n) >= 0) {
1498
+ if (o === O.WebSockets && !this._options.WebSocket || o === O.ServerSentEvents && !this._options.EventSource)
1499
+ return this._logger.log(h.Debug, `Skipping transport '${O[o]}' because it is not supported in your environment.'`), new it(`'${O[o]}' is not supported in your environment.`, o);
1500
+ this._logger.log(h.Debug, `Selecting transport '${O[o]}'.`);
1501
+ try {
1502
+ return this.features.reconnect = o === O.WebSockets ? s : void 0, this._constructTransport(o);
1503
+ } catch (c) {
1504
+ return c;
1505
+ }
1506
+ } else
1507
+ return this._logger.log(h.Debug, `Skipping transport '${O[o]}' because it does not support the requested transfer format '${B[n]}'.`), new Error(`'${O[o]}' does not support ${B[n]}.`);
1508
+ else
1509
+ return this._logger.log(h.Debug, `Skipping transport '${O[o]}' because it was disabled by the client.`), new at(`'${O[o]}' is disabled by the client.`, o);
1510
+ }
1511
+ _isITransport(e) {
1512
+ return e && typeof e == "object" && "connect" in e;
1513
+ }
1514
+ _stopConnection(e) {
1515
+ if (this._logger.log(h.Debug, `HttpConnection.stopConnection(${e}) called while in state ${this._connectionState}.`), this.transport = void 0, e = this._stopError || e, this._stopError = void 0, this._connectionState === "Disconnected") {
1516
+ this._logger.log(h.Debug, `Call to HttpConnection.stopConnection(${e}) was ignored because the connection is already in the disconnected state.`);
1517
+ return;
1518
+ }
1519
+ if (this._connectionState === "Connecting")
1520
+ throw this._logger.log(h.Warning, `Call to HttpConnection.stopConnection(${e}) was ignored because the connection is still in the connecting state.`), new Error(`HttpConnection.stopConnection(${e}) was called while the connection is still in the connecting state.`);
1521
+ if (this._connectionState === "Disconnecting" && this._stopPromiseResolver(), e ? this._logger.log(h.Error, `Connection disconnected with error '${e}'.`) : this._logger.log(h.Information, "Connection disconnected."), this._sendQueue && (this._sendQueue.stop().catch((t) => {
1522
+ this._logger.log(h.Error, `TransportSendQueue.stop() threw error '${t}'.`);
1523
+ }), this._sendQueue = void 0), this.connectionId = void 0, this._connectionState = "Disconnected", this._connectionStarted) {
1524
+ this._connectionStarted = !1;
1525
+ try {
1526
+ this.onclose && this.onclose(e);
1527
+ } catch (t) {
1528
+ this._logger.log(h.Error, `HttpConnection.onclose(${e}) threw error '${t}'.`);
1529
+ }
1530
+ }
1531
+ }
1532
+ _resolveUrl(e) {
1533
+ if (e.lastIndexOf("https://", 0) === 0 || e.lastIndexOf("http://", 0) === 0)
1534
+ return e;
1535
+ if (!k.isBrowser)
1536
+ throw new Error(`Cannot resolve '${e}'.`);
1537
+ const t = window.document.createElement("a");
1538
+ return t.href = e, this._logger.log(h.Information, `Normalizing '${e}' to '${t.href}'.`), t.href;
1539
+ }
1540
+ _resolveNegotiateUrl(e) {
1541
+ const t = new URL(e);
1542
+ t.pathname.endsWith("/") ? t.pathname += "negotiate" : t.pathname += "/negotiate";
1543
+ const n = new URLSearchParams(t.searchParams);
1544
+ return n.has("negotiateVersion") || n.append("negotiateVersion", this._negotiateVersion.toString()), n.has("useStatefulReconnect") ? n.get("useStatefulReconnect") === "true" && (this._options._useStatefulReconnect = !0) : this._options._useStatefulReconnect === !0 && n.append("useStatefulReconnect", "true"), t.search = n.toString(), t.toString();
1545
+ }
1546
+ }
1547
+ function Ot(r, e) {
1548
+ return !r || (e & r) !== 0;
1549
+ }
1550
+ class We {
1551
+ constructor(e) {
1552
+ this._transport = e, this._buffer = [], this._executing = !0, this._sendBufferedData = new Se(), this._transportResult = new Se(), this._sendLoopPromise = this._sendLoop();
1553
+ }
1554
+ send(e) {
1555
+ return this._bufferData(e), this._transportResult || (this._transportResult = new Se()), this._transportResult.promise;
1556
+ }
1557
+ stop() {
1558
+ return this._executing = !1, this._sendBufferedData.resolve(), this._sendLoopPromise;
1559
+ }
1560
+ _bufferData(e) {
1561
+ if (this._buffer.length && typeof this._buffer[0] != typeof e)
1562
+ throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);
1563
+ this._buffer.push(e), this._sendBufferedData.resolve();
1564
+ }
1565
+ async _sendLoop() {
1566
+ for (; ; ) {
1567
+ if (await this._sendBufferedData.promise, !this._executing) {
1568
+ this._transportResult && this._transportResult.reject("Connection stopped.");
1569
+ break;
1570
+ }
1571
+ this._sendBufferedData = new Se();
1572
+ const e = this._transportResult;
1573
+ this._transportResult = void 0;
1574
+ const t = typeof this._buffer[0] == "string" ? this._buffer.join("") : We._concatBuffers(this._buffer);
1575
+ this._buffer.length = 0;
1576
+ try {
1577
+ await this._transport.send(t), e.resolve();
1578
+ } catch (n) {
1579
+ e.reject(n);
1580
+ }
1581
+ }
1582
+ }
1583
+ static _concatBuffers(e) {
1584
+ const t = e.map((o) => o.byteLength).reduce((o, i) => o + i), n = new Uint8Array(t);
1585
+ let s = 0;
1586
+ for (const o of e)
1587
+ n.set(new Uint8Array(o), s), s += o.byteLength;
1588
+ return n.buffer;
1589
+ }
1590
+ }
1591
+ class Se {
1592
+ constructor() {
1593
+ this.promise = new Promise((e, t) => [this._resolver, this._rejecter] = [e, t]);
1594
+ }
1595
+ resolve() {
1596
+ this._resolver();
1597
+ }
1598
+ reject(e) {
1599
+ this._rejecter(e);
1600
+ }
1601
+ }
1602
+ const Mt = "json";
1603
+ class Lt {
1604
+ constructor() {
1605
+ this.name = Mt, this.version = 2, this.transferFormat = B.Text;
1606
+ }
1607
+ /** Creates an array of {@link @microsoft/signalr.HubMessage} objects from the specified serialized representation.
1608
+ *
1609
+ * @param {string} input A string containing the serialized representation.
1610
+ * @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
1611
+ */
1612
+ parseMessages(e, t) {
1613
+ if (typeof e != "string")
1614
+ throw new Error("Invalid input for JSON hub protocol. Expected a string.");
1615
+ if (!e)
1616
+ return [];
1617
+ t === null && (t = fe.instance);
1618
+ const n = q.parse(e), s = [];
1619
+ for (const o of n) {
1620
+ const i = JSON.parse(o);
1621
+ if (typeof i.type != "number")
1622
+ throw new Error("Invalid payload.");
1623
+ switch (i.type) {
1624
+ case _.Invocation:
1625
+ this._isInvocationMessage(i);
1626
+ break;
1627
+ case _.StreamItem:
1628
+ this._isStreamItemMessage(i);
1629
+ break;
1630
+ case _.Completion:
1631
+ this._isCompletionMessage(i);
1632
+ break;
1633
+ case _.Ping:
1634
+ break;
1635
+ case _.Close:
1636
+ break;
1637
+ case _.Ack:
1638
+ this._isAckMessage(i);
1639
+ break;
1640
+ case _.Sequence:
1641
+ this._isSequenceMessage(i);
1642
+ break;
1643
+ default:
1644
+ t.log(h.Information, "Unknown message type '" + i.type + "' ignored.");
1645
+ continue;
1646
+ }
1647
+ s.push(i);
1648
+ }
1649
+ return s;
1650
+ }
1651
+ /** Writes the specified {@link @microsoft/signalr.HubMessage} to a string and returns it.
1652
+ *
1653
+ * @param {HubMessage} message The message to write.
1654
+ * @returns {string} A string containing the serialized representation of the message.
1655
+ */
1656
+ writeMessage(e) {
1657
+ return q.write(JSON.stringify(e));
1658
+ }
1659
+ _isInvocationMessage(e) {
1660
+ this._assertNotEmptyString(e.target, "Invalid payload for Invocation message."), e.invocationId !== void 0 && this._assertNotEmptyString(e.invocationId, "Invalid payload for Invocation message.");
1661
+ }
1662
+ _isStreamItemMessage(e) {
1663
+ if (this._assertNotEmptyString(e.invocationId, "Invalid payload for StreamItem message."), e.item === void 0)
1664
+ throw new Error("Invalid payload for StreamItem message.");
1665
+ }
1666
+ _isCompletionMessage(e) {
1667
+ if (e.result && e.error)
1668
+ throw new Error("Invalid payload for Completion message.");
1669
+ !e.result && e.error && this._assertNotEmptyString(e.error, "Invalid payload for Completion message."), this._assertNotEmptyString(e.invocationId, "Invalid payload for Completion message.");
1670
+ }
1671
+ _isAckMessage(e) {
1672
+ if (typeof e.sequenceId != "number")
1673
+ throw new Error("Invalid SequenceId for Ack message.");
1674
+ }
1675
+ _isSequenceMessage(e) {
1676
+ if (typeof e.sequenceId != "number")
1677
+ throw new Error("Invalid SequenceId for Sequence message.");
1678
+ }
1679
+ _assertNotEmptyString(e, t) {
1680
+ if (typeof e != "string" || e === "")
1681
+ throw new Error(t);
1682
+ }
1683
+ }
1684
+ const Gt = {
1685
+ trace: h.Trace,
1686
+ debug: h.Debug,
1687
+ info: h.Information,
1688
+ information: h.Information,
1689
+ warn: h.Warning,
1690
+ warning: h.Warning,
1691
+ error: h.Error,
1692
+ critical: h.Critical,
1693
+ none: h.None
1694
+ };
1695
+ function Wt(r) {
1696
+ const e = Gt[r.toLowerCase()];
1697
+ if (typeof e < "u")
1698
+ return e;
1699
+ throw new Error(`Unknown log level: ${r}`);
1700
+ }
1701
+ class Bt {
1702
+ configureLogging(e) {
1703
+ if (D.isRequired(e, "logging"), Ft(e))
1704
+ this.logger = e;
1705
+ else if (typeof e == "string") {
1706
+ const t = Wt(e);
1707
+ this.logger = new be(t);
1708
+ } else
1709
+ this.logger = new be(e);
1710
+ return this;
1711
+ }
1712
+ withUrl(e, t) {
1713
+ return D.isRequired(e, "url"), D.isNotEmpty(e, "url"), this.url = e, typeof t == "object" ? this.httpConnectionOptions = { ...this.httpConnectionOptions, ...t } : this.httpConnectionOptions = {
1714
+ ...this.httpConnectionOptions,
1715
+ transport: t
1716
+ }, this;
1717
+ }
1718
+ /** Configures the {@link @microsoft/signalr.HubConnection} to use the specified Hub Protocol.
1719
+ *
1720
+ * @param {IHubProtocol} protocol The {@link @microsoft/signalr.IHubProtocol} implementation to use.
1721
+ */
1722
+ withHubProtocol(e) {
1723
+ return D.isRequired(e, "protocol"), this.protocol = e, this;
1724
+ }
1725
+ withAutomaticReconnect(e) {
1726
+ if (this.reconnectPolicy)
1727
+ throw new Error("A reconnectPolicy has already been set.");
1728
+ return e ? Array.isArray(e) ? this.reconnectPolicy = new je(e) : this.reconnectPolicy = e : this.reconnectPolicy = new je(), this;
1729
+ }
1730
+ /** Configures {@link @microsoft/signalr.HubConnection.serverTimeoutInMilliseconds} for the {@link @microsoft/signalr.HubConnection}.
1731
+ *
1732
+ * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
1733
+ */
1734
+ withServerTimeout(e) {
1735
+ return D.isRequired(e, "milliseconds"), this._serverTimeoutInMilliseconds = e, this;
1736
+ }
1737
+ /** Configures {@link @microsoft/signalr.HubConnection.keepAliveIntervalInMilliseconds} for the {@link @microsoft/signalr.HubConnection}.
1738
+ *
1739
+ * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
1740
+ */
1741
+ withKeepAliveInterval(e) {
1742
+ return D.isRequired(e, "milliseconds"), this._keepAliveIntervalInMilliseconds = e, this;
1743
+ }
1744
+ /** Enables and configures options for the Stateful Reconnect feature.
1745
+ *
1746
+ * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
1747
+ */
1748
+ withStatefulReconnect(e) {
1749
+ return this.httpConnectionOptions === void 0 && (this.httpConnectionOptions = {}), this.httpConnectionOptions._useStatefulReconnect = !0, this._statefulReconnectBufferSize = e == null ? void 0 : e.bufferSize, this;
1750
+ }
1751
+ /** Creates a {@link @microsoft/signalr.HubConnection} from the configuration options specified in this builder.
1752
+ *
1753
+ * @returns {HubConnection} The configured {@link @microsoft/signalr.HubConnection}.
1754
+ */
1755
+ build() {
1756
+ const e = this.httpConnectionOptions || {};
1757
+ if (e.logger === void 0 && (e.logger = this.logger), !this.url)
1758
+ throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");
1759
+ const t = new Nt(this.url, e);
1760
+ return Ge.create(t, this.logger || fe.instance, this.protocol || new Lt(), this.reconnectPolicy, this._serverTimeoutInMilliseconds, this._keepAliveIntervalInMilliseconds, this._statefulReconnectBufferSize);
1761
+ }
1762
+ }
1763
+ function Ft(r) {
1764
+ return r.log !== void 0;
1765
+ }
1766
+ var w;
1767
+ (function(r) {
1768
+ r[r.PLAIN_TO_CLASS = 0] = "PLAIN_TO_CLASS", r[r.CLASS_TO_PLAIN = 1] = "CLASS_TO_PLAIN", r[r.CLASS_TO_CLASS = 2] = "CLASS_TO_CLASS";
1769
+ })(w || (w = {}));
1770
+ var Ut = (
1771
+ /** @class */
1772
+ function() {
1773
+ function r() {
1774
+ this._typeMetadatas = /* @__PURE__ */ new Map(), this._transformMetadatas = /* @__PURE__ */ new Map(), this._exposeMetadatas = /* @__PURE__ */ new Map(), this._excludeMetadatas = /* @__PURE__ */ new Map(), this._ancestorsMap = /* @__PURE__ */ new Map();
1775
+ }
1776
+ return r.prototype.addTypeMetadata = function(e) {
1777
+ this._typeMetadatas.has(e.target) || this._typeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._typeMetadatas.get(e.target).set(e.propertyName, e);
1778
+ }, r.prototype.addTransformMetadata = function(e) {
1779
+ this._transformMetadatas.has(e.target) || this._transformMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._transformMetadatas.get(e.target).has(e.propertyName) || this._transformMetadatas.get(e.target).set(e.propertyName, []), this._transformMetadatas.get(e.target).get(e.propertyName).push(e);
1780
+ }, r.prototype.addExposeMetadata = function(e) {
1781
+ this._exposeMetadatas.has(e.target) || this._exposeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._exposeMetadatas.get(e.target).set(e.propertyName, e);
1782
+ }, r.prototype.addExcludeMetadata = function(e) {
1783
+ this._excludeMetadatas.has(e.target) || this._excludeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._excludeMetadatas.get(e.target).set(e.propertyName, e);
1784
+ }, r.prototype.findTransformMetadatas = function(e, t, n) {
1785
+ return this.findMetadatas(this._transformMetadatas, e, t).filter(function(s) {
1786
+ return !s.options || s.options.toClassOnly === !0 && s.options.toPlainOnly === !0 ? !0 : s.options.toClassOnly === !0 ? n === w.CLASS_TO_CLASS || n === w.PLAIN_TO_CLASS : s.options.toPlainOnly === !0 ? n === w.CLASS_TO_PLAIN : !0;
1787
+ });
1788
+ }, r.prototype.findExcludeMetadata = function(e, t) {
1789
+ return this.findMetadata(this._excludeMetadatas, e, t);
1790
+ }, r.prototype.findExposeMetadata = function(e, t) {
1791
+ return this.findMetadata(this._exposeMetadatas, e, t);
1792
+ }, r.prototype.findExposeMetadataByCustomName = function(e, t) {
1793
+ return this.getExposedMetadatas(e).find(function(n) {
1794
+ return n.options && n.options.name === t;
1795
+ });
1796
+ }, r.prototype.findTypeMetadata = function(e, t) {
1797
+ return this.findMetadata(this._typeMetadatas, e, t);
1798
+ }, r.prototype.getStrategy = function(e) {
1799
+ var t = this._excludeMetadatas.get(e), n = t && t.get(void 0), s = this._exposeMetadatas.get(e), o = s && s.get(void 0);
1800
+ return n && o || !n && !o ? "none" : n ? "excludeAll" : "exposeAll";
1801
+ }, r.prototype.getExposedMetadatas = function(e) {
1802
+ return this.getMetadata(this._exposeMetadatas, e);
1803
+ }, r.prototype.getExcludedMetadatas = function(e) {
1804
+ return this.getMetadata(this._excludeMetadatas, e);
1805
+ }, r.prototype.getExposedProperties = function(e, t) {
1806
+ return this.getExposedMetadatas(e).filter(function(n) {
1807
+ return !n.options || n.options.toClassOnly === !0 && n.options.toPlainOnly === !0 ? !0 : n.options.toClassOnly === !0 ? t === w.CLASS_TO_CLASS || t === w.PLAIN_TO_CLASS : n.options.toPlainOnly === !0 ? t === w.CLASS_TO_PLAIN : !0;
1808
+ }).map(function(n) {
1809
+ return n.propertyName;
1810
+ });
1811
+ }, r.prototype.getExcludedProperties = function(e, t) {
1812
+ return this.getExcludedMetadatas(e).filter(function(n) {
1813
+ return !n.options || n.options.toClassOnly === !0 && n.options.toPlainOnly === !0 ? !0 : n.options.toClassOnly === !0 ? t === w.CLASS_TO_CLASS || t === w.PLAIN_TO_CLASS : n.options.toPlainOnly === !0 ? t === w.CLASS_TO_PLAIN : !0;
1814
+ }).map(function(n) {
1815
+ return n.propertyName;
1816
+ });
1817
+ }, r.prototype.clear = function() {
1818
+ this._typeMetadatas.clear(), this._exposeMetadatas.clear(), this._excludeMetadatas.clear(), this._ancestorsMap.clear();
1819
+ }, r.prototype.getMetadata = function(e, t) {
1820
+ var n = e.get(t), s;
1821
+ n && (s = Array.from(n.values()).filter(function(p) {
1822
+ return p.propertyName !== void 0;
1823
+ }));
1824
+ for (var o = [], i = 0, c = this.getAncestors(t); i < c.length; i++) {
1825
+ var a = c[i], l = e.get(a);
1826
+ if (l) {
1827
+ var u = Array.from(l.values()).filter(function(p) {
1828
+ return p.propertyName !== void 0;
1829
+ });
1830
+ o.push.apply(o, u);
1831
+ }
1832
+ }
1833
+ return o.concat(s || []);
1834
+ }, r.prototype.findMetadata = function(e, t, n) {
1835
+ var s = e.get(t);
1836
+ if (s) {
1837
+ var o = s.get(n);
1838
+ if (o)
1839
+ return o;
1840
+ }
1841
+ for (var i = 0, c = this.getAncestors(t); i < c.length; i++) {
1842
+ var a = c[i], l = e.get(a);
1843
+ if (l) {
1844
+ var u = l.get(n);
1845
+ if (u)
1846
+ return u;
1847
+ }
1848
+ }
1849
+ }, r.prototype.findMetadatas = function(e, t, n) {
1850
+ var s = e.get(t), o;
1851
+ s && (o = s.get(n));
1852
+ for (var i = [], c = 0, a = this.getAncestors(t); c < a.length; c++) {
1853
+ var l = a[c], u = e.get(l);
1854
+ u && u.has(n) && i.push.apply(i, u.get(n));
1855
+ }
1856
+ return i.slice().reverse().concat((o || []).slice().reverse());
1857
+ }, r.prototype.getAncestors = function(e) {
1858
+ if (!e)
1859
+ return [];
1860
+ if (!this._ancestorsMap.has(e)) {
1861
+ for (var t = [], n = Object.getPrototypeOf(e.prototype.constructor); typeof n.prototype < "u"; n = Object.getPrototypeOf(n.prototype.constructor))
1862
+ t.push(n);
1863
+ this._ancestorsMap.set(e, t);
1864
+ }
1865
+ return this._ancestorsMap.get(e);
1866
+ }, r;
1867
+ }()
1868
+ ), H = new Ut();
1869
+ function Ht() {
1870
+ if (typeof globalThis < "u")
1871
+ return globalThis;
1872
+ if (typeof global < "u")
1873
+ return global;
1874
+ if (typeof window < "u")
1875
+ return window;
1876
+ if (typeof self < "u")
1877
+ return self;
1878
+ }
1879
+ function jt(r) {
1880
+ return r !== null && typeof r == "object" && typeof r.then == "function";
1881
+ }
1882
+ var Je = function(r, e, t) {
1883
+ if (t || arguments.length === 2) for (var n = 0, s = e.length, o; n < s; n++)
1884
+ (o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
1885
+ return r.concat(o || Array.prototype.slice.call(e));
1886
+ };
1887
+ function zt(r) {
1888
+ var e = new r();
1889
+ return !(e instanceof Set) && !("push" in e) ? [] : e;
1890
+ }
1891
+ var oe = (
1892
+ /** @class */
1893
+ function() {
1894
+ function r(e, t) {
1895
+ this.transformationType = e, this.options = t, this.recursionStack = /* @__PURE__ */ new Set();
1896
+ }
1897
+ return r.prototype.transform = function(e, t, n, s, o, i) {
1898
+ var c = this;
1899
+ if (i === void 0 && (i = 0), Array.isArray(t) || t instanceof Set) {
1900
+ var a = s && this.transformationType === w.PLAIN_TO_CLASS ? zt(s) : [];
1901
+ return t.forEach(function(g, b) {
1902
+ var y = e ? e[b] : void 0;
1903
+ if (!c.options.enableCircularCheck || !c.isCircular(g)) {
1904
+ var T = void 0;
1905
+ if (typeof n != "function" && n && n.options && n.options.discriminator && n.options.discriminator.property && n.options.discriminator.subTypes) {
1906
+ if (c.transformationType === w.PLAIN_TO_CLASS) {
1907
+ T = n.options.discriminator.subTypes.find(function(J) {
1908
+ return J.name === g[n.options.discriminator.property];
1909
+ });
1910
+ var z = { newObject: a, object: g, property: void 0 }, C = n.typeFunction(z);
1911
+ T === void 0 ? T = C : T = T.value, n.options.keepDiscriminatorProperty || delete g[n.options.discriminator.property];
1912
+ }
1913
+ c.transformationType === w.CLASS_TO_CLASS && (T = g.constructor), c.transformationType === w.CLASS_TO_PLAIN && (g[n.options.discriminator.property] = n.options.discriminator.subTypes.find(function(J) {
1914
+ return J.value === g.constructor;
1915
+ }).name);
1916
+ } else
1917
+ T = n;
1918
+ var N = c.transform(y, g, T, void 0, g instanceof Map, i + 1);
1919
+ a instanceof Set ? a.add(N) : a.push(N);
1920
+ } else c.transformationType === w.CLASS_TO_CLASS && (a instanceof Set ? a.add(g) : a.push(g));
1921
+ }), a;
1922
+ } else {
1923
+ if (n === String && !o)
1924
+ return t == null ? t : String(t);
1925
+ if (n === Number && !o)
1926
+ return t == null ? t : Number(t);
1927
+ if (n === Boolean && !o)
1928
+ return t == null ? t : !!t;
1929
+ if ((n === Date || t instanceof Date) && !o)
1930
+ return t instanceof Date ? new Date(t.valueOf()) : t == null ? t : new Date(t);
1931
+ if (Ht().Buffer && (n === Buffer || t instanceof Buffer) && !o)
1932
+ return t == null ? t : Buffer.from(t);
1933
+ if (jt(t) && !o)
1934
+ return new Promise(function(g, b) {
1935
+ t.then(function(y) {
1936
+ return g(c.transform(void 0, y, n, void 0, void 0, i + 1));
1937
+ }, b);
1938
+ });
1939
+ if (!o && t !== null && typeof t == "object" && typeof t.then == "function")
1940
+ return t;
1941
+ if (typeof t == "object" && t !== null) {
1942
+ !n && t.constructor !== Object && (!Array.isArray(t) && t.constructor === Array || (n = t.constructor)), !n && e && (n = e.constructor), this.options.enableCircularCheck && this.recursionStack.add(t);
1943
+ var l = this.getKeys(n, t, o), u = e || {};
1944
+ !e && (this.transformationType === w.PLAIN_TO_CLASS || this.transformationType === w.CLASS_TO_CLASS) && (o ? u = /* @__PURE__ */ new Map() : n ? u = new n() : u = {});
1945
+ for (var p = function(g) {
1946
+ if (g === "__proto__" || g === "constructor")
1947
+ return "continue";
1948
+ var b = g, y = g, T = g;
1949
+ if (!f.options.ignoreDecorators && n) {
1950
+ if (f.transformationType === w.PLAIN_TO_CLASS) {
1951
+ var z = H.findExposeMetadataByCustomName(n, g);
1952
+ z && (T = z.propertyName, y = z.propertyName);
1953
+ } else if (f.transformationType === w.CLASS_TO_PLAIN || f.transformationType === w.CLASS_TO_CLASS) {
1954
+ var z = H.findExposeMetadata(n, g);
1955
+ z && z.options && z.options.name && (y = z.options.name);
1956
+ }
1957
+ }
1958
+ var C = void 0;
1959
+ f.transformationType === w.PLAIN_TO_CLASS ? C = t[b] : t instanceof Map ? C = t.get(b) : t[b] instanceof Function ? C = t[b]() : C = t[b];
1960
+ var N = void 0, J = C instanceof Map;
1961
+ if (n && o)
1962
+ N = n;
1963
+ else if (n) {
1964
+ var $ = H.findTypeMetadata(n, T);
1965
+ if ($) {
1966
+ var ye = { newObject: u, object: t, property: T }, se = $.typeFunction ? $.typeFunction(ye) : $.reflectedType;
1967
+ $.options && $.options.discriminator && $.options.discriminator.property && $.options.discriminator.subTypes ? t[b] instanceof Array ? N = $ : (f.transformationType === w.PLAIN_TO_CLASS && (N = $.options.discriminator.subTypes.find(function(U) {
1968
+ if (C && C instanceof Object && $.options.discriminator.property in C)
1969
+ return U.name === C[$.options.discriminator.property];
1970
+ }), N === void 0 ? N = se : N = N.value, $.options.keepDiscriminatorProperty || C && C instanceof Object && $.options.discriminator.property in C && delete C[$.options.discriminator.property]), f.transformationType === w.CLASS_TO_CLASS && (N = C.constructor), f.transformationType === w.CLASS_TO_PLAIN && C && (C[$.options.discriminator.property] = $.options.discriminator.subTypes.find(function(U) {
1971
+ return U.value === C.constructor;
1972
+ }).name)) : N = se, J = J || $.reflectedType === Map;
1973
+ } else if (f.options.targetMaps)
1974
+ f.options.targetMaps.filter(function(U) {
1975
+ return U.target === n && !!U.properties[T];
1976
+ }).forEach(function(U) {
1977
+ return N = U.properties[T];
1978
+ });
1979
+ else if (f.options.enableImplicitConversion && f.transformationType === w.PLAIN_TO_CLASS) {
1980
+ var le = Reflect.getMetadata("design:type", n.prototype, T);
1981
+ le && (N = le);
1982
+ }
1983
+ }
1984
+ var ue = Array.isArray(t[b]) ? f.getReflectedType(n, T) : void 0, de = e ? e[b] : void 0;
1985
+ if (u.constructor.prototype) {
1986
+ var S = Object.getOwnPropertyDescriptor(u.constructor.prototype, y);
1987
+ if ((f.transformationType === w.PLAIN_TO_CLASS || f.transformationType === w.CLASS_TO_CLASS) && // eslint-disable-next-line @typescript-eslint/unbound-method
1988
+ (S && !S.set || u[y] instanceof Function))
1989
+ return "continue";
1990
+ }
1991
+ if (!f.options.enableCircularCheck || !f.isCircular(C)) {
1992
+ var F = f.transformationType === w.PLAIN_TO_CLASS ? y : g, I = void 0;
1993
+ f.transformationType === w.CLASS_TO_PLAIN ? (I = t[F], I = f.applyCustomTransformations(I, n, F, t, f.transformationType), I = t[F] === I ? C : I, I = f.transform(de, I, N, ue, J, i + 1)) : C === void 0 && f.options.exposeDefaultValues ? I = u[y] : (I = f.transform(de, C, N, ue, J, i + 1), I = f.applyCustomTransformations(I, n, F, t, f.transformationType)), (I !== void 0 || f.options.exposeUnsetFields) && (u instanceof Map ? u.set(y, I) : u[y] = I);
1994
+ } else if (f.transformationType === w.CLASS_TO_CLASS) {
1995
+ var I = C;
1996
+ I = f.applyCustomTransformations(I, n, g, t, f.transformationType), (I !== void 0 || f.options.exposeUnsetFields) && (u instanceof Map ? u.set(y, I) : u[y] = I);
1997
+ }
1998
+ }, f = this, P = 0, W = l; P < W.length; P++) {
1999
+ var M = W[P];
2000
+ p(M);
2001
+ }
2002
+ return this.options.enableCircularCheck && this.recursionStack.delete(t), u;
2003
+ } else
2004
+ return t;
2005
+ }
2006
+ }, r.prototype.applyCustomTransformations = function(e, t, n, s, o) {
2007
+ var i = this, c = H.findTransformMetadatas(t, n, this.transformationType);
2008
+ return this.options.version !== void 0 && (c = c.filter(function(a) {
2009
+ return a.options ? i.checkVersion(a.options.since, a.options.until) : !0;
2010
+ })), this.options.groups && this.options.groups.length ? c = c.filter(function(a) {
2011
+ return a.options ? i.checkGroups(a.options.groups) : !0;
2012
+ }) : c = c.filter(function(a) {
2013
+ return !a.options || !a.options.groups || !a.options.groups.length;
2014
+ }), c.forEach(function(a) {
2015
+ e = a.transformFn({ value: e, key: n, obj: s, type: o, options: i.options });
2016
+ }), e;
2017
+ }, r.prototype.isCircular = function(e) {
2018
+ return this.recursionStack.has(e);
2019
+ }, r.prototype.getReflectedType = function(e, t) {
2020
+ if (e) {
2021
+ var n = H.findTypeMetadata(e, t);
2022
+ return n ? n.reflectedType : void 0;
2023
+ }
2024
+ }, r.prototype.getKeys = function(e, t, n) {
2025
+ var s = this, o = H.getStrategy(e);
2026
+ o === "none" && (o = this.options.strategy || "exposeAll");
2027
+ var i = [];
2028
+ if ((o === "exposeAll" || n) && (t instanceof Map ? i = Array.from(t.keys()) : i = Object.keys(t)), n)
2029
+ return i;
2030
+ if (this.options.ignoreDecorators && this.options.excludeExtraneousValues && e) {
2031
+ var c = H.getExposedProperties(e, this.transformationType), a = H.getExcludedProperties(e, this.transformationType);
2032
+ i = Je(Je([], c, !0), a, !0);
2033
+ }
2034
+ if (!this.options.ignoreDecorators && e) {
2035
+ var c = H.getExposedProperties(e, this.transformationType);
2036
+ this.transformationType === w.PLAIN_TO_CLASS && (c = c.map(function(p) {
2037
+ var f = H.findExposeMetadata(e, p);
2038
+ return f && f.options && f.options.name ? f.options.name : p;
2039
+ })), this.options.excludeExtraneousValues ? i = c : i = i.concat(c);
2040
+ var l = H.getExcludedProperties(e, this.transformationType);
2041
+ l.length > 0 && (i = i.filter(function(p) {
2042
+ return !l.includes(p);
2043
+ })), this.options.version !== void 0 && (i = i.filter(function(p) {
2044
+ var f = H.findExposeMetadata(e, p);
2045
+ return !f || !f.options ? !0 : s.checkVersion(f.options.since, f.options.until);
2046
+ })), this.options.groups && this.options.groups.length ? i = i.filter(function(p) {
2047
+ var f = H.findExposeMetadata(e, p);
2048
+ return !f || !f.options ? !0 : s.checkGroups(f.options.groups);
2049
+ }) : i = i.filter(function(p) {
2050
+ var f = H.findExposeMetadata(e, p);
2051
+ return !f || !f.options || !f.options.groups || !f.options.groups.length;
2052
+ });
2053
+ }
2054
+ return this.options.excludePrefixes && this.options.excludePrefixes.length && (i = i.filter(function(u) {
2055
+ return s.options.excludePrefixes.every(function(p) {
2056
+ return u.substr(0, p.length) !== p;
2057
+ });
2058
+ })), i = i.filter(function(u, p, f) {
2059
+ return f.indexOf(u) === p;
2060
+ }), i;
2061
+ }, r.prototype.checkVersion = function(e, t) {
2062
+ var n = !0;
2063
+ return n && e && (n = this.options.version >= e), n && t && (n = this.options.version < t), n;
2064
+ }, r.prototype.checkGroups = function(e) {
2065
+ return e ? this.options.groups.some(function(t) {
2066
+ return e.includes(t);
2067
+ }) : !0;
2068
+ }, r;
2069
+ }()
2070
+ ), re = {
2071
+ enableCircularCheck: !1,
2072
+ enableImplicitConversion: !1,
2073
+ excludeExtraneousValues: !1,
2074
+ excludePrefixes: void 0,
2075
+ exposeDefaultValues: !1,
2076
+ exposeUnsetFields: !0,
2077
+ groups: void 0,
2078
+ ignoreDecorators: !1,
2079
+ strategy: void 0,
2080
+ targetMaps: void 0,
2081
+ version: void 0
2082
+ }, j = function() {
2083
+ return j = Object.assign || function(r) {
2084
+ for (var e, t = 1, n = arguments.length; t < n; t++) {
2085
+ e = arguments[t];
2086
+ for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && (r[s] = e[s]);
2087
+ }
2088
+ return r;
2089
+ }, j.apply(this, arguments);
2090
+ }, qt = (
2091
+ /** @class */
2092
+ function() {
2093
+ function r() {
2094
+ }
2095
+ return r.prototype.instanceToPlain = function(e, t) {
2096
+ var n = new oe(w.CLASS_TO_PLAIN, j(j({}, re), t));
2097
+ return n.transform(void 0, e, void 0, void 0, void 0, void 0);
2098
+ }, r.prototype.classToPlainFromExist = function(e, t, n) {
2099
+ var s = new oe(w.CLASS_TO_PLAIN, j(j({}, re), n));
2100
+ return s.transform(t, e, void 0, void 0, void 0, void 0);
2101
+ }, r.prototype.plainToInstance = function(e, t, n) {
2102
+ var s = new oe(w.PLAIN_TO_CLASS, j(j({}, re), n));
2103
+ return s.transform(void 0, t, e, void 0, void 0, void 0);
2104
+ }, r.prototype.plainToClassFromExist = function(e, t, n) {
2105
+ var s = new oe(w.PLAIN_TO_CLASS, j(j({}, re), n));
2106
+ return s.transform(e, t, void 0, void 0, void 0, void 0);
2107
+ }, r.prototype.instanceToInstance = function(e, t) {
2108
+ var n = new oe(w.CLASS_TO_CLASS, j(j({}, re), t));
2109
+ return n.transform(void 0, e, void 0, void 0, void 0, void 0);
2110
+ }, r.prototype.classToClassFromExist = function(e, t, n) {
2111
+ var s = new oe(w.CLASS_TO_CLASS, j(j({}, re), n));
2112
+ return s.transform(t, e, void 0, void 0, void 0, void 0);
2113
+ }, r.prototype.serialize = function(e, t) {
2114
+ return JSON.stringify(this.instanceToPlain(e, t));
2115
+ }, r.prototype.deserialize = function(e, t, n) {
2116
+ var s = JSON.parse(t);
2117
+ return this.plainToInstance(e, s, n);
2118
+ }, r.prototype.deserializeArray = function(e, t, n) {
2119
+ var s = JSON.parse(t);
2120
+ return this.plainToInstance(e, s, n);
2121
+ }, r;
2122
+ }()
2123
+ ), Jt = new qt();
2124
+ function ae(r, e, t) {
2125
+ return Jt.deserializeArray(r, e, t);
2126
+ }
2127
+ const Te = "1.0.90", Kt = [
2128
+ {
2129
+ oid: "1",
2130
+ name: "",
2131
+ mail: "",
2132
+ authority: "",
2133
+ tid: "",
2134
+ companyName: "",
2135
+ companyDomain: "",
2136
+ session: "Sign In",
2137
+ sel: !0
2138
+ }
2139
+ ], Xt = [
2140
+ {
2141
+ tid: "1",
2142
+ name: "",
2143
+ domain: "",
2144
+ tenantType: "",
2145
+ authority: "",
2146
+ sel: !0,
2147
+ graphSP: ""
2148
+ }
2149
+ ], Zt = [], Qt = [
2150
+ {
2151
+ id: "1",
2152
+ name: "",
2153
+ associatedUsers: [
2154
+ "1"
2155
+ ],
2156
+ associatedTenants: [
2157
+ "1"
2158
+ ],
2159
+ associatedConfigs: [],
2160
+ sel: !0
2161
+ }
2162
+ ], Yt = [
2163
+ {
2164
+ Run: "3",
2165
+ Start: "2023-09-17T12:00:00.000-07:00",
2166
+ POST: "2023-09-17T12:00:09.500-07:00",
2167
+ Read: "2023-09-17T12:00:15.500-07:00",
2168
+ Write: "2023-09-17T12:01:30.000-07:00"
2169
+ },
2170
+ {
2171
+ Run: "2",
2172
+ Start: "2023-09-17T12:00:00.000-07:00",
2173
+ POST: "2023-09-17T12:00:09.500-07:00",
2174
+ Read: "2023-09-17T12:00:15.500-07:00",
2175
+ Write: "2023-09-17T12:01:30.000-07:00"
2176
+ },
2177
+ {
2178
+ Run: "1",
2179
+ Start: "2023-09-17T12:00:00.000-07:00",
2180
+ POST: "2023-09-17T12:00:09.500-07:00",
2181
+ Read: "2023-09-17T12:00:15.500-07:00",
2182
+ Write: "2023-09-17T12:01:30.000-07:00"
2183
+ }
2184
+ ], Vt = [
2185
+ {
2186
+ type: "mg",
2187
+ resource: "Tenant Root Group",
2188
+ cost: 0,
2189
+ expanded: !0,
2190
+ resources: [
2191
+ {
2192
+ type: "sub",
2193
+ resource: "Applications",
2194
+ cost: 16677.52,
2195
+ expanded: !0,
2196
+ resources: [
2197
+ {
2198
+ type: "rg",
2199
+ resource: "ssfdev",
2200
+ cost: 7500.08,
2201
+ expanded: !0,
2202
+ resources: [
2203
+ {
2204
+ type: "resources",
2205
+ resource: "SSFServices",
2206
+ cost: 0,
2207
+ expanded: !1,
2208
+ resources: []
2209
+ }
2210
+ ]
2211
+ }
2212
+ ]
2213
+ },
2214
+ {
2215
+ type: "sub",
2216
+ resource: "Infrastructure",
2217
+ cost: 8737.58,
2218
+ expanded: !0,
2219
+ resources: [
2220
+ {
2221
+ type: "rg",
2222
+ resource: "SFFA_Prod_Mgmt_Shared_Resources_RG",
2223
+ cost: 7500.08,
2224
+ expanded: !0,
2225
+ resources: [
2226
+ {
2227
+ type: "resources",
2228
+ resource: "SSFA-Prod-UTIL-01",
2229
+ cost: 0,
2230
+ expanded: !1,
2231
+ resources: []
2232
+ }
2233
+ ]
2234
+ }
2235
+ ]
2236
+ }
2237
+ ]
2238
+ }
2239
+ ], en = [
2240
+ {
2241
+ type: "user",
2242
+ actor: "arvind@mindline.site",
2243
+ resource: "kv-syncproject",
2244
+ role: "Key Vault Certificate Officer",
2245
+ updatedby: "arvind@mindline.site",
2246
+ updatedon: "2023-09-06T15:36:45.7760714Z",
2247
+ resources: []
2248
+ },
2249
+ {
2250
+ type: "app",
2251
+ actor: "mindline1-sync-512169f5-38d1-4b57-be8b-967f2d0ae4c6",
2252
+ resource: "dev-subscription",
2253
+ role: "Contributor",
2254
+ updatedby: "arvind@mindline.site",
2255
+ updatedon: "2023-09-06T15:36:45.7760714Z",
2256
+ resources: []
2257
+ }
2258
+ ], ie = "workspaceIDs";
2259
+ function Fn(r, e) {
2260
+ return r + e;
2261
+ }
2262
+ function Un() {
2263
+ return "hello NPM";
2264
+ }
2265
+ class A {
2266
+ constructor() {
2267
+ d(this, "result");
2268
+ d(this, "status");
2269
+ d(this, "error");
2270
+ d(this, "version");
2271
+ d(this, "array");
2272
+ this.result = !0, this.status = 200, this.error = "", this.version = Te, this.array = null;
2273
+ }
2274
+ }
2275
+ class ge {
2276
+ }
2277
+ // azure graph REST API endpoints
2278
+ d(ge, "azureElevateAccess", "https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"), d(ge, "azureListRootAssignments", "https://management.azure.com/providers/Microsoft.Authorization/roleAssignments?api-version=2022-04-01&$filter=principalId+eq+");
2279
+ const L = class L {
2280
+ // config API endpoints
2281
+ static adminEndpoint() {
2282
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admin`;
2283
+ }
2284
+ static adminIncompleteEndpoint() {
2285
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/incomplete-admin`;
2286
+ }
2287
+ static adminsEndpoint() {
2288
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`;
2289
+ }
2290
+ static configConsentEndpoint() {
2291
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`;
2292
+ }
2293
+ static configEnabledEndpoint() {
2294
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`;
2295
+ }
2296
+ static configEndpoint() {
2297
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`;
2298
+ }
2299
+ static configsEndpoint() {
2300
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configurations`;
2301
+ }
2302
+ static initEndpoint() {
2303
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/init`;
2304
+ }
2305
+ static readerStartSyncEndpoint() {
2306
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/startSync`;
2307
+ }
2308
+ static tenantEndpoint() {
2309
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenant`;
2310
+ }
2311
+ static tenantsEndpoint() {
2312
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenants`;
2313
+ }
2314
+ static workspaceEndpoint() {
2315
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace`;
2316
+ }
2317
+ static workspacesEndpoint() {
2318
+ return `https://${L.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspaces`;
2319
+ }
2320
+ // SignalR endpoint
2321
+ static signalREndpoint() {
2322
+ return `https://${L.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`;
2323
+ }
2324
+ };
2325
+ d(L, "environmentTag", "dev");
2326
+ let R = L;
2327
+ class m {
2328
+ }
2329
+ // graph API predicates
2330
+ d(m, "graphGroupsPredicate", "v1.0/groups"), d(m, "graphMailPredicate", "v1.0/me/messages"), d(m, "graphMePredicate", "v1.0/me"), d(m, "graphOauth2PermissionGrantsPredicate", "v1.0/oauth2PermissionGrants"), d(m, "graphServicePrincipalsPredicate", "v1.0/servicePrincipals"), d(m, "graphUsersPredicate", "v1.0/users"), d(m, "graphTenantByDomainPredicate", "beta/tenantRelationships/findTenantInformationByDomainName"), d(m, "graphTenantByIdPredicate", "beta/tenantRelationships/findTenantInformationByTenantId"), // authority values are based on the well-known OIDC auth endpoints
2331
+ d(m, "authorityWW", "https://login.microsoftonline.com/"), d(m, "authorityWWRegex", /^(https:\/\/login\.microsoftonline\.com\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/), d(m, "authorityUS", "https://login.microsoftonline.us/"), d(m, "authorityUSRegex", /^(https:\/\/login\.microsoftonline\.us\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/), d(m, "authorityCN", "https://login.partner.microsoftonline.cn/"), d(m, "authorityCNRegex", /^(https:\/\/login\.partner\.microsoftonline\.cn\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/);
2332
+ class Hn {
2333
+ constructor() {
2334
+ d(this, "id", "");
2335
+ d(this, "displayName", "");
2336
+ d(this, "description", "");
2337
+ }
2338
+ }
2339
+ class jn {
2340
+ constructor() {
2341
+ d(this, "group", "");
2342
+ d(this, "value", "");
2343
+ d(this, "consented", !1);
2344
+ d(this, "removable", !1);
2345
+ d(this, "expanded", "");
2346
+ }
2347
+ static compareByValue(e, t) {
2348
+ return e.value.localeCompare(t.value);
2349
+ }
2350
+ static compareByGroup(e, t) {
2351
+ return e.group.localeCompare(t.group);
2352
+ }
2353
+ }
2354
+ class $e {
2355
+ // set when the user is logging in to support spinner visibility
2356
+ constructor() {
2357
+ d(this, "oid");
2358
+ d(this, "name");
2359
+ d(this, "mail");
2360
+ d(this, "authority");
2361
+ d(this, "tid");
2362
+ d(this, "companyName");
2363
+ d(this, "companyDomain");
2364
+ d(this, "workspaceIDs");
2365
+ d(this, "session");
2366
+ // button text
2367
+ d(this, "spacode");
2368
+ // to get front end access token
2369
+ d(this, "graphAccessToken");
2370
+ // front end graph access token
2371
+ d(this, "mindlineAccessToken");
2372
+ // front end mindline access token
2373
+ d(this, "azureAccessToken");
2374
+ // front end azure access token
2375
+ d(this, "loginHint");
2376
+ // to help sign out without prompt
2377
+ d(this, "scopes");
2378
+ // to detect if incremental consent has happened
2379
+ d(this, "authTS");
2380
+ // timestamp user was authenticated
2381
+ d(this, "sel");
2382
+ // selection state
2383
+ d(this, "loggingIn");
2384
+ this.oid = "", this.name = "", this.mail = "", this.authority = "", this.tid = "", this.companyName = "", this.companyDomain = "", this.workspaceIDs = "", this.session = "Sign In", this.spacode = "", this.graphAccessToken = "", this.mindlineAccessToken = "", this.azureAccessToken = "", this.loginHint = "", this.scopes = new Array(), this.authTS = /* @__PURE__ */ new Date(0), this.sel = !1, this.loggingIn = !1;
2385
+ }
2386
+ }
2387
+ var tn = /* @__PURE__ */ ((r) => (r[r.invalid = 0] = "invalid", r[r.aad = 1] = "aad", r[r.ad = 2] = "ad", r[r.googleworkspace = 3] = "googleworkspace", r))(tn || {}), nn = /* @__PURE__ */ ((r) => (r[r.read = 1] = "read", r[r.write = 2] = "write", r[r.notassigned = 3] = "notassigned", r))(nn || {});
2388
+ class me {
2389
+ // are we validating by TID or by domain? "Domain" | "Tenant ID"
2390
+ constructor() {
2391
+ d(this, "tid");
2392
+ d(this, "name");
2393
+ d(this, "domain");
2394
+ d(this, "tenantType");
2395
+ d(this, "authority");
2396
+ d(this, "workspaceIDs");
2397
+ d(this, "sel");
2398
+ // selection state
2399
+ d(this, "graphSP");
2400
+ // graph resource ID (service principal) for this tenant
2401
+ d(this, "lookupfield");
2402
+ this.tid = "", this.name = "", this.domain = "", this.tenantType = "aad", this.authority = "", this.workspaceIDs = "", this.sel = !1, this.graphSP = "", this.lookupfield = "Domain";
2403
+ }
2404
+ }
2405
+ function sn(r, e) {
2406
+ switch (r) {
2407
+ case m.authorityWW:
2408
+ return e === 1 ? "85d35da2-4118-4b03-aa05-605cedd7f2f8" : "63100afe-506e-4bb2-8ff7-d8d5ab373129";
2409
+ case m.authorityUS:
2410
+ return e === 1 ? "b08630c7-e227-4215-9746-afc9286fb864" : "17aa5d5a-f09f-4cec-87a6-28596f9fa513";
2411
+ case m.authorityCN:
2412
+ return e === 1 ? "7db7293b-add9-4a3f-8562-1a20bfe27d5e" : "debd015b-1154-4111-a4cb-fc220a537697";
2413
+ default:
2414
+ debugger;
2415
+ return "";
2416
+ }
2417
+ }
2418
+ function ne(r) {
2419
+ switch (r) {
2420
+ case m.authorityWW:
2421
+ return "https://graph.microsoft.com/";
2422
+ case m.authorityUS:
2423
+ return "https://graph.microsoft.us/";
2424
+ case m.authorityCN:
2425
+ return "https://microsoftgraph.chinacloudapi.cn/";
2426
+ default:
2427
+ debugger;
2428
+ return "";
2429
+ }
2430
+ }
2431
+ function on(r) {
2432
+ switch (r) {
2433
+ case m.authorityWW:
2434
+ return "https://login.microsoftonline.com/";
2435
+ case m.authorityUS:
2436
+ return "https://login.microsoftonline.us/";
2437
+ case m.authorityCN:
2438
+ return "https://login.partner.microsoftonline.cn/";
2439
+ default:
2440
+ debugger;
2441
+ return "";
2442
+ }
2443
+ }
2444
+ var rn = /* @__PURE__ */ ((r) => (r[r.source = 1] = "source", r[r.target = 2] = "target", r[r.sourcetarget = 3] = "sourcetarget", r))(rn || {});
2445
+ class an {
2446
+ constructor() {
2447
+ d(this, "tid");
2448
+ d(this, "sourceGroupId");
2449
+ d(this, "sourceGroupName");
2450
+ d(this, "targetGroupId");
2451
+ d(this, "targetGroupName");
2452
+ d(this, "configurationTenantType");
2453
+ d(this, "deltaToken");
2454
+ d(this, "usersWritten");
2455
+ d(this, "configId");
2456
+ d(this, "batchId");
2457
+ d(this, "isReadPermissionConsented");
2458
+ d(this, "isWritePermissionConsented");
2459
+ this.tid = "", this.sourceGroupId = "", this.sourceGroupName = "", this.targetGroupId = "", this.targetGroupName = "", this.configurationTenantType = "source", this.deltaToken = "", this.usersWritten = 0, this.configId = "", this.batchId = "", this.isReadPermissionConsented = !1, this.isWritePermissionConsented = !1;
2460
+ }
2461
+ }
2462
+ class De {
2463
+ // selection state
2464
+ constructor() {
2465
+ d(this, "id");
2466
+ d(this, "workspaceId");
2467
+ d(this, "name");
2468
+ d(this, "description");
2469
+ d(this, "tenants");
2470
+ d(this, "isEnabled");
2471
+ d(this, "workspaceIDs");
2472
+ d(this, "sel");
2473
+ this.id = "", this.name = "", this.workspaceId = "", this.description = "", this.tenants = new Array(), this.isEnabled = !1, this.workspaceIDs = "", this.sel = !1;
2474
+ }
2475
+ }
2476
+ class Re {
2477
+ // selection state
2478
+ constructor() {
2479
+ d(this, "id");
2480
+ d(this, "name");
2481
+ d(this, "ownerid");
2482
+ d(this, "associatedUsers");
2483
+ d(this, "associatedTenants");
2484
+ d(this, "associatedConfigs");
2485
+ d(this, "sel");
2486
+ this.id = "", this.name = "", this.ownerid = "", this.associatedUsers = new Array(), this.associatedTenants = new Array(), this.associatedConfigs = new Array(), this.sel = !1;
2487
+ }
2488
+ }
2489
+ function Q() {
2490
+ let r;
2491
+ try {
2492
+ r = window.localStorage;
2493
+ const e = "__storage_test__";
2494
+ return r.setItem(e, e), r.removeItem(e), !0;
2495
+ } catch (e) {
2496
+ return e instanceof DOMException && // everything except Firefox
2497
+ (e.code === 22 || // Firefox
2498
+ e.code === 1014 || // test name field too, because code might not be present
2499
+ // everything except Firefox
2500
+ e.name === "QuotaExceededError" || // Firefox
2501
+ e.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
2502
+ r && r.length !== 0;
2503
+ }
2504
+ }
2505
+ var Ce, Qe;
2506
+ class zn {
2507
+ constructor(e = !1) {
2508
+ we(this, Ce);
2509
+ d(this, "version", "");
2510
+ d(this, "tab", 0);
2511
+ d(this, "us", []);
2512
+ d(this, "ts", []);
2513
+ d(this, "cs", []);
2514
+ d(this, "ws", []);
2515
+ d(this, "configlevelconsent_configid", "");
2516
+ d(this, "configlevelconsent_access", 3);
2517
+ this.init(e);
2518
+ }
2519
+ // get initial data from localStorage or file
2520
+ init(e) {
2521
+ if (console.log(`Calling InitInfo::init(bClearLocalStorage: ${e ? "true" : "false"})`), Q()) {
2522
+ let i = localStorage.getItem("InitInfo");
2523
+ if (i != null && typeof i == "string" && i !== "") {
2524
+ let a = JSON.parse(i);
2525
+ if (a.us.length !== 0)
2526
+ if (e)
2527
+ localStorage.removeItem("InitInfo");
2528
+ else {
2529
+ Z(this, Ce, Qe).call(this, a);
2530
+ return;
2531
+ }
2532
+ }
2533
+ }
2534
+ this.tab = 0, this.version = Te, this.configlevelconsent_configid = "", this.configlevelconsent_access = 3;
2535
+ var t = JSON.stringify(Kt), n = JSON.stringify(Xt), s = JSON.stringify(Zt), o = JSON.stringify(Qt);
2536
+ try {
2537
+ this.us = ae($e, t), this.ts = ae(me, n), this.cs = ae(De, s), this.ws = ae(Re, o), this.tagWithWorkspaces();
2538
+ } catch {
2539
+ debugger;
2540
+ }
2541
+ }
2542
+ save() {
2543
+ let e = JSON.stringify(this);
2544
+ localStorage.setItem("InitInfo", e);
2545
+ }
2546
+ tagWithWorkspaces() {
2547
+ this.us.map((e) => e.workspaceIDs = ""), this.ts.map((e) => e.workspaceIDs = ""), this.cs.map((e) => e.workspaceIDs = "");
2548
+ for (let e of this.ws) {
2549
+ for (let t of e.associatedUsers) {
2550
+ let n = this.us.find((s) => s.oid === t);
2551
+ if (n !== void 0)
2552
+ n[ie] += e.id, n[ie] += " ";
2553
+ else
2554
+ debugger;
2555
+ }
2556
+ for (let t of e.associatedTenants) {
2557
+ let n = this.ts.find((s) => s.tid === t);
2558
+ if (n !== void 0)
2559
+ n[ie] += e.id, n[ie] += " ";
2560
+ else
2561
+ debugger;
2562
+ }
2563
+ for (let t of e.associatedConfigs) {
2564
+ let n = this.cs.find((s) => s.id === t);
2565
+ if (n !== void 0)
2566
+ n[ie] += e.id, n[ie] += " ";
2567
+ else
2568
+ debugger;
2569
+ }
2570
+ }
2571
+ return !0;
2572
+ }
2573
+ }
2574
+ Ce = new WeakSet(), Qe = function(e) {
2575
+ this.tab = e.tab, this.version = Te, this.configlevelconsent_configid = e.configlevelconsent_configid, this.configlevelconsent_access = e.configlevelconsent_access, typeof e.us > "u" ? this.us = new Array() : this.us = e.us.map((t) => {
2576
+ let n = new $e();
2577
+ return n.oid = t.oid, n.name = t.name, n.mail = t.mail, n.authority = t.authority, n.tid = t.tid, n.companyName = t.companyName, n.companyDomain = t.companyDomain, n.workspaceIDs = t.workspaceIDs, n.session = t.session, n.spacode = t.spacode, n.graphAccessToken = t.graphAccessToken, n.mindlineAccessToken = t.mindlineAccessToken, n.azureAccessToken = t.azureAccessToken, n.loginHint = t.loginHint, n.scopes = t.scopes, n.authTS = new Date(t.authTS), n.sel = t.sel, n.loggingIn = t.loggingIn, n;
2578
+ }), typeof e.ts > "u" ? this.ts = new Array() : this.ts = e.ts.map((t) => {
2579
+ let n = new me();
2580
+ return n.tid = t.tid, n.name = t.name, n.domain = t.domain, n.tenantType = t.tenantType, n.authority = t.authority, n.workspaceIDs = t.workspaceIDs, n.sel = t.sel, n.lookupfield = t.lookupfield, n;
2581
+ }), typeof e.cs > "u" ? this.cs = new Array() : this.cs = e.cs.map((t) => {
2582
+ let n = new De();
2583
+ return n.id = t.id, n.workspaceId = t.workspaceId, n.name = t.name, n.description = t.description, n.tenants = t.tenants, n.isEnabled = t.isEnabled, n.workspaceIDs = t.workspaceIDs, n.sel = t.sel, n;
2584
+ }), typeof e.ws > "u" ? this.ws = new Array() : this.ws = e.ws.map((t) => {
2585
+ let n = new Re();
2586
+ return n.id = t.id, n.name = t.name, n.ownerid = t.ownerid, n.associatedUsers = t.associatedUsers, n.associatedTenants = t.associatedTenants, n.associatedConfigs = t.associatedConfigs, n.sel = t.sel, n;
2587
+ });
2588
+ };
2589
+ const cn = [
2590
+ {
2591
+ id: 1,
2592
+ task: "initialization",
2593
+ start: "1970-01-01T00:00:00",
2594
+ end: "1970-01-01T00:00:00",
2595
+ expected: "0:22",
2596
+ status: "not started",
2597
+ expanded: !0,
2598
+ subtasks: [
2599
+ {
2600
+ id: 2,
2601
+ task: "authenticate user",
2602
+ start: "1970-01-01T00:00:00",
2603
+ end: "1970-01-01T00:00:00",
2604
+ expected: "0:01",
2605
+ status: "not started"
2606
+ },
2607
+ {
2608
+ id: 3,
2609
+ task: "reload React",
2610
+ start: "1970-01-01T00:00:00",
2611
+ end: "1970-01-01T00:00:00",
2612
+ expected: "0:07",
2613
+ status: "not started"
2614
+ },
2615
+ {
2616
+ id: 4,
2617
+ task: "GET tenant details",
2618
+ start: "1970-01-01T00:00:00",
2619
+ end: "1970-01-01T00:00:00",
2620
+ expected: "0:01",
2621
+ status: "not started"
2622
+ },
2623
+ {
2624
+ id: 5,
2625
+ task: "POST config init",
2626
+ start: "1970-01-01T00:00:00",
2627
+ end: "1970-01-01T00:00:00",
2628
+ expected: "0:10",
2629
+ status: "not started"
2630
+ },
2631
+ {
2632
+ id: 6,
2633
+ task: "GET workspaces",
2634
+ start: "1970-01-01T00:00:00",
2635
+ end: "1970-01-01T00:00:00",
2636
+ expected: "0:04",
2637
+ status: "not started"
2638
+ }
2639
+ ]
2640
+ }
2641
+ ];
2642
+ var X, xe, Ne, Oe;
2643
+ class qn {
2644
+ constructor(e) {
2645
+ we(this, X);
2646
+ d(this, "tasks");
2647
+ this.tasks = [new Pe()], this.init(e);
2648
+ }
2649
+ // get initial data from localStorage or file
2650
+ init(e) {
2651
+ if (console.log(`Calling TaskArray::init(bClearLocalStorage: ${e ? "true" : "false"})`), this.tasks.length = 0, e && Q() && localStorage.removeItem("Tasks"), Q()) {
2652
+ let t = localStorage.getItem("Tasks");
2653
+ if (t != null && typeof t == "string" && t !== "") {
2654
+ let s = JSON.parse(t);
2655
+ if (this.tasks = Z(this, X, Ne).call(this, s.tasks), this.tasks.length !== 0) return;
2656
+ }
2657
+ }
2658
+ this.tasks = Z(this, X, Ne).call(this, cn);
2659
+ }
2660
+ // set start time for a task
2661
+ setTaskStart(e, t) {
2662
+ let n = Z(this, X, xe).call(this, e);
2663
+ if (n != null && n != null)
2664
+ n.setStart(t), n.status = "in progress", Z(this, X, Oe).call(this);
2665
+ else
2666
+ debugger;
2667
+ }
2668
+ // set end time for a task
2669
+ setTaskEnd(e, t, n) {
2670
+ let s = Z(this, X, xe).call(this, e);
2671
+ if (s != null && s != null)
2672
+ s.setEnd(t), s.status = n, Z(this, X, Oe).call(this);
2673
+ else
2674
+ debugger;
2675
+ }
2676
+ }
2677
+ X = new WeakSet(), //
2678
+ // private
2679
+ //
2680
+ xe = function(e) {
2681
+ let t = this.tasks.find((n) => n.task == e);
2682
+ if (t == null || t == null) {
2683
+ for (t of this.tasks)
2684
+ if (t.subtasks != null && t.subtasks != null && (t = t.subtasks.find((n) => n.task == e), t != null && t != null))
2685
+ break;
2686
+ }
2687
+ return t;
2688
+ }, Ne = function(e) {
2689
+ return e.map((t) => {
2690
+ let n = new Pe();
2691
+ return n.id = t.id, n.task = t.task, n.setStart(new Date(t.start)), n.setEnd(new Date(t.end)), n.expected = t.expected, n.status = t.status, n.expanded = t.expanded, typeof t.subtasks < "u" && t.subtasks != null && (n.subtasks = t.subtasks.map((s) => {
2692
+ let o = new Pe();
2693
+ return o.id = s.id, o.task = s.task, o.setStart(new Date(s.start)), o.setEnd(new Date(s.end)), o.expected = s.expected, o.status = s.status, o.expanded = s.expanded, o;
2694
+ })), n;
2695
+ });
2696
+ }, Oe = function() {
2697
+ let e = JSON.stringify(this);
2698
+ Q() && localStorage.setItem("Tasks", e);
2699
+ };
2700
+ class Pe {
2701
+ constructor() {
2702
+ d(this, "id", 0);
2703
+ d(this, "task", "");
2704
+ d(this, "start", /* @__PURE__ */ new Date());
2705
+ d(this, "startDisplay", "");
2706
+ d(this, "end", /* @__PURE__ */ new Date());
2707
+ d(this, "endDisplay", "");
2708
+ d(this, "elapsedDisplay", "");
2709
+ d(this, "expected", 0);
2710
+ d(this, "status", "");
2711
+ d(this, "expanded", !1);
2712
+ d(this, "subtasks", []);
2713
+ }
2714
+ setEnd(e) {
2715
+ this.end = e, this.endDisplay = `${this.end.getMinutes().toString().padStart(2, "0")}:${this.end.getSeconds().toString().padStart(2, "0")}`;
2716
+ let t = 0, n = this.end.getSeconds() - this.start.getSeconds();
2717
+ n < 0 && (n += 60, t = -1);
2718
+ let s = this.end.getMinutes() - this.start.getMinutes() + t;
2719
+ s < 0 && (s += 60), this.elapsedDisplay = `${s.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}`;
2720
+ }
2721
+ setStart(e) {
2722
+ this.start = e, this.startDisplay = `${this.start.getMinutes().toString().padStart(2, "0")}:${this.start.getSeconds().toString().padStart(2, "0")}`;
2723
+ }
2724
+ }
2725
+ class he {
2726
+ constructor(e) {
2727
+ d(this, "Run", 0);
2728
+ d(this, "Start", /* @__PURE__ */ new Date());
2729
+ d(this, "startDisplay", "");
2730
+ d(this, "POST");
2731
+ d(this, "postDisplay");
2732
+ d(this, "Read");
2733
+ d(this, "readDisplay");
2734
+ d(this, "Write");
2735
+ d(this, "writeDisplay");
2736
+ d(this, "Duration");
2737
+ d(this, "durationDisplay");
2738
+ this.Run = e, this.start(""), this.POST = /* @__PURE__ */ new Date(), this.postDisplay = "", this.Read = /* @__PURE__ */ new Date(), this.readDisplay = "", this.Write = /* @__PURE__ */ new Date(), this.writeDisplay = "", this.Duration = /* @__PURE__ */ new Date(), this.durationDisplay = "";
2739
+ }
2740
+ start(e) {
2741
+ e == "" ? this.Start = /* @__PURE__ */ new Date() : this.Start = new Date(e), this.startDisplay = `${this.Start.getMinutes().toString().padStart(2, "0")}:${this.Start.getSeconds().toString().padStart(2, "0")}`;
2742
+ }
2743
+ post(e) {
2744
+ e == "" ? this.POST = /* @__PURE__ */ new Date() : this.POST = new Date(e), this.postDisplay = `${this.POST.getMinutes().toString().padStart(2, "0")}:${this.POST.getSeconds().toString().padStart(2, "0")}`;
2745
+ }
2746
+ read(e) {
2747
+ e == "" ? this.Read = /* @__PURE__ */ new Date() : this.Read = new Date(e), this.readDisplay = `${this.Read.getMinutes().toString().padStart(2, "0")}:${this.Read.getSeconds().toString().padStart(2, "0")}`;
2748
+ }
2749
+ write(e) {
2750
+ e == "" ? this.Write = /* @__PURE__ */ new Date() : this.Write = new Date(e), this.writeDisplay = `${this.Write.getMinutes().toString().padStart(2, "0")}:${this.Write.getSeconds().toString().padStart(2, "0")}`, this.Duration = new Date(this.Write.getTime() - this.Start.getTime()), this.durationDisplay = `${this.Duration.getMinutes().toString().padStart(2, "0")}:${this.Duration.getSeconds().toString().padStart(2, "0")}`;
2751
+ }
2752
+ }
2753
+ var _e, Me;
2754
+ class ln {
2755
+ constructor(e) {
2756
+ we(this, _e);
2757
+ d(this, "milestones", []);
2758
+ this.init(e);
2759
+ }
2760
+ init(e) {
2761
+ if (Q()) {
2762
+ let t = localStorage.getItem("syncmilestones");
2763
+ if (t != null && typeof t == "string" && t !== "") {
2764
+ let s = JSON.parse(t);
2765
+ if (s.length !== 0)
2766
+ if (e)
2767
+ localStorage.removeItem("syncmilestones");
2768
+ else {
2769
+ Z(this, _e, Me).call(this, s);
2770
+ return;
2771
+ }
2772
+ }
2773
+ }
2774
+ Z(this, _e, Me).call(this, Yt);
2775
+ }
2776
+ save() {
2777
+ let e = JSON.stringify(this.milestones);
2778
+ Q() && localStorage.setItem("syncmilestones", e);
2779
+ }
2780
+ // milestone tracking during a sync
2781
+ start(e) {
2782
+ if (this.milestones == null || this.milestones.length < 1) {
2783
+ debugger;
2784
+ return;
2785
+ }
2786
+ let t = Number(this.milestones[0].Run), n = new he(t + 1);
2787
+ this.milestones.unshift(n), this.milestones = this.milestones.map((s) => {
2788
+ let o = new he(s.Run);
2789
+ return o.Start = s.Start, o.startDisplay = s.startDisplay, o.POST = s.POST, o.postDisplay = s.postDisplay, o.Read = s.Read, o.readDisplay = s.readDisplay, o.Write = s.Write, o.writeDisplay = s.writeDisplay, o.Duration = s.Duration, o.durationDisplay = s.durationDisplay, o;
2790
+ }), e(this.milestones), console.log(`Start milestone: ${this.milestones[0].Run}:${this.milestones[0].Start}`);
2791
+ }
2792
+ unstart(e) {
2793
+ if (this.milestones == null || this.milestones.length < 1) {
2794
+ debugger;
2795
+ return;
2796
+ }
2797
+ let t = this.milestones.shift();
2798
+ this.milestones = this.milestones.map((n) => {
2799
+ let s = new he(n.Run);
2800
+ return s.Start = n.Start, s.startDisplay = n.startDisplay, s.POST = n.POST, s.postDisplay = n.postDisplay, s.Read = n.Read, s.readDisplay = n.readDisplay, s.Write = n.Write, s.writeDisplay = n.writeDisplay, s.Duration = n.Duration, s.durationDisplay = n.durationDisplay, s;
2801
+ }), e(this.milestones), console.log(`Unstart removed first milestone: ${t.Run}:${t.Start}`);
2802
+ }
2803
+ post(e) {
2804
+ if (this.milestones == null || this.milestones.length < 1) {
2805
+ debugger;
2806
+ return;
2807
+ }
2808
+ this.milestones[0].post(""), e(this.milestones), console.log(`POST milestone: ${this.milestones[0].Run}:${this.milestones[0].POST}`);
2809
+ }
2810
+ read(e) {
2811
+ if (this.milestones == null || this.milestones.length < 1) {
2812
+ debugger;
2813
+ return;
2814
+ }
2815
+ this.milestones[0].read(""), e(this.milestones), console.log(`Read milestone: ${this.milestones[0].Run}:${this.milestones[0].Read}`);
2816
+ }
2817
+ write(e) {
2818
+ if (this.milestones == null || this.milestones.length < 1) {
2819
+ debugger;
2820
+ return;
2821
+ }
2822
+ for (this.milestones[0].write(""); this.milestones.length > 10; ) {
2823
+ let t = this.milestones.pop();
2824
+ console.log(`Removed milestone #${t.Run}: ${t.Start}`);
2825
+ }
2826
+ this.save(), this.milestones = this.milestones.map((t) => {
2827
+ let n = new he(t.Run);
2828
+ return n.Start = t.Start, n.startDisplay = t.startDisplay, n.POST = t.POST, n.postDisplay = t.postDisplay, n.Read = t.Read, n.readDisplay = t.readDisplay, n.Write = t.Write, n.writeDisplay = t.writeDisplay, n.Duration = t.Duration, n.durationDisplay = t.durationDisplay, n;
2829
+ }), e(this.milestones);
2830
+ }
2831
+ }
2832
+ _e = new WeakSet(), Me = function(e) {
2833
+ e == null ? this.milestones = new Array() : this.milestones = e.map((t) => {
2834
+ let n = new he(Number(t.Run));
2835
+ return n.start(t.Start), n.post(t.POST), n.read(t.Read), n.write(t.Write), n;
2836
+ });
2837
+ };
2838
+ class Jn {
2839
+ constructor(e, t, n) {
2840
+ d(this, "tenantNodes");
2841
+ d(this, "pb_startTS");
2842
+ d(this, "pb_progress");
2843
+ d(this, "pb_increment");
2844
+ d(this, "pb_idle");
2845
+ d(this, "pb_idleMax");
2846
+ d(this, "pb_total");
2847
+ d(this, "pb_timer");
2848
+ d(this, "milestoneArray");
2849
+ this.tenantNodes = new Array(), this.init(e, t, n), this.pb_startTS = 0, this.pb_progress = 0, this.pb_increment = 0, this.pb_timer = null, this.pb_idle = 0, this.pb_idleMax = 0, this.pb_total = 0, this.milestoneArray = new ln(!1);
2850
+ }
2851
+ // populate tenantNodes based on config tenants
2852
+ init(e, t, n) {
2853
+ console.log(
2854
+ `Calling BatchArray::init(config: "${e ? e.name : "null"}", bClearLocalStorage: ${n ? "true" : "false"})`
2855
+ ), n && Q() && (localStorage.removeItem(e.name), this.milestoneArray.init(n)), e != null && e.tenants != null && t != null && (this.tenantNodes.length = 0, e.tenants.map((s) => {
2856
+ if (s.configurationTenantType === "source" || s.configurationTenantType === "sourcetarget") {
2857
+ let o = t.ts.find(
2858
+ (i) => i.tid === s.tid
2859
+ );
2860
+ if (o != null) {
2861
+ let i = new Ke(
2862
+ s.tid,
2863
+ o.name,
2864
+ s.batchId
2865
+ );
2866
+ this.tenantNodes.push(i);
2867
+ } else {
2868
+ console.log(
2869
+ `Error: no tenant found for config source tenant ${e.name}`
2870
+ );
2871
+ debugger;
2872
+ return;
2873
+ }
2874
+ }
2875
+ }), this.tenantNodes.map((s) => {
2876
+ e.tenants.map((o) => {
2877
+ if ((o.configurationTenantType === "target" || o.configurationTenantType === "sourcetarget") && o.tid !== s.tid) {
2878
+ let i = t.ts.find(
2879
+ (c) => c.tid === o.tid
2880
+ );
2881
+ if (i != null) {
2882
+ let c = new Ke(
2883
+ o.tid,
2884
+ i.name,
2885
+ o.batchId
2886
+ );
2887
+ s.targets.push(c), s.expanded = !0;
2888
+ } else {
2889
+ console.log(
2890
+ `Error: no tenant found for config target tenant ${e.name}`
2891
+ );
2892
+ debugger;
2893
+ return;
2894
+ }
2895
+ }
2896
+ });
2897
+ }));
2898
+ }
2899
+ initializeProgressBar(e, t, n, s) {
2900
+ this.pb_startTS = Date.now(), this.pb_progress = 0, this.pb_increment = 0.25, this.pb_idle = 0, this.pb_idleMax = 0, this.pb_total = 0, this.pb_timer = setInterval(() => {
2901
+ this.milestoneArray.milestones[0].Write != null ? (clearInterval(this.pb_timer), this.pb_timer = null, this.pb_progress = 100, e(this.pb_progress), n(`Complete. [max idle: ${this.pb_idleMax}]`)) : (this.pb_total = this.pb_total + 1, this.pb_idle = this.pb_idle + 1, this.pb_idleMax = Math.max(this.pb_idle, this.pb_idleMax), n(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago. [max idle: ${this.pb_idleMax}/60]`), this.pb_idle >= 60 && this.milestoneArray.milestones[0].Write == null && t(`sync continuing, but no update for ${this.pb_idle} seconds`), this.pb_progress < 100 && (this.pb_progress = Math.min(100, this.pb_progress + this.pb_increment), e(this.pb_progress)));
2902
+ }, 1e3), this.milestoneArray.start(s);
2903
+ }
2904
+ uninitializeProgressBar(e, t, n, s) {
2905
+ this.pb_startTS = 0, this.pb_progress = 0, e(this.pb_progress), t("sync failed to execute"), this.pb_increment = 0, clearInterval(this.pb_timer), this.pb_timer = null, this.pb_idle = 0, this.pb_idleMax = 0, n(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`), this.milestoneArray.unstart(s);
2906
+ }
2907
+ initializeSignalR(e, t, n, s, o, i, c, a, l, u, p) {
2908
+ this.milestoneArray.post(l), u("started sync, waiting for updates..."), this.init(e, t, !1);
2909
+ let f = (P) => {
2910
+ console.log(P);
2911
+ let W = JSON.parse(P);
2912
+ this.pb_idle = 0;
2913
+ let M = n.find((S) => S.BatchId == W.TargetID);
2914
+ if (M == null) {
2915
+ console.log(`Batch ${W.TargetID} not found in batchIdArray.`);
2916
+ debugger;
2917
+ return;
2918
+ }
2919
+ let g = this.tenantNodes.find((S) => S.tid === M.SourceId);
2920
+ if (g == null) {
2921
+ console.log(`Tenant ${M.SourceId} not found in BatchArray.`);
2922
+ debugger;
2923
+ return;
2924
+ }
2925
+ g.batchId = M.BatchId;
2926
+ let b = W.Stats, y = Object.keys(b), T = Object.values(b), z = !1, C = !1;
2927
+ for (let S = 0; S < y.length; S++) {
2928
+ let F = y[S].endsWith("TotalCount"), I = y[S].endsWith("CurrentCount"), U = y[S].endsWith("DeferredCount"), ke = y[S].endsWith("RescheduledCount");
2929
+ if (y[S].startsWith("Reader")) {
2930
+ let Y = /Reader\/TID:(.+)\/TotalCount/;
2931
+ if (I && (Y = /Reader\/TID:(.+)\/CurrentCount/), U && (Y = /Reader\/TID:(.+)\/DeferredCount/), ke && (Y = /Reader\/TID:(.+)\/RescheduledCount/), y[S].match(Y) == null) {
2932
+ console.log(`tid not found in ${y[S]}.`);
2933
+ debugger;
2934
+ return;
2935
+ }
2936
+ F ? (z = Number(T[S]) == 0, g.total = Math.max(Number(T[S]), g.total), console.log(`----- ${g.name} TID: ${g.tid} batchId: ${g.batchId}`), console.log(`----- ${g.name} Total To Read: ${g.total}`)) : (C = Number(T[S]) == 0, g.read = Math.max(Number(T[S]), g.read), console.log(`----- ${g.name} Currently Read: ${g.read}`));
2937
+ }
2938
+ if (g.nothingtosync = z && C, y[S].startsWith("Writer")) {
2939
+ let Y = /Writer\/TID:(.+)\/TotalCount/;
2940
+ I && (Y = /Writer\/TID:(.+)\/CurrentCount/), U && (Y = /Writer\/TID:(.+)\/DeferredCount/), ke && (Y = /Writer\/TID:(.+)\/RescheduledCount/);
2941
+ let Ae = y[S].match(Y);
2942
+ if (Ae == null) {
2943
+ console.log(`tid not found in ${y[S]}.`);
2944
+ debugger;
2945
+ return;
2946
+ }
2947
+ let E = g.targets.find((nt) => nt.tid === Ae[1]);
2948
+ if (E == null) {
2949
+ console.log(`Writer ${g.name} not found under Reader ${g.name}.`);
2950
+ debugger;
2951
+ return;
2952
+ }
2953
+ if (E.batchId = M.BatchId, F)
2954
+ E.total = Math.max(Number(T[S]), E.total), console.log(`----- ${E.name} TID: ${E.tid} batchId: ${E.batchId}`), console.log(`----- ${E.name} Total To Write: ${E.total}`);
2955
+ else if (I)
2956
+ E.written = Math.max(Number(T[S]), E.written), console.log(`----- ${E.name} Total Written: ${E.written}`);
2957
+ else if (U || ke)
2958
+ E.deferred = Math.max(Number(T[S]), E.deferred), console.log(`----- ${E.name} Total Deferred: ${E.deferred}`);
2959
+ else {
2960
+ console.log("unknown writer type");
2961
+ debugger;
2962
+ return;
2963
+ }
2964
+ E.update(E.total, E.read, E.written, E.deferred);
2965
+ }
2966
+ }
2967
+ g.update(g.total, g.read, g.written, g.deferred);
2968
+ let N = !0, J = !0, $ = !1, ye = !0, se = 0, le = 0, ue = 0, de = 0;
2969
+ if (this.tenantNodes.map((S) => {
2970
+ S.targets.map((F) => {
2971
+ J && (J = F.status == "complete" || F.status == "failed"), $ || ($ = F.total > 0 || F.status != "not started"), ue += Math.max(F.total, S.total), de += F.written;
2972
+ }), ye && (ye = S.nothingtosync), N && (N = S.status == "complete" || S.status == "failed"), se += S.total, le += S.read;
2973
+ }), o(se), i(le), c(Math.max(ue, se)), a(de), ye)
2974
+ this.milestoneArray.write(l), u("nothing to sync"), console.log('Setting config sync result: "nothing to sync"');
2975
+ else {
2976
+ if (N && this.milestoneArray.milestones[0].Read == null) {
2977
+ this.milestoneArray.read(l), u("reading complete"), console.log('Setting config sync result: "reading complete"'), s(e.workspaceId);
2978
+ let U = (Date.now() - this.pb_startTS) / 1e3 / 8.5;
2979
+ this.pb_increment = U, console.log(`Setting increment: ${this.pb_increment}% per second`);
2980
+ }
2981
+ J ? (this.milestoneArray.write(l), u("sync complete"), console.log('Setting config sync result: "complete"')) : $ ? (u("writing in progress"), console.log('Setting config sync result: "writing in progress"')) : this.milestoneArray.milestones[0].Read == null && (u("reading in progress"), console.log('Setting config sync result: "reading in progress"'));
2982
+ }
2983
+ };
2984
+ n.map((P) => {
2985
+ const W = R.signalREndpoint();
2986
+ let M = new URL(W);
2987
+ M.searchParams.append("statsId", P.BatchId), console.log(`Creating SignalR Hub for TID: ${P.SourceId} ${M.href}`);
2988
+ const g = new Bt().withUrl(M.href).withAutomaticReconnect().configureLogging(h.Information).build();
2989
+ g.on("newMessage", f), g.onreconnecting((b) => {
2990
+ console.assert(g.state === v.Reconnecting), console.log(`Connection lost due to error "${b}". Reconnecting.`);
2991
+ }), g.onreconnected((b) => {
2992
+ console.assert(g.state === v.Connected), console.log(`Connection reestablished. Connected with connectionId "${b}".`);
2993
+ }), g.onclose(async () => {
2994
+ console.log("Connection closing. Attempting restart."), await g.start();
2995
+ }), g.start().catch(console.error);
2996
+ });
2997
+ }
2998
+ // start a sync cycle
2999
+ async startSync(e, t, n) {
3000
+ let s = new A();
3001
+ if (this.tenantNodes == null || this.tenantNodes.length == 0) {
3002
+ debugger;
3003
+ return s.result = !1, s.error = "startSync: invalid parameters", s.status = 500, s;
3004
+ }
3005
+ return s = await Gn(e, t, n), s;
3006
+ }
3007
+ }
3008
+ class Ke {
3009
+ constructor(e, t, n) {
3010
+ d(this, "expanded");
3011
+ d(this, "status", "");
3012
+ d(this, "name");
3013
+ d(this, "tid");
3014
+ d(this, "batchId");
3015
+ d(this, "total", 0);
3016
+ d(this, "read", 0);
3017
+ d(this, "written", 0);
3018
+ d(this, "deferred", 0);
3019
+ d(this, "nothingtosync");
3020
+ d(this, "targets");
3021
+ this.expanded = !1, this.name = t, this.tid = e, this.batchId = n, this.nothingtosync = !1, this.targets = new Array(), this.update(0, 0, 0, 0);
3022
+ }
3023
+ update(e, t, n, s) {
3024
+ this.total = e, this.read = t, this.written = n, this.deferred = s, this.read === 0 && this.written === 0 && (this.status = "not started"), this.read > 0 ? this.read < this.total ? this.status = "in progress" : this.read === this.total && (this.status = "complete") : this.written > 0 && (this.written + this.deferred < this.total ? this.status = "in progress" : this.written === this.total ? this.status = "complete" : this.written + this.deferred >= this.total && (this.status = "failed"));
3025
+ }
3026
+ }
3027
+ class Ye {
3028
+ constructor(e, t) {
3029
+ d(this, "resourceNodes");
3030
+ this.resourceNodes = new Array(), e && this.init(t);
3031
+ }
3032
+ // get resource data from localStorage or file
3033
+ init(e) {
3034
+ if (console.log(`Calling ResourceArray::init(bClearLocalStorage: ${e ? "true" : "false"})`), Q()) {
3035
+ let n = localStorage.getItem("ResourceArray");
3036
+ if (n != null && typeof n == "string" && n !== "")
3037
+ if (e)
3038
+ localStorage.removeItem("ResourceArray");
3039
+ else {
3040
+ let o = JSON.parse(n);
3041
+ this.resourceNodes = o.resourceNodes;
3042
+ return;
3043
+ }
3044
+ }
3045
+ var t = JSON.stringify(Vt);
3046
+ try {
3047
+ this.resourceNodes = ae(un, t);
3048
+ } catch {
3049
+ debugger;
3050
+ }
3051
+ }
3052
+ // read
3053
+ async read(e, t) {
3054
+ let n = new Ye(!1, !1);
3055
+ return n.resourceNodes = await bn(e, t), n;
3056
+ }
3057
+ // save resource data to localstorage
3058
+ save() {
3059
+ if (Q()) {
3060
+ let e = JSON.stringify(this);
3061
+ localStorage.setItem("ResourceArray", e);
3062
+ }
3063
+ }
3064
+ }
3065
+ class un {
3066
+ constructor(e, t, n) {
3067
+ d(this, "type");
3068
+ d(this, "resource");
3069
+ d(this, "cost");
3070
+ d(this, "expanded");
3071
+ d(this, "resources");
3072
+ this.type = e, this.resource = t, this.cost = n, this.expanded = !1, this.resources = new Array();
3073
+ }
3074
+ }
3075
+ class Kn {
3076
+ constructor(e) {
3077
+ d(this, "actorNodes");
3078
+ this.actorNodes = new Array(), this.init(e);
3079
+ }
3080
+ // get initial data from localStorage or file
3081
+ init(e) {
3082
+ if (console.log(`Calling ResourceArray::init(bClearLocalStorage: ${e ? "true" : "false"})`), Q()) {
3083
+ let n = localStorage.getItem("RBACActors");
3084
+ if (n != null && typeof n == "string" && n !== "")
3085
+ if (e)
3086
+ localStorage.removeItem("RBACActors");
3087
+ else {
3088
+ let o = JSON.parse(n);
3089
+ this.actorNodes = o.actorNodes;
3090
+ return;
3091
+ }
3092
+ }
3093
+ var t = JSON.stringify(en);
3094
+ try {
3095
+ this.actorNodes = ae(dn, t);
3096
+ } catch {
3097
+ debugger;
3098
+ }
3099
+ }
3100
+ }
3101
+ class dn {
3102
+ constructor(e, t, n, s, o, i) {
3103
+ d(this, "type");
3104
+ d(this, "actor");
3105
+ d(this, "resource");
3106
+ d(this, "role");
3107
+ d(this, "updatedby");
3108
+ d(this, "updatedon");
3109
+ d(this, "actors");
3110
+ this.type = e, this.actor = t, this.resource = n, this.role = s, this.updatedby = o, this.updatedon = i, this.actors = new Array();
3111
+ }
3112
+ }
3113
+ function hn(r) {
3114
+ return "Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All";
3115
+ }
3116
+ async function ve(r, e) {
3117
+ const t = new Headers();
3118
+ t.append("Content-Type", "application/json"), t.append("accept", "*/*");
3119
+ const n = hn();
3120
+ if (e.graphAccessToken == null || e.graphAccessToken === "")
3121
+ try {
3122
+ let s = await r.acquireTokenByCode({
3123
+ code: e.spacode
3124
+ });
3125
+ e.graphAccessToken = s.accessToken, console.log("Front end token acquired by code: " + e.graphAccessToken.slice(0, 20));
3126
+ } catch (s) {
3127
+ console.log("Front end token failure: " + s);
3128
+ }
3129
+ else
3130
+ try {
3131
+ let s = r.getAllAccounts(), o = e.oid + "." + e.tid, i = null;
3132
+ for (let a = 0; a < s.length; a++)
3133
+ s[a].homeAccountId == o && (i = s[a]);
3134
+ let c = await r.acquireTokenSilent({
3135
+ scopes: [n],
3136
+ account: i
3137
+ });
3138
+ e.graphAccessToken = c.accessToken, console.log("Front end token graph acquired silently: " + e.graphAccessToken.slice(0, 20));
3139
+ } catch (s) {
3140
+ try {
3141
+ console.log("Front end graph token silent acquisition failure: " + s);
3142
+ let o = r.getAllAccounts(), i = e.oid + "." + e.tid, c = null;
3143
+ for (let a = 0; a < o.length; a++)
3144
+ o[a].homeAccountId == i && (c = o[a]);
3145
+ r.acquireTokenRedirect({
3146
+ scopes: [n],
3147
+ account: c
3148
+ });
3149
+ } catch (o) {
3150
+ console.log("Front end graph token redirect acquisition failure: " + o);
3151
+ }
3152
+ }
3153
+ return t.append("Authorization", `Bearer ${e.graphAccessToken}`), t;
3154
+ }
3155
+ async function Xn(r, e, t) {
3156
+ if (e == null || e.spacode == "")
3157
+ return { groups: [], error: "500: invalid user passed to groupsGet" };
3158
+ let s = { method: "GET", headers: await ve(r, e) };
3159
+ try {
3160
+ let o = ne(e.authority) + m.graphGroupsPredicate;
3161
+ o += `/?$filter=startsWith(displayName, '${t}')`;
3162
+ let c = await (await fetch(o, s)).json();
3163
+ return typeof c.error < "u" ? { groups: [], error: `${c.error.code}: ${c.error.message}` } : { groups: c.value, error: "" };
3164
+ } catch (o) {
3165
+ return console.log(o), { groups: [], error: `Exception: ${o}` };
3166
+ }
3167
+ }
3168
+ async function fn(r, e, t, n) {
3169
+ try {
3170
+ let s = ne(e.authority) + m.graphOauth2PermissionGrantsPredicate, o = new URL(s);
3171
+ o.searchParams.append("$filter", `resourceId eq '${t}' and consentType eq 'Principal' and principalId eq '${n}'`);
3172
+ let c = await (await fetch(o.href, r)).json();
3173
+ if (typeof c.error < "u")
3174
+ return { grants: null, id: null, error: `${c.error.code}: ${c.error.message}` };
3175
+ if (c.value.length != 1) {
3176
+ debugger;
3177
+ return { grants: null, id: null, error: "oauth2PermissionGrantsGet: more than one matching delegated consent grant." };
3178
+ }
3179
+ return { grants: c.value[0].scope, id: c.value[0].id, error: "" };
3180
+ } catch (s) {
3181
+ return console.log(s), { grants: null, id: null, error: `Exception: ${s}` };
3182
+ }
3183
+ }
3184
+ async function pn(r, e, t, n) {
3185
+ if (e == null || e.spacode == "")
3186
+ return !1;
3187
+ try {
3188
+ let s = ne(e.authority);
3189
+ s += m.graphOauth2PermissionGrantsPredicate + `/${t}`;
3190
+ let o = `{ "scope": "${n}" }`, c = { method: "PATCH", headers: await ve(r, e), body: o }, a = await fetch(s, c), l = await a.json();
3191
+ if (a.status == 204 && a.statusText == "No Content")
3192
+ return !0;
3193
+ debugger;
3194
+ return console.log(`oauth2PermissionGrantsSet: PATCH failed ${l.error.code}: ${l.error.message}`), !1;
3195
+ } catch (s) {
3196
+ debugger;
3197
+ return console.log(s), !1;
3198
+ }
3199
+ }
3200
+ function Zn(r, e) {
3201
+ let t = on(r.authority);
3202
+ t += r.tid, t += "/adminconsent";
3203
+ let n = new URL(t), s = sn(r.authority, e);
3204
+ n.searchParams.append("client_id", s), n.searchParams.append("redirect_uri", window.location.origin), n.searchParams.append("domain_hint", r.companyDomain), n.searchParams.append("login_hint", r.mail), window.location.assign(n.href);
3205
+ }
3206
+ async function gn(r, e, t) {
3207
+ try {
3208
+ let n = ne(e.authority);
3209
+ n += m.graphServicePrincipalsPredicate, n += `(appId='${t}')`;
3210
+ let s = new URL(n);
3211
+ s.searchParams.append("$select", "id,appId,displayName");
3212
+ let i = await (await fetch(s.href, r)).json();
3213
+ return typeof i.error < "u" ? { spid: "", error: `${i.error.code}: ${i.error.message}` } : { spid: i.id, error: "" };
3214
+ } catch (n) {
3215
+ return console.log(n), { spid: "", error: `Exception: ${n}` };
3216
+ }
3217
+ }
3218
+ async function Qn(r, e) {
3219
+ if (r.authority == "") {
3220
+ let s = new me();
3221
+ if (s.domain = r.tid, await Ve(s, !1))
3222
+ r.authority = s.authority;
3223
+ else {
3224
+ debugger;
3225
+ return !1;
3226
+ }
3227
+ }
3228
+ let t = window.location.href;
3229
+ switch (r.authority) {
3230
+ case m.authorityWW:
3231
+ t += "MicrosoftIdentity/Account/SignIn";
3232
+ break;
3233
+ case m.authorityUS:
3234
+ t += "USGov/SignIn";
3235
+ break;
3236
+ case m.authorityCN:
3237
+ t += "China/SignIn";
3238
+ break;
3239
+ default:
3240
+ return !1;
3241
+ }
3242
+ let n = new URL(t);
3243
+ if (n.searchParams.append("redirectUri", window.location.origin), r.oid !== "1") {
3244
+ n.searchParams.append("loginHint", r.mail);
3245
+ const s = /@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/, o = r.mail.match(s);
3246
+ let i = o ? o[1] : "organizations";
3247
+ n.searchParams.append("domainHint", i);
3248
+ } else
3249
+ n.searchParams.append("domainHint", "organizations");
3250
+ return e.setTaskStart("initialization", /* @__PURE__ */ new Date()), e.setTaskStart("authenticate user", /* @__PURE__ */ new Date()), window.location.assign(n.href), !0;
3251
+ }
3252
+ function Yn(r, e) {
3253
+ debugger;
3254
+ if (r.oid == "1") return;
3255
+ let t = window.location.href;
3256
+ switch (r.authority) {
3257
+ case m.authorityWW:
3258
+ t += "MicrosoftIdentity/Account/Challenge";
3259
+ break;
3260
+ case m.authorityUS:
3261
+ t += "USGov/Challenge";
3262
+ break;
3263
+ case m.authorityCN:
3264
+ t += "China/Challenge";
3265
+ break;
3266
+ default:
3267
+ return;
3268
+ }
3269
+ let n = new URL(t);
3270
+ n.searchParams.append("redirectUri", window.location.origin), n.searchParams.append("scope", e), n.searchParams.append("domainHint", "organizations"), n.searchParams.append("loginHint", r.mail), window.location.assign(n.href);
3271
+ }
3272
+ async function Vn(r) {
3273
+ if (r.oid == "1") return !1;
3274
+ let e = window.location.href;
3275
+ e += "user";
3276
+ let t = new URL(e);
3277
+ t.searchParams.append("oid", r.oid), t.searchParams.append("tid", r.tid), t.searchParams.append("loginHint", r.loginHint), t.searchParams.append("verb", "LOGOUT");
3278
+ let n = { method: "PATCH" }, s = await fetch(t.href, n);
3279
+ if (s.status == 200 && s.statusText == "OK")
3280
+ console.log(`Successfully set admin ${r.mail} logout_hint`);
3281
+ else
3282
+ return console.log(`Failed to set admin ${r.mail} logout_hint`), !1;
3283
+ let o = window.location.href;
3284
+ switch (r.authority) {
3285
+ case m.authorityWW:
3286
+ o += "MicrosoftIdentity/Account/SignOut";
3287
+ break;
3288
+ case m.authorityUS:
3289
+ o += "USGov/SignOut";
3290
+ break;
3291
+ case m.authorityCN:
3292
+ o += "China/SignOut";
3293
+ break;
3294
+ default:
3295
+ return !1;
3296
+ }
3297
+ return t = new URL(o), t.searchParams.append("redirectUri", window.location.origin), window.location.assign(t.href), !0;
3298
+ }
3299
+ async function es(r, e, t, n) {
3300
+ if (n) debugger;
3301
+ if (e.name != null && e.name !== "") return !1;
3302
+ if (r.graphAccessToken != null && r.graphAccessToken === "") {
3303
+ console.log(`tenantRelationshipsGetByDomain called with invalid logged in user: ${r.name}`);
3304
+ try {
3305
+ let a = await t.acquireTokenByCode({ code: r.spacode, scopes: ["user.read", "contacts.read", "CrossTenantInformation.ReadBasic.All"] });
3306
+ r.graphAccessToken = a.accessToken, console.log("tenantRelationshipsGetByDomain: Front end token acquired: " + r.graphAccessToken.slice(0, 20));
3307
+ } catch (a) {
3308
+ return console.log("tenantRelationshipsGetByDomain: Front end token failure: " + a), !1;
3309
+ }
3310
+ }
3311
+ const s = new Headers(), o = `Bearer ${r.graphAccessToken}`;
3312
+ s.append("Authorization", o);
3313
+ let i = { method: "GET", headers: s };
3314
+ try {
3315
+ var c = ne(e.authority) + m.graphTenantByDomainPredicate;
3316
+ c += "(domainName='", c += e.domain, c += "')", console.log("tenantRelationshipsGetByDomain: Attempting GET from /findTenantInformationByDomainName:", c);
3317
+ let a = await fetch(c, i);
3318
+ if (a.status == 200) {
3319
+ let l = await a.json();
3320
+ if (l) {
3321
+ if (l.error != null) {
3322
+ debugger;
3323
+ return console.log("tenantRelationshipsGetByDomain: Failed GET from /findTenantInformationByDomainName: ", l.error.message), !1;
3324
+ } else if (l.displayName != null && l.displayName !== "")
3325
+ return e.tid = l.tenantId, e.name = l.displayName, console.log("tenantRelationshipsGetByDomain: Successful GET from /findTenantInformationByDomainName: ", l.displayName), !0;
3326
+ } else
3327
+ console.log("tenantRelationshipsGetByDomain: Failed to GET from /findTenantInformationByDomainName: ", c);
3328
+ }
3329
+ } catch (a) {
3330
+ return console.log("Failed to GET from /findTenantInformationByDomainName: ", a), !1;
3331
+ }
3332
+ return !1;
3333
+ }
3334
+ async function mn(r, e, t, n, s) {
3335
+ if (console.log("**** tenantRelationshipsGetById"), s) debugger;
3336
+ if (r.graphAccessToken === "")
3337
+ try {
3338
+ let l = await n.acquireTokenByCode({ code: r.spacode, scopes: ["user.read", "contacts.read", "CrossTenantInformation.ReadBasic.All"] });
3339
+ r.graphAccessToken = l.accessToken, console.log("tenantRelationshipsGetById: Front end token acquired: " + r.graphAccessToken.slice(0, 20));
3340
+ } catch (l) {
3341
+ return console.log("tenantRelationshipsGetById: Front end token failure: " + l), !1;
3342
+ }
3343
+ const o = new Headers(), i = `Bearer ${r.graphAccessToken}`;
3344
+ o.append("Authorization", i);
3345
+ let c = { method: "GET", headers: o };
3346
+ try {
3347
+ var a = ne(r.authority) + m.graphTenantByIdPredicate;
3348
+ a += "(tenantId='", a += e.tid, a += "')", console.log("tenantRelationshipsGetById: Attempting GET from /findTenantInformationByTenantId:", a);
3349
+ let u = await (await fetch(a, c)).json();
3350
+ if (u && typeof u.displayName !== void 0 && u.displayName !== "") {
3351
+ if (e !== void 0)
3352
+ e.name = u.displayName, e.domain = u.defaultDomainName;
3353
+ else {
3354
+ console.log("tenantRelationshipsGetById: missing associated tenant for logged in user.");
3355
+ debugger;
3356
+ }
3357
+ return console.log("tenantRelationshipsGetById: Successful GET from /findTenantInformationByTenantId: ", u.displayName), !0;
3358
+ } else
3359
+ console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ", a);
3360
+ } catch (l) {
3361
+ return console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ", l), !1;
3362
+ }
3363
+ return !1;
3364
+ }
3365
+ async function Ve(r, e) {
3366
+ if (e) debugger;
3367
+ let t = [m.authorityWW, m.authorityUS, m.authorityCN], n = [m.authorityWWRegex, m.authorityUSRegex, m.authorityCNRegex], s = null;
3368
+ try {
3369
+ for (let a = 0; a < 3; a++) {
3370
+ var o = t[a];
3371
+ if (r.lookupfield == "Domain" ? o += r.domain : r.lookupfield == "Tenant ID" && (o += r.tid), o += "/.well-known/openid-configuration", console.log("Attempting GET from openid well-known endpoint: ", o), s = await fetch(o), s.status == 200) {
3372
+ let l = await s.json();
3373
+ if (l) {
3374
+ var i = l.authorization_endpoint;
3375
+ for (let u = 0; u < 3; u++) {
3376
+ var c = i.match(n[u]);
3377
+ if (c != null)
3378
+ return r.tid = c[2], r.authority = c[1], console.log(`Successful GET from openid well-known endpoint: tid: ${r.tid} authority: ${r.authority}`), !0;
3379
+ }
3380
+ } else
3381
+ console.log(`Failed JSON parse of openid well-known endpoint response ${o}.`);
3382
+ } else
3383
+ console.log(`Failed GET from ${o}.`);
3384
+ }
3385
+ } catch (a) {
3386
+ console.log("Failed to GET from openid well-known endpoint: ", a);
3387
+ }
3388
+ return (r.tid == "" || r.authority == "") && console.log(`GET from openid well-known endpoint failed to find tenant: ${s ? s.statusText : "unknown"}`), !1;
3389
+ }
3390
+ async function _n(r, e, t) {
3391
+ if (e == null || e.spacode == "" || t == null) {
3392
+ debugger;
3393
+ return { scopes: null, id: null, error: "500: invalid parameter(s) passed to getUserDelegatedScopes" };
3394
+ }
3395
+ let s = { method: "GET", headers: await ve(r, e) };
3396
+ try {
3397
+ if (t.graphSP == "") {
3398
+ let { spid: a, error: l } = await gn(s, e, "00000003-0000-0000-c000-000000000000");
3399
+ if (l != "") {
3400
+ debugger;
3401
+ return { scopes: null, id: null, error: `${l}` };
3402
+ }
3403
+ t.graphSP = a;
3404
+ }
3405
+ let { grants: o, id: i, error: c } = await fn(s, e, t.graphSP, e.oid);
3406
+ if (c != "") {
3407
+ debugger;
3408
+ return { scopes: null, id: null, error: `${c}` };
3409
+ }
3410
+ return { scopes: o, id: i, error: "" };
3411
+ } catch (o) {
3412
+ debugger;
3413
+ return console.log(o), { scopes: null, id: null, error: `Exception: ${o}` };
3414
+ }
3415
+ }
3416
+ async function ts(r, e, t, n) {
3417
+ if (e == null || e.spacode == "" || t == null) {
3418
+ debugger;
3419
+ return !1;
3420
+ }
3421
+ let { scopes: s, id: o, error: i } = await _n(r, e, t);
3422
+ if (i != "") {
3423
+ debugger;
3424
+ return console.log(`userDelegatedScopesRemove: cannot find userDelegatedScopes for ${e.mail}: ${i}`), !1;
3425
+ }
3426
+ s = s.replace(n, "");
3427
+ let c = await pn(r, e, o, s);
3428
+ if (!c) {
3429
+ debugger;
3430
+ return console.log(`userDelegatedScopesRemove: cannot set oauth2PermissionGrants for ${e.mail}: ${i}`), !1;
3431
+ }
3432
+ return e.scopes = s.split(" "), c;
3433
+ }
3434
+ async function ns(r, e) {
3435
+ if (e == null || e.spacode == "")
3436
+ return { users: [], error: "500: invalid user passed to usersGet" };
3437
+ try {
3438
+ let n = { method: "GET", headers: await ve(r, e) }, s = ne(e.authority);
3439
+ s += m.graphUsersPredicate;
3440
+ let i = await (await fetch(s, n)).json();
3441
+ if (typeof i.error < "u")
3442
+ return { users: [], error: `${i.error.code}: ${i.error.message}` };
3443
+ let c = new Array();
3444
+ for (let a of i.value)
3445
+ c.push(a.mail);
3446
+ return { users: c, error: "" };
3447
+ } catch (t) {
3448
+ return console.log(t), { users: [], error: `Exception: ${t}` };
3449
+ }
3450
+ }
3451
+ async function ss(r, e, t, n, s, o, i, c) {
3452
+ let a = new A();
3453
+ if (t.id === "1") {
3454
+ if (a = await $n(r, e, t, o.id, c), a.result) {
3455
+ n && n(t.id);
3456
+ const l = {};
3457
+ Object.defineProperty(l, t.id, { value: !0, writable: !0, enumerable: !0 }), s(l);
3458
+ let u = o.associatedConfigs.findIndex((p) => p == "1");
3459
+ u !== -1 && (o.associatedConfigs.splice(u, 1), o.associatedConfigs.push(t.id));
3460
+ }
3461
+ } else
3462
+ a = await Dn(r, e, t, c);
3463
+ return i.save(), a;
3464
+ }
3465
+ async function os(r, e, t, n, s) {
3466
+ let o = new A();
3467
+ return o = await Pn(r, e, t, n, s), o;
3468
+ }
3469
+ async function rs(r, e, t, n, s) {
3470
+ return En(r, e, t, n);
3471
+ }
3472
+ async function is(r, e, t, n, s) {
3473
+ return kn(r, e, t, n, s);
3474
+ }
3475
+ async function as(r, e, t, n, s) {
3476
+ return An(r, e, t, n, s);
3477
+ }
3478
+ async function cs(r, e, t, n, s) {
3479
+ let o = new A();
3480
+ if (s) debugger;
3481
+ try {
3482
+ let i = n.ws.find((c) => c.id === t);
3483
+ if (i != null) {
3484
+ i.associatedConfigs.length = 0;
3485
+ let c = await tt(r, e, i.id, s);
3486
+ if (!c.result) return c;
3487
+ let a = "";
3488
+ for (let l of i.associatedConfigs) {
3489
+ let u = n.cs.find((p) => p.id === l);
3490
+ u != null && u.sel && (a = u.id);
3491
+ }
3492
+ et(i, n, c.array, a), n.tagWithWorkspaces();
3493
+ }
3494
+ return o;
3495
+ } catch (i) {
3496
+ console.log(i.message), o.error = i.message;
3497
+ }
3498
+ return o.result = !1, o.status = 500, o;
3499
+ }
3500
+ async function ls(r, e, t, n, s) {
3501
+ console.log(">>>>>> initGet");
3502
+ let o = new A();
3503
+ if (s)
3504
+ debugger;
3505
+ let i = new me();
3506
+ return i.tid = e.tid, i.domain = e.tid, await Ve(i, s) ? (e.authority = i.authority, n.setTaskStart("GET tenant details", /* @__PURE__ */ new Date()), o.result = await mn(e, i, t, r, s), n.setTaskEnd("GET tenant details", /* @__PURE__ */ new Date(), "complete"), o.result && (e.companyName = i.name, e.companyDomain = i.domain, n.setTaskStart("POST config init", /* @__PURE__ */ new Date()), o = await Rn(r, e, s), n.setTaskEnd("POST config init", /* @__PURE__ */ new Date(), o.result ? "complete" : "failed")), o.result && (n.setTaskStart("GET workspaces", /* @__PURE__ */ new Date()), o = await Sn(r, e, t, s), n.setTaskEnd("GET workspaces", /* @__PURE__ */ new Date(), o.result ? "complete" : "failed")), console.log("initGet complete. Version: " + Te), o) : (o.error = `Failed to retrieve authority for user "${e.mail}" TID ${e.tid}.`, o.result = !1, o);
3507
+ }
3508
+ async function us(r, e, t, n) {
3509
+ return On(r, e, t, n);
3510
+ }
3511
+ async function ds(r, e, t, n, s) {
3512
+ return xn(r, e, t, n);
3513
+ }
3514
+ async function hs(r, e, t, n) {
3515
+ return vn(r, e, t, n);
3516
+ }
3517
+ async function fs(r, e, t, n) {
3518
+ return Cn(r, e, t, n);
3519
+ }
3520
+ async function ps(r, e, t, n) {
3521
+ return await Mn(r, e, t, n);
3522
+ }
3523
+ function yn(r, e, t, n) {
3524
+ t.map((s) => {
3525
+ let o = null, i = e.us.findIndex((l) => l.oid === s.userId || l.oid === s.email);
3526
+ if (i === -1) {
3527
+ let l = e.us.findIndex((u) => u.oid === "1");
3528
+ if (l !== -1) {
3529
+ o = e.us.at(l);
3530
+ let u = r.associatedUsers.findIndex((p) => p == "1");
3531
+ u !== -1 && (r.associatedUsers.splice(u, 1), r.associatedUsers.push(s.userId));
3532
+ } else
3533
+ o = new $e(), e.us.push(o);
3534
+ } else
3535
+ o = e.us.at(i);
3536
+ o.sel = n === s.userId, o.oid = s.userId ? s.userId : s.email, o.name = s.firstName ?? o.name, o.mail = s.email, o.tid = s.tenantId;
3537
+ let c = e.ts.find((l) => l.tid === o.tid);
3538
+ c != null && (o.authority = c.authority, o.companyName = c.name, o.companyDomain = c.domain), r.associatedUsers.findIndex((l) => l === o.oid) == -1 && r.associatedUsers.push(o.oid);
3539
+ }), e.save();
3540
+ }
3541
+ function wn(r, e, t, n) {
3542
+ t.map((s) => {
3543
+ let o = null, i = e.ts.findIndex((u) => u.tid === s.tenantId);
3544
+ if (i === -1) {
3545
+ let u = e.ts.findIndex((p) => p.tid === "1");
3546
+ if (u !== -1) {
3547
+ o = e.ts.at(u);
3548
+ let p = r.associatedTenants.findIndex((f) => f == "1");
3549
+ p !== -1 && (r.associatedTenants.splice(p, 1), r.associatedTenants.push(s.tenantId));
3550
+ } else
3551
+ o = new me(), e.ts.push(o);
3552
+ } else
3553
+ o = e.ts.at(i);
3554
+ o.sel = n === s.tenantId, o.tid = s.tenantId, o.name = s.name, o.domain = s.domain, o.tenantType = s.type.toLowerCase();
3555
+ const c = /^(https:\/\/login.microsoftonline.(?:us|com)\/)organizations\/v2.0$/, a = s.authority.match(c);
3556
+ o.authority = a ? a[1] : s.authority, r.associatedTenants.findIndex((u) => u === s.tenantId) == -1 && r.associatedTenants.push(s.tenantId);
3557
+ }), e.save();
3558
+ }
3559
+ function et(r, e, t, n) {
3560
+ t.map((s) => {
3561
+ let o = null, i = e.cs.findIndex((a) => a.id === s.id);
3562
+ if (i === -1) {
3563
+ let a = e.cs.findIndex((l) => l.id === "1");
3564
+ if (a !== -1) {
3565
+ o = e.cs.at(a);
3566
+ let l = r.associatedConfigs.findIndex((u) => u == "1");
3567
+ l !== -1 && (r.associatedConfigs.splice(l, 1), r.associatedConfigs.push(s.id));
3568
+ } else
3569
+ o = new De(), e.cs.push(o);
3570
+ } else
3571
+ o = e.cs.at(i);
3572
+ o.sel = n === s.id, o.id = s.id, o.workspaceId = s.workspaceId, o.name = s.name, o.description = s.description, o.isEnabled = s.isEnabled, o.tenants.length = 0, s.tenants.map((a) => {
3573
+ let l = new an();
3574
+ l.tid = a.tenantId, l.sourceGroupId = a.sourceGroupId ?? "", l.sourceGroupName = a.sourceGroupName ?? "", l.targetGroupId = a.targetGroupId ?? "", l.targetGroupName = a.targetGroupName ?? "", l.configurationTenantType = a.configurationTenantType.toLowerCase(), l.deltaToken = a.deltaToken ?? "", l.configId = o.id, l.batchId = a.batchId ?? "", l.isReadPermissionConsented = a.isReadPermissionConsented, l.isWritePermissionConsented = a.isWritePermissionConsented, o.tenants.push(l);
3575
+ }), r.associatedConfigs.findIndex((a) => a === s.id) == -1 && r.associatedConfigs.push(s.id);
3576
+ }), e.save();
3577
+ }
3578
+ async function Sn(r, e, t, n) {
3579
+ let s = new A();
3580
+ if (n) debugger;
3581
+ try {
3582
+ if (s = await Ln(r, e, n), s.result) {
3583
+ for (let o of s.array) {
3584
+ let i = null, c = t.ws.findIndex((b) => b.id === o.id);
3585
+ if (c === -1) {
3586
+ let b = t.ws.findIndex((y) => y.id === "1");
3587
+ b !== -1 ? i = t.ws.at(b) : (i = new Re(), t.ws.push(i));
3588
+ } else
3589
+ i = t.ws.at(c);
3590
+ let a = "";
3591
+ for (let b of i.associatedUsers) {
3592
+ let y = t.us.find((T) => T.oid === b);
3593
+ y != null && y.sel && (a = y.oid);
3594
+ }
3595
+ let l = "";
3596
+ for (let b of i.associatedTenants) {
3597
+ let y = t.ts.find((T) => T.tid === b);
3598
+ y != null && y.sel && (l = y.tid);
3599
+ }
3600
+ let u = "";
3601
+ for (let b of i.associatedConfigs) {
3602
+ let y = t.cs.find((T) => T.id === b);
3603
+ y != null && y.sel && (u = y.id);
3604
+ }
3605
+ i.associatedUsers.length = 0, i.associatedTenants.length = 0, i.associatedConfigs.length = 0, i.id = o.id, i.name = o.name, i.ownerid = o.ownerid;
3606
+ let p = In(r, e, i.id, n), f = Nn(r, e, i.id, n), P = tt(r, e, i.id, n), [W, M, g] = await Promise.all([p, f, P]);
3607
+ if (!W.result) return W;
3608
+ if (!M.result) return M;
3609
+ if (!g.result) return g;
3610
+ wn(i, t, M.array, l), yn(i, t, W.array, a), et(i, t, g.array, u), t.tagWithWorkspaces();
3611
+ }
3612
+ return s;
3613
+ }
3614
+ } catch (o) {
3615
+ console.log(o.message), s.error = o.message;
3616
+ }
3617
+ return s.result = !1, s.status = 500, s;
3618
+ }
3619
+ async function gs(r, e) {
3620
+ let t = "";
3621
+ try {
3622
+ let n = r.getAllAccounts(), s = e.oid + "." + e.tid, o = null;
3623
+ for (let c = 0; c < n.length; c++)
3624
+ n[c].homeAccountId == s && (o = n[c]);
3625
+ t = (await r.acquireTokenSilent({
3626
+ scopes: [
3627
+ "https://analysis.windows.net/powerbi/api/App.Read.All",
3628
+ "https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All",
3629
+ "https://analysis.windows.net/powerbi/api/Report.ReadWrite.All",
3630
+ "https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"
3631
+ ],
3632
+ account: o
3633
+ })).accessToken, console.log("PowerBI token acquired silently: " + t.slice(0, 20));
3634
+ } catch {
3635
+ console.log("PowerBI token failed to be acquired silently");
3636
+ }
3637
+ return t;
3638
+ }
3639
+ async function Be(r, e) {
3640
+ const t = new Headers();
3641
+ if (t.append("Content-Type", "application/json"), t.append("accept", "*/*"), e.azureAccessToken == null || e.azureAccessToken === "")
3642
+ try {
3643
+ let n = r.getAllAccounts(), s = e.oid + "." + e.tid, o = null;
3644
+ for (let c = 0; c < n.length; c++)
3645
+ n[c].homeAccountId == s && (o = n[c]);
3646
+ let i = await r.acquireTokenSilent({
3647
+ scopes: ["https://management.azure.com/user_impersonation"],
3648
+ account: o
3649
+ });
3650
+ e.azureAccessToken = i.accessToken, console.log("Front end token acquired silently: " + e.azureAccessToken.slice(0, 20));
3651
+ } catch (n) {
3652
+ try {
3653
+ console.log("Front end token silent acquisition failure: " + n);
3654
+ let s = r.getAllAccounts(), o = e.oid + "." + e.tid, i = null;
3655
+ for (let c = 0; c < s.length; c++)
3656
+ s[c].homeAccountId == o && (i = s[c]);
3657
+ r.acquireTokenRedirect({
3658
+ scopes: ["https://management.azure.com/user_impersonation"],
3659
+ account: i
3660
+ });
3661
+ } catch (s) {
3662
+ console.log("Front end token popup acquisition failure: " + s);
3663
+ }
3664
+ }
3665
+ return t.append("Authorization", `Bearer ${e.azureAccessToken}`), t;
3666
+ }
3667
+ async function ms(r, e) {
3668
+ if (e == null || e.spacode == "")
3669
+ return !1;
3670
+ try {
3671
+ let n = { method: "GET", headers: await Be(r, e) }, s = ge.azureListRootAssignments;
3672
+ s += "'", s += e.oid, s += "'";
3673
+ let o = await fetch(s, n);
3674
+ if (o.status == 200) {
3675
+ let i = await o.json();
3676
+ i = i;
3677
+ debugger;
3678
+ console.log("Successful call to Azure Resource Graph list root assignments");
3679
+ } else
3680
+ return console.log(await x(o)), !1;
3681
+ } catch (t) {
3682
+ return console.log(t), !1;
3683
+ }
3684
+ return !0;
3685
+ }
3686
+ async function _s(r, e) {
3687
+ if (e == null || e.spacode == "")
3688
+ return !1;
3689
+ try {
3690
+ let n = { method: "POST", headers: await Be(r, e) }, s = ge.azureElevateAccess, o = await fetch(s, n);
3691
+ if (o.status == 200)
3692
+ console.log("Successful call to Azure Resource Graph list root assignments");
3693
+ else
3694
+ return console.log(await x(o)), !1;
3695
+ } catch (t) {
3696
+ return console.log(t), !1;
3697
+ }
3698
+ return !0;
3699
+ }
3700
+ async function bn(r, e) {
3701
+ let t = new Array();
3702
+ if (e == null || e.spacode == "")
3703
+ return t;
3704
+ try {
3705
+ let s = { method: "GET", headers: await Be(r, e) }, o = ge.azureListRootAssignments;
3706
+ o += "'", o += e.oid, o += "'";
3707
+ let i = await fetch(o, s);
3708
+ if (i.status == 200) {
3709
+ let c = await i.json();
3710
+ c = c;
3711
+ debugger;
3712
+ console.log("Successful call to Azure Resource Graph list root assignments");
3713
+ } else
3714
+ return console.log(await x(i)), t;
3715
+ } catch (n) {
3716
+ return console.log(n), t;
3717
+ }
3718
+ return t;
3719
+ }
3720
+ function Tn(r) {
3721
+ let e = "8d95d21c-c378-4bb0-9f52-88c30d271e7a", t = r.authority.toLowerCase();
3722
+ return t.startsWith("https://login.microsoftonline.com/") ? e = "8d95d21c-c378-4bb0-9f52-88c30d271e7a" : t.startsWith("https://login.microsoftonline.us/") ? e = "48da942e-ea3d-49e4-a054-81649012f8f2" : t.startsWith("https://login.partner.microsoftonline.cn/") && (e = "c91d32e4-dcc5-4d77-826a-16e93ffce666"), `api://${e}/Config.Write`;
3723
+ }
3724
+ async function G(r, e) {
3725
+ debugger;
3726
+ console.log("DEBUGGER: mindlineDefineHeaders");
3727
+ const t = new Headers();
3728
+ t.append("Content-Type", "application/json"), t.append("accept", "*/*");
3729
+ const n = Tn(e);
3730
+ try {
3731
+ let s = r.getAllAccounts(), o = e.oid + "." + e.tid, i = null;
3732
+ for (let a = 0; a < s.length; a++)
3733
+ s[a].homeAccountId == o && (i = s[a]);
3734
+ let c = await r.acquireTokenSilent({
3735
+ scopes: [n],
3736
+ account: i
3737
+ });
3738
+ e.mindlineAccessToken = c.accessToken, console.log("Front end mindline token acquired silently: " + e.mindlineAccessToken.slice(0, 20));
3739
+ } catch (s) {
3740
+ try {
3741
+ console.log("Front end mindline token silent acquisition failure, triggering redirect: " + s);
3742
+ let o = r.getAllAccounts(), i = e.oid + "." + e.tid, c = null;
3743
+ for (let a = 0; a < o.length; a++)
3744
+ o[a].homeAccountId == i && (c = o[a]);
3745
+ r.acquireTokenRedirect({
3746
+ scopes: [n],
3747
+ account: c
3748
+ });
3749
+ } catch (o) {
3750
+ console.log("Front end mindline token redirect acquisition failure: " + o);
3751
+ }
3752
+ }
3753
+ return t.append("Authorization", `Bearer ${e.mindlineAccessToken}`), t;
3754
+ }
3755
+ async function x(r) {
3756
+ let e = "";
3757
+ if (r.status === 401 && (e = r.statusText, e != ""))
3758
+ return e;
3759
+ let t = await r.json();
3760
+ if (t.error !== void 0)
3761
+ e = `Error: ${t.error} Message: ${t.message}`;
3762
+ else if (t.errors !== void 0)
3763
+ e = Object.keys(t.errors).reduce(
3764
+ (o, i) => o + i + ": " + t.errors[i] + " ",
3765
+ ""
3766
+ );
3767
+ else if (t.title !== void 0)
3768
+ e = t.title;
3769
+ else
3770
+ debugger;
3771
+ return e;
3772
+ }
3773
+ async function Cn(r, e, t, n) {
3774
+ let s = new A();
3775
+ if (t.oid == "" && t.mail == "" || n == "")
3776
+ return s.result = !1, s.error = "adminDelete: invalid parameters", s.status = 500, s;
3777
+ let o = null;
3778
+ o = new URL(R.adminEndpoint()), o.searchParams.append("workspaceId", n), o.searchParams.append("email", t.mail);
3779
+ let c = { method: "DELETE", headers: await G(r, e) };
3780
+ try {
3781
+ console.log("Attempting DELETE from /admin: " + o.href);
3782
+ let a = await fetch(o.href, c);
3783
+ return a.status === 200 && a.statusText === "OK" ? (console.log(`Successful DELETE from /admin: ${o.href}`), s) : (s.error = await x(a), console.log(`Failed DELETE from /admin: ${o.href}`), console.log(s.error), s.status = 500, s.result = !1, s);
3784
+ } catch (a) {
3785
+ s.error = a.message, s.status = 500, s.result = !1, console.log(a.message);
3786
+ }
3787
+ return s;
3788
+ }
3789
+ async function In(r, e, t, n) {
3790
+ let s = new A();
3791
+ if (t === "")
3792
+ return s.result = !1, s.status = 500, s.error = "adminsGet: no workspace provided", s;
3793
+ let o = R.adminsEndpoint(), i = new URL(o);
3794
+ i.searchParams.append("workspaceId", t);
3795
+ let a = { method: "GET", headers: await G(r, e) };
3796
+ try {
3797
+ if (n) debugger;
3798
+ console.log("Attempting GET from /admins: " + i.href);
3799
+ let l = await fetch(i.href, a);
3800
+ if (l.status === 200 && l.statusText === "OK") {
3801
+ let u = await l.json();
3802
+ return u != null ? (s.array = u, console.log(`Successful GET from /admins: ${s.array.reduce((f, P) => f + P.email + " ", "")}`), s) : (s.error = "Failed GET from /admins: failed to JSON-parse response", console.log(s.error), s.status = 500, s.result = !1, s);
3803
+ } else
3804
+ return console.log(`Failed GET from /admins: ${i.href}`), s.error = await x(l), s.status = 500, s.result = !1, console.log(s.error), s;
3805
+ } catch (l) {
3806
+ s.error = l.message, s.status = 500, s.result = !1, console.log(l.message);
3807
+ }
3808
+ return s;
3809
+ }
3810
+ async function vn(r, e, t, n) {
3811
+ let s = new A();
3812
+ if (t.mail == "" || t.authority == "" || t.tid === "")
3813
+ return s.result = !1, s.error = "adminPost: invalid argument", s.status = 500, s;
3814
+ let o = R.adminEndpoint();
3815
+ const i = await G(r, e);
3816
+ let c = `
3817
+ {"email": "${t.mail}",
3818
+ "tenantId": "${t.tid}",
3819
+ "workspaceId": "${n}"
3820
+ }`, a = { method: "POST", headers: i, body: c };
3821
+ try {
3822
+ console.log("Attempting POST to /admin: " + o);
3823
+ let l = await fetch(o, a);
3824
+ return l.status === 200 && l.statusText === "OK" ? (console.log(`Successful POST to /admin: ${c}`), s) : (s.error = await x(l), console.log(`Failed POST to /admin: ${c}`), console.log(s.error), s.status = 500, s.result = !1, s);
3825
+ } catch (l) {
3826
+ s.error = l.message, s.status = 500, s.result = !1, console.log(l.message);
3827
+ }
3828
+ return s;
3829
+ }
3830
+ async function kn(r, e, t, n, s) {
3831
+ let o = new A(), i = R.configConsentEndpoint(), c = new URL(i);
3832
+ c.searchParams.append("configurationId", t);
3833
+ const a = await G(r, e);
3834
+ let l = `
3835
+ {
3836
+ "tenantId": "${n}",
3837
+ "isReadPermissionConsented": ${s ? "true" : "false"}
3838
+ }`, u = { method: "PUT", headers: a, body: l };
3839
+ try {
3840
+ console.log("Attempting PUT read consent to /configuration/consent: " + c.href);
3841
+ let p = await fetch(c.href, u);
3842
+ return p.status === 200 && p.statusText === "OK" ? (console.log(`Successful PUT to ${c.href}`), o) : (o.error = await x(p), console.log(`Failed PUT to ${c.href}`), console.log(o.error), o.status = 500, o.result = !1, o);
3843
+ } catch (p) {
3844
+ o.error = p.message, o.status = 500, o.result = !1, console.log(p.message);
3845
+ }
3846
+ return o;
3847
+ }
3848
+ async function An(r, e, t, n, s) {
3849
+ let o = new A(), i = R.configConsentEndpoint(), c = new URL(i);
3850
+ c.searchParams.append("configurationId", t);
3851
+ const a = await G(r, e);
3852
+ let l = `
3853
+ {
3854
+ "tenantId": "${n}",
3855
+ "isWritePermissionConsented": ${s ? "true" : "false"}
3856
+ }`, u = { method: "PUT", headers: a, body: l };
3857
+ try {
3858
+ console.log("Attempting PUT read consent to /configuration/consent: " + c.href);
3859
+ let p = await fetch(c.href, u);
3860
+ return p.status === 200 && p.statusText === "OK" ? (console.log(`Successful PUT to ${c.href}`), o) : (o.error = await x(p), console.log(`Failed PUT to ${c.href}`), console.log(o.error), o.status = 500, o.result = !1, o);
3861
+ } catch (p) {
3862
+ o.error = p.message, o.status = 500, o.result = !1, console.log(p.message);
3863
+ }
3864
+ return o;
3865
+ }
3866
+ async function En(r, e, t, n, s) {
3867
+ let o = new A();
3868
+ if (t.id === "" || n == "")
3869
+ return o.result = !1, o.error = "configPost: invalid config ID", o.status = 500, o;
3870
+ let i = null;
3871
+ i = new URL(R.configEndpoint()), i.searchParams.append("configurationId", t.id);
3872
+ let a = { method: "DELETE", headers: await G(r, e) };
3873
+ try {
3874
+ console.log("Attempting DELETE from /config: " + i.href);
3875
+ let l = await fetch(i.href, a);
3876
+ return l.status === 200 && l.statusText === "OK" ? (console.log("Successful DELETE from /config"), o) : (o.error = await x(l), console.log(`Failed DELETE from ${i.href}`), console.log(o.error), o.status = 500, o.result = !1, o);
3877
+ } catch (l) {
3878
+ o.error = l.message, o.status = 500, o.result = !1, console.log(l.message);
3879
+ }
3880
+ return o;
3881
+ }
3882
+ async function Pn(r, e, t, n, s) {
3883
+ let o = new A();
3884
+ if (t === "")
3885
+ return o.result = !1, o.error = "configPatch: invalid config ID", o.status = 500, o;
3886
+ let i = R.configEnabledEndpoint(), c = new URL(i);
3887
+ c.searchParams.append("configurationId", t), c.searchParams.append("isEnabled", n.toString());
3888
+ let l = { method: "PATCH", headers: await G(r, e) };
3889
+ try {
3890
+ if (s) debugger;
3891
+ console.log("Attempting PATCH to /config: " + c.href);
3892
+ let u = await fetch(c.href, l);
3893
+ return u.status === 200 && u.statusText === "OK" ? (console.log(`Successful PATCH to ${c.href}: ${n.toString()}`), o) : (o.error = await x(u), console.log(`Failed PATCH to ${c.href}: ${n.toString()}`), console.log(o.error), o.status = 500, o.result = !1, o);
3894
+ } catch (u) {
3895
+ o.error = u.message, o.status = 500, o.result = !1, console.log(u.message);
3896
+ }
3897
+ return o;
3898
+ }
3899
+ async function $n(r, e, t, n, s) {
3900
+ let o = new A();
3901
+ if (t.id === "")
3902
+ return o.result = !1, o.error = "configPost: invalid config ID", o.status = 500, o;
3903
+ let i = R.configEndpoint();
3904
+ const c = await G(r, e);
3905
+ let a = `
3906
+ {
3907
+ "workspaceId": "${n}",
3908
+ "name": "${t.name}",
3909
+ "description": "${t.description}",
3910
+ "isEnabled": ${t.isEnabled},
3911
+ "tenants": [`;
3912
+ t.tenants.map((u) => {
3913
+ let p = u.sourceGroupId != "" ? `"${u.sourceGroupId}"` : "null", f = u.sourceGroupName != "" ? `"${u.sourceGroupName}"` : "null", P = u.targetGroupId != "" ? `"${u.targetGroupId}"` : "null", W = u.targetGroupName != "" ? `"${u.targetGroupName}"` : "null";
3914
+ a.slice(-1) === "}" && (a += ","), a += `{
3915
+ "tenantId": "${u.tid}",
3916
+ "sourceGroupId": ${p},
3917
+ "sourceGroupName": ${f},
3918
+ "targetGroupId": ${P},
3919
+ "targetGroupName": ${W},
3920
+ "configurationTenantType": "${u.configurationTenantType}"
3921
+ }`;
3922
+ }), a += "]}";
3923
+ let l = { method: "POST", headers: c, body: a };
3924
+ try {
3925
+ if (s) debugger;
3926
+ console.log("Attempting POST to /config: " + i);
3927
+ let u = await fetch(i, l);
3928
+ if (u.status === 200 && u.statusText === "OK") {
3929
+ let p = await u.json();
3930
+ return t.id = p, console.log(
3931
+ `Successful ConfigID: ${p} from POST to /config: ${a}`
3932
+ ), o;
3933
+ } else
3934
+ return o.error = await x(u), console.log(`Failed PUT to /config: ${a}`), console.log(o.error), o.status = 500, o.result = !1, o;
3935
+ } catch (u) {
3936
+ return o.status = 500, o.result = !1, o.error = u.message, console.log(o.error), o;
3937
+ }
3938
+ }
3939
+ async function Dn(r, e, t, n) {
3940
+ let s = new A();
3941
+ if (t.id === "")
3942
+ return s.result = !1, s.error = "configPost: invalid config ID", s.status = 500, s;
3943
+ let o = R.configEndpoint(), i = new URL(o);
3944
+ i.searchParams.append("configurationId", t.id);
3945
+ const c = await G(r, e);
3946
+ let a = `
3947
+ {
3948
+ "name": "${t.name}",
3949
+ "description": "${t.description}",
3950
+ "tenants": [`;
3951
+ t.tenants.map((u) => {
3952
+ a.slice(-1) === "}" && (a += ",");
3953
+ let f = u.sourceGroupId != "" ? `"${u.sourceGroupId}"` : "null", P = u.sourceGroupName != "" ? `"${u.sourceGroupName}"` : "null", W = u.targetGroupId != "" ? `"${u.targetGroupId}"` : "null", M = u.targetGroupName != "" ? `"${u.targetGroupName}"` : "null";
3954
+ a += `{
3955
+ "tenantId": "${u.tid}",
3956
+ "sourceGroupId": ${f},
3957
+ "sourceGroupName": ${P},
3958
+ "targetGroupId": ${W},
3959
+ "targetGroupName": ${M},
3960
+ "configurationTenantType": "${u.configurationTenantType}",
3961
+ "deltaToken": "${u.deltaToken}"
3962
+ }`;
3963
+ }), a += "]}";
3964
+ let l = { method: "PUT", headers: c, body: a };
3965
+ try {
3966
+ if (n) debugger;
3967
+ console.log("Attempting PUT to /config: " + i.href);
3968
+ let u = await fetch(i.href, l);
3969
+ return u.status === 200 && u.statusText === "OK" ? (console.log(`Successful PUT to ${i.href}: ${a}`), s) : (s.error = await x(u), console.log(`Failed PUT to ${i.href}: ${a}`), console.log(s.error), s.status = 500, s.result = !1, s);
3970
+ } catch (u) {
3971
+ s.error = u.message, s.status = 500, s.result = !1, console.log(u.message);
3972
+ }
3973
+ return s;
3974
+ }
3975
+ async function tt(r, e, t, n) {
3976
+ let s = new A();
3977
+ if (t === "")
3978
+ return s.result = !1, s.status = 500, s.error = "configsGet: no workspace provided", s;
3979
+ let o = R.configsEndpoint(), i = new URL(o);
3980
+ i.searchParams.append("workspaceId", t);
3981
+ let a = { method: "GET", headers: await G(r, e) };
3982
+ try {
3983
+ if (n) debugger;
3984
+ console.log("Attempting GET from /configurations: " + i.href);
3985
+ let l = await fetch(i.href, a);
3986
+ if (l.status === 200 && l.statusText === "OK") {
3987
+ let u = await l.json();
3988
+ return u != null ? (s.array = u, console.log(`Successful GET from /configurations: ${s.array.reduce((f, P) => f + P.name + " ", "")}`), s) : (s.error = "Failed GET from /configurations: failed to JSON-parse response", console.log(s.error), s.status = 500, s.result = !1, s);
3989
+ } else
3990
+ return console.log(`Failed GET from /configurations: ${i.href}`), s.error = await x(l), s.status = 500, s.result = !1, console.log(s.error), s;
3991
+ } catch (l) {
3992
+ s.error = l.message, s.status = 500, s.result = !1, console.log(l.message);
3993
+ }
3994
+ return s;
3995
+ }
3996
+ async function Rn(r, e, t) {
3997
+ let n = new A();
3998
+ if (e.companyName === "" || e.companyDomain === "")
3999
+ return n.result = !1, n.error = "initPost: invalid company name or domain", n.status = 500, n;
4000
+ let s = R.initEndpoint();
4001
+ const o = await G(r, e);
4002
+ let i = `
4003
+ {
4004
+ "tenantCreateModel": {
4005
+ "tenantId": "${e.tid}",
4006
+ "name": "${e.companyName}",
4007
+ "domain": "${e.companyDomain}",
4008
+ "type": "aad",
4009
+ "authority": "${e.authority}"
4010
+ }
4011
+ }`, c = { method: "POST", headers: o, body: i };
4012
+ try {
4013
+ if (t) debugger;
4014
+ console.log("Attempting POST to /configuration/init: " + s);
4015
+ let a = await fetch(s, c);
4016
+ return a.status === 200 && a.statusText === "OK" ? (console.log(`Successful POST to /configuration/init: ${i}`), n) : (n.error = await x(a), n.status = 500, n.result = !1, console.log(`Failed POST to /configuration/init: ${i}`), console.log(n.error), n);
4017
+ } catch (a) {
4018
+ n.error = a.message, console.log(n.error);
4019
+ }
4020
+ return n.status = 500, n.result = !1, n;
4021
+ }
4022
+ async function xn(r, e, t, n, s) {
4023
+ let o = new A();
4024
+ if (t.tid === "" || n === "")
4025
+ return o.result = !1, o.error = "tenantDelete: invalid tid, workspaceId", o.status = 500, o;
4026
+ let i = new URL(R.tenantEndpoint());
4027
+ i.searchParams.append("tenantId", t.tid), i.searchParams.append("workspaceId", n);
4028
+ let a = { method: "DELETE", headers: await G(r, e) };
4029
+ try {
4030
+ console.log("Attempting DELETE from /tenant: " + i.href);
4031
+ let l = await fetch(i.href, a);
4032
+ return l.status === 200 && l.statusText === "OK" ? (console.log(`Successful DELETE from /tenant: ${i.href}`), o) : (console.log(`Failed DELETE from /tenant: ${i.href}`), o.error = await x(l), console.log(o.error), o.status = 500, o.result = !1, o);
4033
+ } catch (l) {
4034
+ o.error = l.message, o.status = 500, o.result = !1, console.log(o.error);
4035
+ }
4036
+ return o;
4037
+ }
4038
+ async function Nn(r, e, t, n) {
4039
+ let s = new A();
4040
+ if (t === "")
4041
+ return s.result = !1, s.status = 500, s.error = "tenantsGet: no workspace provided", s;
4042
+ let o = R.tenantsEndpoint(), i = new URL(o);
4043
+ i.searchParams.append("workspaceId", t);
4044
+ let a = { method: "GET", headers: await G(r, e) };
4045
+ try {
4046
+ if (n) debugger;
4047
+ console.log(`Attempting GET from /tenants: ${i.href}`);
4048
+ let l = await fetch(i.href, a);
4049
+ if (l.status === 200 && l.statusText === "OK") {
4050
+ let u = await l.json();
4051
+ return u != null ? (s.array = u, console.log(`Successful GET from /tenants: ${s.array.reduce((f, P) => f + P.domain + " ", "")}`), s) : (s.error = "Failed GET from /tenants: failed to JSON-parse response", console.log(s.error), s.status = 500, s.result = !1, s);
4052
+ } else
4053
+ return console.log(`Failed GET from /tenants: ${i.href}`), s.error = await x(l), s.status = 500, s.result = !1, console.log(s.error), s;
4054
+ } catch (l) {
4055
+ s.error = l.message, s.status = 500, s.result = !1, console.log(l.message);
4056
+ }
4057
+ return s;
4058
+ }
4059
+ async function On(r, e, t, n) {
4060
+ let s = new A();
4061
+ if (t.tid === "" || t.name === "" || t.domain === "")
4062
+ return s.result = !1, s.error = "tenantPost: invalid tid, name, domain", s.status = 500, s;
4063
+ let o = R.tenantEndpoint(), i = new URL(o);
4064
+ i.searchParams.append("workspaceId", n);
4065
+ const c = await G(r, e);
4066
+ let a = `
4067
+ {"tenantId": "${t.tid}",
4068
+ "name": "${t.name}",
4069
+ "domain": "${t.domain}",
4070
+ "type": 1,
4071
+ "authority": "${t.authority}"
4072
+ }`, l = { method: "POST", headers: c, body: a };
4073
+ try {
4074
+ console.log(`Attempting POST to ${i.href}: ${a}`);
4075
+ let u = await fetch(i.href, l);
4076
+ return u.status === 200 && u.statusText === "OK" ? (console.log(`Successful POST to ${i.href}: ${a}`), s) : (console.log(`Failed POST to ${i.href}: ${a}`), s.error = await x(u), console.log(s.error), s.status = 500, s.result = !1, s);
4077
+ } catch (u) {
4078
+ s.error = u.message, s.status = 500, s.result = !1, console.log(s.error);
4079
+ }
4080
+ return s;
4081
+ }
4082
+ async function Mn(r, e, t, n) {
4083
+ let s = new A();
4084
+ if (t == "" || n == "")
4085
+ return s.result = !1, s.error = "workspacePut: invalid workspace ID or name", s.status = 500, s;
4086
+ let o = R.workspaceEndpoint(), i = new URL(o);
4087
+ i.searchParams.append("workspaceId", t), i.searchParams.append("workspaceName", n);
4088
+ let a = { method: "PUT", headers: await G(r, e) };
4089
+ try {
4090
+ console.log("Attempting PUT to /workspace: " + i.href);
4091
+ let l = await fetch(i.href, a);
4092
+ return l.status === 200 && l.statusText === "OK" ? (console.log(`Successful PUT to ${i.href}`), s) : (s.error = await x(l), console.log(`Failed PUT to ${i.href}`), console.log(s.error), s.status = 500, s.result = !1, s);
4093
+ } catch (l) {
4094
+ s.error = l.message, s.status = 500, s.result = !1, console.log(l.message);
4095
+ }
4096
+ return s;
4097
+ }
4098
+ async function Ln(r, e, t) {
4099
+ let n = new A();
4100
+ if (e.mail == null || e.mail == "")
4101
+ return n.result = !1, n.status = 500, n.error = "adminsGet: no workspace provided", n;
4102
+ let s = R.workspacesEndpoint(), o = new URL(s), c = { method: "GET", headers: await G(r, e) };
4103
+ try {
4104
+ if (t) debugger;
4105
+ console.log("Attempting GET from /workspaces endpoint: " + o.href);
4106
+ let a = await fetch(o.href, c);
4107
+ if (a.status === 200 && a.statusText === "OK") {
4108
+ let l = await a.json();
4109
+ return l != null ? (n.array = l, console.log(`Successful GET from /workspaces: ${n.array.reduce((p, f) => p + f.name + " ", "")}`), n) : (n.error = "Failed GET from /workspaces: failed to JSON-parse response", console.log(n.error), n.status = 500, n.result = !1, n);
4110
+ } else
4111
+ return console.log(`Failed GET from /workspaces: ${o.href}`), n.error = await x(a), n.status = 500, n.result = !1, console.log(n.error), n;
4112
+ } catch (a) {
4113
+ n.error = a.message, n.status = 500, n.result = !1, console.log(a.message);
4114
+ }
4115
+ return n;
4116
+ }
4117
+ async function Gn(r, e, t) {
4118
+ let n = new A();
4119
+ if (r == null || e == null)
4120
+ return n.result = !1, n.error = "readerPost: invalid parameters", n.status = 500, n;
4121
+ let s = R.readerStartSyncEndpoint(), o = new URL(s);
4122
+ o.searchParams.append("configurationId", t.id);
4123
+ let c = { method: "POST", headers: await G(r, e) };
4124
+ try {
4125
+ console.log("Attempting POST to /startSync: " + o.href);
4126
+ let a = await fetch(o.href, c);
4127
+ if (a.status === 200 && a.statusText === "OK") {
4128
+ console.log(`Successful POST to /startSync: ${s}`);
4129
+ let l = await a.json();
4130
+ return l.PayloadStr != "" ? n.array = JSON.parse(l.PayloadStr) : (n.result = !1, n.error = "readerPost: blank payload returned, sync may be disabled on back end", n.status = 500), n;
4131
+ } else
4132
+ return n.error = await x(a), console.log(`Failed POST to /startSync: ${s}`), console.log(n.error), n.status = 500, n.result = !1, n;
4133
+ } catch (a) {
4134
+ n.error = a.message, n.status = 500, n.result = !1, console.log(a.message);
4135
+ }
4136
+ return n;
4137
+ }
4138
+ export {
4139
+ A as APIResult,
4140
+ Kn as ActorArray,
4141
+ dn as ActorNode,
4142
+ Jn as BatchArray,
4143
+ De as Config,
4144
+ Hn as Group,
4145
+ zn as InitInfo,
4146
+ he as Milestone,
4147
+ ln as MilestoneArray,
4148
+ Ye as ResourceArray,
4149
+ un as ResourceNode,
4150
+ Pe as Task,
4151
+ qn as TaskArray,
4152
+ me as Tenant,
4153
+ an as TenantConfigInfo,
4154
+ rn as TenantConfigType,
4155
+ Ke as TenantNode,
4156
+ nn as TenantPermissionType,
4157
+ tn as TenantType,
4158
+ $e as User,
4159
+ jn as UserScope,
4160
+ Re as Workspace,
4161
+ Cn as adminDelete,
4162
+ vn as adminPost,
4163
+ In as adminsGet,
4164
+ ge as azureConfig,
4165
+ ms as canListRootAssignments,
4166
+ is as configConsentForRead,
4167
+ as as configConsentForWrite,
4168
+ kn as configConsentReadPut,
4169
+ An as configConsentWritePut,
4170
+ En as configDelete,
4171
+ ss as configEdit,
4172
+ os as configEnable,
4173
+ Pn as configPatch,
4174
+ $n as configPost,
4175
+ Dn as configPut,
4176
+ rs as configRemove,
4177
+ tt as configsGet,
4178
+ cs as configsRefresh,
4179
+ _s as elevateGlobalAdminToUserAccessAdmin,
4180
+ gs as getPowerBIAccessToken,
4181
+ m as graphConfig,
4182
+ Xn as groupsGet,
4183
+ Un as helloNpm,
4184
+ ls as initGet,
4185
+ Rn as initPost,
4186
+ R as mindlineConfig,
4187
+ fn as oauth2PermissionGrantsGet,
4188
+ pn as oauth2PermissionGrantsSet,
4189
+ x as processErrors,
4190
+ Gn as readerPost,
4191
+ Zn as requestAdminConsent,
4192
+ gn as servicePrincipalGet,
4193
+ Qn as signIn,
4194
+ Yn as signInIncrementally,
4195
+ Vn as signOut,
4196
+ Fn as sum,
4197
+ us as tenantAdd,
4198
+ xn as tenantDelete,
4199
+ On as tenantPost,
4200
+ es as tenantRelationshipsGetByDomain,
4201
+ mn as tenantRelationshipsGetById,
4202
+ ds as tenantRemove,
4203
+ Ve as tenantUnauthenticatedLookup,
4204
+ Nn as tenantsGet,
4205
+ hs as userAdd,
4206
+ _n as userDelegatedScopesGet,
4207
+ ts as userDelegatedScopesRemove,
4208
+ fs as userRemove,
4209
+ ns as usersGet,
4210
+ ps as workspaceEdit,
4211
+ Mn as workspacePut,
4212
+ Ln as workspacesGet
4213
+ };
4214
+ //# sourceMappingURL=sync.es.js.map