@formant/data-sdk 1.11.0 → 1.12.0

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.
@@ -1,11 +1,11 @@
1
1
  var re = Object.defineProperty;
2
2
  var se = (a, e, t) => e in a ? re(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var s = (a, e, t) => (se(a, typeof e != "symbol" ? e + "" : e, t), t);
3
+ var r = (a, e, t) => (se(a, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  import { decode as J } from "base-64";
5
- import * as u from "date-fns";
6
- import { startOfMinute as ce, addMinutes as de, roundToNearestMinutes as he, addSeconds as le } from "date-fns";
7
- import { RtcClient as D, SignalingPromiseClient as P } from "@formant/realtime-sdk";
8
- import { EventEmitter as ue } from "eventemitter3";
5
+ import * as l from "date-fns";
6
+ import { startOfMinute as ce, addMinutes as de, roundToNearestMinutes as he, addSeconds as ue } from "date-fns";
7
+ import { RtcClient as A, SignalingPromiseClient as j } from "@formant/realtime-sdk";
8
+ import { EventEmitter as le } from "eventemitter3";
9
9
  import { deflate as me } from "pako";
10
10
  import { fromByteArray as fe } from "base64-js";
11
11
  const we = "https://api.formant.io";
@@ -44,17 +44,17 @@ class ye {
44
44
  refreshAuthToken: t,
45
45
  addAccessTokenRefreshListener: n
46
46
  }) {
47
- s(this, "_refreshToken");
48
- s(this, "_isShareToken", !1);
49
- s(this, "_currentOrganization");
50
- s(this, "_currentUser");
51
- s(this, "_defaultDeviceId");
52
- s(this, "_token");
53
- s(this, "_waitingForAuth", /* @__PURE__ */ new Set());
54
- s(this, "_refreshTimer");
55
- s(this, "_apiUrl");
56
- s(this, "_refreshAuthToken");
57
- s(this, "_addAccessTokenRefreshListener");
47
+ r(this, "_refreshToken");
48
+ r(this, "_isShareToken", !1);
49
+ r(this, "_currentOrganization");
50
+ r(this, "_currentUser");
51
+ r(this, "_defaultDeviceId");
52
+ r(this, "_token");
53
+ r(this, "_waitingForAuth", /* @__PURE__ */ new Set());
54
+ r(this, "_refreshTimer");
55
+ r(this, "_apiUrl");
56
+ r(this, "_refreshAuthToken");
57
+ r(this, "_addAccessTokenRefreshListener");
58
58
  this._apiUrl = e, this._refreshAuthToken = t, this._addAccessTokenRefreshListener = n;
59
59
  }
60
60
  get token() {
@@ -104,9 +104,9 @@ class ye {
104
104
  var i;
105
105
  const n = JSON.parse(J(e.split(".")[1]));
106
106
  try {
107
- let r;
108
- 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) {
109
- const c = await fetch(`${this._apiUrl}/v1/admin/users/${r}`, {
107
+ let s;
108
+ 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 || (s = n.sub), n["formant:claims"] && n["formant:claims"].userId && (s = n["formant:claims"].userId), s && ((i = this._currentUser) == null ? void 0 : i.id) !== s) {
109
+ const c = await fetch(`${this._apiUrl}/v1/admin/users/${s}`, {
110
110
  method: "GET",
111
111
  headers: {
112
112
  "Content-Type": "application/json",
@@ -118,8 +118,8 @@ class ye {
118
118
  this._currentUser = d;
119
119
  }
120
120
  this._token = e, this._waitingForAuth.forEach((c) => c(!0));
121
- } catch (r) {
122
- console.error("loginWithToken() failed", { err: r }), this._waitingForAuth.forEach((c) => c(!1));
121
+ } catch (s) {
122
+ console.error("loginWithToken() failed", { err: s }), this._waitingForAuth.forEach((c) => c(!1));
123
123
  } finally {
124
124
  this._waitingForAuth.clear();
125
125
  }
@@ -241,7 +241,7 @@ function V() {
241
241
  module: a
242
242
  });
243
243
  }
244
- function F(a) {
244
+ function G(a) {
245
245
  function e(t) {
246
246
  const n = t.data;
247
247
  n.type === "auth_token" && a(n.token);
@@ -253,7 +253,7 @@ function F(a) {
253
253
  const o = new ye({
254
254
  apiUrl: h,
255
255
  refreshAuthToken: V,
256
- addAccessTokenRefreshListener: F
256
+ addAccessTokenRefreshListener: G
257
257
  });
258
258
  async function ge(a) {
259
259
  return (await (await fetch(
@@ -327,7 +327,7 @@ function Oe(a) {
327
327
  function Re(a) {
328
328
  T({ type: "show_message", message: a });
329
329
  }
330
- function be(a, e) {
330
+ function Ae(a, e) {
331
331
  const t = (n) => {
332
332
  const i = n.data;
333
333
  i.type === "channel_data" && i.channel === a && e({
@@ -337,7 +337,7 @@ function be(a, e) {
337
337
  };
338
338
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
339
339
  }
340
- function Ae(a) {
340
+ function be(a) {
341
341
  const e = (t) => {
342
342
  const n = t.data;
343
343
  n.type === "module_menu_item_clicked" && a(n.menu);
@@ -351,7 +351,7 @@ function De(a) {
351
351
  };
352
352
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
353
353
  }
354
- function Pe(a) {
354
+ function je(a) {
355
355
  const e = k();
356
356
  e && T({ type: "request_module_data", module: e });
357
357
  const t = (n) => {
@@ -364,7 +364,7 @@ function Pe(a) {
364
364
  };
365
365
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
366
366
  }
367
- function je(a) {
367
+ function Ne(a) {
368
368
  T({ type: "request_devices" });
369
369
  const e = (t) => {
370
370
  const n = t.data;
@@ -372,14 +372,14 @@ function je(a) {
372
372
  };
373
373
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
374
374
  }
375
- const Ne = 1, W = 1e3, G = 60 * W, H = 60 * G, I = 24 * H, Ie = 7 * I, Le = 30 * I, _e = 365 * I, L = {
376
- millisecond: Ne,
377
- second: W,
378
- minute: G,
379
- hour: H,
380
- day: I,
381
- week: Ie,
382
- month: Le,
375
+ const Pe = 1, H = 1e3, F = 60 * H, W = 60 * F, L = 24 * W, Le = 7 * L, Ie = 30 * L, _e = 365 * L, I = {
376
+ millisecond: Pe,
377
+ second: H,
378
+ minute: F,
379
+ hour: W,
380
+ day: L,
381
+ week: Le,
382
+ month: Ie,
383
383
  year: _e
384
384
  };
385
385
  function $e(a, e) {
@@ -387,27 +387,27 @@ function $e(a, e) {
387
387
  }
388
388
  function ze(a, e, t) {
389
389
  const n = e.getTime(), i = t.getTime();
390
- return a.map((r) => ({
391
- ...r,
392
- points: r.points.filter(
390
+ return a.map((s) => ({
391
+ ...s,
392
+ points: s.points.filter(
393
393
  ([c]) => c >= n && c < i
394
394
  )
395
- })).filter(({ points: r }) => r.length > 0);
395
+ })).filter(({ points: s }) => s.length > 0);
396
396
  }
397
397
  class x {
398
398
  constructor({
399
399
  capacity: e,
400
400
  timeout: t
401
401
  } = {}) {
402
- s(this, "entries", /* @__PURE__ */ new Map());
403
- s(this, "metadata", /* @__PURE__ */ new Map());
404
- s(this, "capacity");
405
- s(this, "timeout");
406
- this.capacity = e || 1e4, this.timeout = t || L.minute;
402
+ r(this, "entries", /* @__PURE__ */ new Map());
403
+ r(this, "metadata", /* @__PURE__ */ new Map());
404
+ r(this, "capacity");
405
+ r(this, "timeout");
406
+ this.capacity = e || 1e4, this.timeout = t || I.minute;
407
407
  }
408
408
  get(e, t) {
409
- const n = this.keyToCacheKey(e), i = this.entries.get(n), r = this.metadata.get(n);
410
- 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;
409
+ const n = this.keyToCacheKey(e), i = this.entries.get(n), s = this.metadata.get(n);
410
+ return (i === void 0 || s && (s == null ? void 0 : s.expiration.getTime()) < Date.now()) && !(s != null && s.generating) && t && this.generate(e, t()), i === void 0 && s && s.lastValue !== void 0 ? s.lastValue : i;
411
411
  }
412
412
  set(e, t) {
413
413
  const n = this.keyToCacheKey(e);
@@ -430,7 +430,7 @@ class x {
430
430
  if (this.metadata.size < 1)
431
431
  return;
432
432
  const [e] = [...this.metadata.entries()].reduce(
433
- ([t, n], [i, r]) => r.expiration.getTime() < n.expiration.getTime() ? [i, r] : [t, n]
433
+ ([t, n], [i, s]) => s.expiration.getTime() < n.expiration.getTime() ? [i, s] : [t, n]
434
434
  );
435
435
  this.clearKey(e);
436
436
  }
@@ -441,9 +441,9 @@ class x {
441
441
  generating: !0,
442
442
  expiration: new Date(Date.now() + this.timeout)
443
443
  }), setTimeout(() => {
444
- t.then((r) => {
444
+ t.then((s) => {
445
445
  const c = this.metadata.get(n);
446
- !(c != null && c.generating) || this.set(e, r);
446
+ !(c != null && c.generating) || this.set(e, s);
447
447
  });
448
448
  }, 0);
449
449
  }
@@ -462,32 +462,32 @@ async function _(a) {
462
462
  }
463
463
  class Be {
464
464
  constructor() {
465
- s(this, "queryStoreCache", new x({
465
+ r(this, "queryStoreCache", new x({
466
466
  capacity: 1e4,
467
- timeout: 20 * L.second
467
+ timeout: 20 * I.second
468
468
  }));
469
- s(this, "liveQueryStoreCache", new x({
469
+ r(this, "liveQueryStoreCache", new x({
470
470
  capacity: 1e4,
471
- timeout: 200 * L.millisecond
471
+ timeout: 200 * I.millisecond
472
472
  }));
473
473
  }
474
- moduleQuery(e, t, n, i, r, c = !1) {
474
+ moduleQuery(e, t, n, i, s, c = !1) {
475
475
  const d = {
476
476
  ...e,
477
477
  names: [...t],
478
478
  types: [...n]
479
- }, p = this.query(d, i, r, c);
480
- return p === void 0 || p === "too much data" ? p : $e(p, n);
479
+ }, y = this.query(d, i, s, c);
480
+ return y === void 0 || y === "too much data" ? y : $e(y, n);
481
481
  }
482
482
  query(e, t, n, i = !1) {
483
- const r = {
483
+ const s = {
484
484
  ...e,
485
485
  start: ce(t).toISOString(),
486
486
  end: i ? n.toISOString() : de(he(n), 1).toISOString(),
487
487
  latestOnly: i
488
- }, c = n > le(/* @__PURE__ */ new Date(), -20);
488
+ }, c = n > ue(/* @__PURE__ */ new Date(), -20);
489
489
  let d;
490
- return c ? d = this.liveQueryCache(r) : d = this.queryCache(r), !d || d === "too much data" || i ? d : ze(d, t, n);
490
+ return c ? d = this.liveQueryCache(s) : d = this.queryCache(s), !d || d === "too much data" || i ? d : ze(d, t, n);
491
491
  }
492
492
  queryCache(e) {
493
493
  return this.queryStoreCache.get(e, async () => {
@@ -511,9 +511,9 @@ class Be {
511
511
  const Me = new Be();
512
512
  function qe(a, e, t) {
513
513
  const n = (i) => {
514
- const r = i.data;
515
- if (r.type === "module_data") {
516
- const { start: c, end: d } = r.queryRange;
514
+ const s = i.data;
515
+ if (s.type === "module_data") {
516
+ const { start: c, end: d } = s.queryRange;
517
517
  t(
518
518
  Me.moduleQuery(
519
519
  {},
@@ -536,8 +536,8 @@ async function xe(a, e, t) {
536
536
  maxTime: t,
537
537
  time: a
538
538
  });
539
- const i = (r) => {
540
- const c = r.data;
539
+ const i = (s) => {
540
+ const c = s.data;
541
541
  c.type === "date_response" && (window.removeEventListener("message", i), n(c.data));
542
542
  };
543
543
  window.addEventListener("message", i);
@@ -553,8 +553,8 @@ async function Ue(a, e) {
553
553
  okText: e == null ? void 0 : e.okText,
554
554
  cancelText: e == null ? void 0 : e.cancelText
555
555
  });
556
- const i = (r) => {
557
- const c = r.data;
556
+ const i = (s) => {
557
+ const c = s.data;
558
558
  c.type === "prompt_response" && c.promptId === n && t(c.data), window.removeEventListener("message", i);
559
559
  };
560
560
  window.addEventListener("message", i);
@@ -586,12 +586,12 @@ const q = class {
586
586
  const i = setTimeout(
587
587
  () => n(new Error("deadline expired: took too long")),
588
588
  e
589
- ), r = (c) => {
590
- window.removeEventListener("message", r), clearTimeout(i);
589
+ ), s = (c) => {
590
+ window.removeEventListener("message", s), clearTimeout(i);
591
591
  const { data: d } = c;
592
592
  d.type === "formant_online" && (this._isOnline = d.online, t(d.online));
593
593
  };
594
- window.addEventListener("message", r), T({ type: "formant_online" });
594
+ window.addEventListener("message", s), T({ type: "formant_online" });
595
595
  });
596
596
  }
597
597
  static waitForConnection(e = 5e3) {
@@ -600,59 +600,62 @@ const q = class {
600
600
  setTimeout(() => {
601
601
  t = !0, d(new Error("deadline expired: took too long"));
602
602
  }, e);
603
- }), i = (c) => new Promise((d) => setTimeout(d, c)), r = async () => {
603
+ }), i = (c) => new Promise((d) => setTimeout(d, c)), s = async () => {
604
604
  for (await i(50); !t && !(this.isOnline || await this.checkConnection); )
605
605
  await i(500);
606
606
  };
607
- return Promise.race([n, r()]);
607
+ return Promise.race([n, s()]);
608
608
  }
609
609
  };
610
- let y = q;
611
- s(y, "getCurrentModuleContext", k), // senders
612
- s(y, "disableAnalyticsBottomBar", ve), s(y, "goToDevice", Te), s(y, "goToTime", Ce), s(y, "refreshAuthToken", V), s(y, "requestModuleData", Se), s(y, "sendChannelData", Ee), s(y, "setModuleDateTimeRange", ke), s(y, "setupModuleMenus", Oe), s(y, "showMessage", Re), // listeners
613
- s(y, "addAccessTokenRefreshListener", F), s(y, "addChannelDataListener", be), s(y, "addMenuListener", Ae), s(y, "addModuleConfigurationListener", De), s(y, "addModuleDataListener", Pe), s(y, "addOverviewDeviceListener", je), s(y, "addStreamListener", qe), // bidirectional
614
- s(y, "getDate", xe), s(y, "prompt", Ue), s(y, "_isOnline", null);
610
+ let g = q;
611
+ r(g, "getCurrentModuleContext", k), // senders
612
+ r(g, "disableAnalyticsBottomBar", ve), r(g, "goToDevice", Te), r(g, "goToTime", Ce), r(g, "refreshAuthToken", V), r(g, "requestModuleData", Se), r(g, "sendChannelData", Ee), r(g, "setModuleDateTimeRange", ke), r(g, "setupModuleMenus", Oe), r(g, "showMessage", Re), // listeners
613
+ r(g, "addAccessTokenRefreshListener", G), r(g, "addChannelDataListener", Ae), r(g, "addMenuListener", be), r(g, "addModuleConfigurationListener", De), r(g, "addModuleDataListener", je), r(g, "addOverviewDeviceListener", Ne), r(g, "addStreamListener", qe), // bidirectional
614
+ r(g, "getDate", xe), r(g, "prompt", Ue), r(g, "_isOnline", null);
615
615
  function f(a, e) {
616
616
  if (a !== void 0)
617
617
  return a;
618
618
  throw new Error(e || "Value is undefined");
619
619
  }
620
- const g = {
620
+ const p = {
621
621
  UNKNOWN: 0,
622
622
  TELEOP: 1,
623
623
  PORT_FORWARD: 2,
624
- OBSERVE: 3
625
- }, Ht = {
626
- ...g,
627
- Unknown: g.UNKNOWN,
628
- Teleop: g.TELEOP,
629
- PortForward: g.PORT_FORWARD,
630
- Observe: g.OBSERVE,
631
- unknown: g.UNKNOWN,
632
- teleop: g.TELEOP,
633
- portForward: g.PORT_FORWARD,
634
- observe: g.OBSERVE
624
+ OBSERVE: 3,
625
+ HEADLESS: 4
626
+ }, Xt = {
627
+ ...p,
628
+ Unknown: p.UNKNOWN,
629
+ Teleop: p.TELEOP,
630
+ PortForward: p.PORT_FORWARD,
631
+ Observe: p.OBSERVE,
632
+ Headless: p.HEADLESS,
633
+ unknown: p.UNKNOWN,
634
+ teleop: p.TELEOP,
635
+ portForward: p.PORT_FORWARD,
636
+ observe: p.OBSERVE,
637
+ headless: p.HEADLESS
635
638
  }, O = Symbol("RtcClientPool.instance");
636
- var qt;
637
- class j {
639
+ var Jt;
640
+ class N {
638
641
  constructor(e) {
639
- s(this, qt, null);
640
- s(this, "createClient");
641
- s(this, "ttlMs");
642
- s(this, "proxyHandler");
643
- s(this, "proxyReceivers", /* @__PURE__ */ new Map());
644
- s(this, "teardownTimeout", null);
645
- s(this, "dispatch", (e, t) => {
642
+ r(this, Jt, null);
643
+ r(this, "createClient");
644
+ r(this, "ttlMs");
645
+ r(this, "proxyHandler");
646
+ r(this, "proxyReceivers", /* @__PURE__ */ new Map());
647
+ r(this, "teardownTimeout", null);
648
+ r(this, "dispatch", (e, t) => {
646
649
  this.proxyReceivers.forEach((n) => n == null ? void 0 : n(e, t));
647
650
  });
648
651
  const { createClient: t, ttlMs: n = 0 } = e;
649
652
  this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
650
- get: (i, r, c) => {
651
- switch (r) {
653
+ get: (i, s, c) => {
654
+ switch (s) {
652
655
  case "shutdown":
653
656
  return () => this.releaseInstance(c);
654
657
  default:
655
- return Reflect.get(i, r, c);
658
+ return Reflect.get(i, s, c);
656
659
  }
657
660
  }
658
661
  };
@@ -691,57 +694,67 @@ class j {
691
694
  }, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
692
695
  }
693
696
  }
694
- qt = O;
695
- const N = async () => f(o.token, "Realtime when user isn't authorized"), R = {
696
- [g.UNKNOWN]: new j({
697
+ Jt = O;
698
+ const P = async () => f(o.token, "Realtime when user isn't authorized"), R = {
699
+ [p.UNKNOWN]: new N({
697
700
  ttlMs: 2500,
698
- createClient: (a) => new D({
699
- signalingClient: new P(h),
700
- getToken: N,
701
- sessionType: g.UNKNOWN,
701
+ createClient: (a) => new A({
702
+ signalingClient: new j(h),
703
+ getToken: P,
704
+ sessionType: p.UNKNOWN,
702
705
  receive: a
703
706
  })
704
707
  }),
705
- [g.TELEOP]: new j({
708
+ [p.TELEOP]: new N({
706
709
  ttlMs: 2500,
707
- createClient: (a) => new D({
708
- signalingClient: new P(h),
709
- getToken: N,
710
- sessionType: g.TELEOP,
710
+ createClient: (a) => new A({
711
+ signalingClient: new j(h),
712
+ getToken: P,
713
+ sessionType: p.TELEOP,
711
714
  receive: a
712
715
  })
713
716
  }),
714
- [g.PORT_FORWARD]: new j({
717
+ [p.PORT_FORWARD]: new N({
715
718
  ttlMs: 2500,
716
- createClient: (a) => new D({
717
- signalingClient: new P(h),
718
- getToken: N,
719
- sessionType: g.PORT_FORWARD,
719
+ createClient: (a) => new A({
720
+ signalingClient: new j(h),
721
+ getToken: P,
722
+ sessionType: p.PORT_FORWARD,
720
723
  receive: a
721
724
  })
722
725
  }),
723
- [g.OBSERVE]: new j({
726
+ [p.OBSERVE]: new N({
724
727
  ttlMs: 2500,
725
- createClient: (a) => new D({
726
- signalingClient: new P(h),
727
- getToken: N,
728
- sessionType: g.OBSERVE,
728
+ createClient: (a) => new A({
729
+ signalingClient: new j(h),
730
+ getToken: P,
731
+ sessionType: p.OBSERVE,
732
+ receive: a
733
+ })
734
+ }),
735
+ [p.HEADLESS]: new N({
736
+ ttlMs: 2500,
737
+ createClient: (a) => new A({
738
+ signalingClient: new j(h),
739
+ getToken: P,
740
+ sessionType: p.HEADLESS,
729
741
  receive: a
730
742
  })
731
743
  })
732
744
  }, Je = {
733
745
  ...R,
734
- unknown: R[g.UNKNOWN],
735
- teleop: R[g.TELEOP],
736
- portForward: R[g.PORT_FORWARD],
737
- observe: R[g.OBSERVE]
738
- }, $ = R[g.TELEOP], Ve = (a) => {
746
+ unknown: R[p.UNKNOWN],
747
+ teleop: R[p.TELEOP],
748
+ portForward: R[p.PORT_FORWARD],
749
+ observe: R[p.OBSERVE],
750
+ headless: R[p.HEADLESS]
751
+ }, $ = R[p.TELEOP], Ve = (a) => {
739
752
  const { sessionType: e } = a;
740
753
  return e ? Je[e] : $;
741
754
  };
742
- class Fe {
755
+ class Ge {
743
756
  constructor(e) {
744
- s(this, "token");
757
+ r(this, "token");
745
758
  this.captureSession = e;
746
759
  }
747
760
  async ingestJSON(e) {
@@ -772,17 +785,17 @@ class Fe {
772
785
  function b(a) {
773
786
  return new Promise((e) => setTimeout(e, a));
774
787
  }
775
- const We = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
776
- class Ge {
788
+ const He = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
789
+ class Fe {
777
790
  constructor(e) {
778
- s(this, "ready", !1);
779
- s(this, "listeners", []);
780
- s(this, "openListeners", []);
781
- s(this, "closeListeners", []);
782
- s(this, "errorListeners", []);
783
- s(this, "binaryListeners", []);
784
- s(this, "error");
785
- s(this, "decoder", new TextDecoder());
791
+ r(this, "ready", !1);
792
+ r(this, "listeners", []);
793
+ r(this, "openListeners", []);
794
+ r(this, "closeListeners", []);
795
+ r(this, "errorListeners", []);
796
+ r(this, "binaryListeners", []);
797
+ r(this, "error");
798
+ r(this, "decoder", new TextDecoder());
786
799
  this.dataChannel = e, this.dataChannel.binaryType = "arraybuffer", this.dataChannel.onopen = () => {
787
800
  this.setReady();
788
801
  }, this.dataChannel.onclose = () => {
@@ -791,8 +804,8 @@ class Ge {
791
804
  console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
792
805
  }, this.dataChannel.onmessage = (t) => {
793
806
  this.listeners.forEach((n) => {
794
- const i = new Uint8Array(t.data), r = this.decoder.decode(i);
795
- n(r);
807
+ const i = new Uint8Array(t.data), s = this.decoder.decode(i);
808
+ n(s);
796
809
  }), this.binaryListeners.forEach((n) => {
797
810
  n(new Uint8Array(t.data));
798
811
  });
@@ -859,10 +872,10 @@ class Ge {
859
872
  this.binaryListeners.splice(t, 1);
860
873
  }
861
874
  }
862
- class He {
875
+ class We {
863
876
  constructor(e, t) {
864
- s(this, "currentListeners", []);
865
- s(this, "onRealtimeMessage", (e, t) => {
877
+ r(this, "currentListeners", []);
878
+ r(this, "onRealtimeMessage", (e, t) => {
866
879
  t.payload.jointState && this.currentListeners.forEach((n) => {
867
880
  t.payload.jointState && n(t.payload.jointState);
868
881
  });
@@ -885,8 +898,8 @@ class He {
885
898
  }
886
899
  class K {
887
900
  constructor(e, t, n) {
888
- s(this, "channel");
889
- s(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
901
+ r(this, "channel");
902
+ r(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
890
903
  this.device = e, this.channel_name = t, this.timeout = n;
891
904
  }
892
905
  addOpenListener(e) {
@@ -917,8 +930,8 @@ class K {
917
930
  class Ke extends K {
918
931
  constructor() {
919
932
  super(...arguments);
920
- s(this, "RESPONSE_SUCCESS_BYTE", 0);
921
- s(this, "decoder", new TextDecoder());
933
+ r(this, "RESPONSE_SUCCESS_BYTE", 0);
934
+ r(this, "decoder", new TextDecoder());
922
935
  }
923
936
  /*
924
937
  Request binary payload layout:
@@ -940,21 +953,21 @@ class Ke extends K {
940
953
  const i = t.slice(0, 16).toString();
941
954
  if (i.length === 0)
942
955
  throw new Error("Invalid response");
943
- const r = t.slice(16);
944
- if (r.length === 0)
956
+ const s = t.slice(16);
957
+ if (s.length === 0)
945
958
  throw new Error("Invalid response");
946
- this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, r);
959
+ this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, s);
947
960
  });
948
961
  }
949
962
  async request(t) {
950
963
  if (this.channel || await this.initialize(), !this.channel)
951
964
  throw new Error("Failed to create channel");
952
- const { channel: n, requestIdToResponseMap: i, timeout: r } = this;
965
+ const { channel: n, requestIdToResponseMap: i, timeout: s } = this;
953
966
  await n.waitTilReady();
954
967
  const c = this.generateBinaryId(), d = c.toString();
955
968
  i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
956
- const p = (/* @__PURE__ */ new Date()).getTime();
957
- for (; (/* @__PURE__ */ new Date()).getTime() < p + r; )
969
+ const y = (/* @__PURE__ */ new Date()).getTime();
970
+ for (; (/* @__PURE__ */ new Date()).getTime() < y + s; )
958
971
  if (await b(50), i.has(d)) {
959
972
  const m = i.get(d);
960
973
  if (m !== !0) {
@@ -970,7 +983,7 @@ class Ke extends K {
970
983
  }
971
984
  throw i.delete(d), console.error({
972
985
  name: "TimeoutError",
973
- message: `Request timed out after ${r / 1e3} seconds`
986
+ message: `Request timed out after ${s / 1e3} seconds`
974
987
  }), new Error("Binary request data channel request timed out");
975
988
  }
976
989
  }
@@ -980,10 +993,10 @@ class Qe extends K {
980
993
  }
981
994
  async initialize() {
982
995
  this.channel = await this.device.createCustomDataChannel(this.channel_name), this.channel.addListener((e) => {
983
- const t = JSON.parse(e), { id: n, data: i, error: r } = t;
996
+ const t = JSON.parse(e), { id: n, data: i, error: s } = t;
984
997
  if (!n)
985
998
  throw new Error("Invalid response");
986
- if (!i && !r)
999
+ if (!i && !s)
987
1000
  throw new Error("Invalid response");
988
1001
  this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
989
1002
  });
@@ -993,22 +1006,22 @@ class Qe extends K {
993
1006
  throw new Error("Failed to create channel");
994
1007
  const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
995
1008
  await t.waitTilReady();
996
- const r = this.generateTextId();
997
- n.set(r, !0), t.send(
1009
+ const s = this.generateTextId();
1010
+ n.set(s, !0), t.send(
998
1011
  JSON.stringify({
999
- id: r,
1012
+ id: s,
1000
1013
  data: e
1001
1014
  })
1002
1015
  );
1003
1016
  const c = (/* @__PURE__ */ new Date()).getTime();
1004
1017
  for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
1005
- if (await b(50), n.has(r)) {
1006
- const d = n.get(r);
1018
+ if (await b(50), n.has(s)) {
1019
+ const d = n.get(s);
1007
1020
  if (d !== !0) {
1008
- n.delete(r);
1009
- const { data: p, error: m } = d;
1010
- if (p)
1011
- return p;
1021
+ n.delete(s);
1022
+ const { data: y, error: m } = d;
1023
+ if (y)
1024
+ return y;
1012
1025
  if (m)
1013
1026
  throw console.error({
1014
1027
  name: "AdapterError",
@@ -1016,20 +1029,20 @@ class Qe extends K {
1016
1029
  }), new Error("Text request datachannel adapter error");
1017
1030
  }
1018
1031
  }
1019
- throw n.delete(r), console.error({
1032
+ throw n.delete(s), console.error({
1020
1033
  name: "TimeoutError",
1021
1034
  message: `Request timed out after ${i / 1e3} seconds`
1022
1035
  }), new Error("Text request datachannel request timed out");
1023
1036
  }
1024
1037
  }
1025
- class Q extends ue {
1038
+ class Q extends le {
1026
1039
  constructor() {
1027
1040
  super(...arguments);
1028
- s(this, "rtcClient");
1029
- s(this, "remoteDevicePeerId", null);
1030
- s(this, "realtimeListeners", []);
1031
- s(this, "connectionMonitorInterval");
1032
- s(this, "handleMessage", (t, n) => {
1041
+ r(this, "rtcClient");
1042
+ r(this, "remoteDevicePeerId", null);
1043
+ r(this, "realtimeListeners", []);
1044
+ r(this, "connectionMonitorInterval");
1045
+ r(this, "handleMessage", (t, n) => {
1033
1046
  this.realtimeListeners.forEach((i) => i(t, n));
1034
1047
  });
1035
1048
  }
@@ -1063,7 +1076,7 @@ class Q extends ue {
1063
1076
  const t = await this.getConfiguration(), n = [];
1064
1077
  for (const i of t.teleop.rosStreams ?? [])
1065
1078
  i.topicType == "sensor_msgs/JointState" && n.push(
1066
- new He(this, {
1079
+ new We(this, {
1067
1080
  currentJointStateStream: { name: i.topicName },
1068
1081
  plannedJointStateStream: i.plannedTopic ? { name: i.plannedTopic } : void 0,
1069
1082
  planValidStream: i.planValidTopic ? { name: i.planValidTopic } : void 0,
@@ -1076,13 +1089,13 @@ class Q extends ue {
1076
1089
  return n;
1077
1090
  }
1078
1091
  async getRealtimeVideoStreams() {
1079
- var i, r, c;
1092
+ var i, s, c;
1080
1093
  const t = await this.getConfiguration(), n = [];
1081
1094
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1082
1095
  d.rtcStreamType === "h264-video-frame" && n.push({
1083
1096
  name: d.name
1084
1097
  });
1085
- for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
1098
+ for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
1086
1099
  d.topicType == "formant/H264VideoFrame" && n.push({
1087
1100
  name: d.topicName
1088
1101
  }), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
@@ -1170,8 +1183,8 @@ class Q extends ue {
1170
1183
  const i = f(
1171
1184
  this.rtcClient,
1172
1185
  "Realtime connection has not been started"
1173
- ), r = await this.getRemotePeer();
1174
- i.controlRemoteStream(f(r).id, {
1186
+ ), s = await this.getRemotePeer();
1187
+ i.controlRemoteStream(f(s).id, {
1175
1188
  streamName: t,
1176
1189
  setAudioFormat: n
1177
1190
  });
@@ -1180,17 +1193,17 @@ class Q extends ue {
1180
1193
  const i = f(
1181
1194
  this.rtcClient,
1182
1195
  "Realtime connection has not been started"
1183
- ), r = await this.getRemotePeer(), c = await new Promise((d) => {
1196
+ ), s = await this.getRemotePeer(), c = await new Promise((d) => {
1184
1197
  i.createCustomDataChannel(
1185
- f(r).id,
1198
+ f(s).id,
1186
1199
  t,
1187
1200
  {
1188
1201
  ordered: !0,
1189
1202
  ...n
1190
1203
  },
1191
1204
  !1,
1192
- (p, m) => {
1193
- const w = new Ge(m);
1205
+ (y, m) => {
1206
+ const w = new Fe(m);
1194
1207
  d(w);
1195
1208
  }
1196
1209
  );
@@ -1203,17 +1216,17 @@ class Q extends ue {
1203
1216
  const i = f(
1204
1217
  this.rtcClient,
1205
1218
  "Realtime connection has not been started"
1206
- ), r = await this.getRemotePeer();
1207
- i.send(f(r).id, t, n);
1219
+ ), s = await this.getRemotePeer();
1220
+ i.send(f(s).id, t, n);
1208
1221
  }
1209
1222
  async getRealtimeAudioStreams() {
1210
- var i, r, c;
1223
+ var i, s, c;
1211
1224
  const t = await this.getConfiguration(), n = [];
1212
1225
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1213
1226
  d.rtcStreamType === "audio-chunk" && n.push({
1214
1227
  name: d.name
1215
1228
  });
1216
- for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
1229
+ for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
1217
1230
  d.topicType == "audio_common_msgs/AudioData" && n.push({
1218
1231
  name: d.topicName
1219
1232
  });
@@ -1254,12 +1267,12 @@ async function Y(a, e) {
1254
1267
  "Content-Type": "application/json",
1255
1268
  Authorization: "Bearer " + o.token
1256
1269
  }
1257
- }), r = h.replace("api", "app"), { code: c } = await i.json();
1258
- return `${r}/shares/${c}#${Ye({
1270
+ }), s = h.replace("api", "app"), { code: c } = await i.json();
1271
+ return `${s}/shares/${c}#${Ye({
1259
1272
  viewId: n[0].id
1260
1273
  })}`;
1261
1274
  }
1262
- const Kt = [
1275
+ const Yt = [
1263
1276
  "day",
1264
1277
  "week",
1265
1278
  "month",
@@ -1267,7 +1280,7 @@ const Kt = [
1267
1280
  "hour",
1268
1281
  "minute",
1269
1282
  "quarter"
1270
- ], Qt = [
1283
+ ], Zt = [
1271
1284
  "interval",
1272
1285
  "start",
1273
1286
  "end",
@@ -1295,7 +1308,7 @@ function it(a) {
1295
1308
  function ot(a) {
1296
1309
  return a.count;
1297
1310
  }
1298
- const Xt = {
1311
+ const en = {
1299
1312
  min: nt,
1300
1313
  max: tt,
1301
1314
  "standard deviation": et,
@@ -1304,53 +1317,53 @@ const Xt = {
1304
1317
  count: ot
1305
1318
  }, Z = {
1306
1319
  day: {
1307
- interval: u.eachDayOfInterval,
1308
- start: u.startOfDay,
1309
- end: u.endOfDay,
1310
- sub: u.subDays,
1311
- get: u.getDay
1320
+ interval: l.eachDayOfInterval,
1321
+ start: l.startOfDay,
1322
+ end: l.endOfDay,
1323
+ sub: l.subDays,
1324
+ get: l.getDay
1312
1325
  },
1313
1326
  week: {
1314
- interval: u.eachWeekOfInterval,
1315
- start: u.startOfWeek,
1316
- end: u.endOfWeek,
1317
- sub: u.subWeeks,
1318
- get: u.getWeek
1327
+ interval: l.eachWeekOfInterval,
1328
+ start: l.startOfWeek,
1329
+ end: l.endOfWeek,
1330
+ sub: l.subWeeks,
1331
+ get: l.getWeek
1319
1332
  },
1320
1333
  month: {
1321
- interval: u.eachMonthOfInterval,
1322
- start: u.startOfMonth,
1323
- end: u.endOfMonth,
1324
- sub: u.subMonths,
1325
- get: u.getMonth
1334
+ interval: l.eachMonthOfInterval,
1335
+ start: l.startOfMonth,
1336
+ end: l.endOfMonth,
1337
+ sub: l.subMonths,
1338
+ get: l.getMonth
1326
1339
  },
1327
1340
  year: {
1328
- interval: u.eachYearOfInterval,
1329
- start: u.startOfYear,
1330
- end: u.endOfYear,
1331
- sub: u.subYears,
1332
- get: u.getYear
1341
+ interval: l.eachYearOfInterval,
1342
+ start: l.startOfYear,
1343
+ end: l.endOfYear,
1344
+ sub: l.subYears,
1345
+ get: l.getYear
1333
1346
  },
1334
1347
  hour: {
1335
- interval: u.eachHourOfInterval,
1336
- start: u.startOfHour,
1337
- end: u.endOfHour,
1338
- sub: u.subHours,
1339
- get: u.getHours
1348
+ interval: l.eachHourOfInterval,
1349
+ start: l.startOfHour,
1350
+ end: l.endOfHour,
1351
+ sub: l.subHours,
1352
+ get: l.getHours
1340
1353
  },
1341
1354
  minute: {
1342
- interval: u.eachMinuteOfInterval,
1343
- start: u.startOfMinute,
1344
- end: u.endOfMinute,
1345
- sub: u.subMinutes,
1346
- get: u.getMinutes
1355
+ interval: l.eachMinuteOfInterval,
1356
+ start: l.startOfMinute,
1357
+ end: l.endOfMinute,
1358
+ sub: l.subMinutes,
1359
+ get: l.getMinutes
1347
1360
  },
1348
1361
  quarter: {
1349
- interval: u.eachQuarterOfInterval,
1350
- start: u.startOfQuarter,
1351
- end: u.endOfQuarter,
1352
- sub: u.subQuarters,
1353
- get: u.getQuarter
1362
+ interval: l.eachQuarterOfInterval,
1363
+ start: l.startOfQuarter,
1364
+ end: l.endOfQuarter,
1365
+ sub: l.subQuarters,
1366
+ get: l.getQuarter
1354
1367
  }
1355
1368
  }, rt = (a, e) => (
1356
1369
  // FIXME this doesn't work for *a lot* locales, other than en-US
@@ -1372,14 +1385,14 @@ async function z(a) {
1372
1385
  })).json()).items;
1373
1386
  }
1374
1387
  async function ee(a, e, t, n, i) {
1375
- const r = Z[e];
1388
+ const s = Z[e];
1376
1389
  return await Promise.all(
1377
1390
  Array(t).fill(0).map(async (c, d) => {
1378
- const p = new Date(n), m = r.sub(
1379
- r.start(p),
1391
+ const y = new Date(n), m = s.sub(
1392
+ s.start(y),
1380
1393
  t - d - 1
1381
- ), w = r.sub(
1382
- r.end(p),
1394
+ ), w = s.sub(
1395
+ s.end(y),
1383
1396
  t - d - 1
1384
1397
  ), v = rt(
1385
1398
  m.toLocaleDateString(),
@@ -1399,10 +1412,10 @@ async function B(a, e) {
1399
1412
  ...a,
1400
1413
  eventTypes: ["annotation"]
1401
1414
  })).filter(
1402
- (r) => !!r.tags && Object.keys(r.tags).includes(e)
1403
- ).reduce((r, c) => {
1415
+ (s) => !!s.tags && Object.keys(s.tags).includes(e)
1416
+ ).reduce((s, c) => {
1404
1417
  const d = c.tags[e];
1405
- return d in r ? (r[d] += 1, r) : (r[d] = 1, r);
1418
+ return d in s ? (s[d] += 1, s) : (s[d] = 1, s);
1406
1419
  }, {});
1407
1420
  }
1408
1421
  async function te(a, e, t) {
@@ -1419,20 +1432,20 @@ async function te(a, e, t) {
1419
1432
  },
1420
1433
  e
1421
1434
  );
1422
- }), p = await Promise.all(d);
1435
+ }), y = await Promise.all(d);
1423
1436
  return c.map((m, w) => ({
1424
1437
  date: new Date(m).toISOString(),
1425
- annotations: p[w]
1438
+ annotations: y[w]
1426
1439
  }));
1427
1440
  }
1428
1441
  async function ne(a, e, t, n, i) {
1429
- let r = a;
1430
- Array.isArray(a) || (r = [a]);
1442
+ let s = a;
1443
+ Array.isArray(a) || (s = [a]);
1431
1444
  let c = e;
1432
1445
  return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
1433
1446
  method: "POST",
1434
1447
  body: JSON.stringify({
1435
- deviceIds: r,
1448
+ deviceIds: s,
1436
1449
  end: n.toISOString(),
1437
1450
  names: c,
1438
1451
  start: t.toISOString(),
@@ -1512,7 +1525,7 @@ async function ht(a) {
1512
1525
  }
1513
1526
  })).json()).items;
1514
1527
  }
1515
- async function lt(a) {
1528
+ async function ut(a) {
1516
1529
  if (!o.token)
1517
1530
  throw new Error("Not authenticated");
1518
1531
  return await (await fetch(
@@ -1604,7 +1617,7 @@ class S extends Q {
1604
1617
  sessionType: t
1605
1618
  }).get(this.handleMessage);
1606
1619
  let d = !1;
1607
- const p = new Promise(
1620
+ const y = new Promise(
1608
1621
  (w, v) => setTimeout(() => {
1609
1622
  d = !0, v(
1610
1623
  new Error(
@@ -1619,7 +1632,7 @@ class S extends Q {
1619
1632
  const w = await this.getRemoteDevicePeerId(c);
1620
1633
  this.assertNotCancelled(d);
1621
1634
  let v;
1622
- for (let A = 0; A < i && (v = await c.connect(w), !v); A++)
1635
+ for (let D = 0; D < i && (v = await c.connect(w), !v); D++)
1623
1636
  b(100), this.assertNotCancelled(d);
1624
1637
  if (!v)
1625
1638
  throw new Error(
@@ -1632,7 +1645,7 @@ class S extends Q {
1632
1645
  `${(/* @__PURE__ */ new Date()).toISOString()} :: Connection completed after ${C} retries`
1633
1646
  ), w;
1634
1647
  };
1635
- return Promise.race([m(), p]).then((w) => {
1648
+ return Promise.race([m(), y]).then((w) => {
1636
1649
  this.remoteDevicePeerId = w, this.initConnectionMonitoring(), this.rtcClient = c, this.emit("connect");
1637
1650
  }).catch((w) => {
1638
1651
  throw console.debug(
@@ -1645,7 +1658,7 @@ class S extends Q {
1645
1658
  }
1646
1659
  async getRemoteDevicePeerId(e) {
1647
1660
  const n = (await e.getPeers()).find((i) => i.deviceId === this.id);
1648
- if (!We(n))
1661
+ if (!He(n))
1649
1662
  throw new Error("Cannot find peer, is the robot offline?");
1650
1663
  return n.id;
1651
1664
  }
@@ -1721,7 +1734,7 @@ class S extends Q {
1721
1734
  throw new Error(`Could not find command with name "${e}"`);
1722
1735
  let d = "";
1723
1736
  t === void 0 ? c.parameterEnabled && c.parameterValue && (d = c.parameterValue) : d = t;
1724
- let p = {
1737
+ let y = {
1725
1738
  value: d,
1726
1739
  scrubberTime: (n || /* @__PURE__ */ new Date()).toISOString(),
1727
1740
  meta: {
@@ -1736,7 +1749,7 @@ class S extends Q {
1736
1749
  organizationId: this.organizationId,
1737
1750
  deviceId: this.id,
1738
1751
  command: c.command,
1739
- parameter: p,
1752
+ parameter: y,
1740
1753
  userId: (w = o.currentUser) == null ? void 0 : w.id
1741
1754
  }),
1742
1755
  headers: {
@@ -1767,7 +1780,7 @@ class S extends Q {
1767
1780
  Authorization: "Bearer " + o.token
1768
1781
  }
1769
1782
  })).json();
1770
- return new Fe(n);
1783
+ return new Ge(n);
1771
1784
  }
1772
1785
  async getTelemetry(e, t, n, i) {
1773
1786
  return await ne(
@@ -1779,7 +1792,7 @@ class S extends Q {
1779
1792
  );
1780
1793
  }
1781
1794
  async getTelemetryStreams() {
1782
- var d, p;
1795
+ var d, y;
1783
1796
  const e = await this.getConfiguration(), t = await fetch(
1784
1797
  `${h}/v1/queries/metadata/stream-names`,
1785
1798
  {
@@ -1793,7 +1806,7 @@ class S extends Q {
1793
1806
  }
1794
1807
  }
1795
1808
  ), n = [], i = [];
1796
- return (p = (d = e.telemetry) == null ? void 0 : d.streams) == null || p.forEach((m) => {
1809
+ return (y = (d = e.telemetry) == null ? void 0 : d.streams) == null || y.forEach((m) => {
1797
1810
  m.disabled !== !0 && n.push(m.name), m.onDemand === !0 && i.push(m.name);
1798
1811
  }), console.log(i), (await t.json()).items.filter((m) => !n.includes(m)).map((m) => ({ name: m, onDemand: i.includes(m) }));
1799
1812
  }
@@ -1844,9 +1857,9 @@ class S extends Q {
1844
1857
  n
1845
1858
  );
1846
1859
  }
1847
- async eventsCounter(e, t, n, i, r) {
1860
+ async eventsCounter(e, t, n, i, s) {
1848
1861
  return await ee(e, t, n, i, {
1849
- ...r,
1862
+ ...s,
1850
1863
  deviceIds: [this.id]
1851
1864
  });
1852
1865
  }
@@ -1854,24 +1867,24 @@ class S extends Q {
1854
1867
  return e.scope.deviceIds = [this.id], await Y(e, t);
1855
1868
  }
1856
1869
  }
1857
- s(S, "createDevice", st), s(S, "patchDevice", ct), s(S, "getDevicesData", dt), s(S, "queryDevicesData", ht), s(S, "disableDevice", lt);
1858
- class ut extends Q {
1870
+ r(S, "createDevice", st), r(S, "patchDevice", ct), r(S, "getDevicesData", dt), r(S, "queryDevicesData", ht), r(S, "disableDevice", ut);
1871
+ class lt extends Q {
1859
1872
  constructor(t) {
1860
1873
  super();
1861
- s(this, "id");
1862
- s(this, "telemetryStreamActive", !1);
1863
- s(this, "streamTelemetry", {});
1874
+ r(this, "id");
1875
+ r(this, "telemetryStreamActive", !1);
1876
+ r(this, "streamTelemetry", {});
1864
1877
  this.peerUrl = t;
1865
1878
  }
1866
1879
  async getLatestTelemetry() {
1867
1880
  this.telemetryStreamActive || this.subscribeToTelemetry();
1868
1881
  const t = this.streamTelemetry;
1869
- return Object.entries(t).map(([i, r]) => ({
1882
+ return Object.entries(t).map(([i, s]) => ({
1870
1883
  deviceId: this.id,
1871
1884
  streamName: i,
1872
1885
  streamType: "json",
1873
- currentValue: r,
1874
- currentValueTime: r.timestamp,
1886
+ currentValue: s,
1887
+ currentValueTime: s.timestamp,
1875
1888
  tags: {}
1876
1889
  }));
1877
1890
  }
@@ -1888,15 +1901,15 @@ class ut extends Q {
1888
1901
  }), n.addEventListener("readystatechange", (i) => {
1889
1902
  n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
1890
1903
  }), n.addEventListener("progress", (i) => {
1891
- const r = i.loaded, c = r - t;
1892
- t = r, n.responseText.substr(-c).split(`
1904
+ const s = i.loaded, c = s - t;
1905
+ t = s, n.responseText.substr(-c).split(`
1893
1906
  `).forEach((m) => {
1894
1907
  var w;
1895
1908
  if (m.length > 0) {
1896
1909
  const v = JSON.parse(m);
1897
1910
  if ((w = v.result) != null && w.datapoint) {
1898
- const C = v.result.datapoint, A = C.stream;
1899
- delete C.stream, this.streamTelemetry[A] = C;
1911
+ const C = v.result.datapoint, D = C.stream;
1912
+ delete C.stream, this.streamTelemetry[D] = C;
1900
1913
  }
1901
1914
  }
1902
1915
  });
@@ -1919,7 +1932,7 @@ class ut extends Q {
1919
1932
  this.rtcClient && console.warn(
1920
1933
  "overwriting existing rtcClient due to missing connectionMonitorInterval"
1921
1934
  );
1922
- const n = new D({
1935
+ const n = new A({
1923
1936
  lanOnlyMode: !0,
1924
1937
  receive: this.handleMessage,
1925
1938
  sessionType: t
@@ -1958,11 +1971,11 @@ class ut extends Q {
1958
1971
  if (t)
1959
1972
  throw new Error(`Realtime connection hasn't been started for ${this.id}`);
1960
1973
  }
1961
- async sendCommand(t, n, i, r) {
1974
+ async sendCommand(t, n, i, s) {
1962
1975
  const c = {
1963
1976
  value: n,
1964
1977
  scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
1965
- meta: r
1978
+ meta: s
1966
1979
  };
1967
1980
  return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
1968
1981
  method: "POST",
@@ -2201,7 +2214,7 @@ async function Rt(...a) {
2201
2214
  }
2202
2215
  )).json()).items;
2203
2216
  }
2204
- async function bt() {
2217
+ async function At() {
2205
2218
  if (!o.token)
2206
2219
  throw new Error("Not authenticated");
2207
2220
  const t = (await (await fetch(`${h}/v1/queries/online-devices`, {
@@ -2213,7 +2226,7 @@ async function bt() {
2213
2226
  })).json()).items;
2214
2227
  return (await M()).filter((i) => t.includes(i.id));
2215
2228
  }
2216
- async function At() {
2229
+ async function bt() {
2217
2230
  if (!o.token)
2218
2231
  throw new Error("Not authenticated");
2219
2232
  const t = (await (await fetch(`${h}/v1/signaling/peers`, {
@@ -2240,7 +2253,7 @@ async function Dt() {
2240
2253
  (t) => t.enabled
2241
2254
  );
2242
2255
  }
2243
- async function Pt(a) {
2256
+ async function jt(a) {
2244
2257
  if (!o.token)
2245
2258
  throw new Error("Not authenticated");
2246
2259
  return await (await fetch(
@@ -2255,7 +2268,7 @@ async function Pt(a) {
2255
2268
  }
2256
2269
  )).json();
2257
2270
  }
2258
- async function jt() {
2271
+ async function Nt() {
2259
2272
  if (!o.token)
2260
2273
  throw new Error("Not authenticated");
2261
2274
  return (await (await fetch(
@@ -2269,7 +2282,7 @@ async function jt() {
2269
2282
  }
2270
2283
  )).json()).items;
2271
2284
  }
2272
- async function Nt() {
2285
+ async function Pt() {
2273
2286
  if (!o.token)
2274
2287
  throw new Error("Not authenticated");
2275
2288
  return (await (await fetch(`${h}/v1/admin/fleets`, {
@@ -2280,7 +2293,7 @@ async function Nt() {
2280
2293
  }
2281
2294
  })).json()).items;
2282
2295
  }
2283
- async function It(a, e) {
2296
+ async function Lt(a, e) {
2284
2297
  if (!o.token)
2285
2298
  throw new Error("Not authenticated");
2286
2299
  return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
@@ -2292,7 +2305,7 @@ async function It(a, e) {
2292
2305
  }
2293
2306
  })).json();
2294
2307
  }
2295
- async function Lt(a) {
2308
+ async function It(a) {
2296
2309
  if (!o.token)
2297
2310
  throw new Error("Not authenticated");
2298
2311
  return await (await fetch(
@@ -2343,6 +2356,46 @@ async function zt(a) {
2343
2356
  }
2344
2357
  })).json();
2345
2358
  }
2359
+ async function Bt() {
2360
+ if (!o.token)
2361
+ throw new Error("Not authenticated");
2362
+ return (await (await fetch(`${h}/v1/admin/event-trigger-groups`, {
2363
+ method: "GET",
2364
+ headers: {
2365
+ "Content-Type": "application/json",
2366
+ Authorization: "Bearer " + o.token
2367
+ }
2368
+ })).json()).items;
2369
+ }
2370
+ async function Mt(a) {
2371
+ if (!o.token)
2372
+ throw new Error("Not authenticated");
2373
+ return await (await fetch(
2374
+ `${h}/v1/admin/event-trigger-groups/${a}`,
2375
+ {
2376
+ method: "GET",
2377
+ headers: {
2378
+ "Content-Type": "application/json",
2379
+ Authorization: "Bearer " + o.token
2380
+ }
2381
+ }
2382
+ )).json();
2383
+ }
2384
+ async function qt(a, e) {
2385
+ if (!o.token)
2386
+ throw new Error("Not authenticated");
2387
+ return await (await fetch(
2388
+ `${h}/v1/admin/event-trigger-groups/${a}`,
2389
+ {
2390
+ method: "PATCH",
2391
+ body: JSON.stringify(e),
2392
+ headers: {
2393
+ "Content-Type": "application/json",
2394
+ Authorization: "Bearer " + o.token
2395
+ }
2396
+ }
2397
+ )).json();
2398
+ }
2346
2399
  const E = class {
2347
2400
  static async setDefaultDevice(e) {
2348
2401
  E.defaultDeviceId = e;
@@ -2363,16 +2416,16 @@ const E = class {
2363
2416
  }
2364
2417
  )).json()).items.find(
2365
2418
  (c) => c.id === E.defaultDeviceId
2366
- ), i = n.name, r = new S(
2419
+ ), i = n.name, s = new S(
2367
2420
  E.defaultDeviceId,
2368
2421
  i,
2369
2422
  f(o.currentOrganization),
2370
2423
  n.tags
2371
2424
  );
2372
- return E.knownContext.push(new WeakRef(r)), r;
2425
+ return E.knownContext.push(new WeakRef(s)), s;
2373
2426
  }
2374
2427
  static async getPeerDevice(e) {
2375
- const t = new ut(e);
2428
+ const t = new lt(e);
2376
2429
  return t.id = await t.getDeviceId(), t;
2377
2430
  }
2378
2431
  static async getDevice(e) {
@@ -2380,9 +2433,9 @@ const E = class {
2380
2433
  return E.knownContext.push(new WeakRef(t)), t;
2381
2434
  }
2382
2435
  };
2383
- let l = E;
2384
- s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "createFleet", zt), s(l, "listFleets", Nt), s(l, "getFleet", Et), s(l, "patchFleet", It), s(l, "deleteFleet", wt), s(l, "addDeviceToFleet", mt), s(l, "getFleetDevices", kt), s(l, "aggregateTelemetry", ft), s(l, "createShareLink", Y), s(l, "eventsCounter", ee), s(l, "getAnalyticStreams", pt), s(l, "getAnalyticsModules", yt), s(l, "getAnalyticsRows", gt), s(l, "getAnnotationCount", B), s(l, "getAnnotationCountByIntervals", te), s(l, "getCurrentGroup", vt), s(l, "getDevices", M), s(l, "getEvent", Ct), s(l, "getFileUrl", St), s(l, "getInterventions", Ot), s(l, "getLatestTelemetry", Rt), s(l, "getOnlineDevices", bt), s(l, "getPeers", ie), s(l, "getRealtimeDevices", At), s(l, "getRealtimeSessions", ae), s(l, "getStreams", Dt), s(l, "getTaskReportRows", Pt), s(l, "getTaskReportTables", jt), s(l, "getTelemetry", ne), s(l, "getViews", X), s(l, "patchStream", Lt), s(l, "patchView", _t), s(l, "queryAnalytics", $t), s(l, "queryDevices", oe), s(l, "queryEvents", z), s(l, "queryTelemetry", _);
2385
- class Yt {
2436
+ let u = E;
2437
+ r(u, "defaultDeviceId"), r(u, "knownContext", []), r(u, "createFleet", zt), r(u, "listFleets", Pt), r(u, "getFleet", Et), r(u, "patchFleet", Lt), r(u, "deleteFleet", wt), r(u, "addDeviceToFleet", mt), r(u, "getFleetDevices", kt), r(u, "aggregateTelemetry", ft), r(u, "createShareLink", Y), r(u, "eventsCounter", ee), r(u, "getAnalyticStreams", pt), r(u, "getAnalyticsModules", yt), r(u, "getAnalyticsRows", gt), r(u, "getAnnotationCount", B), r(u, "getAnnotationCountByIntervals", te), r(u, "getCurrentGroup", vt), r(u, "getDevices", M), r(u, "getEvent", Ct), r(u, "getFileUrl", St), r(u, "getInterventions", Ot), r(u, "getLatestTelemetry", Rt), r(u, "getOnlineDevices", At), r(u, "getPeers", ie), r(u, "getRealtimeDevices", bt), r(u, "getRealtimeSessions", ae), r(u, "getStreams", Dt), r(u, "getTaskReportRows", jt), r(u, "getTaskReportTables", Nt), r(u, "getTelemetry", ne), r(u, "getViews", X), r(u, "patchStream", It), r(u, "patchView", _t), r(u, "queryAnalytics", $t), r(u, "queryDevices", oe), r(u, "queryEvents", z), r(u, "queryTelemetry", _), r(u, "getAllEventTriggerGroup", Bt), r(u, "getEventTriggerGroup", Mt), r(u, "patchEventTriggergroup", qt);
2438
+ class tn {
2386
2439
  static async set(e, t, n) {
2387
2440
  try {
2388
2441
  const i = await fetch(h + "/v1/admin/key-value", {
@@ -2397,9 +2450,9 @@ class Yt {
2397
2450
  "Content-Type": "application/json",
2398
2451
  Authorization: "Bearer " + o.token
2399
2452
  }
2400
- }), r = await i.json();
2453
+ }), s = await i.json();
2401
2454
  if (i.status !== 200)
2402
- throw new Error(r.message);
2455
+ throw new Error(s.message);
2403
2456
  } catch (i) {
2404
2457
  throw i;
2405
2458
  }
@@ -2478,37 +2531,37 @@ class Yt {
2478
2531
  }
2479
2532
  }
2480
2533
  }
2481
- function Bt(a) {
2534
+ function xt(a) {
2482
2535
  return Uint8Array.from(J(a), (e) => e.charCodeAt(0));
2483
2536
  }
2484
2537
  function U() {
2485
2538
  const { userAgent: a } = navigator;
2486
2539
  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";
2487
2540
  }
2488
- const Mt = "audio-chunk";
2489
- class Zt {
2541
+ const Ut = "audio-chunk";
2542
+ class nn {
2490
2543
  constructor(e, t) {
2491
- s(this, "muted", !1);
2492
- s(this, "hasReceivedData", !1);
2493
- s(this, "audioContext");
2494
- s(this, "chunks", []);
2495
- s(this, "isPlaying", !1);
2496
- s(this, "startTime", 0);
2497
- s(this, "lastChunkOffset", 0);
2498
- s(this, "bufferSize", 3);
2499
- s(this, "receive", async (e) => {
2544
+ r(this, "muted", !1);
2545
+ r(this, "hasReceivedData", !1);
2546
+ r(this, "audioContext");
2547
+ r(this, "chunks", []);
2548
+ r(this, "isPlaying", !1);
2549
+ r(this, "startTime", 0);
2550
+ r(this, "lastChunkOffset", 0);
2551
+ r(this, "bufferSize", 3);
2552
+ r(this, "receive", async (e) => {
2500
2553
  var c;
2501
2554
  const t = (c = e.payload.audioChunk) == null ? void 0 : c.chunk_data;
2502
2555
  if (!t)
2503
2556
  return;
2504
2557
  this.hasReceivedData || (this.hasReceivedData = !0);
2505
2558
  const { audioContext: n, muted: i } = this;
2506
- if (!n || e.header.stream.streamType !== Mt || i !== !1)
2559
+ if (!n || e.header.stream.streamType !== Ut || i !== !1)
2507
2560
  return;
2508
- const r = Bt(t);
2561
+ const s = xt(t);
2509
2562
  try {
2510
2563
  await n.decodeAudioData(
2511
- r.buffer,
2564
+ s.buffer,
2512
2565
  this.scheduleChunk
2513
2566
  );
2514
2567
  } catch (d) {
@@ -2518,7 +2571,7 @@ class Zt {
2518
2571
  ), this.changeAudioWireFormat("wav");
2519
2572
  }
2520
2573
  });
2521
- s(this, "scheduleChunk", (e) => {
2574
+ r(this, "scheduleChunk", (e) => {
2522
2575
  const { audioContext: t } = this;
2523
2576
  if (!t)
2524
2577
  return;
@@ -2528,8 +2581,8 @@ class Zt {
2528
2581
  const n = this.createChunk(e);
2529
2582
  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));
2530
2583
  });
2531
- this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, r) => {
2532
- this.receive(r);
2584
+ this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, s) => {
2585
+ this.receive(s);
2533
2586
  }), U() === "Safari" || U() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
2534
2587
  const n = window.AudioContext || window.webkitAudioContext;
2535
2588
  this.audioContext = new n();
@@ -2558,7 +2611,7 @@ class Zt {
2558
2611
  (async () => await this.device.changeStreamAudioType(t.name, e))();
2559
2612
  }
2560
2613
  }
2561
- class en {
2614
+ class an {
2562
2615
  static async listAccounts() {
2563
2616
  if (!o.token)
2564
2617
  throw new Error("Not authenticated");
@@ -2631,7 +2684,7 @@ class en {
2631
2684
  )).json();
2632
2685
  }
2633
2686
  }
2634
- class tn {
2687
+ class on {
2635
2688
  static async listRoles() {
2636
2689
  if (!o.token)
2637
2690
  throw new Error("Not authenticated");
@@ -2690,7 +2743,7 @@ class tn {
2690
2743
  });
2691
2744
  }
2692
2745
  }
2693
- class nn {
2746
+ class rn {
2694
2747
  static async listUsers() {
2695
2748
  if (!o.token)
2696
2749
  throw new Error("Not authenticated");
@@ -2750,14 +2803,14 @@ class nn {
2750
2803
  });
2751
2804
  }
2752
2805
  }
2753
- const an = ["viewer", "operator", "administrator"], on = "viewer", rn = "operator", sn = "administrator", cn = [
2806
+ const sn = ["viewer", "operator", "administrator"], cn = "viewer", dn = "operator", hn = "administrator", un = [
2754
2807
  "year",
2755
2808
  "month",
2756
2809
  "week",
2757
2810
  "day",
2758
2811
  "hour",
2759
2812
  "minute"
2760
- ], dn = ["tag", "sheet", "user"], hn = [
2813
+ ], ln = ["tag", "sheet", "user"], mn = [
2761
2814
  "triggered-event",
2762
2815
  "intervention-request",
2763
2816
  "teleop-session-record",
@@ -2769,44 +2822,44 @@ const an = ["viewer", "operator", "administrator"], on = "viewer", rn = "operato
2769
2822
  "comment",
2770
2823
  "system",
2771
2824
  "annotation"
2772
- ], ln = [
2825
+ ], fn = [
2773
2826
  "unknown",
2774
2827
  "operational",
2775
2828
  "offline",
2776
2829
  "error"
2777
- ], un = ["selection", "labeling", "teleop"], mn = ["info", "warning", "error", "critical"], fn = ["video/mp4"], wn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
2830
+ ], wn = ["selection", "labeling", "teleop"], pn = ["info", "warning", "error", "critical"], yn = ["video/mp4"], gn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
2778
2831
  try {
2779
2832
  const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
2780
- e && l.setDefaultDevice(e);
2833
+ e && u.setDefaultDevice(e);
2781
2834
  const t = a.get("auth");
2782
- t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && y.listenForConnectionEvents();
2835
+ t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && g.listenForConnectionEvents();
2783
2836
  } catch {
2784
2837
  }
2785
2838
  export {
2786
- en as Account,
2787
- y as App,
2788
- Zt as AudioPlayer,
2839
+ an as Account,
2840
+ g as App,
2841
+ nn as AudioPlayer,
2789
2842
  o as Authentication,
2790
2843
  Ke as BinaryRequestDataChannel,
2791
- Fe as CaptureStream,
2792
- Ge as DataChannel,
2844
+ Ge as CaptureStream,
2845
+ Fe as DataChannel,
2793
2846
  S as Device,
2794
- l as Fleet,
2795
- Yt as KeyValue,
2796
- He as Manipulator,
2797
- ut as PeerDevice,
2798
- tn as Role,
2799
- Ht as SessionType,
2847
+ u as Fleet,
2848
+ tn as KeyValue,
2849
+ We as Manipulator,
2850
+ lt as PeerDevice,
2851
+ on as Role,
2852
+ Xt as SessionType,
2800
2853
  Qe as TextRequestDataChannel,
2801
- nn as User,
2802
- an as accessLevels,
2803
- sn as administrator,
2854
+ rn as User,
2855
+ sn as accessLevels,
2856
+ hn as administrator,
2804
2857
  Z as aggregateByDateFunctions,
2805
- Xt as aggregateFunctionMap,
2806
- Qt as aggregateFunctions,
2807
- cn as aggregateLevels,
2808
- dn as annotationTypes,
2809
- hn as eventTypes,
2858
+ en as aggregateFunctionMap,
2859
+ Zt as aggregateFunctions,
2860
+ un as aggregateLevels,
2861
+ ln as annotationTypes,
2862
+ mn as eventTypes,
2810
2863
  rt as formatTimeFrameText,
2811
2864
  at as getAverage,
2812
2865
  ot as getCount,
@@ -2815,13 +2868,13 @@ export {
2815
2868
  et as getStandardDeviation,
2816
2869
  it as getSum,
2817
2870
  Ze as getVariance,
2818
- ln as healthStatuses,
2819
- un as interventionTypes,
2820
- rn as operator,
2821
- mn as severities,
2822
- wn as timeout,
2823
- Kt as vailableAggregationIntervals,
2824
- fn as videoMimeTypes,
2825
- on as viewer
2871
+ fn as healthStatuses,
2872
+ wn as interventionTypes,
2873
+ dn as operator,
2874
+ pn as severities,
2875
+ gn as timeout,
2876
+ Yt as vailableAggregationIntervals,
2877
+ yn as videoMimeTypes,
2878
+ cn as viewer
2826
2879
  };
2827
2880
  //# sourceMappingURL=data-sdk.es.js.map