@formant/data-sdk 1.5.3 → 1.5.4

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.
@@ -3,7 +3,7 @@ var re = (a, e, t) => e in a ? oe(a, e, { enumerable: !0, configurable: !0, writ
3
3
  var s = (a, e, t) => (re(a, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  import * as u from "date-fns";
5
5
  import { startOfMinute as se, addMinutes as ce, roundToNearestMinutes as de, addSeconds as he } from "date-fns";
6
- import { RtcClient as A, SignalingPromiseClient as D } from "@formant/realtime-sdk";
6
+ import { RtcClient as A, SignalingPromiseClient as P } from "@formant/realtime-sdk";
7
7
  import { EventEmitter as le } from "eventemitter3";
8
8
  import { deflate as ue } from "pako";
9
9
  import { fromByteArray as me } from "base64-js";
@@ -103,9 +103,9 @@ class pe {
103
103
  var i;
104
104
  const n = JSON.parse(atob(e.split(".")[1]));
105
105
  try {
106
- let o;
107
- if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (o = n.sub), n["formant:claims"] && n["formant:claims"].userId && (o = n["formant:claims"].userId), o && ((i = this._currentUser) == null ? void 0 : i.id) !== o) {
108
- const c = await fetch(`${this._apiUrl}/v1/admin/users/${o}`, {
106
+ let r;
107
+ if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (r = n.sub), n["formant:claims"] && n["formant:claims"].userId && (r = n["formant:claims"].userId), r && ((i = this._currentUser) == null ? void 0 : i.id) !== r) {
108
+ const c = await fetch(`${this._apiUrl}/v1/admin/users/${r}`, {
109
109
  method: "GET",
110
110
  headers: {
111
111
  "Content-Type": "application/json",
@@ -117,8 +117,8 @@ class pe {
117
117
  this._currentUser = d;
118
118
  }
119
119
  this._token = e, this._waitingForAuth.forEach((c) => c(!0));
120
- } catch (o) {
121
- console.error("loginWithToken() failed", { err: o }), this._waitingForAuth.forEach((c) => c(!1));
120
+ } catch (r) {
121
+ console.error("loginWithToken() failed", { err: r }), this._waitingForAuth.forEach((c) => c(!1));
122
122
  } finally {
123
123
  this._waitingForAuth.clear();
124
124
  }
@@ -223,7 +223,7 @@ class pe {
223
223
  await this.loginWithToken(n.authentication.accessToken, e);
224
224
  }
225
225
  }
226
- function E() {
226
+ function k() {
227
227
  return typeof window < "u" && window.location ? new URLSearchParams(window.location.search).get("module") : null;
228
228
  }
229
229
  function T(a) {
@@ -232,7 +232,7 @@ function T(a) {
232
232
  window.parent.postMessage(a, "*");
233
233
  }
234
234
  function J() {
235
- const a = E();
235
+ const a = k();
236
236
  if (!a)
237
237
  throw new Error("No module context");
238
238
  T({
@@ -249,7 +249,7 @@ function V(a) {
249
249
  window.removeEventListener("message", e);
250
250
  };
251
251
  }
252
- const r = new pe({
252
+ const o = new pe({
253
253
  apiUrl: h,
254
254
  refreshAuthToken: J,
255
255
  addAccessTokenRefreshListener: V
@@ -260,7 +260,7 @@ async function ye(a) {
260
260
  {
261
261
  headers: {
262
262
  "Content-Type": "application/json",
263
- Authorization: "Bearer " + r.token
263
+ Authorization: "Bearer " + o.token
264
264
  }
265
265
  }
266
266
  )).json()).configuration;
@@ -283,7 +283,7 @@ function Te(a) {
283
283
  });
284
284
  }
285
285
  function Ce() {
286
- const a = E();
286
+ const a = k();
287
287
  if (!a)
288
288
  throw new Error("No module context");
289
289
  T({
@@ -292,7 +292,7 @@ function Ce() {
292
292
  });
293
293
  }
294
294
  function Se(a, e) {
295
- const t = E();
295
+ const t = k();
296
296
  if (!t)
297
297
  throw new Error("No module context");
298
298
  T({
@@ -303,7 +303,7 @@ function Se(a, e) {
303
303
  });
304
304
  }
305
305
  function Ee(a, e) {
306
- const t = E();
306
+ const t = k();
307
307
  if (!t)
308
308
  throw new Error("No module context");
309
309
  T({
@@ -314,7 +314,7 @@ function Ee(a, e) {
314
314
  });
315
315
  }
316
316
  function ke(a) {
317
- const e = E();
317
+ const e = k();
318
318
  if (!e)
319
319
  throw new Error("No module context");
320
320
  T({
@@ -323,10 +323,10 @@ function ke(a) {
323
323
  menus: a
324
324
  });
325
325
  }
326
- function Re(a) {
326
+ function Oe(a) {
327
327
  T({ type: "show_message", message: a });
328
328
  }
329
- function Oe(a, e) {
329
+ function Re(a, e) {
330
330
  const t = (n) => {
331
331
  const i = n.data;
332
332
  i.type === "channel_data" && i.channel === a && e({
@@ -343,15 +343,15 @@ function be(a) {
343
343
  };
344
344
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
345
345
  }
346
- function Ae(a) {
346
+ function De(a) {
347
347
  const e = (t) => {
348
348
  const n = t.data;
349
349
  n.type === "module_configuration" && a(n);
350
350
  };
351
351
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
352
352
  }
353
- function De(a) {
354
- const e = E();
353
+ function Ae(a) {
354
+ const e = k();
355
355
  e && T({ type: "request_module_data", module: e });
356
356
  const t = (n) => {
357
357
  const i = n.data;
@@ -371,27 +371,27 @@ function Pe(a) {
371
371
  };
372
372
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
373
373
  }
374
- const Ne = 1, F = 1e3, W = 60 * F, G = 60 * W, I = 24 * G, Ie = 7 * I, Le = 30 * I, je = 365 * I, j = {
374
+ const Ne = 1, F = 1e3, W = 60 * F, G = 60 * W, I = 24 * G, je = 7 * I, Ie = 30 * I, Le = 365 * I, L = {
375
375
  millisecond: Ne,
376
376
  second: F,
377
377
  minute: W,
378
378
  hour: G,
379
379
  day: I,
380
- week: Ie,
381
- month: Le,
382
- year: je
380
+ week: je,
381
+ month: Ie,
382
+ year: Le
383
383
  };
384
384
  function _e(a, e) {
385
385
  return a.filter((t) => e.includes(t.type));
386
386
  }
387
387
  function $e(a, e, t) {
388
388
  const n = e.getTime(), i = t.getTime();
389
- return a.map((o) => ({
390
- ...o,
391
- points: o.points.filter(
389
+ return a.map((r) => ({
390
+ ...r,
391
+ points: r.points.filter(
392
392
  ([c]) => c >= n && c < i
393
393
  )
394
- })).filter(({ points: o }) => o.length > 0);
394
+ })).filter(({ points: r }) => r.length > 0);
395
395
  }
396
396
  class x {
397
397
  constructor({
@@ -402,11 +402,11 @@ class x {
402
402
  s(this, "metadata", /* @__PURE__ */ new Map());
403
403
  s(this, "capacity");
404
404
  s(this, "timeout");
405
- this.capacity = e || 1e4, this.timeout = t || j.minute;
405
+ this.capacity = e || 1e4, this.timeout = t || L.minute;
406
406
  }
407
407
  get(e, t) {
408
- const n = this.keyToCacheKey(e), i = this.entries.get(n), o = this.metadata.get(n);
409
- return (i === void 0 || o && (o == null ? void 0 : o.expiration.getTime()) < Date.now()) && !(o != null && o.generating) && t && this.generate(e, t()), i === void 0 && o && o.lastValue !== void 0 ? o.lastValue : i;
408
+ const n = this.keyToCacheKey(e), i = this.entries.get(n), r = this.metadata.get(n);
409
+ return (i === void 0 || r && (r == null ? void 0 : r.expiration.getTime()) < Date.now()) && !(r != null && r.generating) && t && this.generate(e, t()), i === void 0 && r && r.lastValue !== void 0 ? r.lastValue : i;
410
410
  }
411
411
  set(e, t) {
412
412
  const n = this.keyToCacheKey(e);
@@ -429,7 +429,7 @@ class x {
429
429
  if (this.metadata.size < 1)
430
430
  return;
431
431
  const [e] = [...this.metadata.entries()].reduce(
432
- ([t, n], [i, o]) => o.expiration.getTime() < n.expiration.getTime() ? [i, o] : [t, n]
432
+ ([t, n], [i, r]) => r.expiration.getTime() < n.expiration.getTime() ? [i, r] : [t, n]
433
433
  );
434
434
  this.clearKey(e);
435
435
  }
@@ -440,53 +440,53 @@ class x {
440
440
  generating: !0,
441
441
  expiration: new Date(Date.now() + this.timeout)
442
442
  }), setTimeout(() => {
443
- t.then((o) => {
443
+ t.then((r) => {
444
444
  const c = this.metadata.get(n);
445
- !(c != null && c.generating) || this.set(e, o);
445
+ !(c != null && c.generating) || this.set(e, r);
446
446
  });
447
447
  }, 0);
448
448
  }
449
449
  }
450
450
  async function _(a) {
451
- if (!r.token)
451
+ if (!o.token)
452
452
  throw new Error("Not authenticated");
453
453
  return (await (await fetch(`${h}/v1/queries/queries`, {
454
454
  method: "POST",
455
455
  body: JSON.stringify(a),
456
456
  headers: {
457
457
  "Content-Type": "application/json",
458
- Authorization: "Bearer " + r.token
458
+ Authorization: "Bearer " + o.token
459
459
  }
460
460
  })).json()).items;
461
461
  }
462
- class Me {
462
+ class ze {
463
463
  constructor() {
464
464
  s(this, "queryStoreCache", new x({
465
465
  capacity: 1e4,
466
- timeout: 20 * j.second
466
+ timeout: 20 * L.second
467
467
  }));
468
468
  s(this, "liveQueryStoreCache", new x({
469
469
  capacity: 1e4,
470
- timeout: 200 * j.millisecond
470
+ timeout: 200 * L.millisecond
471
471
  }));
472
472
  }
473
- moduleQuery(e, t, n, i, o, c = !1) {
473
+ moduleQuery(e, t, n, i, r, c = !1) {
474
474
  const d = {
475
475
  ...e,
476
476
  names: [...t],
477
477
  types: [...n]
478
- }, p = this.query(d, i, o, c);
478
+ }, p = this.query(d, i, r, c);
479
479
  return p === void 0 || p === "too much data" ? p : _e(p, n);
480
480
  }
481
481
  query(e, t, n, i = !1) {
482
- const o = {
482
+ const r = {
483
483
  ...e,
484
484
  start: se(t).toISOString(),
485
485
  end: i ? n.toISOString() : ce(de(n), 1).toISOString(),
486
486
  latestOnly: i
487
487
  }, c = n > he(/* @__PURE__ */ new Date(), -20);
488
488
  let d;
489
- return c ? d = this.liveQueryCache(o) : d = this.queryCache(o), !d || d === "too much data" || i ? d : $e(d, t, n);
489
+ return c ? d = this.liveQueryCache(r) : d = this.queryCache(r), !d || d === "too much data" || i ? d : $e(d, t, n);
490
490
  }
491
491
  queryCache(e) {
492
492
  return this.queryStoreCache.get(e, async () => {
@@ -507,14 +507,14 @@ class Me {
507
507
  });
508
508
  }
509
509
  }
510
- const ze = new Me();
510
+ const Me = new ze();
511
511
  function Be(a, e, t) {
512
512
  const n = (i) => {
513
- const o = i.data;
514
- if (o.type === "module_data") {
515
- const { start: c, end: d } = o.queryRange;
513
+ const r = i.data;
514
+ if (r.type === "module_data") {
515
+ const { start: c, end: d } = r.queryRange;
516
516
  t(
517
- ze.moduleQuery(
517
+ Me.moduleQuery(
518
518
  {},
519
519
  a,
520
520
  e,
@@ -535,8 +535,8 @@ async function qe(a, e, t) {
535
535
  maxTime: t,
536
536
  time: a
537
537
  });
538
- const i = (o) => {
539
- const c = o.data;
538
+ const i = (r) => {
539
+ const c = r.data;
540
540
  c.type === "date_response" && (window.removeEventListener("message", i), n(c.data));
541
541
  };
542
542
  window.addEventListener("message", i);
@@ -552,8 +552,8 @@ async function xe(a, e) {
552
552
  okText: e == null ? void 0 : e.okText,
553
553
  cancelText: e == null ? void 0 : e.cancelText
554
554
  });
555
- const i = (o) => {
556
- const c = o.data;
555
+ const i = (r) => {
556
+ const c = r.data;
557
557
  c.type === "prompt_response" && c.promptId === n && t(c.data), window.removeEventListener("message", i);
558
558
  };
559
559
  window.addEventListener("message", i);
@@ -561,7 +561,7 @@ async function xe(a, e) {
561
561
  }
562
562
  const q = class {
563
563
  static isModule() {
564
- return E() !== null;
564
+ return k() !== null;
565
565
  }
566
566
  static async getCurrentModuleConfiguration() {
567
567
  let e = new URLSearchParams("");
@@ -585,12 +585,12 @@ const q = class {
585
585
  const i = setTimeout(
586
586
  () => n(new Error("deadline expired: took too long")),
587
587
  e
588
- ), o = (c) => {
589
- window.removeEventListener("message", o), clearTimeout(i);
588
+ ), r = (c) => {
589
+ window.removeEventListener("message", r), clearTimeout(i);
590
590
  const { data: d } = c;
591
591
  d.type === "formant_online" && (this._isOnline = d.online, t(d.online));
592
592
  };
593
- window.addEventListener("message", o), T({ type: "formant_online" });
593
+ window.addEventListener("message", r), T({ type: "formant_online" });
594
594
  });
595
595
  }
596
596
  static waitForConnection(e = 5e3) {
@@ -599,17 +599,17 @@ const q = class {
599
599
  setTimeout(() => {
600
600
  t = !0, d(new Error("deadline expired: took too long"));
601
601
  }, e);
602
- }), i = (c) => new Promise((d) => setTimeout(d, c)), o = async () => {
602
+ }), i = (c) => new Promise((d) => setTimeout(d, c)), r = async () => {
603
603
  for (await i(50); !t && !(this.isOnline || await this.checkConnection); )
604
604
  await i(500);
605
605
  };
606
- return Promise.race([n, o()]);
606
+ return Promise.race([n, r()]);
607
607
  }
608
608
  };
609
609
  let y = q;
610
- s(y, "getCurrentModuleContext", E), // senders
611
- s(y, "disableAnalyticsBottomBar", ge), s(y, "goToDevice", ve), s(y, "goToTime", Te), s(y, "refreshAuthToken", J), s(y, "requestModuleData", Ce), s(y, "sendChannelData", Se), s(y, "setModuleDateTimeRange", Ee), s(y, "setupModuleMenus", ke), s(y, "showMessage", Re), // listeners
612
- s(y, "addAccessTokenRefreshListener", V), s(y, "addChannelDataListener", Oe), s(y, "addMenuListener", be), s(y, "addModuleConfigurationListener", Ae), s(y, "addModuleDataListener", De), s(y, "addOverviewDeviceListener", Pe), s(y, "addStreamListener", Be), // bidirectional
610
+ s(y, "getCurrentModuleContext", k), // senders
611
+ s(y, "disableAnalyticsBottomBar", ge), s(y, "goToDevice", ve), s(y, "goToTime", Te), s(y, "refreshAuthToken", J), s(y, "requestModuleData", Ce), s(y, "sendChannelData", Se), s(y, "setModuleDateTimeRange", Ee), s(y, "setupModuleMenus", ke), s(y, "showMessage", Oe), // listeners
612
+ s(y, "addAccessTokenRefreshListener", V), s(y, "addChannelDataListener", Re), s(y, "addMenuListener", be), s(y, "addModuleConfigurationListener", De), s(y, "addModuleDataListener", Ae), s(y, "addOverviewDeviceListener", Pe), s(y, "addStreamListener", Be), // bidirectional
613
613
  s(y, "getDate", qe), s(y, "prompt", xe), s(y, "_isOnline", null);
614
614
  function f(a, e) {
615
615
  if (a !== void 0)
@@ -621,7 +621,7 @@ const g = {
621
621
  TELEOP: 1,
622
622
  PORT_FORWARD: 2,
623
623
  OBSERVE: 3
624
- }, qt = {
624
+ }, Vt = {
625
625
  ...g,
626
626
  Unknown: g.UNKNOWN,
627
627
  Teleop: g.TELEOP,
@@ -631,11 +631,11 @@ const g = {
631
631
  teleop: g.TELEOP,
632
632
  portForward: g.PORT_FORWARD,
633
633
  observe: g.OBSERVE
634
- }, k = Symbol("RtcClientPool.instance");
635
- var Lt;
636
- class P {
634
+ }, O = Symbol("RtcClientPool.instance");
635
+ var zt;
636
+ class N {
637
637
  constructor(e) {
638
- s(this, Lt, null);
638
+ s(this, zt, null);
639
639
  s(this, "createClient");
640
640
  s(this, "ttlMs");
641
641
  s(this, "proxyHandler");
@@ -646,18 +646,18 @@ class P {
646
646
  });
647
647
  const { createClient: t, ttlMs: n = 0 } = e;
648
648
  this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
649
- get: (i, o, c) => {
650
- switch (o) {
649
+ get: (i, r, c) => {
650
+ switch (r) {
651
651
  case "shutdown":
652
652
  return () => this.releaseInstance(c);
653
653
  default:
654
- return Reflect.get(i, o, c);
654
+ return Reflect.get(i, r, c);
655
655
  }
656
656
  }
657
657
  };
658
658
  }
659
659
  get isActive() {
660
- return this[k] !== null;
660
+ return this[O] !== null;
661
661
  }
662
662
  get size() {
663
663
  return this.proxyReceivers.size;
@@ -667,13 +667,13 @@ class P {
667
667
  return this.proxyReceivers.set(t, e ?? null), t;
668
668
  }
669
669
  allocate() {
670
- if (this[k])
671
- return this.teardownTimeout && (clearTimeout(this.teardownTimeout), this.teardownTimeout = null), this[k];
670
+ if (this[O])
671
+ return this.teardownTimeout && (clearTimeout(this.teardownTimeout), this.teardownTimeout = null), this[O];
672
672
  const e = this.createClient(this.dispatch);
673
- return this[k] = e, e;
673
+ return this[O] = e, e;
674
674
  }
675
675
  async teardown() {
676
- const e = this[k];
676
+ const e = this[O];
677
677
  if (!e) {
678
678
  console.warn("singleton has already been shutdown!");
679
679
  return;
@@ -681,7 +681,7 @@ class P {
681
681
  try {
682
682
  await e.shutdown();
683
683
  } finally {
684
- this[k] = null;
684
+ this[O] = null;
685
685
  }
686
686
  }
687
687
  async releaseInstance(e) {
@@ -690,40 +690,40 @@ class P {
690
690
  }, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
691
691
  }
692
692
  }
693
- Lt = k;
694
- const N = async () => f(r.token, "Realtime when user isn't authorized"), R = {
695
- [g.UNKNOWN]: new P({
693
+ zt = O;
694
+ const j = async () => f(o.token, "Realtime when user isn't authorized"), R = {
695
+ [g.UNKNOWN]: new N({
696
696
  ttlMs: 2500,
697
697
  createClient: (a) => new A({
698
- signalingClient: new D(h),
699
- getToken: N,
698
+ signalingClient: new P(h),
699
+ getToken: j,
700
700
  sessionType: g.UNKNOWN,
701
701
  receive: a
702
702
  })
703
703
  }),
704
- [g.TELEOP]: new P({
704
+ [g.TELEOP]: new N({
705
705
  ttlMs: 2500,
706
706
  createClient: (a) => new A({
707
- signalingClient: new D(h),
708
- getToken: N,
707
+ signalingClient: new P(h),
708
+ getToken: j,
709
709
  sessionType: g.TELEOP,
710
710
  receive: a
711
711
  })
712
712
  }),
713
- [g.PORT_FORWARD]: new P({
713
+ [g.PORT_FORWARD]: new N({
714
714
  ttlMs: 2500,
715
715
  createClient: (a) => new A({
716
- signalingClient: new D(h),
717
- getToken: N,
716
+ signalingClient: new P(h),
717
+ getToken: j,
718
718
  sessionType: g.PORT_FORWARD,
719
719
  receive: a
720
720
  })
721
721
  }),
722
- [g.OBSERVE]: new P({
722
+ [g.OBSERVE]: new N({
723
723
  ttlMs: 2500,
724
724
  createClient: (a) => new A({
725
- signalingClient: new D(h),
726
- getToken: N,
725
+ signalingClient: new P(h),
726
+ getToken: j,
727
727
  sessionType: g.OBSERVE,
728
728
  receive: a
729
729
  })
@@ -768,7 +768,7 @@ class Ve {
768
768
  });
769
769
  }
770
770
  }
771
- function O(a) {
771
+ function b(a) {
772
772
  return new Promise((e) => setTimeout(e, a));
773
773
  }
774
774
  const Fe = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
@@ -790,8 +790,8 @@ class We {
790
790
  console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
791
791
  }, this.dataChannel.onmessage = (t) => {
792
792
  this.listeners.forEach((n) => {
793
- const i = new Uint8Array(t.data), o = this.decoder.decode(i);
794
- n(o);
793
+ const i = new Uint8Array(t.data), r = this.decoder.decode(i);
794
+ n(r);
795
795
  }), this.binaryListeners.forEach((n) => {
796
796
  n(new Uint8Array(t.data));
797
797
  });
@@ -939,22 +939,22 @@ class He extends H {
939
939
  const i = t.slice(0, 16).toString();
940
940
  if (i.length === 0)
941
941
  throw new Error("Invalid response");
942
- const o = t.slice(16);
943
- if (o.length === 0)
942
+ const r = t.slice(16);
943
+ if (r.length === 0)
944
944
  throw new Error("Invalid response");
945
- this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, o);
945
+ this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, r);
946
946
  });
947
947
  }
948
948
  async request(t) {
949
949
  if (this.channel || await this.initialize(), !this.channel)
950
950
  throw new Error("Failed to create channel");
951
- const { channel: n, requestIdToResponseMap: i, timeout: o } = this;
951
+ const { channel: n, requestIdToResponseMap: i, timeout: r } = this;
952
952
  await n.waitTilReady();
953
953
  const c = this.generateBinaryId(), d = c.toString();
954
954
  i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
955
955
  const p = (/* @__PURE__ */ new Date()).getTime();
956
- for (; (/* @__PURE__ */ new Date()).getTime() < p + o; )
957
- if (await O(50), i.has(d)) {
956
+ for (; (/* @__PURE__ */ new Date()).getTime() < p + r; )
957
+ if (await b(50), i.has(d)) {
958
958
  const m = i.get(d);
959
959
  if (m !== !0) {
960
960
  i.delete(d);
@@ -969,7 +969,7 @@ class He extends H {
969
969
  }
970
970
  throw i.delete(d), console.error({
971
971
  name: "TimeoutError",
972
- message: `Request timed out after ${o / 1e3} seconds`
972
+ message: `Request timed out after ${r / 1e3} seconds`
973
973
  }), new Error("Binary request data channel request timed out");
974
974
  }
975
975
  }
@@ -979,10 +979,10 @@ class Ke extends H {
979
979
  }
980
980
  async initialize() {
981
981
  this.channel = await this.device.createCustomDataChannel(this.channel_name), this.channel.addListener((e) => {
982
- const t = JSON.parse(e), { id: n, data: i, error: o } = t;
982
+ const t = JSON.parse(e), { id: n, data: i, error: r } = t;
983
983
  if (!n)
984
984
  throw new Error("Invalid response");
985
- if (!i && !o)
985
+ if (!i && !r)
986
986
  throw new Error("Invalid response");
987
987
  this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
988
988
  });
@@ -992,19 +992,19 @@ class Ke extends H {
992
992
  throw new Error("Failed to create channel");
993
993
  const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
994
994
  await t.waitTilReady();
995
- const o = this.generateTextId();
996
- n.set(o, !0), t.send(
995
+ const r = this.generateTextId();
996
+ n.set(r, !0), t.send(
997
997
  JSON.stringify({
998
- id: o,
998
+ id: r,
999
999
  data: e
1000
1000
  })
1001
1001
  );
1002
1002
  const c = (/* @__PURE__ */ new Date()).getTime();
1003
1003
  for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
1004
- if (await O(50), n.has(o)) {
1005
- const d = n.get(o);
1004
+ if (await b(50), n.has(r)) {
1005
+ const d = n.get(r);
1006
1006
  if (d !== !0) {
1007
- n.delete(o);
1007
+ n.delete(r);
1008
1008
  const { data: p, error: m } = d;
1009
1009
  if (p)
1010
1010
  return p;
@@ -1015,7 +1015,7 @@ class Ke extends H {
1015
1015
  }), new Error("Text request datachannel adapter error");
1016
1016
  }
1017
1017
  }
1018
- throw n.delete(o), console.error({
1018
+ throw n.delete(r), console.error({
1019
1019
  name: "TimeoutError",
1020
1020
  message: `Request timed out after ${i / 1e3} seconds`
1021
1021
  }), new Error("Text request datachannel request timed out");
@@ -1075,13 +1075,13 @@ class K extends le {
1075
1075
  return n;
1076
1076
  }
1077
1077
  async getRealtimeVideoStreams() {
1078
- var i, o, c;
1078
+ var i, r, c;
1079
1079
  const t = await this.getConfiguration(), n = [];
1080
1080
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1081
1081
  d.rtcStreamType === "h264-video-frame" && n.push({
1082
1082
  name: d.name
1083
1083
  });
1084
- for (const d of ((o = t.teleop) == null ? void 0 : o.rosStreams) ?? [])
1084
+ for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
1085
1085
  d.topicType == "formant/H264VideoFrame" && n.push({
1086
1086
  name: d.topicName
1087
1087
  }), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
@@ -1169,8 +1169,8 @@ class K extends le {
1169
1169
  const i = f(
1170
1170
  this.rtcClient,
1171
1171
  "Realtime connection has not been started"
1172
- ), o = await this.getRemotePeer();
1173
- i.controlRemoteStream(f(o).id, {
1172
+ ), r = await this.getRemotePeer();
1173
+ i.controlRemoteStream(f(r).id, {
1174
1174
  streamName: t,
1175
1175
  setAudioFormat: n
1176
1176
  });
@@ -1179,9 +1179,9 @@ class K extends le {
1179
1179
  const i = f(
1180
1180
  this.rtcClient,
1181
1181
  "Realtime connection has not been started"
1182
- ), o = await this.getRemotePeer(), c = await new Promise((d) => {
1182
+ ), r = await this.getRemotePeer(), c = await new Promise((d) => {
1183
1183
  i.createCustomDataChannel(
1184
- f(o).id,
1184
+ f(r).id,
1185
1185
  t,
1186
1186
  {
1187
1187
  ordered: !0,
@@ -1202,17 +1202,17 @@ class K extends le {
1202
1202
  const i = f(
1203
1203
  this.rtcClient,
1204
1204
  "Realtime connection has not been started"
1205
- ), o = await this.getRemotePeer();
1206
- i.send(f(o).id, t, n);
1205
+ ), r = await this.getRemotePeer();
1206
+ i.send(f(r).id, t, n);
1207
1207
  }
1208
1208
  async getRealtimeAudioStreams() {
1209
- var i, o, c;
1209
+ var i, r, c;
1210
1210
  const t = await this.getConfiguration(), n = [];
1211
1211
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1212
1212
  d.rtcStreamType === "audio-chunk" && n.push({
1213
1213
  name: d.name
1214
1214
  });
1215
- for (const d of ((o = t.teleop) == null ? void 0 : o.rosStreams) ?? [])
1215
+ for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
1216
1216
  d.topicType == "audio_common_msgs/AudioData" && n.push({
1217
1217
  name: d.topicName
1218
1218
  });
@@ -1230,18 +1230,18 @@ function Xe(a) {
1230
1230
  return me(n);
1231
1231
  }
1232
1232
  async function Q() {
1233
- if (!r.token)
1233
+ if (!o.token)
1234
1234
  throw new Error("Not authenticated");
1235
1235
  return (await (await fetch(`${h}/v1/admin/views`, {
1236
1236
  method: "GET",
1237
1237
  headers: {
1238
1238
  "Content-Type": "application/json",
1239
- Authorization: "Bearer " + r.token
1239
+ Authorization: "Bearer " + o.token
1240
1240
  }
1241
1241
  })).json()).items;
1242
1242
  }
1243
1243
  async function X(a, e) {
1244
- if (!r.token)
1244
+ if (!o.token)
1245
1245
  throw new Error("Not authenticated");
1246
1246
  const n = (await Q()).filter((d) => d.name === e);
1247
1247
  if (n.length === 0)
@@ -1251,14 +1251,14 @@ async function X(a, e) {
1251
1251
  body: JSON.stringify(a),
1252
1252
  headers: {
1253
1253
  "Content-Type": "application/json",
1254
- Authorization: "Bearer " + r.token
1254
+ Authorization: "Bearer " + o.token
1255
1255
  }
1256
- }), o = h.replace("api", "app"), { code: c } = await i.json();
1257
- return `${o}/shares/${c}#${Xe({
1256
+ }), r = h.replace("api", "app"), { code: c } = await i.json();
1257
+ return `${r}/shares/${c}#${Xe({
1258
1258
  viewId: n[0].id
1259
1259
  })}`;
1260
1260
  }
1261
- const xt = [
1261
+ const Ft = [
1262
1262
  "day",
1263
1263
  "week",
1264
1264
  "month",
@@ -1266,7 +1266,7 @@ const xt = [
1266
1266
  "hour",
1267
1267
  "minute",
1268
1268
  "quarter"
1269
- ], Ut = [
1269
+ ], Wt = [
1270
1270
  "interval",
1271
1271
  "start",
1272
1272
  "end",
@@ -1294,7 +1294,7 @@ function at(a) {
1294
1294
  function it(a) {
1295
1295
  return a.count;
1296
1296
  }
1297
- const Jt = {
1297
+ const Gt = {
1298
1298
  min: tt,
1299
1299
  max: et,
1300
1300
  "standard deviation": Ze,
@@ -1358,32 +1358,32 @@ const Jt = {
1358
1358
  // bg-BG: 'dd.mm.YYYY'
1359
1359
  a.split("/")[0] + "/" + a.split("/")[1] + "–" + e.split("/")[0] + "/" + e.split("/")[1]
1360
1360
  );
1361
- async function M(a) {
1362
- if (!r.token)
1361
+ async function z(a) {
1362
+ if (!o.token)
1363
1363
  throw new Error("Not authenticated");
1364
1364
  return (await (await fetch(`${h}/v1/admin/events/query`, {
1365
1365
  method: "POST",
1366
1366
  body: JSON.stringify(a),
1367
1367
  headers: {
1368
1368
  "Content-Type": "application/json",
1369
- Authorization: "Bearer " + r.token
1369
+ Authorization: "Bearer " + o.token
1370
1370
  }
1371
1371
  })).json()).items;
1372
1372
  }
1373
1373
  async function Z(a, e, t, n, i) {
1374
- const o = Y[e];
1374
+ const r = Y[e];
1375
1375
  return await Promise.all(
1376
1376
  Array(t).fill(0).map(async (c, d) => {
1377
- const p = new Date(n), m = o.sub(
1378
- o.start(p),
1377
+ const p = new Date(n), m = r.sub(
1378
+ r.start(p),
1379
1379
  t - d - 1
1380
- ), w = o.sub(
1381
- o.end(p),
1380
+ ), w = r.sub(
1381
+ r.end(p),
1382
1382
  t - d - 1
1383
1383
  ), v = ot(
1384
1384
  m.toLocaleDateString(),
1385
1385
  w.toLocaleDateString()
1386
- ), C = await M({
1386
+ ), C = await z({
1387
1387
  ...i,
1388
1388
  eventTypes: a,
1389
1389
  start: new Date(m).toISOString(),
@@ -1393,15 +1393,15 @@ async function Z(a, e, t, n, i) {
1393
1393
  })
1394
1394
  );
1395
1395
  }
1396
- async function z(a, e) {
1397
- return (await M({
1396
+ async function M(a, e) {
1397
+ return (await z({
1398
1398
  ...a,
1399
1399
  eventTypes: ["annotation"]
1400
1400
  })).filter(
1401
- (o) => !!o.tags && Object.keys(o.tags).includes(e)
1402
- ).reduce((o, c) => {
1401
+ (r) => !!r.tags && Object.keys(r.tags).includes(e)
1402
+ ).reduce((r, c) => {
1403
1403
  const d = c.tags[e];
1404
- return d in o ? (o[d] += 1, o) : (o[d] = 1, o);
1404
+ return d in r ? (r[d] += 1, r) : (r[d] = 1, r);
1405
1405
  }, {});
1406
1406
  }
1407
1407
  async function ee(a, e, t) {
@@ -1410,7 +1410,7 @@ async function ee(a, e, t) {
1410
1410
  end: new Date(n)
1411
1411
  }), d = c.map((m, w) => {
1412
1412
  const v = new Date(m).toISOString(), C = w === c.length - 1 ? new Date(Date.now()).toISOString() : new Date(c[w + 1]);
1413
- return z(
1413
+ return M(
1414
1414
  {
1415
1415
  ...a,
1416
1416
  start: v,
@@ -1425,13 +1425,13 @@ async function ee(a, e, t) {
1425
1425
  }));
1426
1426
  }
1427
1427
  async function te(a, e, t, n, i) {
1428
- let o = a;
1429
- Array.isArray(a) || (o = [a]);
1428
+ let r = a;
1429
+ Array.isArray(a) || (r = [a]);
1430
1430
  let c = e;
1431
1431
  return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
1432
1432
  method: "POST",
1433
1433
  body: JSON.stringify({
1434
- deviceIds: o,
1434
+ deviceIds: r,
1435
1435
  end: n.toISOString(),
1436
1436
  names: c,
1437
1437
  start: t.toISOString(),
@@ -1439,12 +1439,12 @@ async function te(a, e, t, n, i) {
1439
1439
  }),
1440
1440
  headers: {
1441
1441
  "Content-Type": "application/json",
1442
- Authorization: "Bearer " + r.token
1442
+ Authorization: "Bearer " + o.token
1443
1443
  }
1444
1444
  })).json()).items;
1445
1445
  }
1446
1446
  async function ne() {
1447
- if (!r.token)
1447
+ if (!o.token)
1448
1448
  throw new Error("Not authenticated");
1449
1449
  const a = $.get();
1450
1450
  try {
@@ -1454,7 +1454,7 @@ async function ne() {
1454
1454
  }
1455
1455
  }
1456
1456
  async function ae() {
1457
- if (!r.token)
1457
+ if (!o.token)
1458
1458
  throw new Error("Not authenticated");
1459
1459
  const a = $.get();
1460
1460
  try {
@@ -1463,7 +1463,55 @@ async function ae() {
1463
1463
  await a.shutdown();
1464
1464
  }
1465
1465
  }
1466
- class L extends K {
1466
+ async function rt(a) {
1467
+ if (!o.token)
1468
+ throw new Error("Not authenticated");
1469
+ return await (await fetch(`${h}/v1/admin/devices`, {
1470
+ method: "POST",
1471
+ body: JSON.stringify(a),
1472
+ headers: {
1473
+ "Content-Type": "application/json",
1474
+ Authorization: "Bearer " + o.token
1475
+ }
1476
+ })).json();
1477
+ }
1478
+ async function st(a, e) {
1479
+ if (!o.token)
1480
+ throw new Error("Not authenticated");
1481
+ return await (await fetch(`${h}/v1/admin/devices/${a}`, {
1482
+ method: "PATCH",
1483
+ body: JSON.stringify(e),
1484
+ headers: {
1485
+ "Content-Type": "application/json",
1486
+ Authorization: "Bearer " + o.token
1487
+ }
1488
+ })).json();
1489
+ }
1490
+ async function ct() {
1491
+ if (!o.token)
1492
+ throw new Error("Not authenticated");
1493
+ return (await (await fetch(`${h}/v1/admin/device-details/query`, {
1494
+ method: "POST",
1495
+ body: JSON.stringify({ enabled: !0, type: "default" }),
1496
+ headers: {
1497
+ "Content-Type": "application/json",
1498
+ Authorization: "Bearer " + o.token
1499
+ }
1500
+ })).json()).items;
1501
+ }
1502
+ async function dt(a) {
1503
+ if (!o.token)
1504
+ throw new Error("Not authenticated");
1505
+ return (await (await fetch(`${h}/v1/admin/devices/query`, {
1506
+ method: "POST",
1507
+ body: JSON.stringify(a),
1508
+ headers: {
1509
+ "Content-Type": "application/json",
1510
+ Authorization: "Bearer " + o.token
1511
+ }
1512
+ })).json()).items;
1513
+ }
1514
+ class E extends K {
1467
1515
  constructor(e, t, n, i) {
1468
1516
  super(), this.id = e, this.name = t, this.organizationId = n, this.tags = i;
1469
1517
  }
@@ -1477,7 +1525,7 @@ class L extends K {
1477
1525
  }),
1478
1526
  headers: {
1479
1527
  "Content-Type": "application/json",
1480
- Authorization: "Bearer " + r.token
1528
+ Authorization: "Bearer " + o.token
1481
1529
  }
1482
1530
  }
1483
1531
  )).json()).items;
@@ -1487,7 +1535,7 @@ class L extends K {
1487
1535
  method: "GET",
1488
1536
  headers: {
1489
1537
  "Content-Type": "application/json",
1490
- Authorization: "Bearer " + r.token
1538
+ Authorization: "Bearer " + o.token
1491
1539
  }
1492
1540
  });
1493
1541
  const t = await e.json();
@@ -1502,7 +1550,7 @@ class L extends K {
1502
1550
  method: "GET",
1503
1551
  headers: {
1504
1552
  "Content-Type": "application/json",
1505
- Authorization: "Bearer " + r.token
1553
+ Authorization: "Bearer " + o.token
1506
1554
  }
1507
1555
  }
1508
1556
  ), (await e.json()).document;
@@ -1515,7 +1563,7 @@ class L extends K {
1515
1563
  }),
1516
1564
  headers: {
1517
1565
  "Content-Type": "application/json",
1518
- Authorization: "Bearer " + r.token
1566
+ Authorization: "Bearer " + o.token
1519
1567
  }
1520
1568
  })).json()).fileUrls;
1521
1569
  }
@@ -1552,19 +1600,19 @@ class L extends K {
1552
1600
  ), m = async () => {
1553
1601
  if ("isReady" in c)
1554
1602
  for (; !c.isReady(); )
1555
- this.assertNotCancelled(d), await O(100);
1603
+ this.assertNotCancelled(d), await b(100);
1556
1604
  const w = await this.getRemoteDevicePeerId(c);
1557
1605
  this.assertNotCancelled(d);
1558
1606
  let v;
1559
- for (let b = 0; b < i && (v = await c.connect(w), !v); b++)
1560
- O(100), this.assertNotCancelled(d);
1607
+ for (let D = 0; D < i && (v = await c.connect(w), !v); D++)
1608
+ b(100), this.assertNotCancelled(d);
1561
1609
  if (!v)
1562
1610
  throw new Error(
1563
1611
  `Session could not be created: exhausted ${i} retries`
1564
1612
  );
1565
1613
  let C = 0;
1566
1614
  for (; !d && c.getConnectionStatus(w) !== "connected"; )
1567
- await O(100), C += 1;
1615
+ await b(100), C += 1;
1568
1616
  return this.assertNotCancelled(d), console.debug(
1569
1617
  `${(/* @__PURE__ */ new Date()).toISOString()} :: Connection completed after ${C} retries`
1570
1618
  ), w;
@@ -1636,7 +1684,7 @@ class L extends K {
1636
1684
  method: "GET",
1637
1685
  headers: {
1638
1686
  "Content-Type": "application/json",
1639
- Authorization: "Bearer " + r.token
1687
+ Authorization: "Bearer " + o.token
1640
1688
  }
1641
1689
  }
1642
1690
  )).json()).items.map((n) => ({
@@ -1674,11 +1722,11 @@ class L extends K {
1674
1722
  deviceId: this.id,
1675
1723
  command: c.command,
1676
1724
  parameter: p,
1677
- userId: (w = r.currentUser) == null ? void 0 : w.id
1725
+ userId: (w = o.currentUser) == null ? void 0 : w.id
1678
1726
  }),
1679
1727
  headers: {
1680
1728
  "Content-Type": "application/json",
1681
- Authorization: "Bearer " + r.token
1729
+ Authorization: "Bearer " + o.token
1682
1730
  }
1683
1731
  });
1684
1732
  }
@@ -1687,7 +1735,7 @@ class L extends K {
1687
1735
  method: "GET",
1688
1736
  headers: {
1689
1737
  "Content-Type": "application/json",
1690
- Authorization: "Bearer " + r.token
1738
+ Authorization: "Bearer " + o.token
1691
1739
  }
1692
1740
  });
1693
1741
  }
@@ -1701,7 +1749,7 @@ class L extends K {
1701
1749
  }),
1702
1750
  headers: {
1703
1751
  "Content-Type": "application/json",
1704
- Authorization: "Bearer " + r.token
1752
+ Authorization: "Bearer " + o.token
1705
1753
  }
1706
1754
  })).json();
1707
1755
  return new Ve(n);
@@ -1726,7 +1774,7 @@ class L extends K {
1726
1774
  }),
1727
1775
  headers: {
1728
1776
  "Content-Type": "application/json",
1729
- Authorization: "Bearer " + r.token
1777
+ Authorization: "Bearer " + o.token
1730
1778
  }
1731
1779
  }
1732
1780
  ), n = [], i = [];
@@ -1749,7 +1797,7 @@ class L extends K {
1749
1797
  }),
1750
1798
  headers: {
1751
1799
  "Content-Type": "application/json",
1752
- Authorization: "Bearer " + r.token
1800
+ Authorization: "Bearer " + o.token
1753
1801
  }
1754
1802
  }
1755
1803
  )).json();
@@ -1766,13 +1814,13 @@ class L extends K {
1766
1814
  }),
1767
1815
  headers: {
1768
1816
  "Content-Type": "application/json",
1769
- Authorization: "Bearer " + r.token
1817
+ Authorization: "Bearer " + o.token
1770
1818
  }
1771
1819
  }
1772
1820
  )).json();
1773
1821
  }
1774
1822
  async getAnnotationCount(e, t) {
1775
- return await z({ ...e, deviceIds: [this.id] }, t);
1823
+ return await M({ ...e, deviceIds: [this.id] }, t);
1776
1824
  }
1777
1825
  async getAnnotationCountByIntervals(e, t, n) {
1778
1826
  return await ee(
@@ -1781,41 +1829,18 @@ class L extends K {
1781
1829
  n
1782
1830
  );
1783
1831
  }
1784
- async eventsCounter(e, t, n, i, o) {
1832
+ async eventsCounter(e, t, n, i, r) {
1785
1833
  return await Z(e, t, n, i, {
1786
- ...o,
1834
+ ...r,
1787
1835
  deviceIds: [this.id]
1788
1836
  });
1789
1837
  }
1790
1838
  async createShareLink(e, t) {
1791
1839
  return e.scope.deviceIds = [this.id], await X(e, t);
1792
1840
  }
1793
- async createDevice(e) {
1794
- if (!r.token)
1795
- throw new Error("Not authenticated");
1796
- return await (await fetch(`${h}/v1/admin/devices`, {
1797
- method: "POST",
1798
- body: JSON.stringify(e),
1799
- headers: {
1800
- "Content-Type": "application/json",
1801
- Authorization: "Bearer " + r.token
1802
- }
1803
- })).json();
1804
- }
1805
- async patchDevice(e, t) {
1806
- if (!r.token)
1807
- throw new Error("Not authenticated");
1808
- return await (await fetch(`${h}/v1/admin/devices/${e}`, {
1809
- method: "PATCH",
1810
- body: JSON.stringify(t),
1811
- headers: {
1812
- "Content-Type": "application/json",
1813
- Authorization: "Bearer " + r.token
1814
- }
1815
- })).json();
1816
- }
1817
1841
  }
1818
- class rt extends K {
1842
+ s(E, "createDevice", rt), s(E, "patchDevice", st), s(E, "getDevicesData", ct), s(E, "queryDevicesData", dt);
1843
+ class ht extends K {
1819
1844
  constructor(t) {
1820
1845
  super();
1821
1846
  s(this, "id");
@@ -1826,12 +1851,12 @@ class rt extends K {
1826
1851
  async getLatestTelemetry() {
1827
1852
  this.telemetryStreamActive || this.subscribeToTelemetry();
1828
1853
  const t = this.streamTelemetry;
1829
- return Object.entries(t).map(([i, o]) => ({
1854
+ return Object.entries(t).map(([i, r]) => ({
1830
1855
  deviceId: this.id,
1831
1856
  streamName: i,
1832
1857
  streamType: "json",
1833
- currentValue: o,
1834
- currentValueTime: o.timestamp,
1858
+ currentValue: r,
1859
+ currentValueTime: r.timestamp,
1835
1860
  tags: {}
1836
1861
  }));
1837
1862
  }
@@ -1848,15 +1873,15 @@ class rt extends K {
1848
1873
  }), n.addEventListener("readystatechange", (i) => {
1849
1874
  n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
1850
1875
  }), n.addEventListener("progress", (i) => {
1851
- const o = i.loaded, c = o - t;
1852
- t = o, n.responseText.substr(-c).split(`
1876
+ const r = i.loaded, c = r - t;
1877
+ t = r, n.responseText.substr(-c).split(`
1853
1878
  `).forEach((m) => {
1854
1879
  var w;
1855
1880
  if (m.length > 0) {
1856
1881
  const v = JSON.parse(m);
1857
1882
  if ((w = v.result) != null && w.datapoint) {
1858
- const C = v.result.datapoint, b = C.stream;
1859
- delete C.stream, this.streamTelemetry[b] = C;
1883
+ const C = v.result.datapoint, D = C.stream;
1884
+ delete C.stream, this.streamTelemetry[D] = C;
1860
1885
  }
1861
1886
  }
1862
1887
  });
@@ -1885,7 +1910,7 @@ class rt extends K {
1885
1910
  sessionType: t
1886
1911
  });
1887
1912
  for (await n.connectLan(this.peerUrl); n.getConnectionStatus(this.peerUrl) !== "connected"; )
1888
- await O(100);
1913
+ await b(100);
1889
1914
  this.rtcClient = n, this.initConnectionMonitoring();
1890
1915
  }
1891
1916
  initConnectionMonitoring() {
@@ -1918,11 +1943,11 @@ class rt extends K {
1918
1943
  if (t)
1919
1944
  throw new Error(`Realtime connection hasn't been started for ${this.id}`);
1920
1945
  }
1921
- async sendCommand(t, n, i, o) {
1946
+ async sendCommand(t, n, i, r) {
1922
1947
  const c = {
1923
1948
  value: n,
1924
1949
  scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
1925
- meta: o
1950
+ meta: r
1926
1951
  };
1927
1952
  return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
1928
1953
  method: "POST",
@@ -1936,43 +1961,43 @@ class rt extends K {
1936
1961
  });
1937
1962
  }
1938
1963
  }
1939
- async function st(a, e) {
1940
- if (!r.token)
1964
+ async function lt(a, e) {
1965
+ if (!o.token)
1941
1966
  throw new Error("Not authenticated");
1942
1967
  return await (await fetch(`${h}/v1/admin/devices/${a}`, {
1943
1968
  method: "PATCH",
1944
1969
  body: JSON.stringify({ fleetId: e }),
1945
1970
  headers: {
1946
1971
  "Content-Type": "application/json",
1947
- Authorization: "Bearer " + r.token
1972
+ Authorization: "Bearer " + o.token
1948
1973
  }
1949
1974
  })).json();
1950
1975
  }
1951
- async function ct(a) {
1952
- if (!r.token)
1976
+ async function ut(a) {
1977
+ if (!o.token)
1953
1978
  throw new Error("Not authenticated");
1954
1979
  return (await (await fetch(`${h}/v1/queries/queries`, {
1955
1980
  method: "POST",
1956
1981
  body: JSON.stringify(a),
1957
1982
  headers: {
1958
1983
  "Content-Type": "application/json",
1959
- Authorization: "Bearer " + r.token
1984
+ Authorization: "Bearer " + o.token
1960
1985
  }
1961
1986
  })).json()).aggregates;
1962
1987
  }
1963
- async function dt(a) {
1964
- if (!r.token)
1988
+ async function mt(a) {
1989
+ if (!o.token)
1965
1990
  throw new Error("Not authenticated");
1966
1991
  await fetch(`${h}/v1/admin/fleets/${a}`, {
1967
1992
  method: "DELETE",
1968
1993
  headers: {
1969
1994
  "Content-Type": "application/json",
1970
- Authorization: "Bearer " + r.token
1995
+ Authorization: "Bearer " + o.token
1971
1996
  }
1972
1997
  });
1973
1998
  }
1974
- async function ht() {
1975
- if (!r.token)
1999
+ async function ft() {
2000
+ if (!o.token)
1976
2001
  throw new Error("Not authenticated");
1977
2002
  return (await (await fetch(
1978
2003
  `${h}/v1/queries/analytics/streams`,
@@ -1980,13 +2005,13 @@ async function ht() {
1980
2005
  method: "GET",
1981
2006
  headers: {
1982
2007
  "Content-Type": "application/json",
1983
- Authorization: "Bearer " + r.token
2008
+ Authorization: "Bearer " + o.token
1984
2009
  }
1985
2010
  }
1986
2011
  )).json()).items;
1987
2012
  }
1988
- async function lt() {
1989
- if (!r.token)
2013
+ async function wt() {
2014
+ if (!o.token)
1990
2015
  throw new Error("Not authenticated");
1991
2016
  return (await (await fetch(
1992
2017
  `${h}/v1/admin/analytics-modules`,
@@ -1994,39 +2019,39 @@ async function lt() {
1994
2019
  method: "GET",
1995
2020
  headers: {
1996
2021
  "Content-Type": "application/json",
1997
- Authorization: "Bearer " + r.token
2022
+ Authorization: "Bearer " + o.token
1998
2023
  }
1999
2024
  }
2000
2025
  )).json()).items;
2001
2026
  }
2002
- async function ut(a) {
2003
- if (!r.token)
2027
+ async function pt(a) {
2028
+ if (!o.token)
2004
2029
  throw new Error("Not authenticated");
2005
2030
  return await (await fetch(`${h}/v1/queries/analytics/rows`, {
2006
2031
  method: "POST",
2007
2032
  body: JSON.stringify(a),
2008
2033
  headers: {
2009
2034
  "Content-Type": "application/json",
2010
- Authorization: "Bearer " + r.token
2035
+ Authorization: "Bearer " + o.token
2011
2036
  }
2012
2037
  })).json();
2013
2038
  }
2014
2039
  async function ie(a) {
2015
- if (!r.token)
2040
+ if (!o.token)
2016
2041
  throw new Error("Not authenticated");
2017
2042
  return (await (await fetch(`${h}/v1/admin/devices/query`, {
2018
2043
  method: "POST",
2019
2044
  body: JSON.stringify(a),
2020
2045
  headers: {
2021
2046
  "Content-Type": "application/json",
2022
- Authorization: "Bearer " + r.token
2047
+ Authorization: "Bearer " + o.token
2023
2048
  }
2024
2049
  })).json()).items.map(
2025
- (n) => new L(n.id, n.name, n.organizationId, n.tags)
2050
+ (n) => new E(n.id, n.name, n.organizationId, n.tags)
2026
2051
  );
2027
2052
  }
2028
- async function mt() {
2029
- if (!r.token)
2053
+ async function yt() {
2054
+ if (!o.token)
2030
2055
  throw new Error("Not authenticated");
2031
2056
  let a = new URLSearchParams("");
2032
2057
  typeof window < "u" && window.location && (a = new URLSearchParams(window.location.search));
@@ -2038,7 +2063,7 @@ async function mt() {
2038
2063
  {
2039
2064
  headers: {
2040
2065
  "Content-Type": "application/json",
2041
- Authorization: "Bearer " + r.token
2066
+ Authorization: "Bearer " + o.token
2042
2067
  }
2043
2068
  }
2044
2069
  ), { tagKey: n, tagValue: i } = await t.json();
@@ -2048,31 +2073,31 @@ async function mt() {
2048
2073
  type: "default"
2049
2074
  });
2050
2075
  }
2051
- async function ft(a) {
2052
- if (!r.token)
2076
+ async function gt(a) {
2077
+ if (!o.token)
2053
2078
  throw new Error("Not authenticated");
2054
2079
  const t = await (await fetch(`${h}/v1/admin/devices/${a}`, {
2055
2080
  method: "GET",
2056
2081
  headers: {
2057
2082
  "Content-Type": "application/json",
2058
- Authorization: "Bearer " + r.token
2083
+ Authorization: "Bearer " + o.token
2059
2084
  }
2060
2085
  })).json(), n = t.name;
2061
- return new L(a, n, t.organizationId, t.tags);
2086
+ return new E(a, n, t.organizationId, t.tags);
2062
2087
  }
2063
2088
  async function B() {
2064
- if (!r.token)
2089
+ if (!o.token)
2065
2090
  throw new Error("Not authenticated");
2066
2091
  const e = await (await fetch(`${h}/v1/admin/device-details/query`, {
2067
2092
  method: "POST",
2068
2093
  body: JSON.stringify({ enabled: !0, type: "default" }),
2069
2094
  headers: {
2070
2095
  "Content-Type": "application/json",
2071
- Authorization: "Bearer " + r.token
2096
+ Authorization: "Bearer " + o.token
2072
2097
  }
2073
2098
  })).json();
2074
2099
  return e.items, e.items.map(
2075
- (t) => new L(
2100
+ (t) => new E(
2076
2101
  t.id,
2077
2102
  t.name,
2078
2103
  t.organizationId,
@@ -2080,8 +2105,8 @@ async function B() {
2080
2105
  )
2081
2106
  );
2082
2107
  }
2083
- async function wt(a) {
2084
- if (!r.token)
2108
+ async function vt(a) {
2109
+ if (!o.token)
2085
2110
  throw new Error("Not authenticated");
2086
2111
  return (await (await fetch(
2087
2112
  `${h}/v1/admin/events/query/id=${a}`,
@@ -2089,12 +2114,12 @@ async function wt(a) {
2089
2114
  method: "GET",
2090
2115
  headers: {
2091
2116
  "Content-Type": "application/json",
2092
- Authorization: "Bearer " + r.token
2117
+ Authorization: "Bearer " + o.token
2093
2118
  }
2094
2119
  }
2095
2120
  )).json()).items;
2096
2121
  }
2097
- async function pt(a) {
2122
+ async function Tt(a) {
2098
2123
  const t = await (await fetch(`${h}/v1/admin/files/query`, {
2099
2124
  method: "POST",
2100
2125
  body: JSON.stringify({
@@ -2102,37 +2127,37 @@ async function pt(a) {
2102
2127
  }),
2103
2128
  headers: {
2104
2129
  "Content-Type": "application/json",
2105
- Authorization: "Bearer " + r.token
2130
+ Authorization: "Bearer " + o.token
2106
2131
  }
2107
2132
  })).json();
2108
2133
  if (t.fileUrls.length === 0)
2109
2134
  throw new Error("File not found");
2110
2135
  return t.fileUrls[0];
2111
2136
  }
2112
- async function yt(a) {
2113
- if (!r.token)
2137
+ async function Ct(a) {
2138
+ if (!o.token)
2114
2139
  throw new Error("Not authenticated");
2115
2140
  return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
2116
2141
  method: "GET",
2117
2142
  headers: {
2118
2143
  "Content-Type": "application/json",
2119
- Authorization: "Bearer " + r.token
2144
+ Authorization: "Bearer " + o.token
2120
2145
  }
2121
2146
  })).json();
2122
2147
  }
2123
- async function gt(a) {
2124
- if (!r.token)
2148
+ async function St(a) {
2149
+ if (!o.token)
2125
2150
  throw new Error("Not authenticated");
2126
2151
  return (await (await fetch(`${h}/v1/admin/fleets/${a}/devices`, {
2127
2152
  method: "GET",
2128
2153
  headers: {
2129
2154
  "Content-Type": "application/json",
2130
- Authorization: "Bearer " + r.token
2155
+ Authorization: "Bearer " + o.token
2131
2156
  }
2132
2157
  })).json()).items;
2133
2158
  }
2134
- async function vt() {
2135
- if (!r.token)
2159
+ async function Et() {
2160
+ if (!o.token)
2136
2161
  throw new Error("Not authenticated");
2137
2162
  return (await (await fetch(
2138
2163
  `${h}/v1/admin/intervention-requests`,
@@ -2140,12 +2165,12 @@ async function vt() {
2140
2165
  method: "GET",
2141
2166
  headers: {
2142
2167
  "Content-Type": "application/json",
2143
- Authorization: "Bearer " + r.token
2168
+ Authorization: "Bearer " + o.token
2144
2169
  }
2145
2170
  }
2146
2171
  )).json()).items;
2147
2172
  }
2148
- async function Tt(...a) {
2173
+ async function kt(...a) {
2149
2174
  const e = a.flat().filter((i) => !!i);
2150
2175
  return e.length === 0 ? [] : (await (await fetch(
2151
2176
  `${h}/v1/queries/stream-current-value`,
@@ -2156,52 +2181,52 @@ async function Tt(...a) {
2156
2181
  }),
2157
2182
  headers: {
2158
2183
  "Content-Type": "application/json",
2159
- Authorization: "Bearer " + r.token
2184
+ Authorization: "Bearer " + o.token
2160
2185
  }
2161
2186
  }
2162
2187
  )).json()).items;
2163
2188
  }
2164
- async function Ct() {
2165
- if (!r.token)
2189
+ async function Ot() {
2190
+ if (!o.token)
2166
2191
  throw new Error("Not authenticated");
2167
2192
  const t = (await (await fetch(`${h}/v1/queries/online-devices`, {
2168
2193
  method: "GET",
2169
2194
  headers: {
2170
2195
  "Content-Type": "application/json",
2171
- Authorization: "Bearer " + r.token
2196
+ Authorization: "Bearer " + o.token
2172
2197
  }
2173
2198
  })).json()).items;
2174
2199
  return (await B()).filter((i) => t.includes(i.id));
2175
2200
  }
2176
- async function St() {
2177
- if (!r.token)
2201
+ async function Rt() {
2202
+ if (!o.token)
2178
2203
  throw new Error("Not authenticated");
2179
2204
  const t = (await (await fetch(`${h}/v1/signaling/peers`, {
2180
2205
  method: "GET",
2181
2206
  headers: {
2182
2207
  "Content-Type": "application/json",
2183
- Authorization: "Bearer " + r.token
2208
+ Authorization: "Bearer " + o.token
2184
2209
  }
2185
2210
  })).json()).items.map(
2186
2211
  (i) => i.deviceId
2187
2212
  );
2188
2213
  return (await B()).filter((i) => t.includes(i.id));
2189
2214
  }
2190
- async function Et() {
2191
- if (!r.token)
2215
+ async function bt() {
2216
+ if (!o.token)
2192
2217
  throw new Error("Not authenticated");
2193
2218
  return (await (await fetch(`${h}/v1/admin/streams`, {
2194
2219
  method: "GET",
2195
2220
  headers: {
2196
2221
  "Content-Type": "application/json",
2197
- Authorization: "Bearer " + r.token
2222
+ Authorization: "Bearer " + o.token
2198
2223
  }
2199
2224
  })).json()).items.filter(
2200
2225
  (t) => t.enabled
2201
2226
  );
2202
2227
  }
2203
- async function kt(a) {
2204
- if (!r.token)
2228
+ async function Dt(a) {
2229
+ if (!o.token)
2205
2230
  throw new Error("Not authenticated");
2206
2231
  return await (await fetch(
2207
2232
  `${h}/v1/queries/analytics/task-report-rows`,
@@ -2210,13 +2235,13 @@ async function kt(a) {
2210
2235
  body: JSON.stringify(a),
2211
2236
  headers: {
2212
2237
  "Content-Type": "application/json",
2213
- Authorization: "Bearer " + r.token
2238
+ Authorization: "Bearer " + o.token
2214
2239
  }
2215
2240
  }
2216
2241
  )).json();
2217
2242
  }
2218
- async function Rt() {
2219
- if (!r.token)
2243
+ async function At() {
2244
+ if (!o.token)
2220
2245
  throw new Error("Not authenticated");
2221
2246
  return (await (await fetch(
2222
2247
  `${h}/v1/queries/analytics/task-reports`,
@@ -2224,36 +2249,36 @@ async function Rt() {
2224
2249
  method: "GET",
2225
2250
  headers: {
2226
2251
  "Content-Type": "application/json",
2227
- Authorization: "Bearer " + r.token
2252
+ Authorization: "Bearer " + o.token
2228
2253
  }
2229
2254
  }
2230
2255
  )).json()).items;
2231
2256
  }
2232
- async function Ot() {
2233
- if (!r.token)
2257
+ async function Pt() {
2258
+ if (!o.token)
2234
2259
  throw new Error("Not authenticated");
2235
2260
  return (await (await fetch(`${h}/v1/admin/fleets`, {
2236
2261
  method: "GET",
2237
2262
  headers: {
2238
2263
  "Content-Type": "application/json",
2239
- Authorization: "Bearer " + r.token
2264
+ Authorization: "Bearer " + o.token
2240
2265
  }
2241
2266
  })).json()).items;
2242
2267
  }
2243
- async function bt(a, e) {
2244
- if (!r.token)
2268
+ async function Nt(a, e) {
2269
+ if (!o.token)
2245
2270
  throw new Error("Not authenticated");
2246
2271
  return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
2247
2272
  method: "PATCH",
2248
2273
  body: JSON.stringify(e),
2249
2274
  headers: {
2250
2275
  "Content-Type": "application/json",
2251
- Authorization: "Bearer " + r.token
2276
+ Authorization: "Bearer " + o.token
2252
2277
  }
2253
2278
  })).json();
2254
2279
  }
2255
- async function At(a) {
2256
- if (!r.token)
2280
+ async function jt(a) {
2281
+ if (!o.token)
2257
2282
  throw new Error("Not authenticated");
2258
2283
  return await (await fetch(
2259
2284
  `${h}/v1/admin/streams/${a.id}`,
@@ -2262,32 +2287,32 @@ async function At(a) {
2262
2287
  body: JSON.stringify(a),
2263
2288
  headers: {
2264
2289
  "Content-Type": "application/json",
2265
- Authorization: "Bearer " + r.token
2290
+ Authorization: "Bearer " + o.token
2266
2291
  }
2267
2292
  }
2268
2293
  )).json();
2269
2294
  }
2270
- async function Dt(a) {
2271
- if (!r.token)
2295
+ async function It(a) {
2296
+ if (!o.token)
2272
2297
  throw new Error("Not authenticated");
2273
2298
  return await (await fetch(`${h}/v1/admin/views/${a.id}`, {
2274
2299
  method: "PATCH",
2275
2300
  body: JSON.stringify(a),
2276
2301
  headers: {
2277
2302
  "Content-Type": "application/json",
2278
- Authorization: "Bearer " + r.token
2303
+ Authorization: "Bearer " + o.token
2279
2304
  }
2280
2305
  })).json();
2281
2306
  }
2282
- async function Pt(a) {
2283
- if (!r.token)
2307
+ async function Lt(a) {
2308
+ if (!o.token)
2284
2309
  throw new Error("Not authenticated");
2285
2310
  return await (await fetch(`${h}/v1/queries/analytics`, {
2286
2311
  method: "POST",
2287
2312
  body: JSON.stringify(a),
2288
2313
  headers: {
2289
2314
  "Content-Type": "application/json",
2290
- Authorization: "Bearer " + r.token
2315
+ Authorization: "Bearer " + o.token
2291
2316
  }
2292
2317
  })).json();
2293
2318
  }
@@ -2296,7 +2321,7 @@ const S = class {
2296
2321
  S.defaultDeviceId = e;
2297
2322
  }
2298
2323
  static async getCurrentDevice() {
2299
- if (!r.token)
2324
+ if (!o.token)
2300
2325
  throw new Error("Not authenticated");
2301
2326
  if (!S.defaultDeviceId)
2302
2327
  throw new Error("No known default device");
@@ -2306,48 +2331,48 @@ const S = class {
2306
2331
  method: "POST",
2307
2332
  headers: {
2308
2333
  "Content-Type": "application/json",
2309
- Authorization: "Bearer " + r.token
2334
+ Authorization: "Bearer " + o.token
2310
2335
  }
2311
2336
  }
2312
2337
  )).json()).items.find(
2313
2338
  (c) => c.id === S.defaultDeviceId
2314
- ), i = n.name, o = new L(
2339
+ ), i = n.name, r = new E(
2315
2340
  S.defaultDeviceId,
2316
2341
  i,
2317
- f(r.currentOrganization),
2342
+ f(o.currentOrganization),
2318
2343
  n.tags
2319
2344
  );
2320
- return S.knownContext.push(new WeakRef(o)), o;
2345
+ return S.knownContext.push(new WeakRef(r)), r;
2321
2346
  }
2322
2347
  static async getPeerDevice(e) {
2323
- const t = new rt(e);
2348
+ const t = new ht(e);
2324
2349
  return t.id = await t.getDeviceId(), t;
2325
2350
  }
2326
2351
  static async getDevice(e) {
2327
- const t = await ft(e);
2352
+ const t = await gt(e);
2328
2353
  return S.knownContext.push(new WeakRef(t)), t;
2329
2354
  }
2330
2355
  };
2331
2356
  let l = S;
2332
- s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "listFleets", Ot), s(l, "getFleet", yt), s(l, "patchFleet", bt), s(l, "deleteFleet", dt), s(l, "addDeviceToFleet", st), s(l, "getFleetDevices", gt), s(l, "aggregateTelemetry", ct), s(l, "createShareLink", X), s(l, "eventsCounter", Z), s(l, "getAnalyticStreams", ht), s(l, "getAnalyticsModules", lt), s(l, "getAnalyticsRows", ut), s(l, "getAnnotationCount", z), s(l, "getAnnotationCountByIntervals", ee), s(l, "getCurrentGroup", mt), s(l, "getDevices", B), s(l, "getEvent", wt), s(l, "getFileUrl", pt), s(l, "getInterventions", vt), s(l, "getLatestTelemetry", Tt), s(l, "getOnlineDevices", Ct), s(l, "getPeers", ae), s(l, "getRealtimeDevices", St), s(l, "getRealtimeSessions", ne), s(l, "getStreams", Et), s(l, "getTaskReportRows", kt), s(l, "getTaskReportTables", Rt), s(l, "getTelemetry", te), s(l, "getViews", Q), s(l, "patchStream", At), s(l, "patchView", Dt), s(l, "queryAnalytics", Pt), s(l, "queryDevices", ie), s(l, "queryEvents", M), s(l, "queryTelemetry", _);
2333
- class Vt {
2357
+ s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "listFleets", Pt), s(l, "getFleet", Ct), s(l, "patchFleet", Nt), s(l, "deleteFleet", mt), s(l, "addDeviceToFleet", lt), s(l, "getFleetDevices", St), s(l, "aggregateTelemetry", ut), s(l, "createShareLink", X), s(l, "eventsCounter", Z), s(l, "getAnalyticStreams", ft), s(l, "getAnalyticsModules", wt), s(l, "getAnalyticsRows", pt), s(l, "getAnnotationCount", M), s(l, "getAnnotationCountByIntervals", ee), s(l, "getCurrentGroup", yt), s(l, "getDevices", B), s(l, "getEvent", vt), s(l, "getFileUrl", Tt), s(l, "getInterventions", Et), s(l, "getLatestTelemetry", kt), s(l, "getOnlineDevices", Ot), s(l, "getPeers", ae), s(l, "getRealtimeDevices", Rt), s(l, "getRealtimeSessions", ne), s(l, "getStreams", bt), s(l, "getTaskReportRows", Dt), s(l, "getTaskReportTables", At), s(l, "getTelemetry", te), s(l, "getViews", Q), s(l, "patchStream", jt), s(l, "patchView", It), s(l, "queryAnalytics", Lt), s(l, "queryDevices", ie), s(l, "queryEvents", z), s(l, "queryTelemetry", _);
2358
+ class Ht {
2334
2359
  static async set(e, t, n) {
2335
2360
  try {
2336
2361
  const i = await fetch(h + "/v1/admin/key-value", {
2337
2362
  method: "POST",
2338
2363
  body: JSON.stringify({
2339
- organizationId: f(r.currentUser).organizationId,
2364
+ organizationId: f(o.currentUser).organizationId,
2340
2365
  key: e,
2341
2366
  value: t,
2342
2367
  tags: n
2343
2368
  }),
2344
2369
  headers: {
2345
2370
  "Content-Type": "application/json",
2346
- Authorization: "Bearer " + r.token
2371
+ Authorization: "Bearer " + o.token
2347
2372
  }
2348
- }), o = await i.json();
2373
+ }), r = await i.json();
2349
2374
  if (i.status !== 200)
2350
- throw new Error(o.message);
2375
+ throw new Error(r.message);
2351
2376
  } catch (i) {
2352
2377
  throw i;
2353
2378
  }
@@ -2360,7 +2385,7 @@ class Vt {
2360
2385
  method: "GET",
2361
2386
  headers: {
2362
2387
  "Content-Type": "application/json",
2363
- Authorization: "Bearer " + r.token
2388
+ Authorization: "Bearer " + o.token
2364
2389
  }
2365
2390
  }
2366
2391
  ), n = await t.json();
@@ -2377,7 +2402,7 @@ class Vt {
2377
2402
  method: "GET",
2378
2403
  headers: {
2379
2404
  "Content-Type": "application/json",
2380
- Authorization: "Bearer " + r.token
2405
+ Authorization: "Bearer " + o.token
2381
2406
  }
2382
2407
  }), t = await e.json();
2383
2408
  if (e.status !== 200)
@@ -2395,7 +2420,7 @@ class Vt {
2395
2420
  method: "DELETE",
2396
2421
  headers: {
2397
2422
  "Content-Type": "application/json",
2398
- Authorization: "Bearer " + r.token
2423
+ Authorization: "Bearer " + o.token
2399
2424
  }
2400
2425
  }
2401
2426
  )).ok)
@@ -2406,15 +2431,15 @@ class Vt {
2406
2431
  }
2407
2432
  }
2408
2433
  }
2409
- function Nt(a) {
2434
+ function _t(a) {
2410
2435
  return Uint8Array.from(atob(a), (e) => e.charCodeAt(0));
2411
2436
  }
2412
2437
  function U() {
2413
2438
  const { userAgent: a } = navigator;
2414
2439
  return a ? a.includes("Firefox/") ? "Firefox" : a.includes("Edg/") ? "Edge" : a.includes("Chrome/") ? "Chrome" : a.includes("Safari/") ? "Safari" : a.includes("MSIE/") || a.includes("Trident/") ? "IE" : "Other" : "Other";
2415
2440
  }
2416
- const It = "audio-chunk";
2417
- class Ft {
2441
+ const $t = "audio-chunk";
2442
+ class Kt {
2418
2443
  constructor(e, t) {
2419
2444
  s(this, "muted", !1);
2420
2445
  s(this, "hasReceivedData", !1);
@@ -2431,12 +2456,12 @@ class Ft {
2431
2456
  return;
2432
2457
  this.hasReceivedData || (this.hasReceivedData = !0);
2433
2458
  const { audioContext: n, muted: i } = this;
2434
- if (!n || e.header.stream.streamType !== It || i !== !1)
2459
+ if (!n || e.header.stream.streamType !== $t || i !== !1)
2435
2460
  return;
2436
- const o = Nt(t);
2461
+ const r = _t(t);
2437
2462
  try {
2438
2463
  await n.decodeAudioData(
2439
- o.buffer,
2464
+ r.buffer,
2440
2465
  this.scheduleChunk
2441
2466
  );
2442
2467
  } catch (d) {
@@ -2456,8 +2481,8 @@ class Ft {
2456
2481
  const n = this.createChunk(e);
2457
2482
  n && n.buffer && (this.isPlaying === !1 && (this.startTime = t.currentTime, this.lastChunkOffset = 0, this.isPlaying = !0), n.start(this.startTime + this.lastChunkOffset, 0, e.duration), this.lastChunkOffset += n.buffer.duration, this.chunks.push(n));
2458
2483
  });
2459
- this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, o) => {
2460
- this.receive(o);
2484
+ this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, r) => {
2485
+ this.receive(r);
2461
2486
  }), U() === "Safari" || U() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
2462
2487
  const n = window.AudioContext || window.webkitAudioContext;
2463
2488
  this.audioContext = new n();
@@ -2486,66 +2511,66 @@ class Ft {
2486
2511
  (async () => await this.device.changeStreamAudioType(t.name, e))();
2487
2512
  }
2488
2513
  }
2489
- class Wt {
2514
+ class Qt {
2490
2515
  static async listAccounts() {
2491
- if (!r.token)
2516
+ if (!o.token)
2492
2517
  throw new Error("Not authenticated");
2493
2518
  return (await (await fetch(`${h}/v1/admin/accounts`, {
2494
2519
  method: "GET",
2495
2520
  headers: {
2496
2521
  "Content-Type": "application/json",
2497
- Authorization: "Bearer " + r.token
2522
+ Authorization: "Bearer " + o.token
2498
2523
  }
2499
2524
  })).json()).items;
2500
2525
  }
2501
2526
  static async createAccounts(e) {
2502
- if (!r.token)
2527
+ if (!o.token)
2503
2528
  throw new Error("Not authenticated");
2504
2529
  return await (await fetch(`${h}/v1/admin/accounts`, {
2505
2530
  method: "POST",
2506
2531
  body: JSON.stringify(e),
2507
2532
  headers: {
2508
2533
  "Content-Type": "application/json",
2509
- Authorization: "Bearer " + r.token
2534
+ Authorization: "Bearer " + o.token
2510
2535
  }
2511
2536
  })).json();
2512
2537
  }
2513
2538
  static async getAccount(e) {
2514
- if (!r.token)
2539
+ if (!o.token)
2515
2540
  throw new Error("Not authenticated");
2516
2541
  return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
2517
2542
  method: "GET",
2518
2543
  headers: {
2519
2544
  "Content-Type": "application/json",
2520
- Authorization: "Bearer " + r.token
2545
+ Authorization: "Bearer " + o.token
2521
2546
  }
2522
2547
  })).json();
2523
2548
  }
2524
2549
  static async patchAccount(e, t) {
2525
- if (!r.token)
2550
+ if (!o.token)
2526
2551
  throw new Error("Not authenticated");
2527
2552
  return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
2528
2553
  method: "PATCH",
2529
2554
  body: JSON.stringify(t),
2530
2555
  headers: {
2531
2556
  "Content-Type": "application/json",
2532
- Authorization: "Bearer " + r.token
2557
+ Authorization: "Bearer " + o.token
2533
2558
  }
2534
2559
  })).json();
2535
2560
  }
2536
2561
  static async deleteAccount(e) {
2537
- if (!r.token)
2562
+ if (!o.token)
2538
2563
  throw new Error("Not authenticated");
2539
2564
  await fetch(`${h}/v1/admin/accounts/${e}`, {
2540
2565
  method: "DELETE",
2541
2566
  headers: {
2542
2567
  "Content-Type": "application/json",
2543
- Authorization: "Bearer " + r.token
2568
+ Authorization: "Bearer " + o.token
2544
2569
  }
2545
2570
  });
2546
2571
  }
2547
2572
  static async getAccountTree(e) {
2548
- if (!r.token)
2573
+ if (!o.token)
2549
2574
  throw new Error("Not authenticated");
2550
2575
  return await (await fetch(
2551
2576
  `${h}/v1/admin/accounts/${e}/tree`,
@@ -2553,139 +2578,139 @@ class Wt {
2553
2578
  method: "GET",
2554
2579
  headers: {
2555
2580
  "Content-Type": "application/json",
2556
- Authorization: "Bearer " + r.token
2581
+ Authorization: "Bearer " + o.token
2557
2582
  }
2558
2583
  }
2559
2584
  )).json();
2560
2585
  }
2561
2586
  }
2562
- class Gt {
2587
+ class Xt {
2563
2588
  static async listRoles() {
2564
- if (!r.token)
2589
+ if (!o.token)
2565
2590
  throw new Error("Not authenticated");
2566
2591
  return (await (await fetch(`${h}/v1/admin/roles`, {
2567
2592
  method: "GET",
2568
2593
  headers: {
2569
2594
  "Content-Type": "application/json",
2570
- Authorization: "Bearer " + r.token
2595
+ Authorization: "Bearer " + o.token
2571
2596
  }
2572
2597
  })).json()).items;
2573
2598
  }
2574
2599
  static async createRole(e) {
2575
- if (!r.token)
2600
+ if (!o.token)
2576
2601
  throw new Error("Not authenticated");
2577
2602
  return await (await fetch(`${h}/v1/admin/roles`, {
2578
2603
  method: "POST",
2579
2604
  body: JSON.stringify(e),
2580
2605
  headers: {
2581
2606
  "Content-Type": "application/json",
2582
- Authorization: "Bearer " + r.token
2607
+ Authorization: "Bearer " + o.token
2583
2608
  }
2584
2609
  })).json();
2585
2610
  }
2586
2611
  static async getRole(e) {
2587
- if (!r.token)
2612
+ if (!o.token)
2588
2613
  throw new Error("Not authenticated");
2589
2614
  return await (await fetch(`${h}/v1/admin/roles/${e}`, {
2590
2615
  method: "GET",
2591
2616
  headers: {
2592
2617
  "Content-Type": "application/json",
2593
- Authorization: "Bearer " + r.token
2618
+ Authorization: "Bearer " + o.token
2594
2619
  }
2595
2620
  })).json();
2596
2621
  }
2597
2622
  static async patchRole(e, t) {
2598
- if (!r.token)
2623
+ if (!o.token)
2599
2624
  throw new Error("Not authenticated");
2600
2625
  return await (await fetch(`${h}/v1/admin/roles/${e}`, {
2601
2626
  method: "PATCH",
2602
2627
  body: JSON.stringify(t),
2603
2628
  headers: {
2604
2629
  "Content-Type": "application/json",
2605
- Authorization: "Bearer " + r.token
2630
+ Authorization: "Bearer " + o.token
2606
2631
  }
2607
2632
  })).json();
2608
2633
  }
2609
2634
  static async deleteRole(e) {
2610
- if (!r.token)
2635
+ if (!o.token)
2611
2636
  throw new Error("Not authenticated");
2612
2637
  await fetch(`${h}/v1/admin/roles/${e}`, {
2613
2638
  method: "DELETE",
2614
2639
  headers: {
2615
2640
  "Content-Type": "application/json",
2616
- Authorization: "Bearer " + r.token
2641
+ Authorization: "Bearer " + o.token
2617
2642
  }
2618
2643
  });
2619
2644
  }
2620
2645
  }
2621
- class Ht {
2646
+ class Yt {
2622
2647
  static async listUsers() {
2623
- if (!r.token)
2648
+ if (!o.token)
2624
2649
  throw new Error("Not authenticated");
2625
2650
  return (await (await fetch(`${h}/v1/admin/users`, {
2626
2651
  method: "GET",
2627
2652
  headers: {
2628
2653
  "Content-Type": "application/json",
2629
- Authorization: "Bearer " + r.token
2654
+ Authorization: "Bearer " + o.token
2630
2655
  }
2631
2656
  })).json()).items;
2632
2657
  }
2633
2658
  static async createUser(e) {
2634
- if (!r.token)
2659
+ if (!o.token)
2635
2660
  throw new Error("Not authenticated");
2636
2661
  return await (await fetch(`${h}/v1/admin/users`, {
2637
2662
  method: "POST",
2638
2663
  body: JSON.stringify(e),
2639
2664
  headers: {
2640
2665
  "Content-Type": "application/json",
2641
- Authorization: "Bearer " + r.token
2666
+ Authorization: "Bearer " + o.token
2642
2667
  }
2643
2668
  })).json();
2644
2669
  }
2645
2670
  static async getUser(e) {
2646
- if (!r.token)
2671
+ if (!o.token)
2647
2672
  throw new Error("Not authenticated");
2648
2673
  return await (await fetch(`${h}/v1/admin/users/${e}`, {
2649
2674
  method: "GET",
2650
2675
  headers: {
2651
2676
  "Content-Type": "application/json",
2652
- Authorization: "Bearer " + r.token
2677
+ Authorization: "Bearer " + o.token
2653
2678
  }
2654
2679
  })).json();
2655
2680
  }
2656
2681
  static async patchUser(e, t) {
2657
- if (!r.token)
2682
+ if (!o.token)
2658
2683
  throw new Error("Not authenticated");
2659
2684
  return await (await fetch(`${h}/v1/admin/users/${e}`, {
2660
2685
  method: "PATCH",
2661
2686
  body: JSON.stringify(t),
2662
2687
  headers: {
2663
2688
  "Content-Type": "application/json",
2664
- Authorization: "Bearer " + r.token
2689
+ Authorization: "Bearer " + o.token
2665
2690
  }
2666
2691
  })).json();
2667
2692
  }
2668
2693
  static async deleteUser(e) {
2669
- if (!r.token)
2694
+ if (!o.token)
2670
2695
  throw new Error("Not authenticated");
2671
2696
  await fetch(`${h}/v1/admin/users/${e}`, {
2672
2697
  method: "PATCH",
2673
2698
  body: JSON.stringify({ enabled: !1, roleId: null, teamId: null }),
2674
2699
  headers: {
2675
2700
  "Content-Type": "application/json",
2676
- Authorization: "Bearer " + r.token
2701
+ Authorization: "Bearer " + o.token
2677
2702
  }
2678
2703
  });
2679
2704
  }
2680
2705
  }
2681
- const Kt = ["viewer", "operator", "administrator"], Qt = "viewer", Xt = "operator", Yt = "administrator", Zt = [
2706
+ const Zt = ["viewer", "operator", "administrator"], en = "viewer", tn = "operator", nn = "administrator", an = [
2682
2707
  "year",
2683
2708
  "month",
2684
2709
  "week",
2685
2710
  "day",
2686
2711
  "hour",
2687
2712
  "minute"
2688
- ], en = ["tag", "sheet", "user"], tn = [
2713
+ ], on = ["tag", "sheet", "user"], rn = [
2689
2714
  "triggered-event",
2690
2715
  "intervention-request",
2691
2716
  "teleop-session-record",
@@ -2697,44 +2722,44 @@ const Kt = ["viewer", "operator", "administrator"], Qt = "viewer", Xt = "operato
2697
2722
  "comment",
2698
2723
  "system",
2699
2724
  "annotation"
2700
- ], nn = [
2725
+ ], sn = [
2701
2726
  "unknown",
2702
2727
  "operational",
2703
2728
  "offline",
2704
2729
  "error"
2705
- ], an = ["selection", "labeling", "teleop"], on = ["info", "warning", "error", "critical"], rn = ["video/mp4"];
2730
+ ], cn = ["selection", "labeling", "teleop"], dn = ["info", "warning", "error", "critical"], hn = ["video/mp4"];
2706
2731
  try {
2707
2732
  const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
2708
2733
  e && l.setDefaultDevice(e);
2709
2734
  const t = a.get("auth");
2710
- t && r.loginWithToken(t), a.get("module") && r.listenForRefresh(), typeof window < "u" && y.listenForConnectionEvents();
2735
+ t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && y.listenForConnectionEvents();
2711
2736
  } catch {
2712
2737
  }
2713
2738
  export {
2714
- Wt as Account,
2739
+ Qt as Account,
2715
2740
  y as App,
2716
- Ft as AudioPlayer,
2717
- r as Authentication,
2741
+ Kt as AudioPlayer,
2742
+ o as Authentication,
2718
2743
  He as BinaryRequestDataChannel,
2719
2744
  Ve as CaptureStream,
2720
2745
  We as DataChannel,
2721
- L as Device,
2746
+ E as Device,
2722
2747
  l as Fleet,
2723
- Vt as KeyValue,
2748
+ Ht as KeyValue,
2724
2749
  Ge as Manipulator,
2725
- rt as PeerDevice,
2726
- Gt as Role,
2727
- qt as SessionType,
2750
+ ht as PeerDevice,
2751
+ Xt as Role,
2752
+ Vt as SessionType,
2728
2753
  Ke as TextRequestDataChannel,
2729
- Ht as User,
2730
- Kt as accessLevels,
2731
- Yt as administrator,
2754
+ Yt as User,
2755
+ Zt as accessLevels,
2756
+ nn as administrator,
2732
2757
  Y as aggregateByDateFunctions,
2733
- Jt as aggregateFunctionMap,
2734
- Ut as aggregateFunctions,
2735
- Zt as aggregateLevels,
2736
- en as annotationTypes,
2737
- tn as eventTypes,
2758
+ Gt as aggregateFunctionMap,
2759
+ Wt as aggregateFunctions,
2760
+ an as aggregateLevels,
2761
+ on as annotationTypes,
2762
+ rn as eventTypes,
2738
2763
  ot as formatTimeFrameText,
2739
2764
  nt as getAverage,
2740
2765
  it as getCount,
@@ -2743,12 +2768,12 @@ export {
2743
2768
  Ze as getStandardDeviation,
2744
2769
  at as getSum,
2745
2770
  Ye as getVariance,
2746
- nn as healthStatuses,
2747
- an as interventionTypes,
2748
- Xt as operator,
2749
- on as severities,
2750
- xt as vailableAggregationIntervals,
2751
- rn as videoMimeTypes,
2752
- Qt as viewer
2771
+ sn as healthStatuses,
2772
+ cn as interventionTypes,
2773
+ tn as operator,
2774
+ dn as severities,
2775
+ Ft as vailableAggregationIntervals,
2776
+ hn as videoMimeTypes,
2777
+ en as viewer
2753
2778
  };
2754
2779
  //# sourceMappingURL=data-sdk.es.js.map